I was having an issue with G4Tessellated slids randomly deleting facets, resulting in broken geometries. I have traced it down to an error in G4VFacet::operator ==. Thie issue is that, as written, the loop for a 3-sided facet runs from 0-3 (inclusive) due to a misplaced autoincrement. Here is the original and the fix. ORIGINAL -- broken /////////////////////////////////////////////////////////////////////////////// // G4bool G4VFacet::operator== (const G4VFacet &right) const { G4double tolerance = kCarTolerance*kCarTolerance/4.0; if (nVertices != right.GetNumberOfVertices()) { return false; } else if ((circumcentre-right.GetCircumcentre()).mag2() > tolerance) { return false; } else if (std::fabs((right.GetSurfaceNormal()).dot(surfaceNormal)) < 0.9999999999) { return false; } G4bool coincident = true; size_t i = 0; do { coincident = false; size_t j = 0; do { coincident = (GetVertex(i)-right.GetVertex(j)).mag2() < tolerance; } while (!coincident && j++ < nVertices); } while (coincident && i++ < nVertices); return coincident; } CORRECTED: /////////////////////////////////////////////////////////////////////////////// // G4bool G4VFacet::operator== (const G4VFacet &right) const { G4double tolerance = kCarTolerance*kCarTolerance/4.0; if (nVertices != right.GetNumberOfVertices()) { return false; } else if ((circumcentre-right.GetCircumcentre()).mag2() > tolerance) { return false; } else if (std::fabs((right.GetSurfaceNormal()).dot(surfaceNormal)) < 0.9999999999) { return false; } G4bool coincident = true; size_t i = 0; do { coincident = false; size_t j = 0; do { coincident = (GetVertex(i)-right.GetVertex(j)).mag2() < tolerance; } while (!coincident && ++j < nVertices); } while (coincident && ++i < nVertices); return coincident; }
Thanks for reporting the problem. The suggested fix is now implemented in tag "geom-specific-V09-01-15" and will be included in the next release and patch.