io
triwarp.io
Mesh file loading via the optional meshio dependency.
load_mesh_data
load_mesh_data(
path: str | Path, *, device: DeviceLike = None
) -> dict[str, wp.array[Any]]
Load every mesh attribute meshio can read from a file into Warp arrays.
Reads path once with meshio and returns a dictionary whose keys are present
only when the corresponding data exists in the file. vertices is always present;
everything else is optional.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to a mesh file in any format supported by |
required |
device
|
DeviceLike
|
Warp device for the returned arrays. Defaults to the current Warp device. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Mapping with these possible keys:
|
See Also
Notes
Only triangle cells are consumed; non-triangle cell blocks are ignored. meshio reads
attributes verbatim and never computes them, so face_normals appears only when the
file itself contained per-face normals.
Source code in triwarp/io.py
24 25 26 27 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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
load_mesh
load_mesh(
path: str | Path, *, device: DeviceLike = None
) -> wp.Mesh
Load a triangle mesh file into a warp.Mesh.
Thin wrapper over load_mesh_data that keeps only the
vertices and triangle faces and wraps them in a warp.Mesh that owns its buffers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to a mesh file in any format supported by |
required |
device
|
DeviceLike
|
Warp device for the returned mesh. Defaults to the current Warp device. |
None
|
Returns:
| Type | Description |
|---|---|
Mesh
|
Mesh with |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file contains no triangle faces (e.g. a point cloud or a triangle-strip
PLY that |
See Also
Source code in triwarp/io.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 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 | |
mesh_from_numpy
mesh_from_numpy(
vertices: ndarray,
faces: ndarray,
*,
device: DeviceLike = None,
) -> Trimesh
Build a Trimesh from NumPy vertex and face arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
ndarray
|
|
required |
faces
|
ndarray
|
|
required |
device
|
DeviceLike
|
Warp device for the returned mesh. Defaults to the current Warp device. |
None
|
Returns:
| Type | Description |
|---|---|
Trimesh
|
New mesh with |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a face references a vertex index |
See Also
Source code in triwarp/io.py
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 | |