From: mpv Date: Thu, 19 Mar 2020 14:21:45 +0000 (+0300) Subject: Fix for the issue #3167: Shaper study contains only result for feature having several... X-Git-Tag: V9_5_0a2~31 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=222300643a341d945f0c5e834b0ff96f924ac2d3;p=modules%2Fshaper.git Fix for the issue #3167: Shaper study contains only result for feature having several results --- diff --git a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py index 509b9a31b..a6a6d2d66 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py +++ b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py @@ -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 diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 7956062dd..10d5385ea 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -1606,6 +1606,15 @@ void ModelHighAPI_Dumper::exportVariables() const anEntryStr<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<second.myCurrentName); + } + } } } } diff --git a/src/PythonAPI/model/services/__init__.py b/src/PythonAPI/model/services/__init__.py index ce63d93a2..1548f4393 100644 --- a/src/PythonAPI/model/services/__init__.py +++ b/src/PythonAPI/model/services/__init__.py @@ -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 ""