Geode-solutions Explicit Models
geode-explicit is the OpenGeode module from Geode-solutions for defining and manipulating explicit geometric models, such as regular grids and explicit solids, within a 3D space. It is part of a larger ecosystem of C++ and Python libraries for geometric modeling. The library is actively maintained with frequent updates and bug fixes, typically following a rapid release cadence for the Geode-solutions ecosystem, with the current version being 7.0.7.
Common errors
-
ImportError: cannot import name 'RegularGrid' from 'geode_explicit.regular_grid'
cause Incorrect or outdated import path. For `geode-explicit` v7.x, many core classes are directly exposed under the top-level `geode_explicit` module.fixUpdate your import statement to `from geode_explicit import RegularGrid` (or the respective class name). -
AttributeError: 'RegularGrid' object has no attribute 'get_cells_number'
cause This method name (or similar) was likely used in older versions (e.g., 6.x) and has been renamed or replaced in 7.x.fixConsult the `geode-explicit` v7.x documentation for the correct method name. For this specific case, `grid.nb_cells()` is the correct equivalent. -
ERROR: No matching distribution found for geode-explicit
cause The Python version in use is not supported by `geode-explicit`, or the package index cannot be reached.fixVerify your Python version is between 3.9 and 3.12 (inclusive). If not, switch to a supported Python version. Also check internet connectivity and PyPI availability. -
RuntimeError: OpenGeode error: Error message from underlying C++ library
cause This is a generic error indicating an issue within the underlying Geode C++ library, often due to invalid input data, memory constraints, or unexpected geometric configurations.fixExamine the exact C++ error message for clues. Check your input data (e.g., bounding box coordinates, grid dimensions) for validity and consistency. Simplify the problem or provide more robust input to narrow down the cause.
Warnings
- breaking The Geode-solutions ecosystem, including `geode-explicit`, underwent significant refactoring for version 7.x. Users migrating from 6.x should expect breaking API changes, particularly in class names, constructor arguments, and method signatures.
- gotcha `geode-explicit` is built on top of C++ libraries. While `pip` handles most dependencies, error messages can sometimes be low-level C++ exceptions (e.g., `std::runtime_error`) which are less descriptive than typical Python errors. Debugging may require familiarity with underlying geometric concepts.
- breaking The library has strict Python version requirements (`>=3.9, <3.13`). Attempting to install or use `geode-explicit` with unsupported Python versions will lead to installation failures or runtime errors due to pre-compiled C++ bindings.
- gotcha `geode-explicit` relies on a large ecosystem of other `geode-*` packages (e.g., `geode-common`, `geode-model`). While `pip` manages these dependencies, ensuring all `geode-*` packages in your environment are of compatible versions is crucial. An incompatibility in one package can lead to runtime issues or crashes in `geode-explicit`.
Install
-
pip install geode-explicit
Imports
- RegularGrid
from geode_explicit import RegularGrid
- ExplicitSolid
from geode_explicit import ExplicitSolid
- Point3D
from geode_common import Point3D
Quickstart
import os
from geode_explicit import RegularGrid
from geode_common import Point3D, BoundingBox
# Define the bounding box for the grid
min_point = Point3D([0.0, 0.0, 0.0])
max_point = Point3D([10.0, 10.0, 10.0])
grid_bbox = BoundingBox(min_point, max_point)
# Create a 3D regular grid with 10x10x10 cells
grid_dimensions = [10, 10, 10]
grid = RegularGrid(grid_bbox, grid_dimensions)
print(f"Created a RegularGrid with {grid.nb_cells()} cells.")
print(f"Grid origin: {grid.grid_origin()}")
print(f"Grid cell size: {grid.cell_size()}")
# Save the grid to a file
output_filename = "my_regular_grid.grd"
grid.save_regular_grid(output_filename)
print(f"Grid saved to {output_filename}")
# Load the grid from the file
loaded_grid = RegularGrid.load_regular_grid(output_filename)
print(f"Loaded a RegularGrid with {loaded_grid.nb_cells()} cells.")
# Clean up the created file
os.remove(output_filename)