2 #include <vtkPointData.h> 3 #include <vtkProperty.h> 4 #include <vtkTextProperty.h> 5 #include <vtkContourFilter.h> 6 #include <vtkOutlineFilter.h> 7 #include <vtkRectilinearGridGeometryFilter.h> 8 #include <vtkGeometryFilter.h> 9 #include <vtkGlyph3D.h> 10 #include <vtkRectilinearGrid.h> 11 #include <vtkGlyphSource2D.h> 12 #include <vtkAssignAttribute.h> 13 #include <vtkProbeFilter.h> 14 #include <vtkTransformPolyDataFilter.h> 15 #include <vtkTransformFilter.h> 16 #include <vtkStreamTracer.h> 17 #include <vtkRibbonFilter.h> 18 #include <vtkArrayCalculator.h> 35 state.quiver_rgbtab_size=tabsize;
36 state.quiver_rgbtab_modified=
true;
43 state.stream_rgbtab_size=tabsize;
44 state.stream_rgbtab_modified=
true;
53 assert(
state.spacedim==2);
55 auto data=vtkDataSet::SafeDownCast(
data_producer->GetOutputDataObject(0));
57 data->GetBounds(bounds);
59 auto probePoints = vtkSmartPointer<vtkPoints>::New();
60 double dx=(bounds[1]-bounds[0])/((
double)nx);
61 double dy=(bounds[3]-bounds[2])/((
double)ny);
63 double x=bounds[0]+0.5*dx;
64 for (
int ix=0; ix<nx;ix++,x+=dx )
66 double y=bounds[2]+0.5*dy;
67 for (
int iy=0;iy<ny;iy++,y+=dy )
68 probePoints->InsertNextPoint ( x, y, 0);
77 assert(
state.spacedim==3);
80 auto data=vtkDataSet::SafeDownCast(
data_producer->GetOutputDataObject(0));
81 data->GetBounds(bounds);
83 auto probePoints = vtkSmartPointer<vtkPoints>::New();
84 double dx=(bounds[1]-bounds[0])/((
double)nx);
85 double dy=(bounds[3]-bounds[2])/((
double)ny);
86 double dz=(bounds[5]-bounds[4])/((
double)nz);
88 double x=bounds[0]+0.5*dx;
89 for (
int ix=0; ix<nx;ix++,x+=dx )
91 double y=bounds[2]+0.5*dy;
92 for (
int iy=0;iy<ny;iy++,y+=dy )
94 double z=bounds[4]+0.5*dz;
95 for (
int iz=0;iz<nz;iz++,z+=dz )
96 probePoints->InsertNextPoint ( x, y, z);
105 template <
class DATA>
114 auto transgeometry=vtkSmartPointer<vtkTransformFilter>::New();
115 transgeometry->SetInputConnection(
data_producer->GetOutputPort());
119 auto vector = vtkSmartPointer<vtkAssignAttribute>::New();
120 vector->Assign(
dataname.c_str(),vtkDataSetAttributes::VECTORS,vtkAssignAttribute::POINT_DATA);
121 vector->SetInputConnection(transgeometry->GetOutputPort());
125 if (
state.show_quiver)
130 throw std::runtime_error(
"Please dont't forget to set quiver points/grid");
132 auto transprobe=vtkSmartPointer<vtkTransformPolyDataFilter>::New();
138 auto probeFilter = vtkSmartPointer<vtkProbeFilter>::New();
139 probeFilter->SetComputeTolerance(
true);
140 probeFilter->SetSourceConnection(vector->GetOutputPort());
141 probeFilter->SetInputConnection(transprobe->GetOutputPort());
142 probeFilter->PassPointArraysOn();
145 auto glyph = vtkSmartPointer<vtkGlyph3D>::New();
146 glyph->SetInputConnection(probeFilter->GetOutputPort());
147 glyph->SetColorModeToColorByVector();
148 glyph->SetScaleModeToScaleByVector();
151 if (
state.spacedim==2)
158 glyph->SetSourceConnection(
arrow3d->GetOutputPort());
166 glyph->SetSourceConnection(
arrow3d->GetOutputPort());
169 auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
170 mapper->SetInputConnection(glyph->GetOutputPort());
172 mapper->UseLookupTableScalarRangeOn();
176 vtkSmartPointer<vtkActor> quiver_actor = vtkSmartPointer<vtkActor>::New();
177 quiver_actor->SetMapper(mapper);
180 if (
state.show_quiver_colorbar)
187 if (
state.show_stream)
192 auto calc= vtkSmartPointer<vtkArrayCalculator>::New();
193 calc->SetInputConnection(vector->GetOutputPort());
194 calc->AddVectorArrayName(
dataname.c_str());
207 calc->SetFunction(func.c_str());
208 calc->SetResultArrayName((
dataname+
"magnitude").c_str());
211 auto vecmag = vtkSmartPointer<vtkAssignAttribute>::New();
212 vecmag->Assign((
dataname+
"magnitude").c_str(),vtkDataSetAttributes::SCALARS,vtkAssignAttribute::POINT_DATA);
213 vecmag->SetInputConnection(calc->GetOutputPort());
216 auto transseed=vtkSmartPointer<vtkTransformPolyDataFilter>::New();
222 auto stream=vtkSmartPointer<vtkStreamTracer>::New();
223 stream->SetInputConnection(vecmag->GetOutputPort());
224 stream->SetSourceConnection(transseed->GetOutputPort());
225 stream->SetIntegrationStepUnit(vtkStreamTracer::LENGTH_UNIT);
226 stream->SetInterpolatorType(vtkStreamTracer::INTERPOLATOR_WITH_CELL_LOCATOR);
227 stream->SetMaximumPropagation(
state.stream_maximum_propagation);
228 stream->SetInitialIntegrationStep(
state.stream_initial_integration_step);
229 stream->SetMaximumIntegrationStep(
state.stream_maximum_integration_step);
230 stream->SetIntegrationDirectionToForward();
231 stream->SetIntegratorTypeToRungeKutta4();
232 stream->SetMaximumNumberOfSteps(
state.stream_maximum_number_of_steps);
255 if (
state.spacedim==2)
259 stream->SetComputeVorticity(
false);
263 stream->SetComputeVorticity(
true);
269 auto ribbon=vtkSmartPointer<vtkRibbonFilter>::New();
270 ribbon->SetInputConnection(stream->GetOutputPort());
271 ribbon->SetWidth(
state.stream_ribbonwidth);
274 auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
275 mapper->SetInputConnection(ribbon->GetOutputPort());
276 mapper->ScalarVisibilityOn();
278 mapper->UseLookupTableScalarRangeOn();
281 vtkSmartPointer<vtkActor> stream_actor = vtkSmartPointer<vtkActor>::New();
282 stream_actor->SetMapper(mapper);
288 if (
state.show_stream_colorbar)
304 this->RTBuildVTKPipeline0<vtkUnstructuredGrid>();
308 this->RTBuildVTKPipeline0<vtkRectilinearGrid>();
void RTBuildVTKPipeline0()
void ServerRTSend(vtkSmartPointer< internals::Communicator > communicator) override final
Client-Server communication.
void RTBuildVTKPipeline() override final
Generic access to filter.
vtkSmartPointer< vtkPolyData > probePolyData
vtkSmartPointer< vtkPolyData > seedPolyData
void ClientMTReceive(vtkSmartPointer< internals::Communicator > communicator) override final
Receive data from server.
void SetStreamLineRGBTable(const V &tab, int lutsize)
Set streamline RGB table from vector.
vtkSmartPointer< vtkLookupTable > BuildLookupTable(RGBTable &xrgb, size_t size)
void SetQuiverRGBTable(const V &tab, int lutsize)
Set quiver RGB table from vector.
std::vector< RGBPoint > RGBTable
vtkSmartPointer< vtkScalarBarActor > BuildColorBar(vtkSmartPointer< vtkPolyDataMapper > mapper, int irank=0)
void SetQuiverGrid(int nx, int ny)
Set quiver points on grid in domain bounding box (2D)