Skip to content

compas_brep.surfaces.nurbs ¤

This is an attempt at Pure-Python rational NURBS surface built on scipy.interpolate.BSpline which seems more doable than a pure-Python Brep.

This is a replacement for the compas.geometry.NurbsSurface pluggable but need to be evaluated for completness.

Classes¤

ControlPointGrid ¤

ControlPointGrid(data: list[list[Point]], surface: NurbsSurface | None = None)

A 2-D grid wrapper that supports both grid[i][j] and grid[i, j] indexing.

Modifications through grid[i, j] = point invalidate the parent surface's caches.

NurbsSurface ¤

NurbsSurface(name: str | None = None)

A rational NURBS surface (tensor-product).

Parameters:

  • name (str | None, default: None ) –

    The name of the surface.

Attributes¤

degree_u property ¤
degree_u: int

Polynomial degree in U direction.

degree_v property ¤
degree_v: int

Polynomial degree in V direction.

domain_u property ¤
domain_u: tuple[float, float]

Parameter domain in U.

domain_v property ¤
domain_v: tuple[float, float]

Parameter domain in V.

knots_u property ¤
knots_u: list[float]

Unique knot values in U direction.

knots_v property ¤
knots_v: list[float]

Unique knot values in V direction.

knotvector_u property ¤
knotvector_u: list[float]

Full knot vector in U direction.

knotvector_v property ¤
knotvector_v: list[float]

Full knot vector in V direction.

mults_u property ¤
mults_u: list[int]

Knot multiplicities in U direction.

mults_v property ¤
mults_v: list[int]

Knot multiplicities in V direction.

points property ¤

2-D grid of control points (nu x nv).

Supports both surface.points[i][j] and surface.points[i, j] indexing.

weights property ¤
weights: list[list[float]]

2-D grid of weights.

Methods:¤

copy ¤
copy() -> NurbsSurface

Return a deep copy.

frame_at ¤
frame_at(u: float, v: float) -> Frame

Local frame at (u, v).

Parameters:

  • u (float) –

    Parameter in U direction.

  • v (float) –

    Parameter in V direction.

from_extrusion classmethod ¤
from_extrusion(curve: NurbsCurve, vector: Vector) -> NurbsSurface

Create a surface by extruding a curve along a vector.

U direction follows the curve, V direction is the extrusion.

Parameters:

  • curve (NurbsCurve) –

    The profile curve.

  • vector (Vector) –

    The extrusion direction.

from_fill classmethod ¤
from_fill(
    curve1: NurbsCurve,
    curve2: NurbsCurve,
    curve3: NurbsCurve | None = None,
    curve4: NurbsCurve | None = None,
    style: str = "stretch",
) -> NurbsSurface

Create a surface filling between boundary curves.

For 2 curves a ruled surface (linear interpolation) is created. For 4 curves a simplified bilinear Coons patch is created.

Parameters:

  • curve1 (NurbsCurve) –

    First boundary curve.

  • curve2 (NurbsCurve) –

    Second boundary curve (opposite to curve1).

  • curve3 (NurbsCurve | None, default: None ) –

    Third boundary curve.

  • curve4 (NurbsCurve | None, default: None ) –

    Fourth boundary curve.

  • style (str, default: 'stretch' ) –

    Fill style (currently only "stretch" is supported).

from_meshgrid classmethod ¤
from_meshgrid(nu: int = 4, nv: int = 4) -> NurbsSurface

Create a flat rectangular surface on the XY plane.

Control points lie on a regular grid from (0, 0, 0) to (nu-1, nv-1, 0).

Parameters:

  • nu (int, default: 4 ) –

    Number of control points in U.

  • nv (int, default: 4 ) –

    Number of control points in V.

from_parameters classmethod ¤
from_parameters(
    points: list[list[Point]],
    weights: list[list[float]],
    knots_u: list[float],
    knots_v: list[float],
    mults_u: list[int],
    mults_v: list[int],
    degree_u: int,
    degree_v: int,
) -> NurbsSurface

Create a NurbsSurface from explicit parameters.

Parameters:

  • points (list[list[Point]]) –

    2-D grid of control points (nu x nv).

  • weights (list[list[float]]) –

    2-D grid of weights.

  • knots_u (list[float]) –

    Unique knot values in U direction.

  • knots_v (list[float]) –

    Unique knot values in V direction.

  • mults_u (list[int]) –

    Multiplicities in U direction.

  • mults_v (list[int]) –

    Multiplicities in V direction.

  • degree_u (int) –

    Degree in U direction.

  • degree_v (int) –

    Degree in V direction.

from_points classmethod ¤
from_points(
    points: list[list[Point]], degree_u: int = 3, degree_v: int = 3
) -> NurbsSurface

Create a NurbsSurface from a 2-D grid of control points.

Generates clamped uniform knot vectors. Degree is clamped to min(degree, n_points - 1) in each direction.

Parameters:

  • points (list[list[Point]]) –

    2-D grid (nu x nv) of control points.

  • degree_u (int, default: 3 ) –

    Desired degree in U direction.

  • degree_v (int, default: 3 ) –

    Desired degree in V direction.

isocurve_u ¤
isocurve_u(u: float) -> NurbsCurve

Extract a V-direction iso-curve at fixed u.

Parameters:

  • u (float) –

    Fixed U parameter.

isocurve_v ¤
isocurve_v(v: float) -> NurbsCurve

Extract a U-direction iso-curve at fixed v.

Parameters:

  • v (float) –

    Fixed V parameter.

normal_at ¤
normal_at(u: float, v: float) -> Vector

Surface normal at (u, v) via finite differences.

Parameters:

  • u (float) –

    Parameter in U direction.

  • v (float) –

    Parameter in V direction.

point_at ¤
point_at(u: float, v: float) -> Point

Evaluate the surface at parameters (u, v).

Parameters:

  • u (float) –

    Parameter in U direction.

  • v (float) –

    Parameter in V direction.

space_u ¤
space_u(n: int = 10) -> list[float]

Return n+1 uniformly spaced parameters in U domain.

Parameters:

  • n (int, default: 10 ) –

    Number of intervals.

space_v ¤
space_v(n: int = 10) -> list[float]

Return n+1 uniformly spaced parameters in V domain.

Parameters:

  • n (int, default: 10 ) –

    Number of intervals.

transform ¤
transform(transformation: Transformation) -> None

Transform all control points in-place.

Parameters: