X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.utils.datastructures%2Fsrc%2Forg%2Fsimantics%2Futils%2Fdatastructures%2Fcollections%2FQuadTree.java;fp=bundles%2Forg.simantics.utils.datastructures%2Fsrc%2Forg%2Fsimantics%2Futils%2Fdatastructures%2Fcollections%2FQuadTree.java;h=0a97064cfcf0d862a1b59e39614bb8763fb0c009;hb=930fd58d2e231b26ecb444f1e8e449829756add7;hp=b22fa27035ef6eec49126a54415089ffb48a98d6;hpb=ca0f4eb1114af9a04ee46dcd8626132f0dff786d;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/collections/QuadTree.java b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/collections/QuadTree.java index b22fa2703..0a97064cf 100644 --- a/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/collections/QuadTree.java +++ b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/collections/QuadTree.java @@ -104,6 +104,50 @@ public class QuadTree { } } + public void remove(T object, Rectangle2D bounds) { + if (leaf) { + contains.remove(object); + } else { + + boolean pX = bounds.getMinX() > center.getX(); + boolean nX = bounds.getMaxX() < center.getX(); + boolean pY = bounds.getMinY() > center.getY(); + boolean nY = bounds.getMaxY() < center.getY(); + + if (pX) { + if (pY) { + pXpY.remove(object, bounds); + } else if (nY) { + pXnY.remove(object, bounds); + } else { + pXpY.remove(object, bounds); + pXnY.remove(object, bounds); + } + } else if (nX) { + if (pY) { + nXpY.remove(object, bounds); + } else if (nY) { + nXnY.remove(object, bounds); + } else { + nXpY.remove(object, bounds); + nXnY.remove(object, bounds); + } + } else if (pY) { + pXpY.remove(object, bounds); + nXpY.remove(object, bounds); + } else if (nY) { + pXnY.remove(object, bounds); + nXnY.remove(object, bounds); + } else { + pXpY.remove(object, bounds); + pXnY.remove(object, bounds); + nXpY.remove(object, bounds); + nXnY.remove(object, bounds); + } + + } + } + public boolean contains(T object) { if (leaf) { return contains.contains(object);