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