-// 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_NamedShape.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_Integer.hxx>
Selector_Intersect::Selector_Intersect() : Selector_AlgoWithSubs()
{
myWeakIndex = -1; // no index by default
+ myRecomputeWeakIndex = false;
}
// returns the sub-shapes of theSubType which belong to all theShapes (so, common or intersection)
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)) {
{
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) {
+ 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);
- if (aSubStr.find(weakNameID()) == 0) { // weak name identifier
- std::wstring aWeakIndex = aSubStr.substr(weakNameID().size());
- myWeakIndex = stoi(aWeakIndex);
+ size_t aFoundOldWeak = aSubStr.find(oldWeakNameID());
+ size_t aFoundNewWeak = aFoundOldWeak != std::wstring::npos ?
+ aSubStr.find(weakNameID()) :
+ aFoundOldWeak;
+ if (aFoundOldWeak == 0 || aFoundNewWeak == 0) { // weak name identifier
+ std::wstring aWeakIndex = aSubStr.substr(aFoundOldWeak + oldWeakNameID().size());
+ myWeakIndex = atoi(Locale::Convert::toString(aWeakIndex).c_str());
+ myRecomputeWeakIndex = aFoundOldWeak == 0;
continue;
}
TopAbs_ShapeEnum aSubShapeType = TopAbs_FACE;
- if (anEndPos != std::string::npos && anEndPos + 1 < theName.size()) {
+ if (anEndPos != std::wstring::npos && anEndPos + 1 < theName.size()) {
wchar_t aShapeChar = theName[anEndPos + 1];
- if (theName[anEndPos + 1] != '[') {
+ if (theName[anEndPos + 1] != L'[') {
switch(aShapeChar) {
case 'e': aSubShapeType = TopAbs_EDGE; break;
case 'v': aSubShapeType = TopAbs_VERTEX; break;
commonShapes(aSubSelectorShapes, myShapeType, aCommon);
if (aCommon.Extent() != 1) {
if (myWeakIndex != -1) {
- Selector_NExplode aNexp(aCommon);
+ Selector_NExplode aNexp(aCommon, myRecomputeWeakIndex);
aResult = aNexp.shape(myWeakIndex);
+ myRecomputeWeakIndex = false;
} else if (geometricalNaming() && aCommon.Extent() > 1) {
// check results are on the same geometry, create compound
TopoDS_ListOfShape::Iterator aCommonIter(aCommon);