function_objects.h

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

H
2,231
字号
    { return c.volume(); }  };  template <typename K>  class Construct_base_vector_3  {    typedef typename K::Vector_3   Vector_3;    typedef typename K::Plane_3    Plane_3;    typedef typename K::FT         FT;    typedef typename K::Construct_cross_product_vector_3    Construct_cross_product_vector_3;    typedef typename K::Construct_orthogonal_vector_3     Construct_orthogonal_vector_3;    Construct_cross_product_vector_3 cp;    Construct_orthogonal_vector_3 co;  public:    typedef Vector_3         result_type;    typedef Arity_tag< 2 >   Arity;    Construct_base_vector_3() {}    Construct_base_vector_3(const Construct_cross_product_vector_3& cp_,			    const Construct_orthogonal_vector_3& co_)      : cp(cp_), co(co_)    {}      Vector_3    operator()( const Plane_3& h, int index ) const    {      if (index == 1) {	if ( CGAL_NTS is_zero(h.a()) )  // parallel to x-axis	  return Vector_3(FT(1), FT(0), FT(0));	 	if ( CGAL_NTS is_zero(h.b()) )  // parallel to y-axis	  return Vector_3(FT(0), FT(1), FT(0));	 	if ( CGAL_NTS is_zero(h.c()) )  // parallel to z-axis	  return Vector_3(FT(0), FT(0), FT(1));	 	return Vector_3(-h.b(), h.a(), FT(0));      } else {	return cp(co(h), this->operator()(h,1));      }    }  };  template <typename K>  class Construct_bisector_2  {    typedef typename K::FT      FT;    typedef typename K::Point_2 Point_2;    typedef typename K::Line_2  Line_2;  public:    typedef Line_2           result_type;    typedef Arity_tag< 2 >   Arity;    Line_2    operator()(const Point_2& p, const Point_2& q) const    {      FT a, b, c;      bisector_of_pointsC2(p.x(), p.y(), q.x(), q.y(), a, b, c);      return Line_2(a, b, c);    }    Line_2    operator()(const Line_2& p, const Line_2& q) const    {      FT a, b, c;      bisector_of_linesC2(p.a(), p.b(), p.c(),                          q.a(), q.b(), q.c(),                          a, b, c);      return Line_2(a, b, c);    }  };  template <typename K>  class Construct_bisector_3  {    typedef typename K::FT      FT;    typedef typename K::Point_3 Point_3;    typedef typename K::Plane_3 Plane_3;  public:    typedef Plane_3          result_type;    typedef Arity_tag< 2 >   Arity;    Plane_3    operator()(const Point_3& p, const Point_3& q) const    {      FT a, b, c, d;      bisector_of_pointsC3(p.x(), p.y(), p.z(),	                   q.x(), q.y(), q.z(),			   a, b, c, d);      return Plane_3(a, b, c, d);    }    Plane_3    operator()(const Plane_3& p, const Plane_3& q) const    {      FT a, b, c, d;      bisector_of_planesC3(p.a(), p.b(), p.c(), p.d(),                           q.a(), q.b(), q.c(), q.d(),                           a, b, c, d);      return Plane_3(a, b, c, d);    }  };  template <typename K>  class Construct_centroid_2  {    typedef typename K::FT       FT;    typedef typename K::Point_2  Point_2;  public:    typedef Point_2          result_type;    typedef Arity_tag< 3 >   Arity;    Point_2    operator()(const Point_2& p, const Point_2& q, const Point_2& r) const    {      typename K::Construct_point_2 construct_point_2;      FT x, y;      centroidC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y(), x, y);      return construct_point_2(x, y);    }    Point_2    operator()(const Point_2& p, const Point_2& q,                const Point_2& r, const Point_2& s) const    {      typename K::Construct_point_2 construct_point_2;      FT x, y;      centroidC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y(), s.x(), s.y(), x, y);      return construct_point_2(x, y);    }  };  template <typename K>  class Construct_centroid_3  {    typedef typename K::FT       FT;    typedef typename K::Point_3  Point_3;  public:    typedef Point_3          result_type;    typedef Arity_tag< 3 >   Arity;    Point_3    operator()(const Point_3& p, const Point_3& q, const Point_3& r) const    {       typename K::Construct_point_3 construct_point_3;      FT x, y, z;      centroidC3(p.x(), p.y(), p.z(),		 q.x(), q.y(), q.z(),		 r.x(), r.y(), r.z(),		 x, y, z);      return construct_point_3(x, y, z);    }    Point_3    operator()(const Point_3& p, const Point_3& q,                const Point_3& r, const Point_3& s) const    {      typename K::Construct_point_3 construct_point_3;      FT x, y, z;      centroidC3(p.x(), p.y(), p.z(),		 q.x(), q.y(), q.z(),		 r.x(), r.y(), r.z(),		 s.x(), s.y(), s.z(),		 x, y, z);      return construct_point_3(x, y, z);    }  };  template <typename K>  class Construct_circumcenter_2  {    typedef typename K::Point_2     Point_2;    typedef typename K::Triangle_2  Triangle_2;  public:    typedef Point_2          result_type;    typedef Arity_tag< 3 >   Arity;    Point_2    operator()(const Point_2& p, const Point_2& q, const Point_2& r) const    {       typename K::Construct_point_2 construct_point_2;      typedef typename K::FT        FT;      FT x, y;      circumcenterC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y(), x, y);      return construct_point_2(x, y);    }    Point_2    operator()(const Triangle_2& t) const    {       return this->operator()(t.vertex(0), t.vertex(1), t.vertex(2));    }  };  template <typename K>  class Construct_circumcenter_3  {    typedef typename K::FT             FT;    typedef typename K::Tetrahedron_3  Tetrahedron_3;    typedef typename K::Triangle_3     Triangle_3;    typedef typename K::Point_3        Point_3;  public:    typedef Point_3          result_type;    typedef Arity_tag< 4 >   Arity;    Point_3    operator()(const Point_3& p, const Point_3& q, const Point_3& r) const    {       typename K::Construct_point_3 construct_point_3;      FT x, y, z;      circumcenterC3(p.x(), p.y(), p.z(),		     q.x(), q.y(), q.z(),		     r.x(), r.y(), r.z(),		     x, y, z);      return construct_point_3(x, y, z);    }    Point_3    operator()(const Triangle_3& t) const    {       return this->operator()(t.vertex(0), t.vertex(1), t.vertex(2));    }    Point_3    operator()(const Point_3& p, const Point_3& q,	       const Point_3& r, const Point_3& s) const    {      typename K::Construct_point_3 construct_point_3;      FT x, y, z;      circumcenterC3(p.x(), p.y(), p.z(),		     q.x(), q.y(), q.z(),		     r.x(), r.y(), r.z(),		     s.x(), s.y(), s.z(),		     x, y, z);      return construct_point_3(x, y, z);    }    Point_3    operator()(const Tetrahedron_3& t) const    {       return this->operator()(t.vertex(0), t.vertex(1),                              t.vertex(2), t.vertex(3));    }  };  template <typename K>  class Construct_cross_product_vector_3  {    typedef typename K::Vector_3  Vector_3;  public:    typedef Vector_3         result_type;    typedef Arity_tag< 2 >   Arity;    Vector_3    operator()(const Vector_3& v, const Vector_3& w) const    {      return Vector_3(v.y() * w.z() - v.z() * w.y(),		      v.z() * w.x() - v.x() * w.z(),		      v.x() * w.y() - v.y() * w.x());    }  };  template <typename K>  class Construct_lifted_point_3  {    typedef typename K::Point_2                    Point_2;    typedef typename K::Point_3                    Point_3;    typedef typename K::Plane_3                    Plane_3;    typedef typename K::Construct_base_vector_3    Construct_base_vector_3;    typedef typename K::Construct_point_on_3       Construct_point_on_3;    typedef typename K::Construct_scaled_vector_3  Construct_scaled_vector_3;    typedef typename K::Construct_translated_point_3      Construct_translated_point_3;    Construct_base_vector_3 cb;    Construct_point_on_3 cp;    Construct_scaled_vector_3 cs;    Construct_translated_point_3 ct;  public:    typedef Point_3          result_type;    typedef Arity_tag< 2 >   Arity;    Construct_lifted_point_3() {}    Construct_lifted_point_3(const Construct_base_vector_3& cb_,			     const Construct_point_on_3& cp_,			     const Construct_scaled_vector_3& cs_,			     const Construct_translated_point_3& ct_)      : cb(cb_), cp(cp_), cs(cs_), ct(ct_)    {}    Point_3    operator()(const Plane_3& h, const Point_2& p) const    {        return ct(ct(cp(h), cs(cb(h,1), p.x())), cs(cb(h,2), p.y()));    }  };  template <typename K>  class Construct_line_2  {    typedef typename K::RT                        RT;    typedef typename K::FT                        FT;    typedef typename K::Point_2                   Point_2;    typedef typename K::Direction_2               Direction_2;    typedef typename K::Vector_2                  Vector_2;    typedef typename K::Segment_2                 Segment_2;    typedef typename K::Ray_2                     Ray_2;    typedef typename K::Line_2                    Line_2;    typedef typename K::Construct_point_on_2      Construct_point_on_2;    Construct_point_on_2 c;  public:    typedef Line_2            result_type;    typedef Arity_tag< 2 >    Arity;    Construct_line_2() {}    Construct_line_2(const Construct_point_on_2& c_) : c(c_) {}    Line_2    operator()() const    { return Line_2(); }// #ifndef CGAL_NO_DEPRECATED_CODE    Line_2    operator()(const RT& a, const RT& b, const RT& cc) const    { return Line_2(a, b, cc); }// #endif // CGAL_NO_DEPRECATED_CODE    Line_2    operator()(const Point_2& p, const Point_2& q) const    {       FT a, b, cc;      line_from_pointsC2(p.x(), p.y(), q.x(), q.y(), a, b, cc);      return Line_2(a, b, cc);    }    Line_2    operator()(const Point_2& p, const Direction_2& d) const    {       FT a, b, cc;      line_from_point_directionC2(p.x(), p.y(), d.dx(), d.dy(), a, b, cc);      return Line_2(a, b, cc);    }    Line_2    operator()(const Point_2& p, const Vector_2& v) const    {       FT a, b, cc;      line_from_point_directionC2(p.x(), p.y(), v.x(), v.y(), a, b, cc);      return Line_2(a, b, cc);    }    Line_2    operator()(const Segment_2& s) const    { return this->operator()(c(s, 0), c(s, 1)); }    Line_2    operator()(const Ray_2& r) const    { return this->operator()(c(r, 0), c(r, 1)); }  };  template <typename K>  class Construct_line_3  {    typedef typename K::Point_3                   Point_3;    typedef typename K::Direction_3               Direction_3;    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::Construct_vector_3        Construct_vector_3;    typedef typename K::Construct_direction_3     Construct_direction_3;    typedef typename K::Construct_point_on_3      Construct_point_on_3;    Construct_vector_3 cv;    Construct_point_on_3 cp;  public:    typedef Line_3            result_type;    typedef Arity_tag< 2 >    Arity;    Construct_line_3() {}    Construct_line_3(const Construct_vector_3& cv_,		     const Construct_point_on_3& cp_)       : cv(cv_), cp(cp_)     {}    Line_3    operator()() const    { return Line_3(); }    Line_3    operator()(const Point_3& p, const Point_3& q) const    { return Line_3(p, cv(p, q)); }    Line_3    operator()(const Point_3& p, const Direction_3& d) const    { return operator()(p, cv(d.dx(), d.dy(), d.dz())); }    Line_3    operator()(const Point_3& p, const Vector_3& v) const    { return Line_3(p, v); }    Line_3    operator()(const Segment_3& s) const    { return Line_3(cp(s,0), cv(cp(s,0), cp(s,1))); }    Line_3    operator()(const Ray_3& r) const    { return Line_3(cp(r,0), cv(cp(r,0), cp(r,1))); }  };  template <typename K>  class Construct_midpoint_2  {    typedef typename K::FT        FT;    typedef typename K::Point_2   Point_2;  public:    typedef Point_2          result_type;    typedef Arity_tag< 2 >   Arity;    Point_2    operator()(const Point_2& p, const Point_2& q) const    {       typename K::Construct_point_2 construct_point_2;      FT x, y;      midpointC2(p.x(), p.y(), q.x(), q.y(), x, y);      return construct_point_2(x, y);    }  };  template <typename K>  class Construct_midpoint_3  {    typedef typename K::FT        FT;    typedef typename K::Point_3   Point_3;  public:    typedef Point_3          result_type;    typedef Arity_tag< 2 >   Arity;    Point_3    operator()(const Point_3& p, const Point_3& q) const    {       typename K::Construct_point_3 construct_point_3;      FT x, y, z;      midpointC3(p.x(), p.y(), p.z(), q.x(), q.y(), q.z(), x, y, z);      return construct_point_3(x, y, z);    }  };

⌨️ 快捷键说明

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