]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' into occ/modificationByFeatures
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 10 Apr 2020 14:26:31 +0000 (17:26 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 10 Apr 2020 14:26:31 +0000 (17:26 +0300)
# Conflicts:
# src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py

1  2 
src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py

index a70cfafed8369a8cfffe93fd645c2206876c93b0,15efb9750ecc4a3b206c338a1bae40f104588ba4..ee81e3e88d3fe5d71472f3149383641c0185697b
@@@ -125,57 -129,32 +125,76 @@@ class PublishToStudyFeature(ModelAPI.Mo
                if len(anEntry) == 0:
                  continue;
                elif anEntry not in allProcessed: # found a removed shape: make it dead for the moment
 -                # remove the reference - red node
 -                aRes, aSO2 = aSO.FindSubObject(1)
 -                if aRes:
 -                  aRes, aRef = aSO2.ReferencedObject()
 +                # but before check this result was updated to the new result
 +                anEvolutionRes = ModelAPI.singleEvolution(anEntry)
 +                if anEvolutionRes:
 +                  # try to find the last evolution
 +                  aNewEntry = self.computeEntry(anEvolutionRes)
 +                  aNewRes = ModelAPI.singleEvolution(aNewEntry)
 +                  while aNewRes:
 +                    aNewEntry = self.computeEntry(aNewRes)
 +                    aNewRes = ModelAPI.singleEvolution(aNewEntry)
 +                  allNewReferences.append(aNewEntry)
 +                  anObj.SetEntry(aNewEntry) # set a new entry and a shape
 +                  anObj.SetShapeByStream(anEvolutionRes.shape().getShapeStream(False))
 +                  aSO.SetAttrString("AttributeName", anEvolutionRes.data().name()) # also rename
 +                else: # remove the reference - red node
 +                  aRes, aSO2 = aSO.FindSubObject(1)
                    if aRes:
 +                    aRes, aRef = aSO2.ReferencedObject()
 +                    if aRes:
 +                      aBuilder = SHAPERSTUDY_utils.getStudy().NewBuilder()
 +                      aBuilder.RemoveReference(aSO2)
++                  # if the object is not marked as dead, mark it (#3201) to make all entries unique
++                  aDeadEntry = anObj.GetEntry()
++                  if not aDeadEntry.startswith("dead"):
++                    anIndex = aSO.Tag()
++                    anObj.SetEntry("dead0" + str(anIndex) + "_" + aDeadEntry)
++
++                    # also for groups
++                    aGrSOIter = SHAPERSTUDY_utils.getStudy().NewChildIterator(aSO)
++                    while aGrSOIter.More():
++                      aGroupSO = aGrSOIter.Value()
++                      aGrSOIter.Next()
++                      anIOR = aGroupSO.GetIOR()
++                      if len(anIOR):
++                        aGroup = salome.orb.string_to_object(anIOR)
++                        if isinstance(aGroup, SHAPERSTUDY_ORB._objref_SHAPER_Group) or \
++                           isinstance(aGroup, SHAPERSTUDY_ORB._objref_SHAPER_Field):
++                          if not aGroup.GetEntry().startswith("dead"):
++                            aDeadGroupEntry = "dead0" + str(anIndex) + "_" + aGroup.GetEntry()
++                            aGroup.SetEntry(aDeadGroupEntry)
 +
 +         # iterate all parts and all results to publish them in SHAPER_STUDY
 +        for aPartId in range(aPartSet.size(model.ModelAPI_ResultPart_group())):
 +          aPartObject = aPartSet.object(model.ModelAPI_ResultPart_group(), aPartId)
 +          aPartRes = ModelAPI.modelAPI_ResultPart(ModelAPI.modelAPI_Result(aPartObject))
 +          aPartDoc = aPartRes.partDoc()
 +          if aPartDoc is None and aPartObject is not None:
 +            break
 +          aPartFeatureId = aPartSet.feature(aPartRes).data().featureId()
 +          # Collects all features of exported results to find results of the same features and extend id.
 +          for aResId in range(aPartDoc.size(model.ModelAPI_ResultBody_group())):
 +            aResObject = aPartDoc.object(model.ModelAPI_ResultBody_group(), aResId)
 +            aRes = model.objectToResult(aResObject)
 +            aSSEntry = self.computeEntry(aRes)
 +            aSShape = anEngine.FindOrCreateShape(aSSEntry)
 +            if not aSSEntry in allNewReferences:
 +              aSShape.SetShapeByStream(aRes.shape().getShapeStream(False))
 +              if not aSShape.GetSO(): # publish in case it is a new shape
 +                anEngine.AddInStudy(aSShape, aRes.data().name(), None)
 +              else: # restore a red reference if it was deleted
 +                aDone, aSO2 = aSShape.GetSO().FindSubObject(1)
 +                if aDone:
 +                  aDone, aRef = aSO2.ReferencedObject()
 +                  if not aDone:
                      aBuilder = SHAPERSTUDY_utils.getStudy().NewBuilder()
 -                    aBuilder.RemoveReference(aSO2)
 -                # if the object is not marked as dead, mark it (#3201) to make all entries unique
 -                aDeadEntry = anObj.GetEntry()
 -                if not aDeadEntry.startswith("dead"):
 -                  anIndex = aSO.Tag()
 -                  anObj.SetEntry("dead0" + str(anIndex) + "_" + aDeadEntry)
 -
 -                  # also for groups
 -                  aGrSOIter = SHAPERSTUDY_utils.getStudy().NewChildIterator(aSO)
 -                  while aGrSOIter.More():
 -                    aGroupSO = aGrSOIter.Value()
 -                    aGrSOIter.Next()
 -                    anIOR = aGroupSO.GetIOR()
 -                    if len(anIOR):
 -                      aGroup = salome.orb.string_to_object(anIOR)
 -                      if isinstance(aGroup, SHAPERSTUDY_ORB._objref_SHAPER_Group) or \
 -                         isinstance(aGroup, SHAPERSTUDY_ORB._objref_SHAPER_Field):
 -                        if not aGroup.GetEntry().startswith("dead"):
 -                          aDeadGroupEntry = "dead0" + str(anIndex) + "_" + aGroup.GetEntry()
 -                          aGroup.SetEntry(aDeadGroupEntry)
 +                    aBuilder.Addreference(aSO2, aSShape.GetSO())
 +            allProcessed.append(aSSEntry)
 +            # Groups
 +            self.processGroups(aRes, anEngine, aPartFeatureId, aSShape, False)
 +            # Fields
 +            self.processGroups(aRes, anEngine, aPartFeatureId, aSShape, True)
  
      # Part of the "execute" method: processes the Groups of theRes result publication.
      # If theFields is true, the same is performed for Fields.