Cadmesh: Sample point is not on the surface

Hi,
after importing several parts as ply-files via cadmesh (GitHub - christopherpoole/CADMesh: A CAD file interface for GEANT4), I sometimes get geometry warnings even for simple parts such as this box.

Does that mean that my geometry export from the cad program is faulty? I would expect no errors/warnings hereā€¦ Makes it difficult to distinguish between actual overlaps, as for some parts generated points are not inside as in this example but outside

Checking overlaps for volume mesh105 (G4TessellatedSolid) ... 
-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomVol1002
      issued by : G4PVPlacement::CheckOverlaps()
Sample point is not on the surface !
          The issue is detected for volume mesh105:0 (G4TessellatedSolid)
          generated point (625.785,-506.69,-149.825) is inside
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

mesh105:

ply
format ascii 1.0
comment Created by Blender 2.91.0 - www.blender.org
element vertex 8
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
property uchar alpha
element face 12
property list uchar uint vertex_indices
end_header
627.047363 -506.954254 -1.275000 255 255 255 255
627.047363 -77.454247 -530.775024 255 255 255 255
627.047363 -77.454247 -1.275000 255 255 255 255
625.047363 -506.954254 -530.775024 255 255 255 255
625.047363 -77.454247 -530.775024 255 255 255 255
625.047363 -77.454247 -1.275000 255 255 255 255
625.047363 -506.954254 -1.275000 255 255 255 255
627.047363 -506.954254 -530.775024 255 255 255 255
3 0 1 2
3 1 3 4
3 2 4 5
3 0 5 6
3 3 5 4
3 7 6 3
3 0 7 1
3 1 7 3
3 2 1 4
3 0 2 5
3 3 6 5
3 7 0 6
1 Like

It looks like a bug in G4TessellatedSolid::Inside().

Please report the issue in the Geant4 Problem Tracking System:
https://bugzilla-geant4.kek.jp

The reason of the issue is the calculation error of the algorithm for calculation of a distance from a point to 3D triangle. In your case the error very often was bigger than the thickness of the surface, it resulted in incorrect return value from Inside().

To fix the issue you can change the code for the region 0 in G4TriangularFacet::Distance(p) (line 346) to the following:

      //
      // We are in region 0.
      //
      G4double dist = fSurfaceNormal.dot(D);
      fSqrDist = dist*dist;
      return fSurfaceNormal*dist;

thanks :slight_smile:
Just checked with the part from before: running /geometry/test/run multiple times did not produce any warnings.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.