// check the value shape can be named as it is, or it is needed to construct it from the
// higher level shapes (like a box vertex by faces that form this vertex)
bool aIsFound = TNaming_Tool::HasLabel(myLab, theValue);
- if (aIsFound) { // additional check for selection and delete evolution only: also could not be used
+ if (aIsFound) { // additional check for selection and delete evolution only: also could not use
aIsFound = false;
for(TNaming_SameShapeIterator aShapes(theValue, myLab); aShapes.More(); aShapes.Next())
{
myWeakIndex = aNexp.index(theValue);
if (myWeakIndex != -1) {
myShapeType = theValue.ShapeType();
- return true;
+ // searching for context shape label to store in myFinal
+ myFinal.Nullify();
+ if (TNaming_Tool::HasLabel(myLab, theContext)) {
+ for(TNaming_SameShapeIterator aShapes(theContext, myLab); aShapes.More(); aShapes.Next())
+ {
+ Handle(TNaming_NamedShape) aNS;
+ if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
+ TNaming_Evolution anEvolution = aNS->Evolution();
+ if (anEvolution == TNaming_PRIMITIVE || anEvolution == TNaming_GENERATED ||
+ anEvolution == TNaming_MODIFY) {
+ // check this is a new shape
+ for(TNaming_Iterator aNSIter(aNS); aNSIter.More(); aNSIter.Next()) {
+ if (aNSIter.NewShape().IsSame(theContext)) {
+ myFinal = aNS->Label();
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return true; // could be final empty (in case it is called recursively) or not
}
return false;
return false;
// searching by neighbours
- std::list<std::pair<TopoDS_Shape, int> > aNBs; /// neighbor sub-shape -> level of neighborhood
+ std::list<std::pair<TopoDS_Shape, int> > aNBs;//neighbor sub-shape -> level of neighborhood
for(int aLevel = 1; true; aLevel++) {
TopTools_MapOfShape aNewNB;
findNeighbors(theContext, theValue, aLevel, aNewNB);
// check which can be named correctly, without by neighbors type
for(TopTools_MapOfShape::Iterator aNBIter(aNewNB); aNBIter.More(); ) {
Selector_Selector aSelector(myLab.FindChild(1));
- if (aSelector.select(theContext, aNBIter.Value(), false)) { // add to the list of good NBs
+ if (aSelector.select(theContext, aNBIter.Value(), false)) {// add to list of good NBs
aNBs.push_back(std::pair<TopoDS_Shape, int>(aNBIter.Value(), aLevel));
}
aNewNB.Remove(aNBIter.Key());
case SELTYPE_WEAK_NAMING: {
TDataStd_Integer::Set(myLab, kWEAK_INDEX, myWeakIndex);
TDataStd_Integer::Set(myLab, kSHAPE_TYPE, (int)myShapeType);
+ // store myFinal in the base array
+ if (!myFinal.IsNull()) {
+ Handle(TDataStd_ReferenceArray) anArray =
+ TDataStd_ReferenceArray::Set(myLab, kBASE_ARRAY, 0, 0);
+ anArray->SetValue(0, myFinal);
+ }
break;
}
default: { // unknown case
if (!myLab.FindAttribute(kSHAPE_TYPE, aShapeTypeAttr))
return false;
myShapeType = TopAbs_ShapeEnum(aShapeTypeAttr->Get());
- return myWeakIndex != -1;
+ Handle(TDataStd_ReferenceArray) anArray;
+ if (myLab.FindAttribute(kBASE_ARRAY, anArray)) {
+ myFinal = anArray->Value(0);
+ }
+ return true;
}
default: { // unknown case
}
break;
}
case SELTYPE_WEAK_NAMING: {
- Selector_NExplode aNexp(theContext, myShapeType);
- aResult = aNexp.shape(myWeakIndex);
+ TopoDS_Shape aContext;
+ if (myFinal.IsNull()) {
+ aContext = theContext;
+ } else {
+ Handle(TNaming_NamedShape) aNS;
+ if (myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
+ aContext = aNS->Get();
+ }
+ }
+ if (!aContext.IsNull()) {
+ Selector_NExplode aNexp(aContext, myShapeType);
+ aResult = aNexp.shape(myWeakIndex);
+ }
}
default: { // unknown case
}
}
static const std::string kWEAK_NAME_IDENTIFIER = "weak_name_";
+static const std::string kPUREWEAK_NAME_IDENTIFIER = "_weak_name_";
std::string Selector_Selector::name(Selector_NameGenerator* theNameGenerator) {
switch(myType) {
std::list<Selector_Selector>::iterator aSubSel = mySubSelList.begin();
for(; aSubSel != mySubSelList.end(); aSubSel++, aLevel++) {
aResult += "(" + aSubSel->name(theNameGenerator) + ")";
- if (*aLevel > 1)
- aResult += *aLevel;
+ if (*aLevel > 1) {
+ std::ostringstream aLevelStr;
+ aLevelStr<<*aLevel;
+ aResult += aLevelStr.str();
+ }
}
return aResult;
}
case SELTYPE_WEAK_NAMING: {
- // weak_naming_1
+ // _weak_naming_1_Context
std::ostringstream aWeakStr;
- aWeakStr<<kWEAK_NAME_IDENTIFIER<<myWeakIndex;
+ aWeakStr<<kPUREWEAK_NAME_IDENTIFIER<<myWeakIndex;
std::string aResult = aWeakStr.str();
+ if (!myFinal.IsNull())
+ aResult += "_" + theNameGenerator->contextName(myFinal);
return aResult;
}
default: { // unknown case
return TDF_Label(); // invalid parentheses
}
return aContext;
+ } if (theName.find(kPUREWEAK_NAME_IDENTIFIER) == 0) { // weak naming identifier
+ myType = SELTYPE_WEAK_NAMING;
+ std::string aWeakIndex = theName.substr(kPUREWEAK_NAME_IDENTIFIER.size());
+ std::size_t aContextPosition = aWeakIndex.find("_");
+ myWeakIndex = atoi(aWeakIndex.c_str());
+ myShapeType = theShapeType;
+ TDF_Label aContext;
+ if (aContextPosition != std::string::npos) { // context is also defined
+ std::string aContextName = aWeakIndex.substr(aContextPosition + 1);
+ theNameGenerator->restoreContext(aContextName, aContext, myFinal);
+ }
+ return aContext;
} else if (theName.find('&') == std::string::npos) { // wihtout '&' it can be only primitive
myType = SELTYPE_PRIMITIVE;
TDF_Label aContext;
if (!myFinal.IsNull())
return aContext;
}
- } if (theName.find(kWEAK_NAME_IDENTIFIER) == 0) { // weak naming identifier
- myType = SELTYPE_WEAK_NAMING;
- std::string aWeakIndex = theName.substr(kWEAK_NAME_IDENTIFIER.size());
- myWeakIndex = atoi(aWeakIndex.c_str());
- myShapeType = theShapeType;
- return myLab;
} else { // modification
myType = SELTYPE_MODIFICATION;
TDF_Label aContext;