brain: add arc-aware inset boundary handling
This commit is contained in:
@@ -14,6 +14,7 @@ import numpy as np
|
||||
from shapely.geometry import Polygon
|
||||
|
||||
from src.atomizer_study import DEFAULT_PARAMS
|
||||
from src.shared.arc_utils import typed_segments_to_polyline
|
||||
from .density_field import evaluate_density_grid
|
||||
from .triangulation import generate_triangulation
|
||||
from .pocket_profiles import generate_pockets
|
||||
@@ -40,6 +41,15 @@ def _merge_params(geometry: Dict[str, Any], params_file: Path | None) -> Dict[st
|
||||
return params
|
||||
|
||||
|
||||
def _plot_boundary_polyline(geometry: Dict[str, Any], arc_pts: int = 64) -> np.ndarray:
|
||||
typed = geometry.get("outer_boundary_typed")
|
||||
if typed:
|
||||
pts = typed_segments_to_polyline(typed, arc_pts=arc_pts)
|
||||
if len(pts) >= 3:
|
||||
return np.asarray(pts, dtype=float)
|
||||
return np.asarray(geometry["outer_boundary"], dtype=float)
|
||||
|
||||
|
||||
def _plot_density(geometry: Dict[str, Any], params: Dict[str, Any], out_path: Path, resolution: float = 3.0) -> None:
|
||||
X, Y, eta = evaluate_density_grid(geometry, params, resolution=resolution)
|
||||
|
||||
@@ -47,7 +57,7 @@ def _plot_density(geometry: Dict[str, Any], params: Dict[str, Any], out_path: Pa
|
||||
m = ax.pcolormesh(X, Y, eta, shading="auto", cmap="viridis", vmin=0.0, vmax=1.0)
|
||||
fig.colorbar(m, ax=ax, label="Density η")
|
||||
|
||||
outer = np.asarray(geometry["outer_boundary"])
|
||||
outer = _plot_boundary_polyline(geometry)
|
||||
ax.plot(np.r_[outer[:, 0], outer[0, 0]], np.r_[outer[:, 1], outer[0, 1]], "w-", lw=1.5)
|
||||
|
||||
for hole in geometry.get("holes", []):
|
||||
@@ -73,7 +83,7 @@ def _plot_triangulation(geometry: Dict[str, Any], triangulation: Dict[str, Any],
|
||||
verts = triangulation["vertices"]
|
||||
tris = triangulation["triangles"]
|
||||
|
||||
outer = np.asarray(geometry["outer_boundary"])
|
||||
outer = _plot_boundary_polyline(geometry)
|
||||
plate_poly = ShapelyPolygon(outer)
|
||||
w_frame = (params or {}).get("w_frame", 2.0)
|
||||
inner_plate = plate_poly.buffer(-w_frame)
|
||||
@@ -133,7 +143,7 @@ def _plot_final_profile(geometry, pockets, ribbed_plate, out_path: Path, params:
|
||||
"""
|
||||
from shapely.geometry import Polygon as ShapelyPolygon
|
||||
|
||||
outer = np.asarray(geometry["outer_boundary"])
|
||||
outer = _plot_boundary_polyline(geometry)
|
||||
plate_poly = ShapelyPolygon(outer)
|
||||
w_frame = (params or {}).get("w_frame", 2.0)
|
||||
inner_plate = plate_poly.buffer(-w_frame)
|
||||
|
||||
Reference in New Issue
Block a user