In the Geant4 Qt viewer, my Cryostat (white), IR Shield (grey), and Crystal (cyan) are rendering as a cloudy wireframe overlay instead of opaque solids

_Geant4 Version: geant4-11-02-patch-02 [MT] (21-June-2024)
_Operating System: Ubuntu 64bit
_Compiler/Version:_g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
_CMake Version: 3.22.1

// ------------------------- NIST 재료 정의 -------------------------
G4Material* matGe = nist->FindOrBuildMaterial(“G4_Ge”);
G4Material* matAl = nist->FindOrBuildMaterial(“G4_Al”);
G4Material* matAir = nist->FindOrBuildMaterial(“G4_AIR”);

// ------------------------- Crystal -------------------------
G4double crystal_radius = 42.5mm;
G4double crystal_height = 30.0
mm;
G4Tubs* solidCrystal = new G4Tubs(“Crystal”, 0, crystal_radius, crystal_height/2, 0., 360.*deg);

G4Tubs* solidCore = new G4Tubs(“Core”, 0, 3.5mm, 9.0mm, 0., 360.deg);
G4SubtractionSolid
solidCrystalFinal = new G4SubtractionSolid(“CrystalWithCore”, solidCrystal, solidCore, 0, G4ThreeVector(0,0,-6.0mm));
G4LogicalVolume
logicCrystal = new G4LogicalVolume(solidCrystalFinal, matGe, “Crystal”);

G4VisAttributes* visCrystal = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0, 1.0)); // 불투명 Cyan
visCrystal->SetForceSolid(true);
logicCrystal->SetVisAttributes(visCrystal);

// ------------------------- IR Shield -------------------------
G4double ir_outer_radius = 50.9mm;
G4double ir_thickness = 1.5
mm;
G4double ir_body_height = 45.9mm;
G4double ir_cap_thickness = 1.5
mm;

G4Tubs* irBody = new G4Tubs(“IRBody”, ir_outer_radius - ir_thickness, ir_outer_radius, ir_body_height/2, 0., 360.deg);
G4Box
irCut = new G4Box(“IRCut”, ir_outer_radius+1mm, ir_outer_radius+1mm, ir_cap_thickness/2);
G4SubtractionSolid* irOpen = new G4SubtractionSolid(“IROpen”, irBody, irCut, 0, G4ThreeVector(0, 0, -ir_body_height/2 + ir_cap_thickness/2));
G4Tubs* irCap = new G4Tubs(“IRCap”, 0, ir_outer_radius, ir_cap_thickness/2, 0., 360.deg);
G4UnionSolid
irWhole = new G4UnionSolid(“IRShield”, irOpen, irCap, 0, G4ThreeVector(0,0,ir_body_height/2));
G4LogicalVolume* logicIR = new G4LogicalVolume(irWhole, matAl, “IRShield”);

G4VisAttributes* visIR = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 1.0)); // 불투명 Grey
visIR->SetForceSolid(true);
logicIR->SetVisAttributes(visIR);

// ------------------------- Cryostat -------------------------
G4double cryo_outer_radius = 52.5mm;
G4double cryo_thickness = 1.6
mm;
G4double cryo_body_height = 50.0mm;
G4double cryo_cap_thickness = 1.6
mm;

G4Tubs* cryoBody = new G4Tubs(“CryoBody”, cryo_outer_radius - cryo_thickness, cryo_outer_radius, cryo_body_height/2, 0., 360.deg);
G4Box
cryoCut = new G4Box(“CryoCut”, cryo_outer_radius+1mm, cryo_outer_radius+1mm, cryo_cap_thickness/2);
G4SubtractionSolid* cryoOpen = new G4SubtractionSolid(“CryoOpen”, cryoBody, cryoCut, 0, G4ThreeVector(0, 0, -cryo_body_height/2 + cryo_cap_thickness/2));
G4Tubs* cryoCap = new G4Tubs(“CryoCap”, 0, cryo_outer_radius, cryo_cap_thickness/2, 0., 360.deg);
G4UnionSolid
cryoWhole = new G4UnionSolid(“Cryostat”, cryoOpen, cryoCap, 0, G4ThreeVector(0,0,cryo_body_height/2));
G4LogicalVolume* logicCryostat = new G4LogicalVolume(cryoWhole, matAl, “Cryostat”);

G4VisAttributes* visCryo = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0, 1.0)); // 불투명 Yellow
visCryo->SetForceSolid(true);
logicCryostat->SetVisAttributes(visCryo);

// ------------------------- Hierarchical Placement (with margin) -------------------------
G4double margin = 0.1 * mm;
G4double z_crystal_in_ir = -(ir_body_height - crystal_height)/2.0 + margin;
G4double z_ir_in_cryo = -(cryo_body_height - ir_body_height)/2.0 + margin;

new G4PVPlacement(0, G4ThreeVector(0, 0, z_crystal_in_ir), logicCrystal, “Crystal”, logicIR, false, 0, true);
new G4PVPlacement(0, G4ThreeVector(0, 0, z_ir_in_cryo), logicIR, “IRShield”, logicCryostat, false, 0, true);
new G4PVPlacement(0, {}, logicCryostat, “Cryostat”, lv_World, false, 0, true);


When I write the code as shown below, the Cryostat and IR Shield appear hazy in the Qt viewer; I’m wondering how I can make them fully opaque. Also, is it safe to run the simulation in this state?

You should have seen messages in the output that the visualization was unable to draw your boolean solid, and was reverting to a “point cloud.” This is a feature, not a bug – in older versions of G4, the visualization would just not draw anything!

It usually means that your boolean solid is “too complex” to draw, but it may also mean that you have a mistake in your code. For example, if you define a Union solid with disjoint pieces, the code is unable to make a single tesselation for that, and it’ll revert to the point cloud.

1 Like

Spot on, Mike. Just to add, yes, it is safe to run the simulation - assuming your geometry is as you intend. It is purely a visualisation issue. Tracking is not affected.

Re Boolean operations, it can help if you avoid coincident surfaces. Particularly with subtraction. It does not hurt, logically, to make the subtractor larger than the subtractee. It is a tough computational problem to generate polyhedra (for drawing), and sometimes it falls - hence the clouds.

1 Like