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

Function shell

cadquery/occ_impl/shapes.py:6060–6117  ·  view source on GitHub ↗

Build shell from faces. If ctx is specified, local sewing is performed.

(
    *s: Shape,
    tol: float = 1e-6,
    manifold: bool = True,
    ctx: Sequence[Shape] | Shape | None = None,
    history: History | None = None,
    name: str | None = None,
)

Source from the content-addressed store, hash-verified

6058
6059@multidispatch
6060def shell(
6061 *s: Shape,
6062 tol: float = 1e-6,
6063 manifold: bool = True,
6064 ctx: Sequence[Shape] | Shape | None = None,
6065 history: History | None = None,
6066 name: str | None = None,
6067) -> Shape:
6068 """
6069 Build shell from faces. If ctx is specified, local sewing is performed.
6070 """
6071
6072 builder = BRepBuilderAPI_Sewing(tol, option4=not manifold)
6073 if ctx:
6074 if isinstance(ctx, Shape):
6075 builder.Load(ctx.wrapped)
6076 else:
6077 builder.Load(compound(ctx).wrapped)
6078
6079 faces: list[Face] = []
6080
6081 for el in s:
6082 for f in _get(el, "Face"):
6083 builder.Add(f.wrapped)
6084 faces.append(f)
6085
6086 builder.Perform()
6087 sewed = builder.SewedShape()
6088
6089 # if specified, use context for history mapping
6090 if ctx:
6091 if isinstance(ctx, Shape):
6092 faces.extend(ctx.Faces())
6093 else:
6094 for el in ctx:
6095 faces.extend(el.Faces())
6096
6097 _update_history(history, name, faces, builder.GetContext().History())
6098 _process_sewing_history(history, faces, builder)
6099
6100 rv = []
6101
6102 # split the results
6103 rv_faces, rv_shells = _shape_to_faces_shells(sewed)
6104
6105 rv.extend(rv_shells)
6106
6107 # for one closed face sewing will not produce a shell, so a special treatment is needed
6108 for f_topo in rv_faces:
6109 tmp = TopoDS_Shell()
6110
6111 builder_topo = TopoDS_Builder()
6112 builder_topo.MakeShell(tmp)
6113 builder_topo.Add(tmp, f_topo)
6114
6115 rv.append(tmp)
6116
6117 return _compound_or_shape(rv)

Callers 3

solidFunction · 0.85
test_constructorsFunction · 0.85
test_sewingFunction · 0.85

Calls 9

compoundFunction · 0.85
_getFunction · 0.85
_update_historyFunction · 0.85
_process_sewing_historyFunction · 0.85
_shape_to_faces_shellsFunction · 0.85
_compound_or_shapeFunction · 0.85
appendMethod · 0.80
extendMethod · 0.80
FacesMethod · 0.45

Tested by 2

test_constructorsFunction · 0.68
test_sewingFunction · 0.68