Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class 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 
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 =========================================================================*/
00034 #ifndef __vtkCompositeManager_h
00035 #define __vtkCompositeManager_h
00036 
00037 #include "vtkObject.h"
00038 
00039 class vtkTimerLog;
00040 class vtkFloatArray;
00041 class vtkDataArray;
00042 class vtkRenderWindow;
00043 class vtkRenderWindowInteractor;
00044 class vtkMultiProcessController;
00045 class vtkRenderer;
00046 class vtkCompositer;
00047 class vtkUnsignedCharArray;
00048 
00049 class VTK_PARALLEL_EXPORT vtkCompositeManager : public vtkObject
00050 {
00051 public:
00052   static vtkCompositeManager *New();
00053   vtkTypeRevisionMacro(vtkCompositeManager,vtkObject);
00054   void PrintSelf(ostream& os, vtkIndent indent);
00055 
00057 
00059   vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
00060   virtual void SetRenderWindow(vtkRenderWindow *renWin);
00062 
00066   void InitializePieces();
00067   
00069   void InitializeOffScreen();
00070   
00072 
00073   void StartInteractor();
00074   void ExitInteractor();
00075   virtual void StartRender();
00076   virtual void EndRender();
00077   virtual void SatelliteStartRender();
00078   virtual void SatelliteEndRender();
00079   void RenderRMI();
00080   void ResetCamera(vtkRenderer *ren);
00081   void ResetCameraClippingRange(vtkRenderer *ren);
00082   void ComputeVisiblePropBoundsRMI();
00084   
00087   virtual void InitializeRMIs();
00088   
00090 
00096   void SetImageReductionFactor(int factor);
00097   vtkGetMacro(ImageReductionFactor, int);
00099 
00101 
00102   void SetReductionFactor(int f) {this->SetImageReductionFactor(f);}
00103   int GetReductionFactor() {return this->GetImageReductionFactor();}
00105 
00107 
00110   void SetUseChar(int useChar);
00111   vtkGetMacro(UseChar, int);
00112   vtkBooleanMacro(UseChar, int);
00114 
00116 
00121   void SetUseRGB(int useRGB);
00122   vtkGetMacro(UseRGB, int);
00123   vtkBooleanMacro(UseRGB, int);
00125 
00127 
00128   vtkSetMacro(UseCompositing, int);
00129   vtkGetMacro(UseCompositing, int);
00130   vtkBooleanMacro(UseCompositing, int);
00132   
00134 
00136   vtkGetMacro(GetBuffersTime, double);
00137   vtkGetMacro(SetBuffersTime, double);
00138   vtkGetMacro(CompositeTime, double);
00139   vtkGetMacro(MaxRenderTime, double);
00141 
00143   double GetZ(int x, int y);
00144 
00146 
00149   void SetController(vtkMultiProcessController* controller);
00150   vtkGetObjectMacro(Controller, vtkMultiProcessController);
00152 
00153 //BTX
00154 
00155   enum Tags {
00156     RENDER_RMI_TAG=12721,
00157     COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG=56563,
00158     WIN_INFO_TAG=22134,
00159     REN_INFO_TAG=22135,
00160     BOUNDS_TAG=94135
00161   };
00162 
00164 
00167   virtual void CheckForAbortRender() {}
00168   virtual int CheckForAbortComposite() {return 0;}  
00170 //ETX
00171 
00173   virtual void ComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6]);
00174 
00176 
00180   vtkSetMacro(Manual, int);
00181   vtkGetMacro(Manual, int);
00182   vtkBooleanMacro(Manual, int);
00183   void Composite();
00185 
00187 
00189   virtual void SetCompositer(vtkCompositer*);
00190   vtkGetObjectMacro(Compositer, vtkCompositer);
00192 
00194 
00195   static void DeleteArray(vtkDataArray* da);
00196   static void ResizeFloatArray(vtkFloatArray* fa, int numComp,
00197                                vtkIdType size);
00198   static void ResizeUnsignedCharArray(vtkUnsignedCharArray* uca, 
00199                                       int numComp, vtkIdType size);
00201 
00203 
00206   void SetNumberOfProcesses(int numProcs);
00207   vtkGetMacro(NumberOfProcesses, int);
00209 
00211 
00213   vtkSetMacro(DoMagnifyBuffer, int);
00214   vtkGetMacro(DoMagnifyBuffer, int);
00216 
00217 protected:
00218   vtkCompositeManager();
00219   ~vtkCompositeManager();
00220   
00221   void SetRendererSize(int x, int y);
00222   void MagnifyBuffer(vtkDataArray *localPdata, vtkDataArray* magPdata,
00223                      int windowSize[2]);
00224 
00225   void ReallocPDataArrays();
00226   
00227   vtkRenderWindow* RenderWindow;
00228   vtkRenderWindowInteractor* RenderWindowInteractor;
00229   vtkMultiProcessController* Controller;
00230 
00231   unsigned long StartInteractorTag;
00232   unsigned long EndInteractorTag;
00233   unsigned long StartTag;
00234   unsigned long EndTag;
00235   unsigned long ResetCameraTag;
00236   unsigned long ResetCameraClippingRangeTag;
00237   int UseChar;
00238   int UseRGB;
00239   int UseCompositing;
00240   
00241   // Convenience method used internally. It set up the start observer
00242   // and allows the render window's interactor to be set before or after
00243   // the compositer's render window (not exactly true).
00244   void SetRenderWindowInteractor(vtkRenderWindowInteractor *iren);
00245 
00246   // This object does the parallel communication for compositing.
00247   vtkCompositer *Compositer;
00248   int NumberOfProcesses;
00249 
00250   // Arrays for compositing.
00251   vtkDataArray *PData;
00252   vtkFloatArray *ZData;
00253   vtkDataArray *LocalPData;
00254   vtkFloatArray *LocalZData;
00255   int RendererSize[2];
00256 
00257   // Reduction factor (For fast interactive compositing).
00258   int ImageReductionFactor;
00259 
00260   int DoMagnifyBuffer;
00261   
00262   // This cause me a head ache while trying to debug a lockup.
00263   // I am taking it out in retaliation.  I do not think nested
00264   // RMI's can occur anyway.
00265   // This flag stops nested RMIs from occuring.  Some rmis send 
00266   // and receive information. Nesting them can lock up the processes.
00267   int Lock;
00268 
00269   double GetBuffersTime;
00270   double SetBuffersTime;
00271   double CompositeTime;
00272   double MaxRenderTime;
00273 
00274   // Needed to compute the MaxRenderTime.
00275   vtkTimerLog *Timer;
00276 
00277   // For manual compositing.
00278   int Manual;
00279 
00280   int FirstRender;
00281 
00282 private:
00283   vtkCompositeManager(const vtkCompositeManager&); // Not implemented
00284   void operator=(const vtkCompositeManager&); // Not implemented
00285 };
00286 
00287 #endif