S
 Type of the space.T
 Type of the subspace.public abstract class AbstractRegion<S extends Space,T extends Space> extends Object implements Region<S>
Region.Location
Modifier  Constructor and Description 

protected 
AbstractRegion(BSPTree<S> tree,
double tolerance)
Build a region from an inside/outside BSP tree.

protected 
AbstractRegion(Collection<SubHyperplane<S>> boundary,
double tolerance)
Build a Region from a Boundary REPresentation (Brep).

protected 
AbstractRegion(double tolerance)
Build a region representing the whole space.


AbstractRegion(Hyperplane<S>[] hyperplanes,
double tolerance)
Build a convex region from an array of bounding hyperplanes.

Modifier and Type  Method and Description 

AbstractRegion<S,T> 
applyTransform(Transform<S,T> transform)
Transform a region.

abstract AbstractRegion<S,T> 
buildNew(BSPTree<S> newTree)
Build a region using the instance as a prototype.

protected Region.Location 
checkPoint(BSPTree<S> node,
Point<S> point)
Check a point with respect to the region starting at a given node.

protected Region.Location 
checkPoint(BSPTree<S> node,
Vector<S> point)
Check a point with respect to the region starting at a given node.

Region.Location 
checkPoint(Point<S> point)
Check a point with respect to the region.

Region.Location 
checkPoint(Vector<S> point)
Check a point with respect to the region.

protected abstract void 
computeGeometricalProperties()
Compute some geometrical properties.

boolean 
contains(Region<S> region)
Check if the instance entirely contains another region.

AbstractRegion<S,T> 
copySelf()
Copy the instance.

Point<S> 
getBarycenter()
Get the barycenter of the instance.

double 
getBoundarySize()
Get the size of the boundary.

double 
getSize()
Get the size of the instance.

double 
getTolerance()
Get the tolerance below which points are considered to belong to hyperplanes.

BSPTree<S> 
getTree(boolean includeBoundaryAttributes)
Get the underlying BSP tree.

SubHyperplane<S> 
intersection(SubHyperplane<S> sub)
Get the parts of a subhyperplane that are contained in the region.

boolean 
isEmpty()
Check if the instance is empty.

boolean 
isEmpty(BSPTree<S> node)
Check if the subtree starting at a given node is empty.

boolean 
isFull()
Check if the instance covers the full space.

boolean 
isFull(BSPTree<S> node)
Check if the subtree starting at a given node covers the full space.

BoundaryProjection<S> 
projectToBoundary(Point<S> point)
Project a point on the boundary of the region.

protected void 
setBarycenter(Point<S> barycenter)
Set the barycenter of the instance.

protected void 
setBarycenter(Vector<S> barycenter)
Set the barycenter of the instance.

protected void 
setSize(double size)
Set the size of the instance.

Side 
side(Hyperplane<S> hyperplane)
Deprecated.

protected AbstractRegion(double tolerance)
tolerance
 tolerance below which points are considered identical.protected AbstractRegion(BSPTree<S> tree, double tolerance)
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).
tree
 inside/outside BSP tree representing the regiontolerance
 tolerance below which points are considered identical.protected AbstractRegion(Collection<SubHyperplane<S>> boundary, double tolerance)
The boundary is provided as a collection of subhyperplanes
. Each subhyperplane 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 nonconnected 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 elements, as a
collection of SubHyperplane
objectstolerance
 tolerance below which points are considered identical.public AbstractRegion(Hyperplane<S>[] hyperplanes, double tolerance)
hyperplanes
 array of bounding hyperplanes (if null, an
empty region will be built)tolerance
 tolerance below which points are considered identical.public abstract AbstractRegion<S,T> buildNew(BSPTree<S> newTree)
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).
public double getTolerance()
public AbstractRegion<S,T> copySelf()
The instance created is completely independant of the original
one. A deep copy is used, none of the underlying objects are
shared (except for the underlying tree Boolean
attributes and immutable objects).
public boolean isEmpty()
public boolean isEmpty(BSPTree<S> node)
public boolean isFull()
public boolean isFull(BSPTree<S> node)
isFull
in interface Region<S extends Space>
node
 root node of the subtree (must have Region
tree semantics, i.e. the leaf nodes must have
Boolean
attributes representing an inside/outside
property)public boolean contains(Region<S> region)
public BoundaryProjection<S> projectToBoundary(Point<S> point)
projectToBoundary
in interface Region<S extends Space>
point
 point to checkpublic Region.Location checkPoint(Vector<S> point)
point
 point to checkRegion.Location.INSIDE
, Region.Location.OUTSIDE
or
Region.Location.BOUNDARY
public Region.Location checkPoint(Point<S> point)
checkPoint
in interface Region<S extends Space>
point
 point to checkRegion.Location.INSIDE
, Region.Location.OUTSIDE
or Region.Location.BOUNDARY
protected Region.Location checkPoint(BSPTree<S> node, Vector<S> point)
protected Region.Location checkPoint(BSPTree<S> node, Point<S> point)
public BSPTree<S> getTree(boolean includeBoundaryAttributes)
Regions are represented by an underlying inside/outside BSP
tree whose leaf attributes are Boolean
instances
representing inside leaf cells if the attribute value is
true
and outside leaf cells if the attribute is
false
. These leaf attributes are always present and
guaranteed to be non null.
In addition to the leaf attributes, the internal nodes which
correspond to cells split by cut subhyperplanes may contain
BoundaryAttribute
objects representing
the parts of the corresponding cut subhyperplane that belong to
the boundary. When the boundary attributes have been computed,
all internal nodes are guaranteed to have nonnull
attributes, however some BoundaryAttribute
instances may have their getPlusInside
and getPlusOutside
methods both
returning null if the corresponding cut subhyperplane does not
have any parts belonging to the boundary.
Since computing the boundary is not always required and can be
timeconsuming for large trees, these internal nodes attributes
are computed using lazy evaluation only when required by setting
the includeBoundaryAttributes
argument to
true
. Once computed, these attributes remain in the
tree, which implies that in this case, further calls to the
method for the same region will always include these attributes
regardless of the value of the
includeBoundaryAttributes
argument.
getTree
in interface Region<S extends Space>
includeBoundaryAttributes
 if true, the boundary attributes
at internal nodes are guaranteed to be included (they may be
included even if the argument is false, if they have already been
computed due to a previous call)BoundaryAttribute
public double getBoundarySize()
getBoundarySize
in interface Region<S extends Space>
public double getSize()
protected void setSize(double size)
size
 size of the instancepublic Point<S> getBarycenter()
getBarycenter
in interface Region<S extends Space>
protected void setBarycenter(Vector<S> barycenter)
barycenter
 barycenter of the instanceprotected void setBarycenter(Point<S> barycenter)
barycenter
 barycenter of the instanceprotected abstract void computeGeometricalProperties()
The properties to compute are the barycenter and the size.
@Deprecated public Side side(Hyperplane<S> hyperplane)
side
in interface Region<S extends Space>
hyperplane
 reference hyperplaneSide.PLUS
, Side.MINUS
, Side.BOTH
or Side.HYPER
(the latter result can occur only if the tree
contains only one cut hyperplane)public SubHyperplane<S> intersection(SubHyperplane<S> sub)
The parts of the subhyperplane that belong to the boundary are not included in the resulting parts.
intersection
in interface Region<S extends Space>
sub
 subhyperplane traversing the regionpublic AbstractRegion<S,T> applyTransform(Transform<S,T> transform)
Applying a transform to a region consist in applying the transform to all the hyperplanes of the underlying BSP tree and of the boundary (and also to the subhyperplanes embedded in these hyperplanes) and to the barycenter. The instance is not modified, a new instance is built.
transform
 transform to applyCopyright © 2003–2015 The Apache Software Foundation. All rights reserved.