Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::TransferFunctionPropertySerializer Class Reference

Serializer for mitk::TransferFunctionProperty. More...

#include <mitkTransferFunctionPropertySerializer.h>

Inheritance diagram for mitk::TransferFunctionPropertySerializer:
Collaboration diagram for mitk::TransferFunctionPropertySerializer:

Public Member Functions

 mitkClassMacro (TransferFunctionPropertySerializer, BasePropertySerializer)
 
Pointer Clone () const
 
tinyxml2::XMLElement * Serialize (tinyxml2::XMLDocument &doc) override
 Serializes the TransferFunctionProperty into an XML element. More...
 
BaseProperty::Pointer Deserialize (const tinyxml2::XMLElement *element) override
 Deserializes an XML element back into a TransferFunctionProperty. More...
 
- Public Member Functions inherited from mitk::BasePropertySerializer
 mitkClassMacroItkParent (BasePropertySerializer, itk::Object)
 
virtual void SetProperty (const BaseProperty *_arg)
 Sets the property to be serialized. More...
 

Static Public Member Functions

static Pointer New ()
 
static bool SerializeTransferFunction (const char *filename, TransferFunction::Pointer tf)
 Serializes a TransferFunction to an XML file. More...
 
static TransferFunction::Pointer DeserializeTransferFunction (const char *filePath)
 Deserializes a TransferFunction from an XML file. More...
 

Protected Member Functions

 TransferFunctionPropertySerializer ()
 
 ~TransferFunctionPropertySerializer () override
 
- Protected Member Functions inherited from mitk::BasePropertySerializer
 BasePropertySerializer ()
 
 ~BasePropertySerializer () override
 

Additional Inherited Members

- Protected Attributes inherited from mitk::BasePropertySerializer
BaseProperty::ConstPointer m_Property
 

Detailed Description

Serializer for mitk::TransferFunctionProperty.

Serializes and deserializes a TransferFunctionProperty to and from an XML representation. The XML structure contains three sub-elements:

  • ScalarOpacity: piecewise function for scalar opacity mapping
  • GradientOpacity: piecewise function for gradient opacity mapping
  • Color: color transfer function with RGB values, midpoints, and sharpness

Additionally provides static convenience methods for serializing/deserializing transfer functions directly to/from files.

See also
BasePropertySerializer, TransferFunctionProperty, TransferFunction

Definition at line 35 of file mitkTransferFunctionPropertySerializer.h.

Constructor & Destructor Documentation

◆ TransferFunctionPropertySerializer()

mitk::TransferFunctionPropertySerializer::TransferFunctionPropertySerializer ( )
protected

◆ ~TransferFunctionPropertySerializer()

mitk::TransferFunctionPropertySerializer::~TransferFunctionPropertySerializer ( )
overrideprotected

Member Function Documentation

◆ Clone()

Pointer mitk::TransferFunctionPropertySerializer::Clone ( ) const

◆ Deserialize()

BaseProperty::Pointer mitk::TransferFunctionPropertySerializer::Deserialize ( const tinyxml2::XMLElement *  element)
overridevirtual

Deserializes an XML element back into a TransferFunctionProperty.

Reconstructs scalar opacity, gradient opacity, and color transfer functions from the XML element.

Parameters
[in]elementThe XML element to deserialize. May be nullptr.
Returns
A smart pointer to the deserialized TransferFunctionProperty, or nullptr if the element is null or parsing fails.
Exceptions
boost::bad_lexical_castIf numeric string values cannot be parsed.

Reimplemented from mitk::BasePropertySerializer.

◆ DeserializeTransferFunction()

static TransferFunction::Pointer mitk::TransferFunctionPropertySerializer::DeserializeTransferFunction ( const char *  filePath)
static

Deserializes a TransferFunction from an XML file.

Convenience method that reads and parses the XML file at the given path, and returns the reconstructed TransferFunction.

Parameters
[in]filePathPath to the XML file containing the transfer function.
Returns
A smart pointer to the deserialized TransferFunction, or nullptr if reading or parsing fails.

◆ mitkClassMacro()

mitk::TransferFunctionPropertySerializer::mitkClassMacro ( TransferFunctionPropertySerializer  ,
BasePropertySerializer   
)

◆ New()

static Pointer mitk::TransferFunctionPropertySerializer::New ( )
static

◆ Serialize()

tinyxml2::XMLElement* mitk::TransferFunctionPropertySerializer::Serialize ( tinyxml2::XMLDocument &  doc)
overridevirtual

Serializes the TransferFunctionProperty into an XML element.

Creates a "TransferFunction" XML element with sub-elements for ScalarOpacity, GradientOpacity, and Color transfer function data.

Parameters
[in,out]docThe XML document used to create elements.
Returns
Pointer to the created XML element, or nullptr if the property is not a TransferFunctionProperty or the transfer function is null.

Reimplemented from mitk::BasePropertySerializer.

◆ SerializeTransferFunction()

static bool mitk::TransferFunctionPropertySerializer::SerializeTransferFunction ( const char *  filename,
TransferFunction::Pointer  tf 
)
static

Serializes a TransferFunction to an XML file.

Convenience method that wraps the transfer function in a TransferFunctionProperty and writes the XML representation to the specified file, including a version header.

Parameters
[in]filenamePath to the output XML file.
[in]tfThe transfer function to serialize.
Returns
True if the file was written successfully, false otherwise.

The documentation for this class was generated from the following file: