diff --git a/Nef_3/include/CGAL/Nef_3/SNC_external_structure.h b/Nef_3/include/CGAL/Nef_3/SNC_external_structure.h index c03e212fdfd..ec2d9912179 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_external_structure.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_external_structure.h @@ -914,7 +914,7 @@ public: number_of_ray_shooting_queries++; timer_ray_shooting.start(); #endif - Object_handle o = pl->shoot(ray); + Object_handle o = pl->shoot(ray, vi); #ifdef CGAL_NEF3_TIMER_POINT_LOCATION timer_ray_shooting.stop(); #endif diff --git a/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h b/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h index 0cb23307d66..71460c0b1d6 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_point_locator.h @@ -80,7 +80,7 @@ public: virtual Object_handle locate(const Point_3& p) const = 0; - virtual Object_handle shoot(const Ray_3& s, int mask=255) const = 0; + virtual Object_handle shoot(const Ray_3& s, Vertex_handle ray_source_vertex, int mask=255) const = 0; virtual void intersect_with_edges( Halfedge_handle edge, const Intersection_call_back& call_back) @@ -216,7 +216,7 @@ public: delete candidate_provider; } - virtual Object_handle shoot(const Ray_3& ray, int mask=255) const { + virtual Object_handle shoot(const Ray_3& ray, Vertex_handle ray_source_vertex, int mask=255) const { CGAL_NEF_TIMER(rs_t.start()); CGAL_assertion( initialized); _CGAL_NEF_TRACEN( "shooting: "<source()->point(),e->twin()->source()->point())); - if( is.does_intersect_internally( ray, Segment_3(e->source()->point(), - e->twin()->source()->point()), q)) { - _CGAL_NEF_TRACEN("ray intersects edge on "<is_point_on_cell( q, objects_iterator)); - if( !candidate_provider->is_point_on_cell( q, objects_iterator)) - continue; - eor = q; - result = make_object(e); - hit = true; - _CGAL_NEF_TRACEN("the edge becomes the new hit object"); + if ((ray_source_vertex != Vertex_handle()) && (ray_source_vertex != e->source()) && (ray_source_vertex != e->twin()->source())) { + + if (is.does_intersect_internally(ray, Segment_3(e->source()->point(), + e->twin()->source()->point()), q)) { + _CGAL_NEF_TRACEN("ray intersects edge on " << q); + _CGAL_NEF_TRACEN("prev. intersection? " << hit); + CGAL_assertion_code + (if (hit) _CGAL_NEF_TRACEN("prev. intersection on " << eor)); + if (hit && !has_smaller_distance_to_point(ray.source(), q, eor)) + continue; + _CGAL_NEF_TRACEN("is the intersection point on the current cell? " << + candidate_provider->is_point_on_cell(q, objects_iterator)); + if (!candidate_provider->is_point_on_cell(q, objects_iterator)) + continue; + eor = q; + result = make_object(e); + hit = true; + _CGAL_NEF_TRACEN("the edge becomes the new hit object"); + } } } else if( CGAL::assign( f, *o) && ((mask&4) != 0)) { @@ -661,7 +664,8 @@ public: private: Volume_handle determine_volume( const Ray_3& ray) const { Halffacet_handle f_below; - Object_handle o = shoot(ray); + Vertex_handle null_vertex; + Object_handle o = shoot(ray, null_vertex); Vertex_handle v; Halfedge_handle e; Halffacet_handle f;