seams
triwarp.seams
Feature edges and the topological cut along them.
Two operations that are only useful together. crease_edges finds the
edges where the surface bends sharply — the ones a modeller would call hard edges — and
cut_along_edges splits the mesh along a given edge set,
duplicating vertices so that the two sides stop sharing them.
The cut is the operation that was missing. Marking edges is a threshold; separating the two sides of a marked edge means rebuilding the vertex array, because the identity of a vertex is exactly what has to change. Three things need it:
- Hard normals. A crease vertex shared by both sides averages a normal that belongs to neither.
- UV seams. A parametrization cannot be continuous across a closed surface, so a disk cut is a
precondition rather than a nicety —
lscmandharmonicboth require the caller to supply a mesh that already has a boundary. Going the other way,uv_seam_edgesrecovers the cut an existing atlas already implies, so a textured mesh can be reopened along exactly the edges its texcoords tear at. - Part separation. Cutting every crease of an assembly and then splitting components
(
split) recovers the pieces.
Nothing here moves a vertex: cut_along_edges changes only which
vertex indices the faces name, so the surface is geometrically identical and topologically opened.
crease_edges
crease_edges(
vertices: array[vec3],
faces: array[int32],
angle: float = 30.0,
*,
include_boundary: bool = False,
) -> twt.Array2dInt32
Edges where the surface bends by more than angle.
MeshLab's compute_selection_crease_per_edge, returned as an explicit edge list rather than a
selection so it feeds straight into cut_along_edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
angle
|
float
|
Dihedral threshold in degrees. An edge is a crease when its two faces meet at strictly
more than this, so |
30.0
|
include_boundary
|
bool
|
When |
False
|
Returns:
| Type | Description |
|---|---|
Array2dInt32
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
If |
Source code in triwarp/seams.py
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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
cut_along_edges
cut_along_edges(
vertices: array[vec3] | array[vec3d],
faces: array[int32],
edges: Array2dInt32,
*,
twins: array[int32] | None = None,
) -> tuple[
wp.array[wp.vec3] | wp.array[wp.vec3d],
wp.array[wp.int32],
]
Split the mesh along an edge set, duplicating vertices so the two sides no longer share them.
Each corner (a face-vertex incidence) becomes a node, two corners at the same vertex are
joined when the mesh edge between them is not in edges, and each connected component of
that graph becomes one output vertex. So a vertex whose whole fan is uncut survives as one
vertex, a vertex crossed by a single marked edge on an open fan survives as one (the fan is
still connected the long way round), and a vertex crossed by two survives as two. That is the
correct local rule, and it is why the answer cannot be computed edge by edge.
MeshLab's meshing_cut_along_crease_edges. Geometrically a no-op — every output vertex sits
exactly where its input did — and topologically the operation that turns a marked edge set into
a boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3] | array[vec3d]
|
|
required |
faces
|
array[int32]
|
Length- |
required |
edges
|
Array2dInt32
|
|
required |
twins
|
array[int32] | None
|
Optional precomputed |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
vertices |
array[vec3] | array[vec3d]
|
Positions of the cut mesh, one per surviving corner component, in |
faces |
array[int32]
|
Flat |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
RuntimeError
|
If |
Notes
The inverse operation is
remove_duplicated_vertices: welding coincident
positions back together closes every cut this makes, which is a useful round-trip check and a
warning — a cut mesh must not be passed through a position-based weld if the seams are meant to
survive.
Source code in triwarp/seams.py
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 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 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 239 240 241 242 243 244 245 246 247 248 | |
uv_seam_edges
uv_seam_edges(
faces: array[int32],
texcoords: array[vec2],
face_texcoords: array[int32] | None = None,
*,
match: Literal["index", "uv"] | None = None,
tolerance: float = 0.0,
n_vertices: int | None = None,
twins: array[int32] | None = None,
) -> tuple[
twt.Array2dInt32, twt.Array2dInt32, twt.Array2dInt32
]
Classify every mesh edge as a UV seam, a boundary or a UV-space foldover.
igl::seam_edges. Where crease_edges asks how the surface
bends, this asks where the atlas tears: an edge is a seam when its two triangles disagree
about where it lands in texture space, so the two sides cannot be sampled from one continuous
patch. Positions are not read at all.
Every result is (face, corner) provenance rather than a vertex pair, because the two sides
of a seam name different texcoords at the same positions and both sides are usually wanted.
Corner c of face f denotes the edge faces[3f + c] -> faces[3f + (c + 1) % 3];
seam_edge_vertices converts any of the three blocks to the
vertex pairs cut_along_edges takes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
faces
|
array[int32]
|
Length- |
required |
texcoords
|
array[vec2]
|
UV coordinates. With |
required |
face_texcoords
|
array[int32] | None
|
igl's |
None
|
match
|
Literal['index', 'uv'] | None
|
How two corners are judged to carry the same texcoord. |
None
|
tolerance
|
float
|
Distance below which two texcoords count as equal under |
0.0
|
n_vertices
|
int | None
|
Total vertex count, used as the edge-pairing radix. When |
None
|
twins
|
array[int32] | None
|
Optional precomputed |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
seams |
Array2dInt32
|
|
boundaries |
Array2dInt32
|
|
foldovers |
Array2dInt32
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
If |
See Also
seam_edge_vertices
uv_seam_vertex_mask
crease_edges
cut_along_edges
triwarp.parametrization.face_flipped_indices
Notes
Divergences from igl::seam_edges, none of which change a row's contents on a consistently
wound manifold mesh:
- Row order. igl iterates an
unordered_setand so has no defined order; rows here come out in ascending canonical-halfedge order, which is face-major and deterministic. - Non-manifold edges raise, because "the other side" of an edge with three triangles is not defined. igl's hash map silently keeps whichever half-edge it saw last.
- Inconsistent winding. Two same-direction half-edges on one edge pair up here (edges are matched undirected); igl's directed map loses one of them and reports the edge as a boundary.
- Precision. The foldover orientation test runs in
float32; igl uses the input scalar type. - igl also takes
V, but reads only its row count — then_verticesargument here.
Source code in triwarp/seams.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | |
seam_edge_vertices
seam_edge_vertices(
faces: array[int32], face_corners: Array2dInt32
) -> twt.Array2dInt32
Vertex-index pairs of (face, corner) rows, the form the cut and the edge helpers take.
Accepts any block uv_seam_edges returns: only columns 0 and 1
are read, which is the whole of a (n, 2) boundary row and the forward half of a
(n, 4) seam or foldover row. The backward half traverses the same undirected edge, so it
would produce the same pair reversed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
faces
|
array[int32]
|
Length- |
required |
face_corners
|
Array2dInt32
|
|
required |
Returns:
| Type | Description |
|---|---|
Array2dInt32
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
RuntimeError
|
If |
See Also
Source code in triwarp/seams.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
uv_seam_vertex_mask
uv_seam_vertex_mask(
faces: array[int32],
texcoords: array[vec2],
face_texcoords: array[int32] | None = None,
*,
include_boundary: bool = True,
match: Literal["index", "uv"] | None = None,
tolerance: float = 0.0,
n_vertices: int | None = None,
) -> wp.array[wp.bool]
Per-vertex mask marking the endpoints of every UV seam.
MeshLab's compute_selection_by_texture_seams_per_vertex, which folds boundaries into the
seam set rather than reporting them apart — hence the include_boundary default. The
per-edge answer, and foldovers, are in uv_seam_edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
faces
|
array[int32]
|
Length- |
required |
texcoords
|
array[vec2]
|
UV coordinates, per-corner or pooled; see
|
required |
face_texcoords
|
array[int32] | None
|
Optional length- |
None
|
include_boundary
|
bool
|
Whether an edge with a single incident triangle counts as a seam. |
True
|
match
|
Literal['index', 'uv'] | None
|
|
None
|
tolerance
|
float
|
Coordinate tolerance under |
0.0
|
n_vertices
|
int | None
|
Total vertex count. When |
None
|
Returns:
| Type | Description |
|---|---|
array[bool]
|
Length- |
Raises:
| Type | Description |
|---|---|
ValueError
|
Delegated from |
RuntimeError
|
If |
Source code in triwarp/seams.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | |