⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snc_constructor.h

📁 很多二维 三维几何计算算法 C++ 类库
💻 H
📖 第 1 页 / 共 5 页
字号:
// 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_constructor.h $// $Id: SNC_constructor.h 39746 2007-08-07 20:10:09Z 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>//                 Peter Hachenberger <hachenberger@mpi-sb.mpg.de>#ifndef CGAL_SNC_CONSTRUCTOR_H#define CGAL_SNC_CONSTRUCTOR_H#include <CGAL/basic.h>#include <CGAL/functional.h> #include <CGAL/function_objects.h> #include <CGAL/Circulator_project.h>#include <CGAL/Nef_S2/Normalizing.h>#include <CGAL/Nef_3/bounded_side_3.h>#include <CGAL/Nef_3/Pluecker_line_3.h>#include <CGAL/Nef_3/SNC_decorator.h>#include <CGAL/Nef_3/SNC_SM_overlayer.h>#include <CGAL/Nef_S2/SM_point_locator.h>#include <CGAL/Nef_3/SNC_sphere_map.h>#include <CGAL/Nef_3/SNC_intersection.h>#include <CGAL/Nef_3/SNC_external_structure.h>#ifdef SM_VISUALIZOR#include <CGAL/Nef_3/SNC_SM_visualizor.h>#endif // SM_VISUALIZOR#include <map>#include <list>#undef CGAL_NEF_DEBUG#define CGAL_NEF_DEBUG 43#include <CGAL/Nef_2/debug.h>CGAL_BEGIN_NAMESPACEtemplate <typename Infi_box, typename Vertex_handle>struct Frame_point_lt {  Frame_point_lt() {}  bool operator()(Vertex_handle v1, Vertex_handle v2) const {    if(v1->point() != v2->point())      return CGAL::lexicographically_xyz_smaller(v1->point(),v2->point());    if(!Infi_box::is_complex_facet_infibox_intersection(*v1) &&        Infi_box::is_complex_facet_infibox_intersection(*v2))      return true;    return false;  }};template <typename T>struct circle_lt {    int m_max;  typedef typename T::Point_3                   Point_3;  typedef typename T::RT                        RT;  circle_lt(int m) :m_max(m) {};  bool operator()(const Point_3& p1, const Point_3& p2) const {             const Quotient<RT> zero(RT(0));    Quotient<RT> x[2];    Quotient<RT> y[2];    switch(m_max) {    case 0:      x[0] = p1.y();       y[0] = p1.z();      x[1] = p2.y();       y[1] = p2.z();        break;    case 1:      x[0] = p1.x();       y[0] = p1.z();      x[1] = p2.x();       y[1] = p2.z();        break;    case 2:      x[0] = p1.x();       y[0] = p1.y();      x[1] = p2.x();       y[1] = p2.y();        break;    }        if(y[0] >= zero) {      if(y[1] < zero) return false;      if(x[0] != x[1]) return (x[0]<x[1]);      if(x[0] > zero) return (y[0]>y[1]);      else return (y[0]<y[1]);    }    else {      if(y[1] >= zero) return true;      if(x[0]!=x[1]) return(x[0]>x[1]);      if(x[0] > zero) return (y[0]>y[1]);      else return  (y[0]<y[1]);    }    CGAL_assertion_msg(false, "control should not reach this line");    return false;  }};// ----------------------------------------------------------------------------// SNC_constructor // ----------------------------------------------------------------------------/*{\Manpage{SNC_constructor}{SNC}{overlay functionality}{O}}*/template <typename Items, typename SNC_structure_>class SNC_constructor_base : public SNC_decorator<SNC_structure_>{ public:  typedef SNC_structure_ SNC_structure;  typedef typename SNC_structure::Infi_box                   Infi_box;  typedef typename SNC_structure_::Sphere_kernel             Sphere_kernel;  typedef typename Infi_box::Standard_kernel                 Standard_kernel;  typedef typename Standard_kernel::Point_3                  Standard_point_3;  typedef typename SNC_structure_::Kernel                    Kernel;  typedef typename Kernel::RT                                RT;  typedef typename Infi_box::NT                              NT;  typedef CGAL::SNC_constructor_base<Items, SNC_structure>        Self;  typedef CGAL::SNC_decorator<SNC_structure>                 SNC_decorator;  typedef typename CGAL::SNC_const_decorator<SNC_structure>  SNC_const_decorator;  typedef CGAL::SNC_intersection<SNC_structure>              SNC_intersection;  typedef typename SNC_structure::Sphere_map             Sphere_map;  typedef CGAL::SM_decorator<Sphere_map>                 SM_decorator;    typedef CGAL::SNC_SM_overlayer<Items, SM_decorator>    SM_overlayer;  typedef CGAL::SM_const_decorator<Sphere_map>           SM_const_decorator;  typedef CGAL::SM_point_locator<SM_decorator>           SM_point_locator;  typedef typename SNC_structure::Vertex_iterator Vertex_iterator;  typedef typename SNC_structure::Halfedge_iterator Halfedge_iterator;  typedef typename SNC_structure::Halffacet_iterator Halffacet_iterator;  typedef typename SNC_structure::Vertex_handle Vertex_handle;  typedef typename SNC_structure::Halfedge_handle Halfedge_handle;  typedef typename SNC_structure::Halffacet_handle Halffacet_handle;  typedef typename SNC_structure::Vertex_const_handle Vertex_const_handle;  typedef typename SNC_structure::Halfedge_const_handle Halfedge_const_handle;  typedef typename SNC_structure::Halffacet_const_handle Halffacet_const_handle;  typedef typename SNC_structure::Halffacet_const_iterator Halffacet_const_iterator;  typedef typename SNC_structure::SVertex_iterator SVertex_iterator;  typedef typename SNC_structure::SHalfedge_iterator SHalfedge_iterator;  typedef typename SNC_structure::SFace_iterator SFace_iterator;  typedef typename SNC_structure::SHalfloop_iterator SHalfloop_iterator;  typedef typename SNC_structure::SVertex_handle SVertex_handle;  typedef typename SNC_structure::SHalfedge_handle SHalfedge_handle;  typedef typename SNC_structure::SFace_handle SFace_handle;  typedef typename SNC_structure::SHalfloop_handle SHalfloop_handle;  typedef typename SNC_structure::SVertex_const_handle SVertex_const_handle;   typedef typename SNC_structure::SHalfedge_const_handle SHalfedge_const_handle;   typedef typename SNC_structure::SHalfloop_const_handle SHalfloop_const_handle;   typedef typename SNC_structure::SFace_const_handle SFace_const_handle;   typedef typename SNC_structure::SHalfedge_around_facet_circulator     SHalfedge_around_facet_circulator;  typedef typename SNC_structure::SHalfedge_around_facet_const_circulator     SHalfedge_around_facet_const_circulator;  typedef typename SNC_structure::SFace_cycle_iterator SFace_cycle_iterator;  typedef typename SNC_structure::SFace_cycle_const_iterator SFace_cycle_const_iterator;  typedef typename SNC_structure::Halffacet_cycle_iterator Halffacet_cycle_iterator;  typedef typename SNC_structure::Halffacet_cycle_const_iterator Halffacet_cycle_const_iterator;  typedef typename SNC_structure::Point_3 Point_3;  typedef typename SNC_structure::Vector_3 Vector_3;  typedef typename SNC_structure::Segment_3 Segment_3;  typedef typename SNC_structure::Plane_3 Plane_3;  typedef typename SNC_structure::Aff_transformation_3 Aff_transformation_3;  typedef typename SNC_structure::Sphere_point Sphere_point;  typedef typename SNC_structure::Sphere_segment Sphere_segment;  typedef typename SNC_structure::Sphere_circle Sphere_circle;  typedef typename SNC_structure::Mark Mark;  typedef typename SM_decorator::SHalfedge_around_svertex_circulator                                  SHalfedge_around_svertex_circulator;  typedef typename SM_const_decorator::SHalfedge_around_svertex_const_circulator                                        SHalfedge_around_svertex_const_circulator;     enum{NORMAL, CORNER, DEGENERATE};  SNC_constructor_base( SNC_structure& W) : SNC_decorator(W) {}  /*{\Mcreate makes |\Mvar| a decorator of |W|.}*/  Vertex_handle create_extended_box_corner(NT x, NT y, NT z,                                  bool space=true, bool boundary=true) const {     CGAL_assertion(CGAL_NTS abs(x) == CGAL_NTS abs(y) &&		   CGAL_NTS abs(y) == CGAL_NTS abs(z));        CGAL_assertion(boundary == true);        CGAL_NEF_TRACEN("  constructing box corner on "<<Point_3(x,y,z)<<"...");    Point_3 p = Infi_box::create_extended_point(x,y,z);     Vertex_handle v = this->sncp()->new_vertex(p , boundary);    CGAL_NEF_TRACEN( v->point());    SM_decorator SD(&*v);    Sphere_point sp[] = { Sphere_point(-x, 0, 0), 			  Sphere_point(0, -y, 0), 			  Sphere_point(0, 0, -z) };      /* create box vertices */    SVertex_handle sv[3];    for(int vi=0; vi<3; ++vi) {      sv[vi] = SD.new_svertex(sp[vi]);      sv[vi]->mark() = boundary;    }    /* create facet's edge uses */    //  Sphere_segment ss[3];    SHalfedge_handle she[3];    for(int si=0; si<3; ++si)      she[si] = SD.new_shalfedge_pair(sv[si], sv[(si+1)%3]);        for(int i=0; i<3;++i) {      she[i]->circle() =       Sphere_circle(Plane_3(sp[i],sp[(i+1)%3],Point_3(0,0,0)));      she[i]->twin()->circle() =  she[i]->circle().opposite();    she[i]->mark() = she[i]->twin()->mark() = boundary;    }        /* create facets */    SFace_handle fi = SD.new_sface();    SFace_handle fe = SD.new_sface();    SD.link_as_face_cycle(she[0], fi);    SD.link_as_face_cycle(she[0]->twin(), fe);        Sphere_point p1 = she[0]->source()->point();    Sphere_point p2 = she[0]->twin()->source()->point();    Sphere_point p3 = she[0]->snext()->twin()->source()->point();    if ( spherical_orientation(p1,p2,p3) > 0 ) {      fi->mark() = space;      fe->mark() = 0;    }    else {      fi->mark() = 0;      fe->mark() = space;    }        return v;  }  /*{\Mop produces the sphere map representing thp,e box corner in          direction $(x,y,z)$.}*/  template<typename Forward_iterator>    void add_outer_sedge_cycle(Vertex_handle v, 			     Forward_iterator start,			     Forward_iterator end, 			     bool orient) {        CGAL_assertion(start!=end);        v->mark() = true;    SM_decorator SD(&*v);        Forward_iterator si;    for(si=start; si!=end; ++si)      SD.new_svertex(*si);        SHalfedge_handle se,se_prev;    std::list<SHalfedge_handle> se_list;    SVertex_iterator sv(SD.svertices_begin()), sv_next(sv);    for(;sv!=SD.svertices_end();++sv) {      ++sv_next;      sv->mark()=true;      if(sv_next==SD.svertices_end()) sv_next=SD.svertices_begin();      se=SD.new_shalfedge_pair(sv,sv_next);      se_list.push_back(se);      se->mark() = se->twin()->mark() = true;     if(sv!=SD.svertices_begin()) {	se->sprev() = se_prev;	se_prev->snext() = se;	se->twin()->snext() = se_prev->twin();	se_prev->twin()->sprev() = se->twin();      }     se_prev = se;    }        se=*se_list.begin();    se->sprev() = se_prev;    se_prev->snext() = se;    se->twin()->snext() = se_prev->twin();    se_prev->twin()->sprev() = se->twin();    typename std::list<SHalfedge_handle>::iterator seli;    for(seli=se_list.begin();seli!=se_list.end();++seli) {      se = *seli;      se->circle() = Sphere_circle(se->source()->point(), se->snext()->source()->point());      if(orient && seli==se_list.begin())	 se->circle() = Sphere_circle(se->snext()->source()->point(), se->source()->point());      se->circle() = normalized(se->circle());      se->twin()->circle() = se->circle().opposite();    }        SFace_handle sfa = SD.new_sface();    SFace_handle sfi = SD.new_sface();    sfi->mark()=true;    sfa->mark()=false;    se=*se_list.begin();    SD.link_as_face_cycle(se,sfi);    SD.link_as_face_cycle(se->twin(),sfa);  }  template<typename Forward_iterator>    void add_inner_sedge_cycle(Vertex_handle v, 			     Forward_iterator start,			     Forward_iterator end, 			     bool orient, bool camera) {    CGAL_assertion(start!=end);    v->mark() = true;    SM_decorator SD(&*v);    Forward_iterator si;    std::list<SVertex_handle> sv_list;    for(si=start; si!=end; ++si)      sv_list.push_back(SD.new_svertex(*si));        SHalfedge_handle se, se_prev;    typename std::list<SVertex_handle>::iterator       sv(sv_list.begin()), sv_next(sv);    std::list<SHalfedge_handle> se_list;        for(;sv!=sv_list.end();++sv) {      ++sv_next;      (*sv)->mark()=true;      if(sv_next==sv_list.end()) sv_next=sv_list.begin();      se=SD.new_shalfedge_pair(*sv,*sv_next);      se_list.push_back(se);      se->mark() = se->twin()->mark() = true;      if(sv!=sv_list.begin()) {	se->prev() = se_prev;	se_prev->next() = se;	se->twin()->next() = se_prev->twin();	se_prev->twin()->prev() = se->twin();      }      se_prev = se;    }    se=*se_list.begin();    se->prev() = se_prev;    se_prev->next() = se;    se->twin()->next() = se_prev->twin();    se_prev->twin()->prev() = se->twin();    typename std::list<SHalfedge_handle>::iterator seli;    for(seli=se_list.begin();seli!=se_list.end();++seli) {      se = *seli;      se->circle() = Sphere_circle(se->source()->point(), se->snext()->source()->point());      if(orient && seli==se_list.begin())	 se->circle() = Sphere_circle(se->snext()->source()->point(), se->source()->point());      se->circle() = normalized(se->circle());      se->twin()->circle() = se->circle().opposite();    }      SFace_handle sfa,sfi;    if(camera) {      sfa = ++SD.sfaces_begin();      sfi = SD.new_sface();      sfi->mark()=false;    } else {      sfa = SD.new_sface();      sfi = SD.new_sface();      sfa->mark()=true;

⌨️ 快捷键说明

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