diff --git a/Mesh/meshGFaceDelaunayInsertion.cpp b/Mesh/meshGFaceDelaunayInsertion.cpp index ac3b41cd07f43d02b462421a47dbf92c8b07e835..a6b16c4e49cfc94a1ca383e9b36601e6525d8051 100644 --- a/Mesh/meshGFaceDelaunayInsertion.cpp +++ b/Mesh/meshGFaceDelaunayInsertion.cpp @@ -1024,6 +1024,7 @@ int insertVertexB(std::list &shell, std::list &cavity, // DT_INSERT_VERTEX += t2-t1; if(std::abs(oldVolume - newVolume) > EPS * oldVolume) return -3; if(onePointIsTooClose) return -4; + if(cavity.size() == 2) return -6; return -5; } } @@ -1252,9 +1253,36 @@ static bool insertAPoint(GFace *gf, Msg::Debug("Point %g %g cannot be inserted because it is out of the " "parametric domain)", center[0], center[1]); + if (result == -6) + Msg::Debug("Point %g %g cannot be inserted because it is not improving " + "the quality of the 2 elements", + center[0], center[1]); AllTris.erase(it); - worst->forceRadius(-1); + + // As in case of result = -6 it might happen that inside we would like to + // refine the mesh, we should not force the radius to -1, but pretend that + // the radius is good enough (less than LIMIT_ but higher than 0). + if (result == -6){ + Msg::Debug("Forcing radius to %g", 0.5 * LIMIT_); + worst->forceRadius(0.5 * LIMIT_); + if(ActiveTris){ + // Go over its neighbours to check whether they should become active + for (size_t index = 0; index < 3; index++){ + MTri3 *pNeighbour = worst->getNeigh(index); // TODO C++11 use auto + if (pNeighbour == 0) continue; + int active_edge; + if(isActive(pNeighbour, LIMIT_, active_edge) && + pNeighbour->getRadius() > LIMIT_){ + if((*ActiveTris).find(pNeighbour) == (*ActiveTris).end()) + (*ActiveTris).insert(pNeighbour); + } + } + } + } + else + worst->forceRadius(-1); + AllTris.insert(worst); delete v; for(std::list::iterator itc = cavity.begin();