Skip to content

Commit 423112c

Browse files
dakersankhesh
authored andcommitted
fix(ArcSource): add vtkArcSource
1 parent 8b18519 commit 423112c

File tree

9 files changed

+561
-1
lines changed

9 files changed

+561
-1
lines changed
2.55 KB
Loading

Documentation/content/examples/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ This will allow you to see the some live code running in your browser. Just pick
133133

134134
<div class="gallery">
135135

136+
[![ArcSource Example][ArcSource]](./ArcSource.html "ArcSource")
136137
[![ArrowSource Example][ArrowSource]](./ArrowSource.html "ArrowSource")
137138
[![CircleSource Example][CircleSource]](./CircleSource.html "CircleSource")
138139
[![ConcentricCylinderSource Example][ConcentricCylinderSource]](./ConcentricCylinderSource.html "ConcentricCylinderSource")
@@ -152,7 +153,7 @@ This will allow you to see the some live code running in your browser. Just pick
152153
[![WindowedSincPolyDataFilter Example][WindowedSincPolyDataFilter]](./WindowedSincPolyDataFilter.html "WindowedSincPolyDataFilter")
153154

154155
<div>
155-
156+
[ArcSource]: ../docs/gallery/ArcSource.jpg
156157
[ArrowSource]: ../docs/gallery/ArrowSource.jpg
157158
[CircleSource]: ../docs/gallery/CircleSource.jpg
158159
[ConcentricCylinderSource]: ../docs/gallery/ConcentricCylinderSource.jpg
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<table>
2+
<tr>
3+
<td>Angle</td>
4+
<td>
5+
<input class='angle' type="range" min="0.5" max="360" step="0.1" value="90.0" />
6+
</td>
7+
</tr>
8+
<tr>
9+
<td>Resolution</td>
10+
<td>
11+
<input class='resolution' type="range" min="1" max="100" step="1" value="6" />
12+
</td>
13+
</tr>
14+
<tr>
15+
<td>Use Normal and Angle</td>
16+
<td>
17+
<input class='useNormalAndAngle' type="checkbox" />
18+
</td>
19+
</table>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import '@kitware/vtk.js/favicon';
2+
3+
// Load the rendering pieces we want to use (for both WebGL and WebGPU)
4+
import '@kitware/vtk.js/Rendering/Profiles/Geometry';
5+
6+
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
7+
import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
8+
import vtkArcSource from '@kitware/vtk.js/Filters/Sources/ArcSource';
9+
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
10+
11+
import controlPanel from './controlPanel.html';
12+
13+
// ----------------------------------------------------------------------------
14+
// Standard rendering code setup
15+
// ----------------------------------------------------------------------------
16+
17+
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance();
18+
const renderer = fullScreenRenderer.getRenderer();
19+
const renderWindow = fullScreenRenderer.getRenderWindow();
20+
21+
// ----------------------------------------------------------------------------
22+
// Example code
23+
// ----------------------------------------------------------------------------
24+
25+
const arcSource = vtkArcSource.newInstance();
26+
const actor = vtkActor.newInstance();
27+
const mapper = vtkMapper.newInstance();
28+
29+
mapper.setInputConnection(arcSource.getOutputPort());
30+
actor.setMapper(mapper);
31+
32+
renderer.addActor(actor);
33+
renderer.resetCamera();
34+
renderWindow.render();
35+
36+
// -----------------------------------------------------------
37+
// UI control handling
38+
// -----------------------------------------------------------
39+
40+
fullScreenRenderer.addController(controlPanel);
41+
42+
['angle', 'resolution'].forEach((propertyName) => {
43+
document.querySelector(`.${propertyName}`).addEventListener('input', (e) => {
44+
const value = Number(e.target.value);
45+
arcSource.set({ [propertyName]: value });
46+
renderer.resetCamera();
47+
renderWindow.render();
48+
});
49+
});
50+
51+
document.querySelector('.useNormalAndAngle').addEventListener('change', (e) => {
52+
const value = e.target.checked;
53+
arcSource.set({ useNormalAndAngle: value });
54+
renderer.resetCamera();
55+
renderWindow.render();
56+
});
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 commit comments

Comments
 (0)