Medical Imaging Interaction Toolkit  2018.4.99-6ca56567
Medical Imaging Interaction Toolkit
mitkBaseData.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 BASEDATA_H_HEADER_INCLUDED_C1EBB6FA
14 #define BASEDATA_H_HEADER_INCLUDED_C1EBB6FA
15 
16 #include <itkDataObject.h>
17 
18 #include "mitkBaseProcess.h"
19 #include "mitkIdentifiable.h"
20 #include "mitkIPropertyOwner.h"
21 #include "mitkOperationActor.h"
22 #include "mitkPropertyList.h"
23 #include "mitkTimeGeometry.h"
24 #include <MitkCoreExports.h>
25 
26 namespace mitk
27 {
28  // class BaseProcess;
29 
30  //##Documentation
31  //## @brief Base of all data objects
32  //##
33  //## Base of all data objects, e.g., images, contours, surfaces etc. Inherits
34  //## from itk::DataObject and thus can be included in a pipeline.
35  //## Inherits also from OperationActor and can be used as a destination for Undo
36  //## @remark Some derived classes may support the persistence of the Identifiable UID.
37  //** but it is no guaranteed feature and also depends on the format the data is stored in
38  //** as not all formats support storing of meta information. Please check the documentation
39  //** of the IFileReader and IFileWriter classes to see if the ID-persistance is supported.
40  //** MITK SceneIO supports the UID persistance for all BaseData derived classes.
41  //## @ingroup Data
43  : public itk::DataObject, public OperationActor, public Identifiable, public IPropertyOwner
44  {
45  public:
46  mitkClassMacroItkParent(BaseData, itk::DataObject);
47 
48  // IPropertyProvider
49  BaseProperty::ConstPointer GetConstProperty(const std::string &propertyKey, const std::string &contextName = "", bool fallBackOnDefaultContext = true) const override;
50  std::vector<std::string> GetPropertyKeys(const std::string &contextName = "", bool includeDefaultContext = false) const override;
51  std::vector<std::string> GetPropertyContextNames() const override;
52 
53  // IPropertyOwner
54  BaseProperty * GetNonConstProperty(const std::string &propertyKey, const std::string &contextName = "", bool fallBackOnDefaultContext = true) override;
55  void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName = "", bool fallBackOnDefaultContext = false) override;
56  void RemoveProperty(const std::string &propertyKey, const std::string &contextName = "", bool fallBackOnDefaultContext = false) override;
57 
67  {
68  return m_TimeGeometry.GetPointer();
69  }
70 
81  DEPRECATED(const mitk::TimeGeometry *GetTimeSlicedGeometry() const) { return GetTimeGeometry(); }
90  mitk::TimeGeometry *GetTimeGeometry() { return m_TimeGeometry.GetPointer(); }
99  const mitk::TimeGeometry *GetUpdatedTimeGeometry();
100 
111  DEPRECATED(const mitk::TimeGeometry *GetUpdatedTimeSliceGeometry()) { return GetUpdatedTimeGeometry(); }
120  virtual void Expand(unsigned int timeSteps);
121 
133  const mitk::BaseGeometry *GetUpdatedGeometry(int t = 0);
134 
135  //##Documentation
136  //## @brief Return the geometry, which is a TimeGeometry, of the data
137  //## as non-const pointer.
138  //##
139  //## \warning No update will be called. Use GetUpdatedGeometry() if you cannot
140  //## be sure that the geometry is up-to-date.
141  //##
142  //## Normally used in GenerateOutputInformation of subclasses of BaseProcess.
143  mitk::BaseGeometry *GetGeometry(int t = 0) const
144  {
145  if (m_TimeGeometry.IsNull())
146  return nullptr;
147  return m_TimeGeometry->GetGeometryForTimeStep(t);
148  }
149 
150  //##Documentation
151  //## @brief Update the information for this BaseData (the geometry in particular)
152  //## so that it can be used as an output of a BaseProcess.
153  //##
154  //## This method is used in the pipeline mechanism to propagate information and
155  //## initialize the meta data associated with a BaseData. Any implementation
156  //## of this method in a derived class is assumed to call its source's
157  //## BaseProcess::UpdateOutputInformation() which determines modified
158  //## times, LargestPossibleRegions, and any extra meta data like spacing,
159  //## origin, etc. Default implementation simply call's it's source's
160  //## UpdateOutputInformation().
161  //## \note Implementations of this methods in derived classes must take care
162  //## that the geometry is updated by calling
163  //## GetTimeGeometry()->UpdateInformation()
164  //## \em after calling its source's BaseProcess::UpdateOutputInformation().
165  void UpdateOutputInformation() override;
166 
167  //##Documentation
168  //## @brief Set the RequestedRegion to the LargestPossibleRegion.
169  //##
170  //## This forces a filter to produce all of the output in one execution
171  //## (i.e. not streaming) on the next call to Update().
172  void SetRequestedRegionToLargestPossibleRegion() override = 0;
173 
174  //##Documentation
175  //## @brief Determine whether the RequestedRegion is outside of the BufferedRegion.
176  //##
177  //## This method returns true if the RequestedRegion
178  //## is outside the BufferedRegion (true if at least one pixel is
179  //## outside). This is used by the pipeline mechanism to determine
180  //## whether a filter needs to re-execute in order to satisfy the
181  //## current request. If the current RequestedRegion is already
182  //## inside the BufferedRegion from the previous execution (and the
183  //## current filter is up to date), then a given filter does not need
184  //## to re-execute
185  bool RequestedRegionIsOutsideOfTheBufferedRegion() override = 0;
186 
187  //##Documentation
188  //## @brief Verify that the RequestedRegion is within the LargestPossibleRegion.
189  //##
190  //## If the RequestedRegion is not within the LargestPossibleRegion,
191  //## then the filter cannot possibly satisfy the request. This method
192  //## returns true if the request can be satisfied (even if it will be
193  //## necessary to process the entire LargestPossibleRegion) and
194  //## returns false otherwise. This method is used by
195  //## PropagateRequestedRegion(). PropagateRequestedRegion() throws a
196  //## InvalidRequestedRegionError exception if the requested region is
197  //## not within the LargestPossibleRegion.
198  bool VerifyRequestedRegion() override = 0;
199 
200  //##Documentation
201  //## @brief Copy information from the specified data set.
202  //##
203  //## This method is part of the pipeline execution model. By default, a
204  //## BaseProcess will copy meta-data from the first input to all of its
205  //## outputs. See ProcessObject::GenerateOutputInformation(). Each
206  //## subclass of DataObject is responsible for being able to copy
207  //## whatever meta-data it needs from another DataObject.
208  //## The default implementation of this method copies the time sliced geometry
209  //## and the property list of an object. If a subclass overrides this
210  //## method, it should always call its superclass' version.
211  void CopyInformation(const itk::DataObject *data) override;
212 
213  //##Documentation
214  //## @brief Check whether the data has been initialized, i.e.,
215  //## at least the Geometry and other header data has been set
216  //##
217  //## \warning Set to \a true by default for compatibility reasons.
218  //## Set m_Initialized=false in constructors of sub-classes that
219  //## support distinction between initialized and uninitialized state.
220  virtual bool IsInitialized() const;
221 
222  //##Documentation
223  //## @brief Calls ClearData() and InitializeEmpty();
224  //## \warning Only use in subclasses that reimplemented these methods.
225  //## Just calling Clear from BaseData will reset an object to a not initialized,
226  //## invalid state.
227  virtual void Clear();
228 
229  //##Documentation
230  //## @brief Check whether object contains data (at
231  //## a specified time), e.g., a set of points may be empty
232  //##
233  //## \warning Returns IsInitialized()==false by default for
234  //## compatibility reasons. Override in sub-classes that
235  //## support distinction between empty/non-empty state.
236  virtual bool IsEmptyTimeStep(unsigned int t) const;
237 
238  //##Documentation
239  //## @brief Check whether object contains data (at
240  //## least at one point in time), e.g., a set of points
241  //## may be empty
242  //##
243  //## \warning Returns IsInitialized()==false by default for
244  //## compatibility reasons. Override in sub-classes that
245  //## support distinction between empty/non-empty state.
246  virtual bool IsEmpty() const;
247 
248  //##Documentation
249  //## @brief Set the requested region from this data object to match the requested
250  //## region of the data object passed in as a parameter.
251  //##
252  //## This method is implemented in the concrete subclasses of BaseData.
253  void SetRequestedRegion(const itk::DataObject *data) override = 0;
254 
255  //##Documentation
256  //##@brief overwrite if the Data can be called by an Interactor (StateMachine).
257  //##
258  //## Empty by default. Overwrite and implement all the necessary operations here
259  //## and get the necessary information from the parameter operation.
260  void ExecuteOperation(Operation *operation) override;
261 
272  virtual void SetGeometry(BaseGeometry *aGeometry3D);
273 
281  virtual void SetTimeGeometry(TimeGeometry *geometry);
282 
291  virtual void SetClonedGeometry(const BaseGeometry *aGeometry3D);
292 
298  virtual void SetClonedTimeGeometry(const TimeGeometry *geometry);
299 
300  //##Documentation
301  //## @brief Set a clone of the provided geometry as BaseGeometry of a given time step.
302  //##
303  //## \sa SetGeometry
304  virtual void SetClonedGeometry(const BaseGeometry *aGeometry3D, unsigned int time);
305 
306  //##Documentation
307  //## @brief Get the data's property list
308  //## @sa GetProperty
309  //## @sa m_PropertyList
310  mitk::PropertyList::Pointer GetPropertyList() const;
311 
312  //##Documentation
313  //## @brief Set the data's property list
314  //## @sa SetProperty
315  //## @sa m_PropertyList
316  void SetPropertyList(PropertyList *propertyList);
317 
318  //##Documentation
319  //## @brief Get the property (instance of BaseProperty) with key @a propertyKey from the PropertyList,
320  //## and set it to this, respectively;
321  //## @sa GetPropertyList
322  //## @sa m_PropertyList
323  //## @sa m_MapOfPropertyLists
324  mitk::BaseProperty::Pointer GetProperty(const char *propertyKey) const;
325 
326  void SetProperty(const char *propertyKey, BaseProperty *property);
327 
328  //##Documentation
329  //## @brief Convenience method for setting the origin of
330  //## the BaseGeometry instances of all time steps
331  //##
332  //## \warning Geometries contained in the BaseGeometry will
333  //## \em not be changed, e.g. in case the BaseGeometry is a
334  //## SlicedGeometry3D the origin will \em not be propagated
335  //## to the contained slices. The sub-class SlicedData
336  //## does this for the case that the SlicedGeometry3D is
337  //## evenly spaced.
338  virtual void SetOrigin(const Point3D &origin);
339 
353  itk::SmartPointer<mitk::BaseDataSource> GetSource() const;
354 
355  //##Documentation
356  //## @brief Get the number of time steps from the TimeGeometry
357  //## As the base data has not a data vector given by itself, the number
358  //## of time steps is defined over the time sliced geometry. In sub classes,
359  //## a better implementation could be over the length of the data vector.
360  unsigned int GetTimeSteps() const { return m_TimeGeometry->CountTimeSteps(); }
361  //##Documentation
362  //## @brief Get the modified time of the last change of the contents
363  //## this data object or its geometry.
364  unsigned long GetMTime() const override;
365 
369  void Graft(const DataObject *) override;
370 
371  protected:
372  BaseData();
373  BaseData(const BaseData &other);
374  ~BaseData() override;
375 
376  //##Documentation
377  //## \brief Initialize the TimeGeometry for a number of time steps.
378  //## The TimeGeometry is initialized empty and evenly timed.
379  //## In many cases it will be necessary to overwrite this in sub-classes.
380  virtual void InitializeTimeGeometry(unsigned int timeSteps = 1);
381 
389  DEPRECATED(virtual void InitializeTimeSlicedGeometry(unsigned int timeSteps = 1))
390  {
391  InitializeTimeGeometry(timeSteps);
392  }
393 
394  //##Documentation
395  //## @brief reset to non-initialized state, release memory
396  virtual void ClearData();
397 
398  //##Documentation
399  //## @brief Pure virtual; Must be used in subclasses to get a data object to a
400  //## valid state. Should at least create one empty object and call
401  //## Superclass::InitializeTimeGeometry() to ensure an existing valid geometry
402  virtual void InitializeEmpty() {}
403  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
404 
406 
407  mutable unsigned int m_SourceOutputIndexDuplicate;
408 
410 
411  private:
412  //##Documentation
413  //## @brief PropertyList, f.e. to hold pic-tags, tracking-data,..
414  //##
415  PropertyList::Pointer m_PropertyList;
416 
417  TimeGeometry::Pointer m_TimeGeometry;
418  };
419 
420 } // namespace mitk
421 
422 #endif /* BASEDATA_H_HEADER_INCLUDED_C1EBB6FA */
#define MITKCORE_EXPORT
const mitk::TimeGeometry * GetTimeSlicedGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:81
Base of all data objects.
Definition: mitkBaseData.h:42
Base class of all Operation-classes.
Definition: mitkOperation.h:29
DataCollection - Class to facilitate loading/accessing structured data.
mitk::TimeGeometry * GetTimeGeometry()
Return the TimeGeometry of the data as pointer.
Definition: mitkBaseData.h:90
Key-value list holding instances of BaseProperty.
abstract class, that can be used by Undo to undo an operation.
#define DEPRECATED(func)
Definition: mitkCommon.h:179
const mitk::TimeGeometry * GetUpdatedTimeSliceGeometry()
Return the TimeGeometry of the data.
Definition: mitkBaseData.h:111
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:66
Abstract base class for properties.
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:49
bool m_LastRequestedRegionWasOutsideOfTheBufferedRegion
Definition: mitkBaseData.h:405
virtual void InitializeEmpty()
Pure virtual; Must be used in subclasses to get a data object to a valid state. Should at least creat...
Definition: mitkBaseData.h:402
unsigned int GetTimeSteps() const
Get the number of time steps from the TimeGeometry As the base data has not a data vector given by it...
Definition: mitkBaseData.h:360
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:143
Base class of identifiable objects.
virtual void InitializeTimeSlicedGeometry(unsigned int timeSteps=1)
Initialize the TimeGeometry for a number of time steps. The TimeGeometry is initialized empty and eve...
Definition: mitkBaseData.h:389
unsigned int m_SourceOutputIndexDuplicate
Definition: mitkBaseData.h:407
BaseGeometry Describes the geometry of a data object.