Skip to content

null mesh for some valid MultiUnions #252

@ManuelHu

Description

@ManuelHu

I found a rendering issue with some MultiUnion cases. The following code is a stripped-down version of legend legend-exp/legend-pygeom-l200#125

OFFSET = 0.01  # CHANGE HERE

vols = []
tras = []

radius = 283 + 2  # mm. in CAD model 283 mm, enlarged to avoid fiber overlaps.
radius_out = radius + 7
topring = g4.solid.Tubs("fiber_support_outer_topring", radius, radius_out, 3, 0, 2 * np.pi, registry)

# add the 20 guiding fins.
fin_radius = 155 + 10 + 20
fin_x = 2
fin_y = 8
fin = g4.solid.Box("fiber_support_outer_fin_box", fin_x, fin_y, 1320, registry)

radius_fins = radius_out + fin_y / 2 + OFFSET

for i in range(20):
    # Each fin needs to be rotated by 18 degrees to make the curved portion radial.
    vols.append(fin)
    tras.append(
        [
            [0, 0, i * 2 * np.pi / 20 - np.pi / 2],
            [radius_fins * np.cos(i * 2 * np.pi / 20), radius_fins * np.sin(i * 2 * np.pi / 20), 55 - 10],
        ]
    )

vols.append(topring)
tras.append([[0, 0, 0], [0, 0, 700]])

# Combine rings and rods
fiber_support = g4.solid.MultiUnion("fiber_support_outer", vols, tras, registry)
fiber_support = g4.LogicalVolume(
    fiber_support,
    "G4_Cu",
    "fiber_support_outer",
    registry,
)

depending on the offset added in radius_fins, this can have three outcomes:

  1. OFFSET > 0 (i.e. 0.01, as above) --> RENDERS FINE:
Image
  1. OFFSET = 0 -> RENDERS NOTHING, error
WARNING:pyg4ometry.visualisation.Mesh:getBoundingBox null mesh error : Multi Union fiber_support_outer
ERROR:pyg4ometry.geant4.LogicalVolume:geant4.LogicalVolume> meshing error fiber_support_outer
WARNING:pyg4ometry.visualisation.ViewerBase:Unknown logical volume type or null mesh

which is cerntainly wrong, as this is a union of many solids that each have finite volume (and no subtractions are involved)

  1. OFFSET < 0 -> RENDERS FINE AGAIN...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions