pysdic.PointCloud.keep_points#
- PointCloud.keep_points(indices, inplace=False)[source]#
Keep only the points at the specified indices in the point cloud.
This method returns a new
PointCloudobject containing only the points at the specified indices. The properties associated with the points are also filtered accordingly.See also
remove_points()for removing points at specified indices.filter_points()for filtering points based on a boolean mask.
- Parameters:
- Returns:
A new
PointCloudobject containing only the points at the specified indices or the modified current instance ifinplaceis True.- Return type:
- Raises:
ValueError – If any index is out of bounds or if the input is not a 1D array of integers.
Examples
Create a
PointCloudfrom a random NumPy array.1import numpy as np 2from pysdic import PointCloud 3 4# Create a random point cloud with 100 points 5random_points = np.random.rand(100, 3) # shape (100, 3) 6point_cloud = PointCloud.from_array(random_points)
Keeping only the points at indices 0, 2, and 4.
1# Keep only points at indices 0, 2, and 4 2indices_to_keep = np.array([0, 2, 4]) 3new_point_cloud = point_cloud.keep_points(indices_to_keep) 4print(new_point_cloud.points) 5# Output: A NumPy array of shape (3, 3) containing only the points at indices 0, 2, and 4