13 #ifndef mitkFloatLookupTablePropertySerializer_h_included 14 #define mitkFloatLookupTablePropertySerializer_h_included 23 class FloatLookupTablePropertySerializer :
public BasePropertySerializer
26 mitkClassMacro(FloatLookupTablePropertySerializer, BasePropertySerializer);
27 itkFactorylessNewMacro(Self) itkCloneMacro(Self)
29 TiXmlElement *Serialize()
override 31 const FloatLookupTableProperty *prop =
dynamic_cast<const FloatLookupTableProperty *
>(m_Property.GetPointer());
35 LocaleSwitch localeSwitch(
"C");
37 FloatLookupTable lut = prop->GetValue();
42 auto element =
new TiXmlElement(
"FloatLookupTableTable");
43 for (
auto it = map.begin(); it != map.end(); ++it)
45 auto tableEntry =
new TiXmlElement(
"LUTValue");
46 tableEntry->SetAttribute(
"id", it->first);
47 tableEntry->SetAttribute(
"value", boost::lexical_cast<std::string>(it->second));
48 element->LinkEndChild(tableEntry);
58 LocaleSwitch localeSwitch(
"C");
61 for (TiXmlElement *child = element->FirstChildElement(
"LUTValue"); child !=
nullptr;
62 child = child->NextSiblingElement(
"LUTValue"))
65 if (child->QueryIntAttribute(
"id", &tempID) != TIXML_SUCCESS)
68 std::string value_string;
69 if (child->QueryStringAttribute(
"value", &value_string) != TIXML_SUCCESS)
73 lut.SetTableValue(
id, boost::lexical_cast<float>(value_string));
75 catch (boost::bad_lexical_cast &e)
77 MITK_ERROR <<
"Could not parse string as number: " << e.what();
85 FloatLookupTablePropertySerializer() {}
86 ~FloatLookupTablePropertySerializer()
override {}
std::map< IdentifierType, ValueType > LookupTableType
MITK_REGISTER_SERIALIZER(FloatLookupTablePropertySerializer)
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< Self > Pointer
unsigned int IdentifierType
#define mitkClassMacro(className, SuperClassName)