gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
drawMesh.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 <cmath>
7 #include "drawContext.h"
8 #include "GmshMessage.h"
9 #include "GmshDefines.h"
10 #include "GModel.h"
11 #include "MLine.h"
12 #include "MTriangle.h"
13 #include "MQuadrangle.h"
14 #include "MTetrahedron.h"
15 #include "MHexahedron.h"
16 #include "MPrism.h"
17 #include "MPyramid.h"
18 #include "MTrihedron.h"
19 #include "MElementCut.h"
20 #include "Context.h"
21 #include "OS.h"
22 #include "gl2ps.h"
23 #include "VertexArray.h"
24 #include "SmoothData.h"
25 #include "PView.h"
26 #include "PViewData.h"
27 
28 #if defined(HAVE_FLTK)
29 #include <FL/Fl.H>
30 #include <FL/gl.h>
31 #endif
32 
33 // from GModelVertexArrays
34 extern unsigned int getColorByEntity(GEntity *e);
35 extern bool isElementVisible(MElement *ele);
36 
37 template <class T>
38 static void drawElementLabels(drawContext *ctx, GEntity *e,
39  std::vector<T *> &elements, int forceColor = 0,
40  unsigned int color = 0)
41 {
42  unsigned col = forceColor ? color : getColorByEntity(e);
43  glColor4ubv((GLubyte *)&col);
44 
45  int labelStep = CTX::instance()->mesh.labelSampling;
46  if(labelStep <= 0) labelStep = 1;
47 
48  for(std::size_t i = 0; i < elements.size(); i++) {
49  MElement *ele = elements[i];
50  if(!isElementVisible(ele)) continue;
51  if(i % labelStep == 0) {
52  SPoint3 pc = ele->barycenter();
53  char str[256];
54  if(CTX::instance()->mesh.labelType == 4)
55  sprintf(str, "(%g,%g,%g)", pc.x(), pc.y(), pc.z());
56  else if(CTX::instance()->mesh.labelType == 3)
57  sprintf(str, "%d", ele->getPartition());
58  else if(CTX::instance()->mesh.labelType == 2) {
59  int np = e->physicals.size();
60  int p = np ? e->physicals[np - 1] : 0;
61  sprintf(str, "%d", p);
62  }
63  else if(CTX::instance()->mesh.labelType == 1)
64  sprintf(str, "%d", e->tag());
65  else
66  sprintf(str, "%lu", ele->getNum());
67  ctx->drawString(str, pc.x(), pc.y(), pc.z());
68  }
69  }
70 }
71 
72 template <class T>
73 static void drawNormals(drawContext *ctx, std::vector<T *> &elements)
74 {
75  glColor4ubv((GLubyte *)&CTX::instance()->color.mesh.normals);
76  for(std::size_t i = 0; i < elements.size(); i++) {
77  MElement *ele = elements[i];
78  if(!isElementVisible(ele)) continue;
79  SVector3 n = ele->getFace(0).normal();
80  for(int j = 0; j < 3; j++)
81  n[j] *= CTX::instance()->mesh.normals * ctx->pixel_equiv_x / ctx->s[j];
82  SPoint3 pc = ele->barycenter();
83  ctx->drawVector(CTX::instance()->vectorType, 0, pc.x(), pc.y(), pc.z(),
84  n[0], n[1], n[2], CTX::instance()->mesh.light);
85  }
86 }
87 
88 template <class T>
89 static void drawTangents(drawContext *ctx, std::vector<T *> &elements)
90 {
91  glColor4ubv((GLubyte *)&CTX::instance()->color.mesh.tangents);
92  for(std::size_t i = 0; i < elements.size(); i++) {
93  MElement *ele = elements[i];
94  if(!isElementVisible(ele)) continue;
95  SVector3 t = ele->getEdge(0).tangent();
96  for(int j = 0; j < 3; j++)
97  t[j] *= CTX::instance()->mesh.tangents * ctx->pixel_equiv_x / ctx->s[j];
98  SPoint3 pc = ele->barycenter();
99  ctx->drawVector(CTX::instance()->vectorType, 0, pc.x(), pc.y(), pc.z(),
100  t[0], t[1], t[2], CTX::instance()->mesh.light);
101  }
102 }
103 
104 static void drawVertexLabel(drawContext *ctx, GEntity *e, MVertex *v,
105  int partition = -1)
106 {
107  if(!v->getVisibility()) return;
108 
109  int np = e->physicals.size();
110  int physical = np ? e->physicals[np - 1] : 0;
111  char str[256];
112  if(CTX::instance()->mesh.labelType == 4)
113  sprintf(str, "(%.16g,%.16g,%.16g)", v->x(), v->y(), v->z());
114  else if(CTX::instance()->mesh.labelType == 3) {
115  if(partition < 0)
116  sprintf(str, "NA");
117  else
118  sprintf(str, "%d", partition);
119  }
120  else if(CTX::instance()->mesh.labelType == 2)
121  sprintf(str, "%d", physical);
122  else if(CTX::instance()->mesh.labelType == 1)
123  sprintf(str, "%d", e->tag());
124  else
125  sprintf(str, "%lu", v->getNum());
126 
127  if(CTX::instance()->mesh.colorCarousel == 0 ||
129  CTX::instance()->mesh.surfaceFaces) { // by element type
130  if(v->getPolynomialOrder() > 1)
131  glColor4ubv((GLubyte *)&CTX::instance()->color.mesh.nodeSup);
132  else
133  glColor4ubv((GLubyte *)&CTX::instance()->color.mesh.node);
134  }
135  else {
136  unsigned int col = getColorByEntity(e);
137  glColor4ubv((GLubyte *)&col);
138  }
139  double offset = (0.5 * CTX::instance()->mesh.nodeSize +
140  0.1 * CTX::instance()->glFontSize) *
141  ctx->pixel_equiv_x;
142  ctx->drawString(str, v->x() + offset / ctx->s[0], v->y() + offset / ctx->s[1],
143  v->z() + offset / ctx->s[2]);
144 }
145 
147 {
148  if(CTX::instance()->mesh.nodes) {
149  if(CTX::instance()->mesh.nodeType) {
150  for(std::size_t i = 0; i < e->mesh_vertices.size(); i++) {
151  MVertex *v = e->mesh_vertices[i];
152  if(!v->getVisibility()) continue;
153  if(CTX::instance()->mesh.colorCarousel == 0 ||
155  CTX::instance()->mesh.surfaceFaces) { // by element type
156  if(v->getPolynomialOrder() > 1)
157  glColor4ubv((GLubyte *)&CTX::instance()->color.mesh.nodeSup);
158  else
159  glColor4ubv((GLubyte *)&CTX::instance()->color.mesh.node);
160  }
161  else {
162  unsigned int col = getColorByEntity(e);
163  glColor4ubv((GLubyte *)&col);
164  }
165  ctx->drawSphere(CTX::instance()->mesh.nodeSize, v->x(), v->y(), v->z(),
167  }
168  }
169  else {
170  glBegin(GL_POINTS);
171  for(std::size_t i = 0; i < e->mesh_vertices.size(); i++) {
172  MVertex *v = e->mesh_vertices[i];
173  if(!v->getVisibility()) continue;
174  if(CTX::instance()->mesh.colorCarousel == 0 ||
176  CTX::instance()->mesh.surfaceFaces) { // by element type
177  if(v->getPolynomialOrder() > 1)
178  glColor4ubv((GLubyte *)&CTX::instance()->color.mesh.nodeSup);
179  else
180  glColor4ubv((GLubyte *)&CTX::instance()->color.mesh.node);
181  }
182  else {
183  unsigned int col = getColorByEntity(e);
184  glColor4ubv((GLubyte *)&col);
185  }
186  glVertex3d(v->x(), v->y(), v->z());
187  }
188  glEnd();
189  }
190  }
191  if(CTX::instance()->mesh.nodeLabels) {
192  int labelStep = CTX::instance()->mesh.labelSampling;
193  if(labelStep <= 0) labelStep = 1;
194  for(std::size_t i = 0; i < e->mesh_vertices.size(); i++)
195  if(i % labelStep == 0) drawVertexLabel(ctx, e, e->mesh_vertices[i]);
196  }
197 }
198 
199 template <class T>
201  std::vector<T *> &elements)
202 {
203  for(std::size_t i = 0; i < elements.size(); i++) {
204  MElement *ele = elements[i];
205  for(std::size_t j = 0; j < ele->getNumVertices(); j++) {
206  MVertex *v = ele->getVertex(j);
207  // FIXME isElementVisible() can be slow: we should also use a
208  // vertex array for drawing vertices...
209  if(isElementVisible(ele) && v->getVisibility()) {
210  if(CTX::instance()->mesh.nodes) {
211  if(CTX::instance()->mesh.colorCarousel == 0 ||
213  CTX::instance()->mesh.surfaceFaces) { // by element type
214  if(v->getPolynomialOrder() > 1)
215  glColor4ubv((GLubyte *)&CTX::instance()->color.mesh.nodeSup);
216  else
217  glColor4ubv((GLubyte *)&CTX::instance()->color.mesh.node);
218  }
219  else {
220  unsigned int col = getColorByEntity(e);
221  glColor4ubv((GLubyte *)&col);
222  }
223  if(CTX::instance()->mesh.nodeType)
224  ctx->drawSphere(CTX::instance()->mesh.nodeSize, v->x(), v->y(),
225  v->z(), CTX::instance()->mesh.light);
226  else {
227  glBegin(GL_POINTS);
228  glVertex3d(v->x(), v->y(), v->z());
229  glEnd();
230  }
231  }
232  if(CTX::instance()->mesh.nodeLabels)
233  drawVertexLabel(ctx, v->onWhat() ? v->onWhat() : e, v);
234  }
235  }
236  }
237 }
238 
239 template <class T> static void drawBarycentricDual(std::vector<T *> &elements)
240 {
241  glColor4ubv((GLubyte *)&CTX::instance()->color.fg);
242  glEnable(GL_LINE_STIPPLE);
243  glLineStipple(1, 0x0F0F);
245  glBegin(GL_LINES);
246  for(std::size_t i = 0; i < elements.size(); i++) {
247  MElement *ele = elements[i];
248  if(!isElementVisible(ele)) continue;
249  SPoint3 pc = ele->barycenter();
250  if(ele->getDim() == 2) {
251  for(int j = 0; j < ele->getNumEdges(); j++) {
252  MEdge e = ele->getEdge(j);
253  SPoint3 p = e.barycenter();
254  glVertex3d(pc.x(), pc.y(), pc.z());
255  glVertex3d(p.x(), p.y(), p.z());
256  }
257  }
258  else if(ele->getDim() == 3) {
259  for(int j = 0; j < ele->getNumFaces(); j++) {
260  MFace f = ele->getFace(j);
261  SPoint3 p = f.barycenter();
262  glVertex3d(pc.x(), pc.y(), pc.z());
263  glVertex3d(p.x(), p.y(), p.z());
264  for(std::size_t k = 0; k < f.getNumVertices(); k++) {
265  MEdge e(f.getVertex(k), (k == f.getNumVertices() - 1) ?
266  f.getVertex(0) :
267  f.getVertex(k + 1));
268  SPoint3 pe = e.barycenter();
269  glVertex3d(p.x(), p.y(), p.z());
270  glVertex3d(pe.x(), pe.y(), pe.z());
271  }
272  }
273  }
274  }
275  glEnd();
276  glDisable(GL_LINE_STIPPLE);
278 }
279 
280 template <class T> static void drawVoronoiDual(std::vector<T *> &elements)
281 {
282  glColor4ubv((GLubyte *)&CTX::instance()->color.fg);
283  glEnable(GL_LINE_STIPPLE);
284  glLineStipple(1, 0x0F0F);
286  glBegin(GL_LINES);
287  for(std::size_t i = 0; i < elements.size(); i++) {
288  T *ele = elements[i];
289  if(!isElementVisible(ele)) continue;
290  SPoint3 pc = ele->circumcenter();
291  if(ele->getDim() == 2) {
292  for(int j = 0; j < ele->getNumEdges(); j++) {
293  MEdge e = ele->getEdge(j);
294  SVector3 p2p1(e.getVertex(1)->x() - e.getVertex(0)->x(),
295  e.getVertex(1)->y() - e.getVertex(0)->y(),
296  e.getVertex(1)->z() - e.getVertex(0)->z());
297  SVector3 pcp1(pc.x() - e.getVertex(0)->x(),
298  pc.y() - e.getVertex(0)->y(),
299  pc.z() - e.getVertex(0)->z());
300  double alpha = dot(pcp1, p2p1) / dot(p2p1, p2p1);
301  SPoint3 p(
302  (1 - alpha) * e.getVertex(0)->x() + alpha * e.getVertex(1)->x(),
303  (1 - alpha) * e.getVertex(0)->y() + alpha * e.getVertex(1)->y(),
304  (1 - alpha) * e.getVertex(0)->z() + alpha * e.getVertex(1)->z());
305  glVertex3d(pc.x(), pc.y(), pc.z());
306  glVertex3d(p.x(), p.y(), p.z());
307  }
308  }
309  else if(ele->getDim() == 3) {
310  for(int j = 0; j < ele->getNumFaces(); j++) {
311  MFace f = ele->getFace(j);
312  SPoint3 p = f.barycenter();
313  glVertex3d(pc.x(), pc.y(), pc.z());
314  glVertex3d(p.x(), p.y(), p.z());
315  for(std::size_t k = 0; k < f.getNumVertices(); k++) {
316  MEdge e(f.getVertex(k), (k == f.getNumVertices() - 1) ?
317  f.getVertex(0) :
318  f.getVertex(k + 1));
319  SPoint3 pe = e.barycenter();
320  glVertex3d(p.x(), p.y(), p.z());
321  glVertex3d(pe.x(), pe.y(), pe.z());
322  }
323  }
324  }
325  }
326  glEnd();
327  glDisable(GL_LINE_STIPPLE);
329 }
330 
331 // Routine for drawing the vertex arrays
332 
333 static void drawArrays(drawContext *ctx, GEntity *e, VertexArray *va,
334  GLint type, bool useNormalArray, int forceColor = 0,
335  unsigned int color = 0)
336 {
337  if(!va || !va->getNumVertices()) return;
338 
339  // If we want to be enable picking of individual elements we need to
340  // draw each one separately
341  bool select =
344  if(select) {
345  if(va->getNumElementPointers() == va->getNumVertices()) {
346  for(int i = 0; i < va->getNumVertices();
347  i += va->getNumVerticesPerElement()) {
348  glPushName(va->getNumVerticesPerElement());
349  glPushName(i);
350  glBegin(type);
351  for(int j = 0; j < va->getNumVerticesPerElement(); j++)
352  glVertex3fv(va->getVertexArray(3 * (i + j)));
353  glEnd();
354  glPopName();
355  glPopName();
356  }
357  return;
358  }
359  }
360 
361  glVertexPointer(3, GL_FLOAT, 0, va->getVertexArray());
362  glEnableClientState(GL_VERTEX_ARRAY);
363 
364  if(useNormalArray) {
365  glEnable(GL_LIGHTING);
366  glNormalPointer(NORMAL_GLTYPE, 0, va->getNormalArray());
367  glEnableClientState(GL_NORMAL_ARRAY);
368  }
369  else
370  glDisableClientState(GL_NORMAL_ARRAY);
371 
372  if(forceColor) {
373  glDisableClientState(GL_COLOR_ARRAY);
374  glColor4ubv((GLubyte *)&color);
375  }
376  else if(CTX::instance()->pickElements ||
377  (!e->getSelection() && (CTX::instance()->mesh.colorCarousel == 0 ||
378  CTX::instance()->mesh.colorCarousel == 3))) {
379  glColorPointer(4, GL_UNSIGNED_BYTE, 0, va->getColorArray());
380  glEnableClientState(GL_COLOR_ARRAY);
381  }
382  else {
383  glDisableClientState(GL_COLOR_ARRAY);
384  color = getColorByEntity(e);
385  glColor4ubv((GLubyte *)&color);
386  }
387 
389  glEnable(GL_POLYGON_OFFSET_FILL);
390 
391  glDrawArrays(type, 0, va->getNumVertices());
392 
393  glDisable(GL_POLYGON_OFFSET_FILL);
394  glDisable(GL_LIGHTING);
395 
396  glDisableClientState(GL_VERTEX_ARRAY);
397  glDisableClientState(GL_NORMAL_ARRAY);
398  glDisableClientState(GL_COLOR_ARRAY);
399 }
400 
401 // GVertex drawing routines
402 
404 private:
406 
407 public:
410  {
411  if(!v->getVisibility()) return;
412 
413  bool select = (_ctx->render_mode == drawContext::GMSH_SELECT &&
414  v->model() == GModel::current());
415  if(select) {
416  glPushName(0);
417  glPushName(v->tag());
418  }
419 
420  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
421 
422  if(CTX::instance()->mesh.nodes || CTX::instance()->mesh.nodeLabels)
424 
425  if(select) {
426  glPopName();
427  glPopName();
428  }
429  }
430 };
431 
432 // GEdge drawing routines
433 
435 private:
437 
438 public:
440  void operator()(GEdge *e)
441  {
442  if(!e->getVisibility()) {
443  return;
444  }
445 
446  bool select = (_ctx->render_mode == drawContext::GMSH_SELECT &&
447  e->model() == GModel::current());
448  if(select) {
449  glPushName(1);
450  glPushName(e->tag());
451  }
452 
453  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
454 
455  if(CTX::instance()->mesh.lines)
456  drawArrays(_ctx, e, e->va_lines, GL_LINES, false);
457 
458  if(CTX::instance()->mesh.lineLabels) drawElementLabels(_ctx, e, e->lines);
459 
460  if(CTX::instance()->mesh.nodes || CTX::instance()->mesh.nodeLabels) {
461  if(e->getAllElementsVisible())
463  else
465  }
466 
467  if(CTX::instance()->mesh.tangents) drawTangents(_ctx, e->lines);
468 
469  if(select) {
470  glPopName();
471  glPopName();
472  }
473  }
474 };
475 
476 // GFace drawing routines
477 
479 private:
481 
482 public:
485  {
486  if(!f->getVisibility()) {
487  return;
488  }
489 
490  bool select = (_ctx->render_mode == drawContext::GMSH_SELECT &&
491  f->model() == GModel::current());
492  if(select) {
493  glPushName(2);
494  glPushName(f->tag());
495  }
496 
497  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
498 
499  drawArrays(_ctx, f, f->va_lines, GL_LINES,
502  CTX::instance()->color.mesh.line);
503 
504  if(CTX::instance()->mesh.lightTwoSide)
505  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
506 
507  drawArrays(_ctx, f, f->va_triangles, GL_TRIANGLES,
509 
510  if(CTX::instance()->mesh.surfaceLabels) {
511  if(CTX::instance()->mesh.triangles)
512  drawElementLabels(_ctx, f, f->triangles,
514  CTX::instance()->color.mesh.line);
515  if(CTX::instance()->mesh.quadrangles)
516  drawElementLabels(_ctx, f, f->quadrangles,
518  CTX::instance()->color.mesh.line);
519  drawElementLabels(_ctx, f, f->polygons,
521  CTX::instance()->color.mesh.line);
522  }
523 
524  if(CTX::instance()->mesh.nodes || CTX::instance()->mesh.nodeLabels) {
525  if(f->getAllElementsVisible())
527  else {
528  if(CTX::instance()->mesh.triangles)
529  drawVerticesPerElement(_ctx, f, f->triangles);
530  if(CTX::instance()->mesh.quadrangles)
531  drawVerticesPerElement(_ctx, f, f->quadrangles);
532  drawVerticesPerElement(_ctx, f, f->polygons);
533  }
534  }
535 
536  if(CTX::instance()->mesh.normals) {
537  if(CTX::instance()->mesh.triangles) drawNormals(_ctx, f->triangles);
538  if(CTX::instance()->mesh.quadrangles) drawNormals(_ctx, f->quadrangles);
539  drawNormals(_ctx, f->polygons);
540  }
541 
542  if(CTX::instance()->mesh.dual) {
543  if(CTX::instance()->mesh.triangles) drawBarycentricDual(f->triangles);
544  if(CTX::instance()->mesh.quadrangles) drawBarycentricDual(f->quadrangles);
545  drawBarycentricDual(f->polygons);
546  }
547  else if(CTX::instance()->mesh.voronoi) {
548  if(CTX::instance()->mesh.triangles) drawVoronoiDual(f->triangles);
549  }
550 
551  if(select) {
552  glPopName();
553  glPopName();
554  }
555  }
556 };
557 
558 // GRegion drawing routines
559 
561 private:
563 
564 public:
567  {
568  if(!r->getVisibility()) return;
569 
570  bool select = (_ctx->render_mode == drawContext::GMSH_SELECT &&
571  r->model() == GModel::current());
572  if(select) {
573  glPushName(3);
574  glPushName(r->tag());
575  }
576 
577  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
578 
579  drawArrays(
580  _ctx, r, r->va_lines, GL_LINES,
583 
584  if(CTX::instance()->mesh.lightTwoSide)
585  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
586 
587  drawArrays(_ctx, r, r->va_triangles, GL_TRIANGLES,
589 
590  if(CTX::instance()->mesh.volumeLabels) {
591  if(CTX::instance()->mesh.tetrahedra)
595  CTX::instance()->color.mesh.line);
596  if(CTX::instance()->mesh.hexahedra)
600  CTX::instance()->color.mesh.line);
601  if(CTX::instance()->mesh.prisms)
605  CTX::instance()->color.mesh.line);
606  if(CTX::instance()->mesh.pyramids)
610  CTX::instance()->color.mesh.line);
611  if(CTX::instance()->mesh.trihedra)
615  CTX::instance()->color.mesh.line);
619  CTX::instance()->color.mesh.line);
620  }
621 
622  if(CTX::instance()->mesh.nodes || CTX::instance()->mesh.nodeLabels) {
623  if(r->getAllElementsVisible())
625  else {
626  if(CTX::instance()->mesh.tetrahedra)
628  if(CTX::instance()->mesh.hexahedra)
630  if(CTX::instance()->mesh.prisms)
632  if(CTX::instance()->mesh.pyramids)
634  if(CTX::instance()->mesh.trihedra)
637  }
638  }
639 
640  if(CTX::instance()->mesh.dual) {
641  if(CTX::instance()->mesh.tetrahedra) drawBarycentricDual(r->tetrahedra);
642  if(CTX::instance()->mesh.hexahedra) drawBarycentricDual(r->hexahedra);
643  if(CTX::instance()->mesh.prisms) drawBarycentricDual(r->prisms);
644  if(CTX::instance()->mesh.pyramids) drawBarycentricDual(r->pyramids);
645  if(CTX::instance()->mesh.trihedra) drawBarycentricDual(r->trihedra);
647  }
648 
649  if(CTX::instance()->mesh.voronoi) {
650  if(CTX::instance()->mesh.tetrahedra) drawVoronoiDual(r->tetrahedra);
651  }
652 
653  if(select) {
654  glPopName();
655  glPopName();
656  }
657  }
658 };
659 
661 {
662  return;
663  // simple additive blending "a la xpost":
664  glBlendFunc(GL_SRC_ALPHA, GL_ONE); // glBlendEquation(GL_FUNC_ADD);
665  // maximum intensity projection "a la volsuite":
666  // glBlendFunc(GL_ONE, GL_ONE); // glBlendEquation(GL_MAX);
667  glEnable(GL_BLEND);
668  glDisable(GL_DEPTH_TEST);
669 }
670 
671 static void endFakeTransparency()
672 {
673  return;
674  glDisable(GL_BLEND);
675  glEnable(GL_DEPTH_TEST);
676 }
677 
678 // Main drawing routine
679 
681 {
682  if(!CTX::instance()->mesh.draw) return;
683 
684  // make sure to flag any model-dependent post-processing view as
685  // changed if the underlying mesh has, before resetting the changed
686  // flag
687  if(CTX::instance()->mesh.changed) {
688  for(std::size_t i = 0; i < GModel::list.size(); i++)
689  for(std::size_t j = 0; j < PView::list.size(); j++)
690  if(PView::list[j]->getData()->hasModel(GModel::list[i]))
691  PView::list[j]->setChanged(true);
692  }
693 
694  glPointSize((float)CTX::instance()->mesh.nodeSize);
695  gl2psPointSize((float)(CTX::instance()->mesh.nodeSize *
697 
698  glLineWidth((float)CTX::instance()->mesh.lineWidth);
699  gl2psLineWidth((float)(CTX::instance()->mesh.lineWidth *
701 
702  if(!CTX::instance()->clipWholeElements) {
703  for(int i = 0; i < 6; i++)
704  if(CTX::instance()->mesh.clip & (1 << i))
705  glEnable((GLenum)(GL_CLIP_PLANE0 + i));
706  else
707  glDisable((GLenum)(GL_CLIP_PLANE0 + i));
708  }
709 
710  for(std::size_t i = 0; i < GModel::list.size(); i++) {
711  GModel *m = GModel::list[i];
712  bool changed = m->fillVertexArrays();
713  if(changed) Msg::Debug("mesh vertex arrays have changed");
714 #if defined(HAVE_FLTK) && defined(__APPLE__)
715  // FIXME: resetting texture pile fixes bug with recent macOS versions
716  if(changed) gl_texture_pile_height(gl_texture_pile_height());
717 #endif
718  if(m->getVisibility() && isVisible(m)) {
719  int status = m->getMeshStatus();
720  if(status >= 0)
721  std::for_each(m->firstVertex(), m->lastVertex(), drawMeshGVertex(this));
722  if(status >= 1)
723  std::for_each(m->firstEdge(), m->lastEdge(), drawMeshGEdge(this));
724  if(status >= 2) {
726  std::for_each(m->firstFace(), m->lastFace(), drawMeshGFace(this));
728  }
729  if(status >= 3)
730  std::for_each(m->firstRegion(), m->lastRegion(), drawMeshGRegion(this));
731  }
732  }
733 
734  CTX::instance()->mesh.changed = 0;
735 
736  for(int i = 0; i < 6; i++) glDisable((GLenum)(GL_CLIP_PLANE0 + i));
737 }
beginFakeTransparency
static void beginFakeTransparency()
Definition: drawMesh.cpp:660
MElement::getNum
virtual std::size_t getNum() const
Definition: MElement.h:68
MVertex::getPolynomialOrder
int getPolynomialOrder()
Definition: MVertex.h:56
gl2ps.h
MTriangle.h
drawMeshGEdge::_ctx
drawContext * _ctx
Definition: drawMesh.cpp:436
contextMeshOptions::light
int light
Definition: Context.h:82
MTrihedron.h
GModel::firstEdge
eiter firstEdge()
Definition: GModel.h:356
CTX::polygonOffset
int polygonOffset
Definition: Context.h:280
drawMeshGRegion::operator()
void operator()(GRegion *r)
Definition: drawMesh.cpp:566
CTX::tangents
unsigned int tangents
Definition: Context.h:363
MEdge
Definition: MEdge.h:14
gl2psEnable
GL2PSDLL_API GLint gl2psEnable(GLint mode)
Definition: gl2ps.cpp:6476
dot
double dot(const SVector3 &a, const SMetric3 &m, const SVector3 &b)
Definition: STensor3.h:71
CTX::color
struct CTX::@3 color
GFace
Definition: GFace.h:33
VertexArray::getNumVerticesPerElement
int getNumVerticesPerElement()
Definition: VertexArray.h:176
GEdge::lines
std::vector< MLine * > lines
Definition: GEdge.h:42
GEntity::model
GModel * model() const
Definition: GEntity.h:277
OS.h
Msg::Debug
static void Debug(const char *fmt,...)
Definition: GmshMessage.cpp:752
MVertex
Definition: MVertex.h:24
MElement::getDim
virtual int getDim() const =0
contextMeshOptions::surfaceFaces
int surfaceFaces
Definition: Context.h:85
drawVerticesPerElement
static void drawVerticesPerElement(drawContext *ctx, GEntity *e, std::vector< T * > &elements)
Definition: drawMesh.cpp:200
drawTangents
static void drawTangents(drawContext *ctx, std::vector< T * > &elements)
Definition: drawMesh.cpp:89
GEntity::va_triangles
VertexArray * va_triangles
Definition: GEntity.h:68
MVertex::z
double z() const
Definition: MVertex.h:62
GEntity::physicals
std::vector< int > physicals
Definition: GEntity.h:65
drawContext::drawString
void drawString(const std::string &s, double x, double y, double z, const std::string &font_name, int font_enum, int font_size, int align, int line_num=0)
Definition: drawGlyph.cpp:16
CTX::epsPointSizeFactor
double epsPointSizeFactor
Definition: Context.h:341
VertexArray.h
SPoint3
Definition: SPoint3.h:14
LegendrePolynomials::f
void f(int n, double u, double *val)
Definition: orthogonalBasis.cpp:77
CTX::pickElements
int pickElements
Definition: Context.h:294
MVertex::getNum
std::size_t getNum() const
Definition: MVertex.h:86
MFace::normal
SVector3 normal() const
Definition: MFace.cpp:204
SVector3
Definition: SVector3.h:16
contextMeshOptions::nodeLabels
int nodeLabels
Definition: Context.h:86
VertexArray
Definition: VertexArray.h:151
CTX::epsLineWidthFactor
double epsLineWidthFactor
Definition: Context.h:341
drawNormals
static void drawNormals(drawContext *ctx, std::vector< T * > &elements)
Definition: drawMesh.cpp:73
PView.h
MVertex::onWhat
GEntity * onWhat() const
Definition: MVertex.h:82
drawMeshGRegion::drawMeshGRegion
drawMeshGRegion(drawContext *ctx)
Definition: drawMesh.cpp:565
GModel::firstVertex
viter firstVertex()
Definition: GModel.h:357
drawContext::drawMesh
void drawMesh()
Definition: drawMesh.cpp:680
MEdge::tangent
SVector3 tangent() const
Definition: MEdge.h:69
VertexArray::getNumVertices
int getNumVertices()
Definition: VertexArray.h:174
GEntity::getSelection
virtual char getSelection()
Definition: GEntity.h:314
drawContext::drawVector
void drawVector(int Type, int Fill, double x, double y, double z, double dx, double dy, double dz, int light)
Definition: drawGlyph.cpp:714
GmshMessage.h
MLine.h
getColorByEntity
unsigned int getColorByEntity(GEntity *e)
Definition: GModelVertexArrays.cpp:25
contextMeshOptions::volumeFaces
int volumeFaces
Definition: Context.h:85
PViewData.h
GEntity
Definition: GEntity.h:31
gl2psPointSize
GL2PSDLL_API GLint gl2psPointSize(GLfloat value)
Definition: gl2ps.cpp:6537
contextMeshOptions::nodeSize
double nodeSize
Definition: Context.h:87
MElement::getNumVertices
virtual std::size_t getNumVertices() const =0
contextMeshOptions::lightLines
int lightLines
Definition: Context.h:82
drawContext::s
double s[3]
Definition: drawContext.h:135
drawMeshGVertex
Definition: drawMesh.cpp:403
GRegion::polyhedra
std::vector< MPolyhedron * > polyhedra
Definition: GRegion.h:168
CTX::fg
unsigned int fg
Definition: Context.h:358
CTX::instance
static CTX * instance()
Definition: Context.cpp:122
MElement::getVertex
virtual const MVertex * getVertex(int num) const =0
drawContext::GMSH_SELECT
@ GMSH_SELECT
Definition: drawContext.h:145
SPoint3::x
double x(void) const
Definition: SPoint3.h:125
GRegion::hexahedra
std::vector< MHexahedron * > hexahedra
Definition: GRegion.h:164
MElement::getEdge
virtual MEdge getEdge(int num) const =0
GModel::lastFace
fiter lastFace()
Definition: GModel.h:359
MFace
Definition: MFace.h:20
CTX::normals
unsigned int normals
Definition: Context.h:363
drawMeshGEdge::operator()
void operator()(GEdge *e)
Definition: drawMesh.cpp:440
drawMeshGVertex::_ctx
drawContext * _ctx
Definition: drawMesh.cpp:405
MEdge::getVertex
MVertex * getVertex(std::size_t i) const
Definition: MEdge.h:39
GEntity::mesh_vertices
std::vector< MVertex * > mesh_vertices
Definition: GEntity.h:56
CTX::draw
int draw
Definition: Context.h:316
drawMeshGFace
Definition: drawMesh.cpp:478
MElementCut.h
MHexahedron.h
GModel::lastVertex
viter lastVertex()
Definition: GModel.h:361
MElement::getNumFaces
virtual int getNumFaces()=0
GVertex
Definition: GVertex.h:23
drawContext::isVisible
bool isVisible(GModel *m)
Definition: drawContext.h:202
drawVoronoiDual
static void drawVoronoiDual(std::vector< T * > &elements)
Definition: drawMesh.cpp:280
drawBarycentricDual
static void drawBarycentricDual(std::vector< T * > &elements)
Definition: drawMesh.cpp:239
VertexArray::getColorArray
unsigned char * getColorArray(int i=0)
Definition: VertexArray.h:192
drawMeshGRegion
Definition: drawMesh.cpp:560
drawMeshGEdge
Definition: drawMesh.cpp:434
drawMeshGFace::operator()
void operator()(GFace *f)
Definition: drawMesh.cpp:484
VertexArray::getNormalArray
normal_type * getNormalArray(int i=0)
Definition: VertexArray.h:187
MElement::getFace
virtual MFace getFace(int num) const =0
GModel
Definition: GModel.h:44
MEdge::barycenter
SPoint3 barycenter() const
Definition: MEdge.h:96
MPyramid.h
GModel::firstFace
fiter firstFace()
Definition: GModel.h:355
GmshDefines.h
SPoint3::y
double y(void) const
Definition: SPoint3.h:127
GRegion::trihedra
std::vector< MTrihedron * > trihedra
Definition: GRegion.h:167
drawContext::render_mode
int render_mode
Definition: drawContext.h:146
drawMeshGEdge::drawMeshGEdge
drawMeshGEdge(drawContext *ctx)
Definition: drawMesh.cpp:439
drawContext
Definition: drawContext.h:120
isElementVisible
bool isElementVisible(MElement *ele)
Definition: GModelVertexArrays.cpp:101
CTX::mesh
contextMeshOptions mesh
Definition: Context.h:313
MElement
Definition: MElement.h:30
drawElementLabels
static void drawElementLabels(drawContext *ctx, GEntity *e, std::vector< T * > &elements, int forceColor=0, unsigned int color=0)
Definition: drawMesh.cpp:38
drawMeshGFace::_ctx
drawContext * _ctx
Definition: drawMesh.cpp:480
GL2PS_LINE_STIPPLE
#define GL2PS_LINE_STIPPLE
Definition: gl2ps.h:149
MVertex::getVisibility
virtual char getVisibility()
Definition: MVertex.h:52
GEntity::tag
int tag() const
Definition: GEntity.h:280
contextMeshOptions::normals
double normals
Definition: Context.h:22
GModel::list
static std::vector< GModel * > list
Definition: GModel.h:202
GModel::fillVertexArrays
bool fillVertexArrays()
Definition: GModelVertexArrays.cpp:452
GRegion
Definition: GRegion.h:28
drawArrays
static void drawArrays(drawContext *ctx, GEntity *e, VertexArray *va, GLint type, bool useNormalArray, int forceColor=0, unsigned int color=0)
Definition: drawMesh.cpp:333
GRegion::prisms
std::vector< MPrism * > prisms
Definition: GRegion.h:165
CTX::print
struct CTX::@2 print
drawMeshGRegion::_ctx
drawContext * _ctx
Definition: drawMesh.cpp:562
GRegion::pyramids
std::vector< MPyramid * > pyramids
Definition: GRegion.h:166
contextMeshOptions::changed
int changed
Definition: Context.h:82
VertexArray::getVertexArray
float * getVertexArray(int i=0)
Definition: VertexArray.h:182
GModel::getVisibility
char getVisibility() const
Definition: GModel.h:340
GModel::firstRegion
riter firstRegion()
Definition: GModel.h:354
GEntity::getAllElementsVisible
bool getAllElementsVisible()
Definition: GEntity.h:372
GModel::lastRegion
riter lastRegion()
Definition: GModel.h:358
gl2psDisable
GL2PSDLL_API GLint gl2psDisable(GLint mode)
Definition: gl2ps.cpp:6512
Context.h
MTetrahedron.h
MQuadrangle.h
CTX::glFontSize
int glFontSize
Definition: Context.h:267
VertexArray::getNumElementPointers
int getNumElementPointers()
Definition: VertexArray.h:178
GEntity::va_lines
VertexArray * va_lines
Definition: GEntity.h:68
drawVerticesPerEntity
static void drawVerticesPerEntity(drawContext *ctx, GEntity *e)
Definition: drawMesh.cpp:146
contextMeshOptions::tangents
double tangents
Definition: Context.h:22
endFakeTransparency
static void endFakeTransparency()
Definition: drawMesh.cpp:671
GEdge
Definition: GEdge.h:26
drawMeshGVertex::drawMeshGVertex
drawMeshGVertex(drawContext *ctx)
Definition: drawMesh.cpp:408
drawMeshGVertex::operator()
void operator()(GVertex *v)
Definition: drawMesh.cpp:409
MPrism.h
drawMeshGFace::drawMeshGFace
drawMeshGFace(drawContext *ctx)
Definition: drawMesh.cpp:483
gl2psLineWidth
GL2PSDLL_API GLint gl2psLineWidth(GLfloat value)
Definition: gl2ps.cpp:6567
MElement::barycenter
virtual SPoint3 barycenter(bool primary=false) const
Definition: MElement.cpp:520
SPoint3::z
double z(void) const
Definition: SPoint3.h:129
NORMAL_GLTYPE
#define NORMAL_GLTYPE
Definition: drawContext.h:33
GModel::lastEdge
eiter lastEdge()
Definition: GModel.h:360
drawContext::pixel_equiv_x
double pixel_equiv_x
Definition: drawContext.h:141
GModel.h
MVertex::y
double y() const
Definition: MVertex.h:61
CTX::lineWidth
double lineWidth
Definition: Context.h:271
MElement::getPartition
virtual int getPartition() const
Definition: MElement.h:92
PView::list
static std::vector< PView * > list
Definition: PView.h:112
drawVertexLabel
static void drawVertexLabel(drawContext *ctx, GEntity *e, MVertex *v, int partition=-1)
Definition: drawMesh.cpp:104
GModel::getMeshStatus
int getMeshStatus(bool countDiscrete=true)
Definition: GModel.cpp:1474
GEntity::getVisibility
virtual char getVisibility()
Definition: GEntity.cpp:35
MElement::getNumEdges
virtual int getNumEdges() const =0
drawContext::drawSphere
void drawSphere(double R, double x, double y, double z, int n1, int n2, int light)
Definition: drawGlyph.cpp:390
contextMeshOptions::colorCarousel
int colorCarousel
Definition: Context.h:88
GRegion::tetrahedra
std::vector< MTetrahedron * > tetrahedra
Definition: GRegion.h:163
GModel::current
static GModel * current(int index=-1)
Definition: GModel.cpp:136
SmoothData.h
MVertex::x
double x() const
Definition: MVertex.h:60
contextMeshOptions::labelSampling
int labelSampling
Definition: Context.h:88
drawContext.h