diff -r 6da1e81c5652 -r 0ab0d61ccee8 ldverify.py --- a/ldverify.py Wed Dec 20 17:25:09 2017 +0200 +++ b/ldverify.py Thu Dec 21 10:46:41 2017 +0200 @@ -1,5 +1,6 @@ #!/usr/bin/env python3 from parse import parse_ldraw_code +from geometry import * def read_ldraw(file, *, libraries): result = list() @@ -7,13 +8,23 @@ result.append(parse_ldraw_code(line)) return result +def hairline_score(smallest_angle): + from math import log10 + return max(0, -log10(smallest_angle)) + if __name__ == '__main__': from sys import argv libraries = [{'path': '/home/teemu/ldraw', 'role': 'official'}] with open(argv[1], 'r') as file: model = read_ldraw(file, libraries = libraries) - for entry in model: + min_angle_tup = (1e12,) + for line_number, entry in enumerate(model, 1): if hasattr(entry, 'geometry') and len(entry.geometry) >= 3: - print(repr(entry)) - print(entry.geometry.area()) - #print(entry.textual_representation().strip(), end = '\r\n') + if hairline_score(entry.geometry.smallest_angle) >= 2.0: + print(str.format( + 'Hairline {type} at line {line_number}', + type = entry.typename(), + line_number = line_number, + )) + print(entry.textual_representation()) + print('-' * 25) \ No newline at end of file