PointSet

Introduction

vtkPointSet is an abstract class that specifies the interface for
datasets that explicitly use “point” arrays to represent geometry.

For example, vtkPolyData and vtkUnstructuredGrid require point arrays
to specify point position, while vtkStructuredPoints generates point
positions implicitly.

Methods

computeBounds

Compute the (X, Y, Z) bounds of the data.

extend

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

getBounds

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

getNumberOfPoints

getPoints

newInstance

Method used to create a new instance of vtkPointSet.

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

setPoints

Source

index.d.ts
import { Bounds } from '../../../types';
import vtkPoints from '../../Core/Points';
import vtkDataSet, { IDataSetInitialValues } from '../DataSet';

/**
*
*/
export interface IPointSetInitialValues extends IDataSetInitialValues {}

export interface vtkPointSet extends vtkDataSet {
/**
* Compute the (X, Y, Z) bounds of the data.
*/
computeBounds(): void;

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

/**
*
*/
getNumberOfPoints(): number;

/**
*
*/
getPoints(): vtkPoints;

/**
*
*/
setPoints(points: vtkPoints): boolean;
}

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

/**
* Method used to create a new instance of vtkPointSet.
* @param {IPointSetInitialValues} [initialValues] for pre-setting some of its content
*/
export function newInstance(
initialValues?: IPointSetInitialValues
): vtkPointSet;

/**
* vtkPointSet is an abstract class that specifies the interface for
* datasets that explicitly use "point" arrays to represent geometry.
*
* For example, vtkPolyData and vtkUnstructuredGrid require point arrays
* to specify point position, while vtkStructuredPoints generates point
* positions implicitly.
*/
export declare const vtkPointSet: {
newInstance: typeof newInstance;
extend: typeof extend;
};
export default vtkPointSet;
index.js
import vtk from 'vtk.js/Sources/vtk';
import macro from 'vtk.js/Sources/macros';
import vtkDataSet from 'vtk.js/Sources/Common/DataModel/DataSet';
import vtkPoints from 'vtk.js/Sources/Common/Core/Points';

// ----------------------------------------------------------------------------
// Global methods
// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------
// vtkPointSet methods
// ----------------------------------------------------------------------------

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

// Create empty points
if (!model.points) {
model.points = vtkPoints.newInstance();
} else {
model.points = vtk(model.points);
}

publicAPI.getNumberOfPoints = () => model.points.getNumberOfPoints();

publicAPI.getBounds = () => model.points.getBounds();

publicAPI.computeBounds = () => {
publicAPI.getBounds();
};

const superShallowCopy = publicAPI.shallowCopy;
publicAPI.shallowCopy = (other, debug = false) => {
superShallowCopy(other, debug);
model.points = vtkPoints.newInstance();
model.points.shallowCopy(other.getPoints());
};
}

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

const DEFAULT_VALUES = {
// points: null,
};

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

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

// Inheritance
vtkDataSet.extend(publicAPI, model, initialValues);
macro.setGet(publicAPI, model, ['points']);

// Object specific methods
vtkPointSet(publicAPI, model);
}

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

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

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

export default { newInstance, extend };