Serializer for mitk::TransferFunctionProperty.
More...
#include <mitkTransferFunctionPropertySerializer.h>
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.
◆ TransferFunctionPropertySerializer()
| mitk::TransferFunctionPropertySerializer::TransferFunctionPropertySerializer |
( |
| ) |
|
|
protected |
◆ ~TransferFunctionPropertySerializer()
| mitk::TransferFunctionPropertySerializer::~TransferFunctionPropertySerializer |
( |
| ) |
|
|
overrideprotected |
◆ 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] | element | The 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_cast | If 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] | filePath | Path to the XML file containing the transfer function. |
- Returns
- A smart pointer to the deserialized TransferFunction, or nullptr if reading or parsing fails.
◆ mitkClassMacro()
◆ 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] | doc | The 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] | filename | Path to the output XML file. |
| [in] | tf | The 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: