/** Constructor * * @param workspace :: iterate through this workspace * @param function :: limiting implicit function * @param beginWI :: first workspace index to iterate * @param endWI :: end when you reach this workspace index */ MatrixWorkspaceMDIterator::MatrixWorkspaceMDIterator(const MatrixWorkspace * workspace, Mantid::Geometry::MDImplicitFunction * function, size_t beginWI, size_t endWI) : m_ws(workspace), m_pos(0), m_max(0), m_function(function), m_errorIsCached(false) { if (!m_ws) throw std::runtime_error("MatrixWorkspaceMDIterator::ctor() NULL MatrixWorkspace"); m_center = VMD(2); m_isBinnedData = m_ws->isHistogramData(); m_dimY = m_ws->getDimension(1); m_blockSize = m_ws->blocksize(); m_beginWI = beginWI; if (m_beginWI >= m_ws->getNumberHistograms()) throw std::runtime_error("MatrixWorkspaceMDIterator: Beginning workspace index passed is too high."); // End point (handle default) m_endWI = endWI; if (m_endWI > m_ws->getNumberHistograms()) m_endWI = m_ws->getNumberHistograms(); if (m_endWI < m_beginWI) throw std::runtime_error("MatrixWorkspaceMDIterator: End point is before the start point."); m_max = (m_endWI - m_beginWI) * m_blockSize; m_xIndex = 0; // Trigger the calculation for the first index m_workspaceIndex = size_t(-1); // This makes sure calcWorkspacePos() updates calcWorkspacePos(m_beginWI); }
//---------------------------------------------------------------------------------------------- /// Returns the position of the center of the box pointed to. Mantid::Kernel::VMD MDHistoWorkspaceIterator::getCenter() const { // Get the indices Utils::NestedForLoop::GetIndicesFromLinearIndex(m_nd, m_pos, m_indexMaker, m_indexMax, m_index); // Find the center for (size_t d=0; d<m_nd; d++) m_center[d] = m_origin[d] + (double(m_index[d]) + 0.5) * m_binWidth[d]; return VMD(m_nd, m_center); }
/** Constructor with min/max dimensions. * * The dimensions must be IN THE SAME ORDER and the SAME LENGTH as the * nd dimensions of the MDEventWorkspace on which they will be applied. * * @param min :: nd-sized vector of the minimum edge of the box in each *dimension * @param max :: nd-sized vector of the maximum edge of the box */ MDBoxImplicitFunction::MDBoxImplicitFunction(const std::vector<coord_t> &min, const std::vector<coord_t> &max) : m_max(max), m_min(min) { construct(VMD(min), VMD(max)); }