BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Filtered_construction.h
Go to the documentation of this file.
00001 // Copyright (c) 2003,2004  INRIA Sophia-Antipolis (France) and
00002 // Notre Dame University (U.S.A.).  All rights reserved.
00003 //
00004 // This file is part of CGAL (www.cgal.org); you may redistribute it under
00005 // the terms of the Q Public License version 1.0.
00006 // See the file LICENSE.QPL distributed with CGAL.
00007 //
00008 // Licensees holding a valid commercial license may use this file in
00009 // accordance with the commercial license agreement provided with the software.
00010 //
00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 //
00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Segment_Delaunay_graph_2/include/CGAL/Filtered_construction.h $
00015 // $Id: Filtered_construction.h 46439 2008-10-23 12:23:18Z afabri $
00016 // 
00017 //
00018 // Author(s)     : Menelaos Karavelas <mkaravel@cse.nd.edu>
00019 
00020 
00021 
00022 
00023 #ifndef CGAL_FILTERED_CONSTRUCTION_H
00024 #define CGAL_FILTERED_CONSTRUCTION_H
00025 
00026 #include <CGAL/basic.h>
00027 #include <CGAL/Interval_arithmetic.h>
00028 
00029 CGAL_BEGIN_NAMESPACE
00030 
00031 template <class AC, class EC, class FC, class C2E, class C2F,
00032           class E2C, class F2C, bool Protection = true>
00033 class Filtered_construction
00034 {
00035 private:
00036   EC Exact_construction;
00037   FC Filter_construction;
00038   C2E To_Exact;
00039   C2F To_Filtered;
00040   E2C From_Exact;
00041   F2C From_Filtered;
00042 
00043   typedef typename AC::result_type  AC_result_type;
00044   typedef typename FC::result_type  FC_result_type;
00045   typedef typename EC::result_type  EC_result_type;
00046 
00047 public:
00048   typedef AC_result_type           result_type;
00049 
00050 public:
00051   Filtered_construction() {}
00052 
00053   template <class A1>
00054   result_type
00055   operator()(const A1 &a1) const
00056   {
00057     // Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG
00058     Protect_FPU_rounding<Protection> P1;
00059     try
00060     {
00061       return From_Filtered( Filter_construction(To_Filtered(a1)) );
00062     }
00063     catch (Uncertain_conversion_exception)
00064     {
00065       Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
00066       return From_Exact( Exact_construction(To_Exact(a1)) );
00067     }
00068   }
00069   template <class A1, class A2>
00070   result_type
00071   operator()(const A1 &a1, const A2 &a2) const
00072   {
00073     Protect_FPU_rounding<Protection> P1;
00074     try
00075     {
00076       return From_Filtered( Filter_construction(To_Filtered(a1),
00077                                                 To_Filtered(a2)) );
00078     }
00079     catch (Uncertain_conversion_exception)
00080     {
00081       Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
00082       return From_Exact( Exact_construction(To_Exact(a1),
00083                                             To_Exact(a2)) );
00084     }
00085   }
00086 
00087   template <class A1, class A2, class A3>
00088   result_type
00089   operator()(const A1 &a1, const A2 &a2, const A3 &a3) const
00090   {
00091     Protect_FPU_rounding<Protection> P1;
00092     try
00093     {
00094       return From_Filtered( Filter_construction(To_Filtered(a1),
00095                                                 To_Filtered(a2),
00096                                                 To_Filtered(a3)) );
00097     }
00098     catch (Uncertain_conversion_exception)
00099     {
00100       Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
00101       return From_Exact( Exact_construction(To_Exact(a1),
00102                                             To_Exact(a2),
00103                                             To_Exact(a3)) );
00104     }
00105   }
00106 
00107 };
00108 
00109 
00110 
00111 CGAL_END_NAMESPACE
00112 
00113 
00114 #endif // CGAL_FILTERED_CONSTRUCTION_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines