Skip to content

compas_wood.viewer ¤

Drawing helpers, mirroring the Rhino plugin's JoinerySolver layer tree.

:data:LAYERS is the plugin's _LAYER_DEFS (same names, colors, default visibility). Rhino's PlatesMesh black is a wire color; shaded parity is grey faces + black lines, hence :data:PLATE_FACE.

These helpers are backend-agnostic: they only ever call scene.add and scene.add_group, so any object providing those two works. The two that ship are :class:compas_wood.session_scene.SessionScene, which writes a .pb for session_viewer, and :class:NullScene, the headless double used by tests/CI.

Everything draws through scene.add(item, parent=group, ...) rather than through a group handle, so per-object colors always reach the backend.

Classes¤

NullScene ¤

NullScene()

Headless scene double - records add/add_group calls in .nodes so tests/CI never need Qt. Group handles are the recorded dicts themselves, usable as parent=.

Functions:¤

aabbs ¤

aabbs(*geometries) -> list[Box]

Axis-aligned bounding boxes - Mesh via aabb(), polylines via point bounds (Polyline.aabb() raises in compas 2.15). None skipped.

add_joinery ¤

add_joinery(scene, elements, joints, *, draw_meshes: bool = False, show_areas: bool = False, show_volumes: bool = False, show_lines: bool = False, name: str = 'JoinerySolver')

Draw joinery solver output as the Rhino plugin's group tree.

Root group name; per-element groups elem_{i} (loft mesh + cut outlines); per-joint groups joint_{j} (area, volumes, lines). The draw_meshes / show_* flags set the objects' show state, matching the plugin's default layer visibility, so everything is in the scene and can be toggled from the sidebar.

Parameters:

Name Type Description Default
scene :class:`compas_wood.session_scene.SessionScene` or :class:`NullScene`
required
elements list[:class:`compas_wood.wood_element.JoineryElement`]
required
joints list[:class:`compas_wood.wood_element.JointResult`]
required

Returns:

Type Description
The root group handle.

add_plate_model ¤

add_plate_model(scene, model, *, show_meshes: bool = True, name: str = 'Plates')

Draw a :class:compas_wood.model.PlateModel: one group per plate, named {plate_type}_{plate_id}, with grey mesh and blue outlines.

Returns:

Type Description
The root group handle.

add_shell ¤

add_shell(scene, shell_mesh, name: str = 'shell', **kwargs)

Add the reference shell mesh - grey faces, real edges only.

add_solid ¤

add_solid(scene, mesh: Mesh, *, parent=None, name: str = 'mesh', facecolor: Color | None = None, edgecolor: Color | None = None, show: bool = True)

Shaded mesh without triangulation wires, plus its real (boundary/crease) edges as one graph object.

add_tags ¤

add_tags(scene, items, name: str = 'dots', **kwargs)

Rhino TextDot parity: one labelled marker per (text, position) pair.

session_py has no text geometry, so each tag is written as a :class:compas.geometry.Point named with its text - the label survives in the viewer's object tree, which is where session_viewer surfaces names. No-op with a warning on a :class:NullScene, which records nothing.

Extra kwargs are accepted and ignored (they were Tag styling).

Returns:

Type Description
list

The scene objects added (empty when skipped).

area_mesh ¤

area_mesh(polyline: Polyline, holes: list[Polyline] | None = None) -> Mesh | None

Filled surface for a closed planar outline, triangulated with CDT.

Contact areas and joint areas are arbitrary planar polygons - frequently concave, sometimes with holes - and an ear-clipping fill gets those wrong: it can put triangles outside the outline and it has no notion of a hole at all. session_py's constrained Delaunay triangulation respects the outline (and every hole) as constrained edges, so the fill is exactly the polygon.

RemeshCDT.triangulate works in x/y and ignores z, so the loops are first projected onto their own plane; the returned indices address the untouched 3D points, so the mesh comes back in the original plane, not flattened.

Returns None when the outline cannot be triangulated (fewer than 3 distinct points, or degenerate to a line).

edges_graph ¤

edges_graph(mesh: Mesh, coplanar_dot: float = 0.999) -> Graph | None

Boundary + crease edges of a mesh as one Graph - the real solid edges, without the triangulation wires of earclipped caps.