deleteFace2Vertices method

ConvexHull deleteFace2Vertices(
  1. Face2 face, [
  2. Face2? absorbingFace2
])

Implementation

ConvexHull deleteFace2Vertices(Face2 face, [Face2? absorbingFace2]) {
  VertexNode? faceVertices = removeAllVerticesFromFace2(face);

  if (faceVertices != null) {
    if (absorbingFace2 == null) {
      // mark the vertices to be reassigned to some other face

      unassigned.appendChain(faceVertices);
    } else {
      // if there's an absorbing face try to assign as many vertices as possible to it

      VertexNode? vertex = faceVertices;

      do {
        // we need to buffer the subsequent vertex at this point because the 'vertex.next' reference
        // will be changed by upcoming method calls

        final nextVertex = vertex!.next;

        final distance = absorbingFace2.distanceToPoint(vertex.point);

        // check if 'vertex' is able to see 'absorbingFace2'

        if (distance > tolerance) {
          addVertexToFace2(vertex, absorbingFace2);
        } else {
          unassigned.append(vertex);
        }

        // now assign next vertex

        vertex = nextVertex;
      } while (vertex != null);
    }
  }

  return this;
}