Skip to content

Commit 352fb01

Browse files
fix: a bit of defensive coding suggested by guithub copilot
1 parent 610dc87 commit 352fb01

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/gh/diffCheck/diffCheck/df_util.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,12 @@ def compute_oriented_bounding_box(brep):
204204
for v in face.ToBrep().Vertices:
205205
bb_vertices.append(Rhino.Geometry.Point3d(v.Location.X, v.Location.Y, v.Location.Z))
206206
df_cloud.points = [np.array([vertex.X, vertex.Y, vertex.Z]).reshape(3, 1) for vertex in bb_vertices]
207-
return diffCheck.df_cvt_bindings.cvt_dfOBB_2_rhbrep(df_cloud.get_tight_bounding_box())
207+
brep_bb = diffCheck.df_cvt_bindings.cvt_dfOBB_2_rhbrep(df_cloud.get_tight_bounding_box())
208+
if brep_bb is not None:
209+
return brep_bb
210+
else:
211+
for edge in brep.Edges:
212+
bb_vertices.extend([Rhino.Geometry.Point3d(pt.X, pt.Y, pt.Z) for pt in edge.ToNurbsCurve().DivideByCount(10, True)])
213+
df_cloud.points = [np.array([vertex.X, vertex.Y, vertex.Z]).reshape(3, 1) for vertex in bb_vertices]
214+
brep_bb = diffCheck.df_cvt_bindings.cvt_dfOBB_2_rhbrep(df_cloud.get_tight_bounding_box())
215+
return brep_bb

0 commit comments

Comments
 (0)