public static final class RegionBSPTree2D.PartitionedRegionBuilder2D extends AbstractPartitionedRegionBuilder<Vector2D,RegionBSPTree2D.RegionNode2D>
Usage of this class consists of two phases: (1) partition insertion and (2) boundary
insertion. Instances begin in the partition insertion phase. Here, partitions can be inserted
into the empty tree using insertPartition
or similar methods. The INHERIT
cut rule is used internally to insert the cut so the represented region remains empty even as partitions are
inserted.
The instance moves into the boundary insertion phase when the caller inserts the first region
boundary, using insertBoundary
or
similar methods. Attempting to insert a partition after this point results in an IllegalStateException
.
This ensures that partitioning cuts are always located higher up the tree than boundary cuts.
After all boundaries are inserted, the build
method is used
to perform final processing and return the computed tree.
buildInternal, insertBoundaryInternal, insertPartitionInternal
public RegionBSPTree2D.PartitionedRegionBuilder2D insertPartition(Line partition)
partition
- partition to insertIllegalStateException
- if a boundary has previously been insertedpublic RegionBSPTree2D.PartitionedRegionBuilder2D insertPartition(LineConvexSubset partition)
partition
- partition to insertIllegalStateException
- if a boundary has previously been insertedpublic RegionBSPTree2D.PartitionedRegionBuilder2D insertAxisAlignedPartitions(Vector2D center, Precision.DoubleEquivalence precision)
center
point and have the directions +x
and +y
in that order. If inserted into an empty tree, this will partition the space
into 4 sections.center
- center point for the partitions; the inserted lines intersect at this pointprecision
- precision context used to construct the linesIllegalStateException
- if a boundary has previously been insertedpublic RegionBSPTree2D.PartitionedRegionBuilder2D insertAxisAlignedGrid(Bounds2D bounds, int level, Precision.DoubleEquivalence precision)
insertAxisAlignedPartitions
.
The algorithm then recurses using bounding boxes from the min point to the center and from the center
point to the max. Note that this means no partitions are ever inserted directly on the boundaries of
the given bounding box. This is intentional and done to allow this method to be called directly with the
bounding box from a set of boundaries to be inserted without unnecessarily adding partitions that will
never have region boundaries on both sides.bounds
- bounding box for the gridlevel
- recursion level for the grid; each level subdivides each grid cube into 4 sections, making the
total number of grid cubes equal to 4 ^ level
precision
- precision context used to construct the partition linesIllegalStateException
- if a boundary has previously been insertedpublic RegionBSPTree2D.PartitionedRegionBuilder2D insertBoundary(LineConvexSubset boundary)
boundary
- region boundary to insertpublic RegionBSPTree2D.PartitionedRegionBuilder2D insertBoundaries(Iterable<? extends LineConvexSubset> boundaries)
boundaries
- boundaries to insertpublic RegionBSPTree2D.PartitionedRegionBuilder2D insertBoundaries(BoundarySource2D boundarySrc)
boundarySrc
- source of boundaries to insertpublic RegionBSPTree2D build()
Copyright © 2016–2021 The Apache Software Foundation. All rights reserved.