Process multi-view dual grid conversion for a single sha256. Args: file: local_path from metadata sha256: sha256 string mesh_dump_root: directory containing mesh dump files transform_root: directory containing transform json files root: output di
(file, sha256, mesh_dump_root, transform_root, root, view_indices=None)
| 19 | |
| 20 | |
| 21 | def _dual_grid_mesh_view(file, sha256, mesh_dump_root, transform_root, root, view_indices=None): |
| 22 | """ |
| 23 | Process multi-view dual grid conversion for a single sha256. |
| 24 | |
| 25 | Args: |
| 26 | file: local_path from metadata |
| 27 | sha256: sha256 string |
| 28 | mesh_dump_root: directory containing mesh dump files |
| 29 | transform_root: directory containing transform json files |
| 30 | root: output directory for dual grids |
| 31 | view_indices: list of view indices to process, None for all views |
| 32 | """ |
| 33 | try: |
| 34 | pack = {'sha256': sha256} |
| 35 | vertices_sphere = None |
| 36 | sphere_radius = None |
| 37 | faces = None |
| 38 | |
| 39 | # Load transforms |
| 40 | transform_path = os.path.join(transform_root, sha256, 'transforms.json') |
| 41 | if not os.path.exists(transform_path): |
| 42 | print(f'Transform file not found for {sha256}, skipping') |
| 43 | return {'sha256': sha256, 'error': 'Transform file not found'} |
| 44 | |
| 45 | with open(transform_path, 'r') as f: |
| 46 | transforms_json = json.load(f) |
| 47 | transform_mats = transforms_json['frames'] |
| 48 | |
| 49 | # Determine views to process |
| 50 | if view_indices is None: |
| 51 | view_indices = list(range(len(transform_mats))) |
| 52 | else: |
| 53 | view_indices = [i for i in view_indices if i < len(transform_mats)] |
| 54 | |
| 55 | # Track processed and skipped counts |
| 56 | processed_count = 0 |
| 57 | skipped_count = 0 |
| 58 | |
| 59 | for view_idx in view_indices: |
| 60 | for res in opt.resolution: |
| 61 | need_process = False |
| 62 | |
| 63 | # Check if already processed |
| 64 | # Path structure: dual_grid_view_{res}/{sha256}/view{idx:02d}.vxz |
| 65 | sha256_dir = os.path.join(root, f'dual_grid_view_{res}', sha256) |
| 66 | vxz_path = os.path.join(sha256_dir, f'view{view_idx:02d}.vxz') |
| 67 | if os.path.exists(vxz_path): |
| 68 | try: |
| 69 | info = o_voxel.io.read_vxz_info(vxz_path) |
| 70 | pack[f'dual_grid_view{view_idx:02d}_converted_{res}'] = True |
| 71 | pack[f'dual_grid_view{view_idx:02d}_size_{res}'] = info['num_voxel'] |
| 72 | skipped_count += 1 |
| 73 | except Exception as e: |
| 74 | print(f'Error reading {sha256}/view{view_idx:02d}.vxz: {e}') |
| 75 | need_process = True |
| 76 | else: |
| 77 | need_process = True |
| 78 |
nothing calls this directly
no test coverage detected