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 vertices property is updated. This is much cheaper than a full rebuild (a single set('vertices', ...) call vs. one delete + one addpoly + ~6 set() 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:
structureDict[str, Any]

Structure dictionary from generate_structure() containing polygon vertices, index, and z-span information.

polygon_namestr, optional

Explicit polygon name override. When provided, takes precedence over structure.get('polygon_name') (which itself defaults to 'optimization_polygon'). Used by CombinedParametrization to give each ClosedCurve child a unique polygon in the FDTD CAD without mutating the child’s structure dict.