Commit Graph
841 Commits
Author SHA1 Message Date
Sebastien Loriot f60daf05e4 Mesh_2: fix degenerate cases (#9290)
## Summary of Changes

This PR fixes the error reported in issue #781. The main two changes
are:

- in `Refine_edges.h`: allow the refinement point of a constrained edge
to be an existing close encroaching vertex,
- in `Refine_faces.h`: skip tiny bad faces when their bbox are smaller
than a few ulp.

## Release Management

* Affected package(s): Triangulation_2, Mesh_2
* Issue(s) solved (if any): fix #781
* 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: maintenance by GeometryFactory, now
copyright change
2026-02-12 15:01:59 +01:00
Laurent Rineau 93fa24e252 Mesh_2: fix bug with Mesh_2/test/Mesh_2/triwild-10070-min1.obj
The bug was reproduced by

```shell
/path/to/build/test/Mesh_2/test_mesh_obj Mesh_2/test/Mesh_2/triwild-10070-min1.obj
```

The log of the error, with all the debug options of Mesh_2 was:

```plain
Before conforming Gabriel: 4 vertices.
  Smallest squared distance between constraint endpoints: 0.010522898628224919
  edge #1= 453.57378188125 445.0501073328125 -- #3= 454.05836694375 445.48749872343745 is encroached by #2= 453.77453855000005 445.23131233749996
  add_constrained_edge_to_be_conformed(#1= 453.57378188125 445.0501073328125, #3= 454.05836694375 445.48749872343745)
  edge #2= 453.77453855000005 445.23131233749996 -- #0= 453.49763280000002 444.98137439999999 is encroached by #1= 453.57378188125 445.0501073328125
  add_constrained_edge_to_be_conformed(#2= 453.77453855000005 445.23131233749996, #0= 453.49763280000002 444.98137439999999)
split_cluster_point(454.05836694375 445.48749872343745 , 453.57378188125 445.0501073328125)
  reduced: 0
result:  453.77453855000005 445.23131233750001
  edge #1= 453.57378188125 445.0501073328125 -- #3= 454.05836694375 445.48749872343745 is encroached by #2= 453.77453855000005 445.23131233749996
Refine_edges_with_clusters::refinement_point_impl(Edge: (#1= 453.57378188125 445.0501073328125, #3= 454.05836694375 445.48749872343745) = 453.77453855000005 445.23131233750001
(453.77453855000005 445.23131233750001) accepted
on edge, insert(453.77453855000005 445.23131233750001): 3 boundary edges in the zone
 inserted new vertex #4= 453.77453855000005 445.23131233750001
update_clusters
va_has_a_cluster=0
vb_has_a_cluster=1
clusters.size()=2
E  edge #3= 454.05836694375 445.48749872343745 -- #2= 453.77453855000005 445.23131233749996 is encroached by #4= 453.77453855000005 445.23131233750001
  add_constrained_edge_to_be_conformed(#3= 454.05836694375 445.48749872343745, #2= 453.77453855000005 445.23131233749996)
  edge #1= 453.57378188125 445.0501073328125 -- #4= 453.77453855000005 445.23131233750001 is encroached by #2= 453.77453855000005 445.23131233749996
  add_constrained_edge_to_be_conformed(#1= 453.57378188125 445.0501073328125, #4= 453.77453855000005 445.23131233750001)
Cluster at #3= 454.05836694375 445.48749872343745 is updated.
  vm: #4= 453.77453855000005 445.23131233750001
  reduction: 1
  min_sq_len: 0.1461900214383674
clusters.size() after update_cluster=2
split_cluster_point(453.49763280000002 444.98137439999999 , 453.77453855000005 445.23131233749996)
  reduced: 0
result:  453.64993096249998 445.11884026562501
  edge #2= 453.77453855000005 445.23131233749996 -- #0= 453.49763280000002 444.98137439999999 is encroached by #1= 453.57378188125 445.0501073328125
Refine_edges_with_clusters::refinement_point_impl(Edge: (#2= 453.77453855000005 445.23131233749996, #0= 453.49763280000002 444.98137439999999) = 453.64993096249998 445.11884026562501
(453.64993096249998 445.11884026562501) accepted
on edge, insert(453.64993096249998 445.11884026562501): 0 boundary edges in the zone
terminate called after throwing an instance of 'CGAL::Precondition_exception'
  what():  CGAL ERROR: precondition violation!
Expr: i >= 0 && i < 3
```

The following edge `(#1, #3)` is encroached by the vertex `#2`:

```plain
  edge #1= 453.57378188125 445.0501073328125 -- #3= 454.05836694375 445.48749872343745 is encroached by #2= 453.77453855000005 445.23131233749996
```

The inserted vertex `#4= 453.77453855000005 445.23131233750001` is the projection of the vertex `#2= 453.77453855000005 445.23131233749996` (rules to refine a segment part of a cluster.

The distance between `#2` and its projection `#4` is:

- `0` on the x-axis,
- `ulp(v2.y()))` on the y-axis.

... and then, Mesh_2 cannot do anything with that.

The fix is to implement a snapping strategy: if the encroaching vertex is close enough, then chose it be the refinement point of the encroached segment. "Close enough" means:

- create tiny `Bbox_2` centered on the encroaching vertex, with snaps equal to 8 ulp on both axis,
- if that tiny bbox intersects the encroached segment, then the refinement is the encroaching vertex.
2026-02-06 16:59:37 +01:00
Sebastien Loriot c5ce7e753a Adding 3D barycentric coordinates for convex polyhedra (#8267)
## Summary of Changes

New package for 3D barycentric coordinates in a convex polyhedron

## Release Management

* Affected package(s): New package
* Feature/Small Feature (if any):
[here](https://cgal.geometryfactory.com/CGAL/Members/wiki/Features/Barycentric_coordinates_3)
* 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: GF

## TODO
- [x] check branch size (@sloriot)
- [x] check usage of `get_tolerance()` from
`Barycentric_coordinates_3/include/CGAL/Barycentric_coordinates_3/internal/utils_3.h`
2026-02-03 15:13:25 +01:00
Laurent Rineau a48e7ee74d Mesh_2: ignore microscopic bad faces 2026-01-20 21:08:12 +01:00
Sven Oesau ba42c7c37a adding Equal_2 to Projection_traits_base_3 2026-01-09 16:40:08 +01:00
Sven Oesau 3e01c496dd Merge branch 'main' into SD_RG_face_normal_map 2025-12-07 11:30:52 +01:00
Sven Oesau b4fa97c745 integrating review 2025-11-12 16:03:46 +01:00
Laurent RineauandCopilot 2a5351cc0a Update Kernel_23/include/CGAL/Kernel/hash_functions.h
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-31 15:40:42 +01:00
Laurent Rineau 07e0ea785d CDT_3: fix for Epeck 2025-10-29 14:12:50 +01:00
Sven Oesau 0a604075d3 moved typedefs into method 2025-10-17 18:04:39 +02:00
Sven Oesau 7e2b312994 merge fix 2025-04-09 10:51:24 +02:00
Sven Oesau 4d39793b1d Merge branch 'master' into SD_RG_face_normal_map 2025-04-09 10:10:29 +02:00
Sébastien Loriot 09564a6d7b do not use result_type 2025-04-03 16:13:27 +02:00
Sébastien Loriot a4170b1fb9 Merge pull request #8586 from MaelRL/Kernel_23-Fix_dangling_ref_in_CC3-GF
Do not rely on result_type definitions in kernels
2025-04-03 16:12:09 +02:00
Sébastien Loriot b6719fc3be Merge remote-tracking branch 'cgal/6.0.x-branch' into cgal/master 2025-04-03 16:09:51 +02:00
Mael Rouxel-Labbé b4422374a0 Fix Compare_xy_2 for the generic 3D projection traits
The previous implementation defined Compare_xy_2 as
simply Compare_xyz_3. This does define an order
over the projected points, but it has a strong downside:
it ignores the direction of the normal, so its order
can be the opposite of the lexicographical order
would give. This new order is in conflict with
the existing Compare_x_2 and Compare_y_2, which
take the normal's direction into account.

(Also with the Less_x_2, Less_y_2, and Less_xy_2
family, which also exist for the projection traits).
2025-03-28 12:51:07 +01:00
Sven Oesau b176ed48ae Merge branch 'master' into SD_RG_face_normal_map 2025-03-27 12:49:44 +01:00
Mael Rouxel-Labbé 0c35489bbe Merge remote-tracking branch 'cgal/master' into Kernel_23-Fix_dangling_ref_in_CC3-GF 2025-03-27 12:28:35 +01:00
Mael Rouxel-Labbé 7bc1bbd842 Add a comment 2025-03-18 12:05:06 +01:00
Mael Rouxel-Labbé 1ae7960a43 Simplify and enhance Type_mapper
There is also a stronger need because now we really need to map
types whereas before it could rely on result_type's to avoid
some tricky cases like CGAL::Sphere_point
2025-03-16 21:45:23 +01:00
Mael Rouxel-Labbé a98d5149de Remove useless header includes 2025-03-16 13:33:44 +01:00
Mael Rouxel-Labbé f9001833b1 Merge remote-tracking branch 'cgal/master' into Kernel_23-Fix_dangling_ref_in_CC3-GF 2025-03-15 14:09:28 +01:00
Léo Valque 91f29df106 Cleaning of the files, remove useless comments, correct indent and tab 2025-02-28 13:58:12 +01:00
Léo Valque 0436efa118 macro for global_function_distance 2025-02-19 19:26:09 +01:00
Léo Valque d7c9cce0b9 Compare squared distance with point 2025-02-19 12:03:06 +01:00
Sébastien Loriot e817be7057 fix bugs + add a robust version of the inside region predicate 2025-01-20 20:07:16 +01:00
Mael Rouxel-Labbé 2f84ba4aea Fix compilation 2025-01-17 13:41:44 +01:00
Mael Rouxel-Labbé 06f862eee7 Misc post-merge fixes 2025-01-17 12:27:21 +01:00
Mael Rouxel-Labbé 3b7a4ed21e Merge remote-tracking branch 'cgal/master' into Kernel_23-Fix_dangling_ref_in_CC3-GF 2025-01-16 11:52:34 +01:00
Mael Rouxel-Labbé 98201c6ecc Point_3 is no different from other kernel objects 2025-01-16 10:41:16 +01:00
Mael Rouxel-Labbé 604103d035 Regroup definitions of operator<=> for kernel objects + add missing 2025-01-16 10:39:21 +01:00
Mael Rouxel-Labbé 2f825080d5 Use the kernel's Boolean and enums 2025-01-16 10:37:38 +01:00
Mael Rouxel-Labbé b7de40afce Update enum_cast<Uncertain> calls to new API 2025-01-08 17:17:55 +01:00
Mael Rouxel-Labbé 7b6886ed17 Misc cleaning 2024-12-20 16:16:26 +01:00
Mael Rouxel-Labbé 9c517a47a2 Fix bad return types 2024-12-20 16:14:40 +01:00
Mael Rouxel-Labbé 4d4549cad6 Get rid of result_type in Kernels + fix some bad return types (wip) 2024-12-20 16:13:35 +01:00
Mael Rouxel-Labbé 778ae1b9c8 Remove unused class 2024-12-20 15:25:03 +01:00
Mael Rouxel-Labbé 20115d3dcb Use std::clamp 2024-12-10 17:09:54 +01:00
Mael Rouxel-Labbé 2838ad24d9 Delay to_double call 2024-12-10 17:09:31 +01:00
Mael Rouxel-Labbé b02776b504 Remove wrong result_type (WIP: does not compile anymore) 2024-11-06 11:26:50 +01:00
Mael Rouxel-Labbé 181ccd2275 More instances of result_type --> dcltype(auto) 2024-11-06 11:25:47 +01:00
Mael Rouxel-Labbé ee451ed469 Fix dangling reference in Construct_center_3(Circle_3)
This fixes the issue, but it could still be broken e.g. by a kernel
that is based on a CGAL kernel, but redefines the Sphere_3 and
with Sphere_3-functor that would not return a const& (or in that
case the custom kernel needs to define the appropriate functors
too...)

But so much breaks into this configuration, that it's out of scope
for this fix.
2024-11-03 18:09:45 +01:00
albert-github f7320ae1c1 Spelling corrections
Spelling corrections
2024-09-13 17:53:05 +02:00
Mael Rouxel-Labbé d2475215bb Use the kernel functor for vector constructions 2024-07-04 18:51:58 +02:00
Mael Rouxel-Labbé 16ea300ab6 Add Compare_angle_3 overload and missing global functions 2024-07-04 18:34:09 +02:00
Laurent Rineau b8022cbe9f Revert "experiment adding tuple-like support for Segment_3"
This reverts commit ac47f30cd8.
2024-05-22 13:06:39 +02:00
Laurent Rineau 70464ea107 Merge remote-tracking branch 'afabri/STL_extension-Fix_Prevent_deref-GF' into pr/lrineau/8170 2024-05-21 18:55:11 +02:00
Laurent Rineau e9fb0190c3 Merge pull request #7373 from sloriot/Kernel-Perfect_forwarding
Add some perfect forwarding in the Kernel
2024-05-15 16:12:23 +02:00
Laurent Rineau ac47f30cd8 experiment adding tuple-like support for Segment_3 2024-04-26 14:44:37 +02:00
Laurent Rineau cfb8722861 add comments on Compare_angle_3 2024-04-26 14:37:21 +02:00