Message: using G4SubtractionSolid correctly for complex geometry Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None using G4SubtractionSolid correctly for complex geometry 

Forum: Geometry
Date: 15 Jan, 2016
From: Anthony Villano <Anthony Villano>

I'm using Geant4.9.5.p01 to compile some geometry. I am upgrading to a more recent version of Geant4 currently, so that's the reason for using this older version for some geometrical constructions being done in parallel.

I am having trouble with G4SubtractionSolid, and I have to confess that I have never been able to get complex geometry with this tool as it seems that I should be able to.

I've attached a mechanical drawing of the plate that I'm trying to make:

   Attachment:
      http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2016/01/15/11.31-25036-boxbottom.pdf

My approach is to make a simple plate, then have 3 additional solids used for "subtractions" on this. These solids are two cylinders, for the countersunk holes, and one rectangle for the ridges. The ridges do not go all the way through and I'm having trouble reproducing that feature. Here is the code for my approach:

1168 /****************************Set up Bottom Plate Construction*******************************************/

1169 //bottom plate subtractions

1170 G4Tubs* small_hole = new G4Tubs("small_hole",0.0,4.32/2.0,10,0.0,2*pi);

1171 G4Tubs* large_hole = new G4Tubs("large_hole",0.0,4.32/2.0,10,0.0,2*pi);

1172 G4Box* shelf = new G4Box("shelf",209.55/2.0,6.35/2.0,10.0/2.0);

1173

1174 //bottom plate

1175 G4VSolid* botPlate = new G4Box("botPlate_S",228.6/2.0,203.2/2.0,6.35/2.0);

1176

1177 //make holes around

1178 float corner_x=-114.3,corner_y=-101.6;

1179 float ystep=25.4;

1180 float yridgestep=15.88;

1181 float x1=4.76,x2=223.8;

1182 G4ThreeVector shift(0.0,0.0,0.0);

1183 for(int i=0;i<7;i++){

1184

1185 //small holes on the "left"

1186 shift.setX(corner_x+x1);

1187 shift.setY(corner_y+(i+1)*ystep);

1188 botPlate = (G4VSolid*) new G4SubtractionSolid("botPlate_S",botPlate,small_hole,NULL,shift);

1189

1190 //small holes on the "right"

1191 shift.setX(corner_x+x2);

1192 shift.setY(corner_y+(i+1)*ystep);

1193 botPlate = (G4VSolid*) new G4SubtractionSolid("botPlate_S",botPlate,small_hole,NULL,shift);

1194 }

1195 for(int i=0;i<8;i++){

1196

1197 //ridges

1198 shift.setX(0.0);

1199 shift.setY(corner_y+(i+1)*yridgestep);

1200 shift.setZ((5.0/2.0)-1.59); //1/16" depth

1201 botPlate = (G4VSolid*) new G4SubtractionSolid("botPlate_S",botPlate,shelf,NULL,shift);

1202

1203 }

1204

1205 /****************************End Bottom Plate Construction*******************************************/

I've also attached it in a text file for easy reading:

      http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2016/01/15/11.35-50773-g4codesnip.txt

When I use the code above I can get the following geometry, where I made the ridges go all the way through:

      http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2016/01/15/11.35-24414-plate.png

However when I try to make it true to the mechanical drawing, i.e. the ridges NOT going all the way through, I get the following error during rendering of the geometry:

 Macro srcCloseup.mac is being run 
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
G4Scene::AddWorldIfEmpty: The scene was empty of run-duration models.
  "world" has been added.

And the geometry does not render. Why does this occur? I am daisy-chaining the creation of the G4SubtractionSolids in a way to make the code more compact, is this reasonabe? I guess it technically makes new memory every iteration and the old copy is probably not deleted, but it seems to me that for solids made with boolean operations this is true in one way or another anyway. And it isn't a memory leak really, because the number of operations is strictly bounded.

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Idea: Re: using G4SubtractionSolid correctly for complex geometry   (Michael H. Kelsey - 15 Jan, 2016)
2 None: Re: using G4SubtractionSolid correctly for complex geometry   (John Allison - 15 Jan, 2016)
1 None: Re: using G4SubtractionSolid correctly for complex geometry   (John Allison - 15 Jan, 2016)
(_ Agree: Re: using G4SubtractionSolid correctly for complex geometry   (Michael H. Kelsey - 15 Jan, 2016)
(_ None: Re: using G4SubtractionSolid correctly for complex geometry   (John Allison - 16 Jan, 2016)
1 None: Re: using G4SubtractionSolid correctly for complex geometry   (Anthony Villano - 16 Jan, 2016)
2 None: Re: using G4SubtractionSolid correctly for complex geometry   (Anthony Villano - 16 Jan, 2016)
... 3 Message(s)
 Add Message Add Message
to: "using G4SubtractionSolid correctly for complex geometry"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]