function_objects.h
来自「CGAL is a collaborative effort of severa」· C头文件 代码 · 共 2,231 行 · 第 1/5 页
H
2,231 行
template <typename K> class Construct_opposite_vector_2 { typedef typename K::Vector_2 Vector_2; public: typedef Vector_2 result_type; typedef Arity_tag< 1 > Arity; Vector_2 operator()( const Vector_2& v) const { return Vector_2(-v.x(), -v.y()); } }; template <typename K> class Construct_opposite_vector_3 { typedef typename K::Vector_3 Vector_3; public: typedef Vector_3 result_type; typedef Arity_tag< 1 > Arity; Vector_3 operator()( const Vector_3& v) const { return Vector_3(-v.x(), -v.y(), -v.z()); } }; template <typename K> class Construct_orthogonal_vector_3 { typedef typename K::FT FT; typedef typename K::Point_3 Point_3; typedef typename K::Vector_3 Vector_3; typedef typename K::Plane_3 Plane_3; public: typedef Vector_3 result_type; typedef Arity_tag< 1 > Arity; Vector_3 operator()( const Plane_3& p ) const { return Vector_3(p.a(), p.b(), p.c()); } Vector_3 operator()( const Point_3& p, const Point_3& q, const Point_3& r ) const { FT rpx = p.x()-r.x(); FT rpy = p.y()-r.y(); FT rpz = p.z()-r.z(); FT rqx = q.x()-r.x(); FT rqy = q.y()-r.y(); FT rqz = q.z()-r.z(); // Cross product rp * rq FT vx = rpy*rqz - rqy*rpz; FT vy = rpz*rqx - rqz*rpx; FT vz = rpx*rqy - rqx*rpy; typename K::Construct_vector_3 construct_vector; return construct_vector(vx, vy, vz); } }; template <typename K> class Construct_projected_point_3 { typedef typename K::Point_3 Point_3; typedef typename K::Plane_3 Plane_3; typedef typename K::Line_3 Line_3; typedef typename K::FT FT; public: typedef Point_3 result_type; typedef Arity_tag< 2 > Arity; Point_3 operator()( const Line_3& l, const Point_3& p ) const { // projects p on the line l FT lpx = l.point().x(); FT lpy = l.point().y(); FT lpz = l.point().z(); FT ldx = l.direction().dx(); FT ldy = l.direction().dy(); FT ldz = l.direction().dz(); FT dpx = p.x()-lpx; FT dpy = p.y()-lpy; FT dpz = p.z()-lpz; FT lambda = (ldx*dpx+ldy*dpy+ldz*dpz) / (ldx*ldx+ldy*ldy+ldz*ldz); return Point_3(lpx + lambda * ldx, lpy + lambda * ldy, lpz + lambda * ldz); } Point_3 operator()( const Plane_3& h, const Point_3& p ) const { return h.projection(p); } }; template <typename K> class Construct_scaled_vector_2 { typedef typename K::FT FT; typedef typename K::Vector_2 Vector_2; public: typedef Vector_2 result_type; typedef Arity_tag< 2 > Arity; Vector_2 operator()( const Vector_2& v, const FT& c) const { return Vector_2(c * v.x(), c * v.y()); } }; template <typename K> class Construct_scaled_vector_3 { typedef typename K::FT FT; typedef typename K::Vector_3 Vector_3; public: typedef Vector_3 result_type; typedef Arity_tag< 2 > Arity; Vector_3 operator()( const Vector_3& w, const FT& c) const { return Vector_3(c * w.x(), c * w.y(), c * w.z()); } }; template <typename K> class Construct_translated_point_2 { typedef typename K::Point_2 Point_2; typedef typename K::Vector_2 Vector_2; public: typedef Point_2 result_type; typedef Arity_tag< 2 > Arity; Point_2 operator()( const Point_2& p, const Vector_2& v) const { typename K::Construct_point_2 construct_point_2; return construct_point_2(p.x() + v.x(), p.y() + v.y()); } Point_2 operator()( const Origin& , const Vector_2& v) const { typename K::Construct_point_2 construct_point_2; return construct_point_2(v.x(), v.y()); } }; template <typename K> class Construct_translated_point_3 { typedef typename K::Point_3 Point_3; typedef typename K::Vector_3 Vector_3; public: typedef Point_3 result_type; typedef Arity_tag< 2 > Arity; Point_3 operator()( const Point_3& p, const Vector_3& v) const { typename K::Construct_point_3 construct_point_3; return construct_point_3(p.x() + v.x(), p.y() + v.y(), p.z() + v.z()); } Point_3 operator()( const Origin& , const Vector_3& v) const { typename K::Construct_point_3 construct_point_3; return construct_point_3(v.x(), v.y(), v.z()); } }; template <typename K> class Construct_vector_2 { typedef typename K::RT RT; typedef typename K::FT FT; typedef typename K::Segment_2 Segment_2; typedef typename K::Ray_2 Ray_2; typedef typename K::Line_2 Line_2; typedef typename K::Vector_2 Vector_2; typedef typename K::Point_2 Point_2; public: typedef Vector_2 result_type; typedef Arity_tag< 2 > Arity; Vector_2 operator()() const { return Vector_2(); } Vector_2 operator()( const Point_2& p, const Point_2& q) const { return Vector_2(q.x() - p.x(), q.y() - p.y()); } Vector_2 operator()( const Origin&, const Point_2& q) const { return Vector_2(q.x(), q.y()); } Vector_2 operator()( const Point_2& p, const Origin& ) const { return Vector_2(-p.x(), -p.y()); } Vector_2 operator()( const Segment_2& s) const { return s.to_vector(); } Vector_2 operator()( const Ray_2& r) const { return r.to_vector(); } Vector_2 operator()( const Line_2& l) const { return l.to_vector(); } Vector_2 operator()( Null_vector) const { return Vector_2(FT(0), FT(0)); }// #ifndef CGAL_NO_DEPRECATED_CODE Vector_2 operator()( const RT& x, const RT& y) const { return Vector_2(x, y); } Vector_2 operator()( const RT& x, const RT& y, const RT& w) const { return Vector_2(x, y, w); }// #endif // CGAL_NO_DEPRECATED_CODE }; template <typename K> class Construct_vector_3 { typedef typename K::RT RT; typedef typename K::FT FT; typedef typename K::Segment_3 Segment_3; typedef typename K::Ray_3 Ray_3; typedef typename K::Line_3 Line_3; typedef typename K::Vector_3 Vector_3; typedef typename K::Point_3 Point_3; public: typedef Vector_3 result_type; typedef Arity_tag< 2 > Arity; Vector_3 operator()() const { return Vector_3(); } Vector_3 operator()( const Point_3& p, const Point_3& q) const { return Vector_3(q.x() - p.x(), q.y() - p.y(), q.z() - p.z()); } Vector_3 operator()( const Origin&, const Point_3& q) const { return Vector_3(q.x(), q.y(), q.z()); } Vector_3 operator()( const Point_3& p, const Origin&) const { return Vector_3(- p.x(), - p.y(), - p.z()); } Vector_3 operator()( const Segment_3& s) const { return s.to_vector(); } Vector_3 operator()( const Ray_3& r) const { return r.to_vector(); } Vector_3 operator()( const Line_3& l) const { return l.to_vector(); } Vector_3 operator()( const Null_vector&) const { return Vector_3(FT(0), FT(0), FT(0)); }// #ifndef CGAL_NO_DEPRECATED_CODE Vector_3 operator()( const RT& x, const RT& y, const RT& z) const { return Vector_3(x, y, z); } Vector_3 operator()( const RT& x, const RT& y, const RT& z, const RT& w) const { return Vector_3(x, y, z, w); }// #endif // CGAL_NO_DEPRECATED_CODE }; template <typename K> class Coplanar_orientation_3 { typedef typename K::Point_3 Point_3;#ifdef CGAL_kernel_exactness_preconditions typedef typename K::Coplanar_3 Coplanar_3; typedef typename K::Collinear_3 Collinear_3; Coplanar_3 cp; Collinear_3 cl;#endif // CGAL_kernel_exactness_preconditions public: typedef Orientation result_type; typedef Arity_tag< 4 > Arity;#ifdef CGAL_kernel_exactness_preconditions Coplanar_orientation_3() {} Coplanar_orientation_3(const Coplanar_3& cp_, const Collinear_3& cl_) : cp(cp_), cl(cl_) {}#endif // CGAL_kernel_exactness_preconditions Orientation operator()(const Point_3& p, const Point_3& q, const Point_3& r) const { return coplanar_orientationC3(p.x(), p.y(), p.z(), q.x(), q.y(), q.z(), r.x(), r.y(), r.z()); } Orientation operator()( const Point_3& p, const Point_3& q, const Point_3& r, const Point_3& s) const { // p,q,r,s supposed to be coplanar // p,q,r supposed to be non collinear // tests whether s is on the same side of p,q as r // returns : // COLLINEAR if pqr collinear // POSITIVE if qrp and qrs have the same orientation // NEGATIVE if qrp and qrs have opposite orientations CGAL_kernel_exactness_precondition( ! cl(p, q, r) ); CGAL_kernel_exactness_precondition( cp(p, q, r, s) ); return coplanar_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 Coplanar_side_of_bounded_circle_3 { typedef typename K::Point_3 Point_3;#ifdef CGAL_kernel_exactness_preconditions typedef typename K::Coplanar_3 Coplanar_3; typedef typename K::Collinear_3 Collinear_3; Coplanar_3 cp; Collinear_3 cl;#endif // CGAL_kernel_exactness_preconditions public: typedef Bounded_side result_type; typedef Arity_tag< 4 > Arity;#ifdef CGAL_kernel_exactness_preconditions Coplanar_side_of_bounded_circle_3() {} Coplanar_side_of_bounded_circle_3(const Coplanar_3& cp_, const Collinear_3& cl_) : cp(cp_), cl(cl_) {}#endif // CGAL_kernel_exactness_preconditions Bounded_side operator()( const Point_3& p, const Point_3& q, const Point_3& r, const Point_3& t) const { // p,q,r,t are supposed to be coplanar. // p,q,r determine an orientation of this plane (not collinear). // returns the equivalent of side_of_bounded_circle(p,q,r,t) // in this plane CGAL_kernel_exactness_precondition( cp(p,q,r,t) ); CGAL_kernel_exactness_precondition( !cl(p,q,r) ); return coplanar_side_of_bounded_circleC3(p.x(), p.y(), p.z(), q.x(), q.y(), q.z(), r.x(), r.y(), r.z(), t.x(), t.y(), t.z()); } }; template <typename K> class Equal_xy_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() && p.y() == q.y(); } }; template <typename K> class Equal_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 Equal_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 Equal_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 Equal_y_3 { typedef typename K::Point_3 Point_3; public: typedef bool result_type; typedef Arity_tag< 2 > Arity;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?