Skip to content

Commit 82fe997

Browse files
committed
fix(clipclosedsurface): fix various uninitialized variables
The logic was broken at some places. It may improve the behavior of ClipClosedSurface and other filters
1 parent 17d2e7d commit 82fe997

7 files changed

Lines changed: 17 additions & 22 deletions

File tree

Sources/Common/DataModel/IncrementalOctreePointLocator/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,15 @@ function vtkIncrementalOctreePointLocator(publicAPI, model) {
6363
return [pntIdx, dist2];
6464
};
6565

66-
publicAPI.findClosestPointInSphere = (point, radius2, maskNode, refDist2) => {
66+
publicAPI.findClosestPointInSphere = (point, radius2, maskNode, minDist2, refDist2) => {
6767
let pointIndx = -1;
68-
let minDist2 = Number.MAX_VALUE;
6968

7069
const nodesBase = [];
7170
nodesBase.push(model.octreeRootNode);
7271

7372
let checkNode;
7473
let childNode;
75-
let distToData;
74+
let distToData;
7675
let tempDist2;
7776
let tempPntId;
7877

@@ -346,7 +345,6 @@ function vtkIncrementalOctreePointLocator(publicAPI, model) {
346345
publicAPI.isInsertedPointForNonZeroTolerance = (x) => {
347346
// minDist2 // min distance to ALL existing points
348347
// elseDst2 // min distance to other nodes (inner boundaries)
349-
let dist2Ext; // min distance to an EXTended set of nodes
350348
let pntIdExt;
351349

352350
// the target leaf node always exists there since the root node of the
@@ -371,12 +369,10 @@ function vtkIncrementalOctreePointLocator(publicAPI, model) {
371369

372370
if (elseDst2 < model.insertTolerance2) {
373371
// one or multiple closer points might exist in the neighboring nodes
374-
// TODO: dist2Ext
375-
pntIdExt = publicAPI.findClosestPointInSphereWithTolerance(
372+
const [pntIdExt, dist2Ext] = publicAPI.findClosestPointInSphereWithTolerance(
376373
x,
377374
model.insertTolerance2,
378-
leafContainer,
379-
dist2Ext
375+
leafContainer
380376
);
381377

382378
if (dist2Ext < minDist2) {

Sources/Common/DataModel/Triangle/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,12 +483,11 @@ function vtkTriangle(publicAPI, model) {
483483
}
484484
outObj.evaluation = 1;
485485
} else {
486-
let t;
487486
if (closestPoint) {
488487
if (weights[1] < 0.0 && weights[2] < 0.0) {
489488
dist2Point = vtkMath.distance2BetweenPoints(x, pt3);
490-
dist2Line1 = vtkLine.distanceToLine(x, pt1, pt3, t, closestPoint1);
491-
dist2Line2 = vtkLine.distanceToLine(x, pt3, pt2, t, closestPoint2);
489+
dist2Line1 = vtkLine.distanceToLine(x, pt1, pt3, closestPoint1);
490+
dist2Line2 = vtkLine.distanceToLine(x, pt3, pt2, closestPoint2);
492491
if (dist2Point < dist2Line1) {
493492
outObj.dist2 = dist2Point;
494493
closest = pt3;
@@ -505,8 +504,8 @@ function vtkTriangle(publicAPI, model) {
505504
}
506505
} else if (weights[2] < 0.0 && weights[0] < 0.0) {
507506
dist2Point = vtkMath.distance2BetweenPoints(x, pt1);
508-
dist2Line1 = vtkLine.distanceToLine(x, pt1, pt3, t, closestPoint1);
509-
dist2Line2 = vtkLine.distanceToLine(x, pt1, pt2, t, closestPoint2);
507+
dist2Line1 = vtkLine.distanceToLine(x, pt1, pt3, closestPoint1);
508+
dist2Line2 = vtkLine.distanceToLine(x, pt1, pt2, closestPoint2);
510509
if (dist2Point < dist2Line1) {
511510
outObj.dist2 = dist2Point;
512511
closest = pt1;
@@ -523,8 +522,8 @@ function vtkTriangle(publicAPI, model) {
523522
}
524523
} else if (weights[1] < 0.0 && weights[0] < 0.0) {
525524
dist2Point = vtkMath.distance2BetweenPoints(x, pt2);
526-
dist2Line1 = vtkLine.distanceToLine(x, pt2, pt3, t, closestPoint1);
527-
dist2Line2 = vtkLine.distanceToLine(x, pt1, pt2, t, closestPoint2);
525+
dist2Line1 = vtkLine.distanceToLine(x, pt2, pt3, closestPoint1);
526+
dist2Line2 = vtkLine.distanceToLine(x, pt1, pt2, closestPoint2);
528527
if (dist2Point < dist2Line1) {
529528
outObj.dist2 = dist2Point;
530529
closest = pt2;

Sources/Filters/General/ClipClosedSurface/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ function vtkClipClosedSurface(publicAPI, model) {
2727
/**
2828
* Take three colors as doubles, and convert to unsigned char.
2929
*
30-
* @param {Number} color1
31-
* @param {Number} color2
32-
* @param {Number} color3
30+
* @param {Number[3]} color1
31+
* @param {Number[3]} color2
32+
* @param {Number[3]} color3
3333
* @param {Number[3][3]} colors
3434
*/
3535
function createColorValues(color1, color2, color3, colors) {

Sources/Filters/General/ContourTriangulator/helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,8 +1822,8 @@ export function vtkCCSFindCuts(
18221822
points.getPoint(outerPoly[k], q1);
18231823
points.getPoint(innerPoly[j], q2);
18241824

1825-
let u;
1826-
let v;
1825+
let u = [];
1826+
let v = [];
18271827
if (
18281828
vtkLine.intersection(p1, p2, q1, q2, u, v) ===
18291829
vtkLine.IntersectionState.YES_INTERSECTION

Sources/Interaction/Widgets/PiecewiseGaussianWidget/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as vtkMath from 'vtk.js/Sources/Common/Core/Math';
33

44
import WebworkerPromise from 'webworker-promise';
55

6+
// eslint-disable-next-line import/no-unresolved, import/default
67
import ComputeHistogramWorker from './ComputeHistogram.worker';
78

89
/* eslint-disable no-continue */

Sources/Rendering/OpenGL/CellArrayBufferObject/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { vec3 } from 'gl-matrix';
22

33
import macro from 'vtk.js/Sources/macros';
44
import vtkBufferObject from 'vtk.js/Sources/Rendering/OpenGL/BufferObject';
5-
import vtkCellArray from 'vtk.js/Sources/Common/Core/CellArray';
65
import { ObjectType } from 'vtk.js/Sources/Rendering/OpenGL/BufferObject/Constants';
76
import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants';
87
import {

Sources/Rendering/OpenGL/Texture/supportsNorm16Linear.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function supportsNorm16Linear() {
107107
}
108108

109109
return r === g && g === b && r !== 0;
110-
} catch (e) {
110+
} catch {
111111
return false;
112112
}
113113
}

0 commit comments

Comments
 (0)