Средство просмотра Pyvista для динамического облака точек ⇐ Python
Средство просмотра Pyvista для динамического облака точек
Following https://tutorial.pyvista.org/tutorial/0 ... idget.html, I need pyvista to visualize a point cloud, not a mesh like in the example.
This point cloud may change according to dynamic parameter (slider).
This doesn't work: the point cloud is unchanged.
>> cat pv_pc.py #!/usr/bin/env python3 import os import sys import numpy as np import pyvista as pv class CustomEngine: def __init__(self, points): # Expected PyVista output. self.points = points self.output = pv.PolyData(self.points) # PyVista output. # Default parameters. self.kwargs = { 'nb_pts': -1, } def __call__(self, param, value): # Callback handling parameter change. self.kwargs[param] = value self.update() def update(self): # Update view on callback. self.points = np.random.uniform(0, self.kwargs['nb_pts'], [1000, 3]) self.output = pv.PolyData(self.points) # PyVista output. return def main(): # Generate random point cloud. val = 100 points = np.random.uniform(0, val, [1000, 3]) # View point cloud with pyvista. engine = CustomEngine(points) pl = pv.Plotter() pl.add_slider_widget( callback=lambda value: engine('nb_pts', int(value)), rng=[1, 1000], value=val, title="nb_pts", pointa=(0.05, 0.1), pointb=(0.95, 0.1), style='modern', ) pl.add_points( points, scalars=points[:, 2], render_points_as_spheres=True, point_size=5, show_scalar_bar=False, ) pl.show() if __name__ == "__main__": main() >> python pv_pc.py Seems the engine (instance of MyCustomRoutine) doesn't change the data to view: how to fix this?
Источник: https://stackoverflow.com/questions/780 ... oint-cloud
Following https://tutorial.pyvista.org/tutorial/0 ... idget.html, I need pyvista to visualize a point cloud, not a mesh like in the example.
This point cloud may change according to dynamic parameter (slider).
This doesn't work: the point cloud is unchanged.
>> cat pv_pc.py #!/usr/bin/env python3 import os import sys import numpy as np import pyvista as pv class CustomEngine: def __init__(self, points): # Expected PyVista output. self.points = points self.output = pv.PolyData(self.points) # PyVista output. # Default parameters. self.kwargs = { 'nb_pts': -1, } def __call__(self, param, value): # Callback handling parameter change. self.kwargs[param] = value self.update() def update(self): # Update view on callback. self.points = np.random.uniform(0, self.kwargs['nb_pts'], [1000, 3]) self.output = pv.PolyData(self.points) # PyVista output. return def main(): # Generate random point cloud. val = 100 points = np.random.uniform(0, val, [1000, 3]) # View point cloud with pyvista. engine = CustomEngine(points) pl = pv.Plotter() pl.add_slider_widget( callback=lambda value: engine('nb_pts', int(value)), rng=[1, 1000], value=val, title="nb_pts", pointa=(0.05, 0.1), pointb=(0.95, 0.1), style='modern', ) pl.add_points( points, scalars=points[:, 2], render_points_as_spheres=True, point_size=5, show_scalar_bar=False, ) pl.show() if __name__ == "__main__": main() >> python pv_pc.py Seems the engine (instance of MyCustomRoutine) doesn't change the data to view: how to fix this?
Источник: https://stackoverflow.com/questions/780 ... oint-cloud
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Ищу рекомендации по извлечению облака точек и измерений лица из сканированных объектов.
Anonymous » » в форуме IOS - 0 Ответы
- 97 Просмотры
-
Последнее сообщение Anonymous
-