findCollapseIndex method

bool findCollapseIndex(
  1. SegmentNode ei0,
  2. SegmentNode ei1,
  3. List<int> collapsedVertexIndex
)

Implementation

bool findCollapseIndex(
    SegmentNode ei0, SegmentNode ei1, List<int> collapsedVertexIndex) {
  // only looking for equal nodes
  if (!ei0.coord.equals2D(ei1.coord)) return false;

  int numVerticesBetween = ei1.segmentIndex - ei0.segmentIndex;
  if (!ei1.isInterior()) {
    numVerticesBetween--;
  }

  // if there is a single vertex between the two equal nodes, this is a collapse
  if (numVerticesBetween == 1) {
    collapsedVertexIndex[0] = ei0.segmentIndex + 1;
    return true;
  }
  return false;
}