Python API reference

Generated by Sphinx autodoc from the installed nurbforge package. The compiled extension nurbforge._core must be importable when the documentation is built (pip install -e ".[docs]", see CONTRIBUTING.md). For a task-oriented overview see the Python API overview.

On GitHub this page is only a stub – the reference itself is rendered on the documentation site.

nurbforge

Nurbforge - headless NURBS-based CAD kernel for scientific software.

The geometry kernel is implemented in C++ (nurbforge._core); this package adds Pythonic helpers, meshing via gmsh (nurbforge.mesh) and an optional LLM interface via Ollama (nurbforge.llm).

class nurbforge.Asphere

Bases: pybind11_object

Rotationally symmetric sag: conic + even (r^4, r^6, …) + odd (r, r^2, …) terms.

property conic
property curvature
property even
property is_conic
max_radius(self: nurbforge._core.Asphere) → float
property odd
sag(self: nurbforge._core.Asphere, r: SupportsFloat | SupportsIndex) → float
class nurbforge.BooleanOp

Bases: pybind11_object

Members:

Union

Intersection

Difference

Difference = <BooleanOp.Difference: 2>
Intersection = <BooleanOp.Intersection: 1>
Union = <BooleanOp.Union: 0>
BooleanOp.name -> str
property value
class nurbforge.CurveChamfer

Bases: pybind11_object

Chamfer (straight cut) between two curves.

property line

straight segment from point_a to point_b

property param_a

parameter of the chamfer point on a

property param_b

parameter of the chamfer point on b

property point_a

chamfer point on a (line start)

property point_b

chamfer point on b (line end)

property trimmed_a

kept part of a ending at point_a (None if trim=False)

property trimmed_b

kept part of b starting at point_b (None if trim=False)

class nurbforge.CurveCurveIntersection

Bases: pybind11_object

property distance
property point
property s
property t
class nurbforge.CurveEnd

Bases: pybind11_object

Members:

Start

End

End = <CurveEnd.End: 1>
Start = <CurveEnd.Start: 0>
CurveEnd.name -> str
property value
class nurbforge.CurveFillet

Bases: pybind11_object

Circular fillet between two planar curves.

property arc

exact rational arc from point_a to point_b

property center
property param_a

parameter of the tangent point on a

property param_b

parameter of the tangent point on b

property point_a
property point_b
property trimmed_a

kept part of a ending at point_a (None if trim=False)

property trimmed_b

kept part of b starting at point_b (None if trim=False)

class nurbforge.CurvePoint

Bases: pybind11_object

property distance
property point
property u
class nurbforge.CurveSurfaceIntersection

Bases: pybind11_object

property distance
property point
property t
property u
property v
class nurbforge.Extension

Bases: pybind11_object

Members:

Natural

Linear

Linear = <Extension.Linear: 1>
Natural = <Extension.Natural: 0>
Extension.name -> str
property value
class nurbforge.FittedSurface

Bases: pybind11_object

Result of fit_surface.

property max_error

largest distance of a point from the surface

property parameters

(u, v) of each point’s foot point

Type:

(n, 2) array

property rms_error

rms of the point distances

property surface

the fitted surface

exception nurbforge.GeometryError

Bases: ValueError

class nurbforge.HatchContour

Bases: pybind11_object

Closed contour: boundary of the region shrunk by distance.

property curves
property distance
property index

Index of the distance in contours.

property loop

First of loops.

property loops

several).

Type:

Loops it was offset from (merged contours

class nurbforge.HatchSegment

Bases: pybind11_object

Hatch segment inside the region bounded by the loops.

property end
property end_loop
property length
property line

Index k of the line n . p = phase + k * spacing.

property region

Outer loop of the region containing the segment.

property start
property start_loop
class nurbforge.IntersectionCurve

Bases: pybind11_object

property closed
property curve
property pcurve1
property pcurve2
property points
class nurbforge.LineFit

Bases: pybind11_object

Best-fit line (orthogonal regression).

property direction

unit direction

property max_deviation

largest perpendicular distance of a point from the line

property point

centroid of the points

property rms

root mean square of the perpendicular distances

class nurbforge.MassProperties

Bases: pybind11_object

Volume, centroid and inertia of a solid (unit density).

property centroid
property inertia

diagonal moments, off-diagonal -products.

Type:

Inertia tensor about the centroid (3 x 3)

property principal_axes

Unit axes as rows, in the order of principal_moments.

property principal_moments
property volume
class nurbforge.NurbsCurve

Bases: pybind11_object

clamped(self: nurbforge._core.NurbsCurve) → nurbforge._core.NurbsCurve

Same curve with a clamped knot vector.

property control_points
decompose_bezier(self: nurbforge._core.NurbsCurve) → list[nurbforge._core.NurbsCurve]

Bezier segments, each on its original parameter interval.

property degree
derivatives(self: nurbforge._core.NurbsCurve, u: SupportsFloat | SupportsIndex, order: SupportsInt | SupportsIndex = 1) → list[nurbforge._core.Vec3]
property domain
elevate_degree(self: nurbforge._core.NurbsCurve, times: SupportsInt | SupportsIndex = 1) → nurbforge._core.NurbsCurve

Degree elevation (shape-preserving); result is clamped.

evaluate(self: nurbforge._core.NurbsCurve, u: SupportsFloat | SupportsIndex) → nurbforge._core.Vec3
static from_points(degree: SupportsInt | SupportsIndex, control_points: Annotated[numpy.typing.ArrayLike, numpy.float64]) → nurbforge._core.NurbsCurve
insert_knot(self: nurbforge._core.NurbsCurve, u: SupportsFloat | SupportsIndex, times: SupportsInt | SupportsIndex = 1) → nurbforge._core.NurbsCurve
property is_clamped
property is_rational
property knots
reduce_degree(self: nurbforge._core.NurbsCurve, tolerance: SupportsFloat | SupportsIndex = 1e-10) → nurbforge._core.NurbsCurve

Degree reduction by one within tolerance (raises GeometryError otherwise).

refine_knots(self: nurbforge._core.NurbsCurve, knots: collections.abc.Sequence[SupportsFloat | SupportsIndex]) → nurbforge._core.NurbsCurve

Insert all given knots at once (shape-preserving).

remove_knot(self: nurbforge._core.NurbsCurve, u: SupportsFloat | SupportsIndex, times: SupportsInt | SupportsIndex = 1, tolerance: SupportsFloat | SupportsIndex = 1e-10) → nurbforge._core.NurbsCurve
reversed(self: nurbforge._core.NurbsCurve) → nurbforge._core.NurbsCurve
sample(self: nurbforge._core.NurbsCurve, n: SupportsInt | SupportsIndex = 100) → numpy.typing.NDArray[numpy.float64]
split(self: nurbforge._core.NurbsCurve, u: SupportsFloat | SupportsIndex) → tuple[nurbforge._core.NurbsCurve, nurbforge._core.NurbsCurve]

Split at u -> (left, right); both keep their parameter intervals.

sub_curve(self: nurbforge._core.NurbsCurve, u0: SupportsFloat | SupportsIndex, u1: SupportsFloat | SupportsIndex) → nurbforge._core.NurbsCurve
tangent(self: nurbforge._core.NurbsCurve, u: SupportsFloat | SupportsIndex) → nurbforge._core.Vec3
transformed(self: nurbforge._core.NurbsCurve, transform: nurbforge._core.Transform) → nurbforge._core.NurbsCurve
try_remove_knot(self: nurbforge._core.NurbsCurve, u: SupportsFloat | SupportsIndex, times: SupportsInt | SupportsIndex = 1, tolerance: SupportsFloat | SupportsIndex = 1e-10) → tuple[nurbforge._core.NurbsCurve, int]

Remove knot u up to times times within tolerance -> (curve, removed).

property weights
class nurbforge.NurbsSurface

Bases: pybind11_object

clamped(self: nurbforge._core.NurbsSurface) → nurbforge._core.NurbsSurface
property control_points
decompose_bezier(self: nurbforge._core.NurbsSurface) → list[nurbforge._core.NurbsSurface]

Bezier patches in row-major order (u span outer), original parameter rectangles.

property degree_u
property degree_v
derivatives(self: nurbforge._core.NurbsSurface, u: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex, order: SupportsInt | SupportsIndex = 1) → list[list[nurbforge._core.Vec3]]

Partial derivatives D[k][l] = d^(k+l)S/du^k dv^l for k + l <= order.

property domain_u
property domain_v
elevate_degree_u(self: nurbforge._core.NurbsSurface, times: SupportsInt | SupportsIndex = 1) → nurbforge._core.NurbsSurface
elevate_degree_v(self: nurbforge._core.NurbsSurface, times: SupportsInt | SupportsIndex = 1) → nurbforge._core.NurbsSurface
evaluate(self: nurbforge._core.NurbsSurface, u: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) → nurbforge._core.Vec3
first_derivatives(self: nurbforge._core.NurbsSurface, u: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) → Annotated[list[nurbforge._core.Vec3], 'FixedSize(3)']
iso_curve_u(self: nurbforge._core.NurbsSurface, u: SupportsFloat | SupportsIndex) → nurbforge._core.NurbsCurve
iso_curve_v(self: nurbforge._core.NurbsSurface, v: SupportsFloat | SupportsIndex) → nurbforge._core.NurbsCurve
property knots_u
property knots_v
normal(self: nurbforge._core.NurbsSurface, u: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) → nurbforge._core.Vec3
property num_u
property num_v
reduce_degree_u(self: nurbforge._core.NurbsSurface, tolerance: SupportsFloat | SupportsIndex = 1e-10) → nurbforge._core.NurbsSurface
reduce_degree_v(self: nurbforge._core.NurbsSurface, tolerance: SupportsFloat | SupportsIndex = 1e-10) → nurbforge._core.NurbsSurface
refine_knots_u(self: nurbforge._core.NurbsSurface, knots: collections.abc.Sequence[SupportsFloat | SupportsIndex]) → nurbforge._core.NurbsSurface
refine_knots_v(self: nurbforge._core.NurbsSurface, knots: collections.abc.Sequence[SupportsFloat | SupportsIndex]) → nurbforge._core.NurbsSurface
remove_knot_u(self: nurbforge._core.NurbsSurface, u: SupportsFloat | SupportsIndex, times: SupportsInt | SupportsIndex = 1, tolerance: SupportsFloat | SupportsIndex = 1e-10) → nurbforge._core.NurbsSurface
remove_knot_v(self: nurbforge._core.NurbsSurface, v: SupportsFloat | SupportsIndex, times: SupportsInt | SupportsIndex = 1, tolerance: SupportsFloat | SupportsIndex = 1e-10) → nurbforge._core.NurbsSurface
sample(self: nurbforge._core.NurbsSurface, nu: SupportsInt | SupportsIndex = 20, nv: SupportsInt | SupportsIndex = 20) → numpy.ndarray
split_u(self: nurbforge._core.NurbsSurface, u: SupportsFloat | SupportsIndex) → tuple[nurbforge._core.NurbsSurface, nurbforge._core.NurbsSurface]
split_v(self: nurbforge._core.NurbsSurface, v: SupportsFloat | SupportsIndex) → tuple[nurbforge._core.NurbsSurface, nurbforge._core.NurbsSurface]
sub_surface(self: nurbforge._core.NurbsSurface, u0: SupportsFloat | SupportsIndex, u1: SupportsFloat | SupportsIndex, v0: SupportsFloat | SupportsIndex, v1: SupportsFloat | SupportsIndex) → nurbforge._core.NurbsSurface
transformed(self: nurbforge._core.NurbsSurface, transform: nurbforge._core.Transform) → nurbforge._core.NurbsSurface
transposed(self: nurbforge._core.NurbsSurface) → nurbforge._core.NurbsSurface
try_remove_knot_u(self: nurbforge._core.NurbsSurface, u: SupportsFloat | SupportsIndex, times: SupportsInt | SupportsIndex = 1, tolerance: SupportsFloat | SupportsIndex = 1e-10) → tuple[nurbforge._core.NurbsSurface, int]
try_remove_knot_v(self: nurbforge._core.NurbsSurface, v: SupportsFloat | SupportsIndex, times: SupportsInt | SupportsIndex = 1, tolerance: SupportsFloat | SupportsIndex = 1e-10) → tuple[nurbforge._core.NurbsSurface, int]
property weights
class nurbforge.Parametrization

Bases: pybind11_object

Members:

Uniform

ChordLength

Centripetal

Centripetal = <Parametrization.Centripetal: 2>
ChordLength = <Parametrization.ChordLength: 1>
Uniform = <Parametrization.Uniform: 0>
Parametrization.name -> str
property value
class nurbforge.PlanarSection

Bases: pybind11_object

property loops
property normal
property origin
property s_axis
property t_axis
class nurbforge.Plane

Bases: pybind11_object

Infinite plane through point with normal normal.

distance(self: nurbforge._core.Plane, p: nurbforge._core.Vec3) → float
property normal
property point
class nurbforge.PlaneFit

Bases: pybind11_object

Best-fit plane (orthogonal regression).

property max_deviation

largest distance of a point from the plane

property plane

plane through the centroid, unit normal

property rms

root mean square of the distances

class nurbforge.ProjectedCurve

Bases: pybind11_object

A curve on a surface: 3D curve and p-curve.

property curve

3D curve on the surface.

property pcurve

(u, v, 0) in the surface’s parameter domain (same parameter as curve).

class nurbforge.RebuiltCurve

Bases: pybind11_object

property curve
property max_error

max distance to the input at equal parameters (dense samples)

class nurbforge.RebuiltSurface

Bases: pybind11_object

property max_error

max distance to the input at equal parameters (dense grid)

property surface
class nurbforge.SectionCurve

Bases: pybind11_object

Piece of a section loop on one face of a shell.

property curve

In plane coordinates (s, t, 0).

property curve3d
property exact
property face
normal(self: nurbforge._core.SectionCurve, t: SupportsFloat | SupportsIndex) → nurbforge._core.Vec3

Outward unit normal of the shell at parameter t.

property pcurve

(u, v, 0) on the source face’s surface.

class nurbforge.SectionLoop

Bases: pybind11_object

property area

> 0 outer loop, < 0 hole.

Type:

Signed area in (s, t)

property curves
class nurbforge.SectionOptions

Bases: pybind11_object

property fit_tolerance
property join_tolerance
property s_axis
class nurbforge.Shell

Bases: pybind11_object

Trimmed faces sewn along shared edges.

area(self: nurbforge._core.Shell, rel_tol: SupportsFloat | SupportsIndex = 1e-08) → float
components(self: nurbforge._core.Shell) → list[nurbforge._core.Shell]

Connected components as separate shells (outer boundary, void boundaries, lumps).

property edges
property face_labels
property faces
faces_labeled(self: nurbforge._core.Shell, label: str) → list[int]

Indices of the faces with this label.

free_edges(self: nurbforge._core.Shell) → list[int]
property is_closed
property is_consistently_oriented
mass_properties(self: nurbforge._core.Shell, rel_tol: SupportsFloat | SupportsIndex = 1e-08) → nurbforge._core.MassProperties

Volume, centroid and inertia tensor (about the centroid, unit density) of the solid.

non_manifold_edges(self: nurbforge._core.Shell) → list[int]
oriented(self: nurbforge._core.Shell) → nurbforge._core.Shell
static sew(faces: collections.abc.Sequence[nurbforge._core.TrimmedSurface], tolerance: SupportsFloat | SupportsIndex = 1e-06) → nurbforge._core.Shell
transformed(self: nurbforge._core.Shell, transform: nurbforge._core.Transform) → nurbforge._core.Shell

The shell mapped by an affine transform (mirrors keep the normals outward).

property vertices
volume(self: nurbforge._core.Shell, rel_tol: SupportsFloat | SupportsIndex = 1e-08) → float
with_face_labels(self: nurbforge._core.Shell, labels: collections.abc.Sequence[str]) → nurbforge._core.Shell

The same shell with one label per face (they survive Booleans, transforms and STEP).

class nurbforge.SurfaceCurvature

Bases: pybind11_object

property dir1
property dir2
property gaussian
property k1
property k2
property mean
property normal
class nurbforge.SurfaceFillet

Bases: pybind11_object

Rolling-ball fillet between two surfaces.

property contact1
property contact2
property pcurve1

contact1 as (u, v, 0) on s1

property pcurve2

contact2 as (u, v, 0) on s2

property spine

path of the ball centre

property surface

spine parameter

Type:

u

Type:

arc from contact1 (u=0) to contact2 (u=1), v

class nurbforge.SurfaceIntersection

Bases: pybind11_object

property curves
property points
class nurbforge.SurfaceIntersectionOptions

Bases: pybind11_object

property chord_tolerance
property fit_tolerance
property tolerance
class nurbforge.SurfacePoint

Bases: pybind11_object

property distance
property point
property u
property v
class nurbforge.SurfaceSide

Bases: pybind11_object

Members:

UMin

UMax

VMin

VMax

UMax = <SurfaceSide.UMax: 1>
UMin = <SurfaceSide.UMin: 0>
VMax = <SurfaceSide.VMax: 3>
VMin = <SurfaceSide.VMin: 2>
SurfaceSide.name -> str
property value
class nurbforge.SurfaceSurfacePoint

Bases: pybind11_object

property point
property u1
property u2
property v1
property v2
class nurbforge.SweepFrame

Bases: pybind11_object

Members:

RotationMinimizing

Fixed

Fixed = <SweepFrame.Fixed: 1>
RotationMinimizing = <SweepFrame.RotationMinimizing: 0>
SweepFrame.name -> str
property value
class nurbforge.SweepOptions

Bases: pybind11_object

property frame
property max_sections
property tolerance
property twist
class nurbforge.TangentLine

Bases: pybind11_object

Line segment tangent to curves.

property line

segment from point_a to point_b

property param_a

tangent parameter on the first curve (nan if it is a point)

property param_b

tangent parameter on the second curve

property point_a

tangent point on the first curve, or the given point

Type:

line start

property point_b

tangent point on the second curve

Type:

line end

class nurbforge.Tolerance

Bases: pybind11_object

Per-operation tolerances (length, parametric, angular).

property angular
property length
property parametric
class nurbforge.Transform

Bases: pybind11_object

apply(self: nurbforge._core.Transform, arg0: nurbforge._core.Vec3) → nurbforge._core.Vec3
apply_vector(self: nurbforge._core.Transform, arg0: nurbforge._core.Vec3) → nurbforge._core.Vec3
matrix(self: nurbforge._core.Transform) → Annotated[list[float], 'FixedSize(12)']
static mirror(point: nurbforge._core.Vec3, normal: nurbforge._core.Vec3) → nurbforge._core.Transform
static rotation(origin: nurbforge._core.Vec3, axis: nurbforge._core.Vec3, angle: SupportsFloat | SupportsIndex) → nurbforge._core.Transform
static scaling(*args, **kwargs)

Overloaded function.

  1. scaling(center: nurbforge._core.Vec3, factor: typing.SupportsFloat | typing.SupportsIndex) -> nurbforge._core.Transform

  2. scaling(center: nurbforge._core.Vec3, factors: nurbforge._core.Vec3) -> nurbforge._core.Transform

static translation(d: nurbforge._core.Vec3) → nurbforge._core.Transform
class nurbforge.TrimLoop

Bases: pybind11_object

Closed loop of parameter-space curves (x = u, y = v, z = 0).

property curves
polyline(self: nurbforge._core.TrimLoop, samples_per_span: SupportsInt | SupportsIndex = 16) → list[Annotated[list[float], 'FixedSize(2)']]
reversed(self: nurbforge._core.TrimLoop) → nurbforge._core.TrimLoop
signed_area(self: nurbforge._core.TrimLoop) → float
class nurbforge.TrimmedSurface

Bases: pybind11_object

area(self: nurbforge._core.TrimmedSurface, rel_tol: SupportsFloat | SupportsIndex = 1e-09) → float
boundary_curves(self: nurbforge._core.TrimmedSurface, tolerance: SupportsFloat | SupportsIndex = 1e-07) → list[list[nurbforge._core.NurbsCurve]]
contains(self: nurbforge._core.TrimmedSurface, u: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) → bool
flipped(self: nurbforge._core.TrimmedSurface) → nurbforge._core.TrimmedSurface

The same face with opposite orientation (normal flipped).

property holes
property is_untrimmed
property label

Face label (boundary condition / physical group); kept by Booleans, transforms, STEP.

property outer
property surface
transformed(self: nurbforge._core.TrimmedSurface, transform: nurbforge._core.Transform) → nurbforge._core.TrimmedSurface

The face mapped by an affine transform (loops and label kept; reflections keep the normal by flipping the face).

with_hole(self: nurbforge._core.TrimmedSurface, hole: nurbforge._core.TrimLoop) → nurbforge._core.TrimmedSurface
with_label(self: nurbforge._core.TrimmedSurface, label: str) → nurbforge._core.TrimmedSurface

The same face with the given label.

class nurbforge.Vec3

Bases: pybind11_object

to_tuple(self: nurbforge._core.Vec3) → tuple[float, float, float]
property x
property y
property z
class nurbforge.XYPolynomialSag

Bases: pybind11_object

sag(self: nurbforge._core.XYPolynomialSag, x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) → float
class nurbforge.ZernikeIndexing

Bases: pybind11_object

Members:

Fringe

Noll

Fringe = <ZernikeIndexing.Fringe: 0>
Noll = <ZernikeIndexing.Noll: 1>
ZernikeIndexing.name -> str
property value
class nurbforge.ZernikeSag

Bases: pybind11_object

property base
property coeffs
property indexing
property norm_radius
sag(self: nurbforge._core.ZernikeSag, x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex) → float
nurbforge.apply_pattern(geometry, transforms)[source]

Return one transformed copy of geometry per transform.

Parameters:
  • geometry (G)

  • transforms (Iterable[Transform])

Return type:

list[G]

nurbforge.approximate_curve(points: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], degree: typing.SupportsInt | typing.SupportsIndex, n_ctrl: typing.SupportsInt | typing.SupportsIndex, method: nurbforge._core.Parametrization = <Parametrization.Centripetal: 2>) → nurbforge._core.NurbsCurve
nurbforge.approximate_curve_tol(points: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], degree: typing.SupportsInt | typing.SupportsIndex, tolerance: typing.SupportsFloat | typing.SupportsIndex, method: nurbforge._core.Parametrization = <Parametrization.Centripetal: 2>) → nurbforge._core.NurbsCurve

Least squares with the fewest control points meeting the tolerance.

nurbforge.approximate_surface(points: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], degree_u: typing.SupportsInt | typing.SupportsIndex, degree_v: typing.SupportsInt | typing.SupportsIndex, ctrl_u: typing.SupportsInt | typing.SupportsIndex, ctrl_v: typing.SupportsInt | typing.SupportsIndex, method: nurbforge._core.Parametrization = <Parametrization.Centripetal: 2>) → nurbforge._core.NurbsSurface
nurbforge.arc_length(curve: nurbforge._core.NurbsCurve, u0: SupportsFloat | SupportsIndex, u1: SupportsFloat | SupportsIndex, rel_tol: SupportsFloat | SupportsIndex = 1e-10) → float
nurbforge.area(*args, **kwargs)

Overloaded function.

  1. area(surface: nurbforge._core.NurbsSurface, rel_tol: typing.SupportsFloat | typing.SupportsIndex = 1e-10) -> float

  2. area(surface: nurbforge._core.NurbsSurface, u0: typing.SupportsFloat | typing.SupportsIndex, u1: typing.SupportsFloat | typing.SupportsIndex, v0: typing.SupportsFloat | typing.SupportsIndex, v1: typing.SupportsFloat | typing.SupportsIndex, rel_tol: typing.SupportsFloat | typing.SupportsIndex = 1e-10) -> float

nurbforge.asphere_profile(asphere: nurbforge._core.Asphere, r_max: SupportsFloat | SupportsIndex, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsCurve
nurbforge.asphere_surface(asphere: nurbforge._core.Asphere, r_max: SupportsFloat | SupportsIndex, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsSurface

Surface of revolution; exact for pure conics.

nurbforge.blend_curves(a: nurbforge._core.NurbsCurve, end0: nurbforge._core.CurveEnd, b: nurbforge._core.NurbsCurve, end1: nurbforge._core.CurveEnd, continuity: SupportsInt | SupportsIndex = 2, tension: SupportsFloat | SupportsIndex = 1.0) → nurbforge._core.NurbsCurve

Smooth transition from an end of curve a to an end of curve b: G1 (cubic) or G2 (quintic, same curvature vectors). The blend leaves a and enters b; |C'| at the ends is tension x chord.

nurbforge.blend_surfaces(s0: nurbforge._core.NurbsSurface, side0: nurbforge._core.SurfaceSide, s1: nurbforge._core.NurbsSurface, side1: nurbforge._core.SurfaceSide, continuity: SupportsInt | SupportsIndex = 2, tension: SupportsFloat | SupportsIndex = 1.0, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsSurface

Blend surface between a side of s0 and a side of s1 continuing both with G0 (ruled), G1 (cubic across) or G2 (quintic across, same normal curvature). u runs along the edge of s0, v from s0 (v = 0) to s1 (v = 1); the edge of s1 is mapped linearly onto it in the orientation pairing the nearer points. The cross speed is tension x the mean edge distance. Exact when the weights do not vary across the sides, otherwise the boundary data are interpolated to tolerance.

nurbforge.boolean(a: nurbforge._core.Shell, b: nurbforge._core.Shell, op: nurbforge._core.BooleanOp, tolerance: SupportsFloat | SupportsIndex = 1e-06) → nurbforge._core.Shell

Boolean union / intersection / difference of two closed shells.

nurbforge.cap(shell: nf::Shell, tolerance: SupportsFloat | SupportsIndex = 1e-06, label: str = 'cap') → nf::Shell

Close the planar openings of a shell with planar faces trimmed exactly by the opening’s edges (coplanar nested openings: faces with holes). The new faces get label; the result is sewn and oriented outwards. Raises GeometryError for non-planar openings.

nurbforge.chamfer_corners(curve: nurbforge._core.NurbsCurve, distance: SupportsFloat | SupportsIndex, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsCurve

Chamfer every corner of a curve (polyline, polygon, …) with straight cuts at distance from the corner on both sides; one curve.

nurbforge.chamfer_curves(a: nurbforge._core.NurbsCurve, b: nurbforge._core.NurbsCurve, distance_a: SupportsFloat | SupportsIndex, distance_b: SupportsFloat | SupportsIndex | None = None, trim: bool = True, corner: nurbforge._core.Vec3 | None = None) → nurbforge._core.CurveChamfer

Chamfer between two intersecting curves: a straight cut from the point of a at distance distance_a from the corner to the point of b at distance_b (default: distance_a), on the kept parts (the longer sides of the intersection, as in fillet_curves). The curves need not be planar. Returns a CurveChamfer (line, parameters, trimmed curves).

nurbforge.chamfer_edges(shell: nf::Shell, edges: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], distance: typing.SupportsFloat | typing.SupportsIndex, label: str = 'chamfer', tolerance: typing.SupportsFloat | typing.SupportsIndex = 0.0, sizes: collections.abc.Sequence[tuple[nurbforge._core.Vec3, typing.SupportsFloat | typing.SupportsIndex]] = []) → nf::Shell

Chamfer edges of a closed shell: a ruled cut between the curves at (geodesic) distance from the edge on both faces. Grouping, vertices, variable sizes (point, distance) and restrictions as for fillet_edges; a corner of three chamfered edges (between planar faces) gets a planar triangle.

nurbforge.circle_loop(cu: SupportsFloat | SupportsIndex, cv: SupportsFloat | SupportsIndex, r: SupportsFloat | SupportsIndex) → nurbforge._core.TrimLoop
nurbforge.clamped_uniform_knots(degree: SupportsInt | SupportsIndex, n_ctrl: SupportsInt | SupportsIndex) → list[float]
nurbforge.closest_point(*args, **kwargs)

Overloaded function.

  1. closest_point(curve: nurbforge._core.NurbsCurve, point: nurbforge._core.Vec3, tolerance: nurbforge._core.Tolerance = Tolerance(length=0.000000, parametric=0.000000, angular=0.000000)) -> nurbforge._core.CurvePoint

Global closest point on a curve (point projection / inversion).

  1. closest_point(surface: nurbforge._core.NurbsSurface, point: nurbforge._core.Vec3, tolerance: nurbforge._core.Tolerance = Tolerance(length=0.000000, parametric=0.000000, angular=0.000000)) -> nurbforge._core.SurfacePoint

Global closest point on a surface.

nurbforge.closest_point_local(*args, **kwargs)

Overloaded function.

  1. closest_point_local(curve: nurbforge._core.NurbsCurve, point: nurbforge._core.Vec3, u0: typing.SupportsFloat | typing.SupportsIndex, tolerance: nurbforge._core.Tolerance = Tolerance(length=0.000000, parametric=0.000000, angular=0.000000)) -> nurbforge._core.CurvePoint

  2. closest_point_local(surface: nurbforge._core.NurbsSurface, point: nurbforge._core.Vec3, u0: typing.SupportsFloat | typing.SupportsIndex, v0: typing.SupportsFloat | typing.SupportsIndex, tolerance: nurbforge._core.Tolerance = Tolerance(length=0.000000, parametric=0.000000, angular=0.000000)) -> nurbforge._core.SurfacePoint

nurbforge.coons(c0: nurbforge._core.NurbsCurve, c1: nurbforge._core.NurbsCurve, d0: nurbforge._core.NurbsCurve, d1: nurbforge._core.NurbsCurve, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsSurface

Coons patch: S(u,0)=c0, S(u,1)=c1, S(0,v)=d0, S(1,v)=d1 (orientations fixed automatically). Exact also for rational boundaries (arcs) whose corner weights agree.

nurbforge.critical_heights(shell: nf::Shell, direction: nurbforge._core.Vec3, tolerance: nurbforge._core.Tolerance = Tolerance(length=0.000000, parametric=0.000000, angular=0.000000)) → list[float]

Sorted heights along direction at which the topology of the planar sections can change.

nurbforge.cross(arg0: nurbforge._core.Vec3, arg1: nurbforge._core.Vec3) → nurbforge._core.Vec3
nurbforge.curvature(curve: nurbforge._core.NurbsCurve, u: SupportsFloat | SupportsIndex) → float

Curvature |C' x C''| / |C'|^3.

nurbforge.data_parameters(points: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], method: nurbforge._core.Parametrization = <Parametrization.Centripetal: 2>) → list[float]
nurbforge.distance(arg0: nurbforge._core.Vec3, arg1: nurbforge._core.Vec3) → float
nurbforge.dot(arg0: nurbforge._core.Vec3, arg1: nurbforge._core.Vec3) → float
nurbforge.edges_between(shell: nf::Shell, label_a: str, label_b: str) → list[int]

Indices of the edges shared by a face labelled label_a and one labelled label_b.

nurbforge.extend(*args, **kwargs)

Overloaded function.

  1. extend(curve: nurbforge._core.NurbsCurve, end: nurbforge._core.CurveEnd, length: typing.SupportsFloat | typing.SupportsIndex, type: nurbforge._core.Extension = <Extension.Natural: 0>) -> nurbforge._core.NurbsCurve

Extend a curve at one end by an arc length; original parameters are kept.

  1. extend(surface: nurbforge._core.NurbsSurface, side: nurbforge._core.SurfaceSide, length: typing.SupportsFloat | typing.SupportsIndex, type: nurbforge._core.Extension = <Extension.Natural: 0>) -> nurbforge._core.NurbsSurface

Extend a surface across one side; original parameters are kept.

nurbforge.extrude(profile: nurbforge._core.NurbsCurve, direction: nurbforge._core.Vec3) → nurbforge._core.NurbsSurface
nurbforge.extrude_tapered(profile: nurbforge._core.NurbsCurve, direction: nurbforge._core.Vec3, angle: SupportsFloat | SupportsIndex, tolerance: SupportsFloat | SupportsIndex = 1e-07) → list[nurbforge._core.NurbsSurface]

Tapered (draft) extrusion of a planar profile normal to direction (its length is the height): the top is the profile offset by height*tan(angle), outwards for angle > 0. Corners are mitred; returns one ruled surface per smooth piece of the profile.

nurbforge.extrude_to_point(curve: nurbforge._core.NurbsCurve, apex: nurbforge._core.Vec3) → nurbforge._core.NurbsSurface

Cone over a curve: ruled surface from the curve (v = 0) to the apex (v = 1); exact, also for rational curves.

nurbforge.fillet_corners(curve: nurbforge._core.NurbsCurve, radius: SupportsFloat | SupportsIndex, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsCurve

Round every corner of a planar curve (polyline, polygon, …) with exact arcs; one G1 curve.

nurbforge.fillet_curves(a: nurbforge._core.NurbsCurve, b: nurbforge._core.NurbsCurve, radius: SupportsFloat | SupportsIndex, plane_normal: nurbforge._core.Vec3 = Vec3(0.000000, 0.000000, 1.000000), side_a: SupportsInt | SupportsIndex = 0, side_b: SupportsInt | SupportsIndex = 0, trim: bool = True, corner: nurbforge._core.Vec3 | None = None, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.CurveFillet

Circular fillet of the given radius between two coplanar intersecting curves. side_a / side_b: +1 = centre to the left of the curve’s direction seen from plane_normal, -1 = right, 0 = automatic (the corner between the kept parts, i.e. the longer sides of the intersection). Returns a CurveFillet (exact arc, tangent parameters, trimmed curves).

nurbforge.fillet_edges(shell: nf::Shell, edges: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], radius: typing.SupportsFloat | typing.SupportsIndex, label: str = 'fillet', tolerance: typing.SupportsFloat | typing.SupportsIndex = 0.0, sizes: collections.abc.Sequence[tuple[nurbforge._core.Vec3, typing.SupportsFloat | typing.SupportsIndex]] = []) → nf::Shell

Round edges of a closed shell with a rolling-ball fillet (convex edges lose, concave edges gain material). Edges between the same two faces are filleted as one chain. Where chains meet at a vertex of three faces: tangent chains continue each other, two chains are mitred (trimmed by each other), three chains get a spherical corner patch; a chain ending alone is trimmed by the third face. Variable radius: sizes = [(point, radius), …] at points on the selected edges, smooth (C2) in between, constant beyond; chains without points use radius. New faces are labelled label.

nurbforge.fillet_surfaces(s1: nurbforge._core.NurbsSurface, s2: nurbforge._core.NurbsSurface, radius: SupportsFloat | SupportsIndex, side1: SupportsInt | SupportsIndex = 1, side2: SupportsInt | SupportsIndex = 1, tolerance: SupportsFloat | SupportsIndex = 1e-06, offset_tolerance: SupportsFloat | SupportsIndex = 0.0, max_sections: SupportsInt | SupportsIndex = 1025, near: nurbforge._core.Vec3 | None = None) → nurbforge._core.SurfaceFillet

Rolling-ball fillet of radius r between two surfaces. side1 / side2 = +1 put the ball on the side of the normal S_u x S_v of s1 / s2, -1 on the opposite side; near selects the spine nearest to a point if there are several. Returns a SurfaceFillet (surface, spine, contact curves, p-curves on s1 / s2).

nurbforge.fit_line(points: Annotated[numpy.typing.ArrayLike, numpy.float64]) → nurbforge._core.LineFit

Best-fit line through points (n, 3) by orthogonal regression (minimal sum of squared perpendicular distances): centroid, unit direction, max and rms deviation.

nurbforge.fit_plane(points: Annotated[numpy.typing.ArrayLike, numpy.float64]) → nurbforge._core.PlaneFit

Best-fit plane through points (n, 3) by orthogonal regression: plane through the centroid with unit normal, max and rms deviation.

nurbforge.fit_surface(points: Annotated[numpy.typing.ArrayLike, numpy.float64], num_u: SupportsInt | SupportsIndex = 0, num_v: SupportsInt | SupportsIndex = 0, degree_u: SupportsInt | SupportsIndex = 3, degree_v: SupportsInt | SupportsIndex = 3, smoothing: SupportsFloat | SupportsIndex = 0.001, iterations: SupportsInt | SupportsIndex = 2, base: nurbforge._core.NurbsSurface | None = None, boundary: collections.abc.Sequence[nurbforge._core.NurbsCurve] = []) → nurbforge._core.FittedSurface

Fit a B-spline surface (domain [0, 1]^2) to unordered points (n, 3): least squares plus smoothing x thin-plate energy (relative weight; 1e-3 barely changes smooth data, 0.1-1 smooths noise), then iterations rounds of parameter correction. Parameters from the best-fit plane (height fields), from base (closest points), or from the Coons patch of four boundary curves [c0, c1, d0, d1], which are then interpolated exactly. num_u/num_v = 0: about sqrt(n / 4). Returns FittedSurface (surface, max_error, rms_error, parameters).

nurbforge.from_step(text: str, *, unit: str = 'mm', tolerance: SupportsFloat | SupportsIndex = 1e-06, skip_unsupported: bool = False) → list[nurbforge._core.Shell]

Read shells from STEP file contents (see read_step).

nurbforge.from_step_named(text: str, *, unit: str = 'mm', tolerance: SupportsFloat | SupportsIndex = 1e-06, skip_unsupported: bool = False) → list

As from_step, as a list of (name, Shell).

nurbforge.gordon(u_curves: collections.abc.Sequence[nurbforge._core.NurbsCurve], v_curves: collections.abc.Sequence[nurbforge._core.NurbsCurve], tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsSurface

Gordon surface through a consistent curve network.

nurbforge.grid_pattern(step_a: nurbforge._core.Vec3, count_a: SupportsInt | SupportsIndex, step_b: nurbforge._core.Vec3, count_b: SupportsInt | SupportsIndex) → list[nurbforge._core.Transform]
nurbforge.hatch(loops: object, direction: collections.abc.Sequence, spacing: SupportsFloat | SupportsIndex, *, phase: SupportsFloat | SupportsIndex = 0.0, contours: collections.abc.Sequence[SupportsFloat | SupportsIndex] = [], min_length: SupportsFloat | SupportsIndex = 0.0, tolerance: SupportsFloat | SupportsIndex = 0.0, contour_tolerance: SupportsFloat | SupportsIndex = 0.0) → tuple[list[nurbforge._core.HatchSegment], list[nurbforge._core.HatchContour]]

Hatch and contour lines of the region bounded by closed planar loops (region on the left).

loops: a PlanarSection, its loops, or closed chains of curves in the xy plane (a single closed curve counts as a loop). Lines n . p = phase + k * spacing along direction (2 or 3 components, z ignored), n = (-d.y, d.x). Returns (segments, contours): HatchSegment list sorted by line and position, and one HatchContour per loop and inward offset distance in contours.

nurbforge.hollow(shell: nf::Shell, thickness: SupportsFloat | SupportsIndex, open_labels: collections.abc.Sequence[str] = [], tolerance: SupportsFloat | SupportsIndex = 1e-06) → nf::Shell

Hollow a smooth closed shell to a wall of the given thickness: an inner void, or - with open_labels - removing the faces with these labels and thickening the rest inwards.

nurbforge.integrate(f: collections.abc.Callable[[float], SupportsFloat | SupportsIndex], a: SupportsFloat | SupportsIndex, b: SupportsFloat | SupportsIndex, rel_tol: SupportsFloat | SupportsIndex = 1e-10, breaks: collections.abc.Sequence[SupportsFloat | SupportsIndex] = [], abs_tol: SupportsFloat | SupportsIndex = 0.0) → float

Globally adaptive Gauss-Kronrod integral of f over [a, b].

nurbforge.interpolate_curve(points: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], degree: typing.SupportsInt | typing.SupportsIndex = 3, method: nurbforge._core.Parametrization = <Parametrization.Centripetal: 2>, end_derivatives: tuple[nurbforge._core.Vec3, nurbforge._core.Vec3] | None = None) → nurbforge._core.NurbsCurve

Global interpolation through points (n, 3); optional (C’(0), C’(1)).

nurbforge.interpolate_on_surface(surface: nurbforge._core.NurbsSurface, points: Annotated[numpy.typing.ArrayLike, numpy.float64], degree: SupportsInt | SupportsIndex = 3, uv: bool = False, tolerance: SupportsFloat | SupportsIndex = 1e-06) → nurbforge._core.ProjectedCurve

Curve on a surface through points (n, 3): projected onto the surface (or (u, v, 0) parameter points if uv=True), interpolated in the parameter domain; returns ProjectedCurve(curve, pcurve) with the 3D curve within tolerance of S(pcurve(t)).

nurbforge.interpolate_surface(points: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], degree_u: typing.SupportsInt | typing.SupportsIndex = 3, degree_v: typing.SupportsInt | typing.SupportsIndex = 3, method: nurbforge._core.Parametrization = <Parametrization.Centripetal: 2>) → nurbforge._core.NurbsSurface

Interpolate a point grid (nu, nv, 3).

nurbforge.intersect(*args, **kwargs)

Overloaded function.

  1. intersect(a: nurbforge._core.NurbsCurve, b: nurbforge._core.NurbsCurve, tolerance: nurbforge._core.Tolerance = Tolerance(length=0.000000, parametric=0.000000, angular=0.000000)) -> list[nurbforge._core.CurveCurveIntersection]

All intersection points of two curves, sorted by the parameter on a.

  1. intersect(curve: nurbforge._core.NurbsCurve, surface: nurbforge._core.NurbsSurface, tolerance: nurbforge._core.Tolerance = Tolerance(length=0.000000, parametric=0.000000, angular=0.000000)) -> list[nurbforge._core.CurveSurfaceIntersection]

All intersection points of a curve and a surface, sorted by the curve parameter.

  1. intersect(a: nurbforge._core.NurbsSurface, b: nurbforge._core.NurbsSurface, options: nurbforge._core.SurfaceIntersectionOptions = <nurbforge._core.SurfaceIntersectionOptions object at 0x7a587c7ff770>) -> nurbforge._core.SurfaceIntersection

Surface/surface intersection: curves (3D + p-curves on both surfaces) and touching points.

  1. intersect(curve: nurbforge._core.NurbsCurve, plane: nurbforge._core.Plane, tolerance: nurbforge._core.Tolerance = Tolerance(length=0.000000, parametric=0.000000, angular=0.000000)) -> list[nurbforge._core.CurveSurfaceIntersection]

Intersection points of a curve with a plane.

nurbforge.is_extrusion_band(shell: nf::Shell, direction: nurbforge._core.Vec3, h0: SupportsFloat | SupportsIndex, h1: SupportsFloat | SupportsIndex, tolerance: nurbforge._core.Tolerance = Tolerance(length=0.000000, parametric=0.000000, angular=0.000000)) → bool

True if all faces meeting the band h0 < p . direction < h1 are parallel to direction there.

nurbforge.join(a: nurbforge._core.NurbsCurve, b: nurbforge._core.NurbsCurve, tolerance: SupportsFloat | SupportsIndex = 1e-10) → nurbforge._core.NurbsCurve

Join curve b to the end of curve a (gap <= tolerance).

nurbforge.join_u(a: nurbforge._core.NurbsSurface, b: nurbforge._core.NurbsSurface, tolerance: SupportsFloat | SupportsIndex = 1e-10) → nurbforge._core.NurbsSurface
nurbforge.join_v(a: nurbforge._core.NurbsSurface, b: nurbforge._core.NurbsSurface, tolerance: SupportsFloat | SupportsIndex = 1e-10) → nurbforge._core.NurbsSurface
nurbforge.length(curve: nurbforge._core.NurbsCurve, rel_tol: SupportsFloat | SupportsIndex = 1e-10) → float

Total arc length of a curve.

nurbforge.linear_pattern(step: nurbforge._core.Vec3, count: SupportsInt | SupportsIndex) → list[nurbforge._core.Transform]
nurbforge.loft(*args, **kwargs)

Overloaded function.

  1. loft(sections: collections.abc.Sequence[nurbforge._core.NurbsCurve], degree_v: typing.SupportsInt | typing.SupportsIndex = 3, method: nurbforge._core.Parametrization = <Parametrization.Centripetal: 2>) -> nurbforge._core.NurbsSurface

Skinned surface through section curves (u along the sections, v across them).

  1. loft(sections: collections.abc.Sequence[nurbforge._core.NurbsCurve], degree_v: typing.SupportsInt | typing.SupportsIndex, v_params: collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex]) -> nurbforge._core.NurbsSurface

nurbforge.loft_parameters(sections: collections.abc.Sequence[nurbforge._core.NurbsCurve], method: nurbforge._core.Parametrization = <Parametrization.Centripetal: 2>) → list[float]
nurbforge.make_arc(center: nurbforge._core.Vec3, x_axis: nurbforge._core.Vec3, y_axis: nurbforge._core.Vec3, radius: SupportsFloat | SupportsIndex, start_angle: SupportsFloat | SupportsIndex, end_angle: SupportsFloat | SupportsIndex) → nurbforge._core.NurbsCurve
nurbforge.make_arc_3pt(p0: nurbforge._core.Vec3, p1: nurbforge._core.Vec3, p2: nurbforge._core.Vec3) → nurbforge._core.NurbsCurve

Circular arc from p0 through p1 to p2.

nurbforge.make_arc_tangent(start: nurbforge._core.Vec3, tangent: nurbforge._core.Vec3, end: nurbforge._core.Vec3) → nurbforge._core.NurbsCurve

Exact circular arc from start, leaving it in the direction tangent, to end (sweep between 0 and 360 degrees). Raises GeometryError if end lies on the tangent line.

nurbforge.make_bilinear(p00: nurbforge._core.Vec3, p10: nurbforge._core.Vec3, p01: nurbforge._core.Vec3, p11: nurbforge._core.Vec3) → nurbforge._core.NurbsSurface
nurbforge.make_box(corner: nurbforge._core.Vec3, size: nurbforge._core.Vec3) → nurbforge._core.Shell

Axis-aligned box (closed Shell, outward normals) with a corner and edge lengths.

nurbforge.make_circle(center: nurbforge._core.Vec3, normal: nurbforge._core.Vec3, radius: SupportsFloat | SupportsIndex) → nurbforge._core.NurbsCurve
nurbforge.make_circle_3pt(p0: nurbforge._core.Vec3, p1: nurbforge._core.Vec3, p2: nurbforge._core.Vec3) → nurbforge._core.NurbsCurve

Full circle through three points (starts at p0, runs through p1 and p2).

nurbforge.make_compatible(curves: collections.abc.Sequence[nurbforge._core.NurbsCurve]) → list[nurbforge._core.NurbsCurve]

Common degree, knot vector and domain [0, 1] for all curves.

nurbforge.make_cone(base: nurbforge._core.Vec3, axis: nurbforge._core.Vec3, r0: SupportsFloat | SupportsIndex, r1: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex) → nurbforge._core.Shell

Frustum: radius r0 at the base, r1 at the top; one radius may be 0 (apex).

nurbforge.make_cylinder(base: nurbforge._core.Vec3, axis: nurbforge._core.Vec3, radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex) → nurbforge._core.Shell

Cylinder with the base disc centred at base along axis.

nurbforge.make_helix(axis_point: nurbforge._core.Vec3, axis: nurbforge._core.Vec3, start: nurbforge._core.Vec3, pitch: SupportsFloat | SupportsIndex, turns: SupportsFloat | SupportsIndex, end_radius: SupportsFloat | SupportsIndex = -1.0, left_handed: bool = False, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsCurve

Helix / conical helix / planar spiral starting at start, parameter = turns; C2 quintic within tolerance of the exact curve. end_radius < 0: cylindrical.

nurbforge.make_line(p0: nurbforge._core.Vec3, p1: nurbforge._core.Vec3) → nurbforge._core.NurbsCurve
nurbforge.make_pipe(*args, **kwargs)

Overloaded function.

  1. make_pipe(path: nurbforge._core.NurbsCurve, radius: typing.SupportsFloat | typing.SupportsIndex, end_radius: typing.SupportsFloat | typing.SupportsIndex = -1.0, tolerance: typing.SupportsFloat | typing.SupportsIndex = 1e-06) -> nf::Shell

Solid pipe along a path: circular cross-section (radius varying linearly to end_radius if given), planar end faces. Faces labelled ‘wall’, ‘inlet’, ‘outlet’; a closed path gives a ring.

  1. make_pipe(path: nurbforge._core.NurbsCurve, radius: collections.abc.Callable[[float], typing.SupportsFloat | typing.SupportsIndex], tolerance: typing.SupportsFloat | typing.SupportsIndex = 1e-06) -> nf::Shell

Solid pipe whose radius is the function radius(t) of the normalised path parameter t in [0, 1] (smooth and positive).

nurbforge.make_polygon(center: nurbforge._core.Vec3, normal: nurbforge._core.Vec3, radius: SupportsFloat | SupportsIndex, n: SupportsInt | SupportsIndex, x_axis: nurbforge._core.Vec3 = Vec3(0.000000, 0.000000, 0.000000)) → nurbforge._core.NurbsCurve

Closed regular polygon with n vertices on the circle of the given radius (first vertex along x_axis).

nurbforge.make_polyline(points: collections.abc.Sequence[nurbforge._core.Vec3]) → nurbforge._core.NurbsCurve
nurbforge.make_rectangle(origin: nurbforge._core.Vec3, edge_u: nurbforge._core.Vec3, edge_v: nurbforge._core.Vec3) → nurbforge._core.NurbsSurface
nurbforge.make_rectangle_curve(origin: nurbforge._core.Vec3, edge_u: nurbforge._core.Vec3, edge_v: nurbforge._core.Vec3) → nurbforge._core.NurbsCurve

Closed rectangle outline (degree 1).

nurbforge.make_sphere(center: nurbforge._core.Vec3, radius: SupportsFloat | SupportsIndex) → nurbforge._core.Shell
nurbforge.make_torus(center: nurbforge._core.Vec3, axis: nurbforge._core.Vec3, major_radius: SupportsFloat | SupportsIndex, minor_radius: SupportsFloat | SupportsIndex) → nurbforge._core.Shell
nurbforge.match_surface(surface: nurbforge._core.NurbsSurface, side: nurbforge._core.SurfaceSide, target: nurbforge._core.NurbsSurface, target_side: nurbforge._core.SurfaceSide, continuity: SupportsInt | SupportsIndex = 2, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsSurface

Modify a surface near one side so that it joins the target’s side with G0, G1 or G2 continuity: the first continuity + 1 control rows are replaced (after refinement), the opposite side and its cross derivatives are kept. Same parameter directions and domain.

nurbforge.merge_faces(shell: nf::Shell, tolerance: SupportsFloat | SupportsIndex = 1e-06) → nf::Shell

Defeaturing: merge adjacent faces with the same label lying on the same surface (pieces of one split face, or coplanar planar faces with the same normal) into one face.

nurbforge.norm(arg0: nurbforge._core.Vec3) → float
nurbforge.offset_curve(curve: nurbforge._core.NurbsCurve, distance: SupportsFloat | SupportsIndex, plane_normal: nurbforge._core.Vec3 = Vec3(0.000000, 0.000000, 1.000000), tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsCurve

Planar offset c(t) + d * normalize(plane_normal x c’(t)) as a cubic B-spline fitted to the tolerance (parameters kept). Raises GeometryError at cusps (|d| >= radius of curvature on the concave side), corners or non-planar curves.

nurbforge.offset_on_surface(surface: nurbforge._core.NurbsSurface, curve: object, distance: SupportsFloat | SupportsIndex, tolerance: SupportsFloat | SupportsIndex = 1e-06) → nurbforge._core.ProjectedCurve

Geodesic offset of a curve within a surface: curve is its p-curve (u, v, 0) or a ProjectedCurve; positive distances go to the left of the curve seen from the normal S_u x S_v. Returns ProjectedCurve(curve, pcurve) within tolerance.

nurbforge.offset_surface(surface: nurbforge._core.NurbsSurface, distance: SupportsFloat | SupportsIndex, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsSurface

Offset surface S(u,v) + d * N(u,v) as a quintic tensor-product spline fitted to the tolerance (parameters kept). Raises GeometryError if d reaches a radius of curvature.

nurbforge.parameter_at_length(curve: nurbforge._core.NurbsCurve, s: SupportsFloat | SupportsIndex, rel_tol: SupportsFloat | SupportsIndex = 1e-10) → float
nurbforge.pipe_surface(path: nurbforge._core.NurbsCurve, radius: collections.abc.Callable[[float], typing.SupportsFloat | typing.SupportsIndex], options: nurbforge._core.SweepOptions = <nurbforge._core.SweepOptions object at 0x7a587c7f8030>) → nurbforge._core.NurbsSurface

Pipe wall: a circle of radius radius(t) (t in [0, 1] along the path) swept with the rotation-minimising frame; u around the circle, v along the path.

nurbforge.planar_section(surface: nurbforge._core.NurbsSurface, plane: nurbforge._core.Plane, options: nurbforge._core.SurfaceIntersectionOptions = <nurbforge._core.SurfaceIntersectionOptions object at 0x7a587c6084b0>) → nurbforge._core.SurfaceIntersection

Section of a surface with a plane (pcurve2 in the plane’s in-plane coordinates).

nurbforge.planar_sections(surface: nurbforge._core.NurbsSurface, plane: nurbforge._core.Plane, spacing: SupportsFloat | SupportsIndex, count: SupportsInt | SupportsIndex, options: nurbforge._core.SurfaceIntersectionOptions = <nurbforge._core.SurfaceIntersectionOptions object at 0x7a587c608730>) → list[nurbforge._core.SurfaceIntersection]
nurbforge.point_in_shell(shell: nurbforge._core.Shell, point: nurbforge._core.Vec3, tolerance: SupportsFloat | SupportsIndex = 1e-06) → bool

True if the point lies inside the closed shell (ray casting).

nurbforge.polar_pattern(axis_point: nurbforge._core.Vec3, axis_dir: nurbforge._core.Vec3, count: SupportsInt | SupportsIndex, total_angle: SupportsFloat | SupportsIndex) → list[nurbforge._core.Transform]
nurbforge.polygon_loop(points: collections.abc.Sequence[Annotated[collections.abc.Sequence[SupportsFloat | SupportsIndex], 'FixedSize(2)']]) → nurbforge._core.TrimLoop
nurbforge.project_curve(curve: nurbforge._core.NurbsCurve, surface: nurbforge._core.NurbsSurface, direction: nurbforge._core.Vec3 = Vec3(0.000000, 0.000000, 0.000000), tolerance: SupportsFloat | SupportsIndex = 1e-06) → nurbforge._core.ProjectedCurve

Project a curve onto a surface along its normal (direction zero) or along direction; returns ProjectedCurve(curve, pcurve) within tolerance of the exact projection.

nurbforge.project_to_plane(*args, **kwargs)

Overloaded function.

  1. project_to_plane(curve: nurbforge._core.NurbsCurve, plane: nurbforge._core.Plane, direction: nurbforge._core.Vec3 = Vec3(0.000000, 0.000000, 0.000000)) -> nurbforge._core.NurbsCurve

Exact parallel projection of a curve onto a plane along direction (zero: along the plane normal, i.e. orthogonal projection).

  1. project_to_plane(surface: nurbforge._core.NurbsSurface, plane: nurbforge._core.Plane, direction: nurbforge._core.Vec3 = Vec3(0.000000, 0.000000, 0.000000)) -> nurbforge._core.NurbsSurface

Exact parallel projection of a surface onto a plane.

nurbforge.rail_revolve(profile: nurbforge._core.NurbsCurve, rail: nurbforge._core.NurbsCurve, axis_point: nurbforge._core.Vec3, axis_dir: nurbforge._core.Vec3, scale_height: bool = False, options: nurbforge._core.SweepOptions = <nurbforge._core.SweepOptions object at 0x7a587c6180f0>) → nurbforge._core.NurbsSurface

Revolve a profile about an axis while its end nearer to the rail follows the rail (radial scaling about the axis; scale_height: also axial scaling about the axis point). E.g. a reflector with a non-round rim.

nurbforge.read_step(path: object, *, unit: str = 'mm', tolerance: SupportsFloat | SupportsIndex = 1e-06, skip_unsupported: bool = False) → list[nurbforge._core.Shell]

Read the B-rep solids and surface models of a STEP file (native reader) as a list of Shells, converted to unit (‘mm’, ‘cm’, ‘m’, ‘inch’, ‘um’). Analytic surfaces (plane, cylinder, cone, sphere, torus) become exact NURBS patches; trim loops are rebuilt in parameter space. tolerance is the sewing tolerance. Unsupported entities raise GeometryError unless skip_unsupported (the faces are then skipped with a warning).

nurbforge.read_step_named(path: object, *, unit: str = 'mm', tolerance: SupportsFloat | SupportsIndex = 1e-06, skip_unsupported: bool = False) → list

As read_step, as a list of (name, Shell): the solid name (write_step(…, names=…)), else the product name.

nurbforge.rebuild_curve(curve: nurbforge._core.NurbsCurve, num_ctrl: SupportsInt | SupportsIndex, degree: SupportsInt | SupportsIndex = 3) → nurbforge._core.RebuiltCurve

Rebuild a curve as a non-rational B-spline with num_ctrl control points and uniform knots on the same domain (least squares, parametrisation kept); returns RebuiltCurve with the max error.

nurbforge.rebuild_surface(surface: nurbforge._core.NurbsSurface, num_u: SupportsInt | SupportsIndex, num_v: SupportsInt | SupportsIndex, degree_u: SupportsInt | SupportsIndex = 3, degree_v: SupportsInt | SupportsIndex = 3) → nurbforge._core.RebuiltSurface

Rebuild a surface with num_u x num_v control points and uniform knots on the same domain; returns RebuiltSurface with the max error.

nurbforge.rectangle_loop(u0: SupportsFloat | SupportsIndex, u1: SupportsFloat | SupportsIndex, v0: SupportsFloat | SupportsIndex, v1: SupportsFloat | SupportsIndex) → nurbforge._core.TrimLoop
nurbforge.reference()[source]

The compact API reference for language models and coding agents (Markdown): conventions, a worked example and every public function, class and LLM tool with signature and description. python -m nurbforge prints it.

Return type:

str

nurbforge.region_area(region: object) → float

Area of a planar region (outer loops minus holes; Green’s theorem on the exact curves).

nurbforge.region_boolean(a: object, b: object, op: nf::BooleanOp, tolerance: SupportsFloat | SupportsIndex = 1e-09) → list[list[nurbforge._core.NurbsCurve]]

Union / intersection / difference of planar regions in the xy plane. A region is a PlanarSection, or a list of loops: closed curves, lists of curves running head to tail, or SectionLoops (nested loops: holes). Returns the result as a list of loops (lists of exact curves; outer counter-clockwise, holes clockwise).

nurbforge.remove_holes(shell: nf::Shell, max_size: SupportsFloat | SupportsIndex, tolerance: SupportsFloat | SupportsIndex = 1e-06) → nf::Shell

Defeaturing: fill the holes (through or blind) of a closed shell whose loops are smaller than max_size across; the faces of the removed features are deleted.

nurbforge.reparametrize(curve: nurbforge._core.NurbsCurve, a: SupportsFloat | SupportsIndex, b: SupportsFloat | SupportsIndex) → nurbforge._core.NurbsCurve
nurbforge.revolve(profile: nurbforge._core.NurbsCurve, axis_point: nurbforge._core.Vec3, axis_dir: nurbforge._core.Vec3, angle: SupportsFloat | SupportsIndex) → nurbforge._core.NurbsSurface
nurbforge.ribbon(curve: nurbforge._core.NurbsCurve, width: SupportsFloat | SupportsIndex, plane_normal: nurbforge._core.Vec3 = Vec3(0.000000, 0.000000, 1.000000), tolerance: SupportsFloat | SupportsIndex = 1e-07) → list[nurbforge._core.NurbsSurface]

Planar ribbon: ruled surfaces between a curve and its offset by width (left of the curve seen from the normal’s tip), mitred at corners; one surface per smooth piece.

nurbforge.ruled(c0: nurbforge._core.NurbsCurve, c1: nurbforge._core.NurbsCurve) → nurbforge._core.NurbsSurface
nurbforge.sag_surface(f: collections.abc.Callable[[float, float], SupportsFloat | SupportsIndex], x0: SupportsFloat | SupportsIndex, x1: SupportsFloat | SupportsIndex, y0: SupportsFloat | SupportsIndex, y1: SupportsFloat | SupportsIndex, degree: SupportsInt | SupportsIndex = 3, tolerance: SupportsFloat | SupportsIndex = 1e-07, max_spans: SupportsInt | SupportsIndex = 256) → nurbforge._core.NurbsSurface

Graph surface z = f(x, y) over a rectangle, fitted to the tolerance.

nurbforge.section(shell: nf::Shell, plane: nurbforge._core.Plane, options: nurbforge._core.SectionOptions = <nurbforge._core.SectionOptions object at 0x7a587c609eb0>) → nurbforge._core.PlanarSection

Section of a closed shell with a plane: closed loops oriented with the solid on the left (outer counter-clockwise, holes clockwise in the plane coordinates).

nurbforge.split(*args, **kwargs)

Overloaded function.

  1. split(surface: nurbforge._core.NurbsSurface, cutter: nurbforge._core.NurbsSurface, tolerance: nurbforge._core.Tolerance = Tolerance(length=0.000000, parametric=0.000000, angular=0.000000)) -> list[nurbforge._core.TrimmedSurface]

Split a surface along its intersection curves with another surface into trimmed regions.

  1. split(surface: nurbforge._core.NurbsSurface, pcurves: collections.abc.Sequence[nurbforge._core.NurbsCurve], tolerance: nurbforge._core.Tolerance = Tolerance(length=0.000000, parametric=0.000000, angular=0.000000)) -> list[nurbforge._core.TrimmedSurface]

Split a surface into trimmed regions along parameter-space curves (u, v, 0). Closed curves become holes and new regions; open curves run from boundary to boundary and may cross.

  1. split(face: nurbforge._core.TrimmedSurface, cuts: collections.abc.Sequence[nurbforge._core.NurbsCurve], tolerance: nurbforge._core.Tolerance = Tolerance(length=0.000000, parametric=0.000000, angular=0.000000)) -> list[nurbforge._core.TrimmedSurface]

Split a trimmed face along parameter-space curves (general planar arrangement): cuts are clipped to the face, may end on the trim loops or on other cuts and may cross each other.

  1. split(shell: nf::Shell, plane: nurbforge._core.Plane, tolerance: typing.SupportsFloat | typing.SupportsIndex = 1e-06, cut_label: str = ‘cut’) -> tuple[nf::Shell, nf::Shell]

Split a closed shell by a plane -> (below, above): two closed shells, below opposite to the plane normal. The new faces in the plane get cut_label (e.g. for a symmetry boundary condition); a part is an empty shell if the plane misses the solid.

nurbforge.surface_curvature(surface: nurbforge._core.NurbsSurface, u: SupportsFloat | SupportsIndex, v: SupportsFloat | SupportsIndex) → nurbforge._core.SurfaceCurvature

Gaussian, mean and principal curvatures and directions.

nurbforge.sweep(*args, **kwargs)

Overloaded function.

  1. sweep(profile: nurbforge._core.NurbsCurve, trajectory: nurbforge._core.NurbsCurve, options: nurbforge._core.SweepOptions = <nurbforge._core.SweepOptions object at 0x7a587c7fbfb0>) -> nurbforge._core.NurbsSurface

Sweep a profile (given at the trajectory start) along a trajectory.

  1. sweep(profiles: collections.abc.Sequence[nurbforge._core.NurbsCurve], trajectory: nurbforge._core.NurbsCurve, params: collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex] = [], options: nurbforge._core.SweepOptions = <nurbforge._core.SweepOptions object at 0x7a587c7f8430>) -> nurbforge._core.NurbsSurface

Sweep with several profiles, each given where it crosses the trajectory (at params[k]; empty: nearest trajectory point); the shape is blended between them (loft) and placed along the trajectory.

nurbforge.sweep2(profile: nurbforge._core.NurbsCurve, rail1: nurbforge._core.NurbsCurve, rail2: nurbforge._core.NurbsCurve, options: nurbforge._core.SweepOptions = <nurbforge._core.SweepOptions object at 0x7a587c610cb0>) → nurbforge._core.NurbsSurface

Two-rail sweep with uniform scaling.

nurbforge.sweep_translational(profile: nurbforge._core.NurbsCurve, trajectory: nurbforge._core.NurbsCurve) → nurbforge._core.NurbsSurface

Exact translational sweep S(u, v) = C(u) + T(v) - T(v0).

nurbforge.tangent_lines(*args, **kwargs)

Overloaded function.

  1. tangent_lines(a: nurbforge._core.NurbsCurve, b: nurbforge._core.NurbsCurve, plane_normal: nurbforge._core.Vec3 = Vec3(0.000000, 0.000000, 1.000000)) -> list[nurbforge._core.TangentLine]

Common tangent lines of two coplanar curves (from a to b), or - with a point as a - the lines from the point tangent to curve b. Returns a list of TangentLine.

  1. tangent_lines(a: nurbforge._core.Vec3, b: nurbforge._core.NurbsCurve, plane_normal: nurbforge._core.Vec3 = Vec3(0.000000, 0.000000, 1.000000)) -> list[nurbforge._core.TangentLine]

nurbforge.thicken(shell: nf::Shell, thickness: SupportsFloat | SupportsIndex, symmetric: bool = False, tolerance: SupportsFloat | SupportsIndex = 1e-06, wall_label: str = 'wall') → nf::Shell

Give an open shell a wall thickness: faces offset along S_u x S_v (negative: against it; symmetric: +-thickness/2), free edges closed by ruled side walls labelled wall_label, offset faces labelled ‘<label>_offset’. The faces must join smoothly; raises GeometryError at creases or where the thickness reaches a radius of curvature.

nurbforge.to_step(shells: object, unit: str = 'mm', name: str = 'nurbforge', author: str = '', organization: str = '', timestamp: str = '', uncertainty: SupportsFloat | SupportsIndex = 1e-06, names: collections.abc.Sequence[str] = []) → str

The STEP file contents (see write_step) as a string.

nurbforge.torsion(curve: nurbforge._core.NurbsCurve, u: SupportsFloat | SupportsIndex) → float
nurbforge.triangle_patch(c0: nurbforge._core.NurbsCurve, c1: nurbforge._core.NurbsCurve, c2: nurbforge._core.NurbsCurve, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsSurface

Three-sided patch bounded by three curves forming a loop: a Coons patch with c0 as one side and the opposite corner as a degenerate side (v = 1).

nurbforge.tween_curves(a: nurbforge._core.NurbsCurve, b: nurbforge._core.NurbsCurve, count: SupportsInt | SupportsIndex) → list[nurbforge._core.NurbsCurve]

count intermediate curves between a and b (made compatible, homogeneous control points interpolated linearly at s = k / (count + 1)). Both should run in the same direction.

nurbforge.unique_knots(knots: collections.abc.Sequence[SupportsFloat | SupportsIndex]) → tuple[list[float], list[int]]

Distinct knot values and multiplicities (gmsh/OCC format).

nurbforge.validate_knots(knots: collections.abc.Sequence[SupportsFloat | SupportsIndex], degree: SupportsInt | SupportsIndex, n_ctrl: SupportsInt | SupportsIndex) → None
nurbforge.write_step(path: object, shells: object, unit: str = 'mm', name: str = 'nurbforge', author: str = '', organization: str = '', timestamp: str = '', uncertainty: SupportsFloat | SupportsIndex = 1e-06, names: collections.abc.Sequence[str] = []) → None

Write a Shell or a list of Shells to a STEP file (AP214, native writer). Closed shells become solids, open shells surface models. unit (‘mm’, ‘cm’, ‘m’, ‘inch’, ‘um’) declares what one model unit means; coordinates are written unchanged. names: one name per shell (solid names, read back by read_step_named).

nurbforge.xy_polynomial_surface(poly: nurbforge._core.XYPolynomialSag, half_width: SupportsFloat | SupportsIndex = 0.0, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsSurface
nurbforge.zernike(j: SupportsInt | SupportsIndex, indexing: nurbforge._core.ZernikeIndexing, rho: SupportsFloat | SupportsIndex, theta: SupportsFloat | SupportsIndex) → float
nurbforge.zernike_nm(j: SupportsInt | SupportsIndex, indexing: nurbforge._core.ZernikeIndexing) → tuple[int, int]
nurbforge.zernike_surface(zernike: nurbforge._core.ZernikeSag, half_width: SupportsFloat | SupportsIndex = 0.0, tolerance: SupportsFloat | SupportsIndex = 1e-07) → nurbforge._core.NurbsSurface

nurbforge.patterns

Helpers to apply transform patterns to geometry objects.

nurbforge.patterns.apply_pattern(geometry, transforms)[source]

Return one transformed copy of geometry per transform.

Parameters:
  • geometry (G)

  • transforms (Iterable[Transform])

Return type:

list[G]

nurbforge.mesh

Transfer Nurbforge NURBS geometry into gmsh’s OpenCASCADE kernel and mesh it.

The NURBS data is handed over exactly (degree, knots, multiplicities, weights), so gmsh meshes the true geometry rather than a tessellation.

Example

>>> import nurbforge as nf
>>> from nurbforge.mesh import GmshSession
>>> sphere = nf.revolve(nf.make_arc((0,0,0),(0,0,-1),(1,0,0),1.0,0.0,3.14159265), (0,0,0),(0,0,1),6.2831853)
>>> with GmshSession() as g:
...     tag = g.add_surface(sphere)
...     g.mesh(dim=2, size=0.1)
...     g.write("sphere.msh")
nurbforge.mesh.gmsh_export.add_curve(curve)[source]

Add a NURBS curve to the current gmsh OCC model. Returns the curve tag.

Parameters:

curve (NurbsCurve)

Return type:

int

nurbforge.mesh.gmsh_export.add_surface(surface, wire_tags=None)[source]

Add a NURBS surface to the current gmsh OCC model. Returns the surface tag.

gmsh expects control points with the u index running fastest, while Nurbforge stores them row-major with v fastest, hence the reordering below. wire_tags (outer contour first, then holes) trims the surface with wires defined in its parameter space.

Parameters:
Return type:

int

nurbforge.mesh.gmsh_export.add_trimmed_surface(trimmed)[source]

Add a trimmed NURBS surface: the trim loops are passed exactly as B-spline wires in the parameter space of the surface (outer contour first, then holes). Returns the tag.

Parameters:

trimmed (TrimmedSurface)

Return type:

int

class nurbforge.mesh.gmsh_export.GmshSession(model_name='nurbforge', verbose=False)[source]

Bases: object

Context manager around gmsh.initialize() / gmsh.finalize().

Shells added with add_shell() keep their face labels, which face_tags() maps to gmsh surfaces and refine() uses for local mesh sizes.

Parameters:
  • model_name (str)

  • verbose (bool)

add_curve(curve)[source]
Parameters:

curve (NurbsCurve)

Return type:

int

add_surface(surface)[source]
Parameters:

surface (NurbsSurface | TrimmedSurface)

Return type:

int

add_shell(shell, solid=True, physical_groups=False, volume_name='volume')[source]

As the module function add_shell(); in addition the session remembers the face labels for face_tags() and refine().

Parameters:
  • shell (Shell)

  • solid (bool)

  • physical_groups (bool)

  • volume_name (str)

Return type:

list[int]

face_tags()[source]

The current gmsh surface tags of every face label of the shells added with add_shell() (unlabelled faces: "unlabeled").

Return type:

dict[str, list[int]]

refine(where, size, distance=0.0)[source]

Local mesh size size on the given faces: face labels of shells added with add_shell() and/or gmsh surface tags. With distance > 0 the size grows linearly from size on the faces to the global size (mesh(size=...)) at that distance, also into the volume; with distance = 0 only the faces themselves are refined. Applied by mesh(); several refinements combine by taking the smallest size.

Parameters:
  • where (str | int | Iterable[str | int])

  • size (float)

  • distance (float)

Return type:

None

mesh(dim=2, size=None, order=1, heal=True, curvature=None)[source]

Synchronise the OCC model and generate a mesh. size is the global maximum element size, curvature the number of elements per 2*pi of curvature (smaller elements on strongly curved faces), local sizes come from refine().

Parameters:
  • dim (int)

  • size (float | None)

  • order (int)

  • heal (bool)

  • curvature (int | None)

Return type:

None

surface_mesh(orient=True)[source]

The triangle surface mesh of the model as a SurfaceMesh, for boundary element solvers. Raises MeshTopologyError unless the mesh is watertight (every edge shared by exactly two triangles) and orientable. With orient the triangles are made consistent across surfaces and their normals point out of the solid (into the void for a cavity); the gmsh mesh is reversed accordingly, so write() exports the same orientation. Call after mesh(dim=2); the triangle groups follow the face labels.

Parameters:

orient (bool)

Return type:

SurfaceMesh

write(path)[source]

Write mesh/geometry; format from extension (.msh, .vtk, .stl, .step, .brep …).

Parameters:

path (str)

Return type:

None

nurbforge.mesh.gmsh_export.add_shell(shell, solid=True, physical_groups=False, volume_name='volume')[source]

Add a shell with its B-rep topology: faces share their edges. For a closed shell and solid=True a volume is created. Returns the gmsh surface tag of every face (in the order of shell.faces, without repetitions) and the volume tag last, if one was created.

The shell is handed over through Nurbforge’s native STEP writer (exact NURBS, shared edges) and OCC’s STEP reader, so OCC builds the topology itself – including the seam edges of closed surfaces (cylinders, cones, spheres, tori), which a face-by-face transfer with duplicate removal or sewing cannot reproduce once such a face is trimmed (e.g. a bore or a slot from a Boolean).

physical_groups=True creates one physical surface group per face label (TrimmedSurface.label, e.g. set with Shell.with_face_labels before a Boolean; unlabelled faces go to "unlabeled") and a physical volume volume_name, so boundary conditions can be assigned by name in the solver. Faces are matched to the gmsh surfaces by an interior point.

Parameters:
  • shell (Shell)

  • solid (bool)

  • physical_groups (bool)

  • volume_name (str)

Return type:

list[int]

nurbforge.mesh.gmsh_export.export_step(objects, path, solid=True)[source]

Write surfaces, trimmed surfaces and shells to a STEP (or BREP/IGES, by extension) file via gmsh’s OpenCASCADE kernel. Closed shells become solids if solid is set.

Parameters:
  • path (str)

  • solid (bool)

Return type:

None

nurbforge.mesh.gmsh_export.bem_mesh(shell, size=None, order=1, curvature=None, refine=None, path=None)[source]

One-shot helper for boundary element solvers: mesh the closed shell with triangles and return a watertight, outward-oriented SurfaceMesh (see GmshSession.surface_mesh()). refine maps face labels or surface tags to local sizes; path additionally writes the mesh (.msh, .stl, .vtk, …) with physical groups per face label.

Parameters:
  • shell (Shell)

  • size (float | None)

  • order (int)

  • curvature (int | None)

  • refine (dict | None)

  • path (str | None)

Return type:

SurfaceMesh

nurbforge.mesh.gmsh_export.mesh_surfaces(surfaces, path, size=None, order=1)[source]

One-shot helper: add surfaces, mesh in 2D and write to path.

Parameters:
Return type:

None

nurbforge.llm

Tool-calling loop: natural language -> geometry operations.

class nurbforge.llm.agent.GeometryAgent(client=None, workspace=None, max_steps=20, verify_rounds=1)[source]

Bases: object

Tool-calling agent.

After the model’s final answer, up to verify_rounds verification rounds follow: the objects created or changed for the request are measured (verify.report: bounding boxes, lengths, areas, volumes, closedness, detected issues such as open shells) and the report is sent back to the model, which either fixes the geometry with further tool calls or confirms. The rounds stop as soon as the model confirms without calling tools. The last report is kept in verification.

Parameters:
ask(prompt)[source]
Parameters:

prompt (str)

Return type:

str

Whitelisted geometry tools exposed to the LLM (JSON-schema function calling).

class nurbforge.llm.tools.Workspace(objects=<factory>)[source]

Bases: object

Named object store the LLM operates on.

Parameters:

objects (dict[str, Any])

objects: dict[str, Any]
put(name, obj)[source]
Parameters:
  • name (str)

  • obj (Any)

Return type:

str

get(name)[source]
Parameters:

name (str)

Return type:

Any

class nurbforge.llm.tools.Tool(name: 'str', description: 'str', parameters: 'dict[str, Any]', func: 'Callable[..., str]')[source]

Bases: object

Parameters:
  • name (str)

  • description (str)

  • parameters (dict[str, Any])

  • func (Callable[[...], str])

name: str
description: str
parameters: dict[str, Any]
func: Callable[[...], str]
schema()[source]
Return type:

dict[str, Any]

nurbforge.llm.tools.call_tool(ws, name, arguments)[source]

Execute a tool call; errors are returned as text so the LLM can correct itself.

Parameters:
  • ws (Workspace)

  • name (str)

  • arguments (dict[str, Any])

Return type:

str

Minimal Ollama HTTP client (stdlib only, no extra dependencies).

exception nurbforge.llm.ollama_client.OllamaError[source]

Bases: RuntimeError

class nurbforge.llm.ollama_client.OllamaClient(host='http://localhost:11434', model='qwen2.5:14b', timeout=300.0)[source]

Bases: object

Thin wrapper around the Ollama REST API (/api/chat, /api/tags).

Parameters:
  • host (str)

  • model (str)

  • timeout (float)

list_models()[source]
Return type:

list[str]

chat(messages, tools=None, temperature=0.0)[source]

Single non-streaming chat turn. Returns the assistant message dict.

Parameters:
  • messages (list[dict[str, Any]])

  • tools (list[dict[str, Any]] | None)

  • temperature (float)

Return type:

dict[str, Any]