add option in select_by_index() to reorder points in the order of the passed indices
- Dominant language
- C++
- Stars
- 14k
- Forks
- 2.6k
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 6
Description
### Checklist
- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [X] For Python issues, I have tested with the [latest development wheel](http://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](http://www.open3d.org/docs/release/) and the [latest documentation](http://www.open3d.org/docs/latest/) (for `master` branch).
### Proposed new feature or change
In the current implementation of select_by_index(), the order in which the indices are passed is irrelevant; the output cloud contains only the points indicated by those indices, but in the original order. That means that if we want to create a new cloud a subset of the indices in a particular order, now we can't, or we 'll have to do it manually.
It would be great to add an option (selectable by argument, eg sort_by_index: bool ), whereby the output cloud had its points ordered in the same order as the given indices.
For example, imagine we have a cloud with the following points:
```
>>> np.asarray(cloud.points)
array([[1., 0.,0.], [2., 0.,0.],[3., 0.,0.],[4., 0.,0.],[5., 0.,0.]])
```
if we run
`>>> cloud2 = cloud.select_by_index([3,2,1])`
The resulting pointcloud is:
```
>>> np.asarray(cloud2.points)
array([[2., 0., 0.], [3., 0., 0.], [4., 0., 0.]])
```
Which keeps the points in the order in which they are found in the original pointcloud, rather than re-sorting them in the given index order. In this case, the desired outcome would be:
```
>>> np.asarray(cloud2.points)
array([[4., 0., 0.], [3., 0., 0.], [2., 0., 0.]])
```
It would be great if select_by_index could get an additional bool argument sort_by_index (default to False so it wouldn't break anything, which, if set to true, returned the pointcloud with the points sorted in the order of the given indices.
Thanks!
### References
_No response_
### Additional information
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.