📄 snc_structure.h
字号:
// Copyright (c) 1997-2002 Max-Planck-Institute Saarbruecken (Germany).// All rights reserved.//// This file is part of CGAL (www.cgal.org); you may redistribute it under// the terms of the Q Public License version 1.0.// See the file LICENSE.QPL distributed with CGAL.//// Licensees holding a valid commercial license may use this file in// accordance with the commercial license agreement provided with the software.//// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.//// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.3-branch/Nef_3/include/CGAL/Nef_3/SNC_structure.h $// $Id: SNC_structure.h 37422 2007-03-23 18:18:36Z hachenb $// //// Author(s) : Michael Seel <seel@mpi-sb.mpg.de>// Miguel Granados <granados@mpi-sb.mpg.de>// Susan Hert <hert@mpi-sb.mpg.de>// Lutz Kettner <kettner@mpi-sb.mpg.de>#ifndef CGAL_SNC_STRUCTURE_H#define CGAL_SNC_STRUCTURE_H#include <CGAL/basic.h>#include <CGAL/Unique_hash_map.h>#include <CGAL/In_place_list.h>#include <CGAL/Nef_S2/Generic_handle_map.h>#include <CGAL/Nef_2/Object_handle.h>#include <CGAL/Nef_3/SNC_iteration.h>#include <CGAL/Nef_2/iterator_tools.h>#include <CGAL/Nef_S2/Sphere_geometry.h>#ifdef CGAL_NEF3_FACET_WITH_BOX#include <CGAL/Box_intersection_d/Box_d.h>#endif#include <list>#undef CGAL_NEF_DEBUG#define CGAL_NEF_DEBUG 41#include <CGAL/Nef_2/debug.h>#include <CGAL/Nef_2/Object_index.h>#include <boost/optional.hpp>#include <boost/none.hpp>CGAL_BEGIN_NAMESPACEtemplate <typename HE>struct move_shalfedge_around_facet { void forward(HE& e) const { e = (e->next()); } void backward(HE& e) const { e = (e->prev()); }};template <class Object, class Hash_map, class Union_find>void merge_sets( Object o1, Object o2, Hash_map& hash, Union_find& uf) { //CGAL_assertion( hash[o1] != 0 && hash[o2] != 0); CGAL_assertion( hash.is_defined(o1) && hash.is_defined(o2)); if( !uf.same_set( hash[o1], hash[o2])) uf.unify_sets( hash[o1], hash[o2]);}template <typename K, typename I, typename M> class SNC_sphere_map;template <typename S> class SM_decorator;template <typename S> class SNC_decorator;/*{\Manpage {SNC_structure}{Items}{Selective Nef Complex}{C}}*/template <typename Kernel_, typename Items_, typename Mark_>class SNC_structure {/*{\Mdefinition The extended Wuerzburg structure is the topologicalstructure of Nef polyhedra. It is programmed around the localgraphs of the vertices of a Nef polyhedron, which describe thepoint set completely. All other concepts are either derived fromthe local graph or added for the comfort of the user.}*/public: /*{\Mtypes 7}*/ typedef Items_ Items; typedef Kernel_ Kernel; typedef Mark_ Mark; typedef SNC_structure<Kernel,Items,Mark> Self; // typedef bool Mark; typedef CGAL::SNC_decorator<Self> SNC_decorator; typedef typename Kernel::FT FT; typedef typename Kernel::RT RT; typedef CGAL::Sphere_geometry<Kernel> Sphere_kernel; typedef SNC_sphere_map<Kernel, Items, Mark> Sphere_map; typedef CGAL::SM_decorator<Sphere_map> SM_decorator; typedef typename Kernel::Point_3 Point_3; /*{\Mtypemember embedding vertices.}*/ typedef typename Kernel::Plane_3 Plane_3; /*{\Mtypemember supporting facets.}*/ typedef typename Kernel::Vector_3 Vector_3; /*{\Mtypemember normal vectors.}*/ typedef typename Kernel::Direction_3 Direction_3; /*{\Mtypemember normal directions.}*/ typedef typename Kernel::Segment_3 Segment_3; /*{\Mtypemember segments in space.}*/ typedef typename Kernel::Line_3 Line_3; /*{\Mtypemember lines in space.}*/ typedef typename Kernel::Ray_3 Ray_3; /*{\Mtypemember rays in space.}*/ typedef typename Kernel::Triangle_3 Triangle_3; /*{\Mtypemember triangles in space.}*/ typedef typename Kernel::Aff_transformation_3 Aff_transformation_3; typedef typename Sphere_kernel::Sphere_point Sphere_point; /*{\Mtypemember points on the unit sphere.}*/ typedef typename Sphere_kernel::Sphere_segment Sphere_segment; /*{\Mtypemember segments on the unit sphere.}*/ typedef typename Sphere_kernel::Sphere_circle Sphere_circle; /*{\Mtypemember segments on the unit sphere.}*/ typedef typename Sphere_kernel::Sphere_direction Sphere_direction; /*{\Mtypemember directions on the unit sphere.}*/ typedef size_t Size_type; /*{\Mtypemember size type.}*/ private: friend class CGAL::SM_decorator<Sphere_map>; friend class CGAL::SNC_decorator<Self>; /*{\Mtext For all objects |Vertex|, |Halfedge|, |Halffacet|, |Volume| there are handle and iterator types |xxx_handle|, |xxx_iterator|. Additionally all objects of the local graph of a vertex |SVertex|, |SHalfedge|, |SHalfloop|, |SFace| are accessed via handles and iterators. There's no type |SHalfloop_iterator|, as there is at most one |SLoop| pair per vertex.}*/#ifdef CGAL_NEF3_FACET_WITH_BOX template<class Refs> class Facet_with_box : public Items::template Halffacet<Refs> { public: typedef typename Items::template Halffacet<Refs> Halffacet; typedef typename Refs::FT FT; typedef typename Box_intersection_d::Box_d<FT,3> Box; Box b; Facet_with_box() : Halffacet(), b() {} Facet_with_box(const Plane_3& h, Mark m) : Halffacet(h,m) {} Facet_with_box(const Facet_with_box<Refs>& f) : Halffacet(f) { b = f.b; } Facet_with_box<Refs>& operator=(const Facet_with_box<Refs>& f) { (Halffacet) *this = (Halffacet) f; b = f.b; return *this; } };#endif public: typedef Sphere_map Vertex_base; typedef SNC_in_place_list_sm<Vertex_base> Vertex; typedef CGAL::In_place_list<Vertex,false> Vertex_list; typedef CGAL_ALLOCATOR(Vertex) Vertex_alloc; typedef typename Vertex_list::iterator Vertex_handle; typedef typename Vertex_list::const_iterator Vertex_const_handle; typedef typename Vertex_list::iterator Vertex_iterator; typedef typename Vertex_list::const_iterator Vertex_const_iterator;#ifdef CGAL_NEF3_FACET_WITH_BOX typedef Facet_with_box<SNC_structure> Halffacet_base;#else typedef typename Items::template Halffacet<SNC_structure> Halffacet_base;#endif typedef SNC_in_place_list_halffacet<Halffacet_base> Halffacet; typedef CGAL::In_place_list<Halffacet,false> Halffacet_list; typedef CGAL_ALLOCATOR(Halffacet) Halffacet_alloc; typedef typename Halffacet_list::iterator Halffacet_handle; typedef typename Halffacet_list::const_iterator Halffacet_const_handle; typedef typename Halffacet_list::iterator Halffacet_iterator; typedef typename Halffacet_list::const_iterator Halffacet_const_iterator; typedef typename Items::template Volume<SNC_structure> Volume_base; typedef SNC_in_place_list_volume<Volume_base> Volume; typedef CGAL::In_place_list<Volume,false> Volume_list; typedef CGAL_ALLOCATOR(Volume) Volume_alloc; typedef typename Volume_list::iterator Volume_handle; typedef typename Volume_list::const_iterator Volume_const_handle; typedef typename Volume_list::iterator Volume_iterator; typedef typename Volume_list::const_iterator Volume_const_iterator; typedef typename Items::template SVertex<SNC_structure> SVertex_base; typedef SNC_in_place_list_svertex<SVertex_base> SVertex; typedef CGAL::In_place_list<SVertex,false> SVertex_list; typedef CGAL_ALLOCATOR(SVertex) SVertex_alloc; typedef typename SVertex_list::iterator SVertex_handle; typedef typename SVertex_list::const_iterator SVertex_const_handle; typedef typename SVertex_list::iterator SVertex_iterator; typedef typename SVertex_list::const_iterator SVertex_const_iterator; typedef typename Items::template SVertex<SNC_structure> Halfedge_base; typedef SNC_in_place_list_svertex<SVertex_base> Halfedge; typedef CGAL::In_place_list<SVertex,false> Halfedge_list; typedef CGAL_ALLOCATOR(SVertex) Halfedge_alloc; typedef typename SVertex_list::iterator Halfedge_handle; typedef typename SVertex_list::const_iterator Halfedge_const_handle; typedef typename SVertex_list::iterator Halfedge_iterator; typedef typename SVertex_list::const_iterator Halfedge_const_iterator; typedef typename Items::template SHalfedge<SNC_structure> SHalfedge_base; typedef SNC_in_place_list_shalfedge<SHalfedge_base> SHalfedge; typedef CGAL::In_place_list<SHalfedge,false> SHalfedge_list; typedef CGAL_ALLOCATOR(SHalfedge) SHalfedge_alloc; typedef typename SHalfedge_list::iterator SHalfedge_handle; typedef typename SHalfedge_list::const_iterator SHalfedge_const_handle; typedef typename SHalfedge_list::iterator SHalfedge_iterator; typedef typename SHalfedge_list::const_iterator SHalfedge_const_iterator; typedef typename Items::template SHalfloop<SNC_structure> SHalfloop_base; typedef SNC_in_place_list_shalfloop<SHalfloop_base> SHalfloop; typedef CGAL::In_place_list<SHalfloop,false> SHalfloop_list; typedef CGAL_ALLOCATOR(SHalfloop) SHalfloop_alloc; typedef typename SHalfloop_list::iterator SHalfloop_handle; typedef typename SHalfloop_list::const_iterator SHalfloop_const_handle; typedef typename SHalfloop_list::iterator SHalfloop_iterator; typedef typename SHalfloop_list::const_iterator SHalfloop_const_iterator; typedef typename Items::template SFace<SNC_structure> SFace_base; typedef SNC_in_place_list_sface<SFace_base> SFace; typedef CGAL::In_place_list<SFace,false> SFace_list; typedef CGAL_ALLOCATOR(SFace) SFace_alloc; typedef typename SFace_list::iterator SFace_handle; typedef typename SFace_list::const_iterator SFace_const_handle; typedef typename SFace_list::iterator SFace_iterator; typedef typename SFace_list::const_iterator SFace_const_iterator; typedef CGAL::Object_handle Object_handle; typedef std::list<Object_handle> Object_list; typedef Object_list::iterator Object_iterator; typedef Object_list::const_iterator Object_const_iterator; typedef Object_list::const_iterator Object_const_handle; typedef typename Sphere_map::SHalfedge_around_svertex_circulator SHalfedge_around_svertex_circulator; typedef typename Sphere_map::SHalfedge_around_sface_circulator SHalfedge_around_sface_circulator; typedef typename Sphere_map::SHalfedge_around_svertex_const_circulator SHalfedge_around_svertex_const_circulator; typedef typename Sphere_map::SHalfedge_around_sface_const_circulator SHalfedge_around_sface_const_circulator; typedef typename Sphere_map::Infi_box Infi_box; typedef typename Infi_box::Standard_kernel Standard_kernel; typedef Vertex_handle Constructor_parameter; typedef Vertex_const_handle Constructor_const_parameter; // Halffacet triangle#ifdef CGAL_NEF_LIST_OF_TRIANGLES class Halffacet_triangle_handle : public Halffacet_handle { typedef Halffacet_handle Base; Triangle_3* triangle; public: Halffacet_triangle_handle() : Base() {} Halffacet_triangle_handle( Halffacet_handle h, Triangle_3& t) : Base(h), triangle(&t) {} Triangle_3& get_triangle() { return *triangle; } void transform(const Aff_transformation_3& t) { *triangle = Triangle_3((*triangle)[0].transform(t), (*triangle)[1].transform(t), (*triangle)[2].transform(t)); } };#else class Halffacet_triangle_const_handle : public Halffacet_const_handle { typedef Halffacet_const_handle Base; Triangle_3 triangle; public: Halffacet_triangle_const_handle() : Base() {} Halffacet_triangle_const_handle( Halffacet_const_handle h, Triangle_3& t) : Base(h), triangle(t) {} Triangle_3 get_triangle() { return triangle; } void transform(const Aff_transformation_3& t) { triangle = Triangle_3(triangle[0].transform(t), triangle[1].transform(t), triangle[2].transform(t)); } }; class Halffacet_triangle_handle : public Halffacet_handle { typedef Halffacet_handle Base; Triangle_3 triangle; public: Halffacet_triangle_handle() : Base() {} Halffacet_triangle_handle( Halffacet_handle h, Triangle_3& t) : Base(h), triangle(t) {} Triangle_3 get_triangle() { return triangle; } void transform(const Aff_transformation_3& t) { triangle = Triangle_3(triangle[0].transform(t), triangle[1].transform(t), triangle[2].transform(t)); } };#endif class Halffacet_cycle_iterator : public Object_iterator /*{\Mtypemember a generic handle to an object in the boundary of a facet. Convertible to |Object_handle|.}*/ { typedef Object_iterator Ibase; public: Halffacet_cycle_iterator() : Ibase() {} Halffacet_cycle_iterator(const Ibase& b) : Ibase(b) {} Halffacet_cycle_iterator(const Halffacet_cycle_iterator& i) : Ibase(i) {} bool is_shalfedge() const { SHalfedge_handle e; return CGAL::assign(e,Ibase::operator*()); } bool is_shalfloop() const { SHalfloop_handle l; return CGAL::assign(l,Ibase::operator*()); } operator SHalfedge_handle() const { SHalfedge_handle e; CGAL::assign(e,Ibase::operator*()); return e; } operator SHalfloop_handle() const { SHalfloop_handle l; CGAL::assign(l,Ibase::operator*()); return l; } operator Object_handle() const { return Ibase::operator*(); } Object_handle& operator*() const { return Ibase::operator*(); } Object_handle operator->() const { CGAL_assertion_msg(0,"not impl."); return Object_handle();} }; class Halffacet_cycle_const_iterator : public Object_const_iterator /*{\Mtypemember a generic handle to an object in the boundary of a facet. Convertible to |Object_handle|.}*/ { typedef Object_const_iterator Ibase; public: Halffacet_cycle_const_iterator() : Ibase() {} Halffacet_cycle_const_iterator(const Ibase& b) : Ibase(b) {} Halffacet_cycle_const_iterator(const Halffacet_cycle_const_iterator& i) : Ibase(i) {} bool is_shalfedge() const { SHalfedge_handle e; return CGAL::assign(e,Ibase::operator*()); } bool is_shalfloop() const { SHalfloop_handle l; return CGAL::assign(l,Ibase::operator*()); } operator SHalfedge_const_handle() const { SHalfedge_handle e; CGAL::assign(e,Ibase::operator*()); return SHalfedge_const_handle(e); } operator SHalfloop_const_handle() const { SHalfloop_handle l; CGAL::assign(l,Ibase::operator*()); return SHalfloop_const_handle(l); } operator Object_handle() const { return Ibase::operator*(); } Object_handle& operator*() const { return Ibase::operator*(); } Object_handle operator->() const { CGAL_assertion_msg(0,"not impl."); return Object_handle();} }; class SFace_cycle_iterator : public Object_iterator /*{\Mtypemember a generic iterator to an object in the boundary of a sface. Convertible to |Object_handle|.}*/ { typedef Object_iterator Ibase; public: SFace_cycle_iterator() : Ibase() {} SFace_cycle_iterator(const Ibase& b) : Ibase(b) {} SFace_cycle_iterator(const SFace_cycle_iterator& i) : Ibase(i) {} bool is_svertex() const { SVertex_handle v; return CGAL::assign(v,Ibase::operator*()); } bool is_shalfedge() const { SHalfedge_handle e; return CGAL::assign(e,Ibase::operator*()); } bool is_shalfloop() const { SHalfloop_handle l; return CGAL::assign(l,Ibase::operator*()); } operator SVertex_handle() const { SVertex_handle v; CGAL::assign(v,Ibase::operator*()); return v; } operator SHalfedge_handle() const
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -