VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkParallelRenderManager.h 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 Copyright 2003 Sandia Corporation. Under the terms of Contract 00011 DE-AC04-94AL85000, there is a non-exclusive license for use of this work by 00012 or on behalf of the U.S. Government. Redistribution and use in source and 00013 binary forms, with or without modification, are permitted provided that this 00014 Notice and any statement of authorship are reproduced on all copies. 00015 00016 This software is distributed WITHOUT ANY WARRANTY; without even 00017 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00018 PURPOSE. See the above copyright notice for more information. 00019 00020 =========================================================================*/ 00049 #ifndef __vtkParallelRenderManager_h 00050 #define __vtkParallelRenderManager_h 00051 00052 #include "vtkRenderingParallelModule.h" // For export macro 00053 #include "vtkObject.h" 00054 00055 class vtkDoubleArray; 00056 class vtkMultiProcessController; 00057 class vtkMultiProcessStream; 00058 class vtkRenderer; 00059 class vtkRendererCollection; 00060 class vtkRenderWindow; 00061 class vtkTimerLog; 00062 class vtkUnsignedCharArray; 00063 00064 class VTKRENDERINGPARALLEL_EXPORT vtkParallelRenderManager : public vtkObject 00065 { 00066 public: 00067 vtkTypeMacro(vtkParallelRenderManager, vtkObject); 00068 virtual void PrintSelf(ostream &os, vtkIndent indent); 00069 00075 virtual vtkRenderWindow *MakeRenderWindow(); 00076 00081 virtual vtkRenderer *MakeRenderer(); 00082 00084 00086 vtkGetObjectMacro(RenderWindow, vtkRenderWindow); 00087 virtual void SetRenderWindow(vtkRenderWindow *renWin); 00089 00091 00093 vtkGetObjectMacro(Controller, vtkMultiProcessController); 00094 virtual void SetController(vtkMultiProcessController *controller); 00096 00099 virtual void InitializePieces(); 00100 00106 virtual void InitializeOffScreen(); 00107 00112 virtual void StartInteractor(); 00113 00116 virtual void StartServices(); 00117 00119 virtual void StopServices(); 00120 00122 00123 virtual void StartRender(); 00124 virtual void EndRender(); 00125 virtual void SatelliteStartRender(); 00126 virtual void SatelliteEndRender(); 00127 virtual void RenderRMI(); 00128 virtual void ResetCamera(vtkRenderer *ren); 00129 virtual void ResetCameraClippingRange(vtkRenderer *ren); 00130 virtual void ComputeVisiblePropBoundsRMI(int renderId); 00132 00133 virtual void InitializeRMIs(); 00134 00138 virtual void ResetAllCameras(); 00139 00141 virtual void ComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6]); 00142 00144 00148 vtkSetMacro(ParallelRendering, int); 00149 vtkGetMacro(ParallelRendering, int); 00150 vtkBooleanMacro(ParallelRendering, int); 00152 00154 00158 vtkSetMacro(RenderEventPropagation, int); 00159 vtkGetMacro(RenderEventPropagation, int); 00160 vtkBooleanMacro(RenderEventPropagation, int); 00162 00164 00167 static void SetDefaultRenderEventPropagation(bool val) 00168 { vtkParallelRenderManager::DefaultRenderEventPropagation = val; } 00169 static bool GetDefaultRenderEventPropagation() 00170 { return vtkParallelRenderManager::DefaultRenderEventPropagation; } 00172 00174 00177 vtkSetMacro(UseCompositing, int); 00178 vtkGetMacro(UseCompositing, int); 00179 vtkBooleanMacro(UseCompositing, int); 00181 00183 00194 virtual void SetImageReductionFactor(double factor); 00195 vtkGetMacro(ImageReductionFactor, double); 00197 00198 vtkSetMacro(MaxImageReductionFactor, double); 00199 vtkGetMacro(MaxImageReductionFactor, double); 00200 00206 virtual void SetImageReductionFactorForUpdateRate(double DesiredUpdateRate); 00207 00209 00212 vtkSetMacro(AutoImageReductionFactor, int); 00213 vtkGetMacro(AutoImageReductionFactor, int); 00214 vtkBooleanMacro(AutoImageReductionFactor, int); 00216 00218 00219 vtkGetMacro(RenderTime, double); 00220 vtkGetMacro(ImageProcessingTime, double); 00222 00224 00232 vtkGetMacro(SyncRenderWindowRenderers, int); 00233 vtkSetMacro(SyncRenderWindowRenderers, int); 00234 vtkBooleanMacro(SyncRenderWindowRenderers, int); 00235 virtual void AddRenderer(vtkRenderer *); 00236 virtual void RemoveRenderer(vtkRenderer *); 00237 virtual void RemoveAllRenderers(); 00239 00241 00248 vtkSetMacro(WriteBackImages, int); 00249 vtkGetMacro(WriteBackImages, int); 00250 vtkBooleanMacro(WriteBackImages, int); 00252 00254 00257 vtkSetMacro(MagnifyImages, int); 00258 vtkGetMacro(MagnifyImages, int); 00259 vtkBooleanMacro(MagnifyImages, int); 00261 00262 //BTX 00263 enum { NEAREST, LINEAR }; 00264 //ETX 00265 00267 00270 virtual void SetMagnifyImageMethod(int method); 00271 vtkGetMacro(MagnifyImageMethod, int); 00272 void SetMagnifyImageMethodToNearest() { 00273 this->SetMagnifyImageMethod(NEAREST); 00274 } 00275 void SetMagnifyImageMethodToLinear() { 00276 this->SetMagnifyImageMethod(LINEAR); 00277 } 00279 00281 00282 virtual void MagnifyImage(vtkUnsignedCharArray *fullImage, 00283 const int fullImageSize[2], 00284 vtkUnsignedCharArray *reducedImage, 00285 const int reducedImageSize[2], 00286 const int fullImageViewport[4] = NULL, 00287 const int reducedImageViewport[4] = NULL); 00288 static void MagnifyImageNearest(vtkUnsignedCharArray *fullImage, 00289 const int fullImageSize[2], 00290 vtkUnsignedCharArray *reducedImage, 00291 const int reducedImageSize[2], 00292 const int fullImageViewport[4] = NULL, 00293 const int reducedImageViewport[4] = NULL); 00294 static void MagnifyImageLinear(vtkUnsignedCharArray *fullImage, 00295 const int fullImageSize[2], 00296 vtkUnsignedCharArray *reducedImage, 00297 const int reducedImageSize[2], 00298 const int fullImageViewport[4] = NULL, 00299 const int reducedImageViewport[4] = NULL); 00301 00303 00308 virtual void GetPixelData(vtkUnsignedCharArray *data); 00309 virtual void GetPixelData(int x1, int y1, int x2, int y2, 00310 vtkUnsignedCharArray *data); 00312 00314 00319 virtual void GetReducedPixelData(vtkUnsignedCharArray *data); 00320 virtual void GetReducedPixelData(int x1, int y1, int x2, int y2, 00321 vtkUnsignedCharArray *data); 00323 00325 00326 vtkGetVector2Macro(FullImageSize, int); 00328 00329 00330 vtkGetVector2Macro(ReducedImageSize, int); 00332 00335 void TileWindows(int xsize, int ysize, int nColumns); 00336 00338 00340 vtkSetMacro(UseRGBA, int); 00341 vtkGetMacro(UseRGBA, int); 00343 00345 00348 vtkSetMacro(ForceRenderWindowSize, int); 00349 vtkGetMacro(ForceRenderWindowSize, int); 00351 00353 00355 vtkSetVector2Macro(ForcedRenderWindowSize, int); 00356 vtkGetVector2Macro(ForcedRenderWindowSize, int); 00358 00359 //BTX 00360 enum Tags { 00361 RENDER_RMI_TAG=34532, 00362 COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG=54636, 00363 WIN_INFO_TAG=87834, 00364 REN_INFO_TAG=87836, 00365 LIGHT_INFO_TAG=87838, 00366 REN_ID_TAG=58794, 00367 BOUNDS_TAG=23543 00368 }; 00369 00370 virtual void CheckForAbortRender() {} 00371 virtual int CheckForAbortComposite() {return 0;} 00372 //ETX 00373 00375 00379 vtkSetMacro(UseBackBuffer, int); 00380 vtkGetMacro(UseBackBuffer, int); 00381 vtkBooleanMacro(UseBackBuffer, int); 00383 00385 00389 vtkSetMacro(SynchronizeTileProperties, int); 00390 vtkGetMacro(SynchronizeTileProperties, int); 00391 vtkBooleanMacro(SynchronizeTileProperties, int); 00393 00395 00397 virtual void GenericStartRenderCallback(); 00398 virtual void GenericEndRenderCallback(); 00400 00401 //BTX 00402 protected: 00403 vtkParallelRenderManager(); 00404 ~vtkParallelRenderManager(); 00405 00406 00408 00409 void AddRenderWindowEventHandlers(); 00410 void RemoveRenderWindowEventHandlers(); 00412 00413 vtkRenderWindow *RenderWindow; 00414 vtkMultiProcessController *Controller; 00415 vtkRendererCollection *Renderers; 00416 00417 virtual vtkRendererCollection *GetRenderers(); 00418 00419 int ForceRenderWindowSize; 00420 int ForcedRenderWindowSize[2]; 00421 00428 int RootProcessId; 00429 00430 int ObservingRenderWindow; 00431 int ObservingAbort; 00432 00433 unsigned long StartRenderTag; 00434 unsigned long EndRenderTag; 00435 unsigned long ResetCameraTag; 00436 unsigned long ResetCameraClippingRangeTag; 00437 unsigned long AbortRenderCheckTag; 00438 00439 double ImageReductionFactor; 00440 double MaxImageReductionFactor; 00441 int AutoImageReductionFactor; 00442 00443 int WriteBackImages; 00444 int MagnifyImages; 00445 int MagnifyImageMethod; 00446 00447 int UseRGBA; 00448 int SynchronizeTileProperties; 00449 int FullImageSize[2]; 00450 int ReducedImageSize[2]; 00451 00452 vtkUnsignedCharArray *FullImage; 00453 vtkUnsignedCharArray *ReducedImage; 00454 00455 int FullImageUpToDate; 00456 int ReducedImageUpToDate; 00457 int RenderWindowImageUpToDate; 00458 00459 vtkDoubleArray *Viewports; 00460 00461 int Lock; 00462 int ParallelRendering; 00463 int RenderEventPropagation; 00464 int UseCompositing; 00465 int SyncRenderWindowRenderers; 00466 00467 vtkTimerLog *Timer; 00468 00469 double RenderTime; 00470 double ImageProcessingTime; 00471 00474 double AverageTimePerPixel; 00475 00477 00481 virtual void SendWindowInformation() {} 00482 virtual void ReceiveWindowInformation() {} 00483 virtual void SendRendererInformation(vtkRenderer *) {}; 00484 virtual void ReceiveRendererInformation(vtkRenderer *) {}; 00486 00488 00494 virtual void CollectWindowInformation(vtkMultiProcessStream&) {} 00495 virtual bool ProcessWindowInformation(vtkMultiProcessStream&) 00496 { return true; } 00497 virtual void CollectRendererInformation(vtkRenderer*, 00498 vtkMultiProcessStream&) {} 00499 virtual bool ProcessRendererInformation(vtkRenderer*, 00500 vtkMultiProcessStream&) { return true; } 00502 00504 00506 virtual void PreRenderProcessing() = 0; 00507 virtual void PostRenderProcessing() = 0; 00509 00512 virtual void SetRenderWindowSize(); 00513 00517 virtual void LocalComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6]); 00518 00520 virtual void MagnifyReducedImage(); 00521 00523 virtual void WriteFullImage(); 00524 00526 virtual void ReadReducedImage(); 00527 00530 virtual int LastRenderInFrontBuffer(); 00531 00533 virtual int ChooseBuffer(); 00534 00536 00537 virtual void SetRenderWindowPixelData(vtkUnsignedCharArray *pixels, 00538 const int pixelDimensions[2]); 00540 00545 virtual int ImageReduceRenderer(vtkRenderer *) { return 1; } 00546 00547 struct RenderWindowInfo 00548 { 00549 int FullSize[2]; 00550 int ReducedSize[2]; 00551 int NumberOfRenderers; 00552 int UseCompositing; 00553 int TileScale[2]; 00554 double ImageReductionFactor; 00555 double DesiredUpdateRate; 00556 double TileViewport[4]; 00557 00558 // Save/restore the struct to/from a stream. 00559 void Save(vtkMultiProcessStream& stream); 00560 bool Restore(vtkMultiProcessStream& stream); 00561 }; 00562 00563 struct RendererInfo 00564 { 00565 int Draw; 00566 int NumberOfLights; 00567 double Viewport[4]; 00568 double CameraPosition[3]; 00569 double CameraFocalPoint[3]; 00570 double CameraViewUp[3]; 00571 double WindowCenter[2]; 00572 double CameraClippingRange[2]; 00573 double CameraViewAngle; 00574 double Background[3]; 00575 double Background2[3]; 00576 bool GradientBackground; 00577 00578 double ParallelScale; 00579 00580 // Save/restore the struct to/from a stream. 00581 void Save(vtkMultiProcessStream& stream); 00582 bool Restore(vtkMultiProcessStream& stream); 00583 }; 00584 00585 struct LightInfo 00586 { 00587 double Position[3]; 00588 double FocalPoint[3]; 00589 double Type; 00590 // Save/restore the struct to/from a stream. 00591 void Save(vtkMultiProcessStream& stream); 00592 bool Restore(vtkMultiProcessStream& stream); 00593 }; 00594 00595 int AddedRMIs; 00596 unsigned long RenderRMIId; 00597 unsigned long BoundsRMIId; 00598 int UseBackBuffer; 00599 00600 static bool DefaultRenderEventPropagation; 00601 00602 private: 00603 vtkParallelRenderManager(const vtkParallelRenderManager &); //Not implemented 00604 void operator=(const vtkParallelRenderManager &); //Not implemented 00605 //ETX 00606 }; 00607 00608 #endif //__vtkParalleRenderManager_h