]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #3167: Shaper study contains only result for feature having several...
authormpv <mikhail.ponikarov@opencascade.com>
Thu, 19 Mar 2020 14:21:45 +0000 (17:21 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Thu, 19 Mar 2020 14:21:45 +0000 (17:21 +0300)
src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py
src/ModelHighAPI/ModelHighAPI_Dumper.cpp
src/PythonAPI/model/services/__init__.py

index 509b9a31b2569aacbafaf8bc1dcf2d94f28dcaef..a6a6d2d6619152e66c4a7d9f5da0639f2be6951a 100644 (file)
@@ -86,11 +86,19 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature):
             EventsAPI.Events_InfoMessage("PublishToStudy", "For publish to SHAPER-STUDY some Part is not activated", self).send()
             break
           aPartFeatureId = aPartSet.feature(aPartRes).data().featureId()
+          # Collects all features of exported results to find results of the same features and extend id.
+          # Map from feature index to index of result. If index is zero (initial), no surrfix to entry is added.
+          aFeaturesIndices = {}
           for aResId in range(aPartDoc.size(model.ModelAPI_ResultBody_group())):
             aResObject = aPartDoc.object(model.ModelAPI_ResultBody_group(), aResId)
             aRes = model.objectToResult(aResObject)
-            aResFeatureId = aPartDoc.feature(aRes).data().featureId()
-            aSSEntry = str(aPartFeatureId) + ":" + str(aResFeatureId)
+            aResFeatureId = str(aPartDoc.feature(aRes).data().featureId())
+            if aResFeatureId in aFeaturesIndices:
+              aFeaturesIndices[aResFeatureId] += 1
+              aResFeatureId += ":" + str(aFeaturesIndices[aResFeatureId])
+            else:
+              aFeaturesIndices[aResFeatureId] = 0
+            aSSEntry = str(aPartFeatureId) + ":" + aResFeatureId
             aSShape = anEngine.FindOrCreateShape(aSSEntry)
             aSShape.SetShapeByStream(aRes.shape().getShapeStream(False))
             if not aSShape.GetSO(): # publish in case it is a new shape
index 7956062dde22d6a48501f3f005e8fc43cb29412e..10d5385ea8f921380e431038e575ab995c8dc55d 100644 (file)
@@ -1606,6 +1606,15 @@ void ModelHighAPI_Dumper::exportVariables() const
         anEntryStr<<aPartId<<":"<<aFeatureId;
         std::string anEntry = anEntryStr.str();
         exportVariable(anEntry, aNameIter->second.myCurrentName);
+        size_t aSize = aFeature->results().size();
+        if (aSize > 1) { // additional entries for features with more than one result
+          for(int a = 1; a < aSize; a++) {
+            std::ostringstream aResEntryStr;
+            aResEntryStr<<anEntry<<":"<<a;
+            std::string aResEntry = aResEntryStr.str();
+            exportVariable(aResEntry, aNameIter->second.myCurrentName);
+          }
+        }
       }
     }
   }
index ce63d93a2c13510c743094ea9088f588d91026e8..1548f43930a4b899964c4aee69d2cb3ed3a9ddc5 100644 (file)
@@ -37,11 +37,15 @@ def publishToShaperStudy():
   end()
 
 # returns unique identifier of the feature : id of part it belongs to + ":" + id of feature
-def featureStringId(theFeature):
+# the second argument may be the number of result if feature has more than one result (1 corresponds to the second result, etc)
+def featureStringId(theFeature, *theArgs):
   aRoot = moduleDocument()
   aCurrent = theFeature.feature().document()
   if aRoot and aCurrent:
-    return str(findPartFeature(aRoot, aCurrent).data().featureId()) + ":" + str(theFeature.feature().data().featureId())
+    aRes = str(findPartFeature(aRoot, aCurrent).data().featureId()) + ":" + str(theFeature.feature().data().featureId())
+    if len(theArgs) == 1:
+      aRes += ":" + str(theArgs[0])
+    return aRes
   return ""