Interface Region<S extends Space>
- Type Parameters:
S
- Type of the space.
- All Known Implementing Classes:
AbstractRegion
,ArcsSet
,IntervalsSet
,PolygonsSet
,PolyhedronsSet
,SphericalPolygonsSet
Region are subsets of a space, they can be infinite (whole space, half space, infinite stripe ...) or finite (polygons in 2D, polyhedrons in 3D ...). Their main characteristic is to separate points that are considered to be inside the region from points considered to be outside of it. In between, there may be points on the boundary of the region.
This implementation is limited to regions for which the boundary
is composed of several sub-hyperplanes
,
including regions with no boundary at all: the whole space and the
empty region. They are not necessarily finite and not necessarily
path-connected. They can contain holes.
Regions can be combined using the traditional sets operations : union, intersection, difference and symetric difference (exclusive or) for the binary operations, complement for the unary operation.
Note that this interface is not intended to be implemented by Hipparchus users, it is only intended to be implemented within the library itself. New methods may be added even for minor versions, which breaks compatibility for external implementations.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Enumerate for the location of a point with respect to the region. -
Method Summary
Modifier and TypeMethodDescriptionBuild a region using the instance as a prototype.checkPoint
(Point<S> point) Check a point with respect to the region.boolean
Check if the instance entirely contains another region.copySelf()
Copy the instance.Get the barycenter of the instance.double
Get the size of the boundary.double
getSize()
Get the size of the instance.getTree
(boolean includeBoundaryAttributes) Get the underlying BSP tree.intersection
(SubHyperplane<S> sub) Get the parts of a sub-hyperplane that are contained in the region.boolean
isEmpty()
Check if the instance is empty.boolean
Check if the sub-tree starting at a given node is empty.boolean
isFull()
Check if the instance covers the full space.boolean
Check if the sub-tree starting at a given node covers the full space.projectToBoundary
(Point<S> point) Project a point on the boundary of the region.
-
Method Details
-
buildNew
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 constantsBoolean.TRUE
andBoolean.FALSE
. The tree also must have either null internal nodes or internal nodes representing the boundary as specified in thegetTree
method).- Parameters:
newTree
- inside/outside BSP tree representing the new region- Returns:
- the built region
-
copySelf
Copy the instance.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).- Returns:
- a new region, copy of the instance
-
isEmpty
boolean isEmpty()Check if the instance is empty.- Returns:
- true if the instance is empty
-
isEmpty
Check if the sub-tree starting at a given node is empty.- Parameters:
node
- root node of the sub-tree (must haveRegion
tree semantics, i.e. the leaf nodes must haveBoolean
attributes representing an inside/outside property)- Returns:
- true if the sub-tree starting at the given node is empty
-
isFull
boolean isFull()Check if the instance covers the full space.- Returns:
- true if the instance covers the full space
-
isFull
Check if the sub-tree starting at a given node covers the full space.- Parameters:
node
- root node of the sub-tree (must haveRegion
tree semantics, i.e. the leaf nodes must haveBoolean
attributes representing an inside/outside property)- Returns:
- true if the sub-tree starting at the given node covers the full space
-
contains
Check if the instance entirely contains another region.- Parameters:
region
- region to check against the instance- Returns:
- true if the instance contains the specified tree
-
checkPoint
Check a point with respect to the region.- Parameters:
point
- point to check- Returns:
- a code representing the point status: either
Region.Location.INSIDE
,Region.Location.OUTSIDE
orRegion.Location.BOUNDARY
-
projectToBoundary
Project a point on the boundary of the region.- Parameters:
point
- point to check- Returns:
- projection of the point on the boundary
-
getTree
Get the underlying BSP tree.Regions are represented by an underlying inside/outside BSP tree whose leaf attributes are
Boolean
instances representing inside leaf cells if the attribute value istrue
and outside leaf cells if the attribute isfalse
. 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 sub-hyperplanes may contain
BoundaryAttribute
objects representing the parts of the corresponding cut sub-hyperplane that belong to the boundary. When the boundary attributes have been computed, all internal nodes are guaranteed to have non-null attributes, however someBoundaryAttribute
instances may have theirgetPlusInside
andgetPlusOutside
methods both returning null if the corresponding cut sub-hyperplane does not have any parts belonging to the boundary.Since computing the boundary is not always required and can be time-consuming for large trees, these internal nodes attributes are computed using lazy evaluation only when required by setting the
includeBoundaryAttributes
argument totrue
. 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 theincludeBoundaryAttributes
argument.- Parameters:
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)- Returns:
- underlying BSP tree
- See Also:
-
getBoundarySize
double getBoundarySize()Get the size of the boundary.- Returns:
- the size of the boundary (this is 0 in 1D, a length in 2D, an area in 3D ...)
-
getSize
double getSize()Get the size of the instance.- Returns:
- the size of the instance (this is a length in 1D, an area in 2D, a volume in 3D ...)
-
getBarycenter
Get the barycenter of the instance.- Returns:
- an object representing the barycenter
-
intersection
Get the parts of a sub-hyperplane that are contained in the region.The parts of the sub-hyperplane that belong to the boundary are not included in the resulting parts.
- Parameters:
sub
- sub-hyperplane traversing the region- Returns:
- filtered sub-hyperplane
-