snc_fm_decorator.h

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

H
512
字号
// Copyright (c) 1997-2000  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_FM_decorator.h,v $// $Revision: 1.28.2.1 $ $Date: 2004/12/08 19:30:35 $// $Name:  $//// Author(s)     : Michael Seel <seel@mpi-sb.mpg.de>#ifndef CGAL_SNC_FM_DECORATOR_H#define CGAL_SNC_FM_DECORATOR_H#include <CGAL/Nef_2/geninfo.h>#include <CGAL/Nef_2/Segment_overlay_traits.h>#include <CGAL/Nef_3/SNC_decorator.h>#include <list>#undef CGAL_NEF_DEBUG#define CGAL_NEF_DEBUG 31#include <CGAL/Nef_2/debug.h>CGAL_BEGIN_NAMESPACE//--------------------------------------------------------------------------/* We introduce a template that is a point that refers to a vertex.   We derive from the point type and add the vertex handle */template <typename P, typename H>class Vertex_point : public P {  H v_;public:  Vertex_point() {}  Vertex_point(const P& p, H v) : P(p)  { v_=v; }  Vertex_point(const Vertex_point& vp) : P(vp) { v_=vp.v_; }  Vertex_point& operator=(const Vertex_point& vp)  { P::operator=(vp); v_=vp.v_; return *this; }   H vertex() const { return v_; }};template <typename P, typename H>std::ostream& operator<<(std::ostream& os, const Vertex_point<P,H>& p){ os << static_cast<P>(p); return os; }template <typename P, typename H>std::ostream& operator<<(std::ostream& os,   const std::pair< Vertex_point<P,H>, Vertex_point<P,H> > & s){ os << s.first << s.second; return os; }template <typename P, typename SE>struct Sort_sedges {  bool operator()(SE e1, SE e2) {    P p1[2], p2[2];    p1[0] = e1->source()->center_vertex()->point();    p1[1] = e1->twin()->source()->twin()->center_vertex()->point();    p2[0] = e2->source()->center_vertex()->point();    p2[1] = e2->twin()->source()->twin()->center_vertex()->point();    int i1(0), i2(0);    if(CGAL::lexicographically_xyz_smaller(p1[1],p1[0])) i1 = 1;    if(CGAL::lexicographically_xyz_smaller(p2[1],p2[0])) i2 = 1;    if(p1[i1] != p2[i2]) return CGAL::lexicographically_xyz_smaller(p1[i1],p2[i2]);    if(p1[1-i1] != p2[1-i2]) return CGAL::lexicographically_xyz_smaller(p1[1-i1],p2[1-i2]);    return i1<i2;  }};//--------------------------------------------------------------------------/* The following type is an output model for our generic segment   sweep module |Segment_overlay_traits|. We use that code to    sweep all sedges of a plane to finally associate facet cycles   to facets. Note that we do not use the segment intersection   functionality of the code as the sedges only touch in endpoints.   There is room for optimization here. *///--------------------------------------------------------------------------template <typename P, typename V, typename E, typename I>struct Halffacet_output {Halffacet_output(CGAL::Unique_hash_map<I,E>& F, std::vector<E>& S)   : From(F), Support(S) { edge_number=0; Support[0]=E(); }typedef P         Point;typedef V         Vertex_handle;typedef unsigned  Halfedge_handle;CGAL::Unique_hash_map<I,E>& From;std::vector<E>& Support;unsigned edge_number;Vertex_handle new_vertex(const Point& p) const{ geninfo<unsigned>::create(p.vertex()->info());  return p.vertex(); }Halfedge_handle new_halfedge_pair_at_source(Vertex_handle v) { CGAL_NEF_TRACEN("new_edge "<<&*v<<" "<<edge_number+1);  return ++edge_number; }void supporting_segment(Halfedge_handle e, I it){ if ( From[it] != E() ) Support[e] = From[it]; }void halfedge_below(Vertex_handle v, Halfedge_handle e){ CGAL_NEF_TRACEN("halfedge_below point "<< v->point() <<": " << e);   geninfo<unsigned>::access(v->info()) = e; }// all empty, no update necessaryvoid link_as_target_and_append(Vertex_handle v, Halfedge_handle e){ /* do nothing */ }void trivial_segment(Vertex_handle v, I it) const {}void starting_segment(Vertex_handle v, I it) const {}void passing_segment(Vertex_handle v, I it) const {}void ending_segment(Vertex_handle v, I it) const {}};//--------------------------------------------------------------------------// the following class is the geometry kernel of the generic sweep// module |Segment_overlay_traits|. //--------------------------------------------------------------------------template <typename Point, typename Plane, typename Handle>class Halffacet_geometry {  public:  typedef Point Point_3;  typedef Plane Plane_3;  typedef Vertex_point<Point,Handle>  Point_2;  typedef std::pair<Point_2,Point_2>  Segment_2; private:  // the underlying plane:  Plane_3 h;  Point_3 above(const Point_3& p) const  { return p + h.orthogonal_vector(); } public:Halffacet_geometry(const Plane_3& hi) : h(hi) {}Point_2 source(const Segment_2& s) const  { return s.first; }Point_2 target(const Segment_2& s) const  { return s.second; }bool is_degenerate(const Segment_2& s) const{ return source(s)==target(s); }Segment_2 construct_segment(const Point_2& p1, const Point_2& p2) const{ return Segment_2(p1,p2); }int orientation(const Point_2& p1, const Point_2& p2, const Point_2& p3) const{ return static_cast<int>(    CGAL::orientation(p1,p2,p3,above(p1))); }int orientation(const Segment_2& s, const Point_2& p) const{ return orientation(source(s),target(s),p); }int compare_xy(const Point_2& p1, const Point_2& p2) const{ return static_cast<int>(    CGAL::compare_xyz(p1,p2)); }Point_2 intersection(const Segment_2& s1, const Segment_2& s2) const{ CGAL_assertion(target(s1)==target(s2));   return target(s1); }bool left_turn(const Point_3& p1, const Point_3& p2, const Point_3& p3) const{ return CGAL::orientation(p1,p2,p3,above(p1)) == CGAL::POSITIVE; }}; // Halffacet_geometry//--------------------------------------------------------------------------// SNC_FM_decorator// Note that we interpret sedges as edge uses between vertices.  We//   overwrite some operations from the base class for that semantics.//--------------------------------------------------------------------------template <typename S> class SNC_decorator;template <typename SNC_structure_>class SNC_FM_decorator : public SNC_decorator<SNC_structure_> {public:  typedef SNC_structure_ SNC_structure;  typedef SNC_decorator<SNC_structure> Base;  typedef typename SNC_structure::Vertex_iterator Vertex_iterator;   typedef typename SNC_structure::Vertex_handle Vertex_handle;  typedef typename SNC_structure::Halfedge_iterator Halfedge_iterator;   typedef typename SNC_structure::Halfedge_handle Halfedge_handle;  typedef typename SNC_structure::Halffacet_iterator Halffacet_iterator;   typedef typename SNC_structure::Halffacet_handle Halffacet_handle;  typedef typename SNC_structure::Volume_iterator Volume_iterator;  typedef typename SNC_structure::Volume_handle Volume_handle;  typedef typename SNC_structure::SVertex_iterator SVertex_iterator;   typedef typename SNC_structure::SVertex_handle SVertex_handle;  typedef typename SNC_structure::SHalfedge_iterator SHalfedge_iterator;   typedef typename SNC_structure::SHalfedge_handle SHalfedge_handle;  typedef typename SNC_structure::SHalfloop_iterator SHalfloop_iterator;   typedef typename SNC_structure::SHalfloop_handle SHalfloop_handle;  typedef typename SNC_structure::SFace_iterator SFace_iterator;   typedef typename SNC_structure::SFace_handle SFace_handle;  typedef typename SNC_structure::SFace_cycle_iterator SFace_cycle_iterator;  typedef typename SNC_structure::Halffacet_cycle_iterator Halffacet_cycle_iterator;  typedef typename SNC_structure::Shell_entry_iterator Shell_entry_iterator;  typedef typename SNC_structure::Object_handle Object_handle;  typedef typename SNC_structure::Point_3 Point_3;  typedef typename SNC_structure::Plane_3 Plane_3;  typedef typename SNC_structure::Mark Mark;  typedef typename Base::SHalfedge_around_facet_circulator    SHalfedge_around_facet_circulator;#if 0  typedef typename Base::SHalfedge_around_facet_const_circulator    SHalfedge_around_facet_const_circulator;#endif  typedef typename std::list<Object_handle>::iterator     Object_list_iterator;  typedef Vertex_point<Point_3,Vertex_handle>  Vertex_point;  typedef std::pair<Vertex_point,Vertex_point> Vertex_segment;  typedef std::list<Vertex_segment>            Segment_list;  typedef typename Segment_list::iterator      Segment_iterator;  typedef CGAL::Halffacet_geometry<Point_3,Plane_3,Vertex_handle>     Halffacet_geometry;protected:  Halffacet_handle f_;public:  SNC_FM_decorator(SNC_structure& W) : Base(W), f_() {}  SNC_FM_decorator(SNC_structure& W, Halffacet_handle f)   : Base(W),f_(f) {}  Halffacet_cycle_iterator facet_cycles_begin() const   { return f_->facet_cycles_begin(); }    Halffacet_cycle_iterator facet_cycles_end()   const   { return f_->facet_cycles_end(); }  void create_facet_objects(const Plane_3& h,    Object_list_iterator start, Object_list_iterator end) const;protected://--------------------------------------------------------------------------/* We provide some information on determine_facet. To understand its   functionality please refer to the Nef_2 implementation report where

⌨️ 快捷键说明

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