snc_point_locator.h

来自「CGAL is a collaborative effort of severa」· C头文件 代码 · 共 889 行 · 第 1/3 页

H
889 行
字号
            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 = Object_handle(e);            hit = true;            _CGAL_NEF_TRACEN("the edge becomes the new hit object");          }        }        else if( CGAL::assign( f, *o)) {          Point_3 q;          _CGAL_NEF_TRACEN("trying facet with on plane "<<plane(f)<<                  " with point on "<<plane(f).point());          if( is.does_intersect_internally( ray, f, q) ) {            _CGAL_NEF_TRACEN("ray intersects facet on "<<q);            _CGAL_NEF_TRACEN("prev. intersection? "<<hit);            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 = Object_handle(f);            hit = true;             _CGAL_NEF_TRACEN("the facet becomes the new hit object");          }        }        else if( CGAL::assign( t, *o)) {          Point_3 q;          Triangle_3 tr = t.get_triangle();          _CGAL_NEF_TRACEN("trying triangle "<<tr);          if( is.does_intersect( ray, tr, q)) {            _CGAL_NEF_TRACEN("ray intersect triangle on "<<q);            _CGAL_NEF_TRACEN("prev. intersection? "<<hit);            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 boundary of the facet? "<<                    is.does_contain_on_boundary( t, q));            if( is.does_contain_on_boundary( t, q))              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 = Object_handle(Halffacet_handle(t));            hit = true;             _CGAL_NEF_TRACEN("the facet becomes the new hit object");          }        }        else          CGAL_assertion_msg( 0, "wrong handle");      }      if(!hit)        ++objects_iterator;    }    TIMER(rs_t.stop());    return result;  }  virtual Object_handle locate( const Point_3& p) const {    if(Infi_box::extended_kernel()) {    TIMER(pl_t.start());    CGAL_assertion( initialized);    _CGAL_NEF_TRACEN( "locate "<<p);    Object_handle result;    Vertex_handle v;    Halfedge_handle e;    Halffacet_handle f;    Halffacet_triangle_handle t;    Object_list candidates = candidate_provider->objects_around_point(p);    Object_list_iterator o = candidates.begin();    bool found = false;    while( !found && o != candidates.end()) {      if( CGAL::assign( v, *o)) {        if ( p == point(v)) {          _CGAL_NEF_TRACEN("found on vertex "<<point(v))                    result = Object_handle(v);          found = true;        }      }      else if( CGAL::assign( e, *o)) {        if ( is.does_contain_internally(Segment_3(e->source()->point(),e->twin()->source()->point()), p) ) {          _CGAL_NEF_TRACEN("found on edge "<<Segment_3(e->source()->point(),e->twin()->source()->point()));          result = Object_handle(e);          found = true;        }      }      else if( CGAL::assign( f, *o)) {        if ( is.does_contain_internally( f, p) ) {          _CGAL_NEF_TRACEN("found on facet...");          result = Object_handle(f);          found = true;        }      }      else if( CGAL::assign( t, *o)) {        Triangle_3 tr = t.get_triangle();        if( tr.has_on(p)) {          _CGAL_NEF_TRACEN("found on triangle "<<tr);	  if(is.does_contain_on_boundary( t, p)) {	    _CGAL_NEF_TRACEN("but located on the facet's boundary");	    continue;	  }          result = Object_handle(Halffacet_handle(t));	  found = true;        }      }      o++;    }    if( !found) {      _CGAL_NEF_TRACEN("point not found in 2-skeleton");      _CGAL_NEF_TRACEN("shooting ray to determine the volume");      Ray_3 r( p, Vector_3( -1, 0, 0));      result = Object_handle(determine_volume(r));    }    TIMER(pl_t.start());    TIMER(pl_t.stop());    return result;  } else {   // standard kernel    CGAL_assertion( initialized);    _CGAL_NEF_TRACEN( "locate "<<p);    typename SNC_structure::FT min_distance;    typename SNC_structure::FT tmp_distance;    Object_handle result;    Vertex_handle v;    Halfedge_handle e;    Halffacet_handle f;    Halffacet_triangle_handle t;    Object_list candidates = candidate_provider->objects_around_point(p);    Object_list_iterator o = candidates.begin();    if(candidates.empty())      return Base(*this).volumes_begin();    CGAL::assign(v,*o);    CGAL_assertion(CGAL::assign(v,*o));    if(p==point(v))      return Object_handle(v);    min_distance = CGAL::squared_distance(point(v),p);    result = Object_handle(v);    ++o;    while(o!=candidates.end() && CGAL::assign(v,*o)) {      if ( p == point(v)) {        _CGAL_NEF_TRACEN("found on vertex "<<point(v));        return Object_handle(v);      }      tmp_distance = CGAL::squared_distance(v->point(),p);      if(tmp_distance < min_distance) {	result = Object_handle(v);        min_distance = tmp_distance;      }      ++o;    }         CGAL::assign(v, result);    Segment_3 s(p,point(v));    Point_3 ip;//    Object_list_iterator ox(o);    for(;o!=candidates.end();++o) {      if( CGAL::assign( e, *o)) {	Segment_3 ss(e->source()->point(),e->twin()->source()->point());	CGAL_NEF_TRACEN("test edge " << e->source()->point() << "->" << e->twin()->source()->point());        if(is.does_contain_internally(ss, p) ) {          _CGAL_NEF_TRACEN("found on edge "<< ss);          return Object_handle(e);        }	if(is.does_intersect_internally(s, ss, ip)) {	  s = Segment_3(p, normalized(ip));	  result = Object_handle(e);        }      } else if( CGAL::assign( f, *o)) {	CGAL_NEF_TRACEN("test facet " << f->plane());        if (is.does_contain_internally(f,p) ) {          _CGAL_NEF_TRACEN("found on facet...");          return Object_handle(f);        }        if( is.does_intersect_internally(s,f,ip)) {	          s = Segment_3(p, normalized(ip));	  result = Object_handle(f);        }      } else CGAL_assertion_msg(false, "wrong handle type");    }    if( CGAL::assign( v, result)) {      _CGAL_NEF_TRACEN("vertex hit, obtaining volume...");      SM_point_locator L(&*v);      Object_handle so = L.locate(s.source()-s.target());      SFace_handle sf;      if(CGAL::assign(sf,so))        return sf->volume();      CGAL_assertion_msg(false, "wrong handle type");/*      SHalfedge_handle se;      CGAL_assertion(CGAL::assign(se,so));      CGAL_NEF_TRACEN("intersect segment " << s << " with edges");      for(;ox!=candidates.end();++ox) {	if(!CGAL::assign(e,*ox)) continue;	CGAL_NEF_TRACEN("test edge " << e->source()->point() << "->" << e->twin()->source()->point());	if(is.does_intersect_internally(s,Segment_3(e->source()->point(),e->twin()->source()->point()),ip)) {	  s = Segment_3(p, normalized(ip));	  result = Object_handle(e);        }      }      CGAL_assertion(CGAL::assign(e,result));      CGAL::assign(e,result);      f = get_visible_facet(e, Ray_3(p, s.target()));	      if( f != Halffacet_handle())	return f->incident_volume();      SM_decorator SD(&*v); // now, the vertex has no incident facets      CGAL_assertion( SD.number_of_sfaces() == 1);      return SD.sfaces_begin()->volume();      */    } else if( CGAL::assign( f, result)) {      _CGAL_NEF_TRACEN("facet hit, obtaining volume...");      if(f->plane().oriented_side(p) == ON_NEGATIVE_SIDE)	f = f->twin();      return Object_handle(f->incident_volume());    } else if( CGAL::assign(e, result)) {      SM_decorator SD(&*source(e));      if( SD.is_isolated(e))        return Object_handle(e->incident_sface()->volume());	      return get_visible_facet(e,Ray_3(s.source(),s.to_vector()))->incident_volume();    }    CGAL_assertion_msg(false, "wrong handle type");    return Object_handle();  }  }  virtual void intersect_with_edges_and_facets( Halfedge_const_handle e0,	const typename SNC_point_locator::Intersection_call_back& call_back) const {    TIMER(it_t.start());    CGAL_assertion( initialized);    _CGAL_NEF_TRACEN( "intersecting edge: "<<&*e0<<' '<<Segment_3(e0->source()->point(),                                                         e0->twin()->source()->point()));#ifdef CGAL_NEF3_TRIANGULATE_FACETS    Unique_hash_map< Halffacet_triangle_handle, bool> f_mark(false);#endif // CGAL_NEF3_TRIANGULATE_FACETS    Segment_3 s(Segment_3(e0->source()->point(),e0->twin()->source()->point()));    Vertex_handle v;    Halfedge_handle e;    Halffacet_handle f;    Halffacet_triangle_handle t;    Object_list_iterator o;    Object_list objects = candidate_provider->objects_around_segment(s);    CGAL_for_each( o, objects) {      if( CGAL::assign( v, *o)) {        /* do nothing */      }      else if( CGAL::assign( e, *o)) {#ifdef CGAL_NEF3_DUMP_STATISTICS      ++number_of_intersection_candidates;#endif        Point_3 q;        if( is.does_intersect_internally( s, Segment_3(e->source()->point(),	                                               e->twin()->source()->point()), q)) {          q = normalized(q);          call_back( e0, Object_handle(Halfedge_const_handle(e)), q);          _CGAL_NEF_TRACEN("edge intersects edge "<<' '<<&*e<< Segment_3(e->source()->point(),                                                                e->twin()->source()->point())<<" on "<<q);        }      }      else if( CGAL::assign( f, *o)) {#ifdef CGAL_NEF3_DUMP_STATISTICS      ++number_of_intersection_candidates;#endif        Point_3 q;        if( is.does_intersect_internally( s, f, q) ) {          q = normalized(q);          call_back( e0, Object_handle(Halffacet_const_handle(f)), q);          _CGAL_NEF_TRACEN("edge intersects facet on plane "<<plane(f)<<" on "<<q);        }      }      else if( CGAL::assign( t, *o)) {        Point_3 q;        Triangle_3 tr = t.get_triangle();#ifdef CGAL_NEF3_TRIANGULATE_FACETS	if( f_mark[t])	  continue;#endif // CGAL_NEF3_TRIANGULATE_FACETS	_CGAL_NEF_TRACEN("trying with triangle "<<tr);        if( is.does_intersect( s, tr, q) &&            !is.does_contain_on_boundary( t, q)) {

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?