Skip to content

Commit c510277

Browse files
committed
feat(mappers): set opacity/color/label tex widths
1 parent 0296cfe commit c510277

File tree

9 files changed

+123
-12
lines changed

9 files changed

+123
-12
lines changed

Sources/Rendering/Core/AbstractImageMapper/index.d.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,54 @@ export interface vtkAbstractImageMapper extends vtkAbstractMapper3D {
122122
* @param customDisplayExtent
123123
*/
124124
setCustomDisplayExtentFrom(customDisplayExtent: number[]): boolean;
125+
126+
/**
127+
* Set the opacity texture width.
128+
*
129+
* The default width (1024) should be fine in most instances.
130+
* Only set this property if your opacity function range width is
131+
* larger than 1024.
132+
*
133+
* @param {Number} width the texture width (defaults to 1024)
134+
*/
135+
setOpacityTextureWidth(width: number): boolean;
136+
137+
/**
138+
* Get the opacity texture width.
139+
*/
140+
getOpacityTextureWidth(): number;
141+
142+
/**
143+
* Set the color texture width.
144+
*
145+
* The default width (1024) should be fine in most instances.
146+
* Only set this property if your color transfer function range width is
147+
* larger than 1024.
148+
*
149+
* @param {Number} width the texture width (defaults to 1024)
150+
*/
151+
setColorTextureWidth(width: number): boolean;
152+
153+
/**
154+
* Get the color texture width.
155+
*/
156+
getColorTextureWidth(): number;
157+
158+
/**
159+
* Set the label outline texture width.
160+
*
161+
* The default width (1024) should be fine in most instances.
162+
* Only set this property if you have more than 1024 labels
163+
* that you want to render with thickness.
164+
*
165+
* @param {Number} width the texture width (defaults to 1024)
166+
*/
167+
setLabelOutlineTextureWidth(width: number): boolean;
168+
169+
/**
170+
* Get the label outline texture width.
171+
*/
172+
getLabelOutlineTextureWidth(): number;
125173
}
126174

127175
/**

Sources/Rendering/Core/AbstractImageMapper/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const DEFAULT_VALUES = {
3030
customDisplayExtent: [0, 0, 0, 0, 0, 0],
3131
useCustomExtents: false,
3232
backgroundColor: [0, 0, 0, 1],
33+
colorTextureWidth: 1024,
34+
opacityTextureWidth: 1024,
35+
labelOutlineTextureWidth: 1024,
3336
};
3437

3538
// ----------------------------------------------------------------------------
@@ -40,7 +43,13 @@ export function extend(publicAPI, model, initialValues = {}) {
4043
// Build VTK API
4144
vtkAbstractMapper3D.extend(publicAPI, model, initialValues);
4245

43-
macro.setGet(publicAPI, model, ['slice', 'useCustomExtents']);
46+
macro.setGet(publicAPI, model, [
47+
'slice',
48+
'useCustomExtents',
49+
'colorTextureWidth',
50+
'opacityTextureWidth',
51+
'labelOutlineTextureWidth',
52+
]);
4453
macro.setGetArray(publicAPI, model, ['customDisplayExtent'], 6);
4554
macro.setGetArray(publicAPI, model, ['backgroundColor'], 4);
4655

Sources/Rendering/Core/CellPicker/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function vtkCellPicker(publicAPI, model) {
277277

278278
// calculate opacity table
279279
const numIComps = 1;
280-
const oWidth = 1024;
280+
const oWidth = mapper.getOpacityTextureWidth();
281281
const tmpTable = new Float32Array(oWidth);
282282
const opacityArray = new Float32Array(oWidth);
283283
let ofun;

Sources/Rendering/Core/VolumeMapper/index.d.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,54 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
318318
*
319319
*/
320320
update(): void;
321+
322+
/**
323+
* Set the opacity texture width.
324+
*
325+
* The default width (1024) should be fine in most instances.
326+
* Only set this property if your opacity function range width is
327+
* larger than 1024.
328+
*
329+
* @param {Number} width the texture width (defaults to 1024)
330+
*/
331+
setOpacityTextureWidth(width: number): boolean;
332+
333+
/**
334+
* Get the opacity texture width.
335+
*/
336+
getOpacityTextureWidth(): number;
337+
338+
/**
339+
* Set the color texture width.
340+
*
341+
* The default width (1024) should be fine in most instances.
342+
* Only set this property if your color transfer function range width is
343+
* larger than 1024.
344+
*
345+
* @param {Number} width the texture width (defaults to 1024)
346+
*/
347+
setColorTextureWidth(width: number): boolean;
348+
349+
/**
350+
* Get the color texture width.
351+
*/
352+
getColorTextureWidth(): number;
353+
354+
/**
355+
* Set the label outline texture width.
356+
*
357+
* The default width (1024) should be fine in most instances.
358+
* Only set this property if you have more than 1024 labels
359+
* that you want to render with thickness.
360+
*
361+
* @param {Number} width the texture width (defaults to 1024)
362+
*/
363+
setLabelOutlineTextureWidth(width: number): boolean;
364+
365+
/**
366+
* Get the label outline texture width.
367+
*/
368+
getLabelOutlineTextureWidth(): number;
321369
}
322370

323371
/**

Sources/Rendering/Core/VolumeMapper/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ const defaultValues = (initialValues) => ({
164164
LAOKernelSize: 15,
165165
LAOKernelRadius: 7,
166166
updatedExtents: [],
167+
colorTextureWidth: 1024,
168+
opacityTextureWidth: 1024,
169+
labelOutlineTextureWidth: 1024,
167170
...initialValues,
168171
});
169172

@@ -193,6 +196,9 @@ export function extend(publicAPI, model, initialValues = {}) {
193196
'LAOKernelSize',
194197
'LAOKernelRadius',
195198
'updatedExtents',
199+
'colorTextureWidth',
200+
'opacityTextureWidth',
201+
'labelOutlineTextureWidth',
196202
]);
197203

198204
macro.setGetArray(publicAPI, model, ['ipScalarRange'], 2);

Sources/Rendering/OpenGL/ImageCPRMapper/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
275275
!cachedColorEntry?.oglObject?.getHandle() ||
276276
cachedColorEntry?.hash !== colorTextureHash;
277277
if (reBuildColorTexture) {
278-
const cWidth = 1024;
278+
const cWidth = model.renderable.getColorTextureWidth();
279279
const cSize = cWidth * textureHeight * 3;
280280
const cTable = new Uint8ClampedArray(cSize);
281281
model.colorTexture = vtkOpenGLTexture.newInstance();
@@ -355,7 +355,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
355355
!cachedPwfEntry?.oglObject?.getHandle() ||
356356
cachedPwfEntry?.hash !== pwfTextureHash;
357357
if (reBuildPwf) {
358-
const pwfWidth = 1024;
358+
const pwfWidth = model.renderable.getOpacityTextureWidth();
359359
const pwfSize = pwfWidth * textureHeight;
360360
const pwfTable = new Uint8ClampedArray(pwfSize);
361361
model.pwfTexture = vtkOpenGLTexture.newInstance();

Sources/Rendering/OpenGL/ImageMapper/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
969969
resizable: true,
970970
});
971971
model.colorTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
972-
const cWidth = 1024;
972+
const cWidth = model.renderable.getColorTextureWidth();
973973
const cSize = cWidth * textureHeight * 3;
974974
const cTable = new Uint8ClampedArray(cSize);
975975
// set interpolation on the texture based on property setting
@@ -1055,7 +1055,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
10551055
const reBuildPwf =
10561056
!pwfTex?.oglObject?.getHandle() || pwfTex?.hash !== pwfunToString;
10571057
if (reBuildPwf) {
1058-
const pwfWidth = 1024;
1058+
const pwfWidth = model.renderable.getOpacityTextureWidth();
10591059
const pwfSize = pwfWidth * textureHeight;
10601060
const pwfTable = new Uint8ClampedArray(pwfSize);
10611061
model.pwfTexture = vtkOpenGLTexture.newInstance({
@@ -1397,7 +1397,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
13971397
const reBuildL = !lTex?.oglObject?.getHandle() || lTex?.hash !== toString;
13981398

13991399
if (reBuildL) {
1400-
const lWidth = 1024;
1400+
const lWidth = model.renderable.getLabelOutlineTextureWidth();
14011401
const lHeight = 1;
14021402
const lSize = lWidth * lHeight;
14031403
const lTable = new Uint8Array(lSize);

Sources/Rendering/OpenGL/ImageResliceMapper/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
302302
model._openGLRenderWindow.getGraphicsResourceForObject(colorTransferFunc);
303303
const reBuildC = !cTex?.oglObject?.getHandle() || cTex?.hash !== toString;
304304
if (reBuildC) {
305-
const cWidth = 1024;
305+
const cWidth = model.renderable.getColorTextureWidth();
306306
const cSize = cWidth * textureHeight * 3;
307307
const cTable = new Uint8ClampedArray(cSize);
308308
model.colorTexture = vtkOpenGLTexture.newInstance();
@@ -382,7 +382,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
382382
const reBuildPwf =
383383
!pwfTex?.oglObject?.getHandle() || pwfTex?.hash !== toString;
384384
if (reBuildPwf) {
385-
const pwfWidth = 1024;
385+
const pwfWidth = model.renderable.getOpacityTextureWidth();
386386
const pwfSize = pwfWidth * textureHeight;
387387
const pwfTable = new Uint8ClampedArray(pwfSize);
388388
model.pwfTexture = vtkOpenGLTexture.newInstance();

Sources/Rendering/OpenGL/VolumeMapper/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
15701570
model.opacityTexture = vtkOpenGLTexture.newInstance();
15711571
model.opacityTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
15721572
// rebuild opacity tfun?
1573-
const oWidth = 1024;
1573+
const oWidth = model.renderable.getOpacityTextureWidth();
15741574
const oSize = oWidth * 2 * numIComps;
15751575
const ofTable = new Float32Array(oSize);
15761576
const tmpTable = new Float32Array(oWidth);
@@ -1659,7 +1659,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
16591659
if (reBuildC) {
16601660
model.colorTexture = vtkOpenGLTexture.newInstance();
16611661
model.colorTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
1662-
const cWidth = 1024;
1662+
const cWidth = model.renderable.getColorTextureWidth();
16631663
const cSize = cWidth * 2 * numIComps * 3;
16641664
const cTable = new Uint8ClampedArray(cSize);
16651665
const tmpTable = new Float32Array(cWidth * 3);
@@ -1856,7 +1856,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
18561856
model.labelOutlineThicknessTexture.setOpenGLRenderWindow(
18571857
model._openGLRenderWindow
18581858
);
1859-
const lWidth = 1024;
1859+
const lWidth = model.renderable.getLabelOutlineTextureWidth();
18601860
const lHeight = 1;
18611861
const lSize = lWidth * lHeight;
18621862
const lTable = new Uint8Array(lSize);

0 commit comments

Comments
 (0)