combine
triwarp.combine
Assembling meshes from parts and splitting them back apart.
concatenate joins whole meshes into one buffer pair without
touching their geometry, and split /
split_batched decompose one back into its connected components.
Mirrors trimesh.util.concatenate and trimesh.Trimesh.split.
Nothing here welds anything: concatenate packs parts side by side and leaves any seam open.
Joining two open meshes across one boundary loop each is stitch and its
variants, in triwarp.holes, where the minimum-weight triangulation machinery
they share with the hole fillers lives.
concatenate
concatenate(
meshes_data: Sequence[tuple[array[vec3], array[int32]]],
) -> tuple[wp.array[wp.vec3], wp.array[wp.int32]]
Concatenate meshes, each given as (vertices, faces) on the same device.
Face indices are renumbered with cumulative vertex offsets, matching
trimesh.util.concatenate (with triwarp's flat (3 * n_faces,) face
layout instead of (n_faces, 3)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meshes_data
|
Sequence[tuple[array[vec3], array[int32]]]
|
Sequence of |
required |
Returns:
| Type | Description |
|---|---|
tuple[array[vec3], array[int32]]
|
Combined vertices and reindexed faces on the shared device. An empty sequence carries no device to share, so the empty result is allocated on Warp's current device. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the given vertex and face buffers are not all on one device. |
See Also
split
The inverse, by connected component.
concatenate
The buffer-level operation of the same name, which joins plain 1-D arrays and does no
reindexing. Both names are required: this one mirrors
trimesh.util.concatenate, that one numpy.concatenate.
trimesh.util.concatenate
Source code in triwarp/combine.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
split
split(
vertices: array[vec3],
faces: array[int32],
*,
copy: bool = False,
) -> list[tuple[wp.array[wp.vec3], wp.array[wp.int32]]]
Split a mesh into connected components by face adjacency.
Each returned pair is a compact (vertices, faces) submesh with vertices
reindexed from zero, matching trimesh.graph.split with
only_watertight=False. concatenate on the
result recovers the input mesh (up to vertex/face ordering within each body).
All components are extracted in one batched pass
(split_batched); this is the slicing wrapper over it.
The returned arrays are views
Each pair slices the two shared buffers split_batched produced, which costs no device
memory and no launches. Two consequences: holding on to a single component keeps both
whole buffers alive, and writing into one component writes into the shared allocation. Pass
copy=True for independent buffers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
copy
|
bool
|
Return independent buffers instead of views into the batched result. One clone per component, so the returned list no longer pins the batched buffers. |
False
|
Returns:
| Type | Description |
|---|---|
list[tuple[array[vec3], array[int32]]]
|
One |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
See Also
split_batched
concatenate
face_connected_component_labels
repair.remove_small_components
Keep a subset of the components in one mesh, rather than taking them all apart.
submesh_from_face_indices
trimesh.graph.split
Source code in triwarp/combine.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
split_batched
split_batched(
vertices: array[vec3], faces: array[int32]
) -> tuple[
wp.array[wp.vec3],
wp.array[wp.int32],
wp.array[wp.int32],
wp.array[wp.int32],
]
Split a mesh into connected components, returned as two CSR buffers.
Same decomposition as split — same components, same vertex and face
order — but with no per-component Python at all, which is the only truly O(1)-in-k
form. Prefer it when the component count is large or when the components feed straight back
into another batched kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
Returns:
| Name | Type | Description |
|---|---|---|
vertices_all |
array[vec3]
|
Every component's compacted vertices, concatenated. |
vertex_offsets |
array[int32]
|
Length- |
faces_all |
array[int32]
|
Every component's reindexed flat faces, concatenated. |
face_offsets |
array[int32]
|
Length- |
All four arrays are empty (and ``k == 0``) when ``n_faces == 0``.
|
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
See Also
Source code in triwarp/combine.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |