PlaneManipulator

Introduction

vtkPlaneManipulator.

Methods

extend

Method use to decorate a given object (publicAPI+model) with vtkPlaneManipulator characteristics.

Argument Type Required Description
publicAPI Yes object on which methods will be bounds (public)
model Yes object on which data structure will be bounds (protected)
initialValues IPlaneManipulatorInitialValues No (default: {})

getNormal

Get the normal of the plane

getNormalByReference

Get the normal of the plane

getOrigin

Get the origin of the plane

getOriginByReference

Get the origin of the plane

handleEvent

Argument Type Required Description
callData Yes
glRenderWindow Yes

intersectDisplayWithPlane

Argument Type Required Description
x Number Yes
y Number Yes
planeOrigin Array. Yes
planeNormal Array. Yes
renderer Yes
glRenderWindow Yes

newInstance

Method use to create a new instance of vtkPlaneManipulator

setNormal

Set the normal of the plane

Argument Type Required Description
x Number Yes The x coordinate.
y Number Yes The y coordinate.
z Number Yes The z coordinate.

setNormal

Set the normal of the plane

Argument Type Required Description
normal Array. Yes The normal coordinate.

setNormalFrom

Set the normal of the plane

Argument Type Required Description
normal Array. Yes The normal coordinate.

setOrigin

Set the origin of the plane.

Argument Type Required Description
x Number Yes The x coordinate of the origin point.
y Number Yes The y coordinate of the origin point.
z Number Yes The z coordinate of the origin point.

setOrigin

Set the origin of the plane.

Argument Type Required Description
origin Array. Yes The coordinate of the origin point.

setOriginFrom

Set the origin of the plane.

Argument Type Required Description
origin Array. Yes The coordinate of the origin point.

Source

index.d.ts
import { vtkObject } from "../../../interfaces";

/**
*
*/
export interface IPlaneManipulatorInitialValues {
origin?: number[];
normal?: number[];
}

export interface vtkPlaneManipulator extends vtkObject {

/**
* Get the normal of the plane
*/
getNormal(): number[];

/**
* Get the normal of the plane
*/
getNormalByReference(): number[];

/**
* Get the origin of the plane
*/
getOrigin(): number[];

/**
* Get the origin of the plane
*/
getOriginByReference(): number[];

/**
*
* @param callData
* @param glRenderWindow
*/
handleEvent(callData: any, glRenderWindow: any): number[];

/**
* Set the normal of the plane
* @param {Number[]} normal The normal coordinate.
*/
setNormal(normal: number[]): boolean;

/**
* Set the normal of the plane
* @param {Number} x The x coordinate.
* @param {Number} y The y coordinate.
* @param {Number} z The z coordinate.
*/
setNormal(x: number, y: number, z: number): boolean;

/**
* Set the normal of the plane
* @param {Number[]} normal The normal coordinate.
*/
setNormalFrom(normal: number[]): boolean;

/**
* Set the origin of the plane.
* @param {Number[]} origin The coordinate of the origin point.
*/
setOrigin(origin: number[]): boolean;

/**
* Set the origin of the plane.
* @param {Number} x The x coordinate of the origin point.
* @param {Number} y The y coordinate of the origin point.
* @param {Number} z The z coordinate of the origin point.
*/
setOrigin(x: number, y: number, z: number): boolean;

/**
* Set the origin of the plane.
* @param {Number[]} origin The coordinate of the origin point.
*/
setOriginFrom(origin: number[]): boolean;
}


/**
* Method use to decorate a given object (publicAPI+model) with vtkPlaneManipulator characteristics.
*
* @param publicAPI object on which methods will be bounds (public)
* @param model object on which data structure will be bounds (protected)
* @param {IPlaneManipulatorInitialValues} [initialValues] (default: {})
*/
export function extend(publicAPI: object, model: object, initialValues?: IPlaneManipulatorInitialValues): void;

/**
* Method use to create a new instance of vtkPlaneManipulator
*/
export function newInstance(initialValues?: IPlaneManipulatorInitialValues): vtkPlaneManipulator;

/**
*
* @param {Number} x
* @param {Number} y
* @param {Number[]} planeOrigin
* @param {Number[]} planeNormal
* @param renderer
* @param glRenderWindow
*/
export function intersectDisplayWithPlane(x: number, y: number, planeOrigin: number[], planeNormal: number[], renderer: any, glRenderWindow: any): number[];


/**
* vtkPlaneManipulator.
*/
export declare const vtkPlaneManipulator: {
newInstance: typeof newInstance,
extend: typeof extend,
intersectDisplayWithPlane: typeof intersectDisplayWithPlane;
};
export default vtkPlaneManipulator;
index.js
import macro from 'vtk.js/Sources/macros';
import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane';

export function intersectDisplayWithPlane(
x,
y,
planeOrigin,
planeNormal,
renderer,
glRenderWindow
) {
const near = glRenderWindow.displayToWorld(x, y, 0, renderer);
const far = glRenderWindow.displayToWorld(x, y, 1, renderer);

return vtkPlane.intersectWithLine(near, far, planeOrigin, planeNormal).x;
}

// ----------------------------------------------------------------------------
// vtkPlaneManipulator methods
// ----------------------------------------------------------------------------

function vtkPlaneManipulator(publicAPI, model) {
// Set our className
model.classHierarchy.push('vtkPlaneManipulator');

// --------------------------------------------------------------------------

publicAPI.handleEvent = (callData, glRenderWindow) =>
intersectDisplayWithPlane(
callData.position.x,
callData.position.y,
model.origin,
model.normal,
callData.pokedRenderer,
glRenderWindow
);
}

// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------

const DEFAULT_VALUES = {
normal: [0, 0, 1],
origin: [0, 0, 0],
};

// ----------------------------------------------------------------------------

export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);
macro.obj(publicAPI, model);
macro.setGetArray(publicAPI, model, ['normal', 'origin'], 3);

vtkPlaneManipulator(publicAPI, model);
}

// ----------------------------------------------------------------------------

export const newInstance = macro.newInstance(extend, 'vtkPlaneManipulator');

// ----------------------------------------------------------------------------

export default { intersectDisplayWithPlane, extend, newInstance };