Commit cf55d9f2 authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Apply clang format patch. Re #12827

parent 81c5b9af
......@@ -51,9 +51,10 @@ void CreateSampleShape::exec() {
} else {
std::ostringstream msg;
msg << "Object has invalid shape.";
if (auto csgShape = dynamic_cast<Geometry::CSGObject*>(shape.get())) {
if (auto csgShape = dynamic_cast<Geometry::CSGObject *>(shape.get())) {
msg << " TopRule = " << csgShape->topRule()
<< ", number of surfaces = " << csgShape->getSurfacePtr().size() << "\n";
<< ", number of surfaces = " << csgShape->getSurfacePtr().size()
<< "\n";
}
throw std::runtime_error(msg.str());
}
......
......@@ -33,8 +33,7 @@ void DefineGaugeVolume::exec() {
// Get the XML definition
const std::string shapeXML = getProperty("ShapeXML");
// Try creating the shape to make sure the input's valid
auto shape_sptr =
Geometry::ShapeFactory().createShape(shapeXML);
auto shape_sptr = Geometry::ShapeFactory().createShape(shapeXML);
if (!shape_sptr->hasValidShape()) {
g_log.error("Invalid shape definition provided. Gauge Volume NOT added to "
"workspace.");
......
......@@ -237,7 +237,8 @@ void SetSampleMaterial::exec() {
normalizedLaue = 0.;
// set the material but leave the geometry unchanged
auto shapeObject = boost::shared_ptr<Geometry::IObject>(expInfo->sample().getShape().clone());
auto shapeObject = boost::shared_ptr<Geometry::IObject>(
expInfo->sample().getShape().clone());
shapeObject->setMaterial(*mat);
expInfo->mutableSample().setShape(shapeObject);
g_log.information() << "Sample number density ";
......
......@@ -121,7 +121,8 @@ public:
TS_ASSERT(alg->isExecuted());
// New shape
auto &sphere = dynamic_cast<const Mantid::Geometry::CSGObject&>(inputWS->sample().getShape());
auto &sphere = dynamic_cast<const Mantid::Geometry::CSGObject &>(
inputWS->sample().getShape());
TS_ASSERT_DELTA(0.02, getSphereRadius(sphere), 1e-08);
// Old material
const auto &material = inputWS->sample().getMaterial();
......@@ -193,7 +194,10 @@ public:
// New shape
// radius was 0.1 in <samplegeometry> set in constructor now 0.4
// from createOverrideGeometryProps
TS_ASSERT_DELTA(0.4, getSphereRadius(dynamic_cast<const Mantid::Geometry::CSGObject&>(sampleShape)), 1e-08);
TS_ASSERT_DELTA(
0.4, getSphereRadius(dynamic_cast<const Mantid::Geometry::CSGObject &>(
sampleShape)),
1e-08);
}
void test_Setting_Geometry_As_FlatPlate() {
......
......@@ -43,7 +43,7 @@ public:
Container();
Container(IObject_sptr shape);
Container(const Container& container);
Container(const Container &container);
Container(std::string xml);
bool hasSampleShape() const;
......@@ -51,48 +51,85 @@ public:
void setSampleShape(const std::string &sampleShapeXML);
bool isValid(const Kernel::V3D &p) const override {return m_shape->isValid(p); }
bool isOnSide(const Kernel::V3D &p) const override {return m_shape->isOnSide(p);}
int calcValidType(const Kernel::V3D &Pt, const Kernel::V3D &uVec) const override {return m_shape->calcValidType(Pt, uVec);}
bool hasValidShape() const override {return m_shape->hasValidShape();}
int setObject(const int ON, const std::string &Ln) override {return m_shape->setObject(ON, Ln);}
int populate(const std::map<int, boost::shared_ptr<Surface>> &m) override {return m_shape->populate(m);}
IObject* clone() const override {return new Container(*this);}
int getName() const override {return m_shape->getName(); }
void setName(const int nx) override {m_shape->setName(nx); }
int interceptSurface(Geometry::Track &t) const override {return m_shape->interceptSurface(t); }
double solidAngle(const Kernel::V3D &observer) const override {return m_shape->solidAngle(observer);}
bool isValid(const Kernel::V3D &p) const override {
return m_shape->isValid(p);
}
bool isOnSide(const Kernel::V3D &p) const override {
return m_shape->isOnSide(p);
}
int calcValidType(const Kernel::V3D &Pt,
const Kernel::V3D &uVec) const override {
return m_shape->calcValidType(Pt, uVec);
}
bool hasValidShape() const override { return m_shape->hasValidShape(); }
int setObject(const int ON, const std::string &Ln) override {
return m_shape->setObject(ON, Ln);
}
int populate(const std::map<int, boost::shared_ptr<Surface>> &m) override {
return m_shape->populate(m);
}
IObject *clone() const override { return new Container(*this); }
int getName() const override { return m_shape->getName(); }
void setName(const int nx) override { m_shape->setName(nx); }
int interceptSurface(Geometry::Track &t) const override {
return m_shape->interceptSurface(t);
}
double solidAngle(const Kernel::V3D &observer) const override {
return m_shape->solidAngle(observer);
}
double solidAngle(const Kernel::V3D &observer,
const Kernel::V3D &scaleFactor) const override {return m_shape->solidAngle(observer, scaleFactor); }
double volume() const override {return m_shape->volume();}
const BoundingBox &getBoundingBox() const override {return m_shape->getBoundingBox(); }
int getPointInObject(Kernel::V3D &point) const override {return m_shape->getPointInObject(point); }
const Kernel::V3D &scaleFactor) const override {
return m_shape->solidAngle(observer, scaleFactor);
}
double volume() const override { return m_shape->volume(); }
const BoundingBox &getBoundingBox() const override {
return m_shape->getBoundingBox();
}
int getPointInObject(Kernel::V3D &point) const override {
return m_shape->getPointInObject(point);
}
Kernel::V3D generatePointInObject(Kernel::PseudoRandomNumberGenerator &rng,
const size_t i) const override {return m_shape->generatePointInObject(rng, i); }
const size_t i) const override {
return m_shape->generatePointInObject(rng, i);
}
Kernel::V3D generatePointInObject(Kernel::PseudoRandomNumberGenerator &rng,
const BoundingBox &activeRegion,
const size_t i) const override {return m_shape->generatePointInObject(rng, activeRegion, i); }
const BoundingBox &activeRegion,
const size_t i) const override {
return m_shape->generatePointInObject(rng, activeRegion, i);
}
void GetObjectGeom(int &type, std::vector<Kernel::V3D> &vectors,
double &myradius, double &myheight) const override {m_shape->GetObjectGeom(type, vectors, myradius, myheight); }
boost::shared_ptr<GeometryHandler> getGeometryHandler() override {return m_shape->getGeometryHandler(); }
std::string getShapeXML() const override {return m_shape->getShapeXML(); }
void draw() const override {m_shape->draw();}
void initDraw() const override {m_shape->initDraw();}
void
setVtkGeometryCacheReader(boost::shared_ptr<vtkGeometryCacheReader> reader) override {m_shape->setVtkGeometryCacheReader(reader);}
void
setVtkGeometryCacheWriter(boost::shared_ptr<vtkGeometryCacheWriter> writer) override {m_shape->setVtkGeometryCacheWriter(writer);}
void setMaterial(const Kernel::Material &material) override {m_shape->setMaterial(material); }
const Kernel::Material material() const override {return m_shape->material(); }
void setID(const std::string &id) override {m_shape->setID(id); }
const std::string &id() const override {return m_shape->id(); }
double &myradius, double &myheight) const override {
m_shape->GetObjectGeom(type, vectors, myradius, myheight);
}
boost::shared_ptr<GeometryHandler> getGeometryHandler() override {
return m_shape->getGeometryHandler();
}
std::string getShapeXML() const override { return m_shape->getShapeXML(); }
void draw() const override { m_shape->draw(); }
void initDraw() const override { m_shape->initDraw(); }
void setVtkGeometryCacheReader(
boost::shared_ptr<vtkGeometryCacheReader> reader) override {
m_shape->setVtkGeometryCacheReader(reader);
}
void setVtkGeometryCacheWriter(
boost::shared_ptr<vtkGeometryCacheWriter> writer) override {
m_shape->setVtkGeometryCacheWriter(writer);
}
void setMaterial(const Kernel::Material &material) override {
m_shape->setMaterial(material);
}
const Kernel::Material material() const override {
return m_shape->material();
}
void setID(const std::string &id) override { m_shape->setID(id); }
const std::string &id() const override { return m_shape->id(); }
private:
IObject_sptr m_shape;
......
......@@ -62,8 +62,7 @@ private:
void parseAndAddContainers(SampleEnvironmentSpec *spec,
Poco::XML::Element *element) const;
Container_const_sptr parseContainer(Poco::XML::Element *element) const;
boost::shared_ptr<IObject>
parseComponent(Poco::XML::Element *element) const;
boost::shared_ptr<IObject> parseComponent(Poco::XML::Element *element) const;
// Members
MaterialsIndex m_materials;
......
......@@ -75,7 +75,7 @@ public:
/// Destructor
virtual ~CSGObject();
/// Clone
IObject* clone() const override { return new CSGObject(*this); }
IObject *clone() const override { return new CSGObject(*this); }
/// Return the top rule
const Rule *topRule() const { return TopRule.get(); }
......@@ -113,7 +113,8 @@ public:
bool isValid(const std::map<int, int> &)
const; ///< Check if a set of surfaces are valid.
bool isOnSide(const Kernel::V3D &) const override;
int calcValidType(const Kernel::V3D &Pt, const Kernel::V3D &uVec) const override;
int calcValidType(const Kernel::V3D &Pt,
const Kernel::V3D &uVec) const override;
std::vector<int> getSurfaceIndex() const;
/// Get the list of surfaces (const version)
......
......@@ -56,11 +56,12 @@ class MANTID_GEOMETRY_DLL IObject {
public:
virtual bool isValid(const Kernel::V3D &) const = 0;
virtual bool isOnSide(const Kernel::V3D &) const = 0;
virtual int calcValidType(const Kernel::V3D &Pt, const Kernel::V3D &uVec) const = 0;
virtual int calcValidType(const Kernel::V3D &Pt,
const Kernel::V3D &uVec) const = 0;
virtual bool hasValidShape() const = 0;
virtual int setObject(const int ON, const std::string &Ln) = 0;
virtual int populate(const std::map<int, boost::shared_ptr<Surface>> &) = 0;
virtual IObject* clone() const = 0;
virtual IObject *clone() const = 0;
virtual int getName() const = 0;
virtual void setName(const int nx) = 0;
......@@ -76,11 +77,13 @@ public:
virtual double volume() const = 0;
virtual int getPointInObject(Kernel::V3D &point) const = 0;
virtual Kernel::V3D generatePointInObject(Kernel::PseudoRandomNumberGenerator &rng,
const size_t) const = 0;
virtual Kernel::V3D generatePointInObject(Kernel::PseudoRandomNumberGenerator &rng,
const BoundingBox &activeRegion,
const size_t) const = 0;
virtual Kernel::V3D
generatePointInObject(Kernel::PseudoRandomNumberGenerator &rng,
const size_t) const = 0;
virtual Kernel::V3D
generatePointInObject(Kernel::PseudoRandomNumberGenerator &rng,
const BoundingBox &activeRegion,
const size_t) const = 0;
virtual void GetObjectGeom(int &type, std::vector<Kernel::V3D> &vectors,
double &myradius, double &myheight) const = 0;
......
......@@ -86,12 +86,12 @@ class MANTID_GEOMETRY_DLL ShapeFactory {
public:
boost::shared_ptr<IObject> createShape(Poco::XML::Element *pElem);
boost::shared_ptr<IObject> createShape(std::string shapeXML,
bool addTypeTag = true);
bool addTypeTag = true);
boost::shared_ptr<IObject> createHexahedralShape(double xlb, double xlf,
double xrf, double xrb,
double ylb, double ylf,
double yrf, double yrb);
double xrf, double xrb,
double ylb, double ylf,
double yrf, double yrb);
private:
std::string parseSphere(Poco::XML::Element *pElem,
......
......@@ -47,20 +47,20 @@ void updateTreeValues(Poco::XML::Element *root,
//------------------------------------------------------------------------------
// Public methods
//------------------------------------------------------------------------------
Container::Container() : m_shape(boost::make_shared<CSGObject>()) {
}
Container::Container() : m_shape(boost::make_shared<CSGObject>()) {}
Container::Container(IObject_sptr shape) : m_shape(shape) {
}
Container::Container(IObject_sptr shape) : m_shape(shape) {}
Container::Container(const Container& container) :
m_shape(IObject_sptr(container.m_shape->clone())), m_sampleShapeXML(container.m_sampleShapeXML) {}
Container::Container(const Container &container)
: m_shape(IObject_sptr(container.m_shape->clone())),
m_sampleShapeXML(container.m_sampleShapeXML) {}
/**
* Construct a container providing an XML definition shape
* @param xml Definition of the shape in xml
*/
Container::Container(std::string xml) : m_shape(boost::make_shared<CSGObject>(xml)) {}
Container::Container(std::string xml)
: m_shape(boost::make_shared<CSGObject>(xml)) {}
/**
* @return True if the can contains a defintion of the sample shape
......
......@@ -55,7 +55,7 @@ Logger g_log("ShapeFactory");
*if XML tags contain no geo. info.)
*/
boost::shared_ptr<IObject> ShapeFactory::createShape(std::string shapeXML,
bool addTypeTag) {
bool addTypeTag) {
// wrap in a type tag
if (addTypeTag)
shapeXML = "<type name=\"userShape\"> " + shapeXML + " </type>";
......
......@@ -81,7 +81,7 @@ public:
void testCopyConstructorGivesObjectWithSameAttributes() {
auto original_ptr = ComponentCreationHelper::createSphere(1.0);
auto &original = dynamic_cast<CSGObject&>(*original_ptr);
auto &original = dynamic_cast<CSGObject &>(*original_ptr);
original.setID("sp-1");
int objType(-1);
double radius(-1.0), height(-1.0);
......@@ -108,7 +108,7 @@ public:
void testAssignmentOperatorGivesObjectWithSameAttributes() {
auto original_ptr = ComponentCreationHelper::createSphere(1.0);
auto &original = dynamic_cast<CSGObject&>(*original_ptr);
auto &original = dynamic_cast<CSGObject &>(*original_ptr);
original.setID("sp-1");
int objType(-1);
double radius(-1.0), height(-1.0);
......@@ -118,7 +118,7 @@ public:
TS_ASSERT(boost::dynamic_pointer_cast<GluGeometryHandler>(
original.getGeometryHandler()));
CSGObject lhs; // initialize
CSGObject lhs; // initialize
lhs = original; // assign
// The copy should be a primitive object with a GluGeometryHandler
objType = -1;
......@@ -572,7 +572,7 @@ public:
void testComplementWithTwoPrimitives() {
auto shell_ptr = ComponentCreationHelper::createHollowShell(0.5, 1.0);
auto shell = dynamic_cast<CSGObject*>(shell_ptr.get());
auto shell = dynamic_cast<CSGObject *>(shell_ptr.get());
TS_ASSERT_EQUALS(2, shell->getSurfaceIndex().size());
......@@ -755,7 +755,7 @@ public:
*/
{
auto geom_obj_ptr = ComponentCreationHelper::createSphere(4.1);
auto geom_obj = dynamic_cast<CSGObject*>(geom_obj_ptr.get());
auto geom_obj = dynamic_cast<CSGObject *>(geom_obj_ptr.get());
double satol = 2e-2; // tolerance for solid angle
// Solid angle at distance 8.1 from centre of sphere radius 4.1 x/y/z
......@@ -1114,7 +1114,7 @@ public:
*/
{
auto geom_obj_ptr = ComponentCreationHelper::createSphere(4.1);
auto geom_obj = dynamic_cast<CSGObject*>(geom_obj_ptr.get());
auto geom_obj = dynamic_cast<CSGObject *>(geom_obj_ptr.get());
double satol = 1e-3; // tolerance for solid angle
// Solid angle at distance 8.1 from centre of sphere radius 4.1 x/y/z
......
......@@ -51,7 +51,10 @@ public:
TS_ASSERT_THROWS_NOTHING(
sampleShape = can->createSampleShape(Container::ShapeArgs()));
TS_ASSERT(sampleShape->hasValidShape());
TS_ASSERT_DELTA(1.0, getSphereRadius(dynamic_cast<const Mantid::Geometry::CSGObject&>(*sampleShape)), 1e-10);
TS_ASSERT_DELTA(
1.0, getSphereRadius(dynamic_cast<const Mantid::Geometry::CSGObject &>(
*sampleShape)),
1e-10);
}
void test_CreateSampleShape_Args_Override_Defaults() {
......@@ -64,7 +67,10 @@ public:
Container::ShapeArgs args = {{"radius", 0.5}};
TS_ASSERT_THROWS_NOTHING(sampleShape = can->createSampleShape(args));
TS_ASSERT(sampleShape->hasValidShape());
TS_ASSERT_DELTA(0.5, getSphereRadius(dynamic_cast<const Mantid::Geometry::CSGObject&>(*sampleShape)), 1e-10);
TS_ASSERT_DELTA(
0.5, getSphereRadius(dynamic_cast<const Mantid::Geometry::CSGObject &>(
*sampleShape)),
1e-10);
}
void test_CreateSampleShape_Args_Not_Matching_Do_Nothing() {
......@@ -77,7 +83,10 @@ public:
Container::ShapeArgs args = {{"height", 0.5}};
TS_ASSERT_THROWS_NOTHING(sampleShape = can->createSampleShape(args));
TS_ASSERT(sampleShape->hasValidShape());
TS_ASSERT_DELTA(1.0, getSphereRadius(dynamic_cast<const Mantid::Geometry::CSGObject&>(*sampleShape)), 1e-10);
TS_ASSERT_DELTA(
1.0, getSphereRadius(dynamic_cast<const Mantid::Geometry::CSGObject &>(
*sampleShape)),
1e-10);
}
// ---------------------------------------------------------------------------
......
......@@ -342,8 +342,7 @@ public:
obj_str << "<radius val=\"0.1\" />";
obj_str << "<height val=\"0.2\" />";
obj_str << "</cylinder>";
auto s =
Mantid::Geometry::ShapeFactory().createShape(obj_str.str());
auto s = Mantid::Geometry::ShapeFactory().createShape(obj_str.str());
ObjCompAssembly bank("BankName");
Component *det1 = new ObjComponent("Det1Name", s);
......@@ -379,8 +378,7 @@ public:
obj_str << "<radius val=\"0.1\" />";
obj_str << "<height val=\"0.2\" />";
obj_str << "</segmented-cylinder>";
auto s =
Mantid::Geometry::ShapeFactory().createShape(obj_str.str());
auto s = Mantid::Geometry::ShapeFactory().createShape(obj_str.str());
ObjCompAssembly bank("BankName");
Component *det1 = new ObjComponent("Det1Name", s);
......
......@@ -86,8 +86,7 @@ public:
}
void testFullConstructor() {
auto cuboidShape =
ComponentCreationHelper::createCuboid(0.5);
auto cuboidShape = ComponentCreationHelper::createCuboid(0.5);
RectangularDetector *det = new RectangularDetector("MyRectangle");
det->setPos(1000., 2000., 3000.);
......@@ -202,8 +201,7 @@ public:
* resizes it.
*/
void testResizingParameter() {
auto cuboidShape =
ComponentCreationHelper::createCuboid(0.5);
auto cuboidShape = ComponentCreationHelper::createCuboid(0.5);
RectangularDetector *det = new RectangularDetector("MyRectangle");
det->setPos(1000., 2000., 3000.);
......
......@@ -596,8 +596,7 @@ public:
xmlShape += "</c5one>";
xmlShape += "<algebra val=\"shape\" /> ";
auto shape_sptr =
getObject(xmlShape); // should return empty object
auto shape_sptr = getObject(xmlShape); // should return empty object
TS_ASSERT(!shape_sptr->isValid(V3D(0.0, 0.0, 1)));
}
......@@ -612,8 +611,7 @@ public:
xmlShape += "</cone>";
xmlShape += "<algebra val=\"shape\" /> ";
auto shape_sptr =
getObject(xmlShape); // should return empty object
auto shape_sptr = getObject(xmlShape); // should return empty object
TS_ASSERT(!shape_sptr->isValid(V3D(0.0, 0.0, 1)));
}
......@@ -628,8 +626,7 @@ public:
xmlShape += "</cone>";
xmlShape += "<algebra val=\"shape\" /> ";
auto shape_sptr =
getObject(xmlShape); // should return empty object
auto shape_sptr = getObject(xmlShape); // should return empty object
TS_ASSERT(!shape_sptr->isValid(V3D(0.0, 0.0, 1)));
}
......
......@@ -116,8 +116,7 @@ public:
}
void testFullConstructor() {
auto cuboidShape =
ComponentCreationHelper::createCuboid(0.5);
auto cuboidShape = ComponentCreationHelper::createCuboid(0.5);
StructuredDetector *det = new StructuredDetector("MyStructuredDetector");
det->setPos(1000., 2000., 3000.);
......@@ -155,8 +154,7 @@ public:
}
void testIncorrectVertexArraySize() {
auto cuboidShape =
ComponentCreationHelper::createCuboid(0.5);
auto cuboidShape = ComponentCreationHelper::createCuboid(0.5);
StructuredDetector *det = new StructuredDetector("MyStructuredDetector");
det->setPos(1000., 2000., 3000.);
......
......@@ -216,8 +216,7 @@ private:
ObjComponent *samplePos = new ObjComponent("samplePos");
instrument->add(samplePos);
instrument->markAsSamplePos(samplePos);
auto sampleShape =
ComponentCreationHelper::createCuboid(0.1, 0.2, 0.3);
auto sampleShape = ComponentCreationHelper::createCuboid(0.1, 0.2, 0.3);
m_expt->mutableSample().setShape(sampleShape);
if (addChopper == WithChopper) {
......@@ -230,8 +229,7 @@ private:
if (addAperture == WithAperture) {
ObjComponent *aperture = new ObjComponent("aperture");
aperture->setPos(m_aperturePos);
auto shape =
ComponentCreationHelper::createCuboid(0.04, 0.025, 0.05);
auto shape = ComponentCreationHelper::createCuboid(0.04, 0.025, 0.05);
aperture->setShape(shape);
instrument->add(aperture);
}
......
......@@ -151,8 +151,7 @@ private:
ObjComponent *aperture = new ObjComponent("aperture");
aperture->setPos(V3D(0.0, 0.0, -10.01));
auto shape =
ComponentCreationHelper::createCuboid(0.047, 0.047, 0.001);
auto shape = ComponentCreationHelper::createCuboid(0.047, 0.047, 0.001);
aperture->setShape(shape);
instrument->add(aperture);
......
......@@ -108,8 +108,7 @@ private:
expt->setModeratorModel(sourceDescr);
// Sample size
auto sampleShape =
ComponentCreationHelper::createCuboid(0.04, 0.025, 0.05);
auto sampleShape = ComponentCreationHelper::createCuboid(0.04, 0.025, 0.05);
expt->mutableSample().setShape(sampleShape);
// OrientedLattice
......@@ -139,8 +138,7 @@ private:
ObjComponent *aperture = new ObjComponent("aperture");
aperture->setPos(V3D(0.0, 0.0, -10.01));
auto shape =
ComponentCreationHelper::createCuboid(0.047, 0.047, 0.001);
auto shape = ComponentCreationHelper::createCuboid(0.047, 0.047, 0.001);
aperture->setShape(shape);
instrument->add(aperture);
......
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