diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-10-08 15:24:27 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-10-08 15:24:27 +0000 |
commit | 58e633f51ffa06aa219231cd1c08eab59457a12f (patch) | |
tree | 83fd798e34b61df36c991de7eccf860ed9194564 /src/Contraction/example/Rips_contraction.cpp | |
parent | 6dd03d72142c98c4348e1b95d538de3b184bbc59 (diff) |
Fix cpplint on examples.
Bug fix on persistence_from_simple_simplex_tree.
Add persistence examples tests.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@843 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 9b7b73abb4a5d6bb110376deb689247bfdae035c
Diffstat (limited to 'src/Contraction/example/Rips_contraction.cpp')
-rw-r--r-- | src/Contraction/example/Rips_contraction.cpp | 99 |
1 files changed, 49 insertions, 50 deletions
diff --git a/src/Contraction/example/Rips_contraction.cpp b/src/Contraction/example/Rips_contraction.cpp index bd0a8b8c..d21246ed 100644 --- a/src/Contraction/example/Rips_contraction.cpp +++ b/src/Contraction/example/Rips_contraction.cpp @@ -19,24 +19,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <gudhi/Edge_contraction.h> +#include <gudhi/Skeleton_blocker.h> +#include <gudhi/Off_reader.h> +#include <gudhi/Point.h> + #include <boost/timer/timer.hpp> #include <iostream> -#include "gudhi/Edge_contraction.h" -#include "gudhi/Skeleton_blocker.h" -#include "gudhi/Off_reader.h" -#include "gudhi/Point.h" using namespace std; using namespace Gudhi; using namespace skbl; using namespace contraction; - -struct Geometry_trait{ - typedef Point_d Point; +struct Geometry_trait { + typedef Point_d Point; }; - typedef Geometry_trait::Point Point; typedef Skeleton_blocker_simple_geometric_traits<Geometry_trait> Complex_geometric_traits; typedef Skeleton_blocker_geometric_complex< Complex_geometric_traits > Complex; @@ -44,62 +43,62 @@ typedef Edge_profile<Complex> Profile; typedef Skeleton_blocker_contractor<Complex> Complex_contractor; template<typename ComplexType> -void build_rips(ComplexType& complex, double offset){ - if (offset<=0) return; - auto vertices = complex.vertex_range(); - for (auto p = vertices.begin(); p != vertices.end(); ++p) - for (auto q = p; ++q != vertices.end(); /**/){ - if ( squared_dist(complex.point(*p), complex.point(*q)) < 4 * offset * offset) - complex.add_edge(*p,*q); - } +void build_rips(ComplexType& complex, double offset) { + if (offset <= 0) return; + auto vertices = complex.vertex_range(); + for (auto p = vertices.begin(); p != vertices.end(); ++p) + for (auto q = p; ++q != vertices.end(); /**/) { + if (squared_dist(complex.point(*p), complex.point(*q)) < 4 * offset * offset) + complex.add_edge(*p, *q); + } } -int main (int argc, char *argv[]) -{ - if (argc!=3){ - std::cerr << "Usage "<<argv[0]<<" ../../../data/meshes/SO3_10000.off 0.3 to load the file ../../data/SO3_10000.off and contract the Rips complex built with paremeter 0.3.\n"; - return -1; - } +int main(int argc, char *argv[]) { + if (argc != 3) { + std::cerr << "Usage " << argv[0] << " ../../../data/meshes/SO3_10000.off 0.3 to load the file " << + "../../data/SO3_10000.off and contract the Rips complex built with paremeter 0.3.\n"; + return -1; + } - Complex complex; + Complex complex; - // load only the points - Skeleton_blocker_off_reader<Complex> off_reader(argv[1],complex,true); - if(!off_reader.is_valid()){ - std::cerr << "Unable to read file:"<<argv[1]<<std::endl; - return EXIT_FAILURE; - } + // load only the points + Skeleton_blocker_off_reader<Complex> off_reader(argv[1], complex, true); + if (!off_reader.is_valid()) { + std::cerr << "Unable to read file:" << argv[1] << std::endl; + return EXIT_FAILURE; + } - std::cout << "Build the Rips complex with "<<complex.num_vertices()<<" vertices"<<std::endl; + std::cout << "Build the Rips complex with " << complex.num_vertices() << " vertices" << std::endl; - build_rips(complex,atof(argv[2])); + build_rips(complex, atof(argv[2])); - boost::timer::auto_cpu_timer t; + boost::timer::auto_cpu_timer t; - std::cout << "Initial complex has "<< - complex.num_vertices()<<" vertices and "<< - complex.num_edges()<<" edges"<<std::endl; + std::cout << "Initial complex has " << + complex.num_vertices() << " vertices and " << + complex.num_edges() << " edges" << std::endl; - Complex_contractor contractor(complex, - new Edge_length_cost<Profile>, - contraction::make_first_vertex_placement<Profile>(), - contraction::make_link_valid_contraction<Profile>(), - contraction::make_remove_popable_blockers_visitor<Profile>()); - contractor.contract_edges(); + Complex_contractor contractor(complex, + new Edge_length_cost<Profile>, + contraction::make_first_vertex_placement<Profile>(), + contraction::make_link_valid_contraction<Profile>(), + contraction::make_remove_popable_blockers_visitor<Profile>()); + contractor.contract_edges(); - std::cout << "Counting final number of simplices \n"; - unsigned num_simplices = std::distance(complex.simplex_range().begin(),complex.simplex_range().end()); + std::cout << "Counting final number of simplices \n"; + unsigned num_simplices = std::distance(complex.simplex_range().begin(), complex.simplex_range().end()); - std::cout << "Final complex has "<< - complex.num_vertices()<<" vertices, "<< - complex.num_edges()<<" edges, "<< - complex.num_blockers()<<" blockers and "<< - num_simplices<<" simplices"<<std::endl; + std::cout << "Final complex has " << + complex.num_vertices() << " vertices, " << + complex.num_edges() << " edges, " << + complex.num_blockers() << " blockers and " << + num_simplices << " simplices" << std::endl; - std::cout << "Time to simplify and enumerate simplices:\n"; + std::cout << "Time to simplify and enumerate simplices:\n"; - return EXIT_SUCCESS; + return EXIT_SUCCESS; } |