gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
Isosurface.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 "Isosurface.h"
7 #include "Context.h"
8 
11  {GMSH_FULLRC, "ExtractVolume", GMSH_IsosurfacePlugin::callbackVol, 0.},
13  {GMSH_FULLRC, "TargetError", GMSH_IsosurfacePlugin::callbackTarget, 1e-4},
14  {GMSH_FULLRC, "View", nullptr, -1.},
15  {GMSH_FULLRC, "OtherTimeStep", nullptr, -1.},
16  {GMSH_FULLRC, "OtherView", nullptr, -1.}};
17 
18 extern "C" {
20 {
21  return new GMSH_IsosurfacePlugin();
22 }
23 }
24 
25 double GMSH_IsosurfacePlugin::callbackValue(int num, int action, double value)
26 {
27  double min = 0., max = 1.;
28  if(action > 0) {
29  int iview = (int)IsosurfaceOptions_Number[4].def;
30  if(iview < 0) iview = num;
31  if(iview >= 0 && iview < (int)PView::list.size()) {
32  min = PView::list[iview]->getData()->getMin();
33  max = PView::list[iview]->getData()->getMax();
34  }
35  }
36  switch(action) { // configure the input field
37  case 1: return (min - max) / 200.;
38  case 2: return min;
39  case 3: return max;
40  default: break;
41  }
42  return 0.;
43 }
44 
45 double GMSH_IsosurfacePlugin::callbackVol(int num, int action, double value)
46 {
47  switch(action) { // configure the input field
48  case 1: return 1.;
49  case 2: return -1.;
50  case 3: return 1.;
51  default: break;
52  }
53  return 0.;
54 }
55 
56 double GMSH_IsosurfacePlugin::callbackRecur(int num, int action, double value)
57 {
58  switch(action) { // configure the input field
59  case 1: return 1.;
60  case 2: return 0.;
61  case 3: return 10.;
62  default: break;
63  }
64  return 0.;
65 }
66 
67 double GMSH_IsosurfacePlugin::callbackTarget(int num, int action, double value)
68 {
69  switch(action) { // configure the input field
70  case 1: return 0.01;
71  case 2: return 0.;
72  case 3: return 1.;
73  default: break;
74  }
75  return 0.;
76 }
77 
78 std::string GMSH_IsosurfacePlugin::getHelp() const
79 {
80  return "Plugin(Isosurface) extracts the isosurface of value "
81  "`Value' from the view `View', and draws the "
82  "`OtherTimeStep'-th step of the view `OtherView' on "
83  "this isosurface.\n\n"
84  "If `ExtractVolume' is nonzero, the plugin extracts the "
85  "isovolume with values greater (if `ExtractVolume' > 0) "
86  "or smaller (if `ExtractVolume' < 0) than the isosurface "
87  "`Value'.\n\n"
88  "If `OtherTimeStep' < 0, the plugin uses, for each time "
89  "step in `View', the corresponding time step in `OtherView'. "
90  "If `OtherView' < 0, the plugin uses `View' as the value "
91  "source.\n\n"
92  "If `View' < 0, the plugin is run on the current view.\n\n"
93  "Plugin(Isosurface) creates as many list-based views as there "
94  "are time steps in `View'.";
95 }
96 
98 {
99  return sizeof(IsosurfaceOptions_Number) / sizeof(StringXNumber);
100 }
101 
103 {
104  return &IsosurfaceOptions_Number[iopt];
105 }
106 
107 double GMSH_IsosurfacePlugin::levelset(double x, double y, double z,
108  double val) const
109 {
110  // we must look into the map for Map(x,y,z) - Value
111  // this is the case when the map is the same as the view,
112  // the result is the extraction of isovalue Value
113  return val - IsosurfaceOptions_Number[0].def;
114 }
115 
117 {
118  int iView = (int)IsosurfaceOptions_Number[4].def;
119  _valueIndependent = 0;
124  _valueView = (int)IsosurfaceOptions_Number[6].def;
126 
127  PView *v1 = getView(iView, v);
128  if(!v1) return v;
129 
130  return GMSH_LevelsetPlugin::execute(v1);
131 }
GMSH_IsosurfacePlugin::callbackRecur
static double callbackRecur(int, int, double)
Definition: Isosurface.cpp:56
PView
Definition: PView.h:27
GMSH_LevelsetPlugin::MAP
@ MAP
Definition: Levelset.h:26
GMSH_Plugin
Definition: Plugin.h:26
StringXNumber::def
double def
Definition: Options.h:922
GMSH_IsosurfacePlugin::getHelp
std::string getHelp() const
Definition: Isosurface.cpp:78
StringXNumber
Definition: Options.h:918
GMSH_LevelsetPlugin::_valueView
int _valueView
Definition: Levelset.h:24
GMSH_IsosurfacePlugin::getOption
StringXNumber * getOption(int iopt)
Definition: Isosurface.cpp:102
GMSH_IsosurfacePlugin::execute
PView * execute(PView *)
Definition: Isosurface.cpp:116
GMSH_LevelsetPlugin::_extractVolume
int _extractVolume
Definition: Levelset.h:25
Isosurface.h
GMSH_LevelsetPlugin::_valueTimeStep
int _valueTimeStep
Definition: Levelset.h:24
IsosurfaceOptions_Number
StringXNumber IsosurfaceOptions_Number[]
Definition: Isosurface.cpp:9
GMSH_FULLRC
#define GMSH_FULLRC
Definition: Options.h:20
GMSH_LevelsetPlugin::execute
virtual PView * execute(PView *)
Definition: Levelset.cpp:537
GMSH_IsosurfacePlugin::levelset
double levelset(double x, double y, double z, double val) const
Definition: Isosurface.cpp:107
GMSH_IsosurfacePlugin::getNbOptions
int getNbOptions() const
Definition: Isosurface.cpp:97
GMSH_IsosurfacePlugin::callbackValue
static double callbackValue(int, int, double)
Definition: Isosurface.cpp:25
GMSH_LevelsetPlugin::_orientation
ORIENTATION _orientation
Definition: Levelset.h:27
GMSH_RegisterIsosurfacePlugin
GMSH_Plugin * GMSH_RegisterIsosurfacePlugin()
Definition: Isosurface.cpp:19
GMSH_LevelsetPlugin::_recurLevel
int _recurLevel
Definition: Levelset.h:24
Context.h
z
const double z
Definition: GaussQuadratureQuad.cpp:56
GMSH_PostPlugin::getView
virtual PView * getView(int index, PView *view)
Definition: Plugin.cpp:81
GMSH_LevelsetPlugin::_valueIndependent
int _valueIndependent
Definition: Levelset.h:24
GMSH_IsosurfacePlugin::callbackVol
static double callbackVol(int, int, double)
Definition: Isosurface.cpp:45
PView::list
static std::vector< PView * > list
Definition: PView.h:112
GMSH_IsosurfacePlugin
Definition: Isosurface.h:15
GMSH_IsosurfacePlugin::callbackTarget
static double callbackTarget(int, int, double)
Definition: Isosurface.cpp:67
GMSH_LevelsetPlugin::_targetError
double _targetError
Definition: Levelset.h:23