forked from jupyter-widgets-contrib/ipygany
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: martinRenou <martin.renou@gmail.com>
- Loading branch information
1 parent
3ebb5e3
commit db10cc0
Showing
4 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,50 @@ | ||
WarpByScalar | ||
============ | ||
|
||
The ``WarpByScalar`` widget will modify the mesh geometry. | ||
|
||
It is similar to ``Paraview``, ``PyVista`` and ``vtk``'s warp-by-scalar effect, but instead of computing the transformation on the CPU, | ||
it is entirely computed on the GPU. Which means that changing the warp factor does not involve looping over the mesh vertices, | ||
we only send the new ``factor`` value to the GPU. | ||
|
||
The ``input`` attribute should be a 1-D data. For example, if your mesh has a 1-D ``Data`` named ``"height"``, your can set the input to be: | ||
|
||
.. code:: | ||
warped_mesh = WarpByScalar(mesh, input='height') # Warp by 'height' data | ||
Examples | ||
-------- | ||
|
||
.. code:: Python | ||
from pyvista import examples | ||
import numpy as np | ||
from ipywidgets import VBox, FloatSlider | ||
from ipygany import PolyMesh, Scene, IsoColor, WarpByScalar | ||
pvmesh = examples.download_topo_global() | ||
ugrid = pvmesh.cast_to_unstructured_grid() | ||
from ipygany import PolyMesh, Scene, IsoColor, WarpByScalar | ||
# Turn the PyVista mesh into a PolyMesh | ||
mesh = PolyMesh.from_vtk(ugrid) | ||
colored_mesh = IsoColor(mesh, min=-10421.0, max=6527.0) | ||
warped_mesh = WarpByScalar(colored_mesh, input='altitude', factor=0.5e-5) | ||
# Link a slider to the warp value | ||
warp_slider = FloatSlider(min=0., max=5., value=0.5) | ||
def on_slider_change(change): | ||
warped_mesh.factor = change['new'] * 1e-5 | ||
warp_slider.observe(on_slider_change, 'value') | ||
VBox((warp_slider, Scene([warped_mesh]))) | ||
.. image:: warpscalar.gif | ||
:alt: warpscalar |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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