tidy3d.plugins.invdes.PolySlabSet#

class PolySlabSet[source]#

Bases: object

Inverse-design contour representation enriched with frame metadata.

Attributes

frame_boundary_vertex_mask

Boolean per-vertex frame mask aligned with polyslabs order.

polyslabs

All polyslabs in ordered ring sequence.

ring_types

Ring types aligned with polyslabs order.

ring_vertex_counts

Number of vertices for each ring in polyslabs order.

ring_vertices

Ring vertices aligned with polyslabs order.

solid_polyslabs

hole_polyslabs

solid_frame_boundary_vertex_mask

hole_frame_boundary_vertex_mask

frame_bounds

in_plane_step

Methods

clip_to_bounds([bounds_xy])

Hard clip ring vertices to ((x_min, y_min), (x_max, y_max)).

flatten_ring_vertices()

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.

max_edge_length()

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 polyslabs order.

property polyslabs#

All polyslabs in ordered ring sequence.

property ring_vertices#

Ring vertices aligned with polyslabs order.

property ring_vertex_counts#

Number of vertices for each ring in polyslabs order.

property frame_boundary_vertex_mask#

Boolean per-vertex frame mask aligned with polyslabs order.

flatten_ring_vertices()[source]#

Flatten all ring vertices into a (2 * sum_i N_i,) vector.

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.

with_flat_ring_vertices(flat_vertices)[source]#

Return a copy from flattened ring-vertex vector.

clip_to_bounds(bounds_xy=None)[source]#

Hard clip ring vertices to ((x_min, y_min), (x_max, y_max)).

smooth(sigma)[source]#

Return a copy with all ring vertices Gaussian-smoothed.

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 into frame_bounds after 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. None skips smoothing; 0.0 is 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 into frame_bounds after 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. None skips smoothing; 0.0 is 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]

max_edge_length()[source]#

Maximum edge length over all rings.

to_structures(*, foreground_medium, background_medium, name_prefix='design_polyslab')[source]#

Convert the polyslab set to foreground/background structures.