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

📄 function_objects.h

📁 很多二维 三维几何计算算法 C++ 类库
💻 H
📖 第 1 页 / 共 5 页
字号:
// Copyright (c) 1999,2002,2005  Utrecht University (The Netherlands),// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),// and Tel-Aviv University (Israel).  All rights reserved.//// This file is part of CGAL (www.cgal.org); you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public License as// published by the Free Software Foundation; version 2.1 of the License.// See the file LICENSE.LGPL distributed with CGAL.//// Licensees holding a valid commercial license may use this file in// accordance with the commercial license agreement provided with the software.//// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.//// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.3-branch/Kernel_23/include/CGAL/Kernel/function_objects.h $// $Id: function_objects.h 37195 2007-03-17 09:51:49Z afabri $////// Author(s)     : Stefan Schirra, Sylvain Pion#ifndef CGAL_KERNEL_FUNCTION_OBJECTS_H#define CGAL_KERNEL_FUNCTION_OBJECTS_H#include <CGAL/functional_base.h>#include <CGAL/Origin.h>#include <CGAL/Bbox_2.h>#include <CGAL/Bbox_3.h>#include <CGAL/Kernel/Cartesian_coordinate_iterator_2.h>#include <CGAL/Kernel/Cartesian_coordinate_iterator_3.h>#include <CGAL/squared_distance_2.h>#include <CGAL/squared_distance_3.h>#include <CGAL/intersection_2.h>#include <CGAL/intersection_3.h>#include <CGAL/Kernel/Return_base_tag.h>CGAL_BEGIN_NAMESPACEnamespace CommonKernelFunctors {  template <typename K>  class Are_ordered_along_line_2  {    typedef typename K::Point_2     Point_2;    typedef typename K::Collinear_2 Collinear_2;    typedef typename K::Collinear_are_ordered_along_line_2    Collinear_are_ordered_along_line_2;    Collinear_2 c;    Collinear_are_ordered_along_line_2 cao;  public:    typedef typename K::Bool_type   result_type;    typedef Arity_tag< 3 >          Arity;    Are_ordered_along_line_2() {}    Are_ordered_along_line_2(const Collinear_2& c_,			     const Collinear_are_ordered_along_line_2& cao_)      : c(c_), cao(cao_)    {}    result_type    operator()(const Point_2& p, const Point_2& q, const Point_2& r) const    { return c(p, q, r) && cao(p, q, r); }  };  template <typename K>  class Are_ordered_along_line_3  {    typedef typename K::Point_3     Point_3;    typedef typename K::Collinear_3 Collinear_3;    typedef typename K::Collinear_are_ordered_along_line_3    Collinear_are_ordered_along_line_3;    Collinear_3 c;    Collinear_are_ordered_along_line_3 cao;  public:    typedef typename K::Bool_type   result_type;    typedef Arity_tag< 3 >          Arity;    Are_ordered_along_line_3() {}    Are_ordered_along_line_3(const Collinear_3& c_,			     const Collinear_are_ordered_along_line_3& cao_)      : c(c_), cao(cao_)    {}    result_type    operator()(const Point_3& p, const Point_3& q, const Point_3& r) const    { return c(p, q, r) && cao(p, q, r); }  };  template <typename K>  class Are_strictly_ordered_along_line_2  {    typedef typename K::Point_2     Point_2;    typedef typename K::Collinear_2 Collinear_2;    typedef typename K::Collinear_are_strictly_ordered_along_line_2    Collinear_are_strictly_ordered_along_line_2;    Collinear_2 c;    Collinear_are_strictly_ordered_along_line_2 cao;  public:    typedef typename K::Bool_type   result_type;    typedef Arity_tag< 3 >          Arity;    Are_strictly_ordered_along_line_2() {}    Are_strictly_ordered_along_line_2(				      const Collinear_2& c_,				      const Collinear_are_strictly_ordered_along_line_2& cao_)      : c(c_), cao(cao_)    {}    result_type    operator()(const Point_2& p, const Point_2& q, const Point_2& r) const    { return c(p, q, r) && cao(p, q, r); }  };  template <typename K>  class Are_strictly_ordered_along_line_3  {    typedef typename K::Point_3     Point_3;    typedef typename K::Collinear_3 Collinear_3;    typedef typename K::Collinear_are_strictly_ordered_along_line_3    Collinear_are_strictly_ordered_along_line_3;    Collinear_3 c;    Collinear_are_strictly_ordered_along_line_3 cao;  public:    typedef typename K::Bool_type   result_type;    typedef Arity_tag< 3 >          Arity;    Are_strictly_ordered_along_line_3() {}    Are_strictly_ordered_along_line_3(				      const Collinear_3& c_,				      const Collinear_are_strictly_ordered_along_line_3& cao_)      : c(c_), cao(cao_)    {}    result_type    operator()(const Point_3& p, const Point_3& q, const Point_3& r) const    { return c(p, q, r) && cao(p, q, r); }  };  template <typename K>  class Assign_2  {    typedef typename K::Object_2  Object_2;  public:    //typedef typename K::Bool_type result_type;    typedef bool                  result_type;    typedef Arity_tag< 2 >        Arity;    template <class T>    result_type    operator()(T& t, const Object_2& o) const    { return assign(t, o); }  };  template <typename K>  class Assign_3  {    typedef typename K::Object_3        Object_3;  public:    //typedef typename K::Bool_type       result_type;    typedef bool                        result_type;    typedef Arity_tag< 2 >              Arity;    template <class T>    result_type    operator()(T& t, const Object_3& o) const    { return assign(t, o); }  };  template <typename K>  class Compute_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 CGAL_NTS sqrt(K().compute_squared_area_3_object()(t));    }    FT    operator()( const Point_3& p, const Point_3& q, const Point_3& r ) const    {	return CGAL_NTS sqrt(K().compute_squared_area_3_object()(p, q, r));    }  };  template <typename K>  class Compute_squared_distance_2  {    typedef typename K::FT   FT;  public:    typedef FT               result_type;    typedef Arity_tag< 2 >   Arity;    // There are 25 combinaisons, we use a template.    template <class T1, class T2>    FT    operator()( const T1& t1, const T2& t2) const    { return CGALi::squared_distance(t1, t2, K()); }  };  template <typename K>  class Compute_squared_distance_3  {    typedef typename K::FT        FT;    typedef typename K::Point_3   Point_3;  public:    typedef FT               result_type;    typedef Arity_tag< 2 >   Arity;    // There are 25 combinaisons, we use a template.    template <class T1, class T2>    FT    operator()( const T1& t1, const T2& t2) const    { return CGALi::squared_distance(t1, t2, K()); }    FT    operator()( const Point_3& pt1, const Point_3& pt2) const    {      typedef typename K::Vector_3 Vector_3;      Vector_3 vec = pt2 - pt1;      return vec*vec;    }  };  template <typename K>  class Compute_squared_length_2  {    typedef typename K::FT          FT;    typedef typename K::Segment_2   Segment_2;    typedef typename K::Vector_2    Vector_2;  public:    typedef FT               result_type;    typedef Arity_tag< 1 >   Arity;    FT    operator()( const Vector_2& v) const    { return CGAL_NTS square(K().compute_x_2_object()(v)) +             CGAL_NTS square(K().compute_y_2_object()(v));}    FT    operator()( const Segment_2& s) const    { return K().compute_squared_distance_2_object()(s.source(), s.target()); }  };  template <typename K>  class Compute_squared_length_3  {    typedef typename K::FT          FT;    typedef typename K::Segment_3   Segment_3;    typedef typename K::Vector_3    Vector_3;  public:    typedef FT               result_type;    typedef Arity_tag< 1 >   Arity;    FT    operator()( const Vector_3& v) const    { return v.rep().squared_length(); }    FT    operator()( const Segment_3& s) const    { return s.squared_length(); }  };  template <typename K>  class Compute_a_2  {    typedef typename K::RT             RT;    typedef typename K::Line_2         Line_2;  public:    typedef RT               result_type;    typedef Arity_tag< 1 >   Arity;    RT    operator()(const Line_2& l) const    {      return l.rep().a();    }  };  template <typename K>  class Compute_a_3  {    typedef typename K::RT             RT;    typedef typename K::Plane_3        Plane_3;  public:    typedef RT               result_type;    typedef Arity_tag< 1 >   Arity;    RT    operator()(const Plane_3& l) const    {      return l.rep().a();    }  };  template <typename K>  class Compute_b_2  {    typedef typename K::RT             RT;    typedef typename K::Line_2         Line_2;  public:    typedef RT               result_type;    typedef Arity_tag< 1 >   Arity;    RT    operator()(const Line_2& l) const    {      return l.rep().b();    }  };  template <typename K>  class Compute_b_3  {    typedef typename K::RT             RT;    typedef typename K::Plane_3        Plane_3;  public:    typedef RT               result_type;    typedef Arity_tag< 1 >   Arity;    RT    operator()(const Plane_3& l) const    {      return l.rep().b();    }  };  template <typename K>  class Compute_c_2  {    typedef typename K::RT             RT;    typedef typename K::Line_2         Line_2;  public:    typedef RT               result_type;    typedef Arity_tag< 1 >   Arity;    RT    operator()(const Line_2& l) const    {      return l.rep().c();    }  };  template <typename K>  class Compute_c_3  {    typedef typename K::RT             RT;    typedef typename K::Plane_3        Plane_3;  public:    typedef RT               result_type;    typedef Arity_tag< 1 >   Arity;    RT    operator()(const Plane_3& l) const    {      return l.rep().c();    }  };  template <typename K>  class Compute_d_3  {    typedef typename K::RT             RT;    typedef typename K::Plane_3        Plane_3;  public:    typedef RT               result_type;    typedef Arity_tag< 1 >   Arity;    RT    operator()(const Plane_3& l) const    {      return l.rep().d();    }  };  template <typename K>  class Compute_x_at_y_2  {    typedef typename K::FT             FT;    typedef typename K::Point_2        Point_2;    typedef typename K::Line_2         Line_2;  public:    typedef FT               result_type;    typedef Arity_tag< 1 >   Arity;    FT    operator()(const Line_2& l, const FT& y) const    {      CGAL_kernel_precondition( ! l.is_degenerate() );      return (FT(-l.b())*y - FT(l.c()) )/FT(l.a());    }  };  template <typename K>  class Compute_y_at_x_2  {    typedef typename K::FT             FT;    typedef typename K::Point_2        Point_2;    typedef typename K::Line_2         Line_2;  public:    typedef FT               result_type;    typedef Arity_tag< 1 >   Arity;    FT    operator()(const Line_2& l, const FT& x) const    {      CGAL_kernel_precondition_msg( ! l.is_vertical(),		    "Compute_y_at_x(FT x) is undefined for vertical line");      return (FT(-l.a())*x - FT(l.c()) )/FT(l.b());    }  };  template <typename K>  class Compute_xmin_2  {    typedef typename K::FT              FT;    typedef typename K::Iso_rectangle_2 Iso_rectangle_2;    typedef FT                          Cartesian_coordinate_type;    //typedef typename K::Cartesian_coordinate_type  Cartesian_coordinate_type;  public:    typedef FT               result_type;    typedef Arity_tag< 1 >   Arity;    Cartesian_coordinate_type    operator()(const Iso_rectangle_2& r) const    {      return (r.min)().x();    }  };  template <typename K>  class Compute_xmin_3  {    typedef typename K::FT              FT;    typedef typename K::Iso_cuboid_3    Iso_cuboid_3;    typedef FT                          Cartesian_coordinate_type;    //typedef typename K::Cartesian_coordinate_type  Cartesian_coordinate_type;  public:    typedef FT               result_type;    typedef Arity_tag< 1 >   Arity;    Cartesian_coordinate_type    operator()(const Iso_cuboid_3& r) const    {      return (r.min)().x();

⌨️ 快捷键说明

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