update_polygon#
- FdtdSession.update_polygon(structure: Dict[str, Any], polygon_name: str | None = None)#
Create or update the optimization polygon in the FDTD CAD.
Two paths:
Fast path – if a polygon with the resolved name already exists, only the
verticesproperty is updated. This is much cheaper than a full rebuild (a singleset('vertices', ...)call vs. onedelete+ oneaddpoly+ ~6set()calls) and avoids the UI flicker that comes from removing and re-adding a structure with the FDTD CAD visible. This is the path taken for every dEps/dP finite-difference perturbation and for every per-iteration geometry update during optimization.Rebuild path – if the polygon does not exist yet (i.e. right after a fresh
setup_base_simulation), it is created from scratch with the full set of properties.
- Parameters:
- structure
Dict[str,Any] Structure dictionary from
generate_structure()containing polygon vertices, index, and z-span information.- polygon_name
str,optional Explicit polygon name override. When provided, takes precedence over
structure.get('polygon_name')(which itself defaults to'optimization_polygon'). Used byCombinedParametrizationto give eachClosedCurvechild a unique polygon in the FDTD CAD without mutating the child’sstructuredict.
- structure