-
-
Notifications
You must be signed in to change notification settings - Fork 394
feat(PlatonicSolidSource): add vtkPlatonicSolidSource #3308
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
+777
−0
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
12 changes: 12 additions & 0 deletions
12
Sources/Filters/Sources/PlatonicSolidSource/Constants.d.ts
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,12 @@ | ||
export declare enum SolidType { | ||
VTK_SOLID_TETRAHEDRON = 0, | ||
VTK_SOLID_CUBE = 1, | ||
VTK_SOLID_OCTAHEDRON = 2, | ||
VTK_SOLID_ICOSAHEDRON = 3, | ||
VTK_SOLID_DODECAHEDRON = 4, | ||
} | ||
|
||
declare const _default: { | ||
SolidType: typeof SolidType; | ||
}; | ||
export default _default; |
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,11 @@ | ||
export const SolidType = { | ||
VTK_SOLID_TETRAHEDRON: 0, | ||
VTK_SOLID_CUBE: 1, | ||
VTK_SOLID_OCTAHEDRON: 2, | ||
VTK_SOLID_ICOSAHEDRON: 3, | ||
VTK_SOLID_DODECAHEDRON: 4, | ||
}; | ||
|
||
export default { | ||
SolidType, | ||
}; |
14 changes: 14 additions & 0 deletions
14
Sources/Filters/Sources/PlatonicSolidSource/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,14 @@ | ||
<table> | ||
<tr> | ||
<td>Solid Type</td> | ||
<td> | ||
<select name="solidType"> | ||
<option value="VTK_SOLID_TETRAHEDRON">Tetrahedron</option> | ||
<option value="VTK_SOLID_CUBE">Cube</option> | ||
<option value="VTK_SOLID_OCTAHEDRON">Octahedron</option> | ||
<option value="VTK_SOLID_DODECAHEDRON">Dodecahedron</option> | ||
<option value="VTK_SOLID_ICOSAHEDRON">Icosahedron</option> | ||
</select> | ||
</td> | ||
</tr> | ||
</table> |
67 changes: 67 additions & 0 deletions
67
Sources/Filters/Sources/PlatonicSolidSource/example/index.js
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,67 @@ | ||
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 vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper'; | ||
import vtkPlatonicSolidSource from '@kitware/vtk.js/Filters/Sources/PlatonicSolidSource'; | ||
import { SolidType } from '@kitware/vtk.js/Filters/Sources/PlatonicSolidSource/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 platonicSolidSource = vtkPlatonicSolidSource.newInstance({ | ||
solidType: SolidType.VTK_SOLID_DODECAHEDRON, | ||
}); | ||
|
||
const mapper = vtkMapper.newInstance(); | ||
const actor = vtkActor.newInstance(); | ||
|
||
mapper.setInputConnection(platonicSolidSource.getOutputPort()); | ||
actor.setMapper(mapper); | ||
|
||
renderer.addActor(actor); | ||
renderer.resetCamera(); | ||
renderWindow.render(); | ||
|
||
// ----------------------------------------------------------- | ||
// UI control handling | ||
// ----------------------------------------------------------- | ||
|
||
fullScreenRenderer.addController(controlPanel); | ||
|
||
const solidTypeSelect = document.querySelector('select[name="solidType"]'); | ||
solidTypeSelect.addEventListener('change', (event) => { | ||
const solidType = event.target.value; | ||
platonicSolidSource.setSolidType(SolidType[solidType.toUpperCase()]); | ||
renderWindow.render(); | ||
}); | ||
|
||
// Set the initial value of the select element | ||
solidTypeSelect.value = 'VTK_SOLID_DODECAHEDRON'; | ||
|
||
// Render the initial state | ||
renderWindow.render(); | ||
|
||
// ----------------------------------------------------------- | ||
// Make some variables global so that you can inspect and | ||
// modify objects in your browser's developer console: | ||
// ----------------------------------------------------------- | ||
|
||
global.platonicSolidSource = platonicSolidSource; | ||
global.mapper = mapper; | ||
global.actor = actor; | ||
global.renderer = renderer; | ||
global.renderWindow = renderWindow; |
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,109 @@ | ||
import { vtkAlgorithm, vtkObject } from '../../../interfaces'; | ||
import { DesiredOutputPrecision } from '../../../Common/DataModel/DataSetAttributes'; | ||
import { SolidType } from './Constants'; | ||
|
||
/** | ||
* | ||
*/ | ||
export interface IPlatonicSolidSourceInitialValues { | ||
solidType?: SolidType; | ||
outputPointsPrecision?: DesiredOutputPrecision; | ||
scale?: number; | ||
} | ||
|
||
type vtkPlatonicSolidSourceBase = vtkObject & | ||
Omit< | ||
vtkAlgorithm, | ||
| 'getInputData' | ||
| 'setInputData' | ||
| 'setInputConnection' | ||
| 'getInputConnection' | ||
| 'addInputConnection' | ||
| 'addInputData' | ||
>; | ||
|
||
export interface vtkPlatonicSolidSource extends vtkPlatonicSolidSourceBase { | ||
/** | ||
* Get the desired output precision. | ||
* @returns {DesiredOutputPrecision} | ||
*/ | ||
getOutputPointsPrecision(): DesiredOutputPrecision; | ||
|
||
/** | ||
* Get the scale factor of the source. | ||
*/ | ||
getScale(): number; | ||
|
||
/** | ||
* Get the solid type of the source. | ||
* @returns {SolidType} | ||
*/ | ||
getSolidType(): SolidType; | ||
|
||
/** | ||
* Request data for the source. | ||
* @param inData | ||
* @param outData | ||
*/ | ||
requestData(inData: any, outData: any): void; | ||
|
||
/** | ||
* Set the desired output precision. | ||
* @param {DesiredOutputPrecision} outputPointsPrecision | ||
*/ | ||
setOutputPointsPrecision( | ||
outputPointsPrecision: DesiredOutputPrecision | ||
): boolean; | ||
|
||
/** | ||
* Set the scale factor of the source. | ||
* @param {Number} scale The scale factor. | ||
*/ | ||
setScale(scale: number): boolean; | ||
|
||
/** | ||
* Set the solid type of the source. | ||
* @param {SolidType} solidType | ||
*/ | ||
setSolidType(solidType: SolidType): boolean; | ||
} | ||
|
||
/** | ||
* Method used to decorate a given object (publicAPI+model) with vtkPlatonicSolidSource characteristics. | ||
* | ||
* @param publicAPI object on which methods will be bounds (public) | ||
* @param model object on which data structure will be bounds (protected) | ||
* @param {IPlatonicSolidSourceInitialValues} [initialValues] (default: {}) | ||
*/ | ||
export function extend( | ||
publicAPI: object, | ||
model: object, | ||
initialValues?: IPlatonicSolidSourceInitialValues | ||
): void; | ||
|
||
/** | ||
* Method used to create a new instance of vtkPlatonicSolidSource. | ||
* @param {IPlatonicSolidSourceInitialValues} [initialValues] for pre-setting some of its content | ||
*/ | ||
export function newInstance( | ||
initialValues?: IPlatonicSolidSourceInitialValues | ||
): vtkPlatonicSolidSource; | ||
|
||
/** | ||
* vtkPlatonicSolidSource can generate each of the five Platonic solids: | ||
* tetrahedron, cube, octahedron, icosahedron, and dodecahedron. Each of the | ||
* solids is placed inside a sphere centered at the origin with radius 1.0. | ||
* | ||
* @example | ||
* ```js | ||
* import vtkPlatonicSolidSource from '@kitware/vtk.js/Filters/Sources/RegularPolygonSource'; | ||
* | ||
* const regularPolygonSource = vtkPlatonicSolidSource.newInstance(); | ||
* const polydata = regularPolygonSource.getOutputData(); | ||
* ``` | ||
*/ | ||
export declare const vtkPlatonicSolidSource: { | ||
newInstance: typeof newInstance; | ||
extend: typeof extend; | ||
}; | ||
export default vtkPlatonicSolidSource; |
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.