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):
selection_level
)
+ self._sel_subshape_widget.hide()
+
def get_limits(self):
"""
# 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()
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()
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)
progress_emitter.emit()
+ geompy.addToStudy(group, result_name)
+
logging.info('Group of selected sub-shapes was created.')
progress_emitter.emit()