#include <mitkTransferFunctionPropertyDeserializer.h>


Public Types | |
| typedef TransferFunctionPropertyDeserializer | Self |
| typedef BasePropertyDeserializer | Superclass |
| typedef itk::SmartPointer< Self > | Pointer |
| typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
| virtual const char * | GetClassName () const |
| virtual BaseProperty::Pointer | Deserialize (TiXmlElement *element) |
Static Public Member Functions | |
| static Pointer | New () |
| static TransferFunction::Pointer | DeserializeTransferFunction (const char *filePath) |
Protected Member Functions | |
| TransferFunctionPropertyDeserializer () | |
| virtual | ~TransferFunctionPropertyDeserializer () |
Definition at line 26 of file mitkTransferFunctionPropertyDeserializer.h.
| typedef itk::SmartPointer<const Self> mitk::TransferFunctionPropertyDeserializer::ConstPointer |
Reimplemented from mitk::BasePropertyDeserializer.
Definition at line 30 of file mitkTransferFunctionPropertyDeserializer.h.
| typedef itk::SmartPointer<Self> mitk::TransferFunctionPropertyDeserializer::Pointer |
Reimplemented from mitk::BasePropertyDeserializer.
Definition at line 30 of file mitkTransferFunctionPropertyDeserializer.h.
Reimplemented from mitk::BasePropertyDeserializer.
Definition at line 30 of file mitkTransferFunctionPropertyDeserializer.h.
Reimplemented from mitk::BasePropertyDeserializer.
Definition at line 30 of file mitkTransferFunctionPropertyDeserializer.h.
| mitk::TransferFunctionPropertyDeserializer::TransferFunctionPropertyDeserializer | ( | ) | [protected] |
Definition at line 21 of file mitkTransferFunctionPropertyDeserializer.cpp.
{
| mitk::TransferFunctionPropertyDeserializer::~TransferFunctionPropertyDeserializer | ( | ) | [protected, virtual] |
Definition at line 25 of file mitkTransferFunctionPropertyDeserializer.cpp.
{
| BaseProperty::Pointer mitk::TransferFunctionPropertyDeserializer::Deserialize | ( | TiXmlElement * | element ) | [virtual] |
Reimplemented from mitk::BasePropertyDeserializer.
Definition at line 29 of file mitkTransferFunctionPropertyDeserializer.cpp.
References TiXmlNode::FirstChildElement(), mitk::TransferFunctionProperty::New(), mitk::TransferFunction::New(), TiXmlNode::NextSiblingElement(), and TIXML_WRONG_TYPE.
{
if (!element)
return NULL;
TransferFunction::Pointer tf = TransferFunction::New();
// deserialize scalar opacity function
TiXmlElement* scalarOpacityPointlist = element->FirstChildElement("ScalarOpacity");
if (scalarOpacityPointlist == NULL)
return NULL;
tf->ClearScalarOpacityPoints();
for( TiXmlElement* pointElement = scalarOpacityPointlist->FirstChildElement("point"); pointElement != NULL; pointElement = pointElement->NextSiblingElement("point"))
{
double x;
double y;
if (pointElement->QueryDoubleAttribute("x", &x) == TIXML_WRONG_TYPE)
return NULL; // TODO: can we do a better error handling?
if (pointElement->QueryDoubleAttribute("y", &y) == TIXML_WRONG_TYPE)
return NULL; // TODO: can we do a better error handling?
tf->AddScalarOpacityPoint(x, y);
}
TiXmlElement* gradientOpacityPointlist = element->FirstChildElement("GradientOpacity");
if (gradientOpacityPointlist == NULL)
return NULL;
tf->ClearGradientOpacityPoints();
for( TiXmlElement* pointElement = gradientOpacityPointlist->FirstChildElement("point"); pointElement != NULL; pointElement = pointElement->NextSiblingElement("point"))
{
double x;
double y;
if (pointElement->QueryDoubleAttribute("x", &x) == TIXML_WRONG_TYPE)
return NULL; // TODO: can we do a better error handling?
if (pointElement->QueryDoubleAttribute("y", &y) == TIXML_WRONG_TYPE)
return NULL; // TODO: can we do a better error handling?
tf->AddGradientOpacityPoint(x, y);
}
TiXmlElement* rgbPointlist = element->FirstChildElement("Color");
if (rgbPointlist == NULL)
return NULL;
vtkColorTransferFunction* ctf = tf->GetColorTransferFunction();
if (ctf == NULL)
return NULL;
ctf->RemoveAllPoints();
for( TiXmlElement* pointElement = rgbPointlist->FirstChildElement("point"); pointElement != NULL; pointElement = pointElement->NextSiblingElement("point"))
{
double x;
double r,g,b, midpoint, sharpness;
if (pointElement->QueryDoubleAttribute("x", &x) == TIXML_WRONG_TYPE)
return NULL; // TODO: can we do a better error handling?
if (pointElement->QueryDoubleAttribute("r", &r) == TIXML_WRONG_TYPE)
return NULL; // TODO: can we do a better error handling?
if (pointElement->QueryDoubleAttribute("g", &g) == TIXML_WRONG_TYPE)
return NULL; // TODO: can we do a better error handling?
if (pointElement->QueryDoubleAttribute("b", &b) == TIXML_WRONG_TYPE)
return NULL; // TODO: can we do a better error handling?
if (pointElement->QueryDoubleAttribute("midpoint", &midpoint) == TIXML_WRONG_TYPE)
return NULL; // TODO: can we do a better error handling?
if (pointElement->QueryDoubleAttribute("sharpness", &sharpness) == TIXML_WRONG_TYPE)
return NULL; // TODO: can we do a better error handling?
ctf->AddRGBPoint(x, r, g, b, midpoint, sharpness);
}
return TransferFunctionProperty::New(tf).GetPointer();
| mitk::TransferFunction::Pointer mitk::TransferFunctionPropertyDeserializer::DeserializeTransferFunction | ( | const char * | filePath ) | [static] |
Definition at line 101 of file mitkTransferFunctionPropertyDeserializer.cpp.
References TiXmlDocument::ErrorDesc(), TiXmlNode::FirstChildElement(), mitk::TransferFunctionProperty::GetValue(), TiXmlDocument::LoadFile(), MITK_ERROR, MITK_WARN, New(), TiXmlElement::QueryIntAttribute(), and TIXML_SUCCESS.
Referenced by QmitkTransferFunctionGeneratorWidget::OnLoadPreset().
{
TiXmlDocument document( filePath );
if (!document.LoadFile())
{
MITK_ERROR << "Could not open/read/parse " << filePath << "\nTinyXML reports: " << document.ErrorDesc() << std::endl;
return NULL;
}
// find version node --> note version in some variable
int fileVersion = 1;
TiXmlElement* versionObject = document.FirstChildElement("Version");
if (versionObject)
{
if ( versionObject->QueryIntAttribute( "TransferfunctionVersion", &fileVersion ) != TIXML_SUCCESS )
{
MITK_WARN << "Transferfunction file " << filePath << " does not contain version information! Trying version 1 format.";
}
}
TiXmlElement* input = document.FirstChildElement("TransferFunction");
TransferFunctionPropertyDeserializer::Pointer tfpd = TransferFunctionPropertyDeserializer::New();
BaseProperty::Pointer bp = tfpd->Deserialize(input);
TransferFunctionProperty::Pointer tfp = dynamic_cast<TransferFunctionProperty*>(bp.GetPointer());
if(tfp.IsNotNull())
{
TransferFunction::Pointer tf = tfp->GetValue();
return tf;
}
MITK_WARN << "Can't deserialize transferfunction";
return NULL;
| virtual const char* mitk::TransferFunctionPropertyDeserializer::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::BasePropertyDeserializer.
| static Pointer mitk::TransferFunctionPropertyDeserializer::New | ( | ) | [static] |
Referenced by DeserializeTransferFunction().
1.7.2