-
-
Notifications
You must be signed in to change notification settings - Fork 397
feat(EllipseArcSource): add vtkEllipseArcSource #3300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
Sources/Filters/Sources/EllipseArcSource/example/controlPanel.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.