Commit 81c5b9af authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

ShapeFactory returns IObject. Re #12827

parent 12593ae3
......@@ -70,11 +70,11 @@ private:
API::Progress &progress, int numBanks, int numMonitors, int pixels,
double pixelSpacing, const double bankDistanceFromSample,
const double sourceSampleDistance);
Geometry::Object_sptr createCappedCylinder(double radius, double height,
Geometry::IObject_sptr createCappedCylinder(double radius, double height,
const Kernel::V3D &baseCentre,
const Kernel::V3D &axis,
const std::string &id);
Geometry::Object_sptr createSphere(double radius, const Kernel::V3D &centre,
Geometry::IObject_sptr createSphere(double radius, const Kernel::V3D &centre,
const std::string &id);
std::vector<double> evalFunction(const std::string &functionString,
const std::vector<double> &xVal,
......
......@@ -504,7 +504,7 @@ Instrument_sptr CreateSampleWorkspace::createTestInstrumentRectangular(
const double cylRadius(pixelSpacing / 2);
const double cylHeight(0.0002);
// One object
Object_sptr pixelShape = createCappedCylinder(
auto pixelShape = createCappedCylinder(
cylRadius, cylHeight, V3D(0.0, -cylHeight / 2.0, 0.0), V3D(0., 1.0, 0.),
"pixel-shape");
......@@ -537,7 +537,7 @@ Instrument_sptr CreateSampleWorkspace::createTestInstrumentRectangular(
int monitorsStart = (numBanks + 1) * pixels * pixels;
Object_sptr monitorShape =
auto monitorShape =
createCappedCylinder(0.1, 0.1, V3D(0.0, -cylHeight / 2.0, 0.0),
V3D(0., 1.0, 0.), "monitor-shape");
......@@ -577,7 +577,7 @@ Instrument_sptr CreateSampleWorkspace::createTestInstrumentRectangular(
testInst->add(chopper);
// Define a sample as a simple sphere
Object_sptr sampleSphere =
auto sampleSphere =
createSphere(0.001, V3D(0.0, 0.0, 0.0), "sample-shape");
ObjComponent *sample =
new ObjComponent("sample", sampleSphere, testInst.get());
......@@ -592,7 +592,7 @@ Instrument_sptr CreateSampleWorkspace::createTestInstrumentRectangular(
/**
* Create a capped cylinder object
*/
Object_sptr CreateSampleWorkspace::createCappedCylinder(double radius,
IObject_sptr CreateSampleWorkspace::createCappedCylinder(double radius,
double height,
const V3D &baseCentre,
const V3D &axis,
......@@ -616,7 +616,7 @@ Object_sptr CreateSampleWorkspace::createCappedCylinder(double radius,
/**
* Create a sphere object
*/
Object_sptr CreateSampleWorkspace::createSphere(double radius,
IObject_sptr CreateSampleWorkspace::createSphere(double radius,
const V3D &centre,
const std::string &id) {
ShapeFactory shapeMaker;
......
......@@ -153,7 +153,7 @@ modelHistogram(const API::MatrixWorkspace &modelWS,
/** Creates a rectangular cuboid shape.
* @return A cube shape.
*/
Geometry::Object_sptr makeCubeShape() {
Geometry::IObject_sptr makeCubeShape() {
using namespace Poco::XML;
const double dimension = 0.05;
AutoPtr<Document> shapeDescription = new Document;
......
......@@ -682,7 +682,7 @@ private:
// Geometry::ReferenceFrame(Geometry::PointingAlong::Y,Geometry::X,Geometry::Left,"")));
const double pixelRadius(0.05);
Geometry::Object_sptr pixelShape =
auto pixelShape =
ComponentCreationHelper::createCappedCylinder(
pixelRadius, 0.02, V3D(0.0, 0.0, 0.0), V3D(0., 1.0, 0.), "tube");
......
......@@ -43,16 +43,16 @@ public:
auto canShape = ComponentCreationHelper::cappedCylinderXML(
0.5, 1.5, V3D(0.0, 0.0, 0.0), V3D(0., 1.0, 0.), "tube");
SampleEnvironment *kit = new SampleEnvironment(
envName, ShapeFactory().createShape<Container>(canShape));
envName, boost::make_shared<Container>(ShapeFactory().createShape(canShape)));
sample.setEnvironment(kit);
OrientedLattice *latt = new OrientedLattice(1.0, 2.0, 3.0, 90, 90, 90);
sample.setOrientedLattice(latt);
delete latt;
Object_sptr shape_sptr = ComponentCreationHelper::createCappedCylinder(
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));
sample.setShape(*shape_sptr);
sample.setShape(shape_sptr);
return sample;
}
......
......@@ -131,7 +131,7 @@ private:
// Pixel shape
const double pixelRadius(0.01);
const double pixelHeight(0.003);
Object_sptr pixelShape = ComponentCreationHelper::createCappedCylinder(
auto pixelShape = ComponentCreationHelper::createCappedCylinder(
pixelRadius, pixelHeight, V3D(0.0, -0.5 * pixelHeight, 0.0),
V3D(0.0, 1.0, 0.0), "pixelShape");
for (int i = 0; i < nTubes; ++i) {
......
......@@ -67,9 +67,9 @@ public:
testWS->getAxis(0)->unit() =
Mantid::Kernel::UnitFactory::Instance().create("Wavelength");
// Define a sample shape
Object_sptr sampleShape =
auto sampleShape =
ComponentCreationHelper::createCuboid(0.005, 0.003, 0.002);
testWS->mutableSample().setShape(*sampleShape);
testWS->mutableSample().setShape(sampleShape);
Mantid::Algorithms::CuboidGaugeVolumeAbsorption abs;
abs.initialize();
......@@ -96,9 +96,9 @@ public:
testWS->getAxis(0)->unit() =
Mantid::Kernel::UnitFactory::Instance().create("Wavelength");
// Define a sample shape
Object_sptr sampleShape =
auto sampleShape =
ComponentCreationHelper::createCuboid(0.025, 0.03, 0.02);
testWS->mutableSample().setShape(*sampleShape);
testWS->mutableSample().setShape(sampleShape);
TS_ASSERT_THROWS_NOTHING(
atten.setProperty<MatrixWorkspace_sptr>("InputWorkspace", testWS));
......
......@@ -121,7 +121,7 @@ private:
// convert into a Geometry object
bool addTypeTag = true;
boost::shared_ptr<CSGObject> shape =
auto shape =
ShapeFactory().createShape(xmlShape, addTypeTag);
boost::shared_ptr<Instrument> instrument = boost::make_shared<Instrument>();
......
......@@ -137,7 +137,7 @@ public:
MCInteractionVolume mcv(sample, sample.getShape().getBoundingBox()),
std::invalid_argument);
// valid shape
sample.setShape(*ComponentCreationHelper::createSphere(1));
sample.setShape(ComponentCreationHelper::createSphere(1));
TS_ASSERT_THROWS_NOTHING(
MCInteractionVolume mcv(sample, sample.getShape().getBoundingBox()));
}
......
......@@ -136,7 +136,7 @@ private:
createCappedCylinder(radius, height, V3D(), V3D(0., 1., 0.), "sample");
const double numberDensity(0.07261);
cylinder->setMaterial(Material("V", getNeutronAtom(23), numberDensity));
testWS->mutableSample().setShape(*cylinder);
testWS->mutableSample().setShape(cylinder);
// Move the detector to a known position
const double twoTheta = 0.10821;
......
......@@ -37,12 +37,12 @@ void addSample(Mantid::API::MatrixWorkspace_sptr ws,
namespace PhysicalConstants = Mantid::PhysicalConstants;
// Define a sample shape
Object_sptr sampleShape =
auto sampleShape =
ComponentCreationHelper::createSphere(0.1, V3D(), "sample-sphere");
// And a material
sampleShape->setMaterial(
Material("Vanadium", PhysicalConstants::getNeutronAtom(23, 0), 0.072));
ws->mutableSample().setShape(*sampleShape);
ws->mutableSample().setShape(sampleShape);
if (environment == Environment::SamplePlusContainer) {
const std::string id("container");
......@@ -52,9 +52,9 @@ void addSample(Mantid::API::MatrixWorkspace_sptr ws,
const V3D axis(0.0, 1.0, 0.0);
ShapeFactory shapeMaker;
auto can = shapeMaker.createShape<Container>(
auto can = boost::make_shared<Container>(shapeMaker.createShape(
ComponentCreationHelper::cappedCylinderXML(radius, height, baseCentre,
axis, id));
axis, id)));
can->setMaterial(Material("CanMaterial",
PhysicalConstants::getNeutronAtom(26, 0), 0.01));
SampleEnvironment *env = new SampleEnvironment("can", can);
......
......@@ -11,6 +11,7 @@
#include "MantidKernel/make_unique.h"
#include "MantidTestHelpers/ComponentCreationHelper.h"
#include <boost/make_shared.hpp>
#include <gmock/gmock.h>
/*
......@@ -68,7 +69,7 @@ inline std::string annulusXML(double innerRadius, double outerRadius,
return os.str();
}
inline Mantid::Geometry::Object_sptr
inline Mantid::Geometry::IObject_sptr
createAnnulus(double innerRadius, double outerRadius, double height,
const Mantid::Kernel::V3D &upAxis) {
using Mantid::Geometry::ShapeFactory;
......@@ -89,8 +90,8 @@ inline Mantid::API::Sample createSamplePlusContainer() {
const double height(0.05), innerRadius(0.0046), outerRadius(0.005);
const V3D centre(0, 0, -0.5 * height), upAxis(0, 0, 1);
// Container
auto can = ShapeFactory().createShape<Container>(
annulusXML(innerRadius, outerRadius, height, upAxis));
auto can = boost::make_shared<Container>(ShapeFactory().createShape(
annulusXML(innerRadius, outerRadius, height, upAxis)));
can->setMaterial(Material("Vanadium", getNeutronAtom(23), 0.02));
auto environment =
Mantid::Kernel::make_unique<SampleEnvironment>("Annulus Container", can);
......@@ -101,7 +102,7 @@ inline Mantid::API::Sample createSamplePlusContainer() {
// Sample object
Sample testSample;
testSample.setShape(*sampleCell);
testSample.setShape(sampleCell);
testSample.setEnvironment(environment.release());
return testSample;
}
......@@ -110,7 +111,7 @@ inline Mantid::API::Sample createTestSample(TestSampleType sampleType) {
using Mantid::API::Sample;
using Mantid::Kernel::Material;
using Mantid::Kernel::V3D;
using Mantid::Geometry::Object_sptr;
using Mantid::Geometry::IObject_sptr;
using Mantid::PhysicalConstants::getNeutronAtom;
using namespace Mantid::Geometry;
......@@ -119,7 +120,7 @@ inline Mantid::API::Sample createTestSample(TestSampleType sampleType) {
if (sampleType == TestSampleType::SamplePlusContainer) {
testSample = createSamplePlusContainer();
} else {
Object_sptr shape;
IObject_sptr shape;
if (sampleType == TestSampleType::SolidSphere) {
shape = ComponentCreationHelper::createSphere(0.1);
} else if (sampleType == TestSampleType::Annulus) {
......@@ -130,7 +131,7 @@ inline Mantid::API::Sample createTestSample(TestSampleType sampleType) {
throw std::invalid_argument("Unknown testing shape type requested");
}
shape->setMaterial(Material("Vanadium", getNeutronAtom(23), 0.02));
testSample.setShape(*shape);
testSample.setShape(shape);
}
return testSample;
}
......
......@@ -89,7 +89,7 @@ public:
const V3D center;
RectangularBeamProfile profile(createTestFrame(), center, width, height);
Sample testSample;
testSample.setShape(*ComponentCreationHelper::createSphere(0.5));
testSample.setShape(ComponentCreationHelper::createSphere(0.5));
auto region = profile.defineActiveRegion(testSample);
TS_ASSERT(region.isNonNull());
......@@ -104,7 +104,7 @@ public:
const V3D center;
RectangularBeamProfile profile(createTestFrame(), center, width, height);
Sample testSample;
testSample.setShape(*ComponentCreationHelper::createSphere(0.5));
testSample.setShape(ComponentCreationHelper::createSphere(0.5));
auto region = profile.defineActiveRegion(testSample);
TS_ASSERT(region.isNonNull());
......
......@@ -42,8 +42,8 @@ public:
double amu = 0.011;
NeutronAtom neutron(static_cast<uint16_t>(EMPTY_DBL()),
static_cast<uint16_t>(0), 0.0, 0.0, smu, 0.0, smu, amu);
CSGObject sampleShape;
sampleShape.setMaterial(Material("SetInAnvredCorrection", neutron, 1.0));
auto sampleShape = boost::make_shared<CSGObject>();
sampleShape->setMaterial(Material("SetInAnvredCorrection", neutron, 1.0));
ws->mutableSample().setShape(sampleShape);
API::Run &mrun = ws->mutableRun();
......
......@@ -40,8 +40,9 @@ public:
double amu = 0.011;
NeutronAtom neutron(static_cast<uint16_t>(EMPTY_DBL()),
static_cast<uint16_t>(0), 0.0, 0.0, smu, 0.0, smu, amu);
CSGObject sampleShape;
sampleShape.setMaterial(Material("SetInSaveHKLTest", neutron, 1.0));
auto sampleShape = boost::make_shared<CSGObject>();
sampleShape->setMaterial(Material("SetInSaveHKLTest", neutron, 1.0));
ws->mutableSample().setShape(sampleShape);
API::Run &mrun = ws->mutableRun();
......
......@@ -16,6 +16,7 @@
#include <cxxtest/TestSuite.h>
#include <fstream>
#include <Poco/File.h>
#include <boost/make_shared.hpp>
using namespace Mantid;
using namespace Mantid::Crystal;
......@@ -49,8 +50,8 @@ public:
double amu = 0.011;
NeutronAtom neutron(static_cast<uint16_t>(EMPTY_DBL()),
static_cast<uint16_t>(0), 0.0, 0.0, smu, 0.0, smu, amu);
CSGObject sampleShape;
sampleShape.setMaterial(Material("SetInSaveHKLTest", neutron, 1.0));
auto sampleShape = boost::make_shared<CSGObject>();
sampleShape->setMaterial(Material("SetInSaveHKLTest", neutron, 1.0));
ws->mutableSample().setShape(sampleShape);
API::Run &mrun = ws->mutableRun();
......
......@@ -14,7 +14,7 @@ class ISpectrum;
}
namespace Geometry {
class CSGObject;
class IObject;
}
namespace CurveFitting {
......@@ -138,7 +138,7 @@ private:
Kernel::V3D m_beamDir; // Directional vector for beam
double m_srcR2; // beam penumbra radius (m)
double m_halfSampleHeight, m_halfSampleWidth, m_halfSampleThick; // (m)
Geometry::CSGObject const *m_sampleShape; // sample shape
Geometry::IObject const *m_sampleShape; // sample shape
SampleComptonProperties *m_sampleProps; // description of sample properties
double m_detHeight, m_detWidth, m_detThick; // (m)
double m_tmin, m_tmax, m_delt; // min, max & dt TOF value
......
......@@ -123,7 +123,7 @@ createFlatPlateSampleWS(const bool detShape = true,
<< "</cuboid>";
auto sampleShape =
Mantid::Geometry::ShapeFactory().createShape(sampleShapeXML.str());
testWS->mutableSample().setShape(*sampleShape);
testWS->mutableSample().setShape(sampleShape);
return testWS;
}
......
......@@ -567,7 +567,7 @@ private:
inst->markAsSamplePos(sample);
// Add a detector
Object_sptr pixelShape = ComponentCreationHelper::createCappedCylinder(
auto pixelShape = ComponentCreationHelper::createCappedCylinder(
0.05, 0.02, V3D(0.0, 0.0, 0.0), V3D(0., 1.0, 0.), "tube");
Detector *det =
new Detector("pixel-1", 1, pixelShape,
......
......@@ -502,7 +502,7 @@ private:
inst->markAsSamplePos(sample);
// Add a detector
Object_sptr pixelShape = ComponentCreationHelper::createCappedCylinder(
auto pixelShape = ComponentCreationHelper::createCappedCylinder(
0.05, 0.02, V3D(0.0, 0.0, 0.0), V3D(0., 1.0, 0.), "tube");
Detector *det =
new Detector("pixel-1", 1, pixelShape,
......
Markdown is supported
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