📄 snc_structure.h
字号:
bool is_boundary_object(H h) { return boundary_item_[h]!=boost::none; } template <typename H> bool is_sm_boundary_object(H h) { return sm_boundary_item_[h]!=boost::none; } template <typename H> Object_iterator& boundary_item(H h) { return *boundary_item_[h]; } template <typename H> Object_iterator& sm_boundary_item(H h) { return *sm_boundary_item_[h]; } template <typename H> void store_boundary_item(H h, Object_iterator o) { boundary_item_[h] = o; } template <typename H> void store_sm_boundary_item(H h, Object_iterator o) { sm_boundary_item_[h] = o; } template <typename H> void undef_boundary_item(H h) { CGAL_assertion(boundary_item_[h]!=boost::none); boundary_item_[h] = boost::none; } template <typename H> void undef_sm_boundary_item(H h) { CGAL_assertion(sm_boundary_item_[h]!=boost::none); sm_boundary_item_[h] = boost::none; } void reset_iterator_hash(Object_iterator it) { SVertex_handle sv; SHalfedge_handle se; SHalfloop_handle sl; if ( CGAL::assign(se,*it) ) { if( is_boundary_object(se)) undef_boundary_item(se); return; } if ( CGAL::assign(sl,*it) ) { if( is_boundary_object(sl)) undef_boundary_item(sl); return; } if ( CGAL::assign(sv,*it) ) { if( is_boundary_object(sv)) undef_boundary_item(sv); return; } } void reset_sm_object_list(Object_list& L) { Object_iterator oit; CGAL_forall_iterators(oit,L) reset_sm_iterator_hash(oit); L.clear(); } void reset_sm_iterator_hash(Object_iterator it) { SVertex_handle sv; SHalfedge_handle se; SHalfloop_handle sl; if ( CGAL::assign(se,*it) ) { if( is_sm_boundary_object(se)) undef_sm_boundary_item(se); return; } if ( CGAL::assign(sl,*it) ) { if( is_sm_boundary_object(sl)) undef_sm_boundary_item(sl); return; } if ( CGAL::assign(sv,*it) ) { if( is_sm_boundary_object(sv)) undef_sm_boundary_item(sv); return; } } void reset_object_list(Object_list& L) { Object_iterator oit; CGAL_forall_iterators(oit,L) reset_iterator_hash(oit); L.clear(); } /*{\Moperations 2.5 3}*/ // The constant iterators and circulators. Vertex_const_iterator vertices_begin() const { return vertices_.begin();} Vertex_const_iterator vertices_end() const { return vertices_.end();} Halfedge_const_iterator halfedges_begin() const { return halfedges_.begin();} Halfedge_const_iterator halfedges_end() const { return halfedges_.end();} Halffacet_const_iterator halffacets_begin() const { return halffacets_.begin();} Halffacet_const_iterator halffacets_end() const { return halffacets_.end();} Volume_const_iterator volumes_begin() const { return volumes_.begin();} Volume_const_iterator volumes_end() const { return volumes_.end();} SVertex_const_iterator svertices_begin() const { return halfedges_.begin();} SVertex_const_iterator svertices_end() const { return halfedges_.end();} SHalfedge_const_iterator shalfedges_begin() const { return shalfedges_.begin();} SHalfedge_const_iterator shalfedges_end() const { return shalfedges_.end();} SHalfloop_const_iterator shalfloops_begin() const { return shalfloops_.begin();} SHalfloop_const_iterator shalfloops_end() const { return shalfloops_.end();} SFace_const_iterator sfaces_begin() const { return sfaces_.begin();} SFace_const_iterator sfaces_end() const { return sfaces_.end();} Vertex_iterator vertices_begin() { return vertices_.begin();} Vertex_iterator vertices_end() { return vertices_.end();} Halfedge_iterator halfedges_begin() { return halfedges_.begin();} Halfedge_iterator halfedges_end() { return halfedges_.end();} Halffacet_iterator halffacets_begin() { return halffacets_.begin();} Halffacet_iterator halffacets_end() { return halffacets_.end();} Volume_iterator volumes_begin() { return volumes_.begin();} Volume_iterator volumes_end() { return volumes_.end();} SVertex_iterator svertices_begin() { return halfedges_.begin();} SVertex_iterator svertices_end() { return halfedges_.end();} SHalfedge_iterator shalfedges_begin() { return shalfedges_.begin();} SHalfedge_iterator shalfedges_end() { return shalfedges_.end();} SHalfloop_iterator shalfloops_begin() { return shalfloops_.begin();} SHalfloop_iterator shalfloops_end() { return shalfloops_.end();} SFace_iterator sfaces_begin() { return sfaces_.begin();} SFace_iterator sfaces_end() { return sfaces_.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:\\ |Vertex_iterator vertices_begin()/vertices_end()|\\ |Halfedge_iterator halfedges_begin()/halfedges_end()|\\ |Halffacet_iterator halffacets_begin()/halffacets_end()|\\ |Volume_iterator volumes_begin()/volumes_end()| The macros are then |CGAL_forall_vertices(v,\Mvar)|, |CGAL_forall_halfedges(e,\Mvar)|, |CGAL_forall_edges(e,\Mvar)|, |CGAL_forall_halffacets(f,\Mvar)|, |CGAL_forall_facets(f,\Mvar)|, |CGAL_forall_volumes(w,\Mvar)|.}*/ Size_type number_of_vertices() const { return vertices_.size(); } /*{\Mop returns the number of vertices.}*/ Size_type number_of_halfedges() const { return halfedges_.size(); } /*{\Mop returns the number of (directed edges).}*/ Size_type number_of_edges() const { return halfedges_.size()/2; } /*{\Mop returns the number of (directed edges).}*/ Size_type number_of_halffacets() const { return halffacets_.size();} /*{\Mop returns the number of halffacets.}*/ Size_type number_of_facets() const { return halffacets_.size()/2;} /*{\Mop returns the number of facets.}*/ Size_type number_of_volumes() const { return volumes_.size();} /*{\Mop returns the number of volumes.}*/ Size_type number_of_svertices() const { return halfedges_.size();} /*{\Mop returns the number of svertices.}*/ Size_type number_of_shalfedges() const { return shalfedges_.size();} /*{\Mop returns the number of sedges.}*/ Size_type number_of_shalfloops() const { return shalfloops_.size();} /*{\Mop returns the number of sloops.}*/ Size_type number_of_sfaces() const { return sfaces_.size();} /*{\Mop returns the number of sfaces.}*/ void print_statistics(std::ostream& os = std::cout) const /*{\Mop print the statistics of |P|: the number of vertices, edges, faces, volumes and sobjects.}*/ { os << "Selective Nef Complex - Statistics\n"; os << "|V| = " << number_of_vertices() << std::endl; os << "|E| = " << number_of_halfedges() << std::endl; os << "|F| = " << number_of_halffacets() << std::endl; os << "|C| = " << number_of_volumes() << std::endl; os << "|VS| = " << number_of_svertices() << std::endl; os << "|ES| = " << number_of_shalfedges() << std::endl; os << "|LS| = " << number_of_shalfloops() << std::endl; os << "|FS| = " << number_of_sfaces() << std::endl; os << std::endl; } bool is_empty() const { /*{\Mop returns true if |\Mvar| is empty, false otherwise.}*/ return number_of_vertices() == 0 && number_of_halfedges() == 0 && number_of_halffacets() == 0 && number_of_volumes() == 0 && number_of_shalfedges() == 0 && number_of_shalfloops() == 0 && number_of_sfaces() == 0; } bool has_bbox_only() const { /*{\Mop returns true if |\Mvar| is only the infimaximal box, false otherwise.}*/ return (number_of_vertices() == 8 && number_of_edges() == 12 && number_of_facets() == 6 && number_of_volumes() == 2 && (++volumes_begin())->mark() == false); } Vertex_handle new_vertex(const Point_3& p = Point_3(), Mark m = Mark()) /*{\Mop returns a new vertex at point |p| marked by |m|.}*/ { Vertex_handle vh = new_vertex_only(); vh->point() = p; vh->mark() = m; vh->sncp() = this; vh->svertices_begin() = vh->svertices_last() = svertices_end(); vh->shalfedges_begin() = vh->shalfedges_last() = shalfedges_end(); vh->sfaces_begin() = vh->sfaces_last() = sfaces_end(); vh->shalfloop() = shalfloops_end(); return vh; } Halfedge_handle new_halfedge_pair(Vertex_handle v1, Vertex_handle v2, Mark m = Mark()) /*{\Mop creates a new halfedge pair between the vertices $v_1$ and $v_2$. The edge is marked by |m|.}*/ { SM_decorator D1(&*v1); SM_decorator D2(&*v2); SVertex_handle e1 = D1.new_vertex(); SVertex_handle e2 = D2.new_vertex(); make_twins(e1,e2); e1->mark() = m; return e1; } Halffacet_handle new_halffacet_pair(const Plane_3& h = Plane_3(), Mark m = Mark()) /*{\Mop creates a new facet supported by the plane |h| and marked with |m|.}*/ { Halffacet_handle f1 = new_halffacet_only(); Halffacet_handle f2 = new_halffacet_only(); f1->plane() = h; f2->plane() = h.opposite(); make_twins(f1,f2); f1->mark() = f2->mark() = m; return f1; } Volume_handle new_volume(Mark m = Mark()) /*{\Mop creates a new volume marked with |m|.}*/ { Volume_handle vh = new_volume_only(); vh->mark() = m; return vh; } template <typename H> void make_twins(H h1, H h2) { h1->twin() = h2; h2->twin() = h1; } void delete_vertex(Vertex_handle v) /*{\Mop deletes the vertex including the objects in its local graph.}*/ { CGAL_NEF_TRACEN("~ deleting vertex "<<&*v<<" from "<<&*this); v->clear(true); delete_vertex_only(v); CGAL_NEF_TRACEN("~~ vertex deleted"<<&*v); } void delete_halfedge_pair(Halfedge_handle e) /*{\Mop deletes the halfedge pair of |e,twin(e)|. Does not care about incident objects in the local graph of |source(e)|.}*/ { CGAL_NEF_TRACEN("~ deleting halfedges pair "<<&*e<<", "<<&*(e->twin())<< " from "<<&*this); Halfedge_handle et = e->twin(); SM_decorator D1(&*e->center_vertex()), D2(&*et->center_vertex()); D1.delete_vertex(e); D2.delete_vertex(et); } void delete_halffacet_pair(Halffacet_handle f) /*{\Mop deletes the halffacet pair |f,twin(f)|. Does not care about boundary cycle objects.}*/ { CGAL_NEF_TRACEN("~ deleting halffacets pair "<<&*f<<", "<<&*(f->twin())<< " from "<<&*this); reset_object_list(f->boundary_entry_objects()); reset_object_list(f->twin()->boundary_entry_objects()); delete_halffacet_only(f->twin()); delete_halffacet_only(f); } void delete_volume(Volume_handle c) /*{\Mop deletes the volume |c|. Does not care about shell objects.}*/ { CGAL_NEF_TRACEN("~ deleting volume "<<&*c<<" from "<<&*this); reset_object_list(c->shell_entry_objects()); delete_volume_only(c); } Vertex_alloc vertex_allocator; Vertex* get_vertex_node( const Vertex& ) { Vertex* p = vertex_allocator.allocate(1); vertex_allocator.construct( p, Vertex()); return p; } void put_vertex_node( Vertex* p) { vertex_allocator.destroy(p); vertex_allocator.deallocate( p, 1); } Halfedge_alloc halfedge_allocator; Halfedge* get_halfedge_node( const Halfedge&) { Halfedge* p = halfedge_allocator.allocate(1); halfedge_allocator.construct( p, Halfedge()); return p; } void put_halfedge_node( Halfedge* p) { halfedge_allocator.destroy(p); halfedge_allocator.deallocate( p, 1); } Halffacet_alloc halffacet_allocator; Halffacet* get_halffacet_node( const Halffacet& ) { Halffacet* p = halffacet_allocator.allocate(1); halffacet_allocator.construct( p, Halffacet()); return p; } void put_halffacet_node( Halffacet* p) { halffacet_allocator.destroy(p); halffacet_allocator.deallocate( p, 1); } Volume_alloc volume_allocator; Volume* get_volume_node( const Volume& ) { Volume* p = volume_allocator.allocate(1); volume_allocator.construct( p, Volume()); return p; } void put_volume_node( Volume* p) { volume_allocator.destroy(p); volume_allocator.deallocate( p, 1); } SHalfedge_alloc shalfedge_allocator; SHalfedge* get_shalfedge_node( const SHalfedge& ) { SHalfedge* p = shalfedge_allocator.allocate(1); shalfedge_allocator.construct( p, SHalfedge()); return p; } void put_shalfedge_node( SHalfedge* p) { shalfedge_allocator.destroy(p); shalfedge_allocator.deallocate( p, 1); } SHalfloop_alloc shalfloop_allocator; SHalfloop* get_shalfloop_node( const SHalfloop& ) { SHalfloop* p = shalfloop_allocator.allocate(1); shalfloop_allocator.construct( p, SHalfloop()); return p; } void put_shalfloop_node( SHalfloop* p) { shalfloop_allocator.destroy(p); shalfloop_allocator.deallocate( p, 1); } SFace_alloc sface_allocator; SFace* get_sface_node( const SFace& ) { SFace* p = sface_allocator.allocate(1); sface_allocator.construct( p, SFace()); return p; } void put_sface_node( SFace* p) { sface_allocator.destroy(p); sface_allocator.deallocate( p, 1); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -