@kitware/vtk.js 29.2.0 → 29.3.1
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/Filters/General/TubeFilter.js +0 -2
- package/Rendering/Core/ImageProperty.d.ts +22 -0
- package/Rendering/Core/ImageProperty.js +6 -2
- package/Rendering/Core/VolumeProperty.d.ts +2 -2
- package/Rendering/OpenGL/ImageMapper.js +175 -3
- package/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl.js +1 -1
- package/macros2.js +2 -2
- package/package.json +1 -1
|
@@ -627,7 +627,6 @@ function vtkTubeFilter(publicAPI, model) {
|
|
|
627
627
|
numberOfComponents: oldArray.getNumberOfComponents(),
|
|
628
628
|
size: numNewPts * oldArray.getNumberOfComponents()
|
|
629
629
|
});
|
|
630
|
-
output.getPointData().removeArrayByIndex(0); // remove oldArray from beginning
|
|
631
630
|
output.getPointData().addArray(newArray); // concat newArray to end
|
|
632
631
|
}
|
|
633
632
|
|
|
@@ -645,7 +644,6 @@ function vtkTubeFilter(publicAPI, model) {
|
|
|
645
644
|
numberOfComponents: oldArray.getNumberOfComponents(),
|
|
646
645
|
size: numNewCells * oldArray.getNumberOfComponents()
|
|
647
646
|
});
|
|
648
|
-
output.getCellData().removeArrayByIndex(0); // remove oldArray from beginning
|
|
649
647
|
output.getCellData().addArray(newArray); // concat newArray to end
|
|
650
648
|
}
|
|
651
649
|
|
|
@@ -18,6 +18,8 @@ export interface IImagePropertyInitialValues {
|
|
|
18
18
|
opacity?: number;
|
|
19
19
|
componentData?: IComponentData[];
|
|
20
20
|
useLookupTableScalarRange?: boolean;
|
|
21
|
+
useLabelOutline?: boolean;
|
|
22
|
+
labelOutlineThickness?: number | number[];
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export interface vtkImageProperty extends vtkObject {
|
|
@@ -92,6 +94,26 @@ export interface vtkImageProperty extends vtkObject {
|
|
|
92
94
|
*/
|
|
93
95
|
getScalarOpacity(idx?: number): vtkPiecewiseFunction;
|
|
94
96
|
|
|
97
|
+
/**
|
|
98
|
+
* gets the label outline thickness
|
|
99
|
+
*/
|
|
100
|
+
getLabelOutlineThickness(): number;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* It will set the label outline thickness for the labelmaps. It can accept
|
|
104
|
+
* a single number or an array of numbers. If a single number is provided,
|
|
105
|
+
* it will be used for all the segments. If an array is provided, it indicates
|
|
106
|
+
* the thickness for each segment index. For instance if you have a labelmap
|
|
107
|
+
* with 3 segments (0: background 1: liver 2: tumor), you can set the thickness
|
|
108
|
+
* to [2,4] to have a thicker outline for the tumor (thickness 4). It should be
|
|
109
|
+
* noted that the thickness is in pixel and also the first array value will
|
|
110
|
+
* control the default thickness for all labels when 0 or not specified.
|
|
111
|
+
*
|
|
112
|
+
* @param {Number | Number[]} labelOutlineThickness
|
|
113
|
+
*/
|
|
114
|
+
setLabelOutlineThickness(labelOutlineThickness: number | number[]): boolean;
|
|
115
|
+
|
|
116
|
+
|
|
95
117
|
/**
|
|
96
118
|
* Set the ambient lighting coefficient.
|
|
97
119
|
* @param {Number} ambient The ambient lighting coefficient.
|
|
@@ -144,7 +144,10 @@ const DEFAULT_VALUES = {
|
|
|
144
144
|
ambient: 1.0,
|
|
145
145
|
diffuse: 0.0,
|
|
146
146
|
opacity: 1.0,
|
|
147
|
-
useLookupTableScalarRange: false
|
|
147
|
+
useLookupTableScalarRange: false,
|
|
148
|
+
useLabelOutline: false,
|
|
149
|
+
labelOutlineThickness: [1],
|
|
150
|
+
labelOutlineOpacity: 1.0
|
|
148
151
|
};
|
|
149
152
|
|
|
150
153
|
// ----------------------------------------------------------------------------
|
|
@@ -165,7 +168,8 @@ function extend(publicAPI, model) {
|
|
|
165
168
|
});
|
|
166
169
|
}
|
|
167
170
|
}
|
|
168
|
-
macro.setGet(publicAPI, model, ['independentComponents', 'interpolationType', 'colorWindow', 'colorLevel', 'ambient', 'diffuse', 'opacity', 'useLookupTableScalarRange']);
|
|
171
|
+
macro.setGet(publicAPI, model, ['independentComponents', 'interpolationType', 'colorWindow', 'colorLevel', 'ambient', 'diffuse', 'opacity', 'useLookupTableScalarRange', 'useLabelOutline', 'labelOutlineOpacity']);
|
|
172
|
+
macro.setGetArray(publicAPI, model, ['labelOutlineThickness']);
|
|
169
173
|
|
|
170
174
|
// Object methods
|
|
171
175
|
vtkImageProperty(publicAPI, model);
|
|
@@ -11,7 +11,7 @@ export interface IVolumePropertyInitialValues {
|
|
|
11
11
|
specular?: number;
|
|
12
12
|
specularPower?: number;
|
|
13
13
|
useLabelOutline?: boolean;
|
|
14
|
-
labelOutlineThickness?: number;
|
|
14
|
+
labelOutlineThickness?: number | number[];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface vtkVolumeProperty extends vtkObject {
|
|
@@ -92,7 +92,7 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
92
92
|
getOpacityMode(index: number): OpacityMode;
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
*
|
|
95
|
+
* gets the label outline thickness
|
|
96
96
|
*/
|
|
97
97
|
getLabelOutlineThickness(): number;
|
|
98
98
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mat4 } from 'gl-matrix';
|
|
1
|
+
import { mat4, mat3 } from 'gl-matrix';
|
|
2
2
|
import Constants from '../Core/ImageMapper/Constants.js';
|
|
3
3
|
import { n as newInstance$1, e as setGet, o as obj, r as vtkErrorMacro$1, c as macro } from '../../macros2.js';
|
|
4
4
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
@@ -34,6 +34,19 @@ function computeFnToString(property, pwfun, numberOfComponents) {
|
|
|
34
34
|
}
|
|
35
35
|
return '0';
|
|
36
36
|
}
|
|
37
|
+
function splitStringOnEnter(inputString) {
|
|
38
|
+
// Split the input string into an array of lines based on "Enter" (newline) characters
|
|
39
|
+
// Remove any leading or trailing whitespace from each line and filter out empty lines
|
|
40
|
+
const lines = inputString.split('\n');
|
|
41
|
+
const trimmedLines = [];
|
|
42
|
+
for (let i = 0; i < lines.length; ++i) {
|
|
43
|
+
const trimmedLine = lines[i].trim();
|
|
44
|
+
if (trimmedLine.length > 0) {
|
|
45
|
+
trimmedLines.push(trimmedLine);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return trimmedLines;
|
|
49
|
+
}
|
|
37
50
|
|
|
38
51
|
// ----------------------------------------------------------------------------
|
|
39
52
|
// vtkOpenGLImageMapper methods
|
|
@@ -109,7 +122,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
109
122
|
// color shift and scale
|
|
110
123
|
'uniform float cshift0;', 'uniform float cscale0;',
|
|
111
124
|
// pwf shift and scale
|
|
112
|
-
'uniform float pwfshift0;', 'uniform float pwfscale0;', 'uniform sampler2D texture1;', 'uniform sampler2D colorTexture1;', 'uniform sampler2D pwfTexture1;', 'uniform float opacity;'];
|
|
125
|
+
'uniform float pwfshift0;', 'uniform float pwfscale0;', 'uniform sampler2D texture1;', 'uniform sampler2D colorTexture1;', 'uniform sampler2D pwfTexture1;', 'uniform sampler2D labelOutlineTexture1;', 'uniform float opacity;', 'uniform float outlineOpacity;'];
|
|
113
126
|
if (iComps) {
|
|
114
127
|
for (let comp = 1; comp < tNumComp; comp++) {
|
|
115
128
|
tcoordDec = tcoordDec.concat([
|
|
@@ -141,6 +154,14 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
141
154
|
}
|
|
142
155
|
}
|
|
143
156
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Dec', tcoordDec).result;
|
|
157
|
+
|
|
158
|
+
// check for the outline thickness and opacity
|
|
159
|
+
const vtkImageLabelOutline = actor.getProperty().getUseLabelOutline();
|
|
160
|
+
if (vtkImageLabelOutline === true) {
|
|
161
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::LabelOutline::Dec', ['uniform int outlineThickness;', 'uniform float vpWidth;', 'uniform float vpHeight;', 'uniform float vpOffsetX;', 'uniform float vpOffsetY;', 'uniform mat4 PCWCMatrix;', 'uniform mat4 vWCtoIDX;', 'uniform ivec3 imageDimensions;']).result;
|
|
162
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ImageLabelOutlineOn', '#define vtkImageLabelOutlineOn').result;
|
|
163
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::LabelOutlineHelperFunction', ['#ifdef vtkImageLabelOutlineOn', 'vec3 fragCoordToIndexSpace(vec4 fragCoord) {', ' vec4 pcPos = vec4(', ' (fragCoord.x / vpWidth - vpOffsetX - 0.5) * 2.0,', ' (fragCoord.y / vpHeight - vpOffsetY - 0.5) * 2.0,', ' (fragCoord.z - 0.5) * 2.0,', ' 1.0);', '', ' vec4 worldCoord = PCWCMatrix * pcPos;', ' vec4 vertex = (worldCoord/worldCoord.w);', '', ' vec3 index = (vWCtoIDX * vertex).xyz;', '', ' // half voxel fix for labelmapOutline', ' return (index + vec3(0.5)) / vec3(imageDimensions);', '}', '#endif']).result;
|
|
164
|
+
}
|
|
144
165
|
if (iComps) {
|
|
145
166
|
const rgba = ['r', 'g', 'b', 'a'];
|
|
146
167
|
let tcoordImpl = ['vec4 tvalue = texture2D(texture1, tcoordVCVSOutput);'];
|
|
@@ -168,7 +189,57 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
168
189
|
// dependent components
|
|
169
190
|
switch (tNumComp) {
|
|
170
191
|
case 1:
|
|
171
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Impl', [
|
|
192
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Impl', [...splitStringOnEnter(`
|
|
193
|
+
#ifdef vtkImageLabelOutlineOn
|
|
194
|
+
vec3 centerPosIS = fragCoordToIndexSpace(gl_FragCoord);
|
|
195
|
+
float centerValue = texture2D(texture1, centerPosIS.xy).r;
|
|
196
|
+
bool pixelOnBorder = false;
|
|
197
|
+
vec3 tColor = texture2D(colorTexture1, vec2(centerValue * cscale0 + cshift0, 0.5)).rgb;
|
|
198
|
+
float scalarOpacity = texture2D(pwfTexture1, vec2(centerValue * pwfscale0 + pwfshift0, 0.5)).r;
|
|
199
|
+
float opacityToUse = scalarOpacity * opacity;
|
|
200
|
+
int segmentIndex = int(centerValue * 255.0);
|
|
201
|
+
float textureCoordinate = float(segmentIndex - 1) / 1024.0;
|
|
202
|
+
float textureValue = texture2D(labelOutlineTexture1, vec2(textureCoordinate, 0.5)).r;
|
|
203
|
+
int actualThickness = int(textureValue * 255.0);
|
|
204
|
+
|
|
205
|
+
if (actualThickness == 0) {
|
|
206
|
+
gl_FragData[0] = vec4(0.0, 0.0, 1.0, 1.0);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (opacityToUse > 0.01) {
|
|
210
|
+
for (int i = -actualThickness; i <= actualThickness; i++) {
|
|
211
|
+
for (int j = -actualThickness; j <= actualThickness; j++) {
|
|
212
|
+
if (i == 0 || j == 0) {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
vec4 neighborPixelCoord = vec4(gl_FragCoord.x + float(i),
|
|
216
|
+
gl_FragCoord.y + float(j),
|
|
217
|
+
gl_FragCoord.z, gl_FragCoord.w);
|
|
218
|
+
vec3 neighborPosIS = fragCoordToIndexSpace(neighborPixelCoord);
|
|
219
|
+
float value = texture2D(texture1, neighborPosIS.xy).r;
|
|
220
|
+
if (value != centerValue) {
|
|
221
|
+
pixelOnBorder = true;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (pixelOnBorder == true) {
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (pixelOnBorder == true) {
|
|
230
|
+
gl_FragData[0] = vec4(tColor, outlineOpacity);
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
gl_FragData[0] = vec4(tColor, opacityToUse);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
#else
|
|
237
|
+
float intensity = texture2D(texture1, tcoordVCVSOutput).r;
|
|
238
|
+
vec3 tcolor = texture2D(colorTexture1, vec2(intensity * cscale0 + cshift0, 0.5)).rgb;
|
|
239
|
+
float scalarOpacity = texture2D(pwfTexture1, vec2(intensity * pwfscale0 + pwfshift0, 0.5)).r;
|
|
240
|
+
gl_FragData[0] = vec4(tcolor, scalarOpacity * opacity);
|
|
241
|
+
#endif
|
|
242
|
+
`)]).result;
|
|
172
243
|
break;
|
|
173
244
|
case 2:
|
|
174
245
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Impl', ['vec4 tcolor = texture2D(texture1, tcoordVCVSOutput);', 'float intensity = tcolor.r*cscale0 + cshift0;', 'gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(intensity, 0.5)).rgb, pwfscale0*tcolor.g + pwfshift0);']).result;
|
|
@@ -338,6 +409,8 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
338
409
|
cellBO.getProgram().setUniformi('colorTexture1', texColorUnit);
|
|
339
410
|
const texOpacityUnit = model.pwfTexture.getTextureUnit();
|
|
340
411
|
cellBO.getProgram().setUniformi('pwfTexture1', texOpacityUnit);
|
|
412
|
+
const outlineThicknessUnit = model.labelOutlineThicknessTexture.getTextureUnit();
|
|
413
|
+
cellBO.getProgram().setUniformi('labelOutlineTexture1', outlineThicknessUnit);
|
|
341
414
|
if (model.renderable.getNumberOfClippingPlanes()) {
|
|
342
415
|
// add all the clipping planes
|
|
343
416
|
let numClipPlanes = model.renderable.getNumberOfClippingPlanes();
|
|
@@ -368,6 +441,13 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
368
441
|
cellBO.getProgram().setUniformi('numClipPlanes', numClipPlanes);
|
|
369
442
|
cellBO.getProgram().setUniform4fv('clipPlanes', planeEquations);
|
|
370
443
|
}
|
|
444
|
+
|
|
445
|
+
// outline thickness and opacity
|
|
446
|
+
const vtkImageLabelOutline = actor.getProperty().getUseLabelOutline();
|
|
447
|
+
if (vtkImageLabelOutline === true) {
|
|
448
|
+
const outlineOpacity = actor.getProperty().getLabelOutlineOpacity();
|
|
449
|
+
cellBO.getProgram().setUniformf('outlineOpacity', outlineOpacity);
|
|
450
|
+
}
|
|
371
451
|
};
|
|
372
452
|
publicAPI.setCameraShaderParameters = (cellBO, ren, actor) => {
|
|
373
453
|
const program = cellBO.getProgram();
|
|
@@ -382,6 +462,25 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
382
462
|
mat4.multiply(model.imagemat, model.imagemat, inverseShiftScaleMat);
|
|
383
463
|
}
|
|
384
464
|
program.setUniformMatrix('MCPCMatrix', model.imagemat);
|
|
465
|
+
const vtkImageLabelOutline = actor.getProperty().getUseLabelOutline();
|
|
466
|
+
if (vtkImageLabelOutline === true) {
|
|
467
|
+
const worldToIndex = image.getWorldToIndex();
|
|
468
|
+
const imageDimensions = image.getDimensions();
|
|
469
|
+
program.setUniform3i('imageDimensions', imageDimensions[0], imageDimensions[1], 1);
|
|
470
|
+
program.setUniformMatrix('vWCtoIDX', worldToIndex);
|
|
471
|
+
const labelOutlineKeyMats = model.openGLCamera.getKeyMatrices(ren);
|
|
472
|
+
|
|
473
|
+
// Get the projection coordinate to world coordinate transformation matrix.
|
|
474
|
+
mat4.invert(model.projectionToWorld, labelOutlineKeyMats.wcpc);
|
|
475
|
+
model.openGLCamera.getKeyMatrices(ren);
|
|
476
|
+
program.setUniformMatrix('PCWCMatrix', model.projectionToWorld);
|
|
477
|
+
const size = publicAPI.getRenderTargetSize();
|
|
478
|
+
program.setUniformf('vpWidth', size[0]);
|
|
479
|
+
program.setUniformf('vpHeight', size[1]);
|
|
480
|
+
const offset = publicAPI.getRenderTargetOffset();
|
|
481
|
+
program.setUniformf('vpOffsetX', offset[0] / size[0]);
|
|
482
|
+
program.setUniformf('vpOffsetY', offset[1] / size[1]);
|
|
483
|
+
}
|
|
385
484
|
};
|
|
386
485
|
publicAPI.setPropertyShaderParameters = (cellBO, ren, actor) => {
|
|
387
486
|
const program = cellBO.getProgram();
|
|
@@ -402,6 +501,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
402
501
|
// activate the texture
|
|
403
502
|
model.openGLTexture.activate();
|
|
404
503
|
model.colorTexture.activate();
|
|
504
|
+
model.labelOutlineThicknessTexture.activate();
|
|
405
505
|
model.pwfTexture.activate();
|
|
406
506
|
|
|
407
507
|
// draw polygons
|
|
@@ -413,6 +513,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
413
513
|
}
|
|
414
514
|
model.openGLTexture.deactivate();
|
|
415
515
|
model.colorTexture.deactivate();
|
|
516
|
+
model.labelOutlineThicknessTexture.deactivate();
|
|
416
517
|
model.pwfTexture.deactivate();
|
|
417
518
|
};
|
|
418
519
|
publicAPI.renderPieceFinish = (ren, actor) => {};
|
|
@@ -600,6 +701,9 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
600
701
|
model.pwfTextureString = pwfTex.hash;
|
|
601
702
|
}
|
|
602
703
|
|
|
704
|
+
// Build outline thickness buffer
|
|
705
|
+
publicAPI.updatelabelOutlineThicknessTexture(actor);
|
|
706
|
+
|
|
603
707
|
// Find what IJK axis and what direction to slice along
|
|
604
708
|
const {
|
|
605
709
|
ijkMode
|
|
@@ -794,6 +898,67 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
794
898
|
model.VBOBuildString = toString;
|
|
795
899
|
}
|
|
796
900
|
};
|
|
901
|
+
publicAPI.updatelabelOutlineThicknessTexture = image => {
|
|
902
|
+
if (!model.labelOutlineThicknessTexture) {
|
|
903
|
+
model.labelOutlineThicknessTexture = vtkOpenGLTexture.newInstance({
|
|
904
|
+
resizable: false
|
|
905
|
+
});
|
|
906
|
+
model.labelOutlineThicknessTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
907
|
+
}
|
|
908
|
+
const labelOutlineThicknessArray = image.getProperty().getLabelOutlineThickness();
|
|
909
|
+
const lTex = model._openGLRenderWindow.getGraphicsResourceForObject(labelOutlineThicknessArray);
|
|
910
|
+
|
|
911
|
+
// compute the join of the labelOutlineThicknessArray so that
|
|
912
|
+
// we can use it to decide whether to rebuild the labelOutlineThicknessTexture
|
|
913
|
+
// or not
|
|
914
|
+
const toString = `${labelOutlineThicknessArray.join('-')}`;
|
|
915
|
+
const reBuildL = !lTex?.vtkObj || lTex?.hash !== toString || model.labelOutlineThicknessTextureString !== toString;
|
|
916
|
+
if (reBuildL) {
|
|
917
|
+
const lWidth = 1024;
|
|
918
|
+
const lHeight = 1;
|
|
919
|
+
const lSize = lWidth * lHeight;
|
|
920
|
+
const lTable = new Uint8Array(lSize);
|
|
921
|
+
|
|
922
|
+
// Assuming labelOutlineThicknessArray contains the thickness for each segment
|
|
923
|
+
for (let i = 0; i < lWidth; ++i) {
|
|
924
|
+
// Retrieve the thickness value for the current segment index.
|
|
925
|
+
// If the value is undefined, null, or 0, use the first element's value as a default.
|
|
926
|
+
const thickness = labelOutlineThicknessArray[i] || labelOutlineThicknessArray[0];
|
|
927
|
+
lTable[i] = thickness;
|
|
928
|
+
}
|
|
929
|
+
model.labelOutlineThicknessTexture.releaseGraphicsResources(model._openGLRenderWindow);
|
|
930
|
+
model.labelOutlineThicknessTexture.resetFormatAndType();
|
|
931
|
+
model.labelOutlineThicknessTexture.setMinificationFilter(Filter.NEAREST);
|
|
932
|
+
model.labelOutlineThicknessTexture.setMagnificationFilter(Filter.NEAREST);
|
|
933
|
+
|
|
934
|
+
// Create a 2D texture (acting as 1D) from the raw data
|
|
935
|
+
model.labelOutlineThicknessTexture.create2DFromRaw(lWidth, lHeight, 1, VtkDataTypes.UNSIGNED_CHAR, lTable);
|
|
936
|
+
model.labelOutlineThicknessTextureString = toString;
|
|
937
|
+
if (labelOutlineThicknessArray) {
|
|
938
|
+
model._openGLRenderWindow.setGraphicsResourceForObject(labelOutlineThicknessArray, model.labelOutlineThicknessTexture, model.labelOutlineThicknessTextureString);
|
|
939
|
+
}
|
|
940
|
+
} else {
|
|
941
|
+
model.labelOutlineThicknessTexture = lTex.vtkObj;
|
|
942
|
+
model.labelOutlineThicknessTextureString = lTex.hash;
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
publicAPI.getRenderTargetSize = () => {
|
|
946
|
+
if (model._useSmallViewport) {
|
|
947
|
+
return [model._smallViewportWidth, model._smallViewportHeight];
|
|
948
|
+
}
|
|
949
|
+
const {
|
|
950
|
+
usize,
|
|
951
|
+
vsize
|
|
952
|
+
} = model._openGLRenderer.getTiledSizeAndOrigin();
|
|
953
|
+
return [usize, vsize];
|
|
954
|
+
};
|
|
955
|
+
publicAPI.getRenderTargetOffset = () => {
|
|
956
|
+
const {
|
|
957
|
+
lowerLeftU,
|
|
958
|
+
lowerLeftV
|
|
959
|
+
} = model._openGLRenderer.getTiledSizeAndOrigin();
|
|
960
|
+
return [lowerLeftU, lowerLeftV];
|
|
961
|
+
};
|
|
797
962
|
}
|
|
798
963
|
|
|
799
964
|
// ----------------------------------------------------------------------------
|
|
@@ -809,6 +974,8 @@ const DEFAULT_VALUES = {
|
|
|
809
974
|
imagematinv: null,
|
|
810
975
|
colorTexture: null,
|
|
811
976
|
pwfTexture: null,
|
|
977
|
+
labelOutlineThicknessTexture: null,
|
|
978
|
+
labelOutlineThicknessTextureString: null,
|
|
812
979
|
lastHaveSeenDepthRequest: false,
|
|
813
980
|
haveSeenDepthRequest: false,
|
|
814
981
|
lastTextureComponents: 0,
|
|
@@ -828,6 +995,11 @@ function extend(publicAPI, model) {
|
|
|
828
995
|
model.tris = vtkHelper.newInstance();
|
|
829
996
|
model.imagemat = mat4.identity(new Float64Array(16));
|
|
830
997
|
model.imagematinv = mat4.identity(new Float64Array(16));
|
|
998
|
+
model.projectionToWorld = mat4.identity(new Float64Array(16));
|
|
999
|
+
model.idxToView = mat4.identity(new Float64Array(16));
|
|
1000
|
+
model.idxNormalMatrix = mat3.identity(new Float64Array(9));
|
|
1001
|
+
model.modelToView = mat4.identity(new Float64Array(16));
|
|
1002
|
+
model.projectionToView = mat4.identity(new Float64Array(16));
|
|
831
1003
|
|
|
832
1004
|
// Build VTK API
|
|
833
1005
|
setGet(publicAPI, model, []);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var vtkPolyDataFS = "//VTK::System::Dec\n\n/*=========================================================================\n\n Program: Visualization Toolkit\n Module: vtkPolyDataFS.glsl\n\n Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n All rights reserved.\n See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n PURPOSE. See the above copyright notice for more information.\n\n=========================================================================*/\n// Template for the polydata mappers fragment shader\n\nuniform int PrimitiveIDOffset;\n\n// VC position of this fragment\n//VTK::PositionVC::Dec\n\n// optional color passed in from the vertex shader, vertexColor\n//VTK::Color::Dec\n\n// optional surface normal declaration\n//VTK::Normal::Dec\n\n// extra lighting parameters\n//VTK::Light::Dec\n\n// Texture coordinates\n//VTK::TCoord::Dec\n\n// picking support\n//VTK::Picking::Dec\n\n// Depth Peeling Support\n//VTK::DepthPeeling::Dec\n\n// clipping plane vars\n//VTK::Clip::Dec\n\n// the output of this shader\n//VTK::Output::Dec\n\n// Apple Bug\n//VTK::PrimID::Dec\n\n// handle coincident offsets\n//VTK::Coincident::Dec\n\n//VTK::ZBuffer::Dec\n\nvoid main()\n{\n // VC position of this fragment. This should not branch/return/discard.\n //VTK::PositionVC::Impl\n\n // Place any calls that require uniform flow (e.g. dFdx) here.\n //VTK::UniformFlow::Impl\n\n // Set gl_FragDepth here (gl_FragCoord.z by default)\n //VTK::Depth::Impl\n\n // Early depth peeling abort:\n //VTK::DepthPeeling::PreColor\n\n // Apple Bug\n //VTK::PrimID::Impl\n\n //VTK::Clip::Impl\n\n //VTK::Color::Impl\n\n // Generate the normal if we are not passed in one\n //VTK::Normal::Impl\n\n //VTK::TCoord::Impl\n\n //VTK::Light::Impl\n\n if (gl_FragData[0].a <= 0.0)\n {\n discard;\n }\n\n //VTK::DepthPeeling::Impl\n\n //VTK::Picking::Impl\n\n // handle coincident offsets\n //VTK::Coincident::Impl\n\n //VTK::ZBuffer::Impl\n\n //VTK::RenderPassFragmentShader::Impl\n}\n";
|
|
1
|
+
var vtkPolyDataFS = "//VTK::System::Dec\n\n/*=========================================================================\n\n Program: Visualization Toolkit\n Module: vtkPolyDataFS.glsl\n\n Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n All rights reserved.\n See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n PURPOSE. See the above copyright notice for more information.\n\n=========================================================================*/\n// Template for the polydata mappers fragment shader\n\nuniform int PrimitiveIDOffset;\n\n// VC position of this fragment\n//VTK::PositionVC::Dec\n\n// optional color passed in from the vertex shader, vertexColor\n//VTK::Color::Dec\n\n// optional surface normal declaration\n//VTK::Normal::Dec\n\n// extra lighting parameters\n//VTK::Light::Dec\n\n// define vtkImageLabelOutlineOn\n//VTK::ImageLabelOutlineOn\n\n// Texture coordinates\n//VTK::TCoord::Dec\n\n// picking support\n//VTK::Picking::Dec\n\n// Depth Peeling Support\n//VTK::DepthPeeling::Dec\n\n// clipping plane vars\n//VTK::Clip::Dec\n\n// label outline \n//VTK::LabelOutline::Dec\n\n// the output of this shader\n//VTK::Output::Dec\n\n// Apple Bug\n//VTK::PrimID::Dec\n\n// handle coincident offsets\n//VTK::Coincident::Dec\n\n//VTK::ZBuffer::Dec\n\n//VTK::LabelOutlineHelperFunction\n\nvoid main()\n{\n // VC position of this fragment. This should not branch/return/discard.\n //VTK::PositionVC::Impl\n\n // Place any calls that require uniform flow (e.g. dFdx) here.\n //VTK::UniformFlow::Impl\n\n // Set gl_FragDepth here (gl_FragCoord.z by default)\n //VTK::Depth::Impl\n\n // Early depth peeling abort:\n //VTK::DepthPeeling::PreColor\n\n // Apple Bug\n //VTK::PrimID::Impl\n\n //VTK::Clip::Impl\n\n //VTK::Color::Impl\n\n // Generate the normal if we are not passed in one\n //VTK::Normal::Impl\n\n //VTK::TCoord::Impl\n\n //VTK::Light::Impl\n\n if (gl_FragData[0].a <= 0.0)\n {\n discard;\n }\n\n //VTK::DepthPeeling::Impl\n\n //VTK::Picking::Impl\n\n // handle coincident offsets\n //VTK::Coincident::Impl\n\n //VTK::ZBuffer::Impl\n\n //VTK::RenderPassFragmentShader::Impl\n}\n";
|
|
2
2
|
|
|
3
3
|
export { vtkPolyDataFS as v };
|
package/macros2.js
CHANGED