VTK
vtkPSurfaceLICComposite.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPSurfaceLICComposite.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  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
24 #ifndef vtkPSurfaceLICComposite_h
25 #define vtkPSurfaceLICComposite_h
26 
27 #include "vtkSurfaceLICComposite.h"
28 #include "vtkWeakPointer.h" // for ren context
29 #include "vtkOpenGLRenderWindow.h" // for context
30 #include "vtkRenderingParallelLICModule.h" // for export macro
31 #include "vtkPixelExtent.h" // for pixel extent
32 #include "vtkPPixelTransfer.h" // for pixel transfer
33 #include <deque> // for deque
34 #include <vector> // for vector
35 #include <list> // for list
36 
37 class vtkFloatArray;
38 class vtkRenderWindow;
40 class vtkTextureObject;
43 class vtkPPixelExtentOps;
44 
45 #ifdef VTK_OPENGL2
46 class vtkOpenGLHelper;
47 #else
48 class vtkShaderProgram2;
49 #endif
50 
51 class VTKRENDERINGPARALLELLIC_EXPORT vtkPSurfaceLICComposite : public vtkSurfaceLICComposite
52 {
53 public:
54  static vtkPSurfaceLICComposite *New();
56  virtual void PrintSelf(ostream &os, vtkIndent indent);
57 
59 
62  virtual void SetContext(vtkOpenGLRenderWindow *rwin);
63  virtual vtkOpenGLRenderWindow *GetContext(){ return this->Context; }
65 
68  virtual void SetCommunicator(vtkPainterCommunicator *comm);
69 
72  virtual int BuildProgram(float *vectors);
73 
75 
77  virtual int Gather(
78  void *pSendPBO,
79  int dataType,
80  int nComps,
81  vtkTextureObject *&newImage);
83 
85 
87  virtual int Scatter(
88  void *pSendPBO,
89  int dataType,
90  int nComps,
91  vtkTextureObject *&newImage);
93 
94 protected:
97 
98 private:
100  int InitializeCompositeShader(vtkOpenGLRenderWindow *context);
101 
103  int ExecuteShader(const vtkPixelExtent &ext, vtkTextureObject *tex);
104 
106 
109  double EstimateCommunicationCost(
110  const std::deque<std::deque<vtkPixelExtent> > &srcExts,
111  const std::deque<std::deque<vtkPixelExtent> > &destExts);
113 
115 
117  double EstimateDecompEfficiency(
118  const std::deque< std::deque<vtkPixelExtent> > &exts,
119  const std::deque< std::deque<vtkPixelExtent> > &guardExts);
121 
123 
124  int DecomposeScreenExtent(
125  std::deque< std::deque<vtkPixelExtent> >&newExts,
126  float *vectors);
128 
130 
131  int DecomposeExtent(
132  vtkPixelExtent &in,
133  int nPieces,
134  std::list<vtkPixelExtent> &out);
136 
138 
144  int MakeDecompDisjoint(
145  const std::deque< std::deque< vtkPixelExtent> > &in,
146  std::deque< std::deque< vtkPixelExtent> > &out,
147  float *vectors);
149 
150 
151  // decomp set of extents
152  int MakeDecompLocallyDisjoint(
153  const std::deque< std::deque< vtkPixelExtent> > &in,
154  std::deque< std::deque< vtkPixelExtent> > &out);
155 
157 
159 
162  int AllGatherExtents(
163  const std::deque<vtkPixelExtent> &localExts,
164  std::deque<std::deque<vtkPixelExtent> > &remoteExts,
165  vtkPixelExtent &dataSetExt);
167 
169 
170  int AllReduceVectorMax(
171  const std::deque<vtkPixelExtent> &originalExts,
172  const std::deque<std::deque<vtkPixelExtent> > &newExts,
173  float *vectors,
174  std::vector<std::vector<float> > &vectorMax);
176 
178 
179  int AddGuardPixels(
180  const std::deque<std::deque<vtkPixelExtent> > &exts,
181  std::deque<std::deque<vtkPixelExtent> > &guardExts,
182  std::deque<std::deque<vtkPixelExtent> > &disjointGuardExts,
183  float *vectors);
185 
186 private:
187  vtkPPainterCommunicator *PainterComm; // mpi state
188  vtkPPixelExtentOps *PixelOps;
189  int CommRank;
190  int CommSize;
191 
192  vtkWeakPointer<vtkOpenGLRenderWindow> Context; // rendering context
193  vtkFrameBufferObject2 *FBO; // buffer object
194 
195 #ifdef VTK_OPENGL2
196  vtkOpenGLHelper *CompositeShader;
197 #else
198  vtkShaderProgram2 *CompositeShader; // shader program for compositing
199 #endif
200 
201  std::deque<vtkPPixelTransfer> GatherProgram; // ordered steps required to move data to new decomp
202  std::deque<vtkPPixelTransfer> ScatterProgram; // ordered steps required to unmove data from new decomp
203 
204  friend VTKRENDERINGPARALLELLIC_EXPORT
205  ostream &operator<<(ostream &os, vtkPSurfaceLICComposite &ss);
206 
207  vtkPSurfaceLICComposite(const vtkPSurfaceLICComposite&); // Not implemented
208  void operator=(const vtkPSurfaceLICComposite&); // Not implemented
209 };
210 
211 VTKRENDERINGPARALLELLIC_EXPORT
212 ostream &operator<<(ostream &os, vtkPSurfaceLICComposite &ss);
213 
214 #endif
OpenGL rendering window.
static vtkSurfaceLICComposite * New()
VTKRENDERINGPARALLELLIC_EXPORT ostream & operator<<(ostream &os, vtkPSurfaceLICComposite &ss)
friend ostream & operator<<(ostream &os, vtkSurfaceLICComposite &ss)
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:45
virtual vtkOpenGLRenderWindow * GetContext()
virtual void SetCommunicator(vtkPainterCommunicator *)
virtual int Gather(void *, int, int, vtkTextureObject *&)
virtual void PrintSelf(ostream &os, vtkIndent indent)
GLSL Program.
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void SetContext(vtkOpenGLRenderWindow *)
int AddGuardPixels(const std::deque< vtkPixelExtent > &exts, std::deque< vtkPixelExtent > &guardExts, std::deque< vtkPixelExtent > &disjointGuardExts, float *vectors)
static int MakeDecompDisjoint(std::deque< vtkPixelExtent > &in, std::deque< vtkPixelExtent > &out)
abstracts an OpenGL texture object.
create a window for renderers to draw into
virtual int Scatter(void *, int, int, vtkTextureObject *&)
virtual int BuildProgram(float *)
Interface to OpenGL framebuffer object.