sm_const_decorator.h
来自「CGAL is a collaborative effort of severa」· C头文件 代码 · 共 482 行 · 第 1/2 页
H
482 行
Size_type number_of_shalfedges() const /*{\Mop returns the number of halfedges.}*/{ return psm_->number_of_shalfedges(); }Size_type number_of_sedges() const /*{\Mop returns the number of edges.}*/{ return number_of_shalfedges()/2; }Size_type number_of_shalfloops() const /*{\Mop returns the number of halfloops.}*/{ return psm_->number_of_shalfloops(); }Size_type number_of_sloops() const /*{\Mop returns the number of loops.}*/{ return psm_->number_of_shalfloops()/2; }Size_type number_of_sfaces() const /*{\Mop returns the number of faces.}*/{ return psm_->number_of_sfaces(); }Size_type number_of_sface_cycles() const;/*{\Mop returns the number of face cycles.}*/Size_type number_of_connected_components() const;/*{\Mop calculates the number of connected components of |P|.}*/void print_statistics(std::ostream& os = std::cout) const/*{\Mop print the statistics of |P|: the number of vertices, edges, and faces.}*/{ os << "Sphere Map - Statistics\n"; os << "|V| = " << number_of_svertices() << std::endl; os << "|E| = " << number_of_shalfedges() << std::endl; os << "|L| = " << number_of_shalfloops() << std::endl; os << "|F| = " << number_of_sfaces() << std::endl; os << "|Fcs| = " << number_of_sface_cycles() << std::endl << std::endl;} void check_integrity_and_topological_planarity(bool faces=true) const;/*{\Mop checks the link structure and the genus of |P|.}*/SHalfedge_const_handle cas(SHalfedge_const_handle e) const { return cyclic_adj_succ(e); } SHalfedge_const_handle cap(SHalfedge_const_handle e) const{ return cyclic_adj_pred(e); }template <typename H>bool is_sm_boundary_object(H h) const{ return psm_->is_sm_boundary_object(h); }/*{\Mtext \headerline{Associated Information}\restoreopdims}*/const Sphere_point& point(SVertex_const_handle v) const/*{\Mop returns the embedding of |v|.}*/{ return v->point(); }const Sphere_circle& circle(SHalfedge_const_handle e) const/*{\Mop returns the circle supporting |e|.}*/{ return e->circle(); }const Sphere_circle& circle(SHalfloop_const_handle l) const/*{\Mop returns the circle supporting |l|.}*/{ return l->circle(); }const Mark& mark(SVertex_const_handle v) const/*{\Mop returns the mark of |v|.}*/{ return v->mark(); }const Mark& mark(SHalfedge_const_handle e) const/*{\Mop returns the mark of |e|.}*/{ return e->mark(); }const Mark& mark(SHalfloop_const_handle l) const/*{\Mop returns the mark of |l|.}*/{ return ( &*l < &*twin(l) ) ? l->mark() : twin(l)->mark(); }const Mark& mark(SFace_const_handle f) const/*{\Mop returns the mark of |f|.}*/{ return f->mark(); }/*{\Mtext \headerline{Iteration}}*//*{\Mtext The list of all objects can be accessed via iterator ranges.For comfortable iteration we also provide iterations macros. The iterator range access operations are of the following kind:\\|SVertex_iterator svertices_begin()/svertices_end()|\\|SHalfedge_iterator shalfedges_begin()/shalfedges_end()|\\|SHalfloop_iterator shalfloops_begin()/shalfloops_end()|\\|SFace_iterator sfaces_begin()/sfaces_end()|The macros are then |CGAL_forall_svertices(v,M)|,|CGAL_forall_shalfedges(e,M)|, |CGAL_forall_sedges(e,M)|,|CGAL_forall_sfaces(f,M)|, |CGAL_forall_sface_cycles_of(fc,F)|where |M| is a sphere map and |F| is a sface.}*/}; // SM_const_decoratortemplate <typename SM_>void SM_const_decorator<SM_>::check_integrity_and_topological_planarity(bool faces) const{ CGAL_NEF_TRACEN("check_integrity_and_topological_planarity:"); using CGAL::Object_index; Object_index<SVertex_const_iterator> VI(svertices_begin(),svertices_end(),'v'); Object_index<SHalfedge_const_iterator> EI(shalfedges_begin(),shalfedges_end(),'e'); Object_index<SFace_const_iterator> FI(sfaces_begin(),sfaces_end(),'f'); typedef SHalfedge_around_svertex_const_circulator hvc_circulator; typedef SHalfedge_around_sface_const_circulator hfc_circulator; SVertex_const_handle v; int iso_vert_num=0; /* check the source links of out edges and count isolated vertices */ CGAL_forall_svertices(v,*this) { if ( is_isolated(v) ) { if ( faces ) CGAL_assertion_msg(face(v) != SFace_const_handle(), VI(v).c_str()); ++iso_vert_num; } else { CGAL_assertion_msg(first_out_edge(v) != SHalfedge_const_handle(), VI(v).c_str()); CGAL_NEF_TRACEN(point(v)<<" "<<EI(first_out_edge(v))); CGAL_assertion_msg(source(first_out_edge(v)) == v, VI(v).c_str()); } } /* check the bidirected links and the face pointer init */ SHalfedge_const_iterator e; CGAL_forall_shalfedges(e,*this) { CGAL_assertion( twin(twin(e)) == e ); CGAL_assertion( source(e) != SVertex_const_handle() ); CGAL_assertion( next(e) != SHalfedge_const_handle() ); CGAL_assertion( previous(next(e)) == e ); CGAL_assertion( target(e) == source(next(e)) ); CGAL_assertion( previous(e) != SHalfedge_const_handle() ); CGAL_assertion( next(previous(e)) == e ); CGAL_assertion( target(previous(e)) == source(e) ); if ( !faces ) continue; CGAL_assertion( face(e) != SFace_const_handle() ); CGAL_assertion( face(next(e)) == face(e) ); CGAL_assertion( face(previous(e)) == face(e) ); } int fc_num(0),iv_num(0); SFace_const_iterator f; SFace_cycle_const_iterator fci; CGAL_forall_sfaces(f,*this) { CGAL_forall_sface_cycles_of(fci,f) { if ( fci.is_shalfedge() ) { CGAL_assertion( face(SHalfedge_const_handle(fci)) == f ); ++fc_num; } else if ( fci.is_svertex() ) { CGAL_assertion( face(SVertex_const_handle(fci)) == f ); ++iv_num; } else if( fci.is_shalfloop() ) { CGAL_assertion( face(SHalfloop_const_handle(fci)) == f ); ++fc_num; } else CGAL_assertion_msg(0,"damn generic handle."); } } CGAL_assertion_code(int v_num = number_of_svertices() - iso_vert_num + number_of_shalfloops()); CGAL_assertion_code(int e_num = number_of_sedges() + number_of_shalfloops()); CGAL_assertion_code(int c_num = number_of_connected_components() - iso_vert_num + number_of_sloops()); CGAL_assertion_code(int f_num = number_of_sface_cycles() - c_num + 1); CGAL_assertion_code(CGAL_NEF_TRACEV(fc_num)); CGAL_assertion_code(CGAL_NEF_TRACEV(iv_num)); CGAL_assertion_code(CGAL_NEF_TRACEV(iso_vert_num)); CGAL_assertion_code(CGAL_NEF_TRACEV(v_num)); CGAL_assertion_code(CGAL_NEF_TRACEV(e_num)); CGAL_assertion_code(CGAL_NEF_TRACEV(c_num)); CGAL_assertion_code(CGAL_NEF_TRACEV(f_num)); /* this means all face cycles and all isolated vertices are indeed referenced from a face */ /* every isolated vertex increases the component count one face cycle per component is redundent except one finally check the Euler formula: */ CGAL_assertion( v_num - e_num + f_num == 1 + c_num );}template <typename SM_>typename SM_const_decorator<SM_>::Size_typeSM_const_decorator<SM_>::number_of_sface_cycles() const{ unsigned int fc_num=0; CGAL::Unique_hash_map<SHalfedge_const_handle,bool> visited; SHalfedge_const_iterator e; CGAL_forall_shalfedges(e,*this) { if (visited[e]) continue; SHalfedge_around_sface_const_circulator hfc(e), hend(hfc); CGAL_For_all(hfc,hend) visited[hfc]=true; ++fc_num; } if ( has_shalfloop() ) fc_num += 2; return fc_num;}template <typename SM_>typename SM_const_decorator<SM_>::Size_typeSM_const_decorator<SM_>::number_of_connected_components() const{ int comp_num=0; CGAL::Unique_hash_map<SVertex_const_iterator,bool> visited(false); SVertex_const_iterator v; CGAL_forall_svertices(v,*this) { if (visited[v]) continue; std::list<SVertex_const_iterator> L; L.push_back(v); visited[v]=true; /* we keep the invariant that all nodes which have been stacked are marked visited */ while (!L.empty()) { SVertex_const_iterator vc = L.front(); L.pop_front(); if ( is_isolated(vc) ) continue; SHalfedge_around_svertex_const_circulator havc(first_out_edge(vc)), hend(havc); CGAL_For_all(havc,hend) { if (!visited[target(havc)]) { L.push_back(target(havc)); visited[target(havc)]=true; } } } ++comp_num; } return comp_num; }CGAL_END_NAMESPACE#endif // CGAL_SM_CONST_DECORATOR_H
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?