From 4846268f9e39e013f5c7223acedae71b3f5cfc6f Mon Sep 17 00:00:00 2001 From: Martin Stepniewski Date: Thu, 30 Jan 2020 10:20:27 +0100 Subject: [PATCH] Added type based volume selection. --- register_selection_tools.cpp | 10 +++++++++- tools/selection_tools.cpp | 23 +++++++++++++++++++++++ tools/selection_tools.h | 9 +++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/register_selection_tools.cpp b/register_selection_tools.cpp index 8cc9034..f3a5e39 100644 --- a/register_selection_tools.cpp +++ b/register_selection_tools.cpp @@ -258,7 +258,15 @@ void RegisterSelectionTools(ProMeshRegistry& reg, string baseGrp) .add_function("SelectUnorientableVolumes", &SelectUnorientableVolumes, grp, "", "mesh", TOOLTIP_SELECT_UNORIENTABLE_VOLUMES) .add_function("SelectVolumeByIndex", &SelectVolumeByIndex, grp, "", - "mesh # index", TOOLTIP_SELECT_VOLUME_BY_INDEX); + "mesh # index", TOOLTIP_SELECT_VOLUME_BY_INDEX) + .add_function("SelectVolumesByType", &SelectVolumesByType, grp, "", + "mesh #" + "Hexahedra || value=true #" + "Octahedra || value=true #" + "Prisms || value=true #" + "Pyramids || value=true #" + "Tetrahedra || value=true #", + TOOLTIP_SELECT_VOLUMES_BY_TYPE); grp = baseGrp + "/Volumes/Coordinate Based"; reg.add_function("SelectVolumeByCoordinate", &SelectElemByCoordinate, grp, "", diff --git a/tools/selection_tools.cpp b/tools/selection_tools.cpp index be44063..b40f371 100644 --- a/tools/selection_tools.cpp +++ b/tools/selection_tools.cpp @@ -961,6 +961,29 @@ bool SelectVolumeByIndex(Mesh* obj, int index) return false; } +void SelectVolumesByType( + Mesh* obj, + bool selHexahedra, + bool selOctahedra, + bool selPrisms, + bool selPyramids, + bool selTetrahedra) +{ + Grid& grid = obj->grid(); + Selector& sel = obj->selector(); + + if(selHexahedra) + sel.select(grid.begin(), grid.end()); + if(selOctahedra) + sel.select(grid.begin(), grid.end()); + if(selPrisms) + sel.select(grid.begin(), grid.end()); + if(selPyramids) + sel.select(grid.begin(), grid.end()); + if(selTetrahedra) + sel.select(grid.begin(), grid.end()); +} + void VolumeSelectionFill(Mesh* obj) { Selector& sel = obj->selector(); diff --git a/tools/selection_tools.h b/tools/selection_tools.h index 14d6863..f9fa9ad 100644 --- a/tools/selection_tools.h +++ b/tools/selection_tools.h @@ -89,6 +89,7 @@ #define TOOLTIP_SELECT_FACE_BY_INDEX "Selects a face given its index." #define TOOLTIP_SELECT_FACES_BY_NORMAL "Selects faces given a normal and a maximum deviation angle." #define TOOLTIP_SELECT_VOLUME_BY_INDEX "Selects a volume given its index." +#define TOOLTIP_SELECT_VOLUMES_BY_TYPE "Selects all volumes of a given type." #define TOOLTIP_SELECT_VERTEX_BY_COORDINATE "Selects a vertex given a coordinate." #define TOOLTIP_SELECT_EDGE_BY_COORDINATE "Selects the edge whose center is closest to the specified coordinate." #define TOOLTIP_SELECT_FACE_BY_COORDINATE "Selects the face whose center is closest to the specified coordinate." @@ -383,6 +384,14 @@ int SelectSlivers(Mesh* obj, number thresholdRatio); bool SelectVolumeByIndex(Mesh* obj, int index); +void SelectVolumesByType( + Mesh* obj, + bool selHexahedra, + bool selOctahedra, + bool selPrisms, + bool selPyramids, + bool selTetrahedra); + void VolumeSelectionFill(Mesh* obj); void ClearMarks(Mesh* obj);