Skip to content

Commit 50decb6

Browse files
MelchiorSchuhBotellaA
authored andcommitted
fix(PythonBindings): Added example to show pyhon binding use for the topology inspector, and modified README to show bindings use.
1 parent 8d25a56 commit 50decb6

File tree

3 files changed

+129
-11
lines changed

3 files changed

+129
-11
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ Go check out the online documentation at [docs.geode-solutions.com].
4242

4343
Installing OpenGeode-Inspector is done:
4444

45-
* by compiling the C++ source.
45+
* either by compiling the C++ source.
46+
* or by using the pip command ```pip install opengeode-inspector``` and adding ```import opengeode_inspector``` in your Python script. Check [this documentation page](https://docs.geode-solutions.com/how-to-use-binding) for more details. Examples are also procured in the ```examples``` folder.
47+
4648

4749
## Questions
4850
For questions and support please use the official [slack](https://slackin-opengeode.herokuapp.com) and go to the channel #inspector. The issue list of this repo is exclusively for bug reports and feature requests.

bindings/python/tests/test-py-brep-topology.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@
2727
import opengeode
2828
import opengeode_inspector_py_inspector as inspector
2929

30-
def test_cell_number( grid ):
31-
if grid.nb_cells() != 750:
32-
raise ValueError( "[Test] Wrong total number of cells" )
33-
if grid.nb_cells_in_direction( 0 ) != 5:
34-
raise ValueError( "[Test] Wrong total number of cells along X" )
35-
if grid.nb_cells_in_direction( 1 ) != 10:
36-
raise ValueError( "[Test] Wrong total number of cells along Y" )
37-
if grid.nb_cells_in_direction( 2 ) != 15:
38-
raise ValueError( "[Test] Wrong total number of cells along Z" )
39-
4030
def check_components_linking( brep_inspector ):
4131
nb_unlinked_corners = brep_inspector.nb_corners_not_linked_to_a_unique_vertex()
4232
print( "There are ", nb_unlinked_corners, " corners not linked to a unique vertex." )

examples/model_inspection.py

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import os
2+
import opengeode
3+
import opengeode_inspector as inspector
4+
import opengeode_io
5+
6+
def check_components_linking( brep_inspector ):
7+
nb_unlinked_corners = brep_inspector.nb_corners_not_linked_to_a_unique_vertex()
8+
print( "There are ", nb_unlinked_corners, " corners not linked to a unique vertex." )
9+
nb_unlinked_lines = brep_inspector.nb_lines_not_linked_to_a_unique_vertex()
10+
print( "There are ", nb_unlinked_lines, " lines not linked to a unique vertex." )
11+
nb_unlinked_surfaces = brep_inspector.nb_surfaces_not_linked_to_a_unique_vertex()
12+
print( "There are ", nb_unlinked_surfaces, " surfaces not linked to a unique vertex." )
13+
nb_unlinked_blocks = brep_inspector.nb_blocks_not_linked_to_a_unique_vertex()
14+
print( "There are ", nb_unlinked_blocks, " blocks not linked to a unique vertex." )
15+
16+
def check_invalid_components_topology_unique_vertices( brep_inspector ):
17+
invalid_components_unique_vertices = brep_inspector.invalid_components_topology_unique_vertices()
18+
print( "There are ", len( invalid_components_unique_vertices ), " vertices with invalid components." )
19+
for vertex_index in invalid_components_unique_vertices:
20+
print( "[Test] Model unique vertex with index ", vertex_index, " has invalid components." )
21+
22+
def check_multiple_corners_unique_vertices( brep_inspector ):
23+
multiple_corners_unique_vertices = brep_inspector.multiple_corners_unique_vertices()
24+
print( "There are ", len( multiple_corners_unique_vertices ), " vertices with multiple corners." )
25+
for vertex_index in multiple_corners_unique_vertices:
26+
print( "[Test] Model unique vertex with index ", vertex_index, " is associated to multiple corners." )
27+
28+
def check_multiple_internals_corner_vertices( brep_inspector ):
29+
multiple_internals_corner_vertices = brep_inspector.multiple_internals_corner_vertices()
30+
print( "There are ", len( multiple_internals_corner_vertices ), " vertices with multiple internals." )
31+
for vertex_index in multiple_internals_corner_vertices:
32+
print( "[Test] Model unique vertex with index ", vertex_index, " is a corner associated with multiple embeddings." )
33+
34+
def check_not_internal_nor_boundary_corner_vertices( brep_inspector ):
35+
not_internal_nor_boundary_corner_vertices = brep_inspector.not_internal_nor_boundary_corner_vertices()
36+
print( "There are ", len( not_internal_nor_boundary_corner_vertices ), " corner vertices with no boundary nor internal property." )
37+
for vertex_index in not_internal_nor_boundary_corner_vertices:
38+
print( "[Test] Model unique vertex with index ", vertex_index, " is neither internal nor a boundary." )
39+
40+
def check_line_corners_without_boundary_status( brep_inspector ):
41+
line_corners_without_boundary_status = brep_inspector.line_corners_without_boundary_status()
42+
print( "There are ", len( line_corners_without_boundary_status ), " corner vertices part of a line but not its boundary." )
43+
for vertex_index in line_corners_without_boundary_status:
44+
print( "[Test] Model unique vertex with index ", vertex_index, " is a corner but has a line for which it is not a boundary." )
45+
46+
def check_part_of_not_boundary_nor_internal_line_unique_vertices( brep_inspector ):
47+
part_of_not_boundary_nor_internal_line_unique_vertices = brep_inspector.part_of_not_boundary_nor_internal_line_unique_vertices()
48+
print( "There are ", len( part_of_not_boundary_nor_internal_line_unique_vertices ), " vertices part of a line which is not boundary not internal." )
49+
for vertex_index in part_of_not_boundary_nor_internal_line_unique_vertices:
50+
print( "[Test] Model unique vertex with index ", vertex_index, " is part of a line which is neither boundary nor internal." )
51+
52+
def check_part_of_line_with_invalid_internal_topology_unique_vertices( brep_inspector ):
53+
part_of_line_with_invalid_internal_topology_unique_vertices = brep_inspector.part_of_line_with_invalid_internal_topology_unique_vertices()
54+
print( "There are ", len( part_of_line_with_invalid_internal_topology_unique_vertices ), " vertices part of lines with invalid internal property." )
55+
for vertex_index in part_of_line_with_invalid_internal_topology_unique_vertices:
56+
print( "[Test] Model unique vertex with index ", vertex_index, " is part of a line with invalid internal properties." )
57+
58+
def check_part_of_invalid_unique_line_unique_vertices( brep_inspector ):
59+
part_of_invalid_unique_line_unique_vertices = brep_inspector.part_of_invalid_unique_line_unique_vertices()
60+
print( "There are ", len( part_of_invalid_unique_line_unique_vertices ), " vertices part of a unique line with invalid toplogy." )
61+
for vertex_index in part_of_invalid_unique_line_unique_vertices:
62+
print( "[Test] Model unique vertex with index ", vertex_index, " is part of a unique line with invalid topological properties." )
63+
64+
def check_part_of_lines_but_not_corner_unique_vertices( brep_inspector ):
65+
part_of_lines_but_not_corner_unique_vertices = brep_inspector.part_of_lines_but_not_corner_unique_vertices()
66+
print( "There are ", len( part_of_lines_but_not_corner_unique_vertices ), " vertices part of multiple lines but not corner." )
67+
for vertex_index in part_of_lines_but_not_corner_unique_vertices:
68+
print( "[Test] Model unique vertex with index ", vertex_index, " is part of multiple lines but is not a corner." )
69+
70+
def check_part_of_not_boundary_nor_internal_surface_unique_vertices( brep_inspector ):
71+
part_of_not_boundary_nor_internal_surface_unique_vertices = brep_inspector.part_of_not_boundary_nor_internal_surface_unique_vertices()
72+
print( "There are ", len( part_of_not_boundary_nor_internal_surface_unique_vertices ), " vertices part of a surface which is neither internal nor boundary." )
73+
for vertex_index in part_of_not_boundary_nor_internal_surface_unique_vertices:
74+
print( "[Test] Model unique vertex with index ", vertex_index, " is part of a surface which is neither internal nor boundary." )
75+
76+
def check_part_of_surface_with_invalid_internal_topology_unique_vertices( brep_inspector ):
77+
part_of_surface_with_invalid_internal_topology_unique_vertices = brep_inspector.part_of_surface_with_invalid_internal_topology_unique_vertices()
78+
print( "There are ", len( part_of_surface_with_invalid_internal_topology_unique_vertices ), " vertices part of a surface with invalid internal topology." )
79+
for vertex_index in part_of_surface_with_invalid_internal_topology_unique_vertices:
80+
print( "[Test] Model unique vertex with index ", vertex_index, " is part of a surface with invalid internal topology." )
81+
82+
def check_part_of_invalid_unique_surface_unique_vertices( brep_inspector ):
83+
part_of_invalid_unique_surface_unique_vertices = brep_inspector.part_of_invalid_unique_surface_unique_vertices()
84+
print( "There are ", len( part_of_invalid_unique_surface_unique_vertices ), " vertices part of a unique surface with invalid topology." )
85+
for vertex_index in part_of_invalid_unique_surface_unique_vertices:
86+
print( "[Test] Model unique vertex with index ", vertex_index, " is part of a unique surface with invalid topology." )
87+
88+
def check_part_of_invalid_multiple_surfaces_unique_vertices( brep_inspector ):
89+
part_of_invalid_multiple_surfaces_unique_vertices = brep_inspector.part_of_invalid_multiple_surfaces_unique_vertices()
90+
print( "There are ", len( part_of_invalid_multiple_surfaces_unique_vertices ), " vertices part of invalid multiple surfaces." )
91+
for vertex_index in part_of_invalid_multiple_surfaces_unique_vertices:
92+
print( "[Test] Model unique vertex with index ", vertex_index, " is part of invalid multiple surfaces." )
93+
94+
def check_part_of_invalid_blocks_unique_vertices( brep_inspector ):
95+
part_of_invalid_blocks_unique_vertices = brep_inspector.part_of_invalid_blocks_unique_vertices()
96+
print( "There are ", len( part_of_invalid_blocks_unique_vertices ), " vertices with invalid block topology." )
97+
for vertex_index in part_of_invalid_blocks_unique_vertices:
98+
print( "[Test] Model unique vertex with index ", vertex_index, " has invalid blocks topology." )
99+
100+
def launch_topological_validity_checks( brep_inspector ):
101+
check_components_linking( brep_inspector )
102+
check_invalid_components_topology_unique_vertices( brep_inspector )
103+
check_multiple_corners_unique_vertices( brep_inspector )
104+
check_multiple_internals_corner_vertices( brep_inspector )
105+
check_not_internal_nor_boundary_corner_vertices( brep_inspector )
106+
check_line_corners_without_boundary_status( brep_inspector )
107+
check_part_of_not_boundary_nor_internal_line_unique_vertices( brep_inspector )
108+
check_part_of_invalid_unique_line_unique_vertices( brep_inspector )
109+
check_part_of_invalid_unique_line_unique_vertices( brep_inspector )
110+
check_part_of_lines_but_not_corner_unique_vertices( brep_inspector )
111+
check_part_of_not_boundary_nor_internal_surface_unique_vertices( brep_inspector )
112+
check_part_of_surface_with_invalid_internal_topology_unique_vertices( brep_inspector )
113+
check_part_of_invalid_unique_surface_unique_vertices( brep_inspector )
114+
check_part_of_invalid_multiple_surfaces_unique_vertices( brep_inspector )
115+
check_part_of_invalid_blocks_unique_vertices( brep_inspector )
116+
117+
if __name__ == '__main__':
118+
test_dir = os.path.dirname(__file__)
119+
data_dir = os.path.abspath(os.path.join(test_dir, "../tests/data"))
120+
brep = opengeode.load_brep( data_dir + "/model_A1_valid.og_brep" )
121+
brep_inspector = inspector.BRepTopologyInspector(brep)
122+
if brep_inspector.brep_topology_is_valid():
123+
print( "Model topology is valid." )
124+
else:
125+
print( "Model topology is invalid." )
126+
launch_topological_validity_checks( brep_inspector )

0 commit comments

Comments
 (0)