@kitware/vtk.js 25.10.0 → 26.0.0-beta.2
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/CellArray.d.ts +0 -6
- package/Common/Core/CellArray.js +21 -12
- package/Common/Core/ClassHierarchy.js +11 -6
- package/Common/Core/DataArray.d.ts +20 -0
- package/Common/Core/DataArray.js +21 -4
- package/Proxy/Core/ViewProxy.js +17 -9
- package/Rendering/Core/ColorTransferFunction.d.ts +0 -20
- package/Rendering/Core/ColorTransferFunction.js +0 -63
- package/Rendering/Core/Prop3D.js +1 -6
- package/Rendering/Core/RenderWindow.js +9 -6
- package/Rendering/Core/VolumeProperty.js +2 -3
- package/Rendering/Misc/CanvasView.js +6 -5
- package/Rendering/Misc/GenericRenderWindow.js +12 -7
- package/Rendering/OpenGL/Actor.js +4 -4
- package/Rendering/OpenGL/Actor2D.js +4 -4
- package/Rendering/OpenGL/Camera.js +7 -4
- package/Rendering/OpenGL/CubeAxesActor.js +7 -5
- package/Rendering/OpenGL/ForwardPass.js +1 -1
- package/Rendering/OpenGL/Glyph3DMapper.js +4 -4
- package/Rendering/OpenGL/ImageMapper.js +9 -5
- package/Rendering/OpenGL/ImageSlice.js +3 -3
- package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +9 -5
- package/Rendering/OpenGL/PolyDataMapper.js +27 -21
- package/Rendering/OpenGL/PolyDataMapper2D.js +17 -10
- package/Rendering/OpenGL/ScalarBarActor.js +6 -4
- package/Rendering/OpenGL/Skybox.js +10 -6
- package/Rendering/OpenGL/Texture.js +6 -5
- package/Rendering/OpenGL/Volume.js +2 -2
- package/Rendering/OpenGL/VolumeMapper.js +11 -11
- package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
- package/Rendering/SceneGraph/RenderPass.js +3 -2
- package/Rendering/WebGPU/ForwardPass.js +1 -1
- package/Rendering/WebGPU/HardwareSelectionPass.js +1 -1
- package/Rendering/WebGPU/HardwareSelector.js +14 -13
- package/Rendering/WebGPU/OpaquePass.js +1 -1
- package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +1 -1
- package/Rendering/WebGPU/VolumePass.js +1 -1
- package/Utilities/config/rules-tests.js +28 -0
- package/Widgets/Core/AbstractWidgetFactory.js +1 -0
- package/Widgets/Core/StateBuilder/color3Mixin.js +22 -0
- package/Widgets/Core/StateBuilder/colorMixin.js +7 -0
- package/Widgets/Core/StateBuilder.js +2 -0
- package/Widgets/Core/WidgetManager.js +21 -256
- package/Widgets/Representations/ArrowHandleRepresentation.js +28 -110
- package/Widgets/Representations/CircleContextRepresentation.js +43 -165
- package/Widgets/Representations/ContextRepresentation.js +0 -3
- package/Widgets/Representations/ConvexFaceContextRepresentation.js +11 -11
- package/Widgets/Representations/CroppingOutlineRepresentation.js +5 -12
- package/Widgets/Representations/CubeHandleRepresentation.js +15 -104
- package/Widgets/Representations/GlyphRepresentation.js +320 -0
- package/Widgets/Representations/HandleRepresentation.js +0 -5
- package/Widgets/Representations/ImplicitPlaneRepresentation.js +68 -49
- package/Widgets/Representations/LineHandleRepresentation.js +116 -0
- package/Widgets/Representations/PolyLineRepresentation.js +52 -49
- package/Widgets/Representations/RectangleContextRepresentation.js +16 -21
- package/Widgets/Representations/SphereContextRepresentation.js +30 -109
- package/Widgets/Representations/SphereHandleRepresentation.js +13 -110
- package/Widgets/Representations/SplineContextRepresentation.js +53 -36
- package/Widgets/Representations/WidgetRepresentation.d.ts +52 -1
- package/Widgets/Representations/WidgetRepresentation.js +140 -78
- package/Widgets/Representations.js +6 -0
- package/Widgets/Widgets3D/AngleWidget.js +1 -4
- package/Widgets/Widgets3D/EllipseWidget/state.js +1 -1
- package/Widgets/Widgets3D/EllipseWidget.js +0 -7
- package/Widgets/Widgets3D/LabelWidget/behavior.js +0 -7
- package/Widgets/Widgets3D/LabelWidget.js +1 -18
- package/Widgets/Widgets3D/LineWidget/behavior.js +0 -44
- package/Widgets/Widgets3D/LineWidget.js +0 -11
- package/Widgets/Widgets3D/PolyLineWidget.js +0 -10
- package/Widgets/Widgets3D/RectangleWidget.js +0 -7
- package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +15 -3
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +93 -36
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +75 -82
- package/Widgets/Widgets3D/ResliceCursorWidget/state.js +49 -170
- package/Widgets/Widgets3D/ResliceCursorWidget.js +61 -23
- package/Widgets/Widgets3D/ShapeWidget.js +1 -1
- package/index.d.ts +0 -1
- package/macros.d.ts +3 -5
- package/macros.js +4 -35
- package/package.json +3 -2
- package/Widgets/Core/WidgetManager/vdom.js +0 -172
- package/Widgets/Representations/ResliceCursorContextRepresentation/Constants.js +0 -12
- package/Widgets/Representations/ResliceCursorContextRepresentation.d.ts +0 -54
- package/Widgets/Representations/ResliceCursorContextRepresentation.js +0 -357
- package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +0 -28
- package/Widgets/SVG/SVGLandmarkRepresentation.js +0 -179
- package/Widgets/SVG/SVGRepresentation.js +0 -163
- package/_vendor/available-typed-arrays/index.js_commonjs-proxy.js +0 -1
- package/_vendor/call-bind/callBound.js_commonjs-proxy.js +0 -1
- package/_vendor/call-bind/index.js_commonjs-module.js +0 -3
- package/_vendor/call-bind/index.js_commonjs-proxy.js +0 -1
- package/_vendor/deep-equal/node_modules/isarray/index.js_commonjs-proxy.js +0 -1
- package/_vendor/define-properties/index.js_commonjs-proxy.js +0 -1
- package/_vendor/es-abstract/helpers/getOwnPropertyDescriptor.js_commonjs-proxy.js +0 -1
- package/_vendor/es-get-iterator/index.js_commonjs-module.js +0 -3
- package/_vendor/es-get-iterator/index.js_commonjs-proxy.js +0 -1
- package/_vendor/es-get-iterator/node_modules/isarray/index.js_commonjs-proxy.js +0 -1
- package/_vendor/foreach/index.js_commonjs-proxy.js +0 -1
- package/_vendor/function-bind/implementation.js_commonjs-proxy.js +0 -1
- package/_vendor/function-bind/index.js_commonjs-proxy.js +0 -1
- package/_vendor/get-intrinsic/index.js_commonjs-proxy.js +0 -1
- package/_vendor/has/src/index.js_commonjs-proxy.js +0 -1
- package/_vendor/has-bigints/index.js_commonjs-proxy.js +0 -1
- package/_vendor/has-symbols/index.js_commonjs-proxy.js +0 -1
- package/_vendor/has-symbols/shams.js_commonjs-proxy.js +0 -1
- package/_vendor/has-tostringtag/shams.js_commonjs-proxy.js +0 -1
- package/_vendor/is-arguments/index.js_commonjs-proxy.js +0 -1
- package/_vendor/is-bigint/index.js_commonjs-module.js +0 -3
- package/_vendor/is-bigint/index.js_commonjs-proxy.js +0 -1
- package/_vendor/is-boolean-object/index.js_commonjs-proxy.js +0 -1
- package/_vendor/is-date-object/index.js_commonjs-proxy.js +0 -1
- package/_vendor/is-map/index.js_commonjs-proxy.js +0 -1
- package/_vendor/is-number-object/index.js_commonjs-proxy.js +0 -1
- package/_vendor/is-regex/index.js_commonjs-proxy.js +0 -1
- package/_vendor/is-set/index.js_commonjs-proxy.js +0 -1
- package/_vendor/is-string/index.js_commonjs-proxy.js +0 -1
- package/_vendor/is-symbol/index.js_commonjs-module.js +0 -3
- package/_vendor/is-symbol/index.js_commonjs-proxy.js +0 -1
- package/_vendor/is-typed-array/index.js_commonjs-proxy.js +0 -1
- package/_vendor/is-weakmap/index.js_commonjs-proxy.js +0 -1
- package/_vendor/is-weakset/index.js_commonjs-proxy.js +0 -1
- package/_vendor/object-inspect/index.js_commonjs-proxy.js +0 -1
- package/_vendor/object-is/implementation.js_commonjs-proxy.js +0 -1
- package/_vendor/object-is/index.js_commonjs-proxy.js +0 -1
- package/_vendor/object-is/polyfill.js_commonjs-proxy.js +0 -1
- package/_vendor/object-is/shim.js_commonjs-proxy.js +0 -1
- package/_vendor/object-keys/implementation.js_commonjs-proxy.js +0 -1
- package/_vendor/object-keys/index.js_commonjs-proxy.js +0 -1
- package/_vendor/object-keys/isArguments.js_commonjs-proxy.js +0 -1
- package/_vendor/object.assign/implementation.js_commonjs-proxy.js +0 -1
- package/_vendor/object.assign/index.js_commonjs-proxy.js +0 -1
- package/_vendor/object.assign/polyfill.js_commonjs-proxy.js +0 -1
- package/_vendor/object.assign/shim.js_commonjs-proxy.js +0 -2
- package/_vendor/regexp.prototype.flags/implementation.js_commonjs-proxy.js +0 -1
- package/_vendor/regexp.prototype.flags/index.js_commonjs-proxy.js +0 -1
- package/_vendor/regexp.prototype.flags/polyfill.js_commonjs-proxy.js +0 -1
- package/_vendor/regexp.prototype.flags/shim.js_commonjs-proxy.js +0 -1
- package/_vendor/side-channel/index.js_commonjs-proxy.js +0 -1
- package/_vendor/which-boxed-primitive/index.js_commonjs-proxy.js +0 -5
- package/_vendor/which-collection/index.js_commonjs-proxy.js +0 -4
- package/_vendor/which-typed-array/index.js_commonjs-proxy.js +0 -1
- package/_virtual/_node-resolve_empty.js_commonjs-proxy.js +0 -6
- package/_virtual/commonjsHelpers.js +0 -18
- package/_virtual/node-resolve_empty.js +0 -8
- package/_virtual/polyfill-node.global.js +0 -5
- package/_virtual/polyfill-node.process.js +0 -225
- package/vendor/available-typed-arrays/index.js +0 -29
- package/vendor/call-bind/callBound.js +0 -19
- package/vendor/call-bind/index.js +0 -52
- package/vendor/deep-equal/index.js +0 -379
- package/vendor/deep-equal/node_modules/isarray/index.js +0 -7
- package/vendor/define-properties/index.js +0 -60
- package/vendor/es-abstract/helpers/getOwnPropertyDescriptor.js +0 -17
- package/vendor/es-get-iterator/index.js +0 -217
- package/vendor/es-get-iterator/node_modules/isarray/index.js +0 -7
- package/vendor/foreach/index.js +0 -22
- package/vendor/function-bind/implementation.js +0 -52
- package/vendor/function-bind/index.js +0 -7
- package/vendor/get-intrinsic/index.js +0 -334
- package/vendor/has/src/index.js +0 -7
- package/vendor/has-bigints/index.js +0 -12
- package/vendor/has-symbols/index.js +0 -15
- package/vendor/has-symbols/shams.js +0 -42
- package/vendor/has-tostringtag/shams.js +0 -9
- package/vendor/is-arguments/index.js +0 -36
- package/vendor/is-bigint/index.js +0 -39
- package/vendor/is-boolean-object/index.js +0 -29
- package/vendor/is-date-object/index.js +0 -22
- package/vendor/is-map/index.js +0 -42
- package/vendor/is-number-object/index.js +0 -26
- package/vendor/is-regex/index.js +0 -61
- package/vendor/is-set/index.js +0 -42
- package/vendor/is-string/index.js +0 -26
- package/vendor/is-symbol/index.js +0 -36
- package/vendor/is-typed-array/index.js +0 -67
- package/vendor/is-weakmap/index.js +0 -42
- package/vendor/is-weakset/index.js +0 -42
- package/vendor/object-inspect/index.js +0 -515
- package/vendor/object-is/implementation.js +0 -18
- package/vendor/object-is/index.js +0 -25
- package/vendor/object-is/polyfill.js +0 -9
- package/vendor/object-is/shim.js +0 -17
- package/vendor/object-keys/implementation.js +0 -124
- package/vendor/object-keys/index.js +0 -35
- package/vendor/object-keys/isArguments.js +0 -17
- package/vendor/object.assign/implementation.js +0 -46
- package/vendor/object.assign/index.js +0 -29
- package/vendor/object.assign/polyfill.js +0 -57
- package/vendor/object.assign/shim.js +0 -17
- package/vendor/regexp.prototype.flags/implementation.js +0 -30
- package/vendor/regexp.prototype.flags/index.js +0 -25
- package/vendor/regexp.prototype.flags/polyfill.js +0 -23
- package/vendor/regexp.prototype.flags/shim.js +0 -29
- package/vendor/side-channel/index.js +0 -128
- package/vendor/which-boxed-primitive/index.js +0 -38
- package/vendor/which-collection/index.js +0 -29
- package/vendor/which-typed-array/index.js +0 -63
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import macro from '../../macros.js';
|
|
3
|
+
import vtkActor from '../../Rendering/Core/Actor.js';
|
|
4
|
+
import vtkGlyphRepresentation from './GlyphRepresentation.js';
|
|
5
|
+
import vtkPixelSpaceCallbackMapper from '../../Rendering/Core/PixelSpaceCallbackMapper.js';
|
|
6
|
+
import vtkCylinderSource from '../../Filters/Sources/CylinderSource.js';
|
|
7
|
+
import { allocateArray } from './WidgetRepresentation.js';
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
var INFINITE_RATIO = 100000; // ----------------------------------------------------------------------------
|
|
13
|
+
// vtkLineHandleRepresentation methods
|
|
14
|
+
// ----------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
function vtkLineHandleRepresentation(publicAPI, model) {
|
|
17
|
+
// Set our className
|
|
18
|
+
model.classHierarchy.push('vtkLineHandleRepresentation'); // --------------------------------------------------------------------------
|
|
19
|
+
// Generic rendering pipeline
|
|
20
|
+
// --------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* displayActors and displayMappers are used to render objects in HTML, allowing objects
|
|
24
|
+
* to be 'rendered' internally in a VTK scene without being visible on the final output
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
model.displayMapper = vtkPixelSpaceCallbackMapper.newInstance();
|
|
28
|
+
model.displayActor = vtkActor.newInstance({
|
|
29
|
+
parentProp: publicAPI
|
|
30
|
+
}); // model.displayActor.getProperty().setOpacity(0); // don't show in 3D
|
|
31
|
+
|
|
32
|
+
model.displayActor.setMapper(model.displayMapper);
|
|
33
|
+
model.displayMapper.setInputConnection(publicAPI.getOutputPort());
|
|
34
|
+
publicAPI.addActor(model.displayActor);
|
|
35
|
+
model.alwaysVisibleActors = [model.displayActor]; // --------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
publicAPI.setGlyphResolution = macro.chain(publicAPI.setGlyphResolution, model._pipeline.glyph.setThetaResolution, model._pipeline.glyph.setPhiResolution); // --------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
function callbackProxy(coords) {
|
|
40
|
+
if (model.displayCallback) {
|
|
41
|
+
var filteredList = [];
|
|
42
|
+
var states = publicAPI.getRepresentationStates();
|
|
43
|
+
|
|
44
|
+
for (var i = 0; i < states.length; i++) {
|
|
45
|
+
if (states[i].getActive()) {
|
|
46
|
+
filteredList.push(coords[i]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (filteredList.length) {
|
|
51
|
+
model.displayCallback(filteredList);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
model.displayCallback();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
publicAPI.setDisplayCallback = function (callback) {
|
|
60
|
+
model.displayCallback = callback;
|
|
61
|
+
model.displayMapper.setCallback(callback ? callbackProxy : null);
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Overwrite scale3 to optionally make lines infinite
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
var superScale3 = publicAPI.getScale3();
|
|
69
|
+
publicAPI.setScale3(function (polyData, states) {
|
|
70
|
+
superScale3(polyData, states);
|
|
71
|
+
|
|
72
|
+
if (model.infiniteLine) {
|
|
73
|
+
var scales = allocateArray(polyData, 'scale', states.length, 'Float32Array', 3).getData();
|
|
74
|
+
|
|
75
|
+
for (var i = 0; i < states.length; ++i) {
|
|
76
|
+
scales[3 * i + 2] = INFINITE_RATIO;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
} // ----------------------------------------------------------------------------
|
|
81
|
+
// Object factory
|
|
82
|
+
// ----------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
function defaultValues(initialValues) {
|
|
86
|
+
var _initialValues$glyphR;
|
|
87
|
+
|
|
88
|
+
return _objectSpread({
|
|
89
|
+
infiniteLine: true,
|
|
90
|
+
glyphResolution: 4,
|
|
91
|
+
_pipeline: {
|
|
92
|
+
glyph: vtkCylinderSource.newInstance({
|
|
93
|
+
resolution: (_initialValues$glyphR = initialValues.glyphResolution) !== null && _initialValues$glyphR !== void 0 ? _initialValues$glyphR : 4,
|
|
94
|
+
direction: [0, 0, 1]
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
}, initialValues);
|
|
98
|
+
} // ----------------------------------------------------------------------------
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
function extend(publicAPI, model) {
|
|
102
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
103
|
+
vtkGlyphRepresentation.extend(publicAPI, model, defaultValues(initialValues));
|
|
104
|
+
macro.setGet(publicAPI, model, ['infiniteLine', 'glyphResolution']); // Object specific methods
|
|
105
|
+
|
|
106
|
+
vtkLineHandleRepresentation(publicAPI, model);
|
|
107
|
+
} // ----------------------------------------------------------------------------
|
|
108
|
+
|
|
109
|
+
var newInstance = macro.newInstance(extend, 'vtkLineHandleRepresentation'); // ----------------------------------------------------------------------------
|
|
110
|
+
|
|
111
|
+
var vtkLineHandleRepresentation$1 = {
|
|
112
|
+
newInstance: newInstance,
|
|
113
|
+
extend: extend
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export { vtkLineHandleRepresentation$1 as default, extend, newInstance };
|
|
@@ -4,10 +4,10 @@ import vtkActor from '../../Rendering/Core/Actor.js';
|
|
|
4
4
|
import vtkMapper from '../../Rendering/Core/Mapper.js';
|
|
5
5
|
import { C as areEquals } from '../../Common/Core/Math/index.js';
|
|
6
6
|
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
7
|
-
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
8
7
|
import vtkTubeFilter from '../../Filters/General/TubeFilter.js';
|
|
9
|
-
import vtkWidgetRepresentation from './WidgetRepresentation.js';
|
|
8
|
+
import vtkWidgetRepresentation, { allocateArray, getPixelWorldHeightAtCoord } from './WidgetRepresentation.js';
|
|
10
9
|
import { RenderingTypes } from '../Core/WidgetManager/Constants.js';
|
|
10
|
+
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
11
11
|
|
|
12
12
|
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; }
|
|
13
13
|
|
|
@@ -24,36 +24,35 @@ function vtkPolyLineRepresentation(publicAPI, model) {
|
|
|
24
24
|
// --------------------------------------------------------------------------
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
var internalPolyData = vtkPolyData.newInstance({
|
|
28
28
|
mtime: 0
|
|
29
29
|
});
|
|
30
|
-
model.cells = [];
|
|
31
30
|
|
|
32
|
-
function allocateSize(size) {
|
|
33
|
-
var closePolyLine = arguments.length >
|
|
31
|
+
function allocateSize(polyData, size) {
|
|
32
|
+
var closePolyLine = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
33
|
+
var points = null;
|
|
34
34
|
|
|
35
35
|
if (size < 2) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
// FIXME: Why 1 point and not 0 ?
|
|
37
|
+
points = allocateArray(polyData, 'points', 1).getData();
|
|
38
|
+
points.set([0, 0, 0]);
|
|
39
|
+
allocateArray(polyData, 'lines', 0).getData();
|
|
40
|
+
} else if (!polyData.getPoints() || polyData.getPoints().length !== size * 3) {
|
|
41
|
+
points = allocateArray(polyData, 'points', size).getData();
|
|
42
|
+
var cellSize = size + 1 + (closePolyLine ? 1 : 0);
|
|
43
|
+
var cells = allocateArray(polyData, 'lines', cellSize).getData();
|
|
44
|
+
cells[0] = cells.length - 1;
|
|
45
|
+
|
|
46
|
+
for (var i = 1; i < cells.length; i++) {
|
|
47
|
+
cells[i] = i - 1;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
if (closePolyLine) {
|
|
48
|
-
|
|
49
|
-
console.log('closePolyLine', closePolyLine, model.cells);
|
|
51
|
+
cells[cells.length - 1] = 0;
|
|
50
52
|
}
|
|
51
|
-
|
|
52
|
-
model.internalPolyData.getPoints().setData(model.points, 3);
|
|
53
|
-
model.internalPolyData.getLines().setData(model.cells);
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
return
|
|
55
|
+
return points;
|
|
57
56
|
}
|
|
58
57
|
/**
|
|
59
58
|
* Change the line/tube thickness.
|
|
@@ -64,34 +63,39 @@ function vtkPolyLineRepresentation(publicAPI, model) {
|
|
|
64
63
|
function applyLineThickness(lineThickness) {
|
|
65
64
|
var scaledLineThickness = lineThickness;
|
|
66
65
|
|
|
67
|
-
if (publicAPI.getScaleInPixels()) {
|
|
68
|
-
var center = vtkBoundingBox.getCenter(
|
|
69
|
-
scaledLineThickness *=
|
|
66
|
+
if (publicAPI.getScaleInPixels() && internalPolyData) {
|
|
67
|
+
var center = vtkBoundingBox.getCenter(internalPolyData.getBounds());
|
|
68
|
+
scaledLineThickness *= getPixelWorldHeightAtCoord(center, model.displayScaleParams);
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
model.tubes.setRadius(scaledLineThickness);
|
|
71
|
+
model._pipelines.tubes.filter.setRadius(scaledLineThickness);
|
|
73
72
|
} // --------------------------------------------------------------------------
|
|
74
73
|
// Generic rendering pipeline
|
|
75
74
|
// --------------------------------------------------------------------------
|
|
76
75
|
|
|
77
76
|
|
|
78
|
-
model.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
model._pipelines = {
|
|
78
|
+
tubes: {
|
|
79
|
+
source: publicAPI,
|
|
80
|
+
filter: vtkTubeFilter.newInstance({
|
|
81
|
+
radius: model.lineThickness,
|
|
82
|
+
numberOfSides: 12,
|
|
83
|
+
capping: false
|
|
84
|
+
}),
|
|
85
|
+
mapper: vtkMapper.newInstance(),
|
|
86
|
+
actor: vtkActor.newInstance({
|
|
87
|
+
parentProp: publicAPI
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
vtkWidgetRepresentation.connectPipeline(model._pipelines.tubes);
|
|
92
|
+
publicAPI.addActor(model._pipelines.tubes.actor); // --------------------------------------------------------------------------
|
|
92
93
|
|
|
93
94
|
publicAPI.requestData = function (inData, outData) {
|
|
94
|
-
var
|
|
95
|
+
var _state$getLineThickne, _state$getLineThickne2;
|
|
96
|
+
|
|
97
|
+
var state = inData[0];
|
|
98
|
+
outData[0] = internalPolyData; // Remove invalid and coincident points for tube filter.
|
|
95
99
|
|
|
96
100
|
var list = publicAPI.getRepresentationStates(state).reduce(function (subStates, subState) {
|
|
97
101
|
var subStateOrigin = subState.getOrigin && subState.getOrigin() ? subState.getOrigin() : null;
|
|
@@ -105,7 +109,7 @@ function vtkPolyLineRepresentation(publicAPI, model) {
|
|
|
105
109
|
return subStates;
|
|
106
110
|
}, []);
|
|
107
111
|
var size = list.length;
|
|
108
|
-
var points = allocateSize(size, model.closePolyLine && size > 2);
|
|
112
|
+
var points = allocateSize(outData[0], size, model.closePolyLine && size > 2);
|
|
109
113
|
|
|
110
114
|
if (points) {
|
|
111
115
|
for (var i = 0; i < size; i++) {
|
|
@@ -116,10 +120,9 @@ function vtkPolyLineRepresentation(publicAPI, model) {
|
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
122
|
|
|
119
|
-
|
|
120
|
-
var lineThickness = state.getLineThickness ?
|
|
121
|
-
applyLineThickness(lineThickness
|
|
122
|
-
outData[0] = model.internalPolyData;
|
|
123
|
+
outData[0].modified();
|
|
124
|
+
var lineThickness = (_state$getLineThickne = (_state$getLineThickne2 = state.getLineThickness) === null || _state$getLineThickne2 === void 0 ? void 0 : _state$getLineThickne2.call(state)) !== null && _state$getLineThickne !== void 0 ? _state$getLineThickne : model.lineThickness;
|
|
125
|
+
applyLineThickness(lineThickness);
|
|
123
126
|
};
|
|
124
127
|
/**
|
|
125
128
|
* When mousing over the line, if behavior != CONTEXT,
|
|
@@ -135,18 +138,18 @@ function vtkPolyLineRepresentation(publicAPI, model) {
|
|
|
135
138
|
};
|
|
136
139
|
|
|
137
140
|
publicAPI.updateActorVisibility = function (renderingType, ctxVisible, hVisible) {
|
|
141
|
+
var _state$getLineThickne3, _state$getLineThickne4;
|
|
142
|
+
|
|
138
143
|
var state = model.inputData[0]; // Make lines/tubes thicker for picking
|
|
139
144
|
|
|
140
|
-
var lineThickness = state.getLineThickness ?
|
|
141
|
-
lineThickness = lineThickness || model.lineThickness;
|
|
145
|
+
var lineThickness = (_state$getLineThickne3 = (_state$getLineThickne4 = state.getLineThickness) === null || _state$getLineThickne4 === void 0 ? void 0 : _state$getLineThickne4.call(state)) !== null && _state$getLineThickne3 !== void 0 ? _state$getLineThickne3 : model.lineThickness;
|
|
142
146
|
|
|
143
147
|
if (renderingType === RenderingTypes.PICKING_BUFFER) {
|
|
144
148
|
lineThickness = Math.max(4, lineThickness);
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
applyLineThickness(lineThickness);
|
|
148
|
-
|
|
149
|
-
return superClass.updateActorVisibility(renderingType, ctxVisible && isValid, hVisible && isValid);
|
|
152
|
+
return superClass.updateActorVisibility(renderingType, ctxVisible, hVisible);
|
|
150
153
|
};
|
|
151
154
|
} // ----------------------------------------------------------------------------
|
|
152
155
|
// Object factory
|
|
@@ -3,6 +3,7 @@ import vtkActor from '../../Rendering/Core/Actor.js';
|
|
|
3
3
|
import vtkContextRepresentation from './ContextRepresentation.js';
|
|
4
4
|
import vtkMapper from '../../Rendering/Core/Mapper.js';
|
|
5
5
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
6
|
+
import { allocateArray } from './WidgetRepresentation.js';
|
|
6
7
|
import { vec3 } from 'gl-matrix';
|
|
7
8
|
|
|
8
9
|
// vtkRectangleContextRepresentation methods
|
|
@@ -14,6 +15,9 @@ function vtkRectangleContextRepresentation(publicAPI, model) {
|
|
|
14
15
|
// Generic rendering pipeline
|
|
15
16
|
// --------------------------------------------------------------------------
|
|
16
17
|
|
|
18
|
+
model.internalPolyData = vtkPolyData.newInstance({
|
|
19
|
+
mtime: 0
|
|
20
|
+
});
|
|
17
21
|
model.mapper = vtkMapper.newInstance();
|
|
18
22
|
model.actor = vtkActor.newInstance({
|
|
19
23
|
parentProp: publicAPI
|
|
@@ -24,16 +28,6 @@ function vtkRectangleContextRepresentation(publicAPI, model) {
|
|
|
24
28
|
model.actor.getProperty().setColor(0, 1, 0);
|
|
25
29
|
publicAPI.addActor(model.actor); // --------------------------------------------------------------------------
|
|
26
30
|
|
|
27
|
-
publicAPI.setDrawBorder = function (draw) {
|
|
28
|
-
model.drawBorder = draw;
|
|
29
|
-
}; // --------------------------------------------------------------------------
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
publicAPI.setDrawFace = function (draw) {
|
|
33
|
-
model.drawFace = draw;
|
|
34
|
-
}; // --------------------------------------------------------------------------
|
|
35
|
-
|
|
36
|
-
|
|
37
31
|
publicAPI.setOpacity = function (opacity) {
|
|
38
32
|
model.actor.getProperty().setOpacity(opacity);
|
|
39
33
|
}; // --------------------------------------------------------------------------
|
|
@@ -44,18 +38,18 @@ function vtkRectangleContextRepresentation(publicAPI, model) {
|
|
|
44
38
|
return;
|
|
45
39
|
}
|
|
46
40
|
|
|
47
|
-
var list = publicAPI.getRepresentationStates(inData[0]);
|
|
41
|
+
var list = publicAPI.getRepresentationStates(inData[0]); // FIXME: support list > 1.
|
|
42
|
+
|
|
48
43
|
var state = list[0];
|
|
49
|
-
var dataset = vtkPolyData.newInstance();
|
|
50
44
|
|
|
51
|
-
if (state.getVisible() && state.getOrigin()) {
|
|
45
|
+
if (state !== null && state !== void 0 && state.getVisible() && state !== null && state !== void 0 && state.getOrigin()) {
|
|
52
46
|
var point1 = state.getOrigin();
|
|
53
47
|
var point2 = state.getCorner();
|
|
54
48
|
var diagonal = [0, 0, 0];
|
|
55
49
|
vec3.subtract(diagonal, point2, point1);
|
|
56
50
|
var up = state.getUp();
|
|
57
51
|
var upComponent = vec3.dot(diagonal, up);
|
|
58
|
-
var points =
|
|
52
|
+
var points = allocateArray(model.internalPolyData, 'points', 4).getData();
|
|
59
53
|
points[0] = point1[0];
|
|
60
54
|
points[1] = point1[1];
|
|
61
55
|
points[2] = point1[2];
|
|
@@ -68,24 +62,24 @@ function vtkRectangleContextRepresentation(publicAPI, model) {
|
|
|
68
62
|
points[9] = point2[0] - upComponent * up[0];
|
|
69
63
|
points[10] = point2[1] - upComponent * up[1];
|
|
70
64
|
points[11] = point2[2] - upComponent * up[2];
|
|
71
|
-
dataset.getPoints().setData(points, 3);
|
|
72
65
|
|
|
73
66
|
if (model.drawFace) {
|
|
74
67
|
var polys = new Uint32Array([4, 0, 1, 2, 3]);
|
|
75
|
-
|
|
68
|
+
model.internalPolyData.getPolys().setData(polys, 1);
|
|
76
69
|
}
|
|
77
70
|
|
|
78
71
|
if (model.drawBorder) {
|
|
79
72
|
var line = new Uint32Array([5, 0, 1, 2, 3, 0]);
|
|
80
|
-
|
|
73
|
+
model.internalPolyData.getLines().setData(line, 1);
|
|
81
74
|
}
|
|
82
75
|
} else {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
model.internalPolyData.getPoints().setData([], 0);
|
|
77
|
+
model.internalPolyData.getPolys().setData([], 0);
|
|
78
|
+
model.internalPolyData.getLines().setData([], 0);
|
|
86
79
|
}
|
|
87
80
|
|
|
88
|
-
|
|
81
|
+
model.internalPolyData.modified();
|
|
82
|
+
outData[0] = model.internalPolyData;
|
|
89
83
|
};
|
|
90
84
|
|
|
91
85
|
publicAPI.getSelectedState = function (prop, compositeID) {
|
|
@@ -106,6 +100,7 @@ function extend(publicAPI, model) {
|
|
|
106
100
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
107
101
|
vtkContextRepresentation.extend(publicAPI, model, initialValues);
|
|
108
102
|
macro.setGetArray(publicAPI, model, ['color'], 1);
|
|
103
|
+
macro.setGet(publicAPI, model, ['drawBorder', 'drawFace']);
|
|
109
104
|
macro.get(publicAPI, model, ['mapper', 'actor']); // Object specific methods
|
|
110
105
|
|
|
111
106
|
vtkRectangleContextRepresentation(publicAPI, model);
|
|
@@ -1,133 +1,54 @@
|
|
|
1
|
-
import
|
|
2
|
-
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
3
|
-
import vtkSphereSource from '../../Filters/Sources/SphereSource.js';
|
|
4
|
-
import vtkActor from '../../Rendering/Core/Actor.js';
|
|
5
|
-
import vtkGlyph3DMapper from '../../Rendering/Core/Glyph3DMapper.js';
|
|
6
|
-
import { ScalarMode } from '../../Rendering/Core/Mapper/Constants.js';
|
|
7
|
-
import vtkContextRepresentation from './ContextRepresentation.js';
|
|
8
|
-
import vtkWidgetRepresentation from './WidgetRepresentation.js';
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
9
2
|
import macro from '../../macros.js';
|
|
3
|
+
import vtkSphereSource from '../../Filters/Sources/SphereSource.js';
|
|
4
|
+
import vtkGlyphRepresentation from './GlyphRepresentation.js';
|
|
5
|
+
import { Behavior } from './WidgetRepresentation/Constants.js';
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
10
|
|
|
11
11
|
function vtkSphereContextRepresentation(publicAPI, model) {
|
|
12
12
|
model.classHierarchy.push('vtkSphereContextRepresentation');
|
|
13
|
-
|
|
14
|
-
mtime: 0
|
|
15
|
-
});
|
|
16
|
-
model.internalArrays = {
|
|
17
|
-
points: model.internalPolyData.getPoints(),
|
|
18
|
-
scale: vtkDataArray.newInstance({
|
|
19
|
-
name: 'scale',
|
|
20
|
-
numberOfComponents: 3,
|
|
21
|
-
empty: true
|
|
22
|
-
}),
|
|
23
|
-
color: vtkDataArray.newInstance({
|
|
24
|
-
name: 'color',
|
|
25
|
-
numberOfComponents: 1,
|
|
26
|
-
empty: true
|
|
27
|
-
})
|
|
28
|
-
};
|
|
29
|
-
model.internalPolyData.getPointData().addArray(model.internalArrays.scale);
|
|
30
|
-
model.internalPolyData.getPointData().addArray(model.internalArrays.color);
|
|
31
|
-
model.pipelines = {
|
|
32
|
-
circle: {
|
|
33
|
-
source: publicAPI,
|
|
34
|
-
glyph: vtkSphereSource.newInstance({
|
|
35
|
-
phiResolution: model.glyphResolution,
|
|
36
|
-
thetaResolution: model.glyphResolution
|
|
37
|
-
}),
|
|
38
|
-
mapper: vtkGlyph3DMapper.newInstance({
|
|
39
|
-
scaleArray: 'scale',
|
|
40
|
-
scaleMode: vtkGlyph3DMapper.ScaleModes.SCALE_BY_MAGNITUDE,
|
|
41
|
-
colorByArrayName: 'color',
|
|
42
|
-
scalarMode: ScalarMode.USE_POINT_FIELD_DATA
|
|
43
|
-
}),
|
|
44
|
-
actor: vtkActor.newInstance({
|
|
45
|
-
pickable: false,
|
|
46
|
-
parentProp: publicAPI
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
model.pipelines.circle.actor.getProperty().setOpacity(0.2);
|
|
51
|
-
vtkWidgetRepresentation.connectPipeline(model.pipelines.circle);
|
|
52
|
-
publicAPI.addActor(model.pipelines.circle.actor);
|
|
53
|
-
publicAPI.setGlyphResolution = macro.chain(publicAPI.setGlyphResolution, function (r) {
|
|
54
|
-
return model.pipelines.circle.glyph.setResolution(r);
|
|
55
|
-
});
|
|
13
|
+
publicAPI.setGlyphResolution = macro.chain(publicAPI.setGlyphResolution, model._pipeline.glyph.setThetaResolution, model._pipeline.glyph.setPhiResolution);
|
|
56
14
|
|
|
57
15
|
publicAPI.setDrawBorder = function (draw) {
|
|
58
|
-
model.
|
|
16
|
+
model._pipeline.glyph.setLines(draw);
|
|
59
17
|
};
|
|
60
18
|
|
|
61
19
|
publicAPI.setDrawFace = function (draw) {
|
|
62
|
-
model.
|
|
20
|
+
model._pipeline.glyph.setFace(draw);
|
|
63
21
|
};
|
|
64
22
|
|
|
65
23
|
publicAPI.setOpacity = function (opacity) {
|
|
66
|
-
model.
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
var superGetRepresentationStates = publicAPI.getRepresentationStates;
|
|
70
|
-
|
|
71
|
-
publicAPI.getRepresentationStates = function () {
|
|
72
|
-
var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : model.inputData[0];
|
|
73
|
-
return superGetRepresentationStates(input).filter(function (state) {
|
|
74
|
-
var _state$getOrigin, _state$isVisible;
|
|
75
|
-
|
|
76
|
-
return ((_state$getOrigin = state.getOrigin) === null || _state$getOrigin === void 0 ? void 0 : _state$getOrigin.call(state)) && ((_state$isVisible = state.isVisible) === null || _state$isVisible === void 0 ? void 0 : _state$isVisible.call(state));
|
|
77
|
-
});
|
|
24
|
+
model._pipeline.actor.getProperty().setOpacity(opacity);
|
|
78
25
|
};
|
|
79
26
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
points = _model$internalArrays.points,
|
|
83
|
-
scale = _model$internalArrays.scale,
|
|
84
|
-
color = _model$internalArrays.color;
|
|
85
|
-
var list = publicAPI.getRepresentationStates(inData[0]);
|
|
86
|
-
var totalCount = list.length;
|
|
87
|
-
|
|
88
|
-
if (color.getNumberOfValues() !== totalCount) {
|
|
89
|
-
// Need to resize dataset
|
|
90
|
-
points.setData(new Float32Array(3 * totalCount));
|
|
91
|
-
scale.setData(new Float32Array(3 * totalCount));
|
|
92
|
-
color.setData(new Float32Array(totalCount));
|
|
93
|
-
}
|
|
27
|
+
model._pipeline.actor.getProperty().setOpacity(0.2);
|
|
28
|
+
}
|
|
94
29
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
scale: scale.getData(),
|
|
98
|
-
color: color.getData()
|
|
99
|
-
};
|
|
30
|
+
function defaultValues(initialValues) {
|
|
31
|
+
var _initialValues$glyphR, _initialValues$glyphR2;
|
|
100
32
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
33
|
+
return _objectSpread({
|
|
34
|
+
glyphResolution: 32,
|
|
35
|
+
drawBorder: false,
|
|
36
|
+
drawFace: true,
|
|
37
|
+
behavior: Behavior.CONTEXT,
|
|
38
|
+
_pipeline: {
|
|
39
|
+
glyph: vtkSphereSource.newInstance({
|
|
40
|
+
phiResolution: (_initialValues$glyphR = initialValues.glyphResolution) !== null && _initialValues$glyphR !== void 0 ? _initialValues$glyphR : 32,
|
|
41
|
+
thetaResolution: (_initialValues$glyphR2 = initialValues.glyphResolution) !== null && _initialValues$glyphR2 !== void 0 ? _initialValues$glyphR2 : 32
|
|
42
|
+
})
|
|
111
43
|
}
|
|
44
|
+
}, initialValues);
|
|
45
|
+
} // ----------------------------------------------------------------------------
|
|
112
46
|
|
|
113
|
-
model.internalPolyData.modified();
|
|
114
|
-
outData[0] = model.internalPolyData;
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
var DEFAULT_VALUES = {
|
|
119
|
-
glyphResolution: 32,
|
|
120
|
-
defaultScale: 1,
|
|
121
|
-
drawBorder: false,
|
|
122
|
-
drawFace: true
|
|
123
|
-
}; // ----------------------------------------------------------------------------
|
|
124
47
|
|
|
125
48
|
function extend(publicAPI, model) {
|
|
126
49
|
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
macro.setGet(publicAPI, model, ['glyphResolution', 'defaultScale']);
|
|
130
|
-
macro.get(publicAPI, model, ['glyph', 'mapper', 'actor']);
|
|
50
|
+
vtkGlyphRepresentation.extend(publicAPI, model, defaultValues(initialValues));
|
|
51
|
+
macro.setGet(publicAPI, model, ['glyphResolution']);
|
|
131
52
|
vtkSphereContextRepresentation(publicAPI, model);
|
|
132
53
|
} // ----------------------------------------------------------------------------
|
|
133
54
|
|