c++ - Is CGAL Polyline simplification non-deterministic? - Stack Overflow

admin2025-04-26  4

I'm trying to simplify many Polygon_with_holes_2, some with shared boundaries. I noticed that when running the following C++ code snippet, I get different results during different runs (i.e. the number of points after Simplification is different for different runs with the same geometry).

CGAL::Constrained_triangulation_plus_2<CDT> ct;

// Presume this vector has been filled up with many `Polygon_with_holes_2`
std::vector<CGAL::Polygon_with_holes_2<Scd>> pwh_vector; 

for (const auto &pwh : pwh_vector) {
  ct.insert_constraint(pwh.outer_boundary());
  for (const auto &h : pwh.holes()) {
    ct.insert_constraint(h);
  }
}

CGAL::Polyline_simplification_2::simplify(ct, Cost(), Stop(0.5));

Thus, I wanted to check: is CGAL's polyline simplification non-deterministic? I could not find any information about the polyline simplification being non-deterministic in the user manual: .html

One reason I could think of is that the visit order of Constrained_triangulation_plus_2<CDT> is undefined.

Another possible reason I could think of if there were ties in determining the priority between two nodes. This would explain why I observe the effect quite frequently for some geometries and never for others.

This non-determinism has made debugging our program quite hard. If this non-determinism is indeed a default feature of CGAL's polyline simplification, is there a way to turn it off?

转载请注明原文地址:http://anycun.com/QandA/1745599952a91008.html