bug-fix CDT_3 (#9081)

_Please use the following template to help us managing pull requests._

## Summary of Changes

_Describe what your pull request changes to CGAL (this can be skipped if
it solves an issue already in the tracker or if it is a Feature or Small
Feature submitted to the CGAL Wiki)._

## Release Management

* Affected package(s):
* Issue(s) solved (if any): fix #0000, fix #0000,...
* Feature/Small Feature (if any):
* Link to compiled documentation (obligatory for small feature) [*wrong
link name to be changed*](httpssss://wrong_URL_to_be_changed/Manual/Pkg)
* License and copyright ownership:
This commit is contained in:
Sebastien Loriot 2025-09-28 17:10:21 +02:00 committed by GitHub
commit b26b07a124
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 739 additions and 547 deletions

View File

@ -369,6 +369,10 @@ public:
return debug_flags[static_cast<int>(Debug_flags::use_older_cavity_algorithm)];
}
bool use_newer_cavity_algorithm() const {
return !debug_flags[static_cast<int>(Debug_flags::use_older_cavity_algorithm)];
}
void use_older_cavity_algorithm(bool b) {
debug_flags.set(static_cast<int>(Debug_flags::use_older_cavity_algorithm), b);
}

View File

@ -48,7 +48,7 @@ decltype(auto) cdt_3_format(std::string_view fmt, const Args&... args) {
template <typename... Args>
constexpr decltype(auto) cdt_3_format(Args&&...) {
return "";
return std::string{};
}
constexpr bool cdt_3_can_use_cxx20_format() {

View File

@ -66,7 +66,7 @@ public:
if(fit_in_double(n,d)){
return std::make_pair(d,true);
}
return std::make_pair(0,false);
return {};
}
std::pair<Bbox_2,bool> operator()(const Bbox_2 b) const
@ -86,7 +86,7 @@ public:
if(fit_in_double(p.x(),x) && fit_in_double(p.y(),y)){
return std::make_pair(Point_2(x,y),true);
}
return std::make_pair(ORIGIN,false);
return {};
}
std::pair<Vector_2,bool> operator()(const typename IK::Vector_2& v) const
@ -96,7 +96,7 @@ public:
if(fit_in_double(v.x(),x) && fit_in_double(v.y(),y)){
return std::make_pair(Vector_2(x,y),true);
}
return std::make_pair(Vector_2(),false);
return {};
}
std::pair<Direction_2,bool> operator()(const typename IK::Direction_2& d) const
@ -106,7 +106,7 @@ public:
if(fit_in_double(d.dx(),x) && fit_in_double(d.dy(),y)){
return std::make_pair(Direction_2(x,y),true);
}
return std::make_pair(Direction_2(),false);
return {};
}
std::pair<Weighted_point_2,bool> operator()(const typename IK::Weighted_point_2& wp) const
@ -116,18 +116,18 @@ public:
if(sp.second && w.second){
return std::make_pair(Weighted_point_2(sp.first,w.first),true);
}
return std::make_pair(Weighted_point_2(),false);
return {};
}
std::pair<Segment_2,bool> operator()(const typename IK::Segment_2& s) const
{
std::pair<Point_2,bool> sp = operator()(s.source());
if(! sp.second){
return std::make_pair(Segment_2(),false);
return {};
}
std::pair<Point_2,bool> tp = operator()(s.target());
if(! tp.second){
return std::make_pair(Segment_2(),false);
return {};
}
return std::make_pair(Segment_2(sp.first,tp.first), true);
}
@ -138,18 +138,18 @@ public:
if(a.second && b.second && c.second){
return std::make_pair(Line_2(a.first, b.first, c.first),true);
}
return std::make_pair(Line_2(), false);
return {};
}
std::pair<Ray_2,bool> operator()(const typename IK::Ray_2& r) const
{
std::pair<Point_2,bool> sp = operator()(r.source());
if(! sp.second){
return std::make_pair(Ray_2(),false);
return {};
}
std::pair<Point_2,bool> tp = operator()(r.second_point());
if(! tp.second){
return std::make_pair(Ray_2(),false);
return {};
}
return std::make_pair(Ray_2(sp.first,tp.first), true);
}
@ -158,15 +158,15 @@ public:
{
std::pair<Point_2,bool> v0 = operator()(t.vertex(0));
if(! v0.second){
return std::make_pair(Triangle_2(),false);
return {};
}
std::pair<Point_2,bool> v1 = operator()(t.vertex(1));
if(! v1.second){
return std::make_pair(Triangle_2(),false);
return {};
}
std::pair<Point_2,bool> v2 = operator()(t.vertex(2));
if(! v2.second){
return std::make_pair(Triangle_2(),false);
return {};
}
return std::make_pair(Triangle_2(v0.first,v1.first, v2.first), true);
}
@ -178,18 +178,18 @@ public:
if(c.second && sr.second){
return std::make_pair(Circle_2(c.first, sr.first, ci.orientation()),true);
}
return std::make_pair(Circle_2(), false);
return {};
}
std::pair<Iso_rectangle_2,bool> operator()(const typename IK::Iso_rectangle_2& ir) const
{
std::pair<Point_2,bool> sp = operator()((ir.min)());
if(! sp.second){
return std::make_pair(Iso_rectangle_2(),false);
return {};
}
std::pair<Point_2,bool> tp = operator()((ir.max)());
if(! tp.second){
return std::make_pair(Iso_rectangle_2(),false);
return {};
}
return std::make_pair(Iso_rectangle_2(sp.first,tp.first), true);
}
@ -199,11 +199,11 @@ public:
{
std::pair<Point_3,bool> sp = operator()(li.point());
if(! sp.second){
return std::make_pair(Line_3(),false);
return {};
}
std::pair<Vector_3,bool> tp = operator()(li.to_vector());
if(! tp.second){
return std::make_pair(Line_3(),false);
return {};
}
return std::make_pair(Line_3(sp.first,tp.first), true);
}
@ -214,22 +214,22 @@ public:
if(a.second && b.second && c.second && d.second){
return std::make_pair(Plane_3(a.first, b.first, c.first, d.first),true);
}
return std::make_pair(Plane_3(), false);
return {};
}
std::pair<Triangle_3,bool> operator()(const typename IK::Triangle_3& t) const
{
std::pair<Point_3,bool> v0 = operator()(t.vertex(0));
if(! v0.second){
return std::make_pair(Triangle_3(),false);
return {};
}
std::pair<Point_3,bool> v1 = operator()(t.vertex(1));
if(! v1.second){
return std::make_pair(Triangle_3(),false);
return {};
}
std::pair<Point_3,bool> v2 = operator()(t.vertex(2));
if(! v2.second){
return std::make_pair(Triangle_3(),false);
return {};
}
return std::make_pair(Triangle_3(v0.first,v1.first, v2.first), true);
}
@ -238,19 +238,19 @@ public:
{
std::pair<Point_3,bool> v0 = operator()(t.vertex(0));
if(! v0.second){
return std::make_pair(Tetrahedron_3(),false);
return {};
}
std::pair<Point_3,bool> v1 = operator()(t.vertex(1));
if(! v1.second){
return std::make_pair(Tetrahedron_3(),false);
return {};
}
std::pair<Point_3,bool> v2 = operator()(t.vertex(2));
if(! v2.second){
return std::make_pair(Tetrahedron_3(),false);
return {};
}
std::pair<Point_3,bool> v3 = operator()(t.vertex(3));
if(! v3.second){
return std::make_pair(Tetrahedron_3(),false);
return {};
}
return std::make_pair(Tetrahedron_3(v0.first,v1.first, v2.first, v3.first), true);
}
@ -259,11 +259,11 @@ public:
{
std::pair<Point_3,bool> sp = operator()(r.source());
if(! sp.second){
return std::make_pair(Ray_3(),false);
return {};
}
std::pair<Point_3,bool> tp = operator()(r.second_point());
if(! tp.second){
return std::make_pair(Ray_3(),false);
return {};
}
return std::make_pair(Ray_3(sp.first,tp.first), true);
}
@ -275,7 +275,7 @@ public:
if(fit_in_double(p.x(),x) && fit_in_double(p.y(),y) && fit_in_double(p.z(),z)){
return std::make_pair(Point_3(x,y,z),true);
}
return std::make_pair(ORIGIN,false);
return {};
}
std::pair<Vector_3,bool> operator()(const typename IK::Vector_3& v) const
@ -285,7 +285,7 @@ public:
if(fit_in_double(v.x(),x) && fit_in_double(v.y(),y) && fit_in_double(v.z(),z)){
return std::make_pair(Vector_3(x,y,z),true);
}
return std::make_pair(Vector_3(),false);
return {};
}
std::pair<Direction_3,bool> operator()(const typename IK::Direction_3& d) const
@ -295,18 +295,18 @@ public:
if(fit_in_double(d.dx(),x) && fit_in_double(d.dy(),y) && fit_in_double(d.dz(),z)){
return std::make_pair(Direction_3(x,y,z),true);
}
return std::make_pair(Direction_3(),false);
return {};
}
std::pair<Segment_3,bool> operator()(const typename IK::Segment_3& s) const
{
std::pair<Point_3,bool> sp = operator()(s.source());
if(! sp.second){
return std::make_pair(Segment_3(),false);
return {};
}
std::pair<Point_3,bool> tp = operator()(s.target());
if(! tp.second){
return std::make_pair(Segment_3(),false);
return {};
}
return std::make_pair(Segment_3(sp.first,tp.first), true);
}
@ -318,7 +318,7 @@ public:
if(sp.second && w.second){
return std::make_pair(Weighted_point_3(sp.first,w.first),true);
}
return std::make_pair(Weighted_point_3(),false);
return {};
}
std::pair<Sphere_3,bool> operator()(const typename IK::Sphere_3& s) const
@ -328,7 +328,7 @@ public:
if(c.second && sr.second){
return std::make_pair(Sphere_3(c.first, sr.first, s.orientation()),true);
}
return std::make_pair(Sphere_3(), false);
return {};
}
std::pair<Circle_3,bool> operator()(const typename IK::Circle_3& ci) const
@ -338,18 +338,18 @@ public:
if(c.second && sr.second){
return std::make_pair(Circle_3(sr.first, c.first),true);
}
return std::make_pair(Circle_3(), false);
return {};
}
std::pair<Iso_cuboid_3,bool> operator()(const typename IK::Iso_cuboid_3& ic) const
{
std::pair<Point_3,bool> sp = operator()((ic.min)());
if(! sp.second){
return std::make_pair(Iso_cuboid_3(),false);
return {};
}
std::pair<Point_3,bool> tp = operator()((ic.max)());
if(! tp.second){
return std::make_pair(Iso_cuboid_3(),false);
return {};
}
return std::make_pair(Iso_cuboid_3(sp.first,tp.first), true);
}

View File

@ -475,8 +475,8 @@ bool collect_intersections(const std::array<typename K::Point_3, 3>& t1,
// #warning TODO get rid of sort and unique calls
// because we don't handle intersection type and can have edge-edge edge-vertex duplicates
std::sort(inter_pts.begin(), inter_pts.end(), [](auto p, auto q){return std::get<0>(p)<std::get<0>(q);});
auto last = std::unique(inter_pts.begin(), inter_pts.end(), [](auto p, auto q){return std::get<0>(p)==std::get<0>(q);});
std::sort(inter_pts.begin(), inter_pts.end(), [](const auto& p, const auto& q){return std::get<0>(p)<std::get<0>(q);});
auto last = std::unique(inter_pts.begin(), inter_pts.end(), [](const auto& p, const auto& q){return std::get<0>(p)==std::get<0>(q);});
inter_pts.erase(last, inter_pts.end());
#ifdef CGAL_AUTOREF_DEBUG_DEPTH

View File

@ -69,12 +69,6 @@ private:
}
};
template<typename I>
Iterator_range<Prevent_deref<I> > make_prevent_deref_range(const Iterator_range<I>& range)
{
return Iterator_range<Prevent_deref<I> >(make_prevent_deref(range.first), make_prevent_deref(range.second));
}
template<typename I>
Prevent_deref<I> make_prevent_deref(const I& i)
{
@ -87,6 +81,20 @@ Iterator_range<Prevent_deref<I> > make_prevent_deref_range(const I& begin, const
return Iterator_range<Prevent_deref<I> >(make_prevent_deref(begin), make_prevent_deref(end));
}
template<typename R>
auto make_prevent_deref_range(R&& range)
{
static_assert( !std::is_rvalue_reference_v<R&&>,
"make_prevent_deref_range cannot be used with"
" rvalue references to avoid dangling references");
// Note: If CGAL were allowed to use C++20, we could use `std::ranges::begin/end`.
// That would allow this to work with rvalue ranges when `std::borrowed_range<R>` is `true`.
// See https://en.cppreference.com/w/cpp/ranges/begin.html#Notes
using std::begin;
using std::end;
return make_range(make_prevent_deref(begin(range)), make_prevent_deref(end(range)));
}
namespace cpp98 {
template<typename Category, typename Tp, typename Distance = std::ptrdiff_t,

View File

@ -24,8 +24,6 @@
#include <CGAL/basic.h>
#include <utility>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <limits>

View File

@ -22,6 +22,7 @@
#include <CGAL/basic.h>
#include <CGAL/memory.h>
#include <cstddef>
#include <iterator>
namespace CGAL {
@ -39,6 +40,7 @@ public:
typedef R_ reference;
typedef P_ pointer;
typedef std::forward_iterator_tag iterator_category;
typedef std::ptrdiff_t difference_type;
UF_forward_iterator() : m_p(0) {}
UF_forward_iterator(PTR_ p) : m_p(p) {}
@ -104,6 +106,7 @@ public:
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef std::forward_iterator_tag iterator_category;
typedef internal::UF_forward_iterator< pointer, T, T&, T*> iterator;
typedef iterator handle;