MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / main

Function main

scripts/separate.py:29–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27 return args;
28
29def main():
30 args = parse_args();
31
32 mesh = load_mesh(args.mesh_in);
33 comps = separate_mesh(mesh, args.connectivity_type);
34
35 if args.highlight:
36 if (args.connectivity_type == "face"):
37 comp_indicator = np.zeros(mesh.num_faces);
38 elif (args.connectivity_type == "voxel"):
39 comp_indicator = np.zeros(mesh.num_voxels);
40 elif (mesh.num_voxels > 0):
41 comp_indicator = np.zeros(mesh.num_voxels);
42 else:
43 comp_indicator = np.zeros(mesh.num_faces);
44
45 for i in range(len(comps)):
46 elem_sources = comps[i].get_attribute("ori_elem_index")\
47 .ravel().astype(int);
48 comp_indicator[elem_sources] = i;
49 mesh.add_attribute("component_index");
50 mesh.set_attribute("component_index", comp_indicator);
51 save_mesh(args.mesh_out, mesh, *mesh.get_attribute_names());
52 else:
53 basename, ext = os.path.splitext(args.mesh_out);
54 for i,comp in enumerate(comps):
55 filename = "{}_cc{}{}".format(basename, i, ext);
56 save_mesh(filename, comp, *comp.get_attribute_names());
57
58if __name__ == "__main__":
59 main();

Callers 1

separate.pyFile · 0.70

Calls 9

load_meshFunction · 0.90
separate_meshFunction · 0.90
save_meshFunction · 0.90
enumerateFunction · 0.85
parse_argsFunction · 0.70
get_attributeMethod · 0.45
add_attributeMethod · 0.45
set_attributeMethod · 0.45
get_attribute_namesMethod · 0.45

Tested by

no test coverage detected