]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #2253 . Problems with load/save python script. Here seam vertex...
authormpv <mpv@opencascade.com>
Tue, 26 Sep 2017 12:55:24 +0000 (15:55 +0300)
committermpv <mpv@opencascade.com>
Tue, 26 Sep 2017 12:55:24 +0000 (15:55 +0300)
src/Model/Model_SelectionNaming.cpp
src/ModelHighAPI/ModelHighAPI_Selection.cpp
src/ModelHighAPI/ModelHighAPI_Tools.cpp

index 5dbe49d9e27abe5e05f0c00b5e61790278819c8f..89c044cb4ff24e32e9ba24f64c91cdbbabce1347 100644 (file)
@@ -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<int, int> 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<TopoDS_Shape>();
                   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<TopoDS_Shape>();
+                      TopExp_Explorer anExp(aShape, TopAbs_VERTEX);
+                      if (anExp.More())
+                        aShape = anExp.Current();
+                      anExp.Next();
+                      if (!anExp.More() || anExp.Current().IsSame(aShape)) {
+                        std::shared_ptr<GeomAPI_Shape> 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<TopoDS_Shape>();
index 3a219f9f18519e386470331687a786799f665be8..60017e8cc972e35af3e319f019f6d01744058b4b 100644 (file)
@@ -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 =
index f2133770289d05bf79c118a21113a5b3d92c6c5b..d03130b59b2f0b01c2b934f22457d97eb10ea545 100644 (file)
@@ -174,8 +174,10 @@ void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
                    const std::shared_ptr<ModelAPI_AttributeRefList> & 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
+  }
 }
 
 //--------------------------------------------------------------------------------------