15#include <Poco/AutoPtr.h>
16#include <Poco/DOM/DOMParser.h>
17#include <Poco/DOM/Document.h>
18#include <Poco/DOM/Element.h>
19#include <Poco/DOM/NodeList.h>
40 throw std::runtime_error(
"Attempting to get dimension information from "
41 "MDGeometryXMLParser, before calling ::execute()");
49 Poco::XML::DOMParser pParser;
50 Poco::AutoPtr<Poco::XML::Document> pDoc = pParser.parseString(
m_xmlToProcess);
51 Poco::XML::Element *pRootElem = pDoc->documentElement();
53 Poco::XML::Element *geometryXMLElement =
nullptr;
55 Poco::XML::Element *temp = pRootElem->getChildElement(
m_rootNodeName);
56 geometryXMLElement = temp;
57 if (geometryXMLElement ==
nullptr) {
58 std::string message =
"Root node was not found to be the expected value of " +
m_rootNodeName;
59 throw std::runtime_error(message);
63 geometryXMLElement = pRootElem;
66 Poco::AutoPtr<Poco::XML::NodeList> dimensionsXML =
68 size_t nDimensions = dimensionsXML->length();
72 for (
size_t i = 0; i < nDimensions; i++) {
73 auto *dimensionXML =
static_cast<Poco::XML::Element *
>(dimensionsXML->item(
static_cast<unsigned long>(i)));
77 Poco::XML::Element *xDimensionElement =
81 if (!xDimId.empty()) {
82 auto xDimensionIt = find_if(vecAllDims.begin(), vecAllDims.end(),
findID(xDimId));
83 if (xDimensionIt == vecAllDims.end()) {
84 throw std::invalid_argument(
"Cannot determine x-dimension mapping.");
87 vecNonMappedDims.erase(std::remove_if(vecNonMappedDims.begin(), vecNonMappedDims.end(),
findID(xDimId)),
88 vecNonMappedDims.end());
91 Poco::XML::Element *yDimensionElement =
96 if (!yDimId.empty()) {
97 auto yDimensionIt = find_if(vecAllDims.begin(), vecAllDims.end(),
findID(yDimId));
98 if (yDimensionIt == vecAllDims.end()) {
99 throw std::invalid_argument(
"Cannot determine y-dimension mapping.");
102 vecNonMappedDims.erase(std::remove_if(vecNonMappedDims.begin(), vecNonMappedDims.end(),
findID(yDimId)),
103 vecNonMappedDims.end());
106 Poco::XML::Element *zDimensionElement =
111 if (!zDimId.empty()) {
112 auto zDimensionIt = find_if(vecAllDims.begin(), vecAllDims.end(),
findID(zDimId));
113 if (zDimensionIt == vecAllDims.end()) {
114 throw std::invalid_argument(
"Cannot determine z-dimension mapping.");
117 vecNonMappedDims.erase(std::remove_if(vecNonMappedDims.begin(), vecNonMappedDims.end(),
findID(zDimId)),
118 vecNonMappedDims.end());
121 Poco::XML::Element *tDimensionElement =
125 if (!tDimId.empty()) {
126 auto tDimensionIt = find_if(vecAllDims.begin(), vecAllDims.end(),
findID(tDimId));
127 if (tDimensionIt == vecAllDims.end()) {
128 throw std::invalid_argument(
"Cannot determine t-dimension mapping.");
131 if (!vecNonMappedDims.empty()) {
132 vecNonMappedDims.erase(std::remove_if(vecNonMappedDims.begin(), vecNonMappedDims.end(),
findID(tDimId)),
133 vecNonMappedDims.end());
146 : m_executed(false), m_xmlToProcess(
std::move(xmlToProcess)) {}
205 temp.erase(std::remove_if(temp.begin(), temp.end(),
findIntegrated()), temp.end());
216 temp.erase(std::remove_if(temp.begin(), temp.end(), std::not_fn(
findIntegrated())), temp.end());
277 if (
this != &other) {
295 : m_executed(other.m_executed), m_rootNodeName(other.m_rootNodeName), m_vecNonMappedDims(other.m_vecNonMappedDims),
296 m_vecAllDims(other.m_vecAllDims), m_xDimension(other.m_xDimension), m_yDimension(other.m_yDimension),
297 m_zDimension(other.m_zDimension), m_tDimension(other.m_tDimension) {}
306 bool bResult =
false;
308 if (candidate->getDimensionId() ==
m_xDimension->getDimensionId()) {
322 bool bResult =
false;
324 if (candidate->getDimensionId() ==
m_yDimension->getDimensionId()) {
338 bool bResult =
false;
340 if (candidate->getDimensionId() ==
m_zDimension->getDimensionId()) {
354 bool bResult =
false;
356 if (candidate->getDimensionId() ==
m_tDimension->getDimensionId()) {
double obj
the value of the quadratic function
static const std::string workspaceXDimensionElementName()
static const std::string workspaceYDimensionElementName()
static const std::string workspaceTDimensionElementName()
static const std::string workspaceDimensionElementName()
static const std::string workspaceRefDimensionElementName()
static const std::string workspaceZDimensionElementName()
Handles the extraction of dimensions from a xml xml string to determine how mappings have been formed...
Mantid::Geometry::VecIMDDimension_sptr m_vecAllDims
void validate() const
Validate the current object.
MDGeometryXMLParser()
Constructor.
Mantid::Geometry::IMDDimension_sptr getZDimension() const
Getter for z dimension.
bool hasYDimension() const
Determine wheter y dimension is present.
MDGeometryXMLParser & operator=(const MDGeometryXMLParser &)
Assignement operator.
bool isZDimension(const Mantid::Geometry::IMDDimension_sptr &) const
Determines whether query dimension is the z dimension.
Mantid::Geometry::IMDDimension_sptr getTDimension() const
Getter for t dimension.
void SetRootNodeCheck(std::string elementName)
Setter for the root element.
Mantid::Geometry::VecIMDDimension_sptr getNonMappedDimensions() const
Getter for all those dimensions which are not mapped.
Mantid::Geometry::IMDDimension_sptr getXDimension() const
Getter for x dimension.
std::string m_xmlToProcess
bool hasZDimension() const
Determine wheter z dimension is present.
bool isTDimension(const Mantid::Geometry::IMDDimension_sptr &) const
Determines whether query dimension is the t dimension.
Mantid::Geometry::IMDDimension_sptr m_yDimension
virtual void execute()
Peforms the processing associated with these transformations.
Mantid::Geometry::IMDDimension_sptr m_tDimension
Mantid::Geometry::IMDDimension_sptr m_zDimension
Mantid::Geometry::VecIMDDimension_sptr getNonIntegratedDimensions() const
Getter for all those dimensions which are not integrated.
bool hasTDimension() const
Determine wheter t dimension is present.
bool isXDimension(const Mantid::Geometry::IMDDimension_sptr &) const
Determines whether query dimension is the x dimension.
bool hasXDimension() const
Determine wheter x dimension is present.
Mantid::Geometry::VecIMDDimension_sptr getAllDimensions() const
Getter for all dimensions parsed.
Mantid::Geometry::VecIMDDimension_sptr m_vecNonMappedDims
Mantid::Geometry::IMDDimension_sptr getYDimension() const
Getter for y dimension.
std::string m_rootNodeName
Mantid::Geometry::VecIMDDimension_sptr getIntegratedDimensions() const
Getter for all those dimensions which are integrated.
Mantid::Geometry::IMDDimension_sptr m_xDimension
bool isYDimension(const Mantid::Geometry::IMDDimension_sptr &) const
Determines whether query dimension is the y dimension.
MANTID_GEOMETRY_DLL IMDDimension_sptr createDimension(const std::string &dimensionXMLString)
Creates IMDDimension objects based on input XML.
std::shared_ptr< IMDDimension > IMDDimension_sptr
Shared Pointer for IMDDimension. Frequently used type in framework.
std::vector< IMDDimension_sptr > VecIMDDimension_sptr
Vector of shared pointers to IMDDimensions.
Helper unary comparison type for finding IMDDimensions by a specified id.
bool operator()(const Mantid::Geometry::IMDDimension_sptr &obj) const
Helper unary comparison type for finding non-integrated dimensions.
bool operator()(const Mantid::Geometry::IMDDimension_sptr &obj) const