Class RegionBSPTree3D
java.lang.Object
org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree<Vector3D, RegionBSPTree3D.RegionNode3D>
org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree<Vector3D, RegionBSPTree3D.RegionNode3D>
org.apache.commons.geometry.euclidean.threed.RegionBSPTree3D
- All Implemented Interfaces:
BoundarySource<PlaneConvexSubset>, BSPSubtree<Vector3D, RegionBSPTree3D.RegionNode3D>, BSPTree<Vector3D, RegionBSPTree3D.RegionNode3D>, HyperplaneBoundedRegion<Vector3D>, Splittable<Vector3D, HyperplaneBoundedRegion<Vector3D>>, Region<Vector3D>, Sized, BoundarySource3D, Linecastable3D
public final class RegionBSPTree3D
extends AbstractRegionBSPTree<Vector3D, RegionBSPTree3D.RegionNode3D>
implements BoundarySource3D
Binary space partitioning (BSP) tree representing a region in three dimensional
Euclidean space.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classClass used to project points onto the 3D region boundary.private static final classBSP tree visitor that performs a linecast operation against the boundaries of the visited tree.static final classClass used to build regions in Euclidean 3D space by inserting boundaries into a BSP tree containing "partitions", i.e.static final classBSP tree node for three dimensional Euclidean space.private static final classVisitor for computing geometric properties for 3D BSP tree instances.Nested classes/interfaces inherited from class AbstractRegionBSPTree
AbstractRegionBSPTree.AbstractRegionNode<P,N>, AbstractRegionBSPTree.BoundaryProjector<P, N>, AbstractRegionBSPTree.RegionSizeProperties<P> Nested classes/interfaces inherited from class AbstractBSPTree
AbstractBSPTree.AbstractNode<P,N>, AbstractBSPTree.SubtreeInitializer<N> Nested classes/interfaces inherited from interface BSPTree
BSPTree.FindNodeCutRule, BSPTree.Node<P,N> -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new, empty region.RegionBSPTree3D(boolean full) Create a new region. -
Method Summary
Modifier and TypeMethodDescriptionReturn anIterablefor iterating over the boundaries of the region.Return a stream containing the boundaries for this instance.Compute the size-related properties of the region.copy()Return a deep copy of this instance.protected RegionBSPTree3D.RegionNode3DCreate a new node for this tree.static RegionBSPTree3Dempty()Return a new, empty instance.static RegionBSPTree3Dfrom(Iterable<? extends PlaneConvexSubset> boundaries) Construct a new tree from the given boundaries.static RegionBSPTree3Dfrom(Iterable<? extends PlaneConvexSubset> boundaries, boolean full) Construct a new tree from the given boundaries.static RegionBSPTree3Dfull()Return a new instance containing all of 3D space.Return a list containing the boundaries of the region.linecast(LineConvexSubset3D subset) Intersect the given line convex subset against the boundaries in this instance, returning a list of all intersections in order of increasing distance along the line.linecastFirst(LineConvexSubset3D subset) Intersect the given line convex subset against the boundaries in this instance, returning the first intersection found when traveling in the direction of the line subset from its start point.Create a newRegionBSPTree3D.PartitionedRegionBuilder3Dinstance which can be used to build balanced BSP trees from region boundaries.Project a point onto the boundary of the region.split(Hyperplane<Vector3D> splitter) Split this instance with the given hyperplane.toConvex()Return a list ofConvexVolumes representing the same region as this instance.private voidtoConvexRecursive(RegionBSPTree3D.RegionNode3D node, ConvexVolume nodeVolume, List<? super ConvexVolume> result) Recursive method to compute the convex volumes of all inside leaf nodes in the subtree rooted at the given node.toTree()Return the current instance.Methods inherited from class AbstractRegionBSPTree
classify, complement, complement, condense, copyNodeProperties, createBoundaryIterable, createBoundaryList, difference, difference, getBoundarySize, getCentroid, getRegionSizeProperties, getSize, getSubtreeInitializer, insert, insert, insert, insert, insert, insert, insert, insert, intersection, intersection, invalidate, isEmpty, isFull, setEmpty, setFull, split, union, union, xor, xorMethods inherited from class AbstractBSPTree
accept, accept, copy, copyNode, copySubtree, count, cutNode, extract, extractParentPath, findNode, findNode, getRoot, getVersion, height, importSubtree, insert, nodes, removeNodeCut, setNodeCut, setRoot, splitIntoTrees, splitSubtree, swapsInsideOutside, toString, transform, treeString, treeString, trimToNodeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface BoundarySource3D
getBounds, toList, toTriangleMesh, triangleStreamMethods inherited from interface Linecastable3D
linecast, linecastFirstMethods inherited from interface Sized
isFinite, isInfinite
-
Constructor Details
-
RegionBSPTree3D
public RegionBSPTree3D()Create a new, empty region. -
RegionBSPTree3D
public RegionBSPTree3D(boolean full) Create a new region. Iffullis true, then the region will represent the entire 3D space. Otherwise, it will be empty.- Parameters:
full- whether or not the region should contain the entire 3D space or be empty
-
-
Method Details
-
copy
Return a deep copy of this instance.- Returns:
- a deep copy of this instance.
- See Also:
-
boundaries
Return anIterablefor iterating over the boundaries of the region. Each boundary is oriented such that its plus side points to the outside of the region. The exact ordering of the boundaries is determined by the internal structure of the tree.- Overrides:
boundariesin classAbstractRegionBSPTree<Vector3D, RegionBSPTree3D.RegionNode3D>- Returns:
- an
Iterablefor iterating over the boundaries of the region - See Also:
-
boundaryStream
Return a stream containing the boundaries for this instance.- Specified by:
boundaryStreamin interfaceBoundarySource<PlaneConvexSubset>- Returns:
- a stream containing the boundaries for this instance
-
getBoundaries
Return a list containing the boundaries of the region. Each boundary is oriented such that its plus side points to the outside of the region. The exact ordering of the boundaries is determined by the internal structure of the tree.- Overrides:
getBoundariesin classAbstractRegionBSPTree<Vector3D, RegionBSPTree3D.RegionNode3D>- Returns:
- a list of the boundaries of the region
-
toConvex
Return a list ofConvexVolumes representing the same region as this instance. One convex volume is returned for each interior leaf node in the tree.- Returns:
- a list of convex volumes representing the same region as this instance
-
toConvexRecursive
private void toConvexRecursive(RegionBSPTree3D.RegionNode3D node, ConvexVolume nodeVolume, List<? super ConvexVolume> result) Recursive method to compute the convex volumes of all inside leaf nodes in the subtree rooted at the given node. The computed convex volumes are added to the given list.- Parameters:
node- root of the subtree to compute the convex volumes fornodeVolume- the convex volume for the current node; this will be split by the node's cut hyperplane to form the convex volumes for any child nodesresult- list containing the results of the computation
-
split
Split this instance with the given hyperplane.- Specified by:
splitin interfaceSplittable<Vector3D, HyperplaneBoundedRegion<Vector3D>>- Parameters:
splitter- the hyperplane to split this object with.- Returns:
- result of the split operation
-
project
Project a point onto the boundary of the region. Null is returned if the region contains no boundaries (ie, is eitherfullorempty).- Specified by:
projectin interfaceRegion<Vector3D>- Overrides:
projectin classAbstractRegionBSPTree<Vector3D, RegionBSPTree3D.RegionNode3D>- Parameters:
pt- pt to project- Returns:
- projection of the point on the boundary of the region or null if the region does not contain any boundaries
-
toTree
Return the current instance.- Specified by:
toTreein interfaceBoundarySource3D- Returns:
- a BSP tree constructed from the boundaries in this instance
- See Also:
-
linecast
Intersect the given line convex subset against the boundaries in this instance, returning a list of all intersections in order of increasing distance along the line. An empty list is returned if no intersections are discovered.- Specified by:
linecastin interfaceBoundarySource3D- Specified by:
linecastin interfaceLinecastable3D- Parameters:
subset- line subset to intersect- Returns:
- a list of computed intersections in order of increasing distance along the line
-
linecastFirst
Intersect the given line convex subset against the boundaries in this instance, returning the first intersection found when traveling in the direction of the line subset from its start point.- Specified by:
linecastFirstin interfaceBoundarySource3D- Specified by:
linecastFirstin interfaceLinecastable3D- Parameters:
subset- line subset to intersect- Returns:
- the first intersection found or null if no intersection is found
-
computeRegionSizeProperties
Compute the size-related properties of the region.- Specified by:
computeRegionSizePropertiesin classAbstractRegionBSPTree<Vector3D, RegionBSPTree3D.RegionNode3D>- Returns:
- object containing size properties for the region
-
createNode
Create a new node for this tree.- Specified by:
createNodein classAbstractBSPTree<Vector3D, RegionBSPTree3D.RegionNode3D>- Returns:
- a new node for this tree
-
full
Return a new instance containing all of 3D space.- Returns:
- a new instance containing all of 3D space.
-
empty
Return a new, empty instance. The represented region is completely empty.- Returns:
- a new, empty instance.
-
from
Construct a new tree from the given boundaries. If no boundaries are present, the returned tree is empty.- Parameters:
boundaries- boundaries to construct the tree from- Returns:
- a new tree instance constructed from the given boundaries
- See Also:
-
from
Construct a new tree from the given boundaries. Iffullis true, then the initial tree before boundary insertion contains the entire space. Otherwise, it is empty.- Parameters:
boundaries- boundaries to construct the tree fromfull- if true, the initial tree will contain the entire space- Returns:
- a new tree instance constructed from the given boundaries
-
partitionedRegionBuilder
Create a newRegionBSPTree3D.PartitionedRegionBuilder3Dinstance which can be used to build balanced BSP trees from region boundaries.- Returns:
- a new
RegionBSPTree3D.PartitionedRegionBuilder3Dinstance
-