-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add Meshes to the pdal API #82
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
Can you verify that it doesn't leak PDAL objects?
Once this is merged, I'll make a new PDAL-python release.
I am not aware of any leaks and tried to follow the existing Array structure as closely as possible - but as usual I don't know what I don't know! |
Please add a test that does |
Will do - probably tomorrow |
@hobu Added tests and documentation |
2.4.0 pushed https://pypi.org/project/PDAL/ |
Adds the ability to access face data from meshes in the Python API:
pdal.Pipeline
calledget_meshes()
that returns a list ofndarray
in the same format asget_arrays()
. Eachndarray
represents one mesh from onePointView
and is a (1, size) array of Triangles, where each triangle is a tuple of(index of corner a, index of corner b, index of corner c)
- the index referring to the points inPointView
array.libpdalpython.pyx
to implement the above,Pipeline
class calledgetMeshes()
that returns a vector of PyMeshPyMesh
very much a copy of thePyArray
class, in this case the class creates the mesh ndarray.All of the above is working on my builds and does not introduce any new dependencies. However, I also wanted to create a way to create a useable Mesh object easily.
NOTE - where there is no mesh attached to the
PointView
,get_meshes
will return an ndarray with 0 rows to ensure that the correspondence between arrays and meshes can be retained.One good way of doing that is using the Meshio package - which allows the Mesh object to be re-used by a wide range of other packages.
So - I have also included the following :
pdal.Pipeline
calledget_meshio(idx: int) -> meshio.Mesh
. This usesget_meshes
andget_arrays
to create a Mesh object. At the moment it does not add the non-geometry data (a ToDo). This method requiresmeshio
and if it is not installed will fail with an informative error.Usage
The simplest usage would look like the following:
NOTE that since we are getting back a vector of meshes - we can do something that was not easy before and was actually the use-case that I needed to solve:
USE-CASE : Take a LiDAR map, create a mesh from the ground points, split into tiles and store the tiles in PostGIS.
(example using 1.2-with-color.las and not doing the ground classification for clarity)
This creates 24 tile meshes in PostGIS