Skip to content

Commit

Permalink
Added tests for facearea
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-Mattheus-Moerman committed Mar 20, 2024
1 parent 922fbfa commit 1afad12
Showing 1 changed file with 52 additions and 8 deletions.
60 changes: 52 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ end
V[1] = GeometryBasics.Point{3, Float64}(0.0, 0.0, 0.0)
V[2] = GeometryBasics.Point{3, Float64}(1.0, 0.0, 0.0)
V[3] = GeometryBasics.Point{3, Float64}(1.0, 1.0, 0.0)
C = facenormal(F,V)
@test C == [Vec3{Float64}(0.0,0.0,1.0)]
N = facenormal(F,V)
@test N == [Vec3{Float64}(0.0,0.0,1.0)]
end
@testset "Single quad" begin
F = [QuadFace{Int64}(1, 2, 3, 4)]
Expand All @@ -316,8 +316,8 @@ end
V[2] = GeometryBasics.Point{3, Float64}(1.0, 0.0, 0.0)
V[3] = GeometryBasics.Point{3, Float64}(1.0, 1.0, 0.0)
V[4] = GeometryBasics.Point{3, Float64}(0.0, 1.0, 0.0)
C = facenormal(F,V)
@test C == [Vec3{Float64}(0.0,0.0,1.0)]
N = facenormal(F,V)
@test N == [Vec3{Float64}(0.0,0.0,1.0)]
end
@testset "Triangles" begin
F = [TriangleFace{Int64}(1, 2, 3),TriangleFace{Int64}(1, 4, 3)]
Expand All @@ -326,8 +326,8 @@ end
V[2] = GeometryBasics.Point{3, Float64}(1.0, 0.0, 0.0)
V[3] = GeometryBasics.Point{3, Float64}(1.0, 1.0, 0.0)
V[4] = GeometryBasics.Point{3, Float64}(0.0, 1.0, 0.0)
C = facenormal(F,V)
@test C == [Vec3{Float64}(0.0,0.0,1.0),Vec3{Float64}(0.0,0.0,-1.0)]
N = facenormal(F,V)
@test N == [Vec3{Float64}(0.0,0.0,1.0),Vec3{Float64}(0.0,0.0,-1.0)]
end
@testset "Quads" begin
F = [QuadFace{Int64}(1, 2, 3, 4),QuadFace{Int64}(6, 5, 4, 3)]
Expand All @@ -338,8 +338,52 @@ end
V[4] = GeometryBasics.Point{3, Float64}(0.0, 1.0, 0.0)
V[5] = GeometryBasics.Point{3, Float64}(2.0, 0.0, 0.0)
V[6] = GeometryBasics.Point{3, Float64}(2.0, 1.0, 0.0)
C = facenormal(F,V)
@test C == [Vec3{Float64}(0.0,0.0,1.0),Vec3{Float64}(0.0,0.0,-1.0)]
N = facenormal(F,V)
@test N == [Vec3{Float64}(0.0,0.0,1.0),Vec3{Float64}(0.0,0.0,-1.0)]
end
end

@testset "facearea" verbose = true begin
@testset "Single triangle" begin
F = [TriangleFace{Int64}(1, 2, 3)]
V = Vector{GeometryBasics.Point{3, Float64}}(undef,3)
V[1] = GeometryBasics.Point{3, Float64}(0.0, 0.0, 0.0)
V[2] = GeometryBasics.Point{3, Float64}(1.0, 0.0, 0.0)
V[3] = GeometryBasics.Point{3, Float64}(1.0, 1.0, 0.0)
A = facearea(F,V)
@test A == [0.5]
end
@testset "Single quad" begin
F = [QuadFace{Int64}(1, 2, 3, 4)]
V = Vector{GeometryBasics.Point{3, Float64}}(undef,4)
V[1] = GeometryBasics.Point{3, Float64}(0.0, 0.0, 0.0)
V[2] = GeometryBasics.Point{3, Float64}(1.0, 0.0, 0.0)
V[3] = GeometryBasics.Point{3, Float64}(1.0, 1.0, 0.0)
V[4] = GeometryBasics.Point{3, Float64}(0.0, 1.0, 0.0)
A = facearea(F,V)
@test A == [1.0]
end
@testset "Triangles" begin
F = [TriangleFace{Int64}(1, 2, 3),TriangleFace{Int64}(1, 4, 3)]
V = Vector{GeometryBasics.Point{3, Float64}}(undef,4)
V[1] = GeometryBasics.Point{3, Float64}(0.0, 0.0, 0.0)
V[2] = GeometryBasics.Point{3, Float64}(1.0, 0.0, 0.0)
V[3] = GeometryBasics.Point{3, Float64}(1.0, 1.0, 0.0)
V[4] = GeometryBasics.Point{3, Float64}(0.0, 1.0, 0.0)
A = facearea(F,V)
@test A == [0.5,0.5]
end
@testset "Quads" begin
F = [QuadFace{Int64}(1, 2, 3, 4),QuadFace{Int64}(6, 5, 4, 3)]
V = Vector{GeometryBasics.Point{3, Float64}}(undef,6)
V[1] = GeometryBasics.Point{3, Float64}(0.0, 0.0, 0.0)
V[2] = GeometryBasics.Point{3, Float64}(1.0, 0.0, 0.0)
V[3] = GeometryBasics.Point{3, Float64}(1.0, 1.0, 0.0)
V[4] = GeometryBasics.Point{3, Float64}(0.0, 1.0, 0.0)
V[5] = GeometryBasics.Point{3, Float64}(2.0, 0.0, 0.0)
V[6] = GeometryBasics.Point{3, Float64}(2.0, 1.0, 0.0)
A = facearea(F,V)
@test A == [1.0,1.0]
end
end

Expand Down

0 comments on commit 1afad12

Please sign in to comment.