Merge pull request #8786 from efifogel/Aos_2-fixes-efif

Fixed do_intersect() of curves (provided by Edkirito).
This commit is contained in:
Sébastien Loriot 2025-03-24 11:51:09 +01:00
commit cf301c4d22
3 changed files with 35 additions and 32 deletions

View File

@ -1568,7 +1568,7 @@ template <typename GeometryTraits_2, typename TopologyTraits,
typename PointLocation>
bool
do_intersect(Arrangement_on_surface_2<GeometryTraits_2, TopologyTraits>& arr,
const typename GeometryTraits_2::X_monotone_curve_2& c,
const typename GeometryTraits_2::Curve_2& c,
const PointLocation& pl, std::is_same<int, double>::type)
{
typedef GeometryTraits_2 Gt2;
@ -1607,7 +1607,7 @@ do_intersect(Arrangement_on_surface_2<GeometryTraits_2, TopologyTraits>& arr,
// Check whether the isolated point lies inside a face (otherwise,
// it coincides with a vertex or an edge).
auto obj = pl.locate(*iso_p);
if (std::get_if<Face_const_handle>(&x_obj) != nullptr) return true;
if (std::get_if<Face_const_handle>(&obj) != nullptr) return true;
}
// If we reached here, the curve does not intersect the arrangement.

View File

@ -8,47 +8,49 @@
#include <list>
#include <iostream>
typedef CGAL::Quotient<int> Number_type;
typedef CGAL::Simple_cartesian<Number_type> Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
typedef Traits_2::Point_2 Point_2;
typedef Traits_2::X_monotone_curve_2 Segment_2;
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
typedef Arrangement_2::Halfedge_handle Halfedge_handle;
using Number_type = CGAL::Quotient<int>;
using Kernel = CGAL::Simple_cartesian<Number_type>;
using Traits_2 = CGAL::Arr_segment_traits_2<Kernel>;
using Point_2 = Traits_2::Point_2;
using Segment_2 = Traits_2::X_monotone_curve_2;
using Arrangement_2 = CGAL::Arrangement_2<Traits_2>;
using Halfedge_handle = Arrangement_2::Halfedge_handle;
#define N_SEGMENTS 3
int main () {
Arrangement_2 arr;
using Tt = Arrangement_2::Topology_traits;
Tt::Default_point_location_strategy def_pl(arr);
int main ()
{
Arrangement_2 arr;
Segment_2 segs[N_SEGMENTS];
bool expected_intersect[N_SEGMENTS];
int k;
Segment_2 segs[] = {
Segment_2(Point_2(-2, -2), Point_2(-1, -1)),
Segment_2(Point_2(-1, 1), Point_2(0, 1)),
Segment_2(Point_2(-1, 0), Point_2(0, 0))
};
segs[0] = Segment_2 (Point_2 (-2, -2), Point_2 (-1, -1));
segs[1] = Segment_2 (Point_2 (-1, 1), Point_2 (0, 1));
segs[2] = Segment_2 (Point_2 (-1, 0), Point_2 (0, 0));
expected_intersect[0] = false;
expected_intersect[1] = true;
expected_intersect[2] = true;
bool expected_intersect[] = {false, true, true};
insert(arr, Segment_2(Point_2(0, 0), Point_2(2, 0)));
insert(arr, Segment_2(Point_2(2, 0), Point_2(2, 2)));
insert(arr, Segment_2(Point_2(2, 2), Point_2(0, 2)));
insert(arr, Segment_2(Point_2(0, 2), Point_2(0, 0)));
for (k = 0; k < N_SEGMENTS; k++)
{
bool do_inter = do_intersect(arr, segs[k]);
size_t k = 0;
for (const auto& seg : segs) {
bool do_inter_0 = do_intersect(arr, seg);
bool do_inter_1 = do_intersect(arr, seg, def_pl, std::true_type());
bool do_inter_2 = do_intersect(arr, seg, def_pl, std::false_type());
std::cout << "Segment: " << segs[k];
std::cout << " Expected: " << expected_intersect[k];
std::cout << " Actual: " << do_inter << std::endl;
std::cout << "Segment: " << segs[k] << std::endl;
std::cout << " Expected: " << expected_intersect[k] << std::endl;
std::cout << " Actual auto: " << do_inter_0 << std::endl;
std::cout << " Actual x-monotone curve: " << do_inter_1 << std::endl;
std::cout << " Actual curve: " << do_inter_2 << std::endl;
if (expected_intersect[k] != do_inter)
return (1);
if (expected_intersect[k] != do_inter_0) return -1;
if (expected_intersect[k] != do_inter_1) return -1;
if (expected_intersect[k] != do_inter_2) return -1;
++k;
}
return (0);
return 0;
}

View File

@ -27,6 +27,7 @@
- Renamed the old concept `AosApproximateTraits_2` to `AosApproximatePointTraits_2` to make room for the new concept `AosApproximateTraits_2`. This concept requires the provision of a functor called `Approximate_2` that has an operator that approximates the coordinates of a point.
- Introduced a new concept called `AosApproximateTraits_2`. It refines the concept `AosApproximatePointTraits_2`. This concept requires the provision of a functor called `Approximate_2`. In addition to an operator that approximates the coordinates of a point, it also requires the provision of (i) an operator that approximates a points, and (ii) an operator that approximates a curve.
- Changed all "typedef" style statements in the user manual to "using" style. (Observe that a similar update to the examples has already been made in a previous release.)
- Fixed do_intersect() of a 2D Arrangement and a curve.
### [3D Mesh Generation](https://doc.cgal.org/6.1/Manual/packages.html#PkgMesh3)