Skip to content

Commit cf301c4

Browse files
committed
Merge pull request #8786 from efifogel/Aos_2-fixes-efif
Fixed do_intersect() of curves (provided by Edkirito).
2 parents e463bca + f1b82b9 commit cf301c4

File tree

3 files changed

+40
-37
lines changed

3 files changed

+40
-37
lines changed

Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_global.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,7 @@ template <typename GeometryTraits_2, typename TopologyTraits,
15681568
typename PointLocation>
15691569
bool
15701570
do_intersect(Arrangement_on_surface_2<GeometryTraits_2, TopologyTraits>& arr,
1571-
const typename GeometryTraits_2::X_monotone_curve_2& c,
1571+
const typename GeometryTraits_2::Curve_2& c,
15721572
const PointLocation& pl, std::is_same<int, double>::type)
15731573
{
15741574
typedef GeometryTraits_2 Gt2;
@@ -1607,7 +1607,7 @@ do_intersect(Arrangement_on_surface_2<GeometryTraits_2, TopologyTraits>& arr,
16071607
// Check whether the isolated point lies inside a face (otherwise,
16081608
// it coincides with a vertex or an edge).
16091609
auto obj = pl.locate(*iso_p);
1610-
if (std::get_if<Face_const_handle>(&x_obj) != nullptr) return true;
1610+
if (std::get_if<Face_const_handle>(&obj) != nullptr) return true;
16111611
}
16121612

16131613
// If we reached here, the curve does not intersect the arrangement.

Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_do_intersect.cpp

+37-35
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,49 @@
88
#include <list>
99
#include <iostream>
1010

11-
typedef CGAL::Quotient<int> Number_type;
12-
typedef CGAL::Simple_cartesian<Number_type> Kernel;
13-
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
14-
typedef Traits_2::Point_2 Point_2;
15-
typedef Traits_2::X_monotone_curve_2 Segment_2;
16-
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
17-
typedef Arrangement_2::Halfedge_handle Halfedge_handle;
18-
19-
#define N_SEGMENTS 3
20-
21-
int main ()
22-
{
23-
Arrangement_2 arr;
24-
Segment_2 segs[N_SEGMENTS];
25-
bool expected_intersect[N_SEGMENTS];
26-
int k;
27-
28-
segs[0] = Segment_2 (Point_2 (-2, -2), Point_2 (-1, -1));
29-
segs[1] = Segment_2 (Point_2 (-1, 1), Point_2 (0, 1));
30-
segs[2] = Segment_2 (Point_2 (-1, 0), Point_2 (0, 0));
31-
32-
expected_intersect[0] = false;
33-
expected_intersect[1] = true;
34-
expected_intersect[2] = true;
11+
using Number_type = CGAL::Quotient<int>;
12+
using Kernel = CGAL::Simple_cartesian<Number_type>;
13+
using Traits_2 = CGAL::Arr_segment_traits_2<Kernel>;
14+
using Point_2 = Traits_2::Point_2;
15+
using Segment_2 = Traits_2::X_monotone_curve_2;
16+
using Arrangement_2 = CGAL::Arrangement_2<Traits_2>;
17+
using Halfedge_handle = Arrangement_2::Halfedge_handle;
18+
19+
int main () {
20+
Arrangement_2 arr;
21+
using Tt = Arrangement_2::Topology_traits;
22+
Tt::Default_point_location_strategy def_pl(arr);
23+
24+
Segment_2 segs[] = {
25+
Segment_2(Point_2(-2, -2), Point_2(-1, -1)),
26+
Segment_2(Point_2(-1, 1), Point_2(0, 1)),
27+
Segment_2(Point_2(-1, 0), Point_2(0, 0))
28+
};
29+
30+
bool expected_intersect[] = {false, true, true};
3531

3632
insert(arr, Segment_2(Point_2(0, 0), Point_2(2, 0)));
3733
insert(arr, Segment_2(Point_2(2, 0), Point_2(2, 2)));
3834
insert(arr, Segment_2(Point_2(2, 2), Point_2(0, 2)));
3935
insert(arr, Segment_2(Point_2(0, 2), Point_2(0, 0)));
4036

41-
for (k = 0; k < N_SEGMENTS; k++)
42-
{
43-
bool do_inter = do_intersect(arr, segs[k]);
44-
45-
std::cout << "Segment: " << segs[k];
46-
std::cout << " Expected: " << expected_intersect[k];
47-
std::cout << " Actual: " << do_inter << std::endl;
48-
49-
if (expected_intersect[k] != do_inter)
50-
return (1);
37+
size_t k = 0;
38+
for (const auto& seg : segs) {
39+
bool do_inter_0 = do_intersect(arr, seg);
40+
bool do_inter_1 = do_intersect(arr, seg, def_pl, std::true_type());
41+
bool do_inter_2 = do_intersect(arr, seg, def_pl, std::false_type());
42+
43+
std::cout << "Segment: " << segs[k] << std::endl;
44+
std::cout << " Expected: " << expected_intersect[k] << std::endl;
45+
std::cout << " Actual auto: " << do_inter_0 << std::endl;
46+
std::cout << " Actual x-monotone curve: " << do_inter_1 << std::endl;
47+
std::cout << " Actual curve: " << do_inter_2 << std::endl;
48+
49+
if (expected_intersect[k] != do_inter_0) return -1;
50+
if (expected_intersect[k] != do_inter_1) return -1;
51+
if (expected_intersect[k] != do_inter_2) return -1;
52+
++k;
5153
}
5254

53-
return (0);
55+
return 0;
5456
}

Installation/CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- 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.
2828
- 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.
2929
- 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.)
30+
- Fixed do_intersect() of a 2D Arrangement and a curve.
3031

3132
### [3D Mesh Generation](https://doc.cgal.org/6.1/Manual/packages.html#PkgMesh3)
3233

0 commit comments

Comments
 (0)