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