Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ImageResliceMapper multi component using multiple image data #3137

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5e46d4e
chore: Remove broken `computeBounds` functions
bruyeret Aug 14, 2024
ff6edc7
chore: Remove error in the console when mapper has no input
bruyeret Aug 14, 2024
40151eb
refactor: Make computation of bounds clearer
bruyeret Aug 20, 2024
0b56f7d
refactor: Avoid code duplication by moving `getBounds`
bruyeret Aug 20, 2024
412e1ee
refactor: Move constants from mapper to volume property
bruyeret Aug 21, 2024
6bc4642
refactor: Move VolumeMapper rendering properties in VolumeProperty
bruyeret Aug 27, 2024
22db7b4
feat: Add multi property handling to the volume actor
bruyeret Aug 21, 2024
1e9aef8
refactor: Add multi volume handling to the core volume mapper
bruyeret Aug 21, 2024
e22d1e1
refactor: Simplify getNeedToRebuildShaders in VolumeMapper
bruyeret Aug 21, 2024
27890ef
refactor: Move functions out of the volumeMapper publicAPI
bruyeret Aug 21, 2024
4c9103a
feat: Multi component using volumes
bruyeret Sep 20, 2024
87084de
refactor: Add v33 modifications to BREAKING_CHANGES
bruyeret Oct 1, 2024
4a51712
fix: Fix typescript
bruyeret Oct 1, 2024
dd4af97
test: Update tests that now fail
bruyeret Oct 1, 2024
5f29c73
fix(VolumeMapper): Use the right volume property for texture creation
bruyeret Oct 2, 2024
533797c
fix: Check if cached opacity texture is deleted
bruyeret Oct 2, 2024
40640d9
refactor: Enable multi properties on all vtkProp3D
bruyeret Oct 2, 2024
6d54ca0
refactor: Fix resource caching and signature of getProperty()
bruyeret Oct 2, 2024
b5707df
feat: Add multi-image support for components to ImageResliceMapper
bruyeret Oct 3, 2024
111f193
fix: Fix update of color and opacity textures
bruyeret Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: Fix resource caching and signature of getProperty()
bruyeret committed Oct 4, 2024
commit 6d54ca0fa3dfed5a6dbffb349f5420a592e7435e
13 changes: 0 additions & 13 deletions Examples/Volume/VolumeMapperLightAndShadow/index.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ import HttpDataAccessHelper from '@kitware/vtk.js/IO/Core/DataAccessHelper/HttpD
import vtkVolumeController from '@kitware/vtk.js/Interaction/UI/VolumeController';
import vtkBoundingBox from '@kitware/vtk.js/Common/DataModel/BoundingBox';
import vtkFPSMonitor from '@kitware/vtk.js/Interaction/UI/FPSMonitor';
import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';

import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
import vtkSphereSource from '@kitware/vtk.js/Filters/Sources/SphereSource';
@@ -87,18 +86,6 @@ function createVolumeShadowViewer(rootContainer, fileContents) {
actor.setMapper(mapper);
mapper.addInputData(source);

for (let i = 0; i < 0; ++i) {
const otherImageData = vtkImageData.newInstance();
otherImageData.setPointData(source.getPointData());
otherImageData.setDimensions(...source.getDimensions());
otherImageData.setSpacing(...source.getSpacing());
otherImageData.setOrigin(...source.getOrigin());
otherImageData.setDirection(...source.getDirection());
otherImageData.setOrigin(...[120 * (i + 1), 0, 0]);
mapper.addInputData(otherImageData);
actor.setProperty(actorProperty, 1 + i);
}

// Add one positional light
const bounds = actor.getBounds();
const center = vtkBoundingBox.getCenter(bounds);
30 changes: 7 additions & 23 deletions Sources/Rendering/Core/ImageSlice/index.d.ts
Original file line number Diff line number Diff line change
@@ -35,16 +35,6 @@ export interface vtkImageSlice extends vtkProp3D {
*/
getIsOpaque(): boolean;

/**
*
*/
getProperty(): vtkImageProperty;

/**
*
*/
getProperties(): vtkImageProperty[];

/**
*
*/
@@ -123,19 +113,6 @@ export interface vtkImageSlice extends vtkProp3D {
*/
setMapper(mapper: vtkAbstractImageMapper): boolean;

/**
*
* @param {vtkImageProperty} property The vtkImageProperty instance.
*/
setProperty(property: vtkImageProperty): boolean;

/**
* Set the actor properties array
* Each element of the array corresponds to a mapper input port
* @param {vtkImageProperty[]} properties
*/
setProperties(properties: vtkImageProperty[]): boolean;

/**
*
* @param {boolean} forceOpaque If true, render during opaque pass even if opacity value is below 1.0.
@@ -147,6 +124,13 @@ export interface vtkImageSlice extends vtkProp3D {
* @param {boolean} forceTranslucent If true, render during translucent pass even if opacity value is 1.0.
*/
setForceTranslucent(forceTranslucent: boolean): boolean;

// Inherited from vtkProp3D, but takes a vtkImageProperty instead of a generic vtkObject
getProperty(mapperInputPort?: number): vtkImageProperty;
getProperties(): vtkImageProperty[];
setProperty(mapperInputPort: number, property: vtkImageProperty): boolean;
setProperty(property: vtkImageProperty): boolean;
setProperties(properties: vtkImageProperty[]): boolean;
}

/**
10 changes: 9 additions & 1 deletion Sources/Rendering/Core/Prop3D/index.js
Original file line number Diff line number Diff line change
@@ -238,7 +238,15 @@ function vtkProp3D(publicAPI, model) {
return model.properties[mapperInputPort];
};

publicAPI.setProperty = (property, mapperInputPort = 0) => {
publicAPI.setProperty = (firstArg, secondArg) => {
// Two options for argument layout:
// - (mapperInputPort, property)
// - (property)
const useInputPortArgument = Number.isInteger(firstArg);
const [mapperInputPort, property] = useInputPortArgument
? [firstArg, secondArg]
: [0, firstArg];

if (model.properties[mapperInputPort] === property) {
return false;
}
29 changes: 5 additions & 24 deletions Sources/Rendering/Core/Volume/index.d.ts
Original file line number Diff line number Diff line change
@@ -29,18 +29,6 @@ export interface vtkVolume extends vtkProp3D {
*/
getVolumes(): vtkVolume[];

/**
* Get the volume property for the specified mapper input port, which defaults to 0
* @param {number} mapperInputPort Defaults to 0
*/
getProperty(mapperInputPort?: number): vtkVolumeProperty;

/**
* Get the volume properties array
* Each element of the array corresponds to a mapper input port
*/
getProperties(): vtkVolumeProperty[];

/**
* Get the `Modified Time` which is a monotonic increasing integer
* global for all vtkObjects.
@@ -71,18 +59,11 @@ export interface vtkVolume extends vtkProp3D {
*/
setMapper(mapper: vtkVolumeMapper): boolean;

/**
* Set the volume property for the specified mapper input port, which defaults to 0
* @param {vtkVolumeProperty} property
* @param {number} mapperInputPort Defaults to 0
*/
setProperty(property: vtkVolumeProperty, mapperInputPort?: number): boolean;

/**
* Set the volume properties array
* Each element of the array corresponds to a mapper input port
* @param {vtkVolumeProperty[]} properties
*/
// Inherited from vtkProp3D, but takes a vtkVolumeProperty instead of a generic vtkObject
getProperty(mapperInputPort?: number): vtkVolumeProperty;
getProperties(): vtkVolumeProperty[];
setProperty(mapperInputPort: number, property: vtkVolumeProperty): boolean;
setProperty(property: vtkVolumeProperty): boolean;
setProperties(properties: vtkVolumeProperty[]): boolean;
}

Original file line number Diff line number Diff line change
@@ -11,7 +11,10 @@ export function getTransferFunctionHash(
}

export function getImageDataHash(image, scalars) {
return `${image.getMTime()}A${scalars.getMTime()}`;
// Don't use the image data, as the scalars will define the texture
// If using the image data in the hash, it will cause issues when two image data
// using the same scalars are in the same mapper (for example the VolumeMapper)
return `${scalars.getMTime()}`;
}

export default { getTransferFunctionHash, getImageDataHash };