Skip to content

Commit 1dd4bdb

Browse files
committed
fix(AABBTree): missing mutex in operators
1 parent 9662762 commit 1dd4bdb

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

src/geode/inspector/criterion/intersections/model_intersections.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ namespace
5050
bool operator()(
5151
geode::index_t first_component, geode::index_t second_component )
5252
{
53+
std::lock_guard< std::mutex > lock( mutex );
5354
component_pairs.emplace_back( first_component, second_component );
5455
return false;
5556
}
5657

58+
std::mutex mutex;
5759
std::vector< std::pair< geode::index_t, geode::index_t > >
5860
component_pairs;
5961
};

src/geode/inspector/criterion/intersections/surface_curve_intersections.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ namespace
6565

6666
void emplace( geode::index_t triangle_id, geode::index_t edge_id )
6767
{
68+
std::lock_guard< std::mutex > lock( mutex_ );
6869
intersecting_elements_.emplace_back( triangle_id, edge_id );
6970
}
7071

@@ -73,6 +74,7 @@ namespace
7374
const geode::EdgedCurve< dimension >& curve_;
7475
std::vector< std::pair< geode::index_t, geode::index_t > >
7576
intersecting_elements_;
77+
std::mutex mutex_;
7678
};
7779

7880
template < geode::index_t dimension >

src/geode/inspector/criterion/intersections/surface_intersections.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ namespace
7575
protected:
7676
void emplace( geode::index_t p1_id, geode::index_t p2_id )
7777
{
78+
std::lock_guard< std::mutex > lock( mutex_ );
7879
intersecting_polygons_.emplace_back( p1_id, p2_id );
7980
}
8081

@@ -88,6 +89,7 @@ namespace
8889
bool stop_at_first_intersection_;
8990
std::vector< std::pair< geode::index_t, geode::index_t > >
9091
intersecting_polygons_;
92+
std::mutex mutex_;
9193
};
9294
} // namespace
9395

tests/inspector/test-surface-intersections.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,18 @@ void check_intersections2D()
5656
"[Test] 2D Surface should have 3 intersecting elements pair." );
5757
bool right_intersections{ true };
5858
const auto &triangles_inter = inspection.issues();
59-
if( triangles_inter.size() != 3 || triangles_inter[0].first != 2
60-
|| triangles_inter[0].second != 0 || triangles_inter[1].first != 2
61-
|| triangles_inter[1].second != 1 || triangles_inter[2].first != 0
62-
|| triangles_inter[2].second != 1 )
59+
if( absl::c_find( triangles_inter, std::make_pair( 2u, 0u ) )
60+
== triangles_inter.end() )
61+
{
62+
right_intersections = false;
63+
}
64+
if( absl::c_find( triangles_inter, std::make_pair( 2u, 1u ) )
65+
== triangles_inter.end() )
66+
{
67+
right_intersections = false;
68+
}
69+
if( absl::c_find( triangles_inter, std::make_pair( 0u, 1u ) )
70+
== triangles_inter.end() )
6371
{
6472
right_intersections = false;
6573
}
@@ -100,9 +108,13 @@ void check_intersections3D()
100108
inspection.nb_issues(), "." );
101109
bool right_intersections{ true };
102110
const auto &triangles_inter = inspection.issues();
103-
if( triangles_inter.size() != 2 || triangles_inter[0].first != 0
104-
|| triangles_inter[0].second != 4 || triangles_inter[1].first != 2
105-
|| triangles_inter[1].second != 4 )
111+
if( absl::c_find( triangles_inter, std::make_pair( 0u, 4u ) )
112+
== triangles_inter.end() )
113+
{
114+
right_intersections = false;
115+
}
116+
if( absl::c_find( triangles_inter, std::make_pair( 2u, 4u ) )
117+
== triangles_inter.end() )
106118
{
107119
right_intersections = false;
108120
}

0 commit comments

Comments
 (0)