]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/Model/Model_SelectionNaming.cpp
Salome HOME
Support of all types of selection in python names import
[modules/shaper.git] / src / Model / Model_SelectionNaming.cpp
index 802b13cfc8d2c07dbf50d81976ca5929808927eb..78c167e9f4628d7147a77ef3a4a16119f14a3d92 100644 (file)
@@ -258,46 +258,6 @@ const TopoDS_Shape findCommonShape(
   return aSharedShape;
 }
 
-// searches theType shape that contains theConnectionType sub-shapes in each shape from the List,
-// so, implements the neighbours searching
-/*
-const TopoDS_Shape findCommonShapeByNB(const TopAbs_ShapeEnum theType,
-  const TopAbs_ShapeEnum theConnectionType, const TopTools_ListOfShape& theList)
-{
-TopTools_MapOfShape aCheckedShapes; // already checked shapes of type theType
-  TopoDS_Shape aResult; // theType result shape
-  for(TopTools_ListIteratorOfListOfShape anIt(theList); anIt.More(); anIt.Next()) { // iterate all
-    for(TopExp_Explorer anExp(anIt.ChangeValue(), theType); anExp.More(); anExp.Next()) {
-      if (aCheckedShapes.Contains(anExp.Current()))
-        continue; // already checked
-      aCheckedShapes.Add(anExp.Current());
-      TopTools_MapOfShape aConnectors; // all connectors of the checked theType shape
-      for(TopExp_Explorer aCExp(anExp.Current(), theConnectionType); aCExp.More(); aCExp.Next()) {
-        aConnectors.Add(aCExp.Current());
-      }
-      // check that all shapes from the List contain the connector sub-shapes
-      bool aFound = true;
-      for(TopTools_ListIteratorOfListOfShape anIt2(theList); anIt2.More() && aFound; anIt2.Next()) {
-        if (anIt2.Value().IsSame(anIt.Value()))
-          continue;
-        aFound = false;
-        for(TopExp_Explorer anE(anIt2.ChangeValue(), theConnectionType); anE.More(); anE.Next()) {
-          if (aConnectors.Contains(anE.Current())) {
-            aFound = true;
-            break;
-          }
-        }
-      }
-      if (aFound) {
-        if (!aResult.IsNull()) // more than one result
-          return TopoDS_Shape();
-        aResult = anExp.Current();
-      }
-    }
-  }
-  return aResult;
-}*/
-
 std::string Model_SelectionNaming::vertexNameByEdges(TopoDS_Shape theContext, TopoDS_Shape theSub,
   std::shared_ptr<Model_Document> theDoc, ResultPtr& theContextRes, const bool theAnotherDoc)
 {
@@ -624,11 +584,11 @@ size_t ParseName(const std::string& theSubShapeName,   std::list<std::string>& t
 
 std::string getContextName(const std::string& theSubShapeName)
 {
-  std::string aName;
-  std::string::size_type n = theSubShapeName.find('/');
-  if (n == std::string::npos) return theSubShapeName;
-  aName = theSubShapeName.substr(0, n);
-  return aName;
+    std::string aName;
+    std::string::size_type n = theSubShapeName.find('/');
+    if (n == std::string::npos) return theSubShapeName;
+    aName = theSubShapeName.substr(0, n);
+    return aName;
 }
 
 /// Parses naming name of sketch sub-elements: takes indices and orientation
@@ -846,6 +806,8 @@ std::string Model_SelectionNaming::shortName(
   aName.erase(std::remove(aName.begin(), aName.end(), '-'), aName.end());
   aName.erase(std::remove(aName.begin(), aName.end(), '/'), aName.end());
   aName.erase(std::remove(aName.begin(), aName.end(), '&'), aName.end());
+  if (aName.empty())
+    return "";
   // remove the last 's', 'e', 'f' and 'r' symbols:
   // they are used as markers of start/end/forward/rewersed indicators
   static const std::string aSyms("sefr");