Render methods

DeviceLayout.render!Function
render!(c::Cell, p::Polygon, meta::GDSMeta=GDSMeta())

Render a polygon p to cell c, defaulting to plain styling. If p has more than 8190 (set by DeviceLayout's GDS_POLYGON_MAX constant), then it is partitioned into smaller polygons which are then rendered. Environment variable ENV["GDS_POLYGON_MAX"] will override this constant. The partitioning algorithm implements guillotine cutting, that goes through at least one existing vertex and in manhattan directions. Cuts are selected by ad hoc optimzation for "nice" partitions.

source
render!(c::CoordinateSystem, ent, meta)

Synonym for place!.

source
render!(cell::Cell{S}, cs::GeometryStructure;
    memoized_cells=Dict{CoordinateSystem, Cell}(),
    map_meta = identity,
    kwargs...) where {S}

Render a geometry structure (e.g., CoordinateSystem) to a cell.

Passes each element and its metadata (mapped by map_meta if a method is supplied) to render!(::Cell, element, ::Meta), traversing the references such that if a CoordinateSystem is referred to in multiple places, it will become a single cell referred to in multiple places.

Rendering a GeometryEntity to a Cell uses the optional keyword arguments

  • map_meta, a function that takes a Meta object and returns another Meta object (or nothing, in which case rendering is skipped)

Usage note: calling this function with non-empty dictionary memoized_cells = Dict{CoordinateSystem, Cell}(cs => cell) is effectively a manual override that forces cs to render as cell.

source
render!(sm::SolidModel, cs::AbstractCoordinateSystem{T}; map_meta=layer, postrender_ops=[], zmap=(_) -> zero(T), kwargs...) where {T}

Render cs to sm.

Keywords

  • map_meta: Function (m::SemanticMeta) -> name of PhysicalGroup (as String or Symbol; may also return nothing to skip rendering m)
  • postrender_ops: Vector of Tuples (destination, op, args, op_kwargs...) specifying "postrendering" of PhysicalGroups executed after entities have been rendered to to sm. Each operation op creates a new PhysicalGroup defined as sm[destination] = op(sm, args...; op_kwargs...). That is, args are the arguments to op (following the first argument, which is always the model sm being rendered to). For most operations, these arguments include the names and dimensions of groups being operated on, and op_kwargs are the keyword arguments passed to op. For example, ("base", difference_geom!, ("writeable_area", "base_negative"), :remove_object => true, :remove_tool => true) defines a postrendering step that subtracts the PhysicalGroup named "base_negative" from "writeable_area" (by default using dimension 2 for each group) to define a new group called "base". The keyword pairs :remove_object=>true and :remove_tool=>true mean that the "object" (first argument) group "writeable_area" and the "tool" (second argument) group "base_negative" are both removed when "base" is created.
  • zmap: Function (m::SemanticMeta) -> z coordinate of corresponding elements. Default: Map all metadata to zero.
  • meshing_parameters: MeshingParameters allows customization of the top level meshing parameters when calling Gmsh.

Available postrendering operations are translate!, extrude_z!, revolve!, union_geom!, intersect_geom!, difference_geom!, fragment_geom!, and box_selection. (The geometric Boolean operations are only available for models using the OpenCASCADE kernel.)

Additional keyword arguments are passed to SolidModels.to_primitives (which falls back to to_polygons) and may be used for certain entity types to control how entities of cs are converted to primitives and added to sm.

source
render!(cs::AbstractCoordinateSystem, obj::GeometryEntity, meta::DeviceLayout.Meta,
    target::LayoutTarget; kwargs...)

Render obj to cs, with metadata mapped to layers and rendering options by target.

source
render!(cs::AbstractCoordinateSystem, cs2::GeometryStructure, target::LayoutTarget; kwargs...)

Render cs2 to cs, with metadata mapped to layers and rendering options by target.

See LayoutTarget documentation for details.

source
render!(
    cs::AbstractCoordinateSystem,
    sch::Schematic,
    target::LayoutTarget;
    strict=:error,
    kwargs...
)

Run build!(sch, target) and render the resulting geometry to cs using target's rendering options.

The strict keyword should be :error, :warn, or :no.

The strict=:error keyword option causes render! to throw an error if any errors were logged while building component geometries or while rendering geometries to cs. This is enabled by default, but can be disabled with strict=:no, in which case any component which was not successfully built will have an empty geometry, and any non-fatal rendering errors will be ignored as usual. Using strict=:no is recommended only for debugging purposes.

The strict=:warn keyword option causes render! to throw an error if any warnings were logged. This is disabled by default. Using strict=:warn is suggested for use in automated pipelines, where warnings may require human review.

source
render!(sm::SolidModel, sch::Schematic, target::Target; strict=:error, kwargs...)

Render sch to sm, using rendering settings from target.

The strict keyword should be :error, :warn, or :no.

The strict=:error keyword option causes render! to throw an error if any errors were logged while building component geometries or while rendering geometries to cs. This is enabled by default, but can be disabled with strict=:no, in which case any component which was not successfully built will have an empty geometry, and any non-fatal rendering errors will be ignored as usual. Using strict=:no is recommended only for debugging purposes.

The strict=:warn keyword option causes render! to throw an error if any warnings were logged. This is disabled by default. Using strict=:warn is suggested for use in automated pipelines, where warnings may require human review.

Additional keyword arguments may be used for certain entity types for controlling how geometry entities are converted to primitives and added to sm.

source

Rendering arbitrary paths

A Segment and Style together define one or more closed curves in the plane. The job of rendering is to approximate these curves by closed polygons. To enable rendering of styles along generic paths in the plane, an adaptive algorithm is used when no other method is available:

DeviceLayout.adapted_gridFunction
adapted_grid(f, anchors;
    max_recursions::Real = 7, max_change = 5°, rand_factor::Real = 0.05,
    grid_step = 1.0μm)

Computes a resampled grid given anchor points so that f.(grid) is sufficiently smooth. The method used is to create an initial grid around the anchor points and refine intervals. When an interval becomes "straight enough" it is no longer divided. Adapted from a contribution to PlotUtils.jl from Kristoffer Carlsson.

  • max_recursions: how many times each interval is allowed to be refined.
  • max_change: specifies acceptable change between evaluations of f on subsequent grid points, as estimated by the derivative times the distance between grid points. Typically, f is the angle of a path in the plane, so this is often an angle threshold. This condition is approximately valid in the end result, but may be weakly violated. This condition may be grossly violated if max_recursions is too low.
  • rand_factor: between anchor points, adapted_grid will wiggle initial grid points a bit to prevent aliasing. The wiggling is sampled uniformly from the interval: [-rand_factor, rand_factor], times the distance between three grid points (e.g. i+1 and i-1). A random number generator is given a fixed seed every time adapted_grid is called, so the rendered results are deterministic.
  • grid_step: Step size for initial grid points. If you set this to be larger than the maximum anchor point, then the lowest resolution consistent with max_change is used (unless f has some fast variations that the algorithm might miss).
source

In some cases, custom rendering methods are implemented when it would improve performance for simple structures or when special attention is required. The rendering methods can specialize on either the Segment or Style types, or both.