Skip to content

Commit c7353d8

Browse files
committed
fix tests
1 parent b5e0937 commit c7353d8

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

src/basic_types.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,22 @@ end
352352
Tables.schema(mesh::Mesh) = Tables.schema(getfield(mesh, :simplices))
353353

354354
function Base.getproperty(mesh::Mesh, name::Symbol)
355-
return getproperty(getfield(mesh, :simplices), name)
355+
if name === :position
356+
# a mesh always has position defined by coordinates...
357+
return coordinates(mesh)
358+
else
359+
return getproperty(getfield(mesh, :simplices), name)
360+
end
356361
end
357362

358363
function Base.propertynames(mesh::Mesh)
359-
return propertynames(getfield(mesh, :simplices))
364+
names = propertynames(getfield(mesh, :simplices))
365+
if :positions in names
366+
return names
367+
else
368+
# a mesh always has positions!
369+
return (names..., :position)
370+
end
360371
end
361372

362373
function Base.summary(io::IO, ::Mesh{Dim, T, Element}) where {Dim, T, Element}

src/geometry_primitives.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ function decompose(::Type{P}, primitive, args...) where {P<:AbstractPoint}
9898
return collect_with_eltype(P, coordinates(primitive, args...))
9999
end
100100

101-
102-
103-
function decompose(::Type{Point}, primitive::GeometryPrimitive{Dim}, args...) where {Dim}
101+
function decompose(::Type{Point}, primitive::Union{GeometryPrimitive{Dim}, Mesh{Dim}}, args...) where {Dim}
104102
return collect_with_eltype(Point{Dim, Float32}, coordinates(primitive, args...))
105103
end
106104

test/runtests.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,15 @@ end
279279

280280
@testset "decompose/triangulation" begin
281281
primitive = Sphere(Point3f0(0), 1)
282-
triangle_mesh(primitive)
282+
mesh = triangle_mesh(primitive)
283+
@test decompose(Point, mesh) isa Vector{Point3f0}
284+
@test decompose(Point, primitive) isa Vector{Point3f0}
283285
primitive = Rect2D(0, 0, 1, 1)
284-
triangle_mesh(primitive)
286+
mesh = triangle_mesh(primitive)
287+
288+
@test decompose(Point, mesh) isa Vector{Point2f0}
289+
@test decompose(Point, primitive) isa Vector{Point2f0}
290+
285291
primitive = Rect3D(0, 0, 0, 1, 1, 1)
286292
triangle_mesh(primitive)
287293

@@ -295,8 +301,8 @@ end
295301
points = decompose(Point2f0, Circle(Point2f0(0), 1))
296302
triangle_mesh(points)
297303
@test true # yay no errors so far!
298-
end
299304

305+
end
300306

301307
@testset "Tests from GeometryTypes" begin
302308
include("geometrytypes.jl")
@@ -317,10 +323,11 @@ end
317323

318324
m, colpopt = GeometryBasics.pop_pointmeta(m, :color)
319325
m, xxpopt = GeometryBasics.pop_pointmeta(m, :xx)
326+
320327
@test propertynames(m) == (:position,)
321328
@test colpopt === color
322329
@test xxpopt === xx
323-
330+
324331
@testset "creating meta" begin
325332
x = Point3f0[(1,3,4)]
326333
# no meta gets added, so should stay the same

0 commit comments

Comments
 (0)