Skip to content

Commit

Permalink
Fix data race in the preprocessing edge collapsing algorithm
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nmnobre committed Jul 7, 2023
1 parent bcb029d commit be9873a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace floatTetWild {
}


void Mesh::one_ring_edge_set(const std::vector<std::array<int, 2>> &edges, const std::vector<bool>& v_is_removed, const std::vector<bool>& f_is_removed,
void Mesh::one_ring_edge_set(const std::vector<std::array<int, 2>> &edges, const std::vector<char>& v_is_removed, const std::vector<char>& f_is_removed,
const std::vector<std::unordered_set<int>>& conn_fs, const std::vector<Vector3>& input_vertices, std::vector<int> &safe_set)
{
// std::vector<int> indices(edges.size());
Expand Down
4 changes: 2 additions & 2 deletions src/Mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ class Random

void partition(const int n_parts, std::vector<std::vector<int>> &tets_id) const;

static void one_ring_edge_set(const std::vector<std::array<int, 2>> &edges, const std::vector<bool> &v_is_removed,
const std::vector<bool> &f_is_removed, const std::vector<std::unordered_set<int>> &conn_fs,
static void one_ring_edge_set(const std::vector<std::array<int, 2>> &edges, const std::vector<char> &v_is_removed,
const std::vector<char> &f_is_removed, const std::vector<std::unordered_set<int>> &conn_fs,
const std::vector<Vector3> &input_vertices, std::vector<int> &safe_set);

inline int t_empty_size() const {
Expand Down
8 changes: 4 additions & 4 deletions src/Simplification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ void floatTetWild::simplify(std::vector<Vector3>& input_vertices, std::vector<Ve
if (skip_simplify)
return;

std::vector<bool> v_is_removed(input_vertices.size(), false);
std::vector<bool> f_is_removed(input_faces.size(), false);
std::vector<char> v_is_removed(input_vertices.size(), false);
std::vector<char> f_is_removed(input_faces.size(), false);
std::vector<std::unordered_set<int>> conn_fs(input_vertices.size());
for (int i = 0; i < input_faces.size(); i++) {
for (int j = 0; j < 3; j++)
Expand Down Expand Up @@ -214,7 +214,7 @@ bool floatTetWild::remove_duplicates(std::vector<Vector3>& input_vertices, std::

void floatTetWild::collapsing(std::vector<Vector3>& input_vertices, std::vector<Vector3i>& input_faces,
const AABBWrapper& tree, const Parameters& params,
std::vector<bool>& v_is_removed, std::vector<bool>& f_is_removed, std::vector<std::unordered_set<int>>& conn_fs){
std::vector<char>& v_is_removed, std::vector<char>& f_is_removed, std::vector<std::unordered_set<int>>& conn_fs){

#ifdef FLOAT_TETWILD_USE_TBB
std::vector<std::array<int, 2>> edges;
Expand Down Expand Up @@ -503,7 +503,7 @@ void floatTetWild::collapsing(std::vector<Vector3>& input_vertices, std::vector<

void floatTetWild::swapping(std::vector<Vector3>& input_vertices, std::vector<Vector3i>& input_faces,
const AABBWrapper& tree, const Parameters& params,
std::vector<bool>& v_is_removed, std::vector<bool>& f_is_removed, std::vector<std::unordered_set<int>>& conn_fs) {
std::vector<char>& v_is_removed, std::vector<char>& f_is_removed, std::vector<std::unordered_set<int>>& conn_fs) {
std::vector<std::array<int, 2>> edges;
edges.reserve(input_faces.size() * 6);
for (int i = 0; i < input_faces.size(); i++) {
Expand Down
6 changes: 3 additions & 3 deletions src/Simplification.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ namespace floatTetWild {
const AABBWrapper& tree, const Parameters& params, bool skip_simplify = false);
bool remove_duplicates(std::vector<Vector3>& input_vertices, std::vector<Vector3i>& input_faces, std::vector<int>& input_tags, const Parameters& params);
void collapsing(std::vector<Vector3>& input_vertices, std::vector<Vector3i>& input_faces, const AABBWrapper& sf_tree, const Parameters& params,
std::vector<bool>& is_v_removed, std::vector<bool>& is_f_removed, std::vector<std::unordered_set<int>>& conn_fs);
std::vector<char>& v_is_removed, std::vector<char>& f_is_removed, std::vector<std::unordered_set<int>>& conn_fs);
void swapping(std::vector<Vector3>& input_vertices, std::vector<Vector3i>& input_faces, const AABBWrapper& sf_tree, const Parameters& params,
std::vector<bool>& is_v_removed, std::vector<bool>& is_f_removed, std::vector<std::unordered_set<int>>& conn_fs);
std::vector<char>& v_is_removed, std::vector<char>& f_is_removed, std::vector<std::unordered_set<int>>& conn_fs);
void flattening(std::vector<Vector3>& input_vertices, std::vector<Vector3i>& input_faces, const AABBWrapper& sf_tree, const Parameters& params);

bool is_out_envelope(const std::array<Vector3, 3>& 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<Vector3>& input_vertices, std::vector<Vector3i>& input_faces, const std::vector<bool>& is_f_removed,
void check_surface(std::vector<Vector3>& input_vertices, std::vector<Vector3i>& input_faces, const std::vector<bool>& f_is_removed,
const AABBWrapper& tree, const Parameters& params);

void output_component(const std::vector<Vector3>& input_vertices, const std::vector<Vector3i>& input_faces, const std::vector<int>& input_tags);
Expand Down

0 comments on commit be9873a

Please sign in to comment.