Actor

Introduction

vtkActor is used to represent an entity in a rendering scene. It inherits
functions related to the actors position, and orientation from
vtkProp3D. The actor also has scaling and maintains a reference to the
defining geometry (i.e., the mapper), rendering properties, and possibly a
texture map. vtkActor combines these instance variables into one 4x4
transformation matrix as follows: [x y z 1] = [x y z 1] Translate(-origin)
Scale(scale) Rot(y) Rot(x) Rot (z) Trans(origin) Trans(position)

See Also

vtkMapper

vtkProperty

Methods

extend

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

getActors

For some exporters and other other operations we must be
able to collect all the actors or volumes. These methods
are used in that process.

getBackfaceProperty

Get the property object that controls this actors backface surface
properties.

getForceOpaque

Check whether the opaque is forced or not.

getForceTranslucent

Check whether the translucency is forced or not.

getIsOpaque

Check if the actor is opaque or not

getMapper

Get the Mapper that this actor is getting its data from.

getSupportsSelection

Check whether if the actor supports selection

hasTranslucentPolygonalGeometry

Return if the prop have some translucent polygonal geometry

makeProperty

Create a new property suitable for use with this type of Actor.

Argument Type Required Description
initialValues IPropertyInitialValues No (default: {})

newInstance

Method used to create a new instance of vtkActor with the following defaults:

  • origin = [0, 0, 0]
  • position = [0, 0, 0]
  • scale = [1, 1, 1]
  • visibility = 1
  • pickable = 1
  • dragable = 1
  • orientation = [0, 0, 0]

No user defined matrix and no texture map.

Argument Type Required Description
initialValues IActorInitialValues No for pre-setting some of its content

setBackfaceProperty

Set the property object that controls this actors backface surface
properties.

Argument Type Required Description
backfaceProperty vtkProperty Yes The backfaceProperty instance.

setForceOpaque

Force the actor to be treated as opaque or translucent.

Argument Type Required Description
forceOpaque Boolean Yes

setForceTranslucent

Force the actor to be treated as opaque or translucent.

Argument Type Required Description
forceTranslucent Boolean Yes

setMapper

This is the method that is used to connect an actor to the end of a
visualization pipeline, i.e. the mapper.

Argument Type Required Description
mapper vtkMapper Yes The vtkMapper instance.

Source

index.d.ts
import { Bounds, Nullable } from '../../../types';
import vtkMapper from '../Mapper';
import vtkProp3D, { IProp3DInitialValues } from '../Prop3D';
import vtkProperty, { IPropertyInitialValues } from '../Property';

/**
*
*/
export interface IActorInitialValues extends IProp3DInitialValues {
mapper?: vtkMapper;
property?: vtkProperty;
backfaceProperty?: vtkProperty;
forceOpaque?: boolean;
forceTranslucent?: boolean;
bounds?: Bounds;
}

export interface vtkActor extends vtkProp3D {
/**
* Return if the prop have some translucent polygonal geometry
*/
hasTranslucentPolygonalGeometry(): boolean;

/**
* For some exporters and other other operations we must be
* able to collect all the actors or volumes. These methods
* are used in that process.
* @return {vtkActor[]} list of actors
*/
getActors(): vtkActor[];

/**
* Get the property object that controls this actors backface surface
* properties.
* @return {vtkProperty} the backface property.
*/
getBackfaceProperty(): vtkProperty;

/**
* Check whether the opaque is forced or not.
*/
getForceOpaque(): boolean;

/**
* Check whether the translucency is forced or not.
*/
getForceTranslucent(): boolean;

/**
* Check if the actor is opaque or not
* @return true if the actor is opaque
*/
getIsOpaque(): boolean;

/**
* Get the Mapper that this actor is getting its data from.
*/
getMapper(): Nullable<vtkMapper>;

/**
* Check whether if the actor supports selection
* @return {Boolean} true if the actor support selection.
*/
getSupportsSelection(): boolean;

/**
* Create a new property suitable for use with this type of Actor.
* @param {IPropertyInitialValues} [initialValues] (default: {})
*/
makeProperty(initialValues?: IPropertyInitialValues): vtkProperty;

/**
* Set the property object that controls this actors backface surface
* properties.
* @param {vtkProperty} backfaceProperty The backfaceProperty instance.
*/
setBackfaceProperty(backfaceProperty: vtkProperty): boolean;

/**
* Force the actor to be treated as opaque or translucent.
* @param {Boolean} forceOpaque
*/
setForceOpaque(forceOpaque: boolean): boolean;

/**
* Force the actor to be treated as opaque or translucent.
* @param {Boolean} forceTranslucent
*/
setForceTranslucent(forceTranslucent: boolean): boolean;

/**
* This is the method that is used to connect an actor to the end of a
* visualization pipeline, i.e. the mapper.
* @param {vtkMapper} mapper The vtkMapper instance.
*/
setMapper(mapper: vtkMapper): boolean;

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

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

/**
* Method used to create a new instance of vtkActor with the following defaults:
*
* * origin = [0, 0, 0]
* * position = [0, 0, 0]
* * scale = [1, 1, 1]
* * visibility = 1
* * pickable = 1
* * dragable = 1
* * orientation = [0, 0, 0]
*
* No user defined matrix and no texture map.
* @param {IActorInitialValues} [initialValues] for pre-setting some of its content
*/
export function newInstance(initialValues?: IActorInitialValues): vtkActor;

/**
* vtkActor is used to represent an entity in a rendering scene. It inherits
* functions related to the actors position, and orientation from
* vtkProp3D. The actor also has scaling and maintains a reference to the
* defining geometry (i.e., the mapper), rendering properties, and possibly a
* texture map. vtkActor combines these instance variables into one 4x4
* transformation matrix as follows: [x y z 1] = [x y z 1] Translate(-origin)
* Scale(scale) Rot(y) Rot(x) Rot (z) Trans(origin) Trans(position)
* @see [vtkMapper](./Rendering_Core_Mapper.html)
* @see [vtkProperty](./Rendering_Core_Property.html)
*/
export declare const vtkActor: {
newInstance: typeof newInstance;
extend: typeof extend;
};
export default vtkActor;
index.js
import macro from 'vtk.js/Sources/macros';
import vtkProp3D from 'vtk.js/Sources/Rendering/Core/Prop3D';
import vtkProperty from 'vtk.js/Sources/Rendering/Core/Property';

// ----------------------------------------------------------------------------
// vtkActor methods
// ----------------------------------------------------------------------------

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

// Capture 'parentClass' api for internal use
const superClass = { ...publicAPI };

publicAPI.getActors = () => [publicAPI];

publicAPI.getIsOpaque = () => {
if (model.forceOpaque) {
return true;
}
if (model.forceTranslucent) {
return false;
}
// make sure we have a property
if (!model.properties[0]) {
// force creation of a property
publicAPI.getProperty();
}

let isOpaque = model.properties[0].getOpacity() >= 1.0;

// are we using an opaque texture, if any?
isOpaque = isOpaque && (!model.texture || !model.texture.isTranslucent());

// are we using an opaque scalar array, if any?
isOpaque = isOpaque && (!model.mapper || model.mapper.getIsOpaque());

return isOpaque;
};

publicAPI.hasTranslucentPolygonalGeometry = () => {
if (model.mapper === null) {
return false;
}
// make sure we have a property
if (!model.properties[0]) {
// force creation of a property
publicAPI.getProperty();
}

// is this actor opaque ?
return !publicAPI.getIsOpaque();
};

publicAPI.makeProperty = vtkProperty.newInstance;

publicAPI.getMTime = () => {
let mt = superClass.getMTime();

if (model.backfaceProperty !== null) {
const time = model.backfaceProperty.getMTime();
mt = time > mt ? time : mt;
}

return mt;
};

publicAPI.getRedrawMTime = () => {
let mt = model.mtime;
if (model.mapper !== null) {
let time = model.mapper.getMTime();
mt = time > mt ? time : mt;
if (model.mapper.getInput() !== null) {
// FIXME !!! getInputAlgorithm / getInput
model.mapper.getInputAlgorithm().update();
time = model.mapper.getInput().getMTime();
mt = time > mt ? time : mt;
}
}
return mt;
};

publicAPI.getSupportsSelection = () =>
model.mapper ? model.mapper.getSupportsSelection() : false;

publicAPI.processSelectorPixelBuffers = (selector, pixelOffsets) => {
if (model.mapper && model.mapper.processSelectorPixelBuffers) {
model.mapper.processSelectorPixelBuffers(selector, pixelOffsets);
}
};
}

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

const DEFAULT_VALUES = {
mapper: null,
backfaceProperty: null,

forceOpaque: false,
forceTranslucent: false,
};

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

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

// Inheritance
vtkProp3D.extend(publicAPI, model, initialValues);

// vtkTimeStamp
model.boundsMTime = {};
macro.obj(model.boundsMTime);

// Build VTK API
macro.setGet(publicAPI, model, [
'backfaceProperty',
'forceOpaque',
'forceTranslucent',
'mapper',
]);

// Object methods
vtkActor(publicAPI, model);
}

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

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

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

export default { newInstance, extend };