Render methods
DeviceLayout.render! — Functionrender!(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.
render!(c::CoordinateSystem, ent, meta)Synonym for place!.
render!(cell::Cell{S}, cs::GeometryStructure;
memoized_cells=Dict{GeometryStructure, 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 structure is referred to in multiple places, it will become a single cell referred to in multiple places.
Rendering a GeometryStructure to a Cell uses the optional keyword arguments
map_meta, a function that takes aMetaobject and returns aGDSMetaobject (ornothing, in which case rendering is skipped)memoized_cells, a dictionary used internally to make sure that if a structure is referred to in multiple places, it will become a single cell referred to in multiple places. Calling this function with non-empty dictionarymemoized_cells = Dict{GeometryStructure, Cell}(geom => prerendered_cell)is effectively a manual override that forcesgeom(which may becsor any structure in its reference hierarchy) to render asprerendered_cell.
Additional keyword arguments are passed to to_polygons for each entity and may be used for certain entity types to control how they are converted to polygons.
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 ofPhysicalGroup(asStringorSymbol; may also returnnothingto skip renderingm)postrender_ops: Vector of Tuples(destination, op, args, op_kwargs...)specifying "postrendering" ofPhysicalGroups executed after entities have been rendered to tosm. Each operationopcreates a newPhysicalGroupdefined assm[destination] = op(sm, args...; op_kwargs...). That is,argsare the arguments toop(following the first argument, which is always the modelsmbeing rendered to). For most operations, these arguments include the names and dimensions of groups being operated on, andop_kwargsare the keyword arguments passed toop. For example,("base", difference_geom!, ("writeable_area", "base_negative"), :remove_object => true, :remove_tool => true)defines a postrendering step that subtracts thePhysicalGroupnamed"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=>trueand:remove_tool=>truemean 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) ->zcoordinate of corresponding elements. Default: Map all metadata to zero.meshing_parameters:MeshingParametersallows customization of the top level meshing parameters when calling Gmsh.
Available postrendering operations include 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.
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.
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.
render!(
cs::AbstractCoordinateSystem,
sch::Schematic,
target::LayoutTarget;
strict=:error,
kwargs...
)Render the schematic sch to cs using target's rendering options, without modifying sch.
Users must run check!(sch) before calling this method; otherwise, it will throw an error.
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.
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.
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. In many cases, including circular arcs and simple styles along B-spline segments, this discretization uses curvature information to render the curve to a tolerance provided to render! using the atol keyword (default 1.0nm). For these curves, assuming small and slowly varying curvature, no point on the true curve is more than approximately atol from the discretization. To enable rendering of styles along generic paths in the plane, an adaptive algorithm based on a maximum allowed change in direction max_change is used when no other method is available.
DeviceLayout.discretize_curve — Functiondiscretize_curve(f, ddf, tolerance)Given a curve f and its second derivative ddf, discretize a curve into piecewise linear segments with an approximate absolute tolerance.
DeviceLayout.adapted_grid — Functionadapted_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 offon subsequent grid points, as estimated by the derivative times the distance between grid points. Typically,fis 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 ifmax_recursionsis too low.rand_factor: between anchor points,adapted_gridwill 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+1andi-1). A random number generator is given a fixed seed every timeadapted_gridis 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 withmax_changeis used (unlessfhas some fast variations that the algorithm might miss).
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.