VTK  9.3.0
vtkParallelRenderManager.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright 2003 Sandia Corporation
3// SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
30#ifndef vtkParallelRenderManager_h
31#define vtkParallelRenderManager_h
32
33#include "vtkObject.h"
34#include "vtkRenderingParallelModule.h" // For export macro
35
36VTK_ABI_NAMESPACE_BEGIN
37class vtkDoubleArray;
40class vtkRenderer;
42class vtkRenderWindow;
43class vtkTimerLog;
45
46class VTKRENDERINGPARALLEL_EXPORT vtkParallelRenderManager : public vtkObject
47{
48public:
50 void PrintSelf(ostream& os, vtkIndent indent) override;
51
60
68
70
74 vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
75 virtual void SetRenderWindow(vtkRenderWindow* renWin);
77
79
83 vtkGetObjectMacro(Controller, vtkMultiProcessController);
84 virtual void SetController(vtkMultiProcessController* controller);
86
91 virtual void InitializePieces();
92
100 virtual void InitializeOffScreen();
101
108 virtual void StartInteractor();
109
114 virtual void StartServices();
115
119 virtual void StopServices();
120
122
125 virtual void StartRender();
126 virtual void EndRender();
127 virtual void SatelliteStartRender();
128 virtual void SatelliteEndRender();
129 virtual void RenderRMI();
130 virtual void ResetCamera(vtkRenderer* ren);
132 virtual void ComputeVisiblePropBoundsRMI(int renderId);
134
135 virtual void InitializeRMIs();
136
142 virtual void ResetAllCameras();
143
147 virtual void ComputeVisiblePropBounds(vtkRenderer* ren, double bounds[6]);
148
150
156 vtkSetMacro(ParallelRendering, int);
157 vtkGetMacro(ParallelRendering, int);
158 vtkBooleanMacro(ParallelRendering, int);
160
162
168 vtkSetMacro(RenderEventPropagation, int);
169 vtkGetMacro(RenderEventPropagation, int);
170 vtkBooleanMacro(RenderEventPropagation, int);
172
179 {
181 }
183 {
185 }
186
188
193 vtkSetMacro(UseCompositing, int);
194 vtkGetMacro(UseCompositing, int);
195 vtkBooleanMacro(UseCompositing, int);
197
199
212 virtual void SetImageReductionFactor(double factor);
213 vtkGetMacro(ImageReductionFactor, double);
215
216 vtkSetMacro(MaxImageReductionFactor, double);
217 vtkGetMacro(MaxImageReductionFactor, double);
218
225 virtual void SetImageReductionFactorForUpdateRate(double DesiredUpdateRate);
226
228
233 vtkSetMacro(AutoImageReductionFactor, int);
234 vtkGetMacro(AutoImageReductionFactor, int);
235 vtkBooleanMacro(AutoImageReductionFactor, int);
237
239
242 vtkGetMacro(RenderTime, double);
243 vtkGetMacro(ImageProcessingTime, double);
245
247
256 vtkGetMacro(SyncRenderWindowRenderers, int);
257 vtkSetMacro(SyncRenderWindowRenderers, int);
258 vtkBooleanMacro(SyncRenderWindowRenderers, int);
259 virtual void AddRenderer(vtkRenderer*);
261 virtual void RemoveAllRenderers();
263
265
274 vtkSetMacro(WriteBackImages, int);
275 vtkGetMacro(WriteBackImages, int);
276 vtkBooleanMacro(WriteBackImages, int);
278
280
285 vtkSetMacro(MagnifyImages, int);
286 vtkGetMacro(MagnifyImages, int);
287 vtkBooleanMacro(MagnifyImages, int);
289
290 enum
291 {
293 LINEAR
294 };
295
297
302 virtual void SetMagnifyImageMethod(int method);
303 vtkGetMacro(MagnifyImageMethod, int);
304 void SetMagnifyImageMethodToNearest() { this->SetMagnifyImageMethod(NEAREST); }
305 void SetMagnifyImageMethodToLinear() { this->SetMagnifyImageMethod(LINEAR); }
307
309
312 virtual void MagnifyImage(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
313 vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
314 const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
315 static void MagnifyImageNearest(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
316 vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
317 const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
318 static void MagnifyImageLinear(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
319 vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
320 const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
322
324
332 virtual void GetPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray* data);
334
336
344 virtual void GetReducedPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray* data);
346
348
351 vtkGetVector2Macro(FullImageSize, int);
354
357 vtkGetVector2Macro(ReducedImageSize, int);
359
364 void TileWindows(int xsize, int ysize, int nColumns);
365
367
371 vtkSetMacro(UseRGBA, int);
372 vtkGetMacro(UseRGBA, int);
374
376
380 vtkSetMacro(ForceRenderWindowSize, int);
381 vtkGetMacro(ForceRenderWindowSize, int);
383
385
389 vtkSetVector2Macro(ForcedRenderWindowSize, int);
390 vtkGetVector2Macro(ForcedRenderWindowSize, int);
392
393 enum Tags
394 {
395 RENDER_RMI_TAG = 34532,
396 COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG = 54636,
397 WIN_INFO_TAG = 87834,
398 REN_INFO_TAG = 87836,
399 LIGHT_INFO_TAG = 87838,
400 REN_ID_TAG = 58794,
401 BOUNDS_TAG = 23543
402 };
403
404 virtual void CheckForAbortRender() {}
405 virtual int CheckForAbortComposite() { return 0; }
406
408
414 vtkSetMacro(UseBackBuffer, int);
415 vtkGetMacro(UseBackBuffer, int);
416 vtkBooleanMacro(UseBackBuffer, int);
418
420
425 vtkSetMacro(SynchronizeTileProperties, int);
426 vtkGetMacro(SynchronizeTileProperties, int);
427 vtkBooleanMacro(SynchronizeTileProperties, int);
429
431
439
440protected:
443
445
451
455
457
459 int ForcedRenderWindowSize[2];
460
470
473
474 unsigned long StartRenderTag;
475 unsigned long EndRenderTag;
476 unsigned long ResetCameraTag;
478 unsigned long AbortRenderCheckTag;
479
483
487
490 int FullImageSize[2];
491 int ReducedImageSize[2];
492
495
499
501
502 int Lock;
507
509
512
518
525 virtual void SendWindowInformation() {}
526 virtual void ReceiveWindowInformation() {}
529
539 virtual bool ProcessWindowInformation(vtkMultiProcessStream&) { return true; }
542
544
548 virtual void PreRenderProcessing() = 0;
549 virtual void PostRenderProcessing() = 0;
551
556 virtual void SetRenderWindowSize();
557
563 virtual void LocalComputeVisiblePropBounds(vtkRenderer* ren, double bounds[6]);
564
568 virtual void MagnifyReducedImage();
569
573 virtual void WriteFullImage();
574
578 virtual void ReadReducedImage();
579
585
589 virtual int ChooseBuffer();
590
594 virtual void SetRenderWindowPixelData(vtkUnsignedCharArray* pixels, const int pixelDimensions[2]);
595
602 virtual int ImageReduceRenderer(vtkRenderer*) { return 1; }
603
605 {
606 int FullSize[2];
607 int ReducedSize[2];
610 int TileScale[2];
613 double TileViewport[4];
614
615 // Initialize members
616 RenderWindowInfo() = default;
617
618 // Save/restore the struct to/from a stream.
621 };
622
624 {
625 int Draw = 0;
626 int NumberOfLights = 0;
627 double Viewport[4] = { 0., 0., 0., 0. };
628 double CameraPosition[3] = { 0., 0., 0. };
629 double CameraFocalPoint[3] = { 0., 0., 0. };
630 double CameraViewUp[3] = { 0., 0., 0. };
631 double WindowCenter[2] = { 0., 0. };
632 double CameraClippingRange[2] = { 0., 0. };
633 double CameraViewAngle = 0.;
634 double Background[3] = { 0., 0., 0. };
635 double Background2[3] = { 0., 0., 0. };
636 bool GradientBackground = false;
637
638 double ParallelScale = 0.;
639
640 // Initialize members
641 RendererInfo() = default;
642
643 // Save/restore the struct to/from a stream.
646 };
647
649 {
650 double Position[3];
651 double FocalPoint[3];
652 double Type;
653
654 // Initialize members
655 LightInfo() = default;
656
657 // Save/restore the struct to/from a stream.
660 };
661
663 unsigned long RenderRMIId;
664 unsigned long BoundsRMIId;
666
668
669private:
671 void operator=(const vtkParallelRenderManager&) = delete;
672};
673
674VTK_ABI_NAMESPACE_END
675#endif // vtkParalleRenderManager_h
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:29
Multiprocessing communication superclass.
stream used to pass data across processes using vtkMultiProcessController.
abstract base class for most VTK objects
Definition vtkObject.h:49
An object to control parallel rendering.
static void MagnifyImageNearest(vtkUnsignedCharArray *fullImage, const int fullImageSize[2], vtkUnsignedCharArray *reducedImage, const int reducedImageSize[2], const int fullImageViewport[4]=nullptr, const int reducedImageViewport[4]=nullptr)
Convenience functions for magnifying images.
virtual vtkRenderer * MakeRenderer()
Builds a vtkRenderer compatible with this render manager.
void RemoveRenderWindowEventHandlers()
Add/Remove event handlers for the render window.
virtual void PreRenderProcessing()=0
Here is a good place to handle processing of data before and after render.
virtual void EndRender()
Callbacks that initialize and finish rendering and other tasks.
virtual int ImageReduceRenderer(vtkRenderer *)
Returns true if the image for the given renderer should be rendered at a reduced size to be magnified...
virtual void ComputeVisiblePropBoundsRMI(int renderId)
Callbacks that initialize and finish rendering and other tasks.
virtual void ResetCameraClippingRange(vtkRenderer *ren)
Callbacks that initialize and finish rendering and other tasks.
virtual void SendRendererInformation(vtkRenderer *)
virtual void InitializeOffScreen()
Make all rendering windows not viewable set as off screen rendering.
virtual void MagnifyReducedImage()
When called, fills FullImage.
virtual void SendWindowInformation()
Used to synchronize rendering information per frame.
virtual bool ProcessWindowInformation(vtkMultiProcessStream &)
virtual bool ProcessRendererInformation(vtkRenderer *, vtkMultiProcessStream &)
void SetMagnifyImageMethodToLinear()
Sets the method used to magnify images.
virtual void GetPixelData(vtkUnsignedCharArray *data)
The most appropriate way to retrieve full size image data after a render.
virtual vtkRenderWindow * MakeRenderWindow()
Builds a vtkRenderWindow compatible with this render manager.
virtual int LastRenderInFrontBuffer()
Returns 1 if the RenderWindow's last image is in the front buffer, 0 if it is in the back.
virtual void RenderRMI()
Callbacks that initialize and finish rendering and other tasks.
virtual void SetImageReductionFactor(double factor)
Set/Get the reduction factor (for sort-last based parallel renderers).
virtual void GetReducedPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray *data)
The most appropriate way to retrieve reduced size image data after a render.
virtual void PostRenderProcessing()=0
Here is a good place to handle processing of data before and after render.
virtual void InitializePieces()
This method sets the piece and number of pieces for each actor with a polydata mapper.
virtual void SetRenderWindowPixelData(vtkUnsignedCharArray *pixels, const int pixelDimensions[2])
Sets the current render window's pixel data.
static void MagnifyImageLinear(vtkUnsignedCharArray *fullImage, const int fullImageSize[2], vtkUnsignedCharArray *reducedImage, const int reducedImageSize[2], const int fullImageViewport[4]=nullptr, const int reducedImageViewport[4]=nullptr)
Convenience functions for magnifying images.
virtual void ReceiveRendererInformation(vtkRenderer *)
virtual void WriteFullImage()
Write the full image back to the RenderWindow.
virtual void GetPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray *data)
The most appropriate way to retrieve full size image data after a render.
virtual void GenericEndRenderCallback()
INTERNAL METHODS (DON NOT USE).
virtual void ReadReducedImage()
Reads in the reduced image from the RenderWindow.
vtkRendererCollection * Renderers
virtual void CollectWindowInformation(vtkMultiProcessStream &)
Subclass should override these methods (instead of SendWindowInformation/ReceiveWindowInformation or ...
static void SetDefaultRenderEventPropagation(bool val)
Get/Set the default value used for RenderEventPropagation when a new instance of vtkParallelRenderMan...
virtual void InitializeRMIs()
virtual void AddRenderer(vtkRenderer *)
By default, the state of all renderers in the root's render window is propagated to the rest of the p...
virtual void RemoveAllRenderers()
By default, the state of all renderers in the root's render window is propagated to the rest of the p...
vtkUnsignedCharArray * ReducedImage
void TileWindows(int xsize, int ysize, int nColumns)
Given the x and y size of the render windows, reposition them in a tile of n columns.
double AverageTimePerPixel
Used by SetImageReductionFactorForUpdateRate to smooth transitions transitions between image reductio...
virtual void GetReducedPixelData(vtkUnsignedCharArray *data)
The most appropriate way to retrieve reduced size image data after a render.
virtual void ResetAllCameras()
Resets the camera of each renderer contained in the RenderWindow.
virtual void MagnifyImage(vtkUnsignedCharArray *fullImage, const int fullImageSize[2], vtkUnsignedCharArray *reducedImage, const int reducedImageSize[2], const int fullImageViewport[4]=nullptr, const int reducedImageViewport[4]=nullptr)
Convenience functions for magnifying images.
virtual void SetRenderWindowSize()
Called in satellites to set the render window size to the current FullImageSize and ReducedImageSize ...
int RootProcessId
The "root" node's process id.
virtual void SetImageReductionFactorForUpdateRate(double DesiredUpdateRate)
Sets the ReductionFactor based on the given desired update rate and the rendering metrics taken from ...
virtual void SetRenderWindow(vtkRenderWindow *renWin)
Set/Get the RenderWindow to use for compositing.
vtkMultiProcessController * Controller
virtual void CollectRendererInformation(vtkRenderer *, vtkMultiProcessStream &)
virtual void SatelliteStartRender()
Callbacks that initialize and finish rendering and other tasks.
virtual void GenericStartRenderCallback()
INTERNAL METHODS (DON NOT USE).
void AddRenderWindowEventHandlers()
Add/Remove event handlers for the render window.
virtual void SetMagnifyImageMethod(int method)
Sets the method used to magnify images.
virtual void StartServices()
If on node other than root, starts serving RMI requests for parallel renders.
virtual void StartInteractor()
Initializes the RMIs and then, if on root node, starts the interactor on the attached render window.
virtual void SatelliteEndRender()
Callbacks that initialize and finish rendering and other tasks.
virtual void ComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6])
Calculates the bounds by gathering information from all processes.
~vtkParallelRenderManager() override
virtual void SetController(vtkMultiProcessController *controller)
Set/Get the vtkMultiProcessController which will handle communications for the parallel rendering.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void StopServices()
If on root node, stops the RMI processing on all service nodes.
virtual void LocalComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6])
Called by ComputeVisiblePropBoundsRMI to get the bounds of a local renderer.
virtual vtkRendererCollection * GetRenderers()
void SetMagnifyImageMethodToNearest()
Sets the method used to magnify images.
virtual void StartRender()
Callbacks that initialize and finish rendering and other tasks.
virtual void RemoveRenderer(vtkRenderer *)
By default, the state of all renderers in the root's render window is propagated to the rest of the p...
virtual int ChooseBuffer()
Select buffer to read from / render into.
virtual void ResetCamera(vtkRenderer *ren)
Callbacks that initialize and finish rendering and other tasks.
create a window for renderers to draw into
an ordered list of renderers
abstract specification for renderers
Definition vtkRenderer.h:59
Timer support and logging.
Definition vtkTimerLog.h:85
dynamic, self-adjusting array of unsigned char
void Save(vtkMultiProcessStream &stream)
bool Restore(vtkMultiProcessStream &stream)
bool Restore(vtkMultiProcessStream &stream)
void Save(vtkMultiProcessStream &stream)
void Save(vtkMultiProcessStream &stream)
bool Restore(vtkMultiProcessStream &stream)