Top Description Inners Fields Constructors Methods
org.apache.commons.math3.geometry.partitioning

public Class RegionFactory<S extends Space>

extends Object
Class Inheritance
Type Parameters
<S>
Type of the space.
Imports
java.util.HashMap, .Map, org.apache.commons.math3.exception.MathIllegalArgumentException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.geometry.Point, .Space, org.apache.commons.math3.geometry.partitioning.BSPTree.VanishingCutHandler, .Region.Location, .SubHyperplane.SplitSubHyperplane

This class is a factory for Region.
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
RegionFactory.DifferenceMerger

BSP tree leaf merger computing difference of two regions.

private class
RegionFactory.IntersectionMerger

BSP tree leaf merger computing intersection of two regions.

private class
RegionFactory.NodesCleaner

Visitor removing internal nodes attributes.

private class
RegionFactory.UnionMerger

BSP tree leaf merger computing union of two regions.

private class
RegionFactory.VanishingToLeaf

Handler replacing nodes with vanishing cuts with leaf nodes.

private class
RegionFactory.XorMerger

BSP tree leaf merger computing symmetric difference (exclusive or) of two regions.

Field Summary

Modifier and TypeField and Description
private final RegionFactory<S>.NodesCleaner
nodeCleaner

Visitor removing internal nodes attributes.

Constructor Summary

AccessConstructor and Description
public
RegionFactory()

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public Region<S>

Returns:

a new convex region, or null if the collection is empty
buildConvex
(final Hyperplane<S>...
collection of bounding hyperplanes
hyperplanes
)

Build a convex region from a collection of bounding hyperplanes.

public Region<S>

Returns:

a new region, result of region1 minus region2
difference
(final Region<S>
first region (will be unusable after the operation as parts of it will be reused in the new region)
region1
,
final Region<S>
second region (will be unusable after the operation as parts of it will be reused in the new region)
region2
)

Compute the difference of two regions.

public Region<S>

Returns:

a new region, complement of the specified one
getComplement
(final Region<S>
region to complement, it will not modified, a new region independent region will be built
region
)

Get the complement of the region (exchanged interior/exterior).

public Region<S>

Returns:

a new region, result of region1 intersection region2
intersection
(final Region<S>
first region (will be unusable after the operation as parts of it will be reused in the new region)
region1
,
final Region<S>
second region (will be unusable after the operation as parts of it will be reused in the new region)
region2
)

Compute the intersection of two regions.

private BSPTree<S>

Returns:

new tree, complement of the node
recurseComplement
(final BSPTree<S>
current node of the original tree
node
)

Recursively build the complement of a BSP tree.

private BSPTree<S>

Returns:

new tree, complement of the node
recurseComplement
(final BSPTree<S>
current node of the original tree
node
,
final Map<BSPTree<S>, BSPTree<S>>
transformed nodes map
map
)

Recursively build the complement of a BSP tree.

public Region<S>

Returns:

a new region, result of region1 union region2
union
(final Region<S>
first region (will be unusable after the operation as parts of it will be reused in the new region)
region1
,
final Region<S>
second region (will be unusable after the operation as parts of it will be reused in the new region)
region2
)

Compute the union of two regions.

public Region<S>

Returns:

a new region, result of region1 xor region2
xor
(final Region<S>
first region (will be unusable after the operation as parts of it will be reused in the new region)
region1
,
final Region<S>
second region (will be unusable after the operation as parts of it will be reused in the new region)
region2
)

Compute the symmetric difference (exclusive or) of two regions.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nodeCleanerback to summary
private final RegionFactory<S>.NodesCleaner nodeCleaner

Visitor removing internal nodes attributes.

Constructor Detail

RegionFactoryback to summary
public RegionFactory()

Simple constructor.

Method Detail

buildConvexback to summary
public Region<S> buildConvex(final Hyperplane<S>... hyperplanes)

Build a convex region from a collection of bounding hyperplanes.

Parameters
hyperplanes:Hyperplane<S>[]

collection of bounding hyperplanes

Returns:Region<S>

a new convex region, or null if the collection is empty

differenceback to summary
public Region<S> difference(final Region<S> region1, final Region<S> region2)

Compute the difference of two regions.

Parameters
region1:Region<S>

first region (will be unusable after the operation as parts of it will be reused in the new region)

region2:Region<S>

second region (will be unusable after the operation as parts of it will be reused in the new region)

Returns:Region<S>

a new region, result of region1 minus region2

getComplementback to summary
public Region<S> getComplement(final Region<S> region)

Get the complement of the region (exchanged interior/exterior).

Parameters
region:Region<S>

region to complement, it will not modified, a new region independent region will be built

Returns:Region<S>

a new region, complement of the specified one

intersectionback to summary
public Region<S> intersection(final Region<S> region1, final Region<S> region2)

Compute the intersection of two regions.

Parameters
region1:Region<S>

first region (will be unusable after the operation as parts of it will be reused in the new region)

region2:Region<S>

second region (will be unusable after the operation as parts of it will be reused in the new region)

Returns:Region<S>

a new region, result of region1 intersection region2

recurseComplementback to summary
private BSPTree<S> recurseComplement(final BSPTree<S> node)

Recursively build the complement of a BSP tree.

Parameters
node:BSPTree<S>

current node of the original tree

Returns:BSPTree<S>

new tree, complement of the node

recurseComplementback to summary
private BSPTree<S> recurseComplement(final BSPTree<S> node, final Map<BSPTree<S>, BSPTree<S>> map)

Recursively build the complement of a BSP tree.

Parameters
node:BSPTree<S>

current node of the original tree

map:Map<BSPTree<S>, BSPTree<S>>

transformed nodes map

Returns:BSPTree<S>

new tree, complement of the node

unionback to summary
public Region<S> union(final Region<S> region1, final Region<S> region2)

Compute the union of two regions.

Parameters
region1:Region<S>

first region (will be unusable after the operation as parts of it will be reused in the new region)

region2:Region<S>

second region (will be unusable after the operation as parts of it will be reused in the new region)

Returns:Region<S>

a new region, result of region1 union region2

xorback to summary
public Region<S> xor(final Region<S> region1, final Region<S> region2)

Compute the symmetric difference (exclusive or) of two regions.

Parameters
region1:Region<S>

first region (will be unusable after the operation as parts of it will be reused in the new region)

region2:Region<S>

second region (will be unusable after the operation as parts of it will be reused in the new region)

Returns:Region<S>

a new region, result of region1 xor region2

org.apache.commons.math3.geometry.partitioning back to summary

private Class RegionFactory.DifferenceMerger

extends Object
implements BSPTree.LeafMerger<S extends Space>, BSPTree.VanishingCutHandler<S extends Space>
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.geometry.partitioning.RegionFactory.DifferenceMerger
All Implemented Interfaces
org.apache.commons.math3.geometry.partitioning.BSPTree.VanishingCutHandler, org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger

BSP tree leaf merger computing difference of two regions.

Field Summary

Modifier and TypeField and Description
private final Region<S>
region1

Region to subtract from.

private final Region<S>
region2

Region to subtract.

Constructor Summary

AccessConstructor and Description
pack-priv
DifferenceMerger(final Region<S>
region to subtract from
region1
,
final Region<S>
region to subtract
region2
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public BSPTree<S>
fixNode(final BSPTree<S>
node to fix
node
)

Implements org.apache.commons.math3.geometry.partitioning.BSPTree.VanishingCutHandler.fixNode.

Fix a node with both vanished cut and children.

public BSPTree<S>
merge(final BSPTree<S>
leaf node (its cut hyperplane is guaranteed to be null)
leaf
,
final BSPTree<S>
tree node (its cut hyperplane may be null or not)
tree
,
final BSPTree<S>
parent tree to connect to (may be null)
parentTree
,
final boolean
if true and if parentTree is not null, the resulting tree should be the plus child of its parent, ignored if parentTree is null
isPlusChild
,
final boolean
if true, the leaf node comes from the instance tree (tree1) and the tree node comes from the argument tree (tree2)
leafFromInstance
)

Implements org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger.merge.

Merge a leaf node and a tree node.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

region1back to summary
private final Region<S> region1

Region to subtract from.

region2back to summary
private final Region<S> region2

Region to subtract.

Constructor Detail

DifferenceMergerback to summary
pack-priv DifferenceMerger(final Region<S> region1, final Region<S> region2)

Simple constructor.

Parameters
region1:Region<S>

region to subtract from

region2:Region<S>

region to subtract

Method Detail

fixNodeback to summary
public BSPTree<S> fixNode(final BSPTree<S> node)

Implements org.apache.commons.math3.geometry.partitioning.BSPTree.VanishingCutHandler.fixNode.

Doc from org.apache.commons.math3.geometry.partitioning.BSPTree.VanishingCutHandler.fixNode.

Fix a node with both vanished cut and children.

Parameters
node:BSPTree<S>

node to fix

Returns:BSPTree<S>

fixed node

mergeback to summary
public BSPTree<S> merge(final BSPTree<S> leaf, final BSPTree<S> tree, final BSPTree<S> parentTree, final boolean isPlusChild, final boolean leafFromInstance)

Implements org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger.merge.

Doc from org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger.merge.

Merge a leaf node and a tree node.

This method is called at the end of a recursive merging resulting from a tree1.merge(tree2, leafMerger) call, when one of the sub-trees involved is a leaf (i.e. when its cut-hyperplane is null). This is the only place where the precise semantics of the operation are required. For all upper level nodes in the tree, the merging operation is only a generic partitioning algorithm.

Since the final operation may be non-commutative, it is important to know if the leaf node comes from the instance tree (tree1) or the argument tree (tree2). The third argument of the method is devoted to this. It can be ignored for commutative operations.

The BSPTree.insertInTree method may be useful to implement this method.

Parameters
leaf:BSPTree<S>

leaf node (its cut hyperplane is guaranteed to be null)

tree:BSPTree<S>

tree node (its cut hyperplane may be null or not)

parentTree:BSPTree<S>

parent tree to connect to (may be null)

isPlusChild:boolean

if true and if parentTree is not null, the resulting tree should be the plus child of its parent, ignored if parentTree is null

leafFromInstance:boolean

if true, the leaf node comes from the instance tree (tree1) and the tree node comes from the argument tree (tree2)

Returns:BSPTree<S>

the BSP tree resulting from the merging (may be one of the arguments)

org.apache.commons.math3.geometry.partitioning back to summary

private Class RegionFactory.IntersectionMerger

extends Object
implements BSPTree.LeafMerger<S extends Space>
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.geometry.partitioning.RegionFactory.IntersectionMerger
All Implemented Interfaces
org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger

BSP tree leaf merger computing intersection of two regions.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public BSPTree<S>
merge(final BSPTree<S>
leaf node (its cut hyperplane is guaranteed to be null)
leaf
,
final BSPTree<S>
tree node (its cut hyperplane may be null or not)
tree
,
final BSPTree<S>
parent tree to connect to (may be null)
parentTree
,
final boolean
if true and if parentTree is not null, the resulting tree should be the plus child of its parent, ignored if parentTree is null
isPlusChild
,
final boolean
if true, the leaf node comes from the instance tree (tree1) and the tree node comes from the argument tree (tree2)
leafFromInstance
)

Implements org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger.merge.

Merge a leaf node and a tree node.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

IntersectionMergerback to summary
private IntersectionMerger()

Method Detail

mergeback to summary
public BSPTree<S> merge(final BSPTree<S> leaf, final BSPTree<S> tree, final BSPTree<S> parentTree, final boolean isPlusChild, final boolean leafFromInstance)

Implements org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger.merge.

Doc from org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger.merge.

Merge a leaf node and a tree node.

This method is called at the end of a recursive merging resulting from a tree1.merge(tree2, leafMerger) call, when one of the sub-trees involved is a leaf (i.e. when its cut-hyperplane is null). This is the only place where the precise semantics of the operation are required. For all upper level nodes in the tree, the merging operation is only a generic partitioning algorithm.

Since the final operation may be non-commutative, it is important to know if the leaf node comes from the instance tree (tree1) or the argument tree (tree2). The third argument of the method is devoted to this. It can be ignored for commutative operations.

The BSPTree.insertInTree method may be useful to implement this method.

Parameters
leaf:BSPTree<S>

leaf node (its cut hyperplane is guaranteed to be null)

tree:BSPTree<S>

tree node (its cut hyperplane may be null or not)

parentTree:BSPTree<S>

parent tree to connect to (may be null)

isPlusChild:boolean

if true and if parentTree is not null, the resulting tree should be the plus child of its parent, ignored if parentTree is null

leafFromInstance:boolean

if true, the leaf node comes from the instance tree (tree1) and the tree node comes from the argument tree (tree2)

Returns:BSPTree<S>

the BSP tree resulting from the merging (may be one of the arguments)

org.apache.commons.math3.geometry.partitioning back to summary

private Class RegionFactory.NodesCleaner

extends Object
implements BSPTreeVisitor<S extends Space>
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.geometry.partitioning.RegionFactory.NodesCleaner
All Implemented Interfaces
org.apache.commons.math3.geometry.partitioning.BSPTreeVisitor

Visitor removing internal nodes attributes.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
visitInternalNode(final BSPTree<S>
BSP node guaranteed to have a non null cut sub-hyperplane
node
)

Implements org.apache.commons.math3.geometry.partitioning.BSPTreeVisitor.visitInternalNode.

Visit a BSP tree node node having a non-null sub-hyperplane.

public void
visitLeafNode(final BSPTree<S>
leaf BSP node having a null sub-hyperplane
node
)

Implements org.apache.commons.math3.geometry.partitioning.BSPTreeVisitor.visitLeafNode.

Visit a leaf BSP tree node node having a null sub-hyperplane.

public BSPTreeVisitor.Order
visitOrder(final BSPTree<S>
BSP node guaranteed to have a non null cut sub-hyperplane
node
)

Implements org.apache.commons.math3.geometry.partitioning.BSPTreeVisitor.visitOrder.

Determine the visit order for this node.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NodesCleanerback to summary
private NodesCleaner()

Method Detail

visitInternalNodeback to summary
public void visitInternalNode(final BSPTree<S> node)

Implements org.apache.commons.math3.geometry.partitioning.BSPTreeVisitor.visitInternalNode.

Doc from org.apache.commons.math3.geometry.partitioning.BSPTreeVisitor.visitInternalNode.

Visit a BSP tree node node having a non-null sub-hyperplane.

It is guaranteed that this method will be called after visitOrder has been called for a given node, it wil be called exactly once for each internal node.

Parameters
node:BSPTree<S>

BSP node guaranteed to have a non null cut sub-hyperplane

visitLeafNodeback to summary
public void visitLeafNode(final BSPTree<S> node)

Implements org.apache.commons.math3.geometry.partitioning.BSPTreeVisitor.visitLeafNode.

Doc from org.apache.commons.math3.geometry.partitioning.BSPTreeVisitor.visitLeafNode.

Visit a leaf BSP tree node node having a null sub-hyperplane.

Parameters
node:BSPTree<S>

leaf BSP node having a null sub-hyperplane

visitOrderback to summary
public BSPTreeVisitor.Order visitOrder(final BSPTree<S> node)

Implements org.apache.commons.math3.geometry.partitioning.BSPTreeVisitor.visitOrder.

Doc from org.apache.commons.math3.geometry.partitioning.BSPTreeVisitor.visitOrder.

Determine the visit order for this node.

Before attempting to visit an internal node, this method is called to determine the desired ordering of the visit. It is guaranteed that this method will be called before visitInternalNode for a given node, it will be called exactly once for each internal node.

Parameters
node:BSPTree<S>

BSP node guaranteed to have a non null cut sub-hyperplane

Returns:BSPTreeVisitor.Order

desired visit order, must be one of Order#PLUS_MINUS_SUB, Order#PLUS_SUB_MINUS, Order#MINUS_PLUS_SUB, Order#MINUS_SUB_PLUS, Order#SUB_PLUS_MINUS, Order#SUB_MINUS_PLUS

org.apache.commons.math3.geometry.partitioning back to summary

private Class RegionFactory.UnionMerger

extends Object
implements BSPTree.LeafMerger<S extends Space>
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.geometry.partitioning.RegionFactory.UnionMerger
All Implemented Interfaces
org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger

BSP tree leaf merger computing union of two regions.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public BSPTree<S>
merge(final BSPTree<S>
leaf node (its cut hyperplane is guaranteed to be null)
leaf
,
final BSPTree<S>
tree node (its cut hyperplane may be null or not)
tree
,
final BSPTree<S>
parent tree to connect to (may be null)
parentTree
,
final boolean
if true and if parentTree is not null, the resulting tree should be the plus child of its parent, ignored if parentTree is null
isPlusChild
,
final boolean
if true, the leaf node comes from the instance tree (tree1) and the tree node comes from the argument tree (tree2)
leafFromInstance
)

Implements org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger.merge.

Merge a leaf node and a tree node.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

UnionMergerback to summary
private UnionMerger()

Method Detail

mergeback to summary
public BSPTree<S> merge(final BSPTree<S> leaf, final BSPTree<S> tree, final BSPTree<S> parentTree, final boolean isPlusChild, final boolean leafFromInstance)

Implements org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger.merge.

Doc from org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger.merge.

Merge a leaf node and a tree node.

This method is called at the end of a recursive merging resulting from a tree1.merge(tree2, leafMerger) call, when one of the sub-trees involved is a leaf (i.e. when its cut-hyperplane is null). This is the only place where the precise semantics of the operation are required. For all upper level nodes in the tree, the merging operation is only a generic partitioning algorithm.

Since the final operation may be non-commutative, it is important to know if the leaf node comes from the instance tree (tree1) or the argument tree (tree2). The third argument of the method is devoted to this. It can be ignored for commutative operations.

The BSPTree.insertInTree method may be useful to implement this method.

Parameters
leaf:BSPTree<S>

leaf node (its cut hyperplane is guaranteed to be null)

tree:BSPTree<S>

tree node (its cut hyperplane may be null or not)

parentTree:BSPTree<S>

parent tree to connect to (may be null)

isPlusChild:boolean

if true and if parentTree is not null, the resulting tree should be the plus child of its parent, ignored if parentTree is null

leafFromInstance:boolean

if true, the leaf node comes from the instance tree (tree1) and the tree node comes from the argument tree (tree2)

Returns:BSPTree<S>

the BSP tree resulting from the merging (may be one of the arguments)

org.apache.commons.math3.geometry.partitioning back to summary

private Class RegionFactory.VanishingToLeaf

extends Object
implements BSPTree.VanishingCutHandler<S extends Space>
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.geometry.partitioning.RegionFactory.VanishingToLeaf
All Implemented Interfaces
org.apache.commons.math3.geometry.partitioning.BSPTree.VanishingCutHandler

Handler replacing nodes with vanishing cuts with leaf nodes.

Field Summary

Modifier and TypeField and Description
private final boolean
inside

Inside/outside indocator to use for ambiguous nodes.

Constructor Summary

AccessConstructor and Description
pack-priv
VanishingToLeaf(final boolean
inside/outside indicator to use for ambiguous nodes
inside
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public BSPTree<S>
fixNode(final BSPTree<S>
node to fix
node
)

Implements org.apache.commons.math3.geometry.partitioning.BSPTree.VanishingCutHandler.fixNode.

Fix a node with both vanished cut and children.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

insideback to summary
private final boolean inside

Inside/outside indocator to use for ambiguous nodes.

Constructor Detail

VanishingToLeafback to summary
pack-priv VanishingToLeaf(final boolean inside)

Simple constructor.

Parameters
inside:boolean

inside/outside indicator to use for ambiguous nodes

Method Detail

fixNodeback to summary
public BSPTree<S> fixNode(final BSPTree<S> node)

Implements org.apache.commons.math3.geometry.partitioning.BSPTree.VanishingCutHandler.fixNode.

Doc from org.apache.commons.math3.geometry.partitioning.BSPTree.VanishingCutHandler.fixNode.

Fix a node with both vanished cut and children.

Parameters
node:BSPTree<S>

node to fix

Returns:BSPTree<S>

fixed node

org.apache.commons.math3.geometry.partitioning back to summary

private Class RegionFactory.XorMerger

extends Object
implements BSPTree.LeafMerger<S extends Space>
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.geometry.partitioning.RegionFactory.XorMerger
All Implemented Interfaces
org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger

BSP tree leaf merger computing symmetric difference (exclusive or) of two regions.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public BSPTree<S>
merge(final BSPTree<S>
leaf node (its cut hyperplane is guaranteed to be null)
leaf
,
final BSPTree<S>
tree node (its cut hyperplane may be null or not)
tree
,
final BSPTree<S>
parent tree to connect to (may be null)
parentTree
,
final boolean
if true and if parentTree is not null, the resulting tree should be the plus child of its parent, ignored if parentTree is null
isPlusChild
,
final boolean
if true, the leaf node comes from the instance tree (tree1) and the tree node comes from the argument tree (tree2)
leafFromInstance
)

Implements org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger.merge.

Merge a leaf node and a tree node.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

XorMergerback to summary
private XorMerger()

Method Detail

mergeback to summary
public BSPTree<S> merge(final BSPTree<S> leaf, final BSPTree<S> tree, final BSPTree<S> parentTree, final boolean isPlusChild, final boolean leafFromInstance)

Implements org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger.merge.

Doc from org.apache.commons.math3.geometry.partitioning.BSPTree.LeafMerger.merge.

Merge a leaf node and a tree node.

This method is called at the end of a recursive merging resulting from a tree1.merge(tree2, leafMerger) call, when one of the sub-trees involved is a leaf (i.e. when its cut-hyperplane is null). This is the only place where the precise semantics of the operation are required. For all upper level nodes in the tree, the merging operation is only a generic partitioning algorithm.

Since the final operation may be non-commutative, it is important to know if the leaf node comes from the instance tree (tree1) or the argument tree (tree2). The third argument of the method is devoted to this. It can be ignored for commutative operations.

The BSPTree.insertInTree method may be useful to implement this method.

Parameters
leaf:BSPTree<S>

leaf node (its cut hyperplane is guaranteed to be null)

tree:BSPTree<S>

tree node (its cut hyperplane may be null or not)

parentTree:BSPTree<S>

parent tree to connect to (may be null)

isPlusChild:boolean

if true and if parentTree is not null, the resulting tree should be the plus child of its parent, ignored if parentTree is null

leafFromInstance:boolean

if true, the leaf node comes from the instance tree (tree1) and the tree node comes from the argument tree (tree2)

Returns:BSPTree<S>

the BSP tree resulting from the merging (may be one of the arguments)