Problem 1301

Summary: GetPointOnSurface() does not return proper distributions for Boolean solids
Product: Geant4 Reporter: Michael Kelsey <kelsey>
Component: geometry/solidsAssignee: Gabriele Cosmo <Gabriele.Cosmo>
Status: RESOLVED DUPLICATE    
Severity: major CC: tatiana.nikitina
Priority: P5    
Version: 9.5   
Hardware: All   
OS: All   

Description Michael Kelsey 2012-04-03 21:55:48 CEST
In addition to report #1294, we find that G4BooleanSolid does not generate a proper distribution of surface points either:

  while(condition)
  {
    rand = G4UniformRand();
    if(rand > 0.5) { p = fPtrSolidA->GetPointOnSurface(); }
    else           { p = fPtrSolidB->GetPointOnSurface(); }
    if(Inside(p) == kSurface)  { break; }
  }

The "0.5" cut is not correct, since the two constituent solids may well have different surface areas (it doesn't take account of the details of overlap, either, but that could be a performance hit).
Comment 1 Gabriele Cosmo 2012-04-04 09:43:54 CEST
I repeat here what stated in #1074 ... GetPointOnSurface() is NOT meant to generate a uniform distribution of points on the surface, but allow the fastest possible way to generate them for overlaps checking and
debug purposes!  What suggested in reports #1074 and #1294 can be considered, but still they're introducing a penalty.
In many cases it is practically impossible to have a uniform distribution, or it would require too much CPU time. Boolean solids is one of these, as any possible solid can be part of it and especially when more than two Boolean operations are involved!
The current algorithm for Boolean solids is more than reasonable in respect to its specifications.
It should be also noticed that for some solids the current approach allows for the generation of more points close to edges or vertices, which is just good for the use which is made of it and for facilitating debugging on critical areas.

*** This problem has been marked as a duplicate of problem 1074 ***