MCPcopy Create free account
hub / github.com/apple/ml-pointersect / generated_cleaned_mesh

Function generated_cleaned_mesh

plib/preprocess_obj.py:16–59  ·  view source on GitHub ↗

Generate a cleaned mesh in the new directory. Args: input_dir: input folder of the mesh (obj) output_dir: output folder of the mesh (obj) relative_filepath: filename / relative path of the mesh (obj) skip_exist: if true, skip if the cleaned mesh already exis

(
        input_dir: str,
        output_dir: str,
        relative_filepath: str,
        skip_exist: bool = True,
        printout: bool = True,
)

Source from the content-addressed store, hash-verified

14
15
16def generated_cleaned_mesh(
17 input_dir: str,
18 output_dir: str,
19 relative_filepath: str,
20 skip_exist: bool = True,
21 printout: bool = True,
22) -> str:
23 """
24 Generate a cleaned mesh in the new directory.
25
26 Args:
27 input_dir: input folder of the mesh (obj)
28 output_dir: output folder of the mesh (obj)
29 relative_filepath: filename / relative path of the mesh (obj)
30 skip_exist: if true, skip if the cleaned mesh already exists.
31
32 Returns:
33 full path of the output file
34 """
35
36 # check whether the cleaned obj already exists
37 output_filepath = os.path.join(output_dir, relative_filepath)
38
39 if printout:
40 print(f'cleaning {os.path.join(input_dir, relative_filepath)} to {output_filepath}')
41
42 if os.path.exists(output_filepath) and skip_exist:
43 if printout:
44 print(f'cleaned file {output_filepath} exists, skipped', flush=True)
45 return output_filepath
46
47 # Copy the obj and related files to new dir
48 output_mtl_filepath = copy_obj_files(
49 input_dir=input_dir,
50 output_dir=output_dir,
51 relative_filepath=relative_filepath,
52 )
53
54 # Handle non-textured mesh
55 map_kd_value_to_textures(output_mtl_filepath)
56 # Remove duplicated mesh with smaller face scalar
57 remove_redundant_face(output_filepath)
58
59 return output_filepath
60
61
62def copy_obj_files(

Callers

nothing calls this directly

Calls 3

copy_obj_filesFunction · 0.85
map_kd_value_to_texturesFunction · 0.85
remove_redundant_faceFunction · 0.85

Tested by

no test coverage detected