snc_constructor.h

来自「CGAL is a collaborative effort of severa」· C头文件 代码 · 共 1,868 行 · 第 1/5 页

H
1,868
字号
// 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.//// $Source: /CVSROOT/CGAL/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h,v $// $Revision: 1.87.2.2 $ $Date: 2004/12/08 19:30:41 $// $Name:  $//// 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_FM_decorator.h>#include <CGAL/Nef_3/SNC_point_locator.h>#include <CGAL/Nef_3/SNC_sphere_map.h>#include <CGAL/Nef_3/SNC_io_parser.h>#include <CGAL/Nef_3/SNC_intersection.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>#include <CGAL/Nef_3/Progress_indicator.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 max;  typedef typename T::Point_3                   Point_3;  typedef typename T::RT                        RT;  circle_lt(int 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(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;  }};template <typename Point, typename Edge, class Decorator>struct Halfedge_key {  typedef Halfedge_key<Point,Edge,Decorator> Self;  Point p; int i; Edge e;  Decorator& D;  Halfedge_key(Point pi, int ii, Edge ei, Decorator& Di ) :     p(pi), i(ii), e(ei), D(Di) {}  Halfedge_key(const Self& k) : p(k.p), i(k.i), e(k.e), D(k.D) {}  Self& operator=(const Self& k) { p=k.p; i=k.i; e=k.e; return *this; }  bool operator==(const Self& k) const { return p==k.p && i==k.i; }  bool operator!=(const Self& k) const { return !operator==(k); }};template <typename Point, typename Edge, class Decorator>struct Halfedge_key_lt {  typedef Halfedge_key<Point,Edge,Decorator> Key;  typedef typename Point::R R;  typedef typename R::Vector_3 Vector;  typedef typename R::Direction_3 Direction;  bool operator()( const Key& k1, const Key& k2) const {     if ( k1.p == k2.p )       return (k1.i < k2.i);    /* previous code:        else return CGAL::lexicographically_xyz_smaller(k1.p,k2.p); */    Direction l(k1.e->vector());    if( k1.i < 0) l = -l;    return (Direction( k2.p - k1.p) == l);   }};template <typename Point, typename Edge, class Decorator>std::ostream& operator<<(std::ostream& os,                          const Halfedge_key<Point,Edge,Decorator>& k ){ os << k.p << " " << k.i; return os; }template <typename R>int sign_of(const CGAL::Plane_3<R>& h){ if ( h.c() != 0 ) return CGAL_NTS sign(h.c());  if ( h.b() != 0 ) return CGAL_NTS sign(-h.b());  return CGAL_NTS sign(h.a());}struct Plane_lt {  template <typename R>  bool operator()(const CGAL::Plane_3<R>& h1,                  const CGAL::Plane_3<R>& h2) const  {     typedef typename R::RT     RT;    RT diff = h1.a()-h2.a();    if ( (diff) != 0 ) return CGAL_NTS sign(diff) < 0;    diff = h1.b()-h2.b();    if ( (diff) != 0 ) return CGAL_NTS sign(diff) < 0;    diff = h1.c()-h2.c();    if ( (diff) != 0 ) return CGAL_NTS sign(diff) < 0;    diff = h1.d()-h2.d(); return CGAL_NTS sign(diff) < 0;  }};// ----------------------------------------------------------------------------// SNC_constructor // ----------------------------------------------------------------------------/*{\Manpage{SNC_constructor}{SNC}{overlay functionality}{O}}*/template <typename SNC_structure_>class SNC_constructor : 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<SNC_structure>               Self;  typedef CGAL::SNC_decorator<SNC_structure>                 Base;  typedef CGAL::SNC_decorator<SNC_structure>                 SNC_decorator;  typedef typename CGAL::SNC_const_decorator<SNC_structure>  SNC_const_decorator;  typedef CGAL::SNC_point_locator<SNC_decorator>       SNC_point_locator;  typedef CGAL::SNC_FM_decorator<SNC_structure>              FM_decorator;  typedef CGAL::SNC_intersection<SNC_structure>              SNC_intersection;  typedef typename SNC_structure::Items                   Items;  typedef typename SNC_structure::Sphere_map              Sphere_map;  typedef CGAL::SM_decorator<Sphere_map>                 SM_decorator;    typedef CGAL::SNC_SM_overlayer<SM_decorator>           SM_overlayer;  typedef CGAL::SM_const_decorator<Sphere_map>           SM_const_decorator;  typedef CGAL::SM_point_locator<SM_const_decorator>     SM_point_locator;  typedef typename SNC_structure::Vertex Vertex;  typedef typename SNC_structure::Halfedge Halfedge;  typedef typename SNC_structure::Halffacet Halffacet;  typedef typename SNC_structure::Volume Volume;    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::Volume_iterator Volume_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::Volume_handle Volume_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::Volume_const_handle Volume_const_handle;  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 SVertex;  typedef typename SNC_structure::SHalfedge SHalfedge;  typedef typename SNC_structure::SFace SFace;  typedef typename SNC_structure::SHalfloop SHalfloop;  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::Object_handle Object_handle;  typedef typename SNC_structure::SHalfedge_around_facet_circulator SHalfedge_around_facet_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::Shell_entry_iterator Shell_entry_iterator;  typedef typename SNC_structure::Shell_entry_const_iterator Shell_entry_const_iterator;  typedef typename SNC_structure::Point_3 Point_3;  typedef typename SNC_structure::Vector_3 Vector_3;  typedef typename SNC_structure::Direction_3 Direction_3;  typedef typename SNC_structure::Segment_3 Segment_3;  typedef typename SNC_structure::Line_3 Line_3;  typedef typename SNC_structure::Plane_3 Plane_3;  typedef typename SNC_structure::Ray_3 Ray_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::Sphere_direction Sphere_direction;  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_point_locator* pl;  Vertex_handle minVertex;  typedef void* GenPtr;  typedef CGAL::Unique_hash_map<SFace_const_handle,unsigned int>                                                           Sface_shell_hash;  typedef CGAL::Unique_hash_map<Halffacet_const_handle,unsigned int>                                                           Face_shell_hash;  typedef CGAL::Unique_hash_map<SFace_const_handle,bool> SFace_visited_hash;  typedef CGAL::Unique_hash_map<SFace_const_handle,bool> Shell_closed_hash;  struct Shell_explorer {    const SNC_decorator& D;    Sface_shell_hash&  ShellSf;    Face_shell_hash&   ShellF;    //    Shell_closed_hash& Closed;    SFace_visited_hash& Done;    SFace_handle sf_min;    int n;    Shell_explorer(const SNC_decorator& Di, Sface_shell_hash& SSf,                    Face_shell_hash& SF, SFace_visited_hash& Vi)       : D(Di), ShellSf(SSf), ShellF(SF), Done(Vi), n(0) {}    void visit(SFace_handle h) {       CGAL_NEF_TRACEN("visit sf "<<D.point(D.vertex(h)));      ShellSf[h]=n;      Done[h]=true;      if ( CGAL::lexicographically_xyz_smaller(		 D.point(D.vertex(h)),D.point(D.vertex(sf_min)) )) 	sf_min = h;     }    void visit(Vertex_handle h) {       CGAL_NEF_TRACEN("visit v  "<<D.point(h));    }    void visit(Halfedge_handle h) {       CGAL_NEF_TRACEN("visit he "<<D.point(D.source(h)));      //      SM_decorator SD(D.vertex(h));      //      SFace_handle sf = D.source(h)->sfaces_begin();      //      if( Closed[sf] ) {      //	if(SD.is_isolated(h)){      //	  if(!SD.has_shalfloop()) Closed[sf] = false;      //	}      //	else {      //	  if(SD.first_out_edge(h) == SD.last_out_edge(h)) Closed[sf] = false;      //	}      //      }    }    void visit(Halffacet_handle h) {       CGAL_NEF_TRACEN(h->plane());       ShellF[h]=n;     }    void visit(SHalfedge_handle se) {}    void visit(SHalfloop_handle sl) {}    SFace_handle& minimal_sface() { return sf_min; }    void increment_shell_number() {       CGAL_NEF_TRACEN("leaving shell "<<n);      ++n;     }  };  SNC_constructor( SNC_structure& W, SNC_point_locator* spl = NULL)     : Base(W), pl(spl) {}  /*{\Mcreate makes |\Mvar| a decorator of |W|.}*/  void set_min_Vertex(Vertex_handle v_min) {minVertex=v_min;}  Vertex_handle get_min_Vertex() {return minVertex;}  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( point(v));    SM_decorator SD(&*v);    Sphere_point sp[] = { Sphere_point(-x, 0, 0), 			  Sphere_point(0, -y, 0), 

⌨️ 快捷键说明

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