gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
CutMesh.cpp
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #include "CutMesh.h"
7 #include "GModel.h"
8 #include "gmshLevelset.h"
9 
10 StringXNumber CutMeshOptions_Number[] = {{GMSH_FULLRC, "View", nullptr, -1.},
11  {GMSH_FULLRC, "Split", nullptr, 0.},
12  {GMSH_FULLRC, "SaveTri", nullptr, 0.}};
13 
14 extern "C" {
16 }
17 
18 std::string GMSH_CutMeshPlugin::getHelp() const
19 {
20  return "Plugin(CutMesh) cuts the mesh of the current GModel with "
21  "the zero value of the levelset defined with the view 'View'."
22  "Sub-elements are created in the new model (polygons in 2D and "
23  "polyhedra in 3D) and border elements are created on the "
24  "zero-levelset.\n\n"
25  "If `Split' is nonzero, the plugin splits the mesh"
26  "along the edges of the cut elements in the positive side.\n\n"
27  "If 'SaveTri' is nonzero, the sub-elements are saved as simplices.\n\n"
28  "Plugin(CutMesh) creates one new GModel.";
29 }
30 
32 {
33  return sizeof(CutMeshOptions_Number) / sizeof(StringXNumber);
34 }
35 
37 {
38  return &CutMeshOptions_Number[iopt];
39 }
40 
42 {
43  int iView = (int)CutMeshOptions_Number[0].def;
44  if(iView < 0) iView = PView::list.size() - 1;
45 
46  gLevelsetPostView *gLs = new gLevelsetPostView(iView);
47 
48  int split = (int)CutMeshOptions_Number[1].def;
49  int saveTri = (int)CutMeshOptions_Number[2].def;
50  GModel *gm = GModel::current();
51  GModel *cgm = gm->buildCutGModel(gLs, !split, saveTri);
52  cgm->setVisibility(1);
53  return 0;
54 }
GModel::setVisibility
void setVisibility(char val)
Definition: GModel.h:341
CutMesh.h
GMSH_Plugin
Definition: Plugin.h:26
GMSH_RegisterCutMeshPlugin
GMSH_Plugin * GMSH_RegisterCutMeshPlugin()
Definition: CutMesh.cpp:15
StringXNumber
Definition: Options.h:918
GMSH_CutMeshPlugin::run
int run()
Definition: CutMesh.cpp:41
GModel::buildCutGModel
GModel * buildCutGModel(gLevelset *ls, bool cutElem=true, bool saveTri=false)
Definition: GModel.cpp:3376
GMSH_CutMeshPlugin
Definition: CutMesh.h:15
GMSH_CutMeshPlugin::getHelp
std::string getHelp() const
Definition: CutMesh.cpp:18
GMSH_CutMeshPlugin::getOption
StringXNumber * getOption(int iopt)
Definition: CutMesh.cpp:36
GMSH_FULLRC
#define GMSH_FULLRC
Definition: Options.h:20
GModel
Definition: GModel.h:44
GModel.h
CutMeshOptions_Number
StringXNumber CutMeshOptions_Number[]
Definition: CutMesh.cpp:10
PView::list
static std::vector< PView * > list
Definition: PView.h:112
gmshLevelset.h
GMSH_CutMeshPlugin::getNbOptions
int getNbOptions() const
Definition: CutMesh.cpp:31
GModel::current
static GModel * current(int index=-1)
Definition: GModel.cpp:136