Cone

Introduction

vtkCone computes the implicit function and/or gradient for a cone. vtkCone is
a concrete implementation of vtkImplicitFunction.

Methods

evaluateFunction

Given the point x evaluate the cone equation.

Argument Type Required Description
x Vector3 Yes The point coordinate.

evaluateGradient

Given the point x evaluate the equation for the cone gradient.

Argument Type Required Description
x Vector3 Yes The point coordinate.

extend

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

getAngle

Get the angle of the cone.

newInstance

Method used to create a new instance of vtkCone.

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

setAngle

Set the value representing the angle of the cone.

Argument Type Required Description
angle Number Yes The angle of the cone.

Source

index.d.ts
import { vtkObject } from '../../../interfaces';
import { Vector3 } from '../../../types';

/**
*
*/
export interface IConeInitialValues {
angle?: number;
}

export interface vtkCone extends vtkObject {
/**
* Given the point x evaluate the cone equation.
* @param {Vector3} x The point coordinate.
*/
evaluateFunction(x: Vector3): number;

/**
* Given the point x evaluate the equation for the cone gradient.
* @param {Vector3} x The point coordinate.
*/
evaluateGradient(x: Vector3): number[];

/**
* Get the angle of the cone.
*/
getAngle(): number;

/**
* Set the value representing the angle of the cone.
* @param {Number} angle The angle of the cone.
*/
setAngle(angle: number): boolean;
}

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

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

/**
* vtkCone computes the implicit function and/or gradient for a cone. vtkCone is
* a concrete implementation of vtkImplicitFunction.
*/
export declare const vtkCone: {
newInstance: typeof newInstance;
extend: typeof extend;
};
export default vtkCone;
index.js
import macro from 'vtk.js/Sources/macros';
import * as vtkMath from 'vtk.js/Sources/Common/Core/Math';
import vtkImplicitFunction from 'vtk.js/Sources/Common/DataModel/ImplicitFunction';

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

// ----------------------------------------------------------------------------
// Static API
// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------
// vtkCone methods
// ----------------------------------------------------------------------------

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

publicAPI.evaluateFunction = (x) => {
const tanTheta = Math.tan(vtkMath.radiansFromDegrees(model.angle));
const retVal =
x[1] * x[1] + x[2] * x[2] - x[0] * x[0] * tanTheta * tanTheta;

return retVal;
};

publicAPI.evaluateGradient = (x) => {
const tanTheta = Math.tan(vtkMath.radiansFromDegrees(model.angle));
const retVal = [-2.0 * x[0] * tanTheta * tanTheta, 2.0 * x[1], 2.0 * x[2]];
return retVal;
};
}

// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------
const DEFAULT_VALUES = {
angle: 15.0,
};

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

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

// Object methods
vtkImplicitFunction.extend(publicAPI, model, initialValues);
macro.setGet(publicAPI, model, ['angle']);

vtkCone(publicAPI, model);
}

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

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

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

export default { newInstance, extend };