BSegments Subroutine

private pure subroutine BSegments(me, nb, knots)

Returns the number of Bezier segments, integer :: nb, of the basis and the real(wp) :: knots(:) array containing the unique values of the knot vector.

Arguments

Type IntentOptional AttributesName
class(basis), intent(in) :: me
integer, intent(out) :: nb

Number of Bezier segments

real(kind=wp), intent(out), optional allocatable:: knots(:)

The unique knot values


Contents

Source Code


Source Code

        pure subroutine BSegments(me,nb,knots)
            class(basis), intent(in)                        :: me
            integer, intent(out)                            :: nb       !< Number of Bezier segments
            real(wp), allocatable, intent(out), optional    :: knots(:) !< The unique knot values
            ! locals
            integer :: i
            real(wp) :: array(me%m-(2*me%p-1))
            
            array = 0.0_wp
            associate(U => me%kv, p => me%p, n => me%n)
                
                ! first, find the number of unique knots
                nb = 1
                array(1) = U(p)
                do i=p+1,n+1
                    if( any( array == U(i) )) cycle
                    nb = nb + 1
                    array(nb) = U(i)
                end do
                
                ! locate the unique knots vector
                if(present(knots))then
                    allocate(knots(nb))
                    knots = array(1:nb)
                end if
                ! substract "1" to determine the number of Bezier segments
                nb = nb - 1
                
            end associate

        end subroutine BSegments