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

Parallel/vtkCompositeManager.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkCompositeManager.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00054 #ifndef __vtkCompositeManager_h
00055 #define __vtkCompositeManager_h
00056 
00057 #include "vtkObject.h"
00058 
00059 class vtkTimerLog;
00060 class vtkFloatArray;
00061 class vtkDataArray;
00062 class vtkRenderWindow;
00063 class vtkRenderWindowInteractor;
00064 class vtkMultiProcessController;
00065 class vtkRenderer;
00066 class vtkCompositer;
00067 class vtkUnsignedCharArray;
00068 
00069 class VTK_PARALLEL_EXPORT vtkCompositeManager : public vtkObject
00070 {
00071 public:
00072   static vtkCompositeManager *New();
00073   vtkTypeRevisionMacro(vtkCompositeManager,vtkObject);
00074   void PrintSelf(ostream& os, vtkIndent indent);
00075 
00077 
00079   vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
00080   virtual void SetRenderWindow(vtkRenderWindow *renWin);
00082 
00086   void InitializePieces();
00087   
00089   void InitializeOffScreen();
00090   
00092 
00093   void StartInteractor();
00094   void ExitInteractor();
00095   virtual void StartRender();
00096   virtual void EndRender();
00097   virtual void SatelliteStartRender();
00098   virtual void SatelliteEndRender();
00099   void RenderRMI();
00100   void ResetCamera(vtkRenderer *ren);
00101   void ResetCameraClippingRange(vtkRenderer *ren);
00102   void ComputeVisiblePropBoundsRMI();
00104   
00107   virtual void InitializeRMIs();
00108   
00110 
00115   void SetReductionFactor(int factor);
00116   vtkGetMacro(ReductionFactor, int);
00118 
00120 
00123   void SetUseChar(int useChar);
00124   vtkGetMacro(UseChar, int);
00125   vtkBooleanMacro(UseChar, int);
00127 
00129 
00134   void SetUseRGB(int useRGB);
00135   vtkGetMacro(UseRGB, int);
00136   vtkBooleanMacro(UseRGB, int);
00138 
00140 
00141   vtkSetMacro(UseCompositing, int);
00142   vtkGetMacro(UseCompositing, int);
00143   vtkBooleanMacro(UseCompositing, int);
00145   
00147 
00149   vtkGetMacro(GetBuffersTime, double);
00150   vtkGetMacro(SetBuffersTime, double);
00151   vtkGetMacro(CompositeTime, double);
00152   vtkGetMacro(MaxRenderTime, double);
00154 
00156   float GetZ(int x, int y);
00157 
00159 
00162   void SetController(vtkMultiProcessController* controller);
00163   vtkGetObjectMacro(Controller, vtkMultiProcessController);
00165 
00166 //BTX
00167 
00168   enum Tags {
00169     RENDER_RMI_TAG=12721,
00170     COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG=56563,
00171     WIN_INFO_TAG=22134,
00172     REN_INFO_TAG=22135,
00173     BOUNDS_TAG=94135
00174   };
00175 
00177 
00180   virtual void CheckForAbortRender() {}
00181   virtual int CheckForAbortComposite() {return 0;}  
00183 //ETX
00184 
00186   virtual void ComputeVisiblePropBounds(vtkRenderer *ren, float bounds[6]);
00187 
00189 
00193   vtkSetMacro(Manual, int);
00194   vtkGetMacro(Manual, int);
00195   vtkBooleanMacro(Manual, int);
00196   void Composite();
00198 
00200 
00202   virtual void SetCompositer(vtkCompositer*);
00203   vtkGetObjectMacro(Compositer, vtkCompositer);
00205 
00207 
00208   static void DeleteArray(vtkDataArray* da);
00209   static void ResizeFloatArray(vtkFloatArray* fa, int numComp,
00210                                vtkIdType size);
00211   static void ResizeUnsignedCharArray(vtkUnsignedCharArray* uca, 
00212                                       int numComp, vtkIdType size);
00214 
00216 
00219   void SetNumberOfProcesses(int numProcs);
00220   vtkGetMacro(NumberOfProcesses, int);
00222 
00223 protected:
00224   vtkCompositeManager();
00225   ~vtkCompositeManager();
00226   
00227   void SetRendererSize(int x, int y);
00228   void MagnifyBuffer(vtkDataArray *localPdata, vtkDataArray* magPdata,
00229                      int windowSize[2]);
00230 
00231   void ReallocPDataArrays();
00232   
00233   vtkRenderWindow* RenderWindow;
00234   vtkRenderWindowInteractor* RenderWindowInteractor;
00235   vtkMultiProcessController* Controller;
00236 
00237   unsigned long StartInteractorTag;
00238   unsigned long EndInteractorTag;
00239   unsigned long StartTag;
00240   unsigned long EndTag;
00241   unsigned long ResetCameraTag;
00242   unsigned long ResetCameraClippingRangeTag;
00243   int UseChar;
00244   int UseRGB;
00245   int UseCompositing;
00246   
00247   // Convenience method used internally. It set up the start observer
00248   // and allows the render window's interactor to be set before or after
00249   // the compositer's render window (not exactly true).
00250   void SetRenderWindowInteractor(vtkRenderWindowInteractor *iren);
00251 
00252   // This object does the parallel communication for compositing.
00253   vtkCompositer *Compositer;
00254   int NumberOfProcesses;
00255 
00256   // Arrays for compositing.
00257   vtkDataArray *PData;
00258   vtkFloatArray *ZData;
00259   vtkDataArray *LocalPData;
00260   vtkFloatArray *LocalZData;
00261   int RendererSize[2];
00262 
00263   // Reduction factor (For fast interactive compositing).
00264   int ReductionFactor;
00265   
00266   // This cause me a head ache while trying to debug a lockup.
00267   // I am taking it out in retaliation.  I do not think nested
00268   // RMI's can occur anyway.
00269   // This flag stops nested RMIs from occuring.  Some rmis send 
00270   // and receive information. Nesting them can lock up the processes.
00271   int Lock;
00272 
00273   double GetBuffersTime;
00274   double SetBuffersTime;
00275   double CompositeTime;
00276   double MaxRenderTime;
00277 
00278   // Needed to compute the MaxRenderTime.
00279   vtkTimerLog *Timer;
00280 
00281   // For manual compositing.
00282   int Manual;
00283 
00284   int FirstRender;
00285 
00286 private:
00287   vtkCompositeManager(const vtkCompositeManager&); // Not implemented
00288   void operator=(const vtkCompositeManager&); // Not implemented
00289 };
00290 
00291 #endif