BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Circle_3.h
Go to the documentation of this file.
00001 // Copyright (c) 2005-2006  INRIA Sophia-Antipolis (France).
00002 // All rights reserved.
00003 //
00004 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License as
00006 // published by the Free Software Foundation; version 2.1 of the License.
00007 // See the file LICENSE.LGPL distributed with CGAL.
00008 //
00009 // Licensees holding a valid commercial license may use this file in
00010 // accordance with the commercial license agreement provided with the software.
00011 //
00012 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014 //
00015 // Partially supported by the IST Programme of the EU as a Shared-cost
00016 // RTD (FET Open) Project under Contract No  IST-2000-26473 
00017 // (ECG - Effective Computational Geometry for Curves and Surfaces) 
00018 // and a STREP (FET Open) Project under Contract No  IST-006413 
00019 // (ACS -- Algorithms for Complex Shapes)
00020 //
00021 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Kernel_23/include/CGAL/Circle_3.h $
00022 // $Id: Circle_3.h 46206 2008-10-11 20:21:08Z spion $
00023 //
00024 // Author(s) : Monique Teillaud <Monique.Teillaud@sophia.inria.fr>
00025 //             Sylvain Pion
00026 //             Pedro Machado    <tashimir@gmail.com>
00027 //             Julien Hazebrouck
00028 //             Damien Leroy
00029 
00030 #ifndef CGAL_CIRCLE_3_H
00031 #define CGAL_CIRCLE_3_H
00032 
00033 #include <boost/static_assert.hpp>
00034 #include <boost/type_traits.hpp>
00035 #include <CGAL/Kernel/Return_base_tag.h>
00036 #include <CGAL/Bbox_3.h>
00037 #include <CGAL/representation_tags.h>
00038 #include <CGAL/Dimension.h>
00039 
00040 CGAL_BEGIN_NAMESPACE
00041 
00042 template <class R_> 
00043   class Circle_3
00044   : public R_::Kernel_base::Circle_3
00045 {
00046   typedef typename R_::RT                    RT;
00047   typedef typename R_::FT                    FT;
00048   typedef typename R_::Point_3               Point_3;
00049   typedef typename R_::Plane_3               Plane_3;
00050   typedef typename R_::Vector_3              Vector_3;
00051   typedef typename R_::Sphere_3              Sphere_3;
00052   typedef typename R_::Direction_3           Direction_3;
00053 
00054   typedef Circle_3                           Self;
00055   BOOST_STATIC_ASSERT((boost::is_same<Self, typename R_::Circle_3>::value));
00056 
00057 public:
00058 
00059   typedef Dimension_tag<3>  Ambient_dimension;
00060   typedef Dimension_tag<1>  Feature_dimension;
00061 
00062   typedef typename R_::Kernel_base::Circle_3 Rep;
00063   typedef R_                                 R;
00064  
00065   const Rep& rep() const
00066   {
00067     return *this;
00068   }
00069 
00070   Rep& rep()
00071   {
00072     return *this;
00073   }
00074 
00075   Circle_3() {}
00076 
00077   Circle_3(const Sphere_3& s, const Plane_3& p, int a)
00078     : Rep(typename R::Construct_circle_3()(s,p,a)) {}
00079 
00080   Circle_3(const Point_3& c, const FT& sr, const Plane_3& p)
00081     : Rep(typename R::Construct_circle_3()(c,sr,p)) {}
00082 
00083   Circle_3(const Point_3& c, const FT& sr, const Direction_3& d) 
00084     : Rep(typename R::Construct_circle_3()(c,sr,d)) {}
00085 
00086   Circle_3(const Point_3& c, const FT& sr, const Vector_3& v) 
00087     : Rep(typename R::Construct_circle_3()(c,sr,v)) {}
00088 
00089   Circle_3(const Sphere_3& s1, const Sphere_3& s2)
00090     : Rep(typename R::Construct_circle_3()(s1,s2)) {}
00091 
00092   Circle_3(const Sphere_3& s, const Plane_3& p)
00093     : Rep(typename R::Construct_circle_3()(s,p)) {}
00094 
00095   Circle_3(const Plane_3& p, const Sphere_3& s)
00096     : Rep(typename R::Construct_circle_3()(p,s)) {}
00097 
00098   Circle_3(const Point_3& p1, const Point_3& p2, const Point_3& p3)
00099     : Rep(typename R::Construct_circle_3()(p1,p2,p3)) {}
00100 
00101   Circle_3(const Rep& r)
00102     : Rep(r) {}
00103 
00104   typename Qualified_result_of
00105   <typename R::Construct_sphere_3, Circle_3>::type
00106   diametral_sphere() const
00107   {
00108     return typename R::Construct_sphere_3()(*this);
00109   }
00110 
00111   Point_3 center() const
00112   {
00113     return typename R::Construct_sphere_3()(*this).center();
00114   }
00115 
00116   FT squared_radius() const
00117   {
00118     return typename R::Construct_sphere_3()(*this).squared_radius();
00119   }
00120 
00121   typename Qualified_result_of
00122   <typename R::Construct_plane_3, Circle_3>::type
00123   supporting_plane() const
00124   {
00125     return typename R::Construct_plane_3()(*this);
00126   }
00127 
00128   Bbox_3 bbox() const
00129   {
00130     return typename R::Construct_bbox_3()(*this); 
00131   }
00132 
00133         FT area_divided_by_pi() const
00134         {
00135           return typename R::Compute_area_divided_by_pi_3()(*this);
00136   }
00137 
00138   double approximate_area() const
00139   {
00140           return typename R::Compute_approximate_area_3()(*this);
00141         }
00142 
00143         FT squared_length_divided_by_pi_square() const
00144         {
00145           return typename R::Compute_squared_length_divided_by_pi_square_3()(*this);
00146   }
00147 
00148   double approximate_squared_length() const
00149   {
00150           return typename R::Compute_approximate_squared_length_3()(*this);
00151         }
00152         
00153         typename R::Boolean
00154   has_on(const Point_3 &p) const
00155   {
00156     return typename R::Has_on_3()(*this, p);
00157   }
00158 
00159 };
00160 
00161 template < typename R >
00162 inline
00163 bool
00164 operator==(const Circle_3<R> &p,
00165            const Circle_3<R> &q)
00166 {
00167   return R().equal_3_object()(p, q);
00168 }
00169 
00170 template < typename R >
00171 inline
00172 bool
00173 operator!=(const Circle_3<R> &p,
00174            const Circle_3<R> &q)
00175 {
00176   return ! (p == q);
00177 }
00178 
00179 template < typename R >
00180 std::ostream &
00181 operator<<(std::ostream & os, const Circle_3<R> &c)
00182 {
00183   return os << c.supporting_plane() << " "
00184     << c.diametral_sphere() << " ";
00185 }
00186 
00187 template < typename R >
00188 std::istream &
00189 operator>>(std::istream & is, Circle_3<R> &c)
00190 {
00191   typename R::Plane_3 p;
00192   typename R::Sphere_3 s;
00193 
00194   is >> p >> s ;
00195   if (is)
00196     c = Circle_3<R>(p, s);
00197   return is;
00198 }
00199 
00200 CGAL_END_NAMESPACE
00201 
00202 #endif // CGAL_CIRCLE_3_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines