From: mpv Date: Tue, 23 Oct 2018 12:26:45 +0000 (+0300) Subject: External edges and vertices of the sketch selection implementation X-Git-Tag: End2018~280 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2da91de2a9adef6b5bc5c94f840831f33334e0cb;p=modules%2Fshaper.git External edges and vertices of the sketch selection implementation --- diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index eb527e696..ffa3015b4 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -88,12 +89,12 @@ Standard_GUID kCIRCLE_CENTER("d0d0e0f1-217a-4b95-8fbb-0c4132f23718"); Standard_GUID kELLIPSE_CENTER1("f70df04c-3168-4dc9-87a4-f1f840c1275d"); // identifier of the selection of the second focus point of ellipse on edge Standard_GUID kELLIPSE_CENTER2("1395ae73-8e02-4cf8-b204-06ff35873a32"); -// identifier of the weak naming index -Standard_GUID kWEAK_NAMING("9dcdd9be-a3a9-46eb-9b16-1c957ab20142"); -// identifier of the weak naming sub-shape type -Standard_GUID kWEAK_NAMING_SHAPETYPE("6b9cc709-e320-4a1f-9c42-df5622369ea7"); // reference to the external sketch face Standard_GUID kEXT_SKETCH_FACE("ba32aa31-bde7-422f-80b4-79c757c77b49"); +// reference to the external sketch edge +Standard_GUID kEXT_SKETCH_EDGE("ba32aa31-bde7-422f-80b4-79c757c77b48"); +// reference to the external sketch vertex +Standard_GUID kEXT_SKETCH_VERT("ba32aa31-bde7-422f-80b4-79c757c77b47"); // prefix for the whole feature context identification const static std::string kWHOLE_FEATURE = "all-in-"; @@ -140,9 +141,9 @@ bool Model_AttributeSelection::setValue(const ObjectPtr& theContext, aSelLab.ForgetAttribute(kCIRCLE_CENTER); aSelLab.ForgetAttribute(kELLIPSE_CENTER1); aSelLab.ForgetAttribute(kELLIPSE_CENTER2); - aSelLab.ForgetAttribute(kWEAK_NAMING); - aSelLab.ForgetAttribute(kWEAK_NAMING_SHAPETYPE); aSelLab.ForgetAttribute(kEXT_SKETCH_FACE); + aSelLab.ForgetAttribute(kEXT_SKETCH_EDGE); + aSelLab.ForgetAttribute(kEXT_SKETCH_VERT); bool isDegeneratedEdge = false; // do not use the degenerated edge as a shape, a null context and shape is used in the case @@ -378,9 +379,42 @@ std::shared_ptr Model_AttributeSelection::internalValue(CenterTyp if (aConstr->isInfinite()) return aResult; // empty result // external sketch face - Handle(TDataStd_Integer) aFaceIndex; - if (aSelLab.FindAttribute(kEXT_SKETCH_FACE, aFaceIndex)) { - return aConstr->face(aFaceIndex->Get()); + Handle(TDataStd_Integer) anIndex; + if (aSelLab.FindAttribute(kEXT_SKETCH_FACE, anIndex)) { + return aConstr->face(anIndex->Get()); + } + if (aSelLab.FindAttribute(kEXT_SKETCH_EDGE, anIndex) || + aSelLab.FindAttribute(kEXT_SKETCH_VERT, anIndex)) { + bool isVert = anIndex->ID() == kEXT_SKETCH_VERT; // vertex is selected + CompositeFeaturePtr aComposite = std::dynamic_pointer_cast( + aConstr->document()->feature(aConstr)); + if (aComposite.get()) { + int aSubNum = anIndex->Get() % 1000000; + int aVertShape = (anIndex->Get() - aSubNum) / 1000000; + FeaturePtr aSubFeat = aComposite->subFeature(aSubNum); + if (aSubFeat.get()) { + const std::list >& aResults = aSubFeat->results(); + std::list >::const_iterator aRes = aResults.cbegin(); + for (; aRes != aResults.cend(); aRes++) { + ResultConstructionPtr aConstr = + std::dynamic_pointer_cast(*aRes); + if (aConstr->shape()) { + if (!isVert && aConstr->shape()->isEdge()) + return aConstr->shape(); + else if (isVert && aVertShape == 0 && aConstr->shape()->isVertex()) + return aConstr->shape(); + else if (isVert && aVertShape > 1 && aConstr->shape()->isEdge()) { + GeomAPI_ShapeExplorer anExp(aConstr->shape(), GeomAPI_Shape::VERTEX); + for(; anExp.more(); anExp.next()) { + if (aVertShape == 1) + return anExp.current(); + aVertShape--; + } + } + } + } + } + } } } if (!aConstr.get()) { // for construction context, return empty result as usual even @@ -401,30 +435,6 @@ std::shared_ptr Model_AttributeSelection::internalValue(CenterTyp } } - if (aSelLab.IsAttribute(kWEAK_NAMING)) { // a weak naming is used - Handle(TDataStd_Integer) aWeakId; - aSelLab.FindAttribute(kWEAK_NAMING, aWeakId); - // get the context shape - GeomShapePtr aContextShape; - ResultBodyPtr aBody = std::dynamic_pointer_cast(context()); - if (aBody.get()) { - aContextShape = aBody->shape(); - } else { - ResultPtr aResult = std::dynamic_pointer_cast(myRef.value()); - if (aResult) { - aContextShape = aResult->shape(); - } - } - if (!aContextShape.get()) - return GeomShapePtr(); - Handle(TDataStd_Integer) aWeakShapeType; - aSelLab.FindAttribute(kWEAK_NAMING_SHAPETYPE, aWeakShapeType); - GeomAlgoAPI_NExplode aNExplode( - aContextShape, GeomAPI_Shape::ShapeType(aWeakShapeType->Get())); - GeomShapePtr aValue = aNExplode.shape(aWeakId->Get()); - return aValue; - } - Handle(TNaming_NamedShape) aSelection; if (aSelLab.FindAttribute(TNaming_NamedShape::GetID(), aSelection)) { TopoDS_Shape aSelShape = aSelection->Get(); @@ -602,29 +612,6 @@ bool Model_AttributeSelection::update() } if (aContext->groupName() == ModelAPI_ResultBody::group()) { - if (aSelLab.IsAttribute(kWEAK_NAMING)) { // a weak naming is used - Handle(TDataStd_Integer) aWeakId; - aSelLab.FindAttribute(kWEAK_NAMING, aWeakId); - // get the context shape - GeomShapePtr aContextShape; - ResultBodyPtr aBody = std::dynamic_pointer_cast(aContext); - if (aBody.get()) { - aContextShape = aBody->shape(); - } else { - ResultPtr aResult = std::dynamic_pointer_cast(myRef.value()); - if (aResult) { - aContextShape = aResult->shape(); - } - } - if (!setInvalidIfFalse(aSelLab, aContextShape.get() != NULL)) // context shape not found - return false; - Handle(TDataStd_Integer) aWeakShapeType; - aSelLab.FindAttribute(kWEAK_NAMING_SHAPETYPE, aWeakShapeType); - GeomAlgoAPI_NExplode aNExplode( - aContextShape, GeomAPI_Shape::ShapeType(aWeakShapeType->Get())); - GeomShapePtr aValue = aNExplode.shape(aWeakId->Get()); - return setInvalidIfFalse(aSelLab, aValue.get() != NULL); - } // body: just a named shape, use topological selection mechanism bool aResult = false; TopoDS_Shape anOldShape; @@ -666,6 +653,16 @@ bool Model_AttributeSelection::update() if (aSelLab.FindAttribute(kEXT_SKETCH_FACE, anIndex)) { return setInvalidIfFalse(aSelLab, anIndex->Get() < aConstructionContext->facesNum()); } + if (aSelLab.FindAttribute(kEXT_SKETCH_EDGE, anIndex) || + aSelLab.FindAttribute(kEXT_SKETCH_VERT, anIndex)) { + CompositeFeaturePtr aComposite = std::dynamic_pointer_cast( + aConstructionContext->document()->feature(aConstructionContext)); + if (aComposite.get()) { + FeaturePtr aSubFeat = aComposite->subFeature(anIndex->Get() % 1000000); + return setInvalidIfFalse(aSelLab, aSubFeat.get() != NULL); + } + return setInvalidIfFalse(aSelLab, false); // composite sub-feature is not found + } Selector_Selector aSelector(aSelLab); aResult = aSelector.restore(); TopoDS_Shape anOldShape = aSelector.value(); @@ -709,18 +706,67 @@ void Model_AttributeSelection::selectBody( TopoDS_Shape aNewSub = theSubShape->impl(); FeaturePtr aFeatureOwner = std::dynamic_pointer_cast(owner()); if (aFeatureOwner->document() != theContext->document()) { // reference to the sketch face - ResultConstructionPtr aConstr = - std::dynamic_pointer_cast(theContext); - int aFaceIndex = -1, aFacesNum = aConstr->facesNum(); - for(int a = 0; a < aFacesNum; a++) { - if (aConstr->face(a)->isEqual(theSubShape)) { - aFaceIndex = a; - break; + if (theSubShape->shapeType() == TopAbs_FACE) { // sketch face + ResultConstructionPtr aConstr = + std::dynamic_pointer_cast(theContext); + int aFaceIndex = -1, aFacesNum = aConstr->facesNum(); + for(int a = 0; a < aFacesNum; a++) { + if (aConstr->face(a)->isEqual(theSubShape)) { + aFaceIndex = a; + break; + } + } + if (aFaceIndex >= 0) { + TDataStd_Integer::Set(aSelLab, kEXT_SKETCH_FACE, aFaceIndex); // store index of the face + return; + } + } else if (theSubShape->shapeType() == TopAbs_EDGE || // sketch result edge (full one) + theSubShape->shapeType() == TopAbs_VERTEX) { // or start/end vertex + bool isVertex = theSubShape->shapeType() == TopAbs_VERTEX; + CompositeFeaturePtr aComposite = std::dynamic_pointer_cast( + theContext->document()->feature(theContext)); + if (aComposite.get()) { // iterate edges of composite to find index of matched with value + int aSub, anEdgeIndex = -1, aSubNum = aComposite->numberOfSubs(); + int aVertIndex = -1, aVertShape = -1; // shape: 0 full, 1 start, 2 end + for(aSub = 0; aSub < aSubNum && anEdgeIndex == -1; aSub++) { + FeaturePtr aSubFeat = aComposite->subFeature(aSub); + const std::list >& aResults = aSubFeat->results(); + std::list >::const_iterator aRes = aResults.cbegin(); + for (; aRes != aResults.cend(); aRes++) { + ResultConstructionPtr aConstr = + std::dynamic_pointer_cast(*aRes); + if (aConstr->shape() && aConstr->shape()->isEdge()) { + if (isVertex) { + GeomAPI_ShapeExplorer aVertExp(aConstr->shape(), GeomAPI_Shape::VERTEX); + for(int aNum = 1; aVertExp.more(); aVertExp.next(), aNum++) { + if (aVertExp.current()->isSame(theSubShape) && aVertShape != 0) { + aVertIndex = aSub; + aVertShape = aNum; + } + } + } else { + if (aConstr->shape()->isSame(theSubShape)) { + anEdgeIndex = aSub; + break; + } + } + } else if (isVertex && aConstr->shape() && aConstr->shape()->isVertex()) { + if (aConstr->shape()->isSame(theSubShape)) { + aVertIndex = aSub; + aVertShape = 0; + } + } + } + } + if (anEdgeIndex >= 0) { + TDataStd_Integer::Set(aSelLab, kEXT_SKETCH_EDGE, anEdgeIndex); // store index of edge + return; + } else if (aVertIndex >= 0) { + aVertIndex += aVertShape * 1000000; // to store both integers: index and shape + TDataStd_Integer::Set(aSelLab, kEXT_SKETCH_VERT, aVertIndex); // store index of edge + return; + } } - } - if (aFaceIndex >= 0) { - TDataStd_Integer::Set(aSelLab, kEXT_SKETCH_FACE, aFaceIndex); // store index of the face - return; } } bool aSelectorOk = true; @@ -734,8 +780,6 @@ void Model_AttributeSelection::selectBody( } catch(...) { aSelectorOk = false; } - // check that selection is correct, otherwise use weak naming solution - aSelLab.ForgetAttribute(kWEAK_NAMING); Handle(TNaming_NamedShape) aSelectorShape; if (aSelectorOk && aSelLab.FindAttribute(TNaming_NamedShape::GetID(), aSelectorShape)) { @@ -743,18 +787,8 @@ void Model_AttributeSelection::selectBody( if (aShape.IsNull() || aShape.ShapeType() != aNewSub.ShapeType()) aSelectorOk = false; } - if (!aSelectorOk) { // weak naming identifier instead - GeomShapePtr aContextShape(new GeomAPI_Shape); - aContextShape->setImpl(new TopoDS_Shape(aContext)); - GeomShapePtr aValueShape(new GeomAPI_Shape); - aValueShape->setImpl(new TopoDS_Shape(aNewSub)); - - GeomAlgoAPI_NExplode aNExplode(aContextShape, aValueShape->shapeType()); - int anId = aNExplode.index(aValueShape); - if (anId) { - TDataStd_Integer::Set(aSelLab, kWEAK_NAMING, anId); - TDataStd_Integer::Set(aSelLab, kWEAK_NAMING_SHAPETYPE, int(aValueShape->shapeType())); - } + if (!aSelectorOk) { + setInvalidIfFalse(aSelLab, false); } } } @@ -842,13 +876,6 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa return contextName(aCont); } - Handle(TDataStd_Integer) aWeakId; - if (aSelLab.FindAttribute(kWEAK_NAMING, aWeakId)) { // a weak naming is used - std::ostringstream aNameStream; - aNameStream<Get(); - return aNameStream.str(); - } - // whole infinitive construction if (aCont->groupName() == ModelAPI_ResultConstruction::group()) { ResultConstructionPtr aConstr = std::dynamic_pointer_cast(aCont); @@ -856,8 +883,10 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa return contextName(aCont); } else { // external sketch face - Handle(TDataStd_Integer) aFaceIndex; - if (aSelLab.FindAttribute(kEXT_SKETCH_FACE, aFaceIndex)) { + Handle(TDataStd_Integer) anIndex; + if (aSelLab.FindAttribute(kEXT_SKETCH_FACE, anIndex) || + aSelLab.FindAttribute(kEXT_SKETCH_EDGE, anIndex) || + aSelLab.FindAttribute(kEXT_SKETCH_VERT, anIndex)) { std::shared_ptr anExtDoc = std::dynamic_pointer_cast(aCont->document()); Selector_Selector aSelector(anExtDoc->extConstructionsLabel()); @@ -1523,11 +1552,6 @@ void Model_AttributeSelection::setParent(Model_AttributeSelectionList* theParent myParent = theParent; } -bool Model_AttributeSelection::isWeakNaming() -{ - return selectionLabel().IsAttribute(kWEAK_NAMING); -} - std::string Model_AttributeSelection::contextName(const TDF_Label theSelectionLab) { std::shared_ptr aDoc = myRestoreDocument.get() ? myRestoreDocument : @@ -1601,13 +1625,24 @@ bool Model_AttributeSelection::restoreContext(std::string theName, std::dynamic_pointer_cast(aDoc->feature(aCont)); if (aComposite.get() && aComposite->numberOfSubs()) { const int aSubNum = aComposite->numberOfSubs(); - for (int a = 0; a < aSubNum; a++) { + for (int a = 0; a < aSubNum && theValue.IsNull(); a++) { FeaturePtr aSub = aComposite->subFeature(a); const std::list >& aResults = aSub->results(); std::list >::const_iterator aRes = aResults.cbegin(); - for (; aRes != aResults.cend(); aRes++) { + for (; aRes != aResults.cend() && theValue.IsNull(); aRes++) { if ((*aRes)->data()->name() == aCompName) { theValue = std::dynamic_pointer_cast((*aRes)->data())->shapeLab(); + break; + } else if (aCompName.find((*aRes)->data()->name()) != std::string::npos) {// sub-vertex + TDF_Label aLab = std::dynamic_pointer_cast((*aRes)->data())->shapeLab(); + TDF_ChildIDIterator aSubNames(aLab, TDataStd_Name::GetID()); + for(; aSubNames.More(); aSubNames.Next()) { + if (Handle(TDataStd_Name)::DownCast(aSubNames.Value())->Get(). + IsEqual(aCompName.c_str())) { + theValue = aSubNames.Value()->Label(); + break; + } + } } } } diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index ed233f85f..4c8f09f2a 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -128,9 +128,6 @@ public: /// or reorder of features upper in the history line (issue #1757) MODEL_EXPORT virtual void updateInHistory(); - /// Returns true if the name was stored using weak naming principle - MODEL_EXPORT virtual bool isWeakNaming(); - // Implementation of the name generator method from the Selector package // This method returns the context name by the label of the sub-selected shape MODEL_EXPORT virtual std::string contextName(const TDF_Label theSelectionLab) override; diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index eb1899184..9676918db 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -229,10 +229,10 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap TopExp_Explorer anExp(aShape, TopAbs_VERTEX); for(int anIndex = 1; anExp.More(); anExp.Next(), anIndex++) { - TDF_Label aSubLab = aShapeLab.FindChild(anIndex);; + TDF_Label aSubLab = aShapeLab.FindChild(anIndex); TNaming_Builder aBuilder(aSubLab); aBuilder.Generated(anExp.Current()); - std::string aVertexName = anIndex == 1 ? "StartVertex" : "EndVertex"; + std::string aVertexName = aMyName + "_" + (anIndex == 1 ? "StartVertex" : "EndVertex"); TDataStd_Name::Set(aSubLab, aVertexName.c_str()); aMyDoc->addNamingName(aSubLab, aVertexName); } diff --git a/src/ModelAPI/ModelAPI_AttributeSelection.h b/src/ModelAPI/ModelAPI_AttributeSelection.h index 212e83be9..65fd3a6c7 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelection.h +++ b/src/ModelAPI/ModelAPI_AttributeSelection.h @@ -115,9 +115,6 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute /// Returns true if recompute of selection become impossible virtual bool isInvalid() = 0; - /// Returns true if the name was stored using weak naming principle - MODELAPI_EXPORT virtual bool isWeakNaming() = 0; - /// To virtually destroy the fields of successors MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelection(); diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 07260dcf2..3f39cecb2 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -1096,9 +1096,8 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( << aMiddlePoint->y() << ", " << aMiddlePoint->z() << ")"; aStandardDump = false; - } else if (theAttrSelect->isWeakNaming() || - (myWeakNamingSelection && aShape.get() && theAttrSelect->context().get() && - aShape != theAttrSelect->context()->shape())) { // weak naming for local selection only + } else if (myWeakNamingSelection && aShape.get() && theAttrSelect->context().get() && + aShape != theAttrSelect->context()->shape()) { // weak naming for local selection only GeomAlgoAPI_NExplode aNExplode(theAttrSelect->context()->shape(), aShape->shapeType()); int anIndex = aNExplode.index(aShape); if (anIndex != 0) { // found a week-naming index, so, export it diff --git a/src/Selector/Selector_Selector.cpp b/src/Selector/Selector_Selector.cpp index 4627c6b69..f59226cc9 100644 --- a/src/Selector/Selector_Selector.cpp +++ b/src/Selector/Selector_Selector.cpp @@ -388,7 +388,28 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape 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; @@ -574,6 +595,12 @@ void Selector_Selector::store() 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 @@ -664,7 +691,11 @@ bool Selector_Selector::restore() 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 } @@ -820,8 +851,19 @@ bool Selector_Selector::solve(const TopoDS_Shape& theContext) 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 } @@ -844,6 +886,7 @@ TopoDS_Shape Selector_Selector::value() } 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) { @@ -906,10 +949,12 @@ std::string Selector_Selector::name(Selector_NameGenerator* theNameGenerator) { return aResult; } case SELTYPE_WEAK_NAMING: { - // weak_naming_1 + // _weak_naming_1_Context std::ostringstream aWeakStr; - aWeakStr<contextName(myFinal); return aResult; } default: { // unknown case @@ -1004,6 +1049,18 @@ TDF_Label Selector_Selector::restoreByName( 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; @@ -1011,12 +1068,6 @@ TDF_Label Selector_Selector::restoreByName( 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;