Commit 5974d7b8 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

New member function: getNumNonIntegratedDims



Signed-off-by: Hahn, Steven's avatarSteven Hahn <hahnse@ornl.gov>
parent aa687486
......@@ -46,6 +46,7 @@ public:
// These are the main methods for dimensions, that CAN be overridden (e.g. by
// MatrixWorkspace)
virtual size_t getNumDims() const;
virtual size_t getNumNonIntegratedDims() const;
virtual std::shared_ptr<const Mantid::Geometry::IMDDimension>
getDimension(size_t index) const;
virtual std::shared_ptr<const Mantid::Geometry::IMDDimension>
......
......@@ -153,6 +153,13 @@ void MDGeometry::initGeometry(
/** @return the number of dimensions in this workspace */
size_t MDGeometry::getNumDims() const { return m_dimensions.size(); }
/** @return the number of non-integrated dimensions in this workspace */
size_t MDGeometry::getNumNonIntegratedDims() const {
return std::count_if(
m_dimensions.cbegin(), m_dimensions.cend(),
[](const auto &dimension) { return !dimension->getIsIntegrated(); });
}
// --------------------------------------------------------------------------------------------
/** Get a dimension
* @param index :: which dimension
......
......@@ -41,6 +41,7 @@ public:
g.initGeometry(dims);
TS_ASSERT_EQUALS(g.getNumDims(), 2);
TS_ASSERT_EQUALS(g.getNumNonIntegratedDims(), 2);
TS_ASSERT_EQUALS(g.getDimension(0)->getName(), "Qx");
TS_ASSERT_EQUALS(g.getDimension(1)->getName(), "Qy");
// Now set the basis vectors
......@@ -114,6 +115,7 @@ public:
MDGeometry g2(g);
TS_ASSERT_EQUALS(g2.getNumDims(), 2);
TS_ASSERT_EQUALS(g2.getNumNonIntegratedDims(), 2);
TS_ASSERT_EQUALS(g2.getBasisVector(0), VMD(1.2, 3.4));
TS_ASSERT_EQUALS(g2.getBasisVector(1), VMD(1.2, 3.4));
TS_ASSERT_EQUALS(g2.getOrigin(), VMD(4, 5));
......@@ -151,6 +153,7 @@ public:
new MDHistoDimension("Qy", "Qy", frame, -1, +1, 0));
TS_ASSERT_THROWS_NOTHING(g.addDimension(dim2);)
TS_ASSERT_EQUALS(g.getNumDims(), 2);
TS_ASSERT_EQUALS(g.getNumNonIntegratedDims(), 2);
TS_ASSERT_EQUALS(g.getDimension(0)->getName(), "Qx");
TS_ASSERT_EQUALS(g.getDimension(1)->getName(), "Qy");
TS_ASSERT_EQUALS(g.getDimensionIndexByName("Qx"), 0);
......@@ -168,6 +171,7 @@ public:
new MDHistoDimension("Qy", "Qy", frame, -2, +2, 0));
TS_ASSERT_THROWS_NOTHING(g.addDimension(dim2);)
TS_ASSERT_EQUALS(g.getNumDims(), 2);
TS_ASSERT_EQUALS(g.getNumNonIntegratedDims(),2);
std::shared_ptr<WorkspaceTester> ws = std::make_shared<WorkspaceTester>();
g.setOriginalWorkspace(ws);
TS_ASSERT(g.hasOriginalWorkspace());
......
......@@ -440,6 +440,7 @@ public:
new MDHistoDimension("T", "t", frame, -10, 10, 10));
MDHistoWorkspace ws(dimX, dimY, dimZ, dimT);
TS_ASSERT_EQUALS("Only 3 of the 4 dimensions should be non-integrated", ws.getNumNonIntegratedDims(), 3)
Mantid::Geometry::VecIMDDimension_const_sptr vecNonIntegratedDims =
ws.getNonIntegratedDimensions();
TSM_ASSERT_EQUALS("Only 3 of the 4 dimensions should be non-integrated", 3,
......
......@@ -245,6 +245,8 @@ public:
// 2 of the 5 dimensions have been setup to be integrated => nbins==1.
MDGeometryXMLParser xmlParser(constructXML("qy", "qx", "en", "qz"));
xmlParser.execute();
TSM_ASSERT_EQUALS("Returned wrong number of non integrated dimensions", 3,
xmlParser.getNumNonIntegratedDims());
TSM_ASSERT_EQUALS("Returned wrong number of non integrated dimensions", 3,
xmlParser.getNonIntegratedDimensions().size());
}
......
......@@ -181,8 +181,8 @@ std::map<std::string, std::string> ReplicateMD::validateInputs() {
std::map<std::string, std::string> errorMap;
IMDHistoWorkspace_sptr shapeWS = this->getProperty("ShapeWorkspace");
IMDHistoWorkspace_sptr dataWS = this->getProperty("DataWorkspace");
if (shapeWS->getNonIntegratedDimensions().size() !=
dataWS->getNonIntegratedDimensions().size() + 1) {
if (shapeWS->getNumNonIntegratedDims() !=
dataWS->getNumNonIntegratedDims() + 1) {
errorMap.emplace(
"DataWorkspace",
"Expect to have n-1 non-interated dimensions of ShapeWorkspace");
......
......@@ -1028,7 +1028,7 @@ void WorkspaceTreeWidget::addMDEventWorkspaceMenuItems(
m_showVatesGui->setEnabled(false);
#endif
} else {
std::size_t nDim = WS->getNonIntegratedDimensions().size();
std::size_t nDim = WS->getNumNonIntegratedDims();
m_showVatesGui->setEnabled(nDim >= 3 && nDim < 5);
}
menu->addAction(m_showSliceViewer); // The 2D slice viewer
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment