Skip to content

PointLocator ​

Introduction ​

vtkPointLocator is a spatial search object to quickly locate points in 3D.

vtkPointLocator works by dividing a specified region of space into a regular array of "rectangular" buckets, and then keeping a list of points that lie in each bucket. Typical operation involves giving a position in 3D and finding the closest point.

vtkPointLocator has two distinct methods of interaction. In the first method, you supply it with a dataset, and it operates on the points in the dataset. In the second method, you supply it with an array of points, and the object operates on the array.

Methods ​

extend ​

Method use to decorate a given object (publicAPI+model) with vtkPointLocator characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesobjectNo(default: {})

findClosestInsertedPoint ​

Find the closest inserted point to the given coordinates.

ArgumentTypeRequiredDescription
xVector3YesThe query point

Returns ​

TypeDescription
NumberThe id of the closest inserted point or -1 if not found

findClosestPoint ​

Find the closest point to a given point.

ArgumentTypeRequiredDescription
xVector3YesThe point coordinates

Returns ​

TypeDescription
The id of the closest point or -1 if not found

findClosestPointWithinRadius ​

Find the closest point within a specified radius.

ArgumentTypeRequiredDescription
radiusNumberYesThe search radius
xVector3YesThe point coordinates
inputDataLengthNumberYesThe length of the input data

Returns ​

TypeDescription
IFindClosestPointResultThe closest point result

freeSearchStructure ​

Free the search structure and reset the locator.

generateRepresentation ​

Generate a polydata representation of the point locator.

ArgumentTypeRequiredDescription
polydatavtkPolyDataYesThe polydata to generate representation for

Returns ​

TypeDescription

getNumberOfPointsPerBucket ​

Get the number of points per bucket.

Returns ​

TypeDescription
NumberThe number of points per bucket.

getPoints ​

Get the points stored in the point locator.

Returns ​

TypeDescription
Nullable<vtkPoints>The vtkPoints object containing the points.

getPointsInBucket ​

Get the points in the specified bucket.

ArgumentTypeRequiredDescription
xVector3YesThe point coordinates

Returns ​

TypeDescription
Array[Number]The points in the bucket

initPointInsertion ​

Initialize point insertion.

ArgumentTypeRequiredDescription
pointsvtkPointsYesThe points to insert
boundsBoundsYesThe bounds for the points
estNumPtsNumberYesEstimated number of points for insertion

insertNextPoint ​

Insert a point into the point locator. If the point is already present, it returns the existing ID. Otherwise, it inserts the point and returns a new ID.

ArgumentTypeRequiredDescription
xVector3YesThe point to insert.

Returns ​

TypeDescription
IInsertPointResultAn object indicating if the point was inserted and its ID.

insertPoint ​

Insert a point into the point locator. If the point is already present, it returns the existing ID. Otherwise, it inserts the point and returns a new ID.

ArgumentTypeRequiredDescription
ptIdNumberYesThe index of the point to insert.
xVector3YesThe point to insert.

Returns ​

TypeDescription
IInsertPointResultAn object indicating if the point was inserted and its ID.

insertUniquePoint ​

Insert a point into the point locator. If the point is already present, it returns the existing ID. Otherwise, it inserts the point and returns a new ID.

ArgumentTypeRequiredDescription
xVector3YesThe point to insert.

Returns ​

TypeDescription
IInsertPointResultAn object indicating if the point was inserted and its ID.

isInsertedPoint ​

Check if a point is already inserted in the point locator.

ArgumentTypeRequiredDescription
xVector3YesThe point to check.

Returns ​

TypeDescription
NumberThe ID of the point if it exists, otherwise -1.

newInstance ​

Method use to create a new instance of vtkPointLocator

ArgumentTypeRequiredDescription
initialValuesIPointLocatorInitialValuesNofor pre-setting some of its content

setDivisions ​

Set the divisions of the point locator.

ArgumentTypeRequiredDescription
xNumberYesThe number of divisions in the x dimension.
yNumberYesThe number of divisions in the y dimension.
zNumberYesThe number of divisions in the z dimension.

Returns ​

TypeDescription
BooleanTrue if the divisions were set successfully, false otherwise.

setDivisions ​

Set the divisions of the point locator.

ArgumentTypeRequiredDescription
divisionsVector3YesThe number of divisions in each dimension.

Returns ​

TypeDescription
BooleanTrue if the divisions were set successfully, false otherwise.

setNumberOfPointsPerBucket ​

Set the number of points per bucket.

ArgumentTypeRequiredDescription
numberOfPointsPerBucketNumberYesThe number of points per bucket.

setPoints ​

Set the points for this point locator. This is typically used to initialize the locator with a set of points.

ArgumentTypeRequiredDescription
pointsvtkPointsYesThe vtkPoints object containing the points.