1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.geometry.core.partitioning.test;
18
19 import org.apache.commons.geometry.core.RegionLocation;
20 import org.apache.commons.geometry.core.partitioning.Hyperplane;
21 import org.apache.commons.geometry.core.partitioning.HyperplaneConvexSubset;
22 import org.apache.commons.geometry.core.partitioning.Split;
23 import org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree;
24 import org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree;
25 import org.apache.commons.geometry.core.partitioning.bsp.RegionCutRule;
26
27
28
29 public final class TestRegionBSPTree extends AbstractRegionBSPTree<TestPoint2D, TestRegionBSPTree.TestRegionNode> {
30
31 public TestRegionBSPTree() {
32 this(true);
33 }
34
35 public TestRegionBSPTree(final boolean full) {
36 super(full);
37 }
38
39
40
41
42 public void cutNode(final TestRegionNode node, final HyperplaneConvexSubset<TestPoint2D> cut) {
43 super.setNodeCut(node, cut, getSubtreeInitializer(RegionCutRule.MINUS_INSIDE));
44 }
45
46
47 @Override
48 protected TestRegionNode createNode() {
49 return new TestRegionNode(this);
50 }
51
52
53 @Override
54 protected RegionSizeProperties<TestPoint2D> computeRegionSizeProperties() {
55
56 return new RegionSizeProperties<>(1234, new TestPoint2D(12, 34));
57 }
58
59
60 @Override
61 public boolean contains(final TestPoint2D pt) {
62 return classify(pt) != RegionLocation.OUTSIDE;
63 }
64
65
66 @Override
67 public Split<TestRegionBSPTree> split(final Hyperplane<TestPoint2D> splitter) {
68 return split(splitter, new TestRegionBSPTree(), new TestRegionBSPTree());
69 }
70
71
72
73 public static final class TestRegionNode
74 extends AbstractRegionBSPTree.AbstractRegionNode<TestPoint2D, TestRegionNode> {
75
76 TestRegionNode(final AbstractBSPTree<TestPoint2D, TestRegionNode> tree) {
77 super(tree);
78 }
79
80
81 @Override
82 protected TestRegionNode getSelf() {
83 return this;
84 }
85 }
86 }