From: mpv Date: Tue, 26 Sep 2017 12:55:24 +0000 (+0300) Subject: Fix for the issue #2253 . Problems with load/save python script. Here seam vertex... X-Git-Tag: V_2.8.0~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d4255d2c6e7da9d372f60ebe625a0d5ad14552a;p=modules%2Fshaper.git Fix for the issue #2253 . Problems with load/save python script. Here seam vertex of sketch circle selection worked wrong. --- diff --git a/src/Model/Model_SelectionNaming.cpp b/src/Model/Model_SelectionNaming.cpp index 5dbe49d9e..89c044cb4 100644 --- a/src/Model/Model_SelectionNaming.cpp +++ b/src/Model/Model_SelectionNaming.cpp @@ -845,10 +845,17 @@ bool Model_SelectionNaming::selectSubShape(const std::string& theType, if (aComposite.get()) { if (aType == TopAbs_VERTEX || aType == TopAbs_EDGE) { // collect all IDs in the name + bool isVertexByEdge = false; std::map anIDs; if (!parseSubIndices(aComposite, aSubShapeName, - aType == TopAbs_EDGE ? "Edge" : "Vertex", anIDs)) - return false; + aType == TopAbs_EDGE ? "Edge" : "Vertex", anIDs)) { + // there is a case when vertex is identified by one circle-edge (2253) + if (aType == TopAbs_VERTEX && + parseSubIndices(aComposite, aSubShapeName, "Edge", anIDs)) + isVertexByEdge = true; + else + return false; + } const int aSubNum = aComposite->numberOfSubs(); for(int a = 0; a < aSubNum; a++) { @@ -865,9 +872,22 @@ bool Model_SelectionNaming::selectSubShape(const std::string& theType, int anOrientation = abs(anIDs[aCompID]); TopoDS_Shape aShape = aRes->shape()->impl(); if (anOrientation == 1) { - if (aType == aShape.ShapeType()) { + if (!isVertexByEdge && aType == aShape.ShapeType()) { theShapeToBeSelected = aRes->shape(); return true; + } else if (isVertexByEdge && aType != aShape.ShapeType()) { + // check that there is only one vertex produces by and circular edge + TopoDS_Shape aShape = aRes->shape()->impl(); + TopExp_Explorer anExp(aShape, TopAbs_VERTEX); + if (anExp.More()) + aShape = anExp.Current(); + anExp.Next(); + if (!anExp.More() || anExp.Current().IsSame(aShape)) { + std::shared_ptr aShapeToBeSelected(new GeomAPI_Shape()); + aShapeToBeSelected->setImpl(new TopoDS_Shape(aShape)); + theShapeToBeSelected = aShapeToBeSelected; + return true; + } } } else { // take first or second vertex of the edge TopoDS_Shape aShape = aRes->shape()->impl(); diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.cpp b/src/ModelHighAPI/ModelHighAPI_Selection.cpp index 3a219f9f1..60017e8cc 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Selection.cpp @@ -133,7 +133,7 @@ void ModelHighAPI_Selection::setName(const std::string& theName) void ModelHighAPI_Selection::setColor(int theRed, int theGreen, int theBlue) { - if (myVariantType != VT_ResultSubShapePair) + if (myVariantType != VT_ResultSubShapePair || !myResultSubShapePair.first.get()) return; AttributeIntArrayPtr aColor = diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index f21337702..d03130b59 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -174,8 +174,10 @@ void fillAttribute(const std::list & theValue, const std::shared_ptr & theAttribute) { theAttribute->clear(); - for (auto it = theValue.begin(); it != theValue.end(); ++it) - theAttribute->append(it->resultSubShapePair().first); // use only context + for (auto it = theValue.begin(); it != theValue.end(); ++it) { + if (it->resultSubShapePair().first) + theAttribute->append(it->resultSubShapePair().first); // use only context + } } //--------------------------------------------------------------------------------------