From 1afad12a1afa808a53b092c37e20159abab3ed3a Mon Sep 17 00:00:00 2001 From: Kevin-Mattheus-Moerman Date: Wed, 20 Mar 2024 15:12:37 +0000 Subject: [PATCH] Added tests for facearea --- test/runtests.jl | 60 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index ca75445..0b378b9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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)] @@ -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)] @@ -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)] @@ -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