-
Notifications
You must be signed in to change notification settings - Fork 122
/
vtkDataSetToImplicitFunction.cpp
69 lines (63 loc) · 2.29 KB
/
vtkDataSetToImplicitFunction.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
66
67
68
69
#include "MantidVatesAPI/vtkDataSetToImplicitFunction.h"
#include "MantidVatesAPI/FieldDataToMetadata.h"
#include "MantidVatesAPI/VatesXMLDefinitions.h"
#include "MantidGeometry/MDGeometry/MDGeometryXMLDefinitions.h"
#include "MantidAPI/ImplicitFunctionFactory.h"
#include "MantidGeometry/MDGeometry/NullImplicitFunction.h"
#include <vtkDataSet.h>
namespace Mantid
{
namespace VATES
{
/**
Static creational method to run functionality in one method call.
@param dataSet : input dataset containing field data.
@return extracted implicit function.
*/
Mantid::Geometry::MDImplicitFunction* vtkDataSetToImplicitFunction::exec(vtkDataSet* dataSet)
{
vtkDataSetToImplicitFunction temp(dataSet);
return temp.execute();
}
/**
Constructor
@param dataSet : input dataset containing field data.
*/
vtkDataSetToImplicitFunction::vtkDataSetToImplicitFunction(vtkDataSet* dataSet) : m_dataset(dataSet)
{
if(m_dataset == NULL)
{
throw std::runtime_error("Tried to construct vtkDataSetToImplicitFunction with NULL vtkDataSet");
}
}
/**
Execution method to run the extraction.
@return implicit function if one could be found, or a NullImplicitFunction.
*/
Mantid::Geometry::MDImplicitFunction* vtkDataSetToImplicitFunction::execute()
{
using Mantid::Geometry::NullImplicitFunction;
using Mantid::Geometry::MDGeometryXMLDefinitions;
Mantid::Geometry::MDImplicitFunction* function = new NullImplicitFunction;
FieldDataToMetadata convert;
std::string xmlString = convert(m_dataset->GetFieldData(), XMLDefinitions::metaDataId());
if (false == xmlString.empty())
{
Poco::XML::DOMParser pParser;
Poco::AutoPtr<Poco::XML::Document> pDoc = pParser.parseString(xmlString);
Poco::XML::Element* pRootElem = pDoc->documentElement();
Poco::XML::Element* functionElem = pRootElem->getChildElement(MDGeometryXMLDefinitions::functionElementName());
if(NULL != functionElem)
{
delete function;
function = Mantid::API::ImplicitFunctionFactory::Instance().createUnwrapped(functionElem);
}
}
return function;
}
/// Destructor.
vtkDataSetToImplicitFunction::~vtkDataSetToImplicitFunction()
{
}
}
}