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

📄 arr_basic_addition_traits.h

📁 很多二维 三维几何计算算法 C++ 类库
💻 H
📖 第 1 页 / 共 2 页
字号:
// Copyright (c) 1997  Tel-Aviv University (Israel).// 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/Arrangement_2/include/CGAL/Sweep_line_2/Arr_basic_addition_traits.h $// $Id: Arr_basic_addition_traits.h 39452 2007-07-22 06:38:22Z ophirset $// //// Author(s)     : Baruch Zukerman <baruchzu@post.tau.ac.il>#ifndef CGAL_ARR_BASIC_ADDITION_TRAITS_H#define CGAL_ARR_BASIC_ADDITION_TRAITS_H#include <CGAL/Object.h> #include <list>#include <iterator>CGAL_BEGIN_NAMESPACEtemplate <class Traits_, class Arrangement_>class Arr_basic_addition_traits {public:  typedef Traits_                                  Traits_2;  typedef Arrangement_                             Arrangement_2;  typedef typename Arrangement_2::Halfedge_handle  Halfedge_handle;  typedef typename Arrangement_2::Vertex_handle    Vertex_handle;  typedef typename Traits_2::X_monotone_curve_2    Base_x_monotone_curve_2;  typedef typename Traits_2::Point_2               Base_point_2;  typedef typename Traits_2::Construct_min_vertex_2                                                   Base_Construct_min_vertex_2;  typedef typename Traits_2::Construct_max_vertex_2                                                   Base_Construct_max_vertex_2;  typedef typename Traits_2::Compare_xy_2          Base_Compare_xy_2;  typedef typename Traits_2::Compare_y_at_x_2      Base_Compare_y_at_x_2;  typedef typename Traits_2::Compare_y_at_x_right_2                                                    Base_Compare_y_at_x_right_2;  typedef typename Traits_2::Equal_2               Base_Equal_2;  typedef typename Traits_2::Compare_x_2           Base_Compare_x_2;  typedef typename Traits_2::Is_vertical_2         Base_Is_vertical_2;  typedef typename Traits_2::Has_boundary_category Base_has_boundary_category;  typedef Tag_true                                 Has_boundary_category;  typedef typename Traits_2::Has_left_category     Has_left_category;protected:  Traits_2*    m_base_traits;public:  Arr_basic_addition_traits()   {}  //Constructor  Arr_basic_addition_traits (Traits_2& tr):    m_base_traits (&tr)  {}  /*! \class   * Nested extension of the x-monotone curve type.   */  class Ex_x_monotone_curve_2   {  public:    typedef  Base_x_monotone_curve_2 Base;    typedef  Base_point_2            Point_2;    Ex_x_monotone_curve_2() :      m_base_cv(),      m_he_handle(),      m_overlap(false)    {}    Ex_x_monotone_curve_2(const Base& cv) :      m_base_cv(cv),      m_he_handle(),      m_overlap(false)    {}    Ex_x_monotone_curve_2(const Base& cv, Halfedge_handle he) :      m_base_cv(cv),      m_he_handle(he),      m_overlap(false)    {}    const Base& base() const    {      return (m_base_cv);    }    Base& base()    {      return (m_base_cv);    }    operator const Base& () const    {      return (m_base_cv);    }    Ex_x_monotone_curve_2& operator=(const Base& cv)    {      m_base_cv = cv;      m_he_handle = Halfedge_handle();      return (*this);    }    Halfedge_handle get_halfedge_handle() const    {      return m_he_handle;    }    void set_halfedge_handle(Halfedge_handle he)    {      m_he_handle = he;    }    bool is_overlapping () const    {      return m_overlap;    }    void set_overlapping ()    {      m_overlap = true;    }  protected:    Base                m_base_cv;    Halfedge_handle     m_he_handle;    bool                m_overlap;  };  friend std::ostream& operator<< (std::ostream& os,                                    const Ex_x_monotone_curve_2 & cv)  {    os << cv.base();    return (os);  }  /*! \class   * Nested extension of the point type.   */  class Ex_point_2   {  public:    typedef  Base_point_2            Base;    Ex_point_2(): m_base_pt(),                  m_v(NULL)    {}    Ex_point_2(const Base& pt): m_base_pt(pt),                                m_v(NULL)    {}    Ex_point_2(const Base& pt, Vertex_handle v): m_base_pt(pt),                                                 m_v(v)    {}    const Base& base() const    {      return (m_base_pt);    }        operator const Base& () const    {      return (m_base_pt);    }    Vertex_handle get_vertex_handle() const    {      return m_v;    }    void set_vertex_handle(Vertex_handle v)    {      m_v = v;    }      protected:    Base             m_base_pt;    Vertex_handle    m_v;  };  friend std::ostream& operator<< (std::ostream& os, const Ex_point_2 & p)  {    os << p.base();    return (os);  }    typedef Ex_x_monotone_curve_2                     X_monotone_curve_2;  typedef Ex_point_2                                Point_2;  /*! \class   * The Boundary_in_x_2 functor.   */  class Boundary_in_x_2  {  public:    Boundary_type operator() (const X_monotone_curve_2& cv,                              Curve_end ind) const    {      return _boundary_in_x_imp (cv, ind, Base_has_boundary_category());    }  private:    Boundary_type _boundary_in_x_imp (const X_monotone_curve_2& cv,                                      Curve_end ind,                                      Tag_true) const    {      Traits_2                    tr;      return (tr.boundary_in_x_2_object() (cv.base(), ind));    }    Boundary_type _boundary_in_x_imp (const X_monotone_curve_2& , Curve_end ,                                      Tag_false) const    {      return (NO_BOUNDARY);    }  };  Boundary_in_x_2 boundary_in_x_2_object () const  {    return Boundary_in_x_2();  }  /*! \class   * The Boundary_in_y_2 functor.   */  class Boundary_in_y_2  {  public:    Boundary_type operator() (const X_monotone_curve_2& cv,                              Curve_end ind) const    {      return _boundary_in_y_imp (cv, ind, Base_has_boundary_category());    }  private:    Boundary_type _boundary_in_y_imp (const X_monotone_curve_2& cv,                                      Curve_end ind,                                      Tag_true) const    {      Traits_2                    tr;      return (tr.boundary_in_y_2_object() (cv.base(), ind));    }    Boundary_type _boundary_in_y_imp (const X_monotone_curve_2& , Curve_end ,                                      Tag_false) const    {      return (NO_BOUNDARY);    }  };  Boundary_in_y_2 boundary_in_y_2_object () const  {    return Boundary_in_y_2();  }  /*! \class   * The Construct_min_vertex_2 functor.   */  class Construct_min_vertex_2  {  private:    Base_Construct_min_vertex_2 m_base_min_v;    Base_Equal_2                m_base_equal;  public:    Construct_min_vertex_2 (const Base_Construct_min_vertex_2& base_min_v,                            const Base_Equal_2& base_equal):      m_base_min_v (base_min_v),      m_base_equal (base_equal)    {}    Point_2 operator() (const X_monotone_curve_2 & cv)     {      // If there is not halfedge associated with the curve, just return      // a point with invalid halfedge handle.      const Base_point_2&  base_p = m_base_min_v(cv.base());      if (cv.get_halfedge_handle() == Halfedge_handle())        return (Point_2 (base_p, Vertex_handle()));      // We probably have to associate the point with the target vertex of      // the halfedge associated with the curve.      Vertex_handle        vh = cv.get_halfedge_handle()->target();      if (! cv.is_overlapping())        return (Point_2(base_p, vh));      // In case of an overlapping curve, make sure the curve endpoint equals      // the point associated with the vertex. If not, we attach an invalid      // vertex to the extended point.      if (! vh->is_at_infinity() && m_base_equal (base_p, vh->point()))

⌨️ 快捷键说明

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