public void fillLakeWithBottom(SinusoidalLocation bottom) { ClosureDivider divider = new ClosureDivider(processor); orderedDepressions.remove(bottom); divider.divideClosure(bottom, orderedDepressions); LocationCollection closure = divider.getClosure(); SinusoidalLocation drain = divider.getLowestBoundaryDrain(closure); processor.addDrainageArrow(bottom, drain); if (!processor.hasTransitiveTerminus(drain)) { throw new RuntimeException("Drain: " + drain); } // System.out.println(bottom + " : " + processor.getDrainageLocation(bottom)); LocationIterator iterator = closure.iterator(); while (iterator.hasNext()) { SinusoidalLocation next = iterator.next(); if (comparator.isLowerThan(next, drain)) { int difference = processor.getElevation(drain) - processor.getElevation(next); processor.setAccumulatedWater(next, difference); } } orderedDepressions = order(divider.getRemaining()); }
public SinusoidalLocation removeNextLowestLocation() { return orderedDepressions.remove(0); }