17 #ifndef mitkPoint3dPropertySerializer_h_included
18 #define mitkPoint3dPropertySerializer_h_included
27 class Point3dPropertySerializer :
public BasePropertySerializer
31 itkFactorylessNewMacro(Self) itkCloneMacro(Self)
33 virtual TiXmlElement *Serialize()
override
35 if (
const Point3dProperty *prop = dynamic_cast<const Point3dProperty *>(m_Property.GetPointer()))
37 LocaleSwitch localeSwitch(
"C");
39 auto element =
new TiXmlElement(
"point");
40 Point3D point = prop->GetValue();
41 element->SetAttribute(
"x", boost::lexical_cast<std::string>(point[0]));
42 element->SetAttribute(
"y", boost::lexical_cast<std::string>(point[1]));
43 element->SetAttribute(
"z", boost::lexical_cast<std::string>(point[2]));
55 LocaleSwitch localeSwitch(
"C");
58 if (element->QueryStringAttribute(
"x", &v_str[0]) != TIXML_SUCCESS)
60 if (element->QueryStringAttribute(
"y", &v_str[1]) != TIXML_SUCCESS)
62 if (element->QueryStringAttribute(
"z", &v_str[2]) != TIXML_SUCCESS)
67 StringsToNumbers<double>(3, v_str, v);
69 catch (boost::bad_lexical_cast &e)
71 MITK_ERROR <<
"Could not parse string as number: " << e.what();
78 Point3dPropertySerializer() {}
79 virtual ~Point3dPropertySerializer() {}
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< Self > Pointer
#define mitkClassMacro(className, SuperClassName)
Point< ScalarType, 3 > Point3D
MITK_REGISTER_SERIALIZER(Point3dPropertySerializer)