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

Definition at line 49 of file vtkfigTools.h.

50  {
51  assert(points.size()==0);
52  assert(cells.size()==0);
53 
54  auto inpoints =vtkSmartPointer<vtkPoints>::New();
55 
56  for (int i=0; i<points_in.size(); i+=2)
57  inpoints->InsertNextPoint(points_in[i], points_in[i+1],0);
58 
59 
60  auto aPolyData= vtkSmartPointer<vtkPolyData>::New();
61  aPolyData->SetPoints(inpoints);
62 
63 
64  auto delaunay = vtkSmartPointer<vtkDelaunay2D>::New();
65  delaunay->SetInputData(aPolyData);
66 
67  auto dgrid=delaunay->GetOutput();
68  delaunay->Update();
69 
70  auto npoints=dgrid->GetNumberOfPoints();
71  auto ncells=dgrid->GetNumberOfPolys();
72 
73  auto vtkpoints=dgrid->GetPoints();
74  for (int i=0;i<npoints;i++)
75  {
76  double x[3];
77  vtkpoints->GetPoint(i,x);
78  points.push_back(x[0]);
79  points.push_back(x[1]);
80  }
81 
82  auto pts =vtkSmartPointer<vtkIdList>::New();
83 
84  for (vtkIdType i=0;i<ncells;i++)
85  {
86  dgrid->GetCellPoints(i,pts);
87  cells.push_back(pts->GetId(0));
88  cells.push_back(pts->GetId(1));
89  cells.push_back(pts->GetId(2));
90  }
91 
92 
93  }