Skip to content
Snippets Groups Projects
Commit 4088432e authored by Owen Arnold's avatar Owen Arnold
Browse files

refs #12939. Normalization check introduced.

Introduce test and then functionality to MDGeometry.
parent 353e5cec
No related branches found
No related tags found
No related merge requests found
......@@ -80,6 +80,7 @@ public:
Mantid::Kernel::VMD &getBasisVector(size_t index);
const Mantid::Kernel::VMD &getBasisVector(size_t index) const;
void setBasisVector(size_t index, const Mantid::Kernel::VMD &vec);
bool allBasisNormalized() const;
// --------------------------------------------------------------------------------------------
bool hasOriginalWorkspace(size_t index = 0) const;
......
......@@ -279,6 +279,17 @@ void MDGeometry::setBasisVector(size_t index, const Mantid::Kernel::VMD &vec) {
m_basisVectors[index] = vec;
}
bool MDGeometry::allBasisNormalized() const {
bool allNormalized = true;
for (auto it = m_basisVectors.begin(); it != m_basisVectors.end(); ++it) {
if (it->length() != 1.0) {
allNormalized = false;
break;
}
}
return allNormalized;
}
//---------------------------------------------------------------------------------------------------
/// @return true if the geometry is defined relative to another workspace.
/// @param index :: index into the vector of original workspaces
......
......@@ -256,6 +256,29 @@ public:
TSM_ASSERT_EQUALS("Wrong number of transforms to original reported.", 2, g.getNumberTransformsToOriginal());
}
void test_all_normalized(){
MDGeometry geometry;
std::vector<IMDDimension_sptr> dims;
IMDDimension_sptr dim1(new MDHistoDimension("Qx", "Qx", "Ang", -1, +1, 10));
IMDDimension_sptr dim2(new MDHistoDimension("Qy", "Qy", "Ang", -1, +1, 20));
dims.push_back(dim1);
dims.push_back(dim2);
geometry.initGeometry(dims);
// Both basis vectors are not normalized
geometry.setBasisVector(0, VMD(2.0, 0.0));
geometry.setBasisVector(1, VMD(0.0, 4.0));
TSM_ASSERT("All Not all basis vectors are normalized", !geometry.allBasisNormalized());
// First basis vector is now normalized. The other is not.
geometry.setBasisVector(1, VMD(0.0, 1.0));
TSM_ASSERT("Not all basis vectors are normalized", !geometry.allBasisNormalized());
// We overwrite the zeroth basis vector to be normalized. Now both are normalized
geometry.setBasisVector(0, VMD(1.0, 0.0));
TSM_ASSERT("All basis vectors are normalized", geometry.allBasisNormalized());
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment