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

Function main

scripts/highlight_non_oriented_edges.py:18–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16 return parser.parse_args();
17
18def main():
19 args = parse_args();
20 mesh = pymesh.load_mesh(args.input_mesh);
21 edge_faces = {};
22 for f in mesh.faces:
23 edges = [
24 sorted([f[0], f[1]]),
25 sorted([f[1], f[2]]),
26 sorted([f[2], f[0]]),
27 ];
28 for e in edges:
29 if tuple(e) in edge_faces:
30 edge_faces[tuple(e)].append(f);
31 else:
32 edge_faces[tuple(e)] = [f];
33
34 non_oriented_vertices = np.zeros(mesh.num_vertices);
35 for e,faces in edge_faces.items():
36 if e[0] == e[1]:
37 non_oriented_vertices[e[0]] = 1;
38 non_oriented_vertices[e[1]] = 1;
39 continue;
40
41 count = 0;
42 for f in faces:
43 if e[0] == f[0] and e[1] == f[1]:
44 count+=1;
45 if e[0] == f[1] and e[1] == f[2]:
46 count+=1;
47 if e[0] == f[2] and e[1] == f[0]:
48 count+=1;
49 if e[1] == f[0] and e[0] == f[1]:
50 count-=1;
51 if e[1] == f[1] and e[0] == f[2]:
52 count-=1;
53 if e[1] == f[2] and e[0] == f[0]:
54 count-=1;
55 if count != 0:
56 non_oriented_vertices[e[0]] = 1;
57 non_oriented_vertices[e[1]] = 1;
58
59 mesh.add_attribute("non_oriented");
60 mesh.set_attribute("non_oriented", non_oriented_vertices);
61 pymesh.save_mesh(args.output_mesh, mesh, "non_oriented");
62
63if __name__ == "__main__":
64 main();

Callers 1

Calls 6

parse_argsFunction · 0.70
tupleFunction · 0.50
load_meshMethod · 0.45
add_attributeMethod · 0.45
set_attributeMethod · 0.45
save_meshMethod · 0.45

Tested by

no test coverage detected