@kitware/vtk.js 34.11.3 → 34.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/Core/CellArray.d.ts +5 -0
- package/Common/Core/CellArray.js +1 -0
- package/Common/Core/Math/index.js +1 -1
- package/Common/Core/Math.d.ts +2 -1
- package/Common/Core/Math.js +1 -1
- package/Common/Core/MatrixBuilder.d.ts +1 -0
- package/Common/DataModel/BoundingBox.js +1 -0
- package/Common/DataModel/DataSet.js +57 -32
- package/Common/DataModel/DataSetAttributes/FieldData.js +2 -2
- package/Common/DataModel/ImageData.js +1 -1
- package/Common/DataModel/IncrementalOctreeNode.js +1 -1
- package/Common/DataModel/IncrementalOctreePointLocator.js +1 -1
- package/Common/DataModel/Line.js +1 -1
- package/Common/DataModel/MergePoints.js +2 -2
- package/Common/DataModel/Planes.js +1 -1
- package/Common/DataModel/PointLocator.js +1 -1
- package/Common/DataModel/PolyData.d.ts +9 -3
- package/Common/DataModel/PolyData.js +10 -1
- package/Common/DataModel/Polygon.js +1 -1
- package/Common/DataModel/Quad.js +1 -1
- package/Common/DataModel/Triangle.js +1 -1
- package/Common/Transform/Transform.d.ts +1 -0
- package/Common/Transform/Transform.js +1 -1
- package/Filters/Core/CleanPolyData.d.ts +208 -0
- package/Filters/Core/CleanPolyData.js +399 -0
- package/Filters/Core/PolyDataNormals.js +1 -1
- package/Filters/Core/ThresholdPoints.js +2 -2
- package/Filters/Core.js +5 -1
- package/Filters/General/ClipClosedSurface.js +1 -1
- package/Filters/General/ContourTriangulator/helper.js +1 -1
- package/Filters/General/TubeFilter.js +1 -1
- package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
- package/Filters/Sources/ArcSource.js +1 -1
- package/Filters/Sources/EllipseArcSource.js +1 -1
- package/Filters/Sources/FrustumSource.js +1 -1
- package/Filters/Sources/TorusSource.js +107 -0
- package/Filters/Sources.js +3 -1
- package/Filters/Texture/TextureMapToPlane.js +1 -1
- package/Filters/Texture/TextureMapToSphere.js +1 -1
- package/Imaging/Core/ImageReslice.d.ts +2 -1
- package/Imaging/Core/ImageReslice.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
- package/Interaction/Style/InteractorStyleMPRSlice.js +1 -1
- package/Interaction/Style/InteractorStyleManipulator.js +1 -0
- package/Proxy/Representations/GlyphRepresentationProxy.js +1 -0
- package/Rendering/Core/CellPicker.js +1 -1
- package/Rendering/Core/Picker.js +1 -1
- package/Rendering/Core/Prop3D.js +10 -0
- package/Rendering/Core/Renderer.js +13 -11
- package/Rendering/OpenGL/ImageResliceMapper.js +1 -1
- package/Rendering/WebGPU/VolumePass.js +1 -1
- package/Widgets/Core/StateBuilder/originMixin.js +1 -1
- package/Widgets/Core/WidgetManager.js +1 -1
- package/Widgets/Manipulators/PlaneManipulator.js +2 -2
- package/Widgets/Manipulators.js +2 -2
- package/Widgets/Representations/RotateTransformHandleRepresentation.js +46 -0
- package/Widgets/Representations/ScaleTransformHandleRepresentation.js +57 -0
- package/Widgets/Representations/TranslateTransformHandleRepresentation/TransformHandleSource.js +85 -0
- package/Widgets/Representations/TranslateTransformHandleRepresentation.js +57 -0
- package/Widgets/Representations.js +6 -0
- package/Widgets/Widgets3D/AngleWidget.js +2 -2
- package/Widgets/Widgets3D/EllipseWidget.js +2 -2
- package/Widgets/Widgets3D/ImageCroppingWidget.js +3 -3
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +2 -2
- package/Widgets/Widgets3D/LabelWidget.js +2 -2
- package/Widgets/Widgets3D/LineWidget.js +3 -3
- package/Widgets/Widgets3D/PaintWidget.js +2 -2
- package/Widgets/Widgets3D/PolyLineWidget.js +2 -2
- package/Widgets/Widgets3D/RectangleWidget.js +2 -2
- package/Widgets/Widgets3D/ResliceCursorWidget.js +3 -3
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/SphereWidget.js +3 -3
- package/Widgets/Widgets3D/SplineWidget.js +2 -2
- package/Widgets/Widgets3D/TransformControlsWidget/behavior.js +180 -0
- package/Widgets/Widgets3D/TransformControlsWidget/constants.js +15 -0
- package/Widgets/Widgets3D/TransformControlsWidget/state.js +157 -0
- package/Widgets/Widgets3D/TransformControlsWidget.js +147 -0
- package/Widgets/Widgets3D.js +3 -1
- package/index.d.ts +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { m as macro } from '../../macros2.js';
|
|
2
|
+
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
3
|
+
import vtkCellArray from '../../Common/Core/CellArray.js';
|
|
4
|
+
import vtkMergePoints from '../../Common/DataModel/MergePoints.js';
|
|
5
|
+
import vtkPointLocator from '../../Common/DataModel/PointLocator.js';
|
|
6
|
+
import vtkPoints from '../../Common/Core/Points.js';
|
|
7
|
+
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
8
|
+
import { DesiredOutputPrecision } from '../../Common/DataModel/DataSetAttributes/Constants.js';
|
|
9
|
+
import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
|
|
10
|
+
|
|
11
|
+
// ----------------------------------------------------------------------------
|
|
12
|
+
// vtkCleanPolyData methods
|
|
13
|
+
// ----------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
function vtkCleanPolyData(publicAPI, model) {
|
|
16
|
+
// Set our classname
|
|
17
|
+
model.classHierarchy.push('vtkCleanPolyData');
|
|
18
|
+
const tempX = [];
|
|
19
|
+
|
|
20
|
+
// Point processing
|
|
21
|
+
function processPoint(ptId, inPts, newPts, inputPD, outputPD, pointMap, numUsedPts) {
|
|
22
|
+
const newX = [0, 0, 0];
|
|
23
|
+
inPts.getPoint(ptId, tempX);
|
|
24
|
+
publicAPI.operateOnPoint(tempX, newX);
|
|
25
|
+
if (!model.pointMerging) {
|
|
26
|
+
if (pointMap[ptId] === -1) {
|
|
27
|
+
pointMap[ptId] = numUsedPts.value++;
|
|
28
|
+
newPts.setPoint(pointMap[ptId], newX);
|
|
29
|
+
outputPD.passData(inputPD, ptId, pointMap[ptId]);
|
|
30
|
+
}
|
|
31
|
+
return pointMap[ptId];
|
|
32
|
+
}
|
|
33
|
+
const newPtId = model._locator.insertUniquePoint(newX).id;
|
|
34
|
+
if (!model.copiedPoints.has(newPtId)) {
|
|
35
|
+
model.copiedPoints.add(newPtId);
|
|
36
|
+
outputPD.passData(inputPD, ptId, newPtId);
|
|
37
|
+
}
|
|
38
|
+
return newPtId;
|
|
39
|
+
}
|
|
40
|
+
publicAPI.operateOnPoint = (inPt, outPt) => {
|
|
41
|
+
outPt[0] = inPt[0];
|
|
42
|
+
outPt[1] = inPt[1];
|
|
43
|
+
outPt[2] = inPt[2];
|
|
44
|
+
};
|
|
45
|
+
publicAPI.operateOnBounds = (inBounds, outBounds) => {
|
|
46
|
+
vtkBoundingBox.setBounds(outBounds, inBounds);
|
|
47
|
+
};
|
|
48
|
+
publicAPI.createDefaultLocator = input => {
|
|
49
|
+
let tol;
|
|
50
|
+
if (model.toleranceIsAbsolute) {
|
|
51
|
+
tol = model.absoluteTolerance;
|
|
52
|
+
} else if (input) {
|
|
53
|
+
tol = model.tolerance * input.getLength();
|
|
54
|
+
} else {
|
|
55
|
+
tol = model.tolerance;
|
|
56
|
+
}
|
|
57
|
+
if (!model._locator) {
|
|
58
|
+
model._locator = tol === 0.0 ? vtkMergePoints.newInstance() : vtkPointLocator.newInstance();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (tol === 0.0 && model._locator?.getTolerance() !== 0.0) {
|
|
62
|
+
model._locator = vtkMergePoints.newInstance();
|
|
63
|
+
} else if (tol > 0.0 && !(model._locator?.getTolerance() > 0.0)) {
|
|
64
|
+
model._locator = vtkPointLocator.newInstance();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
publicAPI.requestData = (inData, outData) => {
|
|
68
|
+
const input = inData[0];
|
|
69
|
+
const output = outData[0]?.initialize() || vtkPolyData.newInstance();
|
|
70
|
+
outData[0] = output;
|
|
71
|
+
const inPts = input.getPoints();
|
|
72
|
+
const numPts = input.getNumberOfPoints();
|
|
73
|
+
if (!inPts || numPts < 1) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const updatedPts = new Array(input.getMaxCellSize());
|
|
77
|
+
const numUsedPts = {
|
|
78
|
+
value: 0
|
|
79
|
+
};
|
|
80
|
+
const precision = model.outputPointsPrecision;
|
|
81
|
+
let pointType = inPts.getDataType();
|
|
82
|
+
if (precision) {
|
|
83
|
+
pointType = precision === DesiredOutputPrecision.DOUBLE ? VtkDataTypes.DOUBLE : VtkDataTypes.FLOAT;
|
|
84
|
+
}
|
|
85
|
+
const newPts = vtkPoints.newInstance({
|
|
86
|
+
dataType: pointType
|
|
87
|
+
});
|
|
88
|
+
const inVerts = input.getVerts();
|
|
89
|
+
const inLines = input.getLines();
|
|
90
|
+
const inPolys = input.getPolys();
|
|
91
|
+
const inStrips = input.getStrips();
|
|
92
|
+
let newVerts = null;
|
|
93
|
+
let newLines = null;
|
|
94
|
+
let newPolys = null;
|
|
95
|
+
let newStrips = null;
|
|
96
|
+
const inputPD = input.getPointData();
|
|
97
|
+
const inputCD = input.getCellData();
|
|
98
|
+
const outputPD = output.getPointData();
|
|
99
|
+
const outputCD = output.getCellData();
|
|
100
|
+
let pointMap = null;
|
|
101
|
+
if (model.pointMerging) {
|
|
102
|
+
publicAPI.createDefaultLocator(input);
|
|
103
|
+
if (model.toleranceIsAbsolute) {
|
|
104
|
+
model._locator.setTolerance(model.absoluteTolerance);
|
|
105
|
+
} else {
|
|
106
|
+
model._locator.setTolerance(model.tolerance * input.getLength());
|
|
107
|
+
}
|
|
108
|
+
const originalBounds = input.getBounds();
|
|
109
|
+
const mappedBounds = [];
|
|
110
|
+
publicAPI.operateOnBounds(originalBounds, mappedBounds);
|
|
111
|
+
model._locator.initPointInsertion(newPts, mappedBounds);
|
|
112
|
+
} else {
|
|
113
|
+
pointMap = new Array(numPts).fill(-1);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Copy data attributes setup
|
|
117
|
+
outputPD.copyStructure(inputPD);
|
|
118
|
+
outputCD.copyStructure(inputCD);
|
|
119
|
+
model.copiedPoints.clear();
|
|
120
|
+
let outLineData = null;
|
|
121
|
+
let outPolyData = null;
|
|
122
|
+
let outStrpData = null;
|
|
123
|
+
let vertIDcounter = 0;
|
|
124
|
+
let lineIDcounter = 0;
|
|
125
|
+
let polyIDcounter = 0;
|
|
126
|
+
let strpIDcounter = 0;
|
|
127
|
+
|
|
128
|
+
// Process vertices
|
|
129
|
+
let inCellID = 0;
|
|
130
|
+
if (inVerts && inVerts.getNumberOfCells() > 0) {
|
|
131
|
+
newVerts = vtkCellArray.newInstance();
|
|
132
|
+
let currentIdx = 0;
|
|
133
|
+
const cellData = inVerts.getData();
|
|
134
|
+
while (currentIdx < cellData.length) {
|
|
135
|
+
const npts = cellData[currentIdx++];
|
|
136
|
+
const inputPointIds = cellData.slice(currentIdx, currentIdx + npts);
|
|
137
|
+
currentIdx += npts;
|
|
138
|
+
let numNewPts = 0;
|
|
139
|
+
for (let i = 0; i < inputPointIds.length; i++) {
|
|
140
|
+
const ptId = inputPointIds[i];
|
|
141
|
+
const newPtId = processPoint(ptId, inPts, newPts, inputPD, outputPD, pointMap, numUsedPts);
|
|
142
|
+
updatedPts[numNewPts++] = newPtId;
|
|
143
|
+
}
|
|
144
|
+
if (numNewPts > 0) {
|
|
145
|
+
newVerts.insertNextCell(updatedPts.slice(0, numNewPts));
|
|
146
|
+
outputCD.passData(inputCD, inCellID, vertIDcounter);
|
|
147
|
+
vertIDcounter++;
|
|
148
|
+
}
|
|
149
|
+
inCellID++;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Process lines
|
|
154
|
+
if (inLines && inLines.getNumberOfCells() > 0) {
|
|
155
|
+
newLines = vtkCellArray.newInstance();
|
|
156
|
+
let currentIdx = 0;
|
|
157
|
+
const cellData = inLines.getData();
|
|
158
|
+
while (currentIdx < cellData.length) {
|
|
159
|
+
const npts = cellData[currentIdx++];
|
|
160
|
+
const inputPointIds = cellData.slice(currentIdx, currentIdx + npts);
|
|
161
|
+
currentIdx += npts;
|
|
162
|
+
let numNewPts = 0;
|
|
163
|
+
for (let i = 0; i < inputPointIds.length; i++) {
|
|
164
|
+
const ptId = inputPointIds[i];
|
|
165
|
+
const newPtId = processPoint(ptId, inPts, newPts, inputPD, outputPD, pointMap, numUsedPts);
|
|
166
|
+
if (i === 0 || newPtId !== updatedPts[numNewPts - 1]) {
|
|
167
|
+
updatedPts[numNewPts++] = newPtId;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (numNewPts >= 2) {
|
|
171
|
+
newLines.insertNextCell(updatedPts.slice(0, numNewPts));
|
|
172
|
+
if (!outLineData) {
|
|
173
|
+
outLineData = [];
|
|
174
|
+
}
|
|
175
|
+
outLineData.push({
|
|
176
|
+
inputId: inCellID,
|
|
177
|
+
outputId: lineIDcounter
|
|
178
|
+
});
|
|
179
|
+
lineIDcounter++;
|
|
180
|
+
} else if (numNewPts === 1 && (inputPointIds.length === numNewPts || model.convertLinesToPoints)) {
|
|
181
|
+
if (!newVerts) {
|
|
182
|
+
newVerts = vtkCellArray.newInstance();
|
|
183
|
+
}
|
|
184
|
+
newVerts.insertNextCell(updatedPts.slice(0, numNewPts));
|
|
185
|
+
outputCD.passData(inputCD, inCellID, vertIDcounter);
|
|
186
|
+
vertIDcounter++;
|
|
187
|
+
}
|
|
188
|
+
inCellID++;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Process polygons
|
|
193
|
+
if (inPolys && inPolys.getNumberOfCells() > 0) {
|
|
194
|
+
newPolys = vtkCellArray.newInstance();
|
|
195
|
+
let currentIdx = 0;
|
|
196
|
+
const cellData = inPolys.getData();
|
|
197
|
+
while (currentIdx < cellData.length) {
|
|
198
|
+
const npts = cellData[currentIdx++];
|
|
199
|
+
const inputPointIds = cellData.slice(currentIdx, currentIdx + npts);
|
|
200
|
+
currentIdx += npts;
|
|
201
|
+
let numNewPts = 0;
|
|
202
|
+
for (let i = 0; i < inputPointIds.length; i++) {
|
|
203
|
+
const ptId = inputPointIds[i];
|
|
204
|
+
const newPtId = processPoint(ptId, inPts, newPts, inputPD, outputPD, pointMap, numUsedPts);
|
|
205
|
+
if (i === 0 || newPtId !== updatedPts[numNewPts - 1]) {
|
|
206
|
+
updatedPts[numNewPts++] = newPtId;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Remove duplicate last point if it matches first
|
|
211
|
+
if (numNewPts > 2 && updatedPts[0] === updatedPts[numNewPts - 1]) {
|
|
212
|
+
numNewPts--;
|
|
213
|
+
}
|
|
214
|
+
if (numNewPts > 2) {
|
|
215
|
+
newPolys.insertNextCell(updatedPts.slice(0, numNewPts));
|
|
216
|
+
if (!outPolyData) {
|
|
217
|
+
outPolyData = [];
|
|
218
|
+
}
|
|
219
|
+
outPolyData.push({
|
|
220
|
+
inputId: inCellID,
|
|
221
|
+
outputId: polyIDcounter
|
|
222
|
+
});
|
|
223
|
+
polyIDcounter++;
|
|
224
|
+
} else if (numNewPts === 2 && (inputPointIds.length === numNewPts || model.convertPolysToLines)) {
|
|
225
|
+
if (!newLines) {
|
|
226
|
+
newLines = vtkCellArray.newInstance();
|
|
227
|
+
outLineData = [];
|
|
228
|
+
}
|
|
229
|
+
newLines.insertNextCell(updatedPts.slice(0, numNewPts));
|
|
230
|
+
outLineData.push({
|
|
231
|
+
inputId: inCellID,
|
|
232
|
+
outputId: lineIDcounter
|
|
233
|
+
});
|
|
234
|
+
lineIDcounter++;
|
|
235
|
+
} else if (numNewPts === 1 && (inputPointIds.length === numNewPts || model.convertLinesToPoints)) {
|
|
236
|
+
if (!newVerts) {
|
|
237
|
+
newVerts = vtkCellArray.newInstance();
|
|
238
|
+
}
|
|
239
|
+
newVerts.insertNextCell(updatedPts.slice(0, numNewPts));
|
|
240
|
+
outputCD.passData(inputCD, inCellID, vertIDcounter);
|
|
241
|
+
vertIDcounter++;
|
|
242
|
+
}
|
|
243
|
+
inCellID++;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Process triangle strips
|
|
248
|
+
if (inStrips && inStrips.getNumberOfCells() > 0) {
|
|
249
|
+
newStrips = vtkCellArray.newInstance();
|
|
250
|
+
let currentIdx = 0;
|
|
251
|
+
const cellData = inStrips.getData();
|
|
252
|
+
while (currentIdx < cellData.length) {
|
|
253
|
+
const npts = cellData[currentIdx++];
|
|
254
|
+
const inputPointIds = cellData.slice(currentIdx, currentIdx + npts);
|
|
255
|
+
currentIdx += npts;
|
|
256
|
+
let numNewPts = 0;
|
|
257
|
+
for (let i = 0; i < inputPointIds.length; i++) {
|
|
258
|
+
const ptId = inputPointIds[i];
|
|
259
|
+
const newPtId = processPoint(ptId, inPts, newPts, inputPD, outputPD, pointMap, numUsedPts);
|
|
260
|
+
if (i === 0 || newPtId !== updatedPts[numNewPts - 1]) {
|
|
261
|
+
updatedPts[numNewPts++] = newPtId;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Remove duplicate last point if it matches first
|
|
266
|
+
if (numNewPts > 1 && updatedPts[0] === updatedPts[numNewPts - 1]) {
|
|
267
|
+
numNewPts--;
|
|
268
|
+
}
|
|
269
|
+
if (numNewPts > 3) {
|
|
270
|
+
newStrips.insertNextCell(updatedPts.slice(0, numNewPts));
|
|
271
|
+
if (!outStrpData) {
|
|
272
|
+
outStrpData = [];
|
|
273
|
+
}
|
|
274
|
+
outStrpData.push({
|
|
275
|
+
inputId: inCellID,
|
|
276
|
+
outputId: strpIDcounter
|
|
277
|
+
});
|
|
278
|
+
strpIDcounter++;
|
|
279
|
+
} else if (numNewPts === 3 && (inputPointIds.length === numNewPts || model.convertStripsToPolys)) {
|
|
280
|
+
if (!newPolys) {
|
|
281
|
+
newPolys = vtkCellArray.newInstance();
|
|
282
|
+
outPolyData = [];
|
|
283
|
+
}
|
|
284
|
+
newPolys.insertNextCell(updatedPts.slice(0, numNewPts));
|
|
285
|
+
outPolyData.push({
|
|
286
|
+
inputId: inCellID,
|
|
287
|
+
outputId: polyIDcounter
|
|
288
|
+
});
|
|
289
|
+
polyIDcounter++;
|
|
290
|
+
} else if (numNewPts === 2 && (inputPointIds.length === numNewPts || model.convertPolysToLines)) {
|
|
291
|
+
if (!newLines) {
|
|
292
|
+
newLines = vtkCellArray.newInstance();
|
|
293
|
+
outLineData = [];
|
|
294
|
+
}
|
|
295
|
+
newLines.insertNextCell(updatedPts.slice(0, numNewPts));
|
|
296
|
+
outLineData.push({
|
|
297
|
+
inputId: inCellID,
|
|
298
|
+
outputId: lineIDcounter
|
|
299
|
+
});
|
|
300
|
+
lineIDcounter++;
|
|
301
|
+
} else if (numNewPts === 1 && (inputPointIds.length === numNewPts || model.convertLinesToPoints)) {
|
|
302
|
+
if (!newVerts) {
|
|
303
|
+
newVerts = vtkCellArray.newInstance();
|
|
304
|
+
}
|
|
305
|
+
newVerts.insertNextCell(updatedPts.slice(0, numNewPts));
|
|
306
|
+
outputCD.passData(inputCD, inCellID, vertIDcounter);
|
|
307
|
+
vertIDcounter++;
|
|
308
|
+
}
|
|
309
|
+
inCellID++;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Clean up
|
|
314
|
+
if (model.pointMerging) {
|
|
315
|
+
model._locator.initialize();
|
|
316
|
+
} else {
|
|
317
|
+
newPts.setNumberOfPoints(numUsedPts.value);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Copy cell data in correct order
|
|
321
|
+
let combinedCellID = vertIDcounter;
|
|
322
|
+
if (outLineData) {
|
|
323
|
+
outLineData.forEach(item => {
|
|
324
|
+
outputCD.passData(inputCD, item.inputId, combinedCellID);
|
|
325
|
+
combinedCellID++;
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
if (outPolyData) {
|
|
329
|
+
outPolyData.forEach(item => {
|
|
330
|
+
outputCD.passData(inputCD, item.inputId, combinedCellID);
|
|
331
|
+
combinedCellID++;
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
if (outStrpData) {
|
|
335
|
+
outStrpData.forEach(item => {
|
|
336
|
+
outputCD.passData(inputCD, item.inputId, combinedCellID);
|
|
337
|
+
combinedCellID++;
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Set output
|
|
342
|
+
output.setPoints(newPts);
|
|
343
|
+
if (newVerts) output.setVerts(newVerts);
|
|
344
|
+
if (newLines) output.setLines(newLines);
|
|
345
|
+
if (newPolys) output.setPolys(newPolys);
|
|
346
|
+
if (newStrips) output.setStrips(newStrips);
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// ----------------------------------------------------------------------------
|
|
351
|
+
// Object factory
|
|
352
|
+
// ----------------------------------------------------------------------------
|
|
353
|
+
|
|
354
|
+
const DEFAULT_VALUES = {
|
|
355
|
+
pointMerging: true,
|
|
356
|
+
toleranceIsAbsolute: false,
|
|
357
|
+
tolerance: 0.0,
|
|
358
|
+
absoluteTolerance: 1.0,
|
|
359
|
+
convertLinesToPoints: true,
|
|
360
|
+
convertPolysToLines: true,
|
|
361
|
+
convertStripsToPolys: true,
|
|
362
|
+
locator: null,
|
|
363
|
+
outputPointsPrecision: DesiredOutputPrecision.DEFAULT
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// ----------------------------------------------------------------------------
|
|
367
|
+
|
|
368
|
+
function extend(publicAPI, model) {
|
|
369
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
370
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
371
|
+
|
|
372
|
+
// Make this a VTK object
|
|
373
|
+
macro.obj(publicAPI, model);
|
|
374
|
+
|
|
375
|
+
// Also make it an algorithm with one input and one output
|
|
376
|
+
macro.algo(publicAPI, model, 1, 1);
|
|
377
|
+
|
|
378
|
+
// Generate macros for properties
|
|
379
|
+
macro.setGet(publicAPI, model, ['pointMerging', 'toleranceIsAbsolute', 'tolerance', 'absoluteTolerance', 'convertPolysToLines', 'convertLinesToPoints', 'convertStripsToPolys', 'outputPointsPrecision']);
|
|
380
|
+
|
|
381
|
+
// Internal state
|
|
382
|
+
model.copiedPoints = new Set();
|
|
383
|
+
|
|
384
|
+
// Object methods
|
|
385
|
+
vtkCleanPolyData(publicAPI, model);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// ----------------------------------------------------------------------------
|
|
389
|
+
|
|
390
|
+
const newInstance = macro.newInstance(extend, 'vtkCleanPolyData');
|
|
391
|
+
|
|
392
|
+
// ----------------------------------------------------------------------------
|
|
393
|
+
|
|
394
|
+
var vtkCleanPolyData$1 = {
|
|
395
|
+
newInstance,
|
|
396
|
+
extend
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
export { vtkCleanPolyData$1 as default, extend, newInstance };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
3
|
-
import {
|
|
3
|
+
import { b as vtkMath } from '../../Common/Core/Math/index.js';
|
|
4
4
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
5
5
|
import vtkTriangle from '../../Common/DataModel/Triangle.js';
|
|
6
6
|
|
|
@@ -209,10 +209,10 @@ const newInstance = macro.newInstance(extend, 'vtkThresholdPoints');
|
|
|
209
209
|
|
|
210
210
|
// ----------------------------------------------------------------------------
|
|
211
211
|
|
|
212
|
-
var
|
|
212
|
+
var vtkThresholdPoints$1 = {
|
|
213
213
|
newInstance,
|
|
214
214
|
extend,
|
|
215
215
|
OperationType
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
-
export {
|
|
218
|
+
export { vtkThresholdPoints$1 as default, extend, newInstance };
|
package/Filters/Core.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import vtkCleanPolyData from './Core/CleanPolyData.js';
|
|
1
2
|
import vtkCutter from './Core/Cutter.js';
|
|
2
3
|
import vtkPolyDataNormals from './Core/PolyDataNormals.js';
|
|
4
|
+
import vtkThresholdPoints from './Core/ThresholdPoints.js';
|
|
3
5
|
|
|
4
6
|
var Core = {
|
|
7
|
+
vtkCleanPolyData,
|
|
5
8
|
vtkCutter,
|
|
6
|
-
vtkPolyDataNormals
|
|
9
|
+
vtkPolyDataNormals,
|
|
10
|
+
vtkThresholdPoints
|
|
7
11
|
};
|
|
8
12
|
|
|
9
13
|
export { Core as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
|
-
import { d as dot,
|
|
2
|
+
import { d as dot, f as distance2BetweenPoints } from '../../Common/Core/Math/index.js';
|
|
3
3
|
import vtkCellArray from '../../Common/Core/CellArray.js';
|
|
4
4
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
5
5
|
import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../../macros2.js';
|
|
2
2
|
import vtkPoints from '../../../Common/Core/Points.js';
|
|
3
|
-
import { s as subtract, j as cross, d as dot, n as norm,
|
|
3
|
+
import { s as subtract, j as cross, d as dot, n as norm, f as distance2BetweenPoints, k as add, l as normalize } from '../../../Common/Core/Math/index.js';
|
|
4
4
|
import vtkLine from '../../../Common/DataModel/Line.js';
|
|
5
5
|
import vtkPolygon from '../../../Common/DataModel/Polygon.js';
|
|
6
6
|
import vtkIncrementalOctreePointLocator from '../../../Common/DataModel/IncrementalOctreePointLocator.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkCellArray from '../../Common/Core/CellArray.js';
|
|
3
3
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
4
|
-
import { l as normalize, j as cross, n as norm, d as dot,
|
|
4
|
+
import { l as normalize, j as cross, n as norm, d as dot, f as distance2BetweenPoints } from '../../Common/Core/Math/index.js';
|
|
5
5
|
import vtkPoints from '../../Common/Core/Points.js';
|
|
6
6
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
7
7
|
import { DesiredOutputPrecision } from '../../Common/DataModel/DataSetAttributes/Constants.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
3
3
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
4
|
-
import {
|
|
4
|
+
import { b as vtkMath } from '../../Common/Core/Math/index.js';
|
|
5
5
|
import { AttributeTypes } from '../../Common/DataModel/DataSetAttributes/Constants.js';
|
|
6
6
|
import vtkPoints from '../../Common/Core/Points.js';
|
|
7
7
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkCellArray from '../../Common/Core/CellArray.js';
|
|
3
3
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
4
|
-
import {
|
|
4
|
+
import { b as vtkMath } from '../../Common/Core/Math/index.js';
|
|
5
5
|
import vtkPoints from '../../Common/Core/Points.js';
|
|
6
6
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
7
7
|
import { DesiredOutputPrecision } from '../../Common/DataModel/DataSetAttributes/Constants.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkCellArray from '../../Common/Core/CellArray.js';
|
|
3
3
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
4
|
-
import {
|
|
4
|
+
import { b as vtkMath } from '../../Common/Core/Math/index.js';
|
|
5
5
|
import vtkPoints from '../../Common/Core/Points.js';
|
|
6
6
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
7
7
|
import { DesiredOutputPrecision } from '../../Common/DataModel/DataSetAttributes/Constants.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
|
-
import {
|
|
2
|
+
import { b as vtkMath } from '../../Common/Core/Math/index.js';
|
|
3
3
|
import vtkCellArray from '../../Common/Core/CellArray.js';
|
|
4
4
|
import vtkPoints from '../../Common/Core/Points.js';
|
|
5
5
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { m as macro } from '../../macros2.js';
|
|
2
|
+
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
3
|
+
import vtkMatrixBuilder from '../../Common/Core/MatrixBuilder.js';
|
|
4
|
+
|
|
5
|
+
// ----------------------------------------------------------------------------
|
|
6
|
+
// vtkTorusSource methods
|
|
7
|
+
// Adapted from three.js TorusGeometry
|
|
8
|
+
// ----------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
const TAU = Math.PI * 2;
|
|
11
|
+
function vtkTorusSource(publicAPI, model) {
|
|
12
|
+
// Set our className
|
|
13
|
+
model.classHierarchy.push('vtkTorusSource');
|
|
14
|
+
function requestData(inData, outData) {
|
|
15
|
+
let dataset = outData[0];
|
|
16
|
+
|
|
17
|
+
// Points
|
|
18
|
+
const points = macro.newTypedArray(model.pointType, 3 * (model.resolution + 1) * (model.tubeResolution + 1));
|
|
19
|
+
let pointIdx = 0;
|
|
20
|
+
for (let ti = 0; ti <= model.tubeResolution; ti++) {
|
|
21
|
+
const v = ti / model.tubeResolution * TAU;
|
|
22
|
+
const cosV = Math.cos(v);
|
|
23
|
+
const sinV = Math.sin(v);
|
|
24
|
+
for (let ri = 0; ri <= model.resolution; ri++) {
|
|
25
|
+
const u = ri / model.resolution * model.arcLength;
|
|
26
|
+
points[pointIdx++] = (model.radius + model.tubeRadius * cosV) * Math.cos(u);
|
|
27
|
+
points[pointIdx++] = (model.radius + model.tubeRadius * cosV) * Math.sin(u);
|
|
28
|
+
points[pointIdx++] = model.tubeRadius * sinV;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Cells
|
|
33
|
+
const cellArraySize = 4 * 2 * (model.resolution * model.tubeResolution);
|
|
34
|
+
let cellLocation = 0;
|
|
35
|
+
const polys = new Uint32Array(cellArraySize);
|
|
36
|
+
for (let ti = 1; ti <= model.tubeResolution; ti++) {
|
|
37
|
+
for (let ri = 1; ri <= model.resolution; ri++) {
|
|
38
|
+
const a = (model.resolution + 1) * ti + ri - 1;
|
|
39
|
+
const b = (model.resolution + 1) * (ti - 1) + ri - 1;
|
|
40
|
+
const c = (model.resolution + 1) * (ti - 1) + ri;
|
|
41
|
+
const d = (model.resolution + 1) * ti + ri;
|
|
42
|
+
polys[cellLocation++] = 3;
|
|
43
|
+
polys[cellLocation++] = a;
|
|
44
|
+
polys[cellLocation++] = b;
|
|
45
|
+
polys[cellLocation++] = d;
|
|
46
|
+
polys[cellLocation++] = 3;
|
|
47
|
+
polys[cellLocation++] = b;
|
|
48
|
+
polys[cellLocation++] = c;
|
|
49
|
+
polys[cellLocation++] = d;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Apply transformation to the points coordinates
|
|
54
|
+
vtkMatrixBuilder.buildFromRadian().translate(...model.center).rotateFromDirections([1, 0, 0], model.direction).apply(points);
|
|
55
|
+
dataset = vtkPolyData.newInstance();
|
|
56
|
+
dataset.getPoints().setData(points, 3);
|
|
57
|
+
dataset.getPolys().setData(polys, 1);
|
|
58
|
+
|
|
59
|
+
// Update output
|
|
60
|
+
outData[0] = dataset;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Expose methods
|
|
64
|
+
publicAPI.requestData = requestData;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ----------------------------------------------------------------------------
|
|
68
|
+
// Object factory
|
|
69
|
+
// ----------------------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
const DEFAULT_VALUES = {
|
|
72
|
+
radius: 0.5,
|
|
73
|
+
tubeRadius: 0.01,
|
|
74
|
+
resolution: 64,
|
|
75
|
+
tubeResolution: 64,
|
|
76
|
+
arcLength: TAU,
|
|
77
|
+
center: [0, 0, 0],
|
|
78
|
+
direction: [1.0, 0.0, 0.0],
|
|
79
|
+
pointType: 'Float64Array'
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// ----------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
function extend(publicAPI, model) {
|
|
85
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
86
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
87
|
+
|
|
88
|
+
// Build VTK API
|
|
89
|
+
macro.obj(publicAPI, model);
|
|
90
|
+
macro.setGet(publicAPI, model, ['radius', 'tubeRadius', 'resolution', 'tubeResolution', 'arcLength']);
|
|
91
|
+
macro.setGetArray(publicAPI, model, ['center', 'direction'], 3);
|
|
92
|
+
macro.algo(publicAPI, model, 0, 1);
|
|
93
|
+
vtkTorusSource(publicAPI, model);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ----------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
const newInstance = macro.newInstance(extend, 'vtkTorusSource');
|
|
99
|
+
|
|
100
|
+
// ----------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
var vtkTorusSource$1 = {
|
|
103
|
+
newInstance,
|
|
104
|
+
extend
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { vtkTorusSource$1 as default, extend, newInstance };
|
package/Filters/Sources.js
CHANGED
|
@@ -16,6 +16,7 @@ import vtkPointSource from './Sources/PointSource.js';
|
|
|
16
16
|
import vtkRTAnalyticSource from './Sources/RTAnalyticSource.js';
|
|
17
17
|
import vtkSLICSource from './Sources/SLICSource.js';
|
|
18
18
|
import vtkSphereSource from './Sources/SphereSource.js';
|
|
19
|
+
import vtkTorusSource from './Sources/TorusSource.js';
|
|
19
20
|
|
|
20
21
|
var Sources = {
|
|
21
22
|
vtkArcSource,
|
|
@@ -35,7 +36,8 @@ var Sources = {
|
|
|
35
36
|
vtkPointSource,
|
|
36
37
|
vtkRTAnalyticSource,
|
|
37
38
|
vtkSLICSource,
|
|
38
|
-
vtkSphereSource
|
|
39
|
+
vtkSphereSource,
|
|
40
|
+
vtkTorusSource
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
export { Sources as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
3
|
-
import { l as normalize, d as dot, j as cross,
|
|
3
|
+
import { l as normalize, d as dot, j as cross, f as distance2BetweenPoints, z as determinant3x3, A as rowsToMat3 } from '../../Common/Core/Math/index.js';
|
|
4
4
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
5
5
|
|
|
6
6
|
const {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
3
|
-
import {
|
|
3
|
+
import { f as distance2BetweenPoints } from '../../Common/Core/Math/index.js';
|
|
4
4
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
5
5
|
|
|
6
6
|
const {
|
|
@@ -666,7 +666,8 @@ export function newInstance(
|
|
|
666
666
|
* slice rather than a volume. You can use both the resliceAxes and the
|
|
667
667
|
* resliceTransform at the same time, in order to extract slices from a
|
|
668
668
|
* volume that you have applied a transformation to.
|
|
669
|
-
*
|
|
669
|
+
* **Note**: vtkImageReslice uses column-major format.
|
|
670
|
+
*/
|
|
670
671
|
export declare const vtkImageReslice: {
|
|
671
672
|
newInstance: typeof newInstance;
|
|
672
673
|
extend: typeof extend;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mat4, vec4 } from 'gl-matrix';
|
|
2
2
|
import { m as macro, v as vtkWarningMacro } from '../../macros2.js';
|
|
3
3
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
4
|
-
import {
|
|
4
|
+
import { b as vtkMath } from '../../Common/Core/Math/index.js';
|
|
5
5
|
import vtkMatrixBuilder from '../../Common/Core/MatrixBuilder.js';
|
|
6
6
|
import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
|
|
7
7
|
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|