For a small (~um) tessellated solid, the Inside function sometimes gives undetermined result. I spend some time to debug and find the problem is caused by G4TriangularFacet Intersect function. Here is the code: G4double d = E[0].dot(DD); G4double e = E[1].dot(DD); G4double s = b*e - c*d; G4double t = b*d - a*e; G4double sTolerance = (std::fabs(b)+ std::fabs(c) + std::fabs(d) + std::fabs(e)) *kCarTolerance; G4double tTolerance = (std::fabs(a)+ std::fabs(b) + std::fabs(d) + std::fabs(e)) *kCarTolerance; G4double detTolerance = (std::fabs(a)+ std::fabs(c) + 2*std::fabs(b) ) *kCarTolerance; if (s < -sTolerance || t < -tTolerance || ( s+t - det ) > detTolerance) both a/b/c/d/e has the dimension of L^2, as a result, s and t should have the dimension as L^4. However, the sTolerance / tTolerance / detTolerance only ~ L^3. I guess sTolerance / tTolerance / detTolerance should be changed to G4double sTolerance = (std::fabs(b)+ std::fabs(c) + std::fabs(d) + std::fabs(e)) *kCarTolerance*kCarTolerance; G4double tTolerance = (std::fabs(a)+ std::fabs(b) + std::fabs(d) + std::fabs(e)) *kCarTolerance*kCarTolerance; G4double detTolerance = (std::fabs(a)+ std::fabs(c) + 2*std::fabs(b) ) *kCarTolerance*kCarTolerance;
Dear Gong Ding, Could you send us more information about the solid or a source code were error happens. It will help to understand the problem. Thank you, Best Regards, Tatiana.