12#include <Poco/DOM/AutoPtr.h>
13#include <Poco/DOM/DOMWriter.h>
14#include <Poco/DOM/Document.h>
15#include <Poco/DOM/Element.h>
16#include <Poco/DOM/Text.h>
17#include <boost/algorithm/string.hpp>
18#include <boost/format.hpp>
34 for (std::size_t i = 0; i < nd; i++) {
50 for (std::size_t i = 0; i < nd; i++) {
63 throw std::runtime_error(
"Only one plane per MDPlaneImplicitFunction.");
74 AutoPtr<Document> pDoc =
new Document;
75 AutoPtr<Element> functionElement = pDoc->createElement(
"Function");
76 pDoc->appendChild(functionElement);
77 AutoPtr<Element> typeElement = pDoc->createElement(
"Type");
78 AutoPtr<Text> typeText = pDoc->createTextNode(this->
getName());
79 typeElement->appendChild(typeText);
80 functionElement->appendChild(typeElement);
82 AutoPtr<Element> parameterListElement = pDoc->createElement(
"ParameterList");
83 functionElement->appendChild(parameterListElement);
86 AutoPtr<Element> normParameterElement = pDoc->createElement(
"Parameter");
87 parameterListElement->appendChild(normParameterElement);
88 AutoPtr<Element> normTypeElement = pDoc->createElement(
"Type");
89 AutoPtr<Text> normText = pDoc->createTextNode(
"NormalParameter");
90 normTypeElement->appendChild(normText);
91 normParameterElement->appendChild(normTypeElement);
92 AutoPtr<Element> normValueElement = pDoc->createElement(
"Value");
94 AutoPtr<Text> normValueText = pDoc->createTextNode(this->
coordValue(norm));
95 normValueElement->appendChild(normValueText);
96 normParameterElement->appendChild(normValueElement);
99 AutoPtr<Element> origParameterElement = pDoc->createElement(
"Parameter");
100 parameterListElement->appendChild(origParameterElement);
101 AutoPtr<Element> origTypeElement = pDoc->createElement(
"Type");
102 AutoPtr<Text> origText = pDoc->createTextNode(
"OriginParameter");
103 origTypeElement->appendChild(origText);
104 origParameterElement->appendChild(origTypeElement);
105 AutoPtr<Element> origValueElement = pDoc->createElement(
"Value");
106 origParameterElement->appendChild(origValueElement);
107 AutoPtr<Text> origValueText = pDoc->createTextNode(this->
coordValue(this->
origin.data()));
108 origValueElement->appendChild(origValueText);
109 origParameterElement->appendChild(origValueElement);
111 std::stringstream xmlstream;
113 writer.writeNode(xmlstream, pDoc);
115 std::string formattedXMLString = boost::str(boost::format(xmlstream.str().c_str()));
116 return formattedXMLString;
126 std::ostringstream valueStream;
128 for (std::size_t i = 0; i < nd - 1; i++) {
129 valueStream << arr[i] <<
" ";
131 valueStream << arr[nd - 1];
132 return valueStream.str();
An "ImplicitFunction" defining a hyper-cuboid-shaped region in N dimensions.
size_t getNumDims() const
void addPlane(const MDPlane &plane)
Add a bounded plane to this implicit function.
size_t getNumPlanes() const
const MDPlane & getPlane(size_t index) const
MDPlaneImplicitFunction()
Default constructor.
std::string coordValue(const coord_t *arr) const
Create string for coordinate values.
std::vector< coord_t > origin
The origin point of the implicit plane.
void checkOrigin()
Set defaults to origin if not used.
std::string getName() const override
std::string toXMLString() const override
void addPlane(const MDPlane &plane)
Overriding the addPlane for check.
A generalized description of a N-dimensional hyperplane.
const coord_t * getNormal() const
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...