PointCloud structures#
PointCloud class#
- class PointCloud(points, n_dimensions=None, properties=None)[source]#
A class representing a \(E\)-dimensional point cloud, which is a collection of \(N_p\) points in a \(E\)-dimensional space.
Point clouds can store any scalar/vector properties associated with each point in the cloud.
Note
The dimension \(E\) of the cloud is not designed to change after point cloud creation.
Note
The coordinates and the properties of the points are stored as copy-on-write (cow) NumPy arrays of type
numpy.float64. Accesing these arrays directly will return unwritable views to prevent accidental modifications.- Parameters:
points (ArrayLike) – A NumPy array of shape \((N_{p}, E)\) representing the coordinates of the points.
n_dimensions (Optional[Integral])
properties (Optional[Dict[str, ArrayLike]])
- n_dimensions: Integral, optional
The dimension \(E\) of the point cloud. If not provided, it is inferred from the shape of the
pointsarray. Ifpointssecond dimension is less thann_dimensions, the points will be reshaped accordingly and filled with zeros. Ifpointssecond dimension is greater thann_dimensions, a ValueError will be raised. Default isNone.- properties: Optional[Dict[
str, ArrayLike]], optional A dictionary of additional properties to associate with the point cloud. Keys are property names, and values are NumPy arrays of property data of shape \((N_{p}, A)\) where \(A\) is the number of attributes per point for the given property. Default is
None, meaning no additional properties are set.
- Raises:
TypeError – If the input points is not a NumPy array. If the given dimension is not an integer. If the properties is not a dictionary of string keys and NumPy array values.
ValueError – If the input array does not have the correct shape. If the given dimension is not a strictly positive integer. If the properties arrays do not have the correct shape.
- Parameters:
points (ArrayLike)
n_dimensions (Optional[Integral])
properties (Optional[Dict[str, ArrayLike]])
Instantiate and export PointCloud object#
To Instantiate a PointCloud object, use one of the following class methods:
|
Create a |
|
Create a |
|
Create a |
|
Create a |
The PointCloud can then be exported to different formats using the following methods:
Convert the point cloud to a NumPy array of shape \((N_p, E)\). |
|
|
Convert the point cloud to a |
|
Save the point cloud to a VTK file (only for \(E=3\) point clouds). |
|
Save the point cloud to a NumPy NPZ file. |
Accessing PointCloud attributes#
The public attributes of a PointCloud object can be accessed using the following properties:
[Get or Set] Alias for |
|
[Get or Set] An numpy array of shape \((N_p, E)\) representing the coordinates of the points in the cloud. |
|
[Get] The dimension \(E\) of the point cloud. |
|
[Get] The number of points \(N_p\) in the point cloud. |
|
[Get] The shape of the points array (\(N_p\), \(E\)). |
Add and manage PointCloud points properties#
The properties of the points in a PointCloud object can be managed using the following methods:
Note
Point properties are stored as named NumPy arrays of shape \((N_p, A)\) where \(N_p\) is the number of points and \(A\) is the number of property components (e.g., 3 for RGB color).
All the point properties must have the same number of points as the PointCloud object and are stored as numpy.float64 arrays.
|
Set a property for the point cloud as a NumPy array of shape \((N_p, A)\) where \(A\) is the number of attributes per point for the given property. |
Get a property of the point cloud by its key/name. |
|
Check if the point cloud has a property with the given key/name. |
|
Delete a property of the point cloud by its key/name. |
|
List all property keys/names associated with the point cloud. |
|
Return a copy of all properties of the point cloud. |
|
Remove all properties from the point cloud. |
Add, remove or modify points in PointCloud objects#
The points of a PointCloud object can be manipulated using the following methods:
|
Check if all points in the current point cloud are approximately equal to the points in another |
Check if all points in the point cloud are finite (i.e., not NaN or infinite). |
|
|
Concatenate the current point cloud with another |
|
Create a copy of the current |
|
Filter points in the point cloud based on a boolean mask. |
|
Transform the point cloud from an input frame of reference to an output frame of reference (only for 3D point clouds). |
Check which points in the point cloud are finite (not NaN or infinite). |
|
Check which points in the point cloud are NaN. |
|
|
Keep only the points at the specified indices in the point cloud. |
|
Remove points from the point cloud that contain non-finite values (NaN or Inf). |
|
Remove points from the point cloud based on their indices. |
PointCloud object geometric computations#
The following methods can be used to perform geometric computations on PointCloud objects:
Compute the axis-aligned bounding box of the point cloud. |
|
Compute the bounding sphere of the point cloud. |
Visualize PointCloud object (1D, 2D, 3D only)#
The PointCloud class provides a method to visualize the point cloud in 1D, 2D, or 3D space using pyvista:
|
Visualize the point cloud using PyVista (only for \(E \leq 3\) point clouds). |