Problem 1573 - Bug vertexMap writing Tesselated solids
Summary: Bug vertexMap writing Tesselated solids
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: persistency/gdml (show other problems)
Version: 9.6
Hardware: All All
: P5 minor
Assignee: Gabriele Cosmo
URL:
Depends on:
Blocks:
 
Reported: 2014-02-18 16:28 CET by henri
Modified: 2014-03-13 14:36 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description henri 2014-02-18 16:28:45 CET
During exportation of a mesh it seems that some "wanted" vertices are ignored.
And the vertexMap is mismatching some relationship.

This is due by the fact that the vertexMap define vertices as G4ThreeVector. And the map is based on the G4ThreeVector operator '<'.

But this operator simply use the length of each vector to make the comparaison. So we can have different vector (Vertex) but which are evaluated as "equal" by this operator. So during the exportation we can skip a vertex and match with a previous one without correspondence.


The problem has been discovered on the Geant4 9.6. version but from what I saw is still present on the 4.10 version.

A quick way to fix it is to redefine the operator of comparison by something like : 

class compareG4_3Vect
{
  public:
  bool operator()(const G4ThreeVector& t1, const G4ThreeVector& t2 )
  {
    if(t1.x() < t2.x())
      return true;

    if(t1.y() < t2.y())
      return true;

    if(t1.z() < t2.z())
      return true;

    return false;
  };
};

and modifying the vertexMap by : 
   std::map<G4ThreeVector, G4String, compareG4_3Vect> vertexMap;
Comment 1 Gabriele Cosmo 2014-03-13 14:36:14 CET
Thanks for reporting this and for the proposed solution.
The fix is now introduced in the development trunk and will be included in the next patch release.