Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
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  //## @ingroup Data
38  : public itk::DataObject, public OperationActor, public Identifiable, public IPropertyOwner
39  {
40  public:
41  mitkClassMacroItkParent(BaseData, itk::DataObject);
42 
43  // IPropertyProvider
44  BaseProperty::ConstPointer GetConstProperty(const std::string &propertyKey, const std::string &contextName = "", bool fallBackOnDefaultContext = true) const override;
45  std::vector<std::string> GetPropertyKeys(const std::string &contextName = "", bool includeDefaultContext = false) const override;
46  std::vector<std::string> GetPropertyContextNames() const override;
47 
48  // IPropertyOwner
49  BaseProperty * GetNonConstProperty(const std::string &propertyKey, const std::string &contextName = "", bool fallBackOnDefaultContext = true) override;
50  void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName = "", bool fallBackOnDefaultContext = false) override;
51  void RemoveProperty(const std::string &propertyKey, const std::string &contextName = "", bool fallBackOnDefaultContext = false) override;
52 
62  {
63  return m_TimeGeometry.GetPointer();
64  }
65 
76  DEPRECATED(const mitk::TimeGeometry *GetTimeSlicedGeometry() const) { return GetTimeGeometry(); }
85  mitk::TimeGeometry *GetTimeGeometry() { return m_TimeGeometry.GetPointer(); }
94  const mitk::TimeGeometry *GetUpdatedTimeGeometry();
95 
106  DEPRECATED(const mitk::TimeGeometry *GetUpdatedTimeSliceGeometry()) { return GetUpdatedTimeGeometry(); }
115  virtual void Expand(unsigned int timeSteps);
116 
128  const mitk::BaseGeometry *GetUpdatedGeometry(int t = 0);
129 
130  //##Documentation
131  //## @brief Return the geometry, which is a TimeGeometry, of the data
132  //## as non-const pointer.
133  //##
134  //## \warning No update will be called. Use GetUpdatedGeometry() if you cannot
135  //## be sure that the geometry is up-to-date.
136  //##
137  //## Normally used in GenerateOutputInformation of subclasses of BaseProcess.
138  mitk::BaseGeometry *GetGeometry(int t = 0) const
139  {
140  if (m_TimeGeometry.IsNull())
141  return nullptr;
142  return m_TimeGeometry->GetGeometryForTimeStep(t);
143  }
144 
145  //##Documentation
146  //## @brief Update the information for this BaseData (the geometry in particular)
147  //## so that it can be used as an output of a BaseProcess.
148  //##
149  //## This method is used in the pipeline mechanism to propagate information and
150  //## initialize the meta data associated with a BaseData. Any implementation
151  //## of this method in a derived class is assumed to call its source's
152  //## BaseProcess::UpdateOutputInformation() which determines modified
153  //## times, LargestPossibleRegions, and any extra meta data like spacing,
154  //## origin, etc. Default implementation simply call's it's source's
155  //## UpdateOutputInformation().
156  //## \note Implementations of this methods in derived classes must take care
157  //## that the geometry is updated by calling
158  //## GetTimeGeometry()->UpdateInformation()
159  //## \em after calling its source's BaseProcess::UpdateOutputInformation().
160  void UpdateOutputInformation() override;
161 
162  //##Documentation
163  //## @brief Set the RequestedRegion to the LargestPossibleRegion.
164  //##
165  //## This forces a filter to produce all of the output in one execution
166  //## (i.e. not streaming) on the next call to Update().
167  void SetRequestedRegionToLargestPossibleRegion() override = 0;
168 
169  //##Documentation
170  //## @brief Determine whether the RequestedRegion is outside of the BufferedRegion.
171  //##
172  //## This method returns true if the RequestedRegion
173  //## is outside the BufferedRegion (true if at least one pixel is
174  //## outside). This is used by the pipeline mechanism to determine
175  //## whether a filter needs to re-execute in order to satisfy the
176  //## current request. If the current RequestedRegion is already
177  //## inside the BufferedRegion from the previous execution (and the
178  //## current filter is up to date), then a given filter does not need
179  //## to re-execute
180  bool RequestedRegionIsOutsideOfTheBufferedRegion() override = 0;
181 
182  //##Documentation
183  //## @brief Verify that the RequestedRegion is within the LargestPossibleRegion.
184  //##
185  //## If the RequestedRegion is not within the LargestPossibleRegion,
186  //## then the filter cannot possibly satisfy the request. This method
187  //## returns true if the request can be satisfied (even if it will be
188  //## necessary to process the entire LargestPossibleRegion) and
189  //## returns false otherwise. This method is used by
190  //## PropagateRequestedRegion(). PropagateRequestedRegion() throws a
191  //## InvalidRequestedRegionError exception if the requested region is
192  //## not within the LargestPossibleRegion.
193  bool VerifyRequestedRegion() override = 0;
194 
195  //##Documentation
196  //## @brief Copy information from the specified data set.
197  //##
198  //## This method is part of the pipeline execution model. By default, a
199  //## BaseProcess will copy meta-data from the first input to all of its
200  //## outputs. See ProcessObject::GenerateOutputInformation(). Each
201  //## subclass of DataObject is responsible for being able to copy
202  //## whatever meta-data it needs from another DataObject.
203  //## The default implementation of this method copies the time sliced geometry
204  //## and the property list of an object. If a subclass overrides this
205  //## method, it should always call its superclass' version.
206  void CopyInformation(const itk::DataObject *data) override;
207 
208  //##Documentation
209  //## @brief Check whether the data has been initialized, i.e.,
210  //## at least the Geometry and other header data has been set
211  //##
212  //## \warning Set to \a true by default for compatibility reasons.
213  //## Set m_Initialized=false in constructors of sub-classes that
214  //## support distinction between initialized and uninitialized state.
215  virtual bool IsInitialized() const;
216 
217  //##Documentation
218  //## @brief Calls ClearData() and InitializeEmpty();
219  //## \warning Only use in subclasses that reimplemented these methods.
220  //## Just calling Clear from BaseData will reset an object to a not initialized,
221  //## invalid state.
222  virtual void Clear();
223 
224  //##Documentation
225  //## @brief Check whether object contains data (at
226  //## a specified time), e.g., a set of points may be empty
227  //##
228  //## \warning Returns IsInitialized()==false by default for
229  //## compatibility reasons. Override in sub-classes that
230  //## support distinction between empty/non-empty state.
231  virtual bool IsEmptyTimeStep(unsigned int t) const;
232 
233  //##Documentation
234  //## @brief Check whether object contains data (at
235  //## least at one point in time), e.g., a set of points
236  //## may be empty
237  //##
238  //## \warning Returns IsInitialized()==false by default for
239  //## compatibility reasons. Override in sub-classes that
240  //## support distinction between empty/non-empty state.
241  virtual bool IsEmpty() const;
242 
243  //##Documentation
244  //## @brief Set the requested region from this data object to match the requested
245  //## region of the data object passed in as a parameter.
246  //##
247  //## This method is implemented in the concrete subclasses of BaseData.
248  void SetRequestedRegion(const itk::DataObject *data) override = 0;
249 
250  //##Documentation
251  //##@brief overwrite if the Data can be called by an Interactor (StateMachine).
252  //##
253  //## Empty by default. Overwrite and implement all the necessary operations here
254  //## and get the necessary information from the parameter operation.
255  void ExecuteOperation(Operation *operation) override;
256 
267  virtual void SetGeometry(BaseGeometry *aGeometry3D);
268 
276  virtual void SetTimeGeometry(TimeGeometry *geometry);
277 
286  virtual void SetClonedGeometry(const BaseGeometry *aGeometry3D);
287 
293  virtual void SetClonedTimeGeometry(const TimeGeometry *geometry);
294 
295  //##Documentation
296  //## @brief Set a clone of the provided geometry as BaseGeometry of a given time step.
297  //##
298  //## \sa SetGeometry
299  virtual void SetClonedGeometry(const BaseGeometry *aGeometry3D, unsigned int time);
300 
301  //##Documentation
302  //## @brief Get the data's property list
303  //## @sa GetProperty
304  //## @sa m_PropertyList
305  mitk::PropertyList::Pointer GetPropertyList() const;
306 
307  //##Documentation
308  //## @brief Set the data's property list
309  //## @sa SetProperty
310  //## @sa m_PropertyList
311  void SetPropertyList(PropertyList *propertyList);
312 
313  //##Documentation
314  //## @brief Get the property (instance of BaseProperty) with key @a propertyKey from the PropertyList,
315  //## and set it to this, respectively;
316  //## @sa GetPropertyList
317  //## @sa m_PropertyList
318  //## @sa m_MapOfPropertyLists
319  mitk::BaseProperty::Pointer GetProperty(const char *propertyKey) const;
320 
321  void SetProperty(const char *propertyKey, BaseProperty *property);
322 
323  //##Documentation
324  //## @brief Convenience method for setting the origin of
325  //## the BaseGeometry instances of all time steps
326  //##
327  //## \warning Geometries contained in the BaseGeometry will
328  //## \em not be changed, e.g. in case the BaseGeometry is a
329  //## SlicedGeometry3D the origin will \em not be propagated
330  //## to the contained slices. The sub-class SlicedData
331  //## does this for the case that the SlicedGeometry3D is
332  //## evenly spaced.
333  virtual void SetOrigin(const Point3D &origin);
334 
348  itk::SmartPointer<mitk::BaseDataSource> GetSource() const;
349 
350  //##Documentation
351  //## @brief Get the number of time steps from the TimeGeometry
352  //## As the base data has not a data vector given by itself, the number
353  //## of time steps is defined over the time sliced geometry. In sub classes,
354  //## a better implementation could be over the length of the data vector.
355  unsigned int GetTimeSteps() const { return m_TimeGeometry->CountTimeSteps(); }
356  //##Documentation
357  //## @brief Get the modified time of the last change of the contents
358  //## this data object or its geometry.
359  unsigned long GetMTime() const override;
360 
364  void Graft(const DataObject *) override;
365 
366  protected:
367  BaseData();
368  BaseData(const BaseData &other);
369  ~BaseData() override;
370 
371  //##Documentation
372  //## \brief Initialize the TimeGeometry for a number of time steps.
373  //## The TimeGeometry is initialized empty and evenly timed.
374  //## In many cases it will be necessary to overwrite this in sub-classes.
375  virtual void InitializeTimeGeometry(unsigned int timeSteps = 1);
376 
384  DEPRECATED(virtual void InitializeTimeSlicedGeometry(unsigned int timeSteps = 1))
385  {
386  InitializeTimeGeometry(timeSteps);
387  }
388 
389  //##Documentation
390  //## @brief reset to non-initialized state, release memory
391  virtual void ClearData();
392 
393  //##Documentation
394  //## @brief Pure virtual; Must be used in subclasses to get a data object to a
395  //## valid state. Should at least create one empty object and call
396  //## Superclass::InitializeTimeGeometry() to ensure an existing valid geometry
397  virtual void InitializeEmpty() {}
398  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
399 
401 
402  mutable unsigned int m_SourceOutputIndexDuplicate;
403 
405 
406  private:
407  //##Documentation
408  //## @brief PropertyList, f.e. to hold pic-tags, tracking-data,..
409  //##
410  PropertyList::Pointer m_PropertyList;
411 
412  TimeGeometry::Pointer m_TimeGeometry;
413  };
414 
415 } // namespace mitk
416 
417 #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:76
Base of all data objects.
Definition: mitkBaseData.h:37
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:85
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:106
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:61
Abstract base class for properties.
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:49
bool m_LastRequestedRegionWasOutsideOfTheBufferedRegion
Definition: mitkBaseData.h:400
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:397
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:355
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:138
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:384
unsigned int m_SourceOutputIndexDuplicate
Definition: mitkBaseData.h:402
BaseGeometry Describes the geometry of a data object.