verify-export-triangle-reference.py 1.1 KB

12345678910111213141516
  1. """Regression at the exporter's pure triangle-reference seam; no bpy or scene startup."""
  2. import ast, math
  3. from pathlib import Path
  4. source = Path('tools/city-massing/assemble-cad-bim.py').read_text(encoding='utf8')
  5. functions = {'prism_triangles', 'facade_window_count', 'massing_triangles'}
  6. module = ast.Module(body=[n for n in ast.parse(source).body if isinstance(n, ast.FunctionDef) and n.name in functions], type_ignores=[])
  7. scope = {'math': math, 'ARCHITECTURE': True}
  8. exec(compile(module, 'triangle-reference-seam', 'exec'), scope)
  9. # A notch-sized edge must remain in the solid but cannot fit the 0.35m facade panel.
  10. ring = [(0,0),(.2,0),(.2,5),(0,5)]
  11. # 4*n-4 shell + 12 door + 2 long-wall windows * 2 triangles * 4 floors.
  12. assert scope['massing_triangles'](ring,4,'lod1') == 12+12+16
  13. scope['ARCHITECTURE'] = False
  14. # Original large rectangular case retains one window on every edge.
  15. assert scope['massing_triangles']([(0,0),(12,0),(12,9),(0,9)],3,'lod1') == 12+12+24
  16. print({'passed':True,'scope':'short surveyed edges counted only as shell; facade reference matches panel size guard','blenderStarted':False})