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

contrib/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 "vtkMutexLock.h"
00063 #include "vtkMultiThreader.h"
00064 #include "vtkImageSource.h"
00065 #include "vtkScalarsToColors.h"
00066 
00067 class VTK_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 Initialize();
00077 
00080   virtual void ReleaseSystemResources();
00081 
00083   virtual void Grab(int n);
00084   void Grab() { this->Grab(1); }
00085 
00088   virtual void Play();
00089 
00091   virtual void Stop();
00092 
00094   vtkGetMacro(Playing,int);
00095 
00098   vtkSetMacro(FrameRate,float);
00099   vtkGetMacro(FrameRate,float);
00100 
00106   virtual void SetFrameSize(int dim[3]) { 
00107     this->SetFrameSize(dim[0], dim[1], dim[2]); };
00108   virtual void SetFrameSize(int x, int y, int z);
00109   vtkGetVector3Macro(FrameSize,int);
00110 
00113   virtual void SetOutputFormat(int format);
00114   void SetOutputFormatToLuminance() { this->SetOutputFormat(VTK_LUMINANCE); };
00115   void SetOutputFormatToRGB() { this->SetOutputFormat(VTK_RGB); };
00116   void SetOutputFormatToRGBA() { this->SetOutputFormat(VTK_RGBA); };
00117   vtkGetMacro(OutputFormat,int);
00118 
00120   virtual void SetFrameBufferSize(int FrameBufferSize);
00121   vtkGetMacro(FrameBufferSize,int);
00122 
00126   vtkSetMacro(NumberOfOutputFrames,int);
00127   vtkGetMacro(NumberOfOutputFrames,int);
00128 
00131   vtkBooleanMacro(AutoAdvance,int);
00132   vtkSetMacro(AutoAdvance,int)
00133   vtkGetMacro(AutoAdvance,int);
00134 
00136   virtual void Advance(int n); 
00137   virtual void Advance() { this->Advance(-1); };
00138 
00140   virtual void Rewind(int n) { this->Advance(-n); };
00141   virtual void Rewind() { this->Advance(-1); };
00142 
00147   virtual void SetClipRegion(int r[6]) { 
00148     this->SetClipRegion(r[0],r[1],r[2],r[3],r[4],r[5]); };
00149   virtual void SetClipRegion(int x0, int x1, int y0, int y1, int z0, int z1);
00150   vtkGetVector6Macro(ClipRegion,int);
00151 
00159   vtkSetVector6Macro(OutputWholeExtent,int);
00160   vtkGetVector6Macro(OutputWholeExtent,int);
00161   
00163   vtkSetVector3Macro(DataSpacing,float);
00164   vtkGetVector3Macro(DataSpacing,float);
00165   
00168   vtkSetVector3Macro(DataOrigin,float);
00169   vtkGetVector3Macro(DataOrigin,float);
00170 
00174   vtkSetMacro(Opacity,float);
00175   vtkGetMacro(Opacity,float);  
00176 
00178   vtkSetMacro(Preview,int);
00179   vtkBooleanMacro(Preview,int);
00180   vtkGetMacro(Preview,int);
00181 
00184   virtual double GetFrameTimeStamp(int frame);
00185   virtual double GetFrameTimeStamp() { return this->GetFrameTimeStamp(0); };
00186 
00189   virtual void SetGrabOnUpdate(int yesno);
00190   vtkBooleanMacro(GrabOnUpdate,int);
00191   vtkGetMacro(GrabOnUpdate,int);
00192 
00196   virtual void InternalGrab();
00197 
00199   void UpdateInformation();
00200 
00201 protected:
00202   vtkVideoSource();
00203   ~vtkVideoSource();
00204   vtkVideoSource(const vtkVideoSource&) {};
00205   void operator=(const vtkVideoSource&) {};
00206   void ExecuteInformation();
00207 
00208   int Initialized;
00209 
00210   int FrameSize[3];
00211   int ClipRegion[6];
00212   int OutputWholeExtent[6];
00213   float DataSpacing[3];
00214   float DataOrigin[3];
00215   int OutputFormat;
00216   // set according to the OutputFormat
00217   int NumberOfScalarComponents;
00218   // The FrameOutputExtent is the WholeExtent for a single output frame.
00219   // It is initialized in ExecuteInformation. 
00220   int FrameOutputExtent[6];
00221 
00222   // save this information from the output so that we can see if the
00223   // output scalars have changed
00224   int LastNumberOfScalarComponents;
00225   int LastOutputExtent[6];
00226 
00227   int Playing;
00228   float FrameRate;
00229 
00230   int AutoAdvance;
00231   int NumberOfOutputFrames;
00232 
00233   float Opacity;
00234   int Preview;
00235 
00236   int GrabOnUpdate;
00237 
00238   // true if Execute() must apply a vertical flip to each frame
00239   int FlipFrames;
00240 
00241   // set if output needs to be cleared to be cleared before being written
00242   int OutputNeedsInitialization;
00243 
00244   // set if a frame has been grabbed in the 'GrabOnUpdate' hack
00245   int FrameGrabbed;
00246 
00247   // An example of asynchrony
00248   vtkMultiThreader *PlayerThreader;
00249   int PlayerThreadId;
00250 
00251   // A mutex for the frame buffer: must be applied when any of the
00252   // below data is modified.
00253 
00254   vtkMutexLock *FrameBufferMutex;
00255 
00256   // set according to the needs of the hardware:
00257   // number of bits per framebuffer pixel
00258   int FrameBufferBitsPerPixel;
00259   // byte alignment of each row in the framebuffer
00260   int FrameBufferRowAlignment;
00261   // FrameBufferExtent is the extent of frame after it has been clipped 
00262   // with ClipRegion.  It is initialized in CheckBuffer().
00263   int FrameBufferExtent[6];
00264 
00265   int FrameBufferSize;
00266   int FrameBufferIndex;
00267   void **FrameBuffer;
00268   double *FrameBufferTimeStamps;
00269 
00271   virtual void UpdateFrameBuffer();
00272   virtual void AdvanceFrameBuffer(int n);
00273   virtual void Execute(vtkImageData *data);
00274   void Execute() { this->vtkImageSource::Execute(); };
00275   // if some component conversion is required, it is done here:
00276   virtual void UnpackRasterLine(char *outPtr, char *rowPtr, 
00277             int start, int count);
00278 };
00279 
00280 #endif
00281 
00282 
00283 
00284 
00285 

Generated on Wed Nov 21 12:26:56 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001