Index: DamTools/GeometryVisualizer/GeometryWithSurfPlot.py =================================================================== diff -u --- DamTools/GeometryVisualizer/GeometryWithSurfPlot.py (revision 0) +++ DamTools/GeometryVisualizer/GeometryWithSurfPlot.py (revision 5351) @@ -0,0 +1,55 @@ +import json +import matplotlib.pyplot as plt + +# Load JSON data +with open('GeometryWithSurf.json', 'r') as file: + data = json.load(file) + +# Extract points +DEFAULT_VALUE = 91919191919.987654321 +surfaces = data.get('Surfaces', []) +for surface in surfaces: + curves = surface.get('OuterLoop', {}).get('Curves', []) + + points = [] + previous_head_point = (DEFAULT_VALUE, DEFAULT_VALUE) + previous_end_point = (DEFAULT_VALUE, DEFAULT_VALUE) + for curve in curves: + head_point_element = curve.get('HeadPoint', {}) + end_point_element = curve.get('EndPoint', {}) + + head_point = (head_point_element['X'], head_point_element['Z']) + end_point = (end_point_element['X'], end_point_element['Z']) + if end_point == previous_head_point or end_point == previous_end_point: + head_point, end_point = end_point, head_point + + points.append(head_point) + points.append(end_point) + previous_head_point = head_point + previous_end_point = end_point + + + +# Plot points and lines + if points: + x_vals, z_vals = zip(*points) + plt.plot(x_vals, z_vals, marker='o') + +# Extract surfaceline +surfaceLine = data.get('Points', []) +surfpoints = [] +for surfpoint in surfaceLine: + surf_point = (surfpoint['X'], surfpoint['Z']) + surfpoints.append(surf_point) + +# Plot surfaceline +if surfpoints: + x_vals, z_vals = zip(*surfpoints) + plt.plot(x_vals, z_vals, marker='X', linestyle='dotted', linewidth='3') + + +# Add labels and grid +plt.xlabel('X') +plt.ylabel('Z') +plt.grid(True) +plt.show()