-
-
Notifications
You must be signed in to change notification settings - Fork 401
feat(CleanPolyData): add vtkCleanPolyData #3322
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
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
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
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
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
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
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
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
22 changes: 22 additions & 0 deletions
22
Sources/Filters/Core/CleanPolyData/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,22 @@ | ||
| <table> | ||
| <tr> | ||
| <td colspan="5"><b>Before(Left Cube)<b></td> | ||
| </tr> | ||
| <tr> | ||
| <td style="padding: 5px;">Points : <span class="initial-points">0</span></td> | ||
| <td style="padding: 5px;">Cells : <span class="initial-cells">0</span></td> | ||
| <td style="padding: 5px;">Lines : <span class="initial-lines">0</span></td> | ||
| <td style="padding: 5px;">Polys : <span class="initial-polys">0</span></td> | ||
| <td style="padding: 5px;">Strips : <span class="initial-strips">0</span></td> | ||
| </tr> | ||
| <tr> | ||
| <td colspan="5"><b>After(Right Cube)<b></td> | ||
| </tr> | ||
| <tr> | ||
| <td style="padding: 5px;">Points : <span class="final-points">0</span></td> | ||
| <td style="padding: 5px;">Cells : <span class="final-cells">0</span></td> | ||
| <td style="padding: 5px;">Lines : <span class="final-lines">0</span></td> | ||
| <td style="padding: 5px;">Polys : <span class="final-polys">0</span></td> | ||
| <td style="padding: 5px;">Strips : <span class="final-strips">0</span></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,116 @@ | ||
| 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 '@kitware/vtk.js/Rendering/Profiles/Glyph'; | ||
|
|
||
| import '@kitware/vtk.js/IO/Core/DataAccessHelper/HttpDataAccessHelper'; | ||
|
|
||
| import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor'; | ||
| import vtkCleanPolyData from '@kitware/vtk.js/Filters/Core/CleanPolyData'; | ||
| import vtkCubeSource from '@kitware/vtk.js/Filters/Sources/CubeSource'; | ||
| import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow'; | ||
| import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper'; | ||
| import vtkGlyph3DMapper from '@kitware/vtk.js/Rendering/Core/Glyph3DMapper'; | ||
| import vtkArrowSource from '@kitware/vtk.js/Filters/Sources/ArrowSource'; | ||
|
|
||
| import controlPanel from './controlPanel.html'; | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
| // Standard rendering code setup | ||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance(); | ||
| const renderer = fullScreenRenderer.getRenderer(); | ||
| const renderWindow = fullScreenRenderer.getRenderWindow(); | ||
|
|
||
| // ----------------------------------------------------------- | ||
| // UI control handling | ||
| // ----------------------------------------------------------- | ||
|
|
||
| fullScreenRenderer.addController(controlPanel); | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
| // Example code | ||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| const cubeSource1 = vtkCubeSource.newInstance(); | ||
| const cubeActor1 = vtkActor.newInstance(); | ||
| const cubeMapper1 = vtkMapper.newInstance(); | ||
| cubeActor1.setMapper(cubeMapper1); | ||
| cubeMapper1.setInputConnection(cubeSource1.getOutputPort()); | ||
| renderer.addActor(cubeActor1); | ||
|
|
||
| const arrowSource1 = vtkArrowSource.newInstance(); | ||
| const glyphMapper1 = vtkGlyph3DMapper.newInstance(); | ||
| glyphMapper1.setInputConnection(cubeSource1.getOutputPort()); | ||
| glyphMapper1.setSourceConnection(arrowSource1.getOutputPort()); | ||
| glyphMapper1.setOrientationModeToDirection(); | ||
| glyphMapper1.setOrientationArray('Normals'); | ||
| glyphMapper1.setScaleModeToScaleByMagnitude(); | ||
| glyphMapper1.setScaleArray('Normals'); | ||
| glyphMapper1.setScaleFactor(0.1); | ||
|
|
||
| const glyphActor1 = vtkActor.newInstance(); | ||
| glyphActor1.setMapper(glyphMapper1); | ||
| renderer.addActor(glyphActor1); | ||
|
|
||
| const cubeSource2 = vtkCubeSource.newInstance(); | ||
| const cubeActor2 = vtkActor.newInstance(); | ||
| const cubeMapper2 = vtkMapper.newInstance(); | ||
|
|
||
| cubeActor2.setMapper(cubeMapper2); | ||
| cubeMapper2.setInputConnection(cubeSource2.getOutputPort()); | ||
| cubeActor2.setPosition(2, 0, 0); | ||
| renderer.addActor(cubeActor2); | ||
|
|
||
| const cleanPolyData = vtkCleanPolyData.newInstance(); | ||
| cleanPolyData.setInputConnection(cubeSource2.getOutputPort()); | ||
|
|
||
| const arrowSource2 = vtkArrowSource.newInstance(); | ||
| const glyphMapper2 = vtkGlyph3DMapper.newInstance(); | ||
| glyphMapper2.setInputConnection(cleanPolyData.getOutputPort()); | ||
| glyphMapper2.setSourceConnection(arrowSource2.getOutputPort()); | ||
| glyphMapper2.setOrientationModeToDirection(); | ||
| glyphMapper2.setOrientationArray('Normals'); | ||
| glyphMapper2.setScaleModeToScaleByMagnitude(); | ||
| glyphMapper2.setScaleArray('Normals'); | ||
| glyphMapper2.setScaleFactor(0.1); | ||
|
|
||
| const glyphActor2 = vtkActor.newInstance(); | ||
| glyphActor2.setMapper(glyphMapper2); | ||
| glyphActor2.setPosition(2, 0, 0); | ||
| renderer.addActor(glyphActor2); | ||
|
|
||
| // --- Render --- | ||
| renderer.resetCamera(); | ||
| renderWindow.render(); | ||
|
|
||
| // ----------------------------------------------------------- | ||
| // Display initial and final polydata stats | ||
| // ----------------------------------------------------------- | ||
| const initialPolyData = cubeSource1.getOutputData(); | ||
| const initialPoints = initialPolyData.getNumberOfPoints(); | ||
| const initialCells = initialPolyData.getNumberOfCells(); | ||
| const initialLines = initialPolyData.getLines().getNumberOfCells(); | ||
| const initialPolys = initialPolyData.getPolys().getNumberOfCells(); | ||
| const initialStrips = initialPolyData.getStrips().getNumberOfCells(); | ||
|
|
||
| document.querySelector('.initial-points').textContent = initialPoints; | ||
| document.querySelector('.initial-cells').textContent = initialCells; | ||
| document.querySelector('.initial-lines').textContent = initialLines; | ||
| document.querySelector('.initial-polys').textContent = initialPolys; | ||
| document.querySelector('.initial-strips').textContent = initialStrips; | ||
|
|
||
| const finalPolyData = cleanPolyData.getOutputData(); | ||
| const finalPoints = finalPolyData.getNumberOfPoints(); | ||
| const finalCells = finalPolyData.getNumberOfCells(); | ||
| const finalLines = finalPolyData.getLines().getNumberOfCells(); | ||
| const finalPolys = finalPolyData.getPolys().getNumberOfCells(); | ||
| const finalStrips = finalPolyData.getStrips().getNumberOfCells(); | ||
|
|
||
| document.querySelector('.final-points').textContent = finalPoints; | ||
| document.querySelector('.final-cells').textContent = finalCells; | ||
| document.querySelector('.final-lines').textContent = finalLines; | ||
| document.querySelector('.final-polys').textContent = finalPolys; | ||
| document.querySelector('.final-strips').textContent = finalStrips; |
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.