-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Selector_Container.h>
return false;
myShapeType = TopAbs_ShapeEnum(aShapeTypeAttr->Get());
// 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)) {
return true;
}
-TDF_Label Selector_Container::restoreByName(std::string theName,
+TDF_Label Selector_Container::restoreByName(std::wstring theName,
const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator)
{
myShapeType = theShapeType;
TDF_Label aContext;
- 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);
+ for(size_t aStart = 0; aStart != std::wstring::npos; aStart = theName.find('[', aStart + 1)) {
+ size_t anEndPos = theName.find(L']', aStart + 1);
+ if (anEndPos != std::wstring::npos) {
+ // there could be sub-intersections, so, [[...]] case; searching for other open-bracket
+ size_t aNextStart = theName.find(L'[', aStart + 1);
+ while(aNextStart != std::wstring::npos && aNextStart < anEndPos) {
+ anEndPos = theName.find(L']', anEndPos + 1);
+ if (anEndPos == std::wstring::npos) {
+ return TDF_Label(); // invalid parentheses
+ }
+ aNextStart = theName.find(L'[', aNextStart + 1);
+ }
+ if (anEndPos == std::wstring::npos)
+ return TDF_Label(); // invalid parentheses
+ std::wstring aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1);
TopAbs_ShapeEnum aSubShapeType = TopAbs_FACE;
switch (myShapeType) {
case TopAbs_COMPSOLID: aSubShapeType = TopAbs_SOLID; break;
}
TDF_Label aSubContext;
Selector_Algo* aSubSel =
- Selector_Algo::restoreByName(
- newSubLabel(), baseDocument(), aSubStr, aSubShapeType, theNameGenerator, aSubContext);
+ Selector_Algo::restoreByName(newSubLabel(), baseDocument(), aSubStr, aSubShapeType,
+ geometricalNaming(), theNameGenerator, aSubContext);
if (!append(aSubSel))
return TDF_Label();
}
} else
return TDF_Label(); // invalid parentheses
+ aStart = anEndPos; // for recursive parenthesis set start on the current end
}
return aContext;
}
aResult = aWire;
break;
}
+ default:
+ break;
}
TopoDS_ListOfShape aSubSelectorShapes;
std::list<Selector_Algo*>::const_iterator aSubSel = list().cbegin();
return false;
}
-std::string Selector_Container::name(Selector_NameGenerator* theNameGenerator)
+std::wstring Selector_Container::name(Selector_NameGenerator* theNameGenerator)
{
- std::string aResult;
+ std::wstring aResult;
// add names of sub-components one by one in "[]"
std::list<Selector_Algo*>::const_iterator aSubSel = list().cbegin();
for(; aSubSel != list().cend(); aSubSel++) {