]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#20442 add new group in connector plugin to plublish feature
authorJérôme <jerome.lucas@cesgenslab.fr>
Mon, 14 Dec 2020 16:11:29 +0000 (17:11 +0100)
committerJérôme <jerome.lucas@cesgenslab.fr>
Mon, 14 Dec 2020 16:11:29 +0000 (17:11 +0100)
src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py
src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.h
src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.h
src/FeaturesPlugin/Test/TestCheckDuplicatedFaces.py
src/FeaturesPlugin/duplicated_faces_macro_widget.xml
src/FeaturesPlugin/duplicated_faces_widget.xml

index a2e401aae849520225473c1b214435a0bf1cb9bf..2f36d1ed4f345e7f10522abf8abb4b00e8caddb8 100644 (file)
@@ -160,51 +160,55 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature):
     # If theFields is true, the same is performed for Fields.
     def processGroups(self, theRes, theEngine, thePartFeatureId, theStudyShape, theFields):
       allGroupsProcessed = []
+      allRefGroups = []
       if theFields:
-        aRefGroups = ModelAPI.referencedFeatures(theRes, "Field", True)
+        allRefGroups.append(ModelAPI.referencedFeatures(theRes, "Field", True))
       else:
-        aRefGroups = ModelAPI.referencedFeatures(theRes, "Group", True)
-      for aRef in aRefGroups:
-        aGroupIndices = []
-        aGroupHasIndex = {}
-        aResShape = theRes.shape()
-        if theFields:
-          aSelList = aRef.selectionList("selected")
-        else:
-          aSelList = aRef.selectionList("group_list")
-        aSelType = GeomAPI_Shape.shapeTypeByStr(aSelList.selectionType())
-        for aGroupRes in aRef.results():
-          aShape = aGroupRes.shape()
-          anExplorer = GeomAPI_ShapeExplorer(aShape, aSelType)
-          while anExplorer.more():
-            anId = GeomAlgoAPI.GeomAlgoAPI_CompoundBuilder.id(aResShape, anExplorer.current())
-            if anId > 0 and not anId in aGroupHasIndex:
-              aGroupIndices.append(anId)
-              aGroupHasIndex[anId] = 0
-            anExplorer.next()
-        if len(aGroupIndices): # create group
-          aGroupFeatureId = aRef.data().featureId()
+        allRefGroups.append(ModelAPI.referencedFeatures(theRes, "Group", True))
+        allRefGroups.append(ModelAPI.referencedFeatures(theRes, "Shared_faces", True))
+        allRefGroups.append(ModelAPI.referencedFeatures(theRes, "Duplicated_faces", True))
+      for aRefGroups in allRefGroups:
+        for aRef in aRefGroups:
+          aGroupIndices = []
+          aGroupHasIndex = {}
+          aResShape = theRes.shape()
           if theFields:
-            aFieldOp = theEngine.GetIFieldOperations()
-            aGroupEntry = "field" + str(thePartFeatureId) + ":" + str(aGroupFeatureId)
-            aGroup = aFieldOp.FindField(theStudyShape, aGroupEntry)
+            aSelList = aRef.selectionList("selected")
           else:
-            aGroupOp = theEngine.GetIGroupOperations()
-            aGroupEntry = "group" + str(thePartFeatureId) + ":" + str(aGroupFeatureId)
-            aGroup = aGroupOp.FindGroup(theStudyShape, aGroupEntry)
-          if not aGroup: # create a new
+            aSelList = aRef.selectionList("group_list")
+          aSelType = GeomAPI_Shape.shapeTypeByStr(aSelList.selectionType())
+          for aGroupRes in aRef.results():
+            aShape = aGroupRes.shape()
+            anExplorer = GeomAPI_ShapeExplorer(aShape, aSelType)
+            while anExplorer.more():
+              anId = GeomAlgoAPI.GeomAlgoAPI_CompoundBuilder.id(aResShape, anExplorer.current())
+              if anId > 0 and not anId in aGroupHasIndex:
+                aGroupIndices.append(anId)
+                aGroupHasIndex[anId] = 0
+              anExplorer.next()
+          if len(aGroupIndices): # create group
+            aGroupFeatureId = aRef.data().featureId()
             if theFields:
-              aGroup = aFieldOp.CreateFieldByType(theStudyShape, aSelType)
+              aFieldOp = theEngine.GetIFieldOperations()
+              aGroupEntry = "field" + str(thePartFeatureId) + ":" + str(aGroupFeatureId)
+              aGroup = aFieldOp.FindField(theStudyShape, aGroupEntry)
             else:
-              aGroup = aGroupOp.CreateGroup(theStudyShape, aSelType)
-            aGroup.SetEntry(aGroupEntry)
-            theEngine.AddInStudy(aGroup, aRef.firstResult().data().name(), theStudyShape)
-          aGroup.SetSelection(aGroupIndices)
-          if theFields:
-            self.fillField(aGroup, aRef, theEngine, aGroupIndices)
-          # a group takes shape from the main result
-          #aGroup.SetShapeByStream(aRef.firstResult().shape().getShapeStream(False)) # group shape
-          allGroupsProcessed.append(aGroupEntry)
+              aGroupOp = theEngine.GetIGroupOperations()
+              aGroupEntry = "group" + str(thePartFeatureId) + ":" + str(aGroupFeatureId)
+              aGroup = aGroupOp.FindGroup(theStudyShape, aGroupEntry)
+            if not aGroup: # create a new
+              if theFields:
+                aGroup = aFieldOp.CreateFieldByType(theStudyShape, aSelType)
+              else:
+                aGroup = aGroupOp.CreateGroup(theStudyShape, aSelType)
+              aGroup.SetEntry(aGroupEntry)
+              theEngine.AddInStudy(aGroup, aRef.firstResult().data().name(), theStudyShape)
+            aGroup.SetSelection(aGroupIndices)
+            if theFields:
+              self.fillField(aGroup, aRef, theEngine, aGroupIndices)
+            # a group takes shape from the main result
+            #aGroup.SetShapeByStream(aRef.firstResult().shape().getShapeStream(False)) # group shape
+            allGroupsProcessed.append(aGroupEntry)
       # check all existing groups: if some does not processed, remove it from the tree
       aSOIter = SHAPERSTUDY_utils.getStudy().NewChildIterator(theStudyShape.GetSO())
       while aSOIter.More():
index 61c7530588b81f2b7110724f9c3980a6654e80ab..b581728792e4843a8654371f29a6383cc3434df4 100644 (file)
@@ -55,10 +55,10 @@ public:
     return MY_NUMBER_FACES_ID;
   }
 
-  /// Attribute name for z coodinate.
+  /// Attribute name for list of faces.
   inline static const std::string& LIST_FACES_ID()
   {
-    static const std::string MY_LIST_FACES_ID("faces");
+    static const std::string MY_LIST_FACES_ID("group_list");
     return MY_LIST_FACES_ID;
   }
 
index 583b770ec23c22ba3b4fd1faea4bc0f73f4b942b..e8d261ceaa3baf2acb525361ba0b9125eaa7ef93 100644 (file)
@@ -55,10 +55,10 @@ public:
     return MY_NUMBER_FACES_ID;
   }
 
-  /// Attribute name for z coodinate.
+  /// Attribute name for list of faces
   inline static const std::string& LIST_FACES_ID()
   {
-    static const std::string MY_LIST_FACES_ID("faces");
+    static const std::string MY_LIST_FACES_ID("group_list");
     return MY_LIST_FACES_ID;
   }
 
index b5d18f47f4ee60dcf38b58d6811284c69403d6cc..da07e6e6489ea23cd2a0199f8f18a45c8cc6c518 100644 (file)
@@ -68,7 +68,7 @@ if __name__ == '__main__':
     assert Duplicated_faces_1_Feature.error() == ''
     assert Duplicated_faces_1_Feature.name() == "Duplicated_faces_1"
 
-    aSelectionList = Duplicated_faces_1_Feature.selectionList("faces")
+    aSelectionList = Duplicated_faces_1_Feature.selectionList("group_list")
     assert aSelectionList.size() == 2
 
     assert(Part_1_doc.size("Groups") == 1)
index df02d0131220f4fb51554a7dd0ceb23294aa0df8..1e9c245059dcb1f3f925fbc0db0cd493e7c46d67 100644 (file)
@@ -10,7 +10,7 @@
   </shape_selector>
   <groupbox title="Duplicated faces">
     <label id="number_duplicated_faces"/>
-    <multi_selector id="faces"
+    <multi_selector id="group_list"
                       label="List of faces :"
                       icon=""
                       shape_types="faces"
index ccd2c420a37ee8637ca2995aa144a2cfdf68a581..c5dcfa468845562da8ad2d7a272e9001123f94e7 100644 (file)
@@ -10,7 +10,7 @@
   </shape_selector>
   <groupbox title="Duplicated faces">
     <label id="number_duplicated_faces"/>
-    <multi_selector id="faces"
+    <multi_selector id="group_list"
                       label="List of faces :"
                       icon=""
                       shape_types="faces"