@@ -204,16 +204,19 @@ end
204204 @test values (ns) ≈ Vec3f[[0.9805807 , 0.0 , 0.19611615 ], [0.0 , 0.9805807 , 0.19611615 ], [- 0.9805807 , 0.0 , 0.19611615 ], [0.0 , - 0.9805807 , 0.19611615 ], [0.0 , 0.0 , - 1.0 ]]
205205end
206206
207- NFace = NgonFace
207+ @testset " Type Utils" begin
208+ @test GeometryBasics. Face (TriangleFace, Int32) == TriangleFace{Int32}
209+ @test GeometryBasics. Face (GLTriangleFace, Int32) == TriangleFace{GLIndex}
210+ end
208211
209212@testset " Faces" begin
210213 @test convert_simplex (GLTriangleFace, QuadFace {Int} (1 , 2 , 3 , 4 )) ==
211214 (GLTriangleFace (1 , 2 , 3 ), GLTriangleFace (1 , 3 , 4 ))
212- @test convert_simplex (NFace {3 ,ZeroIndex{Int}}, QuadFace {ZeroIndex{Int}} (1 , 2 , 3 , 4 )) ==
213- (NFace {3,ZeroIndex{Int}} (1 , 2 , 3 ), NFace {3,ZeroIndex{Int}} (1 , 3 , 4 ))
214- @test convert_simplex (NFace {3 ,OffsetInteger{3 ,Int}},
215- NFace {4,OffsetInteger{2,Int}} (1 , 2 , 3 , 4 )) ==
216- (NFace {3,OffsetInteger{3,Int}} (1 , 2 , 3 ), NFace {3,OffsetInteger{3,Int}} (1 , 3 , 4 ))
215+ @test convert_simplex (NgonFace {3 ,ZeroIndex{Int}}, QuadFace {ZeroIndex{Int}} (1 , 2 , 3 , 4 )) ==
216+ (NgonFace {3,ZeroIndex{Int}} (1 , 2 , 3 ), NgonFace {3,ZeroIndex{Int}} (1 , 3 , 4 ))
217+ @test convert_simplex (NgonFace {3 ,OffsetInteger{3 ,Int}},
218+ NgonFace {4,OffsetInteger{2,Int}} (1 , 2 , 3 , 4 )) ==
219+ (NgonFace {3,OffsetInteger{3,Int}} (1 , 2 , 3 ), NgonFace {3,OffsetInteger{3,Int}} (1 , 3 , 4 ))
217220 @test convert_simplex (LineFace{Int}, QuadFace {Int} (1 , 2 , 3 , 4 )) ==
218221 (LineFace {Int} (1 , 2 ), LineFace {Int} (2 , 3 ), LineFace {Int} (3 , 4 ),
219222 LineFace {Int} (4 , 1 ))
@@ -226,6 +229,33 @@ NFace = NgonFace
226229 @test convert_simplex (NgonFace{1 ,UInt32}, face) === (NgonFace {1,UInt32} ((1 ,)),)
227230 @test convert_simplex (typeof (face), face) === (face,)
228231 end
232+
233+ ps = rand (Point2f, 10 )
234+ f = GLTriangleFace (1 , 2 , 3 )
235+ @test ps[f] == Triangle (ps[[1 ,2 ,3 ]]. .. )
236+ data = [string (i) for i in 1 : 10 ]
237+ f = QuadFace (3 , 4 , 7 , 8 )
238+ @test data[f] == (" 3" , " 4" , " 7" , " 8" )
239+
240+ @test hash (f) != hash (QuadFace (1 ,2 ,3 ,4 ))
241+ @test hash (f) == hash (QuadFace (3 ,4 ,7 ,8 ))
242+ # cyclic permutation does not change the face
243+ @test hash (f) == hash (QuadFace (7 ,8 ,3 ,4 ))
244+ @test hash (GLTriangleFace (1 ,2 ,3 )) == hash (GLTriangleFace (1 ,2 ,3 ))
245+ @test hash (GLTriangleFace (1 ,2 ,3 )) == hash (GLTriangleFace (2 ,3 ,1 ))
246+ @test hash (GLTriangleFace (1 ,2 ,3 )) == hash (GLTriangleFace (3 ,1 ,2 ))
247+ end
248+
249+ @testset " FaceView" begin
250+ ps = rand (Point2f, 5 )
251+ fs = GLTriangleFace[(1 ,2 ,3 ), (2 ,3 ,4 ), (5 ,5 ,5 )]
252+ fv = FaceView (ps, fs)
253+ @test faces (fv) == fs
254+ @test values (fv) == ps
255+ @test fv[fs[1 ]] == ps[fs[1 ]]
256+ @test ! isempty (fv)
257+ @test fv == FaceView (ps, fs)
258+ @test length (fv) == 5
229259end
230260
231261@testset " Normals" begin
253283 v_ns = normals (coordinates (c), filter! (f -> f isa QuadFace, faces (c)))[1 : end - 2 ]
254284 @test values (ns)[1 : 15 ] ≈ v_ns[1 : 15 ]
255285 @test values (ns)[1 : 15 ] ≈ v_ns[16 : 30 ] # repeated via FaceView in ns
256-
257286end
258287
259288@testset " HyperSphere" begin
455484 r = Rect2i (2 , 4 , 2 , 4 )
456485 @test M[r] == [53 63 73 83 ; 54 64 74 84 ]
457486
487+ end
488+
489+ @testset " LineStrings" begin
490+ ps1 = rand (Point2f, 10 )
491+ ls1 = LineString (ps1)
492+ _ls1 = LineString (ps1)
493+ @test coordinates (ls1) == ps1
494+ @test length (ls1) == 10
495+ @test ls1 == _ls1
496+
497+ ls2 = LineString (rand (Point2f, 6 ))
498+ ls3 = LineString (rand (Point2f, 4 ))
499+ mls = MultiLineString ([ls1, ls2, ls3])
500+ @test mls. linestrings == [ls1, ls2, ls3]
501+ @test mls[1 ] == ls1
502+ @test mls[2 ] == ls2
503+ @test mls[3 ] == ls3
504+ @test size (mls) == (3 , ) # TODO : Does this make sense?
505+ @test length (mls) == 3
506+ @test MultiLineString (OffsetArray ([ls1, ls2, ls3], 0 )) == mls
507+ end
508+
509+ @testset " MultiPoint" begin
510+ ps1 = rand (Point2f, 10 )
511+ mp = MultiPoint (ps1)
512+ @test all (getindex .(Ref (mp), 1 : 10 ) .== ps1)
513+ @test size (mp) == (10 , ) # TODO : Does this make sense?
514+ @test length (mp) == 10
458515end
0 commit comments