Skip to content

Commit 8b18519

Browse files
dakersankhesh
authored andcommitted
feat(EllipseArcSource): add vtkEllipseArcSource
1 parent 856b657 commit 8b18519

File tree

9 files changed

+610
-0
lines changed

9 files changed

+610
-0
lines changed
2.75 KB
Loading

Documentation/content/examples/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ This will allow you to see the some live code running in your browser. Just pick
141141
[![CubeSource Example][CubeSource]](./CubeSource.html "CubeSource")
142142
[![Cursor3D Example][Cursor3D]](./Cursor3D.html "Cursor3D")
143143
[![CylinderSource Example][CylinderSource]](./CylinderSource.html "CylinderSource")
144+
[![EllipseArcSource Example][EllipseArcSource]](./EllipseArcSource.html "EllipseArcSource")
144145
[![LineSource Example][LineSource]](./LineSource.html "LineSource")
145146
[![PlaneSource Example][PlaneSource]](./PlaneSource.html "PlaneSource")
146147
[![PointSource Example][PointSource]](./PointSource.html "PointSource")
@@ -160,6 +161,7 @@ This will allow you to see the some live code running in your browser. Just pick
160161
[CubeSource]: ../docs/gallery/CubeSource.jpg
161162
[Cursor3D]: ../docs/gallery/Cursor3D.gif
162163
[CylinderSource]: ../docs/gallery/CylinderSource.jpg
164+
[EllipseArcSource]: ../docs/gallery/EllipseArcSource.jpg
163165
[LineSource]: ../docs/gallery/LineSource.jpg
164166
[PlaneSource]: ../docs/gallery/PlaneSource.jpg
165167
[PointSource]: ../docs/gallery/PointSource.jpg
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<table>
2+
<tr>
3+
<td>StartAngle</td>
4+
<td>
5+
<input
6+
class="startAngle"
7+
type="range"
8+
min="0.5"
9+
max="360"
10+
step="0.1"
11+
value="0.0"
12+
/>
13+
</td>
14+
</tr>
15+
<tr>
16+
<td>SegmentAngle</td>
17+
<td>
18+
<input
19+
class="segmentAngle"
20+
type="range"
21+
min="0.5"
22+
max="360"
23+
step="0.1"
24+
value="90.0"
25+
/>
26+
</td>
27+
</tr>
28+
<tr>
29+
<td>Resolution</td>
30+
<td>
31+
<input
32+
class="resolution"
33+
type="range"
34+
min="1"
35+
max="100"
36+
step="1"
37+
value="100"
38+
/>
39+
</td>
40+
</tr>
41+
<tr>
42+
<td>Ratio</td>
43+
<td>
44+
<input
45+
class="ratio"
46+
type="range"
47+
min="0"
48+
max="1"
49+
step="0.1"
50+
value="1"
51+
/>
52+
</td>
53+
</tr>
54+
<tr>
55+
<td>Close</td>
56+
<td>
57+
<input class="close" type="checkbox" />
58+
</td>
59+
</tr>
60+
</table>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 vtkEllipseArcSource from '@kitware/vtk.js/Filters/Sources/EllipseArcSource';
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 = vtkEllipseArcSource.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+
['startAngle', 'segmentAngle', 'resolution', 'ratio'].forEach(
43+
(propertyName) => {
44+
document
45+
.querySelector(`.${propertyName}`)
46+
.addEventListener('input', (e) => {
47+
const value = Number(e.target.value);
48+
arcSource.set({ [propertyName]: value });
49+
renderer.resetCamera();
50+
renderWindow.render();
51+
});
52+
}
53+
);
54+
55+
document.querySelector('.close').addEventListener('change', (e) => {
56+
const value = e.target.checked;
57+
arcSource.set({ close: value });
58+
renderer.resetCamera();
59+
renderWindow.render();
60+
});
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 commit comments

Comments
 (0)