13 #ifndef mitkVector3DPropertySerializer_h_included 14 #define mitkVector3DPropertySerializer_h_included 23 class Vector3DPropertySerializer :
public BasePropertySerializer
26 mitkClassMacro(Vector3DPropertySerializer, BasePropertySerializer);
27 itkFactorylessNewMacro(Self) itkCloneMacro(Self)
29 TiXmlElement *Serialize()
override 31 if (
const Vector3DProperty *prop = dynamic_cast<const Vector3DProperty *>(m_Property.GetPointer()))
33 LocaleSwitch localeSwitch(
"C");
35 auto element =
new TiXmlElement(
"vector");
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 '" << v_str <<
"'as number: " << e.what();
75 Vector3DPropertySerializer() {}
76 ~Vector3DPropertySerializer()
override {}
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< Self > Pointer
Vector< ScalarType, 3 > Vector3D
#define mitkClassMacro(className, SuperClassName)
MITK_REGISTER_SERIALIZER(Vector3DPropertySerializer)