ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkVideoStream.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkVideoStream_h
19 #define __itkVideoStream_h
20 
21 #include "itkTemporalDataObject.h"
22 #include "itkImage.h"
23 
24 namespace itk
25 {
26 
40 template<class TFrameType>
41 class ITK_EXPORT VideoStream : public TemporalDataObject
42 {
43 public:
44 
46  typedef VideoStream Self;
51 
52  typedef TFrameType FrameType;
53  typedef typename FrameType::Pointer FramePointer;
54  typedef typename FrameType::ConstPointer FrameConstPointer;
55  typedef typename Superclass::BufferType BufferType;
56 
57  typedef typename FrameType::RegionType SpatialRegionType;
58  typedef typename FrameType::IndexType IndexType;
59  typedef typename FrameType::PixelType PixelType;
60  typedef typename FrameType::PointType PointType;
61  typedef typename FrameType::SpacingType SpacingType;
62  typedef typename FrameType::SizeType SizeType;
63  typedef typename FrameType::DirectionType DirectionType;
64 
66  typedef typename std::map<SizeValueType, SpatialRegionType> SpatialRegionMapType;
67  typedef typename std::map<SizeValueType, PointType> PointMapType;
68  typedef typename std::map<SizeValueType, DirectionType> DirectionMapType;
69  typedef typename std::map<SizeValueType, SpacingType> SpacingMapType;
70 
72  itkStaticConstMacro(FrameDimension, unsigned int, FrameType::ImageDimension);
73  static unsigned int GetFrameDimension()
74  {
75  return FrameType::ImageDimension;
76  }
78 
79  itkNewMacro(Self);
80 
82  itkTypeMacro(VideoStream, TemporalDataObject);
83 
85  void SetMinimumBufferSize(SizeValueType minimumNumberOfFrames);
86 
93  void InitializeEmptyFrames();
94 
96  BufferType* GetFrameBuffer()
97  {
98  return reinterpret_cast<BufferType*>(m_DataObjectBuffer.GetPointer() );
99  }
100  const BufferType* GetFrameBuffer() const
101  {
102  return reinterpret_cast<BufferType*>(m_DataObjectBuffer.GetPointer() );
103  }
105 
107  void SetFrameBuffer(BufferType* buffer);
108 
110  const SpatialRegionMapType & GetLargestPossibleSpatialRegionCache() const
111  {
112  return m_LargestPossibleSpatialRegionCache;
113  }
114  void SetLargestPossibleSpatialRegionCache(SpatialRegionMapType map)
115  {
116  m_LargestPossibleSpatialRegionCache = map;
117  }
119 
120  const SpatialRegionMapType & GetRequestedSpatialRegionCache() const
121  {
122  return m_RequestedSpatialRegionCache;
123  }
124  void SetRequestedSpatialRegionCache(SpatialRegionMapType map)
125  {
126  m_RequestedSpatialRegionCache = map;
127  }
128 
129  const SpatialRegionMapType & GetBufferedSpatialRegionCache() const
130  {
131  return m_BufferedSpatialRegionCache;
132  }
133  void SetBufferedSpatialRegionCache(SpatialRegionMapType map)
134  {
135  m_BufferedSpatialRegionCache = map;
136  }
137 
138  const SpacingMapType & GetSpacingCache() const
139  {
140  return m_SpacingCache;
141  }
142  void SetSpacingCache(SpacingMapType map)
143  {
144  m_SpacingCache = map;
145  }
146 
147  const PointMapType & GetOriginCache() const
148  {
149  return m_OriginCache;
150  }
151  void SetOriginCache(PointMapType map)
152  {
153  m_OriginCache = map;
154  }
155 
156  const DirectionMapType & GetDirectionCache() const
157  {
158  return m_DirectionCache;
159  }
160  void SetDirectionCache(DirectionMapType map)
161  {
162  m_DirectionCache = map;
163  }
164 
166  void SetFrame(SizeValueType frameNumber, FramePointer frame);
167 
172  FramePointer GetFrame(SizeValueType frameNumber);
173  FrameConstPointer GetFrame(SizeValueType frameNumber) const;
175 
177  void SetFrameLargestPossibleSpatialRegion(SizeValueType frameNumber,
178  SpatialRegionType region);
179 
180  const SpatialRegionType &
181  GetFrameLargestPossibleSpatialRegion(SizeValueType frameNumber) const;
182 
184  void SetFrameRequestedSpatialRegion(SizeValueType frameNumber,
185  SpatialRegionType region);
186 
187  const SpatialRegionType &
188  GetFrameRequestedSpatialRegion(SizeValueType frameNumber) const;
189 
191  void SetFrameBufferedSpatialRegion(SizeValueType frameNumber,
192  SpatialRegionType region);
193 
194  const SpatialRegionType &
195  GetFrameBufferedSpatialRegion(SizeValueType frameNumber) const;
196 
198  void SetFrameSpacing(SizeValueType frameNumber, SpacingType spacing);
199 
200  const SpacingType & GetFrameSpacing(SizeValueType frameNumber) const;
201 
203  void SetFrameOrigin(SizeValueType frameNumber, PointType origin);
204 
205  const PointType & GetFrameOrigin(SizeValueType frameNumber) const;
206 
208  void SetFrameDirection(SizeValueType frameNumber, DirectionType direction);
209 
210  const DirectionType & GetFrameDirection(SizeValueType frameNumber) const;
211 
215  void SetAllLargestPossibleSpatialRegions(SpatialRegionType region);
216 
220  void SetAllRequestedSpatialRegions(SpatialRegionType region);
221 
225  void SetAllBufferedSpatialRegions(SpatialRegionType region);
226 
230  void SetAllFramesSpacing(SpacingType spacing);
231 
235  void SetAllFramesOrigin(PointType origin);
236 
240  void SetAllFramesDirection(DirectionType direction);
241 
274  void Allocate();
276 
281  virtual void Graft(const DataObject* data);
282 
283 protected:
284 
286  }
287  virtual ~VideoStream() {
288  }
289  virtual void PrintSelf(std::ostream & os, Indent indent) const
290  {
291  Superclass::Print(os, indent);
292  }
293 
300 
306 
307 private:
308 
309  VideoStream(const Self &); //purposely not implemented
310  void operator=(const Self &); //purposely not implemented
311 
312 }; // end class VideoStream
313 
314 } // end namespace itk
315 
316 #ifndef ITK_MANUAL_INSTANTIATION
317 #include "itkVideoStream.hxx"
318 #endif
319 
320 #endif
321