Mantid
Loading...
Searching...
No Matches
CompositeDomainMD.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7//----------------------------------------------------------------------
8// Includes
9//----------------------------------------------------------------------
13
14#include <stdexcept>
15
16namespace Mantid::API {
17
24 : m_iterator(ws->createIterator()) {
25 m_totalSize = m_iterator->getDataSize();
26
27 size_t maxDomainSizeDiv = maxDomainSize + 1;
28 size_t nParts = m_totalSize / maxDomainSizeDiv;
29
30 m_domains.resize(nParts);
31 for (size_t i = 0; i < nParts - 1; ++i) {
32 size_t start = i * maxDomainSize;
33 m_domains[i] = std::make_unique<FunctionDomainMD>(ws, start, maxDomainSize);
34 }
35 size_t start = (nParts - 1) * maxDomainSize;
36 m_domains.back() = std::make_unique<FunctionDomainMD>(ws, start, m_totalSize - start);
37}
38
43
46 if (i >= m_domains.size()) {
47 throw std::out_of_range("Domain index out of range");
48 }
49 m_domains[i]->reset();
50
51 return *m_domains[i];
52}
53
54} // namespace Mantid::API
~CompositeDomainMD() override
Destructor.
CompositeDomainMD(const IMDWorkspace_const_sptr &ws, size_t maxDomainSize)
Create a composite domain from a IMDWorkspace.
std::vector< std::unique_ptr< FunctionDomainMD > > m_domains
smaller parts of the domain
const FunctionDomain & getDomain(size_t i) const override
Return i-th domain.
std::unique_ptr< IMDIterator > m_iterator
IMDIterator.
size_t m_totalSize
The total size of the domain.
Base class that represents the domain of a function.
std::shared_ptr< const IMDWorkspace > IMDWorkspace_const_sptr
Shared pointer to the IMDWorkspace base class (const version)
Definition: IMDWorkspace.h:148