00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00052 #ifndef __vtkParallelRenderManager_h
00053 #define __vtkParallelRenderManager_h
00054
00055 #include "vtkObject.h"
00056
00057 class vtkDoubleArray;
00058 class vtkMultiProcessController;
00059 class vtkRenderer;
00060 class vtkRendererCollection;
00061 class vtkRenderWindow;
00062 class vtkTimerLog;
00063 class vtkUnsignedCharArray;
00064
00065 class VTK_PARALLEL_EXPORT vtkParallelRenderManager : public vtkObject
00066 {
00067 public:
00068 vtkTypeRevisionMacro(vtkParallelRenderManager, vtkObject);
00069 virtual void PrintSelf(ostream &os, vtkIndent indent);
00070
00076 virtual vtkRenderWindow *MakeRenderWindow();
00077
00082 virtual vtkRenderer *MakeRenderer();
00083
00085
00087 vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
00088 virtual void SetRenderWindow(vtkRenderWindow *renWin);
00090
00092
00094 vtkGetObjectMacro(Controller, vtkMultiProcessController);
00095 virtual void SetController(vtkMultiProcessController *controller);
00097
00100 virtual void InitializePieces();
00101
00107 virtual void InitializeOffScreen();
00108
00113 virtual void StartInteractor();
00114
00117 virtual void StartServices();
00118
00120 virtual void StopServices();
00121
00123
00124 virtual void StartRender();
00125 virtual void EndRender();
00126 virtual void SatelliteStartRender();
00127 virtual void SatelliteEndRender();
00128 virtual void RenderRMI();
00129 virtual void ResetCamera(vtkRenderer *ren);
00130 virtual void ResetCameraClippingRange(vtkRenderer *ren);
00131 virtual void ComputeVisiblePropBoundsRMI();
00133
00134 virtual void InitializeRMIs();
00135
00139 virtual void ResetAllCameras();
00140
00142 virtual void ComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6]);
00143
00145
00149 vtkSetMacro(ParallelRendering, int);
00150 vtkGetMacro(ParallelRendering, int);
00151 vtkBooleanMacro(ParallelRendering, int);
00153
00155
00159 vtkSetMacro(RenderEventPropagation, int);
00160 vtkGetMacro(RenderEventPropagation, int);
00161 vtkBooleanMacro(RenderEventPropagation, int);
00163
00165
00168 vtkSetMacro(UseCompositing, int);
00169 vtkGetMacro(UseCompositing, int);
00170 vtkBooleanMacro(UseCompositing, int);
00172
00174
00185 virtual void SetImageReductionFactor(double factor);
00186 vtkGetMacro(ImageReductionFactor, double);
00188
00189 vtkSetMacro(MaxImageReductionFactor, double);
00190 vtkGetMacro(MaxImageReductionFactor, double);
00191
00197 virtual void SetImageReductionFactorForUpdateRate(double DesiredUpdateRate);
00198
00200
00203 vtkSetMacro(AutoImageReductionFactor, int);
00204 vtkGetMacro(AutoImageReductionFactor, int);
00205 vtkBooleanMacro(AutoImageReductionFactor, int);
00207
00209
00210 vtkGetMacro(RenderTime, double);
00211 vtkGetMacro(ImageProcessingTime, double);
00213
00215
00223 vtkGetMacro(SyncRenderWindowRenderers, int);
00224 vtkSetMacro(SyncRenderWindowRenderers, int);
00225 vtkBooleanMacro(SyncRenderWindowRenderers, int);
00226 virtual void AddRenderer(vtkRenderer *);
00227 virtual void RemoveRenderer(vtkRenderer *);
00228 virtual void RemoveAllRenderers();
00230
00232
00239 vtkSetMacro(WriteBackImages, int);
00240 vtkGetMacro(WriteBackImages, int);
00241 vtkBooleanMacro(WriteBackImages, int);
00243
00245
00248 vtkSetMacro(MagnifyImages, int);
00249 vtkGetMacro(MagnifyImages, int);
00250 vtkBooleanMacro(MagnifyImages, int);
00252
00253
00254 enum { NEAREST, LINEAR };
00255
00256
00258
00261 virtual void SetMagnifyImageMethod(int method);
00262 vtkGetMacro(MagnifyImageMethod, int);
00263 void SetMagnifyImageMethodToNearest() {
00264 this->SetMagnifyImageMethod(NEAREST);
00265 }
00266 void SetMagnifyImageMethodToLinear() {
00267 this->SetMagnifyImageMethod(LINEAR);
00268 }
00270
00272
00273 virtual void MagnifyImage(vtkUnsignedCharArray *fullImage,
00274 const int fullImageSize[2],
00275 vtkUnsignedCharArray *reducedImage,
00276 const int reducedImageSize[2],
00277 const int fullImageViewport[4] = NULL,
00278 const int reducedImageViewport[4] = NULL);
00279 static void MagnifyImageNearest(vtkUnsignedCharArray *fullImage,
00280 const int fullImageSize[2],
00281 vtkUnsignedCharArray *reducedImage,
00282 const int reducedImageSize[2],
00283 const int fullImageViewport[4] = NULL,
00284 const int reducedImageViewport[4] = NULL);
00285 static void MagnifyImageLinear(vtkUnsignedCharArray *fullImage,
00286 const int fullImageSize[2],
00287 vtkUnsignedCharArray *reducedImage,
00288 const int reducedImageSize[2],
00289 const int fullImageViewport[4] = NULL,
00290 const int reducedImageViewport[4] = NULL);
00292
00294
00299 virtual void GetPixelData(vtkUnsignedCharArray *data);
00300 virtual void GetPixelData(int x1, int y1, int x2, int y2,
00301 vtkUnsignedCharArray *data);
00303
00305
00310 virtual void GetReducedPixelData(vtkUnsignedCharArray *data);
00311 virtual void GetReducedPixelData(int x1, int y1, int x2, int y2,
00312 vtkUnsignedCharArray *data);
00314
00316
00317 vtkGetVector2Macro(FullImageSize, int);
00318
00319
00320 vtkGetVector2Macro(ReducedImageSize, int);
00322
00325 void TileWindows(int xsize, int ysize, int nColumns);
00326
00328
00330 vtkSetMacro(UseRGBA, int);
00331 vtkGetMacro(UseRGBA, int);
00333
00335
00338 vtkSetMacro(ForceRenderWindowSize, int);
00339 vtkGetMacro(ForceRenderWindowSize, int);
00341
00343
00345 vtkSetVector2Macro(ForcedRenderWindowSize, int);
00346 vtkGetVector2Macro(ForcedRenderWindowSize, int);
00348
00349
00350 enum Tags {
00351 RENDER_RMI_TAG=34532,
00352 COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG=54636,
00353 WIN_INFO_INT_TAG=87834,
00354 WIN_INFO_DOUBLE_TAG=87835,
00355 REN_INFO_INT_TAG=87836,
00356 REN_INFO_DOUBLE_TAG=87837,
00357 LIGHT_INFO_DOUBLE_TAG=87838,
00358 REN_ID_TAG=58794,
00359 BOUNDS_TAG=23543
00360 };
00361
00362 virtual void CheckForAbortRender() {}
00363 virtual int CheckForAbortComposite() {return 0;}
00364
00365
00366
00367 #if defined(_COMPILER_VERSION)
00368 # pragma set woff 3303
00369 #endif
00370 #if defined(__INTEL_COMPILER)
00371 # pragma warning (push)
00372 # pragma warning (disable:858)
00373 #endif
00374
00375 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
00376 # define StartServiceA StartService
00377 # define StartServiceW StartService
00378 #endif
00379
00382 VTK_LEGACY(virtual void StartService());
00383
00384 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
00385 # undef StartServiceW
00386 # undef StartServiceA
00387
00388 VTK_LEGACY(virtual void StartServiceA());
00389 VTK_LEGACY(virtual void StartServiceW());
00390
00391 #endif
00392
00393
00394 #if defined(__INTEL_COMPILER)
00395 # pragma warning (pop)
00396 #endif
00397 #if defined(_COMPILER_VERSION)
00398 # pragma reset woff 3303
00399 #endif
00400
00402
00406 vtkSetMacro(UseBackBuffer, int);
00407 vtkGetMacro(UseBackBuffer, int);
00408 vtkBooleanMacro(UseBackBuffer, int);
00410
00412
00416 vtkSetMacro(SynchronizeTileProperties, int);
00417 vtkGetMacro(SynchronizeTileProperties, int);
00418 vtkBooleanMacro(SynchronizeTileProperties, int);
00420 protected:
00421 vtkParallelRenderManager();
00422 ~vtkParallelRenderManager();
00423
00424 vtkRenderWindow *RenderWindow;
00425 vtkMultiProcessController *Controller;
00426 vtkRendererCollection *Renderers;
00427
00428 virtual vtkRendererCollection *GetRenderers();
00429
00430 int ForceRenderWindowSize;
00431 int ForcedRenderWindowSize[2];
00432
00439 int RootProcessId;
00440
00441 int ObservingRenderWindow;
00442 int ObservingAbort;
00443
00444 unsigned long StartRenderTag;
00445 unsigned long EndRenderTag;
00446 unsigned long ResetCameraTag;
00447 unsigned long ResetCameraClippingRangeTag;
00448 unsigned long AbortRenderCheckTag;
00449
00450 double ImageReductionFactor;
00451 double MaxImageReductionFactor;
00452 int AutoImageReductionFactor;
00453
00454 int WriteBackImages;
00455 int MagnifyImages;
00456 int MagnifyImageMethod;
00457
00458 int UseRGBA;
00459 int SynchronizeTileProperties;
00460 int FullImageSize[2];
00461 int ReducedImageSize[2];
00462
00463 vtkUnsignedCharArray *FullImage;
00464 vtkUnsignedCharArray *ReducedImage;
00465
00466 int FullImageUpToDate;
00467 int ReducedImageUpToDate;
00468 int RenderWindowImageUpToDate;
00469
00470 vtkDoubleArray *Viewports;
00471
00472 int Lock;
00473 int ParallelRendering;
00474 int RenderEventPropagation;
00475 int UseCompositing;
00476 int SyncRenderWindowRenderers;
00477
00478 vtkTimerLog *Timer;
00479
00480 double RenderTime;
00481 double ImageProcessingTime;
00482
00485 double AverageTimePerPixel;
00486
00488
00489 virtual void SendWindowInformation() {}
00490 virtual void ReceiveWindowInformation() {}
00491 virtual void SendRendererInformation(vtkRenderer *) {};
00492 virtual void ReceiveRendererInformation(vtkRenderer *) {};
00494
00496
00498 virtual void PreRenderProcessing() = 0;
00499 virtual void PostRenderProcessing() = 0;
00501
00504 virtual void SetRenderWindowSize();
00505
00509 virtual void LocalComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6]);
00510
00512 virtual void MagnifyReducedImage();
00513
00515 virtual void WriteFullImage();
00516
00518 virtual void ReadReducedImage();
00519
00522 virtual int LastRenderInFrontBuffer();
00523
00525 virtual int ChooseBuffer();
00526
00528
00529 virtual void SetRenderWindowPixelData(vtkUnsignedCharArray *pixels,
00530 const int pixelDimensions[2]);
00532
00537 virtual int ImageReduceRenderer(vtkRenderer *) { return 1; }
00538
00539
00540 struct RenderWindowInfoInt
00541 {
00542 int FullSize[2];
00543 int ReducedSize[2];
00544 int NumberOfRenderers;
00545 int UseCompositing;
00546 int TileScale[2];
00547 };
00548
00549 struct RenderWindowInfoDouble
00550 {
00551 double ImageReductionFactor;
00552 double DesiredUpdateRate;
00553 double TileViewport[4];
00554 };
00555
00556 struct RendererInfoInt
00557 {
00558 int Draw;
00559 int NumberOfLights;
00560 };
00561
00562 struct RendererInfoDouble
00563 {
00564 double Viewport[4];
00565 double CameraPosition[3];
00566 double CameraFocalPoint[3];
00567 double CameraViewUp[3];
00568 double WindowCenter[2];
00569 double CameraClippingRange[2];
00570 double CameraViewAngle;
00571 double Background[3];
00572 double ParallelScale;
00573 };
00574
00575 struct LightInfoDouble
00576 {
00577 double Position[3];
00578 double FocalPoint[3];
00579 double Type;
00580 };
00581
00582 static const int WIN_INFO_INT_SIZE;
00583 static const int WIN_INFO_DOUBLE_SIZE;
00584 static const int REN_INFO_INT_SIZE;
00585 static const int REN_INFO_DOUBLE_SIZE;
00586 static const int LIGHT_INFO_DOUBLE_SIZE;
00587
00588
00589 int AddedRMIs;
00590 unsigned long RenderRMIId;
00591 unsigned long BoundsRMIId;
00592 int UseBackBuffer;
00593 private:
00594 vtkParallelRenderManager(const vtkParallelRenderManager &);
00595 void operator=(const vtkParallelRenderManager &);
00596 };
00597
00598 #endif //__vtkParalleRenderManager_h