ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkVideoStream.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkVideoStream_h
00019 #define __itkVideoStream_h
00020 
00021 #include "itkTemporalDataObject.h"
00022 #include "itkImage.h"
00023 
00024 namespace itk
00025 {
00026 
00040 template<class TFrameType>
00041 class ITK_EXPORT VideoStream : public TemporalDataObject
00042 {
00043 public:
00044 
00046   typedef VideoStream                       Self;
00047   typedef TemporalDataObject                Superclass;
00048   typedef SmartPointer< Self >              Pointer;
00049   typedef SmartPointer< const Self >        ConstPointer;
00050   typedef WeakPointer< const Self >         ConstWeakPointer;
00051 
00052   typedef TFrameType                        FrameType;
00053   typedef typename FrameType::Pointer       FramePointer;
00054   typedef typename FrameType::ConstPointer  FrameConstPointer;
00055   typedef typename Superclass::BufferType   BufferType;
00056 
00057   typedef typename FrameType::RegionType    SpatialRegionType;
00058   typedef typename FrameType::IndexType     IndexType;
00059   typedef typename FrameType::PixelType     PixelType;
00060   typedef typename FrameType::PointType     PointType;
00061   typedef typename FrameType::SpacingType   SpacingType;
00062   typedef typename FrameType::SizeType      SizeType;
00063   typedef typename FrameType::DirectionType DirectionType;
00064 
00066   typedef typename std::map<SizeValueType, SpatialRegionType> SpatialRegionMapType;
00067   typedef typename std::map<SizeValueType, PointType>         PointMapType;
00068   typedef typename std::map<SizeValueType, DirectionType>     DirectionMapType;
00069   typedef typename std::map<SizeValueType, SpacingType>       SpacingMapType;
00070 
00072   itkStaticConstMacro(FrameDimension, unsigned int, FrameType::ImageDimension);
00073   static unsigned int GetFrameDimension()
00074   {
00075     return FrameType::ImageDimension;
00076   }
00078 
00079   itkNewMacro(Self);
00080 
00082   itkTypeMacro(VideoStream, TemporalDataObject);
00083 
00085   void SetMinimumBufferSize(SizeValueType minimumNumberOfFrames);
00086 
00093   void InitializeEmptyFrames();
00094 
00096   BufferType* GetFrameBuffer()
00097   {
00098     return reinterpret_cast<BufferType*>(m_DataObjectBuffer.GetPointer() );
00099   }
00100   const BufferType* GetFrameBuffer() const
00101   {
00102     return reinterpret_cast<BufferType*>(m_DataObjectBuffer.GetPointer() );
00103   }
00105 
00107   void SetFrameBuffer(BufferType* buffer);
00108 
00110   const SpatialRegionMapType & GetLargestPossibleSpatialRegionCache() const
00111   {
00112     return m_LargestPossibleSpatialRegionCache;
00113   }
00114   void SetLargestPossibleSpatialRegionCache(SpatialRegionMapType map)
00115   {
00116     m_LargestPossibleSpatialRegionCache = map;
00117   }
00119 
00120   const SpatialRegionMapType & GetRequestedSpatialRegionCache() const
00121   {
00122     return m_RequestedSpatialRegionCache;
00123   }
00124   void SetRequestedSpatialRegionCache(SpatialRegionMapType map)
00125   {
00126     m_RequestedSpatialRegionCache = map;
00127   }
00128 
00129   const SpatialRegionMapType & GetBufferedSpatialRegionCache() const
00130   {
00131     return m_BufferedSpatialRegionCache;
00132   }
00133   void SetBufferedSpatialRegionCache(SpatialRegionMapType map)
00134   {
00135     m_BufferedSpatialRegionCache = map;
00136   }
00137 
00138   const SpacingMapType & GetSpacingCache() const
00139   {
00140     return m_SpacingCache;
00141   }
00142   void SetSpacingCache(SpacingMapType map)
00143   {
00144     m_SpacingCache = map;
00145   }
00146 
00147   const PointMapType & GetOriginCache() const
00148   {
00149     return m_OriginCache;
00150   }
00151   void SetOriginCache(PointMapType map)
00152   {
00153     m_OriginCache = map;
00154   }
00155 
00156   const DirectionMapType & GetDirectionCache() const
00157   {
00158     return m_DirectionCache;
00159   }
00160   void SetDirectionCache(DirectionMapType map)
00161   {
00162     m_DirectionCache = map;
00163   }
00164 
00166   void SetFrame(SizeValueType frameNumber, FramePointer frame);
00167 
00172   FramePointer GetFrame(SizeValueType frameNumber);
00173   FrameConstPointer GetFrame(SizeValueType frameNumber) const;
00175 
00177   void SetFrameLargestPossibleSpatialRegion(SizeValueType frameNumber,
00178                                             SpatialRegionType region);
00179 
00180   const SpatialRegionType &
00181   GetFrameLargestPossibleSpatialRegion(SizeValueType frameNumber) const;
00182 
00184   void SetFrameRequestedSpatialRegion(SizeValueType frameNumber,
00185                                       SpatialRegionType region);
00186 
00187   const SpatialRegionType &
00188   GetFrameRequestedSpatialRegion(SizeValueType frameNumber) const;
00189 
00191   void SetFrameBufferedSpatialRegion(SizeValueType frameNumber,
00192                                      SpatialRegionType region);
00193 
00194   const SpatialRegionType &
00195   GetFrameBufferedSpatialRegion(SizeValueType frameNumber) const;
00196 
00198   void SetFrameSpacing(SizeValueType frameNumber, SpacingType spacing);
00199 
00200   const SpacingType & GetFrameSpacing(SizeValueType frameNumber) const;
00201 
00203   void SetFrameOrigin(SizeValueType frameNumber, PointType origin);
00204 
00205   const PointType & GetFrameOrigin(SizeValueType frameNumber) const;
00206 
00208   void SetFrameDirection(SizeValueType frameNumber, DirectionType direction);
00209 
00210   const DirectionType & GetFrameDirection(SizeValueType frameNumber) const;
00211 
00215   void SetAllLargestPossibleSpatialRegions(SpatialRegionType region);
00216 
00220   void SetAllRequestedSpatialRegions(SpatialRegionType region);
00221 
00225   void SetAllBufferedSpatialRegions(SpatialRegionType region);
00226 
00230   void SetAllFramesSpacing(SpacingType spacing);
00231 
00235   void SetAllFramesOrigin(PointType origin);
00236 
00240   void SetAllFramesDirection(DirectionType direction);
00241 
00274   void Allocate();
00276 
00281   virtual void Graft(const DataObject* data);
00282 
00283 protected:
00284 
00285   VideoStream() {
00286   }
00287   virtual ~VideoStream() {
00288   }
00289   virtual void PrintSelf(std::ostream & os, Indent indent) const
00290   {
00291     Superclass::Print(os, indent);
00292   }
00293 
00297   SpatialRegionMapType m_LargestPossibleSpatialRegionCache;
00298   SpatialRegionMapType m_RequestedSpatialRegionCache;
00299   SpatialRegionMapType m_BufferedSpatialRegionCache;
00300 
00303   SpacingMapType       m_SpacingCache;
00304   DirectionMapType     m_DirectionCache;
00305   PointMapType         m_OriginCache;
00306 private:
00307 
00308   VideoStream(const Self &);    //purposely not implemented
00309   void operator=(const Self &); //purposely not implemented
00310 
00311 };  // end class VideoStream
00312 
00313 } // end namespace itk
00314 
00315 #if ITK_TEMPLATE_TXX
00316 #include "itkVideoStream.hxx"
00317 #endif
00318 
00319 #endif
00320