VTKFIG  0.20.20181114
Easy VTK based in situ visualization
template<class V , class IV >
void vtkfig::Delaunay3D ( const V &  points_in,
V &  points,
IV &  cells 
)
inline
Examples:
examples/example-simplexcontour3d.cxx.

Definition at line 97 of file vtkfigTools.h.

98  {
99  assert(points.size()==0);
100  assert(cells.size()==0);
101 
102  auto inpoints = vtkSmartPointer<vtkPoints>::New();
103 
104  for (int i=0; i<points_in.size(); i+=3)
105  inpoints->InsertNextPoint(points_in[i], points_in[i+1], points_in[i+2]);
106 
107 
108 
109  auto aPolyData = vtkSmartPointer<vtkPolyData>::New();
110  aPolyData->SetPoints(inpoints);
111 
112 
113  auto delaunay = vtkSmartPointer<vtkDelaunay3D>::New();
114  delaunay->SetInputData(aPolyData);
115 
116  auto dgrid=delaunay->GetOutput();
117  delaunay->Update();
118 
119  auto npoints=dgrid->GetNumberOfPoints();
120  auto ncells=dgrid->GetNumberOfCells();
121 
122  auto vtkpoints=dgrid->GetPoints();
123  for (int i=0;i<npoints;i++)
124  {
125  double x[3];
126  vtkpoints->GetPoint(i,x);
127  points.push_back(x[0]);
128  points.push_back(x[1]);
129  points.push_back(x[2]);
130  }
131 
132  auto pts = vtkSmartPointer<vtkIdList>::New();
133 
134  for (vtkIdType i=0;i<ncells;i++)
135  {
136  dgrid->GetCellPoints(i,pts);
137  cells.push_back(pts->GetId(0));
138  cells.push_back(pts->GetId(1));
139  cells.push_back(pts->GetId(2));
140  cells.push_back(pts->GetId(3));
141  }
142 
143 
144  }