Skip to content

Commit

Permalink
refactor(picking): move intersectWithLines and friend to protected
Browse files Browse the repository at this point in the history
those methods are protected in VTK C++, which makes sense

BREAKING CHANGE: intersectWithLine, intersectActorWithLine and intersectVolumeWithLine from
vtkPicker, vtkCellPicker and vtkPointPicker no longer belongs to the public API.
  • Loading branch information
bourdaisj authored and finetjul committed Mar 22, 2024
1 parent 7d6f14e commit 3e7f69f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 89 deletions.
32 changes: 0 additions & 32 deletions Sources/Rendering/Core/CellPicker/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,38 +85,6 @@ export interface vtkCellPicker extends vtkPicker {
* @param {vtkRenderer} renderer The vtkRenderer instance.
*/
pick(selection: any, renderer: vtkRenderer): void;

/**
*
* @param {Vector3} p1
* @param {Vector3} p2
* @param {Number} tolerance
* @param {Nullable<vtkProp3D>} actor
* @param {vtkMapper} mapper The vtkMapper instance.
*/
intersectWithLine(p1: Vector3, p2: Vector3, tolerance: number, actor: Nullable<vtkProp3D>, mapper: vtkMapper): number;

/**
*
* @param {Vector3} p1
* @param {Vector3} p2
* @param {Number} t1
* @param {Number} t2
* @param {Number} tolerance
* @param {vtkMapper} mapper The vtkMapper instance.
*/
intersectActorWithLine(p1: Vector3, p2: Vector3, t1: number, t2: number, tolerance: number, mapper: vtkMapper): number;

/**
*
* @param {Vector3} p1
* @param {Vector3} p2
* @param {Number} t1
* @param {Number} t2
* @param {Number} tolerance
* @param {vtkMapper} mapper The vtkMapper instance.
*/
intersectVolumeWithLine(p1: Vector3, p2: Vector3, t1: number, t2: number, tolerance: number, mapper: vtkMapper): number;
}

/**
Expand Down
26 changes: 6 additions & 20 deletions Sources/Rendering/Core/CellPicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function vtkCellPicker(publicAPI, model) {
return pickResult;
};

publicAPI.intersectWithLine = (p1, p2, tolerance, actor, mapper) => {
model.intersectWithLine = (p1, p2, tolerance, prop, mapper) => {
let tMin = Number.MAX_VALUE;
let t1 = 0.0;
let t2 = 1.0;
Expand Down Expand Up @@ -201,7 +201,7 @@ function vtkCellPicker(publicAPI, model) {
} else if (mapper.isA('vtkVolumeMapper')) {
// we calculate here the parametric intercept points between the ray and the bounding box, so
// if the application defines for some reason a too large ray length (1e6), it restrict the calculation
// to the vtkVolume actor bounding box
// to the vtkVolume prop bounding box
const interceptionObject = vtkBox.intersectWithLine(
mapper.getBounds(),
p1,
Expand All @@ -217,23 +217,9 @@ function vtkCellPicker(publicAPI, model) {
? interceptionObject.t2
: clipLine.t2;

tMin = publicAPI.intersectVolumeWithLine(
p1,
p2,
t1,
t2,
tolerance,
actor
);
tMin = model.intersectVolumeWithLine(p1, p2, t1, t2, tolerance, prop);
} else if (mapper.isA('vtkMapper')) {
tMin = publicAPI.intersectActorWithLine(
p1,
p2,
t1,
t2,
tolerance,
mapper
);
tMin = model.intersectActorWithLine(p1, p2, t1, t2, tolerance, mapper);
}

if (tMin < model.globalTMin) {
Expand Down Expand Up @@ -280,7 +266,7 @@ function vtkCellPicker(publicAPI, model) {
return tMin;
};

publicAPI.intersectVolumeWithLine = (p1, p2, t1, t2, tolerance, volume) => {
model.intersectVolumeWithLine = (p1, p2, t1, t2, tolerance, volume) => {
let tMin = Number.MAX_VALUE;
const mapper = volume.getMapper();
const imageData = mapper.getInputData();
Expand Down Expand Up @@ -402,7 +388,7 @@ function vtkCellPicker(publicAPI, model) {
return tMin;
};

publicAPI.intersectActorWithLine = (p1, p2, t1, t2, tolerance, mapper) => {
model.intersectActorWithLine = (p1, p2, t1, t2, tolerance, mapper) => {
let tMin = Number.MAX_VALUE;
const minXYZ = [0, 0, 0];
let pDistMin = Number.MAX_VALUE;
Expand Down
11 changes: 0 additions & 11 deletions Sources/Rendering/Core/Picker/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,6 @@ export interface vtkPicker extends vtkAbstractPicker {
*/
onPickChange(callback: OnPickChangeCallback): vtkSubscription;

/**
* Intersect data with specified ray.
* Project the center point of the mapper onto the ray and determine its parametric value
* @param {Vector3} p1
* @param {Vector3} p2
* @param {Number} tolerance
* @param {Nullable<vtkProp3D>} prop
* @param {vtkMapper} mapper
*/
intersectWithLine(p1: Vector3, p2: Vector3, tolerance: number, prop: Nullable<vtkProp3D>, mapper: vtkMapper): number;

/**
* Perform pick operation with selection point provided.
* @param {Vector3} selection First two values should be x-y pixel coordinate, the third is usually zero.
Expand Down
5 changes: 2 additions & 3 deletions Sources/Rendering/Core/Picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ function vtkPicker(publicAPI, model) {
if (vtkBoundingBox.intersectBox(bounds, p1Mapper, ray, hitPosition, [])) {
mat4.getScaling(transformScale, model.transformMatrix);

// TODO: better naming?
const t = publicAPI.intersectWithLine(
const t = model.intersectWithLine(
p1Mapper,
p2Mapper,
tolerance *
Expand Down Expand Up @@ -224,7 +223,7 @@ function vtkPicker(publicAPI, model) {

// Intersect data with specified ray.
// Project the center point of the mapper onto the ray and determine its parametric value
publicAPI.intersectWithLine = (p1, p2, tolerance, prop, mapper) => {
model.intersectWithLine = (p1, p2, tolerance, prop, mapper) => {
if (!mapper) {
return Number.MAX_VALUE;
}
Expand Down
20 changes: 0 additions & 20 deletions Sources/Rendering/Core/PointPicker/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,6 @@ export interface vtkPointPicker extends vtkPicker {
*/
getUseCells(): boolean;

/**
*
* @param {Vector3} p1
* @param {Vector3} p2
* @param {Number} tolerance
* @param {vtkProp3D} actor
* @param {vtkMapper} mapper
*/
intersectWithLine(p1: Vector3, p2: Vector3, tolerance: number, actor: Nullable<vtkProp3D>, mapper: vtkMapper): number;

/**
*
* @param {Vector3} p1
* @param {Vector3} p2
* @param {Number} tolerance
* @param {vtkProp3D} actor
* @param {vtkMapper} mapper
*/
intersectActorWithLine(p1: Vector3, p2: Vector3, tolerance: number, mapper: vtkMapper): number;

/**
* Specify whether the point search should be based on cell points or directly on the point list.
* @param useCells
Expand Down
6 changes: 3 additions & 3 deletions Sources/Rendering/Core/PointPicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function vtkPointPicker(publicAPI, model) {
// Set our className
model.classHierarchy.push('vtkPointPicker');

publicAPI.intersectWithLine = (p1, p2, tolerance, actor, mapper) => {
model.intersectWithLine = (p1, p2, tolerance, prop, mapper) => {
let tMin = Number.MAX_VALUE;

if (mapper.isA('vtkImageMapper') || mapper.isA('vtkImageArrayMapper')) {
Expand All @@ -22,13 +22,13 @@ function vtkPointPicker(publicAPI, model) {
model.pointIJK = pickData.ijk;
}
} else if (mapper.isA('vtkMapper')) {
tMin = publicAPI.intersectActorWithLine(p1, p2, tolerance, mapper);
tMin = model.intersectActorWithLine(p1, p2, tolerance, mapper);
}

return tMin;
};

publicAPI.intersectActorWithLine = (p1, p2, tolerance, mapper) => {
model.intersectActorWithLine = (p1, p2, tolerance, mapper) => {
// Get dataset
const input = mapper.getInputData();

Expand Down

0 comments on commit 3e7f69f

Please sign in to comment.