Skip to content

OCCNurbsSurface ¤

OCCNurbsSurface(native_surface: Geom_Surface, name: str | None = None)

Class representing a NURBS surface based on the BSplineSurface of the OCC geometry kernel.

Parameters:

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

    The name of the curve

Attributes:

  • points (ControlPoints) –

    The control points of the surface.

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

    The weights of the control points of the surface.

  • knots_u (list[float]) –

    The knots of the surface in the U direction, without multiplicities.

  • knots_v (list[float]) –

    The knots of the surface in the V direction, without multiplicities.

  • mults_u (list[int]) –

    The multiplicities of the knots of the surface in the U direction.

  • mults_v (list[int]) –

    The multiplicities of the knots of the surface in the V direction.

Examples:

Construct a surface from points...

from compas.geometry import Point
from compas_occ.geometry import OCCNurbsSurface

points = [
    [Point(0, 0, 0), Point(1, 0, 0), Point(2, 0, 0), Point(3, 0, 0)],
    [Point(0, 1, 0), Point(1, 1, 2), Point(2, 1, 2), Point(3, 1, 0)],
    [Point(0, 2, 0), Point(1, 2, 2), Point(2, 2, 2), Point(3, 2, 0)],
    [Point(0, 3, 0), Point(1, 3, 0), Point(2, 3, 0), Point(3, 3, 0)],
]

surface = OCCNurbsSurface.from_points(points=points)

Construct a surface from points...

from compas.geometry import Point
from compas_occ.geometry import OCCNurbsSurface

points = [
    [Point(0, 0, 0), Point(1, 0, +0), Point(2, 0, +0), Point(3, 0, +0), Point(4, 0, +0), Point(5, 0, 0)],
    [Point(0, 1, 0), Point(1, 1, -1), Point(2, 1, -1), Point(3, 1, -1), Point(4, 1, -1), Point(5, 1, 0)],
    [Point(0, 2, 0), Point(1, 2, -1), Point(2, 2, +2), Point(3, 2, +2), Point(4, 2, -1), Point(5, 2, 0)],
    [Point(0, 3, 0), Point(1, 3, -1), Point(2, 3, +2), Point(3, 3, +2), Point(4, 3, -1), Point(5, 3, 0)],
    [Point(0, 4, 0), Point(1, 4, -1), Point(2, 4, -1), Point(3, 4, -1), Point(4, 4, -1), Point(5, 4, 0)],
    [Point(0, 5, 0), Point(1, 5, +0), Point(2, 5, +0), Point(3, 5, +0), Point(4, 5, +0), Point(5, 5, 0)],
]

weights = [
    [1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
    [1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
    [1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
    [1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
    [1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
    [1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
]

surface = OCCNurbsSurface.from_parameters(
    points=points,
    weights=weights,
    knots_u=[1.0, 1 + 1 / 9, 1 + 2 / 9, 1 + 3 / 9, 1 + 4 / 9, 1 + 5 / 9, 1 + 6 / 9, 1 + 7 / 9, 1 + 8 / 9, 2.0],
    knots_v=[0.0, 1 / 9, 2 / 9, 3 / 9, 4 / 9, 5 / 9, 6 / 9, 7 / 9, 8 / 9, 1.0],
    mults_u=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
    mults_v=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
    degree_u=3,
    degree_v=3,
)

Functions¤

copy ¤

copy() -> OCCNurbsSurface

Make an independent copy of the current surface.

Returns:

from_extrusion classmethod ¤

from_extrusion(curve: Curve, vector: Vector) -> OCCNurbsSurface

Construct a NURBS surface from an extrusion of a basis curve.

Note that the extrusion surface is constructed by generating an infill between the basis curve and a translated copy with :meth:from_fill.

Parameters:

  • curve (Curve) –

    The basis curve for the extrusion.

  • vector (Vector) –

    The extrusion vector, which serves as a translation vector for the basis curve.

Returns:

from_fill classmethod ¤

from_fill(
    curve1: OCCNurbsCurve,
    curve2: OCCNurbsCurve,
    curve3: OCCNurbsCurve | None = None,
    curve4: OCCNurbsCurve | None = None,
    style: Literal["stretch", "coons", "curved"] = "stretch",
) -> OCCNurbsSurface

Construct a NURBS surface from the infill between two, three or four contiguous NURBS curves.

Parameters:

  • curve1 (OCCNurbsCurve) –

    The first boundary curve.

  • curve2 (OCCNurbsCurve) –

    The second boundary curve.

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

    The third boundary curve.

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

    The fourth boundary curve.

  • style (Literal['stretch', 'coons', 'curved'], default: 'stretch' ) –

    The fill style. Options are:

    • 'stretch' produces the flattest patch.
    • 'curved' produces a rounded patch.
    • 'coons' is between stretch and coons.

Raises:

  • ValueError

    If the fill style is not supported.

Returns:

from_interpolation classmethod ¤

from_interpolation(
    points: list[list[Point]], precision: float = 0.001
) -> OCCNurbsSurface

Construct a NURBS surface by approximating or interpolating a 2D collection of points.

Parameters:

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

    The 2D collection of points.

  • precision (float, default: 0.001 ) –

    The fitting precision.

Returns:

from_native classmethod ¤

from_native(native_surface: Geom_BSplineSurface) -> OCCNurbsSurface

Construct a NURBS surface from an existing OCC Surface.

Parameters:

  • native_surface (Geom_BSplineSurface) –

    An OCC surface.

Returns:

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,
    is_periodic_u: bool = False,
    is_periodic_v: bool = False,
) -> OCCNurbsSurface

Construct a NURBS surface from explicit parameters.

Parameters:

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

    The control points of the surface.

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

    The weights of the control points.

  • knots_u (list[float]) –

    The knots in the U direction, without multiplicities.

  • knots_v (list[float]) –

    The knots in the V direction, without multiplicities.

  • mults_u (list[int]) –

    The multiplicities of the knots in the U direction.

  • mults_v (list[int]) –

    The multiplicities of the knots in the V direction.

  • u_dergee

    Degree in the U direction.

  • degree_v (int) –

    Degree in the V direction.

  • is_periodic_u (bool, default: False ) –

    Flag indicating that the surface is periodic in the U direction.

  • is_periodic_v (bool, default: False ) –

    Flag indicating that the surface is periodic in the V direction.

Returns:

from_plane classmethod ¤

from_plane(plane: Plane) -> OCCNurbsSurface

Construct a NURBS surface from a plane.

Parameters:

  • plane (Plane) –

    The plane to construct the surface from.

Returns:

from_points classmethod ¤

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

Construct a NURBS surface from control points.

Parameters:

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

    The control points.

  • degree_u (int, default: 3 ) –

    Degree in the U direction.

  • degree_v (int, default: 3 ) –

    Degree in the V direction.

Returns: