sphere_map.h
来自「CGAL is a collaborative effort of severa」· C头文件 代码 · 共 579 行 · 第 1/2 页
H
579 行
void reset_sm_object_list(Object_list& L) { Object_iterator oit; CGAL_forall_iterators(oit,L) reset_sm_iterator_hash(oit); L.clear(); } /*{\Moperations 2.5 3}*/ // The constant iterators and circulators. SVertex_const_iterator svertices_begin() const { return svertices_.begin();} SVertex_const_iterator svertices_end() const { return svertices_.end();} SHalfedge_const_iterator shalfedges_begin() const { return sedges_.begin();} SHalfedge_const_iterator shalfedges_end() const { return sedges_.end();} SHalfloop_const_iterator shalfloops_begin() const { return shalfloop_; } SHalfloop_const_iterator shalfloops_end() const { return shalfloop_ != 0 ? shalfloop_+2 : shalfloop_; } SFace_const_iterator sfaces_begin() const { return sfaces_.begin();} SFace_const_iterator sfaces_end() const { return sfaces_.end();} SVertex_iterator svertices_begin() { return svertices_.begin();} SVertex_iterator svertices_end() { return svertices_.end();} SHalfedge_iterator shalfedges_begin() { return sedges_.begin();} SHalfedge_iterator shalfedges_end() { return sedges_.end();} SHalfloop_iterator shalfloops_begin() { return shalfloop_; } SHalfloop_iterator shalfloops_end() { return shalfloop_ != 0 ? shalfloop_+2 : shalfloop_; } SFace_iterator sfaces_begin() { return sfaces_.begin();} SFace_iterator sfaces_end() { return sfaces_.end();} SFace_cycle_const_iterator sface_cycles_begin(SFace_const_handle f) const { return f->sface_cycles_begin(); } SFace_cycle_const_iterator sface_cycles_end(SFace_const_handle f) const { return f->sface_cycles_end(); } SFace_cycle_iterator sface_cycles_begin(SFace_handle f) const { return f->sface_cycles_begin(); } SFace_cycle_iterator sface_cycles_end(SFace_handle f) const { return f->sface_cycles_end(); } /*{\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 vertices_begin()/vertices_end()|\\ |SHalfedge_iterator halfedges_begin()/halfedges_end()|\\ |SHalfloop_iterator halfloops_begin()/halfloops_end()|\\ |SFace_iterator faces_begin()/faces_end()| */ Size_type number_of_svertices() const { return svertices_.size();} /*{\Mop returns the number of vertices.}*/ Size_type number_of_shalfedges() const { return sedges_.size();} /*{\Mop returns the number of (directed edges).}*/ Size_type number_of_sfaces() const { return sfaces_.size();} /*{\Mop returns the number of facets.}*/ Size_type number_of_shalfloops() const { return shalfloop_!=SHalfloop_handle() ? 2 : 0; } /*{\Mop returns the number of shalfloop.}*/ bool empty() const { return number_of_svertices() == 0 && number_of_shalfedges() == 0 && number_of_shalfloops() == 0 && number_of_sfaces() == 0; } bool has_shalfloop() const { return shalfloop_ != 0; } SHalfloop_handle& shalfloop() { return shalfloop_; } SHalfloop_const_handle shalfloop() const { return shalfloop_; } SVertex_alloc vertex_allocator; SVertex* get_vertex_node( const SVertex& t) { SVertex* p = vertex_allocator.allocate(1); vertex_allocator.construct( p, SVertex()); return p; } void put_vertex_node( SVertex* p) { vertex_allocator.destroy(p); vertex_allocator.deallocate( p, 1); } SHalfedge_alloc halfedge_allocator; SHalfedge* get_halfedge_node( const SHalfedge& t) { SHalfedge* p = halfedge_allocator.allocate(1); halfedge_allocator.construct( p, SHalfedge()); return p; } void put_halfedge_node( SHalfedge* p) { halfedge_allocator.destroy(p); halfedge_allocator.deallocate( p, 1); } SFace_alloc face_allocator; SFace* get_face_node( const SFace& t) { SFace* p = face_allocator.allocate(1); face_allocator.construct( p, SFace()); return p; } void put_face_node( SFace* p) { face_allocator.destroy(p); face_allocator.deallocate( p, 1); } SVertex_handle new_svertex(const Sphere_point& p, Mark m = Mark()) /*{\Mop returns a new vertex at point |p| marked by |m|.}*/ { SVertex_handle vh = new_svertex(); vh->point() = p; vh->mark() = m; CGAL_NEF_TRACEN("new_svertex "<<&*vh); return vh; } template <typename H> void make_twins(H h1, H h2) { h1->twin() = h2; h2->twin() = h1; } SVertex_handle new_svertex() { svertices_.push_back( * get_vertex_node(SVertex())); return --svertices_end(); } SFace_handle new_sface() { sfaces_.push_back( * get_face_node(SFace())); return --sfaces_end(); } SHalfedge_handle new_shalfedge_pair() { SHalfedge* ep2 = get_halfedge_node(SHalfedge()); SHalfedge* ep1 = get_halfedge_node(SHalfedge()); sedges_.push_back( *ep1 ); SHalfedge_handle e1 = --shalfedges_end(); sedges_.push_back( *ep2 ); SHalfedge_handle e2 = --shalfedges_end(); make_twins(e1,e2); return e1; } SHalfloop_handle new_shalfloop_pair() { SHalfloop_handle ph = new SHalfloop[2]; SHalfloop* pt(ph); ++pt; make_twins(ph,pt); shalfloop_=ph; return ph; } SHalfedge_handle new_shalfedge_pair(const SHalfedge& e1) { const SHalfedge& e2 = *(e1.twin()); SHalfedge* ep2 = new SHalfedge[2]; SHalfedge* ep1 = ep2++; *ep1=e1; *ep2=e2; sedges_.push_back( *ep1 ); SHalfedge_handle eh1 = --shalfedges_end(); sedges_.push_back( *ep2 ); SHalfedge_handle eh2 = --shalfedges_end(); make_twins(eh1,eh2); return eh1; } SHalfloop_handle new_shalfloop_pair(const SHalfloop& l1) { const SHalfloop& l2 = *(l1.twin()); SHalfloop* ph = new SHalfloop[2]; SHalfloop* pt(ph); ++pt; *ph=l1; *pt=l2; make_twins(ph,pt); shalfloop_=ph; return ph; } void delete_svertex(SVertex_handle h) { svertices_.erase(h); put_vertex_node(&*h); } void delete_sface(SFace_handle h) { sfaces_.erase(h); put_face_node(&*h); } void delete_shalfedge_pair(SHalfedge_handle h) { SHalfedge_handle t = h->twin(); sedges_.erase(h); sedges_.erase(t); put_halfedge_node(&*h); put_halfedge_node(&*t); } void delete_shalfloop_pair() { CGAL_assertion(has_shalfloop()); SHalfloop* ph = &*shalfloop_; SHalfloop* pt = &*shalfloop_->twin(); if ( ph > pt ) std::swap(ph,pt); shalfloop_ = SHalfloop_handle(); delete [] ph; }protected: void pointer_update(const Self& D); Handle_to_iterator_map boundary_item_; static Object_iterator undef_; SVertex_list svertices_; SHalfedge_list sedges_; SFace_list sfaces_; SHalfloop_iterator shalfloop_;}; // Sphere_maptemplate <typename K, typename I, typename M>void Sphere_map<K, I, M>::pointer_update(const Sphere_map<K, I, M>& D){ CGAL::Unique_hash_map<SVertex_const_handle,SVertex_handle> VM; CGAL::Unique_hash_map<SHalfedge_const_handle,SHalfedge_handle> EM; CGAL::Unique_hash_map<SHalfloop_const_handle,SHalfloop_handle> LM; CGAL::Unique_hash_map<SFace_const_handle,SFace_handle> FM; SVertex_const_iterator vc = D.svertices_begin(); SVertex_iterator v = svertices_begin(); for ( ; vc != D.svertices_end(); ++vc,++v) VM[vc] = v; VM[D.svertices_end()] = svertices_end(); SHalfedge_const_iterator ec = D.shalfedges_begin(); SHalfedge_iterator e = shalfedges_begin(); for ( ; ec != D.shalfedges_end(); ++ec,++e) { EM[ec] = e; e->mark() = ec->mark(); } EM[D.shalfedges_end()] = shalfedges_end(); SFace_const_iterator fc = D.sfaces_begin(); SFace_iterator f = sfaces_begin(); for ( ; fc != D.sfaces_end(); ++fc,++f) FM[fc] = f; FM[D.sfaces_end()] = sfaces_end(); SHalfloop_iterator l; if ( D.shalfloop_ != 0 ) { LM[D.shalfloop_] = shalfloop_; LM[D.shalfloop_->twin()] = shalfloop_->twin(); l = shalfloop(); shalfloop_->mark() = D.shalfloop()->mark(); shalfloop_->twin()->mark() = D.shalfloop()->twin()->mark(); if( !l->is_twin() && D.shalfloop()->is_twin()) l->mark() = l->twin()->mark(); } for (v = svertices_begin(); v != svertices_end(); ++v) { // Local Graph update: (SVertices are postponed/updated as Edges) v->out_sedge() = EM[v->out_sedge()]; v->incident_sface() = FM[v->incident_sface()]; } // Edge update: for (e = shalfedges_begin(); e != shalfedges_end(); ++e) { e->twin() = EM[e->twin()]; e->sprev() = EM[e->sprev()]; e->snext() = EM[e->snext()]; e->source() = VM[e->source()]; e->incident_sface() = FM[e->incident_sface()]; } for ( ec = D.shalfedges_begin(), e = shalfedges_begin(); ec != D.shalfedges_end(); ++ec, ++e) { if( !e->is_twin() && ec->is_twin()) e->mark() = e->twin()->mark(); } for (l = shalfloops_begin(); l != shalfloops_end(); ++l) { // l->twin() = LM[l->twin()]; l->incident_sface() = FM[l->incident_sface()]; } for (f = sfaces_begin(); f != sfaces_end(); ++f) { SFace_cycle_iterator fci; for(fci = f->boundary_entry_objects().begin(); fci != f->boundary_entry_objects().end(); ++fci) { if ( fci.is_svertex() ) { v = SVertex_handle(fci); *fci = Object_handle(VM[v]); store_sm_boundary_item(v,fci); } else if ( fci.is_shalfedge() ) { e = SHalfedge_handle(fci); *fci = Object_handle(EM[e]); store_sm_boundary_item(e,fci); } else if ( fci.is_shalfloop() ) { l = SHalfloop_handle(fci); *fci = Object_handle(LM[l]); store_sm_boundary_item(l,fci); } else CGAL_assertion_msg(0,"damn wrong boundary item in face."); } }}template <typename Kernel_, typename Items_, typename Mark_> typename Sphere_map<Kernel_, Items_, Mark_>::Object_iteratorSphere_map<Kernel_, Items_, Mark_>::undef_;CGAL_END_NAMESPACE#endif // CGAL_SPHERE_MAP_H
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?