13 #ifndef mitkPoint4dPropertySerializer_h_included 14 #define mitkPoint4dPropertySerializer_h_included 23 class Point4dPropertySerializer :
public BasePropertySerializer
27 itkFactorylessNewMacro(Self) itkCloneMacro(Self)
29 TiXmlElement *Serialize()
override 31 if (
const Point4dProperty *prop = dynamic_cast<const Point4dProperty *>(m_Property.GetPointer()))
33 LocaleSwitch localeSwitch(
"C");
35 auto element =
new TiXmlElement(
"point");
36 Point4D 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]));
40 element->SetAttribute(
"t", boost::lexical_cast<std::string>(point[3]));
52 LocaleSwitch localeSwitch(
"C");
55 if (element->QueryStringAttribute(
"x", &v_str[0]) != TIXML_SUCCESS)
57 if (element->QueryStringAttribute(
"y", &v_str[1]) != TIXML_SUCCESS)
59 if (element->QueryStringAttribute(
"z", &v_str[2]) != TIXML_SUCCESS)
61 if (element->QueryStringAttribute(
"t", &v_str[3]) != TIXML_SUCCESS)
66 StringsToNumbers<double>(4, v_str, v);
68 catch (boost::bad_lexical_cast &e)
70 MITK_ERROR <<
"Could not parse string as number: " << e.what();
77 Point4dPropertySerializer() {}
78 ~Point4dPropertySerializer()
override {}
MITK_REGISTER_SERIALIZER(Point4dPropertySerializer)
Point< ScalarType, 4 > Point4D
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< Self > Pointer
#define mitkClassMacro(className, SuperClassName)