Class PolygonsSet.SegmentsBuilder
- java.lang.Object
-
- org.apache.commons.math3.geometry.euclidean.twod.PolygonsSet.SegmentsBuilder
-
- All Implemented Interfaces:
BSPTreeVisitor<Euclidean2D>
- Enclosing class:
- PolygonsSet
private static class PolygonsSet.SegmentsBuilder extends java.lang.Object implements BSPTreeVisitor<Euclidean2D>
Visitor building segments.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.commons.math3.geometry.partitioning.BSPTreeVisitor
BSPTreeVisitor.Order
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<PolygonsSet.ConnectableSegment>segmentsBuilt segments.private doubletoleranceTolerance for close nodes connection.
-
Constructor Summary
Constructors Constructor Description SegmentsBuilder(double tolerance)Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddContribution(SubHyperplane<Euclidean2D> sub, BSPTree<Euclidean2D> node, java.lang.Iterable<BSPTree<Euclidean2D>> splitters, boolean reversed)Add the contribution of a boundary facet.java.util.List<PolygonsSet.ConnectableSegment>getSegments()Get the segments.private BSPTree<Euclidean2D>selectClosest(Vector2D point, java.lang.Iterable<BSPTree<Euclidean2D>> candidates)Select the node whose cut sub-hyperplane is closest to specified point.voidvisitInternalNode(BSPTree<Euclidean2D> node)Visit a BSP tree node node having a non-null sub-hyperplane.voidvisitLeafNode(BSPTree<Euclidean2D> node)Visit a leaf BSP tree node node having a null sub-hyperplane.BSPTreeVisitor.OrdervisitOrder(BSPTree<Euclidean2D> node)Determine the visit order for this node.
-
-
-
Field Detail
-
tolerance
private final double tolerance
Tolerance for close nodes connection.
-
segments
private final java.util.List<PolygonsSet.ConnectableSegment> segments
Built segments.
-
-
Method Detail
-
visitOrder
public BSPTreeVisitor.Order visitOrder(BSPTree<Euclidean2D> node)
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
visitInternalNodefor a given node, it will be called exactly once for each internal node.- Specified by:
visitOrderin interfaceBSPTreeVisitor<Euclidean2D>- Parameters:
node- BSP node guaranteed to have a non null cut sub-hyperplane- Returns:
- desired visit order, must be one of
BSPTreeVisitor.Order.PLUS_MINUS_SUB,BSPTreeVisitor.Order.PLUS_SUB_MINUS,BSPTreeVisitor.Order.MINUS_PLUS_SUB,BSPTreeVisitor.Order.MINUS_SUB_PLUS,BSPTreeVisitor.Order.SUB_PLUS_MINUS,BSPTreeVisitor.Order.SUB_MINUS_PLUS
-
visitInternalNode
public void visitInternalNode(BSPTree<Euclidean2D> node)
Visit a BSP tree node node having a non-null sub-hyperplane.It is guaranteed that this method will be called after
visitOrderhas been called for a given node, it wil be called exactly once for each internal node.- Specified by:
visitInternalNodein interfaceBSPTreeVisitor<Euclidean2D>- Parameters:
node- BSP node guaranteed to have a non null cut sub-hyperplane- See Also:
BSPTreeVisitor.visitLeafNode(org.apache.commons.math3.geometry.partitioning.BSPTree<S>)
-
visitLeafNode
public void visitLeafNode(BSPTree<Euclidean2D> node)
Visit a leaf BSP tree node node having a null sub-hyperplane.- Specified by:
visitLeafNodein interfaceBSPTreeVisitor<Euclidean2D>- Parameters:
node- leaf BSP node having a null sub-hyperplane- See Also:
BSPTreeVisitor.visitInternalNode(org.apache.commons.math3.geometry.partitioning.BSPTree<S>)
-
addContribution
private void addContribution(SubHyperplane<Euclidean2D> sub, BSPTree<Euclidean2D> node, java.lang.Iterable<BSPTree<Euclidean2D>> splitters, boolean reversed)
Add the contribution of a boundary facet.- Parameters:
sub- boundary facetnode- node containing segmentsplitters- splitters for the boundary facetreversed- if true, the facet has the inside on its plus side
-
selectClosest
private BSPTree<Euclidean2D> selectClosest(Vector2D point, java.lang.Iterable<BSPTree<Euclidean2D>> candidates)
Select the node whose cut sub-hyperplane is closest to specified point.- Parameters:
point- reference pointcandidates- candidate nodes- Returns:
- node closest to point, or null if no node is closer than tolerance
-
getSegments
public java.util.List<PolygonsSet.ConnectableSegment> getSegments()
Get the segments.- Returns:
- built segments
-
-