1 #include <vtkSliderRepresentation2D.h> 2 #include <vtkProperty2D.h> 3 #include <vtkAlgorithmOutput.h> 4 #include <vtkTextProperty.h> 5 #include <vtkRectilinearGrid.h> 6 #include <vtkGeometryFilter.h> 7 #include <vtkRectilinearGridGeometryFilter.h> 8 #include <vtkUnstructuredGrid.h> 9 #include <vtkUnstructuredGridGeometryFilter.h> 11 #include <vtkCutter.h> 12 #include <vtkImplicitBoolean.h> 13 #include <vtkOutlineFilter.h> 14 #include <vtkCubeAxesActor2D.h> 15 #include <vtkAppendPolyData.h> 16 #include <vtkAssignAttribute.h> 17 #include <vtkCamera.h> 18 #include <vtkTextActor.h> 19 #include <vtkCoordinate.h> 20 #include <vtkTransformPolyDataFilter.h> 21 #include <vtkTransformFilter.h> 22 #include <vtkClipPolyData.h> 23 #include <vtkWarpScalar.h> 24 #include <vtkExtractCells.h> 25 #include <vtkIdList.h> 46 state.surface_rgbtab_size=tabsize;
47 state.surface_rgbtab_modified=
true;
61 state.elevation_scale=val;
70 template <
class DATA,
class FILTER>
79 auto values=vtkDoubleArray::SafeDownCast(DATA::SafeDownCast(
data_producer->GetOutputDataObject(0))->GetPointData()->GetAbstractArray(
dataname.c_str()));
81 vtkSmartPointer<vtkExtractCells> subgrid;
84 subgrid=vtkSmartPointer<vtkExtractCells>::New();
90 auto scalar = vtkSmartPointer<vtkAssignAttribute>::New();
91 scalar->Assign(
dataname.c_str(),vtkDataSetAttributes::SCALARS,vtkAssignAttribute::POINT_DATA);
93 scalar->SetInputConnection(subgrid->GetOutputPort());
97 auto geometry=vtkSmartPointer<FILTER>::New();
98 geometry->SetInputConnection(scalar->GetOutputPort());
102 auto transgeometry=vtkSmartPointer<vtkTransformPolyDataFilter>::New();
103 transgeometry->SetInputConnection(geometry->GetOutputPort());
109 vtkSmartPointer<vtkTransformPolyDataFilter> transallgeometry;
112 auto allgeometry=vtkSmartPointer<FILTER>::New();
113 allgeometry->SetInputConnection(
data_producer->GetOutputPort());
115 transallgeometry=vtkSmartPointer<vtkTransformPolyDataFilter>::New();
116 transallgeometry->SetTransform(
transform);
117 transallgeometry->SetInputConnection(allgeometry->GetOutputPort());
120 transallgeometry=transgeometry;
124 auto wtransgeometry=vtkSmartPointer<vtkTransformPolyDataFilter>::New();
125 wtransgeometry->SetInputConnection(transgeometry->GetOutputPort());
128 auto elevation = vtkSmartPointer<vtkWarpScalar>::New();
129 elevation->SetInputConnection(wtransgeometry->GetOutputPort());
130 elevation->SetScaleFactor(
state.elevation_scale*0.5/(
state.real_vmax-
state.real_vmin));
131 vtkSmartPointer<vtkPolyDataMapper> wmapper = vtkSmartPointer<vtkPolyDataMapper>::New();
132 wmapper->SetInputConnection(elevation->GetOutputPort());
133 vtkSmartPointer<vtkActor> wplot = vtkSmartPointer<vtkActor>::New();
134 wmapper->UseLookupTableScalarRangeOn();
144 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
145 mapper->SetInputConnection(transgeometry->GetOutputPort());
148 mapper->UseLookupTableScalarRangeOn();
150 #ifdef VTK_HAS_MAPPER_IMMEDIATE_RENDERING_ON 151 mapper->ImmediateModeRenderingOn();
157 if (
state.show_surface_colorbar)
160 cbar->SetLabelFormat(
state.surface_colorbar_label_format);
161 cbar->SetNumberOfLabels(
state.surface_colorbar_num_labels);
170 isoline_filter->SetInputConnection(transgeometry->GetOutputPort());
172 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
176 mapper->ScalarVisibilityOff();
199 template <
class DATA,
class FILTER>
206 vtkSmartPointer<vtkExtractCells> subgrid;
209 subgrid=vtkSmartPointer<vtkExtractCells>::New();
216 auto scalar = vtkSmartPointer<vtkAssignAttribute>::New();
217 scalar->Assign(
dataname.c_str(),vtkDataSetAttributes::SCALARS,vtkAssignAttribute::POINT_DATA);
219 scalar->SetInputConnection(subgrid->GetOutputPort());
226 auto transgeometry=vtkSmartPointer<vtkTransformFilter>::New();
227 transgeometry->SetInputConnection(scalar->GetOutputPort());
230 vtkSmartPointer<vtkTransformFilter> transallgeometry;
233 auto allgeometry=vtkSmartPointer<FILTER>::New();
234 allgeometry->SetInputConnection(
data_producer->GetOutputPort());
236 transallgeometry=vtkSmartPointer<vtkTransformFilter>::New();
237 transallgeometry->SetTransform(
transform);
238 transallgeometry->SetInputConnection(allgeometry->GetOutputPort());
241 transallgeometry=transgeometry;
250 planecutX->SetInputConnection(transgeometry->GetOutputPort());
255 planecutY->SetInputConnection(transgeometry->GetOutputPort());
259 planecutZ->SetInputConnection(transgeometry->GetOutputPort());
265 vtkSmartPointer<vtkClipPolyData> clipgeometry=0;
269 clipgeometry=vtkSmartPointer<vtkClipPolyData>::New();
270 auto sfilter=vtkSmartPointer<FILTER>::New();
271 sfilter->SetInputConnection(transgeometry->GetOutputPort());
272 clipgeometry->SetInputConnection(sfilter->GetOutputPort());
273 clipgeometry->SetClipFunction(
planeZ);
274 clipgeometry->SetInsideOut(1);
276 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
279 mapper->SetInputConnection(clipgeometry->GetOutputPort());
280 mapper->UseLookupTableScalarRangeOn();
282 auto splot=vtkSmartPointer<vtkActor>::New();
283 splot->GetProperty()->SetOpacity(1.0);
284 splot->SetMapper(mapper);
291 auto xyz = vtkSmartPointer<vtkAppendPolyData>::New();
292 xyz->SetUserManagedInputs(1);
294 xyz->SetNumberOfInputs(4);
296 xyz->SetNumberOfInputs(3);
298 xyz->SetInputConnectionByNumber(0,
planecutX->GetOutputPort());
299 xyz->SetInputConnectionByNumber(1,
planecutY->GetOutputPort());
300 xyz->SetInputConnectionByNumber(2,
planecutZ->GetOutputPort());
302 xyz->SetInputConnectionByNumber(3,clipgeometry->GetOutputPort());
305 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
306 mapper->SetInputConnection(xyz->GetOutputPort());
307 mapper->UseLookupTableScalarRangeOn();
310 vtkSmartPointer<vtkActor> plot = vtkSmartPointer<vtkActor>::New();
311 plot->GetProperty()->SetOpacity(1);
312 plot->SetMapper(mapper);
324 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
328 mapper->ScalarVisibilityOff();
344 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
346 mapper->UseLookupTableScalarRangeOn();
368 if (
state.spacedim==2)
369 this->RTBuildVTKPipeline2D<vtkUnstructuredGrid,vtkGeometryFilter>();
371 this->RTBuildVTKPipeline3D<vtkUnstructuredGrid,vtkGeometryFilter>();
375 if (
state.spacedim==2)
376 this->RTBuildVTKPipeline2D<vtkRectilinearGrid,vtkRectilinearGridGeometryFilter>();
378 this->RTBuildVTKPipeline3D<vtkRectilinearGrid,vtkRectilinearGridGeometryFilter>();
390 if (
state.surface_rgbtab_modified)
393 state.surface_rgbtab_modified=
false;
400 if (
state.surface_rgbtab_modified)
void ServerRTSend(vtkSmartPointer< internals::Communicator > communicator) override final
Client-Server communication.
void RTBuildVTKPipeline2D()
2D Filter
void ClientMTReceive(vtkSmartPointer< internals::Communicator > communicator) override final
Receive data from server.
void SetElevationScale(double val)
Change scale for elevation plot.
vtkSmartPointer< vtkLookupTable > BuildLookupTable(RGBTable &xrgb, size_t size)
void SetSurfaceRGBTable(const V &tab, int lutsize)
Set Surface RGB table from vector.
std::vector< RGBPoint > RGBTable
void RTBuildVTKPipeline() override final
Generic access to filter.
vtkSmartPointer< vtkScalarBarActor > BuildColorBar(vtkSmartPointer< vtkPolyDataMapper > mapper, int irank=0)
void RTBuildVTKPipeline3D()
3D Filter
void SetElevationZShift(double val)
Change zshift for elevation plot.