@kitware/vtk.js 34.16.7 → 34.18.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,150 @@
1
+ import { m as macro } from '../../macros2.js';
2
+ import { b as vtkMath } from '../../Common/Core/Math/index.js';
3
+ import vtkPolyData from '../../Common/DataModel/PolyData.js';
4
+ import vtkPoints from '../../Common/Core/Points.js';
5
+ import vtkCellArray from '../../Common/Core/CellArray.js';
6
+ import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
7
+ import { DesiredOutputPrecision } from '../../Common/DataModel/DataSetAttributes/Constants.js';
8
+
9
+ // ----------------------------------------------------------------------------
10
+ // vtkRegularPolygonSource methods
11
+ // ----------------------------------------------------------------------------
12
+
13
+ function vtkRegularPolygonSource(publicAPI, model) {
14
+ // Set our className
15
+ model.classHierarchy.push('vtkRegularPolygonSource');
16
+ publicAPI.requestData = (inData, outData) => {
17
+ const output = outData[0]?.initialize() || vtkPolyData.newInstance();
18
+ const numPts = model.numberOfSides;
19
+ const newPoints = vtkPoints.newInstance({
20
+ dataType: model.outputPointsPrecision === DesiredOutputPrecision.DOUBLE ? VtkDataTypes.DOUBLE : VtkDataTypes.FLOAT
21
+ });
22
+
23
+ // Generate polyline if requested
24
+ if (model.generatePolyline) {
25
+ const newLine = vtkCellArray.newInstance();
26
+ const linePoints = [];
27
+ for (let i = 0; i < numPts; i++) {
28
+ linePoints.push(i);
29
+ }
30
+ linePoints.push(0); // close the polyline
31
+ newLine.insertNextCell(linePoints);
32
+ output.setLines(newLine);
33
+ }
34
+
35
+ // Generate polygon if requested
36
+ if (model.generatePolygon) {
37
+ const newPoly = vtkCellArray.newInstance();
38
+ const polyPoints = [];
39
+ for (let i = 0; i < numPts; i++) {
40
+ polyPoints.push(i);
41
+ }
42
+ newPoly.insertNextCell(polyPoints);
43
+ output.setPolys(newPoly);
44
+ }
45
+
46
+ // Make sure the polygon normal is a unit vector
47
+ const n = [...model.normal];
48
+ const nLength = vtkMath.normalize(n);
49
+ if (nLength === 0.0) {
50
+ n[0] = 0.0;
51
+ n[1] = 0.0;
52
+ n[2] = 1.0;
53
+ }
54
+
55
+ // Find a vector in the polygon plane (perpendicular to normal)
56
+ const px = [0, 0, 0];
57
+ const py = [0, 0, 0];
58
+ let foundPlaneVector = false;
59
+
60
+ // Cross with unit axis vectors and eventually find vector in the polygon plane
61
+ const axis = [1.0, 0.0, 0.0];
62
+ vtkMath.cross(n, axis, px);
63
+ const pxLength = vtkMath.normalize(px);
64
+ if (pxLength > 1.0e-3) {
65
+ foundPlaneVector = true;
66
+ }
67
+ if (!foundPlaneVector) {
68
+ axis[0] = 0.0;
69
+ axis[1] = 1.0;
70
+ axis[2] = 0.0;
71
+ vtkMath.cross(n, axis, px);
72
+ const pxLength2 = vtkMath.normalize(px);
73
+ if (pxLength2 > 1.0e-3) {
74
+ foundPlaneVector = true;
75
+ }
76
+ }
77
+ if (!foundPlaneVector) {
78
+ axis[0] = 0.0;
79
+ axis[1] = 0.0;
80
+ axis[2] = 1.0;
81
+ vtkMath.cross(n, axis, px);
82
+ vtkMath.normalize(px);
83
+ }
84
+
85
+ // Create second orthogonal axis in polygon plane
86
+ vtkMath.cross(px, n, py);
87
+
88
+ // Generate polygon points
89
+ const theta = 2.0 * Math.PI / numPts;
90
+ const points = [];
91
+ const r = [0, 0, 0];
92
+ const x = [0, 0, 0];
93
+ for (let j = 0; j < numPts; j++) {
94
+ const cosTheta = Math.cos(j * theta);
95
+ const sinTheta = Math.sin(j * theta);
96
+ r[0] = px[0] * cosTheta + py[0] * sinTheta;
97
+ r[1] = px[1] * cosTheta + py[1] * sinTheta;
98
+ r[2] = px[2] * cosTheta + py[2] * sinTheta;
99
+ x[0] = model.center[0] + model.radius * r[0];
100
+ x[1] = model.center[1] + model.radius * r[1];
101
+ x[2] = model.center[2] + model.radius * r[2];
102
+ points.push(x[0], x[1], x[2]);
103
+ }
104
+ newPoints.setData(points);
105
+ output.setPoints(newPoints);
106
+ outData[0] = output;
107
+ };
108
+ }
109
+
110
+ // ----------------------------------------------------------------------------
111
+ // Object factory
112
+ // ----------------------------------------------------------------------------
113
+
114
+ const DEFAULT_VALUES = {
115
+ numberOfSides: 6,
116
+ center: [0.0, 0.0, 0.0],
117
+ normal: [0.0, 0.0, 1.0],
118
+ radius: 0.5,
119
+ generatePolygon: true,
120
+ generatePolyline: true,
121
+ outputPointsPrecision: DesiredOutputPrecision.FLOAT
122
+ };
123
+
124
+ // ----------------------------------------------------------------------------
125
+
126
+ function extend(publicAPI, model, initialValues = {}) {
127
+ Object.assign(model, DEFAULT_VALUES, initialValues);
128
+
129
+ // Build VTK API
130
+ macro.obj(publicAPI, model);
131
+ macro.algo(publicAPI, model, 0, 1);
132
+
133
+ // Build VTK API
134
+ macro.setGet(publicAPI, model, ['numberOfSides', 'radius', 'generatePolygon', 'generatePolyline', 'outputPointsPrecision']);
135
+ macro.setGetArray(publicAPI, model, ['center', 'normal'], 3);
136
+ vtkRegularPolygonSource(publicAPI, model);
137
+ }
138
+
139
+ // ----------------------------------------------------------------------------
140
+
141
+ const newInstance = macro.newInstance(extend, 'vtkRegularPolygonSource');
142
+
143
+ // ----------------------------------------------------------------------------
144
+
145
+ var vtkRegularPolygonSource$1 = {
146
+ newInstance,
147
+ extend
148
+ };
149
+
150
+ export { vtkRegularPolygonSource$1 as default, extend, newInstance };
@@ -13,6 +13,7 @@ import vtkLineSource from './Sources/LineSource.js';
13
13
  import vtkPlaneSource from './Sources/PlaneSource.js';
14
14
  import vtkPlatonicSolidSource from './Sources/PlatonicSolidSource.js';
15
15
  import vtkPointSource from './Sources/PointSource.js';
16
+ import vtkRegularPolygonSource from './Sources/RegularPolygonSource.js';
16
17
  import vtkRTAnalyticSource from './Sources/RTAnalyticSource.js';
17
18
  import vtkSLICSource from './Sources/SLICSource.js';
18
19
  import vtkSphereSource from './Sources/SphereSource.js';
@@ -34,6 +35,7 @@ var Sources = {
34
35
  vtkPlaneSource,
35
36
  vtkPlatonicSolidSource,
36
37
  vtkPointSource,
38
+ vtkRegularPolygonSource,
37
39
  vtkRTAnalyticSource,
38
40
  vtkSLICSource,
39
41
  vtkSphereSource,
@@ -22,6 +22,7 @@ import '../../Filters/Sources/LineSource.js';
22
22
  import '../../Filters/Sources/PlaneSource.js';
23
23
  import '../../Filters/Sources/PlatonicSolidSource.js';
24
24
  import '../../Filters/Sources/PointSource.js';
25
+ import '../../Filters/Sources/RegularPolygonSource.js';
25
26
  import '../../Filters/Sources/RTAnalyticSource.js';
26
27
  import '../../Filters/Sources/SLICSource.js';
27
28
  import '../../Filters/Sources/SphereSource.js';
@@ -10,6 +10,10 @@ export interface IAbstractImageMapperInitialValues
10
10
  customDisplayExtent?: number[];
11
11
  useCustomExtents?: boolean;
12
12
  slice?: number;
13
+ backgroundColor?: RGBAColor;
14
+ colorTextureWidth?: number;
15
+ opacityTextureWidth?: number;
16
+ labelOutlineTextureWidth?: number;
13
17
  }
14
18
 
15
19
  export interface vtkAbstractImageMapper extends vtkAbstractMapper3D {
@@ -21,6 +21,7 @@ export interface IImagePropertyInitialValues {
21
21
  useLookupTableScalarRange?: boolean;
22
22
  useLabelOutline?: boolean;
23
23
  labelOutlineThickness?: number | number[];
24
+ labelOutlineOpacity?: number | number[];
24
25
  }
25
26
 
26
27
  export interface vtkImageProperty extends vtkObject {
@@ -127,6 +128,12 @@ export interface vtkImageProperty extends vtkObject {
127
128
  */
128
129
  getLabelOutlineThickness(): number;
129
130
 
131
+ /**
132
+ * Get the label outline thickness array by reference.
133
+ * This returns the actual internal array, not a copy.
134
+ */
135
+ getLabelOutlineThicknessByReference(): number[];
136
+
130
137
  /**
131
138
  * It will set the label outline thickness for the labelmaps. It can accept
132
139
  * a single number or an array of numbers. If a single number is provided,