# Path: antitile/off.py
# def readline_comment(file, symbol='#'):
# def load_off(file):
# def write_off(vertices, faces, facecolors=None, edges=None, edgecolors=None,
#               verts=None, vertexcolors=None):
# 
# Path: antitile/tiling.py
# class Tiling:
#     def __init__(self, vertices, faces):
#     def edges(self):
#     def face_size(self):
#     def faces_by_size(self):
#     def face_normals(self):
#     def true_faces(self):
#     def faces_by_edge(self, edges):
#     def vertex_adjacency(self):
#     def face_adjacency(self):
#     def face_vertex_incidence(self):
#     def vertex_f_adjacency(self):
#     def face_v_adjacency(self):
#     def normalize_faces(self):
#     def id_dupe_faces(self, face_group=None, oriented=False):
# def edges_from_facelist(faces):
# def orient_face(face, edge):
# def energy(xyz, exponent=1, over=None):
# def center_of_gravity(xyz):
# def bentness(xyz, poly):
# def edge_length(xyz, edges, spherical=False):
# def face_area(xyz, poly, spherical=False):
# def aspect_ratio(xyz, poly, spherical=False):


import argparse
import csv
import glob
import numpy as np
from sys import stdin
from antitile import off, tiling
Statistics of polyhedra, with a focus on using similar grid subdivision
polyhedra to approximate the sphere
"""

def main():
    desc = "Statistics of a tiling that are relevant to use as a grid"
    parser = argparse.ArgumentParser(description=desc)
    parser.add_argument("filename", nargs='*',
                        help="Input files. Reads from stdin if not given.")
    parser.add_argument("-s", action="store_true",
                        help="Suppress spherical measures")
    parser.add_argument("-c", help="Write to csv file")

    args = parser.parse_args()
    header = ['filename', 'n_v', 'n_f', 'energy', 'cog', 'bent_min',
              'bent_max', 'edge_min', 'edge_max', 'aspect_ratio_min',
              'aspect_ratio_max', 'faces_min', 'faces_max']
    if not args.s:
        header += ['angle_min', 'angle_max', 'angle_aspect_min',
                   'angle_aspect_max', 'solid_angle_min', 'solid_angle_max']

    lines = [header]
    if len(args.filename) == 1 and '*' in args.filename[0]:
        handles = ((fn, open(fn)) for fn in glob.iglob(args.filename[0]))
    elif args.filename:
        handles = ((fn, open(fn)) for fn in args.filename)
    else:
        handles = [('stdin', stdin)]
    for fn, h in handles:
        with h as handle:

# Path: antitile/off.py
# def readline_comment(file, symbol='#'):
# def load_off(file):
# def write_off(vertices, faces, facecolors=None, edges=None, edgecolors=None,
#               verts=None, vertexcolors=None):
# 
# Path: antitile/tiling.py
# class Tiling:
#     def __init__(self, vertices, faces):
#     def edges(self):
#     def face_size(self):
#     def faces_by_size(self):
#     def face_normals(self):
#     def true_faces(self):
#     def faces_by_edge(self, edges):
#     def vertex_adjacency(self):
#     def face_adjacency(self):
#     def face_vertex_incidence(self):
#     def vertex_f_adjacency(self):
#     def face_v_adjacency(self):
#     def normalize_faces(self):
#     def id_dupe_faces(self, face_group=None, oriented=False):
# def edges_from_facelist(faces):
# def orient_face(face, edge):
# def energy(xyz, exponent=1, over=None):
# def center_of_gravity(xyz):
# def bentness(xyz, poly):
# def edge_length(xyz, edges, spherical=False):
# def face_area(xyz, poly, spherical=False):
# def aspect_ratio(xyz, poly, spherical=False):


# Path: bin/gcostats.py
import argparse
import csv
import glob
import numpy as np
from sys import stdin
from antitile import off, tiling

Statistics of polyhedra, with a focus on using similar grid subdivision
polyhedra to approximate the sphere
"""

def main():
    desc = "Statistics of a tiling that are relevant to use as a grid"
    parser = argparse.ArgumentParser(description=desc)
    parser.add_argument("filename", nargs='*',
                        help="Input files. Reads from stdin if not given.")
    parser.add_argument("-s", action="store_true",
                        help="Suppress spherical measures")
    parser.add_argument("-c", help="Write to csv file")

    args = parser.parse_args()
    header = ['filename', 'n_v', 'n_f', 'energy', 'cog', 'bent_min',
              'bent_max', 'edge_min', 'edge_max', 'aspect_ratio_min',
              'aspect_ratio_max', 'faces_min', 'faces_max']
    if not args.s:
        header += ['angle_min', 'angle_max', 'angle_aspect_min',
                   'angle_aspect_max', 'solid_angle_min', 'solid_angle_max']

    lines = [header]
    if len(args.filename) == 1 and '*' in args.filename[0]:
        handles = ((fn, open(fn)) for fn in glob.iglob(args.filename[0]))
    elif args.filename:
        handles = ((fn, open(fn)) for fn in args.filename)
    else:
        handles = [('stdin', stdin)]
    for fn, h in handles:
        with h as handle:

            vertices, faces, fc, e, ec, v, vc = off.load_off(handle)