Skip to content

Commit 61bc49d

Browse files
committed
Add check topology in NurbsHandler
1 parent 39a68b6 commit 61bc49d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

pygem/nurbshandler.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,38 @@ def write(self, mesh_points, filename, tolerance=None):
217217
faces_explorer.Next()
218218
self.write_shape_to_file(compound, self.outfile)
219219

220+
def check_topology(self):
221+
"""
222+
Method to check the topology of imported geometry.
223+
:return: 0: 1 solid = 1 shell = n faces
224+
1: 1 solid = 0 shell = n free faces
225+
2: 1 solid = n shell = n faces (1 shell = 1 face)
226+
"""
227+
# read shells and faces
228+
shells_explorer = TopExp_Explorer(self.shape, TopAbs_SHELL)
229+
n_shells = 0
230+
while shells_explorer.More():
231+
n_shells += 1
232+
shells_explorer.Next()
233+
234+
faces_explorer = TopExp_Explorer(self.shape, TopAbs_FACE)
235+
n_faces = 0
236+
while faces_explorer.More():
237+
n_faces += 1
238+
faces_explorer.Next()
239+
240+
print("##############################################\n"
241+
"Model statistics -- Nb Shells: {0} Faces: {1} \n"
242+
"----------------------------------------------\n"
243+
.format(n_shells, n_faces))
244+
245+
if n_shells == 0:
246+
self.check_topo = 1
247+
elif n_shells == n_faces:
248+
self.check_topo = 2
249+
else:
250+
self.check_topo = 0
251+
220252
def write_shape_to_file(self, shape, filename):
221253
"""
222254
Abstract method to write the 'shape' to the `filename`.

0 commit comments

Comments
 (0)