File: MeshSizeFieldView.cpp

package info (click to toggle)
gmsh 4.8.4%2Bds2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 87,812 kB
  • sloc: cpp: 378,014; ansic: 99,669; yacc: 7,216; python: 6,680; java: 3,486; lisp: 659; lex: 621; perl: 571; makefile: 470; sh: 440; xml: 415; javascript: 113; pascal: 35; modula3: 32
file content (63 lines) | stat: -rw-r--r-- 1,715 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Gmsh - Copyright (C) 1997-2021 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// issues on https://gitlab.onelab.info/gmsh/gmsh/issues.

#include "MeshSizeFieldView.h"
#include "GmshConfig.h"
#include "GModel.h"

#if defined(HAVE_MESH)
#include "Field.h"
#endif

StringXNumber MeshSizeFieldViewOptions_Number[] = {
  {GMSH_FULLRC, "MeshSizeField", nullptr, 0.},
  {GMSH_FULLRC, "View", nullptr, -1.},
  {GMSH_FULLRC, "Component", nullptr, 0.}};

extern "C" {
GMSH_Plugin *GMSH_RegisterMeshSizeFieldViewPlugin()
{
  return new GMSH_MeshSizeFieldViewPlugin();
}
}

std::string GMSH_MeshSizeFieldViewPlugin::getHelp() const
{
  return "Plugin(MeshSizeFieldView) evaluates the mesh size field "
         "`MeshSizeField' "
         "on specified `Component` (0 for scalar) of the post-processing view "
         "`View'.";
}

int GMSH_MeshSizeFieldViewPlugin::getNbOptions() const
{
  return sizeof(MeshSizeFieldViewOptions_Number) / sizeof(StringXNumber);
}

StringXNumber *GMSH_MeshSizeFieldViewPlugin::getOption(int iopt)
{
  return &MeshSizeFieldViewOptions_Number[iopt];
}

PView *GMSH_MeshSizeFieldViewPlugin::execute(PView *view)
{
#if defined(HAVE_MESH)
  int field = (int)MeshSizeFieldViewOptions_Number[0].def;
  int iView = (int)MeshSizeFieldViewOptions_Number[1].def;
  int comp = (int)MeshSizeFieldViewOptions_Number[2].def;

  PView *v1 = getView(iView, view);
  if(!v1) return view;
  Field *f = GModel::current()->getFields()->get(field);
  if(f)
    f->putOnView(v1, comp);
  else
    Msg::Error("Unknown mesh size field %d", field);
  return v1;
#else
  Msg::Error("Plugin(MeshSizeFieldView) requires the mesh module");
  return view;
#endif
}