28 extern thread_local IntegrationRule
cut_TriPts;
37 <<
"+------------------------------------+" << endl
39 <<
"+------------------------------------+" << endl
40 <<
"| a - Displays/Hides the axes |" << endl
41 <<
"| A - Turns antialiasing on/off |" << endl
42 <<
"| b - Displacements step back |" << endl
43 <<
"| c - Toggle colorbar and caption |" << endl
44 <<
"| C - Change the main plot caption |" << endl
45 <<
"| d - Displays/Hides displacements |" << endl
46 <<
"| e - Displays/Hides the elements |" << endl
47 <<
"| E - Toggle the elements in the CP |" << endl
48 <<
"| f - Smooth/Flat shading |" << endl
49 <<
"| F - Display mag./x/y/z component |" << endl
50 <<
"| g - Toggle background |" << endl
51 <<
"| h - Displays help menu |" << endl
52 <<
"| i - Toggle cutting plane |" << endl
53 <<
"| j - Turn on/off perspective |" << endl
54 <<
"| k/K Adjust the transparency level |" << endl
55 <<
"| ,/< Adjust color transparency |" << endl
56 <<
"| l - Turns on/off the light |" << endl
57 <<
"| L - Toggle logarithmic scale |" << endl
58 <<
"| m - Displays/Hides the mesh |" << endl
59 <<
"| M - Toggle the mesh in the CP |" << endl
60 <<
"| n - Displacements step forward |" << endl
61 <<
"| o/O (De)refine elem, disc shading |" << endl
62 <<
"| p/P Cycle through color palettes |" << endl
63 <<
"| q - Quits |" << endl
64 <<
"| r - Reset the plot to 3D view |" << endl
65 <<
"| R - Reset the plot to 2D view |" << endl
66 <<
"| s - Turn on/off unit cube scaling |" << endl
67 <<
"| S - Take snapshot/Record a movie |" << endl
68 <<
"| t - Cycle materials and lights |" << endl
69 <<
"| u/U Move the level field vectors |" << endl
70 <<
"| v/V Vector field |" << endl
71 <<
"| w/W Add/Delete level field vector |" << endl
72 <<
"| x/X Rotate cutting plane (phi) |" << endl
73 <<
"| y/Y Rotate cutting plane (theta) |" << endl
74 <<
"| z/Z Translate cutting plane |" << endl
75 <<
"| \\ - Set light source position |" << endl
76 <<
"| Ctrl+p - Print to a PDF file |" << endl
77 <<
"+------------------------------------+" << endl
78 <<
"| Function keys |" << endl
79 <<
"+------------------------------------+" << endl
80 <<
"| F1 - X window info and keystrokes |" << endl
81 <<
"| F2 - Update colors, etc. |" << endl
82 <<
"| F3/F4 - Shrink/Zoom bdr elements |" << endl
83 <<
"| Ctrl+F3/F4 - Cut face bdr elements |" << endl
84 <<
"| F6 - Palette options |" << endl
85 <<
"| F7 - Manually set min/max value |" << endl
86 <<
"| F8 - List of subdomains to show |" << endl
87 <<
"| F9/F10 - Walk through subdomains |" << endl
88 <<
"| F11/F12 - Shrink/Zoom subdomains |" << endl
89 <<
"+------------------------------------+" << endl
90 <<
"| Keypad |" << endl
91 <<
"+------------------------------------+" << endl
92 <<
"| 1-9 Small rotation, reset with 5 |" << endl
93 <<
"| *,/ Scale up/down |" << endl
94 <<
"| +/- Change z-scaling |" << endl
95 <<
"| . - Start/stop spinning |" << endl
96 <<
"| 0/Enter - Spinning speed and dir. |" << endl
97 <<
"+------------------------------------+" << endl
98 <<
"| Mouse |" << endl
99 <<
"+------------------------------------+" << endl
100 <<
"| left btn - Rotation |" << endl
101 <<
"| middle btn - Translation |" << endl
102 <<
"| right btn - Scaling |" << endl
103 <<
"| left + Alt - Tilt |" << endl
104 <<
"| left + Shift - Spinning |" << endl
105 <<
"| right + Shift - Change light pos. |" << endl
106 <<
"| left + Ctrl - Spherical rotation |" << endl
107 <<
"| middle+ Ctrl - Object translation |" << endl
108 <<
"| right + Ctrl - Object scaling |" << endl
109 <<
"| left + Ctrl + Shift - z-Spinning |" << endl
110 <<
"+------------------------------------+" << endl;
181 PrepareDisplacedMesh();
207 for (i = 0; i < vflevel.Size(); i++)
208 if (vflevel[i] == 0 && v == -1)
214 vflevel[i] = (vflevel[i] + v) % (nl+1);
216 for (i = 0; i < vflevel.Size(); i++)
218 dvflevel[i] = level[vflevel[i]];
223 static void KeywPressed()
229 static void KeyWPressed()
237 int next = vflevel[vflevel.Size()-1];
238 next = (next + 1) % (nl+1);
239 vflevel.Append(next);
240 dvflevel.Append(level[next]);
246 vflevel.DeleteLast();
247 dvflevel.DeleteLast();
263 static void VectorKeyFPressed()
271 drawvector = (drawvector+i+6)%6;
272 PrepareVectorField();
275 static const char *scal_func_name[] =
276 {
"magnitude",
"x-component",
"y-component",
"z-component"};
280 FiniteElementSpace *fes = (VecGridF) ? VecGridF->FESpace() : NULL;
285 for (
int i = 0; i < sol->Size(); i++)
286 (*sol)(i) = sqrt((*solx)(i) * (*solx)(i) +
287 (*soly)(i) * (*soly)(i) +
288 (*solz)(i) * (*solz)(i) );
292 for (
int i = 0; i < GridF->Size(); i++)
296 fes->DofsToVDofs(dofs);
297 double x = (*VecGridF)(dofs[0]);
298 double y = (*VecGridF)(dofs[1]);
299 double z = (*VecGridF)(dofs[2]);
301 (*GridF)(i) = sqrt(x*x+y*y+z*z);
308 for (
int i = 0; i < GridF->Size(); i++)
310 (*GridF)(i) = (*VecGridF)(fes->DofToVDof(i, 0));
316 for (
int i = 0; i < GridF->Size(); i++)
318 (*GridF)(i) = (*VecGridF)(fes->DofToVDof(i, 1));
324 for (
int i = 0; i < GridF->Size(); i++)
326 (*GridF)(i) = (*VecGridF)(fes->DofToVDof(i, 2));
335 scal_func = (scal_func + 1) % 4;
336 cout <<
"Displaying " << scal_func_name[scal_func] << endl;
338 FindNewValueRange(
true);
342 Vector &sy, Vector &sz)
349 sol =
new Vector(mesh->GetNV());
359 FiniteElementSpace *fes = vgf.FESpace();
360 if (fes == NULL || fes->GetVDim() != 3)
362 cout <<
"VisualizationSceneVector3d::VisualizationSceneVector3d" << endl;
368 mesh = fes->GetMesh();
370 sfes =
new FiniteElementSpace(mesh, fes->FEColl(), 1, fes->GetOrdering());
371 GridF =
new GridFunction(sfes);
373 solx =
new Vector(mesh->GetNV());
374 soly =
new Vector(mesh->GetNV());
375 solz =
new Vector(mesh->GetNV());
377 vgf.GetNodalValues(*solx, 1);
378 vgf.GetNodalValues(*soly, 2);
379 vgf.GetNodalValues(*solz, 3);
381 sol =
new Vector(mesh->GetNV());
401 PrepareVectorField();
402 PrepareDisplacedMesh();
405 dvflevel.Append(level[0]);
454 Mesh *new_m, GridFunction *new_v)
465 if (mesh->GetNV() != new_m->GetNV())
468 node_pos =
new double[new_m->GetNV()];
472 if (mesh->Dimension() != new_m->Dimension() ||
473 (mesh->Dimension() == 2 && mesh->GetNE() != new_m->GetNE()) ||
474 (mesh->Dimension() == 3 && mesh->GetNBE() != new_m->GetNBE()))
477 int ref = GetAutoRefineFactor();
478 if (TimesToRefine != ref)
481 cout <<
"Subdivision factor = " << TimesToRefine << endl;
485 FiniteElementSpace *new_fes = new_v->FESpace();
491 sfes =
new FiniteElementSpace(mesh, new_fes->FEColl(), 1,
492 new_fes->GetOrdering());
493 GridF =
new GridFunction(sfes);
495 solx =
new Vector(mesh->GetNV());
496 soly =
new Vector(mesh->GetNV());
497 solz =
new Vector(mesh->GetNV());
499 VecGridF->GetNodalValues(*solx, 1);
500 VecGridF->GetNodalValues(*soly, 2);
501 VecGridF->GetNodalValues(*solz, 3);
503 sol =
new Vector(mesh->GetNV());
514 PrepareVectorField();
515 PrepareDisplacedMesh();
524 int dim = mesh->Dimension();
525 int ne = (dim == 3) ? mesh->GetNBE() : mesh->GetNE();
526 DenseMatrix pointmat;
528 double p[4][3], c[4];
530 for (i = 0; i < ne; i++)
534 if (!bdr_attr_to_show[mesh->GetBdrAttribute(i)-1]) {
continue; }
536 mesh->GetBdrPointMatrix(i, pointmat);
537 mesh->GetBdrElementVertices(i, vertices);
541 if (!bdr_attr_to_show[mesh->GetAttribute(i)-1]) {
continue; }
543 mesh->GetPointMatrix(i, pointmat);
544 mesh->GetElementVertices(i, vertices);
547 for (j = 0; j < pointmat.Width(); j++)
554 for (j = 0; j < pointmat.Width(); j++)
556 p[j][0] = pointmat(0, j);
557 p[j][1] = pointmat(1, j);
558 p[j][2] = pointmat(2, j);
559 c[j] = (*sol)(vertices[j]);
565 DrawCutTriangle(disp_buf, p, c, minv, maxv);
569 DrawTriangle(disp_buf, p, c, minv, maxv);
576 DrawCutQuad(disp_buf, p, c, minv, maxv);
580 DrawQuad(disp_buf, p, c, minv, maxv);
584 updated_bufs.emplace_back(&disp_buf);
589 int fn, fo, di = 0, have_normals;
590 double bbox_diam, vmin, vmax;
591 int dim = mesh->Dimension();
592 int ne = (dim == 3) ? mesh->GetNBE() : mesh->GetNE();
594 DenseMatrix pointmat, normals;
595 DenseMatrix vec_vals;
596 Vector values, normal;
597 RefinedGeometry * RefG;
600 IsoparametricTransformation T;
602 bbox_diam = sqrt( (bb.x[1]-bb.x[0])*(bb.x[1]-bb.x[0]) +
603 (bb.y[1]-bb.y[0])*(bb.y[1]-bb.y[0]) +
604 (bb.z[1]-bb.z[0])*(bb.z[1]-bb.z[0]) );
605 double sc = FaceShiftScale * bbox_diam;
609 vmin = numeric_limits<double>::infinity();
611 for (
int i = 0; i < ne; i++)
614 switch ((dim == 3) ? mesh->GetBdrElementType(i) : mesh->GetElementType(i))
616 case Element::TRIANGLE:
620 case Element::QUADRILATERAL:
628 if (!bdr_attr_to_show[mesh->GetBdrAttribute(i)-1]) {
continue; }
634 mesh->GetBdrElementFace(i, &f, &o);
635 mesh->GetFaceElements(f, &e1, &e2);
636 mesh->GetElementVertices(e1, vertices);
640 mesh->GetBdrElementVertices(i, vertices);
645 if (!bdr_attr_to_show[mesh->GetAttribute(i)-1]) {
continue; }
646 mesh->GetElementVertices(i, vertices);
649 if (cplane == 2 && CheckPositions(vertices)) {
continue; }
653 mesh -> GetBdrElementFace (i, &fn, &fo);
665 if (di == 1 && !mesh->FaceIsInterior(fn))
670 IntegrationRule &RefPts = (cut_lambda > 0) ?
673 GridF->GetFaceValues(fn, di, RefPts, values, pointmat);
676 VecGridF->GetFaceVectorValues(fn, di, RefPts, vec_vals,
683 GetFaceNormals(fn, di, RefPts, normals);
686 ShrinkPoints(pointmat, i, fn, di);
698 IntegrationRule &RefPts = (cut_lambda > 0) ?
701 GridF->GetValues(i, RefPts, values, pointmat);
704 VecGridF->GetVectorValues(i, RefPts, vec_vals, pointmat);
710 const IntegrationRule &ir = (cut_lambda > 0) ?
713 normals.SetSize(3, values.Size());
714 mesh->GetElementTransformation(i, &T);
715 for (
int j = 0; j < values.Size(); j++)
717 T.SetIntPoint(&ir.IntPoint(j));
718 normals.GetColumnReference(j, normal);
719 CalcOrtho(T.Jacobian(), normal);
720 normal /= normal.Norml2();
725 ShrinkPoints(pointmat, i, 0, 0);
728 vmin = fmin(vmin, values.Min());
729 vmax = fmax(vmax, values.Max());
731 if (sc != 0.0 && have_normals)
733 for (
int j = 0; j < 3; j++)
738 for (
int k = 0; k < normals.Width(); k++)
739 for (
int j = 0; j < 3; j++)
741 norm[j] += normals(j, k);
744 for (
int k = 0; k < pointmat.Width(); k++)
746 double val = sc * (values(k) - minv) / (maxv - minv);
747 for (
int j = 0; j < 3; j++)
749 pointmat(j, k) += val * norm[j];
755 have_normals = have_normals ? 2 : 0;
758 have_normals = -1 - have_normals;
761 Array<int> &RefGeoms = (cut_lambda > 0) ?
764 int psides = (cut_lambda > 0) ? 4 : sides;
765 DrawPatch(disp_buf, pointmat, values, normals, psides, RefGeoms,
766 minv, maxv, have_normals);
768 updated_bufs.emplace_back(&disp_buf);
769 cout <<
"VisualizationSceneVector3d::PrepareFlat2() : [min,max] = ["
770 << vmin <<
"," << vmax <<
"]" << endl;
792 int dim = mesh->Dimension();
793 int ne = (dim == 3) ? mesh->GetNBE() : mesh->GetNE();
794 int nv = mesh -> GetNV();
795 DenseMatrix pointmat;
803 const Array<int> &attributes =
804 ((dim == 3) ? mesh->bdr_attributes : mesh->attributes);
805 for (
int d = 0; d < attributes.Size(); d++)
807 if (!bdr_attr_to_show[attributes[d]-1]) {
continue; }
813 for (i = 0; i < ne; i++)
816 (dim == 3) ? mesh->GetBdrAttribute(i) : mesh->GetAttribute(i);
817 if (attr != attributes[d]) {
continue; }
821 mesh->GetBdrPointMatrix (i, pointmat);
822 mesh->GetBdrElementVertices (i, vertices);
826 mesh->GetPointMatrix(i, pointmat);
827 mesh->GetElementVertices(i, vertices);
830 for (j = 0; j < pointmat.Size(); j++)
837 if (pointmat.Width() == 3)
839 &pointmat(0,2), nor);
842 &pointmat(0,2), &pointmat(0,3), nor);
844 for (j = 0; j < pointmat.Size(); j++)
846 nx(vertices[j]) += nor[0];
847 ny(vertices[j]) += nor[1];
848 nz(vertices[j]) += nor[2];
852 for (i = 0; i < ne; i++)
855 (dim == 3) ? mesh->GetBdrAttribute(i) : mesh->GetAttribute(i);
856 if (attr != attributes[d]) {
continue; }
859 (dim == 3) ? mesh->GetBdrElementType(i) : mesh->GetElementType(i);
862 case Element::TRIANGLE:
866 case Element::QUADRILATERAL:
872 mesh->GetBdrPointMatrix (i, pointmat);
873 mesh->GetBdrElementVertices (i, vertices);
877 mesh->GetPointMatrix(i, pointmat);
878 mesh->GetElementVertices(i, vertices);
880 for (j = 0; j < pointmat.Size(); j++)
886 for (j = 0; j < pointmat.Size(); j++)
888 MySetColor(draw, (*sol)(vertices[j]), minv, maxv);
889 draw.
glNormal3d(nx(vertices[j]), ny(vertices[j]), nz(vertices[j]));
895 updated_bufs.emplace_back(&disp_buf);
900 if (!drawmesh) {
return; }
908 int dim = mesh->Dimension();
909 int i, j, ne = (dim == 3) ? mesh->GetNBE() : mesh->GetNE();
910 DenseMatrix pointmat;
916 for (i = 0; i < ne; i++)
918 int attr = (dim == 3) ? mesh->GetBdrAttribute(i) : mesh->GetAttribute(i);
919 if (!bdr_attr_to_show[attr-1]) {
continue; }
927 mesh->GetBdrElementFace(i, &f, &o);
928 mesh->GetFaceElements(f, &e1, &e2);
929 mesh->GetElementVertices(e1, vertices);
931 if (CheckPositions(vertices)) {
continue; }
933 mesh->GetBdrElementVertices(i, vertices);
934 mesh->GetBdrPointMatrix(i, pointmat);
938 mesh->GetElementVertices(i, vertices);
939 mesh->GetPointMatrix(i, pointmat);
942 if (cplane == 2 && CheckPositions(vertices)) {
continue; }
944 for (j = 0; j < pointmat.Size(); j++)
956 for (j = 0; j < pointmat.Size(); j++)
958 line.
glVertex3d (pointmat(0, j), pointmat(1, j), pointmat(2, j));
964 for (j = 0; j < pointmat.Size(); j++)
966 for (
int k = 0; k < 3; k++)
968 point[j][k] = pointmat(k,j);
970 point[j][3] = (*sol)(vertices[j]);
972 DrawPolygonLevelLines(line, point[0], pointmat.Size(), level,
false);
976 updated_bufs.emplace_back(&line_buf);
981 int i, j, k, fn, fo, di = 0;
987 int dim = mesh->Dimension();
988 int ne = (dim == 3) ? mesh->GetNBE() : mesh->GetNE();
989 DenseMatrix pointmat;
990 DenseMatrix vec_vals;
992 RefinedGeometry * RefG;
995 bbox_diam = sqrt ( (bb.x[1]-bb.x[0])*(bb.x[1]-bb.x[0]) +
996 (bb.y[1]-bb.y[0])*(bb.y[1]-bb.y[0]) +
997 (bb.z[1]-bb.z[0])*(bb.z[1]-bb.z[0]) );
998 double sc = FaceShiftScale * bbox_diam;
1000 for (i = 0; i < ne; i++)
1002 int attr = (dim == 3) ? mesh->GetBdrAttribute(i) : mesh->GetAttribute(i);
1003 if (!bdr_attr_to_show[attr-1]) {
continue; }
1011 mesh->GetBdrElementFace(i, &f, &o);
1012 mesh->GetFaceElements(f, &e1, &e2);
1013 mesh->GetElementVertices(e1, vertices);
1017 mesh->GetBdrElementVertices (i, vertices);
1022 mesh->GetElementVertices(i, vertices);
1025 if (cplane == 2 && CheckPositions(vertices)) {
continue; }
1029 mesh -> GetBdrElementFace (i, &fn, &fo);
1034 if (di == 1 && !mesh->FaceIsInterior(fn))
1038 GridF -> GetFaceValues (fn, di, RefG->RefPts, values, pointmat);
1039 VecGridF -> GetFaceVectorValues (fn, di, RefG->RefPts,
1040 vec_vals, pointmat);
1045 ShrinkPoints(pointmat, i, fn, di);
1051 GridF->GetValues(i, RefG->RefPts, values, pointmat);
1052 VecGridF->GetVectorValues(i, RefG->RefPts, vec_vals, pointmat);
1057 ShrinkPoints(pointmat, i, 0, 0);
1060 int *RG = &(RefG->RefGeoms[0]);
1063 { pointmat(0,RG[0]), pointmat(1,RG[0]), pointmat(2,RG[0]) },
1064 { pointmat(0,RG[1]), pointmat(1,RG[1]), pointmat(2,RG[1]) },
1065 { pointmat(0,RG[2]), pointmat(1,RG[2]), pointmat(2,RG[2]) }
1069 if (di != 0 && sc != 0.0)
1078 Array<int> &REdges = RefG->RefEdges;
1080 for (k = 0; k < REdges.Size()/2; k++)
1082 int *RE = &(REdges[2*k]);
1086 for (j = 0; j < 2; j++)
1087 line.
glVertex3d (pointmat(0, RE[j]), pointmat(1, RE[j]),
1088 pointmat(2, RE[j]));
1092 for (j = 0; j < 2; j++)
1094 double val = sc * (values(RE[j]) - minv) / (maxv - minv);
1095 line.
glVertex3d (pointmat(0, RE[j])+val*norm[0],
1096 pointmat(1, RE[j])+val*norm[1],
1097 pointmat(2, RE[j])+val*norm[2]);
1103 else if (drawmesh == 2)
1107 switch ((dim == 3) ? mesh->GetBdrElementType(i) :
1108 mesh->GetElementType(i))
1110 case Element::TRIANGLE:
1114 case Element::QUADRILATERAL:
1119 for (k = 0; k < RefG->RefGeoms.Size()/sides; k++)
1121 RG = &(RefG->RefGeoms[k*sides]);
1125 for (j = 0; j < sides; j++)
1127 for (
int ii = 0; ii < 3; ii++)
1129 point[j][ii] = pointmat(ii, RG[j]);
1131 point[j][3] = values(RG[j]);
1136 for (j = 0; j < sides; j++)
1138 double val = (values(RG[j]) - minv) / (maxv - minv);
1140 for (
int ii = 0; ii < 3; ii++)
1142 point[j][ii] = pointmat(ii, RG[j])+val*norm[ii];
1144 point[j][3] = values(RG[j]);
1147 DrawPolygonLevelLines(line, point[0], sides, level,
false);
1151 updated_bufs.emplace_back(&line_buf);
1156 int dim = mesh->Dimension();
1157 int i, j, ne = (dim == 3) ? mesh->GetNBE() : mesh->GetNE();
1158 DenseMatrix pointmat;
1159 Array<int> vertices;
1162 displine_buf.clear();
1165 for (i = 0; i < ne; i++)
1167 builder.
glBegin(GL_LINE_LOOP);
1170 mesh->GetBdrPointMatrix (i, pointmat);
1171 mesh->GetBdrElementVertices (i, vertices);
1175 mesh->GetPointMatrix(i, pointmat);
1176 mesh->GetElementVertices(i, vertices);
1179 for (j = 0; j < pointmat.Size(); j++)
1181 pointmat(0, j) += (*solx)(vertices[j])*(ianimd)/
ianimmax;
1182 pointmat(1, j) += (*soly)(vertices[j])*(ianimd)/
ianimmax;
1183 pointmat(2, j) += (*solz)(vertices[j])*(ianimd)/
ianimmax;
1186 for (j = 0; j < pointmat.Size(); j++)
1188 builder.
glVertex3d (pointmat(0, j), pointmat(1, j), pointmat(2, j) );
1192 updated_bufs.emplace_back(&displine_buf);
1196 int nl, Array<double> & level)
1198 static int first_time = 1;
1199 static int nll = nl;
1201 if (!first_time && nll == nl)
1213 double eps = (level[1] - level[0])/2;
1215 for (i = 0; i <= nl; i++)
1220 for (j = 0; j < nv; j++)
1223 for (i = 0; i <= nl; i++)
1225 if (fabs(v-level[i]) < eps)
1230 if (v < level[i] - eps)
1240 double eps = (level[nl] - level[0])/10;
1241 for (
int i = 0; i <= nl; i++)
1243 if (fabs(v-level[i]) < eps)
1247 if (v < level[i] - eps)
1256 int type,
double v0,
double v1,
1257 double v2,
double sx,
double sy,
1258 double sz,
double s)
1260 static int nv = mesh -> GetNV();
1261 static double volume = (bb.x[1]-bb.x[0])*(bb.y[1]-bb.y[0])*(bb.z[1]-bb.z[0]);
1262 static double h = pow(volume/nv, 0.333);
1263 static double hh = pow(volume, 0.333) / 10;
1270 arrow_scaling_type = 0;
1272 Arrow(builder,v0,v1,v2,sx,sy,sz,s);
1279 arrow_scaling_type = 1;
1280 MySetColor(builder, s, minv, maxv);
1281 Arrow(builder,v0,v1,v2,sx,sy,sz,h,0.125);
1288 arrow_scaling_type = 1;
1290 MySetColor(builder, s, minv, maxv);
1291 Arrow(builder,v0,v1,v2,sx,sy,sz,h*s/maxv,0.125);
1299 arrow_scaling_type = 1;
1301 Arrow(builder,v0,v1,v2,sx,sy,sz,hh*s/maxv,0.125);
1309 int i, nv = mesh -> GetNV();
1321 for (i = 0; i < nv; i++)
1324 vertex = mesh->GetVertex(i);
1325 DrawVector(builder, drawvector, vertex[0], vertex[1], vertex[2],
1326 (*solx)(i), (*soly)(i), (*solz)(i), (*sol)(i));
1333 arrow_scaling_type = 1;
1334 for (i = 0; i < nv; i++)
1337 vertex = mesh->GetVertex(i);
1338 DrawVector(builder, drawvector, vertex[0], vertex[1], vertex[2],
1339 (*solx)(i), (*soly)(i), (*solz)(i), (*sol)(i));
1347 arrow_scaling_type = 1;
1349 for (i = 0; i < nv; i++)
1352 vertex = mesh->GetVertex(i);
1353 DrawVector(builder, drawvector, vertex[0], vertex[1], vertex[2],
1354 (*solx)(i), (*soly)(i), (*solz)(i), (*sol)(i));
1361 Array<int> *l =
new Array<int>[nl+1];
1366 for (k = 0; k < vflevel.Size(); k++)
1369 for (j = 0; j < l[i].Size(); j++)
1371 vertex = mesh->GetVertex( l[i][j] );
1372 DrawVector(builder, drawvector, vertex[0], vertex[1], vertex[2],
1373 (*solx)(l[i][j]), (*soly)(l[i][j]), (*solz)(l[i][j]),
1384 int dim = mesh->Dimension();
1385 int j, k, ne = (dim == 3) ? mesh->GetNBE() : mesh->GetNE();
1386 Array<int> vertices;
1387 Array<bool> vert_marker(nv);
1389 vert_marker =
false;
1390 for (k = 0; k < ne; k++)
1394 mesh->GetBdrElementVertices(k, vertices);
1398 mesh->GetElementVertices(k, vertices);
1400 for (j = 0; j < vertices.Size(); j++)
1403 if (vert_marker[i]) {
continue; }
1404 vertex = mesh->GetVertex(i);
1405 DrawVector(builder, drawvector, vertex[0], vertex[1], vertex[2],
1406 (*solx)(i), (*soly)(i), (*solz)(i), (*sol)(i));
1407 vert_marker[i] =
true;
1413 updated_bufs.emplace_back(&vector_buf);
1418 if (cp_drawelems == 0 || cplane != 1 || drawvector == 0 ||
1419 mesh->Dimension() != 3)
1426 int flag[4], ind[6][2]= {{0,3},{0,2},{0,1},{1,2},{1,3},{2,3}};
1427 double t, point[4][4], val[4][3];
1432 DenseMatrix pointmat(3,4);
1436 for (i = 0; i < mesh->GetNE(); i++)
1438 if (mesh->GetElementType(i) != Element::TETRAHEDRON)
1446 mesh -> GetElementVertices(i,nodes);
1447 mesh -> GetPointMatrix (i,pointmat);
1449 if (node_pos[nodes[j]] == 0.0)
1452 coord = mesh -> GetVertex(nodes[j]);
1455 point[n][k] = coord[k];
1458 point[n][3] = (*sol)(nodes[j]);
1459 val[n][0] = (*solx)(nodes[j]);
1460 val[n][1] = (*soly)(nodes[j]);
1461 val[n][2] = (*solz)(nodes[j]);
1464 else if (node_pos[nodes[j]] < 0.)
1474 if (flag[ind[j][0]] != 1 && flag[ind[j][1]] != 1 &&
1475 flag[ind[j][0]] != flag[ind[j][1]])
1477 t = node_pos[ nodes[ind[j][1]] ] / (node_pos[ nodes[ind[j][1]] ] -
1478 node_pos[ nodes[ind[j][0]] ] );
1480 point[n][k] = t*(pointmat(k,ind[j][0]) -
1481 pointmat(k,ind[j][1])) +
1482 pointmat(k,ind[j][1]);
1484 point[n][3] = t * ((*sol)(nodes[ind[j][0]]) -
1485 (*sol)(nodes[ind[j][1]])) +
1486 (*sol)(nodes[ind[j][1]]);
1487 val[n][0] = t * ((*solx)(nodes[ind[j][0]]) -
1488 (*solx)(nodes[ind[j][1]])) +
1489 (*solx)(nodes[ind[j][1]]);
1490 val[n][1] = t * ((*soly)(nodes[ind[j][0]]) -
1491 (*soly)(nodes[ind[j][1]])) +
1492 (*soly)(nodes[ind[j][1]]);
1493 val[n][2] = t * ((*solz)(nodes[ind[j][0]]) -
1494 (*solz)(nodes[ind[j][1]])) +
1495 (*solz)(nodes[ind[j][1]]);
1501 double v10[] = { point[1][0]-point[0][0],
1502 point[1][1]-point[0][1],
1503 point[1][2]-point[0][2]
1505 double v21[] = { point[2][0]-point[1][0],
1506 point[2][1]-point[1][1],
1507 point[2][2]-point[1][2]
1510 double norm[] = { v10[1]*v21[2]-v10[2]*v21[1],
1511 v10[2]*v21[0]-v10[0]*v21[2],
1512 v10[0]*v21[1]-v10[1]*v21[0]
1515 double * eq = CuttingPlane -> Equation();
1517 if ( eq[0]*norm[0]+eq[1]*norm[1]+eq[2]*norm[2] > 0.0 )
1519 if (drawvector != 5)
1524 MySetColor ( builder, point[j][3], maxv, minv);
1526 builder.
glVertex3d (point[j][0],point[j][1],point[j][2]);
1532 DrawVector(builder, drawvector, point[n][0], point[n][1], point[n][2],
1533 val[n][0],val[n][1], val[n][2], point[n][3]);
1537 if (drawvector != 5)
1540 for (j=n-1; j>=0; j--)
1542 MySetColor ( builder, point[j][3], minv, maxv);
1544 builder.
glVertex3d (point[j][0],point[j][1],point[j][2]);
1549 for (j=n-1; j>=0; j--)
1550 DrawVector(builder, drawvector, point[n][0], point[n][1], point[n][2],
1551 val[n][0],val[n][1], val[n][2], point[n][3]);
1555 updated_bufs.emplace_back(&cplane_buf);
1562 Array<double>* cb_level =
nullptr;
1563 if (drawvector == 4)
1565 cb_level = &dvflevel;
1567 else if (drawmesh == 2 || cp_drawmesh >= 2)
1571 PrepareColorBar(minv, maxv, cb_level);
1576 double* cp_eqn = CuttingPlane->Equation();
1577 params.
clip_plane_eqn = {cp_eqn[0], cp_eqn[1], cp_eqn[2], cp_eqn[3]};
1580 if (drawvector == 2 || drawvector == 3)
1582 scene.
queue.emplace_back(params, &vector_buf);
1587 scene.
queue.emplace_back(params, &disp_buf);
1590 if (cplane && cp_drawelems)
1593 scene.
queue.emplace_back(params, &cplane_buf);
1602 scene.
queue.emplace_back(params, &vector_buf);
1608 if (drawvector == 1)
1610 scene.
queue.emplace_back(params, &vector_buf);
1616 scene.
queue.emplace_back(params, &line_buf);
1623 scene.
queue.emplace_back(params, &displine_buf);
1630 scene.
queue.emplace_back(params, &cplines_buf);
void SendExposeEvent()
Send expose event. In our case MyReshape is executed and Draw after it.
thread_local GeometryRefiner GLVisGeometryRefiner
void DrawVector(gl3::GlBuilder &builder, int type, double v0, double v1, double v2, double sx, double sy, double sz, double s)
virtual void PrepareCuttingPlane()
VisualizationSceneVector3d(Mesh &m, Vector &sx, Vector &sy, Vector &sz)
void glVertex3d(double x, double y, double z)
int Normalize(double v[])
thread_local Array< int > cut_TriGeoms
virtual void PrepareCuttingPlane()
thread_local SdlWindow * wnd
void glColor3f(float r, float g, float b)
thread_local IntegrationRule cut_QuadPts
virtual gl3::SceneInfo GetSceneObjs()
virtual void PrepareFlat()
void AddVectorFieldLevel()
virtual void PrepareLines()
thread_local int ianimmax
virtual std::string GetHelpString() const
void glNormal3dv(const double *d)
int Compute3DUnitNormal(const double p1[], const double p2[], const double p3[], double nor[])
void CutReferenceElements(int TimesToRefine, double lambda)
virtual gl3::SceneInfo GetSceneObjs()
int ArrowDrawOrNot(double v, int nl, Array< double > &level)
void PrepareDisplacedMesh()
void glNormal3d(double nx, double ny, double nz)
thread_local Array< int > cut_QuadGeoms
void RemoveIdleFunc(void(*Func)(void))
Crude fixed-function OpenGL emulation helper.
thread_local string extra_caption
void NewMeshAndSolution(Mesh *new_m, GridFunction *new_v)
void ToggleScalarFunction()
thread_local VisualizationSceneVector3d * vsvector3d
thread_local IntegrationRule cut_TriPts
void ArrowsDrawOrNot(Array< int > l[], int nv, Vector &sol, int nl, Array< double > &level)
void glVertex3dv(const double *d)
bool contains_translucent
void RemoveVectorFieldLevel()
virtual ~VisualizationSceneVector3d()
virtual void PrepareVectorField()
std::array< float, 4 > static_color
void setOnKeyDown(int key, Delegate func)
void ToggleVectorFieldLevel(int v)
std::array< double, 4 > clip_plane_eqn
thread_local VisualizationScene * locscene
void ToggleVectorField(int i)