diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index c0c37141275e0ac9ac82a6f54dfa2172d1b27d47..0382980f94430d6a50328acee9d41610985314cf 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -1760,24 +1760,26 @@ int GModel::removeDuplicateMeshVertices(double tolerance) } // replace vertices in periodic copies std::map<MVertex*,MVertex*>& corrVtcs = ge->correspondingVertices; - std::map<MVertex*,MVertex*>::iterator cIter; - for (cIter = duplicates.begin(); cIter != duplicates.end(); ++cIter) { - MVertex* oldTgt = cIter->first; - MVertex* newTgt = cIter->second; - std::map<MVertex*, MVertex*>::iterator cvIter = corrVtcs.find(oldTgt); - if (cvIter != corrVtcs.end()) { - MVertex* src = cvIter->second; - corrVtcs.erase(cvIter); - corrVtcs[newTgt] = src; - } - } - for (cIter = corrVtcs.begin(); cIter != corrVtcs.end(); ++cIter) { - MVertex* oldSrc = cIter->second; - std::map<MVertex*,MVertex*>::iterator nIter = duplicates.find(oldSrc); - if (nIter != duplicates.end()) { - MVertex* tgt = cIter->first; - MVertex* newSrc = nIter->second; - corrVtcs[tgt] = newSrc; + if(corrVtcs.size()){ + std::map<MVertex*,MVertex*>::iterator cIter; + for (cIter = duplicates.begin(); cIter != duplicates.end(); ++cIter) { + MVertex* oldTgt = cIter->first; + MVertex* newTgt = cIter->second; + std::map<MVertex*, MVertex*>::iterator cvIter = corrVtcs.find(oldTgt); + if (cvIter != corrVtcs.end()) { + MVertex* src = cvIter->second; + corrVtcs.erase(cvIter); + corrVtcs[newTgt] = src; + } + } + for (cIter = corrVtcs.begin(); cIter != corrVtcs.end(); ++cIter) { + MVertex* oldSrc = cIter->second; + std::map<MVertex*,MVertex*>::iterator nIter = duplicates.find(oldSrc); + if (nIter != duplicates.end()) { + MVertex* tgt = cIter->first; + MVertex* newSrc = nIter->second; + corrVtcs[tgt] = newSrc; + } } } }