13 #ifndef mitkPoint3dPropertySerializer_h_included 14 #define mitkPoint3dPropertySerializer_h_included 23 class Point3dPropertySerializer :
public BasePropertySerializer
27 itkFactorylessNewMacro(Self) itkCloneMacro(Self)
29 TiXmlElement *Serialize()
override 31 if (
const Point3dProperty *prop = dynamic_cast<const Point3dProperty *>(m_Property.GetPointer()))
33 LocaleSwitch localeSwitch(
"C");
35 auto element =
new TiXmlElement(
"point");
36 Point3D point = prop->GetValue();
37 element->SetAttribute(
"x", boost::lexical_cast<std::string>(point[0]));
38 element->SetAttribute(
"y", boost::lexical_cast<std::string>(point[1]));
39 element->SetAttribute(
"z", boost::lexical_cast<std::string>(point[2]));
51 LocaleSwitch localeSwitch(
"C");
54 if (element->QueryStringAttribute(
"x", &v_str[0]) != TIXML_SUCCESS)
56 if (element->QueryStringAttribute(
"y", &v_str[1]) != TIXML_SUCCESS)
58 if (element->QueryStringAttribute(
"z", &v_str[2]) != TIXML_SUCCESS)
63 StringsToNumbers<double>(3, v_str, v);
65 catch (boost::bad_lexical_cast &e)
67 MITK_ERROR <<
"Could not parse string as number: " << e.what();
74 Point3dPropertySerializer() {}
75 ~Point3dPropertySerializer()
override {}
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< Self > Pointer
#define mitkClassMacro(className, SuperClassName)
Point< ScalarType, 3 > Point3D
MITK_REGISTER_SERIALIZER(Point3dPropertySerializer)