mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-13 02:00:35 +05:00
[bos #38044][EDF] (2023-T3) Support for automatic reparation. Added selection of sub-shapes.
This commit is contained in:
parent
76f0b01625
commit
7b15be21d5
@ -26,9 +26,11 @@ from qtsalome import QGridLayout, QFrame, QApplication, \
|
|||||||
|
|
||||||
from salome.geom.geomrepairadv.basedlg import BaseDlg
|
from salome.geom.geomrepairadv.basedlg import BaseDlg
|
||||||
from salome.geom import geomBuilder
|
from salome.geom import geomBuilder
|
||||||
|
from libGEOM_Swig import GEOM_Swig
|
||||||
|
|
||||||
from .geomrepairadv_common import DlgRef_1Spin_QTD
|
from .geomrepairadv_common import DlgRef_1Spin_QTD
|
||||||
from .geomrepairadv_execute import execute
|
from .geomrepairadv_execute import execute
|
||||||
|
from .geomrepairadv_logger import logger
|
||||||
import GEOM
|
import GEOM
|
||||||
|
|
||||||
class LocateSubShapesDlg(BaseDlg):
|
class LocateSubShapesDlg(BaseDlg):
|
||||||
@ -96,6 +98,8 @@ class LocateSubShapesDlg(BaseDlg):
|
|||||||
selection_level
|
selection_level
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._sel_subshape_widget.hide()
|
||||||
|
|
||||||
|
|
||||||
def get_limits(self):
|
def get_limits(self):
|
||||||
"""
|
"""
|
||||||
@ -195,9 +199,9 @@ class LocateSubShapesDlg(BaseDlg):
|
|||||||
|
|
||||||
# Update counters
|
# Update counters
|
||||||
geompy = geomBuilder.New()
|
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()
|
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
|
# Update label
|
||||||
self.update_subshapes_label()
|
self.update_subshapes_label()
|
||||||
@ -246,21 +250,30 @@ class LocateSubShapesDlg(BaseDlg):
|
|||||||
param_ids = { GEOM.EDGE : 0, GEOM.FACE : 1, GEOM.SOLID : 2 }
|
param_ids = { GEOM.EDGE : 0, GEOM.FACE : 1, GEOM.SOLID : 2 }
|
||||||
param_index = param_ids[selection_level]
|
param_index = param_ids[selection_level]
|
||||||
|
|
||||||
|
ids_to_select = []
|
||||||
|
|
||||||
limits = self.get_limits()
|
limits = self.get_limits()
|
||||||
for shape in subshapes:
|
for shape in subshapes:
|
||||||
# Get properties as a list [theLength, theSurfArea, theVolume]
|
# Get properties as a list [theLength, theSurfArea, theVolume]
|
||||||
properties = geompy.BasicProperties(shape)
|
properties = geompy.BasicProperties(shape)
|
||||||
param = properties[param_index]
|
param = properties[param_index]
|
||||||
|
logger.debug('param: {}'.format(param))
|
||||||
|
|
||||||
# Check if it fits to the limits
|
# Check if it fits to the limits
|
||||||
if param >= limits[0] and param <= limits[1]:
|
if param >= limits[0] and param <= limits[1]:
|
||||||
# TODO: implement selections with GEOM_Swig_LocalSelector or something...
|
# TODO: implement selections with GEOM_Swig_LocalSelector or something...
|
||||||
# Select sub-shape
|
# Select sub-shape
|
||||||
pass
|
sub_shape_id = geompy.GetSubShapeID(self._selected_object, shape)
|
||||||
|
ids_to_select.append(sub_shape_id)
|
||||||
else:
|
else:
|
||||||
# Deselect sub-shape
|
# Deselect sub-shape
|
||||||
pass
|
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
|
# Update displayed info
|
||||||
self.update_subshapes_info()
|
self.update_subshapes_info()
|
||||||
|
|
||||||
|
@ -77,7 +77,11 @@ def run(args_dict, progress_emitter):
|
|||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
|
|
||||||
# Make a group
|
# 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
|
# Iterate all over the group's ids and remove unselected
|
||||||
group_ids = geompy.GetObjectIDs(group)
|
group_ids = geompy.GetObjectIDs(group)
|
||||||
@ -90,6 +94,8 @@ def run(args_dict, progress_emitter):
|
|||||||
|
|
||||||
progress_emitter.emit()
|
progress_emitter.emit()
|
||||||
|
|
||||||
|
geompy.addToStudy(group, result_name)
|
||||||
|
|
||||||
logging.info('Group of selected sub-shapes was created.')
|
logging.info('Group of selected sub-shapes was created.')
|
||||||
progress_emitter.emit()
|
progress_emitter.emit()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user