Skip to content
Open
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 @@ -151,6 +151,7 @@ This will allow you to see the some live code running in your browser. Just pick
[![PlaneSource Example][PlaneSource]](./PlaneSource.html "PlaneSource")
[![PointSource Example][PointSource]](./PointSource.html "PointSource")
[![PlatonicSolidSource Example][PlatonicSolidSource]](./PlatonicSolidSource.html "PlatonicSolidSource")
[![RegularPolygonSource Example][RegularPolygonSource]](./RegularPolygonSource.html "RegularPolygonSource")
[![SLICSource Example][SLICSource]](./SLICSource.html "SLICSource")
[![SphereSource Example][SphereSource]](./SphereSource.html "SphereSource")
[![WarpScalar Example][WarpScalargif]](./WarpScalar.html "WarpScalar")
Expand All @@ -173,6 +174,7 @@ This will allow you to see the some live code running in your browser. Just pick
[PlaneSource]: ../docs/gallery/PlaneSource.jpg
[PointSource]: ../docs/gallery/PointSource.jpg
[PlatonicSolidSource]: ../docs/gallery/PlatonicSolidSource.jpg
[RegularPolygonSource]: ../docs/gallery/RegularPolygonSource.jpg
[SLICSource]: ../docs/gallery/SLICSource.jpg
[SphereSource]: ../docs/gallery/SphereSource.gif
[WarpScalargif]: ../docs/gallery/WarpScalar.gif
Expand Down
6 changes: 3 additions & 3 deletions Sources/Filters/Sources/PlatonicSolidSource/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ export function newInstance(
*
* @example
* ```js
* import vtkPlatonicSolidSource from '@kitware/vtk.js/Filters/Sources/RegularPolygonSource';
* import vtkPlatonicSolidSource from '@kitware/vtk.js/Filters/Sources/PlatonicSolidSource';
*
* const regularPolygonSource = vtkPlatonicSolidSource.newInstance();
* const polydata = regularPolygonSource.getOutputData();
* const platonicSolidSource = vtkPlatonicSolidSource.newInstance();
* const polydata = platonicSolidSource.getOutputData();
* ```
*/
export declare const vtkPlatonicSolidSource: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<table>
<tr>
<td>Number Of Sides</td>
<td>
<input class='numberOfSides' type="range" min="3" max="100" step="1" value="6" />
</td>
</tr>
</table>
62 changes: 62 additions & 0 deletions Sources/Filters/Sources/RegularPolygonSource/example/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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 vtkRegularPolygonSource from '@kitware/vtk.js/Filters/Sources/RegularPolygonSource';
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
import { Representation } from '@kitware/vtk.js/Rendering/Core/Property/Constants';

import controlPanel from './controlPanel.html';

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

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

// ----------------------------------------------------------------------------
// Example code
// ----------------------------------------------------------------------------
const regularPolygonSource = vtkRegularPolygonSource.newInstance();

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

actor.getProperty().setRepresentation(Representation.WIREFRAME);

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

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

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

fullScreenRenderer.addController(controlPanel);

['numberOfSides'].forEach((propertyName) => {
document.querySelector(`.${propertyName}`).addEventListener('input', (e) => {
const value = Number(e.target.value);
regularPolygonSource.set({ [propertyName]: value });
renderWindow.render();
});
});

// -----------------------------------------------------------
// Make some variables global so that you can inspect and
// modify objects in your browser's developer console:
// -----------------------------------------------------------

global.regularPolygonSource = regularPolygonSource;
global.mapper = mapper;
global.actor = actor;
global.renderer = renderer;
global.renderWindow = renderWindow;
183 changes: 183 additions & 0 deletions Sources/Filters/Sources/RegularPolygonSource/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
import { vtkAlgorithm, vtkObject } from '../../../interfaces';
import { Vector3 } from '../../../types';
import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes';

/**
*
*/
export interface IPlaneSourceInitialValues {
numberOfSides?: number;
center?: Vector3;
normal?: Vector3;
radius?: number;
generatePolygon?: boolean;
generatePolyline?: boolean;
outputPointsPrecision?: DesiredOutputPrecision;
}

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

export interface vtkRegularPolygonSource extends vtkRegularPolygonSourceBase {
/**
* Get the center of the regular polygon.
* @returns {Vector3} center of the polygon
*/
getCenter(): Vector3;

/**
* Get a reference to the center of the regular polygon.
* @returns {Vector3} reference to the center of the polygon
*/
getCenterByReference(): Vector3;

/**
* Get whether to generate polygon points.
* @returns {Boolean} true if polygon points are generated, false otherwise
*/
getGeneratePolygon(): boolean;

/**
* Get whether to generate polyline points.
* @returns {Boolean} true if polyline points are generated, false otherwise
*/
getGeneratePolyline(): boolean;

/**
* Get the normal of the regular polygon.
* @returns {Vector3} normal of the polygon
*/
getNormal(): Vector3;

/**
* Get a reference to the normal of the regular polygon.
* @returns {Vector3} reference to the normal of the polygon
*/
getNormalByReference(): Vector3;

/**
* Get the number of sides for the regular polygon.
* @returns {Number} number of sides
*/
getNumberOfSides(): number;

/**
* Get the output points precision.
* @returns {DesiredOutputPrecision} the output points precision
*/
getOutputPointsPrecision(): DesiredOutputPrecision;

/**
* Get the radius of the regular polygon.
* @returns {Number} radius of the polygon
*/
getRadius(): number;

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

/**
* Set the center of the regular polygon.
* @param {Vector3} center
* @returns {Boolean} true if the value was changed, false otherwise
*/
setCenter(center: Vector3): boolean;

/**
* Set whether to generate polygon points.
* @param generatePolygon
* @returns {Boolean} true if the value was changed, false otherwise
*/
setGeneratePolygon(generatePolygon: boolean): boolean;

/**
* Set whether to generate polyline points.
* @param generatePolyline
* @returns {Boolean} true if the value was changed, false otherwise
*/
setGeneratePolyline(generatePolyline: boolean): boolean;

/**
* Set the normal of the regular polygon.
* @param {Vector3} normal
* @returns {Boolean} true if the value was changed, false otherwise
*/
setNormal(normal: Vector3): boolean;

/**
* Set the number of sides for the regular polygon.
* @param numberOfSides
* @returns {Boolean} true if the value was changed, false otherwise
*/
setNumberOfSides(numberOfSides: number): boolean;

/**
* Set the output points precision.
* @param outputPointsPrecision
* @returns {Boolean} true if the value was changed, false otherwise
*/
setOutputPointsPrecision(
outputPointsPrecision: DesiredOutputPrecision
): boolean;

/**
* Set the radius of the regular polygon.
* @param radius
* @returns {Boolean} true if the value was changed, false otherwise
*/
setRadius(radius: number): boolean;
}

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

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

/**
* vtkRegularPolygonSource is a source object that creates a single n-sided
* polygon and/or polyline. The polygon is centered at a specified point,
* orthogonal to a specified normal, and with a circumscribing radius set by the
* user. The user can also specify the number of sides of the polygon ranging
* from [3,N].
*
* @example
* ```js
* import vtkRegularPolygonSource from '@kitware/vtk.js/Filters/Sources/RegularPolygonSource';
*
* const regularPolygonSource = vtkRegularPolygonSource.newInstance();
* const polydata = regularPolygonSource.getOutputData();
* ```
*/
export declare const vtkRegularPolygonSource: {
newInstance: typeof newInstance;
extend: typeof extend;
};
export default vtkRegularPolygonSource;
Loading