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 http://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 SLICEDDATA_H_HEADER_INCLUDED 00020 #define SLICEDDATA_H_HEADER_INCLUDED 00021 00022 #include "mitkCommon.h" 00023 #include "mitkBaseData.h" 00024 #include "mitkTimeSlicedGeometry.h" 00025 #include "mitkSlicedGeometry3D.h" 00026 #include "itkIndex.h" 00027 #include "itkOffset.h" 00028 #include "itkSize.h" 00029 #include "itkImageRegion.h" 00030 00031 namespace mitk { 00032 00033 class SlicedGeometry3D; 00034 00035 //##Documentation 00036 //## @brief Super class of data objects consisting of slices 00037 //## 00038 //## Super class of data objects consisting of slices, e.g., images or a stack 00039 //## of contours. (GetGeometry will return a Geometry3D containing Geometry2D 00040 //## objects). 00041 //## 00042 //## SlicedData-objects have geometries of type SlicedGeometry3D or sub-classes. 00043 //## @ingroup Data 00044 class MITK_CORE_EXPORT SlicedData : public BaseData 00045 { 00046 public: 00047 mitkClassMacro(SlicedData, BaseData); 00048 00049 itkStaticConstMacro(RegionDimension, unsigned int, 5); 00050 00052 typedef itk::ImageRegion<RegionDimension> RegionType; 00053 00055 typedef itk::Index<RegionDimension> IndexType; 00056 typedef IndexType::IndexValueType IndexValueType; 00057 00060 typedef itk::Offset<RegionDimension> OffsetType; 00061 typedef OffsetType::OffsetValueType OffsetValueType; 00062 00064 typedef itk::Size<RegionDimension> SizeType; 00065 typedef SizeType::SizeValueType SizeValueType; 00066 00067 //##Documentation 00068 //## Update the information for this DataObject so that it can be used as 00069 //## an output of a ProcessObject. This method is used in the pipeline 00070 //## mechanism to propagate information and initialize the meta data 00071 //## associated with a itk::DataObject. Any implementation of this method 00072 //## in a derived class of itk::DataObject is assumed to call its source's 00073 //## ProcessObject::UpdateOutputInformation() which determines modified 00074 //## times, LargestPossibleRegions, and any extra meta data like spacing, 00075 //## origin, etc. 00076 virtual void UpdateOutputInformation(); 00077 00078 virtual void PrepareForNewData(); 00079 00080 //##Documentation 00081 //## Set the RequestedRegion to the LargestPossibleRegion. This forces a 00082 //## filter to produce all of the output in one execution (i.e. not 00083 //## streaming) on the next call to Update(). 00084 virtual void SetRequestedRegionToLargestPossibleRegion(); 00085 00086 //##Documentation 00087 //## Determine whether the RequestedRegion is outside of the 00088 //## BufferedRegion. This method returns true if the RequestedRegion is 00089 //## outside the BufferedRegion (true if at least one pixel is outside). 00090 //## This is used by the pipeline mechanism to determine whether a filter 00091 //## needs to re-execute in order to satisfy the current request. If the 00092 //## current RequestedRegion is already inside the BufferedRegion from the 00093 //## previous execution (and the current filter is up to date), then a 00094 //## given filter does not need to re-execute 00095 virtual bool RequestedRegionIsOutsideOfTheBufferedRegion(); 00096 00097 //##Documentation 00098 //## @brief Verify that the RequestedRegion is within the 00099 //## LargestPossibleRegion. 00100 //## 00101 //## Verify that the RequestedRegion is within the LargestPossibleRegion. 00102 //## If the RequestedRegion is not within the LargestPossibleRegion, 00103 //## then the filter cannot possibly satisfy the request. This method 00104 //## returns true if the request can be satisfied (even if it will be 00105 //## necessary to process the entire LargestPossibleRegion) and 00106 //## returns false otherwise. This method is used by 00107 //## PropagateRequestedRegion(). PropagateRequestedRegion() throws a 00108 //## InvalidRequestedRegionError exception if the requested region is 00109 //## not within the LargestPossibleRegion. 00110 virtual bool VerifyRequestedRegion(); 00111 00112 //##Documentation 00113 //## Set the requested region from this data object to match the requested 00114 //## region of the data object passed in as a parameter. This method is 00115 //## implemented in the concrete subclasses of DataObject. 00116 virtual void SetRequestedRegion(itk::DataObject *data); 00117 00118 //##Documentation 00119 //## Set the requested region from this data object to match the requested 00120 //## region of the data object passed in as a parameter. This method is 00121 //## implemented in the concrete subclasses of DataObject. 00122 virtual void SetRequestedRegion(SlicedData::RegionType *region); 00123 00124 const RegionType& GetLargestPossibleRegion() const 00125 { 00126 return m_LargestPossibleRegion; 00127 } 00128 00129 //##Documentation 00130 //## Get the region object that defines the size and starting index 00131 //## for the region of the image requested (i.e., the region of the 00132 //## image to be operated on by a filter). 00133 virtual const RegionType& GetRequestedRegion() const 00134 { 00135 return m_RequestedRegion; 00136 } 00137 00138 virtual bool IsSliceSet(int s = 0, int t = 0, int n = 0) const = 0; 00139 virtual bool IsVolumeSet(int t = 0, int n = 0) const = 0; 00140 virtual bool IsChannelSet(int n = 0) const = 0; 00141 virtual void CopyInformation(const itk::DataObject *data); 00142 00143 //##Documentation 00144 //## @brief Get the number of channels 00145 unsigned int GetNumberOfChannels() const 00146 { 00147 return m_LargestPossibleRegion.GetSize(4); 00148 } 00149 00160 //virtual const mitk::Geometry2D* GetGeometry2D(int s, int t=0) const; 00161 00162 //##Documentation 00163 //## @brief Convenience access method for the geometry, which is of type SlicedGeometry3D (or a sub-class of it). 00164 //## 00165 //## @em No update will be called. Normally used in GenerateOutputInformation of 00166 //## subclasses of BaseProcess. 00167 SlicedGeometry3D* GetSlicedGeometry(unsigned int t=0) const; 00168 00169 //##Documentation 00170 //## @brief Convenience access method for the geometry, which is of type SlicedGeometry3D (or a sub-class of it). 00171 //## 00172 //## The method does not simply return the value of the m_Geometry3D member. 00173 //## Before doing this, it makes sure that the Geometry3D is up-to-date before 00174 //## returning it (by setting the update extent appropriately and calling 00175 //## UpdateOutputInformation). 00176 //## 00177 //## @warning GetGeometry not yet completely implemented. 00178 //## @todo Appropriate setting of the update extent is missing. 00179 const SlicedGeometry3D* GetUpdatedSlicedGeometry(unsigned int t=0); 00180 00181 //##Documentation 00182 //## @brief Set the Geometry3D of the data, which will be referenced (not copied!). It 00183 //## has to be a sub-class of SlicedGeometry3D. 00184 //## 00185 //## @warning This method will normally be called internally by the sub-class of SlicedData 00186 //## during initialization. 00187 virtual void SetGeometry(Geometry3D* aGeometry3D); 00188 00189 //##Documentation 00190 //## @brief Convenience method for setting the origin of 00191 //## the SlicedGeometry3D instances of all time steps 00192 //## 00193 //## In case the SlicedGeometry3D is evenly spaced, 00194 //## the origin of the first slice is set to \a origin. 00195 //## \sa mitk::BaseData::SetOrigin 00196 virtual void SetOrigin(const Point3D& origin); 00197 00198 //##Documentation 00199 //## @brief Convenience method for setting the spacing of 00200 //## the SlicedGeometry3D instances of all time steps 00201 virtual void SetSpacing(const float aSpacing[3]); 00202 00203 //##Documentation 00204 //## @brief Convenience method for setting the spacing of 00205 //## the SlicedGeometry3D instances of all time steps 00206 virtual void SetSpacing(mitk::Vector3D aSpacing); 00207 00208 protected: 00209 00210 SlicedData(); 00211 virtual ~SlicedData(); 00212 00213 RegionType m_LargestPossibleRegion; 00214 00215 RegionType m_RequestedRegion; 00216 RegionType m_BufferedRegion; 00217 bool m_UseLargestPossibleRegion; 00218 }; 00219 00220 } // namespace mitk 00221 00222 #endif /* SLICEDDATA_H_HEADER_INCLUDED */