@kitware/vtk.js 34.6.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.
- package/Common/Core/Math/index.js +12 -1
- package/Common/Core/Math.d.ts +24 -18
- package/Common/Core/Math.js +1 -1
- package/Common/DataModel/Polygon.d.ts +13 -0
- package/Common/DataModel/Polygon.js +29 -2
- package/Common/DataModel/Triangle.js +8 -13
- package/Filters/Core/Cutter.js +1 -0
- package/Filters/General/ShrinkPolyData.d.ts +85 -0
- package/Filters/General/ShrinkPolyData.js +317 -0
- package/Filters/General.js +2 -0
- package/Filters/Sources/ArcSource.d.ts +244 -0
- package/Filters/Sources/ArcSource.js +138 -0
- package/Filters/Sources/EllipseArcSource.d.ts +212 -0
- package/Filters/Sources/EllipseArcSource.js +159 -0
- package/Filters/Sources/PlatonicSolidSource/Constants.d.ts +12 -0
- package/Filters/Sources/PlatonicSolidSource/Constants.js +12 -0
- package/Filters/Sources/PlatonicSolidSource.d.ts +109 -0
- package/Filters/Sources/PlatonicSolidSource.js +149 -0
- package/Filters/Sources.js +6 -0
- package/IO/Misc/OBJWriter.d.ts +103 -0
- package/IO/Misc/OBJWriter.js +237 -0
- package/IO/Misc.js +2 -0
- package/Interaction/Style/InteractorStyleManipulator.js +75 -2
- package/Proxy/Representations/GlyphRepresentationProxy.js +3 -0
- package/Rendering/Core/Camera.d.ts +3 -3
- package/Rendering/Core/Camera.js +33 -3
- package/Rendering/Core/ColorTransferFunction/CssFilters.js +1 -1
- package/Rendering/Core/ColorTransferFunction.js +1 -1
- package/Rendering/Core/Coordinate.js +1 -1
- package/Rendering/Core/CubeAxesActor.js +1 -1
- package/Rendering/Core/ImageMapper.js +1 -1
- package/Rendering/Core/Renderer.js +1 -1
- package/Rendering/Core/ScalarBarActor.js +1 -1
- package/Rendering/Core/TextActor.js +1 -1
- package/Rendering/Core/VolumeProperty.js +1 -1
- package/Rendering/OpenGL/PolyDataMapper2D.js +1 -1
- package/Rendering/OpenGL/Texture.js +1 -1
- package/Widgets/Widgets3D/AngleWidget.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
- package/index.d.ts +6 -0
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -0,0 +1,159 @@
|
|
|
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
|
+
vtkErrorMacro
|
|
11
|
+
} = macro;
|
|
12
|
+
const {
|
|
13
|
+
VtkDataTypes
|
|
14
|
+
} = vtkDataArray;
|
|
15
|
+
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
// vtkEllipseArcSource methods
|
|
18
|
+
// ----------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
function vtkEllipseArcSource(publicAPI, model) {
|
|
21
|
+
// Set our className
|
|
22
|
+
model.classHierarchy.push('vtkEllipseArcSource');
|
|
23
|
+
publicAPI.requestData = (inData, outData) => {
|
|
24
|
+
const isClosedShape = Math.abs(model.segmentAngle - 360.0) < 1e-5;
|
|
25
|
+
const resolution = model.close && !isClosedShape ? model.resolution + 1 : model.resolution;
|
|
26
|
+
const numLines = resolution;
|
|
27
|
+
const numPts = resolution + 1;
|
|
28
|
+
const tc = [0.0, 0.0];
|
|
29
|
+
const output = outData[0] || vtkPolyData.newInstance();
|
|
30
|
+
|
|
31
|
+
// Make sure the normal vector is normalized
|
|
32
|
+
const normal = [...model.normal];
|
|
33
|
+
vtkMath.normalize(normal);
|
|
34
|
+
|
|
35
|
+
// Get orthogonal vector between user-defined major radius and normal
|
|
36
|
+
const orthogonalVect = [0, 0, 0];
|
|
37
|
+
vtkMath.cross(normal, model.majorRadiusVector, orthogonalVect);
|
|
38
|
+
if (vtkMath.norm(orthogonalVect) < 1e-10) {
|
|
39
|
+
vtkErrorMacro('Ellipse normal vector and major radius axis are collinear');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
vtkMath.normalize(orthogonalVect);
|
|
43
|
+
const majorRadiusVect = [0, 0, 0];
|
|
44
|
+
vtkMath.cross(orthogonalVect, normal, majorRadiusVect);
|
|
45
|
+
vtkMath.normalize(majorRadiusVect);
|
|
46
|
+
const a = vtkMath.norm(model.majorRadiusVector);
|
|
47
|
+
const b = a * model.ratio;
|
|
48
|
+
let startAngleRad = vtkMath.radiansFromDegrees(model.startAngle);
|
|
49
|
+
if (startAngleRad < 0) {
|
|
50
|
+
startAngleRad += 2.0 * Math.PI;
|
|
51
|
+
}
|
|
52
|
+
const segmentAngleRad = vtkMath.radiansFromDegrees(model.segmentAngle);
|
|
53
|
+
const angleIncRad = segmentAngleRad / model.resolution;
|
|
54
|
+
let pointType = VtkDataTypes.FLOAT;
|
|
55
|
+
if (model.outputPointsPrecision === DesiredOutputPrecision.SINGLE) {
|
|
56
|
+
pointType = VtkDataTypes.FLOAT;
|
|
57
|
+
} else if (model.outputPointsPrecision === DesiredOutputPrecision.DOUBLE) {
|
|
58
|
+
pointType = VtkDataTypes.DOUBLE;
|
|
59
|
+
}
|
|
60
|
+
const points = vtkPoints.newInstance({
|
|
61
|
+
dataType: pointType
|
|
62
|
+
});
|
|
63
|
+
points.setNumberOfPoints(numPts);
|
|
64
|
+
const tcoords = vtkDataArray.newInstance({
|
|
65
|
+
numberOfComponents: 2,
|
|
66
|
+
size: numPts * 2,
|
|
67
|
+
dataType: VtkDataTypes.FLOAT,
|
|
68
|
+
name: 'TextureCoordinates'
|
|
69
|
+
});
|
|
70
|
+
const lines = vtkCellArray.newInstance();
|
|
71
|
+
lines.allocate(numLines);
|
|
72
|
+
const skipLastPoint = model.close && isClosedShape;
|
|
73
|
+
let theta = startAngleRad;
|
|
74
|
+
let pointIndex = 0;
|
|
75
|
+
for (let i = 0; i <= resolution; ++i, theta += angleIncRad) {
|
|
76
|
+
const quotient = Math.floor(theta / (2.0 * Math.PI));
|
|
77
|
+
const normalizedTheta = theta - quotient * 2.0 * Math.PI;
|
|
78
|
+
let thetaEllipse = Math.atan(Math.tan(normalizedTheta) * model.ratio);
|
|
79
|
+
if (normalizedTheta > Math.PI / 2 && normalizedTheta <= Math.PI) {
|
|
80
|
+
thetaEllipse += Math.PI;
|
|
81
|
+
} else if (normalizedTheta > Math.PI && normalizedTheta <= 1.5 * Math.PI) {
|
|
82
|
+
thetaEllipse -= Math.PI;
|
|
83
|
+
}
|
|
84
|
+
const cosTheta = Math.cos(thetaEllipse);
|
|
85
|
+
const sinTheta = Math.sin(thetaEllipse);
|
|
86
|
+
const p = [model.center[0] + a * cosTheta * majorRadiusVect[0] + b * sinTheta * orthogonalVect[0], model.center[1] + a * cosTheta * majorRadiusVect[1] + b * sinTheta * orthogonalVect[1], model.center[2] + a * cosTheta * majorRadiusVect[2] + b * sinTheta * orthogonalVect[2]];
|
|
87
|
+
tc[0] = i / resolution;
|
|
88
|
+
tc[1] = 0.0;
|
|
89
|
+
if (i !== resolution || !skipLastPoint) {
|
|
90
|
+
points.setPoint(pointIndex, ...p);
|
|
91
|
+
tcoords.setTuple(pointIndex, tc);
|
|
92
|
+
pointIndex++;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const actualNumPts = pointIndex;
|
|
96
|
+
const pointIds = [];
|
|
97
|
+
for (let k = 0; k < actualNumPts - 1; ++k) {
|
|
98
|
+
pointIds.push(k);
|
|
99
|
+
}
|
|
100
|
+
if (model.close) {
|
|
101
|
+
pointIds.push(0);
|
|
102
|
+
} else {
|
|
103
|
+
pointIds.push(actualNumPts - 1);
|
|
104
|
+
}
|
|
105
|
+
lines.insertNextCell(pointIds);
|
|
106
|
+
output.setPoints(points);
|
|
107
|
+
output.getPointData().setTCoords(tcoords);
|
|
108
|
+
output.setLines(lines);
|
|
109
|
+
outData[0] = output;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// ----------------------------------------------------------------------------
|
|
114
|
+
// Object factory
|
|
115
|
+
// ----------------------------------------------------------------------------
|
|
116
|
+
|
|
117
|
+
const DEFAULT_VALUES = {
|
|
118
|
+
center: [0.0, 0.0, 0.0],
|
|
119
|
+
normal: [0.0, 0.0, 1.0],
|
|
120
|
+
majorRadiusVector: [1.0, 0.0, 0.0],
|
|
121
|
+
startAngle: 0.0,
|
|
122
|
+
segmentAngle: 90.0,
|
|
123
|
+
resolution: 100,
|
|
124
|
+
close: false,
|
|
125
|
+
outputPointsPrecision: DesiredOutputPrecision.SINGLE,
|
|
126
|
+
ratio: 1.0
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// ----------------------------------------------------------------------------
|
|
130
|
+
|
|
131
|
+
function extend(publicAPI, model) {
|
|
132
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
133
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
134
|
+
|
|
135
|
+
// Ensure resolution is at least 1
|
|
136
|
+
if (model.resolution < 1) {
|
|
137
|
+
model.resolution = 1;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Build VTK API
|
|
141
|
+
macro.obj(publicAPI, model);
|
|
142
|
+
macro.algo(publicAPI, model, 0, 1);
|
|
143
|
+
macro.setGet(publicAPI, model, ['resolution', 'startAngle', 'segmentAngle', 'close', 'outputPointsPrecision', 'ratio']);
|
|
144
|
+
macro.setGetArray(publicAPI, model, ['center', 'normal', 'majorRadiusVector'], 3);
|
|
145
|
+
vtkEllipseArcSource(publicAPI, model);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ----------------------------------------------------------------------------
|
|
149
|
+
|
|
150
|
+
const newInstance = macro.newInstance(extend, 'vtkEllipseArcSource');
|
|
151
|
+
|
|
152
|
+
// ----------------------------------------------------------------------------
|
|
153
|
+
|
|
154
|
+
var vtkEllipseArcSource$1 = {
|
|
155
|
+
newInstance,
|
|
156
|
+
extend
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export { vtkEllipseArcSource$1 as default, extend, newInstance };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare enum SolidType {
|
|
2
|
+
VTK_SOLID_TETRAHEDRON = 0,
|
|
3
|
+
VTK_SOLID_CUBE = 1,
|
|
4
|
+
VTK_SOLID_OCTAHEDRON = 2,
|
|
5
|
+
VTK_SOLID_ICOSAHEDRON = 3,
|
|
6
|
+
VTK_SOLID_DODECAHEDRON = 4,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare const _default: {
|
|
10
|
+
SolidType: typeof SolidType;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { vtkAlgorithm, vtkObject } from './../../interfaces';
|
|
2
|
+
import { DesiredOutputPrecision } from './../../Common/DataModel/DataSetAttributes';
|
|
3
|
+
import { SolidType } from './PlatonicSolidSource/Constants';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export interface IPlatonicSolidSourceInitialValues {
|
|
9
|
+
solidType?: SolidType;
|
|
10
|
+
outputPointsPrecision?: DesiredOutputPrecision;
|
|
11
|
+
scale?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type vtkPlatonicSolidSourceBase = vtkObject &
|
|
15
|
+
Omit<
|
|
16
|
+
vtkAlgorithm,
|
|
17
|
+
| 'getInputData'
|
|
18
|
+
| 'setInputData'
|
|
19
|
+
| 'setInputConnection'
|
|
20
|
+
| 'getInputConnection'
|
|
21
|
+
| 'addInputConnection'
|
|
22
|
+
| 'addInputData'
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
export interface vtkPlatonicSolidSource extends vtkPlatonicSolidSourceBase {
|
|
26
|
+
/**
|
|
27
|
+
* Get the desired output precision.
|
|
28
|
+
* @returns {DesiredOutputPrecision}
|
|
29
|
+
*/
|
|
30
|
+
getOutputPointsPrecision(): DesiredOutputPrecision;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get the scale factor of the source.
|
|
34
|
+
*/
|
|
35
|
+
getScale(): number;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get the solid type of the source.
|
|
39
|
+
* @returns {SolidType}
|
|
40
|
+
*/
|
|
41
|
+
getSolidType(): SolidType;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Request data for the source.
|
|
45
|
+
* @param inData
|
|
46
|
+
* @param outData
|
|
47
|
+
*/
|
|
48
|
+
requestData(inData: any, outData: any): void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Set the desired output precision.
|
|
52
|
+
* @param {DesiredOutputPrecision} outputPointsPrecision
|
|
53
|
+
*/
|
|
54
|
+
setOutputPointsPrecision(
|
|
55
|
+
outputPointsPrecision: DesiredOutputPrecision
|
|
56
|
+
): boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Set the scale factor of the source.
|
|
60
|
+
* @param {Number} scale The scale factor.
|
|
61
|
+
*/
|
|
62
|
+
setScale(scale: number): boolean;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Set the solid type of the source.
|
|
66
|
+
* @param {SolidType} solidType
|
|
67
|
+
*/
|
|
68
|
+
setSolidType(solidType: SolidType): boolean;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Method used to decorate a given object (publicAPI+model) with vtkPlatonicSolidSource characteristics.
|
|
73
|
+
*
|
|
74
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
75
|
+
* @param model object on which data structure will be bounds (protected)
|
|
76
|
+
* @param {IPlatonicSolidSourceInitialValues} [initialValues] (default: {})
|
|
77
|
+
*/
|
|
78
|
+
export function extend(
|
|
79
|
+
publicAPI: object,
|
|
80
|
+
model: object,
|
|
81
|
+
initialValues?: IPlatonicSolidSourceInitialValues
|
|
82
|
+
): void;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Method used to create a new instance of vtkPlatonicSolidSource.
|
|
86
|
+
* @param {IPlatonicSolidSourceInitialValues} [initialValues] for pre-setting some of its content
|
|
87
|
+
*/
|
|
88
|
+
export function newInstance(
|
|
89
|
+
initialValues?: IPlatonicSolidSourceInitialValues
|
|
90
|
+
): vtkPlatonicSolidSource;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* vtkPlatonicSolidSource can generate each of the five Platonic solids:
|
|
94
|
+
* tetrahedron, cube, octahedron, icosahedron, and dodecahedron. Each of the
|
|
95
|
+
* solids is placed inside a sphere centered at the origin with radius 1.0.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```js
|
|
99
|
+
* import vtkPlatonicSolidSource from '@kitware/vtk.js/Filters/Sources/RegularPolygonSource';
|
|
100
|
+
*
|
|
101
|
+
* const regularPolygonSource = vtkPlatonicSolidSource.newInstance();
|
|
102
|
+
* const polydata = regularPolygonSource.getOutputData();
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare const vtkPlatonicSolidSource: {
|
|
106
|
+
newInstance: typeof newInstance;
|
|
107
|
+
extend: typeof extend;
|
|
108
|
+
};
|
|
109
|
+
export default vtkPlatonicSolidSource;
|