Skip to content

Render Geometry¤

compas_model.viewer.rendergeometry ¤

Classes¤

RenderGeometry dataclass ¤

RenderGeometry(
    vertices: NDArray[float64],
    triangles: NDArray[int32],
    line_vertices: NDArray[float64],
    point_vertices: NDArray[float64],
    representation: RenderRepresentation,
)

Backend-neutral, precomputed geometry for interactive rendering.

Filled faces and visible lines are intentionally stored separately. Therefore, face-triangulation diagonals do not become displayed edges.

Parameters:

  • vertices (NDArray[float64]) –

    Face vertices with shape (n, 3).

  • triangles (NDArray[int32]) –

    Triangle indices into vertices with shape (m, 3).

  • line_vertices (NDArray[float64]) –

    Explicit line-segment endpoints with shape (2k, 3).

  • point_vertices (NDArray[float64]) –

    Optional displayed points with shape (p, 3).

  • representation (RenderRepresentation) –

    Source geometry representation.

Attributes¤
backface_vertices property ¤
backface_vertices: NDArray[float64]

NDArray[np.float64]: Reversed triangle vertices for back faces.

face_vertices property ¤
face_vertices: NDArray[float64]

NDArray[np.float64]: Triangle vertices expanded for GPU buffers.

Functions:¤

render_geometry_from_brep ¤

render_geometry_from_brep(
    brep: Brep,
    linear_deflection: float | None = None,
    angular_deflection: float | None = None,
) -> RenderGeometry

Create render geometry from a BRep's native view-mesh infrastructure.

Parameters:

  • brep (Brep) –

    BRep providing a view mesh and sampled topological boundaries.

  • linear_deflection (float | None, default: None ) –

    Maximum linear tessellation deviation supported by the backend.

  • angular_deflection (float | None, default: None ) –

    Maximum angular tessellation deviation supported by the backend.

Returns:

  • RenderGeometry –

    Backend triangles and separately sampled BRep boundaries.

Raises:

  • TypeError –

    If the backend does not return a mesh and boundary polylines.

render_geometry_from_mesh ¤

render_geometry_from_mesh(mesh: Mesh, tolerance: float = 1e-09) -> RenderGeometry

Create render geometry from a mesh without displaying triangulation edges.

Parameters:

  • mesh (Mesh) –

    Source mesh. It is not modified.

  • tolerance (float, default: 1e-09 ) –

    Cleanup and validation tolerance used by polygon ear clipping.

Returns:

  • RenderGeometry –

    Triangulated faces and original mesh edges in separate buffers.