CDT3: Fix face_constraint_index() (#9155)

## Summary of Changes

Fix the function and add it in an example so that it gets tested.

## Release Management

* Affected package(s): Constraind_triangulation_3
* License and copyright ownership: unchanged
This commit is contained in:
Sebastien Loriot 2025-12-03 11:37:59 +01:00 committed by GitHub
commit 15d96571a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 2 deletions

View File

@ -5,6 +5,7 @@
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
#include <vector>
#include <algorithm>
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
@ -29,6 +30,18 @@ int main(int argc, char* argv[])
<< "Number of constrained facets in the CDT: "
<< ccdt.number_of_constrained_facets() << '\n';
// Collect constrained facets per polygon
std::vector<std::size_t> constrained_facets(polygons.size());
for(auto facet : ccdt.constrained_facets())
{
int i = ccdt.face_constraint_index(facet);
++constrained_facets[i];
}
auto it = std::max_element(constrained_facets.begin(), constrained_facets.end());
std::cout << "The polygon with the most constrained facets has index "
<< (it - constrained_facets.begin()) << " and " << *it << " facets.\n";
std::ofstream ofs(argc > 2 ? argv[2] : "out.mesh");
ofs.precision(17);
CGAL::IO::write_MEDIT(ofs, ccdt);

View File

@ -1034,7 +1034,7 @@ public:
*/
CDT_3_signed_index face_constraint_index(typename Triangulation::Cell_handle ch, int i) const
{
return ch->face_id[static_cast<unsigned>(i)];
return ch->ccdt_3_data().face_constraint_index(i);
}
/*!

View File

@ -98,7 +98,7 @@ public:
CGAL::read(is, i);
}
if(!is) return is;
c.face_id[li] = i;
c->ccdt_3_data().set_face_constraint_index(li, i);
}
return is;
}