summaryrefslogtreecommitdiff
path: root/src/common
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/common
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/common')
-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
3 files changed, 38 insertions, 29 deletions
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()));
}