ordito.adjacency
Mesh face-adjacency graph: which faces share an edge, and what each adjacent pair looks like.
face_adjacency is the table every other function here reads:
one row per edge-adjacent face pair. The rest are per-adjacency-row quantities over that table, all
row-aligned with it, so a caller derives the pairs once and passes them in --
require_paired_adjacency states the one rule those
keywords carry, and is public because the functions taking the pair span three modules.
face_adjacency_unsharedgives the two opposite corners of each pair, andface_adjacency_anglesthe dihedral between the two faces.face_adjacency_convexanswers whether a pair is convex -- each face's third vertex on the inner side of the other's plane -- andface_adjacency_projectionsreturns the signed distances it thresholds, for callers that want the margin rather than the verdict.
face_connected_component_labels is the one
whole-graph answer: face-level connected components over the same adjacency.
Functions:
| Name | Description |
|---|---|
face_adjacency |
Face index pairs that share an undirected mesh edge. |
require_paired_adjacency |
Raise unless a precomputed face-adjacency pair is either wholly given or wholly omitted. |
vertex_face_adjacency |
Incidence CSR of the faces touching each vertex, as |
vertex_face_adjacency_from_counts |
|
face_adjacency_unshared |
Vertex on each adjacent face that is not on their shared edge. |
face_adjacency_angles |
Unsigned angle in radians between each pair of adjacent faces. |
face_adjacency_projections |
Project each adjacent face pair's non-shared vertex onto the first face plane. |
face_adjacency_convex |
Whether each adjacent face pair is locally convex, one flag per adjacency row. |
face_connected_component_labels |
Connected-component label per face (face-adjacency graph). |
sorted_face_edge_keys |
Every halfedge's undirected edge key, sorted, and the permutation that sorted them. |
face_adjacency
face_adjacency(
faces: array[int32],
*,
return_edges: Literal[False] = False,
n_vertices: int | None = None,
edges_paired: bool = False,
) -> odt.Array2dInt32
face_adjacency(
faces: array[int32],
*,
return_edges: Literal[True],
n_vertices: int | None = None,
edges_paired: bool = False,
) -> tuple[odt.Array2dInt32, odt.Array2dInt32]
face_adjacency(
faces: array[int32],
*,
return_edges: bool = False,
n_vertices: int | None = None,
edges_paired: bool = False,
) -> (
odt.Array2dInt32
| tuple[odt.Array2dInt32, odt.Array2dInt32]
)
Face index pairs that share an undirected mesh edge.
Each output row lists two face indices whose triangles share an edge (vertex pair). On a closed manifold mesh every interior edge appears exactly twice in the edge list, so only edges with duplicate sorted rows are kept—boundary edges that appear once are omitted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
faces
|
array[int32]
|
|
required |
return_edges
|
bool
|
If |
False
|
n_vertices
|
int | None
|
Optional vertex count, used as the row-hashing radix. It does not change the answer:
when |
None
|
edges_paired
|
bool
|
Promise that every undirected edge is shared by exactly two faces -- what
|
False
|
Returns:
| Type | Description |
|---|---|
odt.Array2dInt32 or tuple of two such arrays
|
When |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Notes
Duplicate-edge grouping uses
group_int_rows with
length=2, equivalent to trimesh.grouping.group_rows with
require_count=2. An empty mesh yields shape (0, 2).
See Also
faces_to_edges
connected_component_labels_from_edges
face_connected_component_labels
trimesh.graph.face_adjacency
Examples:
Two triangles sharing the edge (1, 2) give one row; on the closed cube every one of the 18
edges joins two faces, so there are 18 rows:
import warp as wp
import ordito as od
faces = wp.array([0, 1, 2, 2, 1, 3], dtype=wp.int32)
adjacency, shared_edges = od.adjacency.face_adjacency(faces, return_edges=True)
print(adjacency.numpy().tolist(), shared_edges.numpy().tolist()) # [[0, 1]] [[1, 2]]
vertices, faces = od.creation.box()
print(od.adjacency.face_adjacency(faces).shape) # (18, 2)
Referenced by 25 places
API Reference API reference › Find a function by task · graph › connected_component_labels_from_edges · curvature › discrete_mean_curvature · combine › split · remesh › flip_to_delaunay · smoothing › filter_normals · adjacency · adjacency › face_adjacency_angles · adjacency › face_adjacency_convex · adjacency › face_adjacency_projections · adjacency › face_adjacency_unshared · adjacency › face_connected_component_labels · adjacency › require_paired_adjacency · adjacency › sorted_face_edge_keys · adjacency › vertex_face_adjacency · halfedge › halfedge_twins · Trimesh › face_adjacency · Trimesh › face_adjacency_edges · selection › submesh_from_face_indices · validation › face_orientation_bits · validation › is_vertex_manifold · sample › resolve_seed · voxels › resolve_voxel_grid
Examples Inspecting meshes › Feature edges: creases, convexity and boundaries
Migrating from another library Migrating from libigl › Discrete differential geometry
Source code in ordito/adjacency.py
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 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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
require_paired_adjacency
require_paired_adjacency(
face_adjacency: Array2dInt32 | None,
face_adjacency_edges: Array2dInt32 | None,
) -> None
Raise unless a precomputed face-adjacency pair is either wholly given or wholly omitted.
The contract behind every face_adjacency= / face_adjacency_edges= keyword in the
package: the two tables are row-aligned halves of one answer and are useless apart, so a
function that accepts them accepts both or neither. Public because the functions that take the
pair live in three modules -- here, ordito.curvature and
ordito.validation -- and they must all reject the same call with the
same message; a caller that validates its own arguments before dispatching between them can
use it for that too.
Call it before an empty-mesh guard, not after. A half-supplied pair is a caller bug
whatever the mesh is, and the four wrappers that take the pair once disagreed about this, so
the same wrong call raised or returned an empty answer depending on the input. The derivation
goes the other way round -- below the guard -- because on an empty mesh
face_adjacency would build two empty tables nothing reads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face_adjacency
|
Array2dInt32 | None
|
|
required |
face_adjacency_edges
|
Array2dInt32 | None
|
|
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If exactly one of the two is given. |
RuntimeError
|
If |
See Also
face_adjacency
Produces the pair, with return_edges=True.
face_adjacency_unshared
face_adjacency_projections
face_adjacency_convex
Examples:
import warp as wp
import ordito as od
faces = wp.array([0, 1, 2, 2, 1, 3], dtype=wp.int32)
adjacency, shared_edges = od.adjacency.face_adjacency(faces, return_edges=True)
od.adjacency.require_paired_adjacency(adjacency, shared_edges)
od.adjacency.require_paired_adjacency(None, None)
try:
od.adjacency.require_paired_adjacency(adjacency, None)
rejected = False
except ValueError:
rejected = True
print(rejected) # True
Referenced by 3 places
API Reference adjacency · sample › resolve_seed · voxels › resolve_voxel_grid
Source code in ordito/adjacency.py
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 | |
vertex_face_adjacency
vertex_face_adjacency(
faces: array[int32], *, n_vertices: int | None = None
) -> tuple[wp.array[wp.int32], wp.array[wp.int32]]
Incidence CSR of the faces touching each vertex, as (vertex_faces, offsets).
Row v is vertex_faces[offsets[v] : offsets[v + 1]] and lists every face that references
vertex v, once per reference. offsets has length n_vertices + 1, so its last entry
is the total 3 * n_faces and no caller needs a sentinel appended. Values first and offsets
second is the package's packed-buffer convention -- see
array.pack_1d_arrays, which states it.
Built by counting sort rather than from halfedge twins, and that is a deliberate limitation
rather than an omission: each row is a set, not a rotation. Ordering a row would require the
halfedge structure, which does not exist at a vertex-non-manifold vertex — and the decimator and
normal-flip guards that consume this must run on exactly such meshes. Use
vertex_one_rings when the rotational order is what is
wanted; it requires an edge-manifold mesh in exchange.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
faces
|
array[int32]
|
|
required |
n_vertices
|
int | None
|
Number of vertices, i.e. the number of CSR rows. When |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
vertex_faces |
array[int32]
|
|
offsets |
array[int32]
|
|
See Also
vertex_face_adjacency_from_counts
The same CSR from per-vertex corner counts the caller already holds.
face_adjacency
vertex_one_rings
igl.vertex_triangle_adjacency
Examples:
Vertices 1 and 2 lie on the shared edge of two triangles, so they touch both faces:
import warp as wp
import ordito as od
faces = wp.array([0, 1, 2, 2, 1, 3], dtype=wp.int32)
vertex_faces, offsets = od.adjacency.vertex_face_adjacency(faces, n_vertices=4)
print(offsets.numpy().tolist()) # [0, 1, 3, 5, 6]
print(sorted(vertex_faces.numpy()[offsets.numpy()[1] : offsets.numpy()[2]].tolist())) # [0, 1]
Referenced by 14 places
API Reference array › pack_1d_arrays · config · graph › edges_to_neighbor_lists · geodesic_walk › descend_field · smoothing › equalize_triangle_areas · smoothing › inflate · smoothing › smooth_region_boundary · adjacency · adjacency › vertex_face_adjacency_from_counts · halfedge › halfedge_mates · Trimesh › vertex_face_adjacency · energies › hessian_energy
Concepts Reproducible results › What it costs · Reproducible results › What it governs
Source code in ordito/adjacency.py
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 | |
vertex_face_adjacency_from_counts
vertex_face_adjacency_from_counts(
faces: array[int32], counts: array[int32]
) -> tuple[wp.array[wp.int32], wp.array[wp.int32]]
vertex_face_adjacency from counts already taken.
The second half of that function, for a caller whose own kernel visits every corner in a pass
it makes anyway and counts each vertex's corners there: the corner histogram is the one launch
this skips. counts is trusted, not checked: it must be exactly each vertex's number of
corners in faces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
faces
|
array[int32]
|
|
required |
counts
|
array[int32]
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
vertex_faces |
array[int32]
|
|
offsets |
array[int32]
|
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
See Also
vertex_face_adjacency
ordito.graph.edges_to_neighbor_lists_from_counts
The same split for an edge list's neighbour lists.
Examples:
import warp as wp
import ordito as od
faces = wp.array([0, 1, 2, 2, 1, 3], dtype=wp.int32)
counts = wp.array([1, 2, 2, 1], dtype=wp.int32)
vertex_faces, offsets = od.adjacency.vertex_face_adjacency_from_counts(faces, counts)
print(offsets.numpy().tolist()) # [0, 1, 3, 5, 6]
print(sorted(vertex_faces.numpy()[offsets.numpy()[1] : offsets.numpy()[2]].tolist())) # [0, 1]
Referenced by 2 places
API Reference graph › edges_to_neighbor_lists_from_counts · adjacency › vertex_face_adjacency
Source code in ordito/adjacency.py
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 440 441 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 | |
face_adjacency_unshared
face_adjacency_unshared(
faces: array[int32],
face_adjacency: Array2dInt32 | None = None,
face_adjacency_edges: Array2dInt32 | None = None,
*,
n_vertices: int | None = None,
) -> odt.Array2dInt32
Vertex on each adjacent face that is not on their shared edge.
For each row of face_adjacency, column 0 is the unshared vertex index on
the first face and column 1 on the second face. When a face does not have
exactly one vertex off the shared edge (degenerate case), that entry is -1.
The answer is defined by the recorded shared edge of each adjacency row, matching
trimesh.graph.face_adjacency_unshared exactly. This matters only for duplicate faces:
two coincident triangles meet along all three of their edges, so they produce three adjacency
rows and each one reports the corner off its own edge ([[2, 2], [1, 1], [0, 0]] for two
copies of (0, 1, 2)). A cheaper "vertex of one face absent from the other" rule would
return -1 for all three, and would not be trimesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
faces
|
array[int32]
|
|
required |
face_adjacency
|
Array2dInt32 | None
|
|
None
|
face_adjacency_edges
|
Array2dInt32 | None
|
|
None
|
n_vertices
|
int | None
|
Optional vertex count used as the row-hashing radix, forwarded to
|
None
|
Returns:
| Type | Description |
|---|---|
Array2dInt32
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If only one of |
RuntimeError
|
If |
Examples:
The two triangles share the edge (1, 2); vertex 0 is off it on the first and vertex 3 on the
second:
import warp as wp
import ordito as od
faces = wp.array([0, 1, 2, 2, 1, 3], dtype=wp.int32)
print(od.adjacency.face_adjacency_unshared(faces).numpy().tolist()) # [[0, 3]]
Referenced by 4 places
API Reference adjacency · adjacency › face_adjacency_projections · adjacency › require_paired_adjacency · Trimesh › face_adjacency_unshared
Source code in ordito/adjacency.py
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 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | |
face_adjacency_angles
face_adjacency_angles(
vertices: array[vec3],
faces: array[int32],
face_adjacency: Array2dInt32 | None = None,
face_normals: array[vec3] | None = None,
) -> wp.array[wp.float32]
Unsigned angle in radians between each pair of adjacent faces.
For each row of face_adjacency, the angle is computed from the two
corresponding face normals (unit vectors). Pair it with
face_adjacency_convex for the sign: that function
reports which side of each shared edge the pair folds towards, which is exactly the sign this
unsigned magnitude is missing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
|
required |
face_adjacency
|
Array2dInt32 | None
|
|
None
|
face_normals
|
array[vec3] | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
array[float32]
|
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
See Also
face_adjacency
face_adjacency_convex
The sign this magnitude omits: convex or concave, per adjacency row.
vector_angle
trimesh.Trimesh.face_adjacency_angles
Examples:
Of the cube's 18 adjacent face pairs, the 6 split by a face diagonal are flat and the 12 across a side meet at a right angle:
import numpy as np
import ordito as od
vertices, faces = od.creation.box()
angles = od.adjacency.face_adjacency_angles(vertices, faces)
print(angles.shape) # (18,)
degrees = np.degrees(angles.numpy()).round(1)
print(int((degrees == 90.0).sum()), int((degrees == 0.0).sum())) # 12 6
Referenced by 5 places
API Reference seams › crease_edges · adjacency · Trimesh › face_adjacency_angles · energies › normal_consistency_loss
Examples Inspecting meshes › Feature edges: creases, convexity and boundaries
Source code in ordito/adjacency.py
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 | |
face_adjacency_projections
face_adjacency_projections(
vertices: array[vec3],
faces: array[int32],
face_adjacency: Array2dInt32 | None = None,
face_adjacency_edges: Array2dInt32 | None = None,
face_adjacency_unshared: Array2dInt32 | None = None,
face_normals: array[vec3] | None = None,
) -> wp.array[wp.float32]
Project each adjacent face pair's non-shared vertex onto the first face plane.
For each row of face_adjacency, the dot product is taken between the
normal of face face_adjacency[k, 0] and the vector from one endpoint of
the shared edge to the unshared vertex on face_adjacency[k, 1].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
|
required |
face_adjacency
|
Array2dInt32 | None
|
|
None
|
face_adjacency_edges
|
Array2dInt32 | None
|
|
None
|
face_adjacency_unshared
|
Array2dInt32 | None
|
|
None
|
face_normals
|
array[vec3] | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
array[float32]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If only one of |
RuntimeError
|
If |
Examples:
Folding the second triangle below the first face's plane gives a negative projection (a convex pair), folding it above a positive one:
import warp as wp
import ordito as od
faces = wp.array([0, 1, 2, 2, 1, 3], dtype=wp.int32)
flat = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
down = wp.array([*flat, [1.0, 1.0, -0.5]], dtype=wp.vec3)
up = wp.array([*flat, [1.0, 1.0, 0.5]], dtype=wp.vec3)
print(f"{od.adjacency.face_adjacency_projections(down, faces).numpy()[0]:.4f}") # -0.5000
print(f"{od.adjacency.face_adjacency_projections(up, faces).numpy()[0]:.4f}") # 0.5000
Referenced by 4 places
API Reference adjacency · adjacency › face_adjacency_convex · adjacency › require_paired_adjacency · Trimesh › face_adjacency_projections
Source code in ordito/adjacency.py
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 | |
face_adjacency_convex
face_adjacency_convex(
vertices: array[vec3],
faces: array[int32],
face_adjacency: Array2dInt32 | None = None,
face_adjacency_edges: Array2dInt32 | None = None,
face_adjacency_unshared: Array2dInt32 | None = None,
face_normals: array[vec3] | None = None,
) -> wp.array[wp.bool]
Whether each adjacent face pair is locally convex, one flag per adjacency row.
A pair is locally convex when the unshared vertex of the second face,
projected onto the plane of the first face, has a projection less than
TOLERANCE_MERGE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
array[vec3]
|
|
required |
faces
|
array[int32]
|
|
required |
face_adjacency
|
Array2dInt32 | None
|
|
None
|
face_adjacency_edges
|
Array2dInt32 | None
|
|
None
|
face_adjacency_unshared
|
Array2dInt32 | None
|
|
None
|
face_normals
|
array[vec3] | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
array[bool]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If only one of |
RuntimeError
|
If |
Examples:
A pair folded below the first face's plane is convex; folded above it, concave:
import warp as wp
import ordito as od
faces = wp.array([0, 1, 2, 2, 1, 3], dtype=wp.int32)
flat = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
down = wp.array([*flat, [1.0, 1.0, -0.5]], dtype=wp.vec3)
up = wp.array([*flat, [1.0, 1.0, 0.5]], dtype=wp.vec3)
print(od.adjacency.face_adjacency_convex(down, faces).numpy().tolist()) # [True]
print(od.adjacency.face_adjacency_convex(up, faces).numpy().tolist()) # [False]
vertices, faces = od.creation.box()
print(bool(od.adjacency.face_adjacency_convex(vertices, faces).numpy().all())) # True
Referenced by 6 places
API Reference adjacency · adjacency › face_adjacency_angles · adjacency › face_adjacency_projections · adjacency › require_paired_adjacency · Trimesh › face_adjacency_convex
Examples Inspecting meshes › Feature edges: creases, convexity and boundaries
Source code in ordito/adjacency.py
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 | |
face_connected_component_labels
face_connected_component_labels(
faces: array[int32],
*,
n_vertices: int | None = None,
mates: array[int32] | None = None,
) -> wp.array[wp.int32]
Connected-component label per face (face-adjacency graph).
The labels are those
connected_component_labels_from_edges
gives over face_adjacency with
node_count = n_faces -- each component named by its smallest face id -- and run through
the same union-find, fed straight from
halfedge_mates instead of a compacted pair table.
Trimesh.face_connected_component_labels calls the edge-list form
directly when it already holds a cached adjacency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
faces
|
array[int32]
|
|
required |
n_vertices
|
int | None
|
Optional exclusive bound on the vertex indices, forwarded to
|
None
|
mates
|
array[int32] | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
array[int32]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
If |
Examples:
The first two triangles share an edge and the third stands alone; each component is named by its smallest face index:
import warp as wp
import ordito as od
faces = wp.array([0, 1, 2, 2, 1, 3, 4, 5, 6], dtype=wp.int32)
print(od.adjacency.face_connected_component_labels(faces).numpy().tolist()) # [0, 0, 2]
Referenced by 11 places
API Reference API reference › Find a function by task · graph › connected_component_labels · graph › connected_component_labels_from_edges · combine › split · combine › split_with_offsets · repair › remove_small_components · adjacency · adjacency › face_adjacency · Trimesh › face_connected_component_labels
Examples Inspecting meshes › Connected components: label, split, remove debris · Repairing meshes › Joining nearby open components
Source code in ordito/adjacency.py
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 | |
sorted_face_edge_keys
sorted_face_edge_keys(
faces: array[int32], *, n_vertices: int | None = None
) -> tuple[wp.array[wp.uint64], wp.array[wp.int32]]
Every halfedge's undirected edge key, sorted, and the permutation that sorted them.
Halfedge 3f + k is corner k of face f, the
faces_to_edges row order, and its key packs the sorted
endpoint pair (lo, hi) as lo + hi * radix -- the key
hash_indices_rows gives those rows. The sort is stable,
so equal keys keep halfedge order: an edge's halfedges are one run, the pairs
face_adjacency groups are its runs of exactly two, and
order[i] // 3 is the face owning sorted position i.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
faces
|
array[int32]
|
|
required |
n_vertices
|
int | None
|
Optional exclusive bound on the vertex indices, used as the packing radix. It lets the sort
order only the low bits the keys can occupy, which is cheaper; without it the keys pack
against |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
sorted_keys |
array[uint64]
|
|
order |
array[int32]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
With n_vertices=4 an edge (lo, hi) packs as lo + 4 * hi; the two halfedges of the
shared edge (1, 2) (halfedges 1 and 3) sort next to each other:
import warp as wp
import ordito as od
faces = wp.array([0, 1, 2, 2, 1, 3], dtype=wp.int32)
sorted_keys, order = od.adjacency.sorted_face_edge_keys(faces, n_vertices=4)
print(sorted_keys.numpy().tolist()) # [4, 8, 9, 9, 13, 14]
print(order.numpy().tolist()) # [0, 2, 1, 3, 4, 5]
Referenced by 2 places
API Reference halfedge › halfedge_mates · energies › normal_consistency_loss
Source code in ordito/adjacency.py
1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 | |