Class NestedLoops
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
FieldsModifier and TypeFieldDescriptionprivate Vector2D[]
Boundary loop.private boolean
Indicator for original loop orientation.private Region
<Euclidean2D> Polygon enclosing a finite region.private List
<NestedLoops> Surrounded loops.private final double
Tolerance below which points are considered identical. -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
NestedLoops
(double tolerance) Simple Constructor.private
NestedLoops
(Vector2D[] loop, double tolerance) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
add
(NestedLoops node) Add a loop in a tree.void
Add a loop in a tree.void
Correct the orientation of the loops contained in the tree.private void
setClockWise
(boolean clockwise) Set the loop orientation.
-
Field Details
-
loop
Boundary loop. -
surrounded
Surrounded loops. -
polygon
Polygon enclosing a finite region. -
originalIsClockwise
private boolean originalIsClockwiseIndicator for original loop orientation. -
tolerance
private final double toleranceTolerance below which points are considered identical.
-
-
Constructor Details
-
NestedLoops
NestedLoops(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
- tolerance below which points are considered identical- Since:
- 3.3
-
NestedLoops
Constructor.Build a tree node with neither parent nor children
- Parameters:
loop
- boundary loop (will be reversed in place if needed)tolerance
- tolerance below which points are considered identical- Throws:
MathIllegalArgumentException
- if an outline has an open boundary loop- Since:
- 3.3
-
-
Method Details
-
add
Add a loop in a tree.- Parameters:
bLoop
- boundary loop (will be reversed in place if needed)- Throws:
MathIllegalArgumentException
- if an outline has crossing boundary loops or open boundary loops
-
add
Add a loop in a tree.- Parameters:
node
- boundary loop (will be reversed in place if needed)- Throws:
MathIllegalArgumentException
- if an outline has boundary loops that cross each other
-
correctOrientation
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 -
setClockWise
private void setClockWise(boolean clockwise) Set the loop orientation.- Parameters:
clockwise
- if true, the loop should be set to clockwise orientation
-