Commit 8f84a7c9 authored by Owen Arnold's avatar Owen Arnold
Browse files

refs #21334. Missing formatting.

parent dfe91fc9
......@@ -635,8 +635,8 @@ public:
TSM_ASSERT("For a root (no parent) relative positions are always the same "
"as absolute ones",
compInfo.position(rootIndex).isApprox(
compInfo.relativePosition(rootIndex)));
compInfo.position(rootIndex)
.isApprox(compInfo.relativePosition(rootIndex)));
const Eigen::Vector3d expectedRelativePos =
compInfo.position(detectorIndex) -
......@@ -720,8 +720,8 @@ public:
info.relativeRotation(rootIndex).isApprox(info.rotation(rootIndex)));
TSM_ASSERT_DELTA(
"90 degree RELATIVE rotation between root ans sub-assembly",
info.relativeRotation(rootIndex).angularDistance(
info.relativeRotation(subAssemblyIndex)),
info.relativeRotation(rootIndex)
.angularDistance(info.relativeRotation(subAssemblyIndex)),
theta, 1e-6);
}
......
......@@ -51,16 +51,16 @@ public:
/// Copy constructor
Peak(const Peak &other);
// MSVC 2015/17 can build with noexcept = default however
// intellisense still incorrectly reports this as an error despite compiling.
// https://connect.microsoft.com/VisualStudio/feedback/details/1795240/visual-c-2015-default-move-constructor-and-noexcept-keyword-bug
// For that reason we still use the supplied default which should be noexcept
// once the above is fixed we can remove this workaround
// MSVC 2015/17 can build with noexcept = default however
// intellisense still incorrectly reports this as an error despite compiling.
// https://connect.microsoft.com/VisualStudio/feedback/details/1795240/visual-c-2015-default-move-constructor-and-noexcept-keyword-bug
// For that reason we still use the supplied default which should be noexcept
// once the above is fixed we can remove this workaround
#if defined(_MSC_VER) && _MSC_VER <= 1910
Peak(Peak &&) = default;
Peak &operator=(Peak &&) = default;
#elif ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ <= 8))
#elif((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ <= 8))
// The noexcept default declaration was fixed in GCC 4.9.0
// so for versions 4.8.x and below use default only
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53903
......
......@@ -98,9 +98,8 @@ public:
std::unique_ptr<Beamline::ComponentInfo> componentInfo,
boost::shared_ptr<const std::vector<Mantid::Geometry::IComponent *>>
componentIds,
boost::shared_ptr<
const std::unordered_map<Geometry::IComponent *, size_t>>
componentIdToIndexMap,
boost::shared_ptr<const std::unordered_map<Geometry::IComponent *,
size_t>> componentIdToIndexMap,
boost::shared_ptr<std::vector<boost::shared_ptr<const Geometry::IObject>>>
shapes);
~ComponentInfo();
......
......@@ -10,7 +10,9 @@ namespace Geometry {
class ComponentVisitor;
class ICompAssembly;
/** ComponentVisitorHelper namespace : Helper functions for Component Visitors. These mainly relate to helping with common code for IDF compatibility problems.
/** ComponentVisitorHelper namespace : Helper functions for Component Visitors.
These mainly relate to helping with common code for IDF compatibility
problems.
Copyright &copy; 2017 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
......@@ -35,7 +37,9 @@ class ICompAssembly;
*/
namespace ComponentVisitorHelper {
size_t MANTID_GEOMETRY_DLL visitAssembly(ComponentVisitor& visitor, const ICompAssembly& visitee, const std::string& nameHint);
size_t MANTID_GEOMETRY_DLL visitAssembly(ComponentVisitor &visitor,
const ICompAssembly &visitee,
const std::string &nameHint);
} // namespace ComponentVisitorHelper
} // namespace Geometry
......
......@@ -129,8 +129,7 @@ private:
/// Shapes stored in fly-weight fashion
boost::shared_ptr<
std::vector<boost::shared_ptr<const Mantid::Geometry::IObject>>>
m_shapes;
std::vector<boost::shared_ptr<const Mantid::Geometry::IObject>>> m_shapes;
/// Scale factors
boost::shared_ptr<std::vector<Eigen::Vector3d>> m_scaleFactors;
......
......@@ -491,8 +491,8 @@ Quat CompAssembly::getRotation() const {
}
size_t CompAssembly::registerContents(ComponentVisitor &visitor) const {
// via common helper
return ComponentVisitorHelper::visitAssembly(visitor, *this, this->getName());
// via common helper
return ComponentVisitorHelper::visitAssembly(visitor, *this, this->getName());
}
/** Print information about elements in the assembly to a stream
......
......@@ -9,15 +9,14 @@ namespace ComponentVisitorHelper {
namespace {
/**
* Does name imply pack of tubes
* @param nameHint
* @return True if matches naming
*/
bool matchesPackOfTubes(const std::string& nameHint){
using boost::regex;
return boost::regex_match(nameHint, regex("^[a-z]*pack$", regex::icase));
bool matchesPackOfTubes(const std::string &nameHint) {
using boost::regex;
return boost::regex_match(nameHint, regex("^[a-z]*pack$", regex::icase));
}
/**
......@@ -25,27 +24,34 @@ bool matchesPackOfTubes(const std::string& nameHint){
* @param nameHint
* @return True if matches naming
*/
bool matchesPSDTube(const std::string& nameHint){
using boost::regex;
return boost::regex_match(nameHint, regex("^tube[0-9]*$", regex::icase));
bool matchesPSDTube(const std::string &nameHint) {
using boost::regex;
return boost::regex_match(nameHint, regex("^tube[0-9]*$", regex::icase));
}
}
/**
* Determines and calls the appropriate vistor method relating to an IComponentAssembly
* Determines and calls the appropriate vistor method relating to an
*IComponentAssembly
*
* The IComponentAssembly hierachy is not rich enough to describe the full range of common components.
* It is desirable to know some of these as there are speedups that can be performed in downstream processing if you know say that the component you have is say a psd tube.
* The IComponentAssembly hierachy is not rich enough to describe the full range
*of common components.
* It is desirable to know some of these as there are speedups that can be
*performed in downstream processing if you know say that the component you have
*is say a psd tube.
*
* This method is written to be conservative in it's approach to matching. Failure to match based on the hint will lead to correct, albeit slower, behaviour.
* This method is written to be conservative in it's approach to matching.
*Failure to match based on the hint will lead to correct, albeit slower,
*behaviour.
*
* @param visitor : The mutable vistor on which the appropriate register method will be called
* @param visitor : The mutable vistor on which the appropriate register method
*will be called
* @param visitee : The visitee that will be interrogated
* @param nameHint : Naming hint that can be used to determine what type of Component we have
* @param nameHint : Naming hint that can be used to determine what type of
*Component we have
*/
size_t visitAssembly(ComponentVisitor &visitor, const ICompAssembly &visitee, const std::string &nameHint)
{
size_t visitAssembly(ComponentVisitor &visitor, const ICompAssembly &visitee,
const std::string &nameHint) {
using boost::regex;
if (matchesPackOfTubes(nameHint)) {
return visitor.registerBankOfTubes(visitee);
......
......@@ -69,9 +69,8 @@ InstrumentVisitor::InstrumentVisitor(
boost::make_shared<std::vector<std::pair<size_t, size_t>>>()),
m_componentRanges(
boost::make_shared<std::vector<std::pair<size_t, size_t>>>()),
m_componentIdToIndexMap(
boost::make_shared<
std::unordered_map<Mantid::Geometry::IComponent *, size_t>>()),
m_componentIdToIndexMap(boost::make_shared<
std::unordered_map<Mantid::Geometry::IComponent *, size_t>>()),
m_detectorIdToIndexMap(makeDetIdToIndexMap(*m_orderedDetectorIds)),
m_positions(boost::make_shared<std::vector<Eigen::Vector3d>>()),
m_detectorPositions(boost::make_shared<std::vector<Eigen::Vector3d>>(
......
......@@ -358,8 +358,8 @@ void ObjCompAssembly::testIntersectionWithChildren(
size_t ObjCompAssembly::registerContents(
Mantid::Geometry::ComponentVisitor &visitor) const {
// via common helper
return ComponentVisitorHelper::visitAssembly(visitor, *this, this->getName());
// via common helper
return ComponentVisitorHelper::visitAssembly(visitor, *this, this->getName());
}
/** Set the outline of the assembly. Creates an Object and sets m_shape point to
......
......@@ -33,9 +33,8 @@ namespace {
*/
boost::shared_ptr<
const std::unordered_map<Mantid::Geometry::ComponentID, size_t>>
makeComponentIDMap(
const boost::shared_ptr<const std::vector<Mantid::Geometry::ComponentID>>
&componentIds) {
makeComponentIDMap(const boost::shared_ptr<
const std::vector<Mantid::Geometry::ComponentID>> &componentIds) {
auto idMap = boost::make_shared<
std::unordered_map<Mantid::Geometry::ComponentID, size_t>>();
......@@ -309,12 +308,10 @@ public:
TS_ASSERT((boundingBox.minPoint() -
(Kernel::V3D{position[0] - radius, position[1] - radius,
position[2] - radius}))
.norm() < 1e-9);
position[2] - radius})).norm() < 1e-9);
TS_ASSERT((boundingBox.maxPoint() -
(Kernel::V3D{position[0] + radius, position[1] + radius,
position[2] + radius}))
.norm() < 1e-9);
position[2] + radius})).norm() < 1e-9);
// Nullify shape and retest BoundingBox
shapes->at(0) = boost::shared_ptr<const Geometry::IObject>(nullptr);
boundingBox = componentInfo.boundingBox(0);
......@@ -340,12 +337,10 @@ public:
auto boundingBox = componentInfo->boundingBox(0 /*detector index*/);
TS_ASSERT((boundingBox.minPoint() -
(Kernel::V3D{detectorPos[0] - radius, detectorPos[1] - radius,
detectorPos[2] - radius}))
.norm() < 1e-9);
detectorPos[2] - radius})).norm() < 1e-9);
TS_ASSERT((boundingBox.maxPoint() -
(Kernel::V3D{detectorPos[0] + radius, detectorPos[1] + radius,
detectorPos[2] + radius}))
.norm() < 1e-9);
detectorPos[2] + radius})).norm() < 1e-9);
// Check bounding box of root (instrument)
boundingBox = componentInfo->boundingBox(componentInfo->root() /*Root*/);
......@@ -354,13 +349,11 @@ public:
// instrument 2.0).
TS_ASSERT((boundingBox.minPoint() -
(Kernel::V3D{samplePos[0] - radius, samplePos[1] - radius,
samplePos[2] - radius}))
.norm() < 1e-9);
samplePos[2] - radius})).norm() < 1e-9);
// max is the detector
TS_ASSERT((boundingBox.maxPoint() -
(Kernel::V3D{detectorPos[0] + radius, detectorPos[1] + radius,
detectorPos[2] + radius}))
.norm() < 1e-9);
detectorPos[2] + radius})).norm() < 1e-9);
}
void test_boundingBox_around_rectangular_bank() {
......@@ -377,7 +370,7 @@ public:
// Check bounding box of root (instrument)
auto boundingBoxRoot =
componentInfo->boundingBox(componentInfo->root() /*Root*/
);
);
// min Z in the sample
auto boundingBoxSample =
componentInfo->boundingBox(componentInfo->sample());
......
......@@ -12,52 +12,53 @@
#include "MantidGeometry/Instrument/ComponentVisitor.h"
using namespace Mantid::Geometry;
std::ostream& operator<<(std::ostream& out, const Mantid::Geometry::IComponent& component)
{
component.printSelf(out);
return out;
std::ostream &operator<<(std::ostream &out,
const Mantid::Geometry::IComponent &component) {
component.printSelf(out);
return out;
}
namespace {
class MockComponentVisitor : public ComponentVisitor {
public:
public:
MOCK_METHOD1(registerComponentAssembly,
size_t(const Mantid::Geometry::ICompAssembly &assembly));
size_t(const Mantid::Geometry::ICompAssembly &assembly));
MOCK_METHOD1(registerGenericComponent,
size_t(const Mantid::Geometry::IComponent &component));
size_t(const Mantid::Geometry::IComponent &component));
MOCK_METHOD1(registerGenericObjComponent,
size_t(const Mantid::Geometry::IObjComponent &objComponent));
size_t(const Mantid::Geometry::IObjComponent &objComponent));
MOCK_METHOD1(registerDetector,
size_t(const Mantid::Geometry::IDetector &detector));
size_t(const Mantid::Geometry::IDetector &detector));
MOCK_METHOD1(registerStructuredBank,
size_t(const Mantid::Geometry::ICompAssembly &bank));
size_t(const Mantid::Geometry::ICompAssembly &bank));
MOCK_METHOD1(registerBankOfTubes,
size_t(const Mantid::Geometry::ICompAssembly &bank));
size_t(const Mantid::Geometry::ICompAssembly &bank));
MOCK_METHOD1(registerTube,
size_t(const Mantid::Geometry::ICompAssembly &tube));
size_t(const Mantid::Geometry::ICompAssembly &tube));
};
}
class ComponentVisitorHelperTest : public CxxTest::TestSuite {
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static ComponentVisitorHelperTest *createSuite() { return new ComponentVisitorHelperTest(); }
static void destroySuite( ComponentVisitorHelperTest *suite ) { delete suite; }
static ComponentVisitorHelperTest *createSuite() {
return new ComponentVisitorHelperTest();
}
static void destroySuite(ComponentVisitorHelperTest *suite) { delete suite; }
void test_visit_as_tube()
{
void test_visit_as_tube() {
MockComponentVisitor visitor;
CompAssembly assembly;
// Test unsuccesful match. Match not close enough, should call generic registeration for assembly instead
// Test unsuccesful match. Match not close enough, should call generic
// registeration for assembly instead
EXPECT_CALL(visitor, registerComponentAssembly(testing::_)).Times(1);
ComponentVisitorHelper::visitAssembly(visitor, assembly, "bankoftube");
TS_ASSERT(testing::Mock::VerifyAndClearExpectations(&visitor));
// Test unsuccessful match if not followed by digits, should call generic registration for assembly instead
// Test unsuccessful match if not followed by digits, should call generic
// registration for assembly instead
EXPECT_CALL(visitor, registerComponentAssembly(testing::_)).Times(1);
ComponentVisitorHelper::visitAssembly(visitor, assembly, "tube12x");
TS_ASSERT(testing::Mock::VerifyAndClearExpectations(&visitor));
......@@ -73,17 +74,18 @@ public:
TS_ASSERT(testing::Mock::VerifyAndClearExpectations(&visitor));
}
void test_visit_as_bank_of_tubes()
{
void test_visit_as_bank_of_tubes() {
MockComponentVisitor visitor;
CompAssembly assembly;
// Match not close enough, should end with PACK. Should call generic registeration for assembly instead
// Match not close enough, should end with PACK. Should call generic
// registeration for assembly instead
EXPECT_CALL(visitor, registerComponentAssembly(testing::_)).Times(1);
ComponentVisitorHelper::visitAssembly(visitor, assembly, "somepackz");
TS_ASSERT(testing::Mock::VerifyAndClearExpectations(&visitor));
// Match not close enough, alphabetical characters preceding only. Should call generic registeration for assembly instead
// Match not close enough, alphabetical characters preceding only. Should
// call generic registeration for assembly instead
EXPECT_CALL(visitor, registerComponentAssembly(testing::_)).Times(1);
ComponentVisitorHelper::visitAssembly(visitor, assembly, "16pack");
TS_ASSERT(testing::Mock::VerifyAndClearExpectations(&visitor));
......@@ -98,8 +100,6 @@ public:
ComponentVisitorHelper::visitAssembly(visitor, assembly, "EightPack");
TS_ASSERT(testing::Mock::VerifyAndClearExpectations(&visitor));
}
};
#endif /* MANTID_GEOMETRY_COMPONENTVISITORHELPERTEST_H_ */
......@@ -196,10 +196,9 @@ public:
"Should contain the sample id", 1,
componentIds.count(visitee->getComponentByName("some-surface-holder")
->getComponentID()));
TSM_ASSERT_EQUALS(
"Should contain the source id", 1,
componentIds.count(
visitee->getComponentByName("source")->getComponentID()));
TSM_ASSERT_EQUALS("Should contain the source id", 1,
componentIds.count(visitee->getComponentByName("source")
->getComponentID()));
auto detectorComponentId =
visitee->getComponentByName("point-detector")->getComponentID();
......
......@@ -452,14 +452,13 @@ void FindPeaksMD::findPeaks(typename MDEventWorkspace<MDE, nd>::sptr ws) {
if (nexp > 1) {
MDBox<MDE, nd> *mdbox = dynamic_cast<MDBox<MDE, nd> *>(box);
typename std::vector<MDE> &events = mdbox->getEvents();
if (std::none_of(events.cbegin(), events.cend(),
[&iexp, &nexp](MDE event) {
return event.getRunIndex() == iexp ||
event.getRunIndex() >= nexp;
}))
if (std::none_of(events.cbegin(), events.cend(), [&iexp, &nexp](
MDE event) {
return event.getRunIndex() == iexp || event.getRunIndex() >= nexp;
}))
continue;
}
// The center of the box = Q in the lab frame
// The center of the box = Q in the lab frame
#ifndef MDBOX_TRACK_CENTROID
coord_t boxCenter[nd];
......
......@@ -737,7 +737,7 @@ createInstrumentWithPSDTubes(const size_t nTubes, const size_t nPixelsPerTube,
tube->setPos(V3D(x, 0.0, z));
for (size_t j = 0; j < nPixelsPerTube; ++j) {
lexer.str("");
lexer << "pixel-" << i * nPixelsPerTube + j;
lexer << "pixel-" << i *nPixelsPerTube + j;
Detector *pixel = new Detector(
lexer.str(), int(i * nPixelsPerTube + j + 1), pixelShape, tube);
const double xpos = 0.0;
......
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