pyvista_cad.topods_to_multiblock

On this page

pyvista_cad.topods_to_multiblock#

topods_to_multiblock(shape, *, linear_deflection=0.1, angular_deflection=0.5)[source]#

Tessellate shape preserving per-face identity and edges.

Returns a two-block pyvista.MultiBlock:

MultiBlock
|-- "faces"  -> MultiBlock(one PolyData per topological face)
|-- "edges"  -> PolyData (see :func:`topods_to_edges`)

Each face block carries a cad.face_id cell array and analytic point Normals (smooth shading on a coarse mesh). A single BRepMesh pass feeds both blocks.

Parameters:
shapeOCP.TopoDS.TopoDS_Shape

Shape to tessellate. build123d / cadquery wrappers are unwrapped automatically.

linear_deflectionfloat, default: 0.1

Maximum chordal deviation from the analytic surface.

angular_deflectionfloat, default: 0.5

Maximum angular deviation (radians) between adjacent triangles.

Returns:
pyvista.MultiBlock

{'faces': MultiBlock, 'edges': PolyData}.

Raises:
pyvista_cad.TessellationError

If OCCT meshing fails.

Warns:
pyvista_cad.CadWarning

When the analytic surface normal cannot be evaluated for one or more faces, those faces fall back to VTK facet normals and shade faceted rather than smooth. A single aggregated warning is emitted per call (never one per face).

Parameters:
  • shape (Any)

  • linear_deflection (float)

  • angular_deflection (float)

Return type:

MultiBlock

Notes

Smooth shading relies on per-node analytic surface normals. For a face whose analytic surface evaluation fails (degenerate pcurve, singular surface point, or a triangulation that carries no UV nodes), the block is emitted without a Normals array and the renderer falls back to faceted facet normals for that face. The geometry itself is unaffected; only the shading degrades.

Examples

Split a build123d box into per-face and edge blocks (requires the [step] extra):

>>> import build123d as b3d
>>> from pyvista_cad import topods_to_multiblock
>>> mb = topods_to_multiblock(b3d.Box(10, 10, 10).wrapped)
>>> sorted(mb.keys())
['edges', 'faces']
>>> mb['faces'].n_blocks
6