@Override public void applyIntersecting(ProtectedRegion region, Predicate<ProtectedRegion> consumer) { for (ProtectedRegion found : region.getIntersectingRegions(regions.values())) { if (!consumer.test(found)) { break; } } }
private void assertIntersection(ProtectedRegion region1, ProtectedRegion region2, boolean expected) { boolean actual = false; List<ProtectedRegion> regions = new ArrayList<>(); regions.add(region2); try { actual = (region1.getIntersectingRegions(regions).size() == 1); } catch (Exception e) { e.printStackTrace(); } assertEquals("Check for '" + region2.getId() + "' region failed.", expected, actual); }
@Override public void applyIntersecting(ProtectedRegion region, Predicate<ProtectedRegion> consumer) { BlockVector3 min = region.getMinimumPoint().floor(); BlockVector3 max = region.getMaximumPoint().ceil(); Set<ProtectedRegion> candidates = new HashSet<>(); MBR pointMBR = new SimpleMBR(min.getX(), max.getX(), min.getY(), max.getY(), min.getZ(), max.getZ()); for (ProtectedRegion found : tree.find(pointMBR)) { candidates.add(found); } for (ProtectedRegion found : region.getIntersectingRegions(candidates)) { if (!consumer.test(found)) { break; } } }