Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkDataCollection.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 #pragma warning (disable : 4996)
17 
18 #ifndef mitkDataCollection_H_
19 #define mitkDataCollection_H_
20 
21 #include <itkLightObject.h>
22 #include <itkDataObject.h>
23 #include "itkObjectFactory.h"
24 #include "mitkCommon.h"
25 #include <mitkImage.h>
26 #include <mitkDataNode.h>
27 
28 #include<mitkBaseData.h>
29 
30 #include <MitkDataCollectionExports.h>
31 
53 namespace mitk
54 {
55  class MITKDATACOLLECTION_EXPORT DataCollection : public BaseData
56  {
57  public:
58 
60 
61  itkFactorylessNewMacro(Self)
62  itkCloneMacro(Self)
63 
64  // Needed methods from Basedata
65  virtual void UpdateOutputInformation();
66  virtual void SetRequestedRegionToLargestPossibleRegion();
67  virtual bool RequestedRegionIsOutsideOfTheBufferedRegion();
68  virtual bool VerifyRequestedRegion();
69  virtual void SetRequestedRegion(const itk::DataObject *);
70 
71  void Init(std::string name);
72 
81  size_t AddData(DataObject::Pointer data, std::string name, std::string filePath = "");
82 
87  void SetName(std::string name);
88 
89  std::string GetName() const;
90 
91  std::string GetDataFilePath(size_t index) const;
92 
99  size_t NameToIndex(std::string name);
100 
106  std::string IndexToName(size_t index) const;
107 
113  bool HasElement(std::string name);
114 
121  bool HasElement(size_t index);
122 
127  size_t Size() const;
128 
135  void SetData(itk::DataObject::Pointer data, size_t index);
136 
143  void SetData(itk::DataObject::Pointer data, std::string name);
144 
153  itk::DataObject::Pointer GetData(size_t index);
154 
163  itk::DataObject::Pointer GetData(std::string name);
164 
173  mitk::Image::Pointer GetMitkImage(size_t index);
174 
183  mitk::Image::Pointer GetMitkImage(std::string name);
184 
188  template <class ImageType>
189  ImageType GetItkImage(size_t index, ImageType* itkImage);
190 
194  template <class ImageType>
195  ImageType GetItkImage(std::string name, ImageType* itkImage);
196 
197  itk::DataObject::Pointer& operator[](size_t index);
198 
199  itk::DataObject::Pointer& operator[](std::string &name);
200 
206  void SetNameForIndex(size_t index, std::string &name);
207 
211  void SetXMLFile(std::string absoluteXMlFile);
212 
216  std::string GetXMLFile();
217 
222  void SetParent(mitk::DataCollection* parent);
223 
228  mitk::DataCollection* GetParent();
229 
235  bool RemoveIndex(size_t index);
236 
242  bool RemoveElement(std::string& name);
243 
247  void Clear();
248 
254  mitk::DataNode::Pointer GetDataNode(size_t index);
255 
261  mitk::DataNode::Pointer GetDataNode(std::string name);
262 
268  mitk::Image::Pointer GetProbabilityMap(std::vector<std::string> probabilityNamesVector);
269 
270  protected:
271 
272  DataCollection();
273  virtual ~DataCollection();
274 
275  private:
276  // DATA
277  std::string m_Name;
278  std::vector<itk::DataObject::Pointer> m_DataVector;
279  std::vector<std::string> m_NameVector;
280  std::vector<std::string> m_FilePathVector;
281  std::map<std::string, size_t> m_DataNames;
282 
283  mitk::DataCollection * m_Parent;
284 
285  std::string m_XMLFile; // is only filled for the hightest layer when loading a data collection
286  };
287 } // end namespace
288 #endif
itk::SmartPointer< Self > Pointer
Base of all data objects.
Definition: mitkBaseData.h:39
DataCollection - Class to facilitate loading/accessing structured data.
T::Pointer GetData(const std::string &name)
map::core::discrete::Elements< 3 >::InternalImageType ImageType
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
static std::string GetName(std::string fileName, std::string suffix)