Skip to content

Commit

Permalink
Merge pull request #199 from JonasIsensee/patch-5
Browse files Browse the repository at this point in the history
improve merge(meshes)
  • Loading branch information
SimonDanisch authored Jul 18, 2023
2 parents 48b1ef6 + ba8bd56 commit d5435e4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/meshes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,23 @@ function Base.merge(meshes::AbstractVector{<:Mesh})
elseif length(meshes) == 1
return meshes[1]
else
m1 = meshes[1]
ps = copy(coordinates(m1))
fs = copy(faces(m1))
ps = reduce(vcat, coordinates.(meshes))
fs = reduce(vcat, faces.(meshes))
idx = length(faces(meshes[1]))
offset = length(coordinates(meshes[1]))
for mesh in Iterators.drop(meshes, 1)
append!(fs, map(f -> f .+ length(ps), faces(mesh)))
append!(ps, coordinates(mesh))
N = length(faces(mesh))
for i = idx .+ (1:N)
fs[i] = fs[i] .+ offset
end
idx += N
offset += length(coordinates(mesh))
end
return Mesh(ps, fs)
end
end


"""
pointmeta(mesh::Mesh; meta_data...)
Expand Down

0 comments on commit d5435e4

Please sign in to comment.