function_objects.h

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

H
2,231
字号
    bool    operator()( const Point_3& p, const Point_3& q) const    { return p.y() == q.y(); }  };  template <typename K>  class Equal_z_3  {    typedef typename K::Point_3    Point_3;  public:    typedef bool             result_type;    typedef Arity_tag< 2 >   Arity;    bool    operator()( const Point_3& p, const Point_3& q) const    { return p.z() == q.z(); }  };  template <typename K>  class Has_on_3  {    typedef typename K::FT               FT;    typedef typename K::Point_3          Point_3;    typedef typename K::Vector_3         Vector_3;    typedef typename K::Line_3           Line_3;    typedef typename K::Ray_3            Ray_3;    typedef typename K::Segment_3        Segment_3;    typedef typename K::Plane_3          Plane_3;    typedef typename K::Triangle_3       Triangle_3;  public:    typedef bool             result_type;    typedef Arity_tag< 2 >   Arity;    bool    operator()( const Line_3& l, const Point_3& p) const    { return l.has_on(p); }    bool    operator()( const Ray_3& r, const Point_3& p) const    { return r.has_on(p); }    bool    operator()( const Segment_3& s, const Point_3& p) const    { return s.has_on(p); }    bool    operator()( const Plane_3& pl, const Point_3& p) const    { return pl.has_on(p); }    bool    operator()( const Triangle_3& t, const Point_3& p) const    {      Point_3  o  = t.vertex(0) + t.supporting_plane().orthogonal_vector();      Vector_3 v0 = t.vertex(0)-o,               v1 = t.vertex(1)-o,               v2 = t.vertex(2)-o;      FT alpha, beta, gamma;      solve(v0, v1, v2, p-o, alpha, beta, gamma);      return (alpha >= FT(0)) && (beta >= FT(0)) && (gamma >= FT(0))          && ((alpha+beta+gamma == FT(1)));    }  };  template <typename K>  class Less_distance_to_point_2  {    typedef typename K::Point_2   Point_2;  public:    typedef bool             result_type;    typedef Arity_tag< 3 >   Arity;    bool    operator()(const Point_2& p, const Point_2& q, const Point_2& r) const    {       return has_smaller_dist_to_pointC2(p.x(), p.y(), 					 q.x(), q.y(), 					 r.x(), r.y());    }  };  template <typename K>  class Less_distance_to_point_3  {    typedef typename K::Point_3   Point_3;  public:    typedef bool             result_type;    typedef Arity_tag< 3 >   Arity;    bool    operator()(const Point_3& p, const Point_3& q, const Point_3& r) const    {       return has_smaller_dist_to_pointC3(p.x(), p.y(), p.z(),					 q.x(), q.y(), q.z(),					 r.x(), r.y(), r.z());    }  };  // TODO ...  template <typename K>  class Less_signed_distance_to_line_2  {    typedef typename K::Point_2   Point_2;    typedef typename K::Line_2   Line_2;    typedef typename K::Equal_2 Equal_2;  public:    typedef bool             result_type;    typedef Arity_tag< 4 >   Arity;    bool    operator()(const Point_2& a, const Point_2& b,               const Point_2& c, const Point_2& d) const    {      CGAL_kernel_precondition_code(Equal_2 equal;)      CGAL_kernel_precondition(! equal(a,b));      Comparison_result res = cmp_signed_dist_to_lineC2(a.x(), a.y(), 							b.x(), b.y(),							c.x(), c.y(),							d.x(), d.y());      if ( res == SMALLER ) return true;      return false;    }    bool    operator()(const Line_2& l, const Point_2& p, const Point_2& q) const    {      return has_smaller_signed_dist_to_directionC2(l.a(), l.b(), 						    p.x(), p.y(),						    q.x(), q.y());    }  };  template <typename K>  class Less_signed_distance_to_plane_3  {    typedef typename K::Point_3 Point_3;    typedef typename K::Plane_3 Plane_3;    typedef typename K::Collinear_3 Collinear_3;  public:    typedef bool             result_type;    typedef Arity_tag< 3 >   Arity;    bool    operator()( const Plane_3& h, const Point_3& p, const Point_3& q) const    {       return has_smaller_signed_dist_to_directionC3(h.a(), h.b(), h.c(),						    p.x(), p.y(), p.z(),						    q.x(), q.y(), q.z());    }    bool    operator()( const Point_3& hp, const Point_3& hq,  const Point_3& hr,		const Point_3& p, const Point_3& q) const    {       CGAL_kernel_precondition_code(Collinear_3 collinear_3;)      CGAL_kernel_precondition(! collinear_3(hp, hq, hr));      return has_smaller_signed_dist_to_planeC3(hp.x(), hp.y(), hp.z(),						hq.x(), hq.y(), hq.z(),						hr.x(), hr.y(), hr.z(),						p.x(),  p.y(),  p.z(),						q.x(),  q.y(),  q.z());;    }  };  template <typename K>  class Less_xyz_3  {    typedef typename K::Point_3 Point_3;    typedef typename K::Compare_xyz_3 Compare_xyz_3;    Compare_xyz_3 c;  public:    typedef bool             result_type;    typedef Arity_tag< 2 >   Arity;    Less_xyz_3() {}    Less_xyz_3(const Compare_xyz_3& c_) : c(c_) {}    bool    operator()( const Point_3& p, const Point_3& q) const    { return c(p, q) == SMALLER; }  };  template <typename K>  class Less_xy_2  {    typedef typename K::Point_2 Point_2;    typedef typename K::Compare_xy_2 Compare_xy_2;    Compare_xy_2 c;  public:    typedef bool             result_type;    typedef Arity_tag< 2 >   Arity;    Less_xy_2() {}    Less_xy_2(const Compare_xy_2& c_) : c(c_) {}    bool    operator()( const Point_2& p, const Point_2& q) const    { return c(p, q) == SMALLER; }  };  template <typename K>  class Less_xy_3  {    typedef typename K::Point_3 Point_3;    typedef typename K::Compare_xy_3 Compare_xy_3;    Compare_xy_3 c;  public:    typedef bool             result_type;    typedef Arity_tag< 2 >   Arity;    Less_xy_3() {}    Less_xy_3(const Compare_xy_3& c_) : c(c_) {}    bool    operator()( const Point_3& p, const Point_3& q) const    { return c(p, q) == SMALLER; }  };  template <typename K>  class Less_x_2  {    typedef typename K::Point_2 Point_2;  public:    typedef bool             result_type;    typedef Arity_tag< 2 >   Arity;    bool    operator()( const Point_2& p, const Point_2& q) const    { return p.x() < q.x(); }  };  template <typename K>  class Less_x_3  {    typedef typename K::Point_3 Point_3;  public:    typedef bool             result_type;    typedef Arity_tag< 2 >   Arity;    bool    operator()( const Point_3& p, const Point_3& q) const    { return p.x() < q.x(); }  };  template <typename K>  class Less_yx_2  {    typedef typename K::Point_2       Point_2;  public:    typedef bool             result_type;    typedef Arity_tag< 2 >   Arity;    bool    operator()( const Point_2& p, const Point_2& q) const    {       return compare_lexicographically_xyC2(p.y(), p.x(), 					    q.y(), q.x()) == SMALLER;     }  };  template <typename K>  class Less_y_2  {    typedef typename K::Point_2 Point_2;  public:    typedef bool             result_type;    typedef Arity_tag< 2 >   Arity;    bool    operator()( const Point_2& p, const Point_2& q) const    { return p.y() < q.y(); }  };  template <typename K>  class Less_y_3  {    typedef typename K::Point_3 Point_3;  public:    typedef bool             result_type;    typedef Arity_tag< 2 >   Arity;    bool    operator()( const Point_3& p, const Point_3& q) const    { return p.y() < q.y(); }  };  template <typename K>  class Less_z_3  {    typedef typename K::Point_3 Point_3;  public:    typedef bool             result_type;    typedef Arity_tag< 2 >   Arity;    bool    operator()( const Point_3& p, const Point_3& q) const    { return p.z() < q.z(); }  };  template <typename K>  class Orientation_2  {    typedef typename K::Point_2 Point_2;  public:    typedef Orientation      result_type;    typedef Arity_tag< 3 >   Arity;    Orientation    operator()(const Point_2& p, const Point_2& q, const Point_2& r) const    {       return orientationC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y());    }  };  template <typename K>  class Orientation_3  {    typedef typename K::Point_3 Point_3;  public:    typedef Orientation      result_type;    typedef Arity_tag< 4 >   Arity;    Orientation    operator()( const Point_3& p, const Point_3& q,	        const Point_3& r, const Point_3& s) const    {       return orientationC3(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 Side_of_bounded_circle_2  {    typedef typename K::Point_2        Point_2;  public:    typedef Bounded_side     result_type;    typedef Arity_tag< 4 >   Arity;    Bounded_side    operator()( const Point_2& p, const Point_2& q, const Point_2& t) const    {       return side_of_bounded_circleC2(p.x(), p.y(), 				      q.x(), q.y(), 				      t.x(), t.y());    }    Bounded_side    operator()( const Point_2& p, const Point_2& q,	        const Point_2& r, const Point_2& t) const    {       return side_of_bounded_circleC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y(),				      t.x(), t.y());    }  };  template <typename K>  class Side_of_bounded_sphere_3  {    typedef typename K::Point_3        Point_3;  public:    typedef Bounded_side   result_type;    typedef Arity_tag< 5 >   Arity;    Bounded_side    operator()( const Point_3& p, const Point_3& q, const Point_3& test) const    {       return side_of_bounded_sphereC3(p.x(), p.y(), p.z(),				      q.x(), q.y(), q.z(),				      test.x(), test.y(), test.z());    }    Bounded_side    operator()( const Point_3& p, const Point_3& q,	        const Point_3& r, const Point_3& test) const    {      return side_of_bounded_sphereC3(p.x(), p.y(), p.z(),				      q.x(), q.y(), q.z(),				      r.x(), r.y(), r.z(),				      test.x(), test.y(), test.z());    }    Bounded_side    operator()( const Point_3& p, const Point_3& q, const Point_3& r,	        const Point_3& s, const Point_3& test) const    {      return side_of_bounded_sphereC3(p.x(), p.y(), p.z(),				      q.x(), q.y(), q.z(),				      r.x(), r.y(), r.z(),				      s.x(), s.y(), s.z(),				      test.x(), test.y(), test.z());    }  };  template <typename K>  class Side_of_oriented_circle_2  {    typedef typename K::Point_2        Point_2;  public:    typedef Oriented_side    result_type;    typedef Arity_tag< 4 >   Arity;    Oriented_side    operator()( const Point_2& p, const Point_2& q,	        const Point_2& r, const Point_2& t) const    {      return side_of_oriented_circleC2(p.x(), p.y(), 				       q.x(), q.y(), 				       r.x(), r.y(),				       t.x(), t.y());    }  };  template <typename K>  class Side_of_oriented_sphere_3  {    typedef typename K::Point_3        Point_3;  public:    typedef Oriented_side    result_type;    typedef Arity_tag< 5 >   Arity;    Oriented_side    operator()( const Point_3& p, const Point_3& q, const Point_3& r,	        const Point_3& s, const Point_3& test) const    {       return side_of_oriented_sphereC3(p.x(), p.y(), p.z(),				       q.x(), q.y(), q.z(),				       r.x(), r.y(), r.z(),				       s.x(), s.y(), s.z(),				       test.x(), test.y(), test.z());    }  };} // namespace CartesianKernelFunctorsCGAL_END_NAMESPACE#endif // CGAL_CARTESIAN_FUNCTION_OBJECTS_H

⌨️ 快捷键说明

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