ImageDataOutlineFilter

Introduction

vtkImageDataOutlineFilter - A filter that generates oriented outline for
vtkImageData.

vtkImageDataOutlineFilter is a filter that generates a wireframe or
triangulated rectangular-cuboid as an outline of an input vtkImageData.
It takes into account the orientation / DirectionMatrix of the image, so the
output outline may not be axes aligned.

Methods

extend

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

getGenerateFaces

Flag that indicates whether the output will generate faces of the outline.

Returns

Type Description
boolean

getGenerateLines

Flag that indicates whether the output will generate wireframe lines of the outline.

Returns

Type Description
boolean

newInstance

Method used to create a new instance of vtkImageDataOutlineFilter

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

requestData

Argument Type Required Description
inData Yes
outData Yes

setGenerateFaces

Flag to indicate that the output should generate triangulated faces of the outline.

Argument Type Required Description
generateFaces boolean Yes

setGenerateLines

Flag to indicate that the output should generate wireframe of the outline.

Argument Type Required Description
generateLines boolean Yes

Source

index.d.ts
import { vtkAlgorithm, vtkObject } from '../../../interfaces';
import vtkImageData from '../../../Common/DataModel/ImageData';
import vtkPolyData from '../../../Common/DataModel/PolyData';

export const LINE_ARRAY: number[];

export interface IImageDataOutlineFilterInitialValues {}

type vtkImageDataOutlineFilterBase = vtkObject & vtkAlgorithm;

export interface vtkImageDataOutlineFilter
extends vtkImageDataOutlineFilterBase {
/**
*
* @param inData
* @param outData
*/
requestData(inData: vtkImageData, outData: vtkPolyData): void;

/**
* Flag that indicates whether the output will generate faces of the outline.
* @returns {boolean}
*/
getGenerateFaces(): boolean;

/**
* Flag that indicates whether the output will generate wireframe lines of the outline.
* @returns {boolean}
*/
getGenerateLines(): boolean;

/**
* Flag to indicate that the output should generate wireframe of the outline.
* @param {boolean} generateLines
*/
setGenerateLines(generateLines: boolean): boolean;

/**
* Flag to indicate that the output should generate triangulated faces of the outline.
* @param {boolean} generateFaces
*/
setGenerateFaces(generateFaces: boolean): boolean;
}

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

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

/**
* vtkImageDataOutlineFilter - A filter that generates oriented outline for
* vtkImageData.
*
* vtkImageDataOutlineFilter is a filter that generates a wireframe or
* triangulated rectangular-cuboid as an outline of an input vtkImageData.
* It takes into account the orientation / DirectionMatrix of the image, so the
* output outline may not be axes aligned.
*
*/
export declare const vtkImageDataOutlineFilter: {
newInstance: typeof newInstance;
extend: typeof extend;
};
export default vtkImageDataOutlineFilter;
index.js
import macro from 'vtk.js/Sources/macros';
import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource';

const { vtkErrorMacro } = macro;

// ----------------------------------------------------------------------------
// vtkImageDataOutlineFilter methods
// ----------------------------------------------------------------------------

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

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

publicAPI.requestData = (inData, outData) => {
// implement requestData
const input = inData[0];

if (!input || !input.isA('vtkImageData')) {
vtkErrorMacro('Invalid or missing input');
return;
}

// First create a cube polydata in the index-space of the image.
// The benefit of using `getSpatialExtent` call is that it automatically
// takes care of 0.5 voxel padding as required by an vtkImageData representation.
const spatialExt = input.getSpatialExtent();
if (!spatialExt) {
vtkErrorMacro('Unable to fetch spatial extents of input image.');
return;
}

model._cubeSource.setBounds(spatialExt);

// Then apply index-to-world transform to the cube to create the outline.
model._cubeSource.setMatrix(input.getIndexToWorld());
outData[0] = model._cubeSource.getOutputData();
};

publicAPI.getMTime = () =>
Math.max(superClass.getMTime(), model._cubeSource.getMTime());

// Forward calls for [set/get]Generate[Faces/Lines] functions to cubeSource:
publicAPI.setGenerateFaces = model._cubeSource.setGenerateFaces;

publicAPI.setGenerateLines = model._cubeSource.setGenerateLines;

publicAPI.getGenerateFaces = model._cubeSource.getGenerateFaces;

publicAPI.getGenerateLines = model._cubeSource.getGenerateLines;
}

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

const DEFAULT_VALUES = {};

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

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

// Make this a VTK object
macro.obj(publicAPI, model);

// Also make it an algorithm with one input and one output
macro.algo(publicAPI, model, 1, 1);

// Internal persistent objects
model._cubeSource = vtkCubeSource.newInstance();

macro.moveToProtected(publicAPI, model, ['cubeSource', 'tmpOut']);

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

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

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

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

export default { newInstance, extend };