]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/Selector/Selector_FilterByNeighbors.cpp
Salome HOME
Merge remote-tracking branch 'remotes/origin/EDF_2020_Lot2'
[modules/shaper.git] / src / Selector / Selector_FilterByNeighbors.cpp
index 07503640024af02fd252c57a9bcfc22a4c5562c8..49992956baf17b69272e20cdb32a5b6e949e68c5 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -194,7 +194,9 @@ bool Selector_FilterByNeighbors::select(
   myContext = theContextLab;
   // searching by neighbors
   std::list<std::pair<TopoDS_Shape, int> > aNBs; /// neighbor sub-shape -> level of neighborhood
-  for(int aLevel = 1; true; aLevel++) {
+  // # 19071 : moving through all levels may be too long, in practice there are no more than 2 or 3
+  // levels real cases, so, make it "5" as maximum possible
+  for(int aLevel = 1; aLevel < 5; aLevel++) {
     TopTools_MapOfShape aNewNB;
     findNeighbors(theContext, theValue, aLevel, aNewNB);
     if (aNewNB.Extent() == 0) { // there are no neighbors of the given level, stop iteration
@@ -271,7 +273,6 @@ bool Selector_FilterByNeighbors::restore()
     myNBLevel.push_back(anArray->Value(anIndex));
   }
   // restore sub-selectors
-  bool aSubResult = true;
   for(TDF_ChildIterator aSub(label(), false); aSub.More(); aSub.Next()) {
     Selector_Algo* aSubSel = restoreByLab(aSub.Value(), baseDocument());
     if (!append(aSubSel, false)) {
@@ -280,7 +281,7 @@ bool Selector_FilterByNeighbors::restore()
       // some selector fails, try to use rest selectors, myNBLevel becomes negative: unused
       if (myNBLevel.size() > list().size()) {
         std::list<int>::iterator aListIter = myNBLevel.begin();
-        for(int a = 0; a < list().size(); a++)
+        for(size_t a = 0; a < list().size(); a++)
           aListIter++;
         *aListIter = -*aListIter;
         list().push_back(NULL);
@@ -300,10 +301,10 @@ TDF_Label Selector_FilterByNeighbors::restoreByName(std::wstring theName,
   myShapeType = theShapeType;
   TDF_Label aContext;
   std::wstring aLastLevel; // last level string (after '(' )  to check the context name in the end
-  for (size_t aStart = 0; aStart != std::string::npos;
-    aStart = theName.find('(', aStart + 1)) {
-    size_t anEndPos = theName.find(')', aStart + 1);
-    if (anEndPos != std::string::npos) {
+  for (size_t aStart = 0; aStart != std::wstring::npos;
+       aStart = theName.find(L'(', aStart + 1)) {
+    size_t anEndPos = theName.find(L')', aStart + 1);
+    if (anEndPos != std::wstring::npos) {
       std::wstring aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1);
       TDF_Label aSubContext;
       Selector_Algo* aSubSel =
@@ -328,13 +329,13 @@ TDF_Label Selector_FilterByNeighbors::restoreByName(std::wstring theName,
 
       // searching for the level index
       std::wstring aLevel;
-      for (anEndPos++; anEndPos != std::string::npos &&
-        theName[anEndPos] != '(' && theName[anEndPos] != 0;
+      for (anEndPos++; anEndPos != std::wstring::npos &&
+        theName[anEndPos] != L'(' && theName[anEndPos] != 0;
         anEndPos++) {
         aLevel += theName[anEndPos];
       }
       aLastLevel = aLevel;
-      if (aLevel.empty() || aLevel[0] == '_')
+      if (aLevel.empty() || aLevel[0] == L'_')
         myNBLevel.push_back(1); // by default it is 1
       else {
         int aNum = std::stoi(aLevel.c_str());
@@ -348,7 +349,7 @@ TDF_Label Selector_FilterByNeighbors::restoreByName(std::wstring theName,
   }
   if (!aLastLevel.empty()) { // get the context
     size_t aLinePos = aLastLevel.find(L"_");
-    if (aLinePos != std::string::npos) {
+    if (aLinePos != std::wstring::npos) {
       std::wstring aContextName = aLastLevel.substr(aLinePos + 1);
       if (!aContextName.empty()) {
         TDF_Label aThisContext, aValue;