]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
[bos #38044][EDF] (2023-T3) Support for automatic reparation. Added selection of...
authorKonstantin Leontev <Konstantin.LEONTEV@opencascade.com>
Thu, 28 Mar 2024 09:18:28 +0000 (09:18 +0000)
committerDUC ANH HOANG <dh77501n@dsp1043837>
Thu, 23 May 2024 11:58:25 +0000 (13:58 +0200)
src/RepairGUIAdv/locate_subshapes.py
src/RepairGUIAdv/locate_subshapes_algo.py

index 2102997208f07e7c9f3bf0ae9f63fe486d6b20a4..b551809e9fa5e461dee6c44923971d640e06c3cd 100644 (file)
@@ -26,9 +26,11 @@ from qtsalome import QGridLayout, QFrame, QApplication, \
 
 from salome.geom.geomrepairadv.basedlg import BaseDlg
 from salome.geom import geomBuilder
+from libGEOM_Swig import GEOM_Swig
 
 from .geomrepairadv_common import DlgRef_1Spin_QTD
 from .geomrepairadv_execute import execute
+from .geomrepairadv_logger import logger
 import GEOM
 
 class LocateSubShapesDlg(BaseDlg):
@@ -96,6 +98,8 @@ class LocateSubShapesDlg(BaseDlg):
             selection_level
             )
 
+        self._sel_subshape_widget.hide()
+
 
     def get_limits(self):
         """
@@ -195,9 +199,9 @@ class LocateSubShapesDlg(BaseDlg):
 
         # Update counters
         geompy = geomBuilder.New()
-        total = geompy.NumberOfSubShapes(self._selected_object, self.get_selection_level())
+        all_ids = geompy.SubShapeAllIDs(self._selected_object, self.get_selection_level())
         selected_ids = self.get_local_selection()
-        self.set_subshapes_counters(len(selected_ids), total)
+        self.set_subshapes_counters(len(selected_ids), len(all_ids))
 
         # Update label
         self.update_subshapes_label()
@@ -246,21 +250,30 @@ class LocateSubShapesDlg(BaseDlg):
         param_ids = { GEOM.EDGE : 0, GEOM.FACE : 1, GEOM.SOLID : 2 }
         param_index = param_ids[selection_level]
 
+        ids_to_select = []
+
         limits = self.get_limits()
         for shape in subshapes:
             # Get properties as a list [theLength, theSurfArea, theVolume]
             properties = geompy.BasicProperties(shape)
             param = properties[param_index]
+            logger.debug('param: {}'.format(param))
 
             # Check if it fits to the limits
             if param >= limits[0] and param <= limits[1]:
                 # TODO: implement selections with GEOM_Swig_LocalSelector or something...
                 # Select sub-shape
-                pass
+                sub_shape_id = geompy.GetSubShapeID(self._selected_object, shape)
+                ids_to_select.append(sub_shape_id)
             else:
                 # Deselect sub-shape
                 pass
 
+        # Select sub-shapes with collected ids
+        geom_swig = GEOM_Swig()
+        geom_swig.setLocalSelection(ids_to_select)
+        logger.debug('ids_to_select: {}'.format(ids_to_select))
+
         # Update displayed info
         self.update_subshapes_info()
 
index bba7c30ccb612b16a5ba368ee18628441f74363d..e7dfc3a7b78bc7d9f5e1e5f8a2c40421e8c163af 100755 (executable)
@@ -77,7 +77,11 @@ def run(args_dict, progress_emitter):
     sleep(0.1)
 
     # Make a group
-    group = geompy.CreateGroup(source_solid, selection_level, theName = result_name)
+    # geomBuilder uses their own types - geomBuilder.ShapeType
+    geom_builder_types = { GEOM.EDGE : 'EDGE', GEOM.FACE : 'FACE', GEOM.SOLID : 'SOLID' }
+    type_str = geom_builder_types[selection_level]
+    shape_type = geompy.ShapeType[type_str]
+    group = geompy.CreateGroup(source_solid, shape_type, theName = result_name)
 
     # Iterate all over the group's ids and remove unselected
     group_ids = geompy.GetObjectIDs(group)
@@ -90,6 +94,8 @@ def run(args_dict, progress_emitter):
 
     progress_emitter.emit()
 
+    geompy.addToStudy(group, result_name)
+
     logging.info('Group of selected sub-shapes was created.')
     progress_emitter.emit()