Problem 314 - Incorrect surface normal from G4IntersectionSolid
Summary: Incorrect surface normal from G4IntersectionSolid
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: geometry/solids (show other problems)
Version: 3.2
Hardware: PC Linux
: P2 normal
Assignee: Gabriele Cosmo
URL: http://citnp.caltech.edu/kamland/mont...
Depends on:
Blocks:
 
Reported: 2001-10-18 16:23 CEST by gas
Modified: 2001-10-19 09:05 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description gas 2001-10-18 16:23:56 CEST
When a point is on the surface of solidB and inside solidA,
G4IntersectionSolid incorrectly returns the normal from solidA.

The reason is an incorrect declaration of the variables
"insideA" and "insideB" in G4IntersectionSolid::SurfaceNormal()
(line 167): they are declared as "G4bool", but they need to be
"EInside".  Changing "G4bool" to "EInside" fixes the problem.

The problem may not be reproducible on all platforms: I am using g++
"egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)".  The reason
the problem occurs is that the assignment
       insideA= fPtrSolidA->Inside(p)
casts the "enum" returned by Inside into a "bool".  In doing so,
code produced by the g++ compiler converts any non-zero value of
the enum into the standard "true" value of 1.  Subsequently, the
test
  if( insideA == kSurface )
returns true even if the original value of "fPtrSolidA->Inside(p)"
was "kInside".  This leads to the problem described.
Comment 1 Gabriele Cosmo 2001-10-19 09:05:59 CEST
Thanks for spotting this. The bug was actually already fixed in a recent
development tag "geom-solid-bool-V03-02-00". The fix will be included in
the next December release.