function_objects.h

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

H
2,231
字号
    {       return compare_slopesC2(s1.source().x(), s1.source().y(),			      s1.target().x(), s1.target().y(),			      s2.source().x(), s2.source().y(),			      s2.target().x(), s2.target().y());    }  };  template <typename K>  class Compare_x_at_y_2  {    typedef typename K::Point_2    Point_2;    typedef typename K::Line_2     Line_2;  public:    typedef Comparison_result      result_type;    typedef Arity_tag< 3 >         Arity;    Comparison_result    operator()( const Point_2& p, const Line_2& h) const    { return compare_y_at_xC2(p.y(), p.x(), h.b(), h.a(), h.c()); }    Comparison_result    operator()( const Point_2& p, const Line_2& h1, const Line_2& h2) const    {       return compare_y_at_xC2(p.y(), h1.b(), h1.a(), h1.c(),			      h2.b(), h2.a(), h2.c());    }    Comparison_result    operator()( const Line_2& l1, const Line_2& l2, const Line_2& h) const    {       return compare_y_at_xC2(l1.b(), l1.a(), l1.c(), l2.b(), l2.a(), l2.c(),			      h.b(), h.a(), h.c());    }    Comparison_result    operator()( const Line_2& l1, const Line_2& l2,	        const Line_2& h1, const Line_2& h2) const    {       return compare_y_at_xC2(l1.b(), l1.a(), l1.c(), l2.b(), l2.a(), l2.c(),			      h1.b(), h1.a(), h1.c(), h2.b(), h2.a(), h2.c());    }  };  template <typename K>  class Compare_xyz_3  {    typedef typename K::Point_3    Point_3;  public:    typedef Comparison_result  result_type;    typedef Arity_tag< 2 >     Arity;    Comparison_result    operator()( const Point_3& p, const Point_3& q) const    {       return compare_lexicographically_xyzC3(p.x(), p.y(), p.z(),					     q.x(), q.y(), q.z());    }  };  template <typename K>  class Compare_xy_2  {    typedef typename K::Point_2    Point_2;  public:    typedef Comparison_result  result_type;    typedef Arity_tag< 2 >     Arity;    Comparison_result    operator()( const Point_2& p, const Point_2& q) const    { return compare_lexicographically_xyC2(p.x(), p.y(), q.x(), q.y()); }  };  template <typename K>  class Compare_xy_3  {    typedef typename K::Point_3    Point_3;  public:    typedef Comparison_result  result_type;    typedef Arity_tag< 2 >     Arity;    Comparison_result    operator()( const Point_3& p, const Point_3& q) const    { return compare_lexicographically_xyC2(p.x(), p.y(), q.x(), q.y()); }  };  template <typename K>  class Compare_x_2  {    typedef typename K::Point_2    Point_2;    typedef typename K::Line_2     Line_2;  public:    typedef Comparison_result      result_type;    typedef Arity_tag< 2 >     Arity;    Comparison_result    operator()( const Point_2& p, const Point_2& q) const    { return CGAL_NTS compare(p.x(), q.x()); }    Comparison_result    operator()( const Point_2& p, const Line_2& l, const Line_2& h) const    { return compare_xC2(p.x(), l.a(), l.b(), l.c(), h.a(), h.b(), h.c()); }    Comparison_result    operator()( const Line_2& l, const Line_2& h1, const Line_2& h2) const    {      return compare_xC2(l.a(), l.b(), l.c(), h1.a(), h1.b(), h1.c(),			 h2.a(), h2.b(), h2.c());    }    Comparison_result    operator()( const Line_2& l1, const Line_2& l2,	        const Line_2& h1, const Line_2& h2) const    {       return compare_xC2(l1.a(), l1.b(), l1.c(), l2.a(), l2.b(), l2.c(),			 h1.a(), h1.b(), h1.c(), h2.a(), h2.b(), h2.c());    }  };  template <typename K>  class Compare_x_3  {    typedef typename K::Point_3    Point_3;  public:    typedef Comparison_result      result_type;    typedef Arity_tag< 2 >         Arity;    Comparison_result    operator()( const Point_3& p, const Point_3& q) const    { return CGAL_NTS compare(p.x(), q.x()); }  };  template <typename K>  class Compare_y_at_x_2  {    typedef typename K::Point_2    Point_2;    typedef typename K::Line_2     Line_2;    typedef typename K::Segment_2  Segment_2;  public:    typedef Comparison_result      result_type;    typedef Arity_tag< 3 >         Arity;    Comparison_result    operator()( const Point_2& p, const Line_2& h) const    { return compare_y_at_xC2(p.x(), p.y(), h.a(), h.b(), h.c()); }    Comparison_result    operator()( const Point_2& p, const Line_2& h1, const Line_2& h2) const    {      return compare_y_at_xC2(p.x(), h1.a(), h1.b(), h1.c(),			      h2.a(), h2.b(), h2.c());    }    Comparison_result    operator()( const Line_2& l1, const Line_2& l2, const Line_2& h) const    {      return compare_y_at_xC2(l1.a(), l1.b(), l1.c(), l2.a(), l2.b(), l2.c(),			      h.a(), h.b(), h.c());    }    Comparison_result    operator()( const Line_2& l1, const Line_2& l2,	        const Line_2& h1, const Line_2& h2) const    {      return compare_y_at_xC2(l1.a(), l1.b(), l1.c(), l2.a(), l2.b(), l2.c(),			      h1.a(), h1.b(), h1.c(), h2.a(), h2.b(), h2.c());    }    Comparison_result    operator()( const Point_2& p, const Segment_2& s) const    {      return compare_y_at_xC2(p.x(), p.y(),			      s.source().x(), s.source().y(),			      s.target().x(), s.target().y());    }    Comparison_result    operator()( const Point_2& p,	        const Segment_2& s1, const Segment_2& s2) const    {      return compare_y_at_x_segment_C2(p.x(),				       s1.source().x(), s1.source().y(),				       s1.target().x(), s1.target().y(),				       s2.source().x(), s2.source().y(),				       s2.target().x(), s2.target().y());    }  };  template <typename K>  class Compare_y_2  {    typedef typename K::Point_2   Point_2;    typedef typename K::Line_2    Line_2;  public:    typedef Comparison_result     result_type;    typedef Arity_tag< 2 >         Arity;    Comparison_result    operator()( const Point_2& p, const Point_2& q) const    { return CGAL_NTS compare(p.y(), q.y()); }    Comparison_result    operator()( const Point_2& p, const Line_2& l1, const Line_2& l2) const    {       return compare_xC2(p.y(), 			 l1.b(), l1.a(), l1.c(), 			 l2.b(), l2.a(), l2.c());    }    Comparison_result    operator()( const Line_2& l, const Line_2& h1, const Line_2& h2) const    {      return compare_xC2(l.b(), l.a(), l.c(), h1.b(), h1.a(), h1.c(),			 l.b(), l.a(), l.c(), h2.b(), h2.a(), h2.c());    }    Comparison_result    operator()( const Line_2& l1, const Line_2& l2,	        const Line_2& h1, const Line_2& h2) const    {      return compare_xC2(l1.b(), l1.a(), l1.c(), l2.b(), l2.a(), l2.c(),			 h1.b(), h1.a(), h1.c(), h2.b(), h2.a(), h2.c());    }  };  template <typename K>  class Compare_y_3  {    typedef typename K::Point_3   Point_3;  public:    typedef Comparison_result     result_type;    typedef Arity_tag< 2 >        Arity;    Comparison_result    operator()( const Point_3& p, const Point_3& q) const    { return CGAL_NTS compare(p.y(), q.y()); }  };  template <typename K>  class Compare_z_3  {    typedef typename K::Point_3   Point_3;  public:    typedef Comparison_result     result_type;    typedef Arity_tag< 2 >        Arity;    Comparison_result    operator()( const Point_3& p, const Point_3& q) const    { return CGAL_NTS compare(p.z(), q.z()); }  };  template <typename K>  class Compute_area_2  {    typedef typename K::FT                FT;    typedef typename K::Iso_rectangle_2   Iso_rectangle_2;    typedef typename K::Triangle_2        Triangle_2;    typedef typename K::Point_2           Point_2;  public:    typedef FT               result_type;    typedef Arity_tag< 1 >   Arity;    FT    operator()( const Point_2& p, const Point_2& q, const Point_2& r ) const    {      FT v1x = q.x() - p.x();      FT v1y = q.y() - p.y();      FT v2x = r.x() - p.x();      FT v2y = r.y() - p.y();      return det2x2_by_formula(v1x, v1y, v2x, v2y)/2;    }    FT    operator()( const Iso_rectangle_2& r ) const    { return r.area(); }    FT    operator()( const Triangle_2& t ) const    { return t.area(); }  };  template <typename K>  class Compute_scalar_product_2  {    typedef typename K::FT                FT;    typedef typename K::Vector_2          Vector_2;  public:    typedef FT               result_type;    typedef Arity_tag< 2 >   Arity;    FT    operator()(const Vector_2& v, const Vector_2& w) const    {	return v.x() * w.x() + v.y() * w.y();    }  };  template <typename K>  class Compute_scalar_product_3  {    typedef typename K::FT                FT;    typedef typename K::Vector_3          Vector_3;  public:    typedef FT               result_type;    typedef Arity_tag< 2 >   Arity;    FT    operator()(const Vector_3& v, const Vector_3& w) const    {	return v.x() * w.x() + v.y() * w.y() + v.z() * w.z();    }  };  template <typename K>  class Compute_squared_area_3  {    typedef typename K::FT                FT;    typedef typename K::Point_3           Point_3;    typedef typename K::Triangle_3        Triangle_3;  public:    typedef FT               result_type;    typedef Arity_tag< 1 >   Arity;    FT    operator()( const Triangle_3& t ) const    {	return this->operator()(t.vertex(0), t.vertex(1), t.vertex(2));    }    FT    operator()( const Point_3& p, const Point_3& q, const Point_3& r ) const    {	return squared_areaC3(p.x(), p.y(), p.z(),                              q.x(), q.y(), q.z(),                              r.x(), r.y(), r.z());    }  };  // FIXME  template <typename K>  class Compute_squared_distance_Point_Point_2 {    typedef typename K::FT       FT;    typedef typename K::Point_2  Point_2;  public:    typedef FT               result_type;    typedef Arity_tag< 2 >   Arity;    FT    operator()( const Point_2& p, const Point_2& q) const    {       return squared_distanceC2(p.x(), p.y(), q.x(), q.y());    }  };  // TODO ...  template <typename K>  class Compute_squared_radius_2  {    typedef typename K::FT          FT;    typedef typename K::Point_2     Point_2;    typedef typename K::Circle_2    Circle_2;  public:    typedef FT               result_type;    typedef Arity_tag< 1 >   Arity;    FT    operator()( const Circle_2& c) const    { return c.squared_radius(); }    FT    operator()( const Point_2& p, const Point_2& q) const    { return squared_radiusC2(p.x(), p.y(), q.x(), q.y()); }    FT    operator()( const Point_2& p, const Point_2& q, const Point_2& r) const    { return squared_radiusC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y()); }  };  template <typename K>  class Compute_squared_radius_3  {    typedef typename K::FT          FT;    typedef typename K::Point_3     Point_3;    typedef typename K::Sphere_3    Sphere_3;  public:    typedef FT               result_type;    typedef Arity_tag< 1 >   Arity;    FT    operator()( const Sphere_3& s) const    { return s.squared_radius(); }    FT    operator()( const Point_3& p, const Point_3& q) const    {      return squared_radiusC3(p.x(), p.y(), p.z(),			      q.x(), q.y(), q.z());    }    FT    operator()( const Point_3& p, const Point_3& q, const Point_3& r) const    {      return squared_radiusC3(p.x(), p.y(), p.z(),			      q.x(), q.y(), q.z(),			      r.x(), r.y(), r.z());    }    FT    operator()( const Point_3& p, const Point_3& q,	        const Point_3& r, const Point_3& s) const    {       return squared_radiusC3(p.x(), p.y(), p.z(),			      q.x(), q.y(), q.z(),			      r.x(), r.y(), r.z(),			      s.x(), s.y(), s.z());    }  };  template <typename K>  class Compute_volume_3  {    typedef typename K::FT             FT;    typedef typename K::Point_3        Point_3;    typedef typename K::Tetrahedron_3  Tetrahedron_3;    typedef typename K::Iso_cuboid_3   Iso_cuboid_3;  public:    typedef FT               result_type;    typedef Arity_tag< 1 >   Arity;    FT    operator()(const Point_3& p0, const Point_3& p1,	       const Point_3& p2, const Point_3& p3) const    {      return det3x3_by_formula(p1.x()-p0.x(), p1.y()-p0.y(), p1.z()-p0.z(),                               p2.x()-p0.x(), p2.y()-p0.y(), p2.z()-p0.z(),                               p3.x()-p0.x(), p3.y()-p0.y(), p3.z()-p0.z())/6;    }    FT    operator()( const Tetrahedron_3& t ) const    {      return this->operator()(t.vertex(0), t.vertex(1),		              t.vertex(2), t.vertex(3));    }    FT    operator()( const Iso_cuboid_3& c ) const

⌨️ 快捷键说明

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