Thu, 21 Dec 2017 10:46:41 +0200
Smallest angles
#!/usr/bin/env python3 from parse import parse_ldraw_code from geometry import * def read_ldraw(file, *, libraries): result = list() for line in file: 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) min_angle_tup = (1e12,) for line_number, entry in enumerate(model, 1): if hasattr(entry, 'geometry') and len(entry.geometry) >= 3: 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)