Skip to content

Commit

Permalink
feat: use "extent" name and some perf improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
floryst committed Jun 11, 2024
1 parent 811ee30 commit 657b587
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 133 deletions.
30 changes: 11 additions & 19 deletions Sources/Rendering/Core/VolumeMapper/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import vtkPiecewiseFunction from "../../../Common/DataModel/PiecewiseFunction";
import { Bounds, Range, Vector3 } from "../../../types";
import { Bounds, Range, Extent } from "../../../types";
import vtkAbstractMapper3D, { IAbstractMapper3DInitialValues } from "../AbstractMapper3D";
import { BlendMode, FilterMode } from "./Constants";

/**
* Represents a 3D region of a volume.
*/
export interface VolumeRegion {
start: Vector3;
size: Vector3;
}

/**
*
*/
Expand Down Expand Up @@ -302,23 +294,23 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
setLAOKernelRadius(LAOKernelRadius: number): void;

/**
* Tells the mapper to only update the specified regions.
*
* If there are zero regions, the mapper updates the entire volume texture.
* Otherwise, the mapper will only update the texture by the specified regions
* Tells the mapper to only update the specified extents.
*
* If there are zero extents, the mapper updates the entire volume texture.
* Otherwise, the mapper will only update the texture by the specified extents
* during the next render call.
*
*
* This array is cleared after a successful render.
* @param regions
* @param extents
*/
setRegionsToUpdate(regions: VolumeRegion[]): boolean;
setUpdatedExtents(extents: Extent[]): boolean;

/**
* Retrieves the regions to update.
*
* Retrieves the updated extents.
*
* This array is cleared after every successful render.
*/
getRegionsToUpdate(): VolumeRegion[];
getUpdatedExtents(): Extent[];

/**
*
Expand Down
4 changes: 2 additions & 2 deletions Sources/Rendering/Core/VolumeMapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const defaultValues = (initialValues) => ({
localAmbientOcclusion: false,
LAOKernelSize: 15,
LAOKernelRadius: 7,
regionsToUpdate: [],
updatedExtents: [],
...initialValues,
});

Expand Down Expand Up @@ -192,7 +192,7 @@ export function extend(publicAPI, model, initialValues = {}) {
'localAmbientOcclusion',
'LAOKernelSize',
'LAOKernelRadius',
'regionsToUpdate',
'updatedExtents',
]);

macro.setGetArray(publicAPI, model, ['ipScalarRange'], 2);
Expand Down
43 changes: 17 additions & 26 deletions Sources/Rendering/OpenGL/Texture/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Wrap, Filter } from './Constants';
import vtkOpenGLRenderWindow from '../RenderWindow';
import { Nullable } from '../../../types';
import { VtkDataTypes } from '../../../Common/Core/DataArray';
import { Extent, Nullable } from '../../../types';
import { VtkDataTypes } from "../../../Common/Core/DataArray";
import { vtkViewNode } from '../../../Rendering/SceneGraph/ViewNode';
import { vtkObject } from '../../../interfaces';

Expand Down Expand Up @@ -256,60 +256,51 @@ export interface vtkOpenGLTexture extends vtkViewNode {

/**
* Creates a 3D texture from raw data.
*
* updatedExtents is currently incompatible with webgl1, since there's no extent scaling.
*
* @param width The width of the texture.
* @param height The height of the texture.
* @param depth The depth of the texture.
* @param numComps The number of components in the texture.
* @param dataType The data type of the texture.
* @param data The raw data for the texture.
* @param updatedExtents Only update the specified extents (default: [])
* @returns {boolean} True if the texture was successfully created, false otherwise.
*/
create3DFromRaw(
width: number,
height: number,
depth: number,
numComps: number,
dataType: VtkDataTypes,
data: any
): boolean;
create3DFromRaw(width: number, height: number, depth: number, numComps: number, dataType: VtkDataTypes, data: any, updatedExtents?: Extent[]): boolean;

/**
* Creates a 3D filterable texture from raw data, with a preference for size over accuracy if necessary.
*
* updatedExtents is currently incompatible with webgl1, since there's no extent scaling.
*
* @param width The width of the texture.
* @param height The height of the texture.
* @param depth The depth of the texture.
* @param numComps The number of components in the texture.
* @param dataType The data type of the texture.
* @param values The raw data for the texture.
* @param preferSizeOverAccuracy Whether to prefer texture size over accuracy.
* @param updatedExtents Only update the specified extents (default: [])
* @returns {boolean} True if the texture was successfully created, false otherwise.
*/
create3DFilterableFromRaw(
width: number,
height: number,
depth: number,
numComps: number,
dataType: VtkDataTypes,
values: any,
preferSizeOverAccuracy: boolean
): boolean;
create3DFilterableFromRaw(width: number, height: number, depth: number, numComps: number, dataType: VtkDataTypes, values: any, preferSizeOverAccuracy: boolean, updatedExtents?: Extent[]): boolean;

/**
* Creates a 3D filterable texture from a data array, with a preference for size over accuracy if necessary.
*
* updatedExtents is currently incompatible with webgl1, since there's no extent scaling.
*
* @param width The width of the texture.
* @param height The height of the texture.
* @param depth The depth of the texture.
* @param dataArray The data array to use for the texture.
* @param preferSizeOverAccuracy Whether to prefer texture size over accuracy.
* @param updatedExtents Only update the specified extents (default: [])
* @returns {boolean} True if the texture was successfully created, false otherwise.
*/
create3DFilterableFromDataArray(
width: number,
height: number,
depth: number,
dataArray: any,
preferSizeOverAccuracy: boolean
): boolean;
create3DFilterableFromDataArray(width: number, height: number, depth: number, dataArray: any, preferSizeOverAccuracy: boolean, updatedExtents?: Extent[]): boolean;

/**
* Sets the OpenGL render window in which the texture will be used.
Expand Down
Loading

0 comments on commit 657b587

Please sign in to comment.