pyvista / pyvista-support

[moved] Please head over to the Discussions tab of the PyVista repository
https://github.com/pyvista/pyvista/discussions
59 stars 4 forks source link

Controlling the thickness and orientation of a slice in Pyvista #517

Closed Ahmadalaili closed 2 years ago

Ahmadalaili commented 2 years ago

Description

Hello, I would like to ask if there is a possibility to control the thickness and orientation of a slice in Pyvista. For example, I have a 3D point cloud and a surface mesh of a tunnel in addition to its spline. Currently I am using Pyvista to slice and get cross sections of the tunnel at a specific x,y and z point. However, I didnt find any solution to control the thickness of the slice or the orientation of it. What I know is that the slice is computed parralel to the cartesian axis. Is there any modification to the code or a current existing pyvista solution for this prolem? Thank you in advance.

MatthewFlamm commented 2 years ago

https://docs.pyvista.org/api/core/_autosummary/pyvista.DataSetFilters.slice.html#pyvista.DataSetFilters.slice

The slice filter allows you to specify the normal direction and the origin point. This filter creates a 2D surface, therefore no thickness. If you want to give this 2D surface thickness, you could use the extrude filter.

Another option is to use either a threshold or clip functions to get a 3D section from the mesh. For example, the https://docs.pyvista.org/api/core/_autosummary/pyvista.DataSetFilters.clip_box.html could be used to specify a rectangular section in an orthogonal direction to the main axes. https://docs.pyvista.org/api/core/_autosummary/pyvista.DataSetFilters.clip_surface.html# would probably be more flexible.

Ahmadalaili commented 2 years ago

Thank you for the reply. Where can I find more details on the normal direction and how Pyvista handles it in terms of computing the slice, because I cant seem to find examples on manipulating the normal direction of the slice although I know how to activate it. Much appreciated for the reply.

MatthewFlamm commented 2 years ago

For slicing see the link I have earlier and https://docs.pyvista.org/examples/01-filter/slicing.html#slice-example