@kitware/vtk.js 23.4.3 → 23.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/Core/Math/Constants.js +12 -0
- package/Common/Core/Math/index.js +1 -1
- package/Common/Core/Math.js +1 -1
- package/Common/Core/ScalarsToColors/Constants.d.ts +18 -0
- package/Common/DataModel/AbstractPointLocator.d.ts +54 -0
- package/Common/DataModel/AbstractPointLocator.js +40 -0
- package/Common/DataModel/BoundingBox.d.ts +659 -0
- package/Common/DataModel/Collection.d.ts +118 -0
- package/Common/DataModel/Collection.js +113 -0
- package/Common/DataModel/DataSet/Constants.d.ts +27 -0
- package/Common/DataModel/EdgeLocator.d.ts +79 -0
- package/Common/DataModel/EdgeLocator.js +85 -0
- package/Common/DataModel/ITKHelper.d.ts +54 -0
- package/Common/DataModel/IncrementalOctreeNode.d.ts +297 -0
- package/Common/DataModel/IncrementalOctreeNode.js +640 -0
- package/Common/DataModel/IncrementalOctreePointLocator.d.ts +61 -0
- package/Common/DataModel/IncrementalOctreePointLocator.js +398 -0
- package/Common/DataModel/Locator.d.ts +43 -0
- package/Common/DataModel/Locator.js +37 -0
- package/Common/DataModel/Plane.js +1 -1
- package/Common/DataModel/PolyData/Constants.d.ts +6 -0
- package/Common/DataModel/PolyLine.d.ts +63 -0
- package/Common/DataModel/PolyLine.js +77 -0
- package/Common/DataModel/Polygon/Constants.js +12 -0
- package/Common/DataModel/Polygon.js +1 -1
- package/Common/DataModel/Quad/Constants.js +9 -0
- package/Common/DataModel/Quad.d.ts +91 -0
- package/Common/DataModel/Quad.js +235 -0
- package/Common/DataModel/SelectionNode/Constants.d.ts +27 -0
- package/Common/DataModel/Spline1D/Constants.js +17 -0
- package/Common/DataModel/Spline3D/Constants.d.ts +9 -0
- package/Common/Transform/Transform.js +51 -0
- package/Filters/Core/PolyDataNormals.js +124 -0
- package/Filters/General/ClipClosedSurface/Constants.js +10 -0
- package/Filters/General/ClipClosedSurface.d.ts +95 -0
- package/Filters/General/ClipClosedSurface.js +972 -0
- package/Filters/General/ContourTriangulator/Constants.js +6 -0
- package/Filters/General/ContourTriangulator/helper.js +1951 -0
- package/Filters/General/ContourTriangulator.d.ts +136 -0
- package/Filters/General/ContourTriangulator.js +202 -0
- package/Filters/General/ImageMarchingCubes.js +1 -1
- package/Filters/General/MoleculeToRepresentation.js +1 -1
- package/Filters/General/OBBTree/OBBNode.js +82 -0
- package/Filters/General/OBBTree/helper.js +92 -0
- package/Filters/General/OBBTree.js +1243 -0
- package/Filters/General/TubeFilter.js +1 -1
- package/Filters/Sources/LineSource.js +1 -1
- package/Filters/Sources/PlaneSource.js +1 -1
- package/Filters/Texture/TextureMapToPlane.js +1 -1
- package/Interaction/Manipulators/CompositeCameraManipulator.d.ts +68 -0
- package/Interaction/Manipulators/CompositeGestureManipulator.d.ts +168 -0
- package/Interaction/Manipulators/CompositeKeyboardManipulator.d.ts +48 -0
- package/Interaction/Manipulators/CompositeMouseManipulator.d.ts +149 -0
- package/Interaction/Manipulators/CompositeVRManipulator.d.ts +44 -0
- package/Interaction/Manipulators/GestureCameraManipulator.d.ts +34 -0
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
- package/Interaction/Manipulators/MouseBoxSelectorManipulator.d.ts +88 -0
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.d.ts +32 -0
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.d.ts +33 -0
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.d.ts +33 -0
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.d.ts +67 -0
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.d.ts +45 -0
- package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.d.ts +26 -0
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseRangeManipulator.d.ts +53 -0
- package/Interaction/Style/InteractorStyleImage.d.ts +107 -0
- package/Interaction/Style/InteractorStyleMPRSlice.js +1 -1
- package/Interaction/Style/InteractorStyleManipulator.d.ts +348 -0
- package/Interaction/Style/InteractorStyleTrackballCamera.d.ts +170 -0
- package/Interaction/Widgets/ImageCroppingRegionsWidget.js +1 -1
- package/Interaction/Widgets/LabelRepresentation.js +1 -1
- package/Interaction/Widgets/OrientationMarkerWidget/Constants.d.ts +11 -0
- package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +1 -1
- package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +1 -1
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +1 -1
- package/Proxy/Core/AbstractRepresentationProxy.d.ts +24 -0
- package/Proxy/Core/LookupTableProxy.d.ts +45 -0
- package/Proxy/Core/PiecewiseFunctionProxy.d.ts +62 -0
- package/Proxy/Core/ProxyManager.d.ts +115 -0
- package/Proxy/Core/SourceProxy.d.ts +22 -0
- package/Proxy/Core/View2DProxy.d.ts +7 -0
- package/Proxy/Core/View2DProxy.js +1 -1
- package/Proxy/Core/ViewProxy.d.ts +86 -0
- package/Proxy/Representations/SliceRepresentationProxy.d.ts +27 -0
- package/Proxy/Representations/VolumeRepresentationProxy.d.ts +44 -0
- package/README.md +2 -2
- package/Rendering/Core/AbstractImageMapper/helper.js +127 -0
- package/Rendering/Core/AbstractImageMapper.d.ts +82 -0
- package/Rendering/Core/AbstractImageMapper.js +44 -0
- package/Rendering/Core/Camera.js +1 -1
- package/Rendering/Core/CellPicker.js +1 -1
- package/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts +24 -0
- package/Rendering/Core/ColorTransferFunction/Constants.d.ts +17 -0
- package/Rendering/Core/ColorTransferFunction.js +1 -1
- package/Rendering/Core/Coordinate/Constants.d.ts +14 -0
- package/Rendering/Core/Coordinate.js +1 -1
- package/Rendering/Core/Glyph3DMapper/Constants.d.ts +17 -0
- package/Rendering/Core/Glyph3DMapper.js +1 -1
- package/Rendering/Core/HardwareSelector.d.ts +84 -0
- package/Rendering/Core/ImageArrayMapper.d.ts +253 -0
- package/Rendering/Core/ImageArrayMapper.js +242 -0
- package/Rendering/Core/ImageMapper/Constants.d.ts +14 -0
- package/Rendering/Core/ImageMapper.js +1 -1
- package/Rendering/Core/ImageProperty/Constants.d.ts +9 -0
- package/Rendering/Core/ImageResliceMapper/Constants.d.ts +11 -0
- package/Rendering/Core/ImageResliceMapper/Constants.js +11 -0
- package/Rendering/Core/ImageResliceMapper.d.ts +245 -0
- package/Rendering/Core/ImageResliceMapper.js +70 -0
- package/Rendering/Core/InteractorObserver.d.ts +132 -0
- package/Rendering/Core/InteractorStyle/Constants.d.ts +16 -0
- package/Rendering/Core/InteractorStyle.d.ts +229 -0
- package/Rendering/Core/Light.js +1 -1
- package/Rendering/Core/Mapper/Constants.d.ts +26 -0
- package/Rendering/Core/Mapper.js +1 -1
- package/Rendering/Core/Picker.js +1 -1
- package/Rendering/Core/Prop/Constants.d.ts +9 -0
- package/Rendering/Core/Prop/Constants.js +9 -0
- package/Rendering/Core/Property/Constants.d.ts +24 -0
- package/Rendering/Core/Property2D/Constants.d.ts +9 -0
- package/Rendering/Core/RenderWindow.js +1 -1
- package/Rendering/Core/RenderWindowInteractor/Constants.d.ts +31 -0
- package/Rendering/Core/Renderer.js +1 -1
- package/Rendering/Core/VolumeMapper/Constants.d.ts +20 -0
- package/Rendering/Core/VolumeMapper.js +1 -1
- package/Rendering/Core/VolumeProperty/Constants.d.ts +16 -0
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +129 -0
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +131 -0
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.d.ts +80 -0
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +763 -0
- package/Rendering/OpenGL/HardwareSelector/Constants.d.ts +8 -0
- package/Rendering/OpenGL/HardwareSelector.d.ts +339 -0
- package/Rendering/OpenGL/ImageResliceMapper.js +996 -0
- package/Rendering/OpenGL/PolyDataMapper.js +1 -1
- package/Rendering/OpenGL/PolyDataMapper2D.js +1 -1
- package/Rendering/OpenGL/RenderWindow/Constants.d.ts +10 -0
- package/Rendering/OpenGL/RenderWindow/Constants.js +13 -0
- package/Rendering/OpenGL/RenderWindow/ContextProxy.js +70 -0
- package/Rendering/OpenGL/glsl/vtkImageResliceMapperFS.glsl.js +3 -0
- package/Rendering/OpenGL/glsl/vtkImageResliceMapperVS.glsl.js +3 -0
- package/Rendering/WebGPU/Actor2D.js +151 -0
- package/Rendering/WebGPU/BufferManager.js +1 -1
- package/Rendering/WebGPU/CellArrayMapper.js +853 -0
- package/Rendering/WebGPU/IndexBuffer.js +397 -0
- package/Rendering/WebGPU/PolyDataMapper2D.js +99 -0
- package/Rendering/WebGPU/SimpleMapper.js +290 -0
- package/Widgets/Core/AbstractWidget.d.ts +187 -0
- package/Widgets/Core/AbstractWidgetFactory.d.ts +131 -0
- package/Widgets/Core/StateBuilder/color3Mixin.js +24 -0
- package/Widgets/Core/StateBuilder/orientationMixin.js +1 -1
- package/Widgets/Core/StateBuilder.d.ts +29 -0
- package/Widgets/Core/WidgetManager/Constants.d.ts +27 -0
- package/Widgets/Core/WidgetManager.d.ts +231 -0
- package/Widgets/Core/WidgetState.d.ts +81 -0
- package/Widgets/Manipulators/AbstractManipulator.d.ts +221 -0
- package/Widgets/Manipulators/AbstractManipulator.js +57 -0
- package/Widgets/Manipulators/LineManipulator.js +1 -1
- package/Widgets/Manipulators/TrackballManipulator.js +1 -1
- package/Widgets/Representations/GlyphRepresentation.js +325 -0
- package/Widgets/Representations/LineHandleRepresentation.js +116 -0
- package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
- package/Widgets/Representations/WidgetRepresentation.js +1 -1
- package/Widgets/Widgets3D/AngleWidget.js +1 -1
- package/Widgets/Widgets3D/InteractiveOrientationWidget.d.ts +40 -0
- package/Widgets/Widgets3D/LabelWidget/behavior.js +157 -0
- package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
- package/Widgets/Widgets3D/LabelWidget.js +78 -0
- package/Widgets/Widgets3D/LineWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
- package/index.d.ts +133 -74
- package/package.json +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { vtkAlgorithm, vtkObject } from './../../interfaces';
|
|
2
|
+
import { Nullable, TypedArray, Vector3 } from './../../types';
|
|
3
|
+
import vtkCellArray from './../../Common/Core/CellArray';
|
|
4
|
+
import vtkPolyData from './../../Common/DataModel/PolyData';
|
|
5
|
+
import vtkPoints from './../../Common/Core/Points';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export interface IContourTriangulatorInitialValues {
|
|
11
|
+
triangulatePolys?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type vtkContourTriangulatorBase = vtkObject & vtkAlgorithm;
|
|
15
|
+
|
|
16
|
+
export interface vtkContourTriangulator extends vtkContourTriangulatorBase {
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {any} inData
|
|
20
|
+
* @param {any} outData
|
|
21
|
+
*/
|
|
22
|
+
requestData(inData: any, outData: any): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sets the behavior of the filter regarding polys.
|
|
26
|
+
* @param {boolean} triangulate whether the filter should triangulate polys
|
|
27
|
+
* or leave them untouched. True by default
|
|
28
|
+
* @return {boolean} true if it changes
|
|
29
|
+
*/
|
|
30
|
+
setTriangulatePolys(triangulate: boolean): boolean;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns the behavior of the filter regarding polys.
|
|
34
|
+
* @return {boolean} True if the filter triangulates polys, false otherwise.
|
|
35
|
+
*/
|
|
36
|
+
getTriangulatePolys(): boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ----------------------------------------------------------------------------
|
|
40
|
+
// Static API
|
|
41
|
+
// ----------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* This is a complex subroutine that takes a collection of lines that
|
|
45
|
+
* were formed by cutting a polydata with a plane, and generates
|
|
46
|
+
* a face that has those lines as its edges. The lines must form one
|
|
47
|
+
* or more closed contours, but they need not be sorted.
|
|
48
|
+
*
|
|
49
|
+
* Only "numLine" lines starting from "firstLine" are used to create new
|
|
50
|
+
* polygons, and the new polygons are appended to "polys". The normal of
|
|
51
|
+
* the cut plane must be provided so that polys will be correctly oriented.
|
|
52
|
+
*
|
|
53
|
+
* Given some closed contour lines, create a triangle mesh that fills
|
|
54
|
+
* those lines. The input lines do not have to be in tail-to-tip order.
|
|
55
|
+
* Only numLines starting from firstLine will be used. Note that holes
|
|
56
|
+
* can be indicated by contour loops whose normals are in the opposite
|
|
57
|
+
* direction to the provided normal.
|
|
58
|
+
*
|
|
59
|
+
* @param {vtkPolyData} polyData
|
|
60
|
+
* @param {Number} firstLine
|
|
61
|
+
* @param {Number} numLines
|
|
62
|
+
* @param {vtkCellArray} polys
|
|
63
|
+
* @param {Nullable<Vector3>} normal If null, the function will compute
|
|
64
|
+
* the normal of the polys.
|
|
65
|
+
* @param {Boolean} [triangulatePolys] (default: true) If set to true
|
|
66
|
+
* the resulting polygons will be triangulated, otherwise the polygons
|
|
67
|
+
* themselves will be added to the output.
|
|
68
|
+
* @param {Boolean} [diagnoseOnTriangulationError] (default: false)
|
|
69
|
+
* If this option is set to true and there was a triangulation error
|
|
70
|
+
* this will add the polys as outlines to the output.
|
|
71
|
+
* @returns {Boolean} Returns true if triangulation was successful,
|
|
72
|
+
* false otherwise.
|
|
73
|
+
*/
|
|
74
|
+
export function triangulateContours(
|
|
75
|
+
polyData: vtkPolyData,
|
|
76
|
+
firstLine: number,
|
|
77
|
+
numLines: number,
|
|
78
|
+
polys: vtkCellArray,
|
|
79
|
+
normal: Nullable<Vector3>,
|
|
80
|
+
triangulatePolys?: boolean,
|
|
81
|
+
diagnoseOnTriangulationError?: boolean
|
|
82
|
+
): boolean;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A robust method for triangulating a polygon. It cleans up the polygon
|
|
86
|
+
* and then applies the ear-cut triangulation. A zero return value
|
|
87
|
+
* indicates that triangulation failed.
|
|
88
|
+
*
|
|
89
|
+
* @param {Array<Number>|TypedArray} polygon Array of point indices defining the polygon
|
|
90
|
+
* @param {vtkPoints} points The point coordinates of the polygon
|
|
91
|
+
* @param {vtkCellArray} triangles The cell array that is going to be
|
|
92
|
+
* filled with the triangulation
|
|
93
|
+
* @returns {Boolean} Returns true if triangulation was successful,
|
|
94
|
+
* false otherwise.
|
|
95
|
+
*/
|
|
96
|
+
export function triangulatePolygon(
|
|
97
|
+
polygon: Array<number> | TypedArray,
|
|
98
|
+
points: vtkPoints,
|
|
99
|
+
triangles: vtkCellArray
|
|
100
|
+
): boolean;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Method use to decorate a given object (publicAPI+model) with vtkContourTriangulator characteristics.
|
|
104
|
+
*
|
|
105
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
106
|
+
* @param model object on which data structure will be bounds (protected)
|
|
107
|
+
* @param {IContourTriangulatorInitialValues} [initialValues] (default: {})
|
|
108
|
+
*/
|
|
109
|
+
export function extend(
|
|
110
|
+
publicAPI: object,
|
|
111
|
+
model: object,
|
|
112
|
+
initialValues?: IContourTriangulatorInitialValues
|
|
113
|
+
): void;
|
|
114
|
+
|
|
115
|
+
// ----------------------------------------------------------------------------
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Method use to create a new instance of vtkContourTriangulator
|
|
119
|
+
* @param {IContourTriangulatorInitialValues} [initialValues] for pre-setting some of its content
|
|
120
|
+
*/
|
|
121
|
+
export function newInstance(
|
|
122
|
+
initialValues?: IContourTriangulatorInitialValues
|
|
123
|
+
): vtkContourTriangulator;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* vtkContourTriangulator
|
|
127
|
+
*/
|
|
128
|
+
export declare const vtkContourTriangulator: {
|
|
129
|
+
newInstance: typeof newInstance;
|
|
130
|
+
extend: typeof extend;
|
|
131
|
+
// static
|
|
132
|
+
triangulateContours: typeof triangulateContours;
|
|
133
|
+
triangulatePolygon: typeof triangulatePolygon;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export default vtkContourTriangulator;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
|
+
import macro from '../../macros.js';
|
|
4
|
+
import vtkCellArray from '../../Common/Core/CellArray.js';
|
|
5
|
+
import vtkPolygon from '../../Common/DataModel/Polygon.js';
|
|
6
|
+
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
7
|
+
import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
|
|
8
|
+
import { vtkCCSMakePolysFromLines, vtkCCSJoinLooseEnds, vtkCCSFindTrueEdges, vtkCCSMakeHoleyPolys, vtkCCSCutHoleyPolys, vtkCCSSplitAtPinchPoints, vtkCCSTriangulate } from './ContourTriangulator/helper.js';
|
|
9
|
+
|
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
+
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
+
var vtkErrorMacro = macro.vtkErrorMacro;
|
|
14
|
+
var TRIANGULATION_ERROR_DISPLAY = false;
|
|
15
|
+
|
|
16
|
+
function triangulateContours(polyData, firstLine, numLines, polys, normal) {
|
|
17
|
+
var triangulatePolys = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
18
|
+
var triangulationFailure = false; // If no cut lines were generated, there's nothing to do
|
|
19
|
+
|
|
20
|
+
if (numLines <= 0) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var points = polyData.getPoints(); // Join all the new lines into connected groups, i.e. polygons.
|
|
25
|
+
// If we are lucky these will be simple, convex polygons. But
|
|
26
|
+
// we can't count on that.
|
|
27
|
+
|
|
28
|
+
var newPolys = [];
|
|
29
|
+
var incompletePolys = [];
|
|
30
|
+
var oriented = (normal === null || normal === void 0 ? void 0 : normal.length) < 3;
|
|
31
|
+
vtkCCSMakePolysFromLines(polyData, firstLine, firstLine + numLines, oriented, newPolys, incompletePolys); // if no normal specified, then compute one from largest contour
|
|
32
|
+
|
|
33
|
+
var computedNormal = normal;
|
|
34
|
+
|
|
35
|
+
if (!oriented) {
|
|
36
|
+
computedNormal = [0, 0, 1];
|
|
37
|
+
var maxnorm = 0;
|
|
38
|
+
var n = [];
|
|
39
|
+
|
|
40
|
+
for (var i = 0; i < newPolys.length; i++) {
|
|
41
|
+
var norm = vtkPolygon.getNormal(newPolys[i], points, n);
|
|
42
|
+
|
|
43
|
+
if (norm > maxnorm) {
|
|
44
|
+
maxnorm = norm;
|
|
45
|
+
computedNormal[0] = n[0];
|
|
46
|
+
computedNormal[1] = n[1];
|
|
47
|
+
computedNormal[2] = n[2];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} // Join any loose ends. If the input was a closed surface then there
|
|
51
|
+
// will not be any loose ends, so this is provided as a service to users
|
|
52
|
+
// who want to clip a non-closed surface.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
vtkCCSJoinLooseEnds(newPolys, incompletePolys, points, computedNormal); // Some points might be in the middle of straight line segments.
|
|
56
|
+
// These points can be removed without changing the shape of the
|
|
57
|
+
// polys, and removing them makes triangulation more stable.
|
|
58
|
+
// Unfortunately removing these points also means that the polys
|
|
59
|
+
// will no longer form a watertight cap over the cut.
|
|
60
|
+
|
|
61
|
+
var polyEdges = [];
|
|
62
|
+
var originalEdges = [];
|
|
63
|
+
vtkCCSFindTrueEdges(newPolys, points, polyEdges, originalEdges); // Next we have to check for polygons with holes, i.e. polygons that
|
|
64
|
+
// have other polygons inside. Each polygon is "grouped" with the
|
|
65
|
+
// polygons that make up its holes.
|
|
66
|
+
// Initialize each group to hold just one polygon.
|
|
67
|
+
|
|
68
|
+
var numNewPolys = newPolys.length;
|
|
69
|
+
var polyGroups = new Array(numNewPolys);
|
|
70
|
+
|
|
71
|
+
for (var _i = 0; _i < numNewPolys; _i++) {
|
|
72
|
+
polyGroups[_i] = [_i];
|
|
73
|
+
} // Find out which polys are holes in larger polys. Create a group
|
|
74
|
+
// for each poly where the first member of the group is the larger
|
|
75
|
+
// poly, and all other members are the holes. The number of polyGroups
|
|
76
|
+
// will be the same as the number of polys, and any polys that are
|
|
77
|
+
// holes will have a matching empty group.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
vtkCCSMakeHoleyPolys(newPolys, points, polyGroups, polyEdges, originalEdges, computedNormal, oriented); // Make cuts to create simple polygons out of the holey polys.
|
|
81
|
+
// After this is done, each polyGroup will have exactly 1 polygon,
|
|
82
|
+
// and no polys will be holes. This is currently the most computationally
|
|
83
|
+
// expensive part of the process.
|
|
84
|
+
|
|
85
|
+
if (!vtkCCSCutHoleyPolys(newPolys, points, polyGroups, polyEdges, computedNormal)) {
|
|
86
|
+
triangulationFailure = true;
|
|
87
|
+
} // Some polys might be self-intersecting. Split the polys at each intersection point.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
vtkCCSSplitAtPinchPoints(newPolys, points, polyGroups, polyEdges, computedNormal, oriented); // ------ Triangulation code ------
|
|
91
|
+
// Go through all polys and triangulate them
|
|
92
|
+
|
|
93
|
+
for (var polyId = 0; polyId < polyGroups.length; polyId++) {
|
|
94
|
+
// If group is empty, then poly was a hole without a containing poly
|
|
95
|
+
if (polyGroups[polyId].length === 0) {
|
|
96
|
+
// eslint-disable-next-line no-continue
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (!triangulatePolys) {
|
|
101
|
+
polys.insertNextCell(originalEdges.slice(1, originalEdges.length));
|
|
102
|
+
} else if (!vtkCCSTriangulate(newPolys[polyId], points, polyEdges[polyId], originalEdges, polys, computedNormal)) {
|
|
103
|
+
triangulationFailure = false; // Diagnostic code: show the polys as outlines
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return !triangulationFailure;
|
|
108
|
+
} // ---------------------------------------------------
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
function triangulatePolygon(polygon, points, triangles) {
|
|
112
|
+
var poly = _toConsumableArray(polygon);
|
|
113
|
+
|
|
114
|
+
var polys = [poly];
|
|
115
|
+
var originalEdges = [];
|
|
116
|
+
var polyEdges = [];
|
|
117
|
+
vtkCCSFindTrueEdges(polys, points, polyEdges, originalEdges);
|
|
118
|
+
var edges = polyEdges[0];
|
|
119
|
+
var success = true;
|
|
120
|
+
var normal = [];
|
|
121
|
+
var norm = vtkPolygon.getNormal(poly, points, normal);
|
|
122
|
+
|
|
123
|
+
if (norm !== 0) {
|
|
124
|
+
success = vtkCCSTriangulate(poly, points, edges, originalEdges, triangles, normal);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return success;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
var STATIC = {
|
|
131
|
+
triangulateContours: triangulateContours,
|
|
132
|
+
triangulatePolygon: triangulatePolygon
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
function vtkContourTriangulator(publicAPI, model) {
|
|
136
|
+
// Set our className
|
|
137
|
+
model.classHierarchy.push('vtkContourTriangulator');
|
|
138
|
+
|
|
139
|
+
publicAPI.requestData = function (inData, outData) {
|
|
140
|
+
// implement requestData
|
|
141
|
+
var input = inData[0]; // FIXME: do not instantiate a new polydata each time the filter is executed.
|
|
142
|
+
|
|
143
|
+
var output = vtkPolyData.newInstance();
|
|
144
|
+
outData[0] = output;
|
|
145
|
+
|
|
146
|
+
if (!input) {
|
|
147
|
+
vtkErrorMacro('Invalid or missing input');
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var triangulationError = false;
|
|
152
|
+
var lines = input.getLines();
|
|
153
|
+
|
|
154
|
+
if (lines == null || lines.getNumberOfCells() === 0) {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
input.buildCells();
|
|
159
|
+
var polysArray = vtkCellArray.newInstance({
|
|
160
|
+
dataType: VtkDataTypes.DOUBLE,
|
|
161
|
+
empty: true
|
|
162
|
+
});
|
|
163
|
+
output.setPolys(polysArray);
|
|
164
|
+
output.setPoints(input.getPoints());
|
|
165
|
+
output.getPointData().passData(input.getPointData());
|
|
166
|
+
triangulationError = !triangulateContours(input, input.getNumberOfVerts(), lines.getNumberOfCells(), polysArray, null, model.triangulatePolys);
|
|
167
|
+
|
|
168
|
+
if (triangulationError && TRIANGULATION_ERROR_DISPLAY) {
|
|
169
|
+
vtkErrorMacro('Triangulation failed, output might have holes.');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return true;
|
|
173
|
+
};
|
|
174
|
+
} // ----------------------------------------------------------------------------
|
|
175
|
+
// Object factory
|
|
176
|
+
// ----------------------------------------------------------------------------
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
var DEFAULT_VALUES = {
|
|
180
|
+
triangulatePolys: true
|
|
181
|
+
}; // ----------------------------------------------------------------------------
|
|
182
|
+
|
|
183
|
+
function extend(publicAPI, model) {
|
|
184
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
185
|
+
Object.assign(model, DEFAULT_VALUES, initialValues); // Make this a VTK object
|
|
186
|
+
|
|
187
|
+
macro.obj(publicAPI, model); // Also make it an algorithm with one input and one output
|
|
188
|
+
|
|
189
|
+
macro.algo(publicAPI, model, 1, 1);
|
|
190
|
+
macro.setGet(publicAPI, model, ['triangulatePolys']); // Object specific methods
|
|
191
|
+
|
|
192
|
+
vtkContourTriangulator(publicAPI, model);
|
|
193
|
+
} // ----------------------------------------------------------------------------
|
|
194
|
+
|
|
195
|
+
var newInstance = macro.newInstance(extend, 'vtkContourTriangulator'); // ----------------------------------------------------------------------------
|
|
196
|
+
|
|
197
|
+
var vtkContourTriangulator$1 = _objectSpread({
|
|
198
|
+
newInstance: newInstance,
|
|
199
|
+
extend: extend
|
|
200
|
+
}, STATIC);
|
|
201
|
+
|
|
202
|
+
export { STATIC, vtkContourTriangulator$1 as default, extend, newInstance };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import macro from '../../macros.js';
|
|
2
2
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
3
3
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
4
|
-
import {
|
|
4
|
+
import { g as normalize } from '../../Common/Core/Math/index.js';
|
|
5
5
|
import vtkCaseTable from './ImageMarchingCubes/caseTable.js';
|
|
6
6
|
|
|
7
7
|
var vtkErrorMacro = macro.vtkErrorMacro,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import macro from '../../macros.js';
|
|
2
2
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
3
3
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
4
|
-
import {
|
|
4
|
+
import { g as normalize } from '../../Common/Core/Math/index.js';
|
|
5
5
|
import { a as atomElem } from '../../Utilities/XMLConverter/chemistry/elements.json.js';
|
|
6
6
|
|
|
7
7
|
var vtkErrorMacro = macro.vtkErrorMacro,
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
|
+
import macro from '../../../macros.js';
|
|
4
|
+
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
+
// vtkOBBNode methods
|
|
9
|
+
// ----------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
function vtkOBBNode(publicAPI, model) {
|
|
12
|
+
// Set our classname
|
|
13
|
+
model.classHierarchy.push('vtkOBBNode');
|
|
14
|
+
/**
|
|
15
|
+
* Copy a vtkOBBNode into an other one
|
|
16
|
+
* @param {vtkOBBNode} nodeSource
|
|
17
|
+
* @param {vtkOBBNode} nodeTarget
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
publicAPI.deepCopy = function (nodeSource) {
|
|
21
|
+
publicAPI.setCorner(nodeSource.getCorner());
|
|
22
|
+
var axes = nodeSource.getAxes();
|
|
23
|
+
publicAPI.setAxes([_toConsumableArray(axes[0]), _toConsumableArray(axes[1]), _toConsumableArray(axes[2])]);
|
|
24
|
+
publicAPI.setCells(_toConsumableArray(nodeSource.getCells()));
|
|
25
|
+
|
|
26
|
+
if (nodeSource.getKids()) {
|
|
27
|
+
var kids0 = vtkOBBNode.newInstance();
|
|
28
|
+
kids0.setParent(publicAPI);
|
|
29
|
+
var kids1 = vtkOBBNode.newInstance();
|
|
30
|
+
kids1.setParent(publicAPI);
|
|
31
|
+
kids0.deepCopy(nodeSource.getKids()[0]);
|
|
32
|
+
kids1.deepCopy(nodeSource.getKids()[1], kids1);
|
|
33
|
+
publicAPI.setKids(kids0, kids1);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
publicAPI.getAxis = function (axis) {
|
|
38
|
+
return model.axes[axis];
|
|
39
|
+
};
|
|
40
|
+
} // ----------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
function defaultValues(initialValues) {
|
|
44
|
+
return _objectSpread({
|
|
45
|
+
corner: [0, 0, 0],
|
|
46
|
+
// center point of this node
|
|
47
|
+
axes: [[0, 0, 0], [0, 0, 0], [0, 0, 0]],
|
|
48
|
+
// the axes defining the OBB - ordered from long->short
|
|
49
|
+
cells: []
|
|
50
|
+
}, initialValues);
|
|
51
|
+
} // ----------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
function extend(publicAPI, model) {
|
|
55
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
56
|
+
Object.assign(model, defaultValues(initialValues));
|
|
57
|
+
model.corner = [0, 0, 0];
|
|
58
|
+
model.axes = [[0, 0, 0], [0, 0, 0], [0, 0, 0]];
|
|
59
|
+
model.parent = null; // parent node; null if root
|
|
60
|
+
|
|
61
|
+
model.kids = null; // two children of this node; nullptr if leaf
|
|
62
|
+
|
|
63
|
+
model.cells = []; // list of cells in node
|
|
64
|
+
// Build VTK API
|
|
65
|
+
|
|
66
|
+
macro.setGet(publicAPI, model, ['parent', 'cells', 'kids']); // macro.setGetArray(publicAPI, model, ['kids'], 2);
|
|
67
|
+
|
|
68
|
+
macro.setGetArray(publicAPI, model, ['corner', 'axes'], 3); // Make this a VTK object
|
|
69
|
+
|
|
70
|
+
macro.obj(publicAPI, model); // Object specific methods
|
|
71
|
+
|
|
72
|
+
vtkOBBNode(publicAPI, model);
|
|
73
|
+
} // ----------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
var newInstance = macro.newInstance(extend, 'vtkOBBNode'); // ----------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
var vtkOBBNode$1 = {
|
|
78
|
+
newInstance: newInstance,
|
|
79
|
+
extend: extend
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { vtkOBBNode$1 as default, extend, newInstance };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { CellType } from '../../../Common/DataModel/CellTypes/Constants.js';
|
|
2
|
+
import vtkOBJReader from '../../../IO/Misc/OBJReader.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get the correct point ID from a cell id
|
|
6
|
+
* @param {Array} cellPtsIds
|
|
7
|
+
* @param {CellType} type
|
|
8
|
+
* @param {Number} idx
|
|
9
|
+
* @returns {Object} Contains three point's id of cells as 'ptId0', 'ptId1', 'ptId2'
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function getCellTriangles(cellPtsIds, type, idx) {
|
|
13
|
+
var ptId0 = -1;
|
|
14
|
+
var ptId1 = -1;
|
|
15
|
+
var ptId2 = -1;
|
|
16
|
+
var cellListLength = cellPtsIds.length;
|
|
17
|
+
|
|
18
|
+
switch (type) {
|
|
19
|
+
case CellType.VTK_TRIANGLE:
|
|
20
|
+
case CellType.VTK_POLYGON:
|
|
21
|
+
case CellType.VTK_QUAD:
|
|
22
|
+
{
|
|
23
|
+
if (idx > cellListLength) break;
|
|
24
|
+
ptId0 = cellPtsIds[0];
|
|
25
|
+
ptId1 = cellPtsIds[idx + 1];
|
|
26
|
+
ptId2 = cellPtsIds[idx + 2];
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
case CellType.VTK_TRIANGLE_STRIP:
|
|
31
|
+
{
|
|
32
|
+
// eslint-disable-next-line no-bitwise
|
|
33
|
+
var idx1 = idx + 1 + (idx & 1); // eslint-disable-next-line no-bitwise
|
|
34
|
+
|
|
35
|
+
var idx2 = idx + 2 - (idx & 1);
|
|
36
|
+
if (idx1 > cellListLength || idx2 > cellListLength) break;
|
|
37
|
+
ptId0 = cellPtsIds[idx];
|
|
38
|
+
ptId1 = cellPtsIds[idx1];
|
|
39
|
+
ptId2 = cellPtsIds[idx2];
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
default:
|
|
44
|
+
ptId0 = -1;
|
|
45
|
+
ptId1 = -1;
|
|
46
|
+
ptId2 = -1;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
ptId0: ptId0,
|
|
52
|
+
ptId1: ptId1,
|
|
53
|
+
ptId2: ptId2
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Concatenate second typed array to the first typed array.
|
|
58
|
+
* @param {TypedArray} first
|
|
59
|
+
* @param {TypedArray} second Must be of the same type as first
|
|
60
|
+
* @return {TypedArray}
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
function pushArray(first, second) {
|
|
64
|
+
var firstLength = first.length;
|
|
65
|
+
var result = new first.constructor(firstLength + second.length);
|
|
66
|
+
result.set(first);
|
|
67
|
+
result.set(second, firstLength);
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Load an obj with point's colors
|
|
72
|
+
*
|
|
73
|
+
* @param {string} url path to the OBJ file
|
|
74
|
+
* @return Promise
|
|
75
|
+
* ---> success : Return vtkPolyData
|
|
76
|
+
* ---> failed : Error message
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
function loadOBJ(url) {
|
|
80
|
+
return new Promise(function (resolve, reject) {
|
|
81
|
+
var reader = vtkOBJReader.newInstance();
|
|
82
|
+
reader.setUrl(url).then(function () {
|
|
83
|
+
var data = reader.getOutputData();
|
|
84
|
+
resolve(data);
|
|
85
|
+
}, function () {
|
|
86
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
87
|
+
reject('Error when loading ', url);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { getCellTriangles, loadOBJ, pushArray };
|