Skip to content

Commit 48caa49

Browse files
authored
feat(OpenGeode): porting to v13 (#57)
1 parent 44ea91c commit 48caa49

File tree

5 files changed

+276
-97
lines changed

5 files changed

+276
-97
lines changed

bindings/python/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
OpenGeode-core >= 12.6.6, == 12.*
2-
OpenGeode-IO >= 5.23.1, == 5.*
3-
OpenGeode-Geosciences >= 5.7.6, == 5.*
4-
OpenGeode-GeosciencesIO >= 3.12.0, == 3.*
1+
OpenGeode-core >= 13.0.0, == 13.*
2+
OpenGeode-IO >= 5.24.0, == 5.*
3+
OpenGeode-Geosciences >= 6.0.0, == 6.*
4+
OpenGeode-GeosciencesIO >= 3.13.0, == 3.*

src/geode/inspector/criterion/colocation/unique_vertices_colocation.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,19 @@ namespace
5353
if( cmv.component_id.type()
5454
== geode::Line< dimension >::component_type_static() )
5555
{
56-
return point.inexact_equal(
57-
model.line( cmv.component_id.id() ).mesh().point( cmv.vertex ),
58-
geode::global_epsilon );
56+
return point.inexact_equal( model.line( cmv.component_id.id() )
57+
.mesh()
58+
.point( cmv.vertex ) );
5959
}
6060
else if( cmv.component_id.type()
6161
== geode::Surface< dimension >::component_type_static() )
6262
{
6363
return point.inexact_equal( model.surface( cmv.component_id.id() )
6464
.mesh()
65-
.point( cmv.vertex ),
66-
geode::global_epsilon );
65+
.point( cmv.vertex ) );
6766
}
6867
return point.inexact_equal(
69-
model.corner( cmv.component_id.id() ).mesh().point( cmv.vertex ),
70-
geode::global_epsilon );
68+
model.corner( cmv.component_id.id() ).mesh().point( cmv.vertex ) );
7169
}
7270

7371
bool model_cmv_is_colocated_on_point( const geode::Section& model,
@@ -83,9 +81,9 @@ namespace
8381
{
8482
if( cmv.component_id.type() == geode::Block3D::component_type_static() )
8583
{
86-
return point.inexact_equal(
87-
model.block( cmv.component_id.id() ).mesh().point( cmv.vertex ),
88-
geode::global_epsilon );
84+
return point.inexact_equal( model.block( cmv.component_id.id() )
85+
.mesh()
86+
.point( cmv.vertex ) );
8987
}
9088
return model_cmv_is_colocated_on_point_base( model, cmv, point );
9189
}

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

Lines changed: 115 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ namespace
4747
{
4848
struct ComponentOverlap
4949
{
50-
void operator()(
50+
bool operator()(
5151
geode::index_t first_component, geode::index_t second_component )
5252
{
5353
component_pairs.emplace_back( first_component, second_component );
54+
return false;
5455
}
5556

5657
std::vector< std::pair< geode::index_t, geode::index_t > >
@@ -75,10 +76,10 @@ namespace
7576
}
7677

7778
template < geode::index_t dimension, typename Model >
78-
class ModelSurfacesIntersection
79+
class ModelSurfacesIntersectionBase
7980
{
8081
public:
81-
ModelSurfacesIntersection( const Model& model,
82+
ModelSurfacesIntersectionBase( const Model& model,
8283
const geode::uuid& surface_id1,
8384
const geode::uuid& surface_id2 )
8485
: model_( model ),
@@ -94,31 +95,13 @@ namespace
9495
{
9596
}
9697

97-
void operator()( geode::index_t t1_id, geode::index_t t2_id )
98-
{
99-
if( same_surface_ && t1_id == t2_id )
100-
{
101-
return;
102-
}
103-
const auto t1_vertices = mesh1_.polygon_vertices( t1_id );
104-
const auto t2_vertices = mesh2_.polygon_vertices( t2_id );
105-
const auto common_vertices =
106-
triangles_common_vertices( t1_vertices, t2_vertices );
107-
if( common_vertices.size() == 3
108-
|| triangles_intersect(
109-
t1_id, t2_id, t1_vertices, t2_vertices, common_vertices ) )
110-
{
111-
intersecting_triangles_.emplace_back( t1_id, t2_id );
112-
}
113-
}
114-
11598
std::vector< std::pair< geode::index_t, geode::index_t > >
11699
intersecting_triangles()
117100
{
118101
return std::move( intersecting_triangles_ );
119102
}
120103

121-
private:
104+
protected:
122105
absl::InlinedVector< std::array< geode::index_t, 2 >, 3 >
123106
triangles_common_vertices(
124107
const geode::PolygonVertices& t1_vertices,
@@ -151,6 +134,21 @@ namespace
151134
absl::Span< const std::array< geode::index_t, 2 > >
152135
common_vertices ) const;
153136

137+
void emplace( geode::index_t t1_id, geode::index_t t2_id )
138+
{
139+
intersecting_triangles_.emplace_back( t1_id, t2_id );
140+
}
141+
142+
const geode::TriangulatedSurface< dimension >& mesh1() const
143+
{
144+
return mesh1_;
145+
}
146+
147+
const geode::TriangulatedSurface< dimension >& mesh2() const
148+
{
149+
return mesh2_;
150+
}
151+
154152
private:
155153
const Model& model_;
156154
DEBUG_CONST bool same_surface_;
@@ -162,6 +160,81 @@ namespace
162160
intersecting_triangles_;
163161
};
164162

163+
template < geode::index_t dimension, typename Model >
164+
class OneModelSurfacesIntersection
165+
: public ModelSurfacesIntersectionBase< dimension, Model >
166+
{
167+
public:
168+
OneModelSurfacesIntersection( const Model& model,
169+
const geode::uuid& surface_id1,
170+
const geode::uuid& surface_id2 )
171+
: ModelSurfacesIntersectionBase< dimension, Model >(
172+
model, surface_id1, surface_id2 ),
173+
same_surface_{ surface_id1 == surface_id2 }
174+
{
175+
}
176+
177+
bool operator()( geode::index_t t1_id, geode::index_t t2_id )
178+
{
179+
if( same_surface_ && t1_id == t2_id )
180+
{
181+
return false;
182+
}
183+
const auto t1_vertices = this->mesh1().polygon_vertices( t1_id );
184+
const auto t2_vertices = this->mesh2().polygon_vertices( t2_id );
185+
const auto common_vertices =
186+
this->triangles_common_vertices( t1_vertices, t2_vertices );
187+
if( common_vertices.size() == 3
188+
|| this->triangles_intersect(
189+
t1_id, t2_id, t1_vertices, t2_vertices, common_vertices ) )
190+
{
191+
this->emplace( t1_id, t2_id );
192+
return true;
193+
}
194+
return false;
195+
}
196+
197+
private:
198+
DEBUG_CONST bool same_surface_;
199+
};
200+
201+
template < geode::index_t dimension, typename Model >
202+
class AllModelSurfacesIntersection
203+
: public ModelSurfacesIntersectionBase< dimension, Model >
204+
{
205+
public:
206+
AllModelSurfacesIntersection( const Model& model,
207+
const geode::uuid& surface_id1,
208+
const geode::uuid& surface_id2 )
209+
: ModelSurfacesIntersectionBase< dimension, Model >(
210+
model, surface_id1, surface_id2 ),
211+
same_surface_{ surface_id1 == surface_id2 }
212+
{
213+
}
214+
215+
bool operator()( geode::index_t t1_id, geode::index_t t2_id )
216+
{
217+
if( same_surface_ && t1_id == t2_id )
218+
{
219+
return false;
220+
}
221+
const auto t1_vertices = this->mesh1().polygon_vertices( t1_id );
222+
const auto t2_vertices = this->mesh2().polygon_vertices( t2_id );
223+
const auto common_vertices =
224+
this->triangles_common_vertices( t1_vertices, t2_vertices );
225+
if( common_vertices.size() == 3
226+
|| this->triangles_intersect(
227+
t1_id, t2_id, t1_vertices, t2_vertices, common_vertices ) )
228+
{
229+
this->emplace( t1_id, t2_id );
230+
}
231+
return false;
232+
}
233+
234+
private:
235+
DEBUG_CONST bool same_surface_;
236+
};
237+
165238
geode::index_t third_point_index( const geode::PolygonVertices& vertices,
166239
absl::Span< const std::array< geode::index_t, 2 > > common_vertices,
167240
geode::local_index_t vertex_position )
@@ -181,13 +254,14 @@ namespace
181254
}
182255

183256
template <>
184-
bool ModelSurfacesIntersection< 2, geode::Section >::triangles_intersect(
185-
geode::index_t t1_id,
186-
geode::index_t t2_id,
187-
const geode::PolygonVertices& t1_vertices,
188-
const geode::PolygonVertices& t2_vertices,
189-
absl::Span< const std::array< geode::index_t, 2 > > common_vertices )
190-
const
257+
bool
258+
ModelSurfacesIntersectionBase< 2, geode::Section >::triangles_intersect(
259+
geode::index_t t1_id,
260+
geode::index_t t2_id,
261+
const geode::PolygonVertices& t1_vertices,
262+
const geode::PolygonVertices& t2_vertices,
263+
absl::Span< const std::array< geode::index_t, 2 > >
264+
common_vertices ) const
191265
{
192266
if( common_vertices.size() == 2 )
193267
{
@@ -307,7 +381,7 @@ namespace
307381
}
308382

309383
template <>
310-
bool ModelSurfacesIntersection< 3, geode::BRep >::triangles_intersect(
384+
bool ModelSurfacesIntersectionBase< 3, geode::BRep >::triangles_intersect(
311385
geode::index_t t1_id,
312386
geode::index_t t2_id,
313387
const geode::PolygonVertices& t1_vertices,
@@ -359,7 +433,8 @@ namespace geode
359433

360434
bool model_has_intersecting_surfaces() const
361435
{
362-
const auto intersections = intersecting_triangles();
436+
const auto intersections = intersecting_triangles<
437+
OneModelSurfacesIntersection< dimension, Model > >();
363438
if( intersections.empty() )
364439
{
365440
return false;
@@ -369,7 +444,8 @@ namespace geode
369444

370445
index_t nb_intersecting_surfaces_elements_pair() const
371446
{
372-
const auto intersections = intersecting_triangles();
447+
const auto intersections = intersecting_triangles<
448+
AllModelSurfacesIntersection< dimension, Model > >();
373449
if( verbose_ )
374450
{
375451
for( const auto& triangle_pair : intersections )
@@ -388,7 +464,8 @@ namespace geode
388464
std::vector< std::pair< ComponentMeshElement, ComponentMeshElement > >
389465
intersecting_surfaces_elements() const
390466
{
391-
const auto intersections = intersecting_triangles();
467+
const auto intersections = intersecting_triangles<
468+
AllModelSurfacesIntersection< dimension, Model > >();
392469
if( verbose_ )
393470
{
394471
for( const auto& triangle_pair : intersections )
@@ -405,6 +482,7 @@ namespace geode
405482
}
406483

407484
private:
485+
template < typename Action >
408486
std::vector< std::pair< ComponentMeshElement, ComponentMeshElement > >
409487
intersecting_triangles() const
410488
{
@@ -430,9 +508,8 @@ namespace geode
430508
{
431509
continue;
432510
}
433-
ModelSurfacesIntersection< dimension, Model >
434-
surfaces_intersection_action{ model_, surface.id(),
435-
surface.id() };
511+
Action surfaces_intersection_action{ model_, surface.id(),
512+
surface.id() };
436513
model_tree
437514
.mesh_trees_[model_tree.mesh_tree_ids_.at( surface.id() )]
438515
.compute_self_element_bbox_intersections(
@@ -462,9 +539,8 @@ namespace geode
462539
{
463540
continue;
464541
}
465-
ModelSurfacesIntersection< dimension, Model >
466-
surfaces_intersection_action{ model_, surface_uuid1,
467-
surface_uuid2 };
542+
Action surfaces_intersection_action{ model_, surface_uuid1,
543+
surface_uuid2 };
468544
model_tree.mesh_trees_[components.first]
469545
.compute_other_element_bbox_intersections(
470546
model_tree.mesh_trees_[components.second],

0 commit comments

Comments
 (0)