Build solid from faces or shells.
(
s1: Shape,
*sn: Shape,
tol: float = 1e-6,
history: History | None = None,
name: str | None = None,
)
| 6135 | |
| 6136 | @multidispatch |
| 6137 | def solid( |
| 6138 | s1: Shape, |
| 6139 | *sn: Shape, |
| 6140 | tol: float = 1e-6, |
| 6141 | history: History | None = None, |
| 6142 | name: str | None = None, |
| 6143 | ) -> Compound | Solid: |
| 6144 | """ |
| 6145 | Build solid from faces or shells. |
| 6146 | """ |
| 6147 | |
| 6148 | builder = ShapeFix_Solid() |
| 6149 | |
| 6150 | # get both Shells and Faces |
| 6151 | s = [s1, *sn] |
| 6152 | shells_faces = [f for el in s for f in _get(el, ("Shell", "Face"))] |
| 6153 | |
| 6154 | # if no shells are present, use faces to construct them |
| 6155 | shells = [el.wrapped for el in shells_faces if isinstance(el, Shell)] |
| 6156 | if not shells: |
| 6157 | faces = [el for el in shells_faces if isinstance(el, Face)] |
| 6158 | shells = [ |
| 6159 | tcast( |
| 6160 | TopoDS_Shell, shell(*faces, tol=tol, history=history, name=name).wrapped |
| 6161 | ) |
| 6162 | ] |
| 6163 | |
| 6164 | rvs = [builder.SolidFromShell(sh) for sh in shells] |
| 6165 | |
| 6166 | return tcast(Compound | Solid, _compound_or_shape(rvs)) |
| 6167 | |
| 6168 | |
| 6169 | @multidispatch |