Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Adding a ray extension intersection point into an arrangment

Subject: CGAL users discussion list

List archive

[cgal-discuss] Adding a ray extension intersection point into an arrangment


Chronological Thread 
  • From: dg <>
  • To:
  • Subject: [cgal-discuss] Adding a ray extension intersection point into an arrangment
  • Date: Sun, 16 Mar 2014 11:30:48 -0700 (PDT)

Hello all,

I am trying to extend an edge of an arrangement and getting its intersection
point with the existing edges. Now, I want to add this new edge into the
arrangement. However, the edge is added, it is not properly added into the
arrangement and the face is not split of the arrangement (i think due to
precision problem).

Here is the relevant part of the code -

typedef double Number_type;
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
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::Ray_2 Ray_2;
typedef Traits_2::X_monotone_curve_2 Segment_2;
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
typedef Arrangement_2::Vertex_handle Vertex_handle;
typedef Arrangement_2::Halfedge_handle Halfedge_handle;

const K::Point_2 p1 = K::Point_2(rcurves[i].source().hx(),
rcurves[i].source().hy());
const K::Point_2 p2 = K::Point_2(rcurves[i].target().hx(),
rcurves[i].target().hy());
K::Ray_2 r1 = K::Ray_2(p1,p2); //rcurves[i].source() , rcurves[i].target()
);

//rcurves[i].source() , rcurves[i].target() );
cout<<"Ray # = "<<i&lt;&lt;&quot; &quot;
&lt;&lt;r1.source().hx()&lt;&lt;&quot;
&quot;&lt;&lt;r1.source().hy()&lt;&lt;&quot;
&quot;&lt;&lt;r1.direction()&lt;&lt;endl;
Arrangement_2::Edge_const_iterator eit;
CGAL::Object obj;
int j=0;

// Try inserting the ray directly ..
Arrangement_2::Halfedge_const_iterator hit;
hit = arr.halfedges_begin();
for(int j=0; j&lt;=arr.number_of_edges(); j++)
{
CGAL::Object resObj;
K::Point_2 ipoint;
K::Segment_2
tseg(K::Point_2(hit->curve().source().hx(),hit->curve().source().hy()) ,
K::Point_2(hit->curve().target().hx(), hit->curve().target().hy()) );

resObj = CGAL::intersection(r1, tseg);
if (assign(ipoint, resObj)) {
cout<<"It intersects at point"<<endl;// handle the point
intersection
case.
cout&lt;&lt;&quot;check Intersecting point =
[&quot;&lt;&lt;ipoint.x()&lt;&lt;&quot;
&quot;&lt;&lt;ipoint.y()&lt;&lt;&quot;]&quot;&lt;&lt;endl;
insert_non_intersecting_curve (arr,
Segment_2(Point_2(rvertices[i].x(),
rvertices[i].y()), Point_2(CGAL::to_double(ipoint.hx()),
CGAL::to_double(ipoint.hy()))) );
}
hit= hit->next();
}


Here is an image -

<http://cgal-discuss.949826.n4.nabble.com/file/n4658967/Screenshot_2014-03-16_14.23.49.png>


Here as I have inserted a new edge into the arrangement ideally it should
split the face and then we should have three faces. Instead it just adds the
vertex with a degree 1 and arrangment is not properly modified. I believe
there is some precision problem.

Can anyone point to me the solution of this.

Thanks.



--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Adding-a-ray-extension-intersection-point-into-an-arrangment-tp4658967.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.18.

Top of Page