Error in geometry made by Boolean operations

Dear Geant4 users and experts,
I create a collimator with hexagonal holes as follows:
1- I used the G4ExtrudedSolid to construct a hexagon, the code I get from this post Need advice how to create Hexagonal prism;
2- than I creat of disc of hexagons with spacing between them by using G4MultiUnion
3- Finaly I use G4SubtractionSolid to get my final collimator geometry.
When I try to make the spacing between the hexagons very thin I got this error :

=================================================
ERROR: G4VSceneHandler::RequestPrimitives
Polyhedron not available for Collimator
Touchable path: World 0 Collimator 0
This means it cannot be visualized in the usual way on most systems.

  1. The solid may not have implemented the CreatePolyhedron method.
  2. For Boolean solids, the BooleanProcessor, which attempts to create
    the resultant polyhedron, may have failed.
    Try RayTracer. It uses Geant4’s tracking algorithms instead.
    Drawing solid with cloud of points.
    =================================================
    But for a spacing equal or more than 0.0005mm the visualization works fine!

Any suggestions are welcome
Thanks
Lazhar.

The error message explains the problem: the BooleanProcessor, which converts volumes to mesh objects, has failed. To overcome the issue you can:

  • use built-in RayTracer;
  • or to draw the collimator as a cloud of points:
    /vis/viewer/set/style cloud

In reality, neither G4MultiUnion nor G4SubtractionSolid are not needed to create a geometry like yours. Hexagonal holes can be defined as child volumes of the disk. A detailed explanation of how to do this is available in the thread you mentioned: Need advice how to create Hexagonal prism

1 Like

Thank you for your replay!
I use /vis/viewer/set/style cloud, but the problem still exist, for RayTracer I dont know how can I use it? BUT it appears with others graphic systems:


You have successfully registered the following graphics systems.
Registered graphics systems are:
ASCIITree (ATree)
DAWNFILE (DAWNFILE)
G4HepRep (HepRepXML)
G4HepRepFile (HepRepFile)
RayTracer (RayTracer)
VRML1FILE (VRML1FILE)
VRML2FILE (VRML2FILE)
gMocrenFile (gMocrenFile)
OpenGLImmediateQt (OGLIQt, OGLI)
OpenGLStoredQt (OGLSQt, OGL, OGLS)
OpenGLImmediateWin32 (OGLIWin32, OGLIQt_FALLBACK)
OpenGLStoredWin32 (OGLSWin32, OGLSQt_FALLBACK)
Qt3D (Qt3D)


Could you show me how i can use RayTracer?
Regards

The problem persists because in your vis.mac there is a line
/vis/viewer/set/style surface
Replace this line with
/vis/viewer/set/style cloud

The ray tracer can be invoked by:
/vis/open RayTracerX

More information is available in the Book For Application Developers, see section Visualization

Hello Evgueni Tcherniaev,
when I use these lines in the file vis.mac I got some errors and warnings with no visualization, the error said that I dont have RayTracerX, although the RayTracer figured in the liste above, the errors are attached bellow:


parameter value (RayTracerX) is not listed in the candidate List.
Candidates are: ATree DAWNFILE HepRepFile HepRepXML OGL OGLI OGLIQt OGLIWin32 OGLS OGLSQt OGLSWin32 Qt3D RayTracer VRML1FILE VRML2FILE gMocrenFile

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : UIMAN0123
issued by : G4UImanager::ApplyCommand
Candidates are: ATree DAWNFILE HepRepFile HepRepXML OGL OGLI OGLIQt OGLIWin32 OGLS OGLSQt OGLSWin32 Qt3D RayTracer VRML1FILE VRML2FILE gMocrenFile
Error code : 1
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

***** Illegal parameter (1) *****

***** Batch is interrupted!! *****

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : UIMAN0123
issued by : G4UImanager::ApplyCommand
Command aborted (1)
Error code : 1
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

***** Illegal parameter (1) *****

***** Batch is interrupted!! *****

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : UIMAN0123
issued by : G4UImanager::ApplyCommand
Command aborted (1)
Error code : 1
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------


I tryed to install RayTraycerX but the right command I dont find, existe some commands but just for Linux not for Windows10!
Could you suggest some actions?

Regards!
Lazhar.

You have to build Geant4 with RayTracerX:
GEANT4_USE_RAYTRACER_X11=ON
See Installation Guide.

I used the same option but i got a lot of error!
cmake -DCMAKE_INSTALL_PREFIX=“D:/Geant4/geant4_10_7_install” -DGEANT4_USE_RAYTRACER_X11=ON “D:/Geant4/geant4_10_7”
I think I will reinstall Geant4 again by including this option!

It seems that you are using a Windows machine.
X11 is a different ‘Windowing’ system, created primarily for Unix Machines.

I am not aware of a RayTracer for Windows system - our colleagues who develop Visualisation or others who use it in more depth may help.

An alternative would be to get an X11 implementation for Windows, but this exists only as part of Cygwin, a Unix environment. I am not aware whether anyone has compiled recent versions of Geant4 with Cygwin (and in particular the visualisation).

Using Cygwin offers advantages, if it can work, but it would mean developing in a very different (Unix-like) environment.

@Zazo : Evgueni’s suggestion would remove the need to use RayTracerX – you could just place the ‘exclusion’ volumes in their mother. You would just need to add a material to these daughter hexagon volumes, as they will appear in your volume hierarchy.

This solution is much more robust vis-a-vis visualisation, and the Geant4 Navigator also handles it very well, resulting in fast computation of intersections. Instead of using G4MultiUnion, you would just place each hexagon inside the collimator volume.

Maybe you would need to tweek the visualisation settings to make these holes transparent … ?

Thank you for the explanation,
Perhapse I must use the Linux envirnement!
Exist an other way more easy beside Cygwin to use Linux on windows10 machine by installing the future WSL ( Windows Subsystem for Linux)!

Regards,
Lazhar

Yes, this one also is a good alternative solution I hope, but what do you mean by “tweek” (I’m not good in English :blush:), because I check this way for a simple geometry but the hexagon volume doesn’t appear transparent!

In your geometry construction code, you can attach visualization attributes to your logical volume, using LV->SetVisAttributes(). Create a G4VisAttributes object in your code, configure it with color, drawing style, and other features, and pass it to that function.

The simplest way to “hide” a volume like this is to make it invisible, with a pre-defined attribute: LV->SetVisAttributes(G4VisAttributes::GetInvisible()).

1 Like

I used the pre-defined attribute LV->SetVisAttributes(G4VisAttributes::GetInvisible()), but the hexagonals are disapeared, I got just the mother disc, I need something else to add in DetectorConstruction.cc or vis.mac?

That’s odd. So it’s showing a solid disk, without the hexagons appearing as holes? Maybe Invisible won’t do for daughters what I thought it would do.

the alternative is to set the color transparency, using G4VisAttributes::SetColour(redfrac, greenfrac, bluefrac, 0.). The fourth argument is opacity (alpha), 1 for solid, 0 for fully transparent.

By using:
G4VisAttributes* att_1 = new G4VisAttributes();
att_1->SetColour(0, 0, 0, 1);
LVElemHex->SetVisAttributes(att_1);
I got this not very clear geometry:


When I used this att_1->SetColour(1, 1, 1, 0); the halls aren’t transparent.
I need to get a geometry like the one constructed by using the G4MultiUnion (see the image in the begining of this thread)

Regards!
Lazhar

I decide to leave my geometry without any customize, since the main problem posted here is resolved now

Thank you @evc, @japost, @mkelsey and @allison for the help

Regards,
Lazhar.