Subject: CGAL users discussion list
List archive
- From: KHartmann <>
- To:
- Subject: [cgal-discuss] Traversing outer boundary half-edges of faces in an arrangement
- Date: Thu, 7 Apr 2016 05:22:43 -0700 (PDT)
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=SoftFail ; spf=None
- Ironport-phdr: 9a23:kaAsixJNMzf97J/O49mcpTZWNBhigK39O0sv0rFitYgUL/zxwZ3uMQTl6Ol3ixeRBMOAu6IC17Gd7vuocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC34LrjKvvoNX6WEZhunmUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO9MxGlldhq5lhf44dqsrtY4q3wD88QIrJARFPyiN+RjFeQZX3waNDU+68Tv8BXCVgCS/WA0U2MMkxMODRKWwgv9W8LSkiLgqu903i/Sac72RKooXD2k6Y9iQxqujz0IYW1quFrLg9B92fsI6CmqoAZyltWMOIw=
<http://cgal-discuss.949826.n4.nabble.com/file/n4661783/TwoSquares.png>
I'm adding two intersecting squares to an arrangement.
Then I traverse the half-edges of the outer boundary
for each face in the arrangement.
I get the correct number of half-edges, but the target
vertex of a half-edge isn't always the source vertex
of the next half-edge.
I wouldn't expect this result from reading the help
documentation. What am I doing wrong?
My program is listed below. Along with the output.
----- Output of Program -------------
Face outer boundary:
(15.000000, 15.000000) - (10.000000, 15.000000)
(10.000000, 15.000000) - (10.000000, 10.000000)
(10.000000, 10.000000) - (15.000000, 10.000000)
(15.000000, 10.000000) - (15.000000, 15.000000)
Face outer boundary:
(15.000000, 15.000000) - (10.000000, 15.000000)
(15.000000, 10.000000) - (15.000000, 15.000000)
(15.000000, 10.000000) - (25.000000, 10.000000)
(25.000000, 10.000000) - (25.000000, 25.000000)
(25.000000, 25.000000) - (10.000000, 25.000000)
(10.000000, 25.000000) - (10.000000, 15.000000)
Face outer boundary:
(0.000000, 15.000000) - (0.000000, 0.000000)
(0.000000, 0.000000) - (15.000000, 0.000000)
(15.000000, 0.000000) - (15.000000, 10.000000)
(10.000000, 10.000000) - (15.000000, 10.000000)
(10.000000, 15.000000) - (10.000000, 10.000000)
(10.000000, 15.000000) - (0.000000, 15.000000)
----- Program ---------------
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/Polygon_set_2.h>
#include <CGAL/Arr_batched_point_location.h>
typedef CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq> > Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel>
Polygon_with_holes_2;
typedef CGAL::Polygon_set_2<Kernel> Polygon_set_2;
typedef Kernel::Circle_2 Circle_2;
typedef CGAL::Gps_circle_segment_traits_2<Kernel> Traits_2;
typedef CGAL::General_polygon_set_2<Traits_2> Gen_Polygon_set_2;
typedef Traits_2::General_polygon_2 Gen_Polygon_2;
typedef Traits_2::General_polygon_with_holes_2
Gen_Polygon_with_holes_2;
typedef Traits_2::Curve_2 Curve_2;
typedef Traits_2::X_monotone_curve_2
X_monotone_curve_2;
typedef Gen_Polygon_set_2::Arrangement_2 Arrangement_2;
typedef Gen_Polygon_set_2::Arrangement_2::Point_2 Arr_Point_2;
typedef CGAL::Arr_point_location_result<Arrangement_2>
Point_location_result;
typedef CGAL::Arr_walk_along_line_point_location<Arrangement_2> Walk_pl;
typedef std::pair<Arr_Point_2, Point_location_result::Type> Query_result;
int main()
{
Arrangement_2 arr;
Point_2 p1( 10.0, 10.0 );
Point_2 p2( 25.0, 10.0 );
Point_2 p3( 25.0, 25.0 );
Point_2 p4( 10.0, 25.0 );
Point_2 p5( 0.0, 0.0 );
Point_2 p6( 15.0, 0.0 );
Point_2 p7( 15.0, 15.0 );
Point_2 p8( 0.0, 15.0 );
X_monotone_curve_2 s1( p1, p2 );
X_monotone_curve_2 s2( p2, p3 );
X_monotone_curve_2 s3( p3, p4 );
X_monotone_curve_2 s4( p4, p1 );
X_monotone_curve_2 s5( p5, p6 );
X_monotone_curve_2 s6( p6, p7 );
X_monotone_curve_2 s7( p7, p8 );
X_monotone_curve_2 s8( p8, p5 );
CGAL::insert (arr, s1);
CGAL::insert (arr, s2);
CGAL::insert (arr, s3);
CGAL::insert (arr, s4);
CGAL::insert (arr, s5);
CGAL::insert (arr, s6);
CGAL::insert (arr, s7);
CGAL::insert (arr, s8);
Arrangement_2::Face_const_iterator fit;
for (fit = arr.faces_begin(); fit != arr.faces_end(); ++fit)
{
Arrangement_2::Face_const_handle f = fit;
if (f->is_unbounded())
continue;
Arrangement_2::Ccb_halfedge_const_circulator startLoc = f->outer_ccb();
Arrangement_2::Ccb_halfedge_const_circulator currLoc = startLoc;
Arrangement_2::Halfedge_const_handle halfEdge;
fprintf( stdout, "Face outer boundary:\n" );
do
{
halfEdge = currLoc;
const X_monotone_curve_2& curve = halfEdge->curve();
fprintf( stdout, "(%lf, %lf) - (%lf, %lf)\n",
CGAL::to_double( curve.source().x() ),
CGAL::to_double( curve.source().y() ),
CGAL::to_double( curve.target().x() ),
CGAL::to_double( curve.target().y() ) );
++currLoc;
} while (currLoc != startLoc);
fprintf( stdout, "\n");
}
return 0;
}
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Traversing-outer-boundary-half-edges-of-faces-in-an-arrangement-tp4661783.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Traversing outer boundary half-edges of faces in an arrangement, KHartmann, 04/07/2016
- Re: [cgal-discuss] Traversing outer boundary half-edges of faces in an arrangement, KHartmann, 04/07/2016
Archive powered by MHonArc 2.6.18.