Extract a Bézier element
Extract the middle of the three rational quadratic arcs in ForCAD’s circle constructor. A Bézier element has one knot span in each parameter direction. It carries its own controls and weights, so it can be passed to an element-local algorithm.
program extract_bezier_element
use forcad, only: rk, nurbs_curve
implicit none
type(nurbs_curve) :: circle, arc
real(rk), allocatable :: bounds(:,:)
real(rk) :: u, point(3)
call circle%set_circle(center=[0._rk,0._rk,0._rk], radius=2._rk)
if (.not. circle%err%ok) error stop "Could not build the circle"
call circle%bezier(ie=2, piece=arc, bounds=bounds)
if (.not. arc%err%ok) error stop "Could not extract the arc"
u = sum(bounds(:,1))/2
point = arc%cmp_Xg(u)
if (maxval(abs(point-circle%cmp_Xg(u))) > 100*epsilon(u)) error stop "Arc mismatch"
print '(a,2f9.5)', "Parameter interval:", bounds(:,1)
print '(a,f7.3)', "Midpoint radius:", norm2(point)
end program
The arc occupies in the original curve’s parameter space. Its midpoint lies at radius 2. Evaluate the result using the returned bounds. In particular, a single Bézier span can occupy an interval other than .
To decompose an entire curve, declare type(nurbs_curve), allocatable :: arcs(:) and use call circle%bezier(pieces=arcs). Surface and volume patches expose the same operation with surface and volume results. For an interval that crosses span boundaries, extract a parameter range.