Nodes of different colours represent the following:
Solid arrows point from a submodule to the (sub)module which it is
descended from. Dashed arrows point from a module or program unit to
modules which it uses.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
This program demonstrates the usage of a NURBS curve object to create, and finalize a NURBS curve.
It sets up control points and weights, generates the curve, and exports the control points
and the curve to VTK files at various stages.
Define control points for the NURBS curve
Define weights for the control points
Set control points and weights for the NURBS curve object
Deallocate local arrays
Export initial control points to a VTK file
Generate the NURBS curve with a resolution of 500
Export the generated curve to a VTK file
Show the control geometry and geometry using PyVista
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
function generate_Xc(num_coils, radius, height, num_points_per_coil) result(control_points)
Arguments
Type
Intent
Optional
Attributes
Name
integer,
intent(in)
::
num_coils
real(kind=rk),
intent(in)
::
radius
real(kind=rk),
intent(in)
::
height
integer,
intent(in)
::
num_points_per_coil
Return Value
real(kind=rk), allocatable, (:,:)
Source Code
program example_nurbs_curveuse forcad,only:rk,nurbs_curveimplicit none type(nurbs_curve)::nurbs!! Declare a NURBS curve objectreal(rk),allocatable::Xc(:,:),Wc(:)!! Arrays for control points and weights!-----------------------------------------------------------------------------! Setting up the NURBS curve!-----------------------------------------------------------------------------!> Define control points for the NURBS curveXc=generate_Xc(5,1.0_rk,2.0_rk,20)!> Define weights for the control pointsallocate(Wc(size(Xc,1)),source=1.0_rk)!> Set control points and weights for the NURBS curve objectcall nurbs%set(Xc,Wc)!> Deallocate local arraysdeallocate(Xc,Wc)!> Export initial control points to a VTK filecall nurbs%export_Xc('vtk/demo_curve_Xc.vtk')!-----------------------------------------------------------------------------! Creating the NURBS curve!-----------------------------------------------------------------------------!> Generate the NURBS curve with a resolution of 500call nurbs%create(res=500)!> Export the generated curve to a VTK filecall nurbs%export_Xg('vtk/demo_curve_Xg.vtk')!-----------------------------------------------------------------------------! Visualization using PyVista! Note: PyVista is required for visualization. Install it using `pip install pyvista`!-----------------------------------------------------------------------------!> Show the control geometry and geometry using PyVistacall nurbs%show('vtk/demo_curve_Xc.vtk','vtk/demo_curve_Xg.vtk')!-----------------------------------------------------------------------------! Finalizing!-----------------------------------------------------------------------------!> Finalize the NURBS curve objectcall nurbs%finalize()contains!-----------------------------------------------------------------------------function generate_Xc(num_coils,radius,height,num_points_per_coil)result(control_points)integer,intent(in)::num_coils,num_points_per_coilreal(rk),intent(in)::radius,heightreal(rk),allocatable::control_points(:,:)integer::coil,ireal(rk)::theta,coil_heightallocate(control_points(num_coils*num_points_per_coil,3))do coil=1,num_coilscoil_height=height*real(coil-1,rk)/real(num_coils-1,rk)theta=0.0_rkdo i=1,num_points_per_coiltheta=theta+2.0_rk*acos(-1.0_rk)/real(num_points_per_coil,rk)control_points((coil-1)*num_points_per_coil+i,1)=radius*cos(theta)control_points((coil-1)*num_points_per_coil+i,2)=radius*sin(theta)control_points((coil-1)*num_points_per_coil+i,3)=coil_heightend do end do end function!-----------------------------------------------------------------------------end program example_nurbs_curve