+std::string Selector_Selector::name(Selector_NameGenerator* theNameGenerator) {
+ switch(myType) {
+ case SELTYPE_CONTAINER:
+ case SELTYPE_INTERSECT: {
+ std::string aResult;
+ // add names of sub-components one by one separated by "&"
+ std::list<Selector_Selector>::iterator aSubSel = mySubSelList.begin();
+ for(; aSubSel != mySubSelList.end(); aSubSel++) {
+ if (aSubSel != mySubSelList.begin())
+ aResult += "&";
+ aResult += aSubSel->name(theNameGenerator);
+ }
+ return aResult;
+ }
+ case SELTYPE_PRIMITIVE: {
+ Handle(TDataStd_Name) aName;
+ if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName))
+ return "";
+ return theNameGenerator->contextName(myFinal) + "/" +
+ std::string(TCollection_AsciiString(aName->Get()).ToCString());
+ }
+ case SELTYPE_MODIFICATION: {
+ // final&/base1&base2
+ std::string aResult;
+ Handle(TDataStd_Name) aName;
+ if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName))
+ return "";
+ aResult += theNameGenerator->contextName(myFinal) + "/" +
+ std::string(TCollection_AsciiString(aName->Get()).ToCString()) + "&/";
+ for(TDF_LabelList::iterator aBase = myBases.begin(); aBase != myBases.end(); aBase++) {
+ if (aBase != myBases.begin())
+ aResult += "&";
+ if (aBase->FindAttribute(TDataStd_Name::GetID(), aName))
+ return "";
+ aResult += theNameGenerator->contextName(*aBase) + "/" +
+ std::string(TCollection_AsciiString(aName->Get()).ToCString());
+ }
+ return aResult;
+ }
+ case SELTYPE_FILTER_BY_NEIGHBOR: {
+ // (nb1)level_if_more_than_1&(nb2)level_if_more_than_1&(nb3)level_if_more_than_1
+ std::string aResult;
+ std::list<int>::iterator aLevel = myNBLevel.begin();
+ std::list<Selector_Selector>::iterator aSubSel = mySubSelList.begin();
+ for(; aSubSel != mySubSelList.end(); aSubSel++, aLevel++) {
+ if (aSubSel != mySubSelList.begin())
+ aResult += "&";
+ aResult += "(" + aSubSel->name(theNameGenerator) + ")";
+ if (*aLevel > 1)
+ aResult += *aLevel;
+ }
+ return aResult;
+ }
+ default: { // unknown case
+ }
+ };
+ return "";
+}
+
+bool Selector_Selector::selectBySubSelector(
+ const TopoDS_Shape theContext, const TopoDS_Shape theValue)