Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/_BSplineManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ end
return a[]
end

function clamp(M::AbstractManifold)
function clampknotvector(M::AbstractManifold)
Ps = bsplinespaces(M)
Ps′ = clamp.(Ps)
Ps′ = clampknotvector.(Ps)
return refinement_I(M, Ps′)
end

Expand Down
10 changes: 5 additions & 5 deletions src/_BSplineSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -608,18 +608,18 @@ function Base.hash(P::BSplineSpace{p}, h::UInt) where p
return hash(BSplineSpace{p}, hash(_vec(k), h))
end

function clamp!(P::BSplineSpace{p, T, <:KnotVector}) where {p, T}
function clampknotvector!(P::BSplineSpace{p, T, <:KnotVector}) where {p, T}
v = _vec(knotvector(P))
v[1:p] .= v[p+1]
v[end-p+1:end] .= v[end-p]
return P
end
function clamp(P::BSplineSpace{p, T, <:KnotVector}) where {p, T}
return clamp!(copy(P))
function clampknotvector(P::BSplineSpace{p, T, <:KnotVector}) where {p, T}
return clampknotvector!(copy(P))
end
function clamp(P::BSplineSpace{p, T, <:UniformKnotVector}) where {p, T}
function clampknotvector(P::BSplineSpace{p, T, <:UniformKnotVector}) where {p, T}
k = knotvector(P)
return clamp(BSplineSpace{p}(KnotVector(k)))
return clampknotvector(BSplineSpace{p}(KnotVector(k)))
end

function isclamped(P::BSplineSpace{p}) where p
Expand Down
2 changes: 1 addition & 1 deletion src/_Refinement.jl
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ refinement(M::RationalBSplineManifold{0, Deg, C, W, T, S} where {Deg, C, W, T, S

function expand_domain(M::RationalBSplineManifold{2}, Δt::Real)
if BasicBSpline.isclamped(M)
M = clamp(M)
M = clampknotvector(M)
end
P1,P2 = bsplinespaces(M)
P1′,P2′ = expand_domain(P1,Δt), expand_domain(P2,Δt)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using StaticArrays
using GeometryBasics
using Plots
using Aqua
using BasicBSpline: clamp, clamp!, isclamped
using BasicBSpline: clampknotvector, clampknotvector!, isclamped

if VERSION ≥ v"1.9.0"
# Disable ambiguities tests for ChainRulesCore.frule
Expand Down
46 changes: 23 additions & 23 deletions test/test_BSplineManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@

M′ = refinement(M, P1′)
M′′ = refinement(M, p₊, k₊)
M′′′ = clamp(M)
M′′′′ = clamp(M′)
M′′′′′ = clamp(M′′)
M′′′ = clampknotvector(M)
M′′′′ = clampknotvector(M′)
M′′′′′ = clampknotvector(M′′)
ts = [[rand()] for _ in 1:10]
for t in ts
@test M(t...) ≈ M′(t...)
Expand Down Expand Up @@ -133,9 +133,9 @@
@test isclamped(M)
@test isclamped(M′)
@test isclamped(M′′)
@test M == clamp(M)
@test M′ == clamp(M′)
@test M′′ == clamp(M′′)
@test M == clampknotvector(M)
@test M′ == clampknotvector(M′)
@test M′′ == clampknotvector(M′′)
end
end

Expand Down Expand Up @@ -173,8 +173,8 @@
@test !Base.mightalias(controlpoints(M), controlpoints(M(:,:,:)))
@test !isclamped(M)
@test !isclamped(M′′)
@test M != clamp(M)
@test M′′ != clamp(M′′)
@test M != clampknotvector(M)
@test M′′ != clampknotvector(M′′)
end
end

Expand Down Expand Up @@ -211,24 +211,24 @@
@test M(t1,t2,t3,t4) ≈ M(t1,t2,:,t4)(t3)
@test M(t1,t2,t3,t4) ≈ M(t1,t2,t3,:)(t4)

@test M(t1,t2,t3,t4) ≈ clamp(M(t1,:,:,:))( t2,t3,t4)
@test M(t1,t2,t3,t4) ≈ clamp(M(:,t2,:,:))(t1, t3,t4)
@test M(t1,t2,t3,t4) ≈ clamp(M(:,:,t3,:))(t1,t2, t4)
@test M(t1,t2,t3,t4) ≈ clamp(M(:,:,:,t4))(t1,t2,t3 )
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(t1,:,:,:))( t2,t3,t4)
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(:,t2,:,:))(t1, t3,t4)
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(:,:,t3,:))(t1,t2, t4)
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(:,:,:,t4))(t1,t2,t3 )

@test M(t1,t2,t3,t4) ≈ clamp(M(t1,t2,:,:))( t3,t4)
@test M(t1,t2,t3,t4) ≈ clamp(M(t1,:,t3,:))( t2, t4)
@test M(t1,t2,t3,t4) ≈ clamp(M(t1,:,:,t4))( t2,t3 )
@test M(t1,t2,t3,t4) ≈ clamp(M(:,t2,t3,:))(t1, t4)
@test M(t1,t2,t3,t4) ≈ clamp(M(:,t2,:,t4))(t1, t3 )
@test M(t1,t2,t3,t4) ≈ clamp(M(:,:,t3,t4))(t1,t2 )
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(t1,t2,:,:))( t3,t4)
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(t1,:,t3,:))( t2, t4)
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(t1,:,:,t4))( t2,t3 )
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(:,t2,t3,:))(t1, t4)
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(:,t2,:,t4))(t1, t3 )
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(:,:,t3,t4))(t1,t2 )

@test M(t1,t2,t3,t4) ≈ clamp(M(:,t2,t3,t4))(t1)
@test M(t1,t2,t3,t4) ≈ clamp(M(t1,:,t3,t4))(t2)
@test M(t1,t2,t3,t4) ≈ clamp(M(t1,t2,:,t4))(t3)
@test M(t1,t2,t3,t4) ≈ clamp(M(t1,t2,t3,:))(t4)
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(:,t2,t3,t4))(t1)
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(t1,:,t3,t4))(t2)
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(t1,t2,:,t4))(t3)
@test M(t1,t2,t3,t4) ≈ clampknotvector(M(t1,t2,t3,:))(t4)

@test M(t1,t2,t3,t4) ≈ clamp(M)(t1,t2,t3,t4)
@test M(t1,t2,t3,t4) ≈ clampknotvector(M)(t1,t2,t3,t4)
end
@test_throws DomainError M(-5,-8,-120,1)

Expand Down
10 changes: 5 additions & 5 deletions test/test_BSplineSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,18 @@
@testset "clamp" begin
P1 = BSplineSpace{2}(knotvector"2132111")
P2 = BSplineSpace{2}(knotvector" 3323")
@test clamp(P1) == P2 == clamp(P2)
@test clampknotvector(P1) == P2 == clampknotvector(P2)
@test !isclamped(P1)
@test isclamped(P2)
@test P1 ≠ P2
clamp!(P1)
clampknotvector!(P1)
@test isclamped(P1)
@test P1 == P2

P3 = BSplineSpace{3}(knotvector(0:10))
@test knotvector(P3) isa UniformKnotVector{Int}
@test_throws MethodError clamp!(P3)
@test knotvector(clamp(P3)) isa KnotVector{Int}
@test clamp(P3) == BSplineSpace{3}(knotvector([3,3,3,3,4,5,6,7,7,7,7]))
@test_throws MethodError clampknotvector!(P3)
@test knotvector(clampknotvector(P3)) isa KnotVector{Int}
@test clampknotvector(P3) == BSplineSpace{3}(knotvector([3,3,3,3,4,5,6,7,7,7,7]))
end
end
Loading