7#include <Poco/DOM/AutoPtr.h>
8#include <Poco/DOM/DOMParser.h>
9#include <Poco/DOM/Document.h>
10#include <Poco/DOM/Element.h>
11#include <Poco/DOM/NodeFilter.h>
12#include <Poco/DOM/NodeIterator.h>
13#include <Poco/Exception.h>
14#include <Poco/SAX/InputSource.h>
24using Poco::XML::DOMParser;
25using Poco::XML::Element;
30Kernel::Logger
g_log(
"vtkGeometryCacheReader");
66 std::stringstream objName;
67 objName <<
obj->getName();
71 g_log.
debug(
"Cache not found for Object with name " + objName.str());
75 int noOfTriangles = 0, noOfPoints = 0;
76 std::vector<double> Points;
77 std::vector<uint32_t> Faces;
78 std::stringstream buff;
80 buff << pEle->getAttribute(
"NumberOfPoints");
84 buff << pEle->getAttribute(
"NumberOfPolys");
85 buff >> noOfTriangles;
89 Element *pPts = pEle->getChildElement(
"Points")->getChildElement(
"DataArray");
93 Element *pTris = pEle->getChildElement(
"Polys")->getChildElement(
"DataArray");
97 std::shared_ptr<GeometryHandler> handle =
obj->getGeometryHandler();
98 handle->setGeometryCache(noOfPoints, noOfTriangles, std::move(Points), std::move(Faces));
105 Element *pRoot =
m_doc->documentElement();
106 if (pRoot ==
nullptr || pRoot->nodeName() !=
"VTKFile")
108 Element *pPolyData = pRoot->getChildElement(
"PolyData");
109 if (pPolyData ==
nullptr)
111 return pPolyData->getElementById(name,
"name");
118 if (pEle ==
nullptr) {
122 points.resize(noOfPoints * 3);
123 if (points.size() !=
static_cast<size_t>(noOfPoints * 3))
125 g_log.
error(
"Cannot allocate memory for triangle cache of Object ");
128 if (pEle->getAttribute(
"format") ==
"ascii") {
129 std::stringstream buf;
130 buf << pEle->innerText();
131 for (
double &point : points) {
142 if (pEle ==
nullptr) {
146 faces.resize(noOfTriangles * 3);
147 if (faces.size() !=
static_cast<size_t>(noOfTriangles * 3))
149 g_log.
error(
"Cannot allocate memory for triangle cache of Object ");
152 if (pEle->getAttribute(
"format") ==
"ascii") {
153 std::stringstream buf;
154 buf << pEle->innerText();
155 for (
unsigned int &face : faces) {
double obj
the value of the quadratic function
IObject : Interface for geometry objects.
Poco::XML::DOMParser * m_pParser
The XML parser.
void readTriangles(Poco::XML::Element *pEle, int noOfTriangles, std::vector< uint32_t > &faces)
Read triangle face indexs.
void readPoints(Poco::XML::Element *pEle, int noOfPoints, std::vector< double > &points)
Read the points from the element.
~vtkGeometryCacheReader()
Destructor.
Poco::XML::Document * m_doc
The XML document.
std::string m_filename
The file name.
Poco::XML::Element * getElementByObjectName(const std::string &name)
Get the Element by using the object name.
void Init()
Initialise Reading of the cached file.
vtkGeometryCacheReader(std::string filename)
Constructor.
void readCacheForObject(IObject *obj)
Set the geometry for the object.
Records the filename and the description of failure.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
Mantid::Kernel::Logger g_log("Goniometer")