MCPcopy Create free account
hub / github.com/PDAL/PDAL / filter

Method filter

filters/DelaunayFilter.cpp:65–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63
64
65void DelaunayFilter::filter(PointView& pointView)
66{
67 // Returns NULL if the mesh already exists
68 TriangularMesh *mesh = pointView.createMesh("delaunay2d");
69
70 if (!mesh)
71 throwError("Unable to create mesh 'delaunay2d'.");
72 if (pointView.size() < 3)
73 {
74 log()->get(LogLevel::Warning) << getName() << ": triangulation "
75 "requested for fewer than three points.\n";
76 return;
77 }
78
79 std::vector<double> delaunayPoints;
80 for (PointId i = 0; i < pointView.size(); i++)
81 {
82 delaunayPoints.push_back(
83 pointView.getFieldAs<double>(Dimension::Id::X, i));
84 delaunayPoints.push_back(
85 pointView.getFieldAs<double>(Dimension::Id::Y, i));
86 }
87
88 // Actually perform the triangulation
89 delaunator::Delaunator triangulation(delaunayPoints);
90
91 for (std::size_t i = 0; i < triangulation.triangles.size(); i += 3)
92 mesh->add(triangulation.triangles[i+2], triangulation.triangles[i+1],
93 triangulation.triangles[i]);
94}
95
96} // namespace pdal

Callers

nothing calls this directly

Calls 6

createMeshMethod · 0.80
getNameFunction · 0.70
logFunction · 0.50
sizeMethod · 0.45
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected