@kitware/vtk.js 30.6.2 → 30.7.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.
@@ -148,6 +148,12 @@ export interface vtkRenderWindow extends vtkObject {
148
148
  */
149
149
  removeRenderer(renderer: vtkRenderer): void;
150
150
 
151
+ /**
152
+ * Remove a child render window added using addRenderWindow(renderWindow)
153
+ * @param {vtkRenderWindow} renderWindow The vtkRenderWindow instance.
154
+ */
155
+ removeRenderWindow(renderWindow: vtkRenderWindow): boolean;
156
+
151
157
  /**
152
158
  * Remove renderer
153
159
  * @param view
@@ -144,6 +144,15 @@ function vtkRenderWindow(publicAPI, model) {
144
144
  publicAPI.modified();
145
145
  return true;
146
146
  };
147
+ publicAPI.removeRenderWindow = child => {
148
+ const childIndex = model.childRenderWindows.findIndex(x => x === child);
149
+ if (childIndex < 0) {
150
+ return false;
151
+ }
152
+ model.childRenderWindows.splice(childIndex, 1);
153
+ publicAPI.modified();
154
+ return true;
155
+ };
147
156
  }
148
157
 
149
158
  // ----------------------------------------------------------------------------
@@ -14,7 +14,7 @@ function vtkOpenGLActor(publicAPI, model) {
14
14
  // Builds myself.
15
15
  publicAPI.buildPass = prepass => {
16
16
  if (prepass) {
17
- model._openGLRenderWindow = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow');
17
+ model._openGLRenderWindow = publicAPI.getLastAncestorOfType('vtkOpenGLRenderWindow');
18
18
  model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer');
19
19
  model.context = model._openGLRenderWindow.getContext();
20
20
  publicAPI.prepareNodes();
@@ -16,7 +16,7 @@ function vtkOpenGLActor2D(publicAPI, model) {
16
16
  if (!model.renderable) {
17
17
  return;
18
18
  }
19
- model._openGLRenderWindow = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow');
19
+ model._openGLRenderWindow = publicAPI.getLastAncestorOfType('vtkOpenGLRenderWindow');
20
20
  model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer');
21
21
  model.context = model._openGLRenderWindow.getContext();
22
22
  publicAPI.prepareNodes();
@@ -551,13 +551,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
551
551
  publicAPI.buildBufferObjects(ren, actor);
552
552
  }
553
553
  };
554
- publicAPI.getNeedToRebuildBufferObjects = (ren, actor) => {
555
- // first do a coarse check
556
- if (model.VBOBuildTime.getMTime() < publicAPI.getMTime() || model.VBOBuildTime.getMTime() < actor.getMTime() || model.VBOBuildTime.getMTime() < model.renderable.getMTime() || model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() || model.VBOBuildTime.getMTime() < model.currentInput.getMTime()) {
557
- return true;
558
- }
559
- return false;
560
- };
554
+ publicAPI.getNeedToRebuildBufferObjects = (ren, actor) => model.VBOBuildTime.getMTime() < publicAPI.getMTime() || model.VBOBuildTime.getMTime() < actor.getMTime() || model.VBOBuildTime.getMTime() < model.renderable.getMTime() || model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() || model.VBOBuildTime.getMTime() < model.currentInput.getMTime() || !model.openGLTexture?.getHandle() || !model.colorTexture?.getHandle() || !model.labelOutlineThicknessTexture?.getHandle() || !model.pwfTexture?.getHandle();
561
555
  publicAPI.buildBufferObjects = (ren, actor) => {
562
556
  const image = model.currentInput;
563
557
  if (!image) {
@@ -577,7 +571,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
577
571
  const colorTransferFunc = actorProperty.getRGBTransferFunction();
578
572
  const cfunToString = computeFnToString(actorProperty, colorTransferFunc, numIComps);
579
573
  const cTex = model._openGLRenderWindow.getGraphicsResourceForObject(colorTransferFunc);
580
- const reBuildC = !cTex?.vtkObj || cTex?.hash !== cfunToString || model.colorTextureString !== cfunToString;
574
+ const reBuildC = !cTex?.vtkObj?.getHandle() || cTex?.hash !== cfunToString || model.colorTextureString !== cfunToString;
581
575
  if (reBuildC) {
582
576
  const cWidth = 1024;
583
577
  const cSize = cWidth * textureHeight * 3;
@@ -640,7 +634,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
640
634
  const pwfunToString = computeFnToString(actorProperty, pwFunc, numIComps);
641
635
  const pwfTex = model._openGLRenderWindow.getGraphicsResourceForObject(pwFunc);
642
636
  // rebuild opacity tfun?
643
- const reBuildPwf = !pwfTex?.vtkObj || pwfTex?.hash !== pwfunToString || model.pwfTextureString !== pwfunToString;
637
+ const reBuildPwf = !pwfTex?.vtkObj?.getHandle() || pwfTex?.hash !== pwfunToString || model.pwfTextureString !== pwfunToString;
644
638
  if (reBuildPwf) {
645
639
  const pwfWidth = 1024;
646
640
  const pwfSize = pwfWidth * textureHeight;
@@ -852,7 +846,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
852
846
  vtkErrorMacro('Reformat slicing not yet supported.');
853
847
  }
854
848
  const tex = model._openGLRenderWindow.getGraphicsResourceForObject(scalars);
855
- if (!tex?.vtkObj) {
849
+ if (!tex?.vtkObj?.getHandle()) {
856
850
  if (model._scalars !== scalars) {
857
851
  model._openGLRenderWindow.releaseGraphicsResourcesForObject(model._scalars);
858
852
  model._scalars = scalars;
@@ -913,7 +907,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
913
907
  // we can use it to decide whether to rebuild the labelOutlineThicknessTexture
914
908
  // or not
915
909
  const toString = `${labelOutlineThicknessArray.join('-')}`;
916
- const reBuildL = !lTex?.vtkObj || lTex?.hash !== toString || model.labelOutlineThicknessTextureString !== toString;
910
+ const reBuildL = !lTex?.vtkObj?.getHandle() || lTex?.hash !== toString || model.labelOutlineThicknessTextureString !== toString;
917
911
  if (reBuildL) {
918
912
  const lWidth = 1024;
919
913
  const lHeight = 1;
@@ -164,7 +164,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
164
164
  publicAPI.buildBufferObjects(ren, actor);
165
165
  }
166
166
  };
167
- publicAPI.getNeedToRebuildBufferObjects = (ren, actor) => model.VBOBuildTime.getMTime() < publicAPI.getMTime() || model.VBOBuildTime.getMTime() < actor.getMTime() || model.VBOBuildTime.getMTime() < model.renderable.getMTime() || model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() || model.VBOBuildTime.getMTime() < model.currentInput.getMTime() || model.VBOBuildTime.getMTime() < model.resliceGeom.getMTime();
167
+ publicAPI.getNeedToRebuildBufferObjects = (ren, actor) => model.VBOBuildTime.getMTime() < publicAPI.getMTime() || model.VBOBuildTime.getMTime() < actor.getMTime() || model.VBOBuildTime.getMTime() < model.renderable.getMTime() || model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() || model.VBOBuildTime.getMTime() < model.currentInput.getMTime() || model.VBOBuildTime.getMTime() < model.resliceGeom.getMTime() || !model.openGLTexture?.getHandle() || !model.colorTexture?.getHandle() || !model.pwfTexture?.getHandle();
168
168
  publicAPI.buildBufferObjects = (ren, actor) => {
169
169
  const image = model.currentInput;
170
170
  if (!image) {
@@ -181,7 +181,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
181
181
  const numComp = scalars.getNumberOfComponents();
182
182
  let toString = `${image.getMTime()}A${scalars.getMTime()}`;
183
183
  const tex = model._openGLRenderWindow.getGraphicsResourceForObject(scalars);
184
- const reBuildTex = !tex?.vtkObj || tex?.hash !== toString;
184
+ const reBuildTex = !tex?.vtkObj?.getHandle() || tex?.hash !== toString;
185
185
  if (reBuildTex) {
186
186
  if (!model.openGLTexture) {
187
187
  model.openGLTexture = vtkOpenGLTexture.newInstance();
@@ -207,7 +207,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
207
207
  const colorTransferFunc = ppty.getRGBTransferFunction();
208
208
  toString = computeFnToString(ppty, colorTransferFunc, numIComps);
209
209
  const cTex = model._openGLRenderWindow.getGraphicsResourceForObject(colorTransferFunc);
210
- const reBuildC = !cTex?.vtkObj || cTex?.hash !== toString || model.colorTextureString !== toString;
210
+ const reBuildC = !cTex?.vtkObj?.getHandle() || cTex?.hash !== toString || model.colorTextureString !== toString;
211
211
  if (reBuildC) {
212
212
  const cWidth = 1024;
213
213
  const cSize = cWidth * textureHeight * 3;
@@ -262,7 +262,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
262
262
  toString = computeFnToString(ppty, pwFunc, numIComps);
263
263
  const pwfTex = model._openGLRenderWindow.getGraphicsResourceForObject(pwFunc);
264
264
  // rebuild opacity tfun?
265
- const reBuildPwf = !pwfTex?.vtkObj || pwfTex?.hash !== toString || model.pwfTextureString !== toString;
265
+ const reBuildPwf = !pwfTex?.vtkObj?.getHandle() || pwfTex?.hash !== toString || model.pwfTextureString !== toString;
266
266
  if (reBuildPwf) {
267
267
  const pwfWidth = 1024;
268
268
  const pwfSize = pwfWidth * textureHeight;
@@ -20,7 +20,7 @@ function vtkOpenGLImageSlice(publicAPI, model) {
20
20
  if (!model.renderable) {
21
21
  return;
22
22
  }
23
- model._openGLRenderWindow = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow');
23
+ model._openGLRenderWindow = publicAPI.getLastAncestorOfType('vtkOpenGLRenderWindow');
24
24
  model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer');
25
25
  model.context = model._openGLRenderWindow.getContext();
26
26
  publicAPI.prepareNodes();
@@ -657,7 +657,9 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
657
657
  if (model.context) {
658
658
  deleteGLContext();
659
659
  }
660
- }, clearEvents, publicAPI.delete, publicAPI.setViewStream);
660
+ publicAPI.setContainer();
661
+ publicAPI.setViewStream();
662
+ }, clearEvents, publicAPI.delete);
661
663
 
662
664
  // Do not trigger modified for performance reasons
663
665
  publicAPI.setActiveFramebuffer = newActiveFramebuffer => {
@@ -17,7 +17,7 @@ function vtkOpenGLVolume(publicAPI, model) {
17
17
  return;
18
18
  }
19
19
  if (prepass) {
20
- model._openGLRenderWindow = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow');
20
+ model._openGLRenderWindow = publicAPI.getLastAncestorOfType('vtkOpenGLRenderWindow');
21
21
  model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer');
22
22
  model.context = model._openGLRenderWindow.getContext();
23
23
  publicAPI.prepareNodes();
@@ -133,7 +133,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
133
133
  // Renders myself
134
134
  publicAPI.volumePass = (prepass, renderPass) => {
135
135
  if (prepass) {
136
- model._openGLRenderWindow = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow');
136
+ model._openGLRenderWindow = publicAPI.getLastAncestorOfType('vtkOpenGLRenderWindow');
137
137
  model.context = model._openGLRenderWindow.getContext();
138
138
  model.tris.setOpenGLRenderWindow(model._openGLRenderWindow);
139
139
  model.jitterTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
@@ -1004,7 +1004,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
1004
1004
  };
1005
1005
  publicAPI.getNeedToRebuildBufferObjects = (ren, actor) => {
1006
1006
  // first do a coarse check
1007
- if (model.VBOBuildTime.getMTime() < publicAPI.getMTime() || model.VBOBuildTime.getMTime() < actor.getMTime() || model.VBOBuildTime.getMTime() < model.renderable.getMTime() || model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() || model.VBOBuildTime.getMTime() < model.currentInput.getMTime()) {
1007
+ if (model.VBOBuildTime.getMTime() < publicAPI.getMTime() || model.VBOBuildTime.getMTime() < actor.getMTime() || model.VBOBuildTime.getMTime() < model.renderable.getMTime() || model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() || model.VBOBuildTime.getMTime() < model.currentInput.getMTime() || !model.scalarTexture?.getHandle() || !model.colorTexture?.getHandle() || !model.labelOutlineThicknessTexture?.getHandle()) {
1008
1008
  return true;
1009
1009
  }
1010
1010
  return false;
@@ -1087,7 +1087,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
1087
1087
  const colorTransferFunc = vprop.getRGBTransferFunction();
1088
1088
  toString = computeFnToString(colorTransferFunc, useIndependentComps, numIComps);
1089
1089
  const cTex = model._openGLRenderWindow.getGraphicsResourceForObject(colorTransferFunc);
1090
- const reBuildC = !cTex?.vtkObj || cTex?.hash !== toString || model.colorTextureString !== toString;
1090
+ const reBuildC = !cTex?.vtkObj?.getHandle() || cTex?.hash !== toString || model.colorTextureString !== toString;
1091
1091
  if (reBuildC) {
1092
1092
  const cWidth = 1024;
1093
1093
  const cSize = cWidth * 2 * numIComps * 3;
@@ -1119,7 +1119,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
1119
1119
  const tex = model._openGLRenderWindow.getGraphicsResourceForObject(scalars);
1120
1120
  // rebuild the scalarTexture if the data has changed
1121
1121
  toString = `${image.getMTime()}A${scalars.getMTime()}`;
1122
- const reBuildTex = !tex?.vtkObj || tex?.hash !== toString;
1122
+ const reBuildTex = !tex?.vtkObj?.getHandle() || tex?.hash !== toString;
1123
1123
  if (reBuildTex) {
1124
1124
  // Build the textures
1125
1125
  const dims = image.getDimensions();
@@ -1202,7 +1202,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
1202
1202
  // we can use it to decide whether to rebuild the labelOutlineThicknessTexture
1203
1203
  // or not
1204
1204
  const toString = `${labelOutlineThicknessArray.join('-')}`;
1205
- const reBuildL = !lTex?.vtkObj || lTex?.hash !== toString || model.labelOutlineThicknessTextureString !== toString;
1205
+ const reBuildL = !lTex?.vtkObj?.getHandle() || lTex?.hash !== toString || model.labelOutlineThicknessTextureString !== toString;
1206
1206
  if (reBuildL) {
1207
1207
  const lWidth = 1024;
1208
1208
  const lHeight = 1;
@@ -26,6 +26,14 @@ export interface vtkViewNode extends vtkObject {
26
26
  */
27
27
  addMissingNode(dobj: any): vtkViewNode | undefined;
28
28
 
29
+ /**
30
+ * Removes a child view node
31
+ * If the node is not found, returns false
32
+ * Otherwise, removes the node from the children list and returns true
33
+ * @param dobj
34
+ */
35
+ removeNode(dobj: any): boolean;
36
+
29
37
  /**
30
38
  *
31
39
  * @param dataObjs
@@ -137,6 +137,19 @@ function vtkViewNode(publicAPI, model) {
137
137
  child.setVisited(true);
138
138
  }
139
139
  };
140
+ publicAPI.removeNode = child => {
141
+ const childIdx = model.children.findIndex(x => x === child);
142
+ if (childIdx < 0) {
143
+ return false;
144
+ }
145
+ const renderable = child.getRenderable();
146
+ if (renderable) {
147
+ model._renderableChildMap.delete(renderable);
148
+ }
149
+ child.delete();
150
+ model.children.splice(childIdx, 1);
151
+ return true;
152
+ };
140
153
  publicAPI.prepareNodes = () => {
141
154
  for (let index = 0; index < model.children.length; ++index) {
142
155
  model.children[index].setVisited(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "30.6.2",
3
+ "version": "30.7.0",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",