summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-11-13 16:41:12 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-11-13 16:41:12 +0000
commitc972b77524faec5d6f297d442539f65b9351654e (patch)
tree7126abaa127128a392959bba9e7d7f12508e7971 /src
parent8881190bccba9da4af0a07c701369099fd7f2277 (diff)
Utils.h -> Debug_utils.h
More verbose in debug mode (use NDEBUG instead of DEBUG_TRACES) GUDHI_CHECK function to throw in debug or ignore in release mode git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alphashapes@911 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 250dc0c0f5146f0b9e3fce0e9a8ca0da6af7cf98
Diffstat (limited to 'src')
-rw-r--r--src/Alpha_complex/example/CMakeLists.txt4
-rw-r--r--src/Alpha_complex/include/gudhi/Alpha_complex.h96
-rw-r--r--src/Alpha_complex/test/CMakeLists.txt4
-rw-r--r--src/CMakeLists.txt13
-rw-r--r--src/Contraction/include/gudhi/Contraction/policies/Link_condition_valid_contraction.h2
-rw-r--r--src/Contraction/include/gudhi/Edge_contraction.h2
-rw-r--r--src/Contraction/include/gudhi/Skeleton_blocker_contractor.h2
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h40
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h2
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h2
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h2
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h2
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h2
-rw-r--r--src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h2
-rw-r--r--src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp2
-rw-r--r--src/common/example/Delaunay_triangulation_off_rw.cpp5
-rw-r--r--src/common/include/gudhi/Debug_utils.h (renamed from src/common/include/gudhi/Utils.h)43
-rw-r--r--src/common/include/gudhi/Delaunay_triangulation_off_io.h19
18 files changed, 119 insertions, 125 deletions
diff --git a/src/Alpha_complex/example/CMakeLists.txt b/src/Alpha_complex/example/CMakeLists.txt
index 24f3a9dc..47e42b72 100644
--- a/src/Alpha_complex/example/CMakeLists.txt
+++ b/src/Alpha_complex/example/CMakeLists.txt
@@ -29,10 +29,6 @@ if(CGAL_FOUND)
if (EIGEN3_FOUND)
message(STATUS "Eigen3 version: ${EIGEN3_VERSION}.")
include( ${EIGEN3_USE_FILE} )
- if (CMAKE_BUILD_TYPE MATCHES Debug)
- # For programs to be more verbose
- add_definitions(-DDEBUG_TRACES)
- endif()
add_executable ( alphaoffreader Alpha_complex_from_off.cpp )
target_link_libraries(alphaoffreader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h
index 10b290b5..2cc93a0a 100644
--- a/src/Alpha_complex/include/gudhi/Alpha_complex.h
+++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h
@@ -26,6 +26,7 @@
// to construct a simplex_tree from Delaunay_triangulation
#include <gudhi/graph_simplicial_complex.h>
#include <gudhi/Simplex_tree.h>
+#include <gudhi/Debug_utils.h>
#include <stdlib.h>
#include <math.h> // isnan, fmax
@@ -39,6 +40,7 @@
#include <limits> // NaN
#include <map>
#include <utility> // std::pair
+#include <stdexcept>
namespace Gudhi {
@@ -112,7 +114,7 @@ class Alpha_complex : public Simplex_tree<> {
: triangulation_(nullptr) {
Gudhi::Delaunay_triangulation_off_reader<Delaunay_triangulation> off_reader(off_file_name);
if (!off_reader.is_valid()) {
- std::cerr << "Alpha_complex - Unable to read file " << off_file_name << std::endl;
+ std::cerr << "Alpha_complex - Unable to read file " << off_file_name;
exit(-1); // ----- >>
}
triangulation_ = off_reader.get_complex();
@@ -137,6 +139,8 @@ class Alpha_complex : public Simplex_tree<> {
*
* The type InputPointRange must be a range for which std::begin and
* std::end return input iterators on a Kernel::Point_d.
+ * \warning In debug mode, the exception std::invalid_argument is thrown if an empty input point range is passed as
+ * argument.
*/
template<typename InputPointRange >
Alpha_complex(const InputPointRange& points,
@@ -144,18 +148,24 @@ class Alpha_complex : public Simplex_tree<> {
: triangulation_(nullptr) {
auto first = std::begin(points);
auto last = std::end(points);
- // point_dimension function initialization
- Point_Dimension point_dimension = kernel_.point_dimension_d_object();
+
+ GUDHI_CHECK((first == last),
+ std::invalid_argument ("Alpha_complex::Alpha_complex(InputPointRange) - Empty input point range"));
+
+ if (first != last) {
+ // point_dimension function initialization
+ Point_Dimension point_dimension = kernel_.point_dimension_d_object();
- // Delaunay triangulation is point dimension minus one.
- triangulation_ = new Delaunay_triangulation(point_dimension(*first) - 1);
+ // Delaunay triangulation is point dimension minus one.
+ triangulation_ = new Delaunay_triangulation(point_dimension(*first) - 1);
- size_type inserted = triangulation_->insert(first, last);
- if (inserted != (last -first)) {
- std::cerr << "Alpha_complex - insertion failed " << inserted << " != " << (last -first) << std::endl;
- exit(-1); // ----- >>
+ size_type inserted = triangulation_->insert(first, last);
+ if (inserted != (last -first)) {
+ std::cerr << "Alpha_complex - insertion failed " << inserted << " != " << (last -first);
+ exit(-1); // ----- >>
+ }
+ init(max_alpha_square);
}
- init(max_alpha_square);
}
/** \brief Alpha_complex destructor from a Delaunay triangulation.
@@ -188,23 +198,25 @@ class Alpha_complex : public Simplex_tree<> {
*/
void init(Filtration_value max_alpha_square) {
if (triangulation_ == nullptr) {
- std::cerr << "Alpha_complex init - Cannot init from a NULL triangulation" << std::endl;
+ std::cerr << "Alpha_complex init - Cannot init from a NULL triangulation";
return; // ----- >>
}
if (triangulation_->number_of_vertices() < 1) {
- std::cerr << "Alpha_complex init - Cannot init from a triangulation without vertices" << std::endl;
+ std::cerr << "Alpha_complex init - Cannot init from a triangulation without vertices";
return; // ----- >>
}
if (triangulation_->maximal_dimension() < 1) {
- std::cerr << "Alpha_complex init - Cannot init from a zero-dimension triangulation" << std::endl;
+ std::cerr << "Alpha_complex init - Cannot init from a zero-dimension triangulation";
return; // ----- >>
}
if (num_vertices() > 0) {
- std::cerr << "Alpha_complex init - Cannot init twice" << std::endl;
+ std::cerr << "Alpha_complex init - Cannot init twice";
return; // ----- >>
}
set_dimension(triangulation_->maximal_dimension());
+ // set_filtration to +inf for prune_above_filtration to be done (if necessary)
+ set_filtration(std::numeric_limits<Filtration_value>::infinity());
// --------------------------------------------------------------------------------------------
// double map to retrieve simplex tree vertex handles from CGAL vertex iterator and vice versa
@@ -213,9 +225,9 @@ class Alpha_complex : public Simplex_tree<> {
// Loop on triangulation vertices list
for (CGAL_vertex_iterator vit = triangulation_->vertices_begin(); vit != triangulation_->vertices_end(); ++vit) {
if (!triangulation_->is_infinite(*vit)) {
-#ifdef DEBUG_TRACES
- std::cout << "Vertex insertion - " << vertex_handle << " -> " << vit->point() << std::endl;
-#endif // DEBUG_TRACES
+ DBGMSG("Vertex insertion - ", vertex_handle);
+ DBGMSG(" -> ", vit->point());
+
vertex_iterator_to_handle_.emplace(vit, vertex_handle);
vertex_handle_to_iterator_.push_back(vit);
vertex_handle++;
@@ -227,21 +239,12 @@ class Alpha_complex : public Simplex_tree<> {
// Simplex_tree construction from loop on triangulation finite full cells list
for (auto cit = triangulation_->finite_full_cells_begin(); cit != triangulation_->finite_full_cells_end(); ++cit) {
Vector_vertex vertexVector;
-#ifdef DEBUG_TRACES
- std::cout << "Simplex_tree insertion ";
-#endif // DEBUG_TRACES
for (auto vit = cit->vertices_begin(); vit != cit->vertices_end(); ++vit) {
if (*vit != nullptr) {
-#ifdef DEBUG_TRACES
- std::cout << " " << vertex_iterator_to_handle_[*vit];
-#endif // DEBUG_TRACES
// Vector of vertex construction for simplex_tree structure
vertexVector.push_back(vertex_iterator_to_handle_[*vit]);
}
}
-#ifdef DEBUG_TRACES
- std::cout << std::endl;
-#endif // DEBUG_TRACES
// Insert each simplex and its subfaces in the simplex tree - filtration is NaN
Simplex_result insert_result = insert_simplex_and_subfaces(vertexVector,
std::numeric_limits<double>::quiet_NaN());
@@ -256,18 +259,11 @@ class Alpha_complex : public Simplex_tree<> {
int f_simplex_dim = dimension(f_simplex);
if (decr_dim == f_simplex_dim) {
Vector_of_CGAL_points pointVector;
-#ifdef DEBUG_TRACES
- std::cout << "Sigma of dim " << decr_dim << " is";
-#endif // DEBUG_TRACES
+ DBGMSG("Sigma of dim ", decr_dim);
for (auto vertex : simplex_vertex_range(f_simplex)) {
pointVector.push_back(get_point(vertex));
-#ifdef DEBUG_TRACES
- std::cout << " " << vertex;
-#endif // DEBUG_TRACES
}
-#ifdef DEBUG_TRACES
- std::cout << std::endl;
-#endif // DEBUG_TRACES
+ DBGCONT(simplex_vertex_range(f_simplex));
// ### If filt(Sigma) is NaN : filt(Sigma) = alpha(Sigma)
if (isnan(filtration(f_simplex))) {
Filtration_value alpha_complex_filtration = 0.0;
@@ -279,9 +275,7 @@ class Alpha_complex : public Simplex_tree<> {
alpha_complex_filtration = squared_radius(pointVector.begin(), pointVector.end());
}
assign_filtration(f_simplex, alpha_complex_filtration);
-#ifdef DEBUG_TRACES
- std::cout << "filt(Sigma) is NaN : filt(Sigma) =" << filtration(f_simplex) << std::endl;
-#endif // DEBUG_TRACES
+ DBGMSG("filt(Sigma) is NaN : filt(Sigma) =", filtration(f_simplex));
}
propagate_alpha_filtration(f_simplex, decr_dim);
}
@@ -301,23 +295,16 @@ class Alpha_complex : public Simplex_tree<> {
void propagate_alpha_filtration(Simplex_handle f_simplex, int decr_dim) {
// ### Foreach Tau face of Sigma
for (auto f_boundary : boundary_simplex_range(f_simplex)) {
-#ifdef DEBUG_TRACES
- std::cout << " | --------------------------------------------------\n";
- std::cout << " | Tau ";
- for (auto vertex : simplex_vertex_range(f_boundary)) {
- std::cout << vertex << " ";
- }
- std::cout << "is a face of Sigma\n";
- std::cout << " | isnan(filtration(Tau)=" << isnan(filtration(f_boundary)) << std::endl;
-#endif // DEBUG_TRACES
+ DBG("------------- TAU -------------");
+ DBGCONT(simplex_vertex_range(f_boundary));
+ DBG("is a face of Sigma");
+ DBGMSG("isnan(filtration(Tau)=", isnan(filtration(f_boundary)));
// ### If filt(Tau) is not NaN
if (!isnan(filtration(f_boundary))) {
// ### filt(Tau) = fmin(filt(Tau), filt(Sigma))
Filtration_value alpha_complex_filtration = fmin(filtration(f_boundary), filtration(f_simplex));
assign_filtration(f_boundary, alpha_complex_filtration);
-#ifdef DEBUG_TRACES
- std::cout << " | filt(Tau) = fmin(filt(Tau), filt(Sigma)) = " << filtration(f_boundary) << std::endl;
-#endif // DEBUG_TRACES
+ DBGMSG("filt(Tau) = fmin(filt(Tau), filt(Sigma)) = ", filtration(f_boundary));
// ### Else
} else {
// No need to compute is_gabriel for dimension <= 2
@@ -344,17 +331,14 @@ class Alpha_complex : public Simplex_tree<> {
Is_Gabriel is_gabriel = kernel_.side_of_bounded_sphere_d_object();
bool is_gab = is_gabriel(pointVector.begin(), pointVector.end(), point_for_gabriel)
!= CGAL::ON_BOUNDED_SIDE;
-#ifdef DEBUG_TRACES
- std::cout << " | Tau is_gabriel(Sigma)=" << is_gab << " - vertexForGabriel=" << vertexForGabriel << std::endl;
-#endif // DEBUG_TRACES
+ DBGMSG("Tau is_gabriel(Sigma)=", is_gab);
+ DBGMSG(" - vertexForGabriel=", vertexForGabriel);
// ### If Tau is not Gabriel of Sigma
if (false == is_gab) {
// ### filt(Tau) = filt(Sigma)
Filtration_value alpha_complex_filtration = filtration(f_simplex);
assign_filtration(f_boundary, alpha_complex_filtration);
-#ifdef DEBUG_TRACES
- std::cout << " | filt(Tau) = filt(Sigma) = " << filtration(f_boundary) << std::endl;
-#endif // DEBUG_TRACES
+ DBGMSG("filt(Tau) = filt(Sigma) = ", filtration(f_boundary));
}
}
}
diff --git a/src/Alpha_complex/test/CMakeLists.txt b/src/Alpha_complex/test/CMakeLists.txt
index 847581aa..fa24e1b1 100644
--- a/src/Alpha_complex/test/CMakeLists.txt
+++ b/src/Alpha_complex/test/CMakeLists.txt
@@ -14,10 +14,6 @@ if(CGAL_FOUND)
message(STATUS "Eigen3 version: ${EIGEN3_VERSION}.")
include( ${EIGEN3_USE_FILE} )
include_directories (BEFORE "../../include")
- if (CMAKE_BUILD_TYPE MATCHES Debug)
- # For programs to be more verbose
- add_definitions(-DDEBUG_TRACES)
- endif()
add_executable ( AlphaComplexUT Alpha_complex_unit_test.cpp )
target_link_libraries(AlphaComplexUT ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cd7f4991..0f946e3b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,15 +3,22 @@ project(GUDHI)
include("CMakeGUDHIVersion.txt")
+if (NOT CMAKE_BUILD_TYPE)
+ # Set default build type to Release
+ set(CMAKE_BUILD_TYPE "Release")
+endif()
+
+if (CMAKE_BUILD_TYPE MATCHES Debug)
+ # For programs to be more verbose
+ add_definitions(-DNDEBUG)
+endif()
+
enable_testing()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
find_package(Boost REQUIRED COMPONENTS system filesystem program_options chrono timer REQUIRED)
-if (NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE "Release")
-endif()
if(MSVC)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4668 /wd4311 /wd4800 /wd4820 /wd4503 /wd4244 /wd4345 /wd4996 /wd4396 /wd4018")
else()
diff --git a/src/Contraction/include/gudhi/Contraction/policies/Link_condition_valid_contraction.h b/src/Contraction/include/gudhi/Contraction/policies/Link_condition_valid_contraction.h
index 919df243..250bba27 100644
--- a/src/Contraction/include/gudhi/Contraction/policies/Link_condition_valid_contraction.h
+++ b/src/Contraction/include/gudhi/Contraction/policies/Link_condition_valid_contraction.h
@@ -23,8 +23,8 @@
#ifndef CONTRACTION_POLICIES_LINK_CONDITION_VALID_CONTRACTION_H_
#define CONTRACTION_POLICIES_LINK_CONDITION_VALID_CONTRACTION_H_
-#include <gudhi/Utils.h>
#include <gudhi/Contraction/policies/Valid_contraction_policy.h>
+#include <gudhi/Debug_utils.h>
namespace Gudhi {
diff --git a/src/Contraction/include/gudhi/Edge_contraction.h b/src/Contraction/include/gudhi/Edge_contraction.h
index 349bb7d8..011ca9bd 100644
--- a/src/Contraction/include/gudhi/Edge_contraction.h
+++ b/src/Contraction/include/gudhi/Edge_contraction.h
@@ -30,7 +30,7 @@
#include <gudhi/Contraction/policies/Valid_contraction_policy.h>
#include <gudhi/Contraction/policies/Dummy_valid_contraction.h>
#include <gudhi/Contraction/policies/Link_condition_valid_contraction.h>
-#include <gudhi/Utils.h>
+#include <gudhi/Debug_utils.h>
namespace Gudhi {
diff --git a/src/Contraction/include/gudhi/Skeleton_blocker_contractor.h b/src/Contraction/include/gudhi/Skeleton_blocker_contractor.h
index 2759b540..47d798c0 100644
--- a/src/Contraction/include/gudhi/Skeleton_blocker_contractor.h
+++ b/src/Contraction/include/gudhi/Skeleton_blocker_contractor.h
@@ -37,7 +37,7 @@
#include <gudhi/Contraction/policies/Contraction_visitor.h>
#include <gudhi/Skeleton_blocker/Skeleton_blocker_complex_visitor.h>
-#include <gudhi/Utils.h>
+#include <gudhi/Debug_utils.h>
#include <boost/scoped_array.hpp>
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h
index 8c1beaef..dc8591fc 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h
@@ -30,6 +30,7 @@
#include <gudhi/reader_utils.h>
#include <gudhi/graph_simplicial_complex.h>
+#include <gudhi/Debug_utils.h>
#include <boost/container/flat_map.hpp>
#include <boost/iterator/transform_iterator.hpp>
@@ -39,7 +40,8 @@
#include <utility>
#include <vector>
#include <functional> // for greater<>
-#include <limits> // for numeric_limits infinity
+#include <stdexcept>
+#include <limits> // Inf
namespace Gudhi {
/** \defgroup simplex_tree Filtered Complexes
@@ -717,7 +719,7 @@ class Simplex_tree {
} else if (the_simplex.size() == 1) {
// When reaching the end of recursivity, vector of simplices shall be empty and filled on back recursive
if ((to_be_inserted.size() != 0) || (to_be_propagated.size() != 0)) {
- std::cerr << "Simplex_tree::rec_insert_simplex_and_subfaces - Error vector not empty" << std::endl;
+ std::cerr << "Simplex_tree::rec_insert_simplex_and_subfaces - Error vector not empty";
exit(-1);
}
std::vector<Vertex_handle> first_simplex(1, the_simplex.back());
@@ -726,7 +728,7 @@ class Simplex_tree {
insert_result = insert_vertex_vector(first_simplex, filtration);
} else {
- std::cerr << "Simplex_tree::rec_insert_simplex_and_subfaces - Recursivity error" << std::endl;
+ std::cerr << "Simplex_tree::rec_insert_simplex_and_subfaces - Recursivity error";
exit(-1);
}
return insert_result;
@@ -1099,22 +1101,23 @@ class Simplex_tree {
os << filtration(sh) << " \n";
}
}
-
+
public:
/** \brief Browse the simplex tree to ensure the filtration is not decreasing.
- * @return The filtration modification information in order to trigger initialize_filtration.
- * \warning initialize_filtration is launched again in case of filtration modification change.
+ * The simplex tree is browsed starting from the root until the leaf, and the filtration values are set with their
+ * parent value (increased), in case the values are decreasing.
+ * @return The filtration modification information.
+ * \warning Some simplex tree functions require the filtration to be valid. `make_filtration_non_decreasing()`
+ * function is not launching `initialize_filtration()` but returns the filtration modification information. If the
+ * complex has changed , please call `initialize_filtration()` to recompute it.
*/
bool make_filtration_non_decreasing() {
bool modified = false;
for (auto sh = root_.members().begin(); sh != root_.members().end(); ++sh) {
if (has_children(sh)) {
- modified = modified || rec_make_filtration_non_decreasing(sh->second.children(), sh->second.filtration());
+ modified |= rec_make_filtration_non_decreasing(sh->second.children(), sh->second.filtration());
}
}
- if (modified) {
- initialize_filtration();
- }
return modified;
}
@@ -1134,7 +1137,7 @@ class Simplex_tree {
sh->second.assign_filtration(upper_filtration);
}
if (has_children(sh)) {
- modified = modified || rec_make_filtration_non_decreasing(sh->second.children(), sh->second.filtration());
+ modified |= rec_make_filtration_non_decreasing(sh->second.children(), sh->second.filtration());
}
}
// Make the modified information to be traced by upper call
@@ -1150,8 +1153,8 @@ class Simplex_tree {
* call `initialize_filtration()` to recompute it.
*/
void prune_above_filtration(Filtration_value filtration) {
- threshold_ = filtration;
- if (filtration != std::numeric_limits<Filtration_value>::infinity()) {
+ if (filtration < threshold_) {
+ threshold_ = filtration;
// Initialize filtration_vect_ if required
if (filtration_vect_.empty()) {
initialize_filtration();
@@ -1168,16 +1171,15 @@ class Simplex_tree {
}
}
- private:
/** \brief Remove a maximal simplex.
* @param[in] sh Simplex handle on the maximal simplex to remove.
- * \warning Exception std::invalid_argument is thrown in sh has children.
+ * \warning In debug mode, the exception std::invalid_argument is thrown if sh has children.
*/
void remove_maximal_simplex(Simplex_handle sh) {
- // Guarantee the simplex is maximal
- if (has_children(sh)) {
- throw std::invalid_argument ("Simplex_tree::remove_maximal_simplex - argument is not a maximal simplex");
- }
+ // Guarantee the simplex has no children
+ GUDHI_CHECK(has_children(sh),
+ std::invalid_argument ("Simplex_tree::remove_maximal_simplex - argument is not a maximal simplex"));
+
// Simplex is a leaf, it means the child is the Siblings owning the leaf.
Siblings* child = sh->second.children();
if (child->size() > 1) {
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h
index 3be480fd..20df93eb 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h
@@ -31,7 +31,7 @@
#include <gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h>
#include <gudhi/Skeleton_blocker/Skeleton_blocker_simple_geometric_traits.h>
-#include <gudhi/Utils.h> // xxx
+#include <gudhi/Debug_utils.h>
namespace Gudhi {
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h
index b33b9606..1b1fe3f0 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h
@@ -25,7 +25,7 @@
#include <gudhi/Skeleton_blocker_complex.h>
#include <gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h>
-#include <gudhi/Utils.h>
+#include <gudhi/Debug_utils.h>
#include <map>
#include <vector>
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h
index 4d71b3f5..27411fc1 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h
@@ -25,7 +25,7 @@
#include <gudhi/Skeleton_blocker_link_complex.h>
#include <gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h>
#include <gudhi/Skeleton_blocker/internal/Trie.h>
-#include <gudhi/Utils.h>
+#include <gudhi/Debug_utils.h>
#include <boost/iterator/iterator_facade.hpp>
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h
index d26d12b0..dc2d9e29 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h
@@ -33,7 +33,7 @@
#include <gudhi/Skeleton_blocker/internal/Top_faces.h>
#include <gudhi/Skeleton_blocker/internal/Trie.h>
-#include <gudhi/Utils.h>
+#include <gudhi/Debug_utils.h>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/connected_components.hpp>
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h
index b8395251..3725b7a2 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h
@@ -22,9 +22,9 @@
#ifndef SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_
#define SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_
-#include <gudhi/Utils.h>
#include <gudhi/Skeleton_blocker_complex.h>
#include <gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h>
+#include <gudhi/Debug_utils.h>
namespace Gudhi {
diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h
index 95d8fa97..3d0039a1 100644
--- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h
+++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h
@@ -22,8 +22,8 @@
#ifndef SKELETON_BLOCKER_LINK_COMPLEX_H_
#define SKELETON_BLOCKER_LINK_COMPLEX_H_
-#include <gudhi/Utils.h>
#include <gudhi/Skeleton_blocker_complex.h>
+#include <gudhi/Debug_utils.h>
namespace Gudhi {
diff --git a/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp b/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp
index 319e3c43..d56a5c91 100644
--- a/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp
+++ b/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp
@@ -24,7 +24,7 @@
#include <string>
#include <fstream>
#include <sstream>
-#include "gudhi/Utils.h"
+#include "gudhi/Debug_utils.h"
#include "gudhi/Test.h"
#include "gudhi/Skeleton_blocker.h"
//#include "gudhi/Skeleton_blocker_link_complex.h"
diff --git a/src/common/example/Delaunay_triangulation_off_rw.cpp b/src/common/example/Delaunay_triangulation_off_rw.cpp
index 75e4fafb..12accd10 100644
--- a/src/common/example/Delaunay_triangulation_off_rw.cpp
+++ b/src/common/example/Delaunay_triangulation_off_rw.cpp
@@ -24,6 +24,11 @@ int main(int argc, char **argv) {
usage(argv[0]);
}
+
+#ifdef GUDHI_NDEBUG
+ std::cout << "pouet pouet !!" << std::endl;
+#endif
+
std::string offInputFile(argv[1]);
// Read the OFF file (input file name given as parameter) and triangulates points
Gudhi::Delaunay_triangulation_off_reader<T> off_reader(offInputFile);
diff --git a/src/common/include/gudhi/Utils.h b/src/common/include/gudhi/Debug_utils.h
index 43916f11..c479d435 100644
--- a/src/common/include/gudhi/Utils.h
+++ b/src/common/include/gudhi/Debug_utils.h
@@ -19,28 +19,35 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef UTILS_H_
-#define UTILS_H_
+#ifndef DEBUG_UTILS_H_
+#define DEBUG_UTILS_H_
+#include <iostream>
+
+#ifdef NDEBUG
+ // GUDHI_NDEBUG is the Gudhi official flag for debug mode.
+ #define GUDHI_NDEBUG
+#endif
#define PRINT(a) std::cerr << #a << ": " << (a) << " (DISP)" << std::endl
-// #define DBG_VERBOSE
-#ifdef DBG_VERBOSE
-#define DBG(a) std::cerr << "DBG: " << (a) << std::endl
-#define DBGMSG(a, b) std::cerr << "DBG: " << a << b << std::endl
-#define DBGVALUE(a) std::cerr << "DBG: " << #a << ": " << a << std::endl
-#define DBGCONT(a) std::cerr << "DBG: container " << #a << " -> "; for (auto x : a) std::cerr << x << ","; std::cerr <<
-std::endl
+#ifdef GUDHI_NDEBUG
+ #define DBG(a) std::cout << "DBG: " << (a) << std::endl
+ #define DBGMSG(a, b) std::cout << "DBG: " << a << b << std::endl
+ #define DBGVALUE(a) std::cout << "DBG: " << #a << ": " << a << std::endl
+ #define DBGCONT(a) std::cout << "DBG: container " << #a << " -> "; for (auto x : a) std::cout << x << ","; std::cout << std::endl
+#else
+ #define DBG(a) (void) 0
+ #define DBGMSG(a, b) (void) 0
+ #define DBGVALUE(a) (void) 0
+ #define DBGCONT(a) (void) 0
+#endif
+
+// GUDHI_CHECK throw an exception on condition in debug mode, but does nothing in release mode
+#ifdef GUDHI_NDEBUG
+ #define GUDHI_CHECK(cond, excpt) if (cond) throw excpt
#else
-// #define DBG(a) a
-// #define DBGMSG(a,b) b
-// #define DBGVALUE(a) a
-// #define DBGCONT(a) a
-#define DBG(a)
-#define DBGMSG(a, b)
-#define DBGVALUE(a)
-#define DBGCONT(a)
+ #define GUDHI_CHECK(cond, excpt) (void) 0
#endif
-#endif // UTILS_H_
+#endif // DEBUG_UTILS_H_
diff --git a/src/common/include/gudhi/Delaunay_triangulation_off_io.h b/src/common/include/gudhi/Delaunay_triangulation_off_io.h
index 4d26bb71..dfa70e40 100644
--- a/src/common/include/gudhi/Delaunay_triangulation_off_io.h
+++ b/src/common/include/gudhi/Delaunay_triangulation_off_io.h
@@ -22,6 +22,8 @@
#ifndef DELAUNAY_TRIANGULATION_OFF_IO_H_
#define DELAUNAY_TRIANGULATION_OFF_IO_H_
+#include <gudhi/Debug_utils.h>
+
#include <string>
#include <vector>
#include <fstream>
@@ -64,10 +66,10 @@ class Delaunay_triangulation_off_visitor_reader {
* @param[in] num_edges number of edges in the OFF file (not used).
*/
void init(int dim, int num_vertices, int num_faces, int num_edges) {
-#ifdef DEBUG_TRACES
- std::cout << "Delaunay_triangulation_off_visitor_reader::init - dim=" << dim << " - num_vertices=" <<
- num_vertices << " - num_faces=" << num_faces << " - num_edges=" << num_edges << std::endl;
-#endif // DEBUG_TRACES
+ DBGMSG("Delaunay_triangulation_off_visitor_reader::init - dim=", dim);
+ DBGMSG(" - num_vertices=", num_vertices);
+ DBGMSG(" - num_faces=", num_faces);
+ DBGMSG(" - num_edges=", num_edges);
if (num_faces > 0) {
std::cerr << "Delaunay_triangulation_off_visitor_reader::init faces are not taken into account from OFF " <<
"file for Delaunay triangulation - faces are computed." << std::endl;
@@ -88,13 +90,8 @@ class Delaunay_triangulation_off_visitor_reader {
* @param[in] point vector of vertex coordinates.
*/
void point(const std::vector<double>& point) {
-#ifdef DEBUG_TRACES
- std::cout << "Delaunay_triangulation_off_visitor_reader::point ";
- for (auto coordinate : point) {
- std::cout << coordinate << " | ";
- }
- std::cout << std::endl;
-#endif // DEBUG_TRACES
+ DBG("Delaunay_triangulation_off_visitor_reader::point");
+ DBGCONT(point);
complex_->insert(Point(point.size(), point.begin(), point.end()));
}