org.apache.commons.math3.geometry.euclidean.oned

## Class IntervalsSet

- java.lang.Object
- - org.apache.commons.math3.geometry.partitioning.AbstractRegion<Euclidean1D,Euclidean1D>
  - - org.apache.commons.math3.geometry.euclidean.oned.IntervalsSet

All Implemented Interfaces:
  Region<Euclidean1D>

    public class IntervalsSet
    extends AbstractRegion<Euclidean1D,Euclidean1D>

This class represents a 1D region: a set of intervals.

Since:
  3.0
Version:
  $Id: IntervalsSet.java 1416643 2012-12-03 19:37:14Z tn $

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.commons.math3.geometry.partitioning.Region

`Region.Location`

### Constructor Summary

Constructors
Constructor and Description
`IntervalsSet()` Build an intervals set representing the whole real line.
`IntervalsSet(BSPTree<Euclidean1D> tree)` Build an intervals set from an inside/outside BSP tree.
`IntervalsSet(java.util.Collection<SubHyperplane<Euclidean1D>> boundary)` Build an intervals set from a Boundary REPresentation (B-rep).
`IntervalsSet(double lower, double upper)` Build an intervals set corresponding to a single interval.

### Method Summary

Methods
`java.util.List<Interval>` `asList()` Build an ordered list of intervals representing the instance.
`IntervalsSet` `buildNew(BSPTree<Euclidean1D> tree)` Build a region using the instance as a prototype.
`private static BSPTree<Euclidean1D>` `buildTree(double lower, double upper)` Build an inside/outside tree representing a single interval.
`protected void` `computeGeometricalProperties()` Compute some geometrical properties.
`double` `getInf()` Get the lowest value belonging to the instance.
`double` `getSup()` Get the highest value belonging to the instance.
`private void` `recurseList(BSPTree<Euclidean1D> node, java.util.List<Interval> list, double lower, double upper)` Update an intervals list.

### Methods inherited from class org.apache.commons.math3.geometry.partitioning.AbstractRegion

`applyTransform, checkPoint, checkPoint, contains, copySelf, getBarycenter, getBoundarySize, getSize, getTree, intersection, isEmpty, isEmpty, setBarycenter, setSize, side`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### IntervalsSet

    public IntervalsSet()

Build an intervals set representing the whole real line.

#### IntervalsSet

    public IntervalsSet(double lower,
                double upper)

Build an intervals set corresponding to a single interval.

Parameters:
  `lower` - lower bound of the interval, must be lesser or equal to `upper` (may be `Double.NEGATIVE_INFINITY`)
  `upper` - upper bound of the interval, must be greater or equal to `lower` (may be `Double.POSITIVE_INFINITY`)

#### IntervalsSet

    public IntervalsSet(BSPTree<Euclidean1D> tree)

Build an intervals set from an inside/outside BSP tree.

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`

Parameters:
  `tree` - inside/outside BSP tree representing the intervals set

#### IntervalsSet

    public IntervalsSet(java.util.Collection<SubHyperplane<Euclidean1D>> boundary)

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

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.

Parameters:
  `boundary` - collection of boundary elements

### Method Detail

#### buildTree

    private static BSPTree<Euclidean1D> buildTree(double lower,
                                 double upper)

Build an inside/outside tree representing a single interval.

Parameters:
  `lower` - lower bound of the interval, must be lesser or equal to `upper` (may be `Double.NEGATIVE_INFINITY`)
  `upper` - upper bound of the interval, must be greater or equal to `lower` (may be `Double.POSITIVE_INFINITY`)
Returns:
  the built tree

#### buildNew

    public IntervalsSet buildNew(BSPTree<Euclidean1D> tree)

Build a region using the instance as a prototype.

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).

Specified by:
  `buildNew` in interface `Region<Euclidean1D>`
Specified by:
  `buildNew` in class `AbstractRegion<Euclidean1D,Euclidean1D>`
Parameters:
  `tree` - inside/outside BSP tree representing the new region
Returns:
  the built region

#### computeGeometricalProperties

    protected void computeGeometricalProperties()

Compute some geometrical properties.

The properties to compute are the barycenter and the size.

Specified by:
  `computeGeometricalProperties` in class `AbstractRegion<Euclidean1D,Euclidean1D>`

#### getInf

    public double getInf()

Get the lowest value belonging to the instance.

Returns:
  lowest value belonging to the instance (`Double.NEGATIVE_INFINITY` if the instance doesn't have any low bound, `Double.POSITIVE_INFINITY` if the instance is empty)

#### getSup

    public double getSup()

Get the highest value belonging to the instance.

Returns:
  highest value belonging to the instance (`Double.POSITIVE_INFINITY` if the instance doesn't have any high bound, `Double.NEGATIVE_INFINITY` if the instance is empty)

#### asList

    public java.util.List<Interval> asList()

Build an ordered list of intervals representing the instance.

This method builds this intervals set as an ordered list of `Interval` elements. If the intervals set has no lower limit, the first interval will have its low bound equal to `Double.NEGATIVE_INFINITY`. If the intervals set has no upper limit, the last interval will have its upper bound equal to `Double.POSITIVE_INFINITY`. An empty tree will build an empty list while a tree representing the whole real line will build a one element list with both bounds beeing infinite.

Returns:
  a new ordered list containing `Interval` elements

#### recurseList

    private void recurseList(BSPTree<Euclidean1D> node,
                   java.util.List<Interval> list,
                   double lower,
                   double upper)

Update an intervals list.

Parameters:
  `node` - current node
  `list` - list to update
  `lower` - lower bound of the current convex cell
  `upper` - upper bound of the current convex cell