Skip to content

Commit 9758bed

Browse files
committed
remove add_meta, pop_meta
1 parent 6ffd173 commit 9758bed

File tree

4 files changed

+3
-74
lines changed

4 files changed

+3
-74
lines changed

src/GeometryBasics.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export decompose, coordinates, faces, normals, decompose_uv, decompose_normals,
4343
texturecoordinates
4444
export Tesselation, Normal, UV, UVW
4545
export AbstractMesh, Mesh, MetaMesh
46-
export add_meta, pop_meta
4746

4847

4948
# all the different predefined mesh types

src/meshes.jl

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function mesh(polygon::AbstractVector{P}; pointtype=P, facetype=GLTriangleFace)
6161
return mesh(Polygon(polygon); pointtype=pointtype, facetype=facetype)
6262
end
6363

64-
function triangle_mesh(primitive::Union{AbstractGeometry{N}, AbstractVector{<: Point{N}}})::TriangleMesh{N} where {N}
64+
function triangle_mesh(primitive::Union{AbstractGeometry{N}, AbstractVector{<: Point{N}}})::SimpleTriangleMesh{N} where {N}
6565
return mesh(primitive; pointtype=Point{N, Float32})
6666
end
6767

@@ -278,36 +278,6 @@ function map_coordinates!(f, mesh::AbstractMesh)
278278
return mesh
279279
end
280280

281-
# TODO:
282-
add_meta(m, kw...) = error("TODO")
283-
pop_meta(m, kw...) = error("TODO")
284-
# function add_meta(mesh::MetaMesh; kw...)
285-
# return MetaMesh(Mesh(mesh), (; meta(mesh)..., kw...))
286-
# end
287-
288-
# function add_meta(mesh::Mesh; kw...)
289-
# return MetaMesh(mesh, (; meta(mesh)..., kw...))
290-
# end
291-
292-
# # I didn't find a simple way to remove a field from a namedtuple in a type stable way without
293-
# # a generated function..
294-
# @generated function pop(nt::NamedTuple{Names, Values}, ::Val{name}) where {Names, Values, name}
295-
# if !(name in Names)
296-
# return :(throw(Base.KeyError($(QuoteNode(name)))))
297-
# else
298-
# names = filter(x-> x !== name, Names)
299-
# nt = map(names) do name
300-
# :($name = nt.$(name))
301-
# end
302-
# return :((; $(nt...)), nt.$(name))
303-
# end
304-
# end
305-
306-
# function pop_meta(mesh::MetaMesh, name::Symbol)
307-
# new_meta, value = pop(meta(mesh), Val(name))
308-
# return MetaMesh(mesh, new_meta), value
309-
# end
310-
311281
function Base.show(io::IO, ::MIME"text/plain", mesh::Mesh{N, T, FT}) where {N, T, FT}
312282
println(io, "Mesh{$N, $T, $FT}")
313283
println(io, " faces: ", length(faces(mesh)))

test/meshes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ end
4545
m2 = GeometryBasics.merge_vertex_indices(m)
4646

4747
@test faces(m) isa AbstractVector{<: GeometryBasics.MultiFace}
48-
@test names(eltype(faces(m))) == keys(GeometryBasics.vertex_attributes(m))
48+
@test propertynames(eltype(faces(m))) == keys(GeometryBasics.vertex_attributes(m))
4949
@test isempty(m.views)
5050

5151
@test faces(m2) isa AbstractVector{<: QuadFace}

test/runtests.jl

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Test, Random, OffsetArrays
22
using GeometryBasics
33
using LinearAlgebra
4-
using GeometryBasics: MetaMesh, add_meta, pop_meta
4+
using GeometryBasics: MetaMesh
55
using GeoInterface
66
using GeoJSON
77
using Extents
@@ -203,46 +203,6 @@ end
203203
@test m.normals == [Vec3f(0, 0, 1) for p in coordinates(m)]
204204
end
205205

206-
@testset "convert mesh + meta" begin
207-
m = uv_normal_mesh(Rect3f(Vec3f(-1), Vec3f(1, 2, 3)))
208-
m_normal = add_meta(m; normals = decompose_normals(m))
209-
# make sure we don't loose the uv
210-
@test hasproperty(m_normal, :uv)
211-
# Make sure we don't create any copies
212-
@test coordinates(m) === coordinates(m_normal)
213-
@test m.normals == m_normal.normals
214-
@test m.uv === m_normal.uv
215-
216-
m = uv_mesh(Rect3f(Vec3f(-1), Vec3f(1, 2, 3)))
217-
m_normal = add_meta(m, normals = decompose_normals(m))
218-
@test hasproperty(m_normal, :uv)
219-
@test coordinates(m) === coordinates(m_normal)
220-
@test decompose_normals(m) == GeometryBasics.normals(m_normal)
221-
# uv stays untouched, since we don't specify the element type in normalmesh
222-
@test m.uv === m_normal.uv
223-
end
224-
225-
@testset "modifying meta" begin
226-
xx = rand(10)
227-
points = rand(Point3f, 10)
228-
m = MetaMesh(points, GLTriangleFace[(1,2,3), (3,4,5)]; xx=xx)
229-
color = rand(10)
230-
m = add_meta(m; color=color)
231-
232-
@test hasproperty(m, :xx)
233-
@test hasproperty(m, :color)
234-
235-
@test m.xx === xx
236-
@test m.color === color
237-
238-
m, colpopt = GeometryBasics.pop_meta(m, :color)
239-
m, xxpopt = GeometryBasics.pop_meta(m, :xx)
240-
241-
@test propertynames(m) == ()
242-
@test colpopt === color
243-
@test xxpopt === xx
244-
end
245-
246206
@testset "mesh conversion" begin
247207
s = Sphere(Point3(0.0), 1.0)
248208
m = GeometryBasics.mesh(s)

0 commit comments

Comments
 (0)