-
Notifications
You must be signed in to change notification settings - Fork 122
/
vtkDataSetToWsLocation.cpp
65 lines (59 loc) · 1.94 KB
/
vtkDataSetToWsLocation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "MantidVatesAPI/vtkDataSetToWsLocation.h"
#include "MantidVatesAPI/FieldDataToMetadata.h"
#include "MantidVatesAPI/VatesXMLDefinitions.h"
#include "MantidGeometry/MDGeometry/MDGeometryXMLDefinitions.h"
#include <vtkDataSet.h>
#include <Poco/DOM/DOMParser.h>
#include <Poco/DOM/Element.h>
#include <Poco/DOM/Document.h>
#include <Poco/AutoPtr.h>
namespace Mantid
{
namespace VATES
{
/**
Static creational method to run functionality in one method call.
@param dataset : input dataset containing field data.
@return location string.
*/
std::string vtkDataSetToWsLocation::exec(vtkDataSet* dataset)
{
vtkDataSetToWsLocation temp(dataset);
return temp.execute();
}
/**
Constructor
@param dataSet : input dataset containing field data.
*/
vtkDataSetToWsLocation::vtkDataSetToWsLocation(vtkDataSet* dataSet) : m_dataset(dataSet)
{
if(m_dataset == NULL)
{
throw std::runtime_error("Tried to construct vtkDataSetToWsLocation with NULL vtkDataSet");
}
}
/**
Execution method to run the extraction.
@return location string
*/
std::string vtkDataSetToWsLocation::execute()
{
using Mantid::Geometry::MDGeometryXMLDefinitions;
FieldDataToMetadata convert;
std::string xmlString = convert(m_dataset->GetFieldData(), XMLDefinitions::metaDataId());
Poco::XML::DOMParser pParser;
Poco::AutoPtr<Poco::XML::Document> pDoc = pParser.parseString(xmlString);
Poco::XML::Element* pRootElem = pDoc->documentElement();
Poco::XML::Element* wsLocationElem = pRootElem->getChildElement(MDGeometryXMLDefinitions::workspaceLocationElementName());
if(wsLocationElem == NULL)
{
throw std::runtime_error("The element containing the workspace location must be present.");
}
return wsLocationElem->innerText();
}
/// Destructor
vtkDataSetToWsLocation::~vtkDataSetToWsLocation()
{
}
}
}