gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
PView.h
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 #ifndef PVIEW_H
7 #define PVIEW_H
8 
9 #include <vector>
10 #include <map>
11 #include <string>
12 #include "MVertex.h"
13 #include "MElement.h"
14 #include "SPoint3.h"
15 
16 class PViewData;
17 class PViewOptions;
18 class VertexArray;
19 class smooth_normals;
20 class GModel;
21 class GMSH_PostPlugin;
22 namespace onelab {
23  class localNetworkClient;
24 }
25 
26 // A post-processing view.
27 class PView {
28 private:
29  static int _globalTag;
30  // unique tag of the view (>= 0)
31  int _tag;
32  // index of the view in the current view list
33  int _index;
34  // flag to mark that the view has changed1
35  bool _changed;
36  // tag of the source view if this view is an alias, -1 otherwise
37  int _aliasOf;
38  // eye position (for transparency sorting)
40  // the options
42  // the data
44  // initialize private stuff
45  void _init(int tag = -1);
46 
47 public:
48  // create a new view with list-based data
49  PView(int tag = -1);
50  // construct a new view using the given data
51  PView(PViewData *data, int tag = -1);
52  // construct a new view, alias of the view "ref"
53  PView(PView *ref, bool copyOptions = true, int tag = -1);
54  // construct a new list-based view from a simple 2D point dataset
55  PView(const std::string &xname, const std::string &yname,
56  std::vector<double> &x, std::vector<double> &y);
57  // construct a new list-based view from a simple 3D point dataset
58  PView(const std::string &name, std::vector<double> &x, std::vector<double> &y,
59  std::vector<double> &z, std::vector<double> &v);
60  // construct a new mesh-based view from a bunch of data
61  PView(const std::string &name, const std::string &type, GModel *model,
62  std::map<int, std::vector<double> > &data, double time = 0.,
63  int numComp = -1, int tag = -1);
64  // add a new time step to a given mesh-based view
65  void addStep(GModel *model, const std::map<int, std::vector<double> > &data,
66  double time = 0., int numComp = -1);
67  // add a new step to a list-based scalar point dataset
68  void addStep(std::vector<double> &y);
69 
70  // default destructor
71  ~PView();
72 
73  // set/get global tag
74  static int getGlobalTag();
75  static void setGlobalTag(int tag);
76 
77  // delete the vertex arrays, used to draw the view efficiently
78  void deleteVertexArrays();
79 
80  // get/set the display options
82  void setOptions(PViewOptions *val = nullptr);
83 
84  // get/set the view data
85  PViewData *getData(bool useAdaptiveIfAvailable = false);
86  void setData(PViewData *val) { _data = val; }
87 
88  // get the view tag (unique and immutable)
89  int getTag() { return _tag; }
90 
91  // get/set the view index (in the view list)
92  int getIndex() { return _index; }
93  void setIndex(int val) { _index = val; }
94 
95  // get/set the changed flag
96  bool &getChanged() { return _changed; }
97  void setChanged(bool val);
98 
99  // check if the view is an alias ("light copy") of another view
100  int getAliasOf() { return _aliasOf; }
101 
102  // get/set the eye position (for transparency calculations)
103  SPoint3 &getEye() { return _eye; }
104  void setEye(SPoint3 &p) { _eye = p; }
105  // void setDrawContext(drawContext *ctx){_ctx=ctx;}
106 
107  // get (approx.) memory used by the view, in Mb
108  double getMemoryInMb();
109 
110 #ifndef SWIG
111  // the static list of all loaded views
112  static std::vector<PView *> list;
113 #endif
114 
115  // combine view
116  static void combine(bool time, int how, bool remove, bool copyOptions);
117 
118  // find view by name, by fileName, or by number. If timeStep >= 0, return view
119  // only if it does *not* contain that timestep; if partition >= 0, return view
120  // only if it does *not* contain that partition, if fileName is not empty,
121  // return view only if it does *not* have that fileName.
122  static PView *getViewByName(const std::string &name, int timeStep = -1,
123  int partition = -1,
124  const std::string &fileName = "");
125  static PView *getViewByFileName(const std::string &fileName,
126  int timeStep = -1, int partition = -1);
127  static PView *getViewByTag(int tag, int timeStep = -1, int partition = -1);
128 
129  // sort views in ::list by name
130  static void sortByName();
131 
132  // IO read routines (these are global: they can create multiple
133  // views)
134  static bool readPOS(const std::string &fileName, int fileIndex = -1);
135  static bool readMSH(const std::string &fileName, int fileIndex = -1,
136  int partitionToRead = -1);
137  static bool readCGNS(const std::vector<std::vector<MVertex *> > &vertPerZone,
138  const std::vector<std::vector<MElement *> > &eltPerZone,
139  const std::string &fileName);
140  static bool readMED(const std::string &fileName, int fileIndex = -1);
141  static bool readPCH(const std::string &fileName, int fileIndex = -1);
142  static bool writeX3D(const std::string &fileName);
143  // IO write routine
144  bool write(const std::string &fileName, int format, bool append = false);
145 
146  // send to ONELAB server
147  void sendToServer(const std::string &name);
148 
149  // Routines for export of adapted views to pvtu file format for parallel
150  // visualization with paraview
151  bool writeAdapt(const std::string &fileName, int useDefaultName,
152  bool isBinary, int adaptLev, double adaptErr, int npart,
153  bool append = false);
154 
155  // vertex arrays to draw the elements efficiently
157 
158  // fill the vertex arrays, given the current option and data
159  bool fillVertexArrays();
160 
161  // fill a vertex array using a raw stream of bytes
162  static void fillVertexArray(onelab::localNetworkClient *remote, int length,
163  const char *data, int swap);
164 
165  // smoothed normals
167 };
168 
169 class nameData {
170 public:
171  std::string name;
172  std::vector<int> indices;
173  std::vector<PViewData *> data;
175 };
176 
177 // this is the maximum number of nodes of elements we actually *draw*
178 // (high order elements are always subdivided before drawing)
179 #define PVIEW_NMAX 8
180 void changeCoordinates(PView *p, int ient, int iele, int numNodes, int type,
181  int numComp, double **xyz, double **val);
182 bool isElementVisible(PViewOptions *opt, int dim, int numNodes, double **xyz);
183 
184 #endif
PView::va_points
VertexArray * va_points
Definition: PView.h:156
PView::_init
void _init(int tag=-1)
Definition: PView.cpp:20
PView
Definition: PView.h:27
PView::~PView
~PView()
Definition: PView.cpp:179
nameData::indices
std::vector< int > indices
Definition: PView.h:172
PView::getViewByName
static PView * getViewByName(const std::string &name, int timeStep=-1, int partition=-1, const std::string &fileName="")
Definition: PView.cpp:347
PView::getMemoryInMb
double getMemoryInMb()
Definition: PView.cpp:388
nameData::name
std::string name
Definition: PView.h:171
PView::_eye
SPoint3 _eye
Definition: PView.h:39
SPoint3
Definition: SPoint3.h:14
PView::_options
PViewOptions * _options
Definition: PView.h:41
nameData
Definition: PView.h:169
PView::getEye
SPoint3 & getEye()
Definition: PView.h:103
PView::readPOS
static bool readPOS(const std::string &fileName, int fileIndex=-1)
Definition: PViewIO.cpp:19
PView::getIndex
int getIndex()
Definition: PView.h:92
VertexArray
Definition: VertexArray.h:151
nameData::options
PViewOptions * options
Definition: PView.h:174
PView::va_vectors
VertexArray * va_vectors
Definition: PView.h:156
smooth_normals
Definition: SmoothData.h:100
changeCoordinates
void changeCoordinates(PView *p, int ient, int iele, int numNodes, int type, int numComp, double **xyz, double **val)
Definition: PViewVertexArrays.cpp:193
PView::_tag
int _tag
Definition: PView.h:31
PView::setData
void setData(PViewData *val)
Definition: PView.h:86
PView::setChanged
void setChanged(bool val)
Definition: PView.cpp:241
PView::_index
int _index
Definition: PView.h:33
PView::_aliasOf
int _aliasOf
Definition: PView.h:37
PView::getViewByTag
static PView * getViewByTag(int tag, int timeStep=-1, int partition=-1)
Definition: PView.cpp:376
PView::getTag
int getTag()
Definition: PView.h:89
PView::normals
smooth_normals * normals
Definition: PView.h:166
nameData::data
std::vector< PViewData * > data
Definition: PView.h:173
PView::va_ellipses
VertexArray * va_ellipses
Definition: PView.h:156
MVertex.h
PView::combine
static void combine(bool time, int how, bool remove, bool copyOptions)
Definition: PView.cpp:249
swap
void swap(double &a, double &b)
Definition: meshTriangulation.cpp:27
PView::setEye
void setEye(SPoint3 &p)
Definition: PView.h:104
PView::readCGNS
static bool readCGNS(const std::vector< std::vector< MVertex * > > &vertPerZone, const std::vector< std::vector< MElement * > > &eltPerZone, const std::string &fileName)
Definition: PViewIO_CGNS.cpp:179
onelab
Definition: GmshMessage.h:18
GModel
Definition: GModel.h:44
PView::getData
PViewData * getData(bool useAdaptiveIfAvailable=false)
Definition: PView.cpp:233
PView::PView
PView(int tag=-1)
Definition: PView.cpp:53
PView::writeX3D
static bool writeX3D(const std::string &fileName)
Definition: PViewX3D.cpp:72
PView::_changed
bool _changed
Definition: PView.h:35
PView::_globalTag
static int _globalTag
Definition: PView.h:29
onelab::localNetworkClient
Definition: onelab.h:1471
PView::_data
PViewData * _data
Definition: PView.h:43
PView::fillVertexArrays
bool fillVertexArrays()
Definition: PViewVertexArrays.cpp:1568
PView::sendToServer
void sendToServer(const std::string &name)
Definition: PViewIO.cpp:443
PView::getAliasOf
int getAliasOf()
Definition: PView.h:100
PViewData
Definition: PViewData.h:29
length
double length(Quaternion &q)
Definition: Camera.cpp:346
PView::getGlobalTag
static int getGlobalTag()
Definition: PView.cpp:206
PView::write
bool write(const std::string &fileName, int format, bool append=false)
Definition: PViewIO.cpp:378
PView::sortByName
static void sortByName()
Definition: PView.cpp:341
PView::va_triangles
VertexArray * va_triangles
Definition: PView.h:156
PView::readMED
static bool readMED(const std::string &fileName, int fileIndex=-1)
Definition: PViewIO.cpp:357
PView::readMSH
static bool readMSH(const std::string &fileName, int fileIndex=-1, int partitionToRead=-1)
Definition: PViewIO.cpp:84
z
const double z
Definition: GaussQuadratureQuad.cpp:56
GMSH_PostPlugin
Definition: Plugin.h:83
PView::readPCH
static bool readPCH(const std::string &fileName, int fileIndex=-1)
Definition: PViewIO.cpp:366
MElement.h
PView::deleteVertexArrays
void deleteVertexArrays()
Definition: PView.cpp:210
PViewOptions
Definition: PViewOptions.h:16
PView::getOptions
PViewOptions * getOptions()
Definition: PView.h:81
PView::setIndex
void setIndex(int val)
Definition: PView.h:93
PView::getViewByFileName
static PView * getViewByFileName(const std::string &fileName, int timeStep=-1, int partition=-1)
Definition: PView.cpp:362
PView::fillVertexArray
static void fillVertexArray(onelab::localNetworkClient *remote, int length, const char *data, int swap)
Definition: PViewVertexArrays.cpp:1574
PView::setGlobalTag
static void setGlobalTag(int tag)
Definition: PView.cpp:208
PView::getChanged
bool & getChanged()
Definition: PView.h:96
PView::addStep
void addStep(GModel *model, const std::map< int, std::vector< double > > &data, double time=0., int numComp=-1)
Definition: PView.cpp:168
PView::list
static std::vector< PView * > list
Definition: PView.h:112
SPoint3.h
isElementVisible
bool isElementVisible(PViewOptions *opt, int dim, int numNodes, double **xyz)
Definition: PViewVertexArrays.cpp:292
PView::setOptions
void setOptions(PViewOptions *val=nullptr)
Definition: PView.cpp:224
PView::writeAdapt
bool writeAdapt(const std::string &fileName, int useDefaultName, bool isBinary, int adaptLev, double adaptErr, int npart, bool append=false)
Definition: PViewIO.cpp:433
PView::va_lines
VertexArray * va_lines
Definition: PView.h:156