Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] use zone() with Arrangement_2

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] use zone() with Arrangement_2


Chronological Thread 
  • From: Efi Fogel <>
  • To:
  • Subject: Re: [cgal-discuss] use zone() with Arrangement_2
  • Date: Thu, 19 Nov 2015 20:36:54 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:505IkxApaQqyPUiHZHx4UyQJP3N1i/DPJgcQr6AfoPdwSP7yp8bcNUDSrc9gkEXOFd2CrakU1qyI6Ou5AT1IyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/niqbsoNaKO1QArQH+SI0xBS3+lR/WuMgSjNkqAYcK4TyNnEF1ff9Lz3hjP1OZkkW0zM6x+Jl+73YY4Kp5pIYTGZj8ZLkyGLxEECw9YSdy/9zurRCFTA2V53JaXH9RiQtNGwGC7Rf0WdD6vSL+8+Z8wyKHJtalcbdhUjur6+JnSQTjlTwcHz8/6mDezMJq34xBpxf0ihJ+i6DTb4yRfK5zcKLTetwXQUJOW89QU2pKBYbqPNhHNPYIIesN99q1nFAJtxbrXQQ=

Look for "Cast Away Constness" in the 2D Arrangement user manual.

   ____  _        ____             _
  /_____/_) o    /__________  __  //
 (____ (   (    (    (_/ (_/-(-'_(/
                         _/



On Thu, Nov 19, 2015 at 8:28 PM, Sebastien Loriot (GeometryFactory) <> wrote:
That's a bit tricky but since the arrangement is non-const,
the simplex type are the non-const one.

>          Arrangement_2::Vertex_handle    vertex;
>          Arrangement_2::Halfedge_handle  edge;
>          Arrangement_2::Face_handle      face;

Sebastien.


On 11/19/2015 06:50 PM, DamienDous wrote:
Hi All,

I try to use zone(arrangement, segment, back_inserter(intersected_objs))
funtion. Here is my code :

/* some includes */

typedef CGAL::Simple_cartesian<double> Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel>        Traits_2;
typedef CGAL::Arr_face_extended_dcel<Traits_2, unsigned int> Dcel;
typedef CGAL::Arrangement_2<Traits_2, Dcel> Arrangement_2;

int            main()
{
         /* Create arrangement */
         CGAL::Arrangement_2<Traits_2, Dcel>  arrangement;
         insert(arrangement, Segment_2(Point_2(0, 0), Point_2(2, 0)));
         insert(arrangement, Segment_2(Point_2(2, 0), Point_2(2, 2)));
         insert(arrangement, Segment_2(Point_2(2, 2), Point_2(0, 2)));
         insert(arrangement, Segment_2(Point_2(0, 2), Point_2(0, 0)));

         /* Create segment */
         const size_t segmentNumber = 3;
         Segment_2 segments[segmentNumber];
         segments[0] = Segment_2(Point_2(-2, -2), Point_2(-1, -1));
         segments[1] = Segment_2(Point_2(-1, 1), Point_2(1, 1));
         segments[2] = Segment_2(Point_2(0, 0), Point_2(3, 0));

         /* Create structure to cast the objects given by zone function */
         Arrangement_2::Vertex_const_handle    vertex;
         Arrangement_2::Halfedge_const_handle  edge;
         Arrangement_2::Face_const_handle      face;

         /* Test for each segment which objects it will cross */
         for (size_t k = 0; k < segmentNumber; k++)
         {
                 std::vector<CGAL::Object> intersected_objs;
                 CGAL::zone(arrangement, segments[k],
std::back_inserter(intersected_objs));

                 std::cout << "the segment intersects " <<
intersected_objs.size()
                 << " objects" << std::endl;

                 for (size_t i = 0; i < intersected_objs.size(); i++) {
                         if (CGAL::assign(face, intersected_objs.at(i)))
                         {
                                 // segments[k] is located inside a face:
                                 if (face->is_unbounded())
                                         std::cout << "inside the unbounded
face." << std::endl;
                                 else
                                         std::cout << "inside a bounded
face." << std::endl;
                         }
                         else if (CGAL::assign(edge, intersected_objs.at(i)))
                         {
                                 // segments[k] is located on an edge:
                                 std::cout << "on an edge: " << edge->curve()
<< std::endl;
                         }
                         else if (CGAL::assign(vertex,
intersected_objs.at(i)))
                         {
                                 // segments[k] is located on a vertex:
                                 if (vertex->is_isolated())
                                         std::cout << "on an isolated vertex:
" << vertex->point() << std::endl;
                                 else
                                         std::cout << "on a vertex: " <<
vertex->point() << std::endl;
                         }
                         else
                         {
                                 std::cout << "invalid object " << std::endl;
                         }
                 }
         }
}

Right now I assume the return of zone function could be
Arrangement_2::Vertex_const_handle, Halfedge_const_handle,
Face_const_handle. I do get non-empty intersected object list (and the
number of intersected objects is correct), but when I try to object_cast its
elements to Vertex/Halfedge/Face, I only get NULL pointer values. The
documentation of zone() doesn't give a list of possible return type. What is
the right way to use this function?

Thanks a lot,

Damien



--
View this message in context: http://cgal-discuss.949826.n4.nabble.com/use-zone-with-Arrangement-2-tp4661363.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss






Archive powered by MHonArc 2.6.18.

Top of Page