-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
65 lines (59 loc) · 1.87 KB
/
__main__.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
import __init__ as SphereDist
def show_version():
print("SphereDist version 0.8.3 by katahiromz")
def show_help():
print(
"SphereDist --- Equal distance distribution of vertexes on a sphere or a hemisphere.\n" +
"Usage: SphereDist [options] [output.tsv]\n" +
"Options:\n" +
" output.tsv Specify the output file (default: output.tsv)\n" +
" --number XXX Specify the value of N (default: 100)\n" +
" --hemisphere Use a half of sphere\n" +
" --no-relocate Don't relocate\n" +
" --help Show this message\n" +
" --version Show version info\n" +
"\n" +
"E-mail: katayama.hirofumi.mz@gmail.com\n")
def main():
import sys
hemisphere = False
no_relocate = False
N = 100
filename = ""
skip = False
for i in range(1, len(sys.argv)):
if skip:
skip = False
continue
arg = sys.argv[i]
if arg == "--help":
show_help()
return 0
if arg == "--version":
show_version()
return 0
if arg == "--hemisphere":
hemisphere = True
continue
if arg == "--no-relocate":
no_relocate = True
continue
if arg == "--number":
N = int(sys.argv[i + 1])
skip = True
continue
if arg[0] == "-":
print("SphereDist: Invalid argument '", arg, "'.")
return -1
if len(filename) == 0:
filename = arg
else:
printf("SphereDist: Too many arguments.")
return -2
if len(filename) == 0:
filename = "output.tsv"
sd = SphereDist.dist(N, hemisphere, not no_relocate)
sd.save(filename)
return 0
main()