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 (Non-Uniform Rational B-Spline) curve object to create and finalize a NURBS curve.
It sets up control points, weights, and knot vectors for all three dimensions, generates the curve, and exports the control points and the curve to VTK files.
Define control points for the NURBS curve
Define weights for the control points (optional)
Define knot vector
Set knot vector, control points, and weights for the NURBS curve object.
Wc is optional
Deallocate local arrays
Export parameter space to a VTK file
Export control points to a VTK file
Generate the NURBS curve with a resolution of 20
Export the generated curve to a VTK file
Export the NURBS curve to an IGES file
Show the control geometry and geometry using PyVista
Print size of the knot vector
Insert knots 0.25, twice and 0.75, once
Print size of the updated knot vector
Print the degree of the curve
Elevate the degree of the curve (2 times)
Print the updated degree of the curve
Print size of the knot vector
Remove knots 0.25, twice and 0.75, once
Print size of the updated knot vector
Generate the refined curve with a resolution of 20
Export refined parameter space to a VTK file
Export updated control points to a VTK file
Export the refined generated curve to a VTK file
Export the refined NURBS curve to an IGES file
Show the control geometry and geometry using PyVista
Rotate the control points
Rotate the generated curve
Translate the control points
Translate the generated curve
Export parameter space to a VTK file
Export the transformed control points to a VTK file
Export the transformed generated volume to a VTK file
Export the transformed NURBS curve to an IGES 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.
program example1_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 weightsreal(rk)::knot(6)!! Array for knot vector!-----------------------------------------------------------------------------! Setting up the NURBS curve!-----------------------------------------------------------------------------!> Define control points for the NURBS curveallocate(Xc(3,3))Xc(1,:)=[0.0_rk,0.0_rk,0.0_rk]Xc(2,:)=[0.0_rk,5.0_rk,0.0_rk]Xc(3,:)=[5.0_rk,5.0_rk,0.0_rk]!> Define weights for the control points (optional)allocate(Wc(3))Wc=[1.0_rk,2.0_rk,0.3_rk]!> Define knot vectorknot=[0.0_rk,0.0_rk,0.0_rk,1.0_rk,1.0_rk,1.0_rk]!> Set knot vector, control points, and weights for the NURBS curve object.!> Wc is optionalcall nurbs%set(knot,Xc,Wc)!> Deallocate local arraysdeallocate(Xc,Wc)!> Export parameter space to a VTK filecall nurbs%export_Xth('vtk/nurbs_curve_Xth.vtk')!> Export control points to a VTK filecall nurbs%export_Xc('vtk/nurbs_curve_Xc.vtk')!-----------------------------------------------------------------------------! Creating the NURBS curve!-----------------------------------------------------------------------------!> Generate the NURBS curve with a resolution of 20call nurbs%create(res=20)!> Export the generated curve to a VTK filecall nurbs%export_Xg('vtk/nurbs_curve_Xg.vtk')!> Export the NURBS curve to an IGES filecall nurbs%export_iges('iges/nurbs_curve.iges')!-----------------------------------------------------------------------------! 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/nurbs_curve_Xc.vtk','vtk/nurbs_curve_Xg.vtk')!-----------------------------------------------------------------------------! Refinements!-----------------------------------------------------------------------------!> Print size of the knot vectorprint*,size(nurbs%get_knot())!> Insert knots 0.25, twice and 0.75, oncecall nurbs%insert_knots([0.25_rk,0.75_rk],[2,1])!> Print size of the updated knot vectorprint*,size(nurbs%get_knot())!> Print the degree of the curveprint*,nurbs%get_degree()!> Elevate the degree of the curve (2 times)call nurbs%elevate_degree(2)!> Print the updated degree of the curveprint*,nurbs%get_degree()!> Print size of the knot vectorprint*,size(nurbs%get_knot())!> Remove knots 0.25, twice and 0.75, oncecall nurbs%remove_knots([0.25_rk,0.75_rk],[2,1])!> Print size of the updated knot vectorprint*,size(nurbs%get_knot())!> Generate the refined curve with a resolution of 20call nurbs%create()!> Export refined parameter space to a VTK filecall nurbs%export_Xth('vtk/nurbs_curve_Xth2.vtk')!> Export updated control points to a VTK filecall nurbs%export_Xc('vtk/nurbs_curve_Xc2.vtk')!> Export the refined generated curve to a VTK filecall nurbs%export_Xg('vtk/nurbs_curve_Xg2.vtk')!> Export the refined NURBS curve to an IGES filecall nurbs%export_iges('iges/nurbs_curve2.iges')!-----------------------------------------------------------------------------! 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/nurbs_curve_Xc2.vtk','vtk/nurbs_curve_Xg2.vtk')!-----------------------------------------------------------------------------! Transformations!-----------------------------------------------------------------------------!> Rotate the control pointscall nurbs%rotate_Xc(alpha=45.0_rk,beta=0.0_rk,theta=90.0_rk)!> Rotate the generated curvecall nurbs%rotate_Xg(alpha=-45.0_rk,beta=0.0_rk,theta=-90.0_rk)!> Translate the control pointscall nurbs%translate_Xc([1.0_rk,2.0_rk,-3.0_rk])!> Translate the generated curvecall nurbs%translate_Xg([-1.0_rk,-2.0_rk,3.0_rk])!> Export parameter space to a VTK filecall nurbs%export_Xth('vtk/nurbs_curve_Xth3.vtk')!> Export the transformed control points to a VTK filecall nurbs%export_Xc('vtk/nurbs_curve_Xc3.vtk')!> Export the transformed generated volume to a VTK filecall nurbs%export_Xg('vtk/nurbs_curve_Xg3.vtk')!> Export the transformed NURBS curve to an IGES filecall nurbs%export_iges('iges/nurbs_curve3.iges')!-----------------------------------------------------------------------------! 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/nurbs_curve_Xc3.vtk','vtk/nurbs_curve_Xg3.vtk')!-----------------------------------------------------------------------------! Finalizing!-----------------------------------------------------------------------------!> Finalize the NURBS curve objectcall nurbs%finalize()end program example1_curve