tidy3d.plugins.invdes.PolySlabSet#
- class PolySlabSet[source]#
Bases:
objectInverse-design contour representation enriched with frame metadata.
Attributes
Boolean per-vertex frame mask aligned with
polyslabsorder.All polyslabs in ordered ring sequence.
Ring types aligned with
polyslabsorder.Number of vertices for each ring in
polyslabsorder.Ring vertices aligned with
polyslabsorder.Methods
clip_to_bounds([bounds_xy])Hard clip ring vertices to
((x_min, y_min), (x_max, y_max)).Flatten all ring vertices into a
(2 * sum_i N_i,)vector.frame_boundary_mask_flat(*[, repeat_xy])Flatten frame-boundary masks into one boolean vector.
from_contour_data(contour_data, *[, ...])Create a polyslab set from shared contour-conversion output.
from_custom_medium(medium, *[, slab_bounds, ...])Create a polyslab set from a custom medium slice.
from_dataarray(data, *[, slab_bounds, axis, ...])Create a polyslab set from a permittivity data array.
from_polyslab(polyslab)Create a polyslab set from one solid polyslab with no frozen boundary vertices.
Maximum edge length over all rings.
safe_update(new_flat_vertices, *[, ...])Apply flattened vertex updates with best-effort self-intersection repair.
smooth(sigma)Return a copy with all ring vertices Gaussian-smoothed.
to_structures(*, foreground_medium, ...[, ...])Convert the polyslab set to foreground/background structures.
update(new_flat_vertices, *[, ...])Apply flattened vertex updates and return a new
PolySlabSet.with_flat_ring_vertices(flat_vertices)Return a copy from flattened ring-vertex vector.
with_ring_vertices(ring_vertices)Return a copy with updated ring vertices, preserving split + masks + metadata.
- solid_polyslabs#
- hole_polyslabs#
- solid_frame_boundary_vertex_mask#
- hole_frame_boundary_vertex_mask#
- frame_bounds#
- in_plane_step#
- static from_contour_data(contour_data, *, smooth_sigma=0.0)[source]#
Create a polyslab set from shared contour-conversion output.
- static from_custom_medium(medium, *, slab_bounds=None, axis=None, frequency=None, threshold=None, pixel_exact=False, boundary_step=None, smooth_sigma=0.0, min_hole_area=0.0, min_island_area=0.0)[source]#
Create a polyslab set from a custom medium slice.
- static from_dataarray(data, *, slab_bounds=None, axis=None, threshold=None, pixel_exact=False, boundary_step=None, smooth_sigma=0.0, min_hole_area=0.0, min_island_area=0.0)[source]#
Create a polyslab set from a permittivity data array.
- static from_polyslab(polyslab)[source]#
Create a polyslab set from one solid polyslab with no frozen boundary vertices.
- property ring_types#
Ring types aligned with
polyslabsorder.
- property polyslabs#
All polyslabs in ordered ring sequence.
- property ring_vertices#
Ring vertices aligned with
polyslabsorder.
- property ring_vertex_counts#
Number of vertices for each ring in
polyslabsorder.
- property frame_boundary_vertex_mask#
Boolean per-vertex frame mask aligned with
polyslabsorder.
- frame_boundary_mask_flat(*, repeat_xy=False)[source]#
Flatten frame-boundary masks into one boolean vector.
- with_ring_vertices(ring_vertices)[source]#
Return a copy with updated ring vertices, preserving split + masks + metadata.
- clip_to_bounds(bounds_xy=None)[source]#
Hard clip ring vertices to
((x_min, y_min), (x_max, y_max)).
- update(new_flat_vertices, *, freeze_boundary=True, respect_bounds=True, smooth_sigma=None)[source]#
Apply flattened vertex updates and return a new
PolySlabSet.- Parameters:
new_flat_vertices (ArrayFloat1D) – Replacement flattened vertex coordinates in the order returned by
flatten_ring_vertices().freeze_boundary (bool = True) – If
True, coordinates marked by the frame-boundary mask stay fixed at their current values instead of taking the proposed update.respect_bounds (bool = True) – If
True, clip every updated vertex back intoframe_boundsafter applying the update.smooth_sigma (float | None = None) – Optional cyclic Gaussian smoothing applied to each updated ring before frozen boundary coordinates are restored and bounds clipping is applied.
Noneskips smoothing;0.0is a no-op.
Notes
This is the raw update path and preserves the current strict behavior for invalid polygon proposals. Use
safe_update()for best-effort self-intersection repair plus an explicit repair status.
- safe_update(new_flat_vertices, *, freeze_boundary=True, respect_bounds=True, smooth_sigma=None)[source]#
Apply flattened vertex updates with best-effort self-intersection repair.
- Parameters:
new_flat_vertices (ArrayFloat1D) – Replacement flattened vertex coordinates in the order returned by
flatten_ring_vertices().freeze_boundary (bool = True) – If
True, coordinates marked by the frame-boundary mask stay fixed at their current values instead of taking the proposed update.respect_bounds (bool = True) – If
True, clip every updated vertex back intoframe_boundsafter applying the update.smooth_sigma (float | None = None) – Optional cyclic Gaussian smoothing applied to each updated ring before frozen boundary coordinates are restored and bounds clipping is applied.
Noneskips smoothing;0.0is a no-op.
- Returns:
The updated polyslab set and a status describing whether the full proposal was applied, a corrected update was found, or no valid corrected update could be found.
- Return type:
tuple[PolySlabSet, SelfIntersectionStatus]