Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/solidmodels/postrender.jl
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,33 @@ function remove_group!(group::PhysicalGroup; recursive=true, remove_entities=fal
return Tuple{Int32, Int32}[]
end

"""
check_overlap(sm::SolidModel)

Check for overlap/intersections between SolidModel groups of the same dimension.
Intersections (if any) for entities of dimension dim should have dim-1. Otherwise it means there is overlap.

Return the overlapping groups as a vector of `(group1, group2, dimension)` `Tuple`s.
"""
function check_overlap(sm::SolidModel)
overlapping_groups = Tuple{String, String, Int}[]
for dim = 1:3
for (name1, _) in SolidModels.dimgroupdict(sm, dim)
for (name2, _) in SolidModels.dimgroupdict(sm, dim)
name1 >= name2 && continue
intersections = intersect_geom!(sm, name1, name2, dim, dim)
for intersection in intersections
if intersection[1] > dim - 1
@warn "Overlap of SolidModel groups $name1 and $name2 of dimension $dim."
push!(overlapping_groups, (name1, name2, dim))
end
end
end
end
end
return overlapping_groups
end

"""
staple_bridge_postrendering(; levels=[], base, bridge, bridge_height=1μm, output="bridge_metal")

Expand Down
26 changes: 25 additions & 1 deletion test/test_solidmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ import DeviceLayout.SolidModels.STP_UNIT
cs = CoordinateSystem("test", nm)
place!(cs, centered(Rectangle(500μm, 100μm)), :l1)
postrender_ops = [("ext", SolidModels.extrude_z!, (:l1, 20μm))]
sm = SolidModel("test"; overwrite=true)
sm = test_sm()
zmap = (m) -> (0μm)
render!(sm, cs, zmap=zmap, postrender_ops=postrender_ops)
sm["Xmin"] = SolidModels.get_boundary(sm["ext", 3]; direction="X", position="min")
Expand All @@ -1024,6 +1024,30 @@ import DeviceLayout.SolidModels.STP_UNIT
periodic_tags = SolidModels.set_periodic!(sm["Xmin", 2], sm["Xmax", 2])
@test !isempty(periodic_tags)

# check_overlap
cs = CoordinateSystem("test", nm)
r1 = Rectangle(2μm, 2μm)
r2 = translate(r1, Point(1μm, 0μm))
r3 = translate(r1, Point(2μm, 0μm))
place!(cs, r1, SemanticMeta(Symbol("r1")))
place!(cs, r2, SemanticMeta(Symbol("r2")))
sm = test_sm()
render!(sm, cs)
@test @test_logs (:warn, "Overlap of SolidModel groups r1 and r2 of dimension 2.") SolidModels.check_overlap(
sm
) == [(
"r1",
"r2",
2
)]

cs = CoordinateSystem("test", nm)
place!(cs, r1, SemanticMeta(Symbol("r1")))
place!(cs, r3, SemanticMeta(Symbol("r3")))
sm = test_sm()
render!(sm, cs)
@test isempty(SolidModels.check_overlap(sm))

# TODO: Composing OptionalStyle

# Explicitly MeshSized Path.
Expand Down