ChangeDegree
1) The first test of the degree changing algorithms is degree elevation of a curve that is given in The NURBS Book's Figure 5.37.
The following program tests the knot removal algorithm for curves by reproducing the case demonstrated above.
program test_curve_degree_elevate
use splines
use points
implicit none
integer, parameter :: wp = selected_real_kind(15,307)
logical, parameter :: T = .true.
logical, parameter :: F = .false.
type(curve) :: c, c2, c3, c4
type(cpt) :: cp(6)
real(wp) :: U(10)
! CPs are relatively exact
cp(:)%x = [-0.010_wp, 0.867_wp, 4.153_wp, 5.202_wp, 8.659_wp, 9.516_wp]
cp(:)%y = [0.000_wp, 5.874_wp, 5.817_wp, 2.108_wp, 2.372_wp, 7.360_wp]
U = [0.0_wp,0.0_wp,0.0_wp,0.0_wp, 0.40_wp, 0.70_wp,1.0_wp,1.0_wp,1.0_wp,1.0_wp]
c = spl(dim=2, pd=1, p=[3], kXi=U, cp=cp)
call c%plot(plotCP=T, labelCP=T, &
terminal='png', fname="test_F5.37a", &
title="Figure 5.37(a). The original cubic curve defined over &
& \\{0, 0, 0, 0, 0.4, 0.7, 1, 1, 1, 1\\}." )
c2 = c
call c2%ChangeDegree(tu=+1)
call plot( me=[c,c2], plotCP=T, &
terminal='png', fname="test_F5.37b", &
title="Figure 5.37(b). The degree is elevated by one." )
c3 = c
call c3%ChangeDegree(tu=+2)
call plot( me=[c,c3], plotCP=T, &
terminal='png', fname="test_F5.37c", &
title="Figure 5.37(c). The degree is elevated by two." )
c4 = c
call c4%ChangeDegree(tu=+4)
call plot( me=[c,c4], plotCP=T, &
terminal='png', fname="test_F5.37d", &
title="Figure 5.37(d). the degree is elevated by four." )
call c%N(1)%plot(terminal='png', fname="test_F5.37a2", &
title="Figure 5.37(a-2). The original bases")
call c2%N(1)%plot(terminal='png', fname="test_F5.37b2", &
title="Figure 5.37(b-2). t_{u}=+1")
call c3%N(1)%plot(terminal='png', fname="test_F5.37c2", &
title="Figure 5.37(c-2). t_{u}=+2")
call c4%N(1)%plot(terminal='png', fname="test_F5.37d2", &
title="Figure 5.37(d-2). t_{u}=+4")
pause
end program test_curve_degree_elevate
The original curve and degree elevated curves obtained by the above test program are given as follows with their corresponding shape functions.
The curves
Shape functions
2) The second test
program test_surface_degree_elevate
use splines
use points
implicit none
integer, parameter :: wp = selected_real_kind(15,307)
logical, parameter :: T = .true.
logical, parameter :: F = .false.
type(surface) :: s,s1,s2,s3,s4
type(cpt) :: scp(16)
real(wp) :: U(8), V(7)
scp(:)%x = [ 1.0, 1.0, 1.0, 1.0, 0.2, 0.2, 0.2, 0.2, &
-0.2, -0.2, -0.2, -0.2, -1.0, -1.0, -1.0, -1.0]
scp(:)%y = [-1.0, -0.2, 0.2, 1.0, -1.0, -0.2, 0.2, 1.0, &
-1.0, -0.2, 0.2, 1.0, -1.0, -0.2, 0.2, 1.0]
scp(:)%z = [ 1.0, 1.0, -2.0, -2.0, 1.0, 1.0, -2.0, -2.0, &
3.0, 3.0, 1.0, 1.0, 3.0, 3.0, 1.0, 1.0]
U = [0.0_wp,0.0_wp,0.0_wp,0.0_wp,1.0_wp,1.0_wp,1.0_wp,1.0_wp]
V = [0.0_wp,0.0_wp,0.0_wp,0.50_wp,1.0_wp,1.0_wp,1.0_wp]
s = spl(dim=3, pd=2, p=[3,2], kXi=U, kEta=V, cp=scp)
call s%Plot(plotCP=T, labelCP=T, terminal='png', fname="test_F5.38a", &
plotOpt=["set colorsequence classic","set view ,120"], &
title="Figure 5.37(a). The original (cubic x quadratic) surface net, the surface defined over &
& U = \\{0, 0, 0, 0, 1, 1, 1, 1\\}, and V = \\{0, 0, 0, 0.5, 1, 1, 1\\}.", work="surfdeg_elevate" )
s1 = s
call s1%ChangeDegree(tu=+1,tv=+1)
call s1%Plot(plotCP=T, labelCP=T, terminal='png', fname="test_F5.38b", &
plotOpt=["set colorsequence classic","set view ,120"], &
title="Figure 5.37(b). The degree elevated by one in both directions", work="surfdeg_elevate" )
s2 = s
call s2%ChangeDegree(tu=+2,tv=+2)
call s2%Plot(plotCP=T, labelCP=T, terminal='png', fname="test_F5.38c", &
plotOpt=["set colorsequence classic","set view ,120"], &
title="Figure 5.37(c). The degree elevated by two in both directions", work="surfdeg_elevate" )
s3 = s
call s3%ChangeDegree(tu=+3,tv=+4)
call s3%Plot(plotCP=T, labelCP=T, terminal='png', fname="test_F5.38d", &
plotOpt=["set colorsequence classic","set view ,120"], &
title="Figure 5.37(d). The degree by three in the u-direction, by four in the v-direction", work="surfdeg_elevate" )
s4 = s
call s4%ChangeDegree(tu=+6,tv=+7)
call s4%Plot(plotCP=T, labelCP=T, terminal='png', fname="test_F5.38e", &
plotOpt=["set colorsequence classic","set view ,120"], &
title="Figure 5.37(e). The degree elevated by six in the u direction, by seven in the v direction", work="surfdeg_elevate" )
pause
end program test_surface_degree_elevate
The original surface and degree elevated surface obtained by the above test program are given as follows.