GEOMETRY-69: shortening nested BSPTreeVisitor enum names; shortening AbstractBSPTree tree visitor method names
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTree.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTree.java
index c06c59d..d2dc7b0 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTree.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTree.java
@@ -29,8 +29,6 @@
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SplitLocation;
import org.apache.commons.geometry.core.partitioning.SubHyperplane;
-import org.apache.commons.geometry.core.partitioning.bsp.BSPTreeVisitor.VisitOrder;
-import org.apache.commons.geometry.core.partitioning.bsp.BSPTreeVisitor.VisitResult;
/** Abstract class for Binary Space Partitioning (BSP) tree implementations.
* @param <P> Point implementation type
@@ -89,7 +87,7 @@
/** {@inheritDoc} */
@Override
public void accept(final BSPTreeVisitor<P, N> visitor) {
- acceptVisitor(getRoot(), visitor);
+ accept(getRoot(), visitor);
}
/** {@inheritDoc} */
@@ -351,8 +349,8 @@
* @param node the node to begin the visit process
* @param visitor the visitor to pass nodes to
*/
- protected void acceptVisitor(final N node, final BSPTreeVisitor<P, N> visitor) {
- acceptVisitorRecursive(node, visitor);
+ protected void accept(final N node, final BSPTreeVisitor<P, N> visitor) {
+ acceptRecursive(node, visitor);
}
/** Recursively visit the nodes in the subtree rooted at the given node.
@@ -360,39 +358,39 @@
* @param visitor the visitor to pass nodes to
* @return true if the visit operation should continue
*/
- private boolean acceptVisitorRecursive(final N node, final BSPTreeVisitor<P, N> visitor) {
+ private boolean acceptRecursive(final N node, final BSPTreeVisitor<P, N> visitor) {
if (node.isLeaf()) {
return shouldContinueVisit(visitor.visit(node));
} else {
- final VisitOrder order = visitor.visitOrder(node);
+ final BSPTreeVisitor.Order order = visitor.visitOrder(node);
if (order != null) {
switch (order) {
case PLUS_MINUS_NODE:
- return acceptVisitorRecursive(node.getPlus(), visitor) &&
- acceptVisitorRecursive(node.getMinus(), visitor) &&
+ return acceptRecursive(node.getPlus(), visitor) &&
+ acceptRecursive(node.getMinus(), visitor) &&
shouldContinueVisit(visitor.visit(node));
case PLUS_NODE_MINUS:
- return acceptVisitorRecursive(node.getPlus(), visitor) &&
+ return acceptRecursive(node.getPlus(), visitor) &&
shouldContinueVisit(visitor.visit(node)) &&
- acceptVisitorRecursive(node.getMinus(), visitor);
+ acceptRecursive(node.getMinus(), visitor);
case MINUS_PLUS_NODE:
- return acceptVisitorRecursive(node.getMinus(), visitor) &&
- acceptVisitorRecursive(node.getPlus(), visitor) &&
+ return acceptRecursive(node.getMinus(), visitor) &&
+ acceptRecursive(node.getPlus(), visitor) &&
shouldContinueVisit(visitor.visit(node));
case MINUS_NODE_PLUS:
- return acceptVisitorRecursive(node.getMinus(), visitor) &&
+ return acceptRecursive(node.getMinus(), visitor) &&
shouldContinueVisit(visitor.visit(node)) &&
- acceptVisitorRecursive(node.getPlus(), visitor);
+ acceptRecursive(node.getPlus(), visitor);
case NODE_PLUS_MINUS:
return shouldContinueVisit(visitor.visit(node)) &&
- acceptVisitorRecursive(node.getPlus(), visitor) &&
- acceptVisitorRecursive(node.getMinus(), visitor);
+ acceptRecursive(node.getPlus(), visitor) &&
+ acceptRecursive(node.getMinus(), visitor);
case NODE_MINUS_PLUS:
return shouldContinueVisit(visitor.visit(node)) &&
- acceptVisitorRecursive(node.getMinus(), visitor) &&
- acceptVisitorRecursive(node.getPlus(), visitor);
+ acceptRecursive(node.getMinus(), visitor) &&
+ acceptRecursive(node.getPlus(), visitor);
default: // NONE
break;
}
@@ -408,8 +406,8 @@
* @return true if the visit operation should continue with remaining nodes in the
* BSP tree
*/
- private boolean shouldContinueVisit(final VisitResult result) {
- return result == VisitResult.CONTINUE;
+ private boolean shouldContinueVisit(final BSPTreeVisitor.Result result) {
+ return result == BSPTreeVisitor.Result.CONTINUE;
}
/** Cut a node with a hyperplane. The algorithm proceeds as follows:
@@ -903,7 +901,7 @@
/** {@inheritDoc} */
@Override
public void accept(final BSPTreeVisitor<P, N> visitor) {
- tree.acceptVisitor(getSelf(), visitor);
+ tree.accept(getSelf(), visitor);
}
/** {@inheritDoc} */
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java
index 402c080..8500396 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java
@@ -805,7 +805,7 @@
/** {@inheritDoc} */
@Override
- public VisitResult visit(final N node) {
+ public Result visit(final N node) {
final P point = getTarget();
if (node.isInternal() && (minDist < 0.0 || isPossibleClosestCut(node.getCut(), point, minDist))) {
@@ -825,7 +825,7 @@
}
}
- return VisitResult.CONTINUE;
+ return Result.CONTINUE;
}
/** Return true if the given node cut subhyperplane is a possible candidate for containing the
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreePrinter.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreePrinter.java
index 464d5a0..b0cb9a0 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreePrinter.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreePrinter.java
@@ -56,7 +56,7 @@
/** {@inheritDoc} */
@Override
- public VisitResult visit(final N node) {
+ public Result visit(final N node) {
final int depth = node.depth();
if (depth <= maxDepth) {
@@ -67,16 +67,16 @@
write(ELLIPSIS);
}
- return VisitResult.CONTINUE;
+ return Result.CONTINUE;
}
/** {@inheritDoc} */
@Override
- public VisitOrder visitOrder(final N node) {
+ public Order visitOrder(final N node) {
if (node.depth() > maxDepth + 1) {
- return VisitOrder.NONE;
+ return Order.NONE;
}
- return VisitOrder.NODE_MINUS_PLUS;
+ return Order.NODE_MINUS_PLUS;
}
/** Start a line for the given node.
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreeVisitor.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreeVisitor.java
index f17b25d..db8a1a6 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreeVisitor.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreeVisitor.java
@@ -28,7 +28,7 @@
/** Enum used to specify the order in which visitors should visit the nodes
* in the tree.
*/
- enum VisitOrder {
+ enum Order {
/** Indicates that the visitor should first visit the plus sub-tree, then
* the minus sub-tree and then the current node.
@@ -66,7 +66,7 @@
/** Enum representing the result of a BSP tree node visit operation.
*/
- enum VisitResult {
+ enum Result {
/** Indicates that the visit operation should continue with the remaining nodes in
* the BSP tree.
@@ -84,17 +84,17 @@
* @param node the node being visited
* @return the result of the visit operation
*/
- VisitResult visit(N node);
+ Result visit(N node);
/** Determine the visit order for the given internal node. This is called for each
* internal node before {@link #visit(BSPTree.Node)} is called. Returning null
- * or {@link VisitOrder#NONE}from this method skips the subtree rooted at the given node.
+ * or {@link Order#NONE}from this method skips the subtree rooted at the given node.
* This method is not called on leaf nodes.
* @param internalNode the internal node to determine the visit order for
* @return the order that the subtree rooted at the given node should be visited
*/
- default VisitOrder visitOrder(final N internalNode) {
- return VisitOrder.NODE_MINUS_PLUS;
+ default Order visitOrder(final N internalNode) {
+ return Order.NODE_MINUS_PLUS;
}
/** Abstract class for {@link BSPTreeVisitor} implementations that base their visit
@@ -123,9 +123,9 @@
}
/** {@link BSPTreeVisitor} base class that orders tree nodes so that nodes closest to the target point are
- * visited first. This is done by choosing {@link VisitOrder#MINUS_NODE_PLUS}
- * when the target point lies on the minus side of the node's cut hyperplane and {@link VisitOrder#PLUS_NODE_MINUS}
- * when it lies on the plus side. The order {@link VisitOrder#MINUS_NODE_PLUS} order is used when
+ * visited first. This is done by choosing {@link Order#MINUS_NODE_PLUS}
+ * when the target point lies on the minus side of the node's cut hyperplane and {@link Order#PLUS_NODE_MINUS}
+ * when it lies on the plus side. The order {@link Order#MINUS_NODE_PLUS} order is used when
* the target point lies directly on the node's cut hyerplane and no child node is closer than the other.
* @param <P> Point implementation type
* @param <N> BSP tree node implementation type
@@ -141,18 +141,18 @@
/** {@inheritDoc} */
@Override
- public VisitOrder visitOrder(N node) {
+ public Order visitOrder(final N node) {
if (node.getCutHyperplane().offset(getTarget()) > 0.0) {
- return VisitOrder.PLUS_NODE_MINUS;
+ return Order.PLUS_NODE_MINUS;
}
- return VisitOrder.MINUS_NODE_PLUS;
+ return Order.MINUS_NODE_PLUS;
}
}
/** {@link BSPTreeVisitor} base class that orders tree nodes so that nodes farthest from the target point
- * are traversed first. This is done by choosing {@link VisitOrder#PLUS_NODE_MINUS}
- * when the target point lies on the minus side of the node's cut hyperplane and {@link VisitOrder#MINUS_NODE_PLUS}
- * when it lies on the plus side. The order {@link VisitOrder#MINUS_NODE_PLUS} order is used when
+ * are traversed first. This is done by choosing {@link Order#PLUS_NODE_MINUS}
+ * when the target point lies on the minus side of the node's cut hyperplane and {@link Order#MINUS_NODE_PLUS}
+ * when it lies on the plus side. The order {@link Order#MINUS_NODE_PLUS} order is used when
* the target point lies directly on the node's cut hyerplane and no child node is closer than the other.
* @param <P> Point implementation type
* @param <N> BSP tree node implementation type
@@ -168,11 +168,11 @@
/** {@inheritDoc} */
@Override
- public VisitOrder visitOrder(N node) {
+ public Order visitOrder(final N node) {
if (node.getCutHyperplane().offset(getTarget()) < 0.0) {
- return VisitOrder.PLUS_NODE_MINUS;
+ return Order.PLUS_NODE_MINUS;
}
- return VisitOrder.MINUS_NODE_PLUS;
+ return Order.MINUS_NODE_PLUS;
}
}
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java
index c9b5e60..50a9781 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java
@@ -33,8 +33,6 @@
import org.apache.commons.geometry.core.partition.test.TestPoint2D;
import org.apache.commons.geometry.core.partition.test.TestTransform2D;
import org.apache.commons.geometry.core.partitioning.bsp.BSPTree.NodeCutRule;
-import org.apache.commons.geometry.core.partitioning.bsp.BSPTreeVisitor.VisitOrder;
-import org.apache.commons.geometry.core.partitioning.bsp.BSPTreeVisitor.VisitResult;
import org.junit.Assert;
import org.junit.Test;
@@ -817,7 +815,7 @@
// act
tree.accept(node -> {
nodes.add(node);
- return VisitResult.CONTINUE;
+ return BSPTreeVisitor.Result.CONTINUE;
});
// assert
@@ -840,37 +838,37 @@
TestNode minusPlus = minus.getPlus();
// act/assert
- TestVisitor plusMinusNode = new TestVisitor(VisitOrder.PLUS_MINUS_NODE);
+ TestVisitor plusMinusNode = new TestVisitor(BSPTreeVisitor.Order.PLUS_MINUS_NODE);
tree.accept(plusMinusNode);
Assert.assertEquals(
Arrays.asList(plus, minusPlus, minusMinus, minus, root),
plusMinusNode.getVisited());
- TestVisitor plusNodeMinus = new TestVisitor(VisitOrder.PLUS_NODE_MINUS);
+ TestVisitor plusNodeMinus = new TestVisitor(BSPTreeVisitor.Order.PLUS_NODE_MINUS);
tree.accept(plusNodeMinus);
Assert.assertEquals(
Arrays.asList(plus, root, minusPlus, minus, minusMinus),
plusNodeMinus.getVisited());
- TestVisitor minusPlusNode = new TestVisitor(VisitOrder.MINUS_PLUS_NODE);
+ TestVisitor minusPlusNode = new TestVisitor(BSPTreeVisitor.Order.MINUS_PLUS_NODE);
tree.accept(minusPlusNode);
Assert.assertEquals(
Arrays.asList(minusMinus, minusPlus, minus, plus, root),
minusPlusNode.getVisited());
- TestVisitor minusNodePlus = new TestVisitor(VisitOrder.MINUS_NODE_PLUS);
+ TestVisitor minusNodePlus = new TestVisitor(BSPTreeVisitor.Order.MINUS_NODE_PLUS);
tree.accept(minusNodePlus);
Assert.assertEquals(
Arrays.asList(minusMinus, minus, minusPlus, root, plus),
minusNodePlus.getVisited());
- TestVisitor nodeMinusPlus = new TestVisitor(VisitOrder.NODE_MINUS_PLUS);
+ TestVisitor nodeMinusPlus = new TestVisitor(BSPTreeVisitor.Order.NODE_MINUS_PLUS);
tree.accept(nodeMinusPlus);
Assert.assertEquals(
Arrays.asList(root, minus, minusMinus, minusPlus, plus),
nodeMinusPlus.getVisited());
- TestVisitor nodePlusMinus = new TestVisitor(VisitOrder.NODE_PLUS_MINUS);
+ TestVisitor nodePlusMinus = new TestVisitor(BSPTreeVisitor.Order.NODE_PLUS_MINUS);
tree.accept(nodePlusMinus);
Assert.assertEquals(
Arrays.asList(root, plus, minus, minusPlus, minusMinus),
@@ -888,9 +886,9 @@
TestNode plus = root.getPlus();
TestNode minus = root.getMinus();
- TestVisitor visitor = new TestVisitor(VisitOrder.NODE_MINUS_PLUS) {
+ TestVisitor visitor = new TestVisitor(BSPTreeVisitor.Order.NODE_MINUS_PLUS) {
@Override
- public VisitOrder visitOrder(TestNode node) {
+ public Order visitOrder(TestNode node) {
if (node == minus) {
return null;
}
@@ -918,11 +916,11 @@
TestNode plus = root.getPlus();
TestNode minus = root.getMinus();
- TestVisitor visitor = new TestVisitor(VisitOrder.NODE_MINUS_PLUS) {
+ TestVisitor visitor = new TestVisitor(BSPTreeVisitor.Order.NODE_MINUS_PLUS) {
@Override
- public VisitOrder visitOrder(TestNode node) {
+ public Order visitOrder(TestNode node) {
if (node == minus) {
- return VisitOrder.NONE;
+ return Order.NONE;
}
return super.visitOrder(node);
}
@@ -949,15 +947,15 @@
TestNode minusMinus = minus.getMinus();
TestNode minusPlus = minus.getPlus();
- TestVisitor visitor = new TestVisitor(VisitOrder.MINUS_PLUS_NODE) {
+ TestVisitor visitor = new TestVisitor(BSPTreeVisitor.Order.MINUS_PLUS_NODE) {
@Override
- public VisitResult visit(TestNode node) {
+ public Result visit(TestNode node) {
super.visit(node);
if (node == minus) {
return null;
}
- return VisitResult.CONTINUE;
+ return Result.CONTINUE;
}
};
@@ -982,15 +980,15 @@
TestNode minusMinus = minus.getMinus();
TestNode minusPlus = minus.getPlus();
- TestVisitor visitor = new TestVisitor(VisitOrder.MINUS_PLUS_NODE) {
+ TestVisitor visitor = new TestVisitor(BSPTreeVisitor.Order.MINUS_PLUS_NODE) {
@Override
- public VisitResult visit(TestNode node) {
+ public Result visit(TestNode node) {
super.visit(node);
if (node == minus) {
- return VisitResult.TERMINATE;
+ return Result.TERMINATE;
}
- return VisitResult.CONTINUE;
+ return Result.CONTINUE;
}
};
@@ -1017,37 +1015,37 @@
TestNode minusPlus = minus.getPlus();
// act/assert
- TestVisitor plusMinusNode = new TestVisitor(VisitOrder.PLUS_MINUS_NODE).withTerminationNode(minus);
+ TestVisitor plusMinusNode = new TestVisitor(BSPTreeVisitor.Order.PLUS_MINUS_NODE).withTerminationNode(minus);
tree.accept(plusMinusNode);
Assert.assertEquals(
Arrays.asList(plus, minusPlus, minusMinus, minus),
plusMinusNode.getVisited());
- TestVisitor plusNodeMinus = new TestVisitor(VisitOrder.PLUS_NODE_MINUS).withTerminationNode(minus);
+ TestVisitor plusNodeMinus = new TestVisitor(BSPTreeVisitor.Order.PLUS_NODE_MINUS).withTerminationNode(minus);
tree.accept(plusNodeMinus);
Assert.assertEquals(
Arrays.asList(plus, root, minusPlus, minus),
plusNodeMinus.getVisited());
- TestVisitor minusPlusNode = new TestVisitor(VisitOrder.MINUS_PLUS_NODE).withTerminationNode(minus);
+ TestVisitor minusPlusNode = new TestVisitor(BSPTreeVisitor.Order.MINUS_PLUS_NODE).withTerminationNode(minus);
tree.accept(minusPlusNode);
Assert.assertEquals(
Arrays.asList(minusMinus, minusPlus, minus),
minusPlusNode.getVisited());
- TestVisitor minusNodePlus = new TestVisitor(VisitOrder.MINUS_NODE_PLUS).withTerminationNode(minus);
+ TestVisitor minusNodePlus = new TestVisitor(BSPTreeVisitor.Order.MINUS_NODE_PLUS).withTerminationNode(minus);
tree.accept(minusNodePlus);
Assert.assertEquals(
Arrays.asList(minusMinus, minus),
minusNodePlus.getVisited());
- TestVisitor nodeMinusPlus = new TestVisitor(VisitOrder.NODE_MINUS_PLUS).withTerminationNode(minus);
+ TestVisitor nodeMinusPlus = new TestVisitor(BSPTreeVisitor.Order.NODE_MINUS_PLUS).withTerminationNode(minus);
tree.accept(nodeMinusPlus);
Assert.assertEquals(
Arrays.asList(root, minus),
nodeMinusPlus.getVisited());
- TestVisitor nodePlusMinus = new TestVisitor(VisitOrder.NODE_PLUS_MINUS).withTerminationNode(minus);
+ TestVisitor nodePlusMinus = new TestVisitor(BSPTreeVisitor.Order.NODE_PLUS_MINUS).withTerminationNode(minus);
tree.accept(nodePlusMinus);
Assert.assertEquals(
Arrays.asList(root, plus, minus),
@@ -1071,7 +1069,7 @@
// act
minus.accept(node -> {
nodes.add(node);
- return VisitResult.CONTINUE;
+ return BSPTreeVisitor.Result.CONTINUE;
});
// assert
@@ -1941,13 +1939,13 @@
private static class TestVisitor implements BSPTreeVisitor<TestPoint2D, TestNode> {
- private final VisitOrder order;
+ private final Order order;
private TestNode terminationNode;
private final List<TestNode> visited = new ArrayList<>();
- public TestVisitor(VisitOrder order) {
+ public TestVisitor(Order order) {
this.order = order;
}
@@ -1958,16 +1956,16 @@
}
@Override
- public VisitResult visit(TestNode node) {
+ public Result visit(TestNode node) {
visited.add(node);
return (terminationNode == node) ?
- VisitResult.TERMINATE :
- VisitResult.CONTINUE;
+ Result.TERMINATE :
+ Result.CONTINUE;
}
@Override
- public VisitOrder visitOrder(TestNode node) {
+ public Order visitOrder(TestNode node) {
return order;
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreeVisitorTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreeVisitorTest.java
index f70f450..cd58ca1 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreeVisitorTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreeVisitorTest.java
@@ -22,8 +22,6 @@
import org.apache.commons.geometry.core.partition.test.TestPoint2D;
import org.apache.commons.geometry.core.partitioning.bsp.BSPTreeVisitor.ClosestFirstVisitor;
import org.apache.commons.geometry.core.partitioning.bsp.BSPTreeVisitor.FarthestFirstVisitor;
-import org.apache.commons.geometry.core.partitioning.bsp.BSPTreeVisitor.VisitOrder;
-import org.apache.commons.geometry.core.partitioning.bsp.BSPTreeVisitor.VisitResult;
import org.junit.Assert;
import org.junit.Test;
@@ -32,10 +30,10 @@
@Test
public void testDefaultVisitOrder() {
// arrange
- BSPTreeVisitor<TestPoint2D, TestNode> visitor = n -> VisitResult.CONTINUE;
+ BSPTreeVisitor<TestPoint2D, TestNode> visitor = n -> BSPTreeVisitor.Result.CONTINUE;
// act/assert
- Assert.assertEquals(VisitOrder.NODE_MINUS_PLUS, visitor.visitOrder(null));
+ Assert.assertEquals(BSPTreeVisitor.Order.NODE_MINUS_PLUS, visitor.visitOrder(null));
}
@Test
@@ -48,25 +46,25 @@
root.getPlus().cut(TestLine.Y_AXIS);
// act
- checkClosestFirst(new TestPoint2D(1, 1), root, VisitOrder.MINUS_NODE_PLUS);
- checkClosestFirst(new TestPoint2D(1, 1), root.getMinus(), VisitOrder.PLUS_NODE_MINUS);
- checkClosestFirst(new TestPoint2D(1, 1), root.getPlus(), VisitOrder.PLUS_NODE_MINUS);
+ checkClosestFirst(new TestPoint2D(1, 1), root, BSPTreeVisitor.Order.MINUS_NODE_PLUS);
+ checkClosestFirst(new TestPoint2D(1, 1), root.getMinus(), BSPTreeVisitor.Order.PLUS_NODE_MINUS);
+ checkClosestFirst(new TestPoint2D(1, 1), root.getPlus(), BSPTreeVisitor.Order.PLUS_NODE_MINUS);
- checkClosestFirst(new TestPoint2D(-1, 1), root, VisitOrder.MINUS_NODE_PLUS);
- checkClosestFirst(new TestPoint2D(-1, 1), root.getMinus(), VisitOrder.MINUS_NODE_PLUS);
- checkClosestFirst(new TestPoint2D(-1, 1), root.getPlus(), VisitOrder.MINUS_NODE_PLUS);
+ checkClosestFirst(new TestPoint2D(-1, 1), root, BSPTreeVisitor.Order.MINUS_NODE_PLUS);
+ checkClosestFirst(new TestPoint2D(-1, 1), root.getMinus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
+ checkClosestFirst(new TestPoint2D(-1, 1), root.getPlus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
- checkClosestFirst(new TestPoint2D(-1, -1), root, VisitOrder.PLUS_NODE_MINUS);
- checkClosestFirst(new TestPoint2D(-1, -1), root.getMinus(), VisitOrder.MINUS_NODE_PLUS);
- checkClosestFirst(new TestPoint2D(-1, -1), root.getPlus(), VisitOrder.MINUS_NODE_PLUS);
+ checkClosestFirst(new TestPoint2D(-1, -1), root, BSPTreeVisitor.Order.PLUS_NODE_MINUS);
+ checkClosestFirst(new TestPoint2D(-1, -1), root.getMinus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
+ checkClosestFirst(new TestPoint2D(-1, -1), root.getPlus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
- checkClosestFirst(new TestPoint2D(1, -1), root, VisitOrder.PLUS_NODE_MINUS);
- checkClosestFirst(new TestPoint2D(1, -1), root.getMinus(), VisitOrder.PLUS_NODE_MINUS);
- checkClosestFirst(new TestPoint2D(1, -1), root.getPlus(), VisitOrder.PLUS_NODE_MINUS);
+ checkClosestFirst(new TestPoint2D(1, -1), root, BSPTreeVisitor.Order.PLUS_NODE_MINUS);
+ checkClosestFirst(new TestPoint2D(1, -1), root.getMinus(), BSPTreeVisitor.Order.PLUS_NODE_MINUS);
+ checkClosestFirst(new TestPoint2D(1, -1), root.getPlus(), BSPTreeVisitor.Order.PLUS_NODE_MINUS);
- checkClosestFirst(TestPoint2D.ZERO, root.getPlus(), VisitOrder.MINUS_NODE_PLUS);
- checkClosestFirst(TestPoint2D.ZERO, root.getPlus(), VisitOrder.MINUS_NODE_PLUS);
- checkClosestFirst(TestPoint2D.ZERO, root.getPlus(), VisitOrder.MINUS_NODE_PLUS);
+ checkClosestFirst(TestPoint2D.ZERO, root.getPlus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
+ checkClosestFirst(TestPoint2D.ZERO, root.getPlus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
+ checkClosestFirst(TestPoint2D.ZERO, root.getPlus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
}
@Test
@@ -79,35 +77,35 @@
root.getPlus().cut(TestLine.Y_AXIS);
// act
- checkFarthestFirst(new TestPoint2D(1, 1), root, VisitOrder.PLUS_NODE_MINUS);
- checkFarthestFirst(new TestPoint2D(1, 1), root.getMinus(), VisitOrder.MINUS_NODE_PLUS);
- checkFarthestFirst(new TestPoint2D(1, 1), root.getPlus(), VisitOrder.MINUS_NODE_PLUS);
+ checkFarthestFirst(new TestPoint2D(1, 1), root, BSPTreeVisitor.Order.PLUS_NODE_MINUS);
+ checkFarthestFirst(new TestPoint2D(1, 1), root.getMinus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
+ checkFarthestFirst(new TestPoint2D(1, 1), root.getPlus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
- checkFarthestFirst(new TestPoint2D(-1, 1), root, VisitOrder.PLUS_NODE_MINUS);
- checkFarthestFirst(new TestPoint2D(-1, 1), root.getMinus(), VisitOrder.PLUS_NODE_MINUS);
- checkFarthestFirst(new TestPoint2D(-1, 1), root.getPlus(), VisitOrder.PLUS_NODE_MINUS);
+ checkFarthestFirst(new TestPoint2D(-1, 1), root, BSPTreeVisitor.Order.PLUS_NODE_MINUS);
+ checkFarthestFirst(new TestPoint2D(-1, 1), root.getMinus(), BSPTreeVisitor.Order.PLUS_NODE_MINUS);
+ checkFarthestFirst(new TestPoint2D(-1, 1), root.getPlus(), BSPTreeVisitor.Order.PLUS_NODE_MINUS);
- checkFarthestFirst(new TestPoint2D(-1, -1), root, VisitOrder.MINUS_NODE_PLUS);
- checkFarthestFirst(new TestPoint2D(-1, -1), root.getMinus(), VisitOrder.PLUS_NODE_MINUS);
- checkFarthestFirst(new TestPoint2D(-1, -1), root.getPlus(), VisitOrder.PLUS_NODE_MINUS);
+ checkFarthestFirst(new TestPoint2D(-1, -1), root, BSPTreeVisitor.Order.MINUS_NODE_PLUS);
+ checkFarthestFirst(new TestPoint2D(-1, -1), root.getMinus(), BSPTreeVisitor.Order.PLUS_NODE_MINUS);
+ checkFarthestFirst(new TestPoint2D(-1, -1), root.getPlus(), BSPTreeVisitor.Order.PLUS_NODE_MINUS);
- checkFarthestFirst(new TestPoint2D(1, -1), root, VisitOrder.MINUS_NODE_PLUS);
- checkFarthestFirst(new TestPoint2D(1, -1), root.getMinus(), VisitOrder.MINUS_NODE_PLUS);
- checkFarthestFirst(new TestPoint2D(1, -1), root.getPlus(), VisitOrder.MINUS_NODE_PLUS);
+ checkFarthestFirst(new TestPoint2D(1, -1), root, BSPTreeVisitor.Order.MINUS_NODE_PLUS);
+ checkFarthestFirst(new TestPoint2D(1, -1), root.getMinus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
+ checkFarthestFirst(new TestPoint2D(1, -1), root.getPlus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
- checkFarthestFirst(TestPoint2D.ZERO, root.getPlus(), VisitOrder.MINUS_NODE_PLUS);
- checkFarthestFirst(TestPoint2D.ZERO, root.getPlus(), VisitOrder.MINUS_NODE_PLUS);
- checkFarthestFirst(TestPoint2D.ZERO, root.getPlus(), VisitOrder.MINUS_NODE_PLUS);
+ checkFarthestFirst(TestPoint2D.ZERO, root.getPlus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
+ checkFarthestFirst(TestPoint2D.ZERO, root.getPlus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
+ checkFarthestFirst(TestPoint2D.ZERO, root.getPlus(), BSPTreeVisitor.Order.MINUS_NODE_PLUS);
}
- private static void checkClosestFirst(TestPoint2D target, TestNode node, VisitOrder order) {
+ private static void checkClosestFirst(TestPoint2D target, TestNode node, BSPTreeVisitor.Order order) {
ClosestFirstStubVisitor visitor = new ClosestFirstStubVisitor(target);
Assert.assertSame(target, visitor.getTarget());
Assert.assertEquals(order, visitor.visitOrder(node));
}
- private static void checkFarthestFirst(TestPoint2D target, TestNode node, VisitOrder order) {
+ private static void checkFarthestFirst(TestPoint2D target, TestNode node, BSPTreeVisitor.Order order) {
FarthestFirstStubVisitor visitor = new FarthestFirstStubVisitor(target);
Assert.assertSame(target, visitor.getTarget());
@@ -121,8 +119,8 @@
}
@Override
- public VisitResult visit(TestNode node) {
- return VisitResult.CONTINUE;
+ public Result visit(TestNode node) {
+ return Result.CONTINUE;
}
}
@@ -133,8 +131,8 @@
}
@Override
- public VisitResult visit(TestNode node) {
- return VisitResult.CONTINUE;
+ public Result visit(TestNode node) {
+ return Result.CONTINUE;
}
}
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java
index 07e8df6..bf9848d 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java
@@ -549,14 +549,14 @@
/** {@inheritDoc} */
@Override
- public VisitResult visit(final RegionNode3D node) {
+ public Result visit(final RegionNode3D node) {
if (node.isInternal()) {
RegionCutBoundary<Vector3D> boundary = node.getCutBoundary();
addFacetContribution(boundary.getOutsideFacing(), false);
addFacetContribution(boundary.getInsideFacing(), true);
}
- return VisitResult.CONTINUE;
+ return Result.CONTINUE;
}
/** Return the computed size properties for the visited region.
@@ -649,20 +649,20 @@
/** {@inheritDoc} */
@Override
- public VisitOrder visitOrder(final RegionNode3D internalNode) {
+ public Order visitOrder(final RegionNode3D internalNode) {
final Plane cut = (Plane) internalNode.getCutHyperplane();
final Line3D line = segment.getLine();
final boolean plusIsNear = line.getDirection().dot(cut.getNormal()) < 0;
return plusIsNear ?
- VisitOrder.PLUS_NODE_MINUS :
- VisitOrder.MINUS_NODE_PLUS;
+ Order.PLUS_NODE_MINUS :
+ Order.MINUS_NODE_PLUS;
}
/** {@inheritDoc} */
@Override
- public VisitResult visit(final RegionNode3D node) {
+ public Result visit(final RegionNode3D node) {
if (node.isInternal()) {
// check if the line segment intersects the cut subhyperplane
final Line3D line = segment.getLine();
@@ -678,12 +678,12 @@
intersectionCut = (ConvexSubPlane) node.getCut();
- return VisitResult.TERMINATE;
+ return Result.TERMINATE;
}
}
}
- return VisitResult.CONTINUE;
+ return Result.CONTINUE;
}
}
}