From bc0ae7d9a07647f251a2d1c17ec0b5a0a78069a3 Mon Sep 17 00:00:00 2001 From: Konstantin Leontev Date: Thu, 28 Mar 2024 09:18:28 +0000 Subject: [PATCH] [bos #38044][EDF] (2023-T3) Support for automatic reparation. Added selection of sub-shapes. --- src/RepairGUIAdv/locate_subshapes.py | 19 ++++++++++++++++--- src/RepairGUIAdv/locate_subshapes_algo.py | 8 +++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/RepairGUIAdv/locate_subshapes.py b/src/RepairGUIAdv/locate_subshapes.py index 210299720..b551809e9 100644 --- a/src/RepairGUIAdv/locate_subshapes.py +++ b/src/RepairGUIAdv/locate_subshapes.py @@ -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() diff --git a/src/RepairGUIAdv/locate_subshapes_algo.py b/src/RepairGUIAdv/locate_subshapes_algo.py index bba7c30cc..e7dfc3a7b 100755 --- a/src/RepairGUIAdv/locate_subshapes_algo.py +++ b/src/RepairGUIAdv/locate_subshapes_algo.py @@ -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() -- 2.39.2