Styled geometry entities
Entities can also be "styled"—paired with a GeometryEntityStyle. This creates a StyledEntity <: GeometryEntity that still supports the entity interface (including the ability to be styled).
DeviceLayout.GeometryEntityStyle — Typeabstract type GeometryEntityStyleA style that can be used with a GeometryEntity to create a modified entity.
May use (sty::MyStyle)(ent), styled(ent, sty), or MyStyle(ent, style_args...; style_kwargs...) to create a StyledEntity.
A GeometryEntityStyle should implement to_polygons(::MyEntity, ::MyStyle; kwargs...) for any entity type it can be applied to. As a fallback, it can implement to_polygons(::Polygon, ::MyStyle; kwargs...), in which case entities will be converted to polygons before applying the style.
Unless implemented by the style, lowerleft and upperright (and hence bounds) of a styled entity will use the underlying entity's bounds. Similarly, footprint and halo will fall back to using the underlying entity. Exceptions include the NoRender style, in which case the entity is treated as a zero-area Rectangle (ignored in collective bounds calculations), as well as OptionalStyle, in which case the default style is used (in case it has special behavior).
DeviceLayout.StyledEntity — TypeStyledEntity{T, U <: GeometryEntity{T}, S <: GeometryEntityStyle} <: GeometryEntityGeometryEntity composing another GeometryEntity with a GeometryEntityStyle.
The use of a StyledEntity allows the composition of operations like rounding on geometric entities without committing to a particular representation of those entities.
DeviceLayout.entity — Functionentity(styled_ent::StyledEntity)Return the GeometryEntity styled by styled_ent.
DeviceLayout.style — Methodstyle(styled_ent::StyledEntity)Return the GeometryEntityStyle of styled_ent.
DeviceLayout.styled — Functionstyled(ent, sty)Return StyledEntity(ent, sty).
DeviceLayout.unstyled — Functionunstyled(styled_ent::StyledEntity)Return the unstyled entity referenced by styled_ent.
If styled_ent.ent is itself a StyledEntity, apply unstyled recursively until the original plain GeometyEntity is found.
DeviceLayout.unstyled_type — Functionunstyled_type(::GeometryEntity)
unstyled_type(::Type{GeometryEntity})Return the type of the unstyled entity beneath all styles.
Basic styles
The styles below can be applied to most entities for generic purposes.
DeviceLayout.Plain — TypePlain <: GeometryEntityStylePlain style. Does not affect rendering of the styled entity.
DeviceLayout.MeshSized — Typestruct MeshSized{T, S} <: GeometryEntityStyle where {T, S <: Real}
h::T
α::S
endStyle that annotates a GeometryEntity with a mesh size to use in SolidModel rendering. The generated mesh will include a size field defined as:
mesh size = h * max(s_g, (d/h)^α)where d is the distance away from the styled entity, and s_g is the global mesh scale parameter specified in MeshingParameters. A smaller value of h will give a finer mesh attached to the styled entity, and a larger value of α will give a more rapid increase in size away from the styled entity.
For α < 0, the size field will use α_default from the MeshingParameters used in rendering.
See also meshsized_entity and SolidModels.MeshingParameters.
DeviceLayout.meshsized_entity — Functionmeshsized_entity(ent::GeometryEntity, h::T, α::S=-1.0) where {T, S <: Real}Create a MeshSized entity, specifying a mesh size use in SolidModel rendering. The generated mesh will include a size field defined as:
mesh size = h * max(s_g, (d/h)^α)where d is the distance away from the styled entity, and s_g is the global mesh scale parameter specified in MeshingParameters. A smaller value of h will give a finer mesh attached to the styled entity, and a larger value of α will give a more rapid increase in size away from the styled entity.
For α < 0, the size field will use α_default from the SolidModels.MeshingParameters used in rendering.
DeviceLayout.NoRender — TypeNoRender <: GeometryEntityStyleStyle that marks an entity to be skipped when rendering.
NoRender-styled entities have zero-area bounds and footprint and empty halo.
DeviceLayout.OptionalStyle — Typestruct OptionalStyle <: GeometryEntityStyle
true_style::GeometryEntityStyle
false_style::GeometryEntityStyle
flag::Symbol
default::Bool
end
OptionalStyle(true_style::GeometryEntityStyle, flag::Symbol;
false_style::GeometryEntityStyle=Plain(), default::Bool=true)Style that depends on a Boolean rendering option flag with default default.
lowerleft, upperright, bounds, footprint, and halo are forwarded to the underlying entity styled with the default style.
Examples
sty = OptionalStyle(Rounded(1μm), :rounding)
p = Rectangle(4μm, 4μm)
rounded_rect = to_polygons(sty(p))
plain_rect = to_polygons(sty(p), rounding=false)DeviceLayout.optional_entity — Functionoptional_entity(ent::GeometryEntity, flag::Symbol;
true_style::GeometryEntityStyle=Plain(), default=true)Return an entity to be rendered or not based on the rendering option flag.
Example
julia> c = Cell();
julia> ent = optional_entity(Rectangle(2, 2), :optional_entities; default=false);
julia> render!(c, ent);
julia> length(elements(c))
0
julia> render!(c, ent; optional_entities=true);
julia> length(elements(c))
1DeviceLayout.ToTolerance — Typestruct ToTolerance{T<:Coordinate} <: GeometryEntityStyle
atol::T
endStyle for rendering an entity to absolute tolerance atol.
Equivalent to passing or overriding the keyword atol when rendering this entity.
AbstractPolygons also have the Polygons.Rounded style, while ClippedPolygons have Polygons.StyleDict.