bring the boundary segments into walk order
Description
Reorders the boundary segments such that consecutive segments of the same chain share a vertex, i.e. gB.F(k,2) == gB.F(k+1,1). A chain is a maximal run of segments joined at vertices where exactly two segments meet; a vertex where any other number of segments meet is a junction and always terminates a chain. Chains occupy contiguous blocks of rows.
Each chain is additionally oriented such that the grain in gB.grainId(:,1) lies to the left of the walk direction. Which side that is cannot be derived from gB alone, so it has to be supplied via the leftPos option - one point per segment lying strictly on the grainId(:,1) side of it. For segments along the outer border, where grainId(:,1) is 0 and no such pixel exists, mirror the pixel of the other side through the segment midpoint. Without leftPos the walk order is still established, but the sense of each chain is arbitrary (deterministic, but not tied to grainId).
Syntax
gB = order(gB)
gB = order(gB,'leftPos',pos)
[gB,p] = order(gB)Input
| gB | grainBoundary |
| pos | vector3d, one per segment, on the gB.grainId(:,1) side of it |
Output
| gB | grainBoundary, in walk order |
| p | the applied permutation, gB_ordered = gB_old.subSet(p) |
See also
chainOrder grainBoundary.chainId grainBoundary.chainV grainBoundary.junctionId