Skip to content

Commit

Permalink
fix(Cell): Remove dataType optimization and fix setData usage and doc
Browse files Browse the repository at this point in the history
There was a risk for a mismatch between dataType and the type of values
  • Loading branch information
finetjul committed Aug 27, 2019
1 parent b7f3960 commit d0585a4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
4 changes: 1 addition & 3 deletions Sources/Common/Core/DataArray/index.js
Expand Up @@ -303,9 +303,7 @@ export function extend(publicAPI, model, initialValues = {}) {

if (model.values) {
model.size = model.values.length;
if (!initialValues.dataType) {
model.dataType = getDataType(model.values);
}
model.dataType = getDataType(model.values);
}

// Object methods
Expand Down
12 changes: 6 additions & 6 deletions Sources/Common/DataModel/Cell/api.md
Expand Up @@ -8,18 +8,18 @@ vtkCell is an abstract method to define a cell
Initialize the cell with point coordinates and cell point ids, example :
```js
const points = vtkPoints.newInstance();
points.setData([0, 0, 0, 0, 0, 1, ..., 255, 255, 255]);
const cellPointsIds = [13, 10, 235];
points.setData(Float32Array.from([0, 0, 0, 0, 0, 1, ..., 255, 255, 255]));
const pointIdsList = [13, 10, 235];
// Create cell
const triangle = vtkTriangle.newInstance();
// Initialize cell
triangle.initialize(points, cellPointsIds);
triangle.initialize(points, pointIdsList);
```
If pointsIds is null, points are shallow copied and pointsIds is
If pointIdsList is null, points are shallow copied and pointIdsList is
generated as such: [0, 1, ..., N-1] where N is the number of points.
If pointsIds is not null, only cellPointsIds point coordinates are copied
If pointIdsList is not null, only pointIdsList point coordinates are copied
into the cell.
cellPointsIds is shallow copied.
pointIdsList is shallow copied.

### getBounds()
Return the bounds of the cell
Expand Down
2 changes: 1 addition & 1 deletion Sources/Common/DataModel/Line/test/testLine.js
Expand Up @@ -104,7 +104,7 @@ test('Test vtkLine intersectWithLine', (t) => {

const points = vtkPoints.newInstance();
points.setNumberOfPoints(3); // only first 2 points are considered
points.setData([0, 0, 0, 1, 0, 0, 1, 1, 0]);
points.setData(Float32Array.from([0, 0, 0, 1, 0, 0, 1, 1, 0]));
// Add points
const line = vtkLine.newInstance();
line.initialize(points);
Expand Down
4 changes: 2 additions & 2 deletions Sources/Common/DataModel/Triangle/test/testTriangle.js
Expand Up @@ -61,7 +61,7 @@ test('Test vtkTriangle intersectWithLine', (t) => {

const points = vtkPoints.newInstance();
points.setNumberOfPoints(4); // only first 3 are considered
points.setData([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0]);
points.setData(Float32Array.from([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0]));
// Add points
const triangle = vtkTriangle.newInstance();
triangle.initialize(points);
Expand Down Expand Up @@ -118,7 +118,7 @@ test('Test vtkTriangle intersectWithLine', (t) => {
test('Test vtkTriangle evaluatePosition', (t) => {
const points = vtkPoints.newInstance();
points.setNumberOfPoints(3);
points.setData([0, 0, 0, 2, 0, 0, 2, 2, 0]);
points.setData(Float32Array.from([0, 0, 0, 2, 0, 0, 2, 2, 0]));
const pointIdList = [0, 1, 2];
// Add points
const triangle = vtkTriangle.newInstance();
Expand Down

0 comments on commit d0585a4

Please sign in to comment.