mirror of https://github.com/CGAL/cgal
replace Object
This commit is contained in:
parent
f669df07bf
commit
a1fb4c4814
|
|
@ -17,28 +17,28 @@ typedef Arr_with_hist_2::Curve_handle Curve_handle;
|
|||
typedef CGAL::Arr_walk_along_line_point_location<Arr_with_hist_2>
|
||||
Point_location;
|
||||
|
||||
int main ()
|
||||
int main()
|
||||
{
|
||||
// Construct an arrangement containing nine circles: C[0] of radius 2 and
|
||||
// C[1], ..., C[8] of radius 1.
|
||||
const Number_type _7_halves = Number_type (7, 2);
|
||||
const Number_type _7_halves = Number_type(7, 2);
|
||||
Arr_with_hist_2 arr;
|
||||
Curve_2 C[9];
|
||||
Curve_handle handles[9];
|
||||
int k;
|
||||
|
||||
C[0] = Circle_2 (Rat_point_2 (_7_halves, _7_halves), 4, CGAL::CLOCKWISE);
|
||||
C[1] = Circle_2 (Rat_point_2 (_7_halves, 6), 1, CGAL::CLOCKWISE);
|
||||
C[2] = Circle_2 (Rat_point_2 (5, 6), 1, CGAL::CLOCKWISE);
|
||||
C[3] = Circle_2 (Rat_point_2 (6, _7_halves), 1, CGAL::CLOCKWISE);
|
||||
C[4] = Circle_2 (Rat_point_2 (5, 2), 1, CGAL::CLOCKWISE);
|
||||
C[5] = Circle_2 (Rat_point_2 (_7_halves, 1), 1, CGAL::CLOCKWISE);
|
||||
C[6] = Circle_2 (Rat_point_2 (2, 2), 1, CGAL::CLOCKWISE);
|
||||
C[7] = Circle_2 (Rat_point_2 (1, _7_halves), 1, CGAL::CLOCKWISE);
|
||||
C[8] = Circle_2 (Rat_point_2 (2, 5), 1, CGAL::CLOCKWISE);
|
||||
C[0] = Circle_2(Rat_point_2(_7_halves, _7_halves), 4, CGAL::CLOCKWISE);
|
||||
C[1] = Circle_2(Rat_point_2(_7_halves, 6), 1, CGAL::CLOCKWISE);
|
||||
C[2] = Circle_2(Rat_point_2(5, 6), 1, CGAL::CLOCKWISE);
|
||||
C[3] = Circle_2(Rat_point_2(6, _7_halves), 1, CGAL::CLOCKWISE);
|
||||
C[4] = Circle_2(Rat_point_2(5, 2), 1, CGAL::CLOCKWISE);
|
||||
C[5] = Circle_2(Rat_point_2(_7_halves, 1), 1, CGAL::CLOCKWISE);
|
||||
C[6] = Circle_2(Rat_point_2(2, 2), 1, CGAL::CLOCKWISE);
|
||||
C[7] = Circle_2(Rat_point_2(1, _7_halves), 1, CGAL::CLOCKWISE);
|
||||
C[8] = Circle_2(Rat_point_2(2, 5), 1, CGAL::CLOCKWISE);
|
||||
|
||||
unsigned int k;
|
||||
for (k = 0; k < 9; k++)
|
||||
handles[k] = insert (arr, C[k]);
|
||||
handles[k] = insert(arr, C[k]);
|
||||
|
||||
std::cout << "The initial arrangement size:" << std::endl
|
||||
<< " V = " << arr.number_of_vertices()
|
||||
|
|
@ -47,7 +47,7 @@ int main ()
|
|||
|
||||
// Remove the large circle C[0].
|
||||
std::cout << "Removing C[0] : ";
|
||||
std::cout << remove_curve (arr, handles[0])
|
||||
std::cout << remove_curve(arr, handles[0])
|
||||
<< " edges have been removed." << std::endl;
|
||||
|
||||
std::cout << "The arrangement size:" << std::endl
|
||||
|
|
@ -56,18 +56,18 @@ int main ()
|
|||
<< ", F = " << arr.number_of_faces() << std::endl;
|
||||
|
||||
// Locate the point q, which should be on an edge e.
|
||||
Point_location pl (arr);
|
||||
const Point_2 q = Point_2 (_7_halves, 7);
|
||||
CGAL::Object obj = pl.locate (q);
|
||||
Point_location pl(arr);
|
||||
const Point_2 q = Point_2(_7_halves, 7);
|
||||
Point_location::result_type obj = pl.locate(q);
|
||||
Arr_with_hist_2::Halfedge_const_handle e;
|
||||
|
||||
CGAL_assertion_code(bool success = ) CGAL::assign (e, obj);
|
||||
CGAL_assertion (success);
|
||||
CGAL_assertion_code(bool success = ) CGAL::assign(e, obj);
|
||||
CGAL_assertion(success);
|
||||
|
||||
// Split the edge e to two edges e1 and e2;
|
||||
Arr_with_hist_2::Halfedge_handle e1, e2;
|
||||
|
||||
e1 = arr.split_edge (arr.non_const_handle (e), q);
|
||||
e1 = arr.split_edge(arr.non_const_handle(e), q);
|
||||
e2 = e1->next();
|
||||
|
||||
std::cout << "After edge split: "
|
||||
|
|
@ -76,7 +76,7 @@ int main ()
|
|||
<< ", F = " << arr.number_of_faces() << std::endl;
|
||||
|
||||
// Merge back the two split edges.
|
||||
arr.merge_edge (e1, e2);
|
||||
arr.merge_edge(e1, e2);
|
||||
|
||||
std::cout << "After edge merge: "
|
||||
<< "V = " << arr.number_of_vertices()
|
||||
|
|
|
|||
|
|
@ -17,23 +17,23 @@ typedef Traits_2::X_monotone_curve_2 Segment_2;
|
|||
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
||||
typedef CGAL::Arr_walk_along_line_point_location<Arrangement_2> Walk_pl;
|
||||
|
||||
int main ()
|
||||
int main()
|
||||
{
|
||||
// Construct the arrangement of five intersecting segments.
|
||||
Arrangement_2 arr;
|
||||
Walk_pl pl(arr);
|
||||
|
||||
Segment_2 s1 (Point_2(1, 0), Point_2(2, 4));
|
||||
Segment_2 s2 (Point_2(5, 0), Point_2(5, 5));
|
||||
Segment_2 s3 (Point_2(1, 0), Point_2(5, 3));
|
||||
Segment_2 s4 (Point_2(0, 2), Point_2(6, 0));
|
||||
Segment_2 s5 (Point_2(3, 0), Point_2(5, 5));
|
||||
Segment_2 s1(Point_2(1, 0), Point_2(2, 4));
|
||||
Segment_2 s2(Point_2(5, 0), Point_2(5, 5));
|
||||
Segment_2 s3(Point_2(1, 0), Point_2(5, 3));
|
||||
Segment_2 s4(Point_2(0, 2), Point_2(6, 0));
|
||||
Segment_2 s5(Point_2(3, 0), Point_2(5, 5));
|
||||
|
||||
insert_non_intersecting_curve (arr, s1, pl);
|
||||
insert_non_intersecting_curve (arr, s2, pl);
|
||||
insert (arr, s3, pl);
|
||||
insert (arr, s4, pl);
|
||||
insert (arr, s5, pl);
|
||||
insert_non_intersecting_curve(arr, s1, pl);
|
||||
insert_non_intersecting_curve(arr, s2, pl);
|
||||
insert(arr, s3, pl);
|
||||
insert(arr, s4, pl);
|
||||
insert(arr, s5, pl);
|
||||
|
||||
// Print the size of the arrangement.
|
||||
std::cout << "The arrangement size:" << std::endl
|
||||
|
|
@ -43,15 +43,15 @@ int main ()
|
|||
|
||||
// Perform a point-location query on the resulting arrangement and print
|
||||
// the boundary of the face that contains it.
|
||||
Point_2 q (4, 1);
|
||||
CGAL::Object obj = pl.locate (q);
|
||||
Point_2 q(4, 1);
|
||||
Walk_pl::result_type obj = pl.locate(q);
|
||||
|
||||
Arrangement_2::Face_const_handle f;
|
||||
CGAL_assertion_code (bool success =) CGAL::assign (f, obj);
|
||||
CGAL_assertion_code(bool success =) CGAL::assign(f, obj);
|
||||
|
||||
CGAL_assertion (success);
|
||||
CGAL_assertion(success);
|
||||
std::cout << "The query point (" << q << ") is located in: ";
|
||||
print_face<Arrangement_2> (f);
|
||||
print_face<Arrangement_2>(f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@
|
|||
// Perform a point-location query and print the result.
|
||||
//
|
||||
template <class PointLocation>
|
||||
void point_location_query
|
||||
(const PointLocation& pl,
|
||||
const typename PointLocation::Arrangement_2::Point_2& q)
|
||||
void
|
||||
point_location_query(const PointLocation& pl,
|
||||
const typename PointLocation::Arrangement_2::Point_2& q)
|
||||
{
|
||||
typedef PointLocation Point_location;
|
||||
// Perform the point-location query.
|
||||
CGAL::Object obj = pl.locate (q);
|
||||
typename Point_location::result_type obj = pl.locate(q);
|
||||
|
||||
// Print the result.
|
||||
typedef typename PointLocation::Arrangement_2 Arrangement_2;
|
||||
|
|
@ -17,33 +18,21 @@ void point_location_query
|
|||
typename Arrangement_2::Face_const_handle f;
|
||||
|
||||
std::cout << "The point (" << q << ") is located ";
|
||||
if (CGAL::assign (f, obj))
|
||||
{
|
||||
if (CGAL::assign(f, obj))
|
||||
// q is located inside a face:
|
||||
if (f->is_unbounded())
|
||||
std::cout << "inside the unbounded face." << std::endl;
|
||||
else
|
||||
std::cout << "inside a bounded face." << std::endl;
|
||||
}
|
||||
else if (CGAL::assign (e, obj))
|
||||
{
|
||||
std::cout << ((f->is_unbounded()) ?
|
||||
"inside the unbounded face." : "inside a bounded face.")
|
||||
<< std::endl;
|
||||
else if (CGAL::assign(e, obj))
|
||||
// q is located on an edge:
|
||||
std::cout << "on an edge: " << e->curve() << std::endl;
|
||||
}
|
||||
else if (CGAL::assign (v, obj))
|
||||
{
|
||||
else if (CGAL::assign(v, obj))
|
||||
// q is located on a vertex:
|
||||
if (v->is_isolated())
|
||||
std::cout << "on an isolated vertex: " << v->point() << std::endl;
|
||||
else
|
||||
std::cout << "on a vertex: " << v->point() << std::endl;
|
||||
}
|
||||
std::cout << ((v->is_isolated()) ?
|
||||
"on an isolated vertex: " : "on a vertex: ")
|
||||
<< v->point() << std::endl;
|
||||
else
|
||||
{
|
||||
CGAL_error_msg( "Invalid object.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -51,11 +40,12 @@ void point_location_query
|
|||
//
|
||||
template <class VerticalRayShoot>
|
||||
void vertical_ray_shooting_query
|
||||
(const VerticalRayShoot& vrs,
|
||||
const typename VerticalRayShoot::Arrangement_2::Point_2& q)
|
||||
(const VerticalRayShoot& vrs,
|
||||
const typename VerticalRayShoot::Arrangement_2::Point_2& q)
|
||||
{
|
||||
typedef VerticalRayShoot Vertical_ray_shoot;
|
||||
// Perform the point-location query.
|
||||
CGAL::Object obj = vrs.ray_shoot_up (q);
|
||||
typename Vertical_ray_shoot::result_type obj = vrs.ray_shoot_up(q);
|
||||
|
||||
// Print the result.
|
||||
typedef typename VerticalRayShoot::Arrangement_2 Arrangement_2;
|
||||
|
|
@ -65,32 +55,21 @@ void vertical_ray_shooting_query
|
|||
typename Arrangement_2::Face_const_handle f;
|
||||
|
||||
std::cout << "Shooting up from (" << q << ") : ";
|
||||
if (CGAL::assign (e, obj))
|
||||
{
|
||||
if (CGAL::assign(e, obj))
|
||||
// We hit an edge:
|
||||
std::cout << "hit an edge: " << e->curve() << std::endl;
|
||||
}
|
||||
else if (CGAL::assign (v, obj))
|
||||
{
|
||||
else if (CGAL::assign(v, obj))
|
||||
// We hit a vertex:
|
||||
if (v->is_isolated())
|
||||
std::cout << "hit an isolated vertex: " << v->point() << std::endl;
|
||||
else
|
||||
std::cout << "hit a vertex: " << v->point() << std::endl;
|
||||
}
|
||||
else if (CGAL::assign (f, obj))
|
||||
{
|
||||
std::cout << ((v->is_isolated()) ?
|
||||
"hit an isolated vertex: " : "hit a vertex: ")
|
||||
<< v->point() << std::endl;
|
||||
else if (CGAL::assign(f, obj)) {
|
||||
// We did not hit anything:
|
||||
CGAL_assertion (f->is_unbounded());
|
||||
|
||||
CGAL_assertion(f->is_unbounded());
|
||||
std::cout << "hit nothing." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
CGAL_error_msg( "Invalid object.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -100,22 +79,20 @@ void vertical_ray_shooting_query
|
|||
// coordinates.
|
||||
//
|
||||
template <class Arrangement>
|
||||
void construct_segments_arr (Arrangement& arr)
|
||||
void construct_segments_arr(Arrangement& arr)
|
||||
{
|
||||
typedef typename Arrangement::Point_2 Point_2;
|
||||
typedef typename Arrangement::X_monotone_curve_2 Segment_2;
|
||||
typedef typename Arrangement::Halfedge_handle Halfedge_handle;
|
||||
|
||||
Point_2 p0 (3,2), p1 (0,3), p2 (2,5), p3 (4,5), p4 (6,3), p5 (3,0);
|
||||
Segment_2 s1 (p1, p2), s2 (p2, p3), s3 (p3, p4), s4 (p4, p5), s5 (p5, p1);
|
||||
Point_2 p0(3,2), p1(0,3), p2(2,5), p3(4,5), p4(6,3), p5(3,0);
|
||||
Segment_2 s1(p1, p2), s2(p2, p3), s3(p3, p4), s4(p4, p5), s5(p5, p1);
|
||||
|
||||
arr.insert_in_face_interior (p0, arr.unbounded_face());
|
||||
arr.insert_in_face_interior(p0, arr.unbounded_face());
|
||||
|
||||
Halfedge_handle e1 = arr.insert_in_face_interior (s1, arr.unbounded_face());
|
||||
Halfedge_handle e2 = arr.insert_from_left_vertex (s2, e1->target());
|
||||
Halfedge_handle e3 = arr.insert_from_left_vertex (s3, e2->target());
|
||||
Halfedge_handle e4 = arr.insert_from_right_vertex (s4, e3->target());
|
||||
Halfedge_handle e5 = arr.insert_at_vertices (s5, e4->target(), e1->source());
|
||||
|
||||
return;
|
||||
Halfedge_handle e1 = arr.insert_in_face_interior(s1, arr.unbounded_face());
|
||||
Halfedge_handle e2 = arr.insert_from_left_vertex(s2, e1->target());
|
||||
Halfedge_handle e3 = arr.insert_from_left_vertex(s3, e2->target());
|
||||
Halfedge_handle e4 = arr.insert_from_right_vertex(s4, e3->target());
|
||||
Halfedge_handle e5 = arr.insert_at_vertices(s5, e4->target(), e1->source());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue