diff options
Diffstat (limited to 'src/Contraction/example')
-rw-r--r-- | src/Contraction/example/Rips_contraction.cpp | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/src/Contraction/example/Rips_contraction.cpp b/src/Contraction/example/Rips_contraction.cpp index acfb516d..2620b04f 100644 --- a/src/Contraction/example/Rips_contraction.cpp +++ b/src/Contraction/example/Rips_contraction.cpp @@ -1,9 +1,24 @@ -/* - * Rips_contraction.cpp - * - * Created on: Nov 28, 2014 - * Author: dsalinas - */ + /* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): David Salinas + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 <list> #include <boost/timer/timer.hpp> #include <iostream> @@ -48,25 +63,28 @@ void build_rips(ComplexType& complex, double offset){ complex.add_edge(*p,*q); } +int main (int argc, char *argv[]) +{ + if (argc!=3){ + std::cerr << "Usage "<<argv[0]<<" GUDHIPATH/src/data/sphere3D.off 0.1 to load the file GUDHIPATH/src/data/sphere3D.off and contract the Rips complex built with paremeter 0.2.\n"; + return -1; + } - - -void test_contraction_rips(string name_file, double offset){ boost::timer::auto_cpu_timer t; Complex complex; // load the points - Skeleton_blocker_off_reader<Complex> off_reader(name_file,complex,true); + Skeleton_blocker_off_reader<Complex> off_reader(argv[1],complex,true); if(!off_reader.is_valid()){ - std::cerr << "Unable to read file:"<<name_file<<std::endl; - return; + std::cerr << "Unable to read file:"<<argv[1]<<std::endl; + return EXIT_FAILURE; } - std::cerr << "build the Rips complex"<<std::endl; + std::cout << "build the Rips complex"<<std::endl; - build_rips(complex,offset); + build_rips(complex,atof(argv[2])); - std::cerr << "Initial complex has "<< + std::cout << "Initial complex has "<< complex.num_vertices()<<" vertices, and "<< complex.num_edges()<<" edges."<<std::endl; @@ -77,24 +95,12 @@ void test_contraction_rips(string name_file, double offset){ contraction::make_remove_popable_blockers_visitor<Profile>()); contractor.contract_edges(); - std::cerr << "Resulting complex has "<< + std::cout << "Resulting complex has "<< complex.num_vertices()<<" vertices, "<< complex.num_edges()<<"edges and "<< complex.num_blockers()<<" blockers"<<std::endl; - -} - - -int main (int argc, char *argv[]) -{ - if (argc!=3){ - std::cerr << "Usage "<<argv[0]<<" GUDHIPATH/src/data/sphere3D.off 0.1 to load the file GUDHIPATH/src/data/sphere3D.off and contract the Rips complex built with paremeter 0.2.\n"; - return -1; - } - - std::string name_file(argv[1]); - test_contraction_rips(name_file,atof(argv[2])); + return EXIT_SUCCESS; } |