|
| 1 | + |
| 2 | +function fragmentless(cs, postrender_ops, zmap) |
| 3 | + sm = SolidModel("test"; overwrite=true) |
| 4 | + render!(sm, cs; zmap, postrender_ops) |
| 5 | + # SolidModels._synchronize!(sm) |
| 6 | + # SolidModels.gmsh.fltk.run() |
| 7 | + |
| 8 | + # Extract the surface loops, and the associated tags for each volume |
| 9 | + # TODO: Need correct treatment of when these are vectors, i.e. separate volumes |
| 10 | + # making up one group. |
| 11 | + ext1_tag = SolidModels.dimtags(sm["ext1", 3])[1][2] |
| 12 | + ext2_tag = SolidModels.dimtags(sm["ext2", 3])[1][2] |
| 13 | + ext3_tag = SolidModels.dimtags(sm["ext3", 3])[1][2] |
| 14 | + ext1_shell, ext1_shell_tags = SolidModels.gmsh.model.occ.get_surface_loops(ext1_tag) |
| 15 | + ext2_shell, ext2_shell_tags = SolidModels.gmsh.model.occ.get_surface_loops(ext2_tag) |
| 16 | + ext3_shell, ext3_shell_tags = SolidModels.gmsh.model.occ.get_surface_loops(ext3_tag) |
| 17 | + |
| 18 | + # Loop tags give the coarse scale topology, i.e. which volumes are holes in |
| 19 | + # which. Now can cut the pattern from the chip surface for each. |
| 20 | + |
| 21 | + # In the shell loops remove the chip face tags |
| 22 | + chip_l1_tags = getindex.(SolidModels.dimtags(sm[:chip_l1, 2]), 2) |
| 23 | + chip_l2_tags = getindex.(SolidModels.dimtags(sm[:chip_l2, 2]), 2) |
| 24 | + filter!.(x -> x ∉ chip_l1_tags, ext1_shell_tags) |
| 25 | + filter!.(x -> x ∉ chip_l2_tags, ext2_shell_tags) |
| 26 | + filter!.(x -> x ∉ chip_l1_tags, ext3_shell_tags) |
| 27 | + filter!.(x -> x ∉ chip_l2_tags, ext3_shell_tags) |
| 28 | + |
| 29 | + # ext1_shell_tags |
| 30 | + # ext2_shell_tags |
| 31 | + # ext3_shell_tags |
| 32 | + |
| 33 | + # Add in the pattern and metal tags |
| 34 | + SolidModels._synchronize!(sm) |
| 35 | + SolidModels.gmsh.fltk.run() |
| 36 | + @show SolidModels.intersect_geom!(sm, :chip_l1, :pattern_l1, 2, 2) |
| 37 | + pattern_l1_bdr_dimtags = SolidModels.gmsh.model.get_boundary( |
| 38 | + SolidModels.dimtags(sm[:pattern_l1, 2]), |
| 39 | + false, |
| 40 | + false, |
| 41 | + true |
| 42 | + ) |
| 43 | + SolidModels.gmsh.model.occ.embed |
| 44 | + sm["metal_l1"] = |
| 45 | + SolidModels.difference_geom!(sm, :chip_l1, :pattern_l1, 2, 2, remove_object=true) |
| 46 | + sm["metal_l2"] = |
| 47 | + SolidModels.difference_geom!(sm, :chip_l2, :pattern_l2, 2, 2, remove_object=true) |
| 48 | + |
| 49 | + SolidModels._synchronize!(sm) |
| 50 | + SolidModels.gmsh.fltk.run() |
| 51 | + # TODO: Fragment is still removing things, despite meshing at the end. Figure |
| 52 | + # out which entities are being hung on to. |
| 53 | + |
| 54 | + metal_l1_tags = getindex.(SolidModels.dimtags(sm[:metal_l1, 2]), 2) |
| 55 | + metal_l2_tags = getindex.(SolidModels.dimtags(sm[:metal_l2, 2]), 2) |
| 56 | + pattern_l1_tags = getindex.(SolidModels.dimtags(sm[:pattern_l1, 2]), 2) |
| 57 | + pattern_l2_tags = getindex.(SolidModels.dimtags(sm[:pattern_l2, 2]), 2) |
| 58 | + |
| 59 | + # Add the tag to outer shell first, as can use inner shell to identify set |
| 60 | + if length(intersect(ext1_shell_tags[1], ext3_shell_tags[2])) == |
| 61 | + length(ext3_shell_tags[2]) |
| 62 | + append!(ext3_shell_tags[2], vcat(metal_l1_tags, pattern_l1_tags)) |
| 63 | + elseif length(intersect(ext1_shell_tags[1], ext3_shell_tags[3])) == |
| 64 | + length(ext3_shell_tags[3]) |
| 65 | + append!(ext3_shell_tags[3], vcat(metal_l1_tags, pattern_l1_tags)) |
| 66 | + end |
| 67 | + if length(intersect(ext2_shell_tags[1], ext3_shell_tags[2])) == |
| 68 | + length(ext3_shell_tags[2]) |
| 69 | + append!(ext3_shell_tags[2], vcat(metal_l2_tags, pattern_l2_tags)) |
| 70 | + elseif length(intersect(ext2_shell_tags[1], ext3_shell_tags[3])) == |
| 71 | + length(ext3_shell_tags[3]) |
| 72 | + append!(ext3_shell_tags[3], vcat(metal_l2_tags, pattern_l2_tags)) |
| 73 | + end |
| 74 | + |
| 75 | + append!(ext1_shell_tags[1], vcat(metal_l1_tags, pattern_l1_tags)) |
| 76 | + append!(ext2_shell_tags[1], vcat(metal_l2_tags, pattern_l2_tags)) |
| 77 | + |
| 78 | + # Remove the volumes non recursively. |
| 79 | + SolidModels._synchronize!(sm) |
| 80 | + SolidModels.remove_group!(sm["ext1", 3], recursive=false, remove_entities=true) |
| 81 | + SolidModels.remove_group!(sm["ext2", 3], recursive=false, remove_entities=true) |
| 82 | + SolidModels.remove_group!(sm["ext3", 3], recursive=false, remove_entities=true) |
| 83 | + |
| 84 | + # Add new volumes back in based on the shell loops |
| 85 | + ext1_shell = SolidModels.gmsh.model.occ.add_surface_loop(ext1_shell_tags[1]) |
| 86 | + ext2_shell = SolidModels.gmsh.model.occ.add_surface_loop(ext2_shell_tags[1]) |
| 87 | + |
| 88 | + ext1_vtag = SolidModels.gmsh.model.occ.add_volume([ext1_shell]) |
| 89 | + ext2_vtag = SolidModels.gmsh.model.occ.add_volume([ext2_shell]) |
| 90 | + ext3_vtag = |
| 91 | + SolidModels.gmsh.model.occ.add_volume([ext3_shell[1], ext1_shell, ext2_shell]) |
| 92 | + |
| 93 | + SolidModels._synchronize!(sm) |
| 94 | + return sm |
| 95 | +end |
0 commit comments