This subcategory includes the IO classes to read or write data objects. More...
![]() |
Classes | |
class | mitk::DataNodeFactory |
Factory, which creates instances of mitk::DataNodes filled with data read from a given file. More... | |
class | mitk::BaseDataIO |
BaseDataIO creates instances of BaseData objects using an object factory. More... | |
class | mitk::ImageWriter |
Writer for mitk::Image. More... | |
class | mitk::IOAdapterBase |
IOAdapterBase class is an abstract adapter class for IO process objects. More... | |
class | mitk::IOAdapter< T > |
IOAdapter class is an adapter class for instantiation of IO process objects. Additional this interface defines the function CanReadFile(). This interface allows the target (object) the access to the adaptee (IO process object). More... | |
class | mitk::ItkImageFileIOFactory |
Create instances of ItkImageFileReader objects using an object factory. More... | |
class | mitk::ItkImageFileReader |
Reader to read file formats supported by itk. More... | |
class | mitk::PicFileIOFactory |
Create instances of PicFileReader objects using an object factory. More... | |
class | mitk::PicFileReader |
Reader to read files in DKFZ-pic-format. More... | |
class | mitk::PicFileWriter |
Writer for mitk::Image. More... | |
class | mitk::PicVolumeTimeSeriesIOFactory |
Create instances of PicVolumeTimeSeriesReader objects using an object factory. More... | |
class | mitk::PicVolumeTimeSeriesReader |
Reader to read a series of volume files in DKFZ-pic-format. More... | |
class | mitk::PointSetIOFactory |
Create instances of PointSetReader objects using an object factory. More... | |
class | mitk::PointSetReader |
reads xml representations of mitk::PointSets from a file More... | |
class | mitk::STLFileIOFactory |
Create instances of STLFileReader objects using an object factory. More... | |
class | mitk::STLFileReader |
Reader to read files in stl-format. More... | |
class | mitk::VtiFileIOFactory |
Create instances of VtiFileReader objects using an object factory. More... | |
class | mitk::VtiFileReader |
Reader to read image files in vtk file format. More... | |
class | mitk::VtkImageIOFactory |
Create instances of VtkImageReader objects using an object factory. More... | |
class | mitk::VtkImageReader |
Reader to read image files in vtk file format. More... | |
class | mitk::VtkSurfaceIOFactory |
Create instances of VtkSurfaceReader objects using an object factory. More... | |
class | mitk::VtkSurfaceReader |
Reader to read surface files in vtk-format. More... | |
class | mitk::NrrdDiffusionImageIOFactory |
Create instances of NrrdDiffusionImageReader objects using an object factory. More... | |
class | mitk::NrrdQBallImageIOFactory |
Create instances of NrrdQBallImageReader objects using an object factory. More... | |
class | mitk::NrrdTensorImageIOFactory |
Create instances of NrrdTensorImageReader objects using an object factory. More... | |
class | mitk::ObjFileIOFactory |
Create instances of ObjFileReader objects using an object factory. More... | |
class | mitk::ObjFileReader |
Reader to read files in Obj-format. More... | |
class | mitk::PACSPlugin |
Interface for minimal PACS communicationDefines some basic function for communication with a PACS. Currently only really implemented for the CHILI Workstation (see CHILIPlugin), but should be basic enough to work with differnt systems, too. More... | |
class | mitk::ParRecFileIOFactory |
Create instances of ParRecFileReader objects using an object factory. More... | |
class | mitk::ParRecFileReader |
Reader to read files in Philips PAR/REC file format. More... | |
class | mitk::StlVolumeTimeSeriesIOFactory |
Create instances of StlVolumeTimeSeriesReader objects using an object factory. More... | |
class | mitk::StlVolumeTimeSeriesReader |
Reader to read a series of volume files in stl-format. More... | |
class | mitk::VtkUnstructuredGridIOFactory |
Create instances of VtkUnstructuredGridReader objects using an object factory. More... | |
class | mitk::VtkUnstructuredGridReader |
Reader to read unstructured grid files in vtk-format. More... | |
class | mitk::VtkVolumeTimeSeriesIOFactory |
Create instances of VtkVolumeTimeSeriesReader objects using an object factory. More... | |
class | mitk::VtkVolumeTimeSeriesReader |
Reader to read a series of volume files in Vtk-format. More... | |
class | mitk::PlanarFigureIOFactory |
Create instances of PlanarFigureReader objects using an object factory. More... | |
class | mitk::PlanarFigureReader |
reads xml representations of mitk::PlanarFigure from a file More... |
This subcategory includes the IO classes to read or write data objects.
Available sections:
The mitk::DataNodeFactory creates instances of mitk::DataNodes filled with data read from a given file. This class reads files, creates an appropriate mitk::BaseData and adds the BaseData to a mitk::DataNode. This filter may produce one or more outputs (i.e. mitk::DataNodes). The number of generated nodes can be retrieved by a call of GetNumberOfOutputs(). If you want to add a new file type, you have to register the factory of the file reader in the class mitk::BaseDataIO.
A short overview of the factory mechanism of the DataNodeFactory.
The mitk::DataNodeFactory calls the mitk::BaseDataIO. BaseDataIO registers the defined factories of the file readers. After registration each registered factory will be asked if it can read the file specified by the filename. If the asked factory can read the file it instantiates the adequate reader. The reader reads the file and returns as output a pointer of BaseData. It is possible that a reader has more than one output. The BaseData is stored in a vector of BaseData. The pointer of this vector is returned to the DataNodeFactory. A node is created for each element of the vector.
Between BaseDataIO and the ObjectFactoryBase there is still an adapter (mitk::IOAdapter). The instantiated reader returns a pointer of mitk::BaseProcess. In the class BaseProcess there couldn't be defined the necessary function CanReadFile(). So we need an adapter class to handle this.
The mitk::XMLWriter and mitk::XMLReader give the possibility to write and to read XML files. These classes were developed with the aim to store and to load the MITK datatree (mitk::DataTree). To avoid external dependencies of the MITK these classes are realized without XML parsers like DOM or SAX. Only dependencies to ITK and VTK are existing.
Mentioned before, the focus of this classes is to store and to load the MITK datatree (mitk::DataTree) with XML. In the following you can see the body of a typical XML file of a MITK image that was kept as a node in the datatree.
A typical XML file of a MITK image.
Initial point is the DataTree class. So <mitkDataTree> is the root element. The hierarchy of the datatree is reflected again in the hierarchy of the XML nodes. At large the XML nodes represent classes. The name of the class is stored with the XML attribute "CLASS_NAME". Generally data is stored with attributes.
Technically the XMLWriter class is derived from mitkBaseXMLWriter class. The constructor needs the filename of the XML file at least.
The following diagram displays the main components:
Classes related to XMLWriter
For writing a XML file the following funtions are important.
Easily speaking the mitk::XMLIO class manages the input and the output of the XML file. New classes that should be written to the XML file have to be derived from the XMLIO class. New classes should also be declared in the mitk::MapClassIDToClassName class. Calling the function WriteXML() writes automatically a complete node of the referenced class to the XML file. The function WriteXML() calls sequential the functions BeginNode(), WriteProperty(), WriteXMLData() and EndNode(). A new XML node is initialized with the function BeginNode("nameOfNewNode"). The function WriteXMLData() writes the data of the referenced class. This function has to be overwritten in new classes. The data is stored with XML attributes. These attributes can be written with the function WriteProperty("key", value). The parameter "key" specifies the name of the attribute and the parameter "value" the data. Different datatypes are supported. For details you can look in the mitk::BaseXMLWriter and mitk::XMLWriter class. The function EndNode() writes the end tag of the started XML node to the XML file.
It is also possible to write custom data apart from classes to the XML file (e.g. data of complex datatypes). In this case you can call BeginNode(),(WriteProperty()), (WriteXMLData()) and EndNode() manually to write XML nodes and attributes. But watch out for the closing tag of each XML node. Each start tag needs an end tag.
It is prefered to define common key words (e.g. name of attriubtes) in the XMLNodes class. Class specific key words should be defined in the class itself (e.g. XML_NODE_NAME).
The nodes of the datatree contain different data like images, surfaces or vessels. These base data is stored in the respectively fitting dataformat. Such files are called source files and are referenced in the XML file.
To manage these references there are different functions implemented in the mitk::XMLWriter class.
A special feature of the XMLWriter is to store the source files relative to the XML file. If no filename is set a new filename is generated.
Initialize and start the XMLWriter
#include <mitkXMLWriter.h> #include <myClass.h> //... const *char filename = "Scene.xml"; mitk::XMLWriter xmlWriter(filename); mitk::myClass::Pointer myClass; xmlWriter.BeginNode("root"); myClass->WriteXML(xmlWriter); xmlWriter.EndNode();
Overwrite the function WriteXMLData of a new class
myClass.h
#include <mitkXMLIO.h> class myClass: public XMLIO public //... static const std::string XML_NODE_NAME; virtual bool WriteXMLData(XMLWriter &xmlWriter);
myClass.cpp
#include <mitkXMLWriter.h> //... static const std::string XML_NODE_NAME = "myClass"; // defines the XML nodename <myClass> bool mitk::myClass::WriteXMLData(XMLWriter &xmlWriter); { xmlWriter.WriteProperty("MY_NUMBER", this->GetNumber()); xmlWriter.BeginNode("uselessNode"); xmlWriter.WriteProperty("USELESS_INFO", "useless info"); xmlWriter.EndNode(); return true; }
The mitk::XMLReader reads a stream and parses XML element tags and corresponding attributes. Technically the XMLReader class is derived from vtkXMLParser class. The constructor needs the filename ((path)+filename) of the XML file and a datatree iterator (mitk::DataTreeIteratorBase) of the datatree.
The following diagram displays the main components:
Classes related to XMLReader
For reading a XML file the following funtions are important.
As mentioned in the section before the mitk::XMLIO class manages the input and the output of the XML file. New classes that should be read data from the XML file have to be derived from the mitkXMLIO class. In new classes the function ReadXMLData() have to be overwritten. Easily speaking this function reads the data from the XML file, provides for instantiation of new objects and sets the data. With the Goto functions it is possible to navigate the parser through the XML document. To get the root XML node call the function Goto("root"). Be careful with the hierarchy of the XML nodes and the actual position of the parser. The function Goto() is looking always for child nodes and function GotoNext() is looking for further XML nodes in the same hierarchy. For creation of new objects of the read class (the class is specified in the XML attribute "CLASS_NAME") the function CreateObject() has to be called. The creation of the asked object is only successful when the new class has already be defined in the mitk::ObjectFactory class. If the asked XML node is reached, the data stored in XML attributes, can be read by the function GetAttribute("key", value). The parameter "key" specifies the name of the attribute and the parameter "value" keeps the data. Different datatypes are supported. For details you can look in the mitk::XMLReader class. When the parser should climb up in the XML tree hierarchy the function GotoParent() does a good job.
The source file management
If the reference to the source file is stored relative to the XML file you need the path of the XML file to calculate the absolute path. This operation is done automatically and you get the absolute path when calling the attribute "FILENAME". It is also possible to get the path of the source file by calling the function GetSourceFilePath().
Initialize and start the XMLReader
#include <mitkXMLReader.h> //... std::string filename = "Scene.xml"; mitk::DataTreePreOrderIterator it(m_Tree); mitk::XMLReader::Load(&it, filename);
Overwrite the function ReadXMLData of a new class
myClass.h
#include <mitkXMLIO.h> class myClass: public XMLIO public //... virtual bool ReadXMLData(XMLReader &xmlReader);
myClass.cpp
#include <mitkXMLReader.h> #include <fictiveClass.h> //... bool mitk::myClass::ReadXMLData(XMLReader &xmlReader); { int value; if(xmlReader.Goto("myClass")){ mitk::fictiveClass::Pointer myFictiveObject = dynamic_cast<fictiveClass*>(xmlReader.CreateObject().GetPointer()); if (xmlReader.GetAttribute("myNumber", value)) this->SetNumber(value); myFictiveObject->ReadXMLData(xmlReader); // further elements can be read xmlReader.GotoParent(); // now we are back on parent tag } return true; }