forcad_nurbs_construction Module
- BSD 3-Clause
- 571 statements
Tensor-product construction and interpolation operations for NURBS geometry.
The public generics construct a higher-rank NURBS object without sampling the source geometry. Polynomial source objects remain polynomial except for revolution, which necessarily introduces the rational quadratic weights of exact circular arcs.
Constructions
extrudeforms or , with degree one and active interval in the new direction.revolveconstructs exact rational quadratic-arc control layers about a three-dimensional axis. Arc endpoints are rotated source controls; each intermediate control lies at the intersection of endpoint tangents. For unit axis , axis point , , and axial projection , Rodrigues' formula gives
The signed angle is split into exact rational quadratic arcs no larger
than .
- sweep forms the translational tensor product
, with
tensor-product weights . It intentionally keeps the profile
frame fixed; it is not a Frenet-, rotation-minimizing-, or guide-rail
sweep.
- loft globally interpolates compatible sections in homogeneous
coordinates. Section degree, control-net shape, coordinate dimension, and
inherited wrapping mode must agree. Knot arrays must have equal shape and
agree within the precision-scaled tolerance documented by
same_knot_vector; the first section's knots are retained.
For a loft through homogeneous section controls at parameters , the new controls satisfy
Thus the supplied homogeneous control data are reproduced to the accepted linear-system residual; no sampled fitting approximation is introduced. If all section knots are identical, this reproduces each section geometry at its supplied loft parameter. If knots differ only within the accepted tolerance, the output still uses the first section's knots and exact equality to every independently parameterized input section is not asserted. A result is accepted only when all interpolated homogeneous weights remain finite and strictly positive.
Invalid input produces an invalid result whose err member describes the
failure. No partially constructed geometry is returned.
Reference
L. Piegl and W. Tiller, The NURBS Book, 2nd ed., Springer, 1997, Chapters 8, 9, and 11. doi:10.1007/978-3-642-59223-2.
Uses
Interfaces
public interface extrude
Construct a degree-one extrusion of a curve or surface.
Curve input returns a surface; surface input returns a volume. The source
directions are copied exactly and the new direction has knot vector
[0,0,1,1], degree one, and no parameter wrapping.
-
private pure function extrude_curve(curve, vector) result(surface)
Extrude a NURBS curve exactly into a degree-one tensor-product surface.
The source knot vector, degree, control points, weights, and parameter wrapping are preserved in direction 1. Direction 2 uses the clamped linear knot vector
[0,0,1,1]; the two control layers are separated byvectorand carry identical weights.In homogeneous coordinates , the output layers are and .
Arguments
Type Intent Optional Attributes Name type(nurbs_curve), intent(in) :: curve Valid source curve.
real(kind=rk), intent(in), contiguous :: vector(:) Finite, nonzero extrusion vector. Its size determines the output coordinate dimension and must be between the source dimension and three.
Return Value type(nurbs_surface)
-
private pure function extrude_surface(surface, vector) result(volume)
Extrude a NURBS surface exactly into a degree-one tensor-product volume.
Source directions 1 and 2 are copied unchanged. Direction 3 uses
[0,0,1,1], and the second control layer is translated byvector. The construction is exact because both layers retain the source weights.Arguments
Type Intent Optional Attributes Name type(nurbs_surface), intent(in) :: surface Valid source surface.
real(kind=rk), intent(in), contiguous :: vector(:) Finite, nonzero extrusion vector. Its size determines the output coordinate dimension and must be between the source dimension and three.
Return Value type(nurbs_volume)
public interface loft
Interpolate compatible curve or surface sections in homogeneous space.
Curve sections return a surface and surface sections return a volume.
The output interpolation direction uses an averaged clamped knot vector;
its degree defaults to min(3,size(sections)-1).
-
private pure function loft_curves(sections, parameters, degree) result(surface)
Interpolate compatible NURBS curve sections by a NURBS surface. Section knot vectors, degrees, control counts and coordinate dimensions must match, with knot values compared by
same_knot_vector. Parameters must be finite and strictly increasing. The default loft degree ismin(3,number_of_sections-1). Interpolation is performed on homogeneous coordinates. With identical section knots, rational section geometry is reproduced at each supplied section parameter to the accepted linear residual. When knots differ within tolerance, the first knot vector is retained and only homogeneous control-data reproduction is asserted. For each source control index , the routine solves , where .Uses the averaged open knot vector and global interpolation construction of Piegl and Tiller, The NURBS Book, 2nd ed., Section 9.2.1. The result is rejected if the solve residual exceeds the criterion documented by
interpolate_loftor any interpolated weight is nonpositive/nonfinite.Arguments
Type Intent Optional Attributes Name type(nurbs_curve), intent(in), contiguous :: sections(:) Two or more valid and mutually compatible curves.
real(kind=rk), intent(in), optional, contiguous :: parameters(:) Optional strictly increasing section parameters, one per section. Uniform values on
[0,1]are used when absent.integer, intent(in), optional :: degree Optional loft-direction degree in
[1,size(sections)-1].Return Value type(nurbs_surface)
-
private pure function loft_surfaces(sections, parameters, degree) result(volume)
Interpolate compatible NURBS surface sections by a NURBS volume. Section knot vectors, degrees, control counts and coordinate dimensions must match, with directional knot values compared by
same_knot_vector. Parameters must be finite and strictly increasing. The default loft degree ismin(3,number_of_sections-1). Interpolation is performed independently for every homogeneous control-net coordinate, including the weight. Identical section knots yield section-geometry interpolation to the accepted solve residual. If knots differ within tolerance, the first surface's knots are retained and only homogeneous control-data reproduction is asserted. For each flattened source control index , the routine solves , where .Uses the averaged open knot vector and global interpolation construction of Piegl and Tiller, The NURBS Book, 2nd ed., Section 9.2.1. The result is rejected if the solve residual exceeds the criterion documented by
interpolate_loftor any interpolated weight is nonpositive/nonfinite.Arguments
Type Intent Optional Attributes Name type(nurbs_surface), intent(in), contiguous :: sections(:) Two or more valid and mutually compatible surfaces.
real(kind=rk), intent(in), optional, contiguous :: parameters(:) Optional strictly increasing section parameters, one per section. Uniform values on
[0,1]are used when absent.integer, intent(in), optional :: degree Optional loft-direction degree in
[1,size(sections)-1].Return Value type(nurbs_volume)
public interface revolve
Construct an exact rational revolution of a curve or surface.
Curve input returns a surface and surface input returns a volume. The output adds a quadratic rational direction whose control count and knot multiplicities depend only on the number of at-most-quarter-circle arcs.
-
private pure function revolve_curve(curve, axis_point, axis_direction, angle) result(surface)
Revolve a NURBS curve exactly into a rational quadratic-arc surface. The angle is signed and measured in radians. The axis is defined by a three-dimensional point and any finite nonzero direction vector. Every arc spans at most ; its middle-layer weight is multiplied by . The source parameter is direction 1 and the revolution parameter is direction 2.
For an arc of signed angle , endpoint layers use the original section weight , while the tangent-intersection layer uses . This is the exact projective conic construction, not a polynomial approximation. One- and two-coordinate source controls are embedded in three dimensions by appending zeros.
See Piegl and Tiller, The NURBS Book, 2nd ed., Section 8.4.
Arguments
Type Intent Optional Attributes Name type(nurbs_curve), intent(in) :: curve Valid source curve with at most three coordinate components.
real(kind=rk), intent(in), contiguous :: axis_point(:) Point on the axis, shape
[3].real(kind=rk), intent(in), contiguous :: axis_direction(:) Finite nonzero axis direction, shape
[3]; it need not be normalized.real(kind=rk), intent(in) :: angle Nonzero signed revolution angle in radians.
Return Value type(nurbs_surface)
-
private pure function revolve_surface(surface, axis_point, axis_direction, angle) result(volume)
Revolve a NURBS surface exactly into a rational quadratic-arc volume. The angle is signed and measured in radians. The axis is defined by a three-dimensional point and any finite nonzero direction vector. Source directions 1 and 2 are retained; the revolution parameter becomes direction 3. Every rational arc spans at most . One- and two-coordinate source controls are embedded in three dimensions by appending zeros.
See Piegl and Tiller, The NURBS Book, 2nd ed., Section 8.4.
Arguments
Type Intent Optional Attributes Name type(nurbs_surface), intent(in) :: surface Valid source surface with at most three coordinate components.
real(kind=rk), intent(in), contiguous :: axis_point(:) Point on the axis, shape
[3].real(kind=rk), intent(in), contiguous :: axis_direction(:) Finite nonzero axis direction, shape
[3]; it need not be normalized.real(kind=rk), intent(in) :: angle Nonzero signed revolution angle in radians.
Return Value type(nurbs_volume)
public interface sweep
Construct a fixed-frame translational sweep along a NURBS curve.
The first argument is a curve or surface profile and the second argument is the spine curve. Source knot vectors, degrees, and wrapping policies are retained in their corresponding output directions.
-
private pure function sweep_curve(profile, spine, origin) result(surface)
Sweep a NURBS curve by exact translation along a NURBS spine. The profile orientation remains fixed. The optional origin is subtracted from the spine before translation. The output control net is the tensor sum of both control polygons and its weights are the pairwise products .
The resulting homogeneous tensor product evaluates exactly to , provided both source weight denominators are nonzero.
Arguments
Type Intent Optional Attributes Name type(nurbs_curve), intent(in) :: profile Valid profile curve; output direction 1.
type(nurbs_curve), intent(in) :: spine Valid translation curve; output direction 2.
real(kind=rk), intent(in), optional, contiguous :: origin(:) Optional finite translation origin. If present, its size must equal the output coordinate dimension.
Return Value type(nurbs_surface)
-
private pure function sweep_surface(profile, spine, origin) result(volume)
Sweep a NURBS surface by exact translation along a NURBS spine. The profile orientation remains fixed. The optional origin is subtracted from the spine before translation. The surface directions become output directions 1 and 2; the spine becomes direction 3.
Arguments
Type Intent Optional Attributes Name type(nurbs_surface), intent(in) :: profile Valid profile surface.
type(nurbs_curve), intent(in) :: spine Valid translation curve.
real(kind=rk), intent(in), optional, contiguous :: origin(:) Optional finite translation origin. If present, its size must equal the output coordinate dimension.
Return Value type(nurbs_volume)