summaryrefslogtreecommitdiff
path: root/src/Bottleneck_distance/include
diff options
context:
space:
mode:
authorfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-12-05 15:42:42 +0000
committerfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-12-05 15:42:42 +0000
commit3e2c4df7d6ac217f09d3aff6d238e71de8229e5b (patch)
tree14fb2bd9bcfcd32bf5d115e2a1b1c9b697bdffe3 /src/Bottleneck_distance/include
parent6d1bfe69ea473088eb2ca3ede626a2accaa58205 (diff)
review prise en compte
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bottleneck_integration@1821 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4c24c2bebc49c70d0502ffdb1f23e451d17a3b88
Diffstat (limited to 'src/Bottleneck_distance/include')
-rw-r--r--src/Bottleneck_distance/include/gudhi/Internal_point.h16
-rw-r--r--src/Bottleneck_distance/include/gudhi/Neighbors_finder.h12
-rw-r--r--src/Bottleneck_distance/include/gudhi/Persistence_graph.h20
3 files changed, 25 insertions, 23 deletions
diff --git a/src/Bottleneck_distance/include/gudhi/Internal_point.h b/src/Bottleneck_distance/include/gudhi/Internal_point.h
index 1a050d48..27a59d3f 100644
--- a/src/Bottleneck_distance/include/gudhi/Internal_point.h
+++ b/src/Bottleneck_distance/include/gudhi/Internal_point.h
@@ -51,14 +51,6 @@ inline int null_point_index() {
return -1;
}
-} // namespace bottleneck_distance
-
-} // namespace Gudhi
-
-namespace CGAL {
-
-typedef Gudhi::bottleneck_distance::Internal_point Internal_point;
-
struct Construct_coord_iterator {
typedef const double* result_type;
const double* operator()(const Internal_point& p) const
@@ -67,6 +59,12 @@ struct Construct_coord_iterator {
{ return p.vec+2; }
};
-} //namespace CGAL
+} // namespace bottleneck_distance
+
+} // namespace Gudhi
+
+
+
+
#endif // INTERNAL_POINT_H_
diff --git a/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h b/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h
index 90ddabef..e6acafc6 100644
--- a/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h
+++ b/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h
@@ -26,7 +26,7 @@
// Inclusion order is important for CGAL patch
#include "CGAL/Kd_tree_node.h"
#include "CGAL/Kd_tree.h"
-#include "CGAL/Orthogonal_incremental_neighbor_search.h"
+#include "CGAL/Orthogonal_k_neighbor_search.h"
#include <CGAL/Weighted_Minkowski_distance.h>
#include <CGAL/Search_traits.h>
@@ -50,9 +50,9 @@ namespace bottleneck_distance {
class Neighbors_finder {
typedef CGAL::Dimension_tag<2> D;
- typedef CGAL::Search_traits<double, Internal_point, const double*, CGAL::Construct_coord_iterator, D> Traits;
+ typedef CGAL::Search_traits<double, Internal_point, const double*, Construct_coord_iterator, D> Traits;
typedef CGAL::Weighted_Minkowski_distance<Traits> Distance;
- typedef CGAL::Orthogonal_incremental_neighbor_search<Traits, Distance> K_neighbor_search;
+ typedef CGAL::Orthogonal_k_neighbor_search<Traits, Distance> K_neighbor_search;
typedef K_neighbor_search::Tree Kd_tree;
public:
@@ -93,7 +93,7 @@ public:
private:
const Persistence_graph& g;
const double r;
- std::vector<std::shared_ptr<Neighbors_finder>> neighbors_finder;
+ std::vector<std::unique_ptr<Neighbors_finder>> neighbors_finder;
};
inline Neighbors_finder::Neighbors_finder(const Persistence_graph& g, double r) :
@@ -123,7 +123,7 @@ inline int Neighbors_finder::pull_near(int u_point_index) {
//Is the query point near to a V point in the plane ?
Internal_point u_point = g.get_u_point(u_point_index);
std::array<double, 2> w = { {1., 1.} };
- K_neighbor_search search(kd_t, u_point, 0., true, Distance(0, 2, w.begin(), w.end()));
+ K_neighbor_search search(kd_t, u_point, 1, 0., true, Distance(0, 2, w.begin(), w.end()));
auto it = search.begin();
if(it==search.end() || g.distance(u_point_index, it->first.point_index) > r)
return null_point_index();
@@ -148,7 +148,7 @@ inline Layered_neighbors_finder::Layered_neighbors_finder(const Persistence_grap
inline void Layered_neighbors_finder::add(int v_point_index, int vlayer) {
for (int l = neighbors_finder.size(); l <= vlayer; l++)
- neighbors_finder.emplace_back(std::shared_ptr<Neighbors_finder>(new Neighbors_finder(g, r)));
+ neighbors_finder.emplace_back(std::unique_ptr<Neighbors_finder>(new Neighbors_finder(g, r)));
neighbors_finder.at(vlayer)->add(v_point_index);
}
diff --git a/src/Bottleneck_distance/include/gudhi/Persistence_graph.h b/src/Bottleneck_distance/include/gudhi/Persistence_graph.h
index ebd3adaf..d31a4826 100644
--- a/src/Bottleneck_distance/include/gudhi/Persistence_graph.h
+++ b/src/Bottleneck_distance/include/gudhi/Persistence_graph.h
@@ -76,16 +76,18 @@ Persistence_graph::Persistence_graph(const Persistence_diagram1 &diag1,
const Persistence_diagram2 &diag2, double e)
: u(), v(), alive_count(0)
{
- for (auto it = diag1.cbegin(); it != diag1.cend(); ++it)
- if(it->second == std::numeric_limits<double>::infinity())
+ for (auto it = std::begin(diag1); it != std::end(diag1); ++it){
+ if(std::get<1>(*it) == std::numeric_limits<double>::infinity())
alive_count++;
- else if (it->second - it->first > e)
+ if (std::get<1>(*it) - std::get<0>(*it) > e)
u.push_back(Internal_point(std::get<0>(*it), std::get<1>(*it), u.size()));
- for (auto it = diag2.cbegin(); it != diag2.cend(); ++it)
- if(it->second == std::numeric_limits<double>::infinity())
+ }
+ for (auto it = std::begin(diag2); it != std::end(diag2); ++it){
+ if(std::get<1>(*it) == std::numeric_limits<double>::infinity())
alive_count--;
- else if (it->second - it->first > e)
+ if (std::get<1>(*it) - std::get<0>(*it) > e)
v.push_back(Internal_point(std::get<0>(*it), std::get<1>(*it), v.size()));
+ }
if (u.size() < v.size())
swap(u, v);
}
@@ -113,6 +115,8 @@ inline double Persistence_graph::distance(int u_point_index, int v_point_index)
return 0.;
Internal_point p_u = get_u_point(u_point_index);
Internal_point p_v = get_v_point(v_point_index);
+ if(p_u.y() == p_v.y())
+ return std::fabs(p_u.x() - p_v.x());
return std::max(std::fabs(p_u.x() - p_v.x()), std::fabs(p_u.y() - p_v.y()));
}
@@ -155,9 +159,9 @@ inline Internal_point Persistence_graph::get_v_point(int v_point_index) const {
inline double Persistence_graph::diameter_bound() const {
double max = 0.;
for(auto it = u.cbegin(); it != u.cend(); it++)
- max = std::max(max,it->y());
+ max = std::max(max,it->y() == std::numeric_limits<double>::infinity() ? it->x() : it->y());
for(auto it = v.cbegin(); it != v.cend(); it++)
- max = std::max(max,it->y());
+ max = std::max(max,it->y() == std::numeric_limits<double>::infinity() ? it->x() : it->y());
return max;
}