summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com>2022-07-04 09:53:35 +0200
committerGitHub <noreply@github.com>2022-07-04 09:53:35 +0200
commit9a16b4fa00dbdbbe5f3fde10c5b2e5512cab35b0 (patch)
treec8bd6b1e258f920090ae386124978246282d589e /src
parenta746d7ad0cd5df72afd874b8dbe5e97afc5581d8 (diff)
parentdd41000ec13553787c8575f7aa55ce9156ad6b8a (diff)
Merge pull request #652 from Hind-M/cech_opti_vector
[Cech] Reuse vector of points and reserve to avoid reallocations
Diffstat (limited to 'src')
-rw-r--r--src/Cech_complex/include/gudhi/Cech_complex_blocker.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Cech_complex/include/gudhi/Cech_complex_blocker.h b/src/Cech_complex/include/gudhi/Cech_complex_blocker.h
index 1bb205b3..e7f548ba 100644
--- a/src/Cech_complex/include/gudhi/Cech_complex_blocker.h
+++ b/src/Cech_complex/include/gudhi/Cech_complex_blocker.h
@@ -73,6 +73,8 @@ class Cech_blocker {
CGAL::NT_converter<FT, Filtration_value> cast_to_fv;
Filtration_value radius = 0;
bool is_min_enclos_ball = false;
+ Point_cloud points;
+ points.reserve(sc_ptr_->dimension(sh)+1);
// for each face of simplex sh, test outsider point is indeed inside enclosing ball, if yes, take it and exit loop, otherwise, new sphere is circumsphere of all vertices
for (auto face_opposite_vertex : sc_ptr_->boundary_opposite_vertex_simplex_range(sh)) {
@@ -82,19 +84,18 @@ class Cech_blocker {
sph = cc_ptr_->get_cache().at(k);
}
else {
- Point_cloud face_points;
for (auto vertex : sc_ptr_->simplex_vertex_range(face_opposite_vertex.first)) {
- face_points.push_back(cc_ptr_->get_point(vertex));
+ points.push_back(cc_ptr_->get_point(vertex));
#ifdef DEBUG_TRACES
std::clog << "#(" << vertex << ")#";
#endif // DEBUG_TRACES
}
- sph = get_sphere(face_points.cbegin(), face_points.cend());
+ sph = get_sphere(points.cbegin(), points.cend());
// Put edge sphere in cache
sc_ptr_->assign_key(face_opposite_vertex.first, cc_ptr_->get_cache().size());
cc_ptr_->get_cache().push_back(sph);
- // Clear face_points
- face_points.clear();
+ // Clear face points
+ points.clear();
}
// Check if the minimal enclosing ball of current face contains the extra point/opposite vertex
if (kernel_.squared_distance_d_object()(sph.first, cc_ptr_->get_point(face_opposite_vertex.second)) <= sph.second) {
@@ -113,7 +114,6 @@ class Cech_blocker {
}
// Spheres of each face don't contain the whole simplex
if(!is_min_enclos_ball) {
- Point_cloud points;
for (auto vertex : sc_ptr_->simplex_vertex_range(sh)) {
points.push_back(cc_ptr_->get_point(vertex));
}