fix compilation of PMP::isotropic_remeshing with Epeck

and add a test to avoid future regressions
This commit is contained in:
Jane Tournois 2025-06-03 14:06:11 +02:00
parent 0a8ca42680
commit 4c462898a8
3 changed files with 43 additions and 10 deletions

View File

@ -271,6 +271,7 @@ namespace internal {
typedef typename boost::graph_traits<PM>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<PM>::face_descriptor face_descriptor;
typedef typename GeomTraits::FT FT;
typedef typename GeomTraits::Point_3 Point;
typedef typename GeomTraits::Vector_3 Vector_3;
typedef typename GeomTraits::Plane_3 Plane_3;
@ -488,7 +489,7 @@ namespace internal {
std::cout << "Split long edges..." << std::endl;
#endif
//collect long edges
typedef std::pair<halfedge_descriptor, double> H_and_sql;
typedef std::pair<halfedge_descriptor, FT> H_and_sql;
std::multiset< H_and_sql, std::function<bool(H_and_sql,H_and_sql)> >
long_edges(
[](const H_and_sql& p1, const H_and_sql& p2)
@ -500,7 +501,7 @@ namespace internal {
if (!is_split_allowed(e))
continue;
const halfedge_descriptor he = halfedge(e, mesh_);
std::optional<double> sqlen = sizing.is_too_long(source(he, mesh_), target(he, mesh_), mesh_);
std::optional<FT> sqlen = sizing.is_too_long(source(he, mesh_), target(he, mesh_), mesh_);
if(sqlen != std::nullopt)
long_edges.emplace(halfedge(e, mesh_), sqlen.value());
}
@ -554,7 +555,7 @@ namespace internal {
//check sub-edges
//if it was more than twice the "long" threshold, insert them
std::optional<double> sqlen_new = sizing.is_too_long(source(hnew, mesh_), target(hnew, mesh_), mesh_);
std::optional<FT> sqlen_new = sizing.is_too_long(source(hnew, mesh_), target(hnew, mesh_), mesh_);
if(sqlen_new != std::nullopt)
long_edges.emplace(hnew, sqlen_new.value());
@ -580,7 +581,7 @@ namespace internal {
if (snew == PATCH)
{
std::optional<double> sql = sizing.is_too_long(source(hnew2, mesh_), target(hnew2, mesh_), mesh_);
std::optional<FT> sql = sizing.is_too_long(source(hnew2, mesh_), target(hnew2, mesh_), mesh_);
if(sql != std::nullopt)
long_edges.emplace(hnew2, sql.value());
}
@ -603,7 +604,7 @@ namespace internal {
if (snew == PATCH)
{
std::optional<double> sql = sizing.is_too_long(source(hnew2, mesh_), target(hnew2, mesh_), mesh_);
std::optional<FT> sql = sizing.is_too_long(source(hnew2, mesh_), target(hnew2, mesh_), mesh_);
if (sql != std::nullopt)
long_edges.emplace(hnew2, sql.value());
}
@ -633,7 +634,7 @@ namespace internal {
{
typedef boost::bimap<
boost::bimaps::set_of<halfedge_descriptor>,
boost::bimaps::multiset_of<double, std::less<double> > > Boost_bimap;
boost::bimaps::multiset_of<FT, std::less<FT> > > Boost_bimap;
typedef typename Boost_bimap::value_type short_edge;
#ifdef CGAL_PMP_REMESHING_VERBOSE
@ -648,7 +649,7 @@ namespace internal {
Boost_bimap short_edges;
for(edge_descriptor e : edges(mesh_))
{
std::optional<double> sqlen = sizing.is_too_short(halfedge(e, mesh_), mesh_);
std::optional<FT> sqlen = sizing.is_too_short(halfedge(e, mesh_), mesh_);
if(sqlen != std::nullopt
&& is_collapse_allowed(e, collapse_constraints))
short_edges.insert(short_edge(halfedge(e, mesh_), sqlen.value()));
@ -747,7 +748,7 @@ namespace internal {
for(halfedge_descriptor ha : halfedges_around_target(va, mesh_))
{
vertex_descriptor va_i = source(ha, mesh_);
std::optional<double> sqha = sizing.is_too_long(vb, va_i, mesh_);
std::optional<FT> sqha = sizing.is_too_long(vb, va_i, mesh_);
if (sqha != std::nullopt)
{
collapse_ok = false;
@ -813,7 +814,7 @@ namespace internal {
//insert new/remaining short edges
for (halfedge_descriptor ht : halfedges_around_target(vkept, mesh_))
{
std::optional<double> sqlen = sizing.is_too_short(ht, mesh_);
std::optional<FT> sqlen = sizing.is_too_short(ht, mesh_);
if (sqlen != std::nullopt
&& is_collapse_allowed(edge(ht, mesh_), collapse_constraints))
short_edges.insert(short_edge(ht, sqlen.value()));
@ -1795,7 +1796,7 @@ private:
//insert new edges in 'short_edges'
if (is_collapse_allowed(edge(hf, mesh_), collapse_constraints))
{
std::optional<double> sqlen = sizing.is_too_short(hf, mesh_);
std::optional<FT> sqlen = sizing.is_too_short(hf, mesh_);
if (sqlen != std::nullopt)
short_edges.insert(typename Bimap::value_type(hf, sqlen.value()));
}

View File

@ -26,6 +26,7 @@ create_single_source_cgal_program("pmp_do_intersect_test.cpp")
create_single_source_cgal_program("test_is_polygon_soup_a_polygon_mesh.cpp")
create_single_source_cgal_program("test_stitching.cpp")
create_single_source_cgal_program("remeshing_test.cpp")
create_single_source_cgal_program("remeshing_test_epeck.cpp")
create_single_source_cgal_program("remeshing_with_isolated_constraints_test.cpp" )
create_single_source_cgal_program("measures_test.cpp")
create_single_source_cgal_program("triangulate_faces_test.cpp")

View File

@ -0,0 +1,31 @@
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/remesh.h>
#include <CGAL/Surface_mesh.h>
#include <fstream>
#include <iostream>
namespace PMP = CGAL::Polygon_mesh_processing;
using Epeck = CGAL::Exact_predicates_exact_constructions_kernel;
using Mesh = CGAL::Surface_mesh<Epeck::Point_3>;
int main(int argc, const char* argv[])
{
const std::string filename = (argc < 2) ? CGAL::data_file_path("meshes/sphere.off") : argv[1];
std::ifstream input(filename);
Mesh mesh;
if (!input || !(input >> mesh))
{
std::cerr << "Error: cannot read surface mesh : " << filename << "\n";
assert(false);
}
double target_edge_length = 1.0;
PMP::isotropic_remeshing(CGAL::faces(mesh), target_edge_length, mesh);
return 0;
}