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:
read_opf
and write_opf
);viz
and viz!
, optionally using coloring by attribute;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!)
read_opf()
write_opf()
.read_ops()