Basic workflow

from geomdb import *
from geomdb.loc import Everywhere, BoundingBox, plot
from geomdb.prop import Constant
from geomdb.db import DataBase

# For visualization
from geomdb.utils import scene_to_notebook

# We can use GPU... but as the default jax is cpu-only, let's disable the "GPU not found" warning for now.
import jax; jax.config.update('jax_platform_name', 'cpu')

Read geometry and create voxelation

voxel = voxel_from_stl("data/stanford-bunny.stl", 2)
lower_left_corner, upper_right_corner = voxel.bounds

Select parts of the voxelation using bounding boxes

bb = BoundingBox(lower_left=lower_left_corner, upper_right=[31, 3, 49])
scene_to_notebook(plot(bb, voxel))

Create a database “on” the geometry

db = DataBase(voxel)

Deposit data into the database

db.add_property(Constant("a", "blah").at(bb))
db.add_property(Constant("b", 1.2).at(~bb))
db.add_property(Constant("c", -1000))

Query the values of certain properties at given locations of the geometry

db.query(["a", "c"]).to_dataframe()
index (a, 0) (c, 0) (index, x) (index, y) (index, z) (coord, x) (coord, y) (coord, z)
0 5794 blah -1000 2 15 19 -20.0 -12.0 44.0
1 5795 blah -1000 2 15 20 -20.0 -12.0 46.0
2 5796 blah -1000 2 15 21 -20.0 -12.0 48.0
3 5848 blah -1000 2 16 18 -20.0 -10.0 42.0
4 5849 blah -1000 2 16 19 -20.0 -10.0 44.0
... ... ... ... ... ... ... ... ... ...
7458 68052 blah -1000 27 22 17 30.0 2.0 40.0
7459 68053 blah -1000 27 22 18 30.0 2.0 42.0
7460 68054 blah -1000 27 22 19 30.0 2.0 44.0
7461 68055 blah -1000 27 22 20 30.0 2.0 46.0
7462 68056 blah -1000 27 22 21 30.0 2.0 48.0

7463 rows × 9 columns

The database can be saved

db.save("overview", override=True)

The saved database can be shared and reloaded on platform with possibly different python versions

db_reload = DataBase.load("overview")

The same query will yield the same result

db_reload.query(["a", "c"]).to_dataframe()
index (a, 0) (c, 0) (index, x) (index, y) (index, z) (coord, x) (coord, y) (coord, z)
0 5794 blah -1000 2 15 19 -20.0 -12.0 44.0
1 5795 blah -1000 2 15 20 -20.0 -12.0 46.0
2 5796 blah -1000 2 15 21 -20.0 -12.0 48.0
3 5848 blah -1000 2 16 18 -20.0 -10.0 42.0
4 5849 blah -1000 2 16 19 -20.0 -10.0 44.0
... ... ... ... ... ... ... ... ... ...
7458 68052 blah -1000 27 22 17 30.0 2.0 40.0
7459 68053 blah -1000 27 22 18 30.0 2.0 42.0
7460 68054 blah -1000 27 22 19 30.0 2.0 44.0
7461 68055 blah -1000 27 22 20 30.0 2.0 46.0
7462 68056 blah -1000 27 22 21 30.0 2.0 48.0

7463 rows × 9 columns