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 PointCloud object containing only the points at the specified indices. The properties associated with the points are also filtered accordingly.

See also

Parameters:
  • indices (ArrayLike) – A 1D NumPy array of integer indices representing the points to be kept in the point cloud.

  • inplace (bool, optional) – If True, modifies the current point cloud in place and returns itself. If False, returns a new PointCloud instance (default is False).

Returns:

A new PointCloud object containing only the points at the specified indices or the modified current instance if inplace is True.

Return type:

PointCloud

Raises:

ValueError – If any index is out of bounds or if the input is not a 1D array of integers.

Examples

Create a PointCloud from 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