Skip to content

Commit 652b8a7

Browse files
committed
autoconvert point dim in merge(meshes) instead of restricitng type
1 parent e084c6a commit 652b8a7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/meshes.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ Generates a new mesh containing all the data of the individual meshes.
236236
If all meshes are consistent in their use of FaceViews they will be preserved.
237237
Otherwise all of them will be converted with `clear_faceviews(mesh)`.
238238
"""
239-
function Base.merge(meshes::AbstractVector{<:Mesh{D}}) where {D}
239+
function Base.merge(meshes::AbstractVector{<:Mesh})
240240
return if isempty(meshes)
241241
return Mesh(Point3f[], GLTriangleFace[])
242242

@@ -271,12 +271,18 @@ function Base.merge(meshes::AbstractVector{<:Mesh{D}}) where {D}
271271
@label DOUBLE_BREAK
272272

273273
if consistent_face_views
274-
274+
275275
# All the same kind of face, can just merge
276276
new_attribs = NamedTuple{names}(map(names) do name
277-
return reduce(vcat, getproperty.(meshes, name))
277+
if name === :position
278+
D = maximum(ndims, meshes)
279+
T = mapreduce(m -> eltype(pointtype(m)), promote_type, meshes)
280+
PT = Point{D, T}
281+
return reduce(vcat, decompose.(PT, meshes))
282+
else
283+
return reduce(vcat, getproperty.(meshes, name))
284+
end
278285
end)
279-
# fs = reduce(vcat, faces.(meshes))
280286
fs = reduce(vcat, faces.(meshes))
281287

282288
# TODO: is the type difference in offset bad?

0 commit comments

Comments
 (0)