Commit 27e9152a authored by Charles Gueunet's avatar Charles Gueunet
Browse files

Improve Delaunay2

parent 0cd2f2f9
Pipeline #280514 failed with stages
in 21 minutes
......@@ -12,18 +12,14 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
using CGAL_Kernel = CGAL::Simple_cartesian<double>;
using CGAL_Kernel = CGAL::Simple_cartesian<double>;
vtkStandardNewMacro(vtkCGALDelaunay2);
using CGAL_Kernel = CGAL::Simple_cartesian<double>;
using CGAL_Kernel = CGAL::Simple_cartesian<double>;
// TODO May try to use ProjectionTraits_3 to handle open 3D surfaces
// Look at perf then
// caution, a sphere won't work: intersection
// caution, infinite loop on some tests
using Delaunay = CGAL::Constrained_Delaunay_triangulation_2<CGAL_Kernel>;
using CGAL_Delaunay = CGAL::Constrained_Delaunay_triangulation_2<CGAL_Kernel>;
//------------------------------------------------------------------------------
void vtkCGALDelaunay2::PrintSelf(ostream& os, vtkIndent indent)
......@@ -75,7 +71,7 @@ int vtkCGALDelaunay2::RequestData(
d3 = 1;
}
std::vector<Delaunay::Point> pts;
std::vector<CGAL_Delaunay::Point> pts;
pts.reserve(nbPts);
for (const auto pt : pointRange)
{
......@@ -85,7 +81,7 @@ int vtkCGALDelaunay2::RequestData(
// CGAL Processing
// ---------------
Delaunay delaunay;
CGAL_Delaunay delaunay;
try
{
// Add constraints (lines and polys)
......@@ -94,8 +90,8 @@ int vtkCGALDelaunay2::RequestData(
// each poly
for (polysIt->GoToFirstCell(); !polysIt->IsDoneWithTraversal(); polysIt->GoToNextCell())
{
vtkIdList* p = polysIt->GetCurrentCell();
std::list<Delaunay::Point> poly;
vtkIdList* p = polysIt->GetCurrentCell();
std::list<CGAL_Delaunay::Point> poly;
// each segment of poly
for (vtkIdType i = 0; i < p->GetNumberOfIds(); i++)
{
......@@ -105,7 +101,7 @@ int vtkCGALDelaunay2::RequestData(
{
delaunay.insert_constraint(poly.begin(), poly.end(), true);
}
catch(const std::exception& e)
catch (const CGAL_Delaunay::Intersection_of_constraints_exception& e)
{
// If we have an invalid constraint (for example overlaping edges)
// we just ignore the constraint and continue
......@@ -120,8 +116,8 @@ int vtkCGALDelaunay2::RequestData(
for (linesIt->GoToFirstCell(); !linesIt->IsDoneWithTraversal(); linesIt->GoToNextCell())
{
// each segment of line
vtkIdList* l = linesIt->GetCurrentCell();
std::list<Delaunay::Point> line;
vtkIdList* l = linesIt->GetCurrentCell();
std::list<CGAL_Delaunay::Point> line;
for (vtkIdType i = 1; i < l->GetNumberOfIds(); i++)
{
line.emplace_back(pts[l->GetId(i)]);
......@@ -130,7 +126,7 @@ int vtkCGALDelaunay2::RequestData(
{
delaunay.insert_constraint(line.begin(), line.end());
}
catch(const std::exception& e)
catch (const CGAL_Delaunay::Intersection_of_constraints_exception& e)
{
// If we have an invalid constraint (for example overlaping edges)
// we just ignore the constraint and continue
......@@ -142,7 +138,7 @@ int vtkCGALDelaunay2::RequestData(
// Add points
for (auto point : pts)
{
delaunay.push_back(Delaunay::Point(point));
delaunay.push_back(CGAL_Delaunay::Point(point));
}
}
catch (std::exception& e)
......@@ -157,7 +153,7 @@ int vtkCGALDelaunay2::RequestData(
vtkNew<vtkPoints> outPts;
const vtkIdType outNPts = delaunay.number_of_vertices();
outPts->Allocate(outNPts);
std::map<Delaunay::Point, vtkIdType> vmap;
std::map<CGAL_Delaunay::Point, vtkIdType> vmap;
for (auto vertex : delaunay.finite_vertex_handles())
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment