public class ArcsSet extends AbstractRegion<Sphere1D,Sphere1D> implements java.lang.Iterable<double[]>
Note that due to the wrapping around \(2 \pi\), barycenter is
ill-defined here. It was defined only in order to fulfill
the requirements of the Region
interface, but its use is discouraged.
Modifier and Type | Class and Description |
---|---|
static class |
ArcsSet.InconsistentStateAt2PiWrapping
Specialized exception for inconsistent BSP tree state inconsistency.
|
static class |
ArcsSet.Split
Class holding the results of the
split method. |
private class |
ArcsSet.SubArcsIterator
Local iterator for sub-arcs.
|
Region.Location
Constructor and Description |
---|
ArcsSet(BSPTree<Sphere1D> tree,
double tolerance)
Build an arcs set from an inside/outside BSP tree.
|
ArcsSet(java.util.Collection<SubHyperplane<Sphere1D>> boundary,
double tolerance)
Build an arcs set from a Boundary REPresentation (B-rep).
|
ArcsSet(double tolerance)
Build an arcs set representing the whole circle.
|
ArcsSet(double lower,
double upper,
double tolerance)
Build an arcs set corresponding to a single arc.
|
Modifier and Type | Method and Description |
---|---|
private void |
addArcLimit(BSPTree<Sphere1D> tree,
double alpha,
boolean isStart)
Add an arc limit to a BSP tree under construction.
|
java.util.List<Arc> |
asList()
Build an ordered list of arcs representing the instance.
|
ArcsSet |
buildNew(BSPTree<Sphere1D> tree)
Build a region using the instance as a prototype.
|
private static BSPTree<Sphere1D> |
buildTree(double lower,
double upper,
double tolerance)
Build an inside/outside tree representing a single arc.
|
private void |
check2PiConsistency()
Check consistency.
|
private BSPTree<Sphere1D> |
childAfter(BSPTree<Sphere1D> node)
Find the child node just after an internal node.
|
private BSPTree<Sphere1D> |
childBefore(BSPTree<Sphere1D> node)
Find the child node just before an internal node.
|
protected void |
computeGeometricalProperties()
Compute some geometrical properties.
|
private ArcsSet |
createSplitPart(java.util.List<java.lang.Double> limits)
Create a split part.
|
private double |
getAngle(BSPTree<Sphere1D> node)
Get the limit angle of an internal node.
|
private BSPTree<Sphere1D> |
getFirstArcStart()
Get the node corresponding to the first arc start.
|
private BSPTree<Sphere1D> |
getFirstLeaf(BSPTree<Sphere1D> root)
Get the first leaf node of a tree.
|
private BSPTree<Sphere1D> |
getLastLeaf(BSPTree<Sphere1D> root)
Get the last leaf node of a tree.
|
private boolean |
isAfterParent(BSPTree<Sphere1D> node)
Check if a node is the child after its parent in trigonometric order.
|
private boolean |
isArcEnd(BSPTree<Sphere1D> node)
Check if an internal node corresponds to the end angle of an arc.
|
private boolean |
isArcStart(BSPTree<Sphere1D> node)
Check if an internal node corresponds to the start angle of an arc.
|
private boolean |
isBeforeParent(BSPTree<Sphere1D> node)
Check if a node is the child before its parent in trigonometric order.
|
private boolean |
isDirect(BSPTree<Sphere1D> node)
Check if an internal node has a direct limit angle.
|
java.util.Iterator<double[]> |
iterator() |
private BSPTree<Sphere1D> |
leafAfter(BSPTree<Sphere1D> node)
Find the leaf node just after an internal node.
|
private BSPTree<Sphere1D> |
leafBefore(BSPTree<Sphere1D> node)
Find the leaf node just before an internal node.
|
private BSPTree<Sphere1D> |
nextInternalNode(BSPTree<Sphere1D> node)
Get the next internal node.
|
private BSPTree<Sphere1D> |
previousInternalNode(BSPTree<Sphere1D> node)
Get the previous internal node.
|
BoundaryProjection<Sphere1D> |
projectToBoundary(Point<Sphere1D> point)
Project a point on the boundary of the region.
|
Side |
side(Arc arc)
Compute the relative position of the instance with respect
to an arc.
|
ArcsSet.Split |
split(Arc arc)
Split the instance in two parts by an arc.
|
applyTransform, checkPoint, checkPoint, checkPoint, checkPoint, contains, copySelf, getBarycenter, getBoundarySize, getSize, getTolerance, getTree, intersection, isEmpty, isEmpty, isFull, isFull, setBarycenter, setBarycenter, setSize, side
public ArcsSet(double tolerance)
tolerance
- tolerance below which close sub-arcs are merged togetherpublic ArcsSet(double lower, double upper, double tolerance) throws NumberIsTooLargeException
If either lower
is equals to upper
or
the interval exceeds \( 2 \pi \), the arc is considered
to be the full circle and its initial defining boundaries
will be forgotten. lower
is not allowed to be greater
than upper
(an exception is thrown in this case).
lower
- lower bound of the arcupper
- upper bound of the arctolerance
- tolerance below which close sub-arcs are merged togetherNumberIsTooLargeException
- if lower is greater than upperpublic ArcsSet(BSPTree<Sphere1D> tree, double tolerance) throws ArcsSet.InconsistentStateAt2PiWrapping
The leaf nodes of the BSP tree must have a
Boolean
attribute representing the inside status of
the corresponding cell (true for inside cells, false for outside
cells). In order to avoid building too many small objects, it is
recommended to use the predefined constants
Boolean.TRUE
and Boolean.FALSE
tree
- inside/outside BSP tree representing the arcs settolerance
- tolerance below which close sub-arcs are merged togetherArcsSet.InconsistentStateAt2PiWrapping
- if the tree leaf nodes are not
consistent across the \( 0, 2 \pi \) crossingpublic ArcsSet(java.util.Collection<SubHyperplane<Sphere1D>> boundary, double tolerance) throws ArcsSet.InconsistentStateAt2PiWrapping
The boundary is provided as a collection of sub-hyperplanes
. Each sub-hyperplane has the
interior part of the region on its minus side and the exterior on
its plus side.
The boundary elements can be in any order, and can form
several non-connected sets (like for example polygons with holes
or a set of disjoints polyhedrons considered as a whole). In
fact, the elements do not even need to be connected together
(their topological connections are not used here). However, if the
boundary does not really separate an inside open from an outside
open (open having here its topological meaning), then subsequent
calls to the checkPoint
method will not be meaningful anymore.
If the boundary is empty, the region will represent the whole space.
boundary
- collection of boundary elementstolerance
- tolerance below which close sub-arcs are merged togetherArcsSet.InconsistentStateAt2PiWrapping
- if the tree leaf nodes are not
consistent across the \( 0, 2 \pi \) crossingprivate static BSPTree<Sphere1D> buildTree(double lower, double upper, double tolerance) throws NumberIsTooLargeException
lower
- lower angular bound of the arcupper
- upper angular bound of the arctolerance
- tolerance below which close sub-arcs are merged togetherNumberIsTooLargeException
- if lower is greater than upperprivate void check2PiConsistency() throws ArcsSet.InconsistentStateAt2PiWrapping
ArcsSet.InconsistentStateAt2PiWrapping
- if the tree leaf nodes are not
consistent across the \( 0, 2 \pi \) crossingprivate BSPTree<Sphere1D> getFirstLeaf(BSPTree<Sphere1D> root)
root
- tree rootprivate BSPTree<Sphere1D> getLastLeaf(BSPTree<Sphere1D> root)
root
- tree rootprivate BSPTree<Sphere1D> getFirstArcStart()
private boolean isArcStart(BSPTree<Sphere1D> node)
node
- internal node to checkprivate boolean isArcEnd(BSPTree<Sphere1D> node)
node
- internal node to checkprivate BSPTree<Sphere1D> nextInternalNode(BSPTree<Sphere1D> node)
node
- current internal nodeprivate BSPTree<Sphere1D> previousInternalNode(BSPTree<Sphere1D> node)
node
- current internal nodeprivate BSPTree<Sphere1D> leafBefore(BSPTree<Sphere1D> node)
node
- internal node at which the sub-tree startsprivate BSPTree<Sphere1D> leafAfter(BSPTree<Sphere1D> node)
node
- internal node at which the sub-tree startsprivate boolean isBeforeParent(BSPTree<Sphere1D> node)
node
- child node consideredprivate boolean isAfterParent(BSPTree<Sphere1D> node)
node
- child node consideredprivate BSPTree<Sphere1D> childBefore(BSPTree<Sphere1D> node)
node
- internal node at which the sub-tree startsprivate BSPTree<Sphere1D> childAfter(BSPTree<Sphere1D> node)
node
- internal node at which the sub-tree startsprivate boolean isDirect(BSPTree<Sphere1D> node)
node
- internal node to checkprivate double getAngle(BSPTree<Sphere1D> node)
node
- internal node to checkpublic ArcsSet buildNew(BSPTree<Sphere1D> tree)
This method allow to create new instances without knowing exactly the type of the region. It is an application of the prototype design pattern.
The leaf nodes of the BSP tree must have a
Boolean
attribute representing the inside status of
the corresponding cell (true for inside cells, false for outside
cells). In order to avoid building too many small objects, it is
recommended to use the predefined constants
Boolean.TRUE
and Boolean.FALSE
. The
tree also must have either null internal nodes or
internal nodes representing the boundary as specified in the
getTree
method).
protected void computeGeometricalProperties()
The properties to compute are the barycenter and the size.
computeGeometricalProperties
in class AbstractRegion<Sphere1D,Sphere1D>
public BoundaryProjection<Sphere1D> projectToBoundary(Point<Sphere1D> point)
projectToBoundary
in interface Region<Sphere1D>
projectToBoundary
in class AbstractRegion<Sphere1D,Sphere1D>
point
- point to checkpublic java.util.List<Arc> asList()
This method builds this arcs set as an ordered list of
Arc
elements. An empty tree will build an empty list
while a tree representing the whole circle will build a one
element list with bounds set to \( 0 and 2 \pi \).
Arc
elementspublic java.util.Iterator<double[]> iterator()
The iterator returns the limit angles pairs of sub-arcs in trigonometric order.
The iterator does not support the optional remove
operation.
iterator
in interface java.lang.Iterable<double[]>
public Side side(Arc arc)
The Side.MINUS
side of the arc is the one covered by the arc.
arc
- arc to check instance againstSide.PLUS
, Side.MINUS
, Side.BOTH
or Side.HYPER
public ArcsSet.Split split(Arc arc)
arc
- splitting arcprivate void addArcLimit(BSPTree<Sphere1D> tree, double alpha, boolean isStart)
tree
- BSP tree under constructionalpha
- arc limitisStart
- if true, the limit is the start of an arcprivate ArcsSet createSplitPart(java.util.List<java.lang.Double> limits)
As per construction, the list of limit angles is known to have an even number of entries, with start angles at even indices and end angles at odd indices.
limits
- limit angles of the split partCopyright (c) 2003-2016 Apache Software Foundation