Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
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 
17 #ifndef BASEDATA_H_HEADER_INCLUDED_C1EBB6FA
18 #define BASEDATA_H_HEADER_INCLUDED_C1EBB6FA
19 
20 #include <itkDataObject.h>
21 
22 #include "mitkBaseProcess.h"
23 #include "mitkOperationActor.h"
24 #include "mitkPropertyList.h"
25 #include "mitkTimeGeometry.h"
26 #include <MitkCoreExports.h>
27 
28 namespace mitk
29 {
30  // class BaseProcess;
31 
32  //##Documentation
33  //## @brief Base of all data objects
34  //##
35  //## Base of all data objects, e.g., images, contours, surfaces etc. Inherits
36  //## from itk::DataObject and thus can be included in a pipeline.
37  //## Inherits also from OperationActor and can be used as a destination for Undo
38  //## @ingroup Data
39  class MITKCORE_EXPORT BaseData : public itk::DataObject, public OperationActor
40  {
41  public:
43 
44 
52  const mitk::TimeGeometry *GetTimeGeometry() const
53  {
54  return m_TimeGeometry.GetPointer();
55  }
56 
67  DEPRECATED(const mitk::TimeGeometry *GetTimeSlicedGeometry() const) { return GetTimeGeometry(); }
76  mitk::TimeGeometry *GetTimeGeometry() { return m_TimeGeometry.GetPointer(); }
85  const mitk::TimeGeometry *GetUpdatedTimeGeometry();
86 
97  DEPRECATED(const mitk::TimeGeometry *GetUpdatedTimeSliceGeometry()) { return GetUpdatedTimeGeometry(); }
106  virtual void Expand(unsigned int timeSteps);
107 
119  const mitk::BaseGeometry *GetUpdatedGeometry(int t = 0);
120 
121  //##Documentation
122  //## @brief Return the geometry, which is a TimeGeometry, of the data
123  //## as non-const pointer.
124  //##
125  //## \warning No update will be called. Use GetUpdatedGeometry() if you cannot
126  //## be sure that the geometry is up-to-date.
127  //##
128  //## Normally used in GenerateOutputInformation of subclasses of BaseProcess.
129  mitk::BaseGeometry *GetGeometry(int t = 0) const
130  {
131  if (m_TimeGeometry.IsNull())
132  return nullptr;
133  return m_TimeGeometry->GetGeometryForTimeStep(t);
134  }
135 
136  //##Documentation
137  //## @brief Update the information for this BaseData (the geometry in particular)
138  //## so that it can be used as an output of a BaseProcess.
139  //##
140  //## This method is used in the pipeline mechanism to propagate information and
141  //## initialize the meta data associated with a BaseData. Any implementation
142  //## of this method in a derived class is assumed to call its source's
143  //## BaseProcess::UpdateOutputInformation() which determines modified
144  //## times, LargestPossibleRegions, and any extra meta data like spacing,
145  //## origin, etc. Default implementation simply call's it's source's
146  //## UpdateOutputInformation().
147  //## \note Implementations of this methods in derived classes must take care
148  //## that the geometry is updated by calling
149  //## GetTimeGeometry()->UpdateInformation()
150  //## \em after calling its source's BaseProcess::UpdateOutputInformation().
151  void UpdateOutputInformation() override;
152 
153  //##Documentation
154  //## @brief Set the RequestedRegion to the LargestPossibleRegion.
155  //##
156  //## This forces a filter to produce all of the output in one execution
157  //## (i.e. not streaming) on the next call to Update().
158  virtual void SetRequestedRegionToLargestPossibleRegion() override = 0;
159 
160  //##Documentation
161  //## @brief Determine whether the RequestedRegion is outside of the BufferedRegion.
162  //##
163  //## This method returns true if the RequestedRegion
164  //## is outside the BufferedRegion (true if at least one pixel is
165  //## outside). This is used by the pipeline mechanism to determine
166  //## whether a filter needs to re-execute in order to satisfy the
167  //## current request. If the current RequestedRegion is already
168  //## inside the BufferedRegion from the previous execution (and the
169  //## current filter is up to date), then a given filter does not need
170  //## to re-execute
171  virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() override = 0;
172 
173  //##Documentation
174  //## @brief Verify that the RequestedRegion is within the LargestPossibleRegion.
175  //##
176  //## If the RequestedRegion is not within the LargestPossibleRegion,
177  //## then the filter cannot possibly satisfy the request. This method
178  //## returns true if the request can be satisfied (even if it will be
179  //## necessary to process the entire LargestPossibleRegion) and
180  //## returns false otherwise. This method is used by
181  //## PropagateRequestedRegion(). PropagateRequestedRegion() throws a
182  //## InvalidRequestedRegionError exception if the requested region is
183  //## not within the LargestPossibleRegion.
184  virtual bool VerifyRequestedRegion() override = 0;
185 
186  //##Documentation
187  //## @brief Copy information from the specified data set.
188  //##
189  //## This method is part of the pipeline execution model. By default, a
190  //## BaseProcess will copy meta-data from the first input to all of its
191  //## outputs. See ProcessObject::GenerateOutputInformation(). Each
192  //## subclass of DataObject is responsible for being able to copy
193  //## whatever meta-data it needs from another DataObject.
194  //## The default implementation of this method copies the time sliced geometry
195  //## and the property list of an object. If a subclass overrides this
196  //## method, it should always call its superclass' version.
197  void CopyInformation(const itk::DataObject *data) override;
198 
199  //##Documentation
200  //## @brief Check whether the data has been initialized, i.e.,
201  //## at least the Geometry and other header data has been set
202  //##
203  //## \warning Set to \a true by default for compatibility reasons.
204  //## Set m_Initialized=false in constructors of sub-classes that
205  //## support distinction between initialized and uninitialized state.
206  virtual bool IsInitialized() const;
207 
208  //##Documentation
209  //## @brief Calls ClearData() and InitializeEmpty();
210  //## \warning Only use in subclasses that reimplemented these methods.
211  //## Just calling Clear from BaseData will reset an object to a not initialized,
212  //## invalid state.
213  virtual void Clear();
214 
215  //##Documentation
216  //## @brief Check whether object contains data (at
217  //## a specified time), e.g., a set of points may be empty
218  //##
219  //## \warning Returns IsInitialized()==false by default for
220  //## compatibility reasons. Override in sub-classes that
221  //## support distinction between empty/non-empty state.
222  virtual bool IsEmptyTimeStep(unsigned int t) const;
223 
224  //##Documentation
225  //## @brief Check whether object contains data (at
226  //## least at one point in time), e.g., a set of points
227  //## may be empty
228  //##
229  //## \warning Returns IsInitialized()==false by default for
230  //## compatibility reasons. Override in sub-classes that
231  //## support distinction between empty/non-empty state.
232  virtual bool IsEmpty() const;
233 
234  //##Documentation
235  //## @brief Set the requested region from this data object to match the requested
236  //## region of the data object passed in as a parameter.
237  //##
238  //## This method is implemented in the concrete subclasses of BaseData.
239  virtual void SetRequestedRegion(const itk::DataObject *data) override = 0;
240 
241  //##Documentation
242  //##@brief overwrite if the Data can be called by an Interactor (StateMachine).
243  //##
244  //## Empty by default. Overwrite and implement all the necessary operations here
245  //## and get the necessary information from the parameter operation.
246  void ExecuteOperation(Operation *operation) override;
247 
258  virtual void SetGeometry(BaseGeometry *aGeometry3D);
259 
267  virtual void SetTimeGeometry(TimeGeometry *geometry);
268 
277  virtual void SetClonedGeometry(const BaseGeometry *aGeometry3D);
278 
284  virtual void SetClonedTimeGeometry(const TimeGeometry *geometry);
285 
286  //##Documentation
287  //## @brief Set a clone of the provided geometry as BaseGeometry of a given time step.
288  //##
289  //## \sa SetGeometry
290  virtual void SetClonedGeometry(const BaseGeometry *aGeometry3D, unsigned int time);
291 
292  //##Documentation
293  //## @brief Get the data's property list
294  //## @sa GetProperty
295  //## @sa m_PropertyList
296  mitk::PropertyList::Pointer GetPropertyList() const;
297 
298  //##Documentation
299  //## @brief Set the data's property list
300  //## @sa SetProperty
301  //## @sa m_PropertyList
302  void SetPropertyList(PropertyList *propertyList);
303 
304  //##Documentation
305  //## @brief Get the property (instance of BaseProperty) with key @a propertyKey from the PropertyList,
306  //## and set it to this, respectively;
307  //## @sa GetPropertyList
308  //## @sa m_PropertyList
309  //## @sa m_MapOfPropertyLists
310  mitk::BaseProperty::Pointer GetProperty(const char *propertyKey) const;
311 
312  void SetProperty(const char *propertyKey, BaseProperty *property);
313 
314  //##Documentation
315  //## @brief Convenience method for setting the origin of
316  //## the BaseGeometry instances of all time steps
317  //##
318  //## \warning Geometries contained in the BaseGeometry will
319  //## \em not be changed, e.g. in case the BaseGeometry is a
320  //## SlicedGeometry3D the origin will \em not be propagated
321  //## to the contained slices. The sub-class SlicedData
322  //## does this for the case that the SlicedGeometry3D is
323  //## evenly spaced.
324  virtual void SetOrigin(const Point3D &origin);
325 
339  itk::SmartPointer<mitk::BaseDataSource> GetSource() const;
340 
341  //##Documentation
342  //## @brief Get the number of time steps from the TimeGeometry
343  //## As the base data has not a data vector given by itself, the number
344  //## of time steps is defined over the time sliced geometry. In sub classes,
345  //## a better implementation could be over the length of the data vector.
346  unsigned int GetTimeSteps() const { return m_TimeGeometry->CountTimeSteps(); }
347  //##Documentation
348  //## @brief Get the modified time of the last change of the contents
349  //## this data object or its geometry.
350  virtual unsigned long GetMTime() const override;
351 
355  virtual void Graft(const DataObject *) override;
356 
357  protected:
358  BaseData();
359  BaseData(const BaseData &other);
360  ~BaseData();
361 
362  //##Documentation
363  //## \brief Initialize the TimeGeometry for a number of time steps.
364  //## The TimeGeometry is initialized empty and evenly timed.
365  //## In many cases it will be necessary to overwrite this in sub-classes.
366  virtual void InitializeTimeGeometry(unsigned int timeSteps = 1);
367 
375  DEPRECATED(virtual void InitializeTimeSlicedGeometry(unsigned int timeSteps = 1))
376  {
377  InitializeTimeGeometry(timeSteps);
378  }
379 
380  //##Documentation
381  //## @brief reset to non-initialized state, release memory
382  virtual void ClearData();
383 
384  //##Documentation
385  //## @brief Pure virtual; Must be used in subclasses to get a data object to a
386  //## valid state. Should at least create one empty object and call
387  //## Superclass::InitializeTimeGeometry() to ensure an existing valid geometry
388  virtual void InitializeEmpty() {}
389  virtual void PrintSelf(std::ostream &os, itk::Indent indent) const override;
390 
392 
393  mutable unsigned int m_SourceOutputIndexDuplicate;
394 
396 
397  private:
398  //##Documentation
399  //## @brief PropertyList, f.e. to hold pic-tags, tracking-data,..
400  //##
401  PropertyList::Pointer m_PropertyList;
402 
403  TimeGeometry::Pointer m_TimeGeometry;
404  };
405 
406 } // namespace mitk
407 
408 #endif /* BASEDATA_H_HEADER_INCLUDED_C1EBB6FA */
#define MITKCORE_EXPORT
Base of all data objects.
Definition: mitkBaseData.h:39
Base class of all Operation-classes.
Definition: mitkOperation.h:33
DataCollection - Class to facilitate loading/accessing structured data.
mitk::TimeGeometry * GetTimeGeometry()
Return the TimeGeometry of the data as pointer.
Definition: mitkBaseData.h:76
Key-value list holding instances of BaseProperty.
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:346
abstract class, that can be used by Undo to undo an operation.
#define DEPRECATED(func)
Definition: mitkCommon.h:183
const mitk::TimeGeometry * GetUpdatedTimeSliceGeometry()
Return the TimeGeometry of the data.
Definition: mitkBaseData.h:97
Abstract base class for properties.
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
const mitk::TimeGeometry * GetTimeSlicedGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:67
bool m_LastRequestedRegionWasOutsideOfTheBufferedRegion
Definition: mitkBaseData.h:391
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:388
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:129
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:375
unsigned int m_SourceOutputIndexDuplicate
Definition: mitkBaseData.h:393
BaseGeometry Describes the geometry of a data object.