Skip to content

compas_brep ¤

compas_brep: Pure Python Brep implementation based on the COMPAS framework.

Classes¤

Brep ¤

Brep(name: str | None = None)

Thin wrapper around a native backend geometry object (OCC or Rhino).

_native_brep is the sole source of truth. Topology lists are lazy caches populated on demand from native via _ensure_topology; they are never written as primary data. All public interface values are COMPAS types.

Attributes¤

aabb property ¤
aabb: Box

Axis-aligned bounding box of this Brep.

Methods:¤

__add__ ¤
__add__(other: Brep) -> list[Brep]

A + B. Same as :meth:from_boolean_union, so it returns a list.

__and__ ¤
__and__(other: Brep) -> list[Brep]

A & B. Same as :meth:from_boolean_intersection, so it returns a list.

__sub__ ¤
__sub__(other: Brep) -> list[Brep]

A - B. Same as :meth:from_boolean_difference, so it returns a list.

cap_planar_holes ¤
cap_planar_holes() -> None

Cap planar holes in this Brep in-place.

contains ¤
contains(obj: Point) -> bool

Check if a point is contained inside this solid Brep.

Parameters:

  • obj (Point) –

    The point to test.

contours ¤
contours(planes: list[Plane]) -> list[list[Polyline]]

Generate contour lines by slicing with multiple planes.

Parameters:

  • planes (list[Plane]) –

    The slicing planes.

copy ¤
copy() -> Brep

Return a deep copy of this Brep.

edge_loops ¤
edge_loops(edge: BrepEdge) -> list[BrepLoop]

Get all loops that contain this edge.

Parameters:

  • edge (BrepEdge) –

    The edge to query.

fillet ¤
fillet(radius: float, edges: list[int] | None = None) -> None

Fillet edges in-place.

Parameters:

  • radius (float) –

    The fillet radius.

  • edges (list[int] | None, default: None ) –

    Indices of edges to fillet. If None, fillets all edges.

filleted ¤
filleted(radius: float, edges: list[int] | None = None) -> Brep

Return a filleted copy of this Brep.

Parameters:

  • radius (float) –

    The fillet radius.

  • edges (list[int] | None, default: None ) –

    Indices of edges to fillet. If None, fillets all edges.

fix ¤
fix() -> None

Fix/repair this Brep in-place.

flip ¤
flip() -> None

Flip face orientations of this Brep in-place.

from_boolean_difference classmethod ¤
from_boolean_difference(brep_a: Brep, brep_b: Brep) -> list[Brep]

Boolean subtraction: A - B.

Returns one Brep per resulting piece — a subtraction can cut a shape into several disconnected ones. Empty when nothing is left.

from_boolean_intersection classmethod ¤
from_boolean_intersection(brep_a: Brep, brep_b: Brep) -> list[Brep]

Boolean intersection: A & B.

Returns one Brep per resulting piece. Empty when the two do not overlap.

from_boolean_union classmethod ¤
from_boolean_union(brep_a: Brep, brep_b: Brep) -> list[Brep]

Boolean union: A + B.

Returns one Brep per resulting piece — disjoint inputs stay disjoint.

from_boolean_union_multi classmethod ¤
from_boolean_union_multi(*breps: Brep) -> list[Brep]

Boolean union of multiple Breps, chained pairwise.

Only the first piece of each intermediate union is carried into the next step, so disjoint inputs are not all preserved. Union them pairwise if that matters.

Parameters:

  • *breps (Brep, default: () ) –

    Two or more Breps to union.

from_box classmethod ¤
from_box(box: Box) -> Brep

Create a Brep from a COMPAS Box.

from_brepfaces classmethod ¤
from_brepfaces(faces: list[BrepFace]) -> Brep

Build a Brep from a list of BrepFace objects.

from_breps classmethod ¤
from_breps(breps: list[Brep]) -> Brep

Join multiple Breps into one by sewing overlapping edges.

Parameters:

from_cone classmethod ¤
from_cone(cone: Any) -> Brep

Create a Brep from a COMPAS Cone.

from_curves classmethod ¤
from_curves(curves: list[Any]) -> Brep

Create a Brep from planar boundary curves.

Parameters:

  • curves (list[Any]) –

    List of curves defining a planar face boundary.

from_cylinder classmethod ¤
from_cylinder(cylinder: Cylinder) -> Brep

Create a Brep from a COMPAS Cylinder.

from_extrusion classmethod ¤
from_extrusion(profile: Any, vector: Vector, cap_ends: bool = True) -> Brep

Create a Brep by extruding a profile along a vector.

Parameters:

  • profile (Any) –

    The profile to extrude (BrepFace, Polygon, or curve).

  • vector (Vector) –

    The extrusion direction and magnitude.

  • cap_ends (bool, default: True ) –

    If True, cap the top and bottom. Passed to the backend where supported.

from_iges classmethod ¤
from_iges(filepath: str) -> Brep

Import a Brep from an IGES file.

Parameters:

  • filepath (str) –

    Path to the .igs or .iges file.

from_loft classmethod ¤
from_loft(curves: list[Any]) -> Brep

Create a Brep by lofting between profile curves.

Delegates to the active backend (OCC or Rhino) for exact NURBS lofting.

Parameters:

  • curves (list[Any]) –

    List of NurbsCurve profiles.

from_mesh classmethod ¤
from_mesh(mesh: Mesh) -> Brep

Create a Brep from a COMPAS Mesh.

from_native classmethod ¤
from_native(native_brep: Any) -> Brep

Create a Brep from a native backend object (OCC TopoDS_Shape or Rhino.Geometry.Brep).

Parameters:

  • native_brep (Any) –

    A native OCC or Rhino brep object.

from_pipe classmethod ¤
from_pipe(path: Brep, radius: float) -> Brep

Create a pipe Brep by sweeping a circle along a path.

Parameters:

  • path (Brep) –

    The path curve (as a Brep with edges).

  • radius (float) –

    The pipe radius.

from_plane classmethod ¤
from_plane(
    plane: Plane,
    domain_u: tuple[float, float] = (-1, 1),
    domain_v: tuple[float, float] = (-1, 1),
) -> Brep

Create a single planar face Brep from a Plane with the given domain.

from_polygons classmethod ¤
from_polygons(polygons: list[Polygon]) -> Brep

Create a Brep from a list of COMPAS Polygons.

from_sphere classmethod ¤
from_sphere(sphere: Sphere) -> Brep

Create a Brep from a COMPAS Sphere.

from_step classmethod ¤
from_step(filepath: str) -> Brep

Import a Brep from a STEP file.

Parameters:

  • filepath (str) –

    Path to the .step or .stp file.

from_surface classmethod ¤
from_surface(
    surface: NurbsSurface,
    domain_u: tuple[float, float] | None = None,
    domain_v: tuple[float, float] | None = None,
) -> Brep

Create a Brep from a NURBS surface.

Parameters:

from_sweep classmethod ¤
from_sweep(profile: Brep, path: Brep) -> Brep

Create a Brep by sweeping a profile along a path.

Parameters:

  • profile (Brep) –

    The profile to sweep.

  • path (Brep) –

    The path to sweep along.

from_torus classmethod ¤
from_torus(torus: Any) -> Brep

Create a Brep from a COMPAS Torus.

heal ¤
heal() -> None

Heal this Brep in-place (fix + sew).

make_solid ¤
make_solid() -> None

Convert this Brep from a shell to a solid in-place.

offset ¤
offset(distance: float) -> Brep

Return an offset copy of this Brep.

Parameters:

  • distance (float) –

    The offset distance (positive = outward, negative = inward).

overlap ¤
overlap(other: Brep, deflection: float | None = None, tolerance: float = 0.0) -> Brep

Compute the overlap between this Brep and another.

Parameters:

  • other (Brep) –

    The other Brep.

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

    Linear deflection for mesh approximation.

  • tolerance (float, default: 0.0 ) –

    Tolerance for overlap detection.

sew ¤
sew() -> None

Sew this Brep in-place.

slice ¤
slice(plane: Plane) -> list[Polyline]

Intersect the Brep with a plane, returning intersection polylines.

Parameters:

  • plane (Plane) –

    The cutting plane.

split ¤
split(cutter: Brep) -> list[Brep]

Split this Brep by a cutter Brep (typically a planar surface).

Parameters:

  • cutter (Brep) –

    The cutting Brep.

to_iges ¤
to_iges(filepath: str) -> None

Export this Brep to an IGES file.

Parameters:

  • filepath (str) –

    Path to the output .igs or .iges file.

to_meshes ¤
to_meshes(u: int = 16, v: int = 16) -> list[Mesh]

Convert the Brep to a list of meshes for visualization.

Returns a single mesh covering the whole Brep.

Parameters:

  • u (int, default: 16 ) –

    Resolution for tessellation.

  • v (int, default: 16 ) –

    Unused, kept for interface compatibility.

to_polygons ¤
to_polygons() -> list[Polygon]

Convert each face to a Polygon.

to_step ¤
to_step(filepath: str, **kwargs) -> None

Export this Brep to a STEP file.

Parameters:

  • filepath (str) –

    Path to the output .step or .stp file.

to_stl ¤
to_stl(filepath: str, **kwargs) -> None

Export this Brep to an STL file.

Parameters:

  • filepath (str) –

    Path to the output .stl file.

to_tesselation ¤
to_tesselation(
    linear_deflection: float = 0.1, n: int = 16, n_curves: int = 64
) -> tuple[Mesh, list[Polyline]]

Create a tessellation of the Brep for visualization.

Returns a triangulated mesh and a list of boundary polylines. Matches the interface expected by compas_viewer's BRepObject.

Uses cached tessellation when available. Otherwise delegates to the active backend via the brep_tessellate pluggable and caches the result.

Parameters:

  • linear_deflection (float, default: 0.1 ) –

    Linear deflection passed to the backend tessellator.

  • n (int, default: 16 ) –

    Resolution for face tessellation.

  • n_curves (int, default: 64 ) –

    Number of samples per curved edge for boundary polylines.

to_viewmesh ¤
to_viewmesh(precision: float = 1e-06, n: int = 16) -> Mesh

Convert the Brep to a single mesh for visualization.

Uses cached tessellation if available, otherwise delegates to the active backend via the brep_tessellate pluggable.

Parameters:

  • precision (float, default: 1e-06 ) –

    Unused, kept for interface compatibility.

  • n (int, default: 16 ) –

    Resolution for tessellation.

transform ¤
transform(transformation: Transformation) -> None

Transform this Brep in-place by a transformation matrix.

Parameters:

trim ¤
trim(plane: Plane) -> None

Trim the Brep in-place with a plane.

Parameters:

  • plane (Plane) –

    The trimming plane.

trimmed ¤
trimmed(plane: Plane) -> Brep

Trim the Brep with a plane, keeping the back side (opposite to normal).

Parameters:

  • plane (Plane) –

    The trimming plane. The side the normal points away from is kept.

BrepEdge ¤

BrepEdge(
    start: BrepVertex,
    end: BrepVertex,
    curve: Line | Circle | Ellipse | NurbsCurve | None = None,
    domain: tuple[float, float] | None = None,
)

A Brep edge defined by start/end vertices and a 3D curve.

The curve is a Line, a Circle, an Ellipse, or a NurbsCurve.

An analytic curve (Circle / Ellipse) is an unbounded closed conic, so the edge also carries domain -- the parameter interval it actually runs over, in the parameter space :func:compas_brep.exchange.analytic_curve_point defines. A quarter-circle fillet edge and a full circular seam are the same Circle with different domains. Line and NurbsCurve carry their own extent, so their domain is None.

Attributes¤

centroid property ¤
centroid: Point

The length-weighted centroid of the edge curve.

curve_type property ¤
curve_type: str

This edge's tag in the exchange format's edge curve tag set.

domain property writable ¤
domain: tuple[float, float] | None

The parameter interval this edge runs over, for an analytic curve.

end_vertex property ¤
end_vertex: BrepVertex

Alias of :attr:last_vertex, for compatibility with compas_rhino.

is_arc property ¤
is_arc: bool

True for an edge running along part of a circle, not the whole of it.

is_circle property ¤
is_circle: bool

True for a full circular edge. A partial one is an arc -- see :attr:is_arc.

start_vertex property ¤
start_vertex: BrepVertex

Alias of :attr:first_vertex, for compatibility with compas_rhino.

type property ¤
type: int

One of the :class:compas.geometry.CurveType constants.

Methods:¤

sample_points ¤
sample_points(n: int = 64) -> list[Point]

Sample points along this edge for visualization.

For NurbsCurve edges, samples at n+1 parameter values (n segments). For Line edges, returns just the two endpoints.

Parameters:

  • n (int, default: 64 ) –

    Number of segments for curved edges. Defaults to 64.

to_line ¤
to_line() -> Line

The edge as a line between its two vertices.

For a non-linear edge this is the chord, not the curve. Matches the behaviour of compas_occ.

BrepError ¤

Represents a generic error in the Brep context.

BrepFace ¤

BrepFace(
    outer_loop: BrepLoop,
    surface: Plane
    | CylindricalSurface
    | SphericalSurface
    | ToroidalSurface
    | ConicalSurface
    | NurbsSurface
    | None = None,
    is_reversed: bool = False,
    domain_u: tuple[float, float] | None = None,
    domain_v: tuple[float, float] | None = None,
)

A Brep face defined by a surface and boundary loops.

The surface can be a Plane, CylindricalSurface, or NurbsSurface. The outer loop defines the face boundary; inner loops define holes.

Attributes¤

boundary property ¤
boundary: BrepLoop

Alias of :attr:outer_loop, for compatibility with compas_rhino.

holes property ¤
holes: list[BrepLoop]

The inner loops of this face.

is_bspline property ¤
is_bspline: bool

Alias of :attr:is_nurbs, for compatibility with compas.geometry.BrepFace.

native_face property ¤
native_face: object | None

The underlying backend face, or None for a face not backed by a kernel.

nurbssurface property ¤
nurbssurface: NurbsSurface

The underlying surface of this face as a NURBS surface.

Provided for compatibility with compas.geometry.BrepFace. Like the old implementations, this returns the unflipped underlying surface - it does not account for :attr:is_reversed. Prefer :meth:frame_at where a face normal is what is wanted.

surface_type property ¤
surface_type: str

Return the surface type as a string: 'plane', 'cylinder', 'sphere', 'torus', 'cone', or 'nurbs'.

type property ¤
type: int

One of the :class:compas.geometry.SurfaceType constants.

Methods:¤

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

The frame of the face at the given surface parameters.

The zaxis of the returned frame is the face normal: for a face whose :attr:is_reversed is True the underlying surface normal is flipped, so that opposite faces of a solid report opposite normals. Use :attr:surface directly to get the unflipped surface.

Parameters:

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

    The u parameter, in the parametrization of :attr:surface. Defaults to the middle of :attr:domain_u.

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

    The v parameter, in the parametrization of :attr:surface. Defaults to the middle of :attr:domain_v.

Returns:

  • class:`compas.geometry.Frame`

    A new frame; modifying it does not affect the face.

Notes

A planar face has no parametrization to speak of - :attr:surface is a :class:compas.geometry.Plane, which carries no x-direction - so for planar faces u and v are distances along the axes of the plane's own frame, measured from the plane's origin, and omitting them puts the frame on the face centroid rather than in the middle of the uv domain.

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

The outward normal of the face at the given surface parameters.

Accounts for :attr:is_reversed, see :meth:frame_at.

Returns:

  • class:`compas.geometry.Vector`

    A new vector; modifying it does not affect the face.

BrepFilletError ¤

Raised when a fillet operation has failed or had no result.

BrepInvalidError ¤

Raised when the process of re-constructing a Brep has resulted in an invalid Brep.

BrepLoop ¤

BrepLoop(
    edges: list[BrepEdge] | None = None,
    trims: list[BrepTrim] | None = None,
    is_outer: bool = True,
)

Pure Python implementation of a Brep loop.

A loop can store edges directly (legacy) or trims (STEP-inspired). When trims are present, edges are derived from them.

Attributes¤

edges property ¤
edges: list[BrepEdge]

The ordered list of edges in this loop.

If trims are present, returns their underlying edges. Singular trims contribute nothing — they have no edge. Otherwise returns the directly-stored edges (legacy path).

is_inner property ¤
is_inner: bool

True if this loop is an inner loop (a hole) of its face.

is_outer property writable ¤
is_outer: bool

True if this loop is the outer boundary of its face.

loop_type property ¤
loop_type: int

One of the :class:LoopType constants.

trims property ¤
trims: list[BrepTrim]

The ordered list of trims (coedges) in this loop.

BrepTrim ¤

BrepTrim(
    edge: BrepEdge | None,
    is_reversed: bool = False,
    curve_2d: NurbsCurve | None = None,
    vertex: BrepVertex | None = None,
)

A coedge: a directed usage of a BrepEdge within a BrepLoop on a BrepFace.

Inspired by STEP's ORIENTED_EDGE / PCURVE model. A trim wraps a shared BrepEdge with: - is_reversed: whether this usage traverses the edge backward - curve_2d: a NurbsCurve in the face surface's UV parameter space (pcurve)

The pcurve allows direct UV-space tessellation without 3D→UV inversion. The 3D curve and vertices are accessed via the underlying edge.

Attributes¤

curve property writable ¤
curve: NurbsCurve | None

The 2D parametric curve in the face's UV space (pcurve).

curve_2d property writable ¤
curve_2d: NurbsCurve | None

Alias for the 2D parametric curve (pcurve).

curve_3d property ¤
curve_3d: Any

The 3D curve from the underlying edge. None for a singular trim.

edge property ¤
edge: BrepEdge | None

The underlying shared BrepEdge, or None for a singular trim.

end_vertex property ¤
end_vertex: BrepVertex

End vertex in the trim's traversal direction.

is_reversed property ¤
is_reversed: bool

Whether this trim traverses the underlying edge backward.

is_singular property ¤
is_singular: bool

Whether this trim has no edge and collapses to a single vertex.

A sphere's poles are the canonical case: the trim spans the full u-range of the surface at v = min or v = max, but every point on it is the same point in 3D.

start_vertex property ¤
start_vertex: BrepVertex

Start vertex in the trim's traversal direction.

vertex property ¤
vertex: BrepVertex | None

The vertex a singular trim collapses to. None for an ordinary trim.

Methods:¤

sample_points ¤
sample_points(surface: Any, n: int = 64) -> list[Point]

Sample points along this trim for visualization.

When a pcurve is available, samples via pcurve → surface evaluation so the resulting polyline lies exactly on the tessellated surface mesh. Falls back to the 3D edge curve when no pcurve is present.

Parameters:

  • surface (Any) –

    The parent face's surface (needed for pcurve → 3D evaluation).

  • n (int, default: 64 ) –

    Number of segments. Defaults to 64.

BrepTrimmingError ¤

Raised when a trimming operation has failed or had no result.

LoopType ¤

Constants describing the role of a loop within its face.

Mirrors the loop types of Rhino.Geometry.BrepLoopType for the two cases compas_brep distinguishes.

NurbsCurve ¤

NurbsCurve(name: str | None = None)

A rational NURBS curve.

Parameters:

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

    The name of the curve.

Attributes¤

degree property ¤
degree: int

Degree of the curve.

domain property ¤
domain: tuple[float, float]

Parameter domain of the curve.

is_closed property ¤
is_closed: bool

True if the first and last control points coincide.

is_periodic property ¤
is_periodic: bool

Always False (simplified).

knots property ¤
knots: list[float]

Unique knot values.

knotvector property ¤
knotvector: list[float]

Full knot vector (knots repeated by multiplicities).

mults property ¤
mults: list[int]

Knot multiplicities.

points property ¤
points: list[Point]

Control points.

weights property ¤
weights: list[float]

Weights.

Methods:¤

copy ¤
copy() -> NurbsCurve

Return a deep copy.

frame_at ¤
frame_at(t: float) -> Frame

Frame at parameter t.

Parameters:

  • t (float) –

    Parameter value.

from_circle classmethod ¤
from_circle(circle: Circle) -> NurbsCurve

Create a rational NURBS circle (degree 2, 9 control points).

Parameters:

  • circle (Circle) –

    The circle.

from_ellipse classmethod ¤
from_ellipse(ellipse: Ellipse) -> NurbsCurve

Create a rational NURBS ellipse (degree 2, 9 control points).

Parameters:

  • ellipse (Ellipse) –

    The ellipse.

from_interpolation classmethod ¤
from_interpolation(points: list[Point], degree: int = 3) -> NurbsCurve

Create a NURBS curve that interpolates through given points.

Uses chord-length parameterization and scipy's make_interp_spline.

Parameters:

  • points (list[Point]) –

    Points to interpolate.

  • degree (int, default: 3 ) –

    Curve degree.

from_line classmethod ¤
from_line(line: Line) -> NurbsCurve

Create a degree-1 NURBS curve from a line.

Parameters:

  • line (Line) –

    The line.

from_parameters classmethod ¤
from_parameters(
    points: list[Point],
    weights: list[float],
    knots: list[float],
    mults: list[int] | None = None,
    degree: int = 3,
    multiplicities: list[int] | None = None,
) -> NurbsCurve

Create a NURBS curve from explicit parameters.

Parameters:

  • points (list[Point]) –

    Control points.

  • weights (list[float]) –

    Weights per control point.

  • knots (list[float]) –

    Unique knot values.

  • mults (list[int] | None, default: None ) –

    Multiplicities per knot.

  • degree (int, default: 3 ) –

    Curve degree.

from_points classmethod ¤
from_points(points: list[Point], degree: int = 3) -> NurbsCurve

Create a NURBS curve with given control points and clamped uniform knot vector.

Parameters:

  • points (list[Point]) –

    Control points.

  • degree (int, default: 3 ) –

    Curve degree.

length ¤
length() -> float

Approximate arc length by dense sampling.

point_at ¤
point_at(t: float) -> Point

Evaluate the curve at parameter t.

Parameters:

  • t (float) –

    Parameter value.

tangent_at ¤
tangent_at(t: float) -> Vector

Tangent vector at parameter t (unnormalized).

Uses finite differences on the rational curve.

Parameters:

  • t (float) –

    Parameter value.

to_linesegments ¤
to_linesegments(n: int = 100) -> list[Line]

Sample the curve into line segments.

Parameters:

  • n (int, default: 100 ) –

    Number of segments.

to_polyline ¤
to_polyline(n: int = 100) -> Polyline

Sample the curve into a polyline.

Parameters:

  • n (int, default: 100 ) –

    Number of segments.

transform ¤
transform(transformation: Transformation) -> None

Transform all control points in-place.

Parameters:

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: