Skip to content

Commit c4cd8cc

Browse files
David Bergerfinetjul
authored andcommitted
feat(Core): Various additions to core functionalities
CellArray - Implemented insertNextCell - Implemented initialize - getNumberOfCells and getCellSizes now use publicAPI.getData() instead of model.values DataArray - Implemented getValue and setValue - Implemented insertTuple - Implemented insertNextTuple - Implemented deepCopy - Implemented interpolateTuple - getRange now uses publicAPI.getData() instead of model.values - getNumberOfValues and getNumberOfTuples now use model.size instead of model.values.length - model.size defaults to model.values.length if not specified during initialization Points - Implemented insertNextPoint - Added tests FieldData - Implemented interpolateData - Changes to passData and a bugfix - addArray now checks if an array with the given name already exists and replaces it in that case. DataSetAttributes - Implemented getAttributes - Implemented copyScalarsOn - Implemented copyVectorsOn - Implemented copyNormalsOn - Implemented copyTCoordsOn - Implemented copyTensorsOn - Implemented copyGlobalIdsOn - Implemented copyPedigreeIdsOn Co-authored-by: Julien Finet <[email protected]>
1 parent 19c26e8 commit c4cd8cc

File tree

9 files changed

+208
-326
lines changed

9 files changed

+208
-326
lines changed
Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,49 @@
1-
import { TypedArray } from "../../../types";
2-
import vtkDataArray, { IDataArrayInitialValues } from "../../Core/DataArray";
3-
1+
import { TypedArray } from '../../../types';
2+
import vtkDataArray, { IDataArrayInitialValues } from '../../Core/DataArray';
43

54
/**
65
* The inital values of a vtkCellArray.
76
*/
87
export interface ICellArrayInitialValues extends IDataArrayInitialValues {
9-
empty?: boolean;
8+
empty?: boolean;
109
}
1110

1211
export interface vtkCellArray extends vtkDataArray {
12+
/**
13+
* Get the number of cells in the array.
14+
* @param {Boolean} [recompute] Recompute the number of cells.
15+
*/
16+
getNumberOfCells(recompute?: boolean): number;
1317

14-
/**
15-
* Get the number of cells in the array.
16-
* @param {Boolean} [recompute] Recompute the number of cells.
17-
*/
18-
getNumberOfCells(recompute?: boolean): number;
19-
20-
/**
21-
* Get the sizes of the cells in this array.
22-
* @param {Boolean} [recompute] Recompute the cell sizes.
23-
*/
24-
getCellSizes(recompute?: boolean): any;
18+
/**
19+
* Get the sizes of the cells in this array. Get the sizes of the cells in this array.
20+
* @param {Boolean} [recompute] Recompute the cell sizes.
21+
*/
22+
getCellSizes(recompute?: boolean): any;
2523

26-
/**
27-
* Set the data of this array.
28-
* @param {TypedArray} typedArray The Array value.
29-
*/
30-
setData(typedArray: TypedArray): void;
24+
/**
25+
* Set the data of this array.
26+
* @param {TypedArray} typedArray The typedArray value.
27+
*/
28+
setData(typedArray: TypedArray): void;
3129

32-
/**
33-
* Returns the point indices at the given location as a subarray.
34-
* @param loc
35-
*/
36-
getCell(loc: any): void;
30+
/**
31+
* Returns the point indices at the given location as a subarray.
32+
* @param loc
33+
*/
34+
getCell(loc: any): void;
3735

38-
/**
39-
* Reset the cell array by setting the number of cells to 0.
40-
* NOTE: This won't touch the actual memory of the underlying typedArray.
41-
*/
42-
initialize(): void;
36+
/**
37+
* Reset this array.
38+
* NOTE: This won't touch the actual memory of the underlying typedArray.
39+
*/
40+
initialize(): void;
4341

44-
/**
45-
* Insert a cell to this array in the next available slot.
46-
* @param {Number[]} cellPointIds The list of point ids (NOT prefixed with the number of points)
47-
* @returns {Number} Idx of where the cell was inserted
48-
*/
49-
insertNextCell(cellPointIds: number[]): number;
42+
/**
43+
* Insert a cell to this array in the next available slot.
44+
* @param {Number[]} cellPoinIds
45+
*/
46+
insertNextCell(cellPoinIds: Number[]): void;
5047
}
5148

5249
/**
@@ -56,37 +53,42 @@ export interface vtkCellArray extends vtkDataArray {
5653
* @param model object on which data structure will be bounds (protected)
5754
* @param {ICellArrayInitialValues} [initialValues] (default: {})
5855
*/
59-
export function extend(publicAPI: object, model: object, initialValues?: ICellArrayInitialValues): void;
56+
export function extend(
57+
publicAPI: object,
58+
model: object,
59+
initialValues?: ICellArrayInitialValues
60+
): void;
6061

6162
/**
6263
* Method used to create a new instance of vtkCellArray
6364
* @param {ICellArrayInitialValues} [initialValues] for pre-setting some of its content
6465
*/
65-
export function newInstance(initialValues?: ICellArrayInitialValues): vtkCellArray;
66-
66+
export function newInstance(
67+
initialValues?: ICellArrayInitialValues
68+
): vtkCellArray;
6769

6870
/**
6971
* @static
7072
* @param cellArray
7173
*/
7274
export function extractCellSizes(cellArray: any): any;
7375

74-
/**
75-
* @static
76-
* @param cellArray
77-
*/
76+
/**
77+
* @static
78+
* @param cellArray
79+
*/
7880
export function getNumberOfCells(cellArray: any): any;
7981

8082
/**
8183
* vtkCellArray stores dataset topologies as an explicit connectivity table
8284
* listing the point ids that make up each cell.
83-
*
85+
*
8486
* @see [vtkDataArray](./Common_Core_DataArray.html)
8587
*/
8688
export declare const vtkCellArray: {
87-
newInstance: typeof newInstance;
88-
extend: typeof extend;
89-
extractCellSizes: typeof extractCellSizes;
90-
getNumberOfCells: typeof getNumberOfCells;
91-
}
89+
newInstance: typeof newInstance;
90+
extend: typeof extend;
91+
extractCellSizes: typeof extractCellSizes;
92+
getNumberOfCells: typeof getNumberOfCells;
93+
};
9294
export default vtkCellArray;

Sources/Common/Core/CellArray/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,17 @@ function vtkCellArray(publicAPI, model) {
8181
const superInitialize = publicAPI.initialize;
8282
publicAPI.initialize = () => {
8383
superInitialize();
84-
// Set to undefined to ensure insertNextCell works correctly
8584
model.numberOfCells = undefined;
8685
model.cellSizes = undefined;
8786
};
8887

8988
publicAPI.insertNextCell = (cellPointIds) => {
9089
const cellId = publicAPI.getNumberOfCells();
91-
publicAPI.insertNextTuples([cellPointIds.length, ...cellPointIds]);
92-
// By computing the number of cells earlier, we made sure that numberOfCells is defined
90+
const numberOfPoints = cellPointIds.length;
91+
publicAPI.insertNextTuple([numberOfPoints]);
92+
for (let i = 0; i < numberOfPoints; ++i) {
93+
publicAPI.insertNextTuple([cellPointIds[i]]);
94+
}
9395
++model.numberOfCells;
9496
if (model.cellSizes != null) {
9597
model.cellSizes.push(cellPointIds.length);

0 commit comments

Comments
 (0)