1 geometry.crops
geometry.crops
Shared closed-box membership, whole-face selection and surface intersection.
ANY_VERTEX keeps a triangle when any original vertex is inside; conservative AABB overlap retains possible intersections even when all vertices are outside; exact clipping constructs the triangle surface intersection without box caps. These predicates are intentionally distinct. Domain policy, errors and fallback remain with callers. All tensor results retain device and coordinate dtype.
1.1 Functions
| Name | Description |
|---|---|
| any_vertex_face_mask | Return [F] ANY_VERTEX face membership from [N] bool and [F,3] indices. |
| clip_mesh_to_obb | Intersect triangle surfaces with the exact oriented box, without caps. |
| face_aabb_overlap_mask | Conservative closed face-AABB overlap, distinct from ANY_VERTEX. |
| points_inside_aabb_mask | Closed point membership for [N,3] in matching-frame bounds. |
| points_inside_obb_mask | Finite world [N,3] point membership in an expanded oriented box. |
| select_mesh_faces | Select whole triangles in source order with ascending original vertex IDs. |
1.1.1 any_vertex_face_mask
geometry.crops.any_vertex_face_mask(vertex_inside, faces)Return [F] ANY_VERTEX face membership from [N] bool and [F,3] indices.
1.1.2 clip_mesh_to_obb
geometry.crops.clip_mesh_to_obb(verts, faces, obb, *, survivor_batch_size=32768)Intersect triangle surfaces with the exact oriented box, without caps.
1.1.2.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
verts Tensor["N 3", floating] |
World vertices in metres. | required | |
faces Tensor["F 3", int64] |
Triangle vertex indices. | required | |
| obb | ObbTW |
Oriented box in world coordinates. | required |
| survivor_batch_size | int | Positive maximum number of overlap survivors per narrow-phase batch; the default bounds polygon memory independently of the total scene face count. | 32768 |
1.1.2.2 Returns
| Name | Type | Description |
|---|---|---|
Tensor |
Vertices Tensor["N_out 3", floating] in world metres and faces |
|
Tensor |
Tensor["F_out 3", int64] on the input device. Vertex dtype is |
|
tuple[Tensor, Tensor] |
preserved. Clipping introduces boundary vertices, preserves winding, and | |
tuple[Tensor, Tensor] |
discards non-finite and zero-area triangles. Inputs are not modified. |
1.1.2.3 Theory
For world-to-object transform \(T_{ow}\) and object-frame bounds \(\ell,u\), the box is \(B=\{x: \ell \le T_{ow}x \le u\}\). Each source triangle \(\Delta\) contributes exactly its surface intersection \(\Delta \cap B\), implemented through the six closed half spaces in the object frame. A convex intersection polygon is triangulated as a fan; no box surface is invented. Unlike any-vertex selection, this includes intersections whose original vertices all lie outside.
1.1.2.4 Notes
Source face bounds are screened vectorially without gathering all triangles. Only survivors are batched to bound temporary polygon storage. Output order is source-face then fan order, independent of survivor batch size. Exact geometric membership is subject to floating precision; intersections are pinned to the clipping plane in the object frame.
1.1.3 face_aabb_overlap_mask
geometry.crops.face_aabb_overlap_mask(
verts,
faces,
lower,
upper,
*,
face_batch_size=None,
)Conservative closed face-AABB overlap, distinct from ANY_VERTEX.
For each [F,3] face, retain iff its finite vertices’ coordinate extrema overlap the box on all three axes. Only scalar [B,3] coordinates are gathered, never a full [F,3,3] triangle table. None screens all faces vectorially; a positive integer bounds temporary screening storage. Output [F] bool preserves original face identity and has the vertex device. Both modes compute identical predicates; they do not clip surfaces.
1.1.4 points_inside_aabb_mask
geometry.crops.points_inside_aabb_mask(points, lower, upper)Closed point membership for [N,3] in matching-frame bounds.
NaNs fail comparison; infinite bounds retain the historical comparison semantics. This operation does not impose a separate finite-value policy.
1.1.5 points_inside_obb_mask
geometry.crops.points_inside_obb_mask(points, obb, *, margin_m=0.0)Finite world [N,3] point membership in an expanded oriented box.
With world-to-object transform \(T\), membership is finite(x) and \(lower-margin <= T(x) <= upper+margin\), using closed inequalities.
1.1.6 select_mesh_faces
geometry.crops.select_mesh_faces(verts, faces, face_mask)Select whole triangles in source order with ascending original vertex IDs.
Inputs are [N,3] coordinates, [F,3] int64 indices and [F] bool mask. Return copied vertices, remapped int64 faces and original int64 face IDs, including shape-consistent empty tensors. No source mutation occurs.