From: mpv Date: Thu, 1 Nov 2018 11:30:21 +0000 (+0300) Subject: Fix for Test2514.py : vertices of the sketch element is renamed with rename of the... X-Git-Tag: End2018~215 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=986dc88bed752ebed1828eb3d54461480e2435f9;p=modules%2Fshaper.git Fix for Test2514.py : vertices of the sketch element is renamed with rename of the sketch element --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 1dda5514c..4c584ea77 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -1422,6 +1422,17 @@ void Model_Document::changeNamingName(const std::string theOldName, } else { // remove from the list aFind->second.erase(aLabIter); } + // check the sketch vertex name located under renamed sketch line + TDF_ChildIDIterator aChild(theLabel, TDataStd_Name::GetID()); + for(; aChild.More(); aChild.Next()) { + Handle(TDataStd_Name) aSubName = Handle(TDataStd_Name)::DownCast(aChild.Value()); + std::string aName = TCollection_AsciiString(aSubName->Get()).ToCString(); + if (aName.find(theOldName) == 0) { // started from parent name + std::string aNewSubName = theNewName + aName.substr(theNewName.size()); + changeNamingName(aName, aNewSubName, aSubName->Label()); + aSubName->Set(aNewSubName.c_str()); + } + } return; } } diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index 6dc346aa0..76706aa41 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -255,15 +255,6 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap TNaming_Builder aBuilder(aSubLab); aBuilder.Generated(anExp.Current()); std::string aVertexName = aMyName + "_" + (anIndex == 1 ? "StartVertex" : "EndVertex"); - // check this name is already used - ResultPtr aThisRes; - do { - static std::string anEmpty; - static bool aUnique; - aThisRes = aMyDoc->findByName(aVertexName, anEmpty, aUnique); - if (aThisRes.get() && aThisRes.get() != this) - aVertexName += "x"; - } while(aThisRes.get() && aThisRes.get() != this); TDataStd_Name::Set(aSubLab, aVertexName.c_str()); aMyDoc->addNamingName(aSubLab, aVertexName); } @@ -406,7 +397,7 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap std::stringstream aName; aName<<"Face"; TopExp_Explorer aPutEdges(aFaceToPut, TopAbs_EDGE); - TNaming_Builder* anEdgesBuilder = 0; + TNaming_Builder *anEdgesBuilder = 0, *aVerticesBuilder = 0; for(TColStd_ListOfInteger::Iterator anIter(aNewInd); anIter.More(); anIter.Next()) { int anIndex = anIter.Value(); int aModIndex = anIndex > 0 ? anIndex : -anIndex; @@ -429,20 +420,43 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap } anEdgesBuilder->Modify(anEdgeIndices.Find(aModIndex), aPutEdges.Current()); } + // put also modified vertices, otherwise vertex of original edge has no history + if (anEdgeIndices.IsBound(aModIndex)) { + TopExp_Explorer aVExpOld(anEdgeIndices.Find(aModIndex), TopAbs_VERTEX); + TopExp_Explorer aVExpNew(aPutEdges.Current(), TopAbs_VERTEX); + for(; aVExpNew.More() && aVExpOld.More(); aVExpNew.Next(), aVExpOld.Next()) { + if (!aVExpOld.Current().IsSame(aVExpNew.Current())) { + if (!aVerticesBuilder) { + TDF_Label aVertLabel = aLab.FindChild(2); + aVerticesBuilder = new TNaming_Builder(aVertLabel); + std::ostringstream aSubName; + // tag is needed for Test1922 to distinguish sub-edges of different faces + aSubName<<"SubVertex_"<Modify(aVExpOld.Current(), aVExpNew.Current()); + + } + } + } aPutEdges.Next(); } + if (anEdgesBuilder) + delete anEdgesBuilder; + if (aVerticesBuilder) + delete aVerticesBuilder; TDataStd_Name::Set(aLab, TCollection_ExtendedString(aName.str().c_str())); aMyDoc->addNamingName(aLab, aName.str()); // put also wires to sub-labels to correctly select them instead of collection by edges - int aWireTag = 2; // first tag is for SubEdge-s + int aWireTag = 3; // first tag is for SubEdge-s, second - for vertices for(TopExp_Explorer aWires(aFaceToPut, TopAbs_WIRE); aWires.More(); aWires.Next()) { TDF_Label aWireLab = aLab.FindChild(aWireTag); TNaming_Builder aWireBuilder(aWireLab); aWireBuilder.Generated(aWires.Current()); std::ostringstream aWireName; aWireName< 2) - aWireName<<"_"< 3) + aWireName<<"_"<addNamingName(aWireLab, aWireName.str()); aWireTag++;