geometry_model
¶
Solver-agnostic geometry model for 3D visualization.
Provides generic Prism and GeometryModel dataclasses that represent extruded 2D polygons without any solver dependency (no meep, no tidy3d). These are suitable for client-side visualization and geometry inspection.
Classes:
-
Prism–A 2D polygon extruded along z.
-
GeometryModel–Collection of prisms organized by layer.
Functions:
-
extract_geometry_model–Convert a LayeredComponentBase into a GeometryModel.
GeometryModel
dataclass
¶
GeometryModel(
prisms: dict[str, list[Prism]],
bbox: tuple[tuple[float, float, float], tuple[float, float, float]],
layer_bboxes: dict[
str, tuple[tuple[float, float, float], tuple[float, float, float]]
] = dict(),
layer_mesh_orders: dict[str, int] = dict(),
)
Complete 3D geometry: layers of prisms, ready for visualization.
Attributes:
-
prisms(dict[str, list[Prism]]) –Mapping from layer name to list of Prism objects.
-
bbox(tuple[tuple[float, float, float], tuple[float, float, float]]) –Axis-aligned 3D bounding box as ((xmin, ymin, zmin), (xmax, ymax, zmax)).
-
layer_bboxes(dict[str, tuple[tuple[float, float, float], tuple[float, float, float]]]) –Optional per-layer bounding boxes for 2D slice logic.
-
layer_mesh_orders(dict[str, int]) –Optional mapping of layer_name -> mesh_order for z-ordering in 2D plots.
- API Guides Shared components guide Geometry
-
API Reference
gsim
Methods:
-
get_layer_bbox–Return the bounding box for a specific layer.
-
get_layer_center–Return the center of a layer's bounding box.
get_layer_bbox
¶
Return the bounding box for a specific layer.
Falls back to the geometry-wide bbox if no per-layer bbox is stored.
Prism
dataclass
¶
Prism(
vertices: ndarray,
z_base: float,
z_top: float,
layer_name: str = "",
material: str = "",
sidewall_angle: float = 0.0,
original_polygon: Any = None,
)
A 2D polygon extruded in z. No solver dependency.
Attributes:
-
vertices(ndarray) –(N, 2) numpy array of xy coordinates defining the polygon.
-
z_base(float) –Bottom z coordinate of the extrusion.
-
z_top(float) –Top z coordinate of the extrusion.
-
layer_name(str) –Name of the layer this prism belongs to.
-
material(str) –Name of the material assigned to this prism.
-
sidewall_angle(float) –Sidewall taper angle in degrees (gdsfactory convention).
-
original_polygon(Any) –Optional reference to the source Shapely polygon.
- API Guides Shared components guide Geometry
-
API Reference
gsim
extract_geometry_model
¶
extract_geometry_model(layered_component: LayeredComponentBase) -> GeometryModel
Convert a LayeredComponentBase into a GeometryModel with generic Prisms.
For each geometry layer (sorted by mesh_order): 1. Retrieve the merged Shapely polygon from layered_component.polygons. 2. Compute z_base / z_top from get_layer_bbox. 3. Iterate sub-polygons for MultiPolygon geometries. 4. Handle polygons with holes via Delaunay triangulation. 5. Produce Prism objects with (N, 2) numpy vertex arrays.
Parameters:
-
layered_component(LayeredComponentBase) –A LayeredComponentBase (or subclass) instance that provides polygons, geometry_layers, and get_layer_bbox.
Returns:
-
GeometryModel–A GeometryModel containing all extracted prisms and the overall
-
GeometryModel–3D bounding box.
- API Guides Shared components guide Geometry