I’m having a tough time optimising and parallelising this function that executes a simplex extrusion (solid modeling). Anything to make it faster would be great, even a couple macros.
function extrudeSimplicial(model::Lar.LAR, pattern)
V = [model[1][:,k] for k=1:size(model[1],2)]
FV = model[2]
d, m = length(FV[1]), length(pattern)
coords = collect(cumsum(append!([0], abs.(pattern))))
offset, outcells, rangelimit, i = length(V), [], d*m, 0
for cell in FV
i += 1
tube = [v+k*offset for k in range(0, length=m+1) for v in cell]
cellTube = [tube[k:k+d] for k in range(1, length=rangelimit)]
if i==1 outcells = reshape(cellTube, d, m)
else outcells = vcat(outcells, reshape(cellTube, d, m)) end
end
cellGroups = []
for i in 1:size(outcells, 2)
if pattern[i]>0
cellGroups = vcat(cellGroups, outcells[:, i])
end
end
outVertices = [vcat(v, [z]) for z in coords for v in V]
cellGroups = convert(Array{Array{Int, 1}, 1}, cellGroups)
outModel = outVertices, cellGroups
hcat(outVertices...), cellGroups
end
function extrudeSimplicial(model::Union{Any,Lar.Cells}, pattern)
V,FV = model
d, m = length(FV[1]), length(pattern)
coords = collect(cumsum(append!([0], abs.(pattern))))
offset, outcells, rangelimit, i = length(V), [], d*m, 0
for cell in FV
i += 1
tube = [v+k*offset for k in range(0, length=m+1) for v in cell]
cellTube = [tube[k:k+d] for k in range(1, length=rangelimit)]
if i==1 outcells = reshape(cellTube, d, m)
else outcells = vcat(outcells, reshape(cellTube, d, m)) end
end
cellGroups = []
for i in 1:size(outcells, 2)
if pattern[i]>0
cellGroups = vcat(cellGroups, outcells[:, i])
end
end
outVertices = [vcat(v, [z]) for z in coords for v in V]
cellGroups = convert(Array{Array{Int, 1}, 1}, cellGroups)
outModel = outVertices, cellGroups
hcat(outVertices...), cellGroups
end