OOF2: The Manual

Name

Swap Edges (SwapEdges) — Rearrange internal edges in pairs of neighboring elements.

Synopsis

SwapEdges(targets, criterion)

Details

Description

SwpaEdges rearranges the interior Segments of neighboring Elements to improve their shape energy or homogeneity. The possible rearrangements are shown in Figure 6.113.

Figure 6.113. Swapping Element Edges

Swapping Element Edges

The blue and pink pairs of Elements on the left can replace their shared edge with new edges and become the one of the configurations on the right. When two quadrilaterals are replaced by three, as in the right hand images in the top row, a new Node is inserted at the average position of its neighbors.


The general procedure for SwapEdges is as follows:

  1. Create a list of Elements chosen by the targets parameter.

  2. Loop over the target Elements in random order to avoid any bias due to the order in which they were created.

    1. For the first Element in the list, try to swap edges with each of its neighbors in all the possible ways illustrated in Figure 6.113.

    2. Replace the Element and its neighbor in the Skeleton with the swap that best satisfies the criterion, if any. Remove the Element and its neighbor from the list. If no swap satisfies the criterion, do nothing.

Figure 6.114 shows the application of SwapEdges in a Skeleton. The Elements with Segments marked in green in (a) have been replaced in (b). The two pairs of Elements on the blue-white boundary have improved their homogeneity, and the pair inside the blue region has improved its shape energy.

Figure 6.114. Swapping Edges

Swapping Edges

(a) Before and (b) after running

          OOF.Skeleton.Modify(
              skeleton='swoops.png:skeleton',
              modifier=SwapEdges(targets=AllElements(),criterion=AverageEnergy(alpha=0.5)))

The segments of the affected Elements are highlighted in green.


See Also