#!/usr/bin/env python3 """Shared rendering helpers: member polygons, frames from *_frames.bin, load-displacement curves.""" import json, os, numpy as np import matplotlib.pyplot as plt from matplotlib.collections import PolyCollection, LineCollection ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) RUNS = os.path.join(ROOT, 'data', 'runs') LEVEL_COLORS = ['#1f3a93', '#2a7ab0', '#2aa198', '#5fb760', '#b0c23a', '#e0a020', '#e06020', '#c02040', '#8a2080', '#503090', '#304090', '#203070'] def load_run(id_): with open(os.path.join(RUNS, id_ + '.json')) as f: return json.load(f) def load_frames(run): if not run.get('framesFile'): return None idx = json.load(open(os.path.join(RUNS, run['id'] + '_frames.json'))) N, E, n = idx['N'], idx['E'], idx['nFrames']; per = 2 * N + 2 * E buf = np.fromfile(os.path.join(RUNS, run['framesFile']), dtype='