OpenAlea.PlantConvert
is a package for converting plants in mtg
format into different other file formats.
You need to install the conda environment. Make sur you have one of conda / miniconda / mamba / micromamba installed, and then:
conda env create -f environment.yaml conda activate plantconvert
>>> import openalea.plantconvert
This project allows you to read and write mtg into mulitiple formats :
- homemade .mtg and .opf file formats
- gltf/glb
- vtk/vtp
If you would like to have example dataset of mtg with geometries, please
install the conda envrionment strawberry.yml
and please also install
pygltflib
and vtk
by pip in the new environment.
For instance, there is not yet available setup tool for current package,
please source the bash script add.sh
one time before you launch
Python scripts that require the package. This bash script
They are encoded in ascii and directly parsed to construct a mtg object.
.mtg
is the default file format used by openalea
and it only
allows to save geometric parameters and not meshes. The .opf
is a
historical file formats used by archimed plateform and allows to save
both the topologic and geometric information.
They are .json
styled file format designed to transmit computer
graphics object by web. It allows to save topologic information by
creating a scene graph (tree graph that explains the hierarchy of
visible objects), we exploit this functionality to save the plants’
topology in those file format. The attributes of an mtg are saved as
extras
field of each node of the scene graph.
We can insert references to meshes inside the .gltf
file. .glb
is the same as .gltf
but with mesh data embedded inside the same
file.
We parse the .gltf
file by using the Python
package
pygltflib
. It constructs a gltf
Python object that is converted
to a mtg object.
They are classic file formats with a large spectrum of geometric tools associated. We use this file formats to save the topology of a plants using polylines. A mtg node is viewed as a point with coordinates of the polylines, the branching system is viewed as segments of polylines, the edge type can be seen as an edge variable of polyline.
The attributes can be saved as points variables.
These formats are very efficient in terms of memory usage, they allow to save data in binary format.
For best experience create a new conda environment (e.g. DEVELOP) with Python 3.9:
conda create -n DEVELOP -c conda-forge python=3.9 conda activate DEVELOP
Before pushing to GitHub, run the following commands:
- Update conda environment:
make conda-env-update
- Install this package:
pip install -e .
- Sync with the latest
template
(optional):
make template-update
- Run quality assurance checks:
make qa
- Run tests:
make unit-tests
- Run the static type checker:
make type-check
- Build the documentation (see Sphinx
tutorial):
make docs-build
Copyright 2023, European Union. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.