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

pack-priv Class NestedLoops

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Iterator, .List, org.apache.commons.math3.exception.MathIllegalArgumentException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.geometry.Point, org.apache.commons.math3.geometry.euclidean.oned.IntervalsSet, org.apache.commons.math3.geometry.partitioning.Region, .RegionFactory, .SubHyperplane

This class represent a tree of nested 2D boundary loops.

This class is used for piecewise polygons construction. Polygons are built using the outline edges as representative of boundaries, the orientation of these lines are meaningful. However, we want to allow the user to specify its outline loops without having to take care of this orientation. This class is devoted to correct mis-oriented loops.

Orientation is computed assuming the piecewise polygon is finite, i.e. the outermost loops have their exterior side facing points at infinity, and hence are oriented counter-clockwise. The orientation of internal loops is computed as the reverse of the orientation of their immediate surrounding loop.

Since
3.0

Field Summary

Modifier and TypeField and Description
private Vector2D[]
loop

Boundary loop.

private boolean
originalIsClockwise

Indicator for original loop orientation.

private Region<Euclidean2D>
polygon

Polygon enclosing a finite region.

private List<NestedLoops>
surrounded

Surrounded loops.

private final double
tolerance

Tolerance below which points are considered identical.

Constructor Summary

AccessConstructor and Description
pack-priv
NestedLoops(final double
tolerance below which points are considered identical
tolerance
)

Simple Constructor.

private
NestedLoops(final Vector2D[]
boundary loop (will be reversed in place if needed)
loop
,
final double
tolerance below which points are considered identical
tolerance
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public void
add(final Vector2D[]
boundary loop (will be reversed in place if needed)
bLoop
)

Add a loop in a tree.

private void
add(final NestedLoops
boundary loop (will be reversed in place if needed)
node
)

Add a loop in a tree.

public void
correctOrientation()

Correct the orientation of the loops contained in the tree.

private void
setClockWise(final boolean
if true, the loop should be set to clockwise orientation
clockwise
)

Set the loop orientation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loopback to summary
private Vector2D[] loop

Boundary loop.

originalIsClockwiseback to summary
private boolean originalIsClockwise

Indicator for original loop orientation.

polygonback to summary
private Region<Euclidean2D> polygon

Polygon enclosing a finite region.

surroundedback to summary
private List<NestedLoops> surrounded

Surrounded loops.

toleranceback to summary
private final double tolerance

Tolerance below which points are considered identical.

Constructor Detail

NestedLoopsback to summary
pack-priv NestedLoops(final double tolerance)

Simple Constructor.

Build an empty tree of nested loops. This instance will become the root node of a complete tree, it is not associated with any loop by itself, the outermost loops are in the root tree child nodes.

Parameters
tolerance:double

tolerance below which points are considered identical

Since
3.3
NestedLoopsback to summary
private NestedLoops(final Vector2D[] loop, final double tolerance) throws MathIllegalArgumentException

Constructor.

Build a tree node with neither parent nor children

Parameters
loop:Vector2D[]

boundary loop (will be reversed in place if needed)

tolerance:double

tolerance below which points are considered identical

Exceptions
MathIllegalArgumentException:
if an outline has an open boundary loop
Since
3.3

Method Detail

addback to summary
public void add(final Vector2D[] bLoop) throws MathIllegalArgumentException

Add a loop in a tree.

Parameters
bLoop:Vector2D[]

boundary loop (will be reversed in place if needed)

Exceptions
MathIllegalArgumentException:
if an outline has crossing boundary loops or open boundary loops
addback to summary
private void add(final NestedLoops node) throws MathIllegalArgumentException

Add a loop in a tree.

Parameters
node:NestedLoops

boundary loop (will be reversed in place if needed)

Exceptions
MathIllegalArgumentException:
if an outline has boundary loops that cross each other
correctOrientationback to summary
public void correctOrientation()

Correct the orientation of the loops contained in the tree.

This is this method that really inverts the loops that where provided through the add method if they are mis-oriented

setClockWiseback to summary
private void setClockWise(final boolean clockwise)

Set the loop orientation.

Parameters
clockwise:boolean

if true, the loop should be set to clockwise orientation