From 204f8ace0554cb8290a7f8cfca947d4a1251f985 Mon Sep 17 00:00:00 2001 From: "ulrich.bauer@gmail.com" Date: Tue, 30 Apr 2013 09:19:22 +0000 Subject: alpha shape creation update git-svn-id: https://phat.googlecode.com/svn/trunk@50 8e3bb3c2-eed4-f18f-5264-0b6c94e6926d --- CMakeLists.txt | 22 ++++++++++++++++++++++ addons/alpha_3.cpp | 21 +++++++++------------ include/phat/compute_persistence_pairs.h | 16 ++++++++++++++++ 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98ffc17..923a069 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ set(CMAKE_BUILD_TYPE "Release") INCLUDE(CheckCXXSourceCompiles) include_directories (include) +include_directories (/opt/local/include) FIND_PACKAGE(OpenMP) @@ -38,3 +39,24 @@ endif() add_executable (simple_example src/simple_example.cpp) add_executable (self_test src/self_test.cpp) add_executable (phat src/phat.cpp) +add_executable (reduction_test reduction_test.cpp) +add_executable (benchmark src/benchmark.cpp) + + +set(CMAKE_MODULE_PATH "modules") +set(CGAL_DIR "/opt/local/lib/cmake") + +FIND_PACKAGE(CGAL) + +if ( CGAL_FOUND ) + + include( ${CGAL_USE_FILE} ) +else() + + message(STATUS "This program requires the CGAL library, and will not be compiled.") + +endif() + +FIND_PACKAGE(Boost) + +add_executable (alpha_3 addons/alpha_3.cpp) diff --git a/addons/alpha_3.cpp b/addons/alpha_3.cpp index 548500a..7616e27 100644 --- a/addons/alpha_3.cpp +++ b/addons/alpha_3.cpp @@ -229,8 +229,7 @@ int main(int argc, char** argv) std::cerr << "Filtration of size " << circumradii.size() << std::endl; - Matrix M; - Dim_container dim_container; + phat::boundary_matrix< phat::vector_vector > boundary_matrix; Vertex_handle v; Edge e; @@ -257,13 +256,13 @@ int main(int argc, char** argv) if(CGAL::assign(v,obj)) { //std::cout << "Vertex " << it->second << std::endl; - dim_container.push_back(0); + boundary_matrix.set_dim(curr_index, 0); v->info().set_index(curr_index); - M.push_back(col); + boundary_matrix.set_col(curr_index, col); } if(CGAL::assign(e,obj)) { //std::cout << "Edge " << it->second << std::endl; - dim_container.push_back(1); + boundary_matrix.set_dim(curr_index, 1); Vertex_handle v1 = e.first->vertex(e.second); CGAL_assertion(v1->info().has_index()); Vertex_handle v2 = e.first->vertex(e.third); @@ -276,12 +275,12 @@ int main(int argc, char** argv) } col.push_back(i1); col.push_back(i2); - M.push_back(col); + boundary_matrix.set_col(curr_index, col); set_index_of_edge(dt,e,curr_index); } if(CGAL::assign(f,obj)) { //std::cout << "Facet " << it->second << std::endl; - dim_container.push_back(2); + boundary_matrix.set_dim(curr_index, 2); Index i1= f.first->info().edge_index( (f.second+1)%4, (f.second+2)%4 ); col.push_back(i1); @@ -290,25 +289,23 @@ int main(int argc, char** argv) Index i3= f.first->info().edge_index( (f.second+2)%4, (f.second+3)%4 ); col.push_back(i3); std::sort(col.begin(),col.end()); - M.push_back(col); + boundary_matrix.set_col(curr_index, col); set_index_of_facet(dt,f,curr_index); } if(CGAL::assign(c,obj)) { //std::cout << "Cell " << it->second << std::endl; - dim_container.push_back(3); + boundary_matrix.set_dim(curr_index, 3); col.push_back(c->info().facet_index(0)); col.push_back(c->info().facet_index(1)); col.push_back(c->info().facet_index(2)); col.push_back(c->info().facet_index(3)); std::sort(col.begin(),col.end()); - M.push_back(col); + boundary_matrix.set_col(curr_index, col); } curr_index++; } - phat::boundary_matrix< phat::vector_vector > boundary_matrix; - boundary_matrix.init(M, dim_container); boundary_matrix.save_binary("alpha_filtration.bin"); //phat::write(std::cout,M,dim_container); diff --git a/include/phat/compute_persistence_pairs.h b/include/phat/compute_persistence_pairs.h index e782bd7..ca46ac0 100644 --- a/include/phat/compute_persistence_pairs.h +++ b/include/phat/compute_persistence_pairs.h @@ -43,8 +43,24 @@ namespace phat { void compute_persistence_pairs_dualized( persistence_pairs& pairs, boundary_matrix< Representation >& boundary_matrix ) { ReductionAlgorithm reduce; const index nr_columns = boundary_matrix.get_num_cols(); + + double start; + + start= omp_get_wtime(); + std::clog << "Dualize ... " << std::endl; + dualize( boundary_matrix ); + + std::clog << omp_get_wtime() - start <<"s" << std::endl; + + start= omp_get_wtime(); + std::clog << "Reduce ... " << std::endl; + reduce( boundary_matrix ); + + std::clog << omp_get_wtime() - start <<"s" << std::endl; + + pairs.clear(); for( index idx = 0; idx < nr_columns; idx++ ) { if( !boundary_matrix.is_empty( idx ) ) { -- cgit v1.2.3