snc_point_locator.h

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

H
889 行
字号
          q = normalized(q);          call_back( e0, Object_handle(Halffacet_handle(t)), q);          _CGAL_NEF_TRACEN("edge intersects facet triangle on plane "<<plane(t)<<" on "<<q);#ifdef CGAL_NEF3_TRIANGULATE_FACETS	  f_mark[t] = true;#endif // CGAL_NEF3_TRIANGULATE_FACETS        }      }      else        CGAL_assertion_msg( 0, "wrong handle");    }    TIMER(it_t.stop());  }  virtual void intersect_with_edges( 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()));    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)) {        /* do nothing */      }      else if( CGAL::assign( t, *o)) {        /* do nothing */      }      else        CGAL_assertion_msg( 0, "wrong handle");    }    TIMER(it_t.stop());  }  virtual void intersect_with_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: "<< 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)) {        /* do nothing */      }      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)) {          q = normalized(q);          call_back( e0, Object_handle(Halffacet_handle(t)), q);          _CGAL_NEF_TRACEN("edge intersects facet triangle on plane "<<plane(t)<<" on "<<q);#ifdef CGAL_NEF3_TRIANGULATE_FACETS	  f_mark[t] = true;#endif // CGAL_NEF3_TRIANGULATE_FACETS        }      }      else        CGAL_assertion_msg( 0, "wrong handle");    }    TIMER(it_t.stop());  }private:  Volume_handle determine_volume( const Ray_3& ray) const {    Halffacet_handle f_below;    Object_handle o = shoot(ray);    Vertex_handle v;    Halfedge_handle e;    Halffacet_handle f;    if( CGAL::assign( v, o)) {      _CGAL_NEF_TRACEN("vertex hit, obtaining volume...");      f_below = get_visible_facet( v, ray);      if( f_below != Halffacet_handle())        return f_below->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( e, o)) {      _CGAL_NEF_TRACEN("edge hit, obtaining volume...");      f_below = get_visible_facet( e, ray);      if( f_below != Halffacet_handle())        return f_below->incident_volume();      CGAL_assertion_code(SM_decorator SD(&*source(e))); // now, the edge has no incident facets      CGAL_assertion(SD.is_isolated(e));      return sface(e)->volume();    }    else if( CGAL::assign( f, o)) {      _CGAL_NEF_TRACEN("facet hit, obtaining volume...");      f_below = get_visible_facet(f, ray);      CGAL_assertion( f_below != Halffacet_handle());      return f_below->incident_volume();    }    return Base(*this).volumes_begin(); // TODO: Comment this hack!  }private:  bool initialized;  SNC_candidate_provider* candidate_provider;  SNC_intersection is;  std::list<Halffacet_triangle_handle> triangulation;};/*template <typename SNC_decorator>class SNC_point_locator_naive :   public SNC_ray_shooter<SNC_structure>,   public SNC_point_locator<SNC_structure>{  typedef SNC_ray_shooter<SNC_structure> Base;  typedef SNC_point_locator_naive<SNC_structure> Self;  typedef SNC_point_locator<SNC_structure> SNC_point_locator;  typedef SNC_intersection<SNC_structure> SNC_intersection;public:  typedef typename SNC_decorator::Object_handle Object_handle;  typedef typename SNC_decorator::Halfedge_const_handle Halfedge_const_handle;  typedef typename SNC_decorator::Halffacet_triangle_handle                                   Halffacet_triangle_handle;  typedef typename SNC_decorator::Point_3 Point_3;  typedef typename SNC_decorator::Segment_3 Segment_3;  typedef typename SNC_decorator::Ray_3 Ray_3;  typedef typename SNC_decorator::Triangle_3 Triangle_3;  typedef typename Decorator_traits::Vertex_handle Vertex_handle;  typedef typename Decorator_traits::Halfedge_handle Halfedge_handle;  typedef typename Decorator_traits::Halffacet_handle Halffacet_handle;  typedef typename Decorator_traits::Volume_handle Volume_handle;  typedef typename Decorator_traits::Vertex_iterator Vertex_iterator;  typedef typename Decorator_traits::Halfedge_iterator Halfedge_iterator;  typedef typename Decorator_traits::Halffacet_iterator Halffacet_iterator;public:  SNC_point_locator_naive() : initialized(false) {}  virtual void initialize(SNC_structure* W) {     TIMER(ct_t.start());    strcpy( version_, "Naive Point Locator (tm)");    CLOG(version());    CGAL_assertion( W != NULL);    Base::initialize(W);     initialized = true;    TIMER(ct_t.stop());  }  virtual Self* clone() const {     return new Self;   }  virtual bool update( Unique_hash_map<Vertex_handle, bool>& V,                        Unique_hash_map<Halfedge_handle, bool>& E,                        Unique_hash_map<Halffacet_handle, bool>& F) {    TIMER(ct_t.start());    CGAL_assertion( initialized);    TIMER(ct_t.stop());    return false;  }  virtual ~SNC_point_locator_naive() {}  virtual Object_handle locate(const Point_3& p) const {    TIMER(pl_t.start());    CGAL_assertion( initialized);    TIMER(pl_t.stop());    return Base::locate(p);  }  virtual Object_handle shoot(const Ray_3& r) const {    TIMER(rs_t.start());    CGAL_assertion( initialized);    TIMER(rs_t.stop());    return Base::shoot(r);  }  virtual void intersect_with_edges( 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: "<< Segment_3(e0->source()->point(),                                              e0->twin()->source()->point()));    SNC_intersection is(*this->sncp());    Segment_3 s(Segment_3(e0->source()->point(),e0->twin()->source()->point()));    Halfedge_iterator e;    CGAL_forall_edges( e, *this->sncp()) {#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);        CGAL_NEF_TRACEN("edge intersects edge "<< Segment_3(e->source()->point(),                                                   e->twin()->source()->point()) <<" on "<<q);        call_back( e0, Object_handle(e), q);      }    }    TIMER(it_t.stop());  }  virtual void intersect_with_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: "<< Segment_3(e0->source()->point(),                                              e0->twin()->source()->point()));    SNC_intersection is(*this->sncp());    Segment_3 s(Segment_3(e0->source()->point(),                          e0->twin()->source()->point()));    Halffacet_iterator f;    CGAL_forall_facets( f, *this->sncp()) {#ifdef CGAL_NEF3_DUMP_STATISTICS      ++number_of_intersection_candidates;#endif      Point_3 q;      if( is.does_intersect_internally( s, f, q) ) {        q = normalized(q);        CGAL_NEF_TRACEN("edge intersects facet on plane "<<plane(f)<<" on "<<q);        call_back( e0, Object_handle(f), q);      }    }    TIMER(it_t.stop());  }private:  bool initialized;};*/CGAL_END_NAMESPACE#endif // SNC_POINT_LOCATOR_H

⌨️ 快捷键说明

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