VTKFIG  0.25.0
Easy VTK based in situ visualization
vtkfigVectorView.h
Go to the documentation of this file.
1 
7 #ifndef VTKFIG_QUIVER_H
8 #define VTKFIG_QUIVER_H
9 
10 #include <vtkPolyData.h>
11 #include <vtkDoubleArray.h>
12 
13 #include "vtkfigFigure.h"
14 #include "vtkfigTools.h"
15 
16 
17 
18 namespace vtkfig
19 {
20 
21 
25  class VectorView: public Figure
26  {
27  public:
28 
29 
31  static std::shared_ptr<VectorView> New();
32 
33  virtual std::string SubClassName() override final {return std::string("VectorView");}
34 
35 
37  void ShowQuiver(bool b) { state.show_quiver=b;}
38 
40  void SetQuiverArrowScale(double scale) { state.quiver_arrowscale_user=scale;}
41 
43  void ShowQuiverColorbar(bool b) { state.show_quiver_colorbar=b;}
44 
46  void SetQuiverGrid(int nx, int ny);
47 
49  void SetQuiverGrid(int nx, int ny, int nz);
50 
52  template <class V>
53  void SetQuiverPoints( const V&p);
54 
55 
56 
67  template <class V>
68  void SetQuiverRGBTable(const V & tab, int lutsize);
69 
75  void SetQuiverRGBTable(RGBTable & tab, int lutsize);
76 
77 
79  void ShowStreamLines(bool b) { state.show_stream=b;}
80 
82  void ShowStreamLineColorbar(bool b) { state.show_stream_colorbar=b;}
83 
85  void SetStreamLineMaximumPropagation(double l){ state.stream_maximum_propagation=l;}
86 
88  void SetStreamLineMaximumNumberOfSteps(int l){ state.stream_maximum_number_of_steps=l;}
89 
91  void SetStreamLineInitialIntegrationStep(double l){ state.stream_initial_integration_step=l;}
92 
94  void SetStreamLineMaximumIntegrationStep(double l){ state.stream_maximum_integration_step=l;}
95 
97  void SetStreamLineWidth(double w){state.stream_ribbonwidth=w;}
98 
99 
101  template <class V>
102  void SetStreamLineSeedPoints( const V&p);
103 
104 
115  template <class V>
116  void SetStreamLineRGBTable(const V & tab, int lutsize);
117 
123  void SetStreamLineRGBTable(RGBTable & tab, int lutsize);
124 
125 
126  protected:
127  VectorView();
128  ~VectorView(){};
129 
130  private:
131 
132  void RTBuildVTKPipeline() override final;
133  void ServerMPSend(vtkSmartPointer<internals::Communicator> communicator) override final;
134  void ClientMPReceive(vtkSmartPointer<internals::Communicator> communicator) override final;
135 
136 
137  template <class DATA> void RTBuildVTKPipeline0();
138 
139 
140  vtkSmartPointer<vtkPolyData> probePolyData;
141  vtkSmartPointer<vtkPolyData> seedPolyData;
142  };
143 
144 
145  template <class V>
146  inline
147  void VectorView::SetQuiverPoints( const V&p)
148  {
149 
150  auto probePoints = vtkSmartPointer<vtkPoints>::New();
151  if (state.spacedim==2)
152  for (int i=0;i<p.size();i+=2)
153  probePoints->InsertNextPoint (p[i+0],p[i+1],0);
154 
155  if (state.spacedim==3)
156  for (int i=0;i<p.size();i+=3)
157  probePoints->InsertNextPoint (p[i+0],p[i+1],p[i+2]);
158  probePolyData =vtkSmartPointer<vtkPolyData>::New();
159  probePolyData->SetPoints(probePoints);
160  };
161 
162 
163 
165  template <class V>
166  inline
167  void VectorView::SetQuiverRGBTable(const V & tab, int lutsize)
168  {
169  RGBTable rgbtab;
170  rgbtab.resize(tab.size()/4);
171  for (int i=0,j=0; i<tab.size(); i+=4,j++)
172  {
173  rgbtab[j].x=tab[i+0];
174  rgbtab[j].r=tab[i+1];
175  rgbtab[j].g=tab[i+2];
176  rgbtab[j].b=tab[i+3];
177  }
178  SetQuiverRGBTable(rgbtab, lutsize);
179  }
180 
181  template <class V>
182  inline
183  void VectorView::SetStreamLineRGBTable(const V & tab, int lutsize)
184  {
185  RGBTable rgbtab;
186  rgbtab.resize(tab.size()/4);
187  for (int i=0,j=0; i<tab.size(); i+=4,j++)
188  {
189  rgbtab[j].x=tab[i+0];
190  rgbtab[j].r=tab[i+1];
191  rgbtab[j].g=tab[i+2];
192  rgbtab[j].b=tab[i+3];
193  }
194  SetStreamLineRGBTable(rgbtab, lutsize);
195  }
196 
197 
198  template <class V>
199  inline
201  {
202 
203  auto seedPoints = vtkSmartPointer<vtkPoints>::New();
204  if (state.spacedim==2)
205  for (size_t i=0;i<p.size();i+=2)
206  seedPoints->InsertNextPoint (p[i+0]*coordinate_scale_factor,p[i+1]*coordinate_scale_factor,0);
207 
208  if (state.spacedim==3)
209  for (size_t i=0;i<p.size();i+=3)
210  seedPoints->InsertNextPoint (p[i+0]*coordinate_scale_factor,
212  p[i+2]*coordinate_scale_factor);
213  seedPolyData =vtkSmartPointer<vtkPolyData>::New();
214  seedPolyData->SetPoints(seedPoints);
215  };
216 
217 
218 }
219 
220 
221 #endif
222 
vtkfig::VectorView::New
static std::shared_ptr< VectorView > New()
Smart pointer constructor.
vtkfig::Figure::state
struct vtkfig::Figure::@0 state
figure state
vtkfig::VectorView::SetStreamLineMaximumNumberOfSteps
void SetStreamLineMaximumNumberOfSteps(int l)
Set maximum number of steps.
Definition: vtkfigVectorView.h:88
vtkfig::VectorView::SetStreamLineWidth
void SetStreamLineWidth(double w)
Set width of stream ribbons.
Definition: vtkfigVectorView.h:97
vtkfig::VectorView::SetQuiverGrid
void SetQuiverGrid(int nx, int ny)
Set quiver points on grid in domain bounding box (2D)
vtkfigFigure.h
vtkfig::Figure::coordinate_scale_factor
double coordinate_scale_factor
coordinate scale
Definition: vtkfigFigure.h:386
vtkfig::VectorView::ShowStreamLineColorbar
void ShowStreamLineColorbar(bool b)
Show color bar for stream lines.
Definition: vtkfigVectorView.h:82
vtkfig::VectorView::SetStreamLineRGBTable
void SetStreamLineRGBTable(const V &tab, int lutsize)
Set streamline RGB table from vector.
Definition: vtkfigVectorView.h:183
vtkfig::VectorView::ShowStreamLines
void ShowStreamLines(bool b)
Show stream lines (false by default)
Definition: vtkfigVectorView.h:79
vtkfig::VectorView::SetStreamLineMaximumIntegrationStep
void SetStreamLineMaximumIntegrationStep(double l)
Set maximum integration step for streamlines.
Definition: vtkfigVectorView.h:94
vtkfig::VectorView::SetStreamLineInitialIntegrationStep
void SetStreamLineInitialIntegrationStep(double l)
Set initial integration step for streamlines.
Definition: vtkfigVectorView.h:91
vtkfig::Figure
Base class for all figures.
Definition: vtkfigFigure.h:61
vtkfig::VectorView::SetQuiverRGBTable
void SetQuiverRGBTable(const V &tab, int lutsize)
Set quiver RGB table from vector.
Definition: vtkfigVectorView.h:167
vtkfig::VectorView::SubClassName
virtual std::string SubClassName() override final
Get subclass name (for s-c communication, should be replaced by tag.
Definition: vtkfigVectorView.h:33
vtkfig::RGBTable
std::vector< RGBPoint > RGBTable
Color table.
Definition: vtkfigTools.h:43
vtkfig::VectorView::SetQuiverArrowScale
void SetQuiverArrowScale(double scale)
Set scaling of arrows.
Definition: vtkfigVectorView.h:40
vtkfig::VectorView::ShowQuiverColorbar
void ShowQuiverColorbar(bool b)
Show color bar for quiver colors.
Definition: vtkfigVectorView.h:43
vtkfig::VectorView::SetQuiverPoints
void SetQuiverPoints(const V &p)
Set quiver points from vector.
Definition: vtkfigVectorView.h:147
vtkfig::VectorView
Quiver plots + streamlines for vector fields.
Definition: vtkfigVectorView.h:25
vtkfig::VectorView::ShowQuiver
void ShowQuiver(bool b)
Show quiver plot (true by default)
Definition: vtkfigVectorView.h:37
vtkfig::VectorView::SetStreamLineSeedPoints
void SetStreamLineSeedPoints(const V &p)
Set seed points for streamlines.
Definition: vtkfigVectorView.h:200
vtkfigTools.h
vtkfig::VectorView::SetStreamLineMaximumPropagation
void SetStreamLineMaximumPropagation(double l)
Set length of stream lines.
Definition: vtkfigVectorView.h:85