P
- Point implementation typeN
- BSP tree node implementation typepublic abstract class AbstractBSPTreeMergeOperator<P extends Point<P>,N extends AbstractBSPTree.AbstractNode<P,N>> extends Object
AbstractBSPTree
instances. Subclasses must override the
mergeLeaf(AbstractBSPTree.AbstractNode, AbstractBSPTree.AbstractNode)
method
to implement the merging logic for their particular use case. The remainder of the
algorithm is independent of the use case.
This class does not expose any public methods so that subclasses can present their own public API, tailored to the specific types being worked with. In particular, most subclasses will want to restrict the tree types used with the algorithm, which is difficult to implement cleanly at this level.
This class maintains state during the merging process and is therefore not thread-safe.
Constructor and Description |
---|
AbstractBSPTreeMergeOperator() |
Modifier and Type | Method and Description |
---|---|
protected AbstractBSPTree<P,N> |
getOutputTree()
Get the tree used as output for this instance.
|
protected abstract N |
mergeLeaf(N node1,
N node2)
Merge a leaf node from one input with a subtree from another.
|
protected N |
outputNode()
Create a new node in the output tree.
|
protected N |
outputSubtree(N node)
Place the subtree rooted at the given input node into the output tree.
|
protected void |
performMerge(AbstractBSPTree<P,N> input1,
AbstractBSPTree<P,N> input2,
AbstractBSPTree<P,N> output)
Perform a merge operation with the two input trees and store the result in the output tree.
|
protected void |
setOutputTree(AbstractBSPTree<P,N> outputTree)
Set the tree used as output for this instance.
|
public AbstractBSPTreeMergeOperator()
protected void setOutputTree(AbstractBSPTree<P,N> outputTree)
outputTree
- the tree used as output for this instanceprotected AbstractBSPTree<P,N> getOutputTree()
protected void performMerge(AbstractBSPTree<P,N> input1, AbstractBSPTree<P,N> input2, AbstractBSPTree<P,N> output)
input1
- first input treeinput2
- second input treeoutput
- output tree all previous content in this tree is overwrittenprotected N outputNode()
protected N outputSubtree(N node)
node
- the root of the subtree to copyprotected abstract N mergeLeaf(N node1, N node2)
When this method is called, one or both of the given nodes will be a leaf node. This method is expected to return a node representing the merger of the two given nodes. The way that the returned node is determined defines the overall behavior of the merge operation.
The return value can be one of the two input nodes or a completely different one.
node1
- node from the first input treenode2
- node from the second input treeCopyright © 2016–2021 The Apache Software Foundation. All rights reserved.