BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Filtered_kernel.h
Go to the documentation of this file.
00001 // Copyright (c) 2001,2004  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 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Filtered_kernel/include/CGAL/Filtered_kernel.h $
00016 // $Id: Filtered_kernel.h 44541 2008-07-28 16:24:08Z spion $
00017 // 
00018 //
00019 // Author(s)     : Sylvain Pion
00020 
00021 #ifndef CGAL_FILTERED_KERNEL_H
00022 #define CGAL_FILTERED_KERNEL_H
00023 
00024 #include <CGAL/basic.h>
00025 #include <CGAL/Filtered_predicate.h>
00026 #include <CGAL/Cartesian_converter.h>
00027 #include <CGAL/Simple_cartesian.h>
00028 #include <CGAL/Kernel/Type_equality_wrapper.h>
00029 
00030 #include <CGAL/MP_Float.h>
00031 #include <CGAL/Quotient.h>
00032 #include <CGAL/Exact_type_selecter.h>
00033 
00034 #ifndef CGAL_NO_STATIC_FILTERS
00035 #  include <CGAL/Static_filters.h>
00036 #endif
00037 
00038 // This file contains the definition of a generic kernel filter.
00039 //
00040 // TODO:
00041 // - at the moment, only the predicates are filtered.
00042 //   Constructions will come later.
00043 // - the kernel provides the traits interface, as well as type equality.
00044 //   Having the global functions working is another story...
00045 // - The converters are more a property of the types rather than anything else,
00046 //   so maybe they should not be passed as template parameter, but use a
00047 //   traits-like mecanism ?
00048 
00049 CGAL_BEGIN_NAMESPACE
00050 
00051 // CK = eventually rebound construction kernel (gets Point_2 from).
00052 // Exact_kernel = exact kernel called when needed by the filter.
00053 // Approximate_kernel = filtering "interval" kernel
00054 template < typename CK >
00055 struct Filtered_kernel_base
00056   : public CK
00057 {
00058     typedef typename Exact_type_selecter<typename CK::RT>::Type  Exact_nt;
00059     typedef Simple_cartesian<Exact_nt>                           Exact_kernel;
00060     typedef Simple_cartesian<Interval_nt_advanced>               Approximate_kernel;
00061     typedef Cartesian_converter<CK, Exact_kernel>                C2E;
00062     typedef Cartesian_converter<CK, Approximate_kernel>          C2F;
00063 
00064     template < typename Kernel2 >
00065     struct Base {
00066         typedef typename CK::template Base<Kernel2> CK2;
00067         typedef Filtered_kernel_base<CK2>  Type;
00068     };
00069 
00070     template < typename T >
00071     struct Ambient_dimension {
00072         typedef typename T::Ambient_dimension type; // maybe not the right way...
00073     };
00074 
00075     template < typename T >
00076     struct Feature_dimension {
00077         typedef typename T::Feature_dimension type; // maybe not the right way...
00078     };
00079 
00080     // We change the predicates.
00081 #define CGAL_Kernel_pred(P, Pf) \
00082     typedef Filtered_predicate<typename Exact_kernel::P, typename Approximate_kernel::P, C2E, C2F> P; \
00083     P Pf() const { return P(); }
00084 
00085     // We don't touch the constructions.
00086 #define CGAL_Kernel_cons(Y,Z)
00087 
00088 #include <CGAL/Kernel/interface_macros.h>
00089 
00090 };
00091 
00092 #ifndef CGAL_NO_STATIC_FILTERS
00093 template < typename CK >
00094 struct Static_filters_base
00095   : public Static_filters< Filtered_kernel_base<CK> >
00096 {
00097     template < typename Kernel2 >
00098     struct Base {
00099         typedef typename CK::template Base<Kernel2>::Type  CK2;
00100         typedef Static_filters_base<CK2>                   Type;
00101     };
00102 };
00103 #endif
00104 
00105 template < typename CK >
00106 struct Filtered_kernel_adaptor
00107 #ifndef CGAL_NO_STATIC_FILTERS
00108   : public Static_filters_base<CK>
00109 #else
00110   : public Filtered_kernel_base<CK>
00111 #endif
00112 {};
00113 
00114 template <class CK>
00115 struct Filtered_kernel
00116   : public Filtered_kernel_adaptor<
00117                Type_equality_wrapper<
00118                    typename CK:: template Base< Filtered_kernel<CK> >::Type,
00119                    Filtered_kernel<CK> > >
00120 {};
00121 
00122 CGAL_END_NAMESPACE
00123 
00124 #endif // CGAL_FILTERED_KERNEL_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines