Commit 67c502d1 authored by mantid-builder's avatar mantid-builder Committed by Karl Palmen
Browse files

clang-format PR21581 d5824c1b

parent d5824c1b
......@@ -364,7 +364,8 @@ int Sample::loadNexus(::NeXus::File *file, const std::string &group) {
Kernel::Material material;
material.loadNexus(file, "material");
// CSGObject expected, if so, set its material
if (auto csgObj = boost::dynamic_pointer_cast<Geometry::CSGObject>(m_shape)) {
if (auto csgObj =
boost::dynamic_pointer_cast<Geometry::CSGObject>(m_shape)) {
csgObj->setMaterial(material);
}
......
......@@ -245,9 +245,9 @@ void AbsorptionCorrection::retrieveBaseProperties() {
static_cast<uint16_t>(0), 0.0, 0.0, sigma_s, 0.0,
sigma_s, sigma_atten);
auto shape =
boost::shared_ptr<IObject>(
m_inputWS->sample().getShape().cloneWithMaterial(Material("SetInAbsorptionCorrection", neutron, rho)));
auto shape = boost::shared_ptr<IObject>(
m_inputWS->sample().getShape().cloneWithMaterial(
Material("SetInAbsorptionCorrection", neutron, rho)));
m_inputWS->mutableSample().setShape(shape);
}
rho *= 100; // Will give right units in going from
......
......@@ -167,19 +167,20 @@ void CopySample::copyParameters(Sample &from, Sample &to, bool nameFlag,
Material rhsMaterial;
if (materialFlag) {
rhsMaterial = from.getMaterial();
}
else {
} else {
// Reset to lhs material
rhsMaterial = to.getMaterial();
}
auto rhsObject = boost::shared_ptr<IObject>(from.getShape().cloneWithMaterial(rhsMaterial));
}
auto rhsObject = boost::shared_ptr<IObject>(
from.getShape().cloneWithMaterial(rhsMaterial));
to.setShape(rhsObject);
to.setGeometryFlag(from.getGeometryFlag());
to.setHeight(from.getHeight());
to.setThickness(from.getThickness());
to.setWidth(from.getWidth());
} else if (materialFlag) {
auto lhsObject = boost::shared_ptr<IObject>(to.getShape().cloneWithMaterial(from.getMaterial()));
auto lhsObject = boost::shared_ptr<IObject>(
to.getShape().cloneWithMaterial(from.getMaterial()));
to.setShape(lhsObject);
}
......
......@@ -167,9 +167,9 @@ API::MatrixWorkspace_sptr HRPDSlabCanAbsorption::runFlatPlateAbsorption() {
NeutronAtom neutron(static_cast<uint16_t>(EMPTY_DBL()),
static_cast<uint16_t>(0), 0.0, 0.0, sigma_s, 0.0,
sigma_s, sigma_atten);
auto shape =
boost::shared_ptr<IObject>(
m_inputWS->sample().getShape().cloneWithMaterial(Material("SetInSphericalAbsorption", neutron, rho)));
auto shape = boost::shared_ptr<IObject>(
m_inputWS->sample().getShape().cloneWithMaterial(
Material("SetInSphericalAbsorption", neutron, rho)));
m_inputWS->mutableSample().setShape(shape);
}
......
......@@ -140,8 +140,9 @@ void MultipleScatteringCylinderAbsorption::exec() {
NeutronAtom neutron(static_cast<uint16_t>(EMPTY_DBL()),
static_cast<uint16_t>(0), 0.0, 0.0, coeff3, 0.0, coeff3,
coeff1);
auto shape = boost::shared_ptr<IObject>
(in_WS->sample().getShape().cloneWithMaterial(Material("SetInMultipleScattering", neutron, coeff2)));
auto shape =
boost::shared_ptr<IObject>(in_WS->sample().getShape().cloneWithMaterial(
Material("SetInMultipleScattering", neutron, coeff2)));
in_WS->mutableSample().setShape(shape);
}
g_log.debug() << "radius=" << radius << " coeff1=" << coeff1
......
......@@ -124,9 +124,9 @@ void SphericalAbsorption::retrieveBaseProperties() {
NeutronAtom neutron(static_cast<uint16_t>(EMPTY_DBL()),
static_cast<uint16_t>(0), 0.0, 0.0, sigma_s, 0.0,
sigma_s, sigma_atten);
auto shape =
boost::shared_ptr<IObject>(
m_inputWS->sample().getShape().cloneWithMaterial(Material("SetInSphericalAbsorption", neutron, rho)));
auto shape = boost::shared_ptr<IObject>(
m_inputWS->sample().getShape().cloneWithMaterial(
Material("SetInSphericalAbsorption", neutron, rho)));
m_inputWS->mutableSample().setShape(shape);
}
......
......@@ -51,7 +51,8 @@ public:
delete latt;
auto shape_sptr = ComponentCreationHelper::createCappedCylinder(
0.0127, 1.0, V3D(), V3D(0.0, 1.0, 0.0), "cyl");
shape_sptr->setMaterial(Material("vanBlock", Mantid::PhysicalConstants::getNeutronAtom(23, 0), 0.072));
shape_sptr->setMaterial(Material(
"vanBlock", Mantid::PhysicalConstants::getNeutronAtom(23, 0), 0.072));
sample.setShape(shape_sptr);
return sample;
}
......
......@@ -40,7 +40,8 @@ void addSample(Mantid::API::MatrixWorkspace_sptr ws,
auto sampleShape =
ComponentCreationHelper::createSphere(0.1, V3D(), "sample-sphere");
// And a material assuming it's a CSG Object
sampleShape->setMaterial(Material("Vanadium", PhysicalConstants::getNeutronAtom(23, 0), 0.072));
sampleShape->setMaterial(
Material("Vanadium", PhysicalConstants::getNeutronAtom(23, 0), 0.072));
ws->mutableSample().setShape(sampleShape);
if (environment == Environment::SamplePlusContainer) {
......@@ -51,10 +52,12 @@ void addSample(Mantid::API::MatrixWorkspace_sptr ws,
const V3D axis(0.0, 1.0, 0.0);
ShapeFactory shapeMaker;
auto canShape = shapeMaker.createShape(ComponentCreationHelper::cappedCylinderXML(
radius, height, baseCentre, axis, id));
auto canShape =
shapeMaker.createShape(ComponentCreationHelper::cappedCylinderXML(
radius, height, baseCentre, axis, id));
// Set material assuming it's a CSG Object
canShape->setMaterial(Material("CanMaterial", PhysicalConstants::getNeutronAtom(26, 0), 0.01));
canShape->setMaterial(Material(
"CanMaterial", PhysicalConstants::getNeutronAtom(26, 0), 0.01));
auto can = boost::make_shared<Container>(canShape);
SampleEnvironment *env = new SampleEnvironment("can", can);
ws->mutableSample().setEnvironment(env);
......
......@@ -89,11 +89,12 @@ inline Mantid::API::Sample createSamplePlusContainer() {
// Create an annulus Vanadium can with silicon sample
const double height(0.05), innerRadius(0.0046), outerRadius(0.005);
const V3D centre(0, 0, -0.5 * height), upAxis(0, 0, 1);
// Container
// Container
auto canShape = ShapeFactory().createShape(
annulusXML(innerRadius, outerRadius, height, upAxis));
annulusXML(innerRadius, outerRadius, height, upAxis));
// CSG Object assumed
if (auto csgObj = boost::dynamic_pointer_cast<Mantid::Geometry::CSGObject>(canShape)) {
if (auto csgObj =
boost::dynamic_pointer_cast<Mantid::Geometry::CSGObject>(canShape)) {
csgObj->setMaterial(Material("Vanadium", getNeutronAtom(23), 0.02));
}
auto can = boost::make_shared<Container>(canShape);
......@@ -103,7 +104,8 @@ inline Mantid::API::Sample createSamplePlusContainer() {
auto sampleCell = ComponentCreationHelper::createCappedCylinder(
innerRadius, height, centre, upAxis, "sample");
// CSG Object assumed
if (auto csgObj = boost::dynamic_pointer_cast<Mantid::Geometry::CSGObject>(sampleCell)) {
if (auto csgObj = boost::dynamic_pointer_cast<Mantid::Geometry::CSGObject>(
sampleCell)) {
csgObj->setMaterial(Material("Si", getNeutronAtom(14), 0.15));
}
......@@ -138,7 +140,8 @@ inline Mantid::API::Sample createTestSample(TestSampleType sampleType) {
throw std::invalid_argument("Unknown testing shape type requested");
}
// CSG Object assumed
if (auto csgObj = boost::dynamic_pointer_cast<Mantid::Geometry::CSGObject>(shape)) {
if (auto csgObj =
boost::dynamic_pointer_cast<Mantid::Geometry::CSGObject>(shape)) {
csgObj->setMaterial(Material("Vanadium", getNeutronAtom(23), 0.02));
}
testSample.setShape(shape);
......
......@@ -359,9 +359,9 @@ void AnvredCorrection::retrieveBaseProperties() {
NeutronAtom neutron(static_cast<uint16_t>(EMPTY_DBL()),
static_cast<uint16_t>(0), 0.0, 0.0, m_smu, 0.0, m_smu,
m_amu);
auto shape =
boost::shared_ptr<IObject>(
m_inputWS->sample().getShape().cloneWithMaterial(Material("SetInAnvredCorrection", neutron, 1.0)));
auto shape = boost::shared_ptr<IObject>(
m_inputWS->sample().getShape().cloneWithMaterial(
Material("SetInAnvredCorrection", neutron, 1.0)));
m_inputWS->mutableSample().setShape(shape);
}
if (m_smu != EMPTY_DBL() && m_amu != EMPTY_DBL())
......
......@@ -168,7 +168,9 @@ void LoadHKL::exec() {
mrun.addProperty<double>("Radius", radius, true);
NeutronAtom neutron(static_cast<uint16_t>(EMPTY_DBL()),
static_cast<uint16_t>(0), 0.0, 0.0, smu, 0.0, smu, amu);
auto shape = boost::shared_ptr<IObject>(ws->sample().getShape().cloneWithMaterial(Material("SetInLoadHKL", neutron, 1.0)));
auto shape =
boost::shared_ptr<IObject>(ws->sample().getShape().cloneWithMaterial(
Material("SetInLoadHKL", neutron, 1.0)));
ws->mutableSample().setShape(shape);
setProperty("OutputWorkspace",
......
......@@ -258,8 +258,9 @@ void SaveHKL::exec() {
NeutronAtom neutron(static_cast<uint16_t>(EMPTY_DBL()),
static_cast<uint16_t>(0), 0.0, 0.0, m_smu, 0.0, m_smu,
m_amu);
auto shape =
boost::shared_ptr<IObject>(peaksW->sample().getShape().cloneWithMaterial(Material("SetInSaveHKL", neutron, 1.0)));
auto shape = boost::shared_ptr<IObject>(
peaksW->sample().getShape().cloneWithMaterial(
Material("SetInSaveHKL", neutron, 1.0)));
peaksW->mutableSample().setShape(shape);
}
if (m_smu != EMPTY_DBL() && m_amu != EMPTY_DBL())
......
......@@ -344,11 +344,12 @@ void SetSample::setSampleShape(API::MatrixWorkspace_sptr &workspace,
}
}
auto shapeObject = can->createSampleShape(shapeArgs);
// Given that the object is a CSG object, set the object
// Given that the object is a CSG object, set the object
// directly on the sample ensuring we preserve the
// material.
const auto mat = workspace->sample().getMaterial();
if (auto csgObj = boost::dynamic_pointer_cast<Geometry::CSGObject>(shapeObject)) {
if (auto csgObj =
boost::dynamic_pointer_cast<Geometry::CSGObject>(shapeObject)) {
csgObj->setMaterial(mat);
}
workspace->mutableSample().setShape(shapeObject);
......
......@@ -264,7 +264,8 @@ void SetSampleMaterial::exec() {
if (isEmpty(rho)) {
g_log.information("Unknown value for number density");
} else {
double smu = material->totalScatterXSection(NeutronAtom::ReferenceLambda) * rho;
double smu =
material->totalScatterXSection(NeutronAtom::ReferenceLambda) * rho;
double amu = material->absorbXSection(NeutronAtom::ReferenceLambda) * rho;
g_log.information() << "Anvred LinearScatteringCoef = " << smu << " 1/cm\n"
<< "Anvred LinearAbsorptionCoef = " << amu << " 1/cm\n";
......
......@@ -78,7 +78,9 @@ public:
IObject *clone() const override { return new CSGObject(*this); }
IObject *cloneWithMaterial(const Kernel::Material &material) const override {
auto obj = new CSGObject(*this); obj->setMaterial(material); return obj;
auto obj = new CSGObject(*this);
obj->setMaterial(material);
return obj;
}
/// Return the top rule
......@@ -86,8 +88,8 @@ public:
void setID(const std::string &id) { m_id = id; }
const std::string &id() const override { return m_id; }
void setName(const int nx) { ObjNum = nx; } ///< Set Name
int getName() const override { return ObjNum; } ///< Get Name
void setName(const int nx) { ObjNum = nx; } ///< Set Name
int getName() const override { return ObjNum; } ///< Get Name
void setMaterial(const Kernel::Material &material);
const Kernel::Material material() const override;
......@@ -186,11 +188,9 @@ public:
void setGeometryHandler(boost::shared_ptr<GeometryHandler> h);
/// set vtkGeometryCache writer
void setVtkGeometryCacheWriter(
boost::shared_ptr<vtkGeometryCacheWriter>);
void setVtkGeometryCacheWriter(boost::shared_ptr<vtkGeometryCacheWriter>);
/// set vtkGeometryCache reader
void setVtkGeometryCacheReader(
boost::shared_ptr<vtkGeometryCacheReader>);
void setVtkGeometryCacheReader(boost::shared_ptr<vtkGeometryCacheReader>);
void GetObjectGeom(int &type, std::vector<Kernel::V3D> &vectors,
double &myradius, double &myheight) const override;
/// Getter for the shape xml
......
......@@ -60,7 +60,8 @@ public:
const Kernel::V3D &uVec) const = 0;
virtual bool hasValidShape() const = 0;
virtual IObject *clone() const = 0;
virtual IObject *cloneWithMaterial(const Kernel::Material &material) const = 0;
virtual IObject *
cloneWithMaterial(const Kernel::Material &material) const = 0;
virtual int getName() const = 0;
......@@ -98,7 +99,6 @@ public:
virtual void draw() const = 0;
virtual void initDraw() const = 0;
virtual const Kernel::Material material() const = 0;
virtual const std::string &id() const = 0;
......
......@@ -65,12 +65,12 @@ class MANTID_GEOMETRY_DLL MeshObject : public IObject {
public:
/// Flexible constructor
MeshObject(const std::vector<uint16_t> &faces,
const std::vector<Mantid::Kernel::V3D> &vertices,
const Kernel::Material &material);
const std::vector<Mantid::Kernel::V3D> &vertices,
const Kernel::Material &material);
// Efficient constructor
MeshObject(std::vector<uint16_t> &&faces,
std::vector<Mantid::Kernel::V3D> &&vertices,
const Kernel::Material &material);
std::vector<Mantid::Kernel::V3D> &&vertices,
const Kernel::Material &material);
/// Copy constructor
MeshObject(const MeshObject &) = delete;
......@@ -88,7 +88,7 @@ public:
const std::string &id() const override { return m_id; }
int getName() const override { return 0; }
int getName() const override { return 0; }
const Kernel::Material material() const override;
......
......@@ -86,12 +86,12 @@ class MANTID_GEOMETRY_DLL ShapeFactory {
public:
boost::shared_ptr<CSGObject> createShape(Poco::XML::Element *pElem);
boost::shared_ptr<CSGObject> createShape(std::string shapeXML,
bool addTypeTag = true);
bool addTypeTag = true);
boost::shared_ptr<CSGObject> 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,
......
......@@ -34,7 +34,7 @@ namespace Geometry {
class MeshObject;
class MANTID_GEOMETRY_DLL MeshGeometryGenerator {
private:
MeshObject *Obj; ///< Input Object
MeshObject *Obj; ///< Input Object
int mNoOfVertices; ///< number of vertices
int mNoOfTriangles; ///< number of triangles
double *mPoints; ///<double array or points
......
......@@ -102,7 +102,7 @@ createVirtualInstrument(Kernel::V3D sourcePos, Kernel::V3D samplePos,
* Create a sphere object
*/
boost::shared_ptr<CSGObject> createSphere(double radius, const V3D &centre,
const std::string &id) {
const std::string &id) {
ShapeFactory shapeMaker;
return shapeMaker.createShape(sphereXML(radius, centre, id));
}
......
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