Mantid
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Mantid::Geometry::ShapeFactory Class Reference

Class originally intended to be used with the DataHandling 'LoadInstrument' algorithm. More...

#include <ShapeFactory.h>

Public Member Functions

std::string addAppliedGoniometerTag (const Kernel::Matrix< double > &bakedRotation, std::string xml)
 Replace or insert the <applied-goniometer> tag, recording how much of <goniometer> is a bake into the lab frame rather than a rotation of the shape within its own frame.
 
std::string addGoniometerTag (const Kernel::Matrix< double > &rotateMatrix, std::string xml)
 Replace or insert the <goniometer> tag, the TOTAL rotation applied to the shape's surfaces.
 
std::shared_ptr< CSGObject > createShape (Poco::XML::Element *pElem)
 Creates a geometric object from a DOM-element-node pointing to an element whose child nodes contain the shape information.
 
std::shared_ptr< CSGObject > createShape (std::string shapeXML, bool addTypeTag=true)
 Creates a geometric object directly from a XML shape string.
 
std::string rebakeGoniometer (const Kernel::Matrix< double > &newBake, std::string xml, const Kernel::Matrix< double > &currentBake)
 Rebase the shape so the baked part becomes exactly newBake, preserving the definition-frame rotation.
 

Static Public Member Functions

static Kernel::Matrix< double > appliedGoniometerFromXML (const std::string &xml)
 The baked part of a shape XML string's rotation - what a shape built from this XML reports through getAppliedRotation.
 
static std::shared_ptr< CSGObject > createHexahedralShape (double xlb, double xlf, double xrf, double xrb, double ylb, double ylf, double yrf, double yrb)
 Create a hexahedral shape object.
 
static std::shared_ptr< CSGObject > createSphere (const Kernel::V3D &centre, double radius)
 Create a Sphere.
 
static Kernel::Matrix< double > generateMatrix (double xRotation, double yRotation, double zRotation)
 Generates a rotate Matrix applying the x rotate then y rotate, then z rotate.
 
static Kernel::Matrix< double > generateXRotation (double xRotation)
 Generates the x component of the rotate matrix.
 
static Kernel::Matrix< double > generateYRotation (double yRotation)
 Generates the y component of the rotate matrix.
 
static Kernel::Matrix< double > generateZRotation (double zRotation)
 Generates the z component of the rotate matrix.
 
static Kernel::Matrix< double > goniometerFromXML (const std::string &xml)
 The total rotation held in a shape XML string's <goniometer> tag, identity if there is none.
 

Private Member Functions

void createGeometryHandler (Poco::XML::Element *, const std::shared_ptr< CSGObject > &)
 create a special geometry handler for the known finite primitives
 
Poco::XML::Element * getOptionalShapeElement (Poco::XML::Element *pElem, const std::string &name)
 Return a subelement of an XML element.
 
Poco::XML::Element * getShapeElement (Poco::XML::Element *pElem, const std::string &name)
 Return a subelement of an XML element, but also checks that there exist exactly one entry of this subelement.
 
std::string parseCone (Poco::XML::Element *pElem, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 Parse XML 'cone' element.
 
CuboidCorners parseCuboid (Poco::XML::Element *pElem)
 Get the four corners of a cuboid from an XML element.
 
std::string parseCuboid (Poco::XML::Element *pElem, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 Parse XML 'cuboid' element.
 
std::string parseCylinder (Poco::XML::Element *pElem, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 Parse XML 'cylinder' element.
 
Hexahedron parseHexahedron (Poco::XML::Element *pElem)
 Get all corners of a hexahedron from an XML element.
 
std::string parseHexahedron (Poco::XML::Element *pElem, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 Parse XML 'hexahedron' element.
 
std::string parseHollowCylinder (Poco::XML::Element *pElem, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 Parse XML 'hollow-cylinder' element.
 
std::string parseInfiniteCone (Poco::XML::Element *pElem, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 Parse XML 'infinite-cone' element.
 
std::string parseInfiniteCylinder (Poco::XML::Element *pElem, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 Parse XML 'infinite-cylinder' element.
 
std::string parseInfinitePlane (Poco::XML::Element *pElem, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 Parse XML 'infinite-plane' element.
 
Kernel::V3D parsePosition (Poco::XML::Element *pElem)
 Get position coordinates from XML element.
 
std::string parseSliceOfCylinderRing (Poco::XML::Element *pElem, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 Parse XML 'slice-of-cylinder-ring' element.
 
std::string parseSphere (Poco::XML::Element *pElem, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 Parse XML 'sphere' element.
 
std::string parseTaperedGuide (Poco::XML::Element *pElem, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 Parse XML 'tapered-guide' element, which is a special case of the XML 'hexahedron' element.
 
std::string parseTorus (Poco::XML::Element *pElem, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 Parse XML 'torus' element.
 

Static Private Member Functions

static double getDoubleAttribute (Poco::XML::Element *pElem, const std::string &name)
 Return value of attribute to XML element.
 
static std::string insertMatrixTag (const std::string &tagName, const Kernel::Matrix< double > &matrix, std::string xml)
 Replace, or insert, a tag holding a 3x3 matrix as a11..a33 attributes.
 
static std::optional< Kernel::Matrix< double > > matrixFromXMLTag (const std::string &xml, const std::string &tagName)
 The matrix held in the named tag of a shape XML string, read as createShape reads it, or nullopt when there is no such tag or the XML does not parse.
 
static std::string parseHexahedronFromStruct (const Hexahedron &hex, std::map< int, std::shared_ptr< Surface > > &prim, int &l_id)
 The "tapered-guide" shape is actually a special case of hexahedron; once we have the 8 points that make up either shape, the process of parsing them can be exactly the same in both cases.
 
static Kernel::Matrix< double > parseMatrixElement (Poco::XML::Element *pElem)
 Read a 3x3 matrix held as a11..a33 attributes on an XML element.
 
static std::string sphereAlgebra (const int surfaceID)
 Create the algebra string for a Sphere.
 

Private Attributes

Kernel::Matrix< double > m_gonioRotateMatrix = Kernel::Matrix<double>(3, 3, 1)
 
Kernel::Matrix< double > m_rotateAllMatrix = Kernel::Matrix<double>(3, 3, 1)
 

Detailed Description

Class originally intended to be used with the DataHandling 'LoadInstrument' algorithm.

In that algorithm it is used for creating shared pointers to the geometric shapes described in the XML instrument definition file.

This class is now also use elsewhere, and in addition to create geometric shapes from an DOM-element-node pointing to a <type> element with shape information, shapes can also be created directly from a XML shape string.

Author
Anders Markvardsen, ISIS, RAL
Date
6/8/2008

Definition at line 90 of file ShapeFactory.h.

Member Function Documentation

◆ addAppliedGoniometerTag()

std::string Mantid::Geometry::ShapeFactory::addAppliedGoniometerTag ( const Kernel::Matrix< double > &  bakedRotation,
std::string  xml 
)

Replace or insert the <applied-goniometer> tag, recording how much of <goniometer> is a bake into the lab frame rather than a rotation of the shape within its own frame.

Definition at line 1712 of file ShapeFactory.cpp.

References insertMatrixTag().

Referenced by rebakeGoniometer().

◆ addGoniometerTag()

std::string Mantid::Geometry::ShapeFactory::addGoniometerTag ( const Kernel::Matrix< double > &  rotateMatrix,
std::string  xml 
)

Replace or insert the <goniometer> tag, the TOTAL rotation applied to the shape's surfaces.

Leaves any <applied-goniometer> tag untouched.

Definition at line 1708 of file ShapeFactory.cpp.

References insertMatrixTag().

Referenced by Mantid::Algorithms::CopySample::copyParameters(), Mantid::DataHandling::RotateSampleShape::exec(), rebakeGoniometer(), and Mantid::DataHandling::SetSample::setSampleShape().

◆ appliedGoniometerFromXML()

Kernel::Matrix< double > Mantid::Geometry::ShapeFactory::appliedGoniometerFromXML ( const std::string &  xml)
static

The baked part of a shape XML string's rotation - what a shape built from this XML reports through getAppliedRotation.

Suitable as rebakeGoniometer's currentBake.

Definition at line 1738 of file ShapeFactory.cpp.

References goniometerFromXML(), and matrixFromXMLTag().

◆ createGeometryHandler()

void Mantid::Geometry::ShapeFactory::createGeometryHandler ( Poco::XML::Element *  pElem,
const std::shared_ptr< CSGObject > &  Obj 
)
private

◆ createHexahedralShape()

std::shared_ptr< CSGObject > Mantid::Geometry::ShapeFactory::createHexahedralShape ( double  xlb,
double  xlf,
double  xrf,
double  xrb,
double  ylb,
double  ylf,
double  yrf,
double  yrb 
)
static

Create a hexahedral shape object.

Parameters
xlb:: Left-back x point or hexahedron
xlf:: Left-front x point of hexahedron
xrf:: Right-front x point of hexahedron
xrb:: Right-back x point of hexahedron
ylb:: Left-back y point or hexahedron
ylf:: Left-front y point of hexahedron
yrf:: Right-front y point of hexahedron
yrb:: Right-back y point of hexahedron
Returns
the newly created hexahedral shape object

Definition at line 1516 of file ShapeFactory.cpp.

References Mantid::Geometry::Hexahedron::lbb, Mantid::Geometry::Hexahedron::lbt, Mantid::Geometry::Hexahedron::lfb, Mantid::Geometry::Hexahedron::lft, parseHexahedronFromStruct(), Mantid::Geometry::Hexahedron::rbb, Mantid::Geometry::Hexahedron::rbt, Mantid::Geometry::Hexahedron::rfb, Mantid::Geometry::Hexahedron::rft, and Mantid::Geometry::detail::ShapeInfo::setHexahedron().

Referenced by Mantid::Geometry::StructuredDetector::addDetector().

◆ createShape() [1/2]

std::shared_ptr< CSGObject > Mantid::Geometry::ShapeFactory::createShape ( Poco::XML::Element *  pElem)

Creates a geometric object from a DOM-element-node pointing to an element whose child nodes contain the shape information.

If no shape information an empty Object is returned.

Parameters
pElemA pointer to an Element node whose children fully define the object. The name of this element is unimportant.
Returns
A shared pointer to a geometric shape

Definition at line 108 of file ShapeFactory.cpp.

References createGeometryHandler(), Mantid::Geometry::g_log, generateMatrix(), getShapeElement(), Mantid::Kernel::Matrix< T >::identityMatrix(), m_gonioRotateMatrix, m_rotateAllMatrix, parseCone(), parseCuboid(), parseCylinder(), parseHexahedron(), parseHollowCylinder(), parseInfiniteCone(), parseInfiniteCylinder(), parseInfinitePlane(), parseMatrixElement(), parsePosition(), parseSliceOfCylinderRing(), parseSphere(), parseTaperedGuide(), parseTorus(), and Mantid::Kernel::Logger::warning().

Referenced by Mantid::Geometry::InstrumentDefinitionParser::adjustTypesContainingCombineComponentsElement(), Mantid::Algorithms::AnyShapeAbsorption::constructGaugeVolume(), Mantid::Algorithms::PaalmanPingsAbsorptionCorrection::constructGaugeVolume(), Mantid::Algorithms::AbsorptionCorrection::constructSample(), Mantid::Algorithms::CopySample::copyParameters(), Mantid::Algorithms::CreateSampleWorkspace::createCappedCylinder(), ComponentCreationHelper::createCappedCylinder(), Mantid::Algorithms::DiscusMultipleScatteringCorrection::createCollimatorHexahedronShape(), ComponentCreationHelper::createCuboid(), ComponentCreationHelper::createCuboid(), ComponentCreationHelper::createHollowCylinder(), ComponentCreationHelper::createHollowShell(), Mantid::Geometry::ObjCompAssembly::createOutline(), Mantid::Geometry::Container::createSampleShape(), createShape(), Mantid::Geometry::InstrumentDefinitionParser::createShapeIfTypeIsNotAnAssembly(), Mantid::Algorithms::CreateSampleWorkspace::createSphere(), ComponentCreationHelper::createSphere(), Mantid::Geometry::ComponentHelper::createSphere(), Mantid::Algorithms::MonteCarloAbsorption::doSimulation(), Mantid::DataHandling::DefineGaugeVolume::exec(), Mantid::DataHandling::FindDetectorsInShape::exec(), Mantid::DataHandling::LoadQKK::exec(), Mantid::Algorithms::IBeamProfile::getIntersectionWithSample(), Mantid::Geometry::getLabFrameShape(), Mantid::Algorithms::SparseWorkspace::makeCubeShape(), WorkspaceCreationHelper::maskSpectra(), Mantid::DataHandling::SampleEnvironmentSpecParser::parseComponent(), Mantid::Algorithms::EstimateScatteringVolumeCentreOfMass::rasterizeLabGaugeAndCalculateMeanElementPosition(), Mantid::DataHandling::SetSample::setSampleEnvironmentFromXML(), Mantid::DataHandling::CreateSampleShape::setSampleShape(), Mantid::API::Sample::setShape(), Mantid::Geometry::GridDetector::shape(), Mantid::Geometry::StructuredDetector::shape(), and Mantid::DataHandling::SetSample::validateGeometry().

◆ createShape() [2/2]

std::shared_ptr< CSGObject > Mantid::Geometry::ShapeFactory::createShape ( std::string  shapeXML,
bool  addTypeTag = true 
)

Creates a geometric object directly from a XML shape string.

Parameters
shapeXML:: XML shape string
addTypeTag:: true to wrap a <type> tag around the XML supplied (default)
Returns
A shared pointer to a geometric shape (defaults to an 'empty' shape if XML tags contain no geo. info.)

Definition at line 78 of file ShapeFactory.cpp.

References createShape(), Mantid::Geometry::g_log, and Mantid::Kernel::Logger::warning().

◆ createSphere()

std::shared_ptr< CSGObject > Mantid::Geometry::ShapeFactory::createSphere ( const Kernel::V3D &  centre,
double  radius 
)
static

Create a Sphere.

Parameters
centreThe center of the sphere
radiusThe radius in metres
Returns
A new CSGObject defining a sphere

Definition at line 1486 of file ShapeFactory.cpp.

References centre, Mantid::Geometry::detail::ShapeInfo::setSphere(), and sphereAlgebra().

Referenced by Mantid::Crystal::SaveHKL::exec(), and Mantid::DataHandling::LoadNXSPE::exec().

◆ generateMatrix()

Kernel::Matrix< double > Mantid::Geometry::ShapeFactory::generateMatrix ( double  xrotate,
double  yrotate,
double  zrotate 
)
static

Generates a rotate Matrix applying the x rotate then y rotate, then z rotate.

Parameters
xrotateThe x rotate required in radians
yrotateThe y rotate required in radians
zrotateThe z rotate required in radians
Returns
a matrix of doubles to use as the rotate matrix

Definition at line 1613 of file ShapeFactory.cpp.

References generateXRotation(), generateYRotation(), and generateZRotation().

Referenced by createShape(), parseCuboid(), parseCylinder(), parseHexahedron(), parseHollowCylinder(), parseInfiniteCylinder(), parseInfinitePlane(), parseSliceOfCylinderRing(), parseTaperedGuide(), and Mantid::DataHandling::MeshFileIO::rotate().

◆ generateXRotation()

Kernel::Matrix< double > Mantid::Geometry::ShapeFactory::generateXRotation ( double  xrotate)
static

Generates the x component of the rotate matrix.

Parameters
xrotateThe x rotate required in radians
Returns
a matrix of doubles to use as the x axis rotate matrix

Definition at line 1626 of file ShapeFactory.cpp.

Referenced by generateMatrix().

◆ generateYRotation()

Kernel::Matrix< double > Mantid::Geometry::ShapeFactory::generateYRotation ( double  yrotate)
static

Generates the y component of the rotate matrix.

Parameters
yrotateThe y rotate required in radians
Returns
a matrix of doubles to use as the y axis rotate matrix

Definition at line 1638 of file ShapeFactory.cpp.

Referenced by generateMatrix().

◆ generateZRotation()

Kernel::Matrix< double > Mantid::Geometry::ShapeFactory::generateZRotation ( double  zrotate)
static

Generates the z component of the rotate matrix.

Parameters
zrotateThe z rotate required in radians
Returns
a matrix of doubles to use as the z axis rotate matrix

Definition at line 1650 of file ShapeFactory.cpp.

Referenced by generateMatrix().

◆ getDoubleAttribute()

double Mantid::Geometry::ShapeFactory::getDoubleAttribute ( Poco::XML::Element *  pElem,
const std::string &  name 
)
staticprivate

Return value of attribute to XML element.

It is an extension of poco's getAttribute method, which in addition check that this attribute exists and if not throws an error.

Parameters
pElem:: XML from instrument def. file
name:: Name of subelement
Returns
Value of attribute
Exceptions
std::invalid_argumentThrown if issues with XML string

Definition at line 1422 of file ShapeFactory.cpp.

References name.

Referenced by parseCone(), parseCuboid(), parseCylinder(), parseHollowCylinder(), parseInfiniteCone(), parseInfiniteCylinder(), parseMatrixElement(), parseSliceOfCylinderRing(), parseSphere(), parseTaperedGuide(), and parseTorus().

◆ getOptionalShapeElement()

Poco::XML::Element * Mantid::Geometry::ShapeFactory::getOptionalShapeElement ( Poco::XML::Element *  pElem,
const std::string &  name 
)
private

Return a subelement of an XML element.

The subelement is optional so it may not exist, but we also check that there is never more than one.

Parameters
pElem:: XML from instrument definition file.
name:: Name of the subelement.
Returns
The subelement, or a null pointer if it does not exist.
Exceptions
std::invalid_argumentif XML string is invalid.

Definition at line 1399 of file ShapeFactory.cpp.

References name.

Referenced by createGeometryHandler(), parseCuboid(), parseCylinder(), parseHexahedron(), parseHollowCylinder(), parseInfiniteCylinder(), parseInfinitePlane(), parseSliceOfCylinderRing(), parseSphere(), and parseTaperedGuide().

◆ getShapeElement()

Poco::XML::Element * Mantid::Geometry::ShapeFactory::getShapeElement ( Poco::XML::Element *  pElem,
const std::string &  name 
)
private

Return a subelement of an XML element, but also checks that there exist exactly one entry of this subelement.

Parameters
pElem:: XML from instrument def. file
name:: Name of subelement
Returns
The subelement
Exceptions
std::invalid_argumentThrown if issues with XML string

Definition at line 1376 of file ShapeFactory.cpp.

References name.

Referenced by createGeometryHandler(), createShape(), parseCone(), parseCylinder(), parseHexahedron(), parseHollowCylinder(), parseInfiniteCone(), parseInfiniteCylinder(), parseInfinitePlane(), parseSliceOfCylinderRing(), parseSphere(), parseTaperedGuide(), and parseTorus().

◆ goniometerFromXML()

Kernel::Matrix< double > Mantid::Geometry::ShapeFactory::goniometerFromXML ( const std::string &  xml)
static

The total rotation held in a shape XML string's <goniometer> tag, identity if there is none.

Definition at line 1734 of file ShapeFactory.cpp.

References matrixFromXMLTag().

Referenced by appliedGoniometerFromXML(), and rebakeGoniometer().

◆ insertMatrixTag()

std::string Mantid::Geometry::ShapeFactory::insertMatrixTag ( const std::string &  tagName,
const Kernel::Matrix< double > &  matrix,
std::string  xml 
)
staticprivate

Replace, or insert, a tag holding a 3x3 matrix as a11..a33 attributes.

tagName carries no angle brackets.

Definition at line 1670 of file ShapeFactory.cpp.

References Mantid::Kernel::Matrix< T >::numCols(), Mantid::Kernel::Matrix< T >::numRows(), and Mantid::Kernel::Matrix< T >::size().

Referenced by addAppliedGoniometerTag(), and addGoniometerTag().

◆ matrixFromXMLTag()

std::optional< Kernel::Matrix< double > > Mantid::Geometry::ShapeFactory::matrixFromXMLTag ( const std::string &  xml,
const std::string &  tagName 
)
staticprivate

The matrix held in the named tag of a shape XML string, read as createShape reads it, or nullopt when there is no such tag or the XML does not parse.

Definition at line 1718 of file ShapeFactory.cpp.

References parseMatrixElement().

Referenced by appliedGoniometerFromXML(), and goniometerFromXML().

◆ parseCone()

std::string Mantid::Geometry::ShapeFactory::parseCone ( Poco::XML::Element *  pElem,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
private

Parse XML 'cone' element.

Parameters
pElem:: XML 'cone' element from instrument def. file
prim:: To add shapes to
l_id:: When shapes added to the map prim l_id is the continuous incremented index
Returns
A Mantid algebra string for this shape
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 909 of file ShapeFactory.cpp.

References getDoubleAttribute(), getShapeElement(), height, Mantid::Kernel::normalize(), and parsePosition().

Referenced by createShape().

◆ parseCuboid() [1/2]

CuboidCorners Mantid::Geometry::ShapeFactory::parseCuboid ( Poco::XML::Element *  pElem)
private

Get the four corners of a cuboid from an XML element.

The XML may consist of one of the two available syntaxes. We disallow a mixture of syntaxes.

Parameters
pElem:: XML 'cuboid' element from instrument definition file.
Returns
The four corners of the cuboid.
Exceptions
std::invalid_argumentif XML string is invalid.

Definition at line 667 of file ShapeFactory.cpp.

References centre, generateMatrix(), getDoubleAttribute(), getOptionalShapeElement(), Mantid::Geometry::CuboidCorners::lbb, Mantid::Geometry::CuboidCorners::lfb, Mantid::Geometry::CuboidCorners::lft, m_gonioRotateMatrix, m_rotateAllMatrix, Mantid::Kernel::normalize(), parsePosition(), Mantid::Geometry::CuboidCorners::rfb, Mantid::Kernel::Quat::rotate(), and Mantid::Geometry::CuboidCorners::rotatePoints().

Referenced by createGeometryHandler(), createShape(), and parseCuboid().

◆ parseCuboid() [2/2]

std::string Mantid::Geometry::ShapeFactory::parseCuboid ( Poco::XML::Element *  pElem,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
private

Parse XML 'cuboid' element.

Parameters
pElem:: XML 'cuboid' element from instrument def. file
prim:: To add shapes to
l_id:: When shapes added to the map prim l_id is the continuous incremented index
Returns
A Mantid algebra string for this shape
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 774 of file ShapeFactory.cpp.

References Mantid::Kernel::normalize(), and parseCuboid().

◆ parseCylinder()

std::string Mantid::Geometry::ShapeFactory::parseCylinder ( Poco::XML::Element *  pElem,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
private

Parse XML 'cylinder' element.

Parameters
pElem:: XML 'cylinder' element from instrument def. file
prim:: To add shapes to
l_id:: When shapes added to the map prim l_id is the continuous incremented index
Returns
A Mantid algebra string for this shape
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 492 of file ShapeFactory.cpp.

References centre, generateMatrix(), getDoubleAttribute(), getOptionalShapeElement(), getShapeElement(), height, m_gonioRotateMatrix, m_rotateAllMatrix, Mantid::Kernel::normalize(), parsePosition(), and Mantid::Kernel::V3D::rotate().

Referenced by createShape().

◆ parseHexahedron() [1/2]

Hexahedron Mantid::Geometry::ShapeFactory::parseHexahedron ( Poco::XML::Element *  pElem)
private

◆ parseHexahedron() [2/2]

std::string Mantid::Geometry::ShapeFactory::parseHexahedron ( Poco::XML::Element *  pElem,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
private

Parse XML 'hexahedron' element.

Parameters
pElem:: XML 'hexahedron' element from instrument def. file
prim:: To add shapes to
l_id:: When shapes added to the map prim l_id is the continuous incremented index
Returns
A Mantid algebra string for this shape
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 1113 of file ShapeFactory.cpp.

References parseHexahedron(), and parseHexahedronFromStruct().

◆ parseHexahedronFromStruct()

std::string Mantid::Geometry::ShapeFactory::parseHexahedronFromStruct ( const Hexahedron &  hex,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
staticprivate

The "tapered-guide" shape is actually a special case of hexahedron; once we have the 8 points that make up either shape, the process of parsing them can be exactly the same in both cases.

Definition at line 958 of file ShapeFactory.cpp.

References Mantid::Geometry::Hexahedron::lbb, Mantid::Geometry::Hexahedron::lbt, Mantid::Geometry::Hexahedron::lfb, Mantid::Geometry::Hexahedron::lft, Mantid::Geometry::Hexahedron::rbb, Mantid::Geometry::Hexahedron::rfb, and Mantid::Geometry::Hexahedron::rft.

Referenced by createHexahedralShape(), parseHexahedron(), and parseTaperedGuide().

◆ parseHollowCylinder()

std::string Mantid::Geometry::ShapeFactory::parseHollowCylinder ( Poco::XML::Element *  pElem,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
private

Parse XML 'hollow-cylinder' element.

Parameters
pElem:: XML 'hollow-cylinder' element from instrument def. file
prim:: To add shapes to
l_id:: When shapes added to the map prim l_id is the continuous incremented index
Returns
A Mantid algebra string for this shape
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 571 of file ShapeFactory.cpp.

References centre, generateMatrix(), getDoubleAttribute(), getOptionalShapeElement(), getShapeElement(), height, m_gonioRotateMatrix, m_rotateAllMatrix, Mantid::Kernel::normalize(), parsePosition(), and Mantid::Kernel::V3D::rotate().

Referenced by createShape().

◆ parseInfiniteCone()

std::string Mantid::Geometry::ShapeFactory::parseInfiniteCone ( Poco::XML::Element *  pElem,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
private

Parse XML 'infinite-cone' element.

Parameters
pElem:: XML 'infinite-cone' element from instrument def. file
prim:: To add shapes to
l_id:: When shapes added to the map prim l_id is the continuous incremented index
Returns
A Mantid algebra string for this shape
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 866 of file ShapeFactory.cpp.

References getDoubleAttribute(), getShapeElement(), Mantid::Kernel::normalize(), and parsePosition().

Referenced by createShape().

◆ parseInfiniteCylinder()

std::string Mantid::Geometry::ShapeFactory::parseInfiniteCylinder ( Poco::XML::Element *  pElem,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
private

Parse XML 'infinite-cylinder' element.

Parameters
pElem:: XML 'infinite-cylinder' element from instrument def. file
prim:: To add shapes to
l_id:: When shapes added to the map prim l_id is the continuous incremented index
Returns
A Mantid algebra string for this shape
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 436 of file ShapeFactory.cpp.

References centre, generateMatrix(), getDoubleAttribute(), getOptionalShapeElement(), getShapeElement(), m_gonioRotateMatrix, m_rotateAllMatrix, Mantid::Kernel::normalize(), parsePosition(), and Mantid::Kernel::V3D::rotate().

Referenced by createShape().

◆ parseInfinitePlane()

std::string Mantid::Geometry::ShapeFactory::parseInfinitePlane ( Poco::XML::Element *  pElem,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
private

Parse XML 'infinite-plane' element.

Parameters
pElem:: XML 'infinite-plane' element from instrument def. file
prim:: To add shapes to
l_id:: When shapes added to the map prim l_id is the continuous incremented index
Returns
A Mantid algebra string for this shape
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 386 of file ShapeFactory.cpp.

References centre, generateMatrix(), getOptionalShapeElement(), getShapeElement(), m_gonioRotateMatrix, m_rotateAllMatrix, Mantid::Kernel::normalize(), parsePosition(), and Mantid::Kernel::V3D::rotate().

Referenced by createShape().

◆ parseMatrixElement()

Kernel::Matrix< double > Mantid::Geometry::ShapeFactory::parseMatrixElement ( Poco::XML::Element *  pElem)
staticprivate

Read a 3x3 matrix held as a11..a33 attributes on an XML element.

Definition at line 1658 of file ShapeFactory.cpp.

References getDoubleAttribute(), and std::to_string().

Referenced by createShape(), and matrixFromXMLTag().

◆ parsePosition()

V3D Mantid::Geometry::ShapeFactory::parsePosition ( Poco::XML::Element *  pElem)
private

Get position coordinates from XML element.

Parameters
pElem:: XML element whose attributes contain position coordinates
Returns
Position coordinates in the form of a V3D object

Definition at line 1435 of file ShapeFactory.cpp.

References Mantid::Kernel::V3D::spherical(), Mantid::Geometry::x, Mantid::Geometry::y, and Mantid::Geometry::z.

Referenced by createGeometryHandler(), createShape(), parseCone(), parseCuboid(), parseCylinder(), parseHexahedron(), parseHollowCylinder(), parseInfiniteCone(), parseInfiniteCylinder(), parseInfinitePlane(), parseSliceOfCylinderRing(), parseSphere(), parseTaperedGuide(), and parseTorus().

◆ parseSliceOfCylinderRing()

std::string Mantid::Geometry::ShapeFactory::parseSliceOfCylinderRing ( Poco::XML::Element *  pElem,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
private

Parse XML 'slice-of-cylinder-ring' element.

Parameters
pElem:: XML 'slice-of-cylinder-ring' element from instrument def. file
prim:: To add shapes to
l_id:: When shapes added to the map prim l_id is the continuous incremented index
Returns
A Mantid algebra string for this shape
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 1264 of file ShapeFactory.cpp.

References Mantid::Geometry::g_log, generateMatrix(), getDoubleAttribute(), getOptionalShapeElement(), getShapeElement(), m_gonioRotateMatrix, m_rotateAllMatrix, parsePosition(), Mantid::Kernel::V3D::rotate(), and Mantid::Kernel::Logger::warning().

Referenced by createShape().

◆ parseSphere()

std::string Mantid::Geometry::ShapeFactory::parseSphere ( Poco::XML::Element *  pElem,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
private

Parse XML 'sphere' element.

Parameters
pElem:: XML 'sphere' element from instrument def. file
prim:: To add shapes to
l_id:: When shapes added to the map prim l_id is the continuous incremented index
Returns
A Mantid algebra string for this shape
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 344 of file ShapeFactory.cpp.

References centre, getDoubleAttribute(), getOptionalShapeElement(), getShapeElement(), m_gonioRotateMatrix, m_rotateAllMatrix, parsePosition(), and sphereAlgebra().

Referenced by createShape().

◆ parseTaperedGuide()

std::string Mantid::Geometry::ShapeFactory::parseTaperedGuide ( Poco::XML::Element *  pElem,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
private

Parse XML 'tapered-guide' element, which is a special case of the XML 'hexahedron' element.

Parameters
pElem:: XML 'hexahedron' element from instrument def. file
prim:: To add shapes to
l_id:: When shapes added to the map prim l_id is the continuous incremented index
Returns
A Mantid algebra string for this shape
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 1132 of file ShapeFactory.cpp.

References centre, generateMatrix(), getDoubleAttribute(), getOptionalShapeElement(), getShapeElement(), Mantid::Geometry::Hexahedron::lbb, Mantid::Geometry::Hexahedron::lbt, Mantid::Geometry::Hexahedron::lfb, Mantid::Geometry::Hexahedron::lft, m_gonioRotateMatrix, m_rotateAllMatrix, Mantid::Kernel::normalize(), parseHexahedronFromStruct(), parsePosition(), Mantid::Geometry::Hexahedron::rbb, Mantid::Geometry::Hexahedron::rbt, Mantid::Geometry::Hexahedron::rfb, Mantid::Geometry::Hexahedron::rft, Mantid::Kernel::Quat::rotate(), and Mantid::Geometry::Hexahedron::rotatePoints().

Referenced by createShape().

◆ parseTorus()

std::string Mantid::Geometry::ShapeFactory::parseTorus ( Poco::XML::Element *  pElem,
std::map< int, std::shared_ptr< Surface > > &  prim,
int &  l_id 
)
private

Parse XML 'torus' element.

Parameters
pElem:: XML 'torus' element from instrument def. file
prim:: To add shapes to
l_id:: When shapes added to the map prim l_id is the continuous incremented index
Returns
A Mantid algebra string for this shape
Exceptions
InstrumentDefinitionErrorThrown if issues with the content of XML instrument file

Definition at line 1224 of file ShapeFactory.cpp.

References getDoubleAttribute(), getShapeElement(), Mantid::Kernel::normalize(), and parsePosition().

Referenced by createShape().

◆ rebakeGoniometer()

std::string Mantid::Geometry::ShapeFactory::rebakeGoniometer ( const Kernel::Matrix< double > &  newBake,
std::string  xml,
const Kernel::Matrix< double > &  currentBake 
)

Rebase the shape so the baked part becomes exactly newBake, preserving the definition-frame rotation.

currentBake is what the shape reports through getAppliedRotation today.

Definition at line 1749 of file ShapeFactory.cpp.

References addAppliedGoniometerTag(), addGoniometerTag(), goniometerFromXML(), and Mantid::Kernel::Matrix< T >::Tprime().

Referenced by Mantid::Geometry::getLabFrameShape().

◆ sphereAlgebra()

std::string Mantid::Geometry::ShapeFactory::sphereAlgebra ( const int  surfaceID)
staticprivate

Create the algebra string for a Sphere.

Parameters
surfaceIDID of surface in map lookup
Returns
A CSG surface algebra string

Definition at line 373 of file ShapeFactory.cpp.

References std::to_string().

Referenced by createSphere(), and parseSphere().

Member Data Documentation

◆ m_gonioRotateMatrix

Kernel::Matrix<double> Mantid::Geometry::ShapeFactory::m_gonioRotateMatrix = Kernel::Matrix<double>(3, 3, 1)
private

◆ m_rotateAllMatrix

Kernel::Matrix<double> Mantid::Geometry::ShapeFactory::m_rotateAllMatrix = Kernel::Matrix<double>(3, 3, 1)
private

The documentation for this class was generated from the following files: