C++ API reference¶
Generated from the public headers in include/nurbforge/ by Doxygen (XML output) and rendered
with Breathe. Build it locally with doxygen docs/Doxyfile from the repository root before
running Sphinx; the standalone Doxygen HTML ends up in build/docs/html. For a task-oriented
overview see the C++ API overview.
On GitHub this page is only a stub – the reference itself is rendered on the documentation site.
Namespace nf¶
-
namespace nf¶
Typedefs
-
using KnotVector = std::vector<double>¶
-
using Region = std::vector<std::vector<NurbsCurve>>¶
A region in the xy plane: closed loops, each a chain of curves running head to tail (z is ignored). Loops are nested: a loop inside an even number of others is an outer boundary, one inside an odd number a hole. Input loops may run either way; results are oriented with the region on the left (outer loops counter-clockwise, holes clockwise).
Enums
-
enum class Parametrization¶
Choice of data parameters on [0, 1] (P&T Eq. 9.3–9.6).
Values:
-
enumerator Uniform¶
equally spaced
-
enumerator ChordLength¶
proportional to the distance between consecutive points
-
enumerator Centripetal¶
proportional to the square root of the distance (robust at sharp turns)
-
enumerator Uniform¶
-
enum class StepLengthUnit¶
Length unit declared in the STEP file. Coordinates are written unchanged: the unit says what one model unit means (default: millimetre, the usual CAD convention).
Values:
-
enumerator Millimetre¶
-
enumerator Centimetre¶
-
enumerator Metre¶
-
enumerator Inch¶
-
enumerator Micrometre¶
-
enumerator Millimetre¶
-
enum class Extension¶
How the geometry is continued.
Values:
-
enumerator Natural¶
polynomial (rational) continuation of the boundary Bézier piece: C-infinity at the old boundary; conics stay conics. Fails if weights would become <= 0.
-
enumerator Linear¶
straight continuation along the boundary tangent: G1, and C1 for non-rational geometry (the parameter speed is matched).
-
enumerator Natural¶
-
enum class SweepFrame¶
Orientation of the profile along the trajectory.
Values:
-
enumerator RotationMinimizing¶
rotation-minimising frame (double reflection, Wang et al. 2008): no spurious twist, defined at inflections and straight parts
-
enumerator Fixed¶
pure translation (no rotation)
-
enumerator RotationMinimizing¶
Functions
-
CurvePoint closest_point(const NurbsCurve &c, const Vec3 &P, const Tolerance &tol = {})¶
Global closest point of P on the curve. Branch and bound over Bézier segments (the distance to the bounding box of a segment’s control points is a safe lower bound, so the global minimum is never discarded), followed by safeguarded Newton iteration (P&T Eq. 6.3) in every remaining monotone segment. Uses tol.length (point coincidence, step size) and tol.angular (orthogonality of C’ and C - P). If several points are equally close (e.g. the centre of a circle), one of them is returned.
-
CurvePoint closest_point_local(const NurbsCurve &c, const Vec3 &P, double u0, const Tolerance &tol = {})¶
Local Newton projection starting at u0 (domain-clamped). Fast, but only finds the local minimum near u0; intended for marching and refinement of a known approximation.
-
SurfacePoint closest_point(const NurbsSurface &s, const Vec3 &P, const Tolerance &tol = {})¶
Global closest point of P on the surface (branch and bound over Bézier patches, then safeguarded 2D Newton, P&T Eq. 6.6). Robust at poles and on the domain boundary.
-
SurfacePoint closest_point_local(const NurbsSurface &s, const Vec3 &P, double u0, double v0, const Tolerance &tol = {})¶
Local 2D Newton projection starting at (u0, v0).
-
Hatching hatch(const std::vector<std::vector<NurbsCurve>> &loops, const Vec3 &direction, double spacing, const HatchOptions &options = {})¶
Hatching of the region bounded by closed planar loops with lines along
direction(projected into the xy plane and normalised; z of the loops is ignored) at distancespacing.Each loop is a chain of curves in the xy plane (end of one = start of the next, last ends at the first), oriented with the region on the left: outer loops counter-clockwise, holes clockwise (as returned by section). Islands inside holes are further counter-clockwise loops. The region is decided by this orientation (winding number), not by even-odd counting.
The lines are n . p = phase + k spacing with n = (-d.y, d.x). Every line is intersected exactly with the loop curves: the height n . c(t) of each Bezier piece is a rational function with the same weights, so its sign changes are found by subdivision of the control values (single sign change: one transversal root, refined to machine precision). A loop that only touches a line within the tolerance, or runs along it and returns to the same side (an edge on the line), does not split it; where the loop runs along a line and then crosses it, the segment ends where the loop leaves the line to the side n . p > c. Consequently tangent lines give no zero-length segments, and edges lying exactly on a hatch line are not hatched themselves (write them as contours).
Contours (options.contours) are the boundaries of the region shrunk by each distance d, i.e. of the points of the region at distance >= d from all loops. The raw offset of every loop (offset_curve of its pieces to the left, i.e. into the region, also for holes; circular arcs about reflex corners; parts where d reaches the radius of curvature of a concave piece left out) is split at all its self- and mutual intersections; the fragments at distance >= d from the loops (within the fit tolerance) and inside the region are chained into closed contours. So contours are trimmed at convex corners, split where the region is narrower than 2 d, merged where a hole comes closer than 2 d to another loop, and vanish where the region is thinner than 2 d everywhere (no contour for that loop). Consecutive contour curves meet within max(100 contour_tolerance, 10 x the largest gap between consecutive loop curves).
Throws GeometryError if spacing <= 0, the direction is zero in the xy plane, or the number of lines exceeds 10^7.
-
Hatching hatch(const std::vector<SectionLoop> &loops, const Vec3 &direction, double spacing, const HatchOptions &options = {})¶
Hatching of section loops (their curves in the plane coordinates (s, t, 0)); same as above.
-
std::vector<CurveCurveIntersection> intersect(const NurbsCurve &a, const NurbsCurve &b, const Tolerance &tol = {})¶
All intersection points of two curves (in 3D: points where they come within tol.length). Subdivision of Bézier pieces with bounding-box rejection until both pieces are monotone, then box-constrained Gauss-Newton on a(s) - b(t) = 0; duplicates at piece boundaries are merged. Sorted by s. Tangential intersections are found as long as the curves come within tol.length; coincident (overlapping) curve portions are not detected as such and yield sample points only.
-
std::vector<CurveSurfaceIntersection> intersect(const NurbsCurve &c, const NurbsSurface &s, const Tolerance &tol = {})¶
All intersection points of a curve and a surface, sorted by t (same method, Gauss-Newton on c(t) - S(u, v) = 0). Curve portions lying in the surface are not detected as such.
-
double integrate(const std::function<double(double)> &f, double a, double b, double rel_tol = kIntegrationRelTol, const std::vector<double> &breaks = {}, double abs_tol = 0.0)¶
Globally adaptive Gauss-Kronrod (7/15) integral of f over [a, b], split at the given interior break points (where f may be non-smooth). Target error max(rel_tol * int |f|, abs_tol); the number of subintervals is bounded, so noisy integrands cannot explode.
-
double curvature(const NurbsCurve &c, double u)¶
Curvature kappa = |C’ x C’’| / |C’|^3 (>= 0). Throws GeometryError where C’ vanishes.
-
double torsion(const NurbsCurve &c, double u)¶
Torsion tau = (C’ x C’’) . C’’’ / |C’ x C’’|^2. Zero for planar curves; throws GeometryError where the curvature vanishes (torsion undefined).
-
double arc_length(const NurbsCurve &c, double u0, double u1, double rel_tol = kIntegrationRelTol)¶
Arc length of the curve between the parameters u0 and u1 (u0 > u1 gives a negative value). Adaptive Gauss-Kronrod (7/15) on every knot span, relative accuracy
rel_tol.
-
double arc_length(const NurbsCurve &c, double rel_tol = kIntegrationRelTol)¶
Arc length of the whole curve.
-
double parameter_at_length(const NurbsCurve &c, double s, double rel_tol = kIntegrationRelTol)¶
Parameter u with arc_length(c, domain_start, u) = s, for 0 <= s <= total length (safeguarded Newton on the arc length function). Throws GeometryError for s out of range.
-
SurfaceCurvature curvature(const NurbsSurface &s, double u, double v)¶
Gaussian, mean and principal curvatures and directions from the first and second fundamental forms. At singular points of the parametrisation (poles, collapsed edges) the values are extrapolated (Richardson, from offsets 1e-4 and 2e-4 of the domain towards the interior; typically accurate to ~1e-8 relative for geometrically smooth surfaces). Umbilic points (k1 = k2) return dir1 along S_u and dir2 perpendicular to it.
-
double area(const NurbsSurface &s, double u0, double u1, double v0, double v1, double rel_tol = kIntegrationRelTol)¶
Area of the surface over [u0, u1] x [v0, v1] (adaptive tensor Gauss-Kronrod on every pair of knot spans, relative accuracy
rel_tol).
-
double area(const NurbsSurface &s, double rel_tol = kIntegrationRelTol)¶
Area of the whole surface.
-
SurfaceIntersection planar_section(const NurbsSurface &s, const Plane &plane, const SurfaceIntersectionOptions &options = {})¶
Section of a surface with a plane: the intersection curves (3D curve and p-curve on the surface; pcurve2 is the curve in the plane’s own (s, t) coordinates along two orthonormal in-plane axes, origin at plane.point) and touching points. The plane is represented by a rectangle covering the surface’s control-point bounding box, so all section curves are found; curves are split where they cross the surface’s parameter boundary (seams).
-
std::vector<SurfaceIntersection> planar_sections(const NurbsSurface &s, const Plane &plane, double spacing, std::size_t count, const SurfaceIntersectionOptions &options = {})¶
countparallel sections, the k-th at plane.point + k * spacing * normal (k = 0..count-1).
-
std::vector<CurveSurfaceIntersection> intersect(const NurbsCurve &c, const Plane &plane, const Tolerance &tol = {})¶
Intersection points of a curve with a plane (curve parameter t, point; u, v are the in-plane coordinates as for planar_section).
-
PlanarSection section(const Shell &shell, const Plane &plane, const SectionOptions &options = {})¶
Section of a closed shell with a plane: the intersection curves of all faces, clipped to the trimmed regions, chained into closed loops and oriented by the outward normals (the shell is oriented first if necessary). Throws GeometryError if a chain does not close (open shell or tolerance problem; the message gives the position) or if the plane contains a face (planes through critical heights, see critical_heights, are not supported).
-
std::vector<double> critical_heights(const Shell &shell, const Vec3 &dir, const Tolerance &tol = {})¶
Heights h = p . dir (dir normalised) at which the topology of the sections of the shell with the planes p . dir = h can change, sorted and merged within tol.length: vertices, planar faces normal to dir, interior extrema of the height on faces (S_u . dir = S_v . dir = 0, Newton from Bezier subdivision) and on edges (C’ . dir = 0). Between two neighbouring critical heights the sections have the same number of loops and pieces.
-
bool is_extrusion_band(const Shell &shell, const Vec3 &dir, double h0, double h1, const Tolerance &tol = {})¶
True if every face of the shell that meets the open band h0 < p . dir < h1 has a normal perpendicular to dir there (within tol.angular), i.e. the band is an extrusion along dir and all its sections are equal. Checked at samples of the face inside the band and on its Bezier control nets.
-
SurfaceIntersection intersect(const NurbsSurface &a, const NurbsSurface &b, const SurfaceIntersectionOptions &options = {})¶
Intersection of two surfaces. Seeds are found by subdividing pairs of Bézier patches; a pair whose normal cones are separated contains no closed loop, so all its intersection curves cross the pair’s boundary and are found by intersecting the boundary curves with the other patch (curve/surface intersection). Curves are traced by predictor-corrector marching along n1 x n2 with step control by the chord tolerance; they end on the boundary of either parameter domain (solved exactly there) or close into loops. Curves are split where they cross the domain boundary (e.g. the seam of a closed surface). Points where the surfaces only touch are reported in
points; surfaces touching along a curve (tangential intersection curves) are not traced.
-
Vec3 normalized(const Vec3 &a)¶
Returns a unit vector; throws GeometryError for (near) zero vectors.
-
std::vector<double> data_parameters(const std::vector<Vec3> &points, Parametrization method)¶
Data parameters for the points (first 0, last 1). Throws GeometryError for fewer than two points or coincident consecutive points (non-uniform parametrisations).
-
std::vector<double> data_parameters(const std::vector<std::vector<Vec3>> &sequences, Parametrization method)¶
Parameters on [0, 1] averaged over several point sequences of equal length (P&T Eq. 9.18, 10.8); degenerate sequences (all points equal) are skipped.
-
NurbsCurve interpolate_curve(const std::vector<Vec3> &points, std::size_t degree, const std::vector<double> ¶ms)¶
Global interpolation with explicit, strictly increasing parameters (domain [params.front(), params.back()], knots by averaging).
-
NurbsCurve interpolate_curve(const std::vector<Vec3> &points, std::size_t degree, Parametrization method = Parametrization::Centripetal, const std::optional<std::pair<Vec3, Vec3>> &end_derivatives = std::nullopt)¶
Global interpolation (A9.1): non-rational B-spline of the given degree on [0, 1] through all points, knots by averaging (Eq. 9.8). Optional end derivatives {C’(0), C’(1)} (w.r.t. the parameter on [0, 1]) add two control points (Eq. 9.21/9.22). Needs at least degree+1 points.
-
NurbsCurve approximate_curve(const std::vector<Vec3> &points, std::size_t degree, std::size_t n_ctrl, Parametrization method = Parametrization::Centripetal)¶
Least-squares approximation (Eq. 9.63–9.69) with n_ctrl control points; the first and last point are interpolated. degree+1 <= n_ctrl <= number of points.
-
NurbsCurve approximate_curve(const std::vector<Vec3> &points, std::size_t degree, const KnotVector &knots, const std::vector<double> ¶ms)¶
Least-squares approximation with given knot vector (clamped, degree+1 <= n_ctrl <= number of points) and data parameters (inside the knot domain, first/last at the domain ends); the first and last point are interpolated. Reproduces data from the spline space exactly, e.g. x(t) = t stays exactly linear (used for graph fits).
-
NurbsCurve approximate_curve_tol(const std::vector<Vec3> &points, std::size_t degree, double tolerance, Parametrization method = Parametrization::Centripetal)¶
Least-squares approximation with the smallest number of control points such that every data point lies within
toleranceof the curve point at its parameter (an upper bound of the point-to-curve distance). Falls back to interpolation if necessary.
-
NurbsSurface interpolate_surface(const std::vector<Vec3> &points, std::size_t num_u, std::size_t num_v, std::size_t degree_u, std::size_t degree_v, Parametrization method = Parametrization::Centripetal)¶
Global surface interpolation (A9.4) through a grid of points, row-major points[i * num_v + j] (i along u). Parameters are averaged over rows/columns; degenerate rows (e.g. a pole, all points equal) are skipped in the averaging.
-
NurbsSurface approximate_surface(const std::vector<Vec3> &points, std::size_t num_u, std::size_t num_v, std::size_t degree_u, std::size_t degree_v, std::size_t ctrl_u, std::size_t ctrl_v, Parametrization method = Parametrization::Centripetal)¶
Least-squares surface approximation of a point grid with ctrl_u x ctrl_v control points (curve approximation through all rows, then through the resulting columns; corners are interpolated).
-
FittedSurface fit_surface(const std::vector<Vec3> &points, const SurfaceFitOptions &options = {})¶
Fits a non-rational B-spline surface (domain [0, 1]^2, uniform clamped knots) to unordered points: penalised least squares (data deviation + smoothing x thin-plate energy) solved as a banded system, followed by parameter correction. Suited to height-field-like data (measurements of optical surfaces, topographies) or, with a base surface or boundary curves, to data over a known shape. Throws GeometryError for fewer than 3 points or data that cannot be parametrised.
-
LineFit fit_line(const std::vector<Vec3> &points)¶
Line through points by orthogonal regression: the centroid and the eigenvector of the largest eigenvalue of the scatter matrix (symmetric Jacobi rotations). Needs at least 2 distinct points; throws GeometryError otherwise.
-
PlaneFit fit_plane(const std::vector<Vec3> &points)¶
Plane through points by orthogonal regression: the centroid and the eigenvector of the smallest eigenvalue of the scatter matrix. Needs at least 3 points that are not collinear; throws GeometryError otherwise.
-
NurbsCurve make_line(const Vec3 &p0, const Vec3 &p1)¶
Straight line segment p0 -> p1 (degree 1).
-
NurbsCurve make_polyline(const std::vector<Vec3> &points)¶
Open polyline through the given points (degree 1).
-
NurbsCurve make_arc(const Vec3 ¢er, const Vec3 &x_axis, const Vec3 &y_axis, double radius, double start_angle, double end_angle)¶
Circular arc (A7.1). x_axis and y_axis span the arc plane and must be orthogonal. Angles in radians, measured from x_axis towards y_axis.
-
NurbsCurve make_circle(const Vec3 ¢er, const Vec3 &normal, double radius)¶
Full circle in the plane through
centerwith the given normal (exact, 9 control points).
-
NurbsSurface make_bilinear(const Vec3 &p00, const Vec3 &p10, const Vec3 &p01, const Vec3 &p11)¶
Bilinear patch from 4 corners: S(0,0)=p00, S(1,0)=p10, S(0,1)=p01, S(1,1)=p11.
-
NurbsSurface make_rectangle(const Vec3 &origin, const Vec3 &edge_u, const Vec3 &edge_v)¶
Planar rectangle with corner
origin, edgesedge_uandedge_v.
-
NurbsCurve make_circle_3pt(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2)¶
Full circle through three non-collinear points, starting at p0 and running through p1 and p2 in this order (exact, rational). Throws GeometryError for (nearly) collinear points.
-
NurbsCurve make_arc_3pt(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2)¶
Circular arc from p0 through p1 to p2 (exact, rational; any sweep below 360 degrees). Throws GeometryError for (nearly) collinear points.
-
NurbsCurve make_arc_tangent(const Vec3 &start, const Vec3 &tangent, const Vec3 &end)¶
Circular arc from
start, leaving it in the directiontangent, toend(exact, rational; sweep in (0, 360) degrees). Throws GeometryError if end coincides with start or lies on the tangent line (the arc would be a straight line).
-
NurbsCurve make_polygon(const Vec3 ¢er, const Vec3 &normal, double radius, std::size_t n, const Vec3 &x_axis = {0, 0, 0})¶
Closed regular polygon with n >= 3 vertices on the circle of the given (circum)radius about
centerin the plane with normalnormal, counter-clockwise about the normal; the first vertex lies in the direction of x_axis (projected into the plane; zero: any_perpendicular).
-
NurbsCurve make_rectangle_curve(const Vec3 &origin, const Vec3 &edge_u, const Vec3 &edge_v)¶
Closed rectangle outline origin -> origin + edge_u -> + edge_v -> origin + edge_v -> origin (degree-1 curve; the boundary of make_rectangle).
-
NurbsCurve make_helix(const Vec3 &axis_point, const Vec3 &axis, const Vec3 &start, double pitch, double turns, double end_radius = -1.0, bool left_handed = false, double tolerance = 1e-7)¶
Helix or spiral about the axis through
axis_pointwith directionaxis, starting atstart: the radius changes linearly from the start radius (distance ofstartfrom the axis) toend_radius(< 0: the start radius, a cylindrical helix), the height along the axis grows bypitchper turn (0: a planar Archimedean spiral; negative: downwards), and the curve windsturns> 0 times counter-clockwise about the axis direction (right-handed for pitch > 0), or clockwise ifleft_handed. Conical helices: pitch != 0 and end_radius != start radius.The curve parameter is the number of turns, t in [0, turns]. A helix is not a NURBS; the result is a C2 quintic B-spline (piecewise quintic Hermite interpolation of position, first and second derivative of the exact curve at equally spaced parameters, interior knots of multiplicity 3) whose distance from the exact point at the same parameter is verified below
toleranceat 24 points per span; the span count is increased (from the observed n^-6 convergence) until it is.
-
std::string to_step(const std::vector<Shell> &shells, const StepOptions &options = {})¶
The STEP file contents for the given shells (see write_step).
-
void write_step(const std::string &path, const std::vector<Shell> &shells, const StepOptions &options = {})¶
Writes the shells to an ISO 10303-21 file with the AP214 schema (AUTOMOTIVE_DESIGN), one product whose shape is:
closed shells: MANIFOLD_SOLID_BREP (BREP_WITH_VOIDS if a shell has inner void components) in an ADVANCED_BREP_SHAPE_REPRESENTATION; shells that are not consistently oriented are oriented first, and outer components get outward normals;
open shells: SHELL_BASED_SURFACE_MODEL(OPEN_SHELL) in a MANIFOLD_SURFACE_SHAPE_REPRESENTATION (if both kinds are present, solids and surface model go into one plain SHAPE_REPRESENTATION). Faces whose normal must point against the surface normal (inside-out components, void shells of BREP_WITH_VOIDS) are written with same_sense .F. and bound orientation .F. Faces are ADVANCED_FACEs on B_SPLINE_SURFACE_WITH_KNOTS (rational: the complex entity with RATIONAL_B_SPLINE_SURFACE), bounded by EDGE_LOOPs of ORIENTED_EDGEs; every shell edge is one EDGE_CURVE (its 3D B-spline curve, as stored in the shell) shared by its uses. Empty shells are skipped. Throws std::runtime_error if the file cannot be written.
-
std::vector<Shell> from_step(const std::string &text, const StepReadOptions &options = {})¶
Reads the B-rep solids and surface models of a STEP (ISO 10303-21) text, see read_step.
-
std::vector<Shell> read_step(const std::string &path, const StepReadOptions &options = {})¶
Reads a STEP file (any AP203 / AP214 / AP242 schema with B-rep geometry) into shells: one shell per MANIFOLD_SOLID_BREP / BREP_WITH_VOIDS (outer shell and voids sewn together; void faces keep their normals pointing into the void) and per shell of a SHELL_BASED_SURFACE_MODEL. Faces may lie on B-spline surfaces (also rational) or on PLANE, CYLINDRICAL_SURFACE, CONICAL_SURFACE, SPHERICAL_SURFACE and TOROIDAL_SURFACE, which are converted to exact NURBS patches covering the face; edges on B-spline curves, LINE, CIRCLE, ELLIPSE and POLYLINE (also inside SURFACE_CURVE / SEAM_CURVE). Trim loops are reconstructed in each face’s parameter space from the 3D edges (exact for planes, otherwise by projection and interpolation to tolerance / 10, handling seams and poles). Faces with same_sense .F. are flipped. Lengths are converted from the file’s length unit (SI_UNIT with prefix or CONVERSION_BASED_UNIT, e.g. inch) to
options.unit. Placement transformations of assemblies are not applied. Throws GeometryError for unsupported entities (naming the entity and instance) unless options.skip_unsupported, std::runtime_error if the file cannot be read.
-
std::vector<NamedShell> from_step_named(const std::string &text, const StepReadOptions &options = {})¶
As from_step / read_step, with the name of every shell (see NamedShell).
-
std::vector<NamedShell> read_step_named(const std::string &path, const StepReadOptions &options = {})¶
-
NurbsCurve blend_curves(const NurbsCurve &a, CurveEnd end0, const NurbsCurve &b, CurveEnd end1, int continuity = 2, double tension = 1.0)¶
A Bézier curve from the end
end0of curve a to the endend1of curve b that continues both curves smoothly: G1 (continuity 1, cubic: same tangent directions) or G2 (continuity 2, quintic: same tangent directions and curvature vectors). The blend leaves a away from it (along the tangent of a at End, against it at Start) and enters b towards its interior. The speed |C’| at both ends istensiontimes the chord between the ends; larger values give fuller blends. Domain [0, 1]. Throws GeometryError if the ends coincide or a tangent vanishes.
-
std::vector<NurbsCurve> tween_curves(const NurbsCurve &a, const NurbsCurve &b, std::size_t count)¶
countintermediate curves between a (s = 0) and b (s = 1) at s = k / (count + 1), k = 1..count. The curves are made compatible (make_compatible: common degree, knots and domain [0, 1]) and the homogeneous control points (w P, w) are interpolated linearly, so tween k is exactly (1 - s) a + s b in homogeneous space (for non-rational curves: the point-wise affine combination at equal parameters). Both curves should run in the same direction (reverse one otherwise). Throws GeometryError if count is 0.
-
std::vector<TangentLine> tangent_lines(const Vec3 &point, const NurbsCurve &curve, const Vec3 &plane_normal = {0, 0, 1})¶
Lines through
pointtangent to a planar curve (all solutions, sorted by the curve parameter): the tangent points t with n . ((c(t) - p) x c’(t)) = 0 for the plane normal n, found by sampling and refined by Newton. Each line runs from the point to the tangent point (param_a is NaN). Points on the curve itself are not tangent points. Throws GeometryError if the point or the curve is not in a plane normal to plane_normal (within 1e-9 of the curve size).
-
std::vector<TangentLine> tangent_lines(const NurbsCurve &a, const NurbsCurve &b, const Vec3 &plane_normal = {0, 0, 1})¶
Common tangent lines of two coplanar curves (all solutions found on a sampling grid, refined by Newton): parameters (s, t) where a’(s), b’(t) and b(t) - a(s) are parallel. Each line runs from a(s) to b(t); intersection points of the curves are excluded. Sorted by s, then t. Throws GeometryError if the curves are not in a common plane normal to plane_normal.
-
NurbsSurface blend_surfaces(const NurbsSurface &s0, SurfaceSide side0, const NurbsSurface &s1, SurfaceSide side1, int continuity = 2, double tension = 1.0, double tolerance = 1e-7)¶
Blend surface between the side
side0of s0 and the sideside1of s1 that continues both surfaces smoothly: G0 (continuity 0: ruled), G1 (1: same tangent planes along both edges, cubic across) or G2 (2: also the same normal curvature, quintic across). u runs along the edge of s0 (in its parameter direction), v across from s0 (v = 0) to s1 (v = 1); the edge of s1 is mapped linearly onto the edge of s0, in the orientation that pairs the nearer points (for closed edges the seams should be aligned). Across the edges the blend is a reparametrisation of the surfaces up to the requested order: B_v = k D1 and B_vv = k^2 D2 with the outward cross-boundary derivatives D1, D2 of the surface and a constant k chosen so that the mean speed |B_v| istensiontimes the mean distance between the edges. The result is exact when the weights of each surface do not vary across its side in the rows involved (non-rational surfaces, extrusions, cylinders along the axis); otherwise the edge and its derivatives are interpolated totolerance(relative to the edge length for the derivatives). Throws GeometryError if the edges touch or a cross derivative vanishes.
-
NurbsSurface match_surface(const NurbsSurface &surface, SurfaceSide side, const NurbsSurface &target, SurfaceSide target_side, int continuity = 2, double tolerance = 1e-7)¶
Changes
surfacenear its sidesideso that it joinstargetalong the sidetarget_sidewith continuity G0 (the edges coincide), G1 (also the tangent planes) or G2 (also the normal curvature). The edge of the target is mapped linearly onto the edge of the surface (orientation as in blend_surfaces); the first continuity + 1 control rows at the side are replaced so that the surface continues the target as a reparametrisation (cross speed kept on average). The surface is refined first (degree and knots along the edge, knots across) so that the opposite side and its cross derivatives up to the same order are kept. Exactness as for blend_surfaces. Returns the modified surface with the same parameter directions and domain.
-
NurbsSurface extrude(const NurbsCurve &profile, const Vec3 &direction)¶
General cylinder: sweeps
profilealong the straight vectordirection. Result: u follows the profile, v the extrusion (degree 1).
-
NurbsSurface revolve(const NurbsCurve &profile, const Vec3 &axis_point, const Vec3 &axis_dir, double angle)¶
Surface of revolution (A8.1): rotates
profilebyangle(radians, 0 < angle <= 2*pi) about the axis throughaxis_pointwith directionaxis_dir. Result: u runs around the axis (degree 2, rational), v follows the profile.
-
NurbsSurface ruled(const NurbsCurve &c0, const NurbsCurve &c1)¶
Ruled (linearly lofted) surface between two curves. v = 0 lies on c0, v = 1 on c1. Curves are made compatible (degree and knots) automatically, see make_compatible.
-
void make_compatible(NurbsCurve &a, NurbsCurve &b)¶
Makes two curves compatible: clamped knot vectors, common domain [0, 1], equal degree (by elevating the lower one) and a common knot vector (by knot insertion). Shapes are unchanged.
-
void make_compatible(std::vector<NurbsCurve> &curves)¶
Same for any number of curves: afterwards all are clamped on [0, 1], have the highest degree and identical knot vectors (union of all knots with maximal multiplicity).
-
NurbsCurve reparametrize(const NurbsCurve &c, double a, double b)¶
Linear reparametrisation of a curve to the domain [a, b].
-
NurbsCurve extend(const NurbsCurve &c, CurveEnd end, double length, Extension type = Extension::Natural)¶
Extends the curve at one end by the arc length
length(> 0). The original parameters are kept: the domain grows to [a - delta, b] or [a, b + delta]. The result is clamped. Throws GeometryError for length <= 0 or if a natural extension of a rational curve would need non-positive weights (use a shorter length or Extension::Linear).
-
NurbsSurface extend(const NurbsSurface &s, SurfaceSide side, double length, Extension type = Extension::Natural)¶
Extends the surface across one side.
lengthis the arc length of the extension measured along the iso-curve through the middle of the side (other iso-curves are extended by the same parameter amount). Original parameters are kept; the domain grows on that side. Linear extension requires constant weights along the extension direction (non-rational iso-curves across the side), e.g. a cylinder can be extended linearly along its axis.
-
CurveFillet fillet_curves(const NurbsCurve &a, const NurbsCurve &b, double radius, const Vec3 &plane_normal = {0.0, 0.0, 1.0}, const CurveFilletOptions &options = {})¶
Circular fillet of the given radius between two coplanar, intersecting curves.
The corner X is an intersection of a and b (the one nearest to options.corner). On each curve the kept part is the side of X with the longer parameter interval (for a polyline corner where a ends and b starts at X: a before X, b after X). With automatic sides the fillet lies in the sector spanned by the kept parts: its centre is to the side of a on which b’s kept part lies, and vice versa. The centre is the intersection of offset_curve(a, side_a * r) and offset_curve(b, side_b * r) nearest to X, refined by Newton on a(s) + d_a N_a(s) = b(t) + d_b N_b(t) (exact unit normals, N = normalize(n x c’)), so the tangent points are the exact foot points of the centre on both curves. Exact for lines (tangent points at distance r / tan(theta / 2) from the corner for an angle theta between the kept parts) and circles.
Throws GeometryError if the curves do not lie in a common plane normal to plane_normal, do not intersect, are tangent at the corner, if r is not positive, if the offsets do not intersect (fillet too large for the curves, or r beyond a radius of curvature on the concave side), or if a tangent point falls on the far side of the corner (trimmed part empty).
-
NurbsCurve fillet_corners(const NurbsCurve &curve, double radius, double tolerance = 1e-7)¶
Rounds every corner (tangent discontinuity) of a planar curve with an exact circular arc of the given radius, e.g. a polyline, make_rectangle_curve or make_polygon. The curve is split at its interior knots of full multiplicity; consecutive pieces meeting with a tangent angle above 1e-9 rad are filleted with fillet_curves (inside the corner), and so is the closing corner of a closed curve. Pieces are trimmed at the tangent points and joined with the arcs into one G1 curve (degrees unified by elevation; for a closed curve the start moves to the first tangent point after the original start). The plane is taken from the control points (Newell normal). Throws GeometryError if the curve is not planar, a corner turns back on itself (180 degrees), or the radius is too large for a piece (the tangent points of its two fillets overlap).
-
CurveChamfer chamfer_curves(const NurbsCurve &a, const NurbsCurve &b, double distance_a, double distance_b, const CurveChamferOptions &options = {})¶
Chamfer between two intersecting curves: a straight cut from the point of a at (Euclidean) distance
distance_afrom the corner X to the point of b at distancedistance_bfrom X, both on the kept parts (corner and kept parts as in fillet_curves: X is the intersection nearest to options.corner, the kept part of a curve is the side of X with the longer parameter interval). The curves need not be planar. For lines the chamfer points are exact; otherwise they are solved to round-off (bisection and Newton on |c(t) - X| = d, the first solution when moving away from X). Throws GeometryError if the curves do not intersect, are tangent at the corner, a distance is not positive, or a kept part is shorter than its distance (the chamfer would consume the curve).
-
NurbsCurve chamfer_corners(const NurbsCurve &curve, double distance, double tolerance = 1e-7)¶
Chamfers every corner (tangent discontinuity) of a curve with straight cuts at the given distance from the corner on both sides; pieces, corners and joining as in fillet_corners (the curve need not be planar). Throws GeometryError if a corner turns back on itself or the distance is too large for a piece (its two chamfer points overlap).
-
SurfaceFillet fillet_surfaces(const NurbsSurface &s1, const NurbsSurface &s2, double radius, const SurfaceFilletOptions &options = {})¶
Rolling-ball fillet of radius r between two surfaces.
Spine: the intersection curve of offset_surface(s1, side1 * r) and offset_surface(s2,
side2 * r) (the longest one if there are several), used as start values. At every section parameter t the exact ball centre C(t) is solved in the plane through spine0(t) normal to the spine tangent (Newton on |C - S1| = r, |C - S2| = r with closest-point projections); contact points are the foot points (with parameters for the p-curves). Sections are the shorter circular arcs (rational, exact) from contact 1 to contact 2 around C; they are skinned (loft, cubic in v) and the section count is refined (interval bisection) until the deviation from the ideal rolling-ball surface at 3 x 17 check points per interval is below options.tolerance. Spine and p-curves are cubic interpolations of the exact section data, contact curves are the boundary iso-curves of the fillet surface.
The fillet is untrimmed and extends over the whole spine (until the offsets leave a parameter domain); s1 and s2 are not trimmed. Throws GeometryError if the offsets do not intersect, the ball cannot be placed (Newton fails, e.g. at tangential configurations), or the tolerance cannot be met with max_sections.
-
NurbsSurface coons(const NurbsCurve &c0, const NurbsCurve &c1, const NurbsCurve &d0, const NurbsCurve &d1, double tolerance = 1e-7)¶
Bilinearly blended Coons patch from four boundary curves: S(u, 0) = c0(u), S(u, 1) = c1(u), S(0, v) = d0(v), S(1, v) = d1(v) on [0, 1]^2. Curve orientations are corrected automatically (d0 must connect the starts of c0 and c1, d1 their ends); corners must agree within
tolerance. Non-rational boundaries are interpolated exactly. Rational boundaries (arcs, conics) are exact too when their weights can be made to agree at the corners by scaling each curve’s weights (e.g. arcs from make_arc, whose end weights are 1): the Boolean sum is then taken in homogeneous coordinates and the result is rational. Otherwise they are replaced by non-rational approximations withintolerancefirst.
-
NurbsSurface gordon(const std::vector<NurbsCurve> &u_curves, const std::vector<NurbsCurve> &v_curves, double tolerance = 1e-7)¶
Gordon surface through a curve network: u_curves run in u and are ordered in v, v_curves run in v and are ordered in u (at least two of each). Every u-curve must meet every v-curve, with consistent parameters: the intersection parameters u_l (on all u-curves) and v_k (on all v-curves) are determined from the network and checked within
tolerance. The result interpolates all network curves (domain [0, 1]^2); degrees across the curves are min(3, count - 1). Rational curves are approximated as in coons().
-
std::vector<double> loft_parameters(const std::vector<NurbsCurve> §ions, Parametrization method = Parametrization::Centripetal)¶
Parameters v_k of the sections (first 0, last 1), averaged over the columns of the compatible control polygons (P&T Eq. 10.8). The sections are made compatible internally.
-
NurbsSurface loft(const std::vector<NurbsCurve> §ions, std::size_t degree_v = 3, Parametrization method = Parametrization::Centripetal)¶
Skinned surface through the section curves, in the given order. u follows the sections (domain [0, 1], made compatible: common degree and knots), v runs across them with degree min(degree_v, number of sections - 1). S(u, v_k) = C_k(u) for the section parameters v_k of loft_parameters. Rational sections are interpolated in homogeneous space; throws GeometryError if that would produce non-positive weights, or for fewer than two sections.
-
NurbsSurface loft(const std::vector<NurbsCurve> §ions, std::size_t degree_v, const std::vector<double> &v_params)¶
As above with explicit, strictly increasing section parameters (the v domain is [v_params.front(), v_params.back()]).
-
NurbsCurve offset_curve(const NurbsCurve &c, double distance, const Vec3 &plane_normal, double tolerance = 1e-7)¶
Planar offset c(t) + d * normalize(plane_normal x c’(t)) of a curve lying in a plane with the given normal (d > 0: to the left of the direction of travel, seen from the tip of plane_normal; e.g. inwards for a counter-clockwise circle about +z).
The result is a non-rational cubic B-spline on the domain of c with offset(t) belonging to c(t). Every Bézier segment of c is fitted separately (rational curves such as circles are only C1 at their knots) to tolerance/2 and the pieces are joined with nf::join, so the result has (at most) C0 knots at the knots of c. Throws GeometryError if the control points do not lie in a plane normal to plane_normal (within
tolerance), if c’ vanishes, if c has a tangent discontinuity at a knot (the offset would have a gap larger than tolerance/2), if d * signed curvature >= 1 somewhere (cusp: |d| reaches the radius of curvature on the concave side), or if the tolerance cannot be reached.
-
NurbsSurface offset_surface(const NurbsSurface &s, double distance, double tolerance = 1e-7)¶
Offset surface S(u,v) + d * N(u,v) with the unit normal N = normal(u, v) (limit normals at poles, so offsets of revolved surfaces with poles are well defined).
The result is a non-rational tensor-product spline of degree 5 x 5 (quintic: the error decreases like h^6, so far fewer control points are needed than with a bicubic at tight tolerances) on the domain of s with offset(u,v) belonging to S(u,v). The knot lines of s are kept as break lines (with a multiplicity matching the continuity of s, up to C0). Knots are first inserted adaptively from fits along iso-lines (to tolerance/2 per direction), then the tensor-product fit is verified at 9 x 9 check points of every knot rectangle (failing rectangles are refined further). Exact references: plane -> plane, sphere -> concentric sphere R + d, cylinder -> coaxial cylinder, torus -> torus with tube radius r + d (signs follow the normal orientation). Throws GeometryError if d * k >= 1 for a principal curvature k (relative to N) on a sample grid (9 x 9 points per knot rectangle), if the normal is discontinuous across a knot line by more than the tolerance allows, or if the tolerance cannot be reached. Local self-intersections are not removed.
-
std::vector<Transform> linear_pattern(const Vec3 &step, std::size_t count)¶
Transforms for
countcopies alongstep(first copy = identity).
-
std::vector<Transform> grid_pattern(const Vec3 &step_a, std::size_t count_a, const Vec3 &step_b, std::size_t count_b)¶
Rectangular grid: count_a x count_b copies (row-major).
-
std::vector<Transform> polar_pattern(const Vec3 &axis_point, const Vec3 &axis_dir, std::size_t count, double total_angle)¶
countcopies rotated about an axis, evenly spread overtotal_angle(radians). For a full circle (2*pi) the last copy does not coincide with the first.
-
template<class Geometry>
std::vector<Geometry> apply_pattern(const Geometry &g, const std::vector<Transform> &ts)¶ Applies a set of transforms to a geometry object.
-
ProjectedCurve project_curve(const NurbsCurve &curve, const NurbsSurface &surface, const Vec3 &direction = {0, 0, 0}, double tolerance = 1e-6)¶
Projects a curve onto a surface: along the surface normal (closest points;
directionzero) or alongdirection(every point moved parallel to it until it meets the surface). The projected points are interpolated (cubic, with the parameters of the input curve) and points are added until the 3D curve and the image of the p-curve are withintoleranceof the exact projections at the midpoints between them. Throws GeometryError if a point does not project (a ray misses the surface), or if the projection crosses the seam of a closed surface (split the curve there).
-
NurbsCurve project_to_plane(const NurbsCurve &curve, const Plane &plane, const Vec3 &direction = {0, 0, 0})¶
Parallel projection onto a plane: every point moves along
direction(zero: along the plane normal, i.e. orthogonal projection) until it meets the plane. The map is affine, so the projection of the control points (weights kept) is exact. Throws GeometryError if the direction is parallel to the plane.
-
NurbsSurface project_to_plane(const NurbsSurface &surface, const Plane &plane, const Vec3 &direction = {0, 0, 0})¶
Parallel projection of a surface onto a plane (exact, see the curve overload).
-
ProjectedCurve interpolate_on_surface(const NurbsSurface &surface, const std::vector<Vec3> &points, std::size_t degree = 3, bool points_are_uv = false, double tolerance = 1e-6)¶
A curve on a surface through points: the points are projected onto the surface (closest points, continued from the previous point so that the curve stays on one branch), or taken as (u, v, 0) parameter points if
points_are_uv; the p-curve interpolates them in the parameter domain (degreedegree, parameters by chord length of the 3D points), and the 3D curve follows S(pcurve(t)) withintolerance. Both share the parameter t in [0, 1]. Throws GeometryError for fewer than 2 points, or if consecutive points lie on opposite sides of the seam of a closed surface.
-
ProjectedCurve offset_on_surface(const NurbsSurface &surface, const NurbsCurve &pcurve, double distance, double tolerance = 1e-6)¶
Offset of a curve within a surface (geodesic offset): from every point S(pcurve(t)) a geodesic of length |distance| is traced perpendicular to the curve, to the left of its direction seen from the surface normal S_u x S_v for distance > 0 (to the right for distance < 0). The geodesics are integrated with parallel transport of the direction (midpoint rule, steps halved until converged); the end points are interpolated like project_curve until the offset curve and its p-curve are within
toleranceof the exact offset points. The result shares the parameter ofpcurve. Throws GeometryError if a geodesic leaves the surface’s parameter domain or the surface is degenerate on the way.
-
RebuiltCurve rebuild_curve(const NurbsCurve &curve, std::size_t num_ctrl, std::size_t degree = 3)¶
Rebuilds a curve as a non-rational B-spline of the given degree with
num_ctrlcontrol points and uniform knots on the same domain: least-squares fit of dense samples at their parameters (end points interpolated), so the parametrisation is kept. The reported error compares points at equal parameters, an upper bound of the geometric deviation. Throws GeometryError if num_ctrl < degree + 1.
-
RebuiltSurface rebuild_surface(const NurbsSurface &surface, std::size_t num_u, std::size_t num_v, std::size_t degree_u = 3, std::size_t degree_v = 3)¶
Rebuilds a surface as a non-rational B-spline surface with num_u x num_v control points, degrees degree_u x degree_v and uniform knots on the same domain (least squares on a dense grid, rows then columns; corners interpolated). The error is measured as for rebuild_curve on a grid four times denser than the fit grid.
-
std::vector<NurbsSurface> extrude_tapered(const NurbsCurve &profile, const Vec3 &direction, double angle, double tolerance = 1e-7)¶
Tapered (drafted) extrusion of a planar profile along
direction(normal to the profile’s plane; its length is the height): the top curve is the profile offset in its plane by height * tan(angle), outwards for angle > 0 (the section grows), inwards for angle < 0, and moved bydirection. For an open profile “outwards” is the left side seen from the tip ofdirection. The profile is split at its corners (tangent discontinuities); the offset pieces are mitred (extended or cut where neighbours meet), and every piece gives one ruled surface from the profile piece to its top piece. Offsets are fitted totolerance(offset_curve); line pieces give exact planar faces. |angle| must be below 90 degrees.
-
std::vector<NurbsSurface> ribbon(const NurbsCurve &curve, double width, const Vec3 &plane_normal, double tolerance = 1e-7)¶
Planar ribbon along a curve: ruled surfaces between the curve and its offset by
widthin the plane with normalplane_normal(width > 0: to the left, seen from the tip of the normal). Corners are mitred as in extrude_tapered; one surface per smooth piece.
-
NurbsSurface extrude_to_point(const NurbsCurve &curve, const Vec3 &apex)¶
Extrusion of a curve to a point (cone over the curve): the ruled surface from the curve (u, as given; v = 0) to the apex (v = 1, a degenerate side with a limit normal). Exact, also for rational curves (a circle gives an exact circular cone).
-
NurbsSurface triangle_patch(const NurbsCurve &c0, const NurbsCurve &c1, const NurbsCurve &c2, double tolerance = 1e-7)¶
Three-sided patch bounded by c0, c1, c2 forming a closed loop (in any orientation; corners must agree within
tolerance): a Coons patch with c0 as one side and the corner opposite to it as a degenerate side (v = 1), so the patch is regular except at that corner, where the limit normal is used. Exact for non-rational curves; rational curves as in coons().
-
NurbsSurface sweep_translational(const NurbsCurve &profile, const NurbsCurve &trajectory)¶
Exact translational sweep S(u, v) = C(u) + T(v) - T(v0): tensor product with P_ij = P_i + Q_j and w_ij = w_i w_j (works for rational curves). u: profile, v: trajectory.
-
NurbsSurface sweep(const NurbsCurve &profile, const NurbsCurve &trajectory, const SweepOptions &options = {})¶
Sweeps the profile along the trajectory. The profile is given in world coordinates at the start of the trajectory; at parameter v it is moved to T(v) and rotated by the frame change from T(v0) to T(v) (plus twist). The surface (u: profile on [0, 1], v: trajectory domain) is skinned through exactly placed copies of the profile; their number is doubled until the deviation from the ideal sweep is below options.tolerance. Throws GeometryError if the tolerance cannot be met with max_sections or the trajectory has a vanishing tangent. With SweepFrame::Fixed and no twist the exact translational sweep is returned.
-
NurbsSurface sweep(const std::vector<NurbsCurve> &profiles, const NurbsCurve &trajectory, std::vector<double> params = {}, const SweepOptions &options = {})¶
Sweep with several profiles: profile k is given in world coordinates where it crosses the trajectory, at trajectory parameter params[k] (empty: the parameter of the trajectory point nearest to the profile). Every profile is moved back to the trajectory start by the inverse of its placement (frame as in sweep()); the moved profiles are lofted over the parameters (cubic for four or more), so the section at v is that blended shape placed at v. Before the first and after the last profile the shape is constant. Closed profiles should have aligned seams. Same skinning and tolerance control as sweep(); u on [0, 1], v the trajectory domain.
-
NurbsSurface rail_revolve(const NurbsCurve &profile, const NurbsCurve &rail, const Vec3 &axis_point, const Vec3 &axis_dir, bool scale_height = false, const SweepOptions &options = {})¶
Rail revolve: the profile is revolved about the axis while its end nearer to the rail follows the rail. At rail parameter v the profile is rotated about the axis to the angle of rail(v) and scaled about the axis in the radial direction so that this end reaches the rail’s distance from the axis; with
scale_heightit is also scaled along the axis (about the axis point) to the rail’s height, otherwise heights are kept. The other end of a profile starting on the axis stays there, e.g. a reflector with a non-round rim. u: profile on [0, 1], v: rail domain (closed rail: closed surface). Same skinning and tolerance control as sweep(). Throws GeometryError if the profile end or the rail touches the axis.
-
NurbsSurface sweep2(const NurbsCurve &profile, const NurbsCurve &rail1, const NurbsCurve &rail2, const SweepOptions &options = {})¶
Two-rail sweep: the profile, given at the rail starts, is moved, rotated and uniformly scaled so that the points it had on rail1(v0) and rail2(v0) follow rail1(v) and rail2(v) (rail2 is linearly reparametrised to rail1’s domain). The orientation about the rail-to-rail axis follows the tangent of rail1. Same skinning and tolerance control as sweep().
-
NurbsSurface pipe_surface(const NurbsCurve &path, const std::function<double(double)> &radius, const SweepOptions &options = {})¶
Pipe surface: a circle swept along
pathwith the rotation-minimising frame, its radius given byradius(t)for the normalised path parameter t in [0, 1] (t = 0 at the path start). u runs around the circle on [0, 1], v along the path domain. Same skinning and tolerance control as sweep(); the radius function must be smooth and positive.
-
std::vector<double> basis_functions(std::size_t span, double u, std::size_t degree, const KnotVector &knots)¶
Non-vanishing basis functions N_{span-p..span, p}(u) (A2.2). Size p+1.
-
std::vector<std::vector<double>> basis_function_derivatives(std::size_t span, double u, std::size_t degree, std::size_t n, const KnotVector &knots)¶
Basis functions and their derivatives up to order n (A2.3). Result[k][j] = k-th derivative of N_{span-p+j, p}(u). Size (n+1) x (p+1).
-
NurbsCurve join(const NurbsCurve &a, const NurbsCurve &b, double tolerance = tol::kLength)¶
Joins curve b to the end of curve a. The end point of a and the start point of b must agree within
tolerance; a remaining gap is closed at its midpoint. Degrees are unified by elevation, b’s weights are rescaled to match at the joint, and b’s parameter interval is shifted to start at a’s domain end (keeping its length). The joint knot is then removed as far as this is exact (tol::kLength), so joining the two halves of a split restores the original continuity. Throws GeometryError if the curves do not meet.
-
NurbsSurface join_u(const NurbsSurface &a, const NurbsSurface &b, double tolerance = tol::kLength)¶
Joins surface b to surface a across the boundary u = u_max of a / u = u_min of b. The surfaces are made compatible in v (degree elevation, b reparametrised to a’s v domain, common knots) and in the u degree. The boundary control rows must agree within
tolerance, and for rational surfaces their weights must be proportional. b’s u interval is shifted to start at a’s u_max. The seam knot is removed as far as this is exact. Throws GeometryError otherwise.
-
NurbsSurface join_v(const NurbsSurface &a, const NurbsSurface &b, double tolerance = tol::kLength)¶
As join_u, across v = v_max of a / v = v_min of b.
-
void validate_knots(const KnotVector &knots, std::size_t degree, std::size_t n_ctrl)¶
Validates a knot vector for a B-spline of given degree with n_ctrl control points. Checks size (n_ctrl + degree + 1), monotonicity and interior multiplicity <= degree. Throws GeometryError on failure.
-
KnotVector clamped_uniform_knots(std::size_t degree, std::size_t n_ctrl)¶
Clamped (open) uniform knot vector on [0, 1].
-
std::size_t find_span(std::size_t n, std::size_t degree, double u, const KnotVector &knots)¶
Index of the knot span containing u (Piegl & Tiller, A2.1). n = n_ctrl - 1. Returns n for u == knots[n+1].
-
std::size_t knot_multiplicity(const KnotVector &knots, double u)¶
Multiplicity of value u inside the knot vector (within tolerance).
-
std::pair<std::vector<double>, std::vector<int>> unique_knots(const KnotVector &knots)¶
Distinct knot values and their multiplicities (format used e.g. by gmsh / OCC).
-
double zernike(std::size_t j, ZernikeIndexing indexing, double rho, double theta)¶
Zernike polynomial Z_j(rho, theta) (j >= 1).
-
void zernike_nm(std::size_t j, ZernikeIndexing indexing, int &n, int &m)¶
Radial order n and azimuthal frequency m (m < 0: sine term) of Z_j.
-
NurbsCurve asphere_profile(const Asphere &a, double r_max, double tolerance = 1e-7)¶
Profile curve (r, 0, z(r)) for 0 <= r <= r_max in the xz-plane. Pure conics are exact (piecewise rational quadratic); otherwise a cubic spline graph whose sag error is below
toleranceat dense check points (x(t) = r exactly, slope 0 at the vertex).
-
NurbsSurface asphere_surface(const Asphere &a, double r_max, double tolerance = 1e-7)¶
Surface of revolution of asphere_profile about the z axis (u: azimuth, v: radius). Exact for pure conics (sphere, ellipsoid, paraboloid, hyperboloid).
-
NurbsSurface sag_surface(const std::function<double(double, double)> &f, double x0, double x1, double y0, double y1, std::size_t degree = 3, double tolerance = 1e-7, std::size_t max_spans = 256)¶
Graph surface (x, y, f(x, y)) over [x0, x1] x [y0, y1]: tensor-product spline of the given degree with x, y exactly linear; knots are inserted adaptively until |S_z - f| <= tolerance at 8 x 8 check points per knot rectangle. Polynomials of degree <=
degreeare reproduced exactly. Throws GeometryError if f is not finite somewhere or max_spans is exceeded.
-
NurbsSurface zernike_surface(const ZernikeSag &z, double half_width = 0.0, double tolerance = 1e-7)¶
Zernike surface over the square [-half_width, half_width]^2 (default: norm_radius).
-
NurbsSurface xy_polynomial_surface(const XYPolynomialSag &p, double half_width = 0.0, double tolerance = 1e-7)¶
XY polynomial surface over the square [-half_width, half_width]^2 (default: norm_radius).
-
bool point_in_shell(const Shell &shell, const Vec3 &p, double tolerance = 1e-6)¶
True if p lies inside the closed shell (ray casting: intersections of rays with the trimmed faces are counted; rays hitting a face boundary or grazing a face are discarded and the result is the majority of several valid rays).
-
Shell boolean(const Shell &a, const Shell &b, BooleanOp op, double tolerance = 1e-6)¶
Boolean operation of two closed shells. Every pair of faces is intersected; the intersection curves are clipped to the part lying in both trimmed faces, the faces are split along them (planar arrangement in their parameter domains), every piece is classified as inside or outside the other shell, and the selected pieces are sewn: Union: A outside B + B outside A Intersection: A inside B + B inside A Difference: A outside B + (B inside A, flipped) Coincident faces (detected by sampling before the surface/surface intersection) are cut along each other’s boundary; their common part is classified “on” with the same or the opposite outward normal: kept once for union and intersection if the normals agree, kept from A for a difference if they are opposite, dropped otherwise. An empty result is an empty shell. Tangential contacts (at a point or along a line) and overlaps thinner than the tolerance are treated as contacts. The inputs are oriented outwards first. Limitation: coincident faces whose common part crosses the seam of a closed surface. Throws GeometryError for open input shells.
-
std::pair<Shell, Shell> split(const Shell &shell, const Plane &plane, double tolerance = 1e-6, const std::string &cut_label = "cut")¶
Splits a closed shell by a plane into the part below (opposite to the normal) and the part above (on the side of the normal); both are closed. The new faces in the plane get the label
cut_label, e.g. to apply a symmetry boundary condition there; all other faces keep their labels. A part is an empty shell if the plane does not cut the solid. Implemented as the intersection and difference with a half-space box that covers the shell.
-
std::vector<std::size_t> edges_between(const Shell &shell, const std::string &label_a, const std::string &label_b)¶
Indices of the edges shared by a face labelled
label_aand a face labelledlabel_b(e.g. edges_between(box, “top”, “front”)).
-
Shell fillet_edges(const Shell &shell, const std::vector<std::size_t> &edges, double radius, const EdgeBlendOptions &options = {})¶
Rounds edges of a shell with a rolling-ball fillet (constant radius, or variable with options.sizes).
The selected edges are grouped by their two adjacent faces; each group (one edge, a chain of edges, or a closed loop such as the rim of a cylinder) is filleted with one surface: the rolling-ball fillet between the two face surfaces (fillet_surfaces; the ball lies inside the material at a convex edge and outside at a concave edge, which adds material). The two faces are cut back along the contact curves. An open chain ends at a vertex of three faces (the two faces and a third one, E):
only this chain ends there: the fillet is trimmed by E along the exact intersection curve and E’s boundary is rerouted along it (convex: the corner is cut off; concave: E grows into the corner);
a second chain (between one of the two faces and E) ends there and E is tangent to the other face (a tangent-continuous chain, e.g. the rim of a rounded rectangle): both fillets end at their common cross-section;
a second chain ends there at a sharp edge: the two fillets are trimmed by each other along their exact intersection curve (mitre); where one of them runs past the edge between the other faces, it is trimmed by the face there, which grows into the corner;
three chains end there (all three edges of the corner): every fillet ends at its cross-section through the ball touching all three faces, and the corner is closed by the spherical triangle of that ball between the three contact points (exact, tangent to the three fillets). The new faces are labelled options.label (“fillet”); all other labels are kept.
Throws GeometryError if an edge is not shared by exactly two faces, if a chain ends at a vertex that does not join exactly three faces and three edges, if a chain continues tangentially into an edge that is not selected, if a convex and a concave chain meet, if the radius is too large for the faces (a contact curve leaves a face through another edge), or if the result is not closed.
-
Shell chamfer_edges(const Shell &shell, const std::vector<std::size_t> &edges, double distance, const EdgeBlendOptions &options = {})¶
Chamfers edges of a shell: a ruled cut from the curve at (geodesic) distance
distancefrom the edge on one face to the curve at the same distance on the other face (variable with options.sizes). Grouping, ends, labels (“chamfer”) and errors as for fillet_edges; convex edges lose material, concave edges gain it. At a corner of three chamfered edges the chamfers end at the straight lines between the points where their contact curves cross, and the corner is closed by the planar triangle of these points (faces at the corner must be planar).
-
Region region_boolean(const Region &a, const Region &b, BooleanOp op, double tolerance = 1e-9)¶
Union, intersection or difference (a minus b) of two planar regions. The curves stay exact: they are split at their intersections and the pieces bounding the result are kept as they are (shared boundary pieces of touching regions cancel).
toleranceis the model-space tolerance for intersections and for chaining. An empty result is an empty region.
-
double region_area(const Region ®ion)¶
Area of a region (outer loops minus holes), by Green’s theorem on the exact curves.
-
Region oriented(const Region ®ion)¶
The region oriented with the material on the left: outer loops counter-clockwise, holes clockwise (by nesting depth).
-
Shell cap(const Shell &shell, double tolerance = 1e-6, const std::string &label = "cap")¶
Closes the planar openings of a shell: the free edges are chained into closed loops, each loop must lie in a plane (within
tolerance), and loops in the same plane become one planar face (nested loops: holes, e.g. the annular end of a tube; islands inside holes are new faces). The faces are planar rectangles trimmed exactly by the opening’s edges (the trim curves are the edge curves mapped affinely into the rectangle’s parameter space). They get the labellabel; the result is sewn and oriented outwards. A closed shell is returned unchanged. Throws GeometryError if a loop does not close or is not planar.
-
Shell thicken(const Shell &shell, double thickness, bool symmetric = false, double tolerance = 1e-6, const std::string &wall_label = "wall")¶
Gives an open shell (or a single face, sewn into a shell) a wall thickness: every face is offset along its normal S_u x S_v by
thickness(negative: against the normal; withsymmetricby +-thickness/2 on both sides), keeping its trim loops, and every free edge is closed by a ruled side wall between the edge and its offset. The result is sewn and oriented outwards; the offset faces keep their labels with the suffix “_offset” (unlabelled faces: “offset”), the side walls getwall_label. The faces must join smoothly (tangent-continuous) along their shared edges, so that their offsets meet; at a crease the result is not closed and GeometryError is raised, as it is where |thickness| reaches a radius of curvature (offset_surface).
-
Shell make_pipe(const NurbsCurve &path, const std::function<double(double)> &radius, double tolerance = 1e-6)¶
Solid pipe along
path: the pipe surface (pipe_surface, radius(t) for t in [0, 1]) closed by planar discs at both ends (cap). Faces are labelled “wall”, “inlet” (path start) and “outlet” (path end); a closed path gives a ring without end faces.toleranceis the deviation of the wall from the ideal pipe and the sewing tolerance is 100 times larger.
-
Shell make_pipe(const NurbsCurve &path, double start_radius, double end_radius = -1.0, double tolerance = 1e-6)¶
Pipe with a radius varying linearly from
start_radiustoend_radius(negative end radius: constant).
-
Shell remove_holes(const Shell &shell, double max_size, double tolerance = 1e-6)¶
Defeaturing: removes holes smaller than
max_sizefrom a closed shell. Every hole loop of a face whose 3D extent (bounding-box diagonal) is belowmax_sizeis dropped – the face is filled there – and the faces that formed the feature (the bore wall of a through hole; wall and bottom of a blind hole) are removed: after dropping the loops they are attached to the rest only along free edges, and they are deleted repeatedly until the shell is closed again. Throws GeometryError if the result is not closed (e.g. a feature that is not a hole).
-
Shell hollow(const Shell &shell, double thickness, const std::vector<std::string> &open_labels = {}, double tolerance = 1e-6)¶
Hollows a smooth closed shell: every face is offset by
thicknessagainst its outward normal, and the offset shell becomes an inner void (Shell with two components). Withopen_labelsthe faces carrying these labels are removed and the rest is thickened inwards instead (thicken), giving a cup-like part open at those faces. Like thicken, the faces must join smoothly, so that their offsets meet (GeometryError otherwise).
-
Shell merge_faces(const Shell &shell, double tolerance = 1e-6)¶
Defeaturing: merges adjacent faces that lie on the same surface and carry the same label into one face – e.g. the coplanar pieces of the top faces after the union of two boxes. Faces qualify if they share an edge and either have the same surface (pieces of one split face) or are planar parallelograms in one plane with the same normal; the merged face is the common surface or a rectangle in that plane, trimmed by the union of the regions (shared boundary pieces cancel, T-junctions are resolved). Trim curves stay exact (affine maps between planar parametrisations). Groups whose boundary does not form valid loops are left as they are. The result is sewn and oriented like the input.
-
Shell make_box(const Vec3 &corner, const Vec3 &size)¶
Axis-aligned box with one corner at
cornerand edge lengths size.x, size.y, size.z (> 0): six planar faces.
-
Shell make_sphere(const Vec3 ¢er, double radius)¶
Sphere: one revolved face (semicircle about the axis through the centre parallel to z), poles at centre +- radius z.
-
Shell make_cylinder(const Vec3 &base, const Vec3 &axis, double radius, double height)¶
Circular cylinder with the base disc centred at
base, axis directionaxis(normalised) and the given height: the extruded circle plus two planar lids trimmed by exact circles.
-
Shell make_cone(const Vec3 &base, const Vec3 &axis, double r0, double r1, double height)¶
Truncated cone (frustum): radius r0 at
base, r1 at base + height axis. One of the radii may be 0 (a cone with its apex as a pole of the revolved side face; no lid there).
-
Shell make_torus(const Vec3 ¢er, const Vec3 &axis, double major_radius, double minor_radius)¶
Torus about the axis through
centerwith directionaxis: major radius R (centre to tube centre) and tube radius r, 0 < r < R. One doubly periodic revolved face.
-
TrimLoop rectangle_loop(double u0, double u1, double v0, double v1)¶
Rectangle [u0, u1] x [v0, v1] as a counter-clockwise loop of four lines.
-
TrimLoop circle_loop(double cu, double cv, double r)¶
Exact circle of radius r about (cu, cv) in the parameter plane (counter-clockwise).
-
TrimLoop polygon_loop(const std::vector<std::array<double, 2>> &points)¶
Closed polygon through the given parameter points.
-
std::vector<TrimmedSurface> split(const NurbsSurface &surface, const NurbsSurface &cutter, const Tolerance &tol = {})¶
Splits
surfacealong its intersection curves withcutterinto trimmed regions (the p-curves onsurfaceof surface/surface intersection). Open curves run from boundary to boundary of the parameter domain (seams count as boundary) and must not cross each other; closed curves become holes of the region around them and outer loops of new regions (nested loops are supported). Returns the untrimmed surface if there is no intersection.
-
std::vector<TrimmedSurface> split(const TrimmedSurface &face, const std::vector<NurbsCurve> &cuts, const Tolerance &tol = {})¶
Splits a trimmed face along parameter-space curves (general planar arrangement): the cuts are clipped to the region, all curves are split at their mutual intersections, dangling pieces are removed, and the faces of the resulting graph are traced (next half-edge clockwise at every vertex). Counter-clockwise cycles inside the face become regions; clockwise cycles (component boundaries) become holes of the smallest region containing them. Cuts may end on the trim loops or on other cuts and may cross each other.
-
std::vector<TrimmedSurface> split(const NurbsSurface &surface, const std::vector<NurbsCurve> &pcurves, const Tolerance &tol = {})¶
Splits
surfaceinto regions along the given parameter-space curves (same rules as above).
Variables
-
constexpr double kIntegrationRelTol = 1e-10¶
Default relative accuracy of the adaptive integrators.
-
struct CurvePoint¶
- #include <nurbforge/analysis/closest_point.hpp>
Foot point on a curve.
-
struct SurfacePoint¶
- #include <nurbforge/analysis/closest_point.hpp>
Foot point on a surface.
-
struct HatchOptions¶
- #include <nurbforge/analysis/hatch.hpp>
Public Members
-
double phase = {0.0}¶
Offset of the line family along the line normal n (see hatch): the lines are n . p = phase + k * spacing for integer k, measured from the origin of the loop coordinates, so the same phase gives the same lines in every layer.
-
std::vector<double> contours¶
Inward offset distances (> 0) of the contour lines; one closed contour per loop and distance.
-
double min_length = {0.0}¶
Hatch segments shorter than this are dropped.
-
double tolerance = {0.0}¶
Length tolerance (model units) for contacts: where a loop comes within this distance of a hatch line without crossing it (tangential contact, an edge lying on the line) the line is not split. 0: 1e-9 of the model size.
-
double contour_tolerance = {0.0}¶
Fit tolerance of the contour curves (see offset_curve). 0: 1e-7 of the model size.
-
double phase = {0.0}¶
-
struct HatchSegment¶
- #include <nurbforge/analysis/hatch.hpp>
One hatch segment, inside the region bounded by the loops.
Public Functions
-
inline double length() const¶
Public Members
-
std::int64_t line = {0}¶
index k of the hatch line n . p = phase + k * spacing
-
std::size_t region = {0}¶
index of the outer loop (area > 0) of the region containing it
-
std::size_t start_loop = {0}¶
loop on which the segment starts
-
std::size_t end_loop = {0}¶
loop on which the segment ends
-
inline double length() const¶
-
struct HatchContour¶
- #include <nurbforge/analysis/hatch.hpp>
Closed contour line: boundary of the region shrunk by
distance, oriented like the loops (region on the left). Usually the offset of one loop; where the region splits (a neck narrower than 2 distance) a loop gives several contours, and where a hole comes closer than 2 distance to another loop their contours merge into one.Public Members
-
std::vector<NurbsCurve> curves¶
consecutive pieces (offsets, arcs at reflex corners)
-
std::size_t loop = {0}¶
loops.front()
-
std::vector<std::size_t> loops¶
indices of the loops it was offset from (sorted)
-
std::size_t index = {0}¶
index of the distance in HatchOptions::contours
-
double distance = {0.0}¶
-
std::vector<NurbsCurve> curves¶
-
struct Hatching¶
- #include <nurbforge/analysis/hatch.hpp>
Public Members
-
std::vector<HatchSegment> segments¶
Sorted by line index, then along the direction.
-
std::vector<HatchContour> contours¶
Sorted by (first) source loop, then by the order of the distances in HatchOptions::contours.
-
std::vector<HatchSegment> segments¶
-
struct CurveCurveIntersection¶
- #include <nurbforge/analysis/intersect.hpp>
-
struct CurveSurfaceIntersection¶
- #include <nurbforge/analysis/intersect.hpp>
-
struct SurfaceCurvature¶
- #include <nurbforge/analysis/properties.hpp>
Curvature of a surface at a point, relative to the unit normal n = S_u x S_v / |S_u x S_v|.
-
struct SectionOptions¶
- #include <nurbforge/analysis/shell_section.hpp>
Public Members
-
double join_tolerance = {1e-6}¶
Chaining tolerance (model units): ends of neighbouring section pieces closer than this are joined (the shell’s sewing tolerance; trim loops are reconstructed to a tenth of it).
-
double fit_tolerance = {0.0}¶
Accuracy of the traced and fitted section curves on general faces (model units); 0: 1e-9 of the model size. Faces whose height along the plane normal depends on one parameter only (extrusions and revolutions about the normal, planar faces) give exact isoparametric curves.
-
double join_tolerance = {1e-6}¶
-
struct SectionCurve¶
- #include <nurbforge/analysis/shell_section.hpp>
One piece of a section loop: a curve on one face of the shell.
Public Functions
Public Members
-
NurbsCurve curve¶
in the plane coordinates (s, t, 0)
-
NurbsCurve curve3d¶
the same curve in 3D (same parameter)
-
NurbsCurve pcurve¶
(u, v, 0) on the surface of the source face (same parameter)
-
std::size_t face = {0}¶
index of the source face in the shell
-
bool exact = {false}¶
isoparametric curve of the face; otherwise traced and fitted
-
NurbsSurface surface¶
surface of the source face (for the normal)
-
double normal_sign = {1.0}¶
-
NurbsCurve curve¶
-
struct SectionLoop¶
- #include <nurbforge/analysis/shell_section.hpp>
Closed loop of section pieces (end of one = start of the next within the join tolerance), oriented with the solid on the left in (s, t): outer loops counter-clockwise (area > 0), voids and holes clockwise (area < 0).
-
struct PlanarSection¶
- #include <nurbforge/analysis/shell_section.hpp>
-
struct SurfaceSurfacePoint¶
- #include <nurbforge/analysis/surface_intersect.hpp>
A point on both surfaces with its parameters.
-
struct IntersectionCurve¶
- #include <nurbforge/analysis/surface_intersect.hpp>
One intersection curve.
Public Members
-
std::vector<SurfaceSurfacePoint> points¶
traced points in order (first == last if closed)
-
bool closed = {false}¶
-
NurbsCurve curve¶
cubic interpolation of the points in 3D (chord-length parameter)
-
NurbsCurve pcurve1¶
(u1, v1, 0) in the parameter domain of the first surface, same parameter
-
NurbsCurve pcurve2¶
(u2, v2, 0) in the parameter domain of the second surface
-
std::vector<SurfaceSurfacePoint> points¶
-
struct SurfaceIntersection¶
- #include <nurbforge/analysis/surface_intersect.hpp>
Public Members
-
std::vector<IntersectionCurve> curves¶
-
std::vector<SurfaceSurfacePoint> points¶
isolated (tangential) contact points
-
std::vector<IntersectionCurve> curves¶
-
struct SurfaceIntersectionOptions¶
- #include <nurbforge/analysis/surface_intersect.hpp>
Public Members
-
double chord_tolerance = {0.0}¶
Maximal deviation of the traced polyline from the true curve (model units); 0: 1e-4 of the model size. Controls the marching step.
-
double fit_tolerance = {0.0}¶
Accuracy of the fitted curves (model units): |S1(pcurve1(t)) - curve(t)| and |S2(pcurve2(t)) - curve(t)| are verified between all fit points and exact points are added where needed (e.g. near poles, where the p-curves vary quickly); 0: 1e-7 of the model size.
-
double chord_tolerance = {0.0}¶
-
class GeometryError : public std::runtime_error¶
- #include <nurbforge/core/error.hpp>
Thrown for invalid geometric input (bad knot vectors, degenerate axes, …).
Public Functions
-
inline explicit GeometryError(const std::string &what)¶
-
inline explicit GeometryError(const std::string &what)¶
-
class NotImplementedError : public std::logic_error¶
- #include <nurbforge/core/error.hpp>
Thrown for features that are planned but not yet implemented.
Public Functions
-
inline explicit NotImplementedError(const std::string &what)¶
-
inline explicit NotImplementedError(const std::string &what)¶
-
struct Tolerance¶
- #include <nurbforge/core/tolerance.hpp>
Per-operation tolerance set. Defaults equal the kernel constants in
nf::tol.
-
struct Vec3¶
- #include <nurbforge/core/vec.hpp>
Public Functions
-
constexpr Vec3() = default¶
-
inline constexpr Vec3(double x_, double y_, double z_)¶
-
inline explicit constexpr Vec3(const std::array<double, 3> &a)¶
-
inline constexpr std::array<double, 3> to_array() const¶
Friends
-
constexpr Vec3() = default¶
-
struct Vec4¶
- #include <nurbforge/core/vec.hpp>
Homogeneous (weighted) point: (w*x, w*y, w*z, w).
-
struct SurfaceFitOptions¶
- #include <nurbforge/fitting/fit.hpp>
Options for fit_surface.
Public Members
-
std::size_t degree_u = {3}¶
-
std::size_t degree_v = {3}¶
-
std::size_t num_u = {0}¶
Control points in u and v; 0 chooses about sqrt(points / 4) (at least degree + 1, at most 40). With boundary curves the count is reached by refining the Coons patch’s knots.
-
std::size_t num_v = {0}¶
-
double smoothing = {1e-3}¶
Weight of the thin-plate energy int |S_uu|^2 + 2 |S_uv|^2 + |S_vv|^2 du dv relative to the least-squares term (scaled by the ratio of the matrix traces, so the value does not depend on the size of the data or the number of points and control points). 0: plain least squares (a tiny energy still keeps control points without data defined); about 1e-3 barely changes smooth data; 0.1 … 1 smooths noisy data. Regions without data are filled smoothly.
-
std::size_t iterations = {2}¶
Parameter correction rounds: the points are projected onto the fitted surface and the surface is fitted again.
-
std::optional<NurbsSurface> base¶
Optional base surface for the initial parameters (closest points). Without base and boundary the points are projected onto their best-fit plane and the parameters are the plane coordinates scaled to [0, 1] over the bounding rectangle (a height field).
-
std::vector<NurbsCurve> boundary¶
Optional boundary curves {c0 (v = 0), c1 (v = 1), d0 (u = 0), d1 (u = 1)} as for coons(): the surface interpolates them exactly (non-rational curves) and the Coons patch is the base for the parameters.
-
std::size_t degree_u = {3}¶
-
struct FittedSurface¶
- #include <nurbforge/fitting/fit.hpp>
Result of fit_surface.
Public Members
-
NurbsSurface surface¶
-
double max_error = {0.0}¶
largest distance of a point from the surface (closest point)
-
double rms_error = {0.0}¶
root mean square of these distances
-
std::vector<std::array<double, 2>> parameters¶
(u, v) of each point’s foot point
-
NurbsSurface surface¶
-
struct LineFit¶
- #include <nurbforge/fitting/fit.hpp>
Best-fit line through points (orthogonal regression: minimises the sum of squared perpendicular distances).
-
struct PlaneFit¶
- #include <nurbforge/fitting/fit.hpp>
Best-fit plane through points (orthogonal regression).
-
struct Plane¶
- #include <nurbforge/geometry/plane.hpp>
Infinite plane through
pointwith normalnormal(normalised internally).
-
class Transform¶
- #include <nurbforge/geometry/transform.hpp>
Public Functions
-
Transform()¶
Identity.
-
inline explicit Transform(const std::array<double, 12> &m)¶
Row-major 3x4 matrix [R | t].
-
inline const std::array<double, 12> &matrix() const noexcept¶
-
Transform()¶
-
struct StepOptions¶
- #include <nurbforge/io/step.hpp>
Public Members
-
StepLengthUnit unit = {StepLengthUnit::Millimetre}¶
-
std::string name = {"nurbforge"}¶
Product name (PRODUCT entity) and FILE_NAME name.
-
std::string author = {}¶
-
std::string organization = {}¶
-
std::string timestamp = {}¶
ISO 8601 time stamp for FILE_NAME; empty: current UTC time.
-
double uncertainty = {1e-6}¶
Modelling uncertainty (UNCERTAINTY_MEASURE_WITH_UNIT, model units); readers such as OpenCASCADE use it as the initial vertex / edge tolerance.
-
std::vector<std::string> shell_names = {}¶
Names of the shells (one per shell passed to to_step / write_step, or empty): written as the name of their MANIFOLD_SOLID_BREP / BREP_WITH_VOIDS (and CLOSED_SHELL / OPEN_SHELL), read back by read_step_named. Applications assign materials or roles by these names.
-
StepLengthUnit unit = {StepLengthUnit::Millimetre}¶
-
struct StepReadOptions¶
- #include <nurbforge/io/step.hpp>
Public Members
-
StepLengthUnit unit = {StepLengthUnit::Millimetre}¶
Unit the geometry is converted to (from the length unit declared in the file).
-
double tolerance = {1e-6}¶
Sewing tolerance (target units); trim curves are fitted to a tenth of it.
-
bool skip_unsupported = {false}¶
Skip faces (or shells) with unsupported entities or failing trim-curve reconstruction instead of throwing; a message per skipped item is appended to
warnings(if set).
-
std::vector<std::string> *warnings = {nullptr}¶
-
double *file_unit_metres = {nullptr}¶
If set: receives the length unit declared in the file in metres (1e-3 for millimetres; 1e-3 if the file declares none), e.g. to detect files written with the wrong unit.
-
StepLengthUnit unit = {StepLengthUnit::Millimetre}¶
-
struct NamedShell¶
- #include <nurbforge/io/step.hpp>
A shell read from STEP with its name: the name of its MANIFOLD_SOLID_BREP / BREP_WITH_VOIDS (or of the OPEN_SHELL / CLOSED_SHELL of a surface model); if that is empty, the PRODUCT name.
-
struct TangentLine¶
- #include <nurbforge/modeling/blend.hpp>
A line segment tangent to curves: from point_a to point_b, touching curve a at param_a (or starting at the given point, param_a NaN) and curve b at param_b.
-
struct CurveFilletOptions¶
- #include <nurbforge/modeling/fillet.hpp>
Options of fillet_curves.
Public Members
-
int side_a = {0}¶
Side of the fillet centre relative to curve a: +1 = left of a’s direction of travel seen from the tip of plane_normal (the side of offset_curve(a, +r, plane_normal)), -1 = right, 0 = automatic (the corner formed by the kept parts of a and b, see fillet_curves).
-
int side_b = {0}¶
same for curve b (relative to b’s direction of travel)
-
bool trim = {true}¶
Trim a and b at the tangent points (CurveFillet::trimmed_a / trimmed_b).
-
std::optional<Vec3> corner = {}¶
If the curves intersect more than once: use the intersection nearest to this point (default: nearest to the midpoint of a’s end point and b’s start point).
-
double tolerance = {1e-7}¶
Fit tolerance of the auxiliary offset curves (start values only; the result is exact).
-
int side_a = {0}¶
-
struct CurveFillet¶
- #include <nurbforge/modeling/fillet.hpp>
Result of fillet_curves.
Public Members
-
NurbsCurve arc¶
Exact rational arc of radius r (make_arc) from point_a to point_b, oriented so that trimmed_a, arc, trimmed_b form a G1 chain (join(join(trimmed_a, arc), trimmed_b)).
-
double param_a = {0.0}¶
parameter of the tangent point on a
-
double param_b = {0.0}¶
parameter of the tangent point on b
-
std::optional<NurbsCurve> trimmed_a¶
The kept part of a (the side of param_a away from the corner), oriented to end at point_a; reversed with respect to a if the kept part lies after param_a. Empty if options.trim is false.
-
std::optional<NurbsCurve> trimmed_b¶
The kept part of b, oriented to start at point_b (reversed if it lies before param_b).
-
NurbsCurve arc¶
-
struct CurveChamferOptions¶
- #include <nurbforge/modeling/fillet.hpp>
Options of chamfer_curves.
-
struct CurveChamfer¶
- #include <nurbforge/modeling/fillet.hpp>
Result of chamfer_curves.
Public Members
-
NurbsCurve line¶
Straight segment (degree 1) from point_a to point_b; trimmed_a, line, trimmed_b form a chain (join(join(trimmed_a, line), trimmed_b)).
-
double param_a = {0.0}¶
parameter of the chamfer point on a
-
double param_b = {0.0}¶
parameter of the chamfer point on b
-
std::optional<NurbsCurve> trimmed_a¶
The kept part of a, oriented to end at point_a (as CurveFillet::trimmed_a). Empty if options.trim is false.
-
std::optional<NurbsCurve> trimmed_b¶
The kept part of b, oriented to start at point_b. Empty if options.trim is false.
-
NurbsCurve line¶
-
struct SurfaceFilletOptions¶
- #include <nurbforge/modeling/fillet.hpp>
Options of fillet_surfaces.
Public Members
-
int side1 = {1}¶
Side of the ball centre relative to s1: centre = contact point + side1 * r * N1 with the unit normal N1 = normalize(S1_u x S1_v) (the side of offset_surface(s1, side1 * r)). Must be +1 or -1.
-
int side2 = {1}¶
same for s2
-
double tolerance = {1e-6}¶
Deviation of the fillet surface from the ideal rolling-ball surface (and of spine, contact curves and mapped p-curves from their exact counterparts), verified at check points between the sections.
-
double offset_tolerance = {0.0}¶
Fit tolerance of the auxiliary offset surfaces (start values only); 0: tolerance / 10.
-
std::size_t max_sections = {1025}¶
-
std::optional<Vec3> near = {}¶
If the offset surfaces intersect in several curves: use the one passing nearest to this point (default: the longest one).
-
std::function<double(const Vec3&)> radius_at = {}¶
Variable radius: the ball radius of the section through the start-spine point Q is radius_at(Q) (empty: the constant
radius). The start spine (offset intersection) is computed withradius, which should lie within the range of radius_at; the sections are still exact rolling-ball arcs (centre at distance radius_at(Q) from both surfaces).
-
int side1 = {1}¶
-
struct SurfaceFillet¶
- #include <nurbforge/modeling/fillet.hpp>
Result of fillet_surfaces. All curves share the parameter t of the spine.
Public Members
-
NurbsSurface surface¶
u in [0, 1]: circular arcs of radius r from the contact on s1 (u = 0) to the contact on s2 (u = 1) around the spine point, in the plane normal to the spine tangent; v = t.
-
NurbsCurve spine¶
path of the ball centre
-
NurbsCurve contact1¶
contact curve on s1 (= surface boundary u = 0)
-
NurbsCurve contact2¶
contact curve on s2 (= surface boundary u = 1)
-
NurbsCurve pcurve1¶
(u1, v1, 0) of contact1 in the parameter domain of s1
-
NurbsCurve pcurve2¶
(u2, v2, 0) of contact2 in the parameter domain of s2
-
NurbsSurface surface¶
-
struct ProjectedCurve¶
- #include <nurbforge/modeling/project.hpp>
A curve on a surface: the 3D curve and its p-curve (u, v, 0) in the surface’s parameter domain, both with the parameter of the projected curve.
Public Members
-
NurbsCurve curve¶
3D curve on the surface
-
NurbsCurve pcurve¶
(u, v, 0) on the surface; S(pcurve(t)) = curve(t) within the tolerance
-
NurbsCurve curve¶
-
struct RebuiltCurve¶
- #include <nurbforge/modeling/surface_tools.hpp>
Result of rebuild_curve.
Public Members
-
NurbsCurve curve¶
-
double max_error = {0.0}¶
max |c(t) - rebuilt(t)| at dense samples (same parameter)
-
NurbsCurve curve¶
-
struct RebuiltSurface¶
- #include <nurbforge/modeling/surface_tools.hpp>
Result of rebuild_surface.
Public Members
-
NurbsSurface surface¶
-
double max_error = {0.0}¶
max |S(u, v) - rebuilt(u, v)| on a dense grid (same parameters)
-
NurbsSurface surface¶
-
struct SweepOptions¶
- #include <nurbforge/modeling/sweep.hpp>
Public Members
-
SweepFrame frame = {SweepFrame::RotationMinimizing}¶
-
double twist = {0.0}¶
additional rotation about the tangent at the end (radians), growing linearly with the trajectory parameter
-
double tolerance = {1e-6}¶
deviation from the ideal swept surface (model units), estimated at test points between the placed sections
-
std::size_t max_sections = {1025}¶
-
SweepFrame frame = {SweepFrame::RotationMinimizing}¶
-
class NurbsCurve¶
- #include <nurbforge/nurbs/curve.hpp>
NURBS curve C(u) = sum N_i,p(u) w_i P_i / sum N_i,p(u) w_i.
Control points are stored in Cartesian form, weights separately. Invariants (checked on construction): valid knot vector, weights > 0.
Public Functions
-
NurbsCurve(std::size_t degree, KnotVector knots, std::vector<Vec3> control_points, std::vector<double> weights = {})¶
Full constructor. Empty weights => non-rational (all weights 1).
-
inline std::size_t degree() const noexcept¶
-
inline const KnotVector &knots() const noexcept¶
-
inline const std::vector<double> &weights() const noexcept¶
-
inline std::size_t num_control_points() const noexcept¶
-
bool is_rational() const noexcept¶
-
inline double domain_start() const noexcept¶
Parameter domain [u_p, u_{n+1}].
-
inline double domain_end() const noexcept¶
-
std::vector<Vec3> derivatives(double u, std::size_t order) const¶
Derivatives C^(k)(u), k = 0..order (A3.2 + A4.2 for the rational case).
-
std::vector<Vec3> sample(std::size_t n) const¶
Uniformly spaced samples in parameter space (n >= 2).
-
NurbsCurve insert_knot(double u, std::size_t r = 1) const¶
Returns a copy with knot u inserted r times (A5.1). Shape is unchanged.
-
NurbsCurve refine_knots(const std::vector<double> &X) const¶
Returns a copy with all knots in X inserted (A5.4). X may be unsorted and contain repeated values; every value must lie in the domain and no knot may exceed multiplicity p. Shape is unchanged.
-
bool is_clamped() const noexcept¶
True if the first and last knot have multiplicity degree+1 (end points interpolated).
-
NurbsCurve clamped() const¶
Same curve on the same domain with a clamped knot vector (copy if already clamped).
-
NurbsCurve elevate_degree(std::size_t t = 1) const¶
Degree elevation by t (A5.9). Shape and domain are unchanged; the result is clamped, has degree p+t and every interior knot multiplicity is raised by t.
-
std::pair<NurbsCurve, std::size_t> try_remove_knot(double u, std::size_t times = 1, double tolerance = tol::kLength) const¶
Removes the interior knot u up to
timestimes (A5.8), as far as the curve stays within the Cartesian deviationtolerance. Returns the new curve and the number of removals.
-
NurbsCurve remove_knot(double u, std::size_t times = 1, double tolerance = tol::kLength) const¶
Like try_remove_knot, but throws GeometryError unless all
timesremovals succeed.
-
NurbsCurve reduce_degree(double tolerance = tol::kLength) const¶
Degree reduction by one within the Cartesian deviation
tolerance(verified rigorously). The result is clamped; knots keep their original continuity where the tolerance allows. Throws GeometryError if the curve cannot be reduced within the tolerance.
-
std::pair<NurbsCurve, NurbsCurve> split(double u) const¶
Splits at the interior parameter u. Both parts are clamped and keep their parameter intervals [a, u] and [u, b].
-
NurbsCurve sub_curve(double u0, double u1) const¶
Part of the curve on [u0, u1] (domain_start <= u0 < u1 <= domain_end), clamped.
-
std::vector<NurbsCurve> decompose_bezier() const¶
Splits the curve into its Bézier segments (one per non-empty knot span of the domain). Segment k is a NURBS of the same degree with knots {a,..,a, b,..,b} on its original parameter interval [a, b], so parameters carry over unchanged.
-
NurbsCurve reversed() const¶
Returns the curve with reversed parametrisation (same geometry).
-
NurbsCurve transformed(const Transform &t) const¶
Applies an affine transformation (exact: NURBS are affinely invariant).
Public Static Functions
-
static NurbsCurve from_points(std::size_t degree, std::vector<Vec3> control_points)¶
Non-rational B-spline with clamped uniform knots.
-
static NurbsCurve from_homogeneous(std::size_t degree, KnotVector knots, const std::vector<Vec4> &pw)¶
Builds a curve from homogeneous control points.
-
NurbsCurve(std::size_t degree, KnotVector knots, std::vector<Vec3> control_points, std::vector<double> weights = {})¶
-
class NurbsSurface¶
- #include <nurbforge/nurbs/surface.hpp>
NURBS surface S(u,v). Control net is stored row-major: index(i, j) = i * num_v + j, where i runs along u (0..num_u-1) and j along v (0..num_v-1).
Public Functions
-
NurbsSurface(std::size_t degree_u, std::size_t degree_v, KnotVector knots_u, KnotVector knots_v, std::size_t num_u, std::size_t num_v, std::vector<Vec3> control_points, std::vector<double> weights = {})¶
-
inline std::size_t degree_u() const noexcept¶
-
inline std::size_t degree_v() const noexcept¶
-
inline const KnotVector &knots_u() const noexcept¶
-
inline const KnotVector &knots_v() const noexcept¶
-
inline std::size_t num_u() const noexcept¶
-
inline std::size_t num_v() const noexcept¶
-
inline const std::vector<double> &weights() const noexcept¶
-
inline double weight(std::size_t i, std::size_t j) const¶
-
inline std::array<double, 2> domain_u() const noexcept¶
-
inline std::array<double, 2> domain_v() const noexcept¶
-
std::vector<std::vector<Vec3>> derivatives(double u, double v, std::size_t order) const¶
All partial derivatives up to total order
order(A3.6 + A4.4 for the rational case): result[k][l] = d^(k+l) S / du^k dv^l for k + l <= order; entries with k + l > order are zero. Size (order+1) x (order+1). Orders above the degree are handled (rational derivatives of any order are generally non-zero).
-
std::array<Vec3, 3> first_derivatives(double u, double v) const¶
{S, S_u, S_v} – first order partial derivatives (rational).
-
Vec3 normal(double u, double v) const¶
Unit normal along S_u x S_v. At degenerate points where S_u or S_v vanishes (poles of revolved surfaces, collapsed edges) the limit normal is computed from the mixed second derivative, oriented consistently with the neighbourhood. Throws GeometryError if the normal is undefined (e.g. both S_u and S_v vanish, or a cusp).
-
NurbsCurve iso_curve_u(double u) const¶
Iso-parametric curve at fixed u (direction v) or fixed v (direction u).
-
NurbsCurve iso_curve_v(double v) const¶
-
std::vector<Vec3> sample(std::size_t nu_samples, std::size_t nv_samples) const¶
Structured grid of points (nu_samples x nv_samples), row-major.
-
NurbsSurface refine_knots_u(const std::vector<double> &X) const¶
Inserts all knots X into the u (resp. v) knot vector (A5.5). Shape is unchanged. Same rules as NurbsCurve::refine_knots.
-
NurbsSurface refine_knots_v(const std::vector<double> &X) const¶
-
NurbsSurface elevate_degree_u(std::size_t t = 1) const¶
Degree elevation by t in u (resp. v), A5.10. Shape and domain are unchanged; the knot vector of that direction becomes clamped.
-
NurbsSurface elevate_degree_v(std::size_t t = 1) const¶
-
NurbsSurface clamped() const¶
Same surface with clamped knot vectors in both directions (copy if already clamped).
-
std::pair<NurbsSurface, NurbsSurface> split_u(double u) const¶
Splits at the interior parameter u (resp. v); both parts keep their parameter ranges.
-
std::pair<NurbsSurface, NurbsSurface> split_v(double v) const¶
-
NurbsSurface sub_surface(double u0, double u1, double v0, double v1) const¶
Part of the surface on [u0, u1] x [v0, v1] (within the domain), clamped.
-
std::pair<NurbsSurface, std::size_t> try_remove_knot_u(double u, std::size_t times = 1, double tolerance = tol::kLength) const¶
Removes the interior knot u (resp. v) up to
timestimes, as far as every row/column stays withintolerance. Returns the new surface and the number of removals.
-
std::pair<NurbsSurface, std::size_t> try_remove_knot_v(double v, std::size_t times = 1, double tolerance = tol::kLength) const¶
-
NurbsSurface remove_knot_u(double u, std::size_t times = 1, double tolerance = tol::kLength) const¶
Removes the interior knot u of the u (resp. v) direction
timestimes (A5.8 applied to all rows/columns). Throws GeometryError unless all removals stay withintolerance.
-
NurbsSurface remove_knot_v(double v, std::size_t times = 1, double tolerance = tol::kLength) const¶
-
NurbsSurface reduce_degree_u(double tolerance = tol::kLength) const¶
Degree reduction by one in u (resp. v) within
tolerance(verified rigorously). Throws GeometryError if the tolerance cannot be met.
-
NurbsSurface reduce_degree_v(double tolerance = tol::kLength) const¶
-
std::vector<NurbsSurface> decompose_bezier() const¶
Splits the surface into Bézier patches, one per pair of non-empty knot spans. Returned in row-major order (u span outer, v span inner); each patch keeps its original parameter rectangle.
-
NurbsSurface transformed(const Transform &t) const¶
-
NurbsSurface transposed() const¶
Swaps the u and v directions (transposes the control net).
-
NurbsSurface(std::size_t degree_u, std::size_t degree_v, KnotVector knots_u, KnotVector knots_v, std::size_t num_u, std::size_t num_v, std::vector<Vec3> control_points, std::vector<double> weights = {})¶
-
struct Asphere¶
- #include <nurbforge/optics/surfaces.hpp>
Rotationally symmetric sag z(r) = c r^2 / (1 + sqrt(1 - (1+k) c^2 r^2)) + sum_i even[i] r^(2i+4) + sum_i odd[i] r^(i+1).
-
struct ZernikeSag¶
- #include <nurbforge/optics/surfaces.hpp>
Zernike sag: base asphere plus sum_j coeffs[j-1] Z_j(r / norm_radius, theta).
Public Functions
-
double sag(double x, double y) const¶
Public Members
-
double norm_radius = {1.0}¶
-
ZernikeIndexing indexing = {ZernikeIndexing::Fringe}¶
-
std::vector<double> coeffs¶
coefficient of Z_1, Z_2, …
-
double sag(double x, double y) const¶
-
struct XYPolynomialSag¶
- #include <nurbforge/optics/surfaces.hpp>
XY polynomial sag: base asphere plus sum c * (x/norm_radius)^i (y/norm_radius)^j.
Public Functions
-
double sag(double x, double y) const¶
-
struct Term¶
- #include <nurbforge/optics/surfaces.hpp>
-
double sag(double x, double y) const¶
-
struct BlendSize¶
- #include <nurbforge/topology/edge_blend.hpp>
Fillet radius or chamfer distance at a point on the selected edges (variable size).
-
struct EdgeBlendOptions¶
- #include <nurbforge/topology/edge_blend.hpp>
Options of fillet_edges and chamfer_edges.
Public Members
-
std::string label = {}¶
Label of the new faces (”” : “fillet” for fillets, “chamfer” for chamfers).
-
double tolerance = {0.0}¶
Sewing tolerance of the result (0: the shell’s tolerance). The blend surfaces, contact curves and end curves are computed to a twentieth of it.
-
std::vector<BlendSize> sizes = {}¶
Variable size: radius (fillets) or distance (chamfers) at points on the selected edges (within the sewing tolerance). Along each edge chain the size passes through the values of its points in chain order, blending smoothly between neighbours (quintic smooth step, zero slope and curvature at the points: s(t) = s0 + (s1 - s0)(10t^3 - 15t^4 + 6t^5), t the arc-length fraction between them); before the first and after the last point it is constant (closed chains: periodic). A chain without points uses the size argument. Where blends meet at a corner of three edges their fillet radii must agree.
-
std::string label = {}¶
-
struct Coedge¶
- #include <nurbforge/topology/shell.hpp>
Use of an edge by a face boundary loop.
-
struct ShellEdge¶
- #include <nurbforge/topology/shell.hpp>
-
struct MassProperties¶
- #include <nurbforge/topology/shell.hpp>
Volume, centroid and inertia of the solid bounded by a closed shell, for unit density (multiply volume and inertia by the density for mass and mass moments of inertia).
Public Members
-
double volume = {0.0}¶
-
std::array<double, 9> inertia = {}¶
Inertia tensor about the centroid, row-major: I_ij = int (|r|^2 delta_ij - r_i r_j) dV with r measured from the centroid (diagonal: moments of inertia, off-diagonal: products of inertia with the minus sign included).
-
std::array<double, 3> principal_moments = {}¶
Eigenvalues of the inertia tensor, ascending, and the corresponding unit axes.
-
double volume = {0.0}¶
-
class Shell¶
- #include <nurbforge/topology/shell.hpp>
Faces sewn along shared boundary curves. Degenerate boundary pieces (poles of revolved surfaces) are not edges. Each face’s boundary loops are mapped to 3D and matched: two boundary curves form the same edge if each lies on the other within the sewing tolerance (same or opposite direction; closed curves may start at different points). T-junctions are resolved first: every boundary curve is split at the end points of other boundary curves lying on it (e.g. a circle split at different points on the two faces sharing it).
Public Functions
-
inline const std::vector<TrimmedSurface> &faces() const noexcept¶
-
inline double tolerance() const noexcept¶
Sewing tolerance the shell was built with (Shell::sew).
-
std::vector<std::size_t> free_edges() const¶
Edges used by exactly one face loop (holes in the shell).
-
std::vector<std::size_t> non_manifold_edges() const¶
Edges used more than twice.
-
bool is_closed() const¶
Watertight: every edge used exactly twice.
-
bool is_consistently_oriented() const¶
Every edge used twice is traversed in opposite directions by its two uses (normals of adjacent faces point to the same side).
-
std::vector<Shell> components() const¶
Connected components (faces linked through shared edges), each as its own shell – e.g. the outer boundary and the void boundaries of a hollow solid, or the separate lumps of a Boolean result.
-
Shell oriented() const¶
Flips faces so that the orientation becomes consistent within every connected component. Closed components are then oriented by nesting: a component lying inside an even number of other closed components is an outer boundary (normals outwards, positive volume), one inside an odd number bounds a void (normals into the void, negative volume) – so a hollow solid keeps its void and the total volume is the solid volume.
-
double area(double rel_tol = 1e-8) const¶
-
double volume(double rel_tol = 1e-8) const¶
Enclosed volume by the divergence theorem, V = 1/3 sum of the face integrals of S . (S_u x S_v). Requires a closed, consistently oriented shell (throws otherwise); positive for outward normals.
-
MassProperties mass_properties(double rel_tol = 1e-8) const¶
Volume, centroid and inertia tensor by the divergence theorem (face integrals of polynomial fields in the coordinates relative to the centre of the bounding box, combined with the parallel-axis theorem). Voids (inward-oriented components) are subtracted. Same requirements as volume(); throws GeometryError if the volume is not positive.
-
Shell transformed(const Transform &t) const¶
The shell mapped by an affine transformation: every face surface is transformed (trim loops unchanged) and the faces are sewn again. Orientation-reversing maps (mirrors, negative scale factors) flip the faces, so outward normals stay outward.
-
Shell with_face_labels(const std::vector<std::string> &labels) const¶
The same shell with face f labelled labels[f] (TrimmedSurface::label; one label per face, “” for none). Labels survive Booleans, so faces can be named before an operation and found again afterwards (boundary conditions, physical groups for meshing).
-
std::vector<std::size_t> faces_labeled(const std::string &label) const¶
Indices of the faces with the given label.
Public Static Functions
-
static Shell sew(std::vector<TrimmedSurface> faces, double tolerance = 1e-6)¶
-
inline const std::vector<TrimmedSurface> &faces() const noexcept¶
-
struct TrimLoop¶
- #include <nurbforge/topology/trimmed_surface.hpp>
Closed loop of curves in the parameter domain of a surface: x = u, y = v, z = 0. The curves are consecutive (end of one = start of the next, last ends at the start of the first).
Public Functions
-
std::vector<std::array<double, 2>> polyline(std::size_t samples_per_span = 16) const¶
Dense polyline approximation (closed: first point not repeated).
-
double signed_area() const¶
Signed area in the parameter plane (> 0 for counter-clockwise loops).
Public Members
-
std::vector<NurbsCurve> curves¶
-
std::vector<std::array<double, 2>> polyline(std::size_t samples_per_span = 16) const¶
-
class TrimmedSurface¶
- #include <nurbforge/topology/trimmed_surface.hpp>
Surface restricted to the region inside
outerand outside allholes. Loops are oriented on construction: outer counter-clockwise, holes clockwise (in the (u, v) plane). Loops must be closed (within tol.length in parameter units) and lie in the parameter domain.Public Functions
-
explicit TrimmedSurface(NurbsSurface surface)¶
Untrimmed: the outer loop is the parameter domain.
-
TrimmedSurface(NurbsSurface surface, TrimLoop outer, std::vector<TrimLoop> holes = {}, const Tolerance &tol = {})¶
-
inline const NurbsSurface &surface() const noexcept¶
-
bool is_untrimmed() const¶
True if the region is the whole parameter domain (no holes, outer loop on the domain boundary).
-
bool contains(double u, double v) const¶
True if (u, v) lies inside the trimmed region (on the boundary: either answer).
-
double area(double rel_tol = 1e-9) const¶
Area of the trimmed region in 3D, by Green’s theorem in the parameter plane: with F(u, v) = int |S_u x S_v| du, area = sum of the loop integrals of F dv (adaptive Gauss-Kronrod per knot span; holes, being clockwise, subtract).
-
double integrate(const std::function<double(double, double)> &f, double rel_tol, double abs_tol) const¶
Integral of f(u, v) over the trimmed region of the parameter plane (Green’s theorem as for area(); include the area element |S_u x S_v| in f for surface integrals).
abs_tolis the absolute error target of the loop integrals (needed when f nearly cancels).
-
TrimmedSurface flipped() const¶
The same surface with opposite orientation (u reversed: S’(u, v) = S(a + b - u, v)); the loops are mirrored accordingly. The normal S_u x S_v flips.
-
TrimmedSurface transformed(const Transform &t) const¶
The face mapped by an affine transform: the surface is transformed, the loops (parameter space) and the label are kept. For a reflection (negative determinant) the face is also flipped, so that its normal is the image of the original normal – as in Shell::transformed.
-
inline const std::string &label() const noexcept¶
Free-form label of the face, e.g. a boundary-condition or physical-group name (”” if none). Kept by flipped(), with_hole(), split(), Booleans (every piece of a split face keeps the label of the face it came from), Shell::oriented() / transformed(), and written to / read from STEP as the ADVANCED_FACE name; the solid primitives label their faces.
-
TrimmedSurface with_label(std::string label) const¶
The same face with the given label.
-
std::vector<std::vector<NurbsCurve>> boundary_curves(double tolerance = 1e-7) const¶
The boundary loops mapped to 3D: each trim curve composed with the surface, fitted to
tolerance(cubic interpolation with adaptive refinement). Outer loop first.
-
TrimmedSurface with_hole(TrimLoop hole) const¶
Adds a hole (must lie inside the region).
-
explicit TrimmedSurface(NurbsSurface surface)¶
-
namespace tol¶
-
namespace detail¶
Functions
-
std::size_t arc_segment_count(double sweep)¶
Number of arcs (<= 90 deg each) used for an angular sweep, and the matching knot vector.
-
KnotVector arc_knots(std::size_t narcs)¶
-
std::size_t arc_segment_count(double sweep)¶
-
using KnotVector = std::vector<double>¶