@ohif/app 3.10.1 → 3.10.2
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/dist/{1919.bundle.6f7de53921f3710a1d54.js → 1919.bundle.6cb4a1f5ea770e504398.js} +2 -2
- package/dist/{1927.bundle.83810560c4d3a90eb7cf.js → 1927.bundle.5c25b9084f704a3582d2.js} +1 -1
- package/dist/{3396.bundle.858cfdfc5ab560840958.js → 2482.bundle.0947bc67ad4429d5fda3.js} +289 -1353
- package/dist/{2701.bundle.f1f15df81406d04851c4.js → 2701.bundle.87301d8d94693b5d5fcc.js} +2 -2
- package/dist/{2860.bundle.5d93c30e2df60e382bda.js → 2860.bundle.130f5c83c90c83017101.js} +1368 -28
- package/dist/{2914.bundle.a0a5ddfebfc9d429063d.js → 2914.bundle.adefec5b51b4955af1f9.js} +2 -0
- package/dist/{2932.bundle.038f79dbbfdd9d1f387b.js → 2932.bundle.2757ab993a28dab49d56.js} +2 -2
- package/dist/{3075.bundle.0624f6bf3f676f30d1b5.js → 3075.bundle.5d83563c3791a0d884df.js} +16 -3
- package/dist/{3353.bundle.184ebb9668df2cbebd26.js → 3353.bundle.1b2d3da25de70f5f1042.js} +33 -4
- package/dist/{3984.bundle.592161af4b618c9dd56f.js → 3984.bundle.1248e382e82ee04eff72.js} +12 -7
- package/dist/{4113.bundle.7ec6da0eb1ab98e1b791.js → 4113.bundle.1a3202dd6a1b2e6b9d5d.js} +5 -5
- package/dist/{4526.bundle.fbdd617a934353019be3.js → 4526.bundle.54c0b8f753ed5c39f6c5.js} +2 -2
- package/dist/{6029.bundle.43e04238ac01880fa66c.js → 6029.bundle.a4206e2a2e75c7b1ad7b.js} +238 -40
- package/dist/{6066.bundle.345453ace06e86bc481c.js → 6066.bundle.89df990e4f257e8ac73b.js} +1466 -39
- package/dist/{6201.bundle.e0d8d1c967a9daed4662.js → 6201.bundle.b584d7554570344d9170.js} +4 -4
- package/dist/{7197.bundle.a9c6429f2859a8feeded.js → 7197.bundle.2032eea26c084877d172.js} +3 -3
- package/dist/{810.bundle.86ba4f6f1311ccc28d41.js → 810.bundle.8b29de53f9632f0f1bf9.js} +4 -4
- package/dist/{8185.bundle.b2252d9ff14ce760df9c.js → 8185.bundle.c7e0ab58fa8f7070de26.js} +22 -16
- package/dist/{8558.bundle.5b67110ba3e66f5525ae.js → 8558.bundle.24bb90c2d5a0857577c5.js} +1 -1
- package/dist/{7241.bundle.7097a0cd314605d766f5.js → 8572.bundle.bd98ac784dae1e224a52.js} +135 -47
- package/dist/{3166.bundle.40162f1d9f9f5fc16b16.js → 908.bundle.7f901ab4610793bb5ee3.js} +29 -5
- package/dist/{934.bundle.c446dfb396152899756f.js → 934.bundle.441c775536d8be5029af.js} +2 -2
- package/dist/{963.bundle.88152346007c0f5049a3.js → 963.bundle.4b88a54196fdd1976d6c.js} +2 -2
- package/dist/{9890.bundle.37d7ed265c0454337a57.js → 9890.bundle.b4c265e3609512785ae8.js} +2 -2
- package/dist/{9977.bundle.071821200c1921021d29.js → 9977.bundle.4f44190c1a5d6a69bc00.js} +3 -1
- package/dist/{app.bundle.d09601053966ecdcfe4b.js → app.bundle.223c009cd6f636320f76.js} +2148 -1758
- package/dist/app.bundle.css +2 -2
- package/dist/{compute.bundle.f0c30502c027d04e94f2.js → compute.bundle.83a75c96620eedca973e.js} +3 -3
- package/dist/index.html +1 -1
- package/dist/{polySeg.bundle.7445d00e1e9ef623d0f1.js → polySeg.bundle.30f6f13491f48e597605.js} +3 -3
- package/dist/sw.js +1 -1
- package/package.json +19 -19
- /package/dist/{1459.bundle.4b6682c8673e199edf64.js → 1459.bundle.ea2023918c1ef217d23a.js} +0 -0
- /package/dist/{1807.bundle.e8c6890ca68e62f46990.js → 1807.bundle.a04f3486b00cdcc6a305.js} +0 -0
- /package/dist/{213.bundle.d8495e69f1d1405d0356.js → 213.bundle.e861b773d4779d7d724a.js} +0 -0
- /package/dist/{2424.bundle.ef98022039ea6e87cfd9.js → 2424.bundle.425cb2260521f2a23f70.js} +0 -0
- /package/dist/{3658.bundle.04fdfe11b9d38cd5f3c6.js → 3658.bundle.a6a9c2e1b32d92e3b621.js} +0 -0
- /package/dist/{6027.bundle.155cbff7fa97c7ede627.js → 6027.bundle.8e1b6021f0d570eb85f5.js} +0 -0
- /package/dist/{7639.bundle.a659acbf2ab7f3f2e8f4.js → 7639.bundle.b622eafdc74d9bfc1280.js} +0 -0
- /package/dist/{8228.bundle.74c8ca5e66a44db80464.js → 8228.bundle.f520ecf3c0a8998e770a.js} +0 -0
- /package/dist/{85.bundle.e65ed829e1a136e33576.js → 85.bundle.a27a1466f85e01adf8e8.js} +0 -0
- /package/dist/{8815.bundle.c8a97b220635e9b15109.js → 8815.bundle.096958a5ae7253911a2e.js} +0 -0
- /package/dist/{9026.bundle.eb2ae9e2311a6a620751.js → 9026.bundle.019d8b4b70096b94302e.js} +0 -0
- /package/dist/{9862.bundle.87d8249a9cf1d8cf579d.js → 9862.bundle.b0ea941458506379f666.js} +0 -0
|
@@ -1807,7 +1807,7 @@ function actorIsA(actorEntry, actorType) {
|
|
|
1807
1807
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1808
1808
|
/* harmony export */ A: () => (/* binding */ applyPreset)
|
|
1809
1809
|
/* harmony export */ });
|
|
1810
|
-
/* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
1810
|
+
/* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(642);
|
|
1811
1811
|
/* harmony import */ var _kitware_vtk_js_Common_DataModel_PiecewiseFunction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(99341);
|
|
1812
1812
|
|
|
1813
1813
|
|
|
@@ -2145,11 +2145,18 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2145
2145
|
/* harmony export */ findMatchingColormap: () => (/* binding */ findMatchingColormap),
|
|
2146
2146
|
/* harmony export */ getColormap: () => (/* binding */ getColormap),
|
|
2147
2147
|
/* harmony export */ getColormapNames: () => (/* binding */ getColormapNames),
|
|
2148
|
-
/* harmony export */ registerColormap: () => (/* binding */ registerColormap)
|
|
2148
|
+
/* harmony export */ registerColormap: () => (/* binding */ registerColormap),
|
|
2149
|
+
/* harmony export */ setColorMapTransferFunctionForVolumeActor: () => (/* binding */ setColorMapTransferFunctionForVolumeActor),
|
|
2150
|
+
/* harmony export */ updateOpacity: () => (/* binding */ updateOpacity),
|
|
2151
|
+
/* harmony export */ updateThreshold: () => (/* binding */ updateThreshold)
|
|
2149
2152
|
/* harmony export */ });
|
|
2150
2153
|
/* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction_ColorMaps__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(660);
|
|
2151
|
-
/* harmony import */ var
|
|
2152
|
-
/* harmony import */ var
|
|
2154
|
+
/* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(642);
|
|
2155
|
+
/* harmony import */ var _kitware_vtk_js_Common_DataModel_PiecewiseFunction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(99341);
|
|
2156
|
+
/* harmony import */ var _isEqual__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(74638);
|
|
2157
|
+
/* harmony import */ var _actorCheck__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(98039);
|
|
2158
|
+
|
|
2159
|
+
|
|
2153
2160
|
|
|
2154
2161
|
|
|
2155
2162
|
|
|
@@ -2174,7 +2181,7 @@ function findMatchingColormap(rgbPoints, actor) {
|
|
|
2174
2181
|
return false;
|
|
2175
2182
|
}
|
|
2176
2183
|
for (let i = 0; i < presetRGBPoints.length; i += 4) {
|
|
2177
|
-
if (!(0,
|
|
2184
|
+
if (!(0,_isEqual__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Ay)(presetRGBPoints.slice(i + 1, i + 4), rgbPoints.slice(i + 1, i + 4))) {
|
|
2178
2185
|
return false;
|
|
2179
2186
|
}
|
|
2180
2187
|
}
|
|
@@ -2184,7 +2191,7 @@ function findMatchingColormap(rgbPoints, actor) {
|
|
|
2184
2191
|
return null;
|
|
2185
2192
|
}
|
|
2186
2193
|
const opacity = [];
|
|
2187
|
-
if ((0,
|
|
2194
|
+
if ((0,_actorCheck__WEBPACK_IMPORTED_MODULE_4__/* .actorIsA */ .N)(actor, 'vtkVolume')) {
|
|
2188
2195
|
const opacityPoints = actor
|
|
2189
2196
|
.getProperty()
|
|
2190
2197
|
.getScalarOpacity(0)
|
|
@@ -2206,6 +2213,80 @@ function findMatchingColormap(rgbPoints, actor) {
|
|
|
2206
2213
|
opacity,
|
|
2207
2214
|
};
|
|
2208
2215
|
}
|
|
2216
|
+
function setColorMapTransferFunctionForVolumeActor(volumeInfo) {
|
|
2217
|
+
const { volumeActor, preset, opacity = 0.9, threshold = null, colorRange = [0, 5], } = volumeInfo;
|
|
2218
|
+
const mapper = volumeActor.getMapper();
|
|
2219
|
+
mapper.setSampleDistance(1.0);
|
|
2220
|
+
const cfun = _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_1__/* ["default"].newInstance */ .Ay.newInstance();
|
|
2221
|
+
const presetToUse = preset || _kitware_vtk_js_Rendering_Core_ColorTransferFunction_ColorMaps__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.getPresetByName('hsv');
|
|
2222
|
+
cfun.applyColorMap(presetToUse);
|
|
2223
|
+
cfun.setMappingRange(colorRange[0], colorRange[1]);
|
|
2224
|
+
volumeActor.getProperty().setRGBTransferFunction(0, cfun);
|
|
2225
|
+
updateOpacityWithThreshold(volumeActor, opacity, threshold);
|
|
2226
|
+
}
|
|
2227
|
+
function updateOpacity(volumeActor, newOpacity) {
|
|
2228
|
+
const currentThreshold = getThresholdValue(volumeActor);
|
|
2229
|
+
updateOpacityWithThreshold(volumeActor, newOpacity, currentThreshold);
|
|
2230
|
+
}
|
|
2231
|
+
function updateThreshold(volumeActor, newThreshold) {
|
|
2232
|
+
const currentOpacity = getMaxOpacity(volumeActor);
|
|
2233
|
+
updateOpacityWithThreshold(volumeActor, currentOpacity, newThreshold);
|
|
2234
|
+
}
|
|
2235
|
+
function updateOpacityWithThreshold(volumeActor, opacity, threshold) {
|
|
2236
|
+
const transferFunction = volumeActor.getProperty().getRGBTransferFunction(0);
|
|
2237
|
+
const range = transferFunction.getRange();
|
|
2238
|
+
const ofun = _kitware_vtk_js_Common_DataModel_PiecewiseFunction__WEBPACK_IMPORTED_MODULE_2__/* ["default"].newInstance */ .Ay.newInstance();
|
|
2239
|
+
if (threshold !== null) {
|
|
2240
|
+
const delta = Math.abs(range[1] - range[0]) * 0.001;
|
|
2241
|
+
const thresholdValue = Math.max(range[0], Math.min(range[1], threshold));
|
|
2242
|
+
ofun.addPoint(range[0], 0);
|
|
2243
|
+
ofun.addPoint(thresholdValue - delta, 0);
|
|
2244
|
+
ofun.addPoint(thresholdValue, opacity);
|
|
2245
|
+
ofun.addPoint(range[1], opacity);
|
|
2246
|
+
}
|
|
2247
|
+
else {
|
|
2248
|
+
ofun.addPoint(range[0], opacity);
|
|
2249
|
+
ofun.addPoint(range[1], opacity);
|
|
2250
|
+
}
|
|
2251
|
+
volumeActor.getProperty().setScalarOpacity(0, ofun);
|
|
2252
|
+
}
|
|
2253
|
+
function getThresholdValue(volumeActor) {
|
|
2254
|
+
const opacityFunction = volumeActor.getProperty().getScalarOpacity(0);
|
|
2255
|
+
if (!opacityFunction) {
|
|
2256
|
+
return null;
|
|
2257
|
+
}
|
|
2258
|
+
const dataArray = opacityFunction.getDataPointer();
|
|
2259
|
+
if (!dataArray || dataArray.length <= 4) {
|
|
2260
|
+
return null;
|
|
2261
|
+
}
|
|
2262
|
+
for (let i = 0; i < dataArray.length - 2; i += 2) {
|
|
2263
|
+
const x1 = dataArray[i];
|
|
2264
|
+
const y1 = dataArray[i + 1];
|
|
2265
|
+
const x2 = dataArray[i + 2];
|
|
2266
|
+
const y2 = dataArray[i + 3];
|
|
2267
|
+
if (y1 === 0 && y2 > 0) {
|
|
2268
|
+
return x2;
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
return null;
|
|
2272
|
+
}
|
|
2273
|
+
function getMaxOpacity(volumeActor) {
|
|
2274
|
+
const opacityFunction = volumeActor.getProperty().getScalarOpacity(0);
|
|
2275
|
+
if (!opacityFunction) {
|
|
2276
|
+
return 1.0;
|
|
2277
|
+
}
|
|
2278
|
+
const dataArray = opacityFunction.getDataPointer();
|
|
2279
|
+
if (!dataArray || dataArray.length === 0) {
|
|
2280
|
+
return 1.0;
|
|
2281
|
+
}
|
|
2282
|
+
let maxOpacity = 0;
|
|
2283
|
+
for (let i = 1; i < dataArray.length; i += 2) {
|
|
2284
|
+
if (dataArray[i] > maxOpacity) {
|
|
2285
|
+
maxOpacity = dataArray[i];
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
return maxOpacity;
|
|
2289
|
+
}
|
|
2209
2290
|
|
|
2210
2291
|
|
|
2211
2292
|
|
|
@@ -2217,7 +2298,7 @@ function findMatchingColormap(rgbPoints, actor) {
|
|
|
2217
2298
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2218
2299
|
/* harmony export */ A: () => (/* binding */ createLinearRGBTransferFunction)
|
|
2219
2300
|
/* harmony export */ });
|
|
2220
|
-
/* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
2301
|
+
/* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(642);
|
|
2221
2302
|
|
|
2222
2303
|
function createLinearRGBTransferFunction(voiRange) {
|
|
2223
2304
|
const cfun = _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__/* ["default"].newInstance */ .Ay.newInstance();
|
|
@@ -2241,7 +2322,7 @@ function createLinearRGBTransferFunction(voiRange) {
|
|
|
2241
2322
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2242
2323
|
/* harmony export */ A: () => (/* binding */ createSigmoidRGBTransferFunction)
|
|
2243
2324
|
/* harmony export */ });
|
|
2244
|
-
/* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
2325
|
+
/* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(642);
|
|
2245
2326
|
/* harmony import */ var _kitware_vtk_js_Common_Core_DataArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(42008);
|
|
2246
2327
|
/* harmony import */ var _windowLevel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(68136);
|
|
2247
2328
|
/* harmony import */ var _logit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(58977);
|
|
@@ -2344,12 +2425,15 @@ function fnv1aHash(str) {
|
|
|
2344
2425
|
/* harmony export */ });
|
|
2345
2426
|
/* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3823);
|
|
2346
2427
|
/* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(74876);
|
|
2347
|
-
/* harmony import */ var
|
|
2348
|
-
/* harmony import */ var
|
|
2428
|
+
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7608);
|
|
2429
|
+
/* harmony import */ var _getSpacingInNormalDirection__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(85008);
|
|
2430
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(19325);
|
|
2431
|
+
|
|
2349
2432
|
|
|
2350
2433
|
|
|
2351
2434
|
|
|
2352
2435
|
|
|
2436
|
+
const log = _logger__WEBPACK_IMPORTED_MODULE_2__.coreLog.getLogger('utilities', 'getClosestImageId');
|
|
2353
2437
|
function getClosestImageId(imageVolume, worldPos, viewPlaneNormal, options) {
|
|
2354
2438
|
const { direction, spacing, imageIds } = imageVolume;
|
|
2355
2439
|
const { ignoreSpacing = false } = options || {};
|
|
@@ -2358,13 +2442,12 @@ function getClosestImageId(imageVolume, worldPos, viewPlaneNormal, options) {
|
|
|
2358
2442
|
}
|
|
2359
2443
|
const kVector = direction.slice(6, 9);
|
|
2360
2444
|
const dotProduct = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(kVector, viewPlaneNormal);
|
|
2361
|
-
if (Math.abs(dotProduct) < 1 -
|
|
2362
|
-
console.debug('View plane normal is not parallel to the image scan axis. Unable to find closest imageId.');
|
|
2445
|
+
if (Math.abs(dotProduct) < 1 - _constants__WEBPACK_IMPORTED_MODULE_4__.EPSILON) {
|
|
2363
2446
|
return;
|
|
2364
2447
|
}
|
|
2365
2448
|
let halfSpacingInNormalDirection;
|
|
2366
2449
|
if (!ignoreSpacing) {
|
|
2367
|
-
const spacingInNormalDirection = (0,
|
|
2450
|
+
const spacingInNormalDirection = (0,_getSpacingInNormalDirection__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A)({ direction, spacing }, viewPlaneNormal);
|
|
2368
2451
|
halfSpacingInNormalDirection = spacingInNormalDirection / 2;
|
|
2369
2452
|
}
|
|
2370
2453
|
let closestImageId;
|
|
@@ -2373,7 +2456,7 @@ function getClosestImageId(imageVolume, worldPos, viewPlaneNormal, options) {
|
|
|
2373
2456
|
const imageId = imageIds[i];
|
|
2374
2457
|
const imagePlaneModule = _metaData__WEBPACK_IMPORTED_MODULE_1__.get('imagePlaneModule', imageId);
|
|
2375
2458
|
if (!imagePlaneModule?.imagePositionPatient) {
|
|
2376
|
-
|
|
2459
|
+
log.warn(`Missing imagePositionPatient for imageId: ${imageId}`);
|
|
2377
2460
|
continue;
|
|
2378
2461
|
}
|
|
2379
2462
|
const { imagePositionPatient } = imagePlaneModule;
|
|
@@ -2394,7 +2477,7 @@ function getClosestImageId(imageVolume, worldPos, viewPlaneNormal, options) {
|
|
|
2394
2477
|
}
|
|
2395
2478
|
}
|
|
2396
2479
|
if (closestImageId === undefined) {
|
|
2397
|
-
|
|
2480
|
+
log.warn('No imageId found within the specified criteria (half spacing or absolute closest).');
|
|
2398
2481
|
}
|
|
2399
2482
|
return closestImageId;
|
|
2400
2483
|
}
|
|
@@ -2530,13 +2613,19 @@ function getScalingParameters(imageId) {
|
|
|
2530
2613
|
rescaleIntercept: modalityLutModule.rescaleIntercept ?? 0,
|
|
2531
2614
|
modality,
|
|
2532
2615
|
};
|
|
2533
|
-
const
|
|
2616
|
+
const scalingModules = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('scalingModule', imageId) || {};
|
|
2534
2617
|
return {
|
|
2535
2618
|
...scalingParameters,
|
|
2536
2619
|
...(modality === 'PT' && {
|
|
2537
|
-
suvbw:
|
|
2538
|
-
suvbsa:
|
|
2539
|
-
suvlbm:
|
|
2620
|
+
suvbw: scalingModules.suvbw,
|
|
2621
|
+
suvbsa: scalingModules.suvbsa,
|
|
2622
|
+
suvlbm: scalingModules.suvlbm,
|
|
2623
|
+
}),
|
|
2624
|
+
...(modality === 'RTDOSE' && {
|
|
2625
|
+
doseGridScaling: scalingModules.DoseGridScaling,
|
|
2626
|
+
doseSummation: scalingModules.DoseSummation,
|
|
2627
|
+
doseType: scalingModules.DoseType,
|
|
2628
|
+
doseUnit: scalingModules.DoseUnit,
|
|
2540
2629
|
}),
|
|
2541
2630
|
};
|
|
2542
2631
|
}
|
|
@@ -6657,7 +6746,7 @@ function updateViewports(enabledElement, targetAnnotation, sourceAnnotation) {
|
|
|
6657
6746
|
/* unused harmony exports default, internalConvertStackToVolumeLabelmap, internalComputeVolumeLabelmapFromStack */
|
|
6658
6747
|
/* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15327);
|
|
6659
6748
|
/* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(99737);
|
|
6660
|
-
/* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
6749
|
+
/* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(642);
|
|
6661
6750
|
/* harmony import */ var _kitware_vtk_js_Common_DataModel_PiecewiseFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(99341);
|
|
6662
6751
|
/* harmony import */ var _triggerSegmentationEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(49906);
|
|
6663
6752
|
/* harmony import */ var _SegmentationStyle__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(92686);
|
|
@@ -7300,13 +7389,16 @@ function normalizeSegments(segmentsConfig, type, data) {
|
|
|
7300
7389
|
const normalizedSegments = {};
|
|
7301
7390
|
if (segmentsConfig) {
|
|
7302
7391
|
Object.entries(segmentsConfig).forEach(([segmentIndex, segment]) => {
|
|
7303
|
-
|
|
7392
|
+
const { label, locked, cachedStats, active, ...rest } = segment;
|
|
7393
|
+
const normalizedSegment = {
|
|
7304
7394
|
segmentIndex: Number(segmentIndex),
|
|
7305
|
-
label:
|
|
7306
|
-
locked:
|
|
7307
|
-
cachedStats:
|
|
7308
|
-
active:
|
|
7395
|
+
label: label ?? `Segment ${segmentIndex}`,
|
|
7396
|
+
locked: locked ?? false,
|
|
7397
|
+
cachedStats: cachedStats ?? {},
|
|
7398
|
+
active: active ?? false,
|
|
7399
|
+
...rest,
|
|
7309
7400
|
};
|
|
7401
|
+
normalizedSegments[segmentIndex] = normalizedSegment;
|
|
7310
7402
|
});
|
|
7311
7403
|
}
|
|
7312
7404
|
else if (type === SegmentationRepresentations.Surface) {
|
|
@@ -8543,6 +8635,7 @@ class BidirectionalTool extends _base__WEBPACK_IMPORTED_MODULE_3__/* .Annotation
|
|
|
8543
8635
|
const [major0, major1] = majorAxis;
|
|
8544
8636
|
const [minor0, minor1] = minorAxis;
|
|
8545
8637
|
const points = [major0, major1, minor0, minor1];
|
|
8638
|
+
const { toolInstance, ...serializableOptions } = options || {};
|
|
8546
8639
|
const annotation = {
|
|
8547
8640
|
annotationUID: options?.annotationUID || _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.uuidv4(),
|
|
8548
8641
|
data: {
|
|
@@ -8572,7 +8665,7 @@ class BidirectionalTool extends _base__WEBPACK_IMPORTED_MODULE_3__/* .Annotation
|
|
|
8572
8665
|
viewPlaneNormal,
|
|
8573
8666
|
FrameOfReferenceUID,
|
|
8574
8667
|
referencedImageId,
|
|
8575
|
-
...
|
|
8668
|
+
...serializableOptions,
|
|
8576
8669
|
},
|
|
8577
8670
|
};
|
|
8578
8671
|
(0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_5__.addAnnotation)(annotation, viewport.element);
|
|
@@ -8939,6 +9032,9 @@ class BrushTool extends _LabelmapBaseTool__WEBPACK_IMPORTED_MODULE_10__/* ["defa
|
|
|
8939
9032
|
}
|
|
8940
9033
|
this.doneEditMemo();
|
|
8941
9034
|
const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.getEnabledElement)(element);
|
|
9035
|
+
if (!enabledElement) {
|
|
9036
|
+
return;
|
|
9037
|
+
}
|
|
8942
9038
|
this.applyActiveStrategyCallback(enabledElement, this.getOperationData(element), _enums__WEBPACK_IMPORTED_MODULE_2__.StrategyCallbacks.RejectPreview);
|
|
8943
9039
|
this._previewData.preview = null;
|
|
8944
9040
|
this._previewData.isDrag = false;
|
|
@@ -14015,7 +14111,7 @@ const computeWorker = {
|
|
|
14015
14111
|
};
|
|
14016
14112
|
},
|
|
14017
14113
|
calculateSegmentsStatisticsVolume: (args) => {
|
|
14018
|
-
const { mode, indices } = args;
|
|
14114
|
+
const { mode, indices, unit } = args;
|
|
14019
14115
|
const { segmentation, image } = computeWorker.getArgsFromInfo(args);
|
|
14020
14116
|
const { voxelManager: segVoxelManager, spacing: segmentationSpacing } = segmentation;
|
|
14021
14117
|
const { voxelManager: imageVoxelManager } = image;
|
|
@@ -14029,8 +14125,8 @@ const computeWorker = {
|
|
|
14029
14125
|
});
|
|
14030
14126
|
const stats = SegmentStatsCalculator.getStatistics({
|
|
14031
14127
|
spacing: segmentationSpacing,
|
|
14032
|
-
unit: 'mm',
|
|
14033
14128
|
mode,
|
|
14129
|
+
unit,
|
|
14034
14130
|
});
|
|
14035
14131
|
return stats;
|
|
14036
14132
|
},
|
|
@@ -14762,6 +14858,1250 @@ var vtkImageData$1 = {
|
|
|
14762
14858
|
|
|
14763
14859
|
|
|
14764
14860
|
|
|
14861
|
+
/***/ }),
|
|
14862
|
+
|
|
14863
|
+
/***/ 642:
|
|
14864
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
14865
|
+
|
|
14866
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
14867
|
+
/* harmony export */ Ay: () => (/* binding */ vtkColorTransferFunction$1)
|
|
14868
|
+
/* harmony export */ });
|
|
14869
|
+
/* unused harmony exports extend, newInstance */
|
|
14870
|
+
/* harmony import */ var _macros2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(28906);
|
|
14871
|
+
/* harmony import */ var _Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16632);
|
|
14872
|
+
/* harmony import */ var _Common_Core_ScalarsToColors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(80993);
|
|
14873
|
+
/* harmony import */ var _ColorTransferFunction_Constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(25128);
|
|
14874
|
+
|
|
14875
|
+
|
|
14876
|
+
|
|
14877
|
+
|
|
14878
|
+
|
|
14879
|
+
const {
|
|
14880
|
+
ColorSpace,
|
|
14881
|
+
Scale
|
|
14882
|
+
} = _ColorTransferFunction_Constants_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Ay;
|
|
14883
|
+
const {
|
|
14884
|
+
ScalarMappingTarget
|
|
14885
|
+
} = _Common_Core_ScalarsToColors_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Ay;
|
|
14886
|
+
const {
|
|
14887
|
+
vtkDebugMacro,
|
|
14888
|
+
vtkErrorMacro,
|
|
14889
|
+
vtkWarningMacro
|
|
14890
|
+
} = _macros2_js__WEBPACK_IMPORTED_MODULE_0__.m;
|
|
14891
|
+
|
|
14892
|
+
// ----------------------------------------------------------------------------
|
|
14893
|
+
// Global methods
|
|
14894
|
+
// ----------------------------------------------------------------------------
|
|
14895
|
+
/* eslint-disable no-continue */
|
|
14896
|
+
|
|
14897
|
+
// Convert to and from a special polar version of CIELAB (useful for creating
|
|
14898
|
+
// continuous diverging color maps).
|
|
14899
|
+
function vtkColorTransferFunctionLabToMsh(lab, msh) {
|
|
14900
|
+
const L = lab[0];
|
|
14901
|
+
const a = lab[1];
|
|
14902
|
+
const b = lab[2];
|
|
14903
|
+
const M = Math.sqrt(L * L + a * a + b * b);
|
|
14904
|
+
const s = M > 0.001 ? Math.acos(L / M) : 0.0;
|
|
14905
|
+
const h = s > 0.001 ? Math.atan2(b, a) : 0.0;
|
|
14906
|
+
msh[0] = M;
|
|
14907
|
+
msh[1] = s;
|
|
14908
|
+
msh[2] = h;
|
|
14909
|
+
}
|
|
14910
|
+
function vtkColorTransferFunctionMshToLab(msh, lab) {
|
|
14911
|
+
const M = msh[0];
|
|
14912
|
+
const s = msh[1];
|
|
14913
|
+
const h = msh[2];
|
|
14914
|
+
lab[0] = M * Math.cos(s);
|
|
14915
|
+
lab[1] = M * Math.sin(s) * Math.cos(h);
|
|
14916
|
+
lab[2] = M * Math.sin(s) * Math.sin(h);
|
|
14917
|
+
}
|
|
14918
|
+
|
|
14919
|
+
// For the case when interpolating from a saturated color to an unsaturated
|
|
14920
|
+
// color, find a hue for the unsaturated color that makes sense.
|
|
14921
|
+
function vtkColorTransferFunctionAdjustHue(msh, unsatM) {
|
|
14922
|
+
if (msh[0] >= unsatM - 0.1) {
|
|
14923
|
+
// The best we can do is hold hue constant.
|
|
14924
|
+
return msh[2];
|
|
14925
|
+
}
|
|
14926
|
+
|
|
14927
|
+
// This equation is designed to make the perceptual change of the
|
|
14928
|
+
// interpolation to be close to constant.
|
|
14929
|
+
const hueSpin = msh[1] * Math.sqrt(unsatM * unsatM - msh[0] * msh[0]) / (msh[0] * Math.sin(msh[1]));
|
|
14930
|
+
// Spin hue away from 0 except in purple hues.
|
|
14931
|
+
if (msh[2] > -0.3 * Math.PI) {
|
|
14932
|
+
return msh[2] + hueSpin;
|
|
14933
|
+
}
|
|
14934
|
+
return msh[2] - hueSpin;
|
|
14935
|
+
}
|
|
14936
|
+
function vtkColorTransferFunctionAngleDiff(a1, a2) {
|
|
14937
|
+
let adiff = a1 - a2;
|
|
14938
|
+
if (adiff < 0.0) {
|
|
14939
|
+
adiff = -adiff;
|
|
14940
|
+
}
|
|
14941
|
+
while (adiff >= 2.0 * Math.PI) {
|
|
14942
|
+
adiff -= 2.0 * Math.PI;
|
|
14943
|
+
}
|
|
14944
|
+
if (adiff > Math.PI) {
|
|
14945
|
+
adiff = 2.0 * Math.PI - adiff;
|
|
14946
|
+
}
|
|
14947
|
+
return adiff;
|
|
14948
|
+
}
|
|
14949
|
+
|
|
14950
|
+
// Interpolate a diverging color map.
|
|
14951
|
+
function vtkColorTransferFunctionInterpolateDiverging(s, rgb1, rgb2, result) {
|
|
14952
|
+
const lab1 = [];
|
|
14953
|
+
const lab2 = [];
|
|
14954
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.N)(rgb1, lab1);
|
|
14955
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.N)(rgb2, lab2);
|
|
14956
|
+
const msh1 = [];
|
|
14957
|
+
const msh2 = [];
|
|
14958
|
+
vtkColorTransferFunctionLabToMsh(lab1, msh1);
|
|
14959
|
+
vtkColorTransferFunctionLabToMsh(lab2, msh2);
|
|
14960
|
+
|
|
14961
|
+
// If the endpoints are distinct saturated colors, then place white in between
|
|
14962
|
+
// them.
|
|
14963
|
+
let localS = s;
|
|
14964
|
+
if (msh1[1] > 0.05 && msh2[1] > 0.05 && vtkColorTransferFunctionAngleDiff(msh1[2], msh2[2]) > 0.33 * Math.PI) {
|
|
14965
|
+
// Insert the white midpoint by setting one end to white and adjusting the
|
|
14966
|
+
// scalar value.
|
|
14967
|
+
let Mmid = Math.max(msh1[0], msh2[0]);
|
|
14968
|
+
Mmid = Math.max(88.0, Mmid);
|
|
14969
|
+
if (s < 0.5) {
|
|
14970
|
+
msh2[0] = Mmid;
|
|
14971
|
+
msh2[1] = 0.0;
|
|
14972
|
+
msh2[2] = 0.0;
|
|
14973
|
+
localS *= 2.0;
|
|
14974
|
+
} else {
|
|
14975
|
+
msh1[0] = Mmid;
|
|
14976
|
+
msh1[1] = 0.0;
|
|
14977
|
+
msh1[2] = 0.0;
|
|
14978
|
+
localS = 2.0 * localS - 1.0;
|
|
14979
|
+
}
|
|
14980
|
+
}
|
|
14981
|
+
|
|
14982
|
+
// If one color has no saturation, then its hue value is invalid. In this
|
|
14983
|
+
// case, we want to set it to something logical so that the interpolation of
|
|
14984
|
+
// hue makes sense.
|
|
14985
|
+
if (msh1[1] < 0.05 && msh2[1] > 0.05) {
|
|
14986
|
+
msh1[2] = vtkColorTransferFunctionAdjustHue(msh2, msh1[0]);
|
|
14987
|
+
} else if (msh2[1] < 0.05 && msh1[1] > 0.05) {
|
|
14988
|
+
msh2[2] = vtkColorTransferFunctionAdjustHue(msh1, msh2[0]);
|
|
14989
|
+
}
|
|
14990
|
+
const mshTmp = [];
|
|
14991
|
+
mshTmp[0] = (1 - localS) * msh1[0] + localS * msh2[0];
|
|
14992
|
+
mshTmp[1] = (1 - localS) * msh1[1] + localS * msh2[1];
|
|
14993
|
+
mshTmp[2] = (1 - localS) * msh1[2] + localS * msh2[2];
|
|
14994
|
+
|
|
14995
|
+
// Now convert back to RGB
|
|
14996
|
+
const labTmp = [];
|
|
14997
|
+
vtkColorTransferFunctionMshToLab(mshTmp, labTmp);
|
|
14998
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.O)(labTmp, result);
|
|
14999
|
+
}
|
|
15000
|
+
|
|
15001
|
+
// ----------------------------------------------------------------------------
|
|
15002
|
+
// vtkColorTransferFunction methods
|
|
15003
|
+
// ----------------------------------------------------------------------------
|
|
15004
|
+
|
|
15005
|
+
function vtkColorTransferFunction(publicAPI, model) {
|
|
15006
|
+
// Set our className
|
|
15007
|
+
model.classHierarchy.push('vtkColorTransferFunction');
|
|
15008
|
+
|
|
15009
|
+
// Return the number of points which specify this function
|
|
15010
|
+
publicAPI.getSize = () => model.nodes.length;
|
|
15011
|
+
|
|
15012
|
+
//----------------------------------------------------------------------------
|
|
15013
|
+
// Add a point defined in RGB
|
|
15014
|
+
publicAPI.addRGBPoint = (x, r, g, b) => publicAPI.addRGBPointLong(x, r, g, b, 0.5, 0.0);
|
|
15015
|
+
|
|
15016
|
+
//----------------------------------------------------------------------------
|
|
15017
|
+
// Add a point defined in RGB
|
|
15018
|
+
publicAPI.addRGBPointLong = function (x, r, g, b) {
|
|
15019
|
+
let midpoint = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0.5;
|
|
15020
|
+
let sharpness = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0.0;
|
|
15021
|
+
// Error check
|
|
15022
|
+
if (midpoint < 0.0 || midpoint > 1.0) {
|
|
15023
|
+
vtkErrorMacro('Midpoint outside range [0.0, 1.0]');
|
|
15024
|
+
return -1;
|
|
15025
|
+
}
|
|
15026
|
+
if (sharpness < 0.0 || sharpness > 1.0) {
|
|
15027
|
+
vtkErrorMacro('Sharpness outside range [0.0, 1.0]');
|
|
15028
|
+
return -1;
|
|
15029
|
+
}
|
|
15030
|
+
|
|
15031
|
+
// remove any node already at this X location
|
|
15032
|
+
if (!model.allowDuplicateScalars) {
|
|
15033
|
+
publicAPI.removePoint(x);
|
|
15034
|
+
}
|
|
15035
|
+
|
|
15036
|
+
// Create the new node
|
|
15037
|
+
const node = {
|
|
15038
|
+
x,
|
|
15039
|
+
r,
|
|
15040
|
+
g,
|
|
15041
|
+
b,
|
|
15042
|
+
midpoint,
|
|
15043
|
+
sharpness
|
|
15044
|
+
};
|
|
15045
|
+
|
|
15046
|
+
// Add it, then sort to get everything in order
|
|
15047
|
+
model.nodes.push(node);
|
|
15048
|
+
publicAPI.sortAndUpdateRange();
|
|
15049
|
+
|
|
15050
|
+
// We need to find the index of the node we just added in order
|
|
15051
|
+
// to return this value
|
|
15052
|
+
let i = 0;
|
|
15053
|
+
for (; i < model.nodes.length; i++) {
|
|
15054
|
+
if (model.nodes[i].x === x) {
|
|
15055
|
+
break;
|
|
15056
|
+
}
|
|
15057
|
+
}
|
|
15058
|
+
|
|
15059
|
+
// If we didn't find it, something went horribly wrong so
|
|
15060
|
+
// return -1
|
|
15061
|
+
if (i < model.nodes.length) {
|
|
15062
|
+
return i;
|
|
15063
|
+
}
|
|
15064
|
+
return -1;
|
|
15065
|
+
};
|
|
15066
|
+
|
|
15067
|
+
//----------------------------------------------------------------------------
|
|
15068
|
+
// Add a point defined in HSV
|
|
15069
|
+
publicAPI.addHSVPoint = (x, h, s, v) => publicAPI.addHSVPointLong(x, h, s, v, 0.5, 0.0);
|
|
15070
|
+
|
|
15071
|
+
//----------------------------------------------------------------------------
|
|
15072
|
+
// Add a point defined in HSV
|
|
15073
|
+
publicAPI.addHSVPointLong = function (x, h, s, v) {
|
|
15074
|
+
let midpoint = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0.5;
|
|
15075
|
+
let sharpness = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0.0;
|
|
15076
|
+
const rgb = [];
|
|
15077
|
+
const hsv = [h, s, v];
|
|
15078
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.h)(hsv, rgb);
|
|
15079
|
+
return publicAPI.addRGBPoint(x, rgb[0], rgb[1], rgb[2], midpoint, sharpness);
|
|
15080
|
+
};
|
|
15081
|
+
|
|
15082
|
+
//----------------------------------------------------------------------------
|
|
15083
|
+
// Set nodes directly
|
|
15084
|
+
publicAPI.setNodes = nodes => {
|
|
15085
|
+
if (model.nodes !== nodes) {
|
|
15086
|
+
const before = JSON.stringify(model.nodes);
|
|
15087
|
+
model.nodes = nodes;
|
|
15088
|
+
const after = JSON.stringify(model.nodes);
|
|
15089
|
+
if (publicAPI.sortAndUpdateRange() || before !== after) {
|
|
15090
|
+
publicAPI.modified();
|
|
15091
|
+
return true;
|
|
15092
|
+
}
|
|
15093
|
+
}
|
|
15094
|
+
return false;
|
|
15095
|
+
};
|
|
15096
|
+
|
|
15097
|
+
//----------------------------------------------------------------------------
|
|
15098
|
+
// Sort the vector in increasing order, then fill in
|
|
15099
|
+
// the Range
|
|
15100
|
+
publicAPI.sortAndUpdateRange = () => {
|
|
15101
|
+
const before = JSON.stringify(model.nodes);
|
|
15102
|
+
model.nodes.sort((a, b) => a.x - b.x);
|
|
15103
|
+
const after = JSON.stringify(model.nodes);
|
|
15104
|
+
const modifiedInvoked = publicAPI.updateRange();
|
|
15105
|
+
// If range is updated, Modified() has been called, don't call it again.
|
|
15106
|
+
if (!modifiedInvoked && before !== after) {
|
|
15107
|
+
publicAPI.modified();
|
|
15108
|
+
return true;
|
|
15109
|
+
}
|
|
15110
|
+
return modifiedInvoked;
|
|
15111
|
+
};
|
|
15112
|
+
|
|
15113
|
+
//----------------------------------------------------------------------------
|
|
15114
|
+
publicAPI.updateRange = () => {
|
|
15115
|
+
const oldRange = [2];
|
|
15116
|
+
oldRange[0] = model.mappingRange[0];
|
|
15117
|
+
oldRange[1] = model.mappingRange[1];
|
|
15118
|
+
const size = model.nodes.length;
|
|
15119
|
+
if (size) {
|
|
15120
|
+
model.mappingRange[0] = model.nodes[0].x;
|
|
15121
|
+
model.mappingRange[1] = model.nodes[size - 1].x;
|
|
15122
|
+
} else {
|
|
15123
|
+
model.mappingRange[0] = 0;
|
|
15124
|
+
model.mappingRange[1] = 0;
|
|
15125
|
+
}
|
|
15126
|
+
|
|
15127
|
+
// If the range is the same, then no need to call Modified()
|
|
15128
|
+
if (oldRange[0] === model.mappingRange[0] && oldRange[1] === model.mappingRange[1]) {
|
|
15129
|
+
return false;
|
|
15130
|
+
}
|
|
15131
|
+
publicAPI.modified();
|
|
15132
|
+
return true;
|
|
15133
|
+
};
|
|
15134
|
+
|
|
15135
|
+
//----------------------------------------------------------------------------
|
|
15136
|
+
// Remove a point
|
|
15137
|
+
publicAPI.removePoint = x => {
|
|
15138
|
+
// First find the node since we need to know its
|
|
15139
|
+
// index as our return value
|
|
15140
|
+
let i = 0;
|
|
15141
|
+
for (; i < model.nodes.length; i++) {
|
|
15142
|
+
if (model.nodes[i].x === x) {
|
|
15143
|
+
break;
|
|
15144
|
+
}
|
|
15145
|
+
}
|
|
15146
|
+
const retVal = i;
|
|
15147
|
+
|
|
15148
|
+
// If the node doesn't exist, we return -1
|
|
15149
|
+
if (i >= model.nodes.length) {
|
|
15150
|
+
return -1;
|
|
15151
|
+
}
|
|
15152
|
+
|
|
15153
|
+
// If the first or last point has been removed, then we update the range
|
|
15154
|
+
// No need to sort here as the order of points hasn't changed.
|
|
15155
|
+
let modifiedInvoked = false;
|
|
15156
|
+
model.nodes.splice(i, 1);
|
|
15157
|
+
if (i === 0 || i === model.nodes.length) {
|
|
15158
|
+
modifiedInvoked = publicAPI.updateRange();
|
|
15159
|
+
}
|
|
15160
|
+
if (!modifiedInvoked) {
|
|
15161
|
+
publicAPI.modified();
|
|
15162
|
+
}
|
|
15163
|
+
return retVal;
|
|
15164
|
+
};
|
|
15165
|
+
|
|
15166
|
+
//----------------------------------------------------------------------------
|
|
15167
|
+
publicAPI.movePoint = (oldX, newX) => {
|
|
15168
|
+
if (oldX === newX) {
|
|
15169
|
+
// Nothing to do.
|
|
15170
|
+
return;
|
|
15171
|
+
}
|
|
15172
|
+
publicAPI.removePoint(newX);
|
|
15173
|
+
for (let i = 0; i < model.nodes.length; i++) {
|
|
15174
|
+
if (model.nodes[i].x === oldX) {
|
|
15175
|
+
model.nodes[i].x = newX;
|
|
15176
|
+
publicAPI.sortAndUpdateRange();
|
|
15177
|
+
break;
|
|
15178
|
+
}
|
|
15179
|
+
}
|
|
15180
|
+
};
|
|
15181
|
+
|
|
15182
|
+
//----------------------------------------------------------------------------
|
|
15183
|
+
// Remove all points
|
|
15184
|
+
publicAPI.removeAllPoints = () => {
|
|
15185
|
+
model.nodes = [];
|
|
15186
|
+
publicAPI.sortAndUpdateRange();
|
|
15187
|
+
};
|
|
15188
|
+
|
|
15189
|
+
//----------------------------------------------------------------------------
|
|
15190
|
+
// Add a line defined in RGB
|
|
15191
|
+
publicAPI.addRGBSegment = (x1, r1, g1, b1, x2, r2, g2, b2) => {
|
|
15192
|
+
// First, find all points in this range and remove them
|
|
15193
|
+
publicAPI.sortAndUpdateRange();
|
|
15194
|
+
for (let i = 0; i < model.nodes.length;) {
|
|
15195
|
+
if (model.nodes[i].x >= x1 && model.nodes[i].x <= x2) {
|
|
15196
|
+
model.nodes.splice(i, 1);
|
|
15197
|
+
} else {
|
|
15198
|
+
i++;
|
|
15199
|
+
}
|
|
15200
|
+
}
|
|
15201
|
+
|
|
15202
|
+
// Now add the points
|
|
15203
|
+
publicAPI.addRGBPointLong(x1, r1, g1, b1, 0.5, 0.0);
|
|
15204
|
+
publicAPI.addRGBPointLong(x2, r2, g2, b2, 0.5, 0.0);
|
|
15205
|
+
publicAPI.modified();
|
|
15206
|
+
};
|
|
15207
|
+
|
|
15208
|
+
//----------------------------------------------------------------------------
|
|
15209
|
+
// Add a line defined in HSV
|
|
15210
|
+
publicAPI.addHSVSegment = (x1, h1, s1, v1, x2, h2, s2, v2) => {
|
|
15211
|
+
const hsv1 = [h1, s1, v1];
|
|
15212
|
+
const hsv2 = [h2, s2, v2];
|
|
15213
|
+
const rgb1 = [];
|
|
15214
|
+
const rgb2 = [];
|
|
15215
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.h)(hsv1, rgb1);
|
|
15216
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.h)(hsv2, rgb2);
|
|
15217
|
+
publicAPI.addRGBSegment(x1, rgb1[0], rgb1[1], rgb1[2], x2, rgb2[0], rgb2[1], rgb2[2]);
|
|
15218
|
+
};
|
|
15219
|
+
|
|
15220
|
+
//----------------------------------------------------------------------------
|
|
15221
|
+
// Returns the RGBA color evaluated at the specified location
|
|
15222
|
+
publicAPI.mapValue = x => {
|
|
15223
|
+
const rgb = [];
|
|
15224
|
+
publicAPI.getColor(x, rgb);
|
|
15225
|
+
return [Math.floor(255.0 * rgb[0] + 0.5), Math.floor(255.0 * rgb[1] + 0.5), Math.floor(255.0 * rgb[2] + 0.5), 255];
|
|
15226
|
+
};
|
|
15227
|
+
|
|
15228
|
+
//----------------------------------------------------------------------------
|
|
15229
|
+
// Returns the RGB color evaluated at the specified location
|
|
15230
|
+
publicAPI.getColor = (x, rgb) => {
|
|
15231
|
+
if (model.indexedLookup) {
|
|
15232
|
+
const numNodes = publicAPI.getSize();
|
|
15233
|
+
// todo
|
|
15234
|
+
const idx = publicAPI.getAnnotatedValueIndexInternal(x);
|
|
15235
|
+
if (idx < 0 || numNodes === 0) {
|
|
15236
|
+
const nanColor = publicAPI.getNanColorByReference();
|
|
15237
|
+
rgb[0] = nanColor[0];
|
|
15238
|
+
rgb[1] = nanColor[1];
|
|
15239
|
+
rgb[2] = nanColor[2];
|
|
15240
|
+
} else {
|
|
15241
|
+
const nodeVal = [];
|
|
15242
|
+
publicAPI.getNodeValue(idx % numNodes, nodeVal);
|
|
15243
|
+
// nodeVal[0] is the x value. nodeVal[1...3] is rgb.
|
|
15244
|
+
rgb[0] = nodeVal[1];
|
|
15245
|
+
rgb[1] = nodeVal[2];
|
|
15246
|
+
rgb[2] = nodeVal[3];
|
|
15247
|
+
}
|
|
15248
|
+
return;
|
|
15249
|
+
}
|
|
15250
|
+
publicAPI.getTable(x, x, 1, rgb);
|
|
15251
|
+
};
|
|
15252
|
+
|
|
15253
|
+
//----------------------------------------------------------------------------
|
|
15254
|
+
// Returns the red color evaluated at the specified location
|
|
15255
|
+
publicAPI.getRedValue = x => {
|
|
15256
|
+
const rgb = [];
|
|
15257
|
+
publicAPI.getColor(x, rgb);
|
|
15258
|
+
return rgb[0];
|
|
15259
|
+
};
|
|
15260
|
+
|
|
15261
|
+
//----------------------------------------------------------------------------
|
|
15262
|
+
// Returns the green color evaluated at the specified location
|
|
15263
|
+
publicAPI.getGreenValue = x => {
|
|
15264
|
+
const rgb = [];
|
|
15265
|
+
publicAPI.getColor(x, rgb);
|
|
15266
|
+
return rgb[1];
|
|
15267
|
+
};
|
|
15268
|
+
|
|
15269
|
+
//----------------------------------------------------------------------------
|
|
15270
|
+
// Returns the blue color evaluated at the specified location
|
|
15271
|
+
publicAPI.getBlueValue = x => {
|
|
15272
|
+
const rgb = [];
|
|
15273
|
+
publicAPI.getColor(x, rgb);
|
|
15274
|
+
return rgb[2];
|
|
15275
|
+
};
|
|
15276
|
+
|
|
15277
|
+
//----------------------------------------------------------------------------
|
|
15278
|
+
// Returns a table of RGB colors at regular intervals along the function
|
|
15279
|
+
publicAPI.getTable = (xStart_, xEnd_, size, table) => {
|
|
15280
|
+
// To handle BigInt limitation
|
|
15281
|
+
const xStart = Number(xStart_);
|
|
15282
|
+
const xEnd = Number(xEnd_);
|
|
15283
|
+
|
|
15284
|
+
// Special case: If either the start or end is a NaN, then all any
|
|
15285
|
+
// interpolation done on them is also a NaN. Therefore, fill the table with
|
|
15286
|
+
// the NaN color.
|
|
15287
|
+
if ((0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.i)(xStart) || (0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.i)(xEnd)) {
|
|
15288
|
+
for (let i = 0; i < size; i++) {
|
|
15289
|
+
table[i * 3 + 0] = model.nanColor[0];
|
|
15290
|
+
table[i * 3 + 1] = model.nanColor[1];
|
|
15291
|
+
table[i * 3 + 2] = model.nanColor[2];
|
|
15292
|
+
}
|
|
15293
|
+
return;
|
|
15294
|
+
}
|
|
15295
|
+
let idx = 0;
|
|
15296
|
+
const numNodes = model.nodes.length;
|
|
15297
|
+
|
|
15298
|
+
// Need to keep track of the last value so that
|
|
15299
|
+
// we can fill in table locations past this with
|
|
15300
|
+
// this value if Clamping is On.
|
|
15301
|
+
let lastR = 0.0;
|
|
15302
|
+
let lastG = 0.0;
|
|
15303
|
+
let lastB = 0.0;
|
|
15304
|
+
if (numNodes !== 0) {
|
|
15305
|
+
lastR = model.nodes[numNodes - 1].r;
|
|
15306
|
+
lastG = model.nodes[numNodes - 1].g;
|
|
15307
|
+
lastB = model.nodes[numNodes - 1].b;
|
|
15308
|
+
}
|
|
15309
|
+
let x = 0.0;
|
|
15310
|
+
let x1 = 0.0;
|
|
15311
|
+
let x2 = 0.0;
|
|
15312
|
+
const rgb1 = [0.0, 0.0, 0.0];
|
|
15313
|
+
const rgb2 = [0.0, 0.0, 0.0];
|
|
15314
|
+
let midpoint = 0.0;
|
|
15315
|
+
let sharpness = 0.0;
|
|
15316
|
+
const tmpVec = [];
|
|
15317
|
+
|
|
15318
|
+
// If the scale is logarithmic, make sure the range is valid.
|
|
15319
|
+
let usingLogScale = model.scale === Scale.LOG10;
|
|
15320
|
+
if (usingLogScale) {
|
|
15321
|
+
// Note: This requires range[0] <= range[1].
|
|
15322
|
+
usingLogScale = model.mappingRange[0] > 0.0;
|
|
15323
|
+
}
|
|
15324
|
+
let logStart = 0.0;
|
|
15325
|
+
let logEnd = 0.0;
|
|
15326
|
+
let logX = 0.0;
|
|
15327
|
+
if (usingLogScale) {
|
|
15328
|
+
logStart = Math.log10(xStart);
|
|
15329
|
+
logEnd = Math.log10(xEnd);
|
|
15330
|
+
}
|
|
15331
|
+
|
|
15332
|
+
// For each table entry
|
|
15333
|
+
for (let i = 0; i < size; i++) {
|
|
15334
|
+
// Find our location in the table
|
|
15335
|
+
const tidx = 3 * i;
|
|
15336
|
+
|
|
15337
|
+
// Find our X location. If we are taking only 1 sample, make
|
|
15338
|
+
// it halfway between start and end (usually start and end will
|
|
15339
|
+
// be the same in this case)
|
|
15340
|
+
if (size > 1) {
|
|
15341
|
+
if (usingLogScale) {
|
|
15342
|
+
logX = logStart + i / (size - 1.0) * (logEnd - logStart);
|
|
15343
|
+
x = 10.0 ** logX;
|
|
15344
|
+
} else {
|
|
15345
|
+
x = xStart + i / (size - 1.0) * (xEnd - xStart);
|
|
15346
|
+
}
|
|
15347
|
+
} else if (usingLogScale) {
|
|
15348
|
+
logX = 0.5 * (logStart + logEnd);
|
|
15349
|
+
x = 10.0 ** logX;
|
|
15350
|
+
} else {
|
|
15351
|
+
x = 0.5 * (xStart + xEnd);
|
|
15352
|
+
}
|
|
15353
|
+
|
|
15354
|
+
// Linearly map x from mappingRange to [0, numberOfValues-1],
|
|
15355
|
+
// discretize (round down to the closest integer),
|
|
15356
|
+
// then map back to mappingRange
|
|
15357
|
+
if (model.discretize) {
|
|
15358
|
+
const range = model.mappingRange;
|
|
15359
|
+
if (x >= range[0] && x <= range[1]) {
|
|
15360
|
+
const numberOfValues = model.numberOfValues;
|
|
15361
|
+
const deltaRange = range[1] - range[0];
|
|
15362
|
+
if (numberOfValues <= 1) {
|
|
15363
|
+
x = range[0] + deltaRange / 2.0;
|
|
15364
|
+
} else {
|
|
15365
|
+
// normalize x
|
|
15366
|
+
const xn = (x - range[0]) / deltaRange;
|
|
15367
|
+
// discretize
|
|
15368
|
+
const discretizeIndex = (0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.K)(numberOfValues * xn);
|
|
15369
|
+
// get discretized x
|
|
15370
|
+
x = range[0] + discretizeIndex / (numberOfValues - 1) * deltaRange;
|
|
15371
|
+
}
|
|
15372
|
+
}
|
|
15373
|
+
}
|
|
15374
|
+
|
|
15375
|
+
// Do we need to move to the next node?
|
|
15376
|
+
while (idx < numNodes && x > model.nodes[idx].x) {
|
|
15377
|
+
idx++;
|
|
15378
|
+
// If we are at a valid point index, fill in
|
|
15379
|
+
// the value at this node, and the one before (the
|
|
15380
|
+
// two that surround our current sample location)
|
|
15381
|
+
// idx cannot be 0 since we just incremented it.
|
|
15382
|
+
if (idx < numNodes) {
|
|
15383
|
+
x1 = model.nodes[idx - 1].x;
|
|
15384
|
+
x2 = model.nodes[idx].x;
|
|
15385
|
+
if (usingLogScale) {
|
|
15386
|
+
x1 = Math.log10(x1);
|
|
15387
|
+
x2 = Math.log10(x2);
|
|
15388
|
+
}
|
|
15389
|
+
rgb1[0] = model.nodes[idx - 1].r;
|
|
15390
|
+
rgb2[0] = model.nodes[idx].r;
|
|
15391
|
+
rgb1[1] = model.nodes[idx - 1].g;
|
|
15392
|
+
rgb2[1] = model.nodes[idx].g;
|
|
15393
|
+
rgb1[2] = model.nodes[idx - 1].b;
|
|
15394
|
+
rgb2[2] = model.nodes[idx].b;
|
|
15395
|
+
|
|
15396
|
+
// We only need the previous midpoint and sharpness
|
|
15397
|
+
// since these control this region
|
|
15398
|
+
midpoint = model.nodes[idx - 1].midpoint;
|
|
15399
|
+
sharpness = model.nodes[idx - 1].sharpness;
|
|
15400
|
+
|
|
15401
|
+
// Move midpoint away from extreme ends of range to avoid
|
|
15402
|
+
// degenerate math
|
|
15403
|
+
if (midpoint < 0.00001) {
|
|
15404
|
+
midpoint = 0.00001;
|
|
15405
|
+
}
|
|
15406
|
+
if (midpoint > 0.99999) {
|
|
15407
|
+
midpoint = 0.99999;
|
|
15408
|
+
}
|
|
15409
|
+
}
|
|
15410
|
+
}
|
|
15411
|
+
|
|
15412
|
+
// Are we at or past the end? If so, just use the last value
|
|
15413
|
+
if (x > model.mappingRange[1]) {
|
|
15414
|
+
table[tidx] = 0.0;
|
|
15415
|
+
table[tidx + 1] = 0.0;
|
|
15416
|
+
table[tidx + 2] = 0.0;
|
|
15417
|
+
if (model.clamping) {
|
|
15418
|
+
if (publicAPI.getUseAboveRangeColor()) {
|
|
15419
|
+
table[tidx] = model.aboveRangeColor[0];
|
|
15420
|
+
table[tidx + 1] = model.aboveRangeColor[1];
|
|
15421
|
+
table[tidx + 2] = model.aboveRangeColor[2];
|
|
15422
|
+
} else {
|
|
15423
|
+
table[tidx] = lastR;
|
|
15424
|
+
table[tidx + 1] = lastG;
|
|
15425
|
+
table[tidx + 2] = lastB;
|
|
15426
|
+
}
|
|
15427
|
+
}
|
|
15428
|
+
} else if (x < model.mappingRange[0] || (0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.L)(x) && x < 0) {
|
|
15429
|
+
// we are before the first node? If so, duplicate this node's values.
|
|
15430
|
+
// We have to deal with -inf here
|
|
15431
|
+
table[tidx] = 0.0;
|
|
15432
|
+
table[tidx + 1] = 0.0;
|
|
15433
|
+
table[tidx + 2] = 0.0;
|
|
15434
|
+
if (model.clamping) {
|
|
15435
|
+
if (publicAPI.getUseBelowRangeColor()) {
|
|
15436
|
+
table[tidx] = model.belowRangeColor[0];
|
|
15437
|
+
table[tidx + 1] = model.belowRangeColor[1];
|
|
15438
|
+
table[tidx + 2] = model.belowRangeColor[2];
|
|
15439
|
+
} else if (numNodes > 0) {
|
|
15440
|
+
table[tidx] = model.nodes[0].r;
|
|
15441
|
+
table[tidx + 1] = model.nodes[0].g;
|
|
15442
|
+
table[tidx + 2] = model.nodes[0].b;
|
|
15443
|
+
}
|
|
15444
|
+
}
|
|
15445
|
+
} else if (idx === 0 && (Math.abs(x - xStart) < 1e-6 || model.discretize)) {
|
|
15446
|
+
if (numNodes > 0) {
|
|
15447
|
+
table[tidx] = model.nodes[0].r;
|
|
15448
|
+
table[tidx + 1] = model.nodes[0].g;
|
|
15449
|
+
table[tidx + 2] = model.nodes[0].b;
|
|
15450
|
+
} else {
|
|
15451
|
+
table[tidx] = 0.0;
|
|
15452
|
+
table[tidx + 1] = 0.0;
|
|
15453
|
+
table[tidx + 2] = 0.0;
|
|
15454
|
+
}
|
|
15455
|
+
} else {
|
|
15456
|
+
// OK, we are between two nodes - interpolate
|
|
15457
|
+
// Our first attempt at a normalized location [0,1] -
|
|
15458
|
+
// we will be modifying this based on midpoint and
|
|
15459
|
+
// sharpness to get the curve shape we want and to have
|
|
15460
|
+
// it pass through (y1+y2)/2 at the midpoint.
|
|
15461
|
+
let s = 0.0;
|
|
15462
|
+
if (usingLogScale) {
|
|
15463
|
+
s = (logX - x1) / (x2 - x1);
|
|
15464
|
+
} else {
|
|
15465
|
+
s = (x - x1) / (x2 - x1);
|
|
15466
|
+
}
|
|
15467
|
+
|
|
15468
|
+
// Readjust based on the midpoint - linear adjustment
|
|
15469
|
+
if (s < midpoint) {
|
|
15470
|
+
s = 0.5 * s / midpoint;
|
|
15471
|
+
} else {
|
|
15472
|
+
s = 0.5 + 0.5 * (s - midpoint) / (1.0 - midpoint);
|
|
15473
|
+
}
|
|
15474
|
+
|
|
15475
|
+
// override for sharpness > 0.99
|
|
15476
|
+
// In this case we just want piecewise constant
|
|
15477
|
+
if (sharpness > 0.99) {
|
|
15478
|
+
// Use the first value since we are below the midpoint
|
|
15479
|
+
if (s < 0.5) {
|
|
15480
|
+
table[tidx] = rgb1[0];
|
|
15481
|
+
table[tidx + 1] = rgb1[1];
|
|
15482
|
+
table[tidx + 2] = rgb1[2];
|
|
15483
|
+
continue;
|
|
15484
|
+
} else {
|
|
15485
|
+
// Use the second value at or above the midpoint
|
|
15486
|
+
table[tidx] = rgb2[0];
|
|
15487
|
+
table[tidx + 1] = rgb2[1];
|
|
15488
|
+
table[tidx + 2] = rgb2[2];
|
|
15489
|
+
continue;
|
|
15490
|
+
}
|
|
15491
|
+
}
|
|
15492
|
+
|
|
15493
|
+
// Override for sharpness < 0.01
|
|
15494
|
+
// In this case we want piecewise linear
|
|
15495
|
+
if (sharpness < 0.01) {
|
|
15496
|
+
// Simple linear interpolation
|
|
15497
|
+
if (model.colorSpace === ColorSpace.RGB) {
|
|
15498
|
+
table[tidx] = (1 - s) * rgb1[0] + s * rgb2[0];
|
|
15499
|
+
table[tidx + 1] = (1 - s) * rgb1[1] + s * rgb2[1];
|
|
15500
|
+
table[tidx + 2] = (1 - s) * rgb1[2] + s * rgb2[2];
|
|
15501
|
+
} else if (model.colorSpace === ColorSpace.HSV) {
|
|
15502
|
+
const hsv1 = [];
|
|
15503
|
+
const hsv2 = [];
|
|
15504
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.M)(rgb1, hsv1);
|
|
15505
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.M)(rgb2, hsv2);
|
|
15506
|
+
if (model.hSVWrap && (hsv1[0] - hsv2[0] > 0.5 || hsv2[0] - hsv1[0] > 0.5)) {
|
|
15507
|
+
if (hsv1[0] > hsv2[0]) {
|
|
15508
|
+
hsv1[0] -= 1.0;
|
|
15509
|
+
} else {
|
|
15510
|
+
hsv2[0] -= 1.0;
|
|
15511
|
+
}
|
|
15512
|
+
}
|
|
15513
|
+
const hsvTmp = [];
|
|
15514
|
+
hsvTmp[0] = (1.0 - s) * hsv1[0] + s * hsv2[0];
|
|
15515
|
+
if (hsvTmp[0] < 0.0) {
|
|
15516
|
+
hsvTmp[0] += 1.0;
|
|
15517
|
+
}
|
|
15518
|
+
hsvTmp[1] = (1.0 - s) * hsv1[1] + s * hsv2[1];
|
|
15519
|
+
hsvTmp[2] = (1.0 - s) * hsv1[2] + s * hsv2[2];
|
|
15520
|
+
|
|
15521
|
+
// Now convert this back to RGB
|
|
15522
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.h)(hsvTmp, tmpVec);
|
|
15523
|
+
table[tidx] = tmpVec[0];
|
|
15524
|
+
table[tidx + 1] = tmpVec[1];
|
|
15525
|
+
table[tidx + 2] = tmpVec[2];
|
|
15526
|
+
} else if (model.colorSpace === ColorSpace.LAB) {
|
|
15527
|
+
const lab1 = [];
|
|
15528
|
+
const lab2 = [];
|
|
15529
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.N)(rgb1, lab1);
|
|
15530
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.N)(rgb2, lab2);
|
|
15531
|
+
const labTmp = [];
|
|
15532
|
+
labTmp[0] = (1 - s) * lab1[0] + s * lab2[0];
|
|
15533
|
+
labTmp[1] = (1 - s) * lab1[1] + s * lab2[1];
|
|
15534
|
+
labTmp[2] = (1 - s) * lab1[2] + s * lab2[2];
|
|
15535
|
+
|
|
15536
|
+
// Now convert back to RGB
|
|
15537
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.O)(labTmp, tmpVec);
|
|
15538
|
+
table[tidx] = tmpVec[0];
|
|
15539
|
+
table[tidx + 1] = tmpVec[1];
|
|
15540
|
+
table[tidx + 2] = tmpVec[2];
|
|
15541
|
+
} else if (model.colorSpace === ColorSpace.DIVERGING) {
|
|
15542
|
+
vtkColorTransferFunctionInterpolateDiverging(s, rgb1, rgb2, tmpVec);
|
|
15543
|
+
table[tidx] = tmpVec[0];
|
|
15544
|
+
table[tidx + 1] = tmpVec[1];
|
|
15545
|
+
table[tidx + 2] = tmpVec[2];
|
|
15546
|
+
} else {
|
|
15547
|
+
vtkErrorMacro('ColorSpace set to invalid value.', model.colorSpace);
|
|
15548
|
+
}
|
|
15549
|
+
continue;
|
|
15550
|
+
}
|
|
15551
|
+
|
|
15552
|
+
// We have a sharpness between [0.01, 0.99] - we will
|
|
15553
|
+
// used a modified hermite curve interpolation where we
|
|
15554
|
+
// derive the slope based on the sharpness, and we compress
|
|
15555
|
+
// the curve non-linearly based on the sharpness
|
|
15556
|
+
|
|
15557
|
+
// First, we will adjust our position based on sharpness in
|
|
15558
|
+
// order to make the curve sharper (closer to piecewise constant)
|
|
15559
|
+
if (s < 0.5) {
|
|
15560
|
+
s = 0.5 * (s * 2.0) ** (1.0 + 10.0 * sharpness);
|
|
15561
|
+
} else if (s > 0.5) {
|
|
15562
|
+
s = 1.0 - 0.5 * ((1.0 - s) * 2) ** (1 + 10.0 * sharpness);
|
|
15563
|
+
}
|
|
15564
|
+
|
|
15565
|
+
// Compute some coefficients we will need for the hermite curve
|
|
15566
|
+
const ss = s * s;
|
|
15567
|
+
const sss = ss * s;
|
|
15568
|
+
const h1 = 2.0 * sss - 3 * ss + 1;
|
|
15569
|
+
const h2 = -2 * sss + 3 * ss;
|
|
15570
|
+
const h3 = sss - 2 * ss + s;
|
|
15571
|
+
const h4 = sss - ss;
|
|
15572
|
+
let slope;
|
|
15573
|
+
let t;
|
|
15574
|
+
if (model.colorSpace === ColorSpace.RGB) {
|
|
15575
|
+
for (let j = 0; j < 3; j++) {
|
|
15576
|
+
// Use one slope for both end points
|
|
15577
|
+
slope = rgb2[j] - rgb1[j];
|
|
15578
|
+
t = (1.0 - sharpness) * slope;
|
|
15579
|
+
|
|
15580
|
+
// Compute the value
|
|
15581
|
+
table[tidx + j] = h1 * rgb1[j] + h2 * rgb2[j] + h3 * t + h4 * t;
|
|
15582
|
+
}
|
|
15583
|
+
} else if (model.colorSpace === ColorSpace.HSV) {
|
|
15584
|
+
const hsv1 = [];
|
|
15585
|
+
const hsv2 = [];
|
|
15586
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.M)(rgb1, hsv1);
|
|
15587
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.M)(rgb2, hsv2);
|
|
15588
|
+
if (model.hSVWrap && (hsv1[0] - hsv2[0] > 0.5 || hsv2[0] - hsv1[0] > 0.5)) {
|
|
15589
|
+
if (hsv1[0] > hsv2[0]) {
|
|
15590
|
+
hsv1[0] -= 1.0;
|
|
15591
|
+
} else {
|
|
15592
|
+
hsv2[0] -= 1.0;
|
|
15593
|
+
}
|
|
15594
|
+
}
|
|
15595
|
+
const hsvTmp = [];
|
|
15596
|
+
for (let j = 0; j < 3; j++) {
|
|
15597
|
+
// Use one slope for both end points
|
|
15598
|
+
slope = hsv2[j] - hsv1[j];
|
|
15599
|
+
t = (1.0 - sharpness) * slope;
|
|
15600
|
+
|
|
15601
|
+
// Compute the value
|
|
15602
|
+
hsvTmp[j] = h1 * hsv1[j] + h2 * hsv2[j] + h3 * t + h4 * t;
|
|
15603
|
+
if (j === 0 && hsvTmp[j] < 0.0) {
|
|
15604
|
+
hsvTmp[j] += 1.0;
|
|
15605
|
+
}
|
|
15606
|
+
}
|
|
15607
|
+
// Now convert this back to RGB
|
|
15608
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.h)(hsvTmp, tmpVec);
|
|
15609
|
+
table[tidx] = tmpVec[0];
|
|
15610
|
+
table[tidx + 1] = tmpVec[1];
|
|
15611
|
+
table[tidx + 2] = tmpVec[2];
|
|
15612
|
+
} else if (model.colorSpace === ColorSpace.LAB) {
|
|
15613
|
+
const lab1 = [];
|
|
15614
|
+
const lab2 = [];
|
|
15615
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.N)(rgb1, lab1);
|
|
15616
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.N)(rgb2, lab2);
|
|
15617
|
+
const labTmp = [];
|
|
15618
|
+
for (let j = 0; j < 3; j++) {
|
|
15619
|
+
// Use one slope for both end points
|
|
15620
|
+
slope = lab2[j] - lab1[j];
|
|
15621
|
+
t = (1.0 - sharpness) * slope;
|
|
15622
|
+
|
|
15623
|
+
// Compute the value
|
|
15624
|
+
labTmp[j] = h1 * lab1[j] + h2 * lab2[j] + h3 * t + h4 * t;
|
|
15625
|
+
}
|
|
15626
|
+
// Now convert this back to RGB
|
|
15627
|
+
(0,_Common_Core_Math_index_js__WEBPACK_IMPORTED_MODULE_1__.O)(labTmp, tmpVec);
|
|
15628
|
+
table[tidx] = tmpVec[0];
|
|
15629
|
+
table[tidx + 1] = tmpVec[1];
|
|
15630
|
+
table[tidx + 2] = tmpVec[2];
|
|
15631
|
+
} else if (model.colorSpace === ColorSpace.DIVERGING) {
|
|
15632
|
+
// I have not implemented proper interpolation by a hermite curve for
|
|
15633
|
+
// the diverging color map, but I cannot think of a good use case for
|
|
15634
|
+
// that anyway.
|
|
15635
|
+
vtkColorTransferFunctionInterpolateDiverging(s, rgb1, rgb2, tmpVec);
|
|
15636
|
+
table[tidx] = tmpVec[0];
|
|
15637
|
+
table[tidx + 1] = tmpVec[1];
|
|
15638
|
+
table[tidx + 2] = tmpVec[2];
|
|
15639
|
+
} else {
|
|
15640
|
+
vtkErrorMacro('ColorSpace set to invalid value.');
|
|
15641
|
+
}
|
|
15642
|
+
|
|
15643
|
+
// Final error check to make sure we don't go outside [0,1]
|
|
15644
|
+
for (let j = 0; j < 3; j++) {
|
|
15645
|
+
table[tidx + j] = table[tidx + j] < 0.0 ? 0.0 : table[tidx + j];
|
|
15646
|
+
table[tidx + j] = table[tidx + j] > 1.0 ? 1.0 : table[tidx + j];
|
|
15647
|
+
}
|
|
15648
|
+
}
|
|
15649
|
+
}
|
|
15650
|
+
};
|
|
15651
|
+
|
|
15652
|
+
//----------------------------------------------------------------------------
|
|
15653
|
+
publicAPI.getUint8Table = function (xStart, xEnd, size) {
|
|
15654
|
+
let withAlpha = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
15655
|
+
if (publicAPI.getMTime() <= model.buildTime && model.tableSize === size && model.tableWithAlpha !== withAlpha) {
|
|
15656
|
+
return model.table;
|
|
15657
|
+
}
|
|
15658
|
+
if (model.nodes.length === 0) {
|
|
15659
|
+
vtkErrorMacro('Attempting to lookup a value with no points in the function');
|
|
15660
|
+
return model.table;
|
|
15661
|
+
}
|
|
15662
|
+
const nbChannels = withAlpha ? 4 : 3;
|
|
15663
|
+
if (model.tableSize !== size || model.tableWithAlpha !== withAlpha) {
|
|
15664
|
+
model.table = new Uint8Array(size * nbChannels);
|
|
15665
|
+
model.tableSize = size;
|
|
15666
|
+
model.tableWithAlpha = withAlpha;
|
|
15667
|
+
}
|
|
15668
|
+
const tmpTable = [];
|
|
15669
|
+
publicAPI.getTable(xStart, xEnd, size, tmpTable);
|
|
15670
|
+
for (let i = 0; i < size; i++) {
|
|
15671
|
+
model.table[i * nbChannels + 0] = Math.floor(tmpTable[i * 3 + 0] * 255.0 + 0.5);
|
|
15672
|
+
model.table[i * nbChannels + 1] = Math.floor(tmpTable[i * 3 + 1] * 255.0 + 0.5);
|
|
15673
|
+
model.table[i * nbChannels + 2] = Math.floor(tmpTable[i * 3 + 2] * 255.0 + 0.5);
|
|
15674
|
+
if (withAlpha) {
|
|
15675
|
+
model.table[i * nbChannels + 3] = 255;
|
|
15676
|
+
}
|
|
15677
|
+
}
|
|
15678
|
+
model.buildTime.modified();
|
|
15679
|
+
return model.table;
|
|
15680
|
+
};
|
|
15681
|
+
publicAPI.buildFunctionFromArray = array => {
|
|
15682
|
+
publicAPI.removeAllPoints();
|
|
15683
|
+
const numComponents = array.getNumberOfComponents();
|
|
15684
|
+
for (let i = 0; i < array.getNumberOfTuples(); i++) {
|
|
15685
|
+
switch (numComponents) {
|
|
15686
|
+
case 3:
|
|
15687
|
+
{
|
|
15688
|
+
model.nodes.push({
|
|
15689
|
+
x: i,
|
|
15690
|
+
r: array.getComponent(i, 0),
|
|
15691
|
+
g: array.getComponent(i, 1),
|
|
15692
|
+
b: array.getComponent(i, 2),
|
|
15693
|
+
midpoint: 0.5,
|
|
15694
|
+
sharpness: 0.0
|
|
15695
|
+
});
|
|
15696
|
+
break;
|
|
15697
|
+
}
|
|
15698
|
+
case 4:
|
|
15699
|
+
{
|
|
15700
|
+
model.nodes.push({
|
|
15701
|
+
x: array.getComponent(i, 0),
|
|
15702
|
+
r: array.getComponent(i, 1),
|
|
15703
|
+
g: array.getComponent(i, 2),
|
|
15704
|
+
b: array.getComponent(i, 3),
|
|
15705
|
+
midpoint: 0.5,
|
|
15706
|
+
sharpness: 0.0
|
|
15707
|
+
});
|
|
15708
|
+
break;
|
|
15709
|
+
}
|
|
15710
|
+
case 5:
|
|
15711
|
+
{
|
|
15712
|
+
model.nodes.push({
|
|
15713
|
+
x: i,
|
|
15714
|
+
r: array.getComponent(i, 0),
|
|
15715
|
+
g: array.getComponent(i, 1),
|
|
15716
|
+
b: array.getComponent(i, 2),
|
|
15717
|
+
midpoint: array.getComponent(i, 4),
|
|
15718
|
+
sharpness: array.getComponent(i, 5)
|
|
15719
|
+
});
|
|
15720
|
+
break;
|
|
15721
|
+
}
|
|
15722
|
+
case 6:
|
|
15723
|
+
{
|
|
15724
|
+
model.nodes.push({
|
|
15725
|
+
x: array.getComponent(i, 0),
|
|
15726
|
+
r: array.getComponent(i, 1),
|
|
15727
|
+
g: array.getComponent(i, 2),
|
|
15728
|
+
b: array.getComponent(i, 3),
|
|
15729
|
+
midpoint: array.getComponent(i, 4),
|
|
15730
|
+
sharpness: array.getComponent(i, 5)
|
|
15731
|
+
});
|
|
15732
|
+
break;
|
|
15733
|
+
}
|
|
15734
|
+
}
|
|
15735
|
+
}
|
|
15736
|
+
publicAPI.sortAndUpdateRange();
|
|
15737
|
+
};
|
|
15738
|
+
|
|
15739
|
+
//----------------------------------------------------------------------------
|
|
15740
|
+
publicAPI.buildFunctionFromTable = (xStart, xEnd, size, table) => {
|
|
15741
|
+
let inc = 0.0;
|
|
15742
|
+
publicAPI.removeAllPoints();
|
|
15743
|
+
if (size > 1) {
|
|
15744
|
+
inc = (xEnd - xStart) / (size - 1.0);
|
|
15745
|
+
}
|
|
15746
|
+
for (let i = 0; i < size; i++) {
|
|
15747
|
+
const node = {
|
|
15748
|
+
x: xStart + inc * i,
|
|
15749
|
+
r: table[i * 3],
|
|
15750
|
+
g: table[i * 3 + 1],
|
|
15751
|
+
b: table[i * 3 + 2],
|
|
15752
|
+
sharpness: 0.0,
|
|
15753
|
+
midpoint: 0.5
|
|
15754
|
+
};
|
|
15755
|
+
model.nodes.push(node);
|
|
15756
|
+
}
|
|
15757
|
+
publicAPI.sortAndUpdateRange();
|
|
15758
|
+
};
|
|
15759
|
+
|
|
15760
|
+
//----------------------------------------------------------------------------
|
|
15761
|
+
// For a specified index value, get the node parameters
|
|
15762
|
+
publicAPI.getNodeValue = (index, val) => {
|
|
15763
|
+
if (index < 0 || index >= model.nodes.length) {
|
|
15764
|
+
vtkErrorMacro('Index out of range!');
|
|
15765
|
+
return -1;
|
|
15766
|
+
}
|
|
15767
|
+
val[0] = model.nodes[index].x;
|
|
15768
|
+
val[1] = model.nodes[index].r;
|
|
15769
|
+
val[2] = model.nodes[index].g;
|
|
15770
|
+
val[3] = model.nodes[index].b;
|
|
15771
|
+
val[4] = model.nodes[index].midpoint;
|
|
15772
|
+
val[5] = model.nodes[index].sharpness;
|
|
15773
|
+
return 1;
|
|
15774
|
+
};
|
|
15775
|
+
|
|
15776
|
+
//----------------------------------------------------------------------------
|
|
15777
|
+
// For a specified index value, get the node parameters
|
|
15778
|
+
publicAPI.setNodeValue = (index, val) => {
|
|
15779
|
+
if (index < 0 || index >= model.nodes.length) {
|
|
15780
|
+
vtkErrorMacro('Index out of range!');
|
|
15781
|
+
return -1;
|
|
15782
|
+
}
|
|
15783
|
+
const oldX = model.nodes[index].x;
|
|
15784
|
+
model.nodes[index].x = val[0];
|
|
15785
|
+
model.nodes[index].r = val[1];
|
|
15786
|
+
model.nodes[index].g = val[2];
|
|
15787
|
+
model.nodes[index].b = val[3];
|
|
15788
|
+
model.nodes[index].midpoint = val[4];
|
|
15789
|
+
model.nodes[index].sharpness = val[5];
|
|
15790
|
+
if (oldX !== val[0]) {
|
|
15791
|
+
// The point has been moved, the order of points or the range might have
|
|
15792
|
+
// been modified.
|
|
15793
|
+
publicAPI.sortAndUpdateRange();
|
|
15794
|
+
// No need to call Modified() here because SortAndUpdateRange() has done it
|
|
15795
|
+
// already.
|
|
15796
|
+
} else {
|
|
15797
|
+
publicAPI.modified();
|
|
15798
|
+
}
|
|
15799
|
+
return 1;
|
|
15800
|
+
};
|
|
15801
|
+
|
|
15802
|
+
//----------------------------------------------------------------------------
|
|
15803
|
+
publicAPI.getNumberOfAvailableColors = () => {
|
|
15804
|
+
if (model.indexedLookup && publicAPI.getSize()) {
|
|
15805
|
+
return publicAPI.getSize();
|
|
15806
|
+
}
|
|
15807
|
+
if (model.tableSize) {
|
|
15808
|
+
// Not sure if this is correct since it is only set if
|
|
15809
|
+
// "const unsigned char *::GetTable(double xStart, double xEnd,int size)"
|
|
15810
|
+
// has been called.
|
|
15811
|
+
return model.tableSize;
|
|
15812
|
+
}
|
|
15813
|
+
const nNodes = model.nodes?.length ?? 0;
|
|
15814
|
+
// The minimum is 4094 colors so that it fills in the 4096 texels texture in `mapScalarsToTexture`
|
|
15815
|
+
return Math.max(4094, nNodes);
|
|
15816
|
+
};
|
|
15817
|
+
|
|
15818
|
+
//----------------------------------------------------------------------------
|
|
15819
|
+
publicAPI.getIndexedColor = (idx, rgba) => {
|
|
15820
|
+
const n = publicAPI.getSize();
|
|
15821
|
+
if (n > 0 && idx >= 0) {
|
|
15822
|
+
const nodeValue = [];
|
|
15823
|
+
publicAPI.getNodeValue(idx % n, nodeValue);
|
|
15824
|
+
for (let j = 0; j < 3; ++j) {
|
|
15825
|
+
rgba[j] = nodeValue[j + 1];
|
|
15826
|
+
}
|
|
15827
|
+
rgba[3] = 1.0; // NodeColor is RGB-only.
|
|
15828
|
+
return;
|
|
15829
|
+
}
|
|
15830
|
+
const nanColor = publicAPI.getNanColorByReference();
|
|
15831
|
+
rgba[0] = nanColor[0];
|
|
15832
|
+
rgba[1] = nanColor[1];
|
|
15833
|
+
rgba[2] = nanColor[2];
|
|
15834
|
+
rgba[3] = 1.0; // NanColor is RGB-only.
|
|
15835
|
+
};
|
|
15836
|
+
|
|
15837
|
+
//----------------------------------------------------------------------------
|
|
15838
|
+
publicAPI.fillFromDataPointer = (nb, ptr) => {
|
|
15839
|
+
if (nb <= 0 || !ptr) {
|
|
15840
|
+
return;
|
|
15841
|
+
}
|
|
15842
|
+
publicAPI.removeAllPoints();
|
|
15843
|
+
for (let i = 0; i < nb; i++) {
|
|
15844
|
+
publicAPI.addRGBPoint(ptr[i * 4], ptr[i * 4 + 1], ptr[i * 4 + 2], ptr[i * 4 + 3]);
|
|
15845
|
+
}
|
|
15846
|
+
};
|
|
15847
|
+
|
|
15848
|
+
//----------------------------------------------------------------------------
|
|
15849
|
+
publicAPI.setMappingRange = (min, max) => {
|
|
15850
|
+
const range = [min, max];
|
|
15851
|
+
const originalRange = publicAPI.getRange();
|
|
15852
|
+
if (originalRange[1] === range[1] && originalRange[0] === range[0]) {
|
|
15853
|
+
return;
|
|
15854
|
+
}
|
|
15855
|
+
if (range[1] === range[0]) {
|
|
15856
|
+
vtkErrorMacro('attempt to set zero width color range');
|
|
15857
|
+
return;
|
|
15858
|
+
}
|
|
15859
|
+
const scale = (range[1] - range[0]) / (originalRange[1] - originalRange[0]);
|
|
15860
|
+
const shift = range[0] - originalRange[0] * scale;
|
|
15861
|
+
for (let i = 0; i < model.nodes.length; ++i) {
|
|
15862
|
+
model.nodes[i].x = model.nodes[i].x * scale + shift;
|
|
15863
|
+
}
|
|
15864
|
+
model.mappingRange[0] = range[0];
|
|
15865
|
+
model.mappingRange[1] = range[1];
|
|
15866
|
+
publicAPI.modified();
|
|
15867
|
+
};
|
|
15868
|
+
|
|
15869
|
+
//----------------------------------------------------------------------------
|
|
15870
|
+
publicAPI.adjustRange = range => {
|
|
15871
|
+
const functionRange = publicAPI.getRange();
|
|
15872
|
+
|
|
15873
|
+
// Make sure we have points at each end of the range
|
|
15874
|
+
const rgb = [];
|
|
15875
|
+
if (functionRange[0] < range[0]) {
|
|
15876
|
+
publicAPI.getColor(range[0], rgb);
|
|
15877
|
+
publicAPI.addRGBPoint(range[0], rgb[0], rgb[1], rgb[2]);
|
|
15878
|
+
} else {
|
|
15879
|
+
publicAPI.getColor(functionRange[0], rgb);
|
|
15880
|
+
publicAPI.addRGBPoint(range[0], rgb[0], rgb[1], rgb[2]);
|
|
15881
|
+
}
|
|
15882
|
+
if (functionRange[1] > range[1]) {
|
|
15883
|
+
publicAPI.getColor(range[1], rgb);
|
|
15884
|
+
publicAPI.addRGBPoint(range[1], rgb[0], rgb[1], rgb[2]);
|
|
15885
|
+
} else {
|
|
15886
|
+
publicAPI.getColor(functionRange[1], rgb);
|
|
15887
|
+
publicAPI.addRGBPoint(range[1], rgb[0], rgb[1], rgb[2]);
|
|
15888
|
+
}
|
|
15889
|
+
|
|
15890
|
+
// Remove all points out-of-range
|
|
15891
|
+
publicAPI.sortAndUpdateRange();
|
|
15892
|
+
for (let i = 0; i < model.nodes.length;) {
|
|
15893
|
+
if (model.nodes[i].x >= range[0] && model.nodes[i].x <= range[1]) {
|
|
15894
|
+
model.nodes.splice(i, 1);
|
|
15895
|
+
} else {
|
|
15896
|
+
++i;
|
|
15897
|
+
}
|
|
15898
|
+
}
|
|
15899
|
+
return 1;
|
|
15900
|
+
};
|
|
15901
|
+
|
|
15902
|
+
//--------------------------------------------------------------------------
|
|
15903
|
+
publicAPI.estimateMinNumberOfSamples = (x1, x2) => {
|
|
15904
|
+
const d = publicAPI.findMinimumXDistance();
|
|
15905
|
+
return Math.ceil((x2 - x1) / d);
|
|
15906
|
+
};
|
|
15907
|
+
|
|
15908
|
+
//----------------------------------------------------------------------------
|
|
15909
|
+
publicAPI.findMinimumXDistance = () => {
|
|
15910
|
+
if (model.nodes.length < 2) {
|
|
15911
|
+
return -1.0;
|
|
15912
|
+
}
|
|
15913
|
+
let distance = Number.MAX_VALUE;
|
|
15914
|
+
for (let i = 0; i < model.nodes.length - 1; i++) {
|
|
15915
|
+
const currentDist = model.nodes[i + 1].x - model.nodes[i].x;
|
|
15916
|
+
if (currentDist < distance) {
|
|
15917
|
+
distance = currentDist;
|
|
15918
|
+
}
|
|
15919
|
+
}
|
|
15920
|
+
return distance;
|
|
15921
|
+
};
|
|
15922
|
+
publicAPI.mapScalarsThroughTable = (input, output, outFormat, inputOffset) => {
|
|
15923
|
+
if (publicAPI.getSize() === 0) {
|
|
15924
|
+
vtkDebugMacro('Transfer Function Has No Points!');
|
|
15925
|
+
return;
|
|
15926
|
+
}
|
|
15927
|
+
if (model.indexedLookup) {
|
|
15928
|
+
publicAPI.mapDataIndexed(input, output, outFormat, inputOffset);
|
|
15929
|
+
} else {
|
|
15930
|
+
publicAPI.mapData(input, output, outFormat, inputOffset);
|
|
15931
|
+
}
|
|
15932
|
+
};
|
|
15933
|
+
|
|
15934
|
+
//----------------------------------------------------------------------------
|
|
15935
|
+
publicAPI.mapData = (input, output, outFormat, inputOffset) => {
|
|
15936
|
+
if (publicAPI.getSize() === 0) {
|
|
15937
|
+
vtkWarningMacro('Transfer Function Has No Points!');
|
|
15938
|
+
return;
|
|
15939
|
+
}
|
|
15940
|
+
const alpha = Math.floor(publicAPI.getAlpha() * 255.0 + 0.5);
|
|
15941
|
+
const length = input.getNumberOfTuples();
|
|
15942
|
+
const inIncr = input.getNumberOfComponents();
|
|
15943
|
+
const outputV = output.getData();
|
|
15944
|
+
const inputV = input.getData();
|
|
15945
|
+
const rgb = [];
|
|
15946
|
+
if (outFormat === ScalarMappingTarget.RGBA) {
|
|
15947
|
+
for (let i = 0; i < length; i++) {
|
|
15948
|
+
const x = inputV[i * inIncr + inputOffset];
|
|
15949
|
+
publicAPI.getColor(x, rgb);
|
|
15950
|
+
outputV[i * 4] = Math.floor(rgb[0] * 255.0 + 0.5);
|
|
15951
|
+
outputV[i * 4 + 1] = Math.floor(rgb[1] * 255.0 + 0.5);
|
|
15952
|
+
outputV[i * 4 + 2] = Math.floor(rgb[2] * 255.0 + 0.5);
|
|
15953
|
+
outputV[i * 4 + 3] = alpha;
|
|
15954
|
+
}
|
|
15955
|
+
}
|
|
15956
|
+
if (outFormat === ScalarMappingTarget.RGB) {
|
|
15957
|
+
for (let i = 0; i < length; i++) {
|
|
15958
|
+
const x = inputV[i * inIncr + inputOffset];
|
|
15959
|
+
publicAPI.getColor(x, rgb);
|
|
15960
|
+
outputV[i * 3] = Math.floor(rgb[0] * 255.0 + 0.5);
|
|
15961
|
+
outputV[i * 3 + 1] = Math.floor(rgb[1] * 255.0 + 0.5);
|
|
15962
|
+
outputV[i * 3 + 2] = Math.floor(rgb[2] * 255.0 + 0.5);
|
|
15963
|
+
}
|
|
15964
|
+
}
|
|
15965
|
+
if (outFormat === ScalarMappingTarget.LUMINANCE) {
|
|
15966
|
+
for (let i = 0; i < length; i++) {
|
|
15967
|
+
const x = inputV[i * inIncr + inputOffset];
|
|
15968
|
+
publicAPI.getColor(x, rgb);
|
|
15969
|
+
outputV[i] = Math.floor(rgb[0] * 76.5 + rgb[1] * 150.45 + rgb[2] * 28.05 + 0.5);
|
|
15970
|
+
}
|
|
15971
|
+
}
|
|
15972
|
+
if (outFormat === ScalarMappingTarget.LUMINANCE_ALPHA) {
|
|
15973
|
+
for (let i = 0; i < length; i++) {
|
|
15974
|
+
const x = inputV[i * inIncr + inputOffset];
|
|
15975
|
+
publicAPI.getColor(x, rgb);
|
|
15976
|
+
outputV[i * 2] = Math.floor(rgb[0] * 76.5 + rgb[1] * 150.45 + rgb[2] * 28.05 + 0.5);
|
|
15977
|
+
outputV[i * 2 + 1] = alpha;
|
|
15978
|
+
}
|
|
15979
|
+
}
|
|
15980
|
+
};
|
|
15981
|
+
|
|
15982
|
+
//----------------------------------------------------------------------------
|
|
15983
|
+
publicAPI.applyColorMap = colorMap => {
|
|
15984
|
+
const oldColorSpace = JSON.stringify(model.colorSpace);
|
|
15985
|
+
if (colorMap.ColorSpace) {
|
|
15986
|
+
model.colorSpace = ColorSpace[colorMap.ColorSpace.toUpperCase()];
|
|
15987
|
+
if (model.colorSpace === undefined) {
|
|
15988
|
+
vtkErrorMacro(`ColorSpace ${colorMap.ColorSpace} not supported, using RGB instead`);
|
|
15989
|
+
model.colorSpace = ColorSpace.RGB;
|
|
15990
|
+
}
|
|
15991
|
+
}
|
|
15992
|
+
let isModified = oldColorSpace !== JSON.stringify(model.colorSpace);
|
|
15993
|
+
const oldNanColor = isModified || JSON.stringify(model.nanColor);
|
|
15994
|
+
if (colorMap.NanColor) {
|
|
15995
|
+
model.nanColor = [].concat(colorMap.NanColor);
|
|
15996
|
+
while (model.nanColor.length < 4) {
|
|
15997
|
+
model.nanColor.push(1.0);
|
|
15998
|
+
}
|
|
15999
|
+
}
|
|
16000
|
+
isModified = isModified || oldNanColor !== JSON.stringify(model.nanColor);
|
|
16001
|
+
const oldNodes = isModified || JSON.stringify(model.nodes);
|
|
16002
|
+
if (colorMap.RGBPoints) {
|
|
16003
|
+
const size = colorMap.RGBPoints.length;
|
|
16004
|
+
model.nodes = [];
|
|
16005
|
+
const midpoint = 0.5;
|
|
16006
|
+
const sharpness = 0.0;
|
|
16007
|
+
for (let i = 0; i < size; i += 4) {
|
|
16008
|
+
model.nodes.push({
|
|
16009
|
+
x: colorMap.RGBPoints[i],
|
|
16010
|
+
r: colorMap.RGBPoints[i + 1],
|
|
16011
|
+
g: colorMap.RGBPoints[i + 2],
|
|
16012
|
+
b: colorMap.RGBPoints[i + 3],
|
|
16013
|
+
midpoint,
|
|
16014
|
+
sharpness
|
|
16015
|
+
});
|
|
16016
|
+
}
|
|
16017
|
+
}
|
|
16018
|
+
const modifiedInvoked = publicAPI.sortAndUpdateRange();
|
|
16019
|
+
const callModified = !modifiedInvoked && (isModified || oldNodes !== JSON.stringify(model.nodes));
|
|
16020
|
+
if (callModified) publicAPI.modified();
|
|
16021
|
+
return modifiedInvoked || callModified;
|
|
16022
|
+
};
|
|
16023
|
+
}
|
|
16024
|
+
|
|
16025
|
+
// ----------------------------------------------------------------------------
|
|
16026
|
+
// Object factory
|
|
16027
|
+
// ----------------------------------------------------------------------------
|
|
16028
|
+
|
|
16029
|
+
const DEFAULT_VALUES = {
|
|
16030
|
+
clamping: true,
|
|
16031
|
+
colorSpace: ColorSpace.RGB,
|
|
16032
|
+
hSVWrap: true,
|
|
16033
|
+
scale: Scale.LINEAR,
|
|
16034
|
+
nanColor: null,
|
|
16035
|
+
belowRangeColor: null,
|
|
16036
|
+
aboveRangeColor: null,
|
|
16037
|
+
useAboveRangeColor: false,
|
|
16038
|
+
useBelowRangeColor: false,
|
|
16039
|
+
allowDuplicateScalars: false,
|
|
16040
|
+
table: null,
|
|
16041
|
+
tableSize: 0,
|
|
16042
|
+
buildTime: null,
|
|
16043
|
+
nodes: null,
|
|
16044
|
+
discretize: false,
|
|
16045
|
+
numberOfValues: 256
|
|
16046
|
+
};
|
|
16047
|
+
|
|
16048
|
+
// ----------------------------------------------------------------------------
|
|
16049
|
+
|
|
16050
|
+
function extend(publicAPI, model) {
|
|
16051
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
16052
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
16053
|
+
|
|
16054
|
+
// Inheritance
|
|
16055
|
+
_Common_Core_ScalarsToColors_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"].extend */ .Ay.extend(publicAPI, model, initialValues);
|
|
16056
|
+
|
|
16057
|
+
// Internal objects initialization
|
|
16058
|
+
model.table = [];
|
|
16059
|
+
model.nodes = [];
|
|
16060
|
+
model.nanColor = [0.5, 0.0, 0.0, 1.0];
|
|
16061
|
+
model.belowRangeColor = [0.0, 0.0, 0.0, 1.0];
|
|
16062
|
+
model.aboveRangeColor = [1.0, 1.0, 1.0, 1.0];
|
|
16063
|
+
model.buildTime = {};
|
|
16064
|
+
_macros2_js__WEBPACK_IMPORTED_MODULE_0__.m.obj(model.buildTime);
|
|
16065
|
+
|
|
16066
|
+
// Create get-only macros
|
|
16067
|
+
_macros2_js__WEBPACK_IMPORTED_MODULE_0__.m.get(publicAPI, model, ['buildTime', 'mappingRange']);
|
|
16068
|
+
|
|
16069
|
+
// Create get-set macros
|
|
16070
|
+
_macros2_js__WEBPACK_IMPORTED_MODULE_0__.m.setGet(publicAPI, model, ['useAboveRangeColor', 'useBelowRangeColor', 'discretize', 'numberOfValues', {
|
|
16071
|
+
type: 'enum',
|
|
16072
|
+
name: 'colorSpace',
|
|
16073
|
+
enum: ColorSpace
|
|
16074
|
+
}, {
|
|
16075
|
+
type: 'enum',
|
|
16076
|
+
name: 'scale',
|
|
16077
|
+
enum: Scale
|
|
16078
|
+
}]);
|
|
16079
|
+
_macros2_js__WEBPACK_IMPORTED_MODULE_0__.m.setArray(publicAPI, model, ['nanColor', 'belowRangeColor', 'aboveRangeColor'], 4);
|
|
16080
|
+
|
|
16081
|
+
// Create get macros for array
|
|
16082
|
+
_macros2_js__WEBPACK_IMPORTED_MODULE_0__.m.getArray(publicAPI, model, ['nanColor', 'belowRangeColor', 'aboveRangeColor']);
|
|
16083
|
+
|
|
16084
|
+
// For more macro methods, see "Sources/macros.js"
|
|
16085
|
+
|
|
16086
|
+
// Object specific methods
|
|
16087
|
+
vtkColorTransferFunction(publicAPI, model);
|
|
16088
|
+
}
|
|
16089
|
+
|
|
16090
|
+
// ----------------------------------------------------------------------------
|
|
16091
|
+
|
|
16092
|
+
const newInstance = _macros2_js__WEBPACK_IMPORTED_MODULE_0__.m.newInstance(extend, 'vtkColorTransferFunction');
|
|
16093
|
+
|
|
16094
|
+
// ----------------------------------------------------------------------------
|
|
16095
|
+
|
|
16096
|
+
var vtkColorTransferFunction$1 = {
|
|
16097
|
+
newInstance,
|
|
16098
|
+
extend,
|
|
16099
|
+
..._ColorTransferFunction_Constants_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Ay
|
|
16100
|
+
};
|
|
16101
|
+
|
|
16102
|
+
|
|
16103
|
+
|
|
16104
|
+
|
|
14765
16105
|
/***/ }),
|
|
14766
16106
|
|
|
14767
16107
|
/***/ 9175:
|