]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/Selector/Selector_WeakName.cpp
Salome HOME
Merge remote-tracking branch 'remotes/origin/EDF_2020_Lot2'
[modules/shaper.git] / src / Selector / Selector_WeakName.cpp
index 6d3ad04552ff95f096623d8b901d39c2630e030a..559071b9c461e8f088a681c1a5de86c3bdcbfdba 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
 #include <Selector_NameGenerator.h>
 #include <Selector_NExplode.h>
 
+#include <Locale_Convert.h>
+
 #include <TNaming_Tool.hxx>
 #include <TNaming_SameShapeIterator.hxx>
 #include <TNaming_Iterator.hxx>
 #include <TDataStd_Integer.hxx>
 
-Selector_WeakName::Selector_WeakName() : Selector_Algo()
+Selector_WeakName::Selector_WeakName() : Selector_Algo(), myRecomputeWeakIndex(false)
 {
 }
 
@@ -88,9 +90,11 @@ bool Selector_WeakName::restore()
 TDF_Label Selector_WeakName::restoreByName(std::wstring theName,
   const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator)
 {
-  std::wstring aWeakIndex = theName.substr(pureWeakNameID().size());
+  size_t aFoundWeak = theName.find(oldPureWeakNameID());
+  std::wstring aWeakIndex = theName.substr(aFoundWeak + oldPureWeakNameID().size());
   std::size_t aContextPosition = aWeakIndex.find(L"_");
-  myWeakIndex = std::stoi(aWeakIndex.c_str());
+  myWeakIndex = atoi(Locale::Convert::toString(aWeakIndex).c_str());
+  myRecomputeWeakIndex = aFoundWeak == 0;
   myShapeType = theShapeType;
   TDF_Label aContext;
   if (aContextPosition != std::wstring::npos) { // context is also defined
@@ -116,8 +120,9 @@ bool Selector_WeakName::solve(const TopoDS_Shape& theContext)
     }
   }
   if (!aContext.IsNull()) {
-    Selector_NExplode aNexp(aContext, myShapeType);
+    Selector_NExplode aNexp(aContext, myShapeType, myRecomputeWeakIndex);
     TopoDS_Shape aResult = aNexp.shape(myWeakIndex);
+    myRecomputeWeakIndex = false;
     if (!aResult.IsNull()) {
       Selector_Algo::store(aResult);
       return true;