diff options
author | glisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-03-26 11:32:25 +0000 |
---|---|---|
committer | glisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-03-26 11:32:25 +0000 |
commit | 1208d423e700764a3453767886e6a3b4c0a09125 (patch) | |
tree | 3e938a2e1e984e80e1137fd30968e385068ec8e4 /src/Contraction | |
parent | 6f9560fe6d6cca6c5a0de35fcf7938912e103930 (diff) | |
parent | 6ed42daddfede2288bc02ab2e98fc12b47cac74e (diff) |
merge from trunk
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/farthest_distance@2244 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 7d261d59dae839dd5de8f6a03c5a167d015f7d85
Diffstat (limited to 'src/Contraction')
-rw-r--r-- | src/Contraction/doc/COPYRIGHT | 18 | ||||
-rw-r--r-- | src/Contraction/example/Garland_heckbert.cpp | 31 | ||||
-rw-r--r-- | src/Contraction/example/Garland_heckbert/Error_quadric.h | 6 | ||||
-rw-r--r-- | src/Contraction/example/Rips_contraction.cpp | 24 |
4 files changed, 48 insertions, 31 deletions
diff --git a/src/Contraction/doc/COPYRIGHT b/src/Contraction/doc/COPYRIGHT new file mode 100644 index 00000000..1de850d7 --- /dev/null +++ b/src/Contraction/doc/COPYRIGHT @@ -0,0 +1,18 @@ +The files of this directory are 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) 2015 INRIA + +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/>. diff --git a/src/Contraction/example/Garland_heckbert.cpp b/src/Contraction/example/Garland_heckbert.cpp index 4689519f..8b5a6a6c 100644 --- a/src/Contraction/example/Garland_heckbert.cpp +++ b/src/Contraction/example/Garland_heckbert.cpp @@ -35,10 +35,6 @@ #include "Garland_heckbert/Error_quadric.h" -using namespace Gudhi; -using namespace skeleton_blocker; -using namespace contraction; - struct Geometry_trait { typedef Point_d Point; }; @@ -46,7 +42,8 @@ struct Geometry_trait { /** * The vertex stored in the complex contains a quadric. */ -struct Garland_heckbert_traits : public Skeleton_blocker_simple_geometric_traits<Geometry_trait> { +struct Garland_heckbert_traits + : public Gudhi::skeleton_blocker::Skeleton_blocker_simple_geometric_traits<Geometry_trait> { public: struct Garland_heckbert_vertex : public Simple_geometric_vertex { Error_quadric<Geometry_trait::Point> quadric; @@ -54,19 +51,21 @@ struct Garland_heckbert_traits : public Skeleton_blocker_simple_geometric_traits typedef Garland_heckbert_vertex Graph_vertex; }; -typedef Skeleton_blocker_geometric_complex< Garland_heckbert_traits > Complex; -typedef Edge_profile<Complex> EdgeProfile; -typedef Skeleton_blocker_contractor<Complex> Complex_contractor; +using Complex = Gudhi::skeleton_blocker::Skeleton_blocker_geometric_complex< Garland_heckbert_traits >; +using EdgeProfile = Gudhi::contraction::Edge_profile<Complex>; +using Complex_contractor = Gudhi::contraction::Skeleton_blocker_contractor<Complex>; /** * How the new vertex is placed after an edge collapse : here it is placed at * the point minimizing the cost of the quadric. */ class GH_placement : public Gudhi::contraction::Placement_policy<EdgeProfile> { + Complex& complex_; + public: typedef Gudhi::contraction::Placement_policy<EdgeProfile>::Placement_type Placement_type; - GH_placement(Complex& complex) { } + GH_placement(Complex& complex) : complex_(complex) { (void)complex_; } Placement_type operator()(const EdgeProfile& profile) const override { auto sum_quad(profile.v0().quadric); @@ -85,10 +84,12 @@ class GH_placement : public Gudhi::contraction::Placement_policy<EdgeProfile> { * which expresses a squared distances with triangles planes. */ class GH_cost : public Gudhi::contraction::Cost_policy<EdgeProfile> { + Complex& complex_; + public: typedef Gudhi::contraction::Cost_policy<EdgeProfile>::Cost_type Cost_type; - GH_cost(Complex& complex) { } + GH_cost(Complex& complex) : complex_(complex) { (void)complex_; } Cost_type operator()(EdgeProfile const& profile, boost::optional<Point> const& new_point) const override { Cost_type res; @@ -107,8 +108,10 @@ class GH_cost : public Gudhi::contraction::Cost_policy<EdgeProfile> { * and we update them when contracting an edge (the quadric become the sum of both quadrics). */ class GH_visitor : public Gudhi::contraction::Contraction_visitor<EdgeProfile> { + Complex& complex_; + public: - GH_visitor(Complex& complex) { } + GH_visitor(Complex& complex) : complex_(complex) { (void)complex_; } // Compute quadrics for every vertex v // The quadric of v consists in the sum of quadric @@ -147,7 +150,7 @@ int main(int argc, char *argv[]) { typedef Complex::Vertex_handle Vertex_handle; // load the points - Skeleton_blocker_off_reader<Complex> off_reader(argv[1], complex); + Gudhi::skeleton_blocker::Skeleton_blocker_off_reader<Complex> off_reader(argv[1], complex); if (!off_reader.is_valid()) { std::cerr << "Unable to read file:" << argv[1] << std::endl; return EXIT_FAILURE; @@ -168,7 +171,7 @@ int main(int argc, char *argv[]) { Complex_contractor contractor(complex, new GH_cost(complex), new GH_placement(complex), - contraction::make_link_valid_contraction<EdgeProfile>(), + Gudhi::contraction::make_link_valid_contraction<EdgeProfile>(), new GH_visitor(complex)); std::cout << "Contract " << num_contractions << " edges" << std::endl; @@ -180,7 +183,7 @@ int main(int argc, char *argv[]) { complex.num_triangles() << " triangles." << std::endl; // write simplified complex - Skeleton_blocker_off_writer<Complex> off_writer(argv[2], complex); + Gudhi::skeleton_blocker::Skeleton_blocker_off_writer<Complex> off_writer(argv[2], complex); return EXIT_SUCCESS; } diff --git a/src/Contraction/example/Garland_heckbert/Error_quadric.h b/src/Contraction/example/Garland_heckbert/Error_quadric.h index 076f1be0..e7dafaa0 100644 --- a/src/Contraction/example/Garland_heckbert/Error_quadric.h +++ b/src/Contraction/example/Garland_heckbert/Error_quadric.h @@ -21,8 +21,8 @@ * */ -#ifndef ERROR_QUADRIC_H_ -#define ERROR_QUADRIC_H_ +#ifndef GARLAND_HECKBERT_ERROR_QUADRIC_H_ +#define GARLAND_HECKBERT_ERROR_QUADRIC_H_ #include <boost/optional/optional.hpp> @@ -179,4 +179,4 @@ template <typename Point> class Error_quadric { } }; -#endif // ERROR_QUADRIC_H_ +#endif // GARLAND_HECKBERT_ERROR_QUADRIC_H_ diff --git a/src/Contraction/example/Rips_contraction.cpp b/src/Contraction/example/Rips_contraction.cpp index 7f19e239..8289b1d3 100644 --- a/src/Contraction/example/Rips_contraction.cpp +++ b/src/Contraction/example/Rips_contraction.cpp @@ -27,19 +27,15 @@ #include <boost/timer/timer.hpp> #include <iostream> -using namespace Gudhi; -using namespace skeleton_blocker; -using namespace contraction; - 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; -typedef Edge_profile<Complex> Profile; -typedef Skeleton_blocker_contractor<Complex> Complex_contractor; +using Complex_geometric_traits = Gudhi::skeleton_blocker::Skeleton_blocker_simple_geometric_traits<Geometry_trait>; +using Complex = Gudhi::skeleton_blocker::Skeleton_blocker_geometric_complex< Complex_geometric_traits >; +using Profile = Gudhi::contraction::Edge_profile<Complex>; +using Complex_contractor = Gudhi::contraction::Skeleton_blocker_contractor<Complex>; + template<typename ComplexType> void build_rips(ComplexType& complex, double offset) { @@ -62,7 +58,7 @@ int main(int argc, char *argv[]) { Complex complex; // load only the points - Skeleton_blocker_off_reader<Complex> off_reader(argv[1], complex, true); + Gudhi::skeleton_blocker::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; @@ -79,10 +75,10 @@ int main(int argc, char *argv[]) { 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>()); + new Gudhi::contraction::Edge_length_cost<Profile>, + Gudhi::contraction::make_first_vertex_placement<Profile>(), + Gudhi::contraction::make_link_valid_contraction<Profile>(), + Gudhi::contraction::make_remove_popable_blockers_visitor<Profile>()); contractor.contract_edges(); std::cout << "Counting final number of simplices \n"; |