function_objects.h
来自「CGAL is a collaborative effort of severa」· C头文件 代码 · 共 2,060 行 · 第 1/4 页
H
2,060 行
// Copyright (c) 1999,2002 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.//// $Source: /CVSROOT/CGAL/Packages/Kernel_23/include/CGAL/Kernel/function_objects.h,v $// $Revision: 1.76 $ $Date: 2004/09/14 13:59:09 $// $Name: $//// 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>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 bool 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_) {} bool 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 bool 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_) {} bool 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 bool 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_) {} bool 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 bool 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_) {} bool 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 bool result_type; typedef Arity_tag< 2 > Arity; template <class T> bool 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 bool result_type; typedef Arity_tag< 2 > Arity; template <class T> bool operator()(T& t, const Object_3& o) const { return assign(t, o); } }; template <typename K> class Bounded_side_2 { typedef typename K::Point_2 Point_2; typedef typename K::Circle_2 Circle_2; typedef typename K::Triangle_2 Triangle_2; typedef typename K::Iso_rectangle_2 Iso_rectangle_2; public: typedef Bounded_side result_type; typedef Arity_tag< 2 > Arity; Bounded_side operator()( const Circle_2& c, const Point_2& p) const { return c.bounded_side(p); } Bounded_side operator()( const Triangle_2& t, const Point_2& p) const { return t.bounded_side(p); } Bounded_side operator()( const Iso_rectangle_2& r, const Point_2& p) const { return r.bounded_side(p); } }; 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; 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_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 v.squared_length(); } FT operator()( const Segment_2& s) const { return s.squared_length(); } }; 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.squared_length(); } FT operator()( const Segment_3& s) const { return s.squared_length(); } }; template <typename K> class Construct_center_2 { typedef typename K::Point_2 Point_2; typedef typename K::Circle_2 Circle_2; public: typedef Point_2 result_type; typedef Arity_tag< 1 > Arity; Point_2 operator()(const Circle_2& c) const { return c.center(); } }; template <typename K> class Construct_center_3 { typedef typename K::Point_3 Point_3; typedef typename K::Sphere_3 Sphere_3; public: typedef Point_3 result_type; typedef Arity_tag< 1 > Arity; Point_3 operator()(const Sphere_3& s) const { return s.center(); } }; template <typename K> class Construct_circle_2 { typedef typename K::FT FT; typedef typename K::Point_2 Point_2; typedef typename K::Circle_2 Circle_2; public: typedef Circle_2 result_type; typedef Arity_tag< 3 > Arity; Circle_2 operator()() const { return Circle_2(); } Circle_2 operator()( const Point_2& center, const FT& squared_radius, Orientation orientation = COUNTERCLOCKWISE) const { return Circle_2(center, squared_radius, orientation); } Circle_2 operator()( const Point_2& p, const Point_2& q, const Point_2& r) const { return Circle_2(p, q, r); } Circle_2 operator()( const Point_2& p, const Point_2& q, Orientation orientation = COUNTERCLOCKWISE) const { return Circle_2(p, q, orientation); } Circle_2 operator()( const Point_2& center, Orientation orientation = COUNTERCLOCKWISE) const { return Circle_2(center, orientation); } }; template <typename K> class Construct_direction_2 { typedef typename K::Direction_2 Direction_2; typedef typename K::Vector_2 Vector_2; typedef typename K::Line_2 Line_2; typedef typename K::Ray_2 Ray_2; typedef typename K::Segment_2 Segment_2; typedef typename K::RT RT; public: typedef Direction_2 result_type; typedef Arity_tag< 1 > Arity; Direction_2 operator()() const { return Direction_2(); }#ifndef CGAL_NO_DEPRECATED_CODE Direction_2 operator()(const RT& x, const RT& y) const { return Direction_2(x, y); }#endif // CGAL_NO_DEPRECATED_CODE Direction_2 operator()(const Vector_2& v) const { return Direction_2(v); } Direction_2 operator()(const Line_2& l) const { return Direction_2(l); } Direction_2 operator()(const Ray_2& r) const { return Direction_2(r); } Direction_2 operator()(const Segment_2& s) const { return Direction_2(s); } }; template <typename K> class Construct_direction_3 { typedef typename K::Direction_3 Direction_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::RT RT; public: typedef Direction_3 result_type; typedef Arity_tag< 1 > Arity; Direction_3 operator()() const { return Direction_3(); }#ifndef CGAL_NO_DEPRECATED_CODE Direction_3 operator()(const RT& x, const RT& y, const RT& z) const { return Direction_3(x, y, z); }#endif // CGAL_NO_DEPRECATED_CODE Direction_3 operator()(const Vector_3& v) const { return Direction_3(v); } Direction_3 operator()(const Line_3& l) const { return Direction_3(l); } Direction_3 operator()(const Ray_3& r) const { return Direction_3(r); } Direction_3 operator()(const Segment_3& s) const { return Direction_3(s); } }; template <typename K> class Construct_iso_cuboid_3 { typedef typename K::Point_3 Point_3; typedef typename K::Iso_cuboid_3 Iso_cuboid_3; public: typedef Iso_cuboid_3 result_type; typedef Arity_tag< 2 > Arity; Iso_cuboid_3 operator()() const { return Iso_cuboid_3(); } Iso_cuboid_3 operator()(const Point_3& p, const Point_3& q) const { return Iso_cuboid_3(p, q); } Iso_cuboid_3 operator()(const Point_3 &left, const Point_3 &right, const Point_3 &bottom, const Point_3 &top, const Point_3 &far_, const Point_3 &close) const { return Iso_cuboid_3(left, right, bottom, top, far_, close); } }; template <typename K> class Construct_iso_rectangle_2 { typedef typename K::Point_2 Point_2; typedef typename K::Iso_rectangle_2 Iso_rectangle_2; public: typedef Iso_rectangle_2 result_type; typedef Arity_tag< 2 > Arity; Iso_rectangle_2 operator()() const { return Iso_rectangle_2(); } Iso_rectangle_2 operator()(const Point_2& p, const Point_2& q) const { return Iso_rectangle_2(p, q); } Iso_rectangle_2 operator()(const Point_2 &left, const Point_2 &right, const Point_2 &bottom, const Point_2 &top) const { return Iso_rectangle_2(left, right, bottom, top); } }; template <typename K> class Construct_max_vertex_2 { typedef typename K::Point_2 Point_2; typedef typename K::Iso_rectangle_2 Iso_rectangle_2; public: typedef Point_2 result_type; typedef Arity_tag< 1 > Arity; Point_2 operator()(const Iso_rectangle_2& r) const { return r.max(); } }; template <typename K> class Construct_min_vertex_2 { typedef typename K::Point_2 Point_2; typedef typename K::Iso_rectangle_2 Iso_rectangle_2; public: typedef Point_2 result_type; typedef Arity_tag< 1 > Arity; Point_2 operator()(const Iso_rectangle_2& r) const { return r.min(); } }; template <typename K> class Construct_max_vertex_3 { typedef typename K::Point_3 Point_3; typedef typename K::Iso_cuboid_3 Iso_cuboid_3; public: typedef Point_3 result_type; typedef Arity_tag< 1 > Arity; Point_3 operator()(const Iso_cuboid_3& r) const
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?