Salome HOME
Merge remote-tracking branch 'remotes/origin/EDF_2020_Lot2'
[modules/shaper.git] / src / Selector / Selector_FilterByNeighbors.cpp
index 0035d48f086b75f46dec9a85c9bd0445e83dc7e3..49992956baf17b69272e20cdb32a5b6e949e68c5 100644 (file)
@@ -295,17 +295,17 @@ bool Selector_FilterByNeighbors::restore()
   return myNBLevel.size() == list().size() && !myNBLevel.empty();
 }
 
-TDF_Label Selector_FilterByNeighbors::restoreByName(std::string theName,
+TDF_Label Selector_FilterByNeighbors::restoreByName(std::wstring theName,
   const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator)
 {
   myShapeType = theShapeType;
   TDF_Label aContext;
-  std::string 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) {
-      std::string aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1);
+  std::wstring aLastLevel; // last level string (after '(' )  to check the context name in the end
+  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 =
         Selector_Algo::restoreByName(newSubLabel(), baseDocument(), aSubStr, myShapeType,
@@ -328,17 +328,17 @@ TDF_Label Selector_FilterByNeighbors::restoreByName(std::string theName,
       //  aContext = theNameGenerator->newestContext(aContext);
 
       // searching for the level index
-      std::string aLevel;
-      for (anEndPos++; anEndPos != std::string::npos &&
-        theName[anEndPos] != '(' && theName[anEndPos] != 0;
+      std::wstring aLevel;
+      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 = atoi(aLevel.c_str());
+        int aNum = std::stoi(aLevel.c_str());
         if (aNum > 0)
           myNBLevel.push_back(aNum);
         else
@@ -348,9 +348,9 @@ TDF_Label Selector_FilterByNeighbors::restoreByName(std::string theName,
       return TDF_Label(); // invalid parentheses
   }
   if (!aLastLevel.empty()) { // get the context
-    size_t aLinePos = aLastLevel.find("_");
-    if (aLinePos != std::string::npos) {
-      std::string aContextName = aLastLevel.substr(aLinePos + 1);
+    size_t aLinePos = aLastLevel.find(L"_");
+    if (aLinePos != std::wstring::npos) {
+      std::wstring aContextName = aLastLevel.substr(aLinePos + 1);
       if (!aContextName.empty()) {
         TDF_Label aThisContext, aValue;
         if (theNameGenerator->restoreContext(aContextName, aThisContext, aValue)) {
@@ -388,23 +388,23 @@ bool Selector_FilterByNeighbors::solve(const TopoDS_Shape& theContext)
   return false;
 }
 
-std::string Selector_FilterByNeighbors::name(Selector_NameGenerator* theNameGenerator)
+std::wstring Selector_FilterByNeighbors::name(Selector_NameGenerator* theNameGenerator)
 {
   // (nb1)level_if_more_than_1(nb2)level_if_more_than_1(nb3)level_if_more_than_1
   bool aThisContextNameNeeded = !myContext.IsNull();
-  std::string aContextName;
+  std::wstring aContextName;
   if (aThisContextNameNeeded)
     aContextName = theNameGenerator->contextName(myContext);
-  std::string aResult;
+  std::wstring aResult;
   std::list<int>::iterator aLevel = myNBLevel.begin();
   std::list<Selector_Algo*>::const_iterator aSubSel = list().cbegin();
   for(; aSubSel != list().cend(); aSubSel++, aLevel++) {
     if (!*aSubSel)
       continue;
-    std::string aSubName = (*aSubSel)->name(theNameGenerator);
-    aResult += "(" + aSubName + ")";
+    std::wstring aSubName = (*aSubSel)->name(theNameGenerator);
+    aResult += L"(" + aSubName + L")";
     if (*aLevel > 1) {
-      std::ostringstream aLevelStr;
+      std::wostringstream aLevelStr;
       aLevelStr<<*aLevel;
       aResult += aLevelStr.str();
     }
@@ -414,7 +414,7 @@ std::string Selector_FilterByNeighbors::name(Selector_NameGenerator* theNameGene
       aThisContextNameNeeded = false;
   }
   if (aThisContextNameNeeded) {
-    aResult = aResult + "_" + aContextName;
+    aResult = aResult + L"_" + aContextName;
   }
   return aResult;
 }