00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 00019 #ifndef TIMESLICEDGEOMETRY_H_HEADER_INCLUDED_C1EBD0AD 00020 #define TIMESLICEDGEOMETRY_H_HEADER_INCLUDED_C1EBD0AD 00021 00022 #include "mitkGeometry3D.h" 00023 00024 namespace mitk { 00025 00026 //##Documentation 00027 //## @brief Describes a geometry consisting of several geometries which 00028 //## exist at different times. 00029 //## 00030 //## The geometry contains m_TimeSteps geometries, which can be accessed 00031 //## using GetGeometry3D(int t). To convert between world-time in 00032 //## milliseconds and the integer timestep-number use MSToTimeStep. 00033 //## The hull (in space and time) of the TimeSlicedGeometry contains all 00034 //## contained geometries. 00035 //## @warning The hull (i.e., transform, bounding-box and 00036 //## time-bounds) is only guaranteed to be up-to-date after calling 00037 //## UpdateInformation(). 00038 //## 00039 //## TimeSlicedGeometry and the associated Geometry3Ds have to be 00040 //## initialized in the method GenerateOutputInformation() of BaseProcess (or 00041 //## CopyInformation/ UpdateOutputInformation of BaseData, if possible, e.g., 00042 //## by analyzing pic tags in Image) subclasses. See also 00043 //## itk::ProcessObject::GenerateOutputInformation(), 00044 //## itk::DataObject::CopyInformation() and 00045 //## itk::DataObject::UpdateOutputInformation(). 00046 //## 00047 //## @ingroup Geometry 00048 class MITK_CORE_EXPORT TimeSlicedGeometry : public Geometry3D 00049 { 00050 public: 00051 mitkClassMacro(TimeSlicedGeometry, Geometry3D); 00052 00053 itkNewMacro(Self); 00054 00055 //##Documentation 00056 //## @brief Re-calculate the hull of the contained geometries. 00057 //## 00058 //## The transforms, bounding-box and time-bounds of this 00059 //## geometry (stored in members of the super-class Geometry3D) 00060 //## are re-calculated from the contained geometries. 00061 void UpdateInformation(); 00062 00063 //##Documentation 00064 //## @brief Get the number of time-steps 00065 itkGetConstMacro(TimeSteps, unsigned int); 00066 00067 //##Documentation 00068 //## @brief Set/Get whether the TimeSlicedGeometry is evenly-timed (m_EvenlyTimed) 00069 //## 00070 //## If (a) we don't have a Geometry3D stored for the requested time, 00071 //## (b) m_EvenlyTimed is activated and (c) the first geometry (t=0) 00072 //## is set, then we clone the geometry and set the m_TimeBounds accordingly. 00073 //## \sa GetGeometry3D 00074 itkGetConstMacro(EvenlyTimed, bool); 00075 virtual void SetEvenlyTimed(bool on = true); 00076 00077 //##Documentation 00078 //## @brief Set the Geometry3D for time @a t 00079 virtual bool SetGeometry3D(mitk::Geometry3D* geometry3D, int t); 00080 00081 //##Documentation 00082 //## @brief Get the Geometry3D at time @a t 00083 virtual mitk::Geometry3D* GetGeometry3D(int t) const; 00084 00085 //##Documentation 00086 //## @brief Test whether @a t is a valid time step 00087 virtual bool IsValidTime(int t) const; 00088 00089 //##Documentation 00090 //## @brief Convert time in ms to a time step 00091 virtual int MSToTimeStep(mitk::ScalarType time_in_ms) const; 00092 00093 //##Documentation 00094 //## @brief Convert time step to time in ms 00095 virtual mitk::ScalarType TimeStepToMS(int timestep) const; 00096 00097 //##Documentation 00098 //## @brief Convert time step in the reference TimeSlicedGeometry to time step 00099 //## in this TimeSlicedGeometry. 00100 virtual int TimeStepToTimeStep(const mitk::TimeSlicedGeometry *referenceGeometry, int t) const; 00101 00102 //##Documentation 00103 //## @brief Completely initialize this instance as evenly-timed with 00104 //## \a timeSteps geometries of type Geometry3D, each initialized by 00105 //## Geometry3D::Initialize(). 00106 virtual void Initialize(unsigned int timeSteps); 00107 00108 //##Documentation 00109 //## @brief Completely initialize this instance as evenly-timed with 00110 //## \a timeSteps geometries identical to the provided Geometry3D 00111 //## except for the time bounds 00112 virtual void InitializeEvenlyTimed(mitk::Geometry3D* geometry3D, unsigned int timeSteps); 00113 00114 //##Documentation 00115 //## @brief Initialize this instance to contain \a timeSteps 00116 //## geometries, but without setting them yet 00117 virtual void InitializeEmpty(unsigned int timeSteps); 00118 00119 //##Documentation 00120 //## @brief Expand the number of time steps contained 00121 //## to \a timeSteps. 00122 //## 00123 //## New, additional time steps will be initialized empty. 00124 //## Only enlargement of the time steps vector is intended and possible. 00125 virtual void ExpandToNumberOfTimeSteps( unsigned int timeSteps ); 00126 00127 virtual void SetImageGeometry(const bool isAnImageGeometry); 00128 00129 //##Documentation 00130 //## @brief Copy the m_TimeBounds of the geometries contained 00131 //## in timeslicedgeometry into the geometries contained in this 00132 //## TimeSlicedGeometry object. 00133 //## 00134 //## Useful for initialization of the TimeSlicedGeometry of the 00135 //## output in GenerateOutputInformation() methods of process objects, 00136 //## see for example BoundingObjectCutter::GenerateOutputInformation(). 00137 //## @param t start time index 00138 //## @param endtimeindex (endtimeindex) is the time index of 00139 //## the last geometry whose time-bounds are copied. If 00140 //## timeslicedgeometry or this TimeSlicedGeometry object does 00141 //## not contain enough geometries, endtimeindex is reduced 00142 //## appropriately. 00143 void CopyTimes(const mitk::TimeSlicedGeometry* timeslicedgeometry, unsigned int t=0, unsigned int endtimeindex = itk::NumericTraits<unsigned int>::max()); 00144 00145 //##Documentation 00146 //## @brief duplicates the geometry 00147 virtual AffineGeometryFrame3D::Pointer Clone() const; 00148 00149 virtual void ExecuteOperation(Operation* operation); 00150 protected: 00151 TimeSlicedGeometry(); 00152 00153 virtual ~TimeSlicedGeometry(); 00154 00155 void InitializeGeometry(Self * newGeometry) const; 00156 00157 virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; 00158 00159 mutable std::vector<Geometry3D::Pointer> m_Geometry3Ds; 00160 00161 //##Documentation 00162 //## @brief Number of time steps 00163 unsigned int m_TimeSteps; 00164 00165 //##Documentation 00166 //## @brief \a true in case the time steps have equal length 00167 bool m_EvenlyTimed; 00168 00169 static const std::string EVENLY_TIMED; 00170 static const std::string TIME_STEPS; 00171 }; 00172 00173 } // namespace mitk 00174 00175 #endif /* TIMESLICEDGEOMETRY_H_HEADER_INCLUDED_C1EBD0AD */