concatenate at `dim`.
(point_clouds: T.List['PointCloud'], dim: int)
| 418 | |
| 419 | @staticmethod |
| 420 | def cat(point_clouds: T.List['PointCloud'], dim: int) -> 'PointCloud': |
| 421 | """concatenate at `dim`.""" |
| 422 | |
| 423 | if dim == 0: |
| 424 | # check all point clouds have the same included_point_at_inf and n |
| 425 | for i in range(1, len(point_clouds)): |
| 426 | assert point_clouds[i].included_point_at_inf == point_clouds[0].included_point_at_inf |
| 427 | assert point_clouds[i].xyz_w.size(1) == point_clouds[0].xyz_w.size(1) |
| 428 | |
| 429 | out_dict = dict() |
| 430 | for name in point_clouds[0].attr_names: |
| 431 | arr = [getattr(p, name, None) for p in point_clouds] |
| 432 | if None in arr: |
| 433 | out_dict[name] = None |
| 434 | else: |
| 435 | out_dict[name] = torch.cat(arr, dim=dim) |
| 436 | |
| 437 | if len(point_clouds) > 0: |
| 438 | out_dict['included_point_at_inf'] = point_clouds[0].included_point_at_inf |
| 439 | else: |
| 440 | out_dict['included_point_at_inf'] = False |
| 441 | elif dim == 1: |
| 442 | out_dict = dict() |
| 443 | for name in point_clouds[0].attr_names: |
| 444 | arrs = [] |
| 445 | for i in range(len(point_clouds)): |
| 446 | arr = getattr(point_clouds[i], name, None) |
| 447 | if arr is not None: |
| 448 | if point_clouds[i].included_point_at_inf and i > 0: |
| 449 | start_idx = 1 # remove point at inf for i >= 1 |
| 450 | else: |
| 451 | start_idx = 0 |
| 452 | arr = arr[:, start_idx:] |
| 453 | arrs.append(arr) |
| 454 | |
| 455 | if None in arrs: |
| 456 | out_dict[name] = None |
| 457 | else: |
| 458 | out_dict[name] = torch.cat(arrs, dim=dim) |
| 459 | |
| 460 | if len(point_clouds) > 0: |
| 461 | out_dict['included_point_at_inf'] = point_clouds[0].included_point_at_inf |
| 462 | else: |
| 463 | out_dict['included_point_at_inf'] = False |
| 464 | else: |
| 465 | raise NotImplementedError |
| 466 | return PointCloud(**out_dict) |
| 467 | |
| 468 | def voxel_downsampling( |
| 469 | self, |
nothing calls this directly
no test coverage detected