EnclosingSimplexAlgorithm¶
- class EnclosingSimplexAlgorithm(*args)¶
Point location algorithm.
Base class to define an algorithm to find simplices containing a list of points.
- Available constructors:
EnclosingSimplexAlgorithm(vertices, simplices)
- Parameters:
- vertices
Sample
Vertices.
- simplices
IndicesCollection
Simplices.
- vertices
See also
Notes
Two algorithms can be selected in any dimension:
NaiveEnclosingSimplex
loops over all simplices and stops when the given point is inside.BoundingVolumeHierarchy
builds a binary tree based on bounding box of simplices.
Two algorithms are specific to 1D meshes, and much more efficient:
RegularGridEnclosingSimplex
is the most efficient algorithm when mesh corresponds to aRegularGrid
,query()
works in constant time.EnclosingSimplexMonotonic1D
looks for enclosing simplex by dichotomy, it only works for sorted 1D meshes.
It is recommended to use derived classes in order to select the best algorithm according to your data. If you create a generic
EnclosingSimplexAlgorithm
, here is how the derived class is selected:If vertices and simplices correspond to a
RegularGrid
,RegularGridEnclosingSimplex
algorithm is selected.If vertices and simplices correspond to a simple 1D mesh with sorted vertices,
EnclosingSimplexMonotonic1D
algorithm is selected.Otherwise, ‘EnclosingSimplexAlgorithm-LargeDimension’
ResourceMap
entry is read. If input dimension is lower than this value,BoundingVolumeHierarchy
algorithm is chosen, otherwise it isNaiveEnclosingSimplex
.
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.EnclosingSimplexAlgorithm(mesh.getVertices(), mesh.getSimplices()) >>> simplex = locator.query([0.1, 0.2])
Methods
Accessor to the object's name.
getId
()Accessor to the object's id.
Accessor to the underlying implementation.
getName
()Accessor to the object's name.
query
(*args)Get the index of the enclosing simplex of the given point.
setName
(name)Accessor to the object's name.
setVerticesAndSimplices
(vertices, simplices)Rebuild a new data structure for these vertices and simplices.
getSimplices
getVertices
- __init__(*args)¶
- getClassName()¶
Accessor to the object’s name.
- Returns:
- class_namestr
The object class name (object.__class__.__name__).
- getId()¶
Accessor to the object’s id.
- Returns:
- idint
Internal unique identifier.
- getImplementation()¶
Accessor to the underlying implementation.
- Returns:
- implImplementation
A copy of the underlying implementation object.
- getName()¶
Accessor to the object’s name.
- Returns:
- namestr
The name of the object.
- 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.
- indices
Indices
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.
- 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:
- vertices
Sample
Vertices.
- simplices
IndicesCollection
Simplices.
- vertices