summaryrefslogtreecommitdiff
path: root/src/Subsampling/include/gudhi/sparsify_point_set.h
diff options
context:
space:
mode:
authorcjamin <cjamin@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-05-31 16:03:05 +0000
committercjamin <cjamin@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-05-31 16:03:05 +0000
commit29cf10daf5e6f2674ccb1491716754a4e5f98cc2 (patch)
tree20c198d9a34c20c212c1a754475e5ed9694f06d2 /src/Subsampling/include/gudhi/sparsify_point_set.h
parentd48e75a5095c48da3bfaf87df5135c209dab58eb (diff)
Fix identation
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1229 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 90afa5dc86416baa5716cdbd7157f96149165dc0
Diffstat (limited to 'src/Subsampling/include/gudhi/sparsify_point_set.h')
-rw-r--r--src/Subsampling/include/gudhi/sparsify_point_set.h97
1 files changed, 48 insertions, 49 deletions
diff --git a/src/Subsampling/include/gudhi/sparsify_point_set.h b/src/Subsampling/include/gudhi/sparsify_point_set.h
index 89770886..a6844919 100644
--- a/src/Subsampling/include/gudhi/sparsify_point_set.h
+++ b/src/Subsampling/include/gudhi/sparsify_point_set.h
@@ -33,66 +33,65 @@
namespace Gudhi {
- template <typename Kernel, typename Point_container, typename OutputIterator>
- bool
- sparsify_point_set(
- const Kernel &k, Point_container const& input_pts,
- typename Kernel::FT min_squared_dist,
- OutputIterator output_it)
- {
- typedef typename Gudhi::Spatial_tree_data_structure<
- Kernel, Point_container> Points_ds;
-
- typename Kernel::Squared_distance_d sqdist = k.squared_distance_d_object();
+template <typename Kernel, typename Point_container, typename OutputIterator>
+bool
+sparsify_point_set(
+ const Kernel &k, Point_container const& input_pts,
+ typename Kernel::FT min_squared_dist,
+ OutputIterator output_it)
+{
+ typedef typename Gudhi::Spatial_tree_data_structure<
+ Kernel, Point_container> Points_ds;
+
+ typename Kernel::Squared_distance_d sqdist = k.squared_distance_d_object();
#ifdef GUDHI_TC_PROFILING
- Gudhi::Clock t;
+ Gudhi::Clock t;
#endif
- Points_ds points_ds(input_pts);
+ Points_ds points_ds(input_pts);
+
+ std::vector<bool> dropped_points(input_pts.size(), false);
+
+ // Parse the input points, and add them if they are not too close to
+ // the other points
+ std::size_t pt_idx = 0;
+ for (typename Point_container::const_iterator it_pt = input_pts.begin() ;
+ it_pt != input_pts.end();
+ ++it_pt, ++pt_idx)
+ {
+ if (dropped_points[pt_idx])
+ continue;
- std::vector<bool> dropped_points(input_pts.size(), false);
+ *output_it++ = *it_pt;
- // Parse the input points, and add them if they are not too close to
- // the other points
- std::size_t pt_idx = 0;
- for (typename Point_container::const_iterator it_pt = input_pts.begin() ;
- it_pt != input_pts.end();
- ++it_pt, ++pt_idx)
+ auto ins_range = points_ds.query_incremental_ANN(*it_pt);
+
+ // If another point Q is closer that min_squared_dist, mark Q to be dropped
+ for (auto const& neighbor : ins_range)
+ {
+ std::size_t neighbor_point_idx = neighbor.first;
+ // If the neighbor is too close, we drop the neighbor
+ if (neighbor.second < min_squared_dist)
+ //if (neighbor.second < 0.2*((*it_pt)[0] + 1.)*0.5 + 0.00005)
+ //if (neighbor.second < ((*it_pt)[0] < 0 ? 0.2 : 0.00001))
{
- if (dropped_points[pt_idx])
- continue;
-
- *output_it++ = *it_pt;
-
- auto ins_range = points_ds.query_incremental_ANN(*it_pt);
-
- // If another point Q is closer that min_squared_dist, mark Q to be dropped
- for (auto const& neighbor : ins_range)
- {
- std::size_t neighbor_point_idx = neighbor.first;
- // If the neighbor is too close, we drop the neighbor
- if (neighbor.second < min_squared_dist)
- //if (neighbor.second < 0.2*((*it_pt)[0] + 1.)*0.5 + 0.00005)
- //if (neighbor.second < ((*it_pt)[0] < 0 ? 0.2 : 0.00001))
- {
- // N.B.: If neighbor_point_idx < pt_idx,
- // dropped_points[neighbor_point_idx] is already true but adding a
- // test doesn't make things faster, so why bother?
- dropped_points[neighbor_point_idx] = true;
- }
- else
- break;
- }
+ // N.B.: If neighbor_point_idx < pt_idx,
+ // dropped_points[neighbor_point_idx] is already true but adding a
+ // test doesn't make things faster, so why bother?
+ dropped_points[neighbor_point_idx] = true;
}
+ else
+ break;
+ }
+ }
#ifdef GUDHI_TC_PROFILING
- t.end();
- std::cerr << "Point set sparsified in " << t.num_seconds()
- << " seconds." << std::endl;
+ t.end();
+ std::cerr << "Point set sparsified in " << t.num_seconds()
+ << " seconds." << std::endl;
#endif
- }
-
+}
} //namespace Gudhi