Skip to content
Snippets Groups Projects
Commit 79c2ec90 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

new options in Plugin(Invisible) to mark as invisible elements outside a bounding box

parent 3b634ec4
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,7 @@ Saved in: @code{General.OptionsFileName} ...@@ -38,7 +38,7 @@ Saved in: @code{General.OptionsFileName}
@item General.BuildInfo @item General.BuildInfo
Gmsh build information (read-only)@* Gmsh build information (read-only)@*
Default value: @code{"Version: 4.9.4-git-1b82f12da; License: GNU General Public License; Build OS: MacOSX-sdk; Build date: 20220202; Build host: MacBook-Pro-Christophe.local; Build options: 64Bit ALGLIB[contrib] ANN[contrib] Bamg Blossom Cairo Cgns DIntegration Dlopen DomHex Eigen[contrib] Fltk GMP Gmm[contrib] Hxt Jpeg Kbipack MathEx[contrib] Med Mesh Metis[contrib] Mmg Mpeg Netgen ONELAB ONELABMetamodel OpenCASCADE OpenCASCADE-CAF OpenGL OpenMP OptHom Parasolid ParasolidSTEP Parser Plugins Png Post QuadMeshingTools QuadTri Solver TetGen/BR TouchBar Voro++[contrib] WinslowUntangler Zlib; FLTK version: 1.4.0; OCC version: 7.7.0; MED version: 4.1.0; Packaged by: geuzaine; Web site: https://gmsh.info; Issue tracker: https://gitlab.onelab.info/gmsh/gmsh/issues"}@* Default value: @code{"Version: 4.9.5-git-f511f1b2c; License: GNU General Public License; Build OS: MacOSX-sdk; Build date: 20220204; Build host: MacBook-Pro-Christophe.local; Build options: 64Bit ALGLIB[contrib] ANN[contrib] Bamg Blossom Cairo Cgns DIntegration Dlopen DomHex Eigen[contrib] Fltk GMP Gmm[contrib] Hxt Jpeg Kbipack MathEx[contrib] Med Mesh Metis[contrib] Mmg Mpeg Netgen ONELAB ONELABMetamodel OpenCASCADE OpenCASCADE-CAF OpenGL OpenMP OptHom Parasolid ParasolidSTEP Parser Plugins Png Post QuadMeshingTools QuadTri Solver TetGen/BR TouchBar Voro++[contrib] WinslowUntangler Zlib; FLTK version: 1.4.0; OCC version: 7.7.0; MED version: 4.1.1; Packaged by: geuzaine; Web site: https://gmsh.info; Issue tracker: https://gitlab.onelab.info/gmsh/gmsh/issues"}@*
Saved in: @code{-} Saved in: @code{-}
@item General.BuildOptions @item General.BuildOptions
...@@ -168,7 +168,7 @@ Saved in: @code{General.SessionFileName} ...@@ -168,7 +168,7 @@ Saved in: @code{General.SessionFileName}
@item General.Version @item General.Version
Gmsh version (read-only)@* Gmsh version (read-only)@*
Default value: @code{"4.9.4-git-1b82f12da"}@* Default value: @code{"4.9.5-git-f511f1b2c"}@*
Saved in: @code{-} Saved in: @code{-}
@item General.WatchFilePattern @item General.WatchFilePattern
......
...@@ -636,13 +636,25 @@ Default value: @code{1} ...@@ -636,13 +636,25 @@ Default value: @code{1}
@end table @end table
@item Plugin(Invisible) @item Plugin(Invisible)
Plugin(Invisible) deletes (if `DeleteElements' is set) or reverses (if `ReverseElements' is set) all the invisible elements in the current model. Plugin(Invisible) deletes (if `DeleteElements' is set) or reverses (if `ReverseElements' is set) all the invisible elements in the current model. If the bounding box defined by `XMin' < x < `XMax, `YMin' < y < `YMax and `ZMin' < z < `ZMax' is not empty, mark all elements outside the bounding box as invisible prior to deleting or inverting the elements.
Numeric options: Numeric options:
@table @code @table @code
@item DeleteElements @item DeleteElements
Default value: @code{1} Default value: @code{1}
@item ReverseElements @item ReverseElements
Default value: @code{0} Default value: @code{0}
@item XMin
Default value: @code{0}
@item YMin
Default value: @code{0}
@item ZMin
Default value: @code{0}
@item XMax
Default value: @code{0}
@item YMax
Default value: @code{0}
@item ZMax
Default value: @code{0}
@end table @end table
@item Plugin(Isosurface) @item Plugin(Isosurface)
......
...@@ -9,6 +9,12 @@ ...@@ -9,6 +9,12 @@
StringXNumber InvisibleOptions_Number[] = { StringXNumber InvisibleOptions_Number[] = {
{GMSH_FULLRC, "DeleteElements", nullptr, 1.}, {GMSH_FULLRC, "DeleteElements", nullptr, 1.},
{GMSH_FULLRC, "ReverseElements", nullptr, 0.}, {GMSH_FULLRC, "ReverseElements", nullptr, 0.},
{GMSH_FULLRC, "XMin", nullptr, 0.},
{GMSH_FULLRC, "YMin", nullptr, 0.},
{GMSH_FULLRC, "ZMin", nullptr, 0.},
{GMSH_FULLRC, "XMax", nullptr, 0.},
{GMSH_FULLRC, "YMax", nullptr, 0.},
{GMSH_FULLRC, "ZMax", nullptr, 0.}
}; };
extern "C" { extern "C" {
...@@ -22,7 +28,10 @@ std::string GMSH_InvisiblePlugin::getHelp() const ...@@ -22,7 +28,10 @@ std::string GMSH_InvisiblePlugin::getHelp() const
{ {
return "Plugin(Invisible) deletes (if `DeleteElements' is set) or " return "Plugin(Invisible) deletes (if `DeleteElements' is set) or "
"reverses (if `ReverseElements' is set) all the invisible elements in " "reverses (if `ReverseElements' is set) all the invisible elements in "
"the current model."; "the current model. If the bounding box defined by `XMin' < x < `XMax, "
"`YMin' < y < `YMax and `ZMin' < z < `ZMax' is not empty, mark all "
"elements outside the bounding box as invisible prior to deleting or "
"inverting the elements.";
} }
int GMSH_InvisiblePlugin::getNbOptions() const int GMSH_InvisiblePlugin::getNbOptions() const
...@@ -37,10 +46,42 @@ StringXNumber *GMSH_InvisiblePlugin::getOption(int iopt) ...@@ -37,10 +46,42 @@ StringXNumber *GMSH_InvisiblePlugin::getOption(int iopt)
PView *GMSH_InvisiblePlugin::execute(PView *v) PView *GMSH_InvisiblePlugin::execute(PView *v)
{ {
double xmin = InvisibleOptions_Number[2].def;
double ymin = InvisibleOptions_Number[3].def;
double zmin = InvisibleOptions_Number[4].def;
double xmax = InvisibleOptions_Number[5].def;
double ymax = InvisibleOptions_Number[6].def;
double zmax = InvisibleOptions_Number[7].def;
GModel *m = GModel::current();
if((xmax - xmin) > 0. || (ymax - ymin) > 0. || (zmax - zmin) > 0.) {
std::vector<GEntity *> entities;
m->getEntities(entities);
for(std::size_t i = 0; i < entities.size(); i++) {
for(std::size_t j = 0; j < entities[i]->getNumMeshElements(); j++) {
MElement *e = entities[i]->getMeshElement(j);
bool visible = false;
for(std::size_t k = 0; k < e->getNumVertices(); k++) {
MVertex *v = e->getVertex(k);
if(v->x() >= xmin && v->x() <= xmax &&
v->y() >= ymin && v->y() <= ymax &&
v->z() >= zmin && v->z() <= zmax) {
visible = true;
break;
}
}
if(!visible) {
e->setVisibility(0);
}
}
}
}
if(InvisibleOptions_Number[0].def) if(InvisibleOptions_Number[0].def)
GModel::current()->removeInvisibleElements(); m->removeInvisibleElements();
if(InvisibleOptions_Number[1].def) if(InvisibleOptions_Number[1].def)
GModel::current()->reverseInvisibleElements(); m->reverseInvisibleElements();
return nullptr; return nullptr;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment