addNewFace2s method

ConvexHull addNewFace2s(
  1. dynamic eyeVertex,
  2. dynamic horizon
)

Implementation

ConvexHull addNewFace2s(eyeVertex, horizon) {
  newFace2s = [];

  HalfEdge? firstSideEdge;
  HalfEdge? previousSideEdge;

  for (int i = 0; i < horizon.length; i++) {
    final horizonEdge = horizon[i];

    // returns the right side edge

    final sideEdge = addAdjoiningFace2(eyeVertex, horizonEdge);

    if (firstSideEdge == null) {
      firstSideEdge = sideEdge;
    } else {
      // joins face.getEdge( 1 ) with previousFace2.getEdge( 0 )

      sideEdge.next.setTwin(previousSideEdge);
    }

    newFace2s.add(sideEdge.face);
    previousSideEdge = sideEdge;
  }

  // perform final join of new faces

  firstSideEdge?.next?.setTwin(previousSideEdge);

  return this;
}