VTK  9.1.0
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=========================================================================*/
50#ifndef vtkParallelRenderManager_h
51#define vtkParallelRenderManager_h
52
53#include "vtkObject.h"
54#include "vtkRenderingParallelModule.h" // For export macro
55
56class vtkDoubleArray;
59class vtkRenderer;
61class vtkRenderWindow;
62class vtkTimerLog;
64
65class VTKRENDERINGPARALLEL_EXPORT vtkParallelRenderManager : public vtkObject
66{
67public:
69 void PrintSelf(ostream& os, vtkIndent indent) override;
70
79
87
89
93 vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
94 virtual void SetRenderWindow(vtkRenderWindow* renWin);
96
98
102 vtkGetObjectMacro(Controller, vtkMultiProcessController);
103 virtual void SetController(vtkMultiProcessController* controller);
105
110 virtual void InitializePieces();
111
119 virtual void InitializeOffScreen();
120
127 virtual void StartInteractor();
128
133 virtual void StartServices();
134
138 virtual void StopServices();
139
141
144 virtual void StartRender();
145 virtual void EndRender();
146 virtual void SatelliteStartRender();
147 virtual void SatelliteEndRender();
148 virtual void RenderRMI();
149 virtual void ResetCamera(vtkRenderer* ren);
151 virtual void ComputeVisiblePropBoundsRMI(int renderId);
153
154 virtual void InitializeRMIs();
155
161 virtual void ResetAllCameras();
162
166 virtual void ComputeVisiblePropBounds(vtkRenderer* ren, double bounds[6]);
167
169
175 vtkSetMacro(ParallelRendering, int);
176 vtkGetMacro(ParallelRendering, int);
177 vtkBooleanMacro(ParallelRendering, int);
179
181
187 vtkSetMacro(RenderEventPropagation, int);
188 vtkGetMacro(RenderEventPropagation, int);
189 vtkBooleanMacro(RenderEventPropagation, int);
191
198 {
200 }
202 {
204 }
205
207
212 vtkSetMacro(UseCompositing, int);
213 vtkGetMacro(UseCompositing, int);
214 vtkBooleanMacro(UseCompositing, int);
216
218
231 virtual void SetImageReductionFactor(double factor);
232 vtkGetMacro(ImageReductionFactor, double);
234
235 vtkSetMacro(MaxImageReductionFactor, double);
236 vtkGetMacro(MaxImageReductionFactor, double);
237
244 virtual void SetImageReductionFactorForUpdateRate(double DesiredUpdateRate);
245
247
252 vtkSetMacro(AutoImageReductionFactor, int);
253 vtkGetMacro(AutoImageReductionFactor, int);
254 vtkBooleanMacro(AutoImageReductionFactor, int);
256
258
261 vtkGetMacro(RenderTime, double);
262 vtkGetMacro(ImageProcessingTime, double);
264
266
275 vtkGetMacro(SyncRenderWindowRenderers, int);
276 vtkSetMacro(SyncRenderWindowRenderers, int);
277 vtkBooleanMacro(SyncRenderWindowRenderers, int);
278 virtual void AddRenderer(vtkRenderer*);
280 virtual void RemoveAllRenderers();
282
284
293 vtkSetMacro(WriteBackImages, int);
294 vtkGetMacro(WriteBackImages, int);
295 vtkBooleanMacro(WriteBackImages, int);
297
299
304 vtkSetMacro(MagnifyImages, int);
305 vtkGetMacro(MagnifyImages, int);
306 vtkBooleanMacro(MagnifyImages, int);
308
309 enum
310 {
312 LINEAR
313 };
314
316
321 virtual void SetMagnifyImageMethod(int method);
322 vtkGetMacro(MagnifyImageMethod, int);
323 void SetMagnifyImageMethodToNearest() { this->SetMagnifyImageMethod(NEAREST); }
324 void SetMagnifyImageMethodToLinear() { this->SetMagnifyImageMethod(LINEAR); }
326
328
331 virtual void MagnifyImage(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 MagnifyImageNearest(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
335 vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
336 const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
337 static void MagnifyImageLinear(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
338 vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
339 const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
341
343
351 virtual void GetPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray* data);
353
355
363 virtual void GetReducedPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray* data);
365
367
370 vtkGetVector2Macro(FullImageSize, int);
373
376 vtkGetVector2Macro(ReducedImageSize, int);
378
383 void TileWindows(int xsize, int ysize, int nColumns);
384
386
390 vtkSetMacro(UseRGBA, int);
391 vtkGetMacro(UseRGBA, int);
393
395
399 vtkSetMacro(ForceRenderWindowSize, int);
400 vtkGetMacro(ForceRenderWindowSize, int);
402
404
408 vtkSetVector2Macro(ForcedRenderWindowSize, int);
409 vtkGetVector2Macro(ForcedRenderWindowSize, int);
411
412 enum Tags
413 {
414 RENDER_RMI_TAG = 34532,
415 COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG = 54636,
416 WIN_INFO_TAG = 87834,
417 REN_INFO_TAG = 87836,
418 LIGHT_INFO_TAG = 87838,
419 REN_ID_TAG = 58794,
420 BOUNDS_TAG = 23543
421 };
422
423 virtual void CheckForAbortRender() {}
424 virtual int CheckForAbortComposite() { return 0; }
425
427
433 vtkSetMacro(UseBackBuffer, int);
434 vtkGetMacro(UseBackBuffer, int);
435 vtkBooleanMacro(UseBackBuffer, int);
437
439
444 vtkSetMacro(SynchronizeTileProperties, int);
445 vtkGetMacro(SynchronizeTileProperties, int);
446 vtkBooleanMacro(SynchronizeTileProperties, int);
448
450
458
459protected:
462
464
470
474
476
478 int ForcedRenderWindowSize[2];
479
489
492
493 unsigned long StartRenderTag;
494 unsigned long EndRenderTag;
495 unsigned long ResetCameraTag;
497 unsigned long AbortRenderCheckTag;
498
502
506
509 int FullImageSize[2];
510 int ReducedImageSize[2];
511
514
518
520
521 int Lock;
526
528
531
537
544 virtual void SendWindowInformation() {}
545 virtual void ReceiveWindowInformation() {}
548
558 virtual bool ProcessWindowInformation(vtkMultiProcessStream&) { return true; }
561
563
567 virtual void PreRenderProcessing() = 0;
568 virtual void PostRenderProcessing() = 0;
570
575 virtual void SetRenderWindowSize();
576
582 virtual void LocalComputeVisiblePropBounds(vtkRenderer* ren, double bounds[6]);
583
587 virtual void MagnifyReducedImage();
588
592 virtual void WriteFullImage();
593
597 virtual void ReadReducedImage();
598
604
608 virtual int ChooseBuffer();
609
613 virtual void SetRenderWindowPixelData(vtkUnsignedCharArray* pixels, const int pixelDimensions[2]);
614
621 virtual int ImageReduceRenderer(vtkRenderer*) { return 1; }
622
624 {
625 int FullSize[2];
626 int ReducedSize[2];
629 int TileScale[2];
632 double TileViewport[4];
633
634 // Initialize members
635 RenderWindowInfo() = default;
636
637 // Save/restore the struct to/from a stream.
640 };
641
643 {
644 int Draw = 0;
645 int NumberOfLights = 0;
646 double Viewport[4] = { 0., 0., 0., 0. };
647 double CameraPosition[3] = { 0., 0., 0. };
648 double CameraFocalPoint[3] = { 0., 0., 0. };
649 double CameraViewUp[3] = { 0., 0., 0. };
650 double WindowCenter[2] = { 0., 0. };
651 double CameraClippingRange[2] = { 0., 0. };
652 double CameraViewAngle = 0.;
653 double Background[3] = { 0., 0., 0. };
654 double Background2[3] = { 0., 0., 0. };
655 bool GradientBackground = false;
656
657 double ParallelScale = 0.;
658
659 // Initialize members
660 RendererInfo() = default;
661
662 // Save/restore the struct to/from a stream.
665 };
666
668 {
669 double Position[3];
670 double FocalPoint[3];
671 double Type;
672
673 // Initialize members
674 LightInfo() = default;
675
676 // Save/restore the struct to/from a stream.
679 };
680
682 unsigned long RenderRMIId;
683 unsigned long BoundsRMIId;
685
687
688private:
690 void operator=(const vtkParallelRenderManager&) = delete;
691};
692
693#endif // vtkParalleRenderManager_h
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition: vtkIndent.h:113
Multiprocessing communication superclass.
stream used to pass data across processes using vtkMultiProcessController.
abstract base class for most VTK objects
Definition: vtkObject.h:82
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.
vtkUnsignedCharArray * FullImage
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:182
Timer support and logging.
Definition: vtkTimerLog.h:199
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)