Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Documentation/content/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ This will allow you to see the some live code running in your browser. Just pick
[![CubeSource Example][CubeSource]](./CubeSource.html "CubeSource")
[![Cursor3D Example][Cursor3D]](./Cursor3D.html "Cursor3D")
[![CylinderSource Example][CylinderSource]](./CylinderSource.html "CylinderSource")
[![EllipseArcSource Example][EllipseArcSource]](./EllipseArcSource.html "EllipseArcSource")
[![LineSource Example][LineSource]](./LineSource.html "LineSource")
[![PlaneSource Example][PlaneSource]](./PlaneSource.html "PlaneSource")
[![PointSource Example][PointSource]](./PointSource.html "PointSource")
Expand All @@ -159,6 +160,7 @@ This will allow you to see the some live code running in your browser. Just pick
[CubeSource]: ../docs/gallery/CubeSource.jpg
[Cursor3D]: ../docs/gallery/Cursor3D.gif
[CylinderSource]: ../docs/gallery/CylinderSource.jpg
[EllipseArcSource]: ../docs/gallery/EllipseArcSource.jpg
[LineSource]: ../docs/gallery/LineSource.jpg
[PlaneSource]: ../docs/gallery/PlaneSource.jpg
[PointSource]: ../docs/gallery/PointSource.jpg
Expand Down
60 changes: 60 additions & 0 deletions Sources/Filters/Sources/EllipseArcSource/example/controlPanel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<table>
<tr>
<td>StartAngle</td>
<td>
<input
class="startAngle"
type="range"
min="0.5"
max="360"
step="0.1"
value="0.0"
/>
</td>
</tr>
<tr>
<td>SegmentAngle</td>
<td>
<input
class="segmentAngle"
type="range"
min="0.5"
max="360"
step="0.1"
value="90.0"
/>
</td>
</tr>
<tr>
<td>Resolution</td>
<td>
<input
class="resolution"
type="range"
min="1"
max="100"
step="1"
value="100"
/>
</td>
</tr>
<tr>
<td>Ratio</td>
<td>
<input
class="ratio"
type="range"
min="0"
max="1"
step="0.1"
value="1"
/>
</td>
</tr>
<tr>
<td>Close</td>
<td>
<input class="close" type="checkbox" />
</td>
</tr>
</table>
60 changes: 60 additions & 0 deletions Sources/Filters/Sources/EllipseArcSource/example/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import '@kitware/vtk.js/favicon';

// Load the rendering pieces we want to use (for both WebGL and WebGPU)
import '@kitware/vtk.js/Rendering/Profiles/Geometry';

import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
import vtkEllipseArcSource from '@kitware/vtk.js/Filters/Sources/EllipseArcSource';
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';

import controlPanel from './controlPanel.html';

// ----------------------------------------------------------------------------
// Standard rendering code setup
// ----------------------------------------------------------------------------

const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance();
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();

// ----------------------------------------------------------------------------
// Example code
// ----------------------------------------------------------------------------

const arcSource = vtkEllipseArcSource.newInstance();
const actor = vtkActor.newInstance();
const mapper = vtkMapper.newInstance();

mapper.setInputConnection(arcSource.getOutputPort());
actor.setMapper(mapper);

renderer.addActor(actor);
renderer.resetCamera();
renderWindow.render();

// -----------------------------------------------------------
// UI control handling
// -----------------------------------------------------------

fullScreenRenderer.addController(controlPanel);

['startAngle', 'segmentAngle', 'resolution', 'ratio'].forEach(
(propertyName) => {
document
.querySelector(`.${propertyName}`)
.addEventListener('input', (e) => {
const value = Number(e.target.value);
arcSource.set({ [propertyName]: value });
renderer.resetCamera();
renderWindow.render();
});
}
);

document.querySelector('.close').addEventListener('change', (e) => {
const value = e.target.checked;
arcSource.set({ close: value });
renderer.resetCamera();
renderWindow.render();
});
212 changes: 212 additions & 0 deletions Sources/Filters/Sources/EllipseArcSource/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes';
import { vtkAlgorithm, vtkObject } from '../../../interfaces';
import { Vector3 } from '../../../types';

/**
*
*/
export interface IEllipseArcSourceInitialValues {
center?: Vector3;
normal?: Vector3;
majorRadiusVector?: Vector3;
startAngle?: number;
segmentAngle?: number;
resolution?: number;
close?: boolean;
outputPointsPrecision?: DesiredOutputPrecision;
ratio?: number;
}

type vtkEllipseArcSourceBase = vtkObject &
Omit<
vtkAlgorithm,
| 'getInputData'
| 'setInputData'
| 'setInputConnection'
| 'getInputConnection'
| 'addInputConnection'
| 'addInputData'
>;

export interface vtkEllipseArcSource extends vtkEllipseArcSourceBase {
/**
* Get whether the arc is closed.
*/
getClose(): boolean;

/**
* Get the center of the arc.
*/
getCenter(): Vector3;

/**
* Get the center of the arc by reference.
*/
getCenterByReference(): Vector3;

/**
* Get the major radius vector of the arc.
*/
getMajorRadiusVector(): Vector3;

/**
* Get the major radius vector of the arc by reference.
*/
getMajorRadiusVectorByReference(): Vector3;

/**
* Get the normal vector of the arc.
*/
getNormal(): Vector3;

/**
* Get the normal vector of the arc by reference.
*/
getNormalByReference(): Vector3;

/**
* Get the output points precision.
*/
getOutputPointsPrecision(): DesiredOutputPrecision;

/**
* Get the ratio of the arc.
*/
getRatio(): number;

/**
* Get the resolution of the arc.
*/
getResolution(): number;

/**
* Get the segment angle of the arc.
*/
getSegmentAngle(): number;

/**
* Get the start angle of the arc.
*/
getStartAngle(): number;

/**
*
* @param inData
* @param outData
*/
requestData(inData: any, outData: any): void;

/**
* Set whether the arc is closed.
* @param {Boolean} close Whether the arc is closed.
*/
setClose(close: boolean): boolean;

/**
* Set the center of the arc.
* @param {Vector3} center The center's coordinates.
*/
setCenter(center: Vector3): boolean;

/**
* Set the center of the arc by reference.
* @param {Vector3} center The center's coordinates.
*/
setCenterFrom(center: Vector3): boolean;

/**
* Set the major radius vector of the arc.
* @param {Vector3} majorRadiusVector The major radius vector's coordinates.
*/
setMajorRadiusVector(majorRadiusVector: Vector3): boolean;

/**
* Set the major radius vector of the arc by reference.
* @param {Vector3} majorRadiusVector The major radius vector's coordinates.
*/
setMajorRadiusVectorFrom(majorRadiusVector: Vector3): boolean;

/**
* Set the normal vector of the arc.
* @param {Vector3} normal The normal vector's coordinates.
*/
setNormal(normal: Vector3): boolean;

/**
* Set the normal vector of the arc by reference.
* @param {Vector3} normal The normal vector's coordinates.
*/
setNormalFrom(normal: Vector3): boolean;

/**
* Set the output points precision.
* @param {DesiredOutputPrecision} precision The desired output precision.
*/
setOutputPointsPrecision(precision: DesiredOutputPrecision): boolean;

/**
* Set the ratio of the arc.
* @param {Number} ratio The ratio of the arc.
*/
setRatio(ratio: number): boolean;

/**
* Set the resolution of the arc.
* @param {Number} resolution The number of points in the arc.
*/
setResolution(resolution: number): boolean;

/**
* Set the segment angle of the arc.
* @param {Number} segmentAngle The segment angle in degrees.
*/
setSegmentAngle(segmentAngle: number): boolean;

/**
* Set the start angle of the arc.
* @param {Number} startAngle The start angle in degrees.
*/
setStartAngle(startAngle: number): boolean;
}

/**
* Method used to decorate a given object (publicAPI+model) with
* vtkEllipseArcSource characteristics.
*
* @param publicAPI object on which methods will be bounds (public)
* @param model object on which data structure will be bounds (protected)
* @param {IEllipseArcSourceInitialValues} [initialValues] (default: {})
*/
export function extend(
publicAPI: object,
model: object,
initialValues?: IEllipseArcSourceInitialValues
): void;

/**
* Method used to create a new instance of vtkEllipseArcSource.
* @param {IEllipseArcSourceInitialValues} [initialValues] for pre-setting some of its content
*/
export function newInstance(
initialValues?: IEllipseArcSourceInitialValues
): vtkEllipseArcSource;

/**
* vtkEllipseArcSource is a source object that creates an elliptical arc defined
* by a normal, a center and the major radius vector. You can define an angle to
* draw only a section of the ellipse. The number of segments composing the
* polyline is controlled by setting the object resolution.
*
* @example
* ```js
* import vtkEllipseArcSource from '@kitware/vtk.js/Filters/Sources/EllipseArcSource';
*
* const arc = vtkEllipseArcSource.newInstance();
* const polydata = arc.getOutputData();
* ```
*/
export declare const vtkEllipseArcSource: {
newInstance: typeof newInstance;
extend: typeof extend;
};
export default vtkEllipseArcSource;
Loading