forked from PyMesh/PyMesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convex_hull.py
executable file
·33 lines (28 loc) · 936 Bytes
/
convex_hull.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
"""
Compute the convex hull of a given mesh.
"""
import argparse
import pymesh
import numpy as np
def parse_args():
parser = argparse.ArgumentParser(__doc__);
parser.add_argument("--engine", default="qhull",
choices=["qhull", "cgal", "triangle", "tetgen"]);
parser.add_argument("--with-timing", help="output timing info",
action="store_true");
parser.add_argument("input_mesh");
parser.add_argument("output_mesh");
return parser.parse_args();
def main():
args = parse_args();
mesh = pymesh.load_mesh(args.input_mesh, drop_zero_dim=True);
r = pymesh.convex_hull(mesh, args.engine, args.with_timing);
if args.with_timing:
hull, running_time = r;
print("Running time: {}s".format(running_time));
else:
hull = r;
pymesh.save_mesh(args.output_mesh, hull, *hull.attribute_names);
if __name__ == "__main__":
main();