Skip to content

Commit b26b07a

Browse files
authored
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:
2 parents 2fd9aed + b5a180d commit b26b07a

File tree

8 files changed

+730
-538
lines changed

8 files changed

+730
-538
lines changed

Constrained_triangulation_3/include/CGAL/Conforming_Delaunay_triangulation_3.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ class Conforming_Delaunay_triangulation_3 : public T_3 {
369369
return debug_flags[static_cast<int>(Debug_flags::use_older_cavity_algorithm)];
370370
}
371371

372+
bool use_newer_cavity_algorithm() const {
373+
return !debug_flags[static_cast<int>(Debug_flags::use_older_cavity_algorithm)];
374+
}
375+
372376
void use_older_cavity_algorithm(bool b) {
373377
debug_flags.set(static_cast<int>(Debug_flags::use_older_cavity_algorithm), b);
374378
}

Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h

Lines changed: 668 additions & 489 deletions
Large diffs are not rendered by default.

Constrained_triangulation_3/include/CGAL/Constrained_triangulation_3/internal/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ decltype(auto) cdt_3_format(std::string_view fmt, const Args&... args) {
4848

4949
template <typename... Args>
5050
constexpr decltype(auto) cdt_3_format(Args&&...) {
51-
return "";
51+
return std::string{};
5252
}
5353

5454
constexpr bool cdt_3_can_use_cxx20_format() {

Filtered_kernel/include/CGAL/Epic_converter.h

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Epic_converter {
6666
if(fit_in_double(n,d)){
6767
return std::make_pair(d,true);
6868
}
69-
return std::make_pair(0,false);
69+
return {};
7070
}
7171

7272
std::pair<Bbox_2,bool> operator()(const Bbox_2 b) const
@@ -86,7 +86,7 @@ class Epic_converter {
8686
if(fit_in_double(p.x(),x) && fit_in_double(p.y(),y)){
8787
return std::make_pair(Point_2(x,y),true);
8888
}
89-
return std::make_pair(ORIGIN,false);
89+
return {};
9090
}
9191

9292
std::pair<Vector_2,bool> operator()(const typename IK::Vector_2& v) const
@@ -96,7 +96,7 @@ class Epic_converter {
9696
if(fit_in_double(v.x(),x) && fit_in_double(v.y(),y)){
9797
return std::make_pair(Vector_2(x,y),true);
9898
}
99-
return std::make_pair(Vector_2(),false);
99+
return {};
100100
}
101101

102102
std::pair<Direction_2,bool> operator()(const typename IK::Direction_2& d) const
@@ -106,7 +106,7 @@ class Epic_converter {
106106
if(fit_in_double(d.dx(),x) && fit_in_double(d.dy(),y)){
107107
return std::make_pair(Direction_2(x,y),true);
108108
}
109-
return std::make_pair(Direction_2(),false);
109+
return {};
110110
}
111111

112112
std::pair<Weighted_point_2,bool> operator()(const typename IK::Weighted_point_2& wp) const
@@ -116,18 +116,18 @@ class Epic_converter {
116116
if(sp.second && w.second){
117117
return std::make_pair(Weighted_point_2(sp.first,w.first),true);
118118
}
119-
return std::make_pair(Weighted_point_2(),false);
119+
return {};
120120
}
121121

122122
std::pair<Segment_2,bool> operator()(const typename IK::Segment_2& s) const
123123
{
124124
std::pair<Point_2,bool> sp = operator()(s.source());
125125
if(! sp.second){
126-
return std::make_pair(Segment_2(),false);
126+
return {};
127127
}
128128
std::pair<Point_2,bool> tp = operator()(s.target());
129129
if(! tp.second){
130-
return std::make_pair(Segment_2(),false);
130+
return {};
131131
}
132132
return std::make_pair(Segment_2(sp.first,tp.first), true);
133133
}
@@ -138,18 +138,18 @@ class Epic_converter {
138138
if(a.second && b.second && c.second){
139139
return std::make_pair(Line_2(a.first, b.first, c.first),true);
140140
}
141-
return std::make_pair(Line_2(), false);
141+
return {};
142142
}
143143

144144
std::pair<Ray_2,bool> operator()(const typename IK::Ray_2& r) const
145145
{
146146
std::pair<Point_2,bool> sp = operator()(r.source());
147147
if(! sp.second){
148-
return std::make_pair(Ray_2(),false);
148+
return {};
149149
}
150150
std::pair<Point_2,bool> tp = operator()(r.second_point());
151151
if(! tp.second){
152-
return std::make_pair(Ray_2(),false);
152+
return {};
153153
}
154154
return std::make_pair(Ray_2(sp.first,tp.first), true);
155155
}
@@ -158,15 +158,15 @@ class Epic_converter {
158158
{
159159
std::pair<Point_2,bool> v0 = operator()(t.vertex(0));
160160
if(! v0.second){
161-
return std::make_pair(Triangle_2(),false);
161+
return {};
162162
}
163163
std::pair<Point_2,bool> v1 = operator()(t.vertex(1));
164164
if(! v1.second){
165-
return std::make_pair(Triangle_2(),false);
165+
return {};
166166
}
167167
std::pair<Point_2,bool> v2 = operator()(t.vertex(2));
168168
if(! v2.second){
169-
return std::make_pair(Triangle_2(),false);
169+
return {};
170170
}
171171
return std::make_pair(Triangle_2(v0.first,v1.first, v2.first), true);
172172
}
@@ -178,18 +178,18 @@ class Epic_converter {
178178
if(c.second && sr.second){
179179
return std::make_pair(Circle_2(c.first, sr.first, ci.orientation()),true);
180180
}
181-
return std::make_pair(Circle_2(), false);
181+
return {};
182182
}
183183

184184
std::pair<Iso_rectangle_2,bool> operator()(const typename IK::Iso_rectangle_2& ir) const
185185
{
186186
std::pair<Point_2,bool> sp = operator()((ir.min)());
187187
if(! sp.second){
188-
return std::make_pair(Iso_rectangle_2(),false);
188+
return {};
189189
}
190190
std::pair<Point_2,bool> tp = operator()((ir.max)());
191191
if(! tp.second){
192-
return std::make_pair(Iso_rectangle_2(),false);
192+
return {};
193193
}
194194
return std::make_pair(Iso_rectangle_2(sp.first,tp.first), true);
195195
}
@@ -199,11 +199,11 @@ class Epic_converter {
199199
{
200200
std::pair<Point_3,bool> sp = operator()(li.point());
201201
if(! sp.second){
202-
return std::make_pair(Line_3(),false);
202+
return {};
203203
}
204204
std::pair<Vector_3,bool> tp = operator()(li.to_vector());
205205
if(! tp.second){
206-
return std::make_pair(Line_3(),false);
206+
return {};
207207
}
208208
return std::make_pair(Line_3(sp.first,tp.first), true);
209209
}
@@ -214,22 +214,22 @@ class Epic_converter {
214214
if(a.second && b.second && c.second && d.second){
215215
return std::make_pair(Plane_3(a.first, b.first, c.first, d.first),true);
216216
}
217-
return std::make_pair(Plane_3(), false);
217+
return {};
218218
}
219219

220220
std::pair<Triangle_3,bool> operator()(const typename IK::Triangle_3& t) const
221221
{
222222
std::pair<Point_3,bool> v0 = operator()(t.vertex(0));
223223
if(! v0.second){
224-
return std::make_pair(Triangle_3(),false);
224+
return {};
225225
}
226226
std::pair<Point_3,bool> v1 = operator()(t.vertex(1));
227227
if(! v1.second){
228-
return std::make_pair(Triangle_3(),false);
228+
return {};
229229
}
230230
std::pair<Point_3,bool> v2 = operator()(t.vertex(2));
231231
if(! v2.second){
232-
return std::make_pair(Triangle_3(),false);
232+
return {};
233233
}
234234
return std::make_pair(Triangle_3(v0.first,v1.first, v2.first), true);
235235
}
@@ -238,19 +238,19 @@ class Epic_converter {
238238
{
239239
std::pair<Point_3,bool> v0 = operator()(t.vertex(0));
240240
if(! v0.second){
241-
return std::make_pair(Tetrahedron_3(),false);
241+
return {};
242242
}
243243
std::pair<Point_3,bool> v1 = operator()(t.vertex(1));
244244
if(! v1.second){
245-
return std::make_pair(Tetrahedron_3(),false);
245+
return {};
246246
}
247247
std::pair<Point_3,bool> v2 = operator()(t.vertex(2));
248248
if(! v2.second){
249-
return std::make_pair(Tetrahedron_3(),false);
249+
return {};
250250
}
251251
std::pair<Point_3,bool> v3 = operator()(t.vertex(3));
252252
if(! v3.second){
253-
return std::make_pair(Tetrahedron_3(),false);
253+
return {};
254254
}
255255
return std::make_pair(Tetrahedron_3(v0.first,v1.first, v2.first, v3.first), true);
256256
}
@@ -259,11 +259,11 @@ class Epic_converter {
259259
{
260260
std::pair<Point_3,bool> sp = operator()(r.source());
261261
if(! sp.second){
262-
return std::make_pair(Ray_3(),false);
262+
return {};
263263
}
264264
std::pair<Point_3,bool> tp = operator()(r.second_point());
265265
if(! tp.second){
266-
return std::make_pair(Ray_3(),false);
266+
return {};
267267
}
268268
return std::make_pair(Ray_3(sp.first,tp.first), true);
269269
}
@@ -275,7 +275,7 @@ class Epic_converter {
275275
if(fit_in_double(p.x(),x) && fit_in_double(p.y(),y) && fit_in_double(p.z(),z)){
276276
return std::make_pair(Point_3(x,y,z),true);
277277
}
278-
return std::make_pair(ORIGIN,false);
278+
return {};
279279
}
280280

281281
std::pair<Vector_3,bool> operator()(const typename IK::Vector_3& v) const
@@ -285,7 +285,7 @@ class Epic_converter {
285285
if(fit_in_double(v.x(),x) && fit_in_double(v.y(),y) && fit_in_double(v.z(),z)){
286286
return std::make_pair(Vector_3(x,y,z),true);
287287
}
288-
return std::make_pair(Vector_3(),false);
288+
return {};
289289
}
290290

291291
std::pair<Direction_3,bool> operator()(const typename IK::Direction_3& d) const
@@ -295,18 +295,18 @@ class Epic_converter {
295295
if(fit_in_double(d.dx(),x) && fit_in_double(d.dy(),y) && fit_in_double(d.dz(),z)){
296296
return std::make_pair(Direction_3(x,y,z),true);
297297
}
298-
return std::make_pair(Direction_3(),false);
298+
return {};
299299
}
300300

301301
std::pair<Segment_3,bool> operator()(const typename IK::Segment_3& s) const
302302
{
303303
std::pair<Point_3,bool> sp = operator()(s.source());
304304
if(! sp.second){
305-
return std::make_pair(Segment_3(),false);
305+
return {};
306306
}
307307
std::pair<Point_3,bool> tp = operator()(s.target());
308308
if(! tp.second){
309-
return std::make_pair(Segment_3(),false);
309+
return {};
310310
}
311311
return std::make_pair(Segment_3(sp.first,tp.first), true);
312312
}
@@ -318,7 +318,7 @@ class Epic_converter {
318318
if(sp.second && w.second){
319319
return std::make_pair(Weighted_point_3(sp.first,w.first),true);
320320
}
321-
return std::make_pair(Weighted_point_3(),false);
321+
return {};
322322
}
323323

324324
std::pair<Sphere_3,bool> operator()(const typename IK::Sphere_3& s) const
@@ -328,7 +328,7 @@ class Epic_converter {
328328
if(c.second && sr.second){
329329
return std::make_pair(Sphere_3(c.first, sr.first, s.orientation()),true);
330330
}
331-
return std::make_pair(Sphere_3(), false);
331+
return {};
332332
}
333333

334334
std::pair<Circle_3,bool> operator()(const typename IK::Circle_3& ci) const
@@ -338,18 +338,18 @@ class Epic_converter {
338338
if(c.second && sr.second){
339339
return std::make_pair(Circle_3(sr.first, c.first),true);
340340
}
341-
return std::make_pair(Circle_3(), false);
341+
return {};
342342
}
343343

344344
std::pair<Iso_cuboid_3,bool> operator()(const typename IK::Iso_cuboid_3& ic) const
345345
{
346346
std::pair<Point_3,bool> sp = operator()((ic.min)());
347347
if(! sp.second){
348-
return std::make_pair(Iso_cuboid_3(),false);
348+
return {};
349349
}
350350
std::pair<Point_3,bool> tp = operator()((ic.max)());
351351
if(! tp.second){
352-
return std::make_pair(Iso_cuboid_3(),false);
352+
return {};
353353
}
354354
return std::make_pair(Iso_cuboid_3(sp.first,tp.first), true);
355355
}

Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/autorefinement.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ bool collect_intersections(const std::array<typename K::Point_3, 3>& t1,
475475

476476
// #warning TODO get rid of sort and unique calls
477477
// because we don't handle intersection type and can have edge-edge edge-vertex duplicates
478-
std::sort(inter_pts.begin(), inter_pts.end(), [](auto p, auto q){return std::get<0>(p)<std::get<0>(q);});
479-
auto last = std::unique(inter_pts.begin(), inter_pts.end(), [](auto p, auto q){return std::get<0>(p)==std::get<0>(q);});
478+
std::sort(inter_pts.begin(), inter_pts.end(), [](const auto& p, const auto& q){return std::get<0>(p)<std::get<0>(q);});
479+
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);});
480480
inter_pts.erase(last, inter_pts.end());
481481

482482
#ifdef CGAL_AUTOREF_DEBUG_DEPTH

STL_Extension/include/CGAL/iterator.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ class Prevent_deref
6969
}
7070
};
7171

72-
template<typename I>
73-
Iterator_range<Prevent_deref<I> > make_prevent_deref_range(const Iterator_range<I>& range)
74-
{
75-
return Iterator_range<Prevent_deref<I> >(make_prevent_deref(range.first), make_prevent_deref(range.second));
76-
}
77-
7872
template<typename I>
7973
Prevent_deref<I> make_prevent_deref(const I& i)
8074
{
@@ -87,6 +81,20 @@ Iterator_range<Prevent_deref<I> > make_prevent_deref_range(const I& begin, const
8781
return Iterator_range<Prevent_deref<I> >(make_prevent_deref(begin), make_prevent_deref(end));
8882
}
8983

84+
template<typename R>
85+
auto make_prevent_deref_range(R&& range)
86+
{
87+
static_assert( !std::is_rvalue_reference_v<R&&>,
88+
"make_prevent_deref_range cannot be used with"
89+
" rvalue references to avoid dangling references");
90+
// Note: If CGAL were allowed to use C++20, we could use `std::ranges::begin/end`.
91+
// That would allow this to work with rvalue ranges when `std::borrowed_range<R>` is `true`.
92+
// See https://en.cppreference.com/w/cpp/ranges/begin.html#Notes
93+
using std::begin;
94+
using std::end;
95+
return make_range(make_prevent_deref(begin(range)), make_prevent_deref(end(range)));
96+
}
97+
9098
namespace cpp98 {
9199

92100
template<typename Category, typename Tp, typename Distance = std::ptrdiff_t,

TDS_3/include/CGAL/Triangulation_data_structure_3.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#include <CGAL/basic.h>
2525

2626
#include <utility>
27-
#include <map>
28-
#include <set>
2927
#include <vector>
3028
#include <stack>
3129
#include <limits>

Union_find/include/CGAL/Union_find.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <CGAL/basic.h>
2323
#include <CGAL/memory.h>
2424
#include <cstddef>
25+
#include <iterator>
2526

2627
namespace CGAL {
2728

@@ -39,6 +40,7 @@ class UF_forward_iterator {
3940
typedef R_ reference;
4041
typedef P_ pointer;
4142
typedef std::forward_iterator_tag iterator_category;
43+
typedef std::ptrdiff_t difference_type;
4244

4345
UF_forward_iterator() : m_p(0) {}
4446
UF_forward_iterator(PTR_ p) : m_p(p) {}
@@ -104,6 +106,7 @@ class Union_find {
104106
typedef T value_type;
105107
typedef T& reference;
106108
typedef const T& const_reference;
109+
typedef std::forward_iterator_tag iterator_category;
107110

108111
typedef internal::UF_forward_iterator< pointer, T, T&, T*> iterator;
109112
typedef iterator handle;

0 commit comments

Comments
 (0)