diff --git a/register_selection_tools.cpp b/register_selection_tools.cpp index ff0b2f6..a998f28 100644 --- a/register_selection_tools.cpp +++ b/register_selection_tools.cpp @@ -327,7 +327,10 @@ void RegisterSelectionTools(ProMeshRegistry& reg, string baseGrp) "vertices || value=true #" "edges || value=true #" "faces || value=true #" - "volumes || value=true", TOOLTIP_SELECT_UNASSIGNED_ELEMENTS); + "volumes || value=true", TOOLTIP_SELECT_UNASSIGNED_ELEMENTS) + .add_function("RestrictSelectionToSubset", &RestrictSelectionToSubset, grp, "", + "mesh #" + "subset index", TOOLTIP_RESTRICT_SELECTION_TO_SUBSET); grp = baseGrp + "/Coordinate Range"; diff --git a/tools/selection_tools.cpp b/tools/selection_tools.cpp index 2f00635..09b11dd 100644 --- a/tools/selection_tools.cpp +++ b/tools/selection_tools.cpp @@ -192,6 +192,21 @@ static void SelectUnassignedElementsHelper( } } +template +static void DeselectUnassignedElementsHelper( + Grid& grid, + SubsetHandler& sh, + Selector& sel) +{ + typedef typename geometry_traits::iterator iterator; + for(iterator iter = grid.begin(); iter != grid.end(); ++iter) + { + if(sh.get_subset_index(*iter) == -1){ + sel.deselect(*iter); + } + } +} + void SelectUnassignedElements( Mesh* obj, bool selVrts, @@ -255,6 +270,30 @@ void CloseSelection(Mesh* obj) CloseSelection (obj->selector()); } +template +void RestrictSelectionToSubset (Selector& sel, const SubsetHandler& sh, int si) +{ + typedef typename geometry_traits::iterator iterator; + + for (iterator iter = sel.begin(); iter != sel.end();){ + TElem* elem = *iter; + ++iter; + if (sh.get_subset_index(elem) != si) + sel.deselect(elem); + } +} + +void RestrictSelectionToSubset(Mesh* obj, int si) +{ + SubsetHandler& sh = obj->subset_handler(); + Selector& sel = obj->selector(); + + RestrictSelectionToSubset(sel, sh, si); + RestrictSelectionToSubset(sel, sh, si); + RestrictSelectionToSubset(sel, sh, si); + RestrictSelectionToSubset(sel, sh, si); +} + //////////////////////////////////////////////////////////////////////////////// // VERTICES void SelectBoundaryVertices(Mesh* obj) diff --git a/tools/selection_tools.h b/tools/selection_tools.h index 4dd102b..b9f2230 100644 --- a/tools/selection_tools.h +++ b/tools/selection_tools.h @@ -109,6 +109,7 @@ #define TOOLTIP_SELECT_SELECTION_BOUNDARY "Selects the boundary of the current selection." #define TOOLTIP_SELECT_BENT_QUADRILATERALS "Selects quadrilaterals which do not lie in a plane." #define TOOLTIP_CLOSE_SELECTION "Selects all associated elements of lower dimensions." +#define TOOLTIP_RESTRICT_SELECTION_TO_SUBSET "Deselects all elements from the selection that are not in the specified subset." #define TOOLTIP_SELECT_SLIVERS "Selects flat tetrahedrons. Threshold-ratio specifies the minimal ratio between the distance of two opposing edges to the length of the longest edge." #define TOOLTIP_SELECT_SELECTION_KINK_VERTICES "Selects kink vertices in selected paths" #define TOOLTIP_SELECT_SUBSET_KINK_VERTICES "Selects kink vertices in subset-paths" @@ -225,6 +226,7 @@ void SelectSelectionBoundary(Mesh* obj); void CloseSelection(Mesh* obj); +void RestrictSelectionToSubset(Mesh* obj, int si); template void SelectInterfaceElements(Mesh* obj, bool regardSelectedNbrsOnly)