PlantGeom, a package for everything 3D in plants.
The package is designed around MultiScaleTreeGraph that serves as the basic structure for the plant topology and attributes.
The package provides different functionalities, the main ones being:
- IO for the OPF file format (see
read_opf
andwrite_opf
); - plotting using
viz
andviz!
, optionally using coloring by attribute; - mesh transformations using
transform_mesh!
Note that :geometry
is a reserved attribute in nodes (e.g. organs) used for the 3D geometry. It is stored as a special structure (geometry
).
Read an example OPF:
using PlantGeom, MultiScaleTreeGraph
file = joinpath(dirname(dirname(pathof(PlantGeom))),"test","files","simple_plant.opf")
mtg = read_opf(file)
Plot the plant geometry:
using GLMakie # Choose a Makie backend here.
viz(mtg)
viz
search for the :geometry
attribute in the MTG nodes, and computes the meshes using the reference meshes and the transformation matrices to plot the 3d geometry of the plants.
Colour by attribute, e.g. using the mesh max Z coordinates:
transform!(mtg, refmesh_to_mesh!, zmax => :z_max, ignore_nothing = true)
viz(mtg, color = :z_max)
By design the 3D geometry of each node is stored in the :geometry
attribute. It stores a reference mesh, a transformation matrix, and the resulting mesh. The resulting mesh is computed lazily, meaning it is computed only the first time it is needed. To compute it explicitly, you can use refmesh_to_mesh!
(like above):
transform!(mtg, refmesh_to_mesh!)
- Add
read_opf()
- Add
write_opf()
. - Use pointers to ref meshes instead of an index. It will be more simple then.
- Add
read_ops()
- Add recipe for MTG diagram (no geometry )
- Import reference meshes from disk (e.g. export from blender): make a tutorial.
- Add tutorials:
- How to plot with Plots.jl
- How to plot with Makie.jl
- How to build a geometry using attributes and reference meshes
- How to build a plant + geometry manually and recursively
- Manage different kind of information into an MTG:
- Mesh for the nodes
- Reference meshes + transformation matrix (e.g. from OPF)
- Reference meshes + Length and/or Width/diameter for scaling. If only Length, scale the whole mesh by a factor, if Length + Width, scale accordingly, etc... This would be a shortcut to using Meshes.jl's scaling.
- Remove coffee.opf from tests and add PlantBiophysics as a dependency instead. It will make PlantGeom much lighter.
- Improve the OPF parser using e.g. our own XML parser. See https://github.com/ordovician/PLists.jl for an example pure Julia XML parser, and the corresponding blogpost here. Make the reading in parallel ? For reference, reading a 80Mo OPF takes 8Go of memory and 4.5 minutes... -> The issue came from SVectors that took forever to be allocated. I replaced them by normal vectors. It is much faster now (~11s on my computer).
- Make read_opf even faster (we should aim for e.g. 2-3s for an 80Mo OPF (largest file we have). We can make it parallel, but I think we can improve some things first (e.g. using structs instead of Dicts everywhere).
- Improve the OPF writer similarly.
- Add a section about the OPF format.
- Fix the example simple OPF -> use one cylinder only, fix the scales of each node.
- Fix the coffee OPF -> scales are wrong (Metamer = 6 -> 3, Leaf = 2 -> 3) + Fix the MTG accordingly
- Add tests using both simple_plant.opf and simple_plant.mtg to make sure both work the same way.
- Compute the vertex normals properly when writting the OPF to disk