diff options
author | salinasd <salinasd@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-02-23 13:58:21 +0000 |
---|---|---|
committer | salinasd <salinasd@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-02-23 13:58:21 +0000 |
commit | 05bd4b83bd56e7b3dedcc513c07fd82be2198d3d (patch) | |
tree | c6ce13c92ceef4203b462d97e6a8c53c90168121 /src/Contraction/example/Rips_contraction.cpp | |
parent | 15059e2c538cc289d6e67d81d829b8f1ad30c46b (diff) |
skbl renaming, new link methods for abstract link of geometrical complex
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@468 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: cb85e1ae86635857fbaaa0781526cb3eeaa9a50a
Diffstat (limited to 'src/Contraction/example/Rips_contraction.cpp')
-rw-r--r-- | src/Contraction/example/Rips_contraction.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/Contraction/example/Rips_contraction.cpp b/src/Contraction/example/Rips_contraction.cpp index 8d9b1ca2..bd0a8b8c 100644 --- a/src/Contraction/example/Rips_contraction.cpp +++ b/src/Contraction/example/Rips_contraction.cpp @@ -24,42 +24,34 @@ #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 std::vector<double> Point; + 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; typedef Edge_profile<Complex> Profile; typedef Skeleton_blocker_contractor<Complex> Complex_contractor; -template<typename Point> -double eucl_distance(const Point& a,const Point& b){ - double res = 0; - auto a_coord = a.begin(); - auto b_coord = b.begin(); - for(; a_coord != a.end(); a_coord++, b_coord++){ - res += (*a_coord - *b_coord) * (*a_coord - *b_coord); - } - return sqrt(res); -} - 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 (eucl_distance(complex.point(*p), complex.point(*q)) < 2 * offset) + 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[]) @@ -71,13 +63,14 @@ int main (int argc, char *argv[]) Complex complex; - // load the points + // 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"<<std::endl; + + std::cout << "Build the Rips complex with "<<complex.num_vertices()<<" vertices"<<std::endl; build_rips(complex,atof(argv[2])); |