Merge remote-tracking branch 'sloriot/CGAL-restore_rounding_mode'

This commit is contained in:
Sébastien Loriot 2021-09-09 11:09:16 +02:00
commit 6bae0e3939
12 changed files with 514 additions and 361 deletions

View File

@ -359,6 +359,8 @@ public:
} }
} }
catch (Uncertain_conversion_exception&){} catch (Uncertain_conversion_exception&){}
Protector protector(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (ek_plane_ptr==nullptr) { if (ek_plane_ptr==nullptr) {
const typename Exact_K::Point_3 ep = to_EK(p); const typename Exact_K::Point_3 ep = to_EK(p);
ek_plane_ptr = new Vector_plus_point<Exact_K>; ek_plane_ptr = new Vector_plus_point<Exact_K>;

View File

@ -44,54 +44,60 @@ public:
result_type result_type
operator()(const A1 &a1) const 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;
try
{ {
return From_Filtered( Filter_construction(To_Filtered(a1)) ); // Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG
} Protect_FPU_rounding<Protection> P1;
catch (Uncertain_conversion_exception&) try
{ {
Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST); return From_Filtered( Filter_construction(To_Filtered(a1)) );
return From_Exact( Exact_construction(To_Exact(a1)) ); }
catch (Uncertain_conversion_exception&)
{}
} }
Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
return From_Exact( Exact_construction(To_Exact(a1)) );
} }
template <class A1, class A2> template <class A1, class A2>
result_type result_type
operator()(const A1 &a1, const A2 &a2) const operator()(const A1 &a1, const A2 &a2) const
{ {
Protect_FPU_rounding<Protection> P1;
try
{ {
return From_Filtered( Filter_construction(To_Filtered(a1), Protect_FPU_rounding<Protection> P1;
To_Filtered(a2)) ); try
} {
catch (Uncertain_conversion_exception&) return From_Filtered( Filter_construction(To_Filtered(a1),
{ To_Filtered(a2)) );
Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST); }
return From_Exact( Exact_construction(To_Exact(a1), catch (Uncertain_conversion_exception&)
To_Exact(a2)) ); {}
} }
Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
return From_Exact( Exact_construction(To_Exact(a1),
To_Exact(a2)) );
} }
template <class A1, class A2, class A3> template <class A1, class A2, class A3>
result_type result_type
operator()(const A1 &a1, const A2 &a2, const A3 &a3) const operator()(const A1 &a1, const A2 &a2, const A3 &a3) const
{ {
Protect_FPU_rounding<Protection> P1;
try
{ {
return From_Filtered( Filter_construction(To_Filtered(a1), Protect_FPU_rounding<Protection> P1;
To_Filtered(a2), try
To_Filtered(a3)) ); {
} return From_Filtered( Filter_construction(To_Filtered(a1),
catch (Uncertain_conversion_exception&) To_Filtered(a2),
{ To_Filtered(a3)) );
Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST); }
return From_Exact( Exact_construction(To_Exact(a1), catch (Uncertain_conversion_exception&)
To_Exact(a2), {}
To_Exact(a3)) );
} }
Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
return From_Exact( Exact_construction(To_Exact(a1),
To_Exact(a2),
To_Exact(a3)) );
} }
}; };

View File

@ -107,6 +107,7 @@ Filtered_predicate<EP,AP,C2E,C2A,Protection>::
} }
CGAL_BRANCH_PROFILER_BRANCH(tmp); CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> p(CGAL_FE_TONEAREST); Protect_FPU_rounding<!Protection> p(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
return ep(c2e(args)...); return ep(c2e(args)...);
} }

View File

@ -74,6 +74,7 @@ Filtered_predicate_with_state<EP,AP,C2E,C2A,O1,Protection>::
} }
CGAL_BRANCH_PROFILER_BRANCH(tmp); CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> p(CGAL_FE_TONEAREST); Protect_FPU_rounding<!Protection> p(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if(! oep){ if(! oep){
#if BOOST_VERSION < 105600 #if BOOST_VERSION < 105600
oep = EP(c2e(o1)); oep = EP(c2e(o1));

View File

@ -885,15 +885,17 @@ struct Lazy_construction_bbox
operator()(const L1& l1) const operator()(const L1& l1) const
{ {
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); 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; // Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG
try { Protect_FPU_rounding<Protection> P;
return ac(CGAL::approx(l1)); try {
} catch (Uncertain_conversion_exception&) { return ac(CGAL::approx(l1));
CGAL_BRANCH_PROFILER_BRANCH(tmp); } catch (Uncertain_conversion_exception&) {}
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
return ec(CGAL::exact(l1));
} }
CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
return ec(CGAL::exact(l1));
} }
}; };
@ -1009,14 +1011,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(ec(CGAL::exact(l)...))>> ET;
typedef std::remove_cv_t<std::remove_reference_t<decltype(ac(CGAL::approx(l)...))>> AT; 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); CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Protect_FPU_rounding<Protection> P; {
try { Protect_FPU_rounding<Protection> P;
return new Lazy_rep_n<AT, ET, AC, EC, To_interval<ET>, L... >(ac, ec, l...); try {
} catch (Uncertain_conversion_exception&) { return new Lazy_rep_n<AT, ET, AC, EC, To_interval<ET>, L... >(ac, ec, l...);
CGAL_BRANCH_PROFILER_BRANCH(tmp); } catch (Uncertain_conversion_exception&) {}
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
return new Lazy_rep_0<AT,ET,To_interval<ET> >(ec( CGAL::exact(l)... ));
} }
CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
return new Lazy_rep_0<AT,ET,To_interval<ET> >(ec( CGAL::exact(l)... ));
} }
}; };
@ -1229,17 +1233,20 @@ public:
operator()(const L1& l1, const L2& l2, R1& r1) const operator()(const L1& l1, const L2& l2, R1& r1) const
{ {
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Protect_FPU_rounding<Protection> P; {
try { Protect_FPU_rounding<Protection> P;
// we suppose that R1 is a Lazy<Something> try {
r1 = R1(new Lazy_rep_2_1<AC, EC, E2A, L1, L2, R1>(ac, ec, l1, l2)); // we suppose that R1 is a Lazy<Something>
} catch (Uncertain_conversion_exception&) { r1 = R1(new Lazy_rep_2_1<AC, EC, E2A, L1, L2, R1>(ac, ec, l1, l2));
CGAL_BRANCH_PROFILER_BRANCH(tmp); return;
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST); } catch (Uncertain_conversion_exception&) {}
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));
} }
CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == 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));
} }
}; };
@ -1295,21 +1302,24 @@ public:
typedef Lazy<typename R1::AT, typename R1::ET, E2A> Handle_1; typedef Lazy<typename R1::AT, typename R1::ET, E2A> Handle_1;
typedef Lazy<typename R2::AT, typename R2::ET, E2A> Handle_2; 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); CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Protect_FPU_rounding<Protection> P; {
try { Protect_FPU_rounding<Protection> P;
typedef Lazy<std::pair<typename R1::AT, typename R2::AT>, std::pair<typename R1::ET, typename R2::ET>, E2A> Lazy_pair; try {
Lazy_pair lv(new Lazy_rep_2_2<AC, EC, E2A, L1, L2, R1, R2>(ac, ec, l1, l2)); typedef Lazy<std::pair<typename R1::AT, typename R2::AT>, std::pair<typename R1::ET, typename R2::ET>, E2A> Lazy_pair;
// lv->approx() is a std::pair<R1::AT, R2::AT>; Lazy_pair lv(new Lazy_rep_2_2<AC, EC, E2A, L1, L2, R1, R2>(ac, ec, l1, l2));
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))); // lv->approx() is a std::pair<R1::AT, R2::AT>;
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))); 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)));
} catch (Uncertain_conversion_exception&) { 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)));
CGAL_BRANCH_PROFILER_BRANCH(tmp); return;
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST); } catch (Uncertain_conversion_exception&) {}
typename R1::ET et1, et2;
ec(CGAL::exact(l1), CGAL::exact(l2), et1, et2);
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)));
} }
CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
typename R1::ET et1, et2;
ec(CGAL::exact(l1), CGAL::exact(l2), et1, et2);
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)));
} }
}; };
@ -1339,36 +1349,38 @@ public:
operator()(const L1& l1, const L2& l2, OutputIterator it) const operator()(const L1& l1, const L2& l2, OutputIterator it) const
{ {
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Protect_FPU_rounding<Protection> P; {
try { Protect_FPU_rounding<Protection> P;
Lazy_vector lv(new Lazy_rep_with_vector_2<AC, EC, E2A, L1, L2>(ac, ec, l1, l2)); try {
// lv.approx() is a std::vector<Object([AK::Point_2,AK::Segment_2])> Lazy_vector lv(new Lazy_rep_with_vector_2<AC, EC, E2A, L1, L2>(ac, ec, l1, l2));
// that is, when we get here we have constructed all approximate results // lv.approx() is a std::vector<Object([AK::Point_2,AK::Segment_2])>
for (unsigned int i = 0; i < lv.approx().size(); i++) { // that is, when we get here we have constructed all approximate results
// FIXME : I'm not sure how this work... for (unsigned int i = 0; i < lv.approx().size(); i++) {
#define CGAL_Kernel_obj(X) if (object_cast<typename AK::X>(& (lv.approx()[i]))) { \ // FIXME : I'm not sure how this work...
*it++ = make_object(typename LK::X(new Lazy_rep_n<typename AK::X, typename EK::X, Ith<typename AK::X>, \ #define CGAL_Kernel_obj(X) if (object_cast<typename AK::X>(& (lv.approx()[i]))) { \
Ith<typename EK::X>, E2A, Lazy_vector> \ *it++ = make_object(typename LK::X(new Lazy_rep_n<typename AK::X, typename EK::X, Ith<typename AK::X>, \
(Ith<typename AK::X>(i), Ith<typename EK::X>(i), lv))); \ Ith<typename EK::X>, E2A, Lazy_vector> \
continue; \ (Ith<typename AK::X>(i), Ith<typename EK::X>(i), lv))); \
continue; \
}
#include <CGAL/Kernel/interface_macros.h>
std::cerr << "we need more casts" << std::endl;
} }
return it;
#include <CGAL/Kernel/interface_macros.h> } catch (Uncertain_conversion_exception&) {}
}
std::cerr << "we need more casts" << std::endl; CGAL_BRANCH_PROFILER_BRANCH(tmp);
} // TODO: Instead of using a vector, write an iterator adapter
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
} catch (Uncertain_conversion_exception&) { CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
CGAL_BRANCH_PROFILER_BRANCH(tmp); std::vector<Object> exact_objects;
// TODO: Instead of using a vector, write an iterator adapter ec(CGAL::exact(l1), CGAL::exact(l2), std::back_inserter(exact_objects));
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST); for (std::vector<Object>::const_iterator oit = exact_objects.begin();
std::vector<Object> exact_objects; oit != exact_objects.end();
ec(CGAL::exact(l1), CGAL::exact(l2), std::back_inserter(exact_objects)); ++oit){
for (std::vector<Object>::const_iterator oit = exact_objects.begin(); *it++ = make_lazy<LK>(*oit);
oit != exact_objects.end();
++oit){
*it++ = make_lazy<LK>(*oit);
}
} }
return it; return it;
} }
@ -1417,32 +1429,33 @@ public:
operator()(const L1& l1) const operator()(const L1& l1) const
{ {
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Protect_FPU_rounding<Protection> P; {
try { Protect_FPU_rounding<Protection> P;
Lazy_object lo(new Lazy_rep_n<result_type, result_type, AC, EC, E2A, L1>(ac, ec, l1)); try {
Lazy_object lo(new Lazy_rep_n<result_type, result_type, AC, EC, E2A, L1>(ac, ec, l1));
if(lo.approx().is_empty()) if(lo.approx().is_empty())
return Object();
#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>
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;
return Object(); return Object();
} catch (Uncertain_conversion_exception&) {}
#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>
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&) {
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(); CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
ET eto = ec(CGAL::exact(l1));
return make_lazy<LK>(eto);
} }
template <typename L1, typename L2> template <typename L1, typename L2>
@ -1450,12 +1463,13 @@ public:
operator()(const L1& l1, const L2& l2) const operator()(const L1& l1, const L2& l2) const
{ {
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Protect_FPU_rounding<Protection> P; {
try { Protect_FPU_rounding<Protection> P;
Lazy_object lo(new Lazy_rep_n<result_type, result_type, AC, EC, E2A, L1, L2>(ac, ec, l1, l2)); try {
Lazy_object lo(new Lazy_rep_n<result_type, result_type, AC, EC, E2A, L1, L2>(ac, ec, l1, l2));
if(lo.approx().is_empty()) if(lo.approx().is_empty())
return Object(); return Object();
#define CGAL_Kernel_obj(X) \ #define CGAL_Kernel_obj(X) \
if (object_cast<typename AK::X>(& (lo.approx()))) { \ if (object_cast<typename AK::X>(& (lo.approx()))) { \
@ -1466,7 +1480,7 @@ public:
#include <CGAL/Kernel/interface_macros.h> #include <CGAL/Kernel/interface_macros.h>
// We now check vector<X> // We now check vector<X>
#define CGAL_Kernel_obj(X) \ #define CGAL_Kernel_obj(X) \
{ \ { \
@ -1483,20 +1497,21 @@ public:
}\ }\
} }
CGAL_Kernel_obj(Point_2) CGAL_Kernel_obj(Point_2)
CGAL_Kernel_obj(Point_3) CGAL_Kernel_obj(Point_3)
#undef CGAL_Kernel_obj #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 << "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; std::cerr << "dynamic type of the Object : " << lo.approx().type().name() << std::endl;
} catch (Uncertain_conversion_exception&) { return Object();
CGAL_BRANCH_PROFILER_BRANCH(tmp); } catch (Uncertain_conversion_exception&) {}
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
ET eto = ec(CGAL::exact(l1), CGAL::exact(l2));
return make_lazy<LK>(eto);
} }
return Object(); CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
ET eto = ec(CGAL::exact(l1), CGAL::exact(l2));
return make_lazy<LK>(eto);
} }
template <typename L1, typename L2, typename L3> template <typename L1, typename L2, typename L3>
@ -1504,12 +1519,13 @@ CGAL_Kernel_obj(Point_3)
operator()(const L1& l1, const L2& l2, const L3& l3) const 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); CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Protect_FPU_rounding<Protection> P; {
try { Protect_FPU_rounding<Protection> P;
Lazy_object lo(new Lazy_rep_n<result_type, result_type, AC, EC, E2A, L1, L2, L3>(ac, ec, l1, l2, l3)); try {
Lazy_object lo(new Lazy_rep_n<result_type, result_type, AC, EC, E2A, L1, L2, L3>(ac, ec, l1, l2, l3));
if(lo.approx().is_empty()) if(lo.approx().is_empty())
return Object(); return Object();
#define CGAL_Kernel_obj(X) \ #define CGAL_Kernel_obj(X) \
if (object_cast<typename AK::X>(& (lo.approx()))) { \ if (object_cast<typename AK::X>(& (lo.approx()))) { \
@ -1520,16 +1536,16 @@ CGAL_Kernel_obj(Point_3)
#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 << "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; std::cerr << "dynamic type of the Object : " << lo.approx().type().name() << std::endl;
return Object();
} catch (Uncertain_conversion_exception&) { } 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(); CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
ET eto = ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3));
return make_lazy<LK>(eto);
} }
}; };
@ -1680,41 +1696,41 @@ struct Lazy_construction_variant {
typedef decltype(std::declval<EC const&>()( CGAL::exact(l1), CGAL::exact(l2))) ET; typedef decltype(std::declval<EC const&>()( CGAL::exact(l1), CGAL::exact(l2))) ET;
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Protect_FPU_rounding<Protection> P; {
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));
try { // the approximate result requires the trait with types from the AK
Lazy<AT, ET, E2A> lazy(new Lazy_rep_n<AT, ET, AC, EC, E2A, L1, L2>(AC(), EC(), l1, l2)); AT approx_v = lazy.approx();
// the result we build
result_type res;
// the approximate result requires the trait with types from the AK if(!approx_v) {
AT approx_v = lazy.approx(); // empty
// the result we build return res;
result_type res; }
// the static visitor fills the result_type with the correct unwrapped type
internal::Fill_lazy_variant_visitor_2< result_type, AK, LK, EK, Lazy<AT, ET, E2A> > visitor(res, lazy);
boost::apply_visitor(visitor, *approx_v);
if(!approx_v) {
// empty
return res; return res;
} } catch (Uncertain_conversion_exception&) {}
}
CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
ET exact_v = EC()(CGAL::exact(l1), CGAL::exact(l2));
result_type res;
// the static visitor fills the result_type with the correct unwrapped type if(!exact_v) {
internal::Fill_lazy_variant_visitor_2< result_type, AK, LK, EK, Lazy<AT, ET, E2A> > visitor(res, lazy);
boost::apply_visitor(visitor, *approx_v);
return res;
} catch (Uncertain_conversion_exception&) {
CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
ET exact_v = EC()(CGAL::exact(l1), CGAL::exact(l2));
result_type res;
if(!exact_v) {
return res;
}
internal::Fill_lazy_variant_visitor_0<result_type, AK, LK, EK> visitor(res);
boost::apply_visitor(visitor, *exact_v);
return res; return res;
} }
internal::Fill_lazy_variant_visitor_0<result_type, AK, LK, EK> visitor(res);
boost::apply_visitor(visitor, *exact_v);
return res;
} }
template <typename L1, typename L2, typename L3> template <typename L1, typename L2, typename L3>
@ -1733,41 +1749,42 @@ struct Lazy_construction_variant {
typedef decltype(std::declval<EC const&>()( CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3))) ET; typedef decltype(std::declval<EC const&>()( CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3))) ET;
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Protect_FPU_rounding<Protection> P; {
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));
try { // the approximate result requires the trait with types from the AK
Lazy<AT, ET, E2A> lazy(new Lazy_rep_n<AT, ET, AC, EC, E2A, L1, L2, L3>(AC(), EC(), l1, l2, l3)); AT approx_v = lazy.approx();
// the result we build
result_type res;
// the approximate result requires the trait with types from the AK if(!approx_v) {
AT approx_v = lazy.approx(); // empty
// the result we build return res;
result_type res; }
// the static visitor fills the result_type with the correct unwrapped type
internal::Fill_lazy_variant_visitor_2< result_type, AK, LK, EK, Lazy<AT, ET, E2A> > visitor(res, lazy);
boost::apply_visitor(visitor, *approx_v);
if(!approx_v) {
// empty
return res; return res;
} } catch (Uncertain_conversion_exception&) {}
}
// the static visitor fills the result_type with the correct unwrapped type CGAL_BRANCH_PROFILER_BRANCH(tmp);
internal::Fill_lazy_variant_visitor_2< result_type, AK, LK, EK, Lazy<AT, ET, E2A> > visitor(res, lazy); Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
boost::apply_visitor(visitor, *approx_v); CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
ET exact_v = EC()(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3));
result_type res;
return res; if(!exact_v) {
} catch (Uncertain_conversion_exception&) {
CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
ET exact_v = EC()(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3));
result_type res;
if(!exact_v) {
return res;
}
internal::Fill_lazy_variant_visitor_0< result_type, AK, LK, EK> visitor(res);
boost::apply_visitor(visitor, *exact_v);
return res; return res;
} }
internal::Fill_lazy_variant_visitor_0< result_type, AK, LK, EK> visitor(res);
boost::apply_visitor(visitor, *exact_v);
return res;
} }
}; };
@ -1801,14 +1818,16 @@ struct Lazy_construction<LK, AC, EC, E2A_, true> {
operator()( BOOST_PP_ENUM(n, CGAL_LARGS, _) ) const { \ operator()( BOOST_PP_ENUM(n, CGAL_LARGS, _) ) const { \
typedef Lazy< AT, ET, E2A> Handle; \ typedef Lazy< AT, ET, E2A> Handle; \
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \
Protect_FPU_rounding<Protection> P; \ { \
try { \ Protect_FPU_rounding<Protection> P; \
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)))); \ try { \
} catch (Uncertain_conversion_exception&) { \ 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)))); \
CGAL_BRANCH_PROFILER_BRANCH(tmp); \ } catch (Uncertain_conversion_exception&) {} \
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, _) ))) ); \
} \ } \
CGAL_BRANCH_PROFILER_BRANCH(tmp); \
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST); \
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST); \
return result_type( Handle(new Lazy_rep_0<AT,ET,E2A>(ec( BOOST_PP_ENUM(n, CGAL_LEXACT, _) ))) ); \
} }
// arity 1-8 // arity 1-8
@ -1859,14 +1878,16 @@ struct Lazy_construction<LK, AC, EC, E2A_, false>
typedef Lazy< AT, ET, E2A> Handle; \ typedef Lazy< AT, ET, E2A> Handle; \
typedef typename result<Lazy_construction(BOOST_PP_ENUM_PARAMS(n, L))>::type result_type; \ typedef typename result<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); \ CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \
Protect_FPU_rounding<Protection> P; \ { \
try { \ Protect_FPU_rounding<Protection> P; \
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)))); \ try { \
} catch (Uncertain_conversion_exception&) { \ 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)))); \
CGAL_BRANCH_PROFILER_BRANCH(tmp); \ } catch (Uncertain_conversion_exception&) {} \
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, _) ))) ); \
} \ } \
CGAL_BRANCH_PROFILER_BRANCH(tmp); \
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST); \
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST); \
return result_type( Handle(new Lazy_rep_0<AT,ET,E2A>(ec( BOOST_PP_ENUM(n, CGAL_LEXACT, _) ))) ); \
} }
// arity 1-8 // arity 1-8

View File

@ -390,40 +390,64 @@ int orientation(const Extended_point<RT>& p1,
const Extended_point<RT>& p3) const Extended_point<RT>& p3)
{ CGAL_NEF_TRACEN("orientation "<<p1<<p2<<p3); { CGAL_NEF_TRACEN("orientation "<<p1<<p2<<p3);
int res; int res;
try { INCTOTAL(or2); Protect_FPU_rounding<true> Protection; bool run_exact = false;
res = orientation_coeff2(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(), {
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(), Protect_FPU_rounding<true> Protection;
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD()); 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);
run_exact=true;
}
} }
catch (Uncertain_conversion_exception&) { INCEXCEPTION(or2); CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (run_exact)
res = orientation_coeff2(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(), res = orientation_coeff2(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(), p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw()); p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw());
}
if ( res != 0 ) return res; if ( res != 0 ) return res;
try { INCTOTAL(or1); Protect_FPU_rounding<true> Protection; run_exact = false;
res = orientation_coeff1(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(), {
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(), Protect_FPU_rounding<true> Protection;
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD()); 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);
run_exact = true;
}
} }
catch (Uncertain_conversion_exception&) { INCEXCEPTION(or1); CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (run_exact)
res = orientation_coeff1(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(), res = orientation_coeff1(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(), p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw()); p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw());
}
if ( res != 0 ) return res; if ( res != 0 ) return res;
try { INCTOTAL(or0); Protect_FPU_rounding<true> Protection; run_exact = false;
res = orientation_coeff0(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(), {
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(), Protect_FPU_rounding<true> Protection;
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD()); 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);
run_exact = true;
}
} }
catch (Uncertain_conversion_exception&) { INCEXCEPTION(or0); CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (run_exact)
res = orientation_coeff0(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(), res = orientation_coeff0(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(), p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw()); p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw());
}
return res; return res;
} }
@ -441,20 +465,38 @@ int compare_x(const Extended_point<RT>& p1,
const Extended_point<RT>& p2) const Extended_point<RT>& p2)
{ {
int res; int res;
try { INCTOTAL(cmpx1); Protect_FPU_rounding<true> Protection; bool run_exact = false;
res = compare_expr(p1.mxD(),p1.hwD(),p2.mxD(),p2.hwD()); {
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);
run_exact = true;
}
} }
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmpx1); CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (run_exact)
res = compare_expr(p1.mx(),p1.hw(),p2.mx(),p2.hw()); res = compare_expr(p1.mx(),p1.hw(),p2.mx(),p2.hw());
}
if ( res != 0 ) return res; if ( res != 0 ) return res;
try { INCTOTAL(cmpx0); Protect_FPU_rounding<true> Protection; run_exact = false;
res = compare_expr(p1.nxD(),p1.hwD(),p2.nxD(),p2.hwD()); {
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);
run_exact = true;
}
} }
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmpx0); CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (run_exact)
res = compare_expr(p1.nx(),p1.hw(),p2.nx(),p2.hw()); res = compare_expr(p1.nx(),p1.hw(),p2.nx(),p2.hw());
}
return res; return res;
} }
@ -466,20 +508,36 @@ int compare_y(const Extended_point<RT>& p1,
const Extended_point<RT>& p2) const Extended_point<RT>& p2)
{ {
int res; int res;
try { INCTOTAL(cmpy1); Protect_FPU_rounding<true> Protection; bool run_exact = false;
res = compare_expr(p1.myD(),p1.hwD(),p2.myD(),p2.hwD()); {
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);
run_exact = true;
}
} }
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmpy1); CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (run_exact)
res = compare_expr(p1.my(),p1.hw(),p2.my(),p2.hw()); res = compare_expr(p1.my(),p1.hw(),p2.my(),p2.hw());
}
if ( res != 0 ) return res; if ( res != 0 ) return res;
try { INCTOTAL(cmpy0); Protect_FPU_rounding<true> Protection; run_exact = false;
res = compare_expr(p1.nyD(),p1.hwD(),p2.nyD(),p2.hwD()); {
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);
run_exact = true;
}
} }
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmpy0); CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (run_exact)
res = compare_expr(p1.ny(),p1.hw(),p2.ny(),p2.hw()); res = compare_expr(p1.ny(),p1.hw(),p2.ny(),p2.hw());
}
return res; return res;
} }
@ -608,46 +666,71 @@ int compare_pair_dist(
const Extended_point<RT>& p3, const Extended_point<RT>& p4) const Extended_point<RT>& p3, const Extended_point<RT>& p4)
{ {
int res; int res;
try { INCTOTAL(cmppd2); Protect_FPU_rounding<true> Protection; bool run_exact = false;
res = cmppd_coeff2(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(), {
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(), Protect_FPU_rounding<true> Protection;
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD(), try { INCTOTAL(cmppd2);
p4.mxD(),p4.nxD(),p4.myD(),p4.nyD(),p4.hwD()); 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);
run_exact = true;
}
} }
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmppd2); CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (run_exact)
res = cmppd_coeff2(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(), res = cmppd_coeff2(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(), p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(), p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(),
p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw()); p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw());
}
if ( res != 0 ) return res; if ( res != 0 ) return res;
try { INCTOTAL(cmppd1); Protect_FPU_rounding<true> Protection; run_exact = false;
res = cmppd_coeff1(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(), {
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(), Protect_FPU_rounding<true> Protection;
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD(), try { INCTOTAL(cmppd1);
p4.mxD(),p4.nxD(),p4.myD(),p4.nyD(),p4.hwD()); 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);
run_exact = true;
}
} }
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmppd1); CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (run_exact)
res = cmppd_coeff1(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(), res = cmppd_coeff1(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(), p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(), p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(),
p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw()); p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw());
}
if ( res != 0 ) return res; if ( res != 0 ) return res;
try { INCTOTAL(cmppd0); Protect_FPU_rounding<true> Protection; run_exact = false;
res = cmppd_coeff0(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(), {
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(), Protect_FPU_rounding<true> Protection;
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD(), try { INCTOTAL(cmppd0);
p4.mxD(),p4.nxD(),p4.myD(),p4.nyD(),p4.hwD()); 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);
run_exact = true;
}
} }
catch (Uncertain_conversion_exception&) { INCEXCEPTION(cmppd0); CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (run_exact)
res = cmppd_coeff0(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(), res = cmppd_coeff0(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(), p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(), p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(),
p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw()); p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw());
}
return res; return res;
} }
@ -873,42 +956,68 @@ int orientation(const Extended_direction<RT>& d1,
Extended_point<RT> p1(d1.p1()), p2(d1.p2()), Extended_point<RT> p1(d1.p1()), p2(d1.p2()),
p3(d2.p1()), p4(d2.p2()); p3(d2.p1()), p4(d2.p2());
int res; int res;
try { INCTOTAL(ord2); Protect_FPU_rounding<true> Protection; bool run_exact = true;
res = coeff2_dor(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(), {
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(), Protect_FPU_rounding<true> Protection;
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD(), try { INCTOTAL(ord2);
p4.mxD(),p4.nxD(),p4.myD(),p4.nyD(),p4.hwD()); res = coeff2_dor(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(),
} catch (Uncertain_conversion_exception&) { INCEXCEPTION(ord2); 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);
run_exact=true;
}
}
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (run_exact)
res = coeff2_dor(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(), res = coeff2_dor(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(), p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(), p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(),
p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw()); p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw());
}
if ( res != 0 ) return res; if ( res != 0 ) return res;
try { INCTOTAL(ord1); Protect_FPU_rounding<true> Protection; run_exact = false;
res = coeff1_dor(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(), {
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(), Protect_FPU_rounding<true> Protection;
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD(), try { INCTOTAL(ord1);
p4.mxD(),p4.nxD(),p4.myD(),p4.nyD(),p4.hwD()); res = coeff1_dor(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(),
} catch (Uncertain_conversion_exception&) { INCEXCEPTION(ord1); 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);
run_exact=true;
}
}
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if (run_exact)
res = coeff1_dor(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(), res = coeff1_dor(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(), p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(), p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(),
p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw()); p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw());
}
if ( res != 0 ) return res; if ( res != 0 ) return res;
try { INCTOTAL(ord0); Protect_FPU_rounding<true> Protection;
res = coeff0_dor(p1.mxD(),p1.nxD(),p1.myD(),p1.nyD(),p1.hwD(), run_exact = false;
p2.mxD(),p2.nxD(),p2.myD(),p2.nyD(),p2.hwD(), {
p3.mxD(),p3.nxD(),p3.myD(),p3.nyD(),p3.hwD(), Protect_FPU_rounding<true> Protection;
p4.mxD(),p4.nxD(),p4.myD(),p4.nyD(),p4.hwD()); try { INCTOTAL(ord0); Protect_FPU_rounding<true> Protection;
} catch (Uncertain_conversion_exception&) { INCEXCEPTION(ord0); 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);
run_exact = true;
}
}
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
if(run_exact)
res = coeff0_dor(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(), res = coeff0_dor(p1.mx(),p1.nx(),p1.my(),p1.ny(),p1.hw(),
p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(), p2.mx(),p2.nx(),p2.my(),p2.ny(),p2.hw(),
p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(), p3.mx(),p3.nx(),p3.my(),p3.ny(),p3.hw(),
p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw()); p4.mx(),p4.nx(),p4.my(),p4.ny(),p4.hw());
}
return res; return res;
} }

View File

@ -48,6 +48,7 @@ struct Cartesian_filter_NT : public Base_
if(is_certain(res)) return get_certain(res); if(is_certain(res)) return get_certain(res);
} catch (Uncertain_conversion_exception&) {} } catch (Uncertain_conversion_exception&) {}
} }
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
return p2(std::forward<U>(u)...); return p2(std::forward<U>(u)...);
} }
}; };

View File

@ -92,6 +92,8 @@ public:
catch (Uncertain_conversion_exception&) {} catch (Uncertain_conversion_exception&) {}
} }
CGAL_BRANCH_PROFILER_BRANCH(tmp); CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> p(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
return ep(c2e(std::forward<Args>(args))...); return ep(c2e(std::forward<Args>(args))...);
} }
}; };

View File

@ -176,14 +176,16 @@ struct Lazy_construction2 {
template<class...L> template<class...L>
std::enable_if_t<(sizeof...(L)>0), result_type> operator()(L const&...l) const { 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); CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Protect_FPU_rounding<Protection> P; {
try { Protect_FPU_rounding<Protection> P;
return new Lazy_rep_XXX<AT, ET, AC, EC, E2A, L...>(ac, ec, l...); try {
} catch (Uncertain_conversion_exception&) { return new Lazy_rep_XXX<AT, ET, AC, EC, E2A, L...>(ac, ec, l...);
CGAL_BRANCH_PROFILER_BRANCH(tmp); } catch (Uncertain_conversion_exception&) {}
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
return new Lazy_rep_0<AT,ET,E2A>(ec(CGAL::exact(l)...));
} }
CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<!Protection> P2(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == 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 // 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(). // Actually, that may be the clearing in update_exact().

View File

@ -313,7 +313,7 @@ sign(TMC_Vertex_handle vit) const
} }
CGAL_BRANCH_PROFILER_BRANCH(tmp); CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<false> P(CGAL_FE_TONEAREST); Protect_FPU_rounding<false> P(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
typedef Exact_predicates_exact_constructions_kernel EK; typedef Exact_predicates_exact_constructions_kernel EK;
typedef Skin_surface_traits_3<EK> Exact_skin_surface_traits; typedef Skin_surface_traits_3<EK> Exact_skin_surface_traits;
typedef Skin_surface_base_3<Exact_skin_surface_traits> Exact_skin_surface_base; typedef Skin_surface_base_3<Exact_skin_surface_traits> Exact_skin_surface_base;
@ -355,6 +355,7 @@ sign(const Bare_point &p, const Cell_info &info) const
} }
CGAL_BRANCH_PROFILER_BRANCH(tmp); CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<false> P(CGAL_FE_TONEAREST); Protect_FPU_rounding<false> P(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
return construct_surface(info.first, return construct_surface(info.first,
Exact_predicates_exact_constructions_kernel()).sign(p); Exact_predicates_exact_constructions_kernel()).sign(p);
} }
@ -630,7 +631,7 @@ compare(Cell_info &info1, const Bare_point &p1,
} }
CGAL_BRANCH_PROFILER_BRANCH(tmp); CGAL_BRANCH_PROFILER_BRANCH(tmp);
Protect_FPU_rounding<false> P(CGAL_FE_TONEAREST); Protect_FPU_rounding<false> P(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
return CGAL_NTS sign( return CGAL_NTS sign(
construct_surface(info1.first, construct_surface(info1.first,
Exact_predicates_exact_constructions_kernel()).value(p1) - Exact_predicates_exact_constructions_kernel()).value(p1) -
@ -689,33 +690,37 @@ locate_in_tmc(const Bare_point &p0, TMC_Cell_handle start) const
// We temporarily put p at i's place in pts. // We temporarily put p at i's place in pts.
const TMC_Point* backup = pts[i]; const TMC_Point* backup = pts[i];
pts[i] = &p_inexact; pts[i] = &p_inexact;
bool run_exact=false;
{ {
Protect_FPU_rounding<true> P; Protect_FPU_rounding<true> P;
try { try {
o = TMC_Geom_traits().orientation_3_object()(*pts[0], *pts[1], o = TMC_Geom_traits().orientation_3_object()(*pts[0], *pts[1],
*pts[2], *pts[3]); *pts[2], *pts[3]);
} catch (Uncertain_conversion_exception&) { } catch (Uncertain_conversion_exception&) { run_exact=true; }
Protect_FPU_rounding<false> P(CGAL_FE_TONEAREST); }
typedef Exact_predicates_exact_constructions_kernel EK; CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
Cartesian_converter<typename Bare_point::R, EK> converter_ek; 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;
Skin_surface_traits_3<EK> exact_traits(shrink_factor()); Skin_surface_traits_3<EK> exact_traits(shrink_factor());
typename EK::Point_3 e_pts[4]; typename EK::Point_3 e_pts[4];
// We know that the 4 vertices of c are positively oriented. // We know that the 4 vertices of c are positively oriented.
// So, in order to test if p is seen outside from one of c's facets, // So, in order to test if p is seen outside from one of c's facets,
// we just replace the corresponding point by p in the orientation // we just replace the corresponding point by p in the orientation
// test. We do this using the array below. // test. We do this using the array below.
for (int k=0; k<4; k++) { for (int k=0; k<4; k++) {
if (k != i) { if (k != i) {
e_pts[k] = get_anchor_point(c->vertex(k)->info(), exact_traits); e_pts[k] = get_anchor_point(c->vertex(k)->info(), exact_traits);
} else { } else {
e_pts[k] = converter_ek(p0); e_pts[k] = converter_ek(p0);
}
} }
o = orientation(e_pts[0], e_pts[1], e_pts[2], e_pts[3]);
} }
o = orientation(e_pts[0], e_pts[1], e_pts[2], e_pts[3]);
} }
if ( o != NEGATIVE ) { if ( o != NEGATIVE ) {

View File

@ -1197,39 +1197,39 @@ Mixed_complex_triangulator_3<RegularTriangulation_3,
TriangulatedMixedComplexObserver_3>:: TriangulatedMixedComplexObserver_3>::
orientation(Tmc_Cell_handle ch) 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 // Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG
Protect_FPU_rounding<true> P; Protect_FPU_rounding<true> P;
try { try {
Tmc_Point pts[4]; Tmc_Point pts[4];
for (int i=0; i<4; i++) for (int i=0; i<4; i++)
pts[i] = ch->vertex(i)->point(); pts[i] = ch->vertex(i)->point();
// filtered kernel // filtered kernel
o = _tmc.geom_traits().orientation_3_object()(pts[0], pts[1], pts[2], pts[3]); return _tmc.geom_traits().orientation_3_object()(pts[0], pts[1], pts[2], pts[3]);
} catch (Uncertain_conversion_exception&) { } 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;
typedef Skin_surface_traits_3<EK> Exact_traits;
typedef Skin_surface_base_3<EK> Exact_skin_surface;
Exact_converter converter;
Exact_traits exact_traits(shrink);
typename Exact_skin_surface::Bare_point e_pts[4];
for (int k=0; k<4; k++) {
e_pts[k] =
Triangulated_mixed_complex_observer::Skin_surface::
get_anchor_point(ch->vertex(k)->info(), exact_traits);
// 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],
e_pts[2], e_pts[3]);
} }
return o; Protect_FPU_rounding<false> P(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
typedef Exact_predicates_exact_constructions_kernel EK;
typedef Cartesian_converter<EK, Tmc_traits> Exact_converter;
typedef Skin_surface_traits_3<EK> Exact_traits;
typedef Skin_surface_base_3<EK> Exact_skin_surface;
Exact_converter converter;
Exact_traits exact_traits(shrink);
typename Exact_skin_surface::Bare_point e_pts[4];
for (int k=0; k<4; k++) {
e_pts[k] =
Triangulated_mixed_complex_observer::Skin_surface::
get_anchor_point(ch->vertex(k)->info(), exact_traits);
// Store the more precise point
ch->vertex(k)->point() = converter(e_pts[k]);
}
return exact_traits.orientation_3_object()(e_pts[0], e_pts[1],
e_pts[2], e_pts[3]);
} }
template <class RegularTriangulation_3, template <class RegularTriangulation_3,

View File

@ -136,20 +136,23 @@ public:
result_type result_type
operator()(A&& ... a) const operator()(A&& ... a) const
{ {
try
{ {
Protect_FPU_rounding<Protection> P; Protect_FPU_rounding<Protection> P;
FC_result_type fr = Filter_construction(To_Filtered(std::forward<A>(a))...); try
{
FC_result_type fr = Filter_construction(To_Filtered(std::forward<A>(a))...);
const double precision = const double precision =
Lazy_exact_nt<double>::get_relative_precision_of_to_double(); Lazy_exact_nt<double>::get_relative_precision_of_to_double();
if ( fr && has_enough_precision(*fr, precision) ) if ( fr && has_enough_precision(*fr, precision) )
return From_Filtered(fr); return From_Filtered(fr);
}
catch (Uncertain_conversion_exception&) {}
} }
catch (Uncertain_conversion_exception&) {}
Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST); Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST);
EC_result_type er = Exact_construction(To_Exact(std::forward<A>(a))...) ; EC_result_type er = Exact_construction(To_Exact(std::forward<A>(a))...) ;
return From_Exact(er); return From_Exact(er);
} }