VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkVideoSource.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00031 #ifndef __vtkVideoSource_h 00032 #define __vtkVideoSource_h 00033 00034 #include "vtkImageAlgorithm.h" 00035 00036 class vtkTimerLog; 00037 class vtkCriticalSection; 00038 class vtkMultiThreader; 00039 class vtkScalarsToColors; 00040 00041 class VTK_HYBRID_EXPORT vtkVideoSource : public vtkImageAlgorithm 00042 { 00043 public: 00044 static vtkVideoSource *New(); 00045 vtkTypeMacro(vtkVideoSource,vtkImageAlgorithm); 00046 void PrintSelf(ostream& os, vtkIndent indent); 00047 00050 virtual void Record(); 00051 00054 virtual void Play(); 00055 00057 virtual void Stop(); 00058 00063 virtual void Rewind(); 00064 00067 virtual void FastForward(); 00068 00071 virtual void Seek(int n); 00072 00074 virtual void Grab(); 00075 00077 00079 vtkGetMacro(Recording,int); 00081 00083 00085 vtkGetMacro(Playing,int); 00087 00089 00094 virtual void SetFrameSize(int x, int y, int z); 00095 virtual void SetFrameSize(int dim[3]) { 00096 this->SetFrameSize(dim[0], dim[1], dim[2]); }; 00097 vtkGetVector3Macro(FrameSize,int); 00099 00101 00102 virtual void SetFrameRate(float rate); 00103 vtkGetMacro(FrameRate,float); 00105 00107 00109 virtual void SetOutputFormat(int format); 00110 void SetOutputFormatToLuminance() { this->SetOutputFormat(VTK_LUMINANCE); }; 00111 void SetOutputFormatToRGB() { this->SetOutputFormat(VTK_RGB); }; 00112 void SetOutputFormatToRGBA() { this->SetOutputFormat(VTK_RGBA); }; 00113 vtkGetMacro(OutputFormat,int); 00115 00117 00119 virtual void SetFrameBufferSize(int FrameBufferSize); 00120 vtkGetMacro(FrameBufferSize,int); 00122 00124 00127 vtkSetMacro(NumberOfOutputFrames,int); 00128 vtkGetMacro(NumberOfOutputFrames,int); 00130 00132 00134 vtkBooleanMacro(AutoAdvance,int); 00135 vtkSetMacro(AutoAdvance,int) 00136 vtkGetMacro(AutoAdvance,int); 00138 00140 00144 virtual void SetClipRegion(int r[6]) { 00145 this->SetClipRegion(r[0],r[1],r[2],r[3],r[4],r[5]); }; 00146 virtual void SetClipRegion(int x0, int x1, int y0, int y1, int z0, int z1); 00147 vtkGetVector6Macro(ClipRegion,int); 00149 00151 00158 vtkSetVector6Macro(OutputWholeExtent,int); 00159 vtkGetVector6Macro(OutputWholeExtent,int); 00161 00163 00164 vtkSetVector3Macro(DataSpacing,double); 00165 vtkGetVector3Macro(DataSpacing,double); 00167 00169 00171 vtkSetVector3Macro(DataOrigin,double); 00172 vtkGetVector3Macro(DataOrigin,double); 00174 00176 00179 vtkSetMacro(Opacity,float); 00180 vtkGetMacro(Opacity,float); 00182 00184 00186 vtkGetMacro(FrameCount, int); 00187 vtkSetMacro(FrameCount, int); 00189 00191 00193 vtkGetMacro(FrameIndex, int); 00195 00200 virtual double GetFrameTimeStamp(int frame); 00201 00205 double GetFrameTimeStamp() { return this->FrameTimeStamp; }; 00206 00208 00210 virtual void Initialize(); 00211 virtual int GetInitialized() { return this->Initialized; }; 00213 00216 virtual void ReleaseSystemResources(); 00217 00221 virtual void InternalGrab(); 00222 00224 00226 void SetStartTimeStamp(double t) { this->StartTimeStamp = t; }; 00227 double GetStartTimeStamp() { return this->StartTimeStamp; }; 00229 00230 protected: 00231 vtkVideoSource(); 00232 ~vtkVideoSource(); 00233 virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00234 00235 int Initialized; 00236 00237 int FrameSize[3]; 00238 int ClipRegion[6]; 00239 int OutputWholeExtent[6]; 00240 double DataSpacing[3]; 00241 double DataOrigin[3]; 00242 int OutputFormat; 00243 // set according to the OutputFormat 00244 int NumberOfScalarComponents; 00245 // The FrameOutputExtent is the WholeExtent for a single output frame. 00246 // It is initialized in ExecuteInformation. 00247 int FrameOutputExtent[6]; 00248 00249 // save this information from the output so that we can see if the 00250 // output scalars have changed 00251 int LastNumberOfScalarComponents; 00252 int LastOutputExtent[6]; 00253 00254 int Recording; 00255 int Playing; 00256 float FrameRate; 00257 int FrameCount; 00258 int FrameIndex; 00259 double StartTimeStamp; 00260 double FrameTimeStamp; 00261 00262 int AutoAdvance; 00263 int NumberOfOutputFrames; 00264 00265 float Opacity; 00266 00267 // true if Execute() must apply a vertical flip to each frame 00268 int FlipFrames; 00269 00270 // set if output needs to be cleared to be cleared before being written 00271 int OutputNeedsInitialization; 00272 00273 // An example of asynchrony 00274 vtkMultiThreader *PlayerThreader; 00275 int PlayerThreadId; 00276 00277 // A mutex for the frame buffer: must be applied when any of the 00278 // below data is modified. 00279 vtkCriticalSection *FrameBufferMutex; 00280 00281 // set according to the needs of the hardware: 00282 // number of bits per framebuffer pixel 00283 int FrameBufferBitsPerPixel; 00284 // byte alignment of each row in the framebuffer 00285 int FrameBufferRowAlignment; 00286 // FrameBufferExtent is the extent of frame after it has been clipped 00287 // with ClipRegion. It is initialized in CheckBuffer(). 00288 int FrameBufferExtent[6]; 00289 00290 int FrameBufferSize; 00291 int FrameBufferIndex; 00292 void **FrameBuffer; 00293 double *FrameBufferTimeStamps; 00294 00296 00297 virtual void UpdateFrameBuffer(); 00298 virtual void AdvanceFrameBuffer(int n); 00299 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00300 // if some component conversion is required, it is done here: 00301 virtual void UnpackRasterLine(char *outPtr, char *rowPtr, 00302 int start, int count); 00304 00305 private: 00306 vtkVideoSource(const vtkVideoSource&); // Not implemented. 00307 void operator=(const vtkVideoSource&); // Not implemented. 00308 }; 00309 00310 #endif 00311 00312 00313 00314 00315