summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-04-08 14:50:03 +0000
committerskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-04-08 14:50:03 +0000
commit244d9ce5a5cb9050255cf519def9bdb273646f81 (patch)
tree53ae2ba1618337366a6d40bd79da4c992ca038a7
parent30b0effaf86ff300c5519e0919b33f61fc4a14f8 (diff)
Added rock-age style off reader
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@553 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 74462161c45893cfbfcc1875569b93b365445e35
-rw-r--r--CMakeLists.txt12
-rw-r--r--src/Witness_complex/example/witness_complex_from_file.cpp43
-rw-r--r--src/Witness_complex/include/gudhi/Witness_complex.h4
3 files changed, 50 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fabba412..0684b18e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,7 +14,7 @@ if(MSVC)
# Turn off some VC++ warnings
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4668 /wd4311 /wd4800 /wd4820 /wd4503 /wd4244 /wd4345 /wd4996 /wd4396 /wd4018")
else()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -std=c++11 -Wall -Wpedantic -Wsign-compare")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -std=c++11 -Wall -Wsign-compare")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
endif()
@@ -24,12 +24,12 @@ set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost)
-find_package(GMP)
-if(GMP_FOUND)
- find_package(GMPXX)
-endif()
+#find_package(GMP)
+#if(GMP_FOUND)
+ #find_package(GMPXX)
+#endif()
-find_package(CGAL)
+#find_package(CGAL)
# Required programs for unitary tests purpose
FIND_PROGRAM( LCOV_PATH lcov )
diff --git a/src/Witness_complex/example/witness_complex_from_file.cpp b/src/Witness_complex/example/witness_complex_from_file.cpp
index cec1d1b8..b1d7575a 100644
--- a/src/Witness_complex/example/witness_complex_from_file.cpp
+++ b/src/Witness_complex/example/witness_complex_from_file.cpp
@@ -28,7 +28,7 @@
//#include "gudhi/graph_simplicial_complex.h"
#include "gudhi/Witness_complex.h"
-
+#include "gudhi/reader_utils.h"
using namespace Gudhi;
@@ -65,6 +65,44 @@ read_points_cust ( std::string file_name , std::vector< std::vector< double > >
in_file.close();
}
+/**
+ * \brief Rock age method of reading off file
+ *
+ */
+inline void
+off_reader_cust ( std::string file_name , std::vector< std::vector< double > > & points)
+{
+ std::ifstream in_file (file_name.c_str(),std::ios::in);
+ if(!in_file.is_open())
+ {
+ std::cerr << "Unable to open file " << file_name << std::endl;
+ return;
+ }
+ std::string line;
+ double x;
+ // Line OFF. No need in it
+ if (!getline(in_file, line))
+ {
+ std::cerr << "No line OFF\n";
+ return;
+ }
+ // Line with 3 numbers. No need
+ if (!getline(in_file, line))
+ {
+ std::cerr << "No line with 3 numbers\n";
+ return;
+ }
+ // Reading points
+ while( getline ( in_file , line ) )
+ {
+ std::vector< double > point;
+ std::istringstream iss( line );
+ while(iss >> x) { point.push_back(x); }
+ points.push_back(point);
+ }
+ in_file.close();
+}
+
int main (int argc, char * const argv[])
{
if (argc != 3)
@@ -83,7 +121,8 @@ int main (int argc, char * const argv[])
std::cout << "Let the carnage begin!\n";
start = clock();
Point_Vector point_vector;
- read_points_cust(file_name, point_vector);
+ off_reader_cust(file_name, point_vector);
+ std::cout << "Successfully read the points\n";
witnessComplex.setNbL(nbL);
witnessComplex.witness_complex_from_points(point_vector);
end = clock();
diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h
index 1b50ca95..f4b1d62c 100644
--- a/src/Witness_complex/include/gudhi/Witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Witness_complex.h
@@ -184,6 +184,7 @@ namespace Gudhi {
active_w.push_back(i);
}
}
+ std::cout << "k=1, active witnesses: " << active_w.size() << std::endl;
//std::cout << "Successfully added edges" << std::endl;
while (!active_w.empty() && k < nbL )
{
@@ -206,6 +207,7 @@ namespace Gudhi {
else
active_w.erase(it++); //First increase the iterator and then erase the previous element
}
+ std::cout << "k=" << k << ", active witnesses: " << active_w.size() << std::endl;
k++;
}
//print_sc(root()); std::cout << std::endl;
@@ -453,7 +455,7 @@ private:
template <typename KNearestNeighbours>
void landmark_choice_by_random_points(Point_Vector &W, int nbP, KNearestNeighbours &WL)
{
- //std::cout << "Enter landmark_choice_by_random_points "<< std::endl;
+ std::cout << "Enter landmark_choice_by_random_points "<< std::endl;
//std::cout << "W="; print_vvector(W);
std::unordered_set< int > chosen_landmarks; // landmark set