Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Hybrid/vtkVideoSource.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkVideoSource.h,v $
00005   Language:  C++
00006 
00007 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00008 All rights reserved.
00009 
00010 Redistribution and use in source and binary forms, with or without
00011 modification, are permitted provided that the following conditions are met:
00012 
00013  * Redistributions of source code must retain the above copyright notice,
00014    this list of conditions and the following disclaimer.
00015 
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019 
00020  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00021    of any contributors may be used to endorse or promote products derived
00022    from this software without specific prior written permission.
00023 
00024  * Modified source versions must be plainly marked as such, and must not be
00025    misrepresented as being the original software.
00026 
00027 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00028 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00031 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00032 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00033 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00034 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00035 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00036 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 
00038 =========================================================================*/
00058 #ifndef __vtkVideoSource_h
00059 #define __vtkVideoSource_h
00060 
00061 #include "vtkTimerLog.h"
00062 #include "vtkCriticalSection.h"
00063 #include "vtkMultiThreader.h"
00064 #include "vtkImageSource.h"
00065 #include "vtkScalarsToColors.h"
00066 
00067 class VTK_HYBRID_EXPORT vtkVideoSource : public vtkImageSource
00068 {
00069 public:
00070   static vtkVideoSource *New();
00071   vtkTypeMacro(vtkVideoSource,vtkImageSource);
00072   void PrintSelf(ostream& os, vtkIndent indent);   
00073 
00076   virtual void Record();
00077 
00080   virtual void Play();
00081 
00083   virtual void Stop();
00084 
00089   virtual void Rewind();
00090 
00093   virtual void FastForward();
00094 
00097   virtual void Seek(int n); 
00098 
00100   virtual void Grab();
00101 
00103 
00105   vtkGetMacro(Recording,int);
00107 
00109 
00111   vtkGetMacro(Playing,int);
00113 
00115 
00120   virtual void SetFrameSize(int x, int y, int z);
00121   virtual void SetFrameSize(int dim[3]) { 
00122     this->SetFrameSize(dim[0], dim[1], dim[2]); };
00123   vtkGetVector3Macro(FrameSize,int);
00125 
00127 
00128   virtual void SetFrameRate(float rate);
00129   vtkGetMacro(FrameRate,float);
00131 
00133 
00135   virtual void SetOutputFormat(int format);
00136   void SetOutputFormatToLuminance() { this->SetOutputFormat(VTK_LUMINANCE); };
00137   void SetOutputFormatToRGB() { this->SetOutputFormat(VTK_RGB); };
00138   void SetOutputFormatToRGBA() { this->SetOutputFormat(VTK_RGBA); };
00139   vtkGetMacro(OutputFormat,int);
00141 
00143 
00145   virtual void SetFrameBufferSize(int FrameBufferSize);
00146   vtkGetMacro(FrameBufferSize,int);
00148 
00150 
00153   vtkSetMacro(NumberOfOutputFrames,int);
00154   vtkGetMacro(NumberOfOutputFrames,int);
00156 
00158 
00160   vtkBooleanMacro(AutoAdvance,int);
00161   vtkSetMacro(AutoAdvance,int)
00162   vtkGetMacro(AutoAdvance,int);
00164 
00166 
00170   virtual void SetClipRegion(int r[6]) { 
00171     this->SetClipRegion(r[0],r[1],r[2],r[3],r[4],r[5]); };
00172   virtual void SetClipRegion(int x0, int x1, int y0, int y1, int z0, int z1);
00173   vtkGetVector6Macro(ClipRegion,int);
00175 
00177 
00184   vtkSetVector6Macro(OutputWholeExtent,int);
00185   vtkGetVector6Macro(OutputWholeExtent,int);
00187   
00189 
00190   vtkSetVector3Macro(DataSpacing,float);
00191   vtkGetVector3Macro(DataSpacing,float);
00193   
00195 
00197   vtkSetVector3Macro(DataOrigin,float);
00198   vtkGetVector3Macro(DataOrigin,float);
00200 
00202 
00205   vtkSetMacro(Opacity,float);
00206   vtkGetMacro(Opacity,float);  
00208 
00210 
00212   vtkGetMacro(FrameCount, int);
00213   vtkSetMacro(FrameCount, int);
00215 
00217 
00219   vtkGetMacro(FrameIndex, int);
00221 
00223 
00227   virtual double GetFrameTimeStamp(int frame);
00228   virtual double GetFrameTimeStamp() { return this->GetFrameTimeStamp(0); };
00230 
00232 
00234   virtual void Initialize();
00235   virtual int GetInitialized() { return this->Initialized; };
00237 
00240   virtual void ReleaseSystemResources();
00241 
00245   virtual void InternalGrab();
00246 
00248 
00250   void SetStartTimeStamp(double t) { this->StartTimeStamp = t; };
00251   double GetStartTimeStamp() { return this->StartTimeStamp; };
00253 
00254 protected:
00255   vtkVideoSource();
00256   ~vtkVideoSource();
00257   void ExecuteInformation();
00258 
00259   int Initialized;
00260 
00261   int FrameSize[3];
00262   int ClipRegion[6];
00263   int OutputWholeExtent[6];
00264   float DataSpacing[3];
00265   float DataOrigin[3];
00266   int OutputFormat;
00267   // set according to the OutputFormat
00268   int NumberOfScalarComponents;
00269   // The FrameOutputExtent is the WholeExtent for a single output frame.
00270   // It is initialized in ExecuteInformation. 
00271   int FrameOutputExtent[6];
00272 
00273   // save this information from the output so that we can see if the
00274   // output scalars have changed
00275   int LastNumberOfScalarComponents;
00276   int LastOutputExtent[6];
00277 
00278   int Recording;
00279   int Playing;
00280   float FrameRate;
00281   int FrameCount;
00282   int FrameIndex;
00283   double StartTimeStamp;
00284 
00285   int AutoAdvance;
00286   int NumberOfOutputFrames;
00287 
00288   float Opacity;
00289 
00290   // true if Execute() must apply a vertical flip to each frame
00291   int FlipFrames;
00292 
00293   // set if output needs to be cleared to be cleared before being written
00294   int OutputNeedsInitialization;
00295 
00296   // An example of asynchrony
00297   vtkMultiThreader *PlayerThreader;
00298   int PlayerThreadId;
00299 
00300   // A mutex for the frame buffer: must be applied when any of the
00301   // below data is modified.
00302   vtkCriticalSection *FrameBufferMutex;
00303 
00304   // set according to the needs of the hardware:
00305   // number of bits per framebuffer pixel
00306   int FrameBufferBitsPerPixel;
00307   // byte alignment of each row in the framebuffer
00308   int FrameBufferRowAlignment;
00309   // FrameBufferExtent is the extent of frame after it has been clipped 
00310   // with ClipRegion.  It is initialized in CheckBuffer().
00311   int FrameBufferExtent[6];
00312 
00313   int FrameBufferSize;
00314   int FrameBufferIndex;
00315   void **FrameBuffer;
00316   double *FrameBufferTimeStamps;
00317 
00319 
00320   virtual void UpdateFrameBuffer();
00321   virtual void AdvanceFrameBuffer(int n);
00322   virtual void ExecuteData(vtkDataObject *data);
00323   // if some component conversion is required, it is done here:
00324   virtual void UnpackRasterLine(char *outPtr, char *rowPtr, 
00325             int start, int count);
00327 
00328 private:
00329   vtkVideoSource(const vtkVideoSource&);  // Not implemented.
00330   void operator=(const vtkVideoSource&);  // Not implemented.
00331 };
00332 
00333 #endif
00334 
00335 
00336 
00337 
00338 

Generated on Thu Mar 28 14:19:24 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001