Method used to decorate a given object (publicAPI+model) with vtkCellArray 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
ICellArrayInitialValues
No
(default: {})
extractCellSizes
Argument
Type
Required
Description
cellArray
Yes
getCell
Returns the point indices at the given location as a subarray.
Argument
Type
Required
Description
loc
Yes
getCellSizes
Get the sizes of the cells in this array.
Argument
Type
Required
Description
recompute
Boolean
No
Recompute the cell sizes.
getNumberOfCells
Argument
Type
Required
Description
cellArray
Yes
getNumberOfCells
Get the number of cells in the array.
Argument
Type
Required
Description
recompute
Boolean
No
Recompute the number of cells.
insertNextCell
Insert a cell to this array in the next available slot. This may re-allocate a new typed array if the current one is not large enough. If the final size of the array is known up-front, it is more efficient to call allocate() before calling insertNextCell() multiple times.
Argument
Type
Required
Description
cellPointIds
Array[Number]
Yes
The list of point ids (NOT prefixed with the number of points)
Returns
Type
Description
Number
Idx of where the cell was inserted
newInstance
Method used to create a new instance of vtkCellArray
/** * The inital values of a vtkCellArray. */ export interface ICellArrayInitialValuesextendsIDataArrayInitialValues { empty?: boolean; }
/** * You are NOT allowed to modify the cell array via `getData()`. * Only via `setData` or `insertNextCell` */ export interface vtkCellArray extends vtkDataArray { /** * Get the number of cells in the array. * @param {Boolean} [recompute] Recompute the number of cells. */ getNumberOfCells(recompute?: boolean): number;
/** * Get the sizes of the cells in this array. * @param {Boolean} [recompute] Recompute the cell sizes. */ getCellSizes(recompute?: boolean): any;
/** * Set the data of this array. * @param {Number[]|TypedArray} typedArray The Array value. */ setData(typedArray: number[] | TypedArray): void;
/** * Returns the point indices at the given location as a subarray. * @paramloc */ getCell(loc: any): void;
/** * Insert a cell to this array in the next available slot. * This may re-allocate a new typed array if the current one is not large enough. * If the final size of the array is known up-front, it is more efficient to call * `allocate()` before calling `insertNextCell()` multiple times. * @param {Number[]} cellPointIds The list of point ids (NOT prefixed with the number of points) * @returns {Number} Idx of where the cell was inserted */ insertNextCell(cellPointIds: number[]): number; }
/** * Method used to decorate a given object (publicAPI+model) with vtkCellArray characteristics. * * @param publicAPI object on which methods will be bounds (public) * @param model object on which data structure will be bounds (protected) * @param {ICellArrayInitialValues} [initialValues] (default: {}) */ exportfunctionextend( publicAPI: object, model: object, initialValues?: ICellArrayInitialValues ): void;
/** * Method used to create a new instance of vtkCellArray * @param {ICellArrayInitialValues} [initialValues] for pre-setting some of its content */ exportfunctionnewInstance( initialValues?: ICellArrayInitialValues ): vtkCellArray;
/** * When `resize()` is being used, you then MUST use `insertNextCell()`. * @see vtkCellArray#insertNextCell * @see vtkDataArray#allocate */ publicAPI.resize = (requestedNumTuples) => { const oldNumTuples = publicAPI.getNumberOfTuples(); superClass.resize(requestedNumTuples); const newNumTuples = publicAPI.getNumberOfTuples(); if (newNumTuples < oldNumTuples) { if (newNumTuples === 0) { model.numberOfCells = 0; model.cellSizes = []; } else { // We do not know how many cells are left. // Set to undefined to ensure insertNextCell works correctly. model.numberOfCells = undefined; model.cellSizes = undefined; } } };
publicAPI.insertNextCell = (cell) => { let cellPointIds; if (isVtkObject(cell)) { cellPointIds = cell.getPointsIds(); } else { cellPointIds = cell; } const cellId = publicAPI.getNumberOfCells(); publicAPI.insertNextTuples([cellPointIds.length, ...cellPointIds]); // By computing the number of cells earlier, we made sure that numberOfCells is defined ++model.numberOfCells; if (model.cellSizes != null) { model.cellSizes.push(cellPointIds.length); } return cellId; }; }