VTKFIG  0.20.20181114
Easy VTK based in situ visualization
template<class DATA , class FILTER >
void vtkfig::ScalarView::RTBuildVTKPipeline2D ( )
private

2D Filter

should react on elevation view

if we cut away a part of the ouline by vtkExtractCells, we still need the axes to be correct, so they must be created using the original geometry

should react on elevation view

if we cut away a part of the ouline by vtkExtractCells, we still need the axes to be correct, so they must be created using the original geometry

Definition at line 56 of file vtkfigScalarView-2018-01-21-2258.cxx.

57  {
58 
60 
62  //renderer->GetActiveCamera()->SetParallelProjection(1);
63 
64  auto values=vtkDoubleArray::SafeDownCast(DATA::SafeDownCast(data_producer->GetOutputDataObject(0))->GetPointData()->GetAbstractArray(dataname.c_str()));
65 
66  vtkSmartPointer<vtkExtractCells> subgrid;
67  if (celllist)
68  {
69  subgrid=vtkSmartPointer<vtkExtractCells>::New();
70  subgrid->SetInputConnection(data_producer->GetOutputPort());
71  subgrid->SetCellList(celllist);
72  }
73 
74 
75  auto scalar = vtkSmartPointer<vtkAssignAttribute>::New();
76  scalar->Assign(dataname.c_str(),vtkDataSetAttributes::SCALARS,vtkAssignAttribute::POINT_DATA);
77  if (celllist)
78  scalar->SetInputConnection(subgrid->GetOutputPort());
79  else
80  scalar->SetInputConnection(data_producer->GetOutputPort());
81 
82  auto geometry=vtkSmartPointer<FILTER>::New();
83  geometry->SetInputConnection(scalar->GetOutputPort());
84 
85 
86 
87  auto transgeometry=vtkSmartPointer<vtkTransformPolyDataFilter>::New();
88  transgeometry->SetInputConnection(geometry->GetOutputPort());
89  transgeometry->SetTransform(transform);
90 
94  vtkSmartPointer<vtkTransformPolyDataFilter> transallgeometry;
95  if (celllist)
96  {
97  auto allgeometry=vtkSmartPointer<FILTER>::New();
98  allgeometry->SetInputConnection(data_producer->GetOutputPort());
99 
100  transallgeometry=vtkSmartPointer<vtkTransformPolyDataFilter>::New();
101  transallgeometry->SetTransform(transform);
102  transallgeometry->SetInputConnection(allgeometry->GetOutputPort());
103  }
104  else
105  transallgeometry=transgeometry;
106 
107  if (true) // Elevation
108  {
109  auto wtransform = vtkSmartPointer<vtkTransform>::New();
110  wtransform->Translate(0,0,0.5);
111  auto wtransgeometry=vtkSmartPointer<vtkTransformPolyDataFilter>::New();
112  wtransgeometry->SetInputConnection(transgeometry->GetOutputPort());
113  wtransgeometry->SetTransform(wtransform);
114 
115  auto elevation = vtkSmartPointer<vtkWarpScalar>::New();
116  elevation->SetInputConnection(wtransgeometry->GetOutputPort());
117  elevation->SetScaleFactor(0.5/(state.real_vmax-state.real_vmin));
118  vtkSmartPointer<vtkPolyDataMapper> wmapper = vtkSmartPointer<vtkPolyDataMapper>::New();
119  wmapper->SetInputConnection(elevation->GetOutputPort());
120  vtkSmartPointer<vtkActor> wplot = vtkSmartPointer<vtkActor>::New();
121  wmapper->UseLookupTableScalarRangeOn();
122  wmapper->SetLookupTable(elevation_lut);
123  elevation_plot->SetMapper(wmapper);
124  elevation_plot->SetVisibility(state.show_elevation);
126  }
127 
128 
129  if (true)
130  {
131  vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
132  mapper->SetInputConnection(transgeometry->GetOutputPort());
133 
134 // mapper->InterpolateScalarsBeforeMappingOn();
135  mapper->UseLookupTableScalarRangeOn();
136  mapper->SetLookupTable(surface_lut);
137 #ifdef VTK_HAS_MAPPER_IMMEDIATE_RENDERING_ON
138  mapper->ImmediateModeRenderingOn();
139 #endif
140  surface_plot->SetMapper(mapper);
141  surface_plot->SetVisibility(state.show_surface);
143 
144  if (state.show_surface_colorbar)
145  {
146  auto cbar=BuildColorBar(mapper);
147  cbar->SetLabelFormat(state.surface_colorbar_label_format);
148  cbar->SetNumberOfLabels(state.surface_colorbar_num_labels);
150  }
151  }
152 
153 
154  if (true)
155  {
156 
157  isoline_filter->SetInputConnection(transgeometry->GetOutputPort());
158 
159  vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
160  mapper->SetInputConnection(isoline_filter->GetOutputPort());
161  //mapper->UseLookupTableScalarRangeOn();
162  //mapper->SetLookupTable(contour_lut);
163  mapper->ScalarVisibilityOff();
164 
165  isoline_plot->SetMapper(mapper);
166  isoline_plot->GetProperty()->SetColor(0,0,0);
167  isoline_plot->GetProperty()->SetLineWidth(state.isoline_width);
168  isoline_plot->SetVisibility(state.show_isolines);
170 
171  // if (state.show_contour_colorbar)
172  // Figure::RTAddActor2D(BuildColorBar(mapper));
173 
174  // if (state.show_slider)
175  // AddSlider(interactor,renderer);
176 
177  }
178 
179 
180  }
std::string dataname
Name of data item in data set.
Definition: vtkfigFigure.h:256
void RTAddActor2D(vtkSmartPointer< vtkActor2D > prop)
Add vtk Actor to renderer showing figure.
vtkSmartPointer< vtkIdList > celllist
Cell mask.
Definition: vtkfigFigure.h:259
vtkSmartPointer< vtkContourFilter > isoline_filter
Definition: vtkfigFigure.h:224
vtkSmartPointer< vtkActor > surface_plot
Items for surface plot.
Definition: vtkfigFigure.h:230
vtkSmartPointer< vtkTrivialProducer > data_producer
Data producer for grid dataset.
Definition: vtkfigFigure.h:247
vtkSmartPointer< vtkTransform > transform
Definition: vtkfigFigure.h:200
void RTCalcTransform()
Calculate transformation to unit cube This shall be applied to all data.
vtkSmartPointer< vtkActor > isoline_plot
Items for isoline plot.
Definition: vtkfigFigure.h:223
vtkSmartPointer< vtkLookupTable > surface_lut
Color lookup table for surface plots.
Definition: vtkfigFigure.h:265
vtkSmartPointer< vtkLookupTable > elevation_lut
Color lookup table for contour plots vtkSmartPointer<vtkLookupTable> contour_lut; RGBTable contour_rg...
Definition: vtkfigFigure.h:303
struct vtkfig::Figure::@0 state
figure state
void RTAddActor(vtkSmartPointer< vtkActor > prop)
Add vtk Actor to renderer showing figure.
vtkSmartPointer< vtkScalarBarActor > cbar
Definition: vtkfigFigure.h:293
vtkSmartPointer< vtkScalarBarActor > BuildColorBar(vtkSmartPointer< vtkPolyDataMapper > mapper, int irank=0)
Definition: vtkfigTools.cxx:88
vtkSmartPointer< vtkActor > elevation_plot
Items for elevation plot.
Definition: vtkfigFigure.h:227

+ Here is the call graph for this function: