23 m_MimeType(
"application/MITK.PlanarFigure"),
26 this->SetNumberOfRequiredInputs(1);
27 this->SetNumberOfIndexedOutputs(0);
43 MITK_ERROR <<
"Could not write planar figures. File name is invalid";
44 throw std::invalid_argument(
"file name is empty");
47 TiXmlDocument document;
48 auto decl =
new TiXmlDeclaration(
"1.0",
"",
"");
49 document.LinkEndChild(decl);
51 auto version =
new TiXmlElement(
"Version");
52 version->SetAttribute(
"Writer", __FILE__);
53 version->SetAttribute(
"CVSRevision",
"$Revision: 17055 $");
54 version->SetAttribute(
"FileVersion", 1);
55 document.LinkEndChild(version);
58 for (
unsigned int i = 0; i < this->GetNumberOfInputs(); ++i)
64 auto pfElement =
new TiXmlElement(
"PlanarFigure");
65 pfElement->SetAttribute(
"type", pf->GetNameOfClass());
66 document.LinkEndChild(pfElement);
68 if (pf->GetNumberOfControlPoints() == 0)
77 mitk::PropertyList::PropertyMap::const_iterator it;
78 for (it = propertyList->GetMap()->begin(); it != propertyList->GetMap()->end(); ++it)
82 std::string serializerName = std::string(prop->GetNameOfClass()) +
"Serializer";
83 std::list<itk::LightObject::Pointer> allSerializers =
84 itk::ObjectFactoryBase::CreateAllInstance(serializerName.c_str());
86 if (allSerializers.size() != 1)
94 if (serializer ==
nullptr)
99 auto keyElement =
new TiXmlElement(
"property");
100 keyElement->SetAttribute(
"key", it->first);
101 keyElement->SetAttribute(
"type", prop->GetNameOfClass());
103 serializer->SetProperty(prop);
104 TiXmlElement *valueElement =
nullptr;
107 valueElement = serializer->Serialize();
113 if (valueElement ==
nullptr)
120 keyElement->LinkEndChild(valueElement);
123 pfElement->LinkEndChild(keyElement);
127 auto controlPointsElement =
new TiXmlElement(
"ControlPoints");
128 pfElement->LinkEndChild(controlPointsElement);
129 for (
unsigned int i = 0; i < pf->GetNumberOfControlPoints(); i++)
131 auto vElement =
new TiXmlElement(
"Vertex");
132 vElement->SetAttribute(
"id", i);
133 vElement->SetDoubleAttribute(
"x", pf->GetControlPoint(i)[0]);
134 vElement->SetDoubleAttribute(
"y", pf->GetControlPoint(i)[1]);
135 controlPointsElement->LinkEndChild(vElement);
137 auto geoElement =
new TiXmlElement(
"Geometry");
138 const auto *planeGeo =
dynamic_cast<const PlaneGeometry *
>(pf->GetPlaneGeometry());
139 if (planeGeo !=
nullptr)
144 const TransformType::ParametersType ¶meters = affineGeometry->GetParameters();
145 auto vElement =
new TiXmlElement(
"transformParam");
146 for (
unsigned int i = 0; i < affineGeometry->GetNumberOfParameters(); ++i)
148 std::stringstream paramName;
149 paramName <<
"param" << i;
150 vElement->SetDoubleAttribute(paramName.str().c_str(), parameters.GetElement(i));
152 geoElement->LinkEndChild(vElement);
156 const BoundsArrayType &bounds = planeGeo->GetBounds();
157 vElement =
new TiXmlElement(
"boundsParam");
158 for (
unsigned int i = 0; i < 6; ++i)
160 std::stringstream boundName;
161 boundName <<
"bound" << i;
162 vElement->SetDoubleAttribute(boundName.str().c_str(), bounds.GetElement(i));
164 geoElement->LinkEndChild(vElement);
167 Vector3D spacing = planeGeo->GetSpacing();
168 Point3D origin = planeGeo->GetOrigin();
172 pfElement->LinkEndChild(geoElement);
179 TiXmlPrinter printer;
181 document.Accept(&printer);
192 MITK_ERROR <<
"Could not write planar figures to " <<
m_FileName <<
"\nTinyXML reports '" << document.ErrorDesc()
194 throw std::ios_base::failure(
"Error during writing of planar figure xml file.");
210 auto vElement =
new TiXmlElement(name);
211 vElement->SetDoubleAttribute(
"x", v.GetElement(0));
212 vElement->SetDoubleAttribute(
"y", v.GetElement(1));
213 vElement->SetDoubleAttribute(
"z", v.GetElement(2));
220 this->SetNumberOfIndexedInputs(num);
229 this->ProcessObject::SetNthInput(0, PlanarFigure);
234 if (
id >= this->GetNumberOfInputs())
236 this->ProcessObject::SetNthInput(
id, PlanarFigure);
241 if (this->GetNumberOfInputs() < 1)
249 return dynamic_cast<InputType *
>(this->ProcessObject::GetInput(num));
254 if (input ==
nullptr)
262 if (PlanarFigure.IsNull())
271 this->ProcessObject::SetNthInput(0, dynamic_cast<mitk::PlanarFigure *>(input->
GetData()));
286 std::vector<std::string> possibleFileExtensions;
288 return possibleFileExtensions;
BoundingBoxType::BoundsArrayType BoundsArrayType
Base of all data objects.
unsigned int m_MemoryBufferSize
GeometryTransformHolder::TransformType TransformType
static const char * GetStaticNameOfClass()
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
Abstract base class for properties.
Base class for objects that serialize BaseProperty types.
Describes a two-dimensional, rectangular plane.
Class for nodes of the DataTree.
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.
BoundingBoxType::BoundsArrayType BoundsArrayType