MCPcopy
hub / github.com/CadQuery/cadquery / _normalize

Function _normalize

cadquery/occ_impl/shapes.py:5329–5348  ·  view source on GitHub ↗

Apply some normalizations: - Shell with only one Face -> Face. - Compound with only one element -> element.

(s: Shape)

Source from the content-addressed store, hash-verified

5327
5328
5329def _normalize(s: Shape) -> Shape:
5330 """
5331 Apply some normalizations:
5332 - Shell with only one Face -> Face.
5333 - Compound with only one element -> element.
5334 """
5335
5336 t = s.ShapeType()
5337 rv = s
5338
5339 if t == "Shell":
5340 faces = s.Faces()
5341 if len(faces) == 1 and not BRep_Tool.IsClosed_s(s.wrapped):
5342 rv = faces[0]
5343 elif t == "Compound":
5344 objs = list(s)
5345 if len(objs) == 1:
5346 rv = objs[0]
5347
5348 return rv
5349
5350
5351def _compound_or_shape(s: TopoDS_Shape | Sequence[TopoDS_Shape]) -> Shape:

Callers 10

_compound_or_shapeFunction · 0.85
_toptools_list_to_shapesFunction · 0.85
_getMethod · 0.85
modifiedMethod · 0.85
generatedMethod · 0.85
deletedMethod · 0.85
firstMethod · 0.85
lastMethod · 0.85
textFunction · 0.85
projectFunction · 0.85

Calls 2

ShapeTypeMethod · 0.45
FacesMethod · 0.45

Tested by

no test coverage detected