Commit 12593ae3 authored by Karl Palmen's avatar Karl Palmen
Browse files

Attempt to make ShapeFactory return IObject pointer re #12827



Earlier changes also included

Signed-off-by: default avatarKarl Palmen <karl.palmen@stfc.ac.uk>
parent bc88b8e8
......@@ -348,7 +348,7 @@ void SetSample::setSampleShape(API::MatrixWorkspace_sptr &workspace,
// material
const auto mat = workspace->sample().getMaterial();
shapeObject->setMaterial(mat);
workspace->mutableSample().setShape(*shapeObject);
workspace->mutableSample().setShape(shapeObject);
} else {
throw std::runtime_error("The can does not define the sample shape. "
"Please either provide a 'Shape' argument "
......
......@@ -237,8 +237,8 @@ void SetSampleMaterial::exec() {
normalizedLaue = 0.;
// set the material but leave the geometry unchanged
auto shapeObject = expInfo->sample().getShape(); // copy
shapeObject.setMaterial(*mat);
auto shapeObject = boost::shared_ptr<Geometry::IObject>(expInfo->sample().getShape().clone());
shapeObject->setMaterial(*mat);
expInfo->mutableSample().setShape(shapeObject);
g_log.information() << "Sample number density ";
if (isEmpty(mat->numberDensity())) {
......
......@@ -43,7 +43,7 @@ public:
Container(std::string xml);
bool hasSampleShape() const;
Object_sptr createSampleShape(const ShapeArgs &args) const;
IObject_sptr createSampleShape(const ShapeArgs &args) const;
void setSampleShape(const std::string &sampleShapeXML);
......
......@@ -26,6 +26,7 @@ namespace Mantid {
namespace Geometry {
class Surface;
class IObject;
class CSGObject;
struct CuboidCorners {
......@@ -83,13 +84,13 @@ File change history is stored at: <https://github.com/mantidproject/mantid>
*/
class MANTID_GEOMETRY_DLL ShapeFactory {
public:
template <typename ObjectType = CSGObject>
template <typename ObjectType = IObject>
boost::shared_ptr<ObjectType> createShape(Poco::XML::Element *pElem);
template <typename ObjectType = CSGObject>
template <typename ObjectType = IObject>
boost::shared_ptr<ObjectType> createShape(std::string shapeXML,
bool addTypeTag = true);
boost::shared_ptr<CSGObject> createHexahedralShape(double xlb, double xlf,
boost::shared_ptr<IObject> createHexahedralShape(double xlb, double xlf,
double xrf, double xrb,
double ylb, double ylf,
double yrf, double yrb);
......
......@@ -2,7 +2,7 @@
#include "MantidGeometry/Instrument/ParameterMap.h"
#include "MantidGeometry/IComponent.h"
#include "MantidGeometry/Instrument/ReferenceFrame.h"
#include "MantidGeometry/Objects/CSGObject.h"
#include "MantidGeometry/Objects/IObject.h"
#include "MantidGeometry/Objects/ShapeFactory.h"
#include "MantidGeometry/Instrument/Detector.h"
......
......@@ -63,7 +63,7 @@ bool Container::hasSampleShape() const { return !m_sampleShapeXML.empty(); }
* @param args A hash of tag values to use in place of the default
* @return A pointer to a object modeling the sample shape
*/
Object_sptr
IObject_sptr
Container::createSampleShape(const Container::ShapeArgs &args) const {
using namespace Poco::XML;
if (!hasSampleShape()) {
......
......@@ -596,7 +596,7 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() {
}
if (!obj_str.str().empty()) {
boost::shared_ptr<CSGObject> s = ShapeFactory().createShape(obj_str.str());
boost::shared_ptr<IObject> s = ShapeFactory().createShape(obj_str.str());
setOutline(s);
return s;
}
......
......@@ -420,7 +420,7 @@ Detector *StructuredDetector::addDetector(CompAssembly *parent,
ylb -= ypos;
ShapeFactory factory;
boost::shared_ptr<Mantid::Geometry::CSGObject> shape =
boost::shared_ptr<Mantid::Geometry::IObject> shape =
factory.createHexahedralShape(xlb, xlf, xrf, xrb, ylb, ylf, yrf, yrb);
// Create detector
......
......@@ -1385,7 +1385,7 @@ V3D ShapeFactory::parsePosition(Poco::XML::Element *pElem) {
@returns the newly created hexahedral shape object
*/
boost::shared_ptr<CSGObject>
boost::shared_ptr<IObject>
ShapeFactory::createHexahedralShape(double xlb, double xlf, double xrf,
double xrb, double ylb, double ylf,
double yrf, double yrb) {
......
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