X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSelector%2FSelector_Modify.cpp;h=536412e52f2ef9be90c6c59ac8b47a3fc7b4317b;hb=2576167d524fef734f4b8cc40bd79a96b2a0fb6a;hp=eb0817d835d1ea815c952294fa5cbb3b1bce203e;hpb=a48a3b574fbf6f526fbeebfd637e1f5d9f4f6ea9;p=modules%2Fshaper.git diff --git a/src/Selector/Selector_Modify.cpp b/src/Selector/Selector_Modify.cpp index eb0817d83..536412e52 100644 --- a/src/Selector/Selector_Modify.cpp +++ b/src/Selector/Selector_Modify.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2020 CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 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 @@ -22,6 +22,8 @@ #include #include +#include + #include #include #include @@ -150,17 +152,18 @@ bool Selector_Modify::select(NCollection_List& theMo const TopoDS_Shape theContext, const TopoDS_Shape theValue) { if (theModifList.Extent() > 1) { // searching for the best modification result: by context + bool isFound = false; Handle(TNaming_NamedShape) aCandidate; NCollection_List::Iterator aModIter(theModifList); - for (; !theModifList.IsEmpty() && aModIter.More(); aModIter.Next()) { + for (; aModIter.More() && !isFound; aModIter.Next()) { aCandidate = aModIter.Value(); TDF_Label aFatherLab = aCandidate->Label().Father(); Handle(TNaming_NamedShape) aFatherNS; if (aFatherLab.FindAttribute(TNaming_NamedShape::GetID(), aFatherNS)) { - for (TNaming_Iterator anIter(aFatherNS); anIter.More(); anIter.Next()) { + for (TNaming_Iterator anIter(aFatherNS); + anIter.More() && !isFound; anIter.Next()) { if (theContext.IsSame(anIter.NewShape())) { // found the best modification - theModifList.Clear(); - break; + isFound = true; } } } @@ -241,25 +244,26 @@ bool Selector_Modify::restore() return false; } -TDF_Label Selector_Modify::restoreByName(std::string theName, +TDF_Label Selector_Modify::restoreByName(std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) { typedef NCollection_DataMap MapOfCompsolids; MapOfCompsolids aWrongSubsCompsolids; TDF_Label aContext; - for(size_t anEnd, aStart = 0; aStart != std::string::npos; aStart = anEnd) { + for(size_t anEnd, aStart = 0; aStart != std::wstring::npos; aStart = anEnd) { if (aStart != 0) aStart++; - anEnd = theName.find('&', aStart); - std::string aSubStr = - theName.substr(aStart, anEnd == std::string::npos ? anEnd : anEnd - aStart); + anEnd = theName.find(L'&', aStart); + std::wstring aSubStr = + theName.substr(aStart, anEnd == std::wstring::npos ? anEnd : anEnd - aStart); size_t aFoundOldWeak = aSubStr.find(oldWeakNameID()); - size_t aFoundNewWeak = aFoundOldWeak != std::string::npos ? + size_t aFoundNewWeak = aFoundOldWeak != std::wstring::npos ? aSubStr.find(weakNameID()) : aFoundOldWeak; if (aFoundOldWeak == 0 || aFoundNewWeak == 0) { // weak name identifier - std::string aWeakIndex = aSubStr.substr(aFoundOldWeak + oldWeakNameID().size()); myWeakIndex = atoi(aWeakIndex.c_str()); + std::wstring aWeakIndex = aSubStr.substr(aFoundOldWeak + oldWeakNameID().size()); + myWeakIndex = atoi(Locale::Convert::toString(aWeakIndex).c_str()); myRecomputeWeakIndex = aFoundOldWeak == 0; continue; } @@ -358,25 +362,25 @@ bool Selector_Modify::solve(const TopoDS_Shape& theContext) return false; } -std::string Selector_Modify::name(Selector_NameGenerator* theNameGenerator) +std::wstring Selector_Modify::name(Selector_NameGenerator* theNameGenerator) { // final&base1&base2 +optionally: [weak_name_1] - std::string aResult; + std::wstring aResult; Handle(TDataStd_Name) aName; if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName)) - return ""; - aResult += theNameGenerator->contextName(myFinal) + "/" + - std::string(TCollection_AsciiString(aName->Get()).ToCString()); + return L""; + aResult += theNameGenerator->contextName(myFinal) + L"/"; + aResult += Locale::Convert::toWString(aName->Get().ToExtString()); for(TDF_LabelList::iterator aBase = myBases.begin(); aBase != myBases.end(); aBase++) { if (!aBase->FindAttribute(TDataStd_Name::GetID(), aName)) - return ""; - aResult += "&"; - aResult += theNameGenerator->contextName(*aBase) + "/" + - std::string(TCollection_AsciiString(aName->Get()).ToCString()); + return L""; + aResult += L"&"; + aResult += theNameGenerator->contextName(*aBase) + L"/"; + aResult += Locale::Convert::toWString(aName->Get().ToExtString()); } if (myWeakIndex != -1) { - std::ostringstream aWeakStr; - aWeakStr<<"&"<