12 #include <vtkContourFilter.h>
13 #include <vtkDelaunay2D.h>
14 #include <vtkDoubleArray.h>
15 #include <vtkLookupTable.h>
16 #include <vtkPoints.h>
17 #include <vtkPolyData.h>
18 #include <vtkPolyDataMapper.h>
19 #include <vtkRenderer.h>
22 class ContourPrivate {
24 QList<Vector4F> vectors;
26 int numberOfContours = 10;
28 vtkActor* planeActor =
nullptr;
29 vtkContourFilter* contour =
nullptr;
33 d_ptr =
new ContourPrivate;
39 if (vectors.isEmpty())
return;
41 d_ptr->vectors = vectors;
46 if (d_ptr->numberOfContours != num) {
47 d_ptr->numberOfContours = num;
50 d_ptr->contour->GenerateValues(d_ptr->numberOfContours,
zMin(),
69 foreach (
const Vector4F& vec, d_ptr->vectors) {
70 vtkpoints->InsertNextPoint(vec.
x, vec.
y, vec.
z);
71 scalars->InsertNextTuple1(vec.
z);
75 polydata->SetPoints(vtkpoints);
76 polydata->GetPointData()->SetScalars(scalars);
79 polydata->GetBounds(bounds);
83 del->SetInputData(polydata);
90 vtkLookupTable* lookupTable = vtkLookupTable::New();
91 lookupTable->SetTableRange(bounds[4], bounds[5]);
92 lookupTable->SetHueRange(0.667, 0.0);
96 mapper->SetInputConnection(del->GetOutputPort());
97 mapper->SetLookupTable(lookupTable);
int numberOfContours() const
Contour(QWidget *parent=nullptr)
bool planeVisible() const
void setPlaneDistance(qreal distance)
bool planeDistance() const
void setVectors(const QList< Vector4F > &vectors)
void setPlaneVisible(bool visible=true)
void setNumberOfContours(int num)
vtkActor * surfaceActor() const
static double distance(T *pot1, T *pot2)
#define VTK_CREATE(type, name)