@kitware/vtk.js 34.15.4 → 34.16.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.
|
@@ -79,24 +79,37 @@ function vtkImageMarchingSquares(publicAPI, model) {
|
|
|
79
79
|
/**
|
|
80
80
|
* Retrieve pixel coordinates.
|
|
81
81
|
* @param {Vector3} ijk origin of the pixel
|
|
82
|
-
* @param {Vector3} origin origin of the image
|
|
83
|
-
* @param {Vector3} spacing spacing of the image
|
|
84
82
|
* @param {number} kernelX index of the X element
|
|
85
83
|
* @param {number} kernelY index of the Y element
|
|
84
|
+
* @param {Function} indexToWorld function to convert index to world coordinates
|
|
86
85
|
*/
|
|
87
|
-
publicAPI.getPixelPoints = (ijk,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
pixelPts
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
pixelPts[
|
|
98
|
-
pixelPts[
|
|
99
|
-
pixelPts[
|
|
86
|
+
publicAPI.getPixelPoints = (ijk, kernelX, kernelY, indexToWorld) => {
|
|
87
|
+
// pixelPts = a flattened world coordinates array of [ (i,j,k), (i+1,j,k), (i,j+1,k), (i+1,j+1,k)]
|
|
88
|
+
|
|
89
|
+
// 0: i, j, k
|
|
90
|
+
const neighborIJK = [...ijk];
|
|
91
|
+
indexToWorld(neighborIJK, pixelPts);
|
|
92
|
+
|
|
93
|
+
// 1: i+1, j, k
|
|
94
|
+
neighborIJK[kernelX] += 1;
|
|
95
|
+
const temp = indexToWorld(neighborIJK, []);
|
|
96
|
+
pixelPts[3] = temp[0];
|
|
97
|
+
pixelPts[4] = temp[1];
|
|
98
|
+
pixelPts[5] = temp[2];
|
|
99
|
+
|
|
100
|
+
// 2: i+1, j+1, k
|
|
101
|
+
neighborIJK[kernelY] += 1;
|
|
102
|
+
indexToWorld(neighborIJK, temp);
|
|
103
|
+
pixelPts[9] = temp[0];
|
|
104
|
+
pixelPts[10] = temp[1];
|
|
105
|
+
pixelPts[11] = temp[2];
|
|
106
|
+
|
|
107
|
+
// 3: i, j+1, k
|
|
108
|
+
neighborIJK[kernelX] -= 1;
|
|
109
|
+
indexToWorld(neighborIJK, temp);
|
|
110
|
+
pixelPts[6] = temp[0];
|
|
111
|
+
pixelPts[7] = temp[1];
|
|
112
|
+
pixelPts[8] = temp[2];
|
|
100
113
|
};
|
|
101
114
|
|
|
102
115
|
/**
|
|
@@ -104,7 +117,6 @@ function vtkImageMarchingSquares(publicAPI, model) {
|
|
|
104
117
|
* @param {number[]} cVal list of contour values
|
|
105
118
|
* @param {Vector3} ijk origin of the pixel
|
|
106
119
|
* @param {Vector3} dims dimensions of the image
|
|
107
|
-
* @param {Vector3} origin origin of the image
|
|
108
120
|
* @param {Vector3} spacing sapcing of the image
|
|
109
121
|
* @param {TypedArray} scalars list of scalar values
|
|
110
122
|
* @param {number[]} points list of points
|
|
@@ -112,9 +124,9 @@ function vtkImageMarchingSquares(publicAPI, model) {
|
|
|
112
124
|
* @param {Vector3} increments IJK slice increments
|
|
113
125
|
* @param {number} kernelX index of the X element
|
|
114
126
|
* @param {number} kernelY index of the Y element
|
|
127
|
+
* @param {Function} indexToWorld function to convert index to world coordinates
|
|
115
128
|
*/
|
|
116
|
-
publicAPI.produceLines = (cVal, ijk, dims,
|
|
117
|
-
const k = ijk[model.slicingMode];
|
|
129
|
+
publicAPI.produceLines = (cVal, ijk, dims, scalars, points, lines, increments, kernelX, kernelY, indexToWorld) => {
|
|
118
130
|
const CASE_MASK = [1, 2, 8, 4]; // case table is actually for quad
|
|
119
131
|
const xyz = [];
|
|
120
132
|
let pId;
|
|
@@ -131,8 +143,7 @@ function vtkImageMarchingSquares(publicAPI, model) {
|
|
|
131
143
|
return; // don't get the pixel coordinates, nothing to do
|
|
132
144
|
}
|
|
133
145
|
|
|
134
|
-
publicAPI.getPixelPoints(ijk,
|
|
135
|
-
const z = origin[model.slicingMode] + k * spacing[model.slicingMode];
|
|
146
|
+
publicAPI.getPixelPoints(ijk, kernelX, kernelY, indexToWorld);
|
|
136
147
|
for (let idx = 0; pixelLines[idx] >= 0; idx += 2) {
|
|
137
148
|
lines.push(2);
|
|
138
149
|
for (let eid = 0; eid < 2; eid++) {
|
|
@@ -143,11 +154,11 @@ function vtkImageMarchingSquares(publicAPI, model) {
|
|
|
143
154
|
}
|
|
144
155
|
if (pId === undefined) {
|
|
145
156
|
const t = (cVal - pixelScalars[edgeVerts[0]]) / (pixelScalars[edgeVerts[1]] - pixelScalars[edgeVerts[0]]);
|
|
146
|
-
const x0 = pixelPts.slice(edgeVerts[0] *
|
|
147
|
-
const x1 = pixelPts.slice(edgeVerts[1] *
|
|
148
|
-
xyz[
|
|
149
|
-
xyz[
|
|
150
|
-
xyz[
|
|
157
|
+
const x0 = pixelPts.slice(edgeVerts[0] * 3, (edgeVerts[0] + 1) * 3);
|
|
158
|
+
const x1 = pixelPts.slice(edgeVerts[1] * 3, (edgeVerts[1] + 1) * 3);
|
|
159
|
+
xyz[0] = x0[0] + t * (x1[0] - x0[0]);
|
|
160
|
+
xyz[1] = x0[1] + t * (x1[1] - x0[1]);
|
|
161
|
+
xyz[2] = x0[2] + t * (x1[2] - x0[2]);
|
|
151
162
|
pId = points.length / 3;
|
|
152
163
|
points.push(xyz[0], xyz[1], xyz[2]);
|
|
153
164
|
if (model.mergePoints) {
|
|
@@ -172,13 +183,12 @@ function vtkImageMarchingSquares(publicAPI, model) {
|
|
|
172
183
|
console.time('msquares');
|
|
173
184
|
|
|
174
185
|
// Retrieve output and volume data
|
|
175
|
-
const origin = input.getOrigin();
|
|
176
|
-
const spacing = input.getSpacing();
|
|
177
186
|
const dims = input.getDimensions();
|
|
178
187
|
const extent = input.getExtent();
|
|
179
188
|
const increments = input.computeIncrements(extent);
|
|
180
189
|
const scalars = input.getPointData().getScalars().getData();
|
|
181
190
|
const [kernelX, kernelY] = getKernels();
|
|
191
|
+
const indexToWorld = input.indexToWorld;
|
|
182
192
|
|
|
183
193
|
// Points - dynamic array
|
|
184
194
|
const points = [];
|
|
@@ -200,7 +210,7 @@ function vtkImageMarchingSquares(publicAPI, model) {
|
|
|
200
210
|
ijk[kernelY] = j;
|
|
201
211
|
for (let i = 0; i < dims[kernelX] - 1; ++i) {
|
|
202
212
|
ijk[kernelX] = i;
|
|
203
|
-
publicAPI.produceLines(model.contourValues[cv], ijk, dims,
|
|
213
|
+
publicAPI.produceLines(model.contourValues[cv], ijk, dims, scalars, points, lines, increments, kernelX, kernelY, indexToWorld);
|
|
204
214
|
}
|
|
205
215
|
}
|
|
206
216
|
edgeLocator.initialize();
|
|
@@ -595,6 +595,197 @@ var vtkColorMaps = [
|
|
|
595
595
|
1
|
|
596
596
|
]
|
|
597
597
|
},
|
|
598
|
+
{
|
|
599
|
+
ColorSpace: "RGB",
|
|
600
|
+
Name: "Grayscale-DICOM-sigmoid",
|
|
601
|
+
Notes: "This is a 16 point sample of a sigmoid grayscale colormap described in the DICOM standard. See equation C.11-1 in section C.11.2",
|
|
602
|
+
NanColor: [
|
|
603
|
+
1,
|
|
604
|
+
0,
|
|
605
|
+
0
|
|
606
|
+
],
|
|
607
|
+
BelowRangeColor: [
|
|
608
|
+
0,
|
|
609
|
+
0,
|
|
610
|
+
0
|
|
611
|
+
],
|
|
612
|
+
AboveRangeColor: [
|
|
613
|
+
1,
|
|
614
|
+
1,
|
|
615
|
+
1
|
|
616
|
+
],
|
|
617
|
+
RGBPoints: [
|
|
618
|
+
-1,
|
|
619
|
+
0.01798620996209156,
|
|
620
|
+
0.01798620996209156,
|
|
621
|
+
0.01798620996209156,
|
|
622
|
+
-0.8666666666666667,
|
|
623
|
+
0.030275691986950463,
|
|
624
|
+
0.030275691986950463,
|
|
625
|
+
0.030275691986950463,
|
|
626
|
+
-0.7333333333333334,
|
|
627
|
+
0.05053016223541345,
|
|
628
|
+
0.05053016223541345,
|
|
629
|
+
0.05053016223541345,
|
|
630
|
+
-0.6,
|
|
631
|
+
0.08317269649392238,
|
|
632
|
+
0.08317269649392238,
|
|
633
|
+
0.08317269649392238,
|
|
634
|
+
-0.4666666666666667,
|
|
635
|
+
0.13392788832407365,
|
|
636
|
+
0.13392788832407365,
|
|
637
|
+
0.13392788832407365,
|
|
638
|
+
-0.33333333333333337,
|
|
639
|
+
0.2086085273260449,
|
|
640
|
+
0.2086085273260449,
|
|
641
|
+
0.2086085273260449,
|
|
642
|
+
-0.19999999999999996,
|
|
643
|
+
0.31002551887238755,
|
|
644
|
+
0.31002551887238755,
|
|
645
|
+
0.31002551887238755,
|
|
646
|
+
-0.06666666666666665,
|
|
647
|
+
0.4337256058045608,
|
|
648
|
+
0.4337256058045608,
|
|
649
|
+
0.4337256058045608,
|
|
650
|
+
0.06666666666666665,
|
|
651
|
+
0.5662743941954392,
|
|
652
|
+
0.5662743941954392,
|
|
653
|
+
0.5662743941954392,
|
|
654
|
+
0.19999999999999996,
|
|
655
|
+
0.6899744811276125,
|
|
656
|
+
0.6899744811276125,
|
|
657
|
+
0.6899744811276125,
|
|
658
|
+
0.33333333333333326,
|
|
659
|
+
0.791391472673955,
|
|
660
|
+
0.791391472673955,
|
|
661
|
+
0.791391472673955,
|
|
662
|
+
0.46666666666666656,
|
|
663
|
+
0.8660721116759263,
|
|
664
|
+
0.8660721116759263,
|
|
665
|
+
0.8660721116759263,
|
|
666
|
+
0.6000000000000001,
|
|
667
|
+
0.9168273035060777,
|
|
668
|
+
0.9168273035060777,
|
|
669
|
+
0.9168273035060777,
|
|
670
|
+
0.7333333333333334,
|
|
671
|
+
0.9494698377645865,
|
|
672
|
+
0.9494698377645865,
|
|
673
|
+
0.9494698377645865,
|
|
674
|
+
0.8666666666666667,
|
|
675
|
+
0.9697243080130495,
|
|
676
|
+
0.9697243080130495,
|
|
677
|
+
0.9697243080130495,
|
|
678
|
+
1,
|
|
679
|
+
0.9820137900379085,
|
|
680
|
+
0.9820137900379085,
|
|
681
|
+
0.9820137900379085
|
|
682
|
+
]
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
ColorSpace: "RGB",
|
|
686
|
+
Name: "Inverted-Grayscale",
|
|
687
|
+
NanColor: [
|
|
688
|
+
1,
|
|
689
|
+
0,
|
|
690
|
+
0
|
|
691
|
+
],
|
|
692
|
+
RGBPoints: [
|
|
693
|
+
0,
|
|
694
|
+
1,
|
|
695
|
+
1,
|
|
696
|
+
1,
|
|
697
|
+
1,
|
|
698
|
+
0,
|
|
699
|
+
0,
|
|
700
|
+
0
|
|
701
|
+
]
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
ColorSpace: "RGB",
|
|
705
|
+
Name: "Inverted-Grayscale-DICOM-sigmoid",
|
|
706
|
+
Notes: "This is a 16 point sample of a sigmoid inverted-grayscale colormap described in the DICOM standard. See equation C.11-1 in section C.11.2",
|
|
707
|
+
BelowRangeColor: [
|
|
708
|
+
1,
|
|
709
|
+
1,
|
|
710
|
+
1
|
|
711
|
+
],
|
|
712
|
+
AboveRangeColor: [
|
|
713
|
+
0,
|
|
714
|
+
0,
|
|
715
|
+
0
|
|
716
|
+
],
|
|
717
|
+
NanColor: [
|
|
718
|
+
1,
|
|
719
|
+
0,
|
|
720
|
+
0
|
|
721
|
+
],
|
|
722
|
+
RGBPoints: [
|
|
723
|
+
-1,
|
|
724
|
+
0.9820137900379085,
|
|
725
|
+
0.9820137900379085,
|
|
726
|
+
0.9820137900379085,
|
|
727
|
+
-0.8666666666666667,
|
|
728
|
+
0.9697243080130495,
|
|
729
|
+
0.9697243080130495,
|
|
730
|
+
0.9697243080130495,
|
|
731
|
+
-0.7333333333333334,
|
|
732
|
+
0.9494698377645866,
|
|
733
|
+
0.9494698377645866,
|
|
734
|
+
0.9494698377645866,
|
|
735
|
+
-0.6,
|
|
736
|
+
0.9168273035060777,
|
|
737
|
+
0.9168273035060777,
|
|
738
|
+
0.9168273035060777,
|
|
739
|
+
-0.4666666666666667,
|
|
740
|
+
0.8660721116759263,
|
|
741
|
+
0.8660721116759263,
|
|
742
|
+
0.8660721116759263,
|
|
743
|
+
-0.33333333333333337,
|
|
744
|
+
0.791391472673955,
|
|
745
|
+
0.791391472673955,
|
|
746
|
+
0.791391472673955,
|
|
747
|
+
-0.19999999999999996,
|
|
748
|
+
0.6899744811276125,
|
|
749
|
+
0.6899744811276125,
|
|
750
|
+
0.6899744811276125,
|
|
751
|
+
-0.06666666666666665,
|
|
752
|
+
0.5662743941954391,
|
|
753
|
+
0.5662743941954391,
|
|
754
|
+
0.5662743941954391,
|
|
755
|
+
0.06666666666666665,
|
|
756
|
+
0.43372560580456077,
|
|
757
|
+
0.43372560580456077,
|
|
758
|
+
0.43372560580456077,
|
|
759
|
+
0.19999999999999996,
|
|
760
|
+
0.3100255188723875,
|
|
761
|
+
0.3100255188723875,
|
|
762
|
+
0.3100255188723875,
|
|
763
|
+
0.33333333333333326,
|
|
764
|
+
0.20860852732604496,
|
|
765
|
+
0.20860852732604496,
|
|
766
|
+
0.20860852732604496,
|
|
767
|
+
0.46666666666666656,
|
|
768
|
+
0.13392788832407365,
|
|
769
|
+
0.13392788832407365,
|
|
770
|
+
0.13392788832407365,
|
|
771
|
+
0.6000000000000001,
|
|
772
|
+
0.08317269649392234,
|
|
773
|
+
0.08317269649392234,
|
|
774
|
+
0.08317269649392234,
|
|
775
|
+
0.7333333333333334,
|
|
776
|
+
0.05053016223541351,
|
|
777
|
+
0.05053016223541351,
|
|
778
|
+
0.05053016223541351,
|
|
779
|
+
0.8666666666666667,
|
|
780
|
+
0.03027569198695046,
|
|
781
|
+
0.03027569198695046,
|
|
782
|
+
0.03027569198695046,
|
|
783
|
+
1,
|
|
784
|
+
0.01798620996209155,
|
|
785
|
+
0.01798620996209155,
|
|
786
|
+
0.01798620996209155
|
|
787
|
+
]
|
|
788
|
+
},
|
|
598
789
|
{
|
|
599
790
|
ColorSpace: "RGB",
|
|
600
791
|
Name: "BkRd",
|