BoundingVolumeHierarchy

class BoundingVolumeHierarchy(*args)

Bounding Volume Hierarchy to speed-up point location.

This spatial data structure helps to find the simplex containing a given point.

Parameters:
points2-d sequence of float

Points.

simplicesIndicesCollection

Simplices.

binNumberint, optional

Maximum number of simplices stored in tree leaves. By default, it is equal to the value defined through the key BoundingVolumeHierarchy-BinNumber of the ResourceMap.

strategystr, optional

Node splitting strategy. Valid values are: Mean and Median. By default, it is equal to the value defined through the key BoundingVolumeHierarchy-Strategy of the ResourceMap (Mean).

Examples

>>> import openturns as ot
>>> mesher = ot.IntervalMesher([5, 10])
>>> lowerbound = [0.0, 0.0]
>>> upperBound = [2.0, 4.0]
>>> interval = ot.Interval(lowerbound, upperBound)
>>> mesh = mesher.build(interval)
>>> locator = ot.BoundingVolumeHierarchy(mesh.getVertices(), mesh.getSimplices())
>>> simplex = locator.query([0.1, 0.2])

Methods

getBarycentricCoordinatesEpsilon()

Accessor to the tolerance for membership test.

getClassName()

Accessor to the object's name.

getName()

Accessor to the object's name.

getSimplices()

Collection of simplex accessor.

getVertices()

Collection of vertices accessor.

hasName()

Test if the object is named.

query(*args)

Get the index of the enclosing simplex of the given point.

setBarycentricCoordinatesEpsilon(epsilon)

Accessor to the tolerance for membership test.

setName(name)

Accessor to the object's name.

setVerticesAndSimplices(vertices, simplices)

Rebuild a new data structure for these vertices and simplices.

__init__(*args)
getBarycentricCoordinatesEpsilon()

Accessor to the tolerance for membership test.

Returns:
epsilonfloat

Tolerance for the membership. A point is in a simplex if its barycentric coordinates \xi_i are all in [-\varepsilon,1+\varepsilon] and \sum_{i=1}^d\xi_i\in[-\varepsilon,1+\varepsilon].

getClassName()

Accessor to the object’s name.

Returns:
class_namestr

The object class name (object.__class__.__name__).

getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

getSimplices()

Collection of simplex accessor.

Returns:
simplicesIndicesCollection

Collection of simplices.

getVertices()

Collection of vertices accessor.

Returns:
verticesSample

Collection of points.

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

query(*args)

Get the index of the enclosing simplex of the given point.

Available usages:

query(point)

query(sample)

Parameters:
pointsequence of float

Given point.

sample2-d sequence of float

Given points.

Returns:
indexint

If point is enclosed in a simplex, return its index; otherwise return an int which is at least greater than the number of simplices.

indicesIndices

Index of enclosing simplex of each point of the sample. If there is no enclosing simplex, value is an int which is at least greater than the number of simplices.

setBarycentricCoordinatesEpsilon(epsilon)

Accessor to the tolerance for membership test.

Parameters:
epsilonfloat

Tolerance for the membership. A point is in a simplex if its barycentric coordinates \xi_i are all in [-\varepsilon,1+\varepsilon] and \sum_{i=1}^d\xi_i\in[-\varepsilon,1+\varepsilon].

setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

setVerticesAndSimplices(vertices, simplices)

Rebuild a new data structure for these vertices and simplices.

Parameters:
verticesSample

Vertices.

simplicesIndicesCollection

Simplices.