vtkMergePoints is a locator object to quickly locate points in 3D.
Methods
extend
Method used to decorate a given object (publicAPI+model) with vtkMergePoints characteristics.
Argument
Type
Required
Description
publicAPI
Yes
object on which methods will be bounds (public)
model
Yes
object on which data structure will be bounds (protected)
initialValues
IMergePointsInitialValues
No
(default: {})
insertUniquePoint
Insert a point into the merge points structure. If the point is already present, it returns the existing ID. Otherwise, it inserts the point and returns a new ID.
Argument
Type
Required
Description
x
Vector3
Yes
The point to insert as an array of 3 numbers.
Returns
Type
Description
IInsertPointResult
An object indicating if the point was inserted and its ID.
isInsertedPoint
Check if a point is already inserted in the merge points structure.
Argument
Type
Required
Description
x
Vector3
Yes
The point to check.
Returns
Type
Description
Number
The ID of the point if it exists, otherwise -1.
newInstance
Method used to create a new instance of vtkMergePoints.
export interface vtkMergePoints extends vtkPointLocator { /** * Check if a point is already inserted in the merge points structure. * * @param {Vector3} x The point to check. * @returns {Number} The ID of the point if it exists, otherwise -1. */ isInsertedPoint(x: Vector3): number;
/** * Insert a point into the merge points structure. * If the point is already present, it returns the existing ID. * Otherwise, it inserts the point and returns a new ID. * * @param {Vector3} x The point to insert as an array of 3 numbers. * @returns {IInsertPointResult} An object indicating if the point was inserted and its ID. */ insertUniquePoint(x: Vector3): IInsertPointResult; }
/** * Method used to decorate a given object (publicAPI+model) with vtkMergePoints characteristics. * * @param publicAPI object on which methods will be bounds (public) * @param model object on which data structure will be bounds (protected) * @param {IMergePointsInitialValues} [initialValues] (default: {}) */ exportfunctionextend( publicAPI: object, model: object, initialValues?: IMergePointsInitialValues ): void;
/** * Method used to create a new instance of vtkMergePoints. * @param {IMergePointsInitialValues} [initialValues] for pre-setting some of its content */ exportfunctionnewInstance( initialValues?: IMergePointsInitialValues ): vtkMergePoints;
/** * vtkMergePoints merge exactly coincident points. * * vtkMergePoints is a locator object to quickly locate points in 3D. */ export declare constvtkMergePoints: { newInstance: typeof newInstance; extend: typeof extend; }; exportdefault vtkMergePoints;
/** * Search for a point in the array using indices from bucketIds * @param {Number[]} bucketIds - The list of point IDs in the bucket. * @param {vtkPoints} points - The vtkPoints object containing the points. * @param {Vector3} x - The point to check. * @returns {Number} - The ID of the point if it exists, otherwise -1. */ functionfindPointInBucket(bucketIds, points, x) { const data = points.getData(); for (let i = 0; i < bucketIds.length; ++i) { const ptId = bucketIds[i]; const idx = ptId * 3; if ( x[0] === data[idx] && x[1] === data[idx + 1] && x[2] === data[idx + 2] ) { return ptId; } } return -1; }
functionvtkMergePoints(publicAPI, model) { // Set our className model.classHierarchy.push('vtkMergePoints');
/** * Check if a point is already inserted in the merge points structure. * * @param {Vector3} x The point to check. * @returns {Number} The ID of the point if it exists, otherwise -1. */ publicAPI.isInsertedPoint = (x) => { const idx = publicAPI.getBucketIndex(x); const bucketIds = model.hashTable.get(idx); if (bucketIds) { returnfindPointInBucket(bucketIds, model.points, x); } return -1; };
/** * Insert a point into the merge points structure. * If the point is already present, it returns the existing ID. * Otherwise, it inserts the point and returns a new ID. * * @param {Vector3} x The point to insert as an array of 3 numbers. * @returns {IInsertPointResult} An object indicating if the point was inserted and its ID. */ publicAPI.insertUniquePoint = (x) => { if (!x || x.length !== 3) { vtkErrorMacro('Point must be a Vector3.'); return { inserted: false, id: -1 }; }
const idx = publicAPI.getBucketIndex(x); let bucketIds = model.hashTable.get(idx); let id = null;
if (bucketIds !== undefined) { const ptId = findPointInBucket(bucketIds, model.points, x); if (ptId !== -1) { id = ptId; return { inserted: false, id }; } } else { bucketIds = []; model.hashTable.set(idx, bucketIds); }
// Insert new point bucketIds.push(model.insertionPointId); model.points.insertNextPoint(...x); id = model.insertionPointId++; return { inserted: true, id }; }; }