vtkImplicitBoolean enables boolean combinations of implicit functions like Plane, Sphere, Cylinder, and Box. Operations include union, intersection, and difference. Multiple implicit functions can be specified (all combined with the same operation).
operation (set/get)
Specify the operation to use: ‘UNION’ (<=0), ‘INTERSECTION’ (=1), ‘DIFFERENCE’ (>=2)
Add an implicit function to the list of functions.
evaluateFunction(xyz)
Given the point xyz (three floating values) evaluate the boolean combination of implicit functions to return the combined function value.
evaluateGradient(xyz)
Given the point xyz (three floating values) evaluate the boolean combination of implicit functions to return the combined gradient value. The method returns an array of three floats.
Source
Constants.js
// Constants in support of ImplicitBoolean // exportconstOperation = { UNION: 0, INTERSECTION: 1, DIFFERENCE: 2, };
publicAPI.evaluateFunction = (xyz) => { let value = 0.0; if (model.functions.length <= 0) { return value; }
if (model.operation === Operation.UNION) { value = Number.MAX_VALUE; for (let i = 0; i < model.functions.length; ++i) { const f = model.functions[i]; const v = f.functionValue(xyz); if (v < value) { value = v; } } } elseif (model.operation === Operation.INTERSECTION) { value = -Number.MAX_VALUE; for (let i = 0; i < model.functions.length; ++i) { const f = model.functions[i]; const v = f.functionValue(xyz); if (v > value) { value = v; } } } else { const firstF = model.functions[0]; value = firstF.functionValue(xyz); for (let i = 1; i < model.functions.length; ++i) { const f = model.functions[i]; const v = -1.0 * f.evaluateFunction(xyz); if (v > value) { value = v; } } } return value; };