tlc.core.data_formats.geometries
¶
2D and 3D geometry instances.
Module Contents¶
Classes¶
Class |
Description |
---|---|
Container for 2D geometry instances. |
|
Container for 3D geometry instances. |
API¶
- class Geometry2DInstances¶
Container for 2D geometry instances.
Supports all primitives: vertices, lines, triangles, axis-aligned bounding boxes, and oriented bounding boxes.
Note
Extras (per_point, per_line, per_triangle, per_instance) support scalars, fixed-size arrays, and composite Python objects (e.g., dicts).
- per_triangle_extras: dict[str, list[ndarray]] = None¶
Mapping from extra name to list of (Ti,) arrays
- classmethod create_empty(
- x_min: float = 0.0,
- y_min: float = 0.0,
- x_max: float = 0.0,
- y_max: float = 0.0,
- per_vertex_extras_keys: Sequence[str] | None = None,
- per_line_extras_keys: Sequence[str] | None = None,
- per_triangle_extras_keys: Sequence[str] | None = None,
- instance_extras_keys: Sequence[str] | None = None,
Create an empty Geometry2DInstances container.
- Parameters:
x_min – Minimum x coordinate (default 0.0)
y_min – Minimum y coordinate (default 0.0)
x_max – Maximum x coordinate
y_max – Maximum y coordinate
per_vertex_extras_keys – Sequence of keys for per-vertex additional data to initialize
per_line_extras_keys – Sequence of keys for per-line additional data to initialize
per_triangle_extras_keys – Sequence of keys for per-triangle additional data to initialize
instance_extras_keys – Sequence of keys for per-instance additional data to initialize
- Raises:
ValueError – If bounds are invalid (e.g., x_max < x_min)
- add_instance(
- vertices: ndarray,
- lines: ndarray | None = None,
- triangles: ndarray | None = None,
- bbs_2d: ndarray | None = None,
- oriented_bbs_2d: ndarray | None = None,
- per_vertex_extras: Mapping[str, ndarray] | None = None,
- per_line_extras: Mapping[str, ndarray] | None = None,
- per_triangle_extras: Mapping[str, ndarray] | None = None,
- per_instance_extras: Mapping[str, Any] | None = None,
Add a 2D instance.
- Parameters:
vertices – Array of shape (N, 2) or flattened (2N,), dtype float32
per_vertex_extras – Dict of arrays of shape (N,)
per_instance_extras – Dict of scalar per-instance attributes (one value or length-1 array)
lines – Flattened int array (2L,) of vertex indices forming L line segments
triangles – Flattened int array (3T,) of vertex indices forming T triangles
bbs_2d – Array of shape (B, 4) or flattened (4B,), dtype float32
oriented_bbs_2d – Array of shape (O, 5) or flattened (5O,), dtype float32
per_line_extras – Dict of arrays of shape (L,) for per-line extras
per_triangle_extras – Dict of arrays of shape (T,) for per-triangle extras
- Raises:
ValueError – On shape/type/index validation errors
- classmethod from_row( ) Geometry2DInstances ¶
Parse a Geometry2D row into a Geometry2DInstances object.
- Parameters:
row – Row dictionary with INSTANCES, X_MIN, Y_MIN, X_MAX, Y_MAX keys
- Raises:
ValueError – If bounds are missing or invalid
- class Geometry3DInstances¶
Container for 3D geometry instances.
Supports all primitives: vertices, lines, triangles, axis-aligned bounding boxes, and oriented bounding boxes.
Note
Extras (per_point, per_line, per_triangle, per_instance) support scalars, fixed-size arrays, and composite Python objects (e.g., dicts).
- per_vertex_extras: dict[str, list[ndarray]] = None¶
Per-vertex extras mapped by key, list per instance
- per_triangle_extras: dict[str, list[ndarray]] = None¶
Per-triangle extras mapped by key, list per instance
- bbs_3d: list[ndarray] = None¶
List of (Bi, 6) float32 arrays, AABB [x_min,y_min,z_min,x_max,y_max,z_max]
- per_instance_extras: dict[str, ndarray] = None¶
Per-instance extras, arrays of shape (num_instances, …)
- classmethod create_empty(
- x_min: float = 0.0,
- x_max: float = 0.0,
- y_min: float = 0.0,
- y_max: float = 0.0,
- z_min: float = 0.0,
- z_max: float = 0.0,
- per_vertex_extras_keys: Sequence[str] | None = None,
- per_line_extras_keys: Sequence[str] | None = None,
- per_triangle_extras_keys: Sequence[str] | None = None,
- instance_extras_keys: Sequence[str] | None = None,
Create an empty Geometry3DInstances container.
- Parameters:
x_min – Minimum x coordinate (default 0.0)
x_max – Maximum x coordinate
y_min – Minimum y coordinate (default 0.0)
y_max – Maximum y coordinate
z_min – Minimum z coordinate (default 0.0)
z_max – Maximum z coordinate
per_vertex_extras_keys – Sequence of keys for per-vertex additional data to initialize
per_line_extras_keys – Sequence of keys for per-line additional data to initialize
per_triangle_extras_keys – Sequence of keys for per-triangle additional data to initialize
instance_extras_keys – Sequence of keys for per-instance additional data to initialize
- Raises:
ValueError – If bounds are not fully specified
- add_instance(
- vertices: ndarray,
- lines: ndarray | None = None,
- triangles: ndarray | None = None,
- bbs_3d: ndarray | None = None,
- oriented_bbs_3d: ndarray | None = None,
- per_vertex_extras: Mapping[str, ndarray] | None = None,
- per_line_extras: Mapping[str, ndarray] | None = None,
- per_triangle_extras: Mapping[str, ndarray] | None = None,
- per_instance_extras: Mapping[str, Any] | None = None,
Add a 3D instance.
- Parameters:
vertices – Array of shape (N, 3) or flattened (3N,), dtype float32
lines – Flattened int array (2L,) of vertex indices forming L line segments
triangles – Flattened int array (3T,) of vertex indices forming T triangles
bbs_3d – Array of shape (B, 6) or flattened (6B,), dtype float32
oriented_bbs_3d – Array of shape (O, 9) or flattened (9O,), dtype float32
per_vertex_extras – Dict of arrays of shape (N,)
per_line_extras – Dict of arrays of shape (L,) for per-line extras
per_triangle_extras – Dict of arrays of shape (T,) for per-triangle extras
per_instance_extras – Dict of scalar per-instance attributes (one value or length-1 array)
- Raises:
ValueError – On shape/type/index validation errors
- classmethod from_row( ) Geometry3DInstances ¶
Parse a Geometry3D row into a Geometry3DInstances object.
- Parameters:
row – Row dictionary with INSTANCES, X_MIN, Y_MIN, Z_MIN, X_MAX, Y_MAX, Z_MAX keys
- Raises:
ValueError – If bounds are missing or invalid