Skip to content

Commit 383982c

Browse files
Merge pull request #115 from Geode-solutions/fix/update_surface_intersections_for_polygons
fix(SurfaceIntersections): Updated code by generalizing surface inter…
2 parents b4e9740 + 26802f4 commit 383982c

File tree

9 files changed

+197
-257
lines changed

9 files changed

+197
-257
lines changed

bindings/python/src/inspector/criterion/intersections/surface_intersections.hpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
#include <absl/strings/str_cat.h>
2424

25-
#include <geode/mesh/core/triangulated_surface.hpp>
25+
#include <geode/mesh/core/surface_mesh.hpp>
2626

2727
#include <geode/inspector/criterion/intersections/surface_intersections.hpp>
2828

@@ -31,18 +31,16 @@ namespace geode
3131
template < index_t dimension >
3232
void do_define_surface_intersections( pybind11::module& module )
3333
{
34-
using TriangulatedSurface = TriangulatedSurface< dimension >;
35-
using TriangulatedSurfaceIntersections =
36-
TriangulatedSurfaceIntersections< dimension >;
34+
using SurfaceMesh = SurfaceMesh< dimension >;
35+
using SurfaceMeshIntersections = SurfaceMeshIntersections< dimension >;
3736
const auto name =
38-
absl::StrCat( "TriangulatedSurfaceIntersections", dimension, "D" );
39-
pybind11::class_< TriangulatedSurfaceIntersections >(
40-
module, name.c_str() )
41-
.def( pybind11::init< const TriangulatedSurface& >() )
37+
absl::StrCat( "SurfaceMeshIntersections", dimension, "D" );
38+
pybind11::class_< SurfaceMeshIntersections >( module, name.c_str() )
39+
.def( pybind11::init< const SurfaceMesh& >() )
4240
.def( "mesh_has_self_intersections",
43-
&TriangulatedSurfaceIntersections::mesh_has_self_intersections )
41+
&SurfaceMeshIntersections::mesh_has_self_intersections )
4442
.def( "intersecting_elements",
45-
&TriangulatedSurfaceIntersections::intersecting_elements );
43+
&SurfaceMeshIntersections::intersecting_elements );
4644
}
4745
void define_surface_intersections( pybind11::module& module )
4846
{

bindings/python/src/inspector/surface_inspector.hpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,25 @@ namespace geode
3333
{
3434
using SurfaceMesh = SurfaceMesh< dimension >;
3535
using SurfaceMeshInspector = SurfaceMeshInspector< dimension >;
36-
using TriangulatedSurface = TriangulatedSurface< dimension >;
37-
using TriangulatedSurfaceInspector =
38-
TriangulatedSurfaceInspector< dimension >;
3936
const auto name =
4037
absl::StrCat( "SurfaceMeshInspector", dimension, "D" );
4138
pybind11::class_< SurfaceMeshInspector,
4239
SurfaceMeshAdjacency< dimension >,
4340
SurfaceMeshColocation< dimension >,
4441
SurfaceMeshDegeneration< dimension >,
4542
SurfaceMeshEdgeManifold< dimension >,
46-
SurfaceMeshVertexManifold< dimension > >( module, name.c_str() )
43+
SurfaceMeshVertexManifold< dimension >,
44+
SurfaceMeshIntersections< dimension > >( module, name.c_str() )
4745
.def( pybind11::init< const SurfaceMesh& >() )
4846
.def( "inspect_surface", &SurfaceMeshInspector::inspect_surface );
4947

50-
const auto trgl_name =
51-
absl::StrCat( "TriangulatedSurfaceInspector", dimension, "D" );
52-
pybind11::class_< TriangulatedSurfaceInspector, SurfaceMeshInspector,
53-
TriangulatedSurfaceIntersections< dimension > >(
54-
module, trgl_name.c_str() )
55-
.def( pybind11::init< const TriangulatedSurface& >() )
56-
.def( "inspect_surface",
57-
&TriangulatedSurfaceInspector::inspect_surface );
58-
5948
const auto inspect_function_name =
6049
absl::StrCat( "inspect_surface", dimension, "D" );
6150
module.def(
6251
inspect_function_name.c_str(), []( const SurfaceMesh& surface ) {
6352
SurfaceMeshInspector inspector{ surface };
6453
return inspector.inspect_surface();
6554
} );
66-
67-
const auto inspect_function_name2 =
68-
absl::StrCat( "inspect_triangulated_surface", dimension, "D" );
69-
module.def( inspect_function_name2.c_str(),
70-
[]( const TriangulatedSurface& surface ) {
71-
TriangulatedSurfaceInspector inspector{ surface };
72-
return inspector.inspect_surface();
73-
} );
7455
}
7556

7657
void define_surface_inspector( pybind11::module& module )

bindings/python/tests/test-py-surface-intersections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def check_intersections2D():
4747
builder.set_polygon_adjacent(geode.PolygonEdge(1, 1), 2)
4848
builder.set_polygon_adjacent(geode.PolygonEdge(2, 0), 1)
4949

50-
intersections_inspector = inspector.TriangulatedSurfaceIntersections2D(
50+
intersections_inspector = inspector.SurfaceMeshIntersections2D(
5151
surface)
5252
if not intersections_inspector.mesh_has_self_intersections():
5353
raise ValueError("[Test] 2D Surface should have intersections.")
@@ -83,7 +83,7 @@ def check_intersections3D():
8383
builder.set_polygon_adjacent(geode.PolygonEdge(2, 1), 3)
8484
builder.set_polygon_adjacent(geode.PolygonEdge(3, 0), 2)
8585

86-
intersections_inspector = inspector.TriangulatedSurfaceIntersections3D(
86+
intersections_inspector = inspector.SurfaceMeshIntersections3D(
8787
surface)
8888
if not intersections_inspector.mesh_has_self_intersections():
8989
raise ValueError("[Test] 3D Surface should have intersections.")

include/geode/inspector/criterion/intersections/surface_intersections.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,24 @@
3232

3333
namespace geode
3434
{
35-
FORWARD_DECLARATION_DIMENSION_CLASS( TriangulatedSurface );
35+
FORWARD_DECLARATION_DIMENSION_CLASS( SurfaceMesh );
3636
} // namespace geode
3737

3838
namespace geode
3939
{
4040
/*!
41-
* Class for inspecting the intersections of TriangulatedSurfaces
41+
* Class for inspecting the intersections of SurfaceMeshes
4242
*/
4343
template < index_t dimension >
44-
class TriangulatedSurfaceIntersections
44+
class SurfaceMeshIntersections
4545
{
46-
OPENGEODE_DISABLE_COPY( TriangulatedSurfaceIntersections );
46+
OPENGEODE_DISABLE_COPY( SurfaceMeshIntersections );
4747

4848
public:
49-
explicit TriangulatedSurfaceIntersections(
50-
const TriangulatedSurface< dimension >& mesh );
49+
explicit SurfaceMeshIntersections(
50+
const SurfaceMesh< dimension >& mesh );
5151

52-
~TriangulatedSurfaceIntersections();
52+
~SurfaceMeshIntersections();
5353

5454
[[nodiscard]] bool mesh_has_self_intersections() const;
5555

@@ -59,5 +59,5 @@ namespace geode
5959
private:
6060
IMPLEMENTATION_MEMBER( impl_ );
6161
};
62-
ALIAS_2D_AND_3D( TriangulatedSurfaceIntersections );
62+
ALIAS_2D_AND_3D( SurfaceMeshIntersections );
6363
} // namespace geode

include/geode/inspector/surface_inspector.hpp

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ namespace geode
7676
SurfaceMeshColocation< dimension >,
7777
SurfaceMeshDegeneration< dimension >,
7878
SurfaceMeshEdgeManifold< dimension >,
79-
SurfaceMeshVertexManifold< dimension > >
79+
SurfaceMeshVertexManifold< dimension >,
80+
SurfaceMeshIntersections< dimension > >
8081
{
8182
OPENGEODE_DISABLE_COPY( SurfaceMeshInspector );
8283

@@ -88,23 +89,4 @@ namespace geode
8889
[[nodiscard]] virtual SurfaceInspectionResult inspect_surface() const;
8990
};
9091
ALIAS_2D_AND_3D( SurfaceMeshInspector );
91-
92-
/*!
93-
* Class for inspecting a TriangulatedSurface
94-
* @extends SurfaceMeshInspector
95-
* @extends TriangulatedSurfaceIntersections
96-
*/
97-
template < index_t dimension >
98-
class TriangulatedSurfaceInspector
99-
: public SurfaceMeshInspector< dimension >,
100-
public AddInspectors< TriangulatedSurface< dimension >,
101-
TriangulatedSurfaceIntersections< dimension > >
102-
{
103-
public:
104-
explicit TriangulatedSurfaceInspector(
105-
const TriangulatedSurface< dimension >& mesh );
106-
107-
[[nodiscard]] SurfaceInspectionResult inspect_surface() const final;
108-
};
109-
ALIAS_2D_AND_3D( TriangulatedSurfaceInspector );
11092
} // namespace geode

0 commit comments

Comments
 (0)