VTK  9.2.6
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=========================================================================*/
47#ifndef vtkParallelRenderManager_h
48#define vtkParallelRenderManager_h
49
50#include "vtkObject.h"
51#include "vtkRenderingParallelModule.h" // For export macro
52
53class vtkDoubleArray;
56class vtkRenderer;
58class vtkRenderWindow;
59class vtkTimerLog;
61
62class VTKRENDERINGPARALLEL_EXPORT vtkParallelRenderManager : public vtkObject
63{
64public:
66 void PrintSelf(ostream& os, vtkIndent indent) override;
67
76
84
86
90 vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
91 virtual void SetRenderWindow(vtkRenderWindow* renWin);
93
95
99 vtkGetObjectMacro(Controller, vtkMultiProcessController);
100 virtual void SetController(vtkMultiProcessController* controller);
102
107 virtual void InitializePieces();
108
116 virtual void InitializeOffScreen();
117
124 virtual void StartInteractor();
125
130 virtual void StartServices();
131
135 virtual void StopServices();
136
138
141 virtual void StartRender();
142 virtual void EndRender();
143 virtual void SatelliteStartRender();
144 virtual void SatelliteEndRender();
145 virtual void RenderRMI();
146 virtual void ResetCamera(vtkRenderer* ren);
148 virtual void ComputeVisiblePropBoundsRMI(int renderId);
150
151 virtual void InitializeRMIs();
152
158 virtual void ResetAllCameras();
159
163 virtual void ComputeVisiblePropBounds(vtkRenderer* ren, double bounds[6]);
164
166
172 vtkSetMacro(ParallelRendering, int);
173 vtkGetMacro(ParallelRendering, int);
174 vtkBooleanMacro(ParallelRendering, int);
176
178
184 vtkSetMacro(RenderEventPropagation, int);
185 vtkGetMacro(RenderEventPropagation, int);
186 vtkBooleanMacro(RenderEventPropagation, int);
188
195 {
197 }
199 {
201 }
202
204
209 vtkSetMacro(UseCompositing, int);
210 vtkGetMacro(UseCompositing, int);
211 vtkBooleanMacro(UseCompositing, int);
213
215
228 virtual void SetImageReductionFactor(double factor);
229 vtkGetMacro(ImageReductionFactor, double);
231
232 vtkSetMacro(MaxImageReductionFactor, double);
233 vtkGetMacro(MaxImageReductionFactor, double);
234
241 virtual void SetImageReductionFactorForUpdateRate(double DesiredUpdateRate);
242
244
249 vtkSetMacro(AutoImageReductionFactor, int);
250 vtkGetMacro(AutoImageReductionFactor, int);
251 vtkBooleanMacro(AutoImageReductionFactor, int);
253
255
258 vtkGetMacro(RenderTime, double);
259 vtkGetMacro(ImageProcessingTime, double);
261
263
272 vtkGetMacro(SyncRenderWindowRenderers, int);
273 vtkSetMacro(SyncRenderWindowRenderers, int);
274 vtkBooleanMacro(SyncRenderWindowRenderers, int);
275 virtual void AddRenderer(vtkRenderer*);
277 virtual void RemoveAllRenderers();
279
281
290 vtkSetMacro(WriteBackImages, int);
291 vtkGetMacro(WriteBackImages, int);
292 vtkBooleanMacro(WriteBackImages, int);
294
296
301 vtkSetMacro(MagnifyImages, int);
302 vtkGetMacro(MagnifyImages, int);
303 vtkBooleanMacro(MagnifyImages, int);
305
306 enum
307 {
309 LINEAR
310 };
311
313
318 virtual void SetMagnifyImageMethod(int method);
319 vtkGetMacro(MagnifyImageMethod, int);
320 void SetMagnifyImageMethodToNearest() { this->SetMagnifyImageMethod(NEAREST); }
321 void SetMagnifyImageMethodToLinear() { this->SetMagnifyImageMethod(LINEAR); }
323
325
328 virtual void MagnifyImage(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 MagnifyImageNearest(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
332 vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
333 const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
334 static void MagnifyImageLinear(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
335 vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
336 const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
338
340
348 virtual void GetPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray* data);
350
352
360 virtual void GetReducedPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray* data);
362
364
367 vtkGetVector2Macro(FullImageSize, int);
370
373 vtkGetVector2Macro(ReducedImageSize, int);
375
380 void TileWindows(int xsize, int ysize, int nColumns);
381
383
387 vtkSetMacro(UseRGBA, int);
388 vtkGetMacro(UseRGBA, int);
390
392
396 vtkSetMacro(ForceRenderWindowSize, int);
397 vtkGetMacro(ForceRenderWindowSize, int);
399
401
405 vtkSetVector2Macro(ForcedRenderWindowSize, int);
406 vtkGetVector2Macro(ForcedRenderWindowSize, int);
408
409 enum Tags
410 {
411 RENDER_RMI_TAG = 34532,
412 COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG = 54636,
413 WIN_INFO_TAG = 87834,
414 REN_INFO_TAG = 87836,
415 LIGHT_INFO_TAG = 87838,
416 REN_ID_TAG = 58794,
417 BOUNDS_TAG = 23543
418 };
419
420 virtual void CheckForAbortRender() {}
421 virtual int CheckForAbortComposite() { return 0; }
422
424
430 vtkSetMacro(UseBackBuffer, int);
431 vtkGetMacro(UseBackBuffer, int);
432 vtkBooleanMacro(UseBackBuffer, int);
434
436
441 vtkSetMacro(SynchronizeTileProperties, int);
442 vtkGetMacro(SynchronizeTileProperties, int);
443 vtkBooleanMacro(SynchronizeTileProperties, int);
445
447
455
456protected:
459
461
467
471
473
475 int ForcedRenderWindowSize[2];
476
486
489
490 unsigned long StartRenderTag;
491 unsigned long EndRenderTag;
492 unsigned long ResetCameraTag;
494 unsigned long AbortRenderCheckTag;
495
499
503
506 int FullImageSize[2];
507 int ReducedImageSize[2];
508
511
515
517
518 int Lock;
523
525
528
534
541 virtual void SendWindowInformation() {}
542 virtual void ReceiveWindowInformation() {}
545
555 virtual bool ProcessWindowInformation(vtkMultiProcessStream&) { return true; }
558
560
564 virtual void PreRenderProcessing() = 0;
565 virtual void PostRenderProcessing() = 0;
567
572 virtual void SetRenderWindowSize();
573
579 virtual void LocalComputeVisiblePropBounds(vtkRenderer* ren, double bounds[6]);
580
584 virtual void MagnifyReducedImage();
585
589 virtual void WriteFullImage();
590
594 virtual void ReadReducedImage();
595
601
605 virtual int ChooseBuffer();
606
610 virtual void SetRenderWindowPixelData(vtkUnsignedCharArray* pixels, const int pixelDimensions[2]);
611
618 virtual int ImageReduceRenderer(vtkRenderer*) { return 1; }
619
621 {
622 int FullSize[2];
623 int ReducedSize[2];
626 int TileScale[2];
629 double TileViewport[4];
630
631 // Initialize members
632 RenderWindowInfo() = default;
633
634 // Save/restore the struct to/from a stream.
637 };
638
640 {
641 int Draw = 0;
642 int NumberOfLights = 0;
643 double Viewport[4] = { 0., 0., 0., 0. };
644 double CameraPosition[3] = { 0., 0., 0. };
645 double CameraFocalPoint[3] = { 0., 0., 0. };
646 double CameraViewUp[3] = { 0., 0., 0. };
647 double WindowCenter[2] = { 0., 0. };
648 double CameraClippingRange[2] = { 0., 0. };
649 double CameraViewAngle = 0.;
650 double Background[3] = { 0., 0., 0. };
651 double Background2[3] = { 0., 0., 0. };
652 bool GradientBackground = false;
653
654 double ParallelScale = 0.;
655
656 // Initialize members
657 RendererInfo() = default;
658
659 // Save/restore the struct to/from a stream.
662 };
663
665 {
666 double Position[3];
667 double FocalPoint[3];
668 double Type;
669
670 // Initialize members
671 LightInfo() = default;
672
673 // Save/restore the struct to/from a stream.
676 };
677
679 unsigned long RenderRMIId;
680 unsigned long BoundsRMIId;
682
684
685private:
687 void operator=(const vtkParallelRenderManager&) = delete;
688};
689
690#endif // vtkParalleRenderManager_h
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:34
Multiprocessing communication superclass.
stream used to pass data across processes using vtkMultiProcessController.
abstract base class for most VTK objects
Definition vtkObject.h:57
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:67
Timer support and logging.
Definition vtkTimerLog.h:90
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)