Class AbstractRegion<S extends Space,P extends Point<S,P>,H extends Hyperplane<S,P,H,I>,I extends SubHyperplane<S,P,H,I>,T extends Space,Q extends Point<T,Q>,F extends Hyperplane<T,Q,F,J>,J extends SubHyperplane<T,Q,F,J>>
- java.lang.Object
-
- org.hipparchus.geometry.partitioning.AbstractRegion<S,P,H,I,T,Q,F,J>
-
- Type Parameters:
S- Type of the space.P- Type of the points in space.H- Type of the hyperplane.I- Type of the sub-hyperplane.T- Type of the sub-space.Q- Type of the points in sub-space.F- Type of the hyperplane.J- Type of the sub-hyperplane.
- All Implemented Interfaces:
Region<S,P,H,I>
- Direct Known Subclasses:
ArcsSet,IntervalsSet,PolygonsSet,PolyhedronsSet,SphericalPolygonsSet
public abstract class AbstractRegion<S extends Space,P extends Point<S,P>,H extends Hyperplane<S,P,H,I>,I extends SubHyperplane<S,P,H,I>,T extends Space,Q extends Point<T,Q>,F extends Hyperplane<T,Q,F,J>,J extends SubHyperplane<T,Q,F,J>> extends Object implements Region<S,P,H,I>
Abstract class for all regions, independently of geometry type or dimension.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hipparchus.geometry.partitioning.Region
Region.Location
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractRegion(double tolerance)Build a region representing the whole space.AbstractRegion(H[] hyperplanes, double tolerance)Build a convex region from an array of bounding hyperplanes.protectedAbstractRegion(Collection<I> boundary, double tolerance)Build a Region from a Boundary REPresentation (B-rep).protectedAbstractRegion(BSPTree<S,P,H,I> tree, double tolerance)Build a region from an inside/outside BSP tree.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AbstractRegion<S,P,H,I,T,Q,F,J>applyTransform(Transform<S,P,H,I,T,Q,F,J> transform)Transform a region.abstract AbstractRegion<S,P,H,I,T,Q,F,J>buildNew(BSPTree<S,P,H,I> newTree)Build a region using the instance as a prototype.protected Region.LocationcheckPoint(BSPTree<S,P,H,I> node, P point)Check a point with respect to the region starting at a given node.Region.LocationcheckPoint(P point)Check a point with respect to the region.protected abstract voidcomputeGeometricalProperties()Compute some geometrical properties.booleancontains(Region<S,P,H,I> region)Check if the instance entirely contains another region.AbstractRegion<S,P,H,I,T,Q,F,J>copySelf()Copy the instance.PgetBarycenter()Get the barycenter of the instance.doublegetBoundarySize()Get the size of the boundary.doublegetSize()Get the size of the instance.doublegetTolerance()Get the tolerance below which points are considered to belong to hyperplanes.BSPTree<S,P,H,I>getTree(boolean includeBoundaryAttributes)Get the underlying BSP tree.Iintersection(I sub)Get the parts of a sub-hyperplane that are contained in the region.booleanisEmpty()Check if the instance is empty.booleanisEmpty(BSPTree<S,P,H,I> node)Check if the sub-tree starting at a given node is empty.booleanisFull()Check if the instance covers the full space.booleanisFull(BSPTree<S,P,H,I> node)Check if the sub-tree starting at a given node covers the full space.BoundaryProjection<S,P>projectToBoundary(P point)Project a point on the boundary of the region.protected voidsetBarycenter(P barycenter)Set the barycenter of the instance.protected voidsetSize(double size)Set the size of the instance.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hipparchus.geometry.partitioning.Region
getInteriorPoint
-
-
-
-
Constructor Detail
-
AbstractRegion
protected AbstractRegion(double tolerance)
Build a region representing the whole space.- Parameters:
tolerance- tolerance below which points are considered identical.
-
AbstractRegion
protected AbstractRegion(BSPTree<S,P,H,I> tree, double tolerance)
Build a region from an inside/outside BSP tree.The leaf nodes of the BSP tree must have a
Booleanattribute 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.TRUEandBoolean.FALSE. The tree also must have either null internal nodes or internal nodes representing the boundary as specified in thegetTreemethod).- Parameters:
tree- inside/outside BSP tree representing the regiontolerance- tolerance below which points are considered identical.
-
AbstractRegion
protected AbstractRegion(Collection<I> boundary, double tolerance)
Build a Region 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
checkPointmethod will not be meaningful anymore.If the boundary is empty, the region will represent the whole space.
- Parameters:
boundary- collection of boundary elements, as a collection ofSubHyperplaneobjectstolerance- tolerance below which points are considered identical.
-
AbstractRegion
public AbstractRegion(H[] hyperplanes, double tolerance)
Build a convex region from an array of bounding hyperplanes.- Parameters:
hyperplanes- array of bounding hyperplanes (if null, an empty region will be built)tolerance- tolerance below which points are considered identical.
-
-
Method Detail
-
buildNew
public abstract AbstractRegion<S,P,H,I,T,Q,F,J> buildNew(BSPTree<S,P,H,I> newTree)
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
Booleanattribute 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.TRUEandBoolean.FALSE. The tree also must have either null internal nodes or internal nodes representing the boundary as specified in thegetTreemethod).
-
getTolerance
public double getTolerance()
Get the tolerance below which points are considered to belong to hyperplanes.- Returns:
- tolerance below which points are considered to belong to hyperplanes
-
copySelf
public AbstractRegion<S,P,H,I,T,Q,F,J> 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
Booleanattributes and immutable objects).
-
isEmpty
public boolean isEmpty()
Check if the instance is empty.
-
isEmpty
public boolean isEmpty(BSPTree<S,P,H,I> node)
Check if the sub-tree starting at a given node is empty.- Specified by:
isEmptyin interfaceRegion<S extends Space,P extends Point<S,P>,H extends Hyperplane<S,P,H,I>,I extends SubHyperplane<S,P,H,I>>- Parameters:
node- root node of the sub-tree (must haveRegiontree semantics, i.e. the leaf nodes must haveBooleanattributes representing an inside/outside property)- Returns:
- true if the sub-tree starting at the given node is empty
-
isFull
public boolean isFull()
Check if the instance covers the full space.
-
isFull
public boolean isFull(BSPTree<S,P,H,I> node)
Check if the sub-tree starting at a given node covers the full space.- Specified by:
isFullin interfaceRegion<S extends Space,P extends Point<S,P>,H extends Hyperplane<S,P,H,I>,I extends SubHyperplane<S,P,H,I>>- Parameters:
node- root node of the sub-tree (must haveRegiontree semantics, i.e. the leaf nodes must haveBooleanattributes representing an inside/outside property)- Returns:
- true if the sub-tree starting at the given node covers the full space
-
contains
public boolean contains(Region<S,P,H,I> region)
Check if the instance entirely contains another region.
-
projectToBoundary
public BoundaryProjection<S,P> projectToBoundary(P point)
Project a point on the boundary of the region.
-
checkPoint
public Region.Location checkPoint(P point)
Check a point with respect to the region.- Specified by:
checkPointin interfaceRegion<S extends Space,P extends Point<S,P>,H extends Hyperplane<S,P,H,I>,I extends SubHyperplane<S,P,H,I>>- Parameters:
point- point to check- Returns:
- a code representing the point status: either
Region.Location.INSIDE,Region.Location.OUTSIDEorRegion.Location.BOUNDARY
-
checkPoint
protected Region.Location checkPoint(BSPTree<S,P,H,I> node, P point)
Check a point with respect to the region starting at a given node.
-
getTree
public BSPTree<S,P,H,I> getTree(boolean includeBoundaryAttributes)
Get the underlying BSP tree.Regions are represented by an underlying inside/outside BSP tree whose leaf attributes are
Booleaninstances representing inside leaf cells if the attribute value istrueand 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
BoundaryAttributeobjects 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 someBoundaryAttributeinstances may have theirgetPlusInsideandgetPlusOutsidemethods 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
includeBoundaryAttributesargument 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 theincludeBoundaryAttributesargument.- Specified by:
getTreein interfaceRegion<S extends Space,P extends Point<S,P>,H extends Hyperplane<S,P,H,I>,I extends SubHyperplane<S,P,H,I>>- 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:
BoundaryAttribute
-
getBoundarySize
public double getBoundarySize()
Get the size of the boundary.
-
getSize
public double getSize()
Get the size of the instance.
-
setSize
protected void setSize(double size)
Set the size of the instance.- Parameters:
size- size of the instance
-
getBarycenter
public P getBarycenter()
Get the barycenter of the instance.
-
setBarycenter
protected void setBarycenter(P barycenter)
Set the barycenter of the instance.- Parameters:
barycenter- barycenter of the instance
-
computeGeometricalProperties
protected abstract void computeGeometricalProperties()
Compute some geometrical properties.The properties to compute are the barycenter and the size.
-
intersection
public I intersection(I sub)
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.
-
applyTransform
public AbstractRegion<S,P,H,I,T,Q,F,J> applyTransform(Transform<S,P,H,I,T,Q,F,J> transform)
Transform a region.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 sub-hyperplanes embedded in these hyperplanes) and to the barycenter. The instance is not modified, a new instance is built.
- Parameters:
transform- transform to apply- Returns:
- a new region, resulting from the application of the transform to the instance
-
-