Thanks to visit codestin.com
Credit goes to glvis.github.io

GLVis  v4.2
Accurate and flexible finite element visualization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
vssolution3d.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2022, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-443271.
4 //
5 // This file is part of the GLVis visualization tool and library. For more
6 // information and source code availability see https://glvis.org.
7 //
8 // GLVis is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef GLVIS_VSSOLUTION_3D_HPP
13 #define GLVIS_VSSOLUTION_3D_HPP
14 
15 #include "mfem.hpp"
16 #include "gl/types.hpp"
17 #include "vsdata.hpp"
18 #include <map>
19 using namespace mfem;
20 
22 {
23 protected:
24 
25  int drawmesh, drawelems, shading, draworder;
26  int cplane;
27  int cp_drawmesh, cp_drawelems, drawlsurf;
28  // Algorithm used to draw the cutting plane when shading is 2 and cplane is 1
29  // 0 - slower, more accurate algorithm for curved meshes (default)
30  // 1 - faster algorithm suitable for meshes with planar faces
31  int cp_algo;
32 
40 
41  double *node_pos;
42 
43  int nlevels;
44  Array<double> levels;
45 
46  GridFunction *GridF;
47 
48  void Init();
49 
50  void GetFaceNormals(const int FaceNo, const int side,
51  const IntegrationRule &ir, DenseMatrix &normals);
52 
53  void DrawRefinedSurf (int n, double *points, int elem, int func,
54  int part = -1);
55  void DrawRefinedSurf (int n, DenseMatrix &pointmat,
56  Vector &values, Array<int> &RefGeoms);
57  void DrawRefinedSurfLevelLines (int n, DenseMatrix &pointmat,
58  Vector &values, Array<int> &RefGeoms);
59  void DrawRefinedSurfEdges (int n, DenseMatrix &pointmat,
60  Vector &values, Array<int> &RefEdges,
61  int part = -1);
62  void LiftRefinedSurf (int n, DenseMatrix &pointmat,
63  Vector &values, int *RG);
64  void DrawTetLevelSurf(gl3::GlDrawable& target, const DenseMatrix &verts,
65  const Vector &vals,
66  const int *ind, const Array<double> &levels,
67  const DenseMatrix *grad = NULL);
68 
69  static int GetPyramidFaceSplits(const Array<bool> &quad_diag,
70  const Array<int> &faces,
71  const Array<int> &ofaces);
72  void DrawRefinedPyramidLevelSurf(gl3::GlDrawable& target,
73  const DenseMatrix &verts,
74  const Vector &vals, const int *RG,
75  const int np, const int face_splits,
76  const DenseMatrix *grad = NULL);
77 
78  static int GetWedgeFaceSplits(const Array<bool> &quad_diag,
79  const Array<int> &faces,
80  const Array<int> &ofaces);
81  void DrawRefinedWedgeLevelSurf(gl3::GlDrawable& target,
82  const DenseMatrix &verts,
83  const Vector &vals, const int *RG,
84  const int np, const int face_splits,
85  const DenseMatrix *grad = NULL);
86 
87  static int GetHexFaceSplits(const Array<bool> &quad_diag,
88  const Array<int> &faces,
89  const Array<int> &ofaces);
90  void DrawRefinedHexLevelSurf(gl3::GlDrawable& target,
91  const DenseMatrix &verts,
92  const Vector &vals, const int *RG,
93  const int nh, const int face_splits,
94  const DenseMatrix *grad = NULL);
95 
96  int GetAutoRefineFactor();
97 
98  bool CheckPositions(Array<int> &vertices) const
99  {
100  int n = 0;
101  for (int j = 0; j < vertices.Size(); j++)
102  {
103  if (node_pos[vertices[j]] >= 0.0) { n++; }
104  }
105  return (n < vertices.Size());
106  }
107 
108 public:
111 
112  Array<int> bdr_attr_to_show;
113 
115  VisualizationSceneSolution3d(Mesh & m, Vector & s);
116 
117  void SetGridFunction (GridFunction *gf) { GridF = gf; }
118 
119  void NewMeshAndSolution(Mesh *new_m, Vector *new_sol,
120  GridFunction *new_u = NULL);
121 
122  virtual ~VisualizationSceneSolution3d();
123 
124  virtual std::string GetHelpString() const;
125 
126  virtual void FindNewBox(bool prepare);
127  virtual void FindNewValueRange(bool prepare);
128 
129  virtual void PrepareRuler()
131  virtual void PrepareFlat();
132  virtual void PrepareLines();
133  virtual void Prepare();
134  virtual void PrepareOrderingCurve();
135  virtual void PrepareOrderingCurve1(gl3::GlDrawable& buf, bool arrows,
136  bool color);
137  virtual gl3::SceneInfo GetSceneObjs();
138 
139  virtual void glTF_Export();
140 
142  { drawelems = !drawelems; Prepare(); }
143 
144  void ToggleDrawMesh();
145 
146  // 0 - none, 1 - no arrows (color), 2 - with arrows (color),
147  // 3 - no arrows (black), 4 - with arrows (black)
148  void ToggleDrawOrdering() { draworder = (draworder+1)%5; }
149 
150  void ToggleShading();
151  int GetShading() { return shading; };
152  virtual void SetShading(int, bool);
153  virtual void SetRefineFactors(int, int);
154  virtual void AutoRefine();
155  virtual void ToggleAttributes(Array<int> &attr_list);
156 
157  void FindNodePos();
158 
159  void CuttingPlaneFunc (int type);
160  // func: 0 - draw surface, 1 - draw level lines
161  void CutRefinedElement(gl3::GlDrawable& target,
162  const DenseMatrix &verts, const Vector &vert_dist,
163  const Vector &vals, const Geometry::Type geom,
164  const int *elems, int num_elems, int func);
165  void CutRefinedFace(gl3::GlDrawable& target,
166  const DenseMatrix &verts, const Vector &vert_dist,
167  const Vector &vals, const Geometry::Type geom,
168  const int *faces, int num_faces);
169  void CPPrepare();
170  void CPMoved();
171  void PrepareFlat2();
172  void PrepareLines2();
173  virtual void PrepareCuttingPlane();
174  void PrepareCuttingPlane2();
175  void PrepareCuttingPlaneLines();
176  void PrepareCuttingPlaneLines2();
177  void PrepareLevelSurf();
178  void ToggleCuttingPlane();
179  void ToggleCPDrawElems();
180  void ToggleCPDrawMesh();
181  void ToggleCPAlgorithm();
182  void MoveLevelSurf(int);
183  void NumberOfLevelSurf(int);
184  virtual void EventUpdateColors();
185  virtual void UpdateLevelLines()
186  { PrepareLines(); PrepareCuttingPlaneLines(); }
187  virtual void UpdateValueRange(bool prepare);
188 
189  virtual void SetDrawMesh(int i)
190  {
191  if (drawmesh != i % 3)
192  {
193  drawmesh = i % 3;
194  PrepareLines();
195  }
196  }
197  virtual int GetDrawMesh() { return drawmesh; }
198 };
199 
200 #endif
virtual void SetDrawMesh(int i)
virtual void PrepareRuler()
Definition: vsdata.hpp:274
void SetGridFunction(GridFunction *gf)
bool CheckPositions(Array< int > &vertices) const
gl3::GlDrawable order_noarrow_buf