()
| 27 | return args; |
| 28 | |
| 29 | def 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 | |
| 58 | if __name__ == "__main__": |
| 59 | main(); |
no test coverage detected