Merge pull request #8890 from afabri/PMP-stitch_deterministic-GF

PMP: Make stitch_borders() deterministic
This commit is contained in:
Sébastien Loriot 2025-06-04 14:56:33 +02:00
commit 6444b9a0d0
3 changed files with 23 additions and 7 deletions

View File

@ -111,6 +111,11 @@ struct HDS_edge {
i.halfedge():i.halfedge()->opposite());
}
friend std::ostream& operator<<(std::ostream& os, const HDS_edge& e)
{
os << e.halfedge_;
return os;
}
private:
Halfedge_handle halfedge_;
};

View File

@ -106,9 +106,9 @@ struct Default_halfedges_keeper
{
typedef typename boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
halfedge_descriptor operator()(const halfedge_descriptor h1, const halfedge_descriptor h2) const
halfedge_descriptor operator()(const halfedge_descriptor h1, const halfedge_descriptor) const
{
return (h1 < h2) ? h1 : h2; // Arbitrary preference
return h1;
}
};
@ -1025,9 +1025,9 @@ std::size_t zip_boundary_cycle(typename boost::graph_traits<PolygonMesh>::halfed
if(!hedges_to_stitch.empty())
{
#ifdef CGAL_PMP_STITCHING_DEBUG_PP
std::cout << hedges_to_stitch.size() " halfedge pairs to stitch on border containing:\n"
<< edge(h, pmesh) << "\n\t" << source(h, pmesh) << "\t(" << get(vpm, source(h, pmesh)) << ")"
<< "\n\t" << target(h, pmesh) << "\t(" << get(vpm, target(h, pmesh)) << ")" << std::endl;
std::cout << hedges_to_stitch.size() << " halfedge pairs to stitch on border containing:\n"
<< edge(bh, pmesh) << "\n\t" << source(bh, pmesh) << "\t(" << get(vpm, source(bh, pmesh)) << ")"
<< "\n\t" << target(bh, pmesh) << "\t(" << get(vpm, target(bh, pmesh)) << ")" << std::endl;
#endif
std::size_t local_stitches = internal::stitch_halfedge_range(hedges_to_stitch, cycle_halfedges,
@ -1369,13 +1369,13 @@ std::size_t stitch_borders(const BorderHalfedgeRange& boundary_cycle_representat
std::back_inserter(to_stitch), np);
res += stitch_halfedge_range(to_stitch, to_consider, pmesh, vpm, cycle_maintainer);
const auto& new_representatives = cycle_maintainer.cycle_representatives();
#ifdef CGAL_PMP_STITCHING_DEBUG
std::cout << "------- Stitched " << res << " halfedge pairs after cycles & general" << std::endl;
std::cout << "------- Stitch cycles (#2)... (" << new_representatives.size() << " cycle(s))" << std::endl;
#endif
const auto& new_representatives = cycle_maintainer.cycle_representatives();
// Don't care about keeping track of the sub-cycles as this is the last pass
internal::Dummy_cycle_rep_maintainer<PolygonMesh> dummy_cycle_maintainer(pmesh);
res += stitch_boundary_cycles(new_representatives, pmesh, dummy_cycle_maintainer, np);

View File

@ -111,6 +111,11 @@ namespace internal {
--*this;
return tmp;
}
friend std::ostream& operator<<(std::ostream& os, const Self& i)
{
return os << i.operator->();
}
};
}
@ -171,6 +176,11 @@ namespace internal {
{
return In_place_list_iterator<T,Alloc>(const_cast<T*>(node));
}
friend std::ostream& operator<<(std::ostream& os, const Self& i)
{
return os << i.operator->();
}
};
@ -189,6 +199,7 @@ template <class T, class Alloc>
return reinterpret_cast<std::size_t>(ptr)/ sizeof(T);
}
}