Medical Imaging Interaction Toolkit  2025.12.02
Medical Imaging Interaction Toolkit
mitkPointSetWriter.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkPointSetWriter_h
14 #define mitkPointSetWriter_h
15 
16 #include <MitkLegacyIOExports.h>
17 
18 #include <itkProcessObject.h>
19 #include <mitkFileWriter.h>
20 #include <mitkPointSet.h>
21 
22 namespace mitk
23 {
37  {
38  public:
40 
42 
43  itkFactorylessNewMacro(Self);
44 
45  itkCloneMacro(Self);
46 
48 
49  typedef InputType::Pointer InputTypePointer;
50 
54  itkSetStringMacro(FileName);
55 
59  itkGetStringMacro(FileName);
60 
64  itkSetStringMacro(FilePrefix);
65 
69  itkGetStringMacro(FilePrefix);
70 
74  itkSetStringMacro(FilePattern);
75 
79  itkGetStringMacro(FilePattern);
80 
85  void SetInput(InputType *input);
86 
94  void SetInput(const unsigned int &num, InputType *input);
95 
100 
105  PointSet *GetInput(const unsigned int &num);
106 
110  std::vector<std::string> GetPossibleFileExtensions() override;
111 
112  std::string GetSupportedBaseData() const override;
113 
117  std::string GetFileExtension() override;
118 
122  bool CanWriteDataType(DataNode *) override;
123 
127  std::string GetWritenMIMEType() override;
128 
133  virtual void SetInput(DataNode *);
134 
138  bool GetSuccess() const;
139 
140  protected:
145 
149  ~PointSetWriter() override;
150 
154  void GenerateData() override;
155 
161  virtual void ResizeInputs(const unsigned int &num);
162 
170  template <typename T>
171  std::string ConvertToString(T value);
172 
179  void WriteXML(mitk::PointSet *pointSet, std::ofstream &out);
180 
185  void WriteXMLHeader(std::ofstream &file);
186 
188  void WriteStartElement(const char *const tag, std::ofstream &file);
189 
194  void WriteEndElement(const char *const tag, std::ofstream &file, const bool &indent = true);
195 
197  void WriteCharacterData(const char *const data, std::ofstream &file);
198 
200  void WriteStartElement(std::string &tag, std::ofstream &file);
201 
203  void WriteEndElement(std::string &tag, std::ofstream &file, const bool &indent = true);
204 
206  void WriteCharacterData(std::string &data, std::ofstream &file);
207 
209  void WriteIndent(std::ofstream &file);
210 
211  std::string m_FileName;
212 
213  std::string m_FilePrefix;
214 
215  std::string m_FilePattern;
216 
217  std::string m_Extension;
218 
219  std::string m_MimeType;
220 
221  unsigned int m_IndentDepth;
222 
223  unsigned int m_Indent;
224 
225  bool m_Success;
226 
227  public:
228  static const char *XML_POINT_SET;
229 
230  static const char *XML_TIME_SERIES;
231 
232  static const char *XML_TIME_SERIES_ID;
233 
234  static const char *XML_POINT_SET_FILE;
235 
236  static const char *XML_FILE_VERSION;
237 
238  static const char *XML_POINT;
239 
240  static const char *XML_SPEC;
241 
242  static const char *XML_ID;
243 
244  static const char *XML_X;
245 
246  static const char *XML_Y;
247 
248  static const char *XML_Z;
249 
250  static const char *VERSION_STRING;
251  };
252 }
253 
254 #endif
#define MITKLEGACYIO_EXPORT
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
Interface class of writers that write data to files.
void SetInput(BaseData *data)
XML-based writer for mitk::PointSets.
void WriteEndElement(std::string &tag, std::ofstream &file, const bool &indent=true)
std::string GetWritenMIMEType() override
Return the MimeType of the saved File.
void WriteXML(mitk::PointSet *pointSet, std::ofstream &out)
virtual void SetInput(DataNode *)
Set the DataTreenode as Input. Important: The Writer always have a SetInput-Function.
std::string GetFileExtension() override
Return the extension to be added to the filename.
static const char * XML_TIME_SERIES_ID
PointSet * GetInput()
static const char * VERSION_STRING
void SetInput(InputType *input)
void WriteStartElement(const char *const tag, std::ofstream &file)
static const char * XML_FILE_VERSION
bool GetSuccess() const
static const char * XML_SPEC
void WriteXMLHeader(std::ofstream &file)
mitk::PointSet InputType
std::vector< std::string > GetPossibleFileExtensions() override
Return the possible file extensions for the data type associated with the writer.
void WriteEndElement(const char *const tag, std::ofstream &file, const bool &indent=true)
std::string ConvertToString(T value)
static const char * XML_X
bool CanWriteDataType(DataNode *) override
Check if the Writer can write the Content of the.
static const char * XML_Y
static const char * XML_ID
static const char * XML_Z
void WriteCharacterData(std::string &data, std::ofstream &file)
void WriteStartElement(std::string &tag, std::ofstream &file)
InputType::Pointer InputTypePointer
std::string GetSupportedBaseData() const override
static const char * XML_POINT_SET_FILE
void SetInput(const unsigned int &num, InputType *input)
void WriteCharacterData(const char *const data, std::ofstream &file)
mitkClassMacro(PointSetWriter, mitk::FileWriter)
virtual void ResizeInputs(const unsigned int &num)
PointSet * GetInput(const unsigned int &num)
static const char * XML_POINT
static const char * XML_TIME_SERIES
~PointSetWriter() override
void GenerateData() override
void WriteIndent(std::ofstream &file)
static const char * XML_POINT_SET
Data structure which stores a set of points.
Definition: mitkPointSet.h:72
Find image slices visible on a given plane.