VTK  9.0.1
vtkParallelRenderManager.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkParallelRenderManager.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  Copyright 2003 Sandia Corporation. Under the terms of Contract
11  DE-AC04-94AL85000, there is a non-exclusive license for use of this work by
12  or on behalf of the U.S. Government. Redistribution and use in source and
13  binary forms, with or without modification, are permitted provided that this
14  Notice and any statement of authorship are reproduced on all copies.
15 
16  This software is distributed WITHOUT ANY WARRANTY; without even
17  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18  PURPOSE. See the above copyright notice for more information.
19 
20 =========================================================================*/
44 #ifndef vtkParallelRenderManager_h
45 #define vtkParallelRenderManager_h
46 
47 #include "vtkObject.h"
48 #include "vtkRenderingParallelModule.h" // For export macro
49 
50 class vtkDoubleArray;
53 class vtkRenderer;
55 class vtkRenderWindow;
56 class vtkTimerLog;
58 
59 class VTKRENDERINGPARALLEL_EXPORT vtkParallelRenderManager : public vtkObject
60 {
61 public:
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
72  virtual vtkRenderWindow* MakeRenderWindow();
73 
80  virtual vtkRenderer* MakeRenderer();
81 
83 
87  vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
88  virtual void SetRenderWindow(vtkRenderWindow* renWin);
90 
92 
96  vtkGetObjectMacro(Controller, vtkMultiProcessController);
97  virtual void SetController(vtkMultiProcessController* controller);
99 
104  virtual void InitializePieces();
105 
113  virtual void InitializeOffScreen();
114 
121  virtual void StartInteractor();
122 
127  virtual void StartServices();
128 
132  virtual void StopServices();
133 
135 
138  virtual void StartRender();
139  virtual void EndRender();
140  virtual void SatelliteStartRender();
141  virtual void SatelliteEndRender();
142  virtual void RenderRMI();
143  virtual void ResetCamera(vtkRenderer* ren);
144  virtual void ResetCameraClippingRange(vtkRenderer* ren);
145  virtual void ComputeVisiblePropBoundsRMI(int renderId);
147 
148  virtual void InitializeRMIs();
149 
155  virtual void ResetAllCameras();
156 
160  virtual void ComputeVisiblePropBounds(vtkRenderer* ren, double bounds[6]);
161 
163 
169  vtkSetMacro(ParallelRendering, int);
170  vtkGetMacro(ParallelRendering, int);
171  vtkBooleanMacro(ParallelRendering, int);
173 
175 
181  vtkSetMacro(RenderEventPropagation, int);
182  vtkGetMacro(RenderEventPropagation, int);
183  vtkBooleanMacro(RenderEventPropagation, int);
185 
191  static void SetDefaultRenderEventPropagation(bool val)
192  {
194  }
196  {
198  }
199 
201 
206  vtkSetMacro(UseCompositing, int);
207  vtkGetMacro(UseCompositing, int);
208  vtkBooleanMacro(UseCompositing, int);
210 
212 
225  virtual void SetImageReductionFactor(double factor);
226  vtkGetMacro(ImageReductionFactor, double);
228 
229  vtkSetMacro(MaxImageReductionFactor, double);
230  vtkGetMacro(MaxImageReductionFactor, double);
231 
238  virtual void SetImageReductionFactorForUpdateRate(double DesiredUpdateRate);
239 
241 
246  vtkSetMacro(AutoImageReductionFactor, int);
247  vtkGetMacro(AutoImageReductionFactor, int);
248  vtkBooleanMacro(AutoImageReductionFactor, int);
250 
252 
255  vtkGetMacro(RenderTime, double);
256  vtkGetMacro(ImageProcessingTime, double);
258 
260 
269  vtkGetMacro(SyncRenderWindowRenderers, int);
270  vtkSetMacro(SyncRenderWindowRenderers, int);
271  vtkBooleanMacro(SyncRenderWindowRenderers, int);
272  virtual void AddRenderer(vtkRenderer*);
273  virtual void RemoveRenderer(vtkRenderer*);
274  virtual void RemoveAllRenderers();
276 
278 
287  vtkSetMacro(WriteBackImages, int);
288  vtkGetMacro(WriteBackImages, int);
289  vtkBooleanMacro(WriteBackImages, int);
291 
293 
298  vtkSetMacro(MagnifyImages, int);
299  vtkGetMacro(MagnifyImages, int);
300  vtkBooleanMacro(MagnifyImages, int);
302 
303  enum
304  {
306  LINEAR
307  };
308 
310 
315  virtual void SetMagnifyImageMethod(int method);
316  vtkGetMacro(MagnifyImageMethod, int);
317  void SetMagnifyImageMethodToNearest() { this->SetMagnifyImageMethod(NEAREST); }
318  void SetMagnifyImageMethodToLinear() { this->SetMagnifyImageMethod(LINEAR); }
320 
322 
325  virtual void MagnifyImage(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
326  vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
327  const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
328  static void MagnifyImageNearest(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
329  vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
330  const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
331  static void MagnifyImageLinear(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
332  vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
333  const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
335 
337 
344  virtual void GetPixelData(vtkUnsignedCharArray* data);
345  virtual void GetPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray* data);
347 
349 
356  virtual void GetReducedPixelData(vtkUnsignedCharArray* data);
357  virtual void GetReducedPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray* data);
359 
361 
364  vtkGetVector2Macro(FullImageSize, int);
366 
367 
370  vtkGetVector2Macro(ReducedImageSize, int);
372 
377  void TileWindows(int xsize, int ysize, int nColumns);
378 
380 
384  vtkSetMacro(UseRGBA, int);
385  vtkGetMacro(UseRGBA, int);
387 
389 
393  vtkSetMacro(ForceRenderWindowSize, int);
394  vtkGetMacro(ForceRenderWindowSize, int);
396 
398 
402  vtkSetVector2Macro(ForcedRenderWindowSize, int);
403  vtkGetVector2Macro(ForcedRenderWindowSize, int);
405 
406  enum Tags
407  {
408  RENDER_RMI_TAG = 34532,
409  COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG = 54636,
410  WIN_INFO_TAG = 87834,
411  REN_INFO_TAG = 87836,
412  LIGHT_INFO_TAG = 87838,
413  REN_ID_TAG = 58794,
414  BOUNDS_TAG = 23543
415  };
416 
417  virtual void CheckForAbortRender() {}
418  virtual int CheckForAbortComposite() { return 0; }
419 
421 
427  vtkSetMacro(UseBackBuffer, int);
428  vtkGetMacro(UseBackBuffer, int);
429  vtkBooleanMacro(UseBackBuffer, int);
431 
433 
438  vtkSetMacro(SynchronizeTileProperties, int);
439  vtkGetMacro(SynchronizeTileProperties, int);
440  vtkBooleanMacro(SynchronizeTileProperties, int);
442 
444 
449  virtual void GenericStartRenderCallback();
450  virtual void GenericEndRenderCallback();
452 
453 protected:
455  ~vtkParallelRenderManager() override;
456 
458 
461  void AddRenderWindowEventHandlers();
462  void RemoveRenderWindowEventHandlers();
464 
468 
469  virtual vtkRendererCollection* GetRenderers();
470 
472  int ForcedRenderWindowSize[2];
473 
483 
486 
487  unsigned long StartRenderTag;
488  unsigned long EndRenderTag;
489  unsigned long ResetCameraTag;
491  unsigned long AbortRenderCheckTag;
492 
496 
500 
501  int UseRGBA;
503  int FullImageSize[2];
504  int ReducedImageSize[2];
505 
508 
512 
514 
515  int Lock;
520 
522 
523  double RenderTime;
525 
531 
538  virtual void SendWindowInformation() {}
539  virtual void ReceiveWindowInformation() {}
542 
552  virtual bool ProcessWindowInformation(vtkMultiProcessStream&) { return true; }
555 
557 
561  virtual void PreRenderProcessing() = 0;
562  virtual void PostRenderProcessing() = 0;
564 
569  virtual void SetRenderWindowSize();
570 
576  virtual void LocalComputeVisiblePropBounds(vtkRenderer* ren, double bounds[6]);
577 
581  virtual void MagnifyReducedImage();
582 
586  virtual void WriteFullImage();
587 
591  virtual void ReadReducedImage();
592 
597  virtual int LastRenderInFrontBuffer();
598 
602  virtual int ChooseBuffer();
603 
607  virtual void SetRenderWindowPixelData(vtkUnsignedCharArray* pixels, const int pixelDimensions[2]);
608 
615  virtual int ImageReduceRenderer(vtkRenderer*) { return 1; }
616 
618  {
619  int FullSize[2];
620  int ReducedSize[2];
623  int TileScale[2];
626  double TileViewport[4];
627 
628  // Initialize members
630 
631  // Save/restore the struct to/from a stream.
632  void Save(vtkMultiProcessStream& stream);
633  bool Restore(vtkMultiProcessStream& stream);
634  };
635 
637  {
638  int Draw;
640  double Viewport[4];
641  double CameraPosition[3];
642  double CameraFocalPoint[3];
643  double CameraViewUp[3];
644  double WindowCenter[2];
645  double CameraClippingRange[2];
647  double Background[3];
648  double Background2[3];
650 
652 
653  // Initialize members
655 
656  // Save/restore the struct to/from a stream.
657  void Save(vtkMultiProcessStream& stream);
658  bool Restore(vtkMultiProcessStream& stream);
659  };
660 
661  struct LightInfo
662  {
663  double Position[3];
664  double FocalPoint[3];
665  double Type;
666 
667  // Initialize members
669 
670  // Save/restore the struct to/from a stream.
671  void Save(vtkMultiProcessStream& stream);
672  bool Restore(vtkMultiProcessStream& stream);
673  };
674 
676  unsigned long RenderRMIId;
677  unsigned long BoundsRMIId;
679 
681 
682 private:
684  void operator=(const vtkParallelRenderManager&) = delete;
685 };
686 
687 #endif // vtkParalleRenderManager_h
vtkUnsignedCharArray * FullImage
virtual bool ProcessWindowInformation(vtkMultiProcessStream &)
vtkMultiProcessController * Controller
virtual bool ProcessRendererInformation(vtkRenderer *, vtkMultiProcessStream &)
abstract base class for most VTK objects
Definition: vtkObject.h:53
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
stream used to pass data across processes using vtkMultiProcessController.
vtkUnsignedCharArray * ReducedImage
An object to control parallel rendering.
double AverageTimePerPixel
Used by SetImageReductionFactorForUpdateRate to smooth transitions transitions between image reductio...
abstract specification for renderers
Definition: vtkRenderer.h:58
virtual void SendRendererInformation(vtkRenderer *)
static void SetDefaultRenderEventPropagation(bool val)
Get/Set the default value used for RenderEventPropagation when a new instance of vtkParallelRenderMan...
void SetMagnifyImageMethodToNearest()
Sets the method used to magnify images.
dynamic, self-adjusting array of double
Timer support and logging.
Definition: vtkTimerLog.h:90
an ordered list of renderers
virtual void CollectWindowInformation(vtkMultiProcessStream &)
Subclass should override these methods (instead of SendWindowInformation/ReceiveWindowInformation or ...
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void ReceiveRendererInformation(vtkRenderer *)
dynamic, self-adjusting array of unsigned char
create a window for renderers to draw into
virtual void SendWindowInformation()
Used to synchronize rendering information per frame.
int RootProcessId
The "root" node's process id.
void SetMagnifyImageMethodToLinear()
Sets the method used to magnify images.
vtkRendererCollection * Renderers
virtual void CollectRendererInformation(vtkRenderer *, vtkMultiProcessStream &)
virtual int ImageReduceRenderer(vtkRenderer *)
Returns true if the image for the given renderer should be rendered at a reduced size to be magnified...
Multiprocessing communication superclass.