summaryrefslogtreecommitdiff
path: root/src/Alpha_complex
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-11-14 09:47:52 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-11-14 09:47:52 +0000
commit4e4b190e9f3937f3f136c83e42c3c9322074f16a (patch)
tree3845d46979bfc611588b98ade45e00e3c3d1c579 /src/Alpha_complex
parentc5ced45c3efd3ccfe2d2b94ee04727ba66c76e6a (diff)
Fix https://github.com/CGAL/cgal/issues/3153
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@3978 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 41b598d277452a2ebcf9eedc3a7e144d96e46b1d
Diffstat (limited to 'src/Alpha_complex')
-rw-r--r--src/Alpha_complex/include/gudhi/Alpha_complex_3d.h49
1 files changed, 42 insertions, 7 deletions
diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
index 0333abbd..00a47d5c 100644
--- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
+++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
@@ -67,12 +67,20 @@ namespace Gudhi {
namespace alpha_complex {
+#ifdef GUDHI_CAN_USE_CXX11_THREAD_LOCAL
+thread_local
+#endif // GUDHI_CAN_USE_CXX11_THREAD_LOCAL
+ double RELATIVE_PRECISION_OF_TO_DOUBLE = 0.00001;
+
// Value_from_iterator returns the filtration value from an iterator on alpha shapes values
//
-// FAST SAFE EXACT
-// *iterator CGAL::to_double(*iterator) CGAL::to_double(iterator->exact())
+// FAST SAFE EXACT
+// not weighted and *iterator Specific case due to CGAL CGAL::to_double(iterator->exact())
+// not periodic issue # 3153
+//
+// otherwise *iterator CGAL::to_double(*iterator) CGAL::to_double(iterator->exact())
-template <complexity Complexity>
+template <complexity Complexity, bool Weighted_or_periodic>
struct Value_from_iterator {
template <typename Iterator>
static double perform(Iterator it) {
@@ -82,16 +90,43 @@ struct Value_from_iterator {
};
template <>
-struct Value_from_iterator<complexity::SAFE> {
+struct Value_from_iterator<complexity::SAFE, true> {
template <typename Iterator>
static double perform(Iterator it) {
- // In SAFE mode, we are with Epeck or Epick with EXACT value set to CGAL::Tag_true.
+ // In SAFE mode, we are with Epick with EXACT value set to CGAL::Tag_true.
return CGAL::to_double(*it);
}
};
template <>
-struct Value_from_iterator<complexity::EXACT> {
+struct Value_from_iterator<complexity::SAFE, false> {
+ template <typename Iterator>
+ static double perform(Iterator it) {
+ // In SAFE mode, we are with Epeck with EXACT value set to CGAL::Tag_true.
+ // Specific case due to CGAL issue https://github.com/CGAL/cgal/issues/3153
+ auto approx = it->approx();
+ double r;
+ if (CGAL::fit_in_double(approx, r)) return r;
+
+ // If it's precise enough, then OK.
+ if (CGAL::has_smaller_relative_precision(approx, RELATIVE_PRECISION_OF_TO_DOUBLE)) return CGAL::to_double(approx);
+
+ it->exact();
+ return CGAL::to_double(it->approx());
+ }
+};
+
+template <>
+struct Value_from_iterator<complexity::EXACT, true> {
+ template <typename Iterator>
+ static double perform(Iterator it) {
+ // In EXACT mode, we are with Epeck or Epick with EXACT value set to CGAL::Tag_true.
+ return CGAL::to_double(it->exact());
+ }
+};
+
+template <>
+struct Value_from_iterator<complexity::EXACT, false> {
template <typename Iterator>
static double perform(Iterator it) {
// In EXACT mode, we are with Epeck or Epick with EXACT value set to CGAL::Tag_true.
@@ -524,7 +559,7 @@ class Alpha_complex_3d {
}
}
// Construction of the simplex_tree
- Filtration_value filtr = Value_from_iterator<Complexity>::perform(alpha_value_iterator);
+ Filtration_value filtr = Value_from_iterator<Complexity, (Weighted || Periodic)>::perform(alpha_value_iterator);
#ifdef DEBUG_TRACES
std::cout << "filtration = " << filtr << std::endl;