Mantid
|
Read an XML definition of a SampleEnvironmentSpec and produce a new SampleEnvironmentSpec object. More...
#include <SampleEnvironmentSpecParser.h>
Public Member Functions | |
SampleEnvironmentSpec_uptr | parse (const std::string &name, const std::string &filename, std::istream &istr) |
Takes a stream that is assumed to contain a single complete SampleEnvironmentSpec definition, reads the definition and produces a new SampleEnvironmentSpec object. More... | |
SampleEnvironmentSpec_uptr | parse (const std::string &name, Poco::XML::Element *element) |
Takes a pointer to an XML node that is assumed to point at a "environmentspec" tag. More... | |
Static Public Attributes | |
static constexpr const char * | ROOT_TAG = "environmentspec" |
Private Types | |
using | MaterialsIndex = std::unordered_map< std::string, Kernel::Material > |
Private Member Functions | |
std::string | findFile (const std::string &filename) const |
void | loadFullSpecification (SampleEnvironmentSpec *spec, Poco::XML::Element *element) |
std::shared_ptr< Geometry::MeshObject > | loadMeshFromSTL (Poco::XML::Element *stlFileElement) const |
Create a mesh shape from an STL input file. More... | |
void | LoadOptionalDoubleFromXML (Poco::XML::Element *componentElement, const std::string &elementName, double &targetVariable) const |
Load a double from an optional XML element. More... | |
void | parseAndAddComponents (SampleEnvironmentSpec *spec, Poco::XML::Element *element) const |
Take a <components> tag, parse the definitions and add them to the spec. More... | |
void | parseAndAddContainers (SampleEnvironmentSpec *spec, Poco::XML::Element *element) const |
Take a <containers> tag, parse the definitions and add them to the spec. More... | |
std::shared_ptr< Geometry::IObject > | parseComponent (Poco::XML::Element *element) const |
Parse a single definition of a component. More... | |
Geometry::Container_const_sptr | parseContainer (Poco::XML::Element *element) const |
Parse a single definition of a Can. More... | |
void | parseMaterials (Poco::XML::Element *element) |
Parse the set of materials in the document. More... | |
std::vector< double > | parseTranslationVector (const std::string &translationVectorStr) const |
Take a comma separated translation vector and return it as a std::vector. More... | |
void | validateRootElement (Poco::XML::Element *element) const |
Validate that the element points to the expected root element. More... | |
Private Attributes | |
std::string | m_filepath |
MaterialsIndex | m_materials |
Read an XML definition of a SampleEnvironmentSpec and produce a new SampleEnvironmentSpec object.
Definition at line 29 of file SampleEnvironmentSpecParser.h.
|
private |
Definition at line 39 of file SampleEnvironmentSpecParser.h.
|
private |
Definition at line 338 of file SampleEnvironmentSpecParser.cpp.
References Mantid::DataHandling::exists(), Mantid::Kernel::SingletonHolder< T >::Instance(), and m_filepath.
Referenced by loadFullSpecification(), and loadMeshFromSTL().
|
private |
Definition at line 204 of file SampleEnvironmentSpecParser.cpp.
References Mantid::DataHandling::SampleEnvironmentSpec::addComponent(), Mantid::DataHandling::SampleEnvironmentSpec::addContainer(), findFile(), Mantid::DataHandling::Mantid3MFFileIO::LoadFile(), Mantid::DataHandling::SampleEnvironmentSpec::ncans(), and Mantid::DataHandling::Mantid3MFFileIO::readMeshObjects().
Referenced by parse().
|
private |
Create a mesh shape from an STL input file.
This can't be in the ShapeFactory because that is in Geometry. This function needs acccess to the STL readers
stlFileElement | A pointer to an XML <stlfile> element |
Definition at line 373 of file SampleEnvironmentSpecParser.cpp.
References Mantid::DataHandling::LoadStlFactory::createReader(), Mantid::DataHandling::exists(), findFile(), Mantid::DataHandling::getScaleTypeFromStr(), LoadOptionalDoubleFromXML(), parseTranslationVector(), and rotation.
Referenced by parseComponent(), and parseContainer().
|
private |
Load a double from an optional XML element.
componentElement | XML element |
attributeName | Attribute that double should be loaded from |
targetVariable | Value read from element attribute |
Definition at line 303 of file SampleEnvironmentSpecParser.cpp.
Referenced by loadMeshFromSTL().
SampleEnvironmentSpec_uptr Mantid::DataHandling::SampleEnvironmentSpecParser::parse | ( | const std::string & | name, |
const std::string & | filename, | ||
std::istream & | istr | ||
) |
Takes a stream that is assumed to contain a single complete SampleEnvironmentSpec definition, reads the definition and produces a new SampleEnvironmentSpec object.
name | The name of the environment |
filename | Optional file name for .xml spec file |
istr | A reference to a stream |
Definition at line 84 of file SampleEnvironmentSpecParser.cpp.
References m_filepath, and parse().
Referenced by parse(), and Mantid::DataHandling::SampleEnvironmentSpecFileFinder::parseSpec().
SampleEnvironmentSpec_uptr Mantid::DataHandling::SampleEnvironmentSpecParser::parse | ( | const std::string & | name, |
Poco::XML::Element * | element | ||
) |
Takes a pointer to an XML node that is assumed to point at a "environmentspec" tag.
It reads the definition and produces a new SampleEnvironmentSpec object.
name | The name of the environment |
element | A pointer to an Element node that is a "environmentspec" tag |
Definition at line 114 of file SampleEnvironmentSpecParser.cpp.
References loadFullSpecification(), parseAndAddComponents(), parseMaterials(), and validateRootElement().
|
private |
Take a <components> tag, parse the definitions and add them to the spec.
It requires the materials to have been parsed
spec | A pointer to a SampleEnvironmentSpec to update |
element | A pointer to a components element |
Definition at line 180 of file SampleEnvironmentSpecParser.cpp.
References Mantid::DataHandling::SampleEnvironmentSpec::addComponent(), m_materials, parseAndAddContainers(), and parseComponent().
Referenced by parse().
|
private |
Take a <containers> tag, parse the definitions and add them to the spec.
It requires the materials to have been parsed.
spec | A pointer to a SampleEnvironmentSpec to update |
element | A pointer to a cans element |
Definition at line 255 of file SampleEnvironmentSpecParser.cpp.
References Mantid::DataHandling::SampleEnvironmentSpec::addContainer(), and parseContainer().
Referenced by parseAndAddComponents().
|
private |
Parse a single definition of a component.
If the component is a can the sample geometry, if available, is also parsed.
element | A pointer to an XML <container> element |
Definition at line 425 of file SampleEnvironmentSpecParser.cpp.
References Mantid::Geometry::ShapeFactory::createShape(), loadMeshFromSTL(), and m_materials.
Referenced by parseAndAddComponents(), and parseContainer().
|
private |
Parse a single definition of a Can.
element | A pointer to an XML <container> element |
Definition at line 273 of file SampleEnvironmentSpecParser.cpp.
References loadMeshFromSTL(), and parseComponent().
Referenced by parseAndAddContainers().
|
private |
Parse the set of materials in the document.
element | A pointer to the materials tag |
Definition at line 157 of file SampleEnvironmentSpecParser.cpp.
References m_filepath, m_materials, and Mantid::Kernel::MaterialXMLParser::parse().
Referenced by parse().
|
private |
Take a comma separated translation vector and return it as a std::vector.
translationVectorStr | Translation vector string |
Definition at line 322 of file SampleEnvironmentSpecParser.cpp.
References Mantid::Kernel::StringTokenizer::cbegin(), Mantid::Kernel::StringTokenizer::cend(), Mantid::Kernel::StringTokenizer::count(), Mantid::Kernel::StringTokenizer::TOK_IGNORE_EMPTY, and Mantid::Kernel::StringTokenizer::TOK_TRIM.
Referenced by loadMeshFromSTL().
|
private |
Validate that the element points to the expected root element.
element | A pointer to the root element |
Definition at line 143 of file SampleEnvironmentSpecParser.cpp.
References ROOT_TAG.
Referenced by parse().
|
private |
Definition at line 56 of file SampleEnvironmentSpecParser.h.
Referenced by findFile(), parse(), and parseMaterials().
|
private |
Definition at line 55 of file SampleEnvironmentSpecParser.h.
Referenced by parseAndAddComponents(), parseComponent(), and parseMaterials().
|
staticconstexpr |
Definition at line 31 of file SampleEnvironmentSpecParser.h.
Referenced by validateRootElement().