You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
970 B
Python
44 lines
970 B
Python
#! /usr/bin/python3
|
|
|
|
import sys
|
|
import re
|
|
from geo import Geo
|
|
|
|
show_triangles = False
|
|
|
|
def listGeo(fn, fh):
|
|
geo = Geo()
|
|
geo.loadFromFile(fh)
|
|
for m in geo.models:
|
|
s = "%s : %s" % (geo.header_modelheader_name.decode("utf-8"), m.name.decode("utf-8"))
|
|
if show_triangles:
|
|
s += " : %d" % (m.tris and len(m.tris) or 0, )
|
|
print(s)
|
|
|
|
def parseOption(opt):
|
|
global show_triangles
|
|
for c in opt[1:]:
|
|
if c == "t":
|
|
show_triangles = True
|
|
|
|
|
|
if len(sys.argv) <= 1:
|
|
print("Usage:")
|
|
print(" %s [<options>] <infile.geo>" % (sys.argv[0], ))
|
|
print("Options:")
|
|
print(" -t Display triangle count.")
|
|
exit()
|
|
|
|
|
|
for i in range(1, len(sys.argv)):
|
|
if sys.argv[i].startswith("-"):
|
|
parseOption(sys.argv[i])
|
|
continue
|
|
try:
|
|
fn = sys.argv[i]
|
|
fh = open(fn, "rb")
|
|
except:
|
|
print("Couldn't open '%s'." % (sys.argv[i], ))
|
|
continue
|
|
listGeo(fn, fh)
|