AbstractMapper3D

Introduction

vtkAbstractMapper3D is an abstract class to specify interface between 3D
data and graphics primitives or software rendering techniques. Subclasses
of vtkAbstractMapper3D can be used for rendering geometry or rendering
volumetric data.

This class also defines an API to support hardware clipping planes (at most
six planes can be defined). It also provides geometric data about the input
data it maps, such as the bounding box and center.

Methods

extend

Method use to decorate a given object (publicAPI+model) with vtkAbstractMapper3D 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 IAbstractMapper3DInitialValues No (default: {})

getBounds

Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].

getCenter

Get the center of this mapper’s data.

getLength

Get the diagonal length of this mappers bounding box.

Source

index.d.ts
import { Bounds, Vector3 } from '../../../types';
import vtkAbstractMapper, { IAbstractMapperInitialValues } from '../AbstractMapper';

/**
*
*/
export interface IAbstractMapper3DInitialValues extends IAbstractMapperInitialValues {
bounds?: Bounds;
center?: Vector3;
}

export interface vtkAbstractMapper3D extends vtkAbstractMapper {
/**
* Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
* @default 0
* @return {Bounds} The bounds for the mapper.
*/
getBounds(): Bounds;


/**
* Get the center of this mapper’s data.
* @return {Vector3} The center of the mapper's data.
*/
getCenter(): Vector3;

/**
* Get the diagonal length of this mappers bounding box.
* @return {Number} The diagonal length of mapper bounding box.
*/
getLength(): number;

}

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

/**
* vtkAbstractMapper3D is an abstract class to specify interface between 3D
* data and graphics primitives or software rendering techniques. Subclasses
* of vtkAbstractMapper3D can be used for rendering geometry or rendering
* volumetric data.
*
* This class also defines an API to support hardware clipping planes (at most
* six planes can be defined). It also provides geometric data about the input
* data it maps, such as the bounding box and center.
*/
export declare const vtkAbstractMapper3D: {
extend: typeof extend,
};
export default vtkAbstractMapper3D;
index.js
import vtkAbstractMapper from 'vtk.js/Sources/Rendering/Core/AbstractMapper';
import * as vtkMath from 'vtk.js/Sources/Common/Core/Math';
// ----------------------------------------------------------------------------
// vtkAbstractMapper methods
// ----------------------------------------------------------------------------

function vtkAbstractMapper3D(publicAPI, model) {
publicAPI.getBounds = () => 0;

publicAPI.getBounds = (bounds) => {
publicAPI.getBounds();
for (let i = 0; i < 6; i++) {
bounds[i] = model.bounds[i];
}
};

publicAPI.getCenter = () => {
publicAPI.getBounds();
for (let i = 0; i < 3; i++) {
model.center[i] = (model.bounds[2 * i + 1] + model.bounds[2 * i]) / 2.0;
}
return model.center.slice();
};

publicAPI.getLength = () => {
let diff = 0.0;
let l = 0.0;
publicAPI.getBounds();
for (let i = 0; i < 3; i++) {
diff = model.bounds[2 * i + 1] - model.bounds[2 * i];
l += diff * diff;
}

return Math.sqrt(l);
};
}

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

const DEFAULT_VALUES = {
bounds: [1, -1, 1, -1, 1, -1],
center: [0, 0, 0],
};

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

export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);
// Inheritance
vtkAbstractMapper.extend(publicAPI, model, initialValues);

if (!model.bounds) {
vtkMath.uninitializeBounds(model.bounds);
}

if (!model.center) {
model.center = [0.0, 0.0, 0.0];
}

vtkAbstractMapper3D(publicAPI, model);
}

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

export default { extend };