GeometryRepresentationProxy

Methods

setRepresentation

Argument Type Required Description
representation Yes a string that describes what representation to use for the explicit geometry. possible values are ‘Surface with edges’, ‘Surface’ (default), ‘Wireframe’,
                  and 'Points'. |

Source

index.d.ts
import { RGBColor } from '../../../types';
import vtkAbstractRepresentationProxy from '../../Core/AbstractRepresentationProxy';

export interface vtkGeometryRepresentationProxy
extends vtkAbstractRepresentationProxy {
/**
*
* @param representation a string that describes what representation to use for the explicit geometry.
* possible values are 'Surface with edges', 'Surface' (default), 'Wireframe',
* and 'Points'.
*/
setRepresentation(representation: string): boolean;
getRepresentation(): string;

// proxy property mappings
getColor(): RGBColor;
setColor(color: RGBColor): boolean;
getInterpolateScalarsBeforeMapping(): boolean;
setInterpolateScalarsBeforeMapping(
interpolateScalarsBeforeMapping: boolean
): boolean;
getOpacity(): number;
setOpacity(opacity: number): boolean;
getVisibility(): boolean;
setVisibility(visible: boolean): boolean;
getPointSize(): number;
setPointSize(pointSize: number): boolean;
getUseShadow(): boolean;
setUseShadow(lighting: boolean): boolean;
getUseBounds(): boolean;
setUseBounds(useBounds: boolean): boolean;
getLineWidth(): number;
setLineWidth(width: number): boolean;
}

export default vtkGeometryRepresentationProxy;
index.js
import macro from 'vtk.js/Sources/macros';
import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor';
import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper';

import vtkAbstractRepresentationProxy from 'vtk.js/Sources/Proxy/Core/AbstractRepresentationProxy';

const PROPERTIES_STATE = {
representation: {
'Surface with edges': {
property: { edgeVisibility: true, representation: 2 },
},
Surface: { property: { edgeVisibility: false, representation: 2 } },
Wireframe: { property: { edgeVisibility: false, representation: 1 } },
Points: { property: { edgeVisibility: false, representation: 0 } },
},
};

const PROPERTIES_DEFAULT = {
representation: 'Surface',
};

// ----------------------------------------------------------------------------
// vtkGeometryRepresentationProxy methods
// ----------------------------------------------------------------------------

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

// Internals
model.mapper = vtkMapper.newInstance({
interpolateScalarsBeforeMapping: true,
useLookupTableScalarRange: true,
scalarVisibility: false,
});
model.actor = vtkActor.newInstance();
model.property = model.actor.getProperty();

// Auto connect mappers
model.sourceDependencies.push(model.mapper);
// connect rendering pipeline
model.actor.setMapper(model.mapper);
model.actors.push(model.actor);
}

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

const DEFAULT_VALUES = {
representation: 'Surface',
};

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

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

// Object methods
vtkAbstractRepresentationProxy.extend(publicAPI, model, initialValues);

// Object specific methods
vtkGeometryRepresentationProxy(publicAPI, model);

// Map proxy properties
macro.proxyPropertyState(
publicAPI,
model,
PROPERTIES_STATE,
PROPERTIES_DEFAULT
);
macro.proxyPropertyMapping(publicAPI, model, {
opacity: { modelKey: 'property', property: 'opacity' },
visibility: { modelKey: 'actor', property: 'visibility' },
color: { modelKey: 'property', property: 'diffuseColor' },
interpolateScalarsBeforeMapping: {
modelKey: 'mapper',
property: 'interpolateScalarsBeforeMapping',
},
pointSize: { modelKey: 'property', property: 'pointSize' },
useShadow: { modelKey: 'property', property: 'lighting' },
lineWidth: { modelKey: 'property', property: 'lineWidth' },
useBounds: { modelKey: 'actor', property: 'useBounds' },
});
}

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

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

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

export default { newInstance, extend };