[Gmsh] Frontal Algo BUG (in edgeSwapPass function)

walter steffe walter.steffe at alice.it
Sat Feb 20 12:29:03 CET 2016

I have finally understood where is the problem:
It is in the following lines (starting at line 2972) of file

        delete *it;
        CONTAINER::iterator itb = it;
        if(it == allTris.end()) break;

CONTAINER (which is type of allTris) was previously defined as:
  typedef std::set<MTri3*, compareTri3Ptr> CONTAINER;

Compare function was defind as:

  class compareTri3Ptr
    inline bool operator () (const MTri3 *a, const MTri3 *b)  const
      if(a->getRadius() > b->getRadius()) return true;
      if(a->getRadius() < b->getRadius()) return false;
      Less_Face lf;
      return lf(a->tri()->getFace(0), b->tri()->getFace(0));

compareTri3Ptr takes care of the triangle value (and not just of its
pointer). So, when triangle is deleted at line 2973, the set ordering is
changed and the iterator can be invalidated. Therefore
allTris.erase(itb) may remove a wrong triangle.

Annexed patch (to be applied to gmsh version 2.11.0) fixes the problem.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: meshGFaceOptimize.cpp.patch
Type: text/x-patch
Size: 430 bytes
Desc: not available
URL: <http://onelab.info/pipermail/gmsh/attachments/20160220/ad250986/attachment.patch>

More information about the gmsh mailing list