@kitware/vtk.js 34.7.0 → 34.8.0

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.
@@ -0,0 +1,244 @@
1
+ import { DesiredOutputPrecision } from './../../Common/DataModel/DataSetAttributes';
2
+ import { vtkAlgorithm, vtkObject } from './../../interfaces';
3
+ import { Vector3 } from './../../types';
4
+
5
+ /**
6
+ *
7
+ */
8
+ export interface IArcSourceInitialValues {
9
+ point1?: Vector3;
10
+ point2?: Vector3;
11
+ center?: Vector3;
12
+ normal?: Vector3;
13
+ polarVector?: Vector3;
14
+ angle?: number;
15
+ resolution?: number;
16
+ negative?: boolean;
17
+ useNormalAndAngle?: boolean;
18
+ outputPointsPrecision?: DesiredOutputPrecision;
19
+ }
20
+
21
+ type vtkArcSourceBase = vtkObject &
22
+ Omit<
23
+ vtkAlgorithm,
24
+ | 'getInputData'
25
+ | 'setInputData'
26
+ | 'setInputConnection'
27
+ | 'getInputConnection'
28
+ | 'addInputConnection'
29
+ | 'addInputData'
30
+ >;
31
+
32
+ export interface vtkArcSource extends vtkArcSourceBase {
33
+ /**
34
+ * Get the angle of the arc.
35
+ */
36
+ getAngle(): number;
37
+
38
+ /**
39
+ * Get the center of the arc.
40
+ */
41
+ getCenter(): Vector3;
42
+
43
+ /**
44
+ * Get the center of the arc by reference.
45
+ */
46
+ getCenterByReference(): Vector3;
47
+
48
+ /**
49
+ * Get the first point of the arc.
50
+ */
51
+ getPoint1(): Vector3;
52
+
53
+ /**
54
+ * Get the first point of the arc by reference.
55
+ */
56
+ getPoint1ByReference(): Vector3;
57
+
58
+ /**
59
+ * Get the second point of the arc.
60
+ */
61
+ getPoint2(): Vector3;
62
+
63
+ /**
64
+ * Get the second point of the arc by reference.
65
+ */
66
+ getPoint2ByReference(): Vector3;
67
+
68
+ /**
69
+ * Get the normal vector of the arc.
70
+ */
71
+ getNormal(): Vector3;
72
+
73
+ /**
74
+ * Get the normal vector of the arc by reference.
75
+ */
76
+ getNormalByReference(): Vector3;
77
+
78
+ /**
79
+ * Get the polar vector of the arc.
80
+ */
81
+ getPolarVector(): Vector3;
82
+
83
+ /**
84
+ * Get the polar vector of the arc by reference.
85
+ */
86
+ getPolarVectorByReference(): Vector3;
87
+
88
+ /**
89
+ * Get the resolution of the arc.
90
+ */
91
+ getResolution(): number;
92
+
93
+ /**
94
+ * Get the negative flag of the arc.
95
+ */
96
+ getNegative(): boolean;
97
+
98
+ /**
99
+ * Get the output points precision.
100
+ */
101
+ getOutputPointsPrecision(): DesiredOutputPrecision;
102
+
103
+ /**
104
+ * Get the use normal and angle flag.
105
+ */
106
+ getUseNormalAndAngle(): boolean;
107
+
108
+ /**
109
+ *
110
+ * @param inData
111
+ * @param outData
112
+ */
113
+ requestData(inData: any, outData: any): void;
114
+
115
+ /**
116
+ * Set the first point of the arc.
117
+ * @param {Vector3} point1 The first point's coordinates.
118
+ */
119
+ setPoint1(point1: Vector3): boolean;
120
+
121
+ /**
122
+ * Set the first point of the arc by reference.
123
+ * @param {Vector3} point1 The first point's coordinates.
124
+ */
125
+ setPoint1From(point1: Vector3): boolean;
126
+
127
+ /**
128
+ * Set the second point of the arc.
129
+ * @param {Vector3} point2 The second point's coordinates.
130
+ */
131
+ setPoint2(point2: Vector3): boolean;
132
+
133
+ /**
134
+ * Set the second point of the arc by reference.
135
+ * @param {Vector3} point2 The second point's coordinates.
136
+ */
137
+ setPoint2From(point2: Vector3): boolean;
138
+
139
+ /**
140
+ * Set the center of the arc.
141
+ * @param {Vector3} center The center point's coordinates.
142
+ */
143
+ setCenter(center: Vector3): boolean;
144
+
145
+ /**
146
+ * Set the center of the arc by reference.
147
+ * @param {Vector3} center The center point's coordinates.
148
+ */
149
+ setCenterFrom(center: Vector3): boolean;
150
+
151
+ /**
152
+ * Set the normal vector of the arc.
153
+ * @param {Vector3} normal The normal vector's coordinates.
154
+ */
155
+ setNormal(normal: Vector3): boolean;
156
+
157
+ /**
158
+ * Set the normal vector of the arc by reference.
159
+ * @param {Vector3} normal The normal vector's coordinates.
160
+ */
161
+ setNormalFrom(normal: Vector3): boolean;
162
+
163
+ /**
164
+ * Set the polar vector of the arc.
165
+ * @param {Vector3} polarVector The polar vector's coordinates.
166
+ */
167
+ setPolarVector(polarVector: Vector3): boolean;
168
+
169
+ /**
170
+ * Set the polar vector of the arc by reference.
171
+ * @param {Vector3} polarVector The polar vector's coordinates.
172
+ */
173
+ setPolarVectorFrom(polarVector: Vector3): boolean;
174
+
175
+ /**
176
+ * Set the angle of the arc.
177
+ * @param {Number} angle The angle in radians.
178
+ */
179
+ setAngle(angle: number): boolean;
180
+
181
+ /**
182
+ * Set the resolution of the arc.
183
+ * @param {Number} resolution The number of points in the arc.
184
+ */
185
+ setResolution(resolution: number): boolean;
186
+
187
+ /**
188
+ * Set the negative flag of the arc.
189
+ * @param {Boolean} negative If true, the arc will be drawn in the negative direction.
190
+ */
191
+ setNegative(negative: boolean): boolean;
192
+
193
+ /**
194
+ * Set the use normal and angle flag.
195
+ * @param {Boolean} useNormalAndAngle If true, the normal and angle will be used to define the arc.
196
+ */
197
+ setUseNormalAndAngle(useNormalAndAngle: boolean): boolean;
198
+
199
+ /**
200
+ * Set the output points precision.
201
+ * @param {DesiredOutputPrecision} precision The desired output precision.
202
+ */
203
+ setOutputPointsPrecision(precision: DesiredOutputPrecision): boolean;
204
+ }
205
+
206
+ /**
207
+ * Method used to decorate a given object (publicAPI+model) with vtkArcSource characteristics.
208
+ *
209
+ * @param publicAPI object on which methods will be bounds (public)
210
+ * @param model object on which data structure will be bounds (protected)
211
+ * @param {IArcSourceInitialValues} [initialValues] (default: {})
212
+ */
213
+ export function extend(
214
+ publicAPI: object,
215
+ model: object,
216
+ initialValues?: IArcSourceInitialValues
217
+ ): void;
218
+
219
+ /**
220
+ * Method used to create a new instance of vtkArcSource.
221
+ * @param {IArcSourceInitialValues} [initialValues] for pre-setting some of its content
222
+ */
223
+ export function newInstance(
224
+ initialValues?: IArcSourceInitialValues
225
+ ): vtkArcSource;
226
+
227
+ /**
228
+ * vtkArcSource is a source object that creates an arc defined by two endpoints
229
+ * and a center. The number of segments composing the polyline is controlled by
230
+ * setting the object resolution.
231
+ *
232
+ * @example
233
+ * ```js
234
+ * import vtkArcSource from '@kitware/vtk.js/Filters/Sources/ArcSource';
235
+ *
236
+ * const arc = vtkArcSource.newInstance();
237
+ * const polydata = arc.getOutputData();
238
+ * ```
239
+ */
240
+ export declare const vtkArcSource: {
241
+ newInstance: typeof newInstance;
242
+ extend: typeof extend;
243
+ };
244
+ export default vtkArcSource;
@@ -0,0 +1,138 @@
1
+ import { m as macro } from '../../macros2.js';
2
+ import vtkCellArray from '../../Common/Core/CellArray.js';
3
+ import vtkDataArray from '../../Common/Core/DataArray.js';
4
+ import { f as vtkMath } from '../../Common/Core/Math/index.js';
5
+ import vtkPoints from '../../Common/Core/Points.js';
6
+ import vtkPolyData from '../../Common/DataModel/PolyData.js';
7
+ import { DesiredOutputPrecision } from '../../Common/DataModel/DataSetAttributes/Constants.js';
8
+
9
+ const {
10
+ VtkDataTypes
11
+ } = vtkDataArray;
12
+
13
+ // ----------------------------------------------------------------------------
14
+ // vtkArcSource methods
15
+ // ----------------------------------------------------------------------------
16
+
17
+ function vtkArcSource(publicAPI, model) {
18
+ // Set our className
19
+ model.classHierarchy.push('vtkArcSource');
20
+ publicAPI.requestData = (inData, outData) => {
21
+ const numLines = model.resolution;
22
+ const numPts = model.resolution + 1;
23
+ const tc = [0.0, 0.0];
24
+ const output = outData[0] || vtkPolyData.newInstance();
25
+ let angle = 0.0;
26
+ let radius = 0.5;
27
+ const perpendicular = [0, 0, 0];
28
+ const v1 = [0, 0, 0];
29
+ if (model.useNormalAndAngle) {
30
+ angle = vtkMath.radiansFromDegrees(model.angle);
31
+ v1[0] = model.polarVector[0];
32
+ v1[1] = model.polarVector[1];
33
+ v1[2] = model.polarVector[2];
34
+ vtkMath.cross(model.normal, model.polarVector, perpendicular);
35
+ radius = vtkMath.normalize(v1);
36
+ } else {
37
+ vtkMath.subtract(model.point1, model.center, v1);
38
+ const v2 = [0, 0, 0];
39
+ vtkMath.subtract(model.point2, model.center, v2);
40
+ const normal = [0, 0, 0];
41
+ vtkMath.cross(v1, v2, normal);
42
+ vtkMath.cross(normal, v1, perpendicular);
43
+ const dotProduct = vtkMath.dot(v1, v2) / (vtkMath.norm(v1) * vtkMath.norm(v2));
44
+ angle = Math.acos(dotProduct);
45
+ if (model.negative) {
46
+ angle -= 2.0 * Math.PI;
47
+ }
48
+ radius = vtkMath.normalize(v1);
49
+ }
50
+ const angleInc = angle / model.resolution;
51
+ vtkMath.normalize(perpendicular);
52
+ let pointType = 0;
53
+ if (model.outputPointsPrecision === DesiredOutputPrecision.SINGLE) {
54
+ pointType = VtkDataTypes.FLOAT;
55
+ } else if (model.outputPointsPrecision === DesiredOutputPrecision.DOUBLE) {
56
+ pointType = VtkDataTypes.DOUBLE;
57
+ }
58
+ const points = vtkPoints.newInstance({
59
+ dataType: pointType
60
+ });
61
+ points.setNumberOfPoints(numPts);
62
+ const tcoords = vtkDataArray.newInstance({
63
+ numberOfComponents: 2,
64
+ size: numPts * 2,
65
+ dataType: VtkDataTypes.FLOAT,
66
+ name: 'TextureCoordinates'
67
+ });
68
+ const lines = vtkCellArray.newInstance();
69
+ lines.allocate(numLines);
70
+ let theta = 0.0;
71
+ for (let i = 0; i <= model.resolution; ++i, theta += angleInc) {
72
+ const cosine = Math.cos(theta);
73
+ const sine = Math.sin(theta);
74
+ const p = [model.center[0] + cosine * radius * v1[0] + sine * radius * perpendicular[0], model.center[1] + cosine * radius * v1[1] + sine * radius * perpendicular[1], model.center[2] + cosine * radius * v1[2] + sine * radius * perpendicular[2]];
75
+ tc[0] = i / model.resolution;
76
+ tc[1] = 0.0;
77
+ points.setPoint(i, ...p);
78
+ tcoords.setTuple(i, tc);
79
+ }
80
+ const pointIds = Array.from({
81
+ length: numPts
82
+ }, (_, i) => i);
83
+ lines.insertNextCell(pointIds);
84
+ output.setPoints(points);
85
+ output.getPointData().setTCoords(tcoords);
86
+ output.setLines(lines);
87
+ outData[0] = output;
88
+ };
89
+ }
90
+
91
+ // ----------------------------------------------------------------------------
92
+ // Object factory
93
+ // ----------------------------------------------------------------------------
94
+
95
+ const DEFAULT_VALUES = {
96
+ point1: [0.0, 0.5, 0.0],
97
+ point2: [0.5, 0.0, 0.0],
98
+ center: [0.0, 0.0, 0.0],
99
+ normal: [0.0, 0.0, 1.0],
100
+ polarVector: [1.0, 0.0, 0.0],
101
+ angle: 90.0,
102
+ resolution: 6,
103
+ negative: false,
104
+ useNormalAndAngle: false,
105
+ outputPointsPrecision: DesiredOutputPrecision.SINGLE
106
+ };
107
+
108
+ // ----------------------------------------------------------------------------
109
+
110
+ function extend(publicAPI, model) {
111
+ let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
112
+ Object.assign(model, DEFAULT_VALUES, initialValues);
113
+
114
+ // Ensure resolution is at least 1
115
+ if (model.resolution < 1) {
116
+ model.resolution = 1;
117
+ }
118
+
119
+ // Build VTK API
120
+ macro.obj(publicAPI, model);
121
+ macro.algo(publicAPI, model, 0, 1);
122
+ macro.setGet(publicAPI, model, ['resolution', 'angle', 'negative', 'useNormalAndAngle', 'outputPointsPrecision']);
123
+ macro.setGetArray(publicAPI, model, ['point1', 'point2', 'center', 'normal', 'polarVector'], 3);
124
+ vtkArcSource(publicAPI, model);
125
+ }
126
+
127
+ // ----------------------------------------------------------------------------
128
+
129
+ const newInstance = macro.newInstance(extend, 'vtkArcSource');
130
+
131
+ // ----------------------------------------------------------------------------
132
+
133
+ var vtkArcSource$1 = {
134
+ newInstance,
135
+ extend
136
+ };
137
+
138
+ export { vtkArcSource$1 as default, extend, newInstance };
@@ -0,0 +1,212 @@
1
+ import { DesiredOutputPrecision } from './../../Common/DataModel/DataSetAttributes';
2
+ import { vtkAlgorithm, vtkObject } from './../../interfaces';
3
+ import { Vector3 } from './../../types';
4
+
5
+ /**
6
+ *
7
+ */
8
+ export interface IEllipseArcSourceInitialValues {
9
+ center?: Vector3;
10
+ normal?: Vector3;
11
+ majorRadiusVector?: Vector3;
12
+ startAngle?: number;
13
+ segmentAngle?: number;
14
+ resolution?: number;
15
+ close?: boolean;
16
+ outputPointsPrecision?: DesiredOutputPrecision;
17
+ ratio?: number;
18
+ }
19
+
20
+ type vtkEllipseArcSourceBase = vtkObject &
21
+ Omit<
22
+ vtkAlgorithm,
23
+ | 'getInputData'
24
+ | 'setInputData'
25
+ | 'setInputConnection'
26
+ | 'getInputConnection'
27
+ | 'addInputConnection'
28
+ | 'addInputData'
29
+ >;
30
+
31
+ export interface vtkEllipseArcSource extends vtkEllipseArcSourceBase {
32
+ /**
33
+ * Get whether the arc is closed.
34
+ */
35
+ getClose(): boolean;
36
+
37
+ /**
38
+ * Get the center of the arc.
39
+ */
40
+ getCenter(): Vector3;
41
+
42
+ /**
43
+ * Get the center of the arc by reference.
44
+ */
45
+ getCenterByReference(): Vector3;
46
+
47
+ /**
48
+ * Get the major radius vector of the arc.
49
+ */
50
+ getMajorRadiusVector(): Vector3;
51
+
52
+ /**
53
+ * Get the major radius vector of the arc by reference.
54
+ */
55
+ getMajorRadiusVectorByReference(): Vector3;
56
+
57
+ /**
58
+ * Get the normal vector of the arc.
59
+ */
60
+ getNormal(): Vector3;
61
+
62
+ /**
63
+ * Get the normal vector of the arc by reference.
64
+ */
65
+ getNormalByReference(): Vector3;
66
+
67
+ /**
68
+ * Get the output points precision.
69
+ */
70
+ getOutputPointsPrecision(): DesiredOutputPrecision;
71
+
72
+ /**
73
+ * Get the ratio of the arc.
74
+ */
75
+ getRatio(): number;
76
+
77
+ /**
78
+ * Get the resolution of the arc.
79
+ */
80
+ getResolution(): number;
81
+
82
+ /**
83
+ * Get the segment angle of the arc.
84
+ */
85
+ getSegmentAngle(): number;
86
+
87
+ /**
88
+ * Get the start angle of the arc.
89
+ */
90
+ getStartAngle(): number;
91
+
92
+ /**
93
+ *
94
+ * @param inData
95
+ * @param outData
96
+ */
97
+ requestData(inData: any, outData: any): void;
98
+
99
+ /**
100
+ * Set whether the arc is closed.
101
+ * @param {Boolean} close Whether the arc is closed.
102
+ */
103
+ setClose(close: boolean): boolean;
104
+
105
+ /**
106
+ * Set the center of the arc.
107
+ * @param {Vector3} center The center's coordinates.
108
+ */
109
+ setCenter(center: Vector3): boolean;
110
+
111
+ /**
112
+ * Set the center of the arc by reference.
113
+ * @param {Vector3} center The center's coordinates.
114
+ */
115
+ setCenterFrom(center: Vector3): boolean;
116
+
117
+ /**
118
+ * Set the major radius vector of the arc.
119
+ * @param {Vector3} majorRadiusVector The major radius vector's coordinates.
120
+ */
121
+ setMajorRadiusVector(majorRadiusVector: Vector3): boolean;
122
+
123
+ /**
124
+ * Set the major radius vector of the arc by reference.
125
+ * @param {Vector3} majorRadiusVector The major radius vector's coordinates.
126
+ */
127
+ setMajorRadiusVectorFrom(majorRadiusVector: Vector3): boolean;
128
+
129
+ /**
130
+ * Set the normal vector of the arc.
131
+ * @param {Vector3} normal The normal vector's coordinates.
132
+ */
133
+ setNormal(normal: Vector3): boolean;
134
+
135
+ /**
136
+ * Set the normal vector of the arc by reference.
137
+ * @param {Vector3} normal The normal vector's coordinates.
138
+ */
139
+ setNormalFrom(normal: Vector3): boolean;
140
+
141
+ /**
142
+ * Set the output points precision.
143
+ * @param {DesiredOutputPrecision} precision The desired output precision.
144
+ */
145
+ setOutputPointsPrecision(precision: DesiredOutputPrecision): boolean;
146
+
147
+ /**
148
+ * Set the ratio of the arc.
149
+ * @param {Number} ratio The ratio of the arc.
150
+ */
151
+ setRatio(ratio: number): boolean;
152
+
153
+ /**
154
+ * Set the resolution of the arc.
155
+ * @param {Number} resolution The number of points in the arc.
156
+ */
157
+ setResolution(resolution: number): boolean;
158
+
159
+ /**
160
+ * Set the segment angle of the arc.
161
+ * @param {Number} segmentAngle The segment angle in degrees.
162
+ */
163
+ setSegmentAngle(segmentAngle: number): boolean;
164
+
165
+ /**
166
+ * Set the start angle of the arc.
167
+ * @param {Number} startAngle The start angle in degrees.
168
+ */
169
+ setStartAngle(startAngle: number): boolean;
170
+ }
171
+
172
+ /**
173
+ * Method used to decorate a given object (publicAPI+model) with
174
+ * vtkEllipseArcSource characteristics.
175
+ *
176
+ * @param publicAPI object on which methods will be bounds (public)
177
+ * @param model object on which data structure will be bounds (protected)
178
+ * @param {IEllipseArcSourceInitialValues} [initialValues] (default: {})
179
+ */
180
+ export function extend(
181
+ publicAPI: object,
182
+ model: object,
183
+ initialValues?: IEllipseArcSourceInitialValues
184
+ ): void;
185
+
186
+ /**
187
+ * Method used to create a new instance of vtkEllipseArcSource.
188
+ * @param {IEllipseArcSourceInitialValues} [initialValues] for pre-setting some of its content
189
+ */
190
+ export function newInstance(
191
+ initialValues?: IEllipseArcSourceInitialValues
192
+ ): vtkEllipseArcSource;
193
+
194
+ /**
195
+ * vtkEllipseArcSource is a source object that creates an elliptical arc defined
196
+ * by a normal, a center and the major radius vector. You can define an angle to
197
+ * draw only a section of the ellipse. The number of segments composing the
198
+ * polyline is controlled by setting the object resolution.
199
+ *
200
+ * @example
201
+ * ```js
202
+ * import vtkEllipseArcSource from '@kitware/vtk.js/Filters/Sources/EllipseArcSource';
203
+ *
204
+ * const arc = vtkEllipseArcSource.newInstance();
205
+ * const polydata = arc.getOutputData();
206
+ * ```
207
+ */
208
+ export declare const vtkEllipseArcSource: {
209
+ newInstance: typeof newInstance;
210
+ extend: typeof extend;
211
+ };
212
+ export default vtkEllipseArcSource;