From 628ef41b07d8dceb4c5696b1a569156ea7cb8361 Mon Sep 17 00:00:00 2001 From: Nuno Miguel Nobre Date: Thu, 6 Jul 2023 16:52:12 +0100 Subject: [PATCH] Fix data race in the preprocessing edge collapsing algorithm See the Container data races section [container.requirements.dataraces] of the C++ standard. You can find draft documents hosted at https://www.open-std.org/jtc1/sc22/wg21/docs/standards#14882. --- src/Mesh.cpp | 2 +- src/Mesh.hpp | 4 ++-- src/Simplification.cpp | 10 +++++----- src/Simplification.h | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 85b171a8..4036ecf7 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -101,7 +101,7 @@ namespace floatTetWild { } - void Mesh::one_ring_edge_set(const std::vector> &edges, const std::vector& v_is_removed, const std::vector& f_is_removed, + void Mesh::one_ring_edge_set(const std::vector> &edges, const std::vector& v_is_removed, const std::vector& f_is_removed, const std::vector>& conn_fs, const std::vector& input_vertices, std::vector &safe_set) { // std::vector indices(edges.size()); diff --git a/src/Mesh.hpp b/src/Mesh.hpp index 31b44931..744bb422 100644 --- a/src/Mesh.hpp +++ b/src/Mesh.hpp @@ -189,8 +189,8 @@ class Random void partition(const int n_parts, std::vector> &tets_id) const; - static void one_ring_edge_set(const std::vector> &edges, const std::vector &v_is_removed, - const std::vector &f_is_removed, const std::vector> &conn_fs, + static void one_ring_edge_set(const std::vector> &edges, const std::vector &v_is_removed, + const std::vector &f_is_removed, const std::vector> &conn_fs, const std::vector &input_vertices, std::vector &safe_set); inline int t_empty_size() const { diff --git a/src/Simplification.cpp b/src/Simplification.cpp index 18a8f2f8..7dab1d3e 100644 --- a/src/Simplification.cpp +++ b/src/Simplification.cpp @@ -31,8 +31,8 @@ void floatTetWild::simplify(std::vector& input_vertices, std::vector v_is_removed(input_vertices.size(), false); - std::vector f_is_removed(input_faces.size(), false); + std::vector v_is_removed(input_vertices.size(), false); + std::vector f_is_removed(input_faces.size(), false); std::vector> conn_fs(input_vertices.size()); for (int i = 0; i < input_faces.size(); i++) { for (int j = 0; j < 3; j++) @@ -214,7 +214,7 @@ bool floatTetWild::remove_duplicates(std::vector& input_vertices, std:: void floatTetWild::collapsing(std::vector& input_vertices, std::vector& input_faces, const AABBWrapper& tree, const Parameters& params, - std::vector& v_is_removed, std::vector& f_is_removed, std::vector>& conn_fs){ + std::vector& v_is_removed, std::vector& f_is_removed, std::vector>& conn_fs){ #ifdef FLOAT_TETWILD_USE_TBB std::vector> edges; @@ -503,7 +503,7 @@ void floatTetWild::collapsing(std::vector& input_vertices, std::vector< void floatTetWild::swapping(std::vector& input_vertices, std::vector& input_faces, const AABBWrapper& tree, const Parameters& params, - std::vector& v_is_removed, std::vector& f_is_removed, std::vector>& conn_fs) { + std::vector& v_is_removed, std::vector& f_is_removed, std::vector>& conn_fs) { std::vector> edges; edges.reserve(input_faces.size() * 6); for (int i = 0; i < input_faces.size(); i++) { @@ -919,7 +919,7 @@ bool floatTetWild::is_out_envelope(const std::array& vs, const AABBW // return false; } -void floatTetWild::check_surface(std::vector& input_vertices, std::vector& input_faces, const std::vector& f_is_removed, +void floatTetWild::check_surface(std::vector& input_vertices, std::vector& input_faces, const std::vector& f_is_removed, const AABBWrapper& tree, const Parameters& params) { cout<<"checking surface"<& input_vertices, std::vector& input_faces, std::vector& input_tags, const Parameters& params); void collapsing(std::vector& input_vertices, std::vector& input_faces, const AABBWrapper& sf_tree, const Parameters& params, - std::vector& is_v_removed, std::vector& is_f_removed, std::vector>& conn_fs); + std::vector& v_is_removed, std::vector& f_is_removed, std::vector>& conn_fs); void swapping(std::vector& input_vertices, std::vector& input_faces, const AABBWrapper& sf_tree, const Parameters& params, - std::vector& is_v_removed, std::vector& is_f_removed, std::vector>& conn_fs); + std::vector& v_is_removed, std::vector& f_is_removed, std::vector>& conn_fs); void flattening(std::vector& input_vertices, std::vector& input_faces, const AABBWrapper& sf_tree, const Parameters& params); bool is_out_envelope(const std::array& vs, const AABBWrapper& tree, const Parameters& params); Scalar get_angle_cos(const Vector3& p, const Vector3& p1, const Vector3& p2); - void check_surface(std::vector& input_vertices, std::vector& input_faces, const std::vector& is_f_removed, + void check_surface(std::vector& input_vertices, std::vector& input_faces, const std::vector& f_is_removed, const AABBWrapper& tree, const Parameters& params); void output_component(const std::vector& input_vertices, const std::vector& input_faces, const std::vector& input_tags);