summaryrefslogtreecommitdiff
path: root/geom_bottleneck/bottleneck/src/ann
diff options
context:
space:
mode:
Diffstat (limited to 'geom_bottleneck/bottleneck/src/ann')
-rw-r--r--geom_bottleneck/bottleneck/src/ann/ANN.cpp11
-rw-r--r--geom_bottleneck/bottleneck/src/ann/bd_tree.cpp3
-rw-r--r--geom_bottleneck/bottleneck/src/ann/kd_dump.cpp11
-rw-r--r--geom_bottleneck/bottleneck/src/ann/kd_tree.cpp8
4 files changed, 31 insertions, 2 deletions
diff --git a/geom_bottleneck/bottleneck/src/ann/ANN.cpp b/geom_bottleneck/bottleneck/src/ann/ANN.cpp
index 7bae577..83c7ef6 100644
--- a/geom_bottleneck/bottleneck/src/ann/ANN.cpp
+++ b/geom_bottleneck/bottleneck/src/ann/ANN.cpp
@@ -30,9 +30,11 @@
#include <ciso646> // make VS more conformal
#endif
+#include <stdexcept>
#include <cstdlib> // C standard lib defs
#include <ANN/ANNx.h> // all ANN includes
#include <ANN/ANNperf.h> // ANN performance
+#include "def_debug_bt.h"
@@ -80,10 +82,12 @@ void annPrintPt( // print a point
int dim, // the dimension
std::ostream &out) // output stream
{
+#ifndef FOR_R_TDA
for (int j = 0; j < dim; j++) {
out << pt[j];
if (j < dim-1) out << " ";
}
+#endif
}
//----------------------------------------------------------------------
@@ -197,11 +201,16 @@ bool ANNorthRect::intersects(const int dim, const ANNorthRect& r) const
void annError(const char* msg, ANNerr level)
{
if (level == ANNabort) {
+#ifndef FOR_R_TDA
cerr << "ANN: ERROR------->" << msg << "<-------------ERROR\n";
- exit(1);
+#endif
+ throw std::runtime_error(std::string("ANN: Error: ") + std::string(msg));
+ //exit(1);
}
else {
+#ifndef FOR_R_TDA
cerr << "ANN: WARNING----->" << msg << "<-------------WARNING\n";
+#endif
}
}
diff --git a/geom_bottleneck/bottleneck/src/ann/bd_tree.cpp b/geom_bottleneck/bottleneck/src/ann/bd_tree.cpp
index 8c1ef6d..a5dd69c 100644
--- a/geom_bottleneck/bottleneck/src/ann/bd_tree.cpp
+++ b/geom_bottleneck/bottleneck/src/ann/bd_tree.cpp
@@ -31,6 +31,7 @@
#include "kd_split.h" // kd-tree splitting rules
#include <ANN/ANNperf.h> // performance evaluation
+#include "def_debug_bt.h"
namespace geom_bt {
//----------------------------------------------------------------------
@@ -43,6 +44,7 @@ void ANNbd_shrink::print( // print shrinking node
int level, // depth of node in tree
ostream &out) // output stream
{
+#ifndef FOR_R_TDA
child[ANN_OUT]->print(level+1, out); // print out-child
out << " ";
@@ -61,6 +63,7 @@ void ANNbd_shrink::print( // print shrinking node
out << "\n";
child[ANN_IN]->print(level+1, out); // print in-child
+#endif
}
//----------------------------------------------------------------------
diff --git a/geom_bottleneck/bottleneck/src/ann/kd_dump.cpp b/geom_bottleneck/bottleneck/src/ann/kd_dump.cpp
index 64db9a7..ecaf7ea 100644
--- a/geom_bottleneck/bottleneck/src/ann/kd_dump.cpp
+++ b/geom_bottleneck/bottleneck/src/ann/kd_dump.cpp
@@ -33,6 +33,7 @@
#include "kd_tree.h" // kd-tree declarations
#include "bd_tree.h" // bd-tree declarations
+#include "def_debug_bt.h"
using namespace std; // make std:: available
@@ -101,6 +102,7 @@ namespace geom_bt {
// ... (repeated n_bnds times)
//----------------------------------------------------------------------
+#ifndef FOR_R_TDA
void ANNkd_tree::Dump( // dump entire tree
ANNbool with_pts, // print points as well?
ostream &out) // output stream
@@ -132,20 +134,24 @@ namespace geom_bt {
}
out.precision(0); // restore default precision
}
+#endif
void ANNkd_split::dump( // dump a splitting node
ostream &out) // output stream
{
+#ifndef FOR_R_TDA
out << "split " << cut_dim << " " << cut_val << " ";
out << cd_bnds[ANN_LO] << " " << cd_bnds[ANN_HI] << "\n";
child[ANN_LO]->dump(out); // print low child
child[ANN_HI]->dump(out); // print high child
+#endif
}
void ANNkd_leaf::dump( // dump a leaf node
ostream &out) // output stream
{
+#ifndef FOR_R_TDA
if (this == KD_TRIVIAL) { // canonical trivial leaf node
out << "leaf 0\n"; // leaf no points
}
@@ -156,17 +162,20 @@ namespace geom_bt {
}
out << "\n";
}
+#endif
}
void ANNbd_shrink::dump( // dump a shrinking node
ostream &out) // output stream
{
+#ifndef FOR_R_TDA
out << "shrink " << n_bnds << "\n";
for (int j = 0; j < n_bnds; j++) {
out << bnds[j].cd << " " << bnds[j].cv << " " << bnds[j].sd << "\n";
}
child[ANN_IN]->dump(out); // print in-child
child[ANN_OUT]->dump(out); // print out-child
+#endif
}
//----------------------------------------------------------------------
@@ -441,7 +450,9 @@ namespace geom_bt {
}
else {
annError("Illegal node type in dump file", ANNabort);
+#ifndef FOR_R_TDA
exit(0); // to keep the compiler happy
+#endif
}
}
}
diff --git a/geom_bottleneck/bottleneck/src/ann/kd_tree.cpp b/geom_bottleneck/bottleneck/src/ann/kd_tree.cpp
index ad3a82d..e8f7f63 100644
--- a/geom_bottleneck/bottleneck/src/ann/kd_tree.cpp
+++ b/geom_bottleneck/bottleneck/src/ann/kd_tree.cpp
@@ -38,6 +38,7 @@
#include "kd_split.h" // kd-tree splitting rules
#include "kd_util.h" // kd-tree utilities
#include <ANN/ANNperf.h> // performance evaluation
+#include "def_debug_bt.h"
namespace geom_bt {
//----------------------------------------------------------------------
@@ -75,6 +76,7 @@ void ANNkd_split::print( // print splitting node
int level, // depth of node in tree
ostream &out) // output stream
{
+#ifndef FOR_R_TDA
child[ANN_HI]->print(level+1, out); // print high child
out << " ";
for (int i = 0; i < level; i++) // print indentation
@@ -85,13 +87,14 @@ void ANNkd_split::print( // print splitting node
out << " np=" << actual_num_points;
out << "\n";
child[ANN_LO]->print(level+1, out); // print low child
+#endif
}
void ANNkd_leaf::print( // print leaf node
int level, // depth of node in tree
ostream &out) // output stream
{
-
+#ifndef FOR_R_TDA
out << " ";
for (int i = 0; i < level; i++) // print indentation
out << "..";
@@ -107,8 +110,10 @@ void ANNkd_leaf::print( // print leaf node
}
out << ">\n";
}
+#endif
}
+#ifndef FOR_R_TDA
void ANNkd_tree::Print( // print entire tree
ANNbool with_pts, // print points as well?
ostream &out) // output stream
@@ -128,6 +133,7 @@ void ANNkd_tree::Print( // print entire tree
root->print(0, out); // invoke printing at root
}
}
+#endif
//----------------------------------------------------------------------
// kd_tree statistics (for performance evaluation)