/** * 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. * @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()`. */ 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 = (cellPointIds) => { 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; }; }