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

public Class PolygonsSet

extends AbstractRegion<Euclidean2D, Euclidean1D>
Class Inheritance
Imports
java.util.ArrayList, .Collection, .List, org.apache.commons.math3.geometry.Point, org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D, .Interval, .IntervalsSet, .Vector1D, org.apache.commons.math3.geometry.partitioning.AbstractRegion, .AbstractSubHyperplane, .BSPTree, .BSPTreeVisitor, .BoundaryAttribute, .Hyperplane, .Side, .SubHyperplane, org.apache.commons.math3.util.FastMath, .Precision

This class represents a 2D region: a set of polygons.
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
PolygonsSet.ConnectableSegment

Private extension of Segment allowing connection.

private static class
PolygonsSet.Edge

Internal class for holding edges while they are processed to build a BSP tree.

private static class
PolygonsSet.SegmentsBuilder

Visitor building segments.

private static class
PolygonsSet.Vertex

Internal class for holding vertices while they are processed to build a BSP tree.

Field Summary

Modifier and TypeField and Description
private static final double
DEFAULT_TOLERANCE

Default value for tolerance.

private Vector2D[][]
vertices

Vertices organized as boundary loops.

Constructor Summary

AccessConstructor and Description
public
PolygonsSet(final double
tolerance below which points are considered identical
tolerance
)

Build a polygons set representing the whole plane.

public
PolygonsSet(final BSPTree<Euclidean2D>
inside/outside BSP tree representing the region
tree
,
final double
tolerance below which points are considered identical
tolerance
)

Build a polygons set from a BSP tree.

public
PolygonsSet(final Collection<SubHyperplane<Euclidean2D>>
collection of boundary elements, as a collection of SubHyperplane objects
boundary
,
final double
tolerance below which points are considered identical
tolerance
)

Build a polygons set from a Boundary REPresentation (B-rep).

public
PolygonsSet(final double
low bound along the x direction
xMin
,
final double
high bound along the x direction
xMax
,
final double
low bound along the y direction
yMin
,
final double
high bound along the y direction
yMax
,
final double
tolerance below which points are considered identical
tolerance
)

Build a parallellepipedic box.

public
PolygonsSet(final double
tolerance below which points are considered to belong to the hyperplane (which is therefore more a slab)
hyperplaneThickness
,
final Vector2D...
vertices of the simple loop boundary
vertices
)

Build a polygon from a simple list of vertices.

public
PolygonsSet()
Deprecated as of 3.3, replaced with PolygonsSet(double)

Build a polygons set representing the whole real line.

public
PolygonsSet(final BSPTree<Euclidean2D>
inside/outside BSP tree representing the region
tree
)
Deprecated as of 3.3, replaced with PolygonsSet(BSPTree, double)

Build a polygons set from a BSP tree.

public
PolygonsSet(final Collection<SubHyperplane<Euclidean2D>>
collection of boundary elements, as a collection of SubHyperplane objects
boundary
)
Deprecated as of 3.3, replaced with PolygonsSet(Collection, double)

Build a polygons set from a Boundary REPresentation (B-rep).

public
PolygonsSet(final double
low bound along the x direction
xMin
,
final double
high bound along the x direction
xMax
,
final double
low bound along the y direction
yMin
,
final double
high bound along the y direction
yMax
)
Deprecated as of 3.3, replaced with PolygonsSet(double, double, double, double, double)

Build a parallellepipedic box.

Method Summary

Modifier and TypeMethod and Description
private static Line[]

Returns:

boundary of the box
boxBoundary
(final double
low bound along the x direction
xMin
,
final double
high bound along the x direction
xMax
,
final double
low bound along the y direction
yMin
,
final double
high bound along the y direction
yMax
,
final double
tolerance below which points are considered identical
tolerance
)

Create a list of hyperplanes representing the boundary of a box.

public PolygonsSet
buildNew(final BSPTree<Euclidean2D>
inside/outside BSP tree representing the new region
tree
)

Implements abstract org.apache.commons.math3.geometry.partitioning.AbstractRegion.buildNew.

Implements org.apache.commons.math3.geometry.partitioning.Region.buildNew.

Build a region using the instance as a prototype.

private int

Returns:

number of connections performed
closeVerticesConnections
(final List<PolygonsSet.ConnectableSegment>
segments complete segments list
segments
)

Connect the segments using Euclidean distance.

protected void
private void
filterSpuriousVertices(final List<Segment>
segments loop to filter (will be modified in-place)
loop
)

Filter out spurious vertices on straight lines (at machine precision).

private List<Segment>

Returns:

loop containing the segment (may be null if the loop is a degenerated infinitely thin 2 points loop
followLoop
(final PolygonsSet.ConnectableSegment
segment used to define the loop
defining
)

Build the loop containing a segment.

private PolygonsSet.ConnectableSegment

Returns:

first segment that has not been processed yet or null if all segments have been processed
getUnprocessed
(final List<PolygonsSet.ConnectableSegment>
segments list
segments
)

Get first unprocessed segment from a list.

public Vector2D[][]

Returns:

vertices of the polygon, organized as oriented boundary loops with the open loops first (the returned value is guaranteed to be non-null)
getVertices
()

Get the vertices of the polygon.

private static void
insertEdges(final double
tolerance below which points are consider to belong to the hyperplane (which is therefore more a slab)
hyperplaneThickness
,
final BSPTree<Euclidean2D>
current tree node (it is a leaf node at the beginning of the call)
node
,
final List<PolygonsSet.Edge>
list of edges to insert in the cell defined by this node (excluding edges not belonging to the cell defined by this node)
edges
)

Recursively build a tree by inserting cut sub-hyperplanes.

private int

Returns:

number of connections performed
naturalFollowerConnections
(final List<PolygonsSet.ConnectableSegment>
segments complete segments list
segments
)

Connect the segments using only natural follower information.

private int

Returns:

number of connections performed
splitEdgeConnections
(final List<PolygonsSet.ConnectableSegment>
segments complete segments list
segments
)

Connect the segments resulting from a line splitting a straight edge.

private static BSPTree<Euclidean2D>

Returns:

the BSP tree of the input vertices
verticesToTree
(final double
tolerance below which points are consider to belong to the hyperplane (which is therefore more a slab)
hyperplaneThickness
,
final Vector2D...
vertices of the simple loop boundary
vertices
)

Build the BSP tree of a polygons set from a simple list of vertices.

Inherited from org.apache.commons.math3.geometry.partitioning.AbstractRegion:
applyTransformcheckPointcheckPointcheckPointcheckPointcontainscopySelfgetBarycentergetBoundarySizegetSizegetTolerancegetTreeintersectionisEmptyisEmptyisFullisFullprojectToBoundarysetBarycentersetBarycentersetSizeside