mirror of https://github.com/CGAL/cgal
make sure the rounding mode is to nearest when doing exact computations
Thoses changes should have been done when the code was modified for CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG
This commit is contained in:
parent
000b03b595
commit
106645ec2e
|
|
@ -43,6 +43,7 @@ public:
|
|||
template <class A1>
|
||||
result_type
|
||||
operator()(const A1 &a1) const
|
||||
{
|
||||
{
|
||||
// Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG
|
||||
Protect_FPU_rounding<Protection> P1;
|
||||
|
|
@ -51,14 +52,15 @@ public:
|
|||
return From_Filtered( Filter_construction(To_Filtered(a1)) );
|
||||
}
|
||||
catch (Uncertain_conversion_exception&)
|
||||
{
|
||||
{}
|
||||
}
|
||||
Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
|
||||
return From_Exact( Exact_construction(To_Exact(a1)) );
|
||||
}
|
||||
}
|
||||
template <class A1, class A2>
|
||||
result_type
|
||||
operator()(const A1 &a1, const A2 &a2) const
|
||||
{
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P1;
|
||||
try
|
||||
|
|
@ -67,16 +69,17 @@ public:
|
|||
To_Filtered(a2)) );
|
||||
}
|
||||
catch (Uncertain_conversion_exception&)
|
||||
{
|
||||
{}
|
||||
}
|
||||
Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
|
||||
return From_Exact( Exact_construction(To_Exact(a1),
|
||||
To_Exact(a2)) );
|
||||
}
|
||||
}
|
||||
|
||||
template <class A1, class A2, class A3>
|
||||
result_type
|
||||
operator()(const A1 &a1, const A2 &a2, const A3 &a3) const
|
||||
{
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P1;
|
||||
try
|
||||
|
|
@ -86,13 +89,13 @@ public:
|
|||
To_Filtered(a3)) );
|
||||
}
|
||||
catch (Uncertain_conversion_exception&)
|
||||
{
|
||||
{}
|
||||
}
|
||||
Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
|
||||
return From_Exact( Exact_construction(To_Exact(a1),
|
||||
To_Exact(a2),
|
||||
To_Exact(a3)) );
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -794,16 +794,17 @@ struct Lazy_construction_bbox
|
|||
result_type operator()(const L1& l1) const
|
||||
{
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
{
|
||||
// Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG
|
||||
Protect_FPU_rounding<Protection> P;
|
||||
try {
|
||||
return ac(CGAL::approx(l1));
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
} catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp);
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
|
||||
return ec(CGAL::exact(l1));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -842,15 +843,16 @@ struct Lazy_construction_nt {
|
|||
typedef std::remove_cv_t<std::remove_reference_t<decltype(ec(CGAL::exact(l)...))>> ET;
|
||||
typedef std::remove_cv_t<std::remove_reference_t<decltype(ac(CGAL::approx(l)...))>> AT;
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P;
|
||||
try {
|
||||
return new Lazy_rep_n<AT, ET, AC, EC, To_interval<ET>, L... >(ac, ec, l...);
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
} catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp);
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
|
||||
return new Lazy_rep_0<AT,ET,To_interval<ET> >(ec( CGAL::exact(l)... ));
|
||||
}
|
||||
}
|
||||
|
||||
#undef CGAL_RESULT_NT
|
||||
};
|
||||
|
|
@ -1064,18 +1066,20 @@ public:
|
|||
operator()(const L1& l1, const L2& l2, R1& r1) const
|
||||
{
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P;
|
||||
try {
|
||||
// we suppose that R1 is a Lazy<Something>
|
||||
r1 = R1(new Lazy_rep_2_1<AC, EC, E2A, L1, L2, R1>(ac, ec, l1, l2));
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
return;
|
||||
} catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp);
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
|
||||
typename R1::ET et;
|
||||
ec(CGAL::exact(l1), CGAL::exact(l2), et);
|
||||
r1 = R1(new Lazy_rep_0<typename R1::AT,typename R1::ET,E2A>(et));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -1130,6 +1134,7 @@ public:
|
|||
typedef Lazy<typename R1::AT, typename R1::ET, E2A> Handle_1;
|
||||
typedef Lazy<typename R2::AT, typename R2::ET, E2A> Handle_2;
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P;
|
||||
try {
|
||||
typedef Lazy<std::pair<typename R1::AT, typename R2::AT>, std::pair<typename R1::ET, typename R2::ET>, E2A> Lazy_pair;
|
||||
|
|
@ -1137,7 +1142,9 @@ public:
|
|||
// lv->approx() is a std::pair<R1::AT, R2::AT>;
|
||||
r1 = R1(Handle_1(new Lazy_rep_n<void, void, First<std::pair<typename R1::AT, typename R2::AT> >, First<std::pair<typename R1::ET, typename R2::ET> >, E2A, Lazy_pair>(First<std::pair<typename R1::AT, typename R2::AT> >(), First<std::pair<typename R1::ET, typename R2::ET> >(), lv)));
|
||||
r2 = R2(Handle_2(new Lazy_rep_n<void, void, Second<std::pair<typename R1::AT, typename R2::AT> >, Second<std::pair<typename R1::ET, typename R2::ET> >, E2A, Lazy_pair>(Second<std::pair<typename R1::AT, typename R2::AT> >(), Second<std::pair<typename R1::ET, typename R2::ET> >(), lv)));
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
return;
|
||||
} catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp);
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
|
||||
typename R1::ET et1, et2;
|
||||
|
|
@ -1145,7 +1152,6 @@ public:
|
|||
r1 = R1(Handle_1(new Lazy_rep_0<typename R1::AT,typename R1::ET,E2A>(et1)));
|
||||
r2 = R2(Handle_2(new Lazy_rep_0<typename R2::AT,typename R2::ET,E2A>(et2)));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -1174,26 +1180,28 @@ public:
|
|||
operator()(const L1& l1, const L2& l2, OutputIterator it) const
|
||||
{
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P;
|
||||
try {
|
||||
Lazy_vector lv(new Lazy_rep_with_vector_2<AC, EC, E2A, L1, L2>(ac, ec, l1, l2));
|
||||
// lv.approx() is a std::vector<Object([AK::Point_2,AK::Segment_2])>
|
||||
// that is, when we get here we have constructed all approximate results
|
||||
for (unsigned int i = 0; i < lv.approx().size(); i++) {
|
||||
// FIXME : I'm not sure how this work...
|
||||
#define CGAL_Kernel_obj(X) if (object_cast<typename AK::X>(& (lv.approx()[i]))) { \
|
||||
// FIXME : I'm not sure how this work...
|
||||
#define CGAL_Kernel_obj(X) if (object_cast<typename AK::X>(& (lv.approx()[i]))) { \
|
||||
*it++ = make_object(typename LK::X(new Lazy_rep_n<typename AK::X, typename EK::X, Ith<typename AK::X>, \
|
||||
Ith<typename EK::X>, E2A, Lazy_vector> \
|
||||
(Ith<typename AK::X>(i), Ith<typename EK::X>(i), lv))); \
|
||||
continue; \
|
||||
}
|
||||
|
||||
#include <CGAL/Kernel/interface_macros.h>
|
||||
#include <CGAL/Kernel/interface_macros.h>
|
||||
|
||||
std::cerr << "we need more casts" << std::endl;
|
||||
}
|
||||
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
return it;
|
||||
} catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp);
|
||||
// TODO: Instead of using a vector, write an iterator adapter
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
|
||||
|
|
@ -1204,7 +1212,6 @@ public:
|
|||
++oit){
|
||||
*it++ = make_lazy<LK>(*oit);
|
||||
}
|
||||
}
|
||||
return it;
|
||||
}
|
||||
};
|
||||
|
|
@ -1252,6 +1259,7 @@ public:
|
|||
operator()(const L1& l1) const
|
||||
{
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P;
|
||||
try {
|
||||
Lazy_object lo(new Lazy_rep_n<result_type, result_type, AC, EC, E2A, L1>(ac, ec, l1));
|
||||
|
|
@ -1259,32 +1267,32 @@ public:
|
|||
if(lo.approx().is_empty())
|
||||
return Object();
|
||||
|
||||
#define CGAL_Kernel_obj(X) \
|
||||
#define CGAL_Kernel_obj(X) \
|
||||
if (object_cast<typename AK::X>(& (lo.approx()))) { \
|
||||
typedef Lazy_rep_n< typename AK::X, typename EK::X, Object_cast<typename AK::X>, Object_cast<typename EK::X>, E2A, Lazy_object> Lcr; \
|
||||
Lcr * lcr = new Lcr(Object_cast<typename AK::X>(), Object_cast<typename EK::X>(), lo); \
|
||||
return make_object(typename LK::X(lcr)); \
|
||||
}
|
||||
|
||||
#include <CGAL/Kernel/interface_macros.h>
|
||||
#include <CGAL/Kernel/interface_macros.h>
|
||||
|
||||
std::cerr << "object_cast inside Lazy_construction_rep::operator() failed. It needs more else if's (#1)" << std::endl;
|
||||
std::cerr << "dynamic type of the Object : " << lo.approx().type().name() << std::endl;
|
||||
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
return Object();
|
||||
} catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp);
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
|
||||
ET eto = ec(CGAL::exact(l1));
|
||||
return make_lazy<LK>(eto);
|
||||
}
|
||||
return Object();
|
||||
}
|
||||
|
||||
template <typename L1, typename L2>
|
||||
result_type
|
||||
operator()(const L1& l1, const L2& l2) const
|
||||
{
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P;
|
||||
try {
|
||||
Lazy_object lo(new Lazy_rep_n<result_type, result_type, AC, EC, E2A, L1, L2>(ac, ec, l1, l2));
|
||||
|
|
@ -1318,27 +1326,28 @@ public:
|
|||
}\
|
||||
}
|
||||
|
||||
CGAL_Kernel_obj(Point_2)
|
||||
CGAL_Kernel_obj(Point_3)
|
||||
CGAL_Kernel_obj(Point_2)
|
||||
CGAL_Kernel_obj(Point_3)
|
||||
#undef CGAL_Kernel_obj
|
||||
|
||||
std::cerr << "object_cast inside Lazy_construction_rep::operator() failed. It needs more else if's (#1)" << std::endl;
|
||||
std::cerr << "dynamic type of the Object : " << lo.approx().type().name() << std::endl;
|
||||
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
return Object();
|
||||
} catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp);
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
|
||||
ET eto = ec(CGAL::exact(l1), CGAL::exact(l2));
|
||||
return make_lazy<LK>(eto);
|
||||
}
|
||||
return Object();
|
||||
}
|
||||
|
||||
template <typename L1, typename L2, typename L3>
|
||||
result_type
|
||||
operator()(const L1& l1, const L2& l2, const L3& l3) const
|
||||
{
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P;
|
||||
try {
|
||||
Lazy_object lo(new Lazy_rep_n<result_type, result_type, AC, EC, E2A, L1, L2, L3>(ac, ec, l1, l2, l3));
|
||||
|
|
@ -1357,15 +1366,14 @@ CGAL_Kernel_obj(Point_3)
|
|||
|
||||
std::cerr << "object_cast inside Lazy_construction_rep::operator() failed. It needs more else if's (#1)" << std::endl;
|
||||
std::cerr << "dynamic type of the Object : " << lo.approx().type().name() << std::endl;
|
||||
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
return Object();
|
||||
} catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp);
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
|
||||
ET eto = ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3));
|
||||
return make_lazy<LK>(eto);
|
||||
}
|
||||
return Object();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -1512,8 +1520,8 @@ struct Lazy_construction_variant {
|
|||
typename Type_mapper<L2, LK, EK>::type)>::type ET;
|
||||
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P;
|
||||
|
||||
try {
|
||||
Lazy<AT, ET, E2A> lazy(new Lazy_rep_n<AT, ET, AC, EC, E2A, L1, L2>(AC(), EC(), l1, l2));
|
||||
|
||||
|
|
@ -1532,7 +1540,8 @@ struct Lazy_construction_variant {
|
|||
boost::apply_visitor(visitor, *approx_v);
|
||||
|
||||
return res;
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
} catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp);
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
|
||||
|
||||
|
|
@ -1547,7 +1556,6 @@ struct Lazy_construction_variant {
|
|||
boost::apply_visitor(visitor, *exact_v);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename L1, typename L2, typename L3>
|
||||
typename result<Lazy_construction_variant(L1, L2, L3)>::type
|
||||
|
|
@ -1562,6 +1570,7 @@ struct Lazy_construction_variant {
|
|||
typename Type_mapper<L3, LK, EK>::type)>::type ET;
|
||||
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P;
|
||||
try {
|
||||
Lazy<AT, ET, E2A> lazy(new Lazy_rep_n<AT, ET, AC, EC, E2A, L1, L2, L3>(AC(), EC(), l1, l2, l3));
|
||||
|
|
@ -1581,7 +1590,8 @@ struct Lazy_construction_variant {
|
|||
boost::apply_visitor(visitor, *approx_v);
|
||||
|
||||
return res;
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
} catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp);
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
|
||||
|
||||
|
|
@ -1596,7 +1606,6 @@ struct Lazy_construction_variant {
|
|||
boost::apply_visitor(visitor, *exact_v);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename LK, typename AC, typename EC, typename E2A = Default,
|
||||
|
|
@ -1629,14 +1638,15 @@ struct Lazy_construction<LK, AC, EC, E2A_, true> {
|
|||
operator()( BOOST_PP_ENUM(n, CGAL_LARGS, _) ) const { \
|
||||
typedef Lazy< AT, ET, E2A> Handle; \
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \
|
||||
{ \
|
||||
Protect_FPU_rounding<Protection> P; \
|
||||
try { \
|
||||
return result_type( Handle(new Lazy_rep_n<AT, ET, AC, EC, E2A, BOOST_PP_ENUM_PARAMS(n, L)>(ac, ec, BOOST_PP_ENUM_PARAMS(n, l)))); \
|
||||
} catch (Uncertain_conversion_exception&) { \
|
||||
} catch (Uncertain_conversion_exception&) {} \
|
||||
} \
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp); \
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST); \
|
||||
return result_type( Handle(new Lazy_rep_0<AT,ET,E2A>(ec( BOOST_PP_ENUM(n, CGAL_LEXACT, _) ))) ); \
|
||||
} \
|
||||
}
|
||||
|
||||
// arity 1-8
|
||||
|
|
@ -1696,14 +1706,15 @@ struct result<F( BOOST_PP_ENUM_PARAMS(n, T) )> { \
|
|||
typedef Lazy< AT, ET, E2A> Handle; \
|
||||
typedef typename cpp11::result_of<Lazy_construction(BOOST_PP_ENUM_PARAMS(n, L))>::type result_type; \
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \
|
||||
{ \
|
||||
Protect_FPU_rounding<Protection> P; \
|
||||
try { \
|
||||
return result_type( Handle(new Lazy_rep_n<AT, ET, AC, EC, E2A, BOOST_PP_ENUM_PARAMS(n, L)>(ac, ec, BOOST_PP_ENUM_PARAMS(n, l)))); \
|
||||
} catch (Uncertain_conversion_exception&) { \
|
||||
} catch (Uncertain_conversion_exception&) {} \
|
||||
} \
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp); \
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST); \
|
||||
return result_type( Handle(new Lazy_rep_0<AT,ET,E2A>(ec( BOOST_PP_ENUM(n, CGAL_LEXACT, _) ))) ); \
|
||||
} \
|
||||
}
|
||||
|
||||
// arity 1-8
|
||||
|
|
|
|||
|
|
@ -390,40 +390,61 @@ int orientation(const Extended_point<RT>& p1,
|
|||
const Extended_point<RT>& p3)
|
||||
{ CGAL_NEF_TRACEN("orientation "<<p1<<p2<<p3);
|
||||
int res;
|
||||
try { INCTOTAL(or2); Protect_FPU_rounding<true> Protection;
|
||||
bool run_exact = false;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try { INCTOTAL(or2);
|
||||
res = orientation_coeff2(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(),
|
||||
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(),
|
||||
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD());
|
||||
}
|
||||
catch (Uncertain_conversion_exception&) { INCEXCEPTION(or2);
|
||||
catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(or2);
|
||||
run_exact=true;
|
||||
}
|
||||
}
|
||||
if (run_exact)
|
||||
res = orientation_coeff2(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
|
||||
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
|
||||
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw());
|
||||
}
|
||||
if ( res != 0 ) return res;
|
||||
|
||||
try { INCTOTAL(or1); Protect_FPU_rounding<true> Protection;
|
||||
run_exact = false;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try { INCTOTAL(or1);
|
||||
res = orientation_coeff1(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(),
|
||||
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(),
|
||||
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD());
|
||||
}
|
||||
catch (Uncertain_conversion_exception&) { INCEXCEPTION(or1);
|
||||
catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(or1);
|
||||
run_exact = true;
|
||||
}
|
||||
}
|
||||
if (run_exact)
|
||||
res = orientation_coeff1(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
|
||||
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
|
||||
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw());
|
||||
}
|
||||
if ( res != 0 ) return res;
|
||||
|
||||
try { INCTOTAL(or0); Protect_FPU_rounding<true> Protection;
|
||||
run_exact = false;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try { INCTOTAL(or0);
|
||||
res = orientation_coeff0(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(),
|
||||
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(),
|
||||
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD());
|
||||
}
|
||||
catch (Uncertain_conversion_exception&) { INCEXCEPTION(or0);
|
||||
catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(or0);
|
||||
run_exact = true;
|
||||
}
|
||||
}
|
||||
if (run_exact)
|
||||
res = orientation_coeff0(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
|
||||
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
|
||||
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -441,20 +462,36 @@ int compare_x(const Extended_point<RT>& p1,
|
|||
const Extended_point<RT>& p2)
|
||||
{
|
||||
int res;
|
||||
try { INCTOTAL(cmpx1); Protect_FPU_rounding<true> Protection;
|
||||
bool run_exact = false;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try { INCTOTAL(cmpx1);
|
||||
res = compare_expr(p1.mxD(),p1.hwD(),p2.mxD(),p2.hwD());
|
||||
}
|
||||
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmpx1);
|
||||
res = compare_expr(p1.mx(),p1.hw(),p2.mx(),p2.hw());
|
||||
catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(cmpx1);
|
||||
run_exact = true;
|
||||
}
|
||||
}
|
||||
if (run_exact)
|
||||
res = compare_expr(p1.mx(),p1.hw(),p2.mx(),p2.hw());
|
||||
|
||||
if ( res != 0 ) return res;
|
||||
|
||||
try { INCTOTAL(cmpx0); Protect_FPU_rounding<true> Protection;
|
||||
run_exact = false;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try {
|
||||
INCTOTAL(cmpx0);
|
||||
res = compare_expr(p1.nxD(),p1.hwD(),p2.nxD(),p2.hwD());
|
||||
}
|
||||
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmpx0);
|
||||
res = compare_expr(p1.nx(),p1.hw(),p2.nx(),p2.hw());
|
||||
catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(cmpx0);
|
||||
run_exact = true;
|
||||
}
|
||||
}
|
||||
if (run_exact)
|
||||
res = compare_expr(p1.nx(),p1.hw(),p2.nx(),p2.hw());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -466,20 +503,34 @@ int compare_y(const Extended_point<RT>& p1,
|
|||
const Extended_point<RT>& p2)
|
||||
{
|
||||
int res;
|
||||
try { INCTOTAL(cmpy1); Protect_FPU_rounding<true> Protection;
|
||||
bool run_exact = false;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try { INCTOTAL(cmpy1);
|
||||
res = compare_expr(p1.myD(),p1.hwD(),p2.myD(),p2.hwD());
|
||||
}
|
||||
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmpy1);
|
||||
res = compare_expr(p1.my(),p1.hw(),p2.my(),p2.hw());
|
||||
catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(cmpy1);
|
||||
run_exact = true;
|
||||
}
|
||||
}
|
||||
if (run_exact)
|
||||
res = compare_expr(p1.my(),p1.hw(),p2.my(),p2.hw());
|
||||
if ( res != 0 ) return res;
|
||||
|
||||
try { INCTOTAL(cmpy0); Protect_FPU_rounding<true> Protection;
|
||||
run_exact = false;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try { INCTOTAL(cmpy0);
|
||||
res = compare_expr(p1.nyD(),p1.hwD(),p2.nyD(),p2.hwD());
|
||||
}
|
||||
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmpy0);
|
||||
res = compare_expr(p1.ny(),p1.hw(),p2.ny(),p2.hw());
|
||||
catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(cmpy0);
|
||||
run_exact = true;
|
||||
}
|
||||
}
|
||||
if (run_exact)
|
||||
res = compare_expr(p1.ny(),p1.hw(),p2.ny(),p2.hw());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -608,46 +659,68 @@ int compare_pair_dist(
|
|||
const Extended_point<RT>& p3, const Extended_point<RT>& p4)
|
||||
{
|
||||
int res;
|
||||
try { INCTOTAL(cmppd2); Protect_FPU_rounding<true> Protection;
|
||||
bool run_exact = false;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try { INCTOTAL(cmppd2);
|
||||
res = cmppd_coeff2(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(),
|
||||
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(),
|
||||
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD(),
|
||||
p4.mxD(),p4.nxD(),p4.myD(),p4.nyD(),p4.hwD());
|
||||
}
|
||||
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmppd2);
|
||||
catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(cmppd2);
|
||||
run_exact = true;
|
||||
}
|
||||
}
|
||||
if (run_exact)
|
||||
res = cmppd_coeff2(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
|
||||
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
|
||||
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(),
|
||||
p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw());
|
||||
}
|
||||
|
||||
if ( res != 0 ) return res;
|
||||
|
||||
try { INCTOTAL(cmppd1); Protect_FPU_rounding<true> Protection;
|
||||
run_exact = false;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try { INCTOTAL(cmppd1);
|
||||
res = cmppd_coeff1(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(),
|
||||
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(),
|
||||
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD(),
|
||||
p4.mxD(),p4.nxD(),p4.myD(),p4.nyD(),p4.hwD());
|
||||
}
|
||||
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmppd1);
|
||||
catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(cmppd1);
|
||||
run_exact = true;
|
||||
}
|
||||
}
|
||||
if (run_exact)
|
||||
res = cmppd_coeff1(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
|
||||
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
|
||||
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(),
|
||||
p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw());
|
||||
}
|
||||
if ( res != 0 ) return res;
|
||||
|
||||
try { INCTOTAL(cmppd0); Protect_FPU_rounding<true> Protection;
|
||||
run_exact = false;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try { INCTOTAL(cmppd0);
|
||||
res = cmppd_coeff0(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(),
|
||||
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(),
|
||||
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD(),
|
||||
p4.mxD(),p4.nxD(),p4.myD(),p4.nyD(),p4.hwD());
|
||||
}
|
||||
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmppd0);
|
||||
catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(cmppd0);
|
||||
run_exact = true;
|
||||
}
|
||||
}
|
||||
if (run_exact)
|
||||
res = cmppd_coeff0(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
|
||||
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
|
||||
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(),
|
||||
p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -873,42 +946,65 @@ int orientation(const Extended_direction<RT>& d1,
|
|||
Extended_point<RT> p1(d1.p1()), p2(d1.p2()),
|
||||
p3(d2.p1()), p4(d2.p2());
|
||||
int res;
|
||||
try { INCTOTAL(ord2); Protect_FPU_rounding<true> Protection;
|
||||
bool run_exact = true;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try { INCTOTAL(ord2);
|
||||
res = coeff2_dor(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(),
|
||||
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(),
|
||||
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD(),
|
||||
p4.mxD(),p4.nxD(),p4.myD(),p4.nyD(),p4.hwD());
|
||||
} catch (Uncertain_conversion_exception&) { INCEXCEPTION(ord2);
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(ord2);
|
||||
run_exact=true;
|
||||
}
|
||||
}
|
||||
if (run_exact)
|
||||
res = coeff2_dor(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
|
||||
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
|
||||
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(),
|
||||
p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw());
|
||||
}
|
||||
if ( res != 0 ) return res;
|
||||
|
||||
try { INCTOTAL(ord1); Protect_FPU_rounding<true> Protection;
|
||||
run_exact = false;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try { INCTOTAL(ord1);
|
||||
res = coeff1_dor(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(),
|
||||
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(),
|
||||
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD(),
|
||||
p4.mxD(),p4.nxD(),p4.myD(),p4.nyD(),p4.hwD());
|
||||
} catch (Uncertain_conversion_exception&) { INCEXCEPTION(ord1);
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(ord1);
|
||||
run_exact=true;
|
||||
}
|
||||
}
|
||||
if (run_exact)
|
||||
res = coeff1_dor(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
|
||||
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
|
||||
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(),
|
||||
p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw());
|
||||
}
|
||||
|
||||
if ( res != 0 ) return res;
|
||||
|
||||
run_exact = false;
|
||||
{
|
||||
Protect_FPU_rounding<true> Protection;
|
||||
try { INCTOTAL(ord0); Protect_FPU_rounding<true> Protection;
|
||||
res = coeff0_dor(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(),
|
||||
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(),
|
||||
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD(),
|
||||
p4.mxD(),p4.nxD(),p4.myD(),p4.nyD(),p4.hwD());
|
||||
} catch (Uncertain_conversion_exception&) { INCEXCEPTION(ord0);
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
INCEXCEPTION(ord0);
|
||||
run_exact = true;
|
||||
}
|
||||
}
|
||||
if(run_exact)
|
||||
res = coeff0_dor(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
|
||||
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
|
||||
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(),
|
||||
p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,15 +176,16 @@ struct Lazy_construction2 {
|
|||
template<class...L>
|
||||
std::enable_if_t<(sizeof...(L)>0), result_type> operator()(L const&...l) const {
|
||||
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P;
|
||||
try {
|
||||
return new Lazy_rep_XXX<AT, ET, AC, EC, E2A, L...>(ac, ec, l...);
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
} catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
CGAL_BRANCH_PROFILER_BRANCH(tmp);
|
||||
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
|
||||
return new Lazy_rep_0<AT,ET,E2A>(ec(CGAL::exact(l)...));
|
||||
}
|
||||
}
|
||||
// FIXME: this forces us to have default constructors for all types, try to make its instantiation lazier
|
||||
// Actually, that may be the clearing in update_exact().
|
||||
result_type operator()() const
|
||||
|
|
|
|||
|
|
@ -689,12 +689,16 @@ locate_in_tmc(const Bare_point &p0, TMC_Cell_handle start) const
|
|||
// We temporarily put p at i's place in pts.
|
||||
const TMC_Point* backup = pts[i];
|
||||
pts[i] = &p_inexact;
|
||||
bool run_exact=false;
|
||||
{
|
||||
Protect_FPU_rounding<true> P;
|
||||
try {
|
||||
o = TMC_Geom_traits().orientation_3_object()(*pts[0], *pts[1],
|
||||
*pts[2], *pts[3]);
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
} catch (Uncertain_conversion_exception&) { run_exact=true; }
|
||||
}
|
||||
if (run_exact)
|
||||
{
|
||||
Protect_FPU_rounding<false> P(CGAL_FE_TONEAREST);
|
||||
typedef Exact_predicates_exact_constructions_kernel EK;
|
||||
Cartesian_converter<typename Bare_point::R, EK> converter_ek;
|
||||
|
|
@ -716,7 +720,6 @@ locate_in_tmc(const Bare_point &p0, TMC_Cell_handle start) const
|
|||
}
|
||||
o = orientation(e_pts[0], e_pts[1], e_pts[2], e_pts[3]);
|
||||
}
|
||||
}
|
||||
|
||||
if ( o != NEGATIVE ) {
|
||||
pts[i] = backup;
|
||||
|
|
|
|||
|
|
@ -1197,7 +1197,7 @@ Mixed_complex_triangulator_3<RegularTriangulation_3,
|
|||
TriangulatedMixedComplexObserver_3>::
|
||||
orientation(Tmc_Cell_handle ch)
|
||||
{
|
||||
Orientation o;
|
||||
{
|
||||
// Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG
|
||||
Protect_FPU_rounding<true> P;
|
||||
try {
|
||||
|
|
@ -1206,8 +1206,9 @@ orientation(Tmc_Cell_handle ch)
|
|||
pts[i] = ch->vertex(i)->point();
|
||||
|
||||
// filtered kernel
|
||||
o = _tmc.geom_traits().orientation_3_object()(pts[0], pts[1], pts[2], pts[3]);
|
||||
} catch (Uncertain_conversion_exception&) {
|
||||
return _tmc.geom_traits().orientation_3_object()(pts[0], pts[1], pts[2], pts[3]);
|
||||
} catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
Protect_FPU_rounding<false> P(CGAL_FE_TONEAREST);
|
||||
typedef Exact_predicates_exact_constructions_kernel EK;
|
||||
typedef Cartesian_converter<EK, Tmc_traits> Exact_converter;
|
||||
|
|
@ -1226,10 +1227,8 @@ orientation(Tmc_Cell_handle ch)
|
|||
// Store the more precise point
|
||||
ch->vertex(k)->point() = converter(e_pts[k]);
|
||||
}
|
||||
o = exact_traits.orientation_3_object()(e_pts[0], e_pts[1],
|
||||
return exact_traits.orientation_3_object()(e_pts[0], e_pts[1],
|
||||
e_pts[2], e_pts[3]);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <class RegularTriangulation_3,
|
||||
|
|
|
|||
|
|
@ -136,9 +136,10 @@ public:
|
|||
result_type
|
||||
operator()(A&& ... a) const
|
||||
{
|
||||
try
|
||||
{
|
||||
Protect_FPU_rounding<Protection> P;
|
||||
try
|
||||
{
|
||||
FC_result_type fr = Filter_construction(To_Filtered(std::forward<A>(a))...);
|
||||
|
||||
const double precision =
|
||||
|
|
@ -148,6 +149,7 @@ public:
|
|||
return From_Filtered(fr);
|
||||
}
|
||||
catch (Uncertain_conversion_exception&) {}
|
||||
}
|
||||
|
||||
Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
|
||||
EC_result_type er = Exact_construction(To_Exact(std::forward<A>(a))...) ;
|
||||
|
|
|
|||
Loading…
Reference in New Issue