placeFreeHoles method

void placeFreeHoles(
  1. List shellList,
  2. List freeHoleList
)

This method determines finds a containing shell for all holes which have not yet been assigned to a shell. These "free" holes should all be properly contained in their parent shells, so it is safe to use the findEdgeRingContaining method. (This is the case because any holes which are NOT properly contained (i.e. are connected to their parent shell) would have formed part of a MaximalEdgeRing and been handled in a previous step).

@throws TopologyException if a hole cannot be assigned to a shell

Implementation

void placeFreeHoles(List shellList, List freeHoleList) {
  for (EdgeRing hole in freeHoleList) {
    // only place this hole if it doesn't yet have a shell
    if (hole.getShell() == null) {
      EdgeRing shell = findEdgeRingContaining(hole, shellList);
      if (shell == null)
        throw new TopologyException.withCoord(
            "unable to assign hole to a shell", hole.getCoordinate(0));
//        Assert.isTrue(shell != null, "unable to assign hole to a shell");
      hole.setShell(shell);
    }
  }
}