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

📄 straight_skeleton_builder_traits_2_aux.h

📁 很多二维 三维几何计算算法 C++ 类库
💻 H
📖 第 1 页 / 共 2 页
字号:
    // These methods returns the edges according to that classification.    // PRECONDITION: Exactly 2 out of 3 edges are collinear    Segment_2 const& collinear_edge    () const { return e(rep().mCSIdx) ; }    Segment_2 const& non_collinear_edge() const { return e(rep().mNCSIdx) ; }    enum SEED_ID { LEFT, RIGHT, UNKNOWN } ;            // Indicates which of the seeds is collinear for a normal collinearity case.    // PRECONDITION: The collinearity is normal.    SEED_ID degenerate_seed_id() const    {      Trisegment_collinearity c = collinearity();              return c == TRISEGMENT_COLLINEARITY_01 ? LEFT : c == TRISEGMENT_COLLINEARITY_12 ? RIGHT : UNKNOWN  ;     }    // A default constructed trisegment is formally null.    // Null trisegments are used to represent seeds which are contour vertices instead of skeleton nodes    // (hence are not defined by a trisegment at all)    bool is_null() const { return !mRep ; }        friend std::ostream& operator << ( std::ostream& os, Trisegment_2<K> const& aTrisegment )    {      if ( aTrisegment.is_null() )      {        return os << "{null}" ;      }        else      {        return os << "[" << s2str(aTrisegment.e0())                  << " " << s2str(aTrisegment.e1())                  << " " << s2str(aTrisegment.e2())                  << " " << trisegment_collinearity_to_string(aTrisegment.collinearity())                   << "]";      }    }  private:    struct Rep : public Ref_counted_base    {      Rep ( Segment_2 const&        aE0          , Segment_2 const&        aE1          , Segment_2 const&        aE2          , Trisegment_collinearity aCollinearity           )       {        mCollinearity = aCollinearity ;                mE[0] = aE0 ;        mE[1] = aE1 ;        mE[2] = aE2 ;                switch ( mCollinearity )        {          case TRISEGMENT_COLLINEARITY_01:            mCSIdx=0; mNCSIdx=2; break ;                      case TRISEGMENT_COLLINEARITY_12:            mCSIdx=1; mNCSIdx=0; break ;                      case TRISEGMENT_COLLINEARITY_02:            mCSIdx=0; mNCSIdx=1; break ;                      case TRISEGMENT_COLLINEARITY_ALL:            mCSIdx=-1; mNCSIdx=-1; break ;                      case TRISEGMENT_COLLINEARITY_NONE:            mCSIdx=-1; mNCSIdx=-1; break ;        }      }                Segment_2               mE[3];      Trisegment_collinearity mCollinearity ;      unsigned                mCSIdx, mNCSIdx ;    } ;        Rep const& rep() const { CGAL_assertion(mRep) ; return *mRep ; }    Rep&       rep()       { CGAL_assertion(mRep) ; return *mRep ; }        boost::intrusive_ptr<Rep> mRep ;} ;//// This record stores the trisegment that defines a given event along with the 2 trisegments that defines// the left and right seed vertices.// If a seed vertex is a contour vertex instead of a skeleton node, it is given as a null trisegment.// // A default constructed seeded trisegment is formally null.//template<class K>class Seeded_trisegment_2{  public :      typedef CGAL_SS_i::Trisegment_2<K> Trisegment_2 ;    Seeded_trisegment_2() {}          Seeded_trisegment_2 ( Trisegment_2 const& event )      :       mEvent(event)      ,mLSeed()      ,mRSeed()                        {}        Seeded_trisegment_2 ( Trisegment_2 const& event                        , Trisegment_2 const& lseed                        , Trisegment_2 const& rseed                        )      :       mEvent(event)      ,mLSeed(lseed)      ,mRSeed(rseed)                        {}        Trisegment_2 const& event() const { return mEvent ; }     Trisegment_2 const& lseed() const { return mLSeed ; }    Trisegment_2 const& rseed() const { return mRSeed ; }      friend std::ostream& operator << ( std::ostream& os, Seeded_trisegment_2<K> const& st )    {      return os << "Event=" << st.event()                << "\n  LSeed=" << st.lseed()                << "\n  RSeed=" << st.rseed() ;                    }      private :      Trisegment_2 mEvent ;    Trisegment_2 mLSeed ;    Trisegment_2 mRSeed ;} ;template<class K>struct Functor_base_2{  typedef typename K::FT        FT ;  typedef typename K::Point_2   Point_2 ;  typedef typename K::Segment_2 Segment_2 ;    typedef CGAL_SS_i::Trisegment_2       <K> Trisegment_2 ;  typedef CGAL_SS_i::Seeded_trisegment_2<K> Seeded_trisegment_2 ;};template<class Converter>struct SS_converter : Converter{  typedef typename Converter::Source_kernel Source_kernel;  typedef typename Converter::Target_kernel Target_kernel;  typedef typename Source_kernel::FT Source_FT ;  typedef typename Target_kernel::FT Target_FT ;  typedef typename Source_kernel::Point_2 Source_point_2 ;  typedef typename Target_kernel::Point_2 Target_point_2 ;  typedef typename Source_kernel::Segment_2 Source_segment_2 ;  typedef typename Target_kernel::Segment_2 Target_segment_2 ;  typedef Trisegment_2<Source_kernel> Source_trisegment_2 ;  typedef Trisegment_2<Target_kernel> Target_trisegment_2 ;  typedef Seeded_trisegment_2<Source_kernel> Source_seeded_trisegment_2 ;  typedef Seeded_trisegment_2<Target_kernel> Target_seeded_trisegment_2 ;    typedef boost::tuple<Source_FT,Source_point_2> Source_time_and_point_2 ;  typedef boost::tuple<Target_FT,Target_point_2> Target_time_and_point_2 ;    typedef boost::optional<Source_point_2> Source_opt_point_2 ;  typedef boost::optional<Target_point_2> Target_opt_point_2 ;    typedef boost::optional<Source_time_and_point_2> Source_opt_time_and_point_2 ;  typedef boost::optional<Target_time_and_point_2> Target_opt_time_and_point_2 ;    typedef boost::optional<Source_segment_2> Source_opt_segment_2 ;  typedef boost::optional<Target_segment_2> Target_opt_segment_2 ;    typedef boost::optional<Source_trisegment_2> Source_opt_trisegment_2 ;  typedef boost::optional<Target_trisegment_2> Target_opt_trisegment_2 ;    Target_FT        cvtn(Source_FT const& n) const  { return this->Converter::operator()(n); }  Target_point_2   cvtp(Source_point_2 const& p) const  { return this->Converter::operator()(p); }  Target_segment_2 cvts( Source_segment_2 const& e) const { return Target_segment_2(cvtp(e.source()), cvtp(e.target()) ) ; }    Target_time_and_point_2 cvttp( Source_time_and_point_2 const& v ) const  {    Source_FT      t ;    Source_point_2 p ;    boost::tie(t,p) = v ;    return Target_time_and_point_2(cvtn(t),cvtp(p));  }    Target_trisegment_2 cvt_tri( Source_trisegment_2 const& t) const  {    return t.is_null() ? Target_trisegment_2::null()                       : Target_trisegment_2(cvts(t.e0())                                            ,cvts(t.e1())                                            ,cvts(t.e2())                                            ,t.collinearity()                                            ) ;      }    Target_seeded_trisegment_2 cvt_seeded_tri( Source_seeded_trisegment_2 const& st ) const  {    return Target_seeded_trisegment_2(cvt_tri(st.event()),cvt_tri(st.lseed()),cvt_tri(st.rseed())) ;      }    Trisegment_collinearity  operator()(Trisegment_collinearity c) const { return c ; }   Target_FT        operator()(Source_FT const& n) const { return cvtn(n) ; }  Target_point_2   operator()( Source_point_2 const& p) const { return cvtp(p) ; }  Target_segment_2 operator()( Source_segment_2 const& s) const { return cvts(s); }    Target_trisegment_2 operator()( Source_trisegment_2 const& t) const  {    return cvt_tri(t);  }    Target_seeded_trisegment_2 operator()( Source_seeded_trisegment_2 const& st) const  {    return cvt_seeded_tri(st);  }    Target_opt_trisegment_2 operator()( Source_opt_trisegment_2 const& t) const  {    if ( t )         return Target_opt_trisegment_2(cvt_tri(*t)) ;    else return Target_opt_trisegment_2();      }  Target_time_and_point_2 operator() ( Source_time_and_point_2 const& v ) const  {    return cvttp(v);  }    Target_opt_point_2 operator()( Source_opt_point_2 const& p) const   {    if ( p )          return Target_opt_point_2(cvtp(*p));    else return Target_opt_point_2();  }  Target_opt_segment_2 operator()( Source_opt_segment_2 const& s) const   {    if ( s )          return Target_opt_segment_2(cvts(*s));    else return Target_opt_segment_2();  }    Target_opt_time_and_point_2 operator()( Source_opt_time_and_point_2 const& v) const   {     if ( v )          return Target_opt_time_and_point_2(cvttp(*v));    else return Target_opt_time_and_point_2();  }  };} // namespace CGAL_SS_i//// This macro defines a global functor adapter which allows users to use it in the followig ways://// Given a 'Functor' provided by a given 'Traits' (or Kernel):////   typedef typename CGAL::Functor<Traits>::type Functor ;//   result r = CGAL::Functor<Traits>(traits)(a,b,c);//#define CGAL_STRAIGHT_SKELETON_CREATE_FUNCTOR_ADAPTER(functor) \        template<class K> \        typename K :: functor functor ( K const& aK ) \        { \          return aK.get((typename K :: functor const*)0);  \        }CGAL_END_NAMESPACE#endif // CGAL_STRAIGHT_SKELETON_BUILDER_TRAITS_2_AUX_H //// EOF //

⌨️ 快捷键说明

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