I’m attempting to port Steven De Keninck’s 3D slicer example application (listed here and demonstrated here) from JavaScript to Julia. The example application loads a 3D model of a bunny (from https://enkimute.github.io/ganja.js/examples/bunny.obj having 5002 triangle faces) and calculates cross sections of it using projective geometric algebra. The demonstration also shows that projective geometric algebra can efficiently calculate the cross section circumference and area, which would be particularly helpful in a slicer application for 3D printing.
In the JavaScript version the bunny object text file is parsed line by line, during which all the vertices are scaled up by a factor of 13. In contrast, the Julia version can parse the whole bunny object text file using Makie.FileIO’s load(), but, to follow the JavaScript version, the Julia version should then scale up all the vertices by a factor of 13 in the immutable GeometryBasics.Mesh structure returned by Makie.FileIO load(). Any tips on how to do that? Specifically, how can the vertices in the GeometryBasics.Mesh structure be converted to some array that can be scaled and then put back in a GeometryBasics.Mesh structure to be plotted by Makie?
using GLMakie, Makie.FileIO, GeometryBasics
# load faces of bunny object
F = load("bunny.obj")
# (TODO: scale the vertices of F by 13)
# plot bunny using Axis3
fig = Figure(resolution = (1000, 700))
ax3d = Axis3(fig[1,1],
elevation = pi/2,
azimuth = 3*pi/2,
aspect = (1,1,1))
m = mesh!(ax3d, F)
fig
P.S., At first, I thought this was a general question about how to modify elements of an immutable structure and I posted the question here. However, the question of how to convert the vertices to an array that can be scaled appears to be specific to GeometryBasics. Of course, it is possible to scale the vertices while parsing the 3D object text file line by line in the Julia version just like in the JavaScript version, but I would like the Julia port to be as elegant as possible because the example will be used in an essay proposing that Julia is a good language choice when implementing projective geometric algebra applications.