summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-02-02 15:24:51 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-02-02 15:24:51 +0000
commit74dcaacda1c887b008ea8c95b28962de1c02a2d0 (patch)
tree0eb1ab5c08fca08f0dccf65a0ad58bd6349adbcb /src
parentcbf1f4c98c9e6d7ba3b7c552e43c7c98ed349954 (diff)
alpha off reader test strategy modification
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alphashapes@995 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: aa4ba97eecefb03e01a53ae1e2b50248a0857043
Diffstat (limited to 'src')
-rw-r--r--src/Alpha_complex/doc/Intro_alpha_complex.h2
-rw-r--r--src/Alpha_complex/example/Alpha_complex_from_off.cpp33
-rw-r--r--src/Alpha_complex/example/Alpha_complex_from_points.cpp2
-rw-r--r--src/Alpha_complex/example/CMakeLists.txt19
-rw-r--r--src/Alpha_complex/example/alphaoffreader_for_doc_32.txt26
-rw-r--r--src/Alpha_complex/test/CMakeLists.txt14
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h15
7 files changed, 78 insertions, 33 deletions
diff --git a/src/Alpha_complex/doc/Intro_alpha_complex.h b/src/Alpha_complex/doc/Intro_alpha_complex.h
index 12d62ac0..8eea6ba7 100644
--- a/src/Alpha_complex/doc/Intro_alpha_complex.h
+++ b/src/Alpha_complex/doc/Intro_alpha_complex.h
@@ -67,7 +67,7 @@ namespace alphacomplex {
*
* When launching:
*
- * \code $> ./alphapoints 60.0
+ * \code $> ./alphapoints
* \endcode
*
* the program output is:
diff --git a/src/Alpha_complex/example/Alpha_complex_from_off.cpp b/src/Alpha_complex/example/Alpha_complex_from_off.cpp
index 780f904b..80445a22 100644
--- a/src/Alpha_complex/example/Alpha_complex_from_off.cpp
+++ b/src/Alpha_complex/example/Alpha_complex_from_off.cpp
@@ -5,14 +5,14 @@
#include <string>
void usage(char * const progName) {
- std::cerr << "Usage: " << progName << " filename.off alpha_square_max_value" << std::endl;
- std::cerr << " i.e.: " << progName << " ../../data/points/alphacomplexdoc.off 60.0" << std::endl;
+ std::cerr << "Usage: " << progName << " filename.off alpha_square_max_value [ouput_file.txt]\n";
+ std::cerr << " i.e.: " << progName << " ../../data/points/alphacomplexdoc.off 60.0\n";
exit(-1); // ----- >>
}
int main(int argc, char **argv) {
- if (argc != 3) {
- std::cerr << "Error: Number of arguments (" << argc << ") is not correct" << std::endl;
+ if ((argc != 3) && (argc != 4)) {
+ std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n";
usage(argv[0]);
}
@@ -25,21 +25,34 @@ int main(int argc, char **argv) {
typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > Kernel;
Gudhi::alphacomplex::Alpha_complex<Kernel> alpha_complex_from_file(off_file_name, alpha_square_max_value);
+ std::streambuf* streambufffer;
+ std::ofstream ouput_file_stream;
+
+ if (argc == 4) {
+ ouput_file_stream.open(std::string(argv[3]));
+ streambufffer = ouput_file_stream.rdbuf();
+ } else {
+ streambufffer = std::cout.rdbuf();
+ }
+
+ std::ostream output_stream(streambufffer);
+
// ----------------------------------------------------------------------------
// Display information about the alpha complex
// ----------------------------------------------------------------------------
- std::cout << "Alpha complex is of dimension " << alpha_complex_from_file.dimension() <<
+ output_stream << "Alpha complex is of dimension " << alpha_complex_from_file.dimension() <<
" - " << alpha_complex_from_file.num_simplices() << " simplices - " <<
alpha_complex_from_file.num_vertices() << " vertices." << std::endl;
- std::cout << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl;
+ output_stream << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl;
for (auto f_simplex : alpha_complex_from_file.filtration_simplex_range()) {
- std::cout << " ( ";
+ output_stream << " ( ";
for (auto vertex : alpha_complex_from_file.simplex_vertex_range(f_simplex)) {
- std::cout << vertex << " ";
+ output_stream << vertex << " ";
}
- std::cout << ") -> " << "[" << alpha_complex_from_file.filtration(f_simplex) << "] ";
- std::cout << std::endl;
+ output_stream << ") -> " << "[" << alpha_complex_from_file.filtration(f_simplex) << "] ";
+ output_stream << std::endl;
}
+ ouput_file_stream.close();
return 0;
}
diff --git a/src/Alpha_complex/example/Alpha_complex_from_points.cpp b/src/Alpha_complex/example/Alpha_complex_from_points.cpp
index dab161c9..815e40d7 100644
--- a/src/Alpha_complex/example/Alpha_complex_from_points.cpp
+++ b/src/Alpha_complex/example/Alpha_complex_from_points.cpp
@@ -10,7 +10,7 @@ typedef Kernel::Point_d Point;
typedef std::vector<Point> Vector_of_points;
int main(int argc, char **argv) {
- double alpha_square_max_value = 32.0;
+ double alpha_square_max_value = 60.0;
// ----------------------------------------------------------------------------
// Init of a list of points
diff --git a/src/Alpha_complex/example/CMakeLists.txt b/src/Alpha_complex/example/CMakeLists.txt
index 33ff6805..d93dd436 100644
--- a/src/Alpha_complex/example/CMakeLists.txt
+++ b/src/Alpha_complex/example/CMakeLists.txt
@@ -27,12 +27,25 @@ if(CGAL_FOUND)
if (EIGEN3_FOUND)
message(STATUS "Eigen3 version: ${EIGEN3_VERSION}.")
include( ${EIGEN3_USE_FILE} )
-
- add_executable ( alphaoffreader Alpha_complex_from_off.cpp )
- target_link_libraries(alphaoffreader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
add_executable ( alphapoints Alpha_complex_from_points.cpp )
target_link_libraries(alphapoints ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
+ add_test(alphapoints ${CMAKE_CURRENT_BINARY_DIR}/alphapoints)
+
+ # Do not forget to copy test files in current binary dir
+ file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
+ # Do not forget to copy test results files in current binary dir
+ file(COPY "alphaoffreader_for_doc_32.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
+ file(COPY "alphaoffreader_for_doc_60.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
+
+ add_executable ( alphaoffreader Alpha_complex_from_off.cpp )
+ target_link_libraries(alphaoffreader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
+ add_test(alphaoffreader_doc_60 ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader alphacomplexdoc.off 60.0 ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_60.txt)
+ add_test(alphaoffreader_doc_32 ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader alphacomplexdoc.off 32.0 ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_32.txt)
+ if (DIFF_PATH)
+ add_test(alphaoffreader_doc_60_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_60.txt ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_for_doc_60.txt)
+ add_test(alphaoffreader_doc_32_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_32.txt ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_for_doc_32.txt)
+ endif()
else()
message(WARNING "Eigen3 not found. Version 3.1.0 is required for Alpha shapes feature.")
endif()
diff --git a/src/Alpha_complex/example/alphaoffreader_for_doc_32.txt b/src/Alpha_complex/example/alphaoffreader_for_doc_32.txt
index 553431a9..13183e86 100644
--- a/src/Alpha_complex/example/alphaoffreader_for_doc_32.txt
+++ b/src/Alpha_complex/example/alphaoffreader_for_doc_32.txt
@@ -7,16 +7,16 @@ Iterator on alpha complex simplices in the filtration order, with [filtration va
( 4 ) -> [0]
( 5 ) -> [0]
( 6 ) -> [0]
- ( 5 4 ) -> [6.25]
- ( 4 1 ) -> [20]
- ( 4 2 ) -> [8.5]
- ( 6 2 ) -> [9.25]
- ( 6 5 ) -> [10]
- ( 6 4 ) -> [11.25]
- ( 6 5 4 ) -> [12.5]
- ( 6 4 2 ) -> [12.9959]
- ( 3 0 ) -> [13.25]
- ( 4 1 ) -> [20]
- ( 1 0 ) -> [22.7367]
- ( 3 1 0 ) -> [22.7367]
- ( 5 0 ) -> [30.25]
+ ( 3 2 ) -> [6.25]
+ ( 5 4 ) -> [7.25]
+ ( 2 0 ) -> [8.5]
+ ( 1 0 ) -> [9.25]
+ ( 3 1 ) -> [10]
+ ( 2 1 ) -> [11.25]
+ ( 3 2 1 ) -> [12.5]
+ ( 2 1 0 ) -> [12.9959]
+ ( 6 5 ) -> [13.25]
+ ( 4 2 ) -> [20]
+ ( 6 4 ) -> [22.7367]
+ ( 6 5 4 ) -> [22.7367]
+ ( 6 3 ) -> [30.25]
diff --git a/src/Alpha_complex/test/CMakeLists.txt b/src/Alpha_complex/test/CMakeLists.txt
index fa24e1b1..52ec0a78 100644
--- a/src/Alpha_complex/test/CMakeLists.txt
+++ b/src/Alpha_complex/test/CMakeLists.txt
@@ -8,6 +8,20 @@ if(CGAL_FOUND)
message(STATUS "CGAL version: ${CGAL_VERSION}.")
include( ${CGAL_USE_FILE} )
+ # In CMakeLists.txt, when include(${CGAL_USE_FILE}), CXX_FLAGS are overwritten.
+ # cf. http://doc.cgal.org/latest/Manual/installation.html#title40
+ # A workaround is to add "-std=c++11" again.
+ # A fix would be to use https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
+ # or even better https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD.html
+ # but it implies to use cmake version 3.1 at least.
+ if(NOT MSVC)
+ include(CheckCXXCompilerFlag)
+ CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
+ if(COMPILER_SUPPORTS_CXX11)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ endif()
+ endif()
+ # - End of workaround
find_package(Eigen3 3.1.0)
if (EIGEN3_FOUND)
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h
index dbef8517..3911f497 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h
@@ -307,7 +307,8 @@ class Simplex_tree {
* of the simplex.
*
* @param[in] sh Simplex for which the boundary is computed. */
- Boundary_simplex_range boundary_simplex_range(Simplex_handle sh) {
+ template<class DictionaryIterator>
+ Boundary_simplex_range boundary_simplex_range(DictionaryIterator sh) {
return Boundary_simplex_range(Boundary_simplex_iterator(this, sh),
Boundary_simplex_iterator(this));
}
@@ -528,7 +529,11 @@ class Simplex_tree {
/** \brief Returns true if the node in the simplex tree pointed by
* sh has children.*/
- bool has_children(Simplex_handle sh) const {
+ /*bool has_children(Simplex_handle sh) const {
+ return (sh->second.children()->parent() == sh->first);
+ }*/
+ template<class DictionaryIterator>
+ bool has_children(DictionaryIterator sh) const {
return (sh->second.children()->parent() == sh->first);
}
@@ -1128,7 +1133,7 @@ class Simplex_tree {
bool make_filtration_non_decreasing() {
bool modified = false;
// Loop must be from the end to the beginning, as higher dimension simplex are always on the left part of the tree
- for (auto sh = (root_.members().end() - 1); sh >= root_.members().begin(); --sh) {
+ for (auto sh = root_.members().rbegin(); sh != root_.members().rend(); ++sh) {
if (has_children(sh)) {
modified |= rec_make_filtration_non_decreasing(sh->second.children());
}
@@ -1144,10 +1149,11 @@ class Simplex_tree {
bool rec_make_filtration_non_decreasing(Siblings * sib) {
bool modified = false;
+ // Loop must be from the end to the beginning, as higher dimension simplex are always on the left part of the tree
for (auto sh = sib->members().begin(); sh != sib->members().end(); ++sh) {
// Find the maximum filtration value in the border
Boundary_simplex_range boundary = boundary_simplex_range(sh);
- Boundary_simplex_iterator max_border = std::max_element( std::begin(boundary), std::end(boundary),
+ Boundary_simplex_iterator max_border = std::max_element(std::begin(boundary), std::end(boundary),
[](Simplex_handle sh1, Simplex_handle sh2) {
return filtration(sh1) < filtration(sh2);
} );
@@ -1175,7 +1181,6 @@ class Simplex_tree {
* call `initialize_filtration()` to recompute it.
*/
void prune_above_filtration(Filtration_value filtration) {
-std::cout << "prune_above_filtration - filtration=" << filtration << std::endl;
// No action if filtration is not stored
if (Options::store_filtration) {
if (filtration < threshold_) {