31 double am = fabs(minv);
32 if (am < fabs(maxv)) { am = fabs(maxv); }
33 if (
float(am) < 100*numeric_limits<float>::min()) { am = 1e-3; }
34 if ((maxv-minv) < 1e-5*am)
38 int old_prec = cout.precision(12);
39 cout <<
"[minv,maxv] = " <<
"[" << minv <<
"," << maxv
40 <<
"] (maxv-minv = " << maxv-minv <<
")\n --> ";
41 minv -= 0.49999e-5*am;
42 maxv += 0.50001e-5*am;
43 cout <<
"[" << minv <<
"," << maxv <<
"]" << endl;
44 cout.precision(old_prec);
52 FindNewBoxAndValueRange(prepare);
54 else if (autoscale == 2)
56 FindNewValueRange(prepare);
58 else if (autoscale == 3)
66 if (autoscale == 1 || autoscale == 3)
68 FindNewBoxAndValueRange(prepare);
72 FindNewValueRange(prepare);
80 const double step = 2*M_PI/n;
81 const double nz = (1.0/4.0);
85 glm::mat3 normXfrm = glm::inverseTranspose(glm::mat3(xfrm));
87 glm::vec3 start1vtx = glm::vec3(xfrm * glm::vec4(0, 0, 0, 1));
88 glm::vec3 start1norm = glm::vec3(normXfrm * glm::vec3(0, 0, 1));
89 glm::vec3 start2vtx = glm::vec3(xfrm * glm::vec4(1, 0, -4, 1));
90 glm::vec3 start2norm = glm::vec3(normXfrm * glm::vec3(1, 0, nz));
92 builder.
glBegin(GL_TRIANGLE_FAN);
93 builder.
glNormal3d(start1norm[0], start1norm[1], start1norm[2]);
94 builder.
glVertex3d(start1vtx[0], start1vtx[1], start1vtx[2]);
95 builder.
glNormal3d(start2norm[0], start2norm[1], start2norm[2]);
96 builder.
glVertex3d(start2vtx[0], start2vtx[1], start2vtx[2]);
98 for (i = 1; i < n; i++)
100 glm::vec3 baseVtx = glm::vec3(xfrm * glm::vec4(cos(point), sin(point), -4, 1));
101 glm::vec3 baseNorm = glm::vec3(normXfrm * glm::vec3(cos(point), sin(point),
103 builder.
glNormal3d(baseNorm[0], baseNorm[1], baseNorm[2]);
104 builder.
glVertex3d(baseVtx[0], baseVtx[1], baseVtx[2]);
107 builder.
glNormal3d(start2norm[0], start2norm[1], start2norm[2]);
108 builder.
glVertex3d(start2vtx[0], start2vtx[1], start2vtx[2]);
115 double px,
double py,
double pz,
116 double vx,
double vy,
double vz,
120 double xc = 0.5*(bb.x[0]+bb.x[1]);
121 double yc = 0.5*(bb.y[0]+bb.y[1]);
122 double zc = 0.5*(bb.z[0]+bb.z[1]);
124 xfrm = glm::translate(xfrm, glm::vec3(xc, yc, zc));
125 xfrm = glm::scale(xfrm, glm::vec3(1.0/xscale, 1.0/yscale, 1.0/zscale));
127 double rlen = length/sqrt(vx*vx+vy*vy+vz*vz);
135 if (arrow_scaling_type == 0)
137 length = sqrt(vx*vx+vy*vy+vz*vz);
140 xfrm = glm::translate(xfrm, glm::vec3(px, py, pz));
142 double rhos = sqrt (vx*vx+vy*vy+vz*vz);
143 float phi = acos(vz/rhos);
145 theta = atan2 (vy, vx);
147 xfrm = glm::rotate(xfrm, theta, glm::vec3(0, 0, 1));
148 xfrm = glm::rotate(xfrm, phi, glm::vec3(0, 1, 0));
150 xfrm = glm::scale(xfrm, glm::vec3(length));
155 xfrm = glm::translate(xfrm, glm::vec3(0, 0, -0.5));
158 glm::vec4 pt1 = xfrm * glm::vec4(0, 0, 0, 1);
159 glm::vec4 pt2 = xfrm * glm::vec4(0, 0, 1, 1);
166 xfrm = glm::translate(xfrm, glm::vec3(0, 0, 1));
167 xfrm = glm::scale(xfrm, glm::vec3(cone_scale));
173 double px,
double py,
double pz,
174 double vx,
double vy,
double vz,
179 xfrm = glm::translate(xfrm, glm::vec3(px, py, pz));
181 double rhos = sqrt (vx*vx+vy*vy+vz*vz);
182 float phi = acos(vz/rhos);
184 theta = atan2 (vy, vx);
186 xfrm = glm::rotate(xfrm, theta, glm::vec3(0, 0, 1));
187 xfrm = glm::rotate(xfrm, phi, glm::vec3(0, 1, 0));
189 xfrm = glm::scale(xfrm, glm::vec3(length));
191 glm::vec4 pt1 = xfrm * glm::vec4(0, 0, 0, 1);
192 glm::vec4 pt2 = xfrm * glm::vec4(0, 0, 1, 1);
199 xfrm = glm::translate(xfrm, glm::vec3(0, 0, 1));
200 xfrm = glm::scale(xfrm, glm::vec3(cone_scale));
206 double px,
double py,
double pz,
207 double vx,
double vy,
double vz,
211 double rhos = sqrt (vx*vx+vy*vy+vz*vz);
216 double phi = acos(vz/rhos), theta = atan2(vy, vx);
218 const double step = 2*M_PI/n, nz = (1.0/4.0);
219 double point = step, cone[n+4][3], normal[n+2][3];
222 cone[0][0] = 0; cone[0][1] = 0; cone[0][2] = 1;
223 cone[1][0] = cone_scale; cone[1][1] = 0; cone[1][2] = -4*cone_scale + 1;
224 normal[0][0] = 0.0/cone_scale;
225 normal[0][1] = 0.0/cone_scale;
226 normal[0][2] = 1.0/cone_scale;
227 normal[1][0] = 1.0/cone_scale;
228 normal[1][1] = 0.0/cone_scale;
229 normal[1][2] = nz/cone_scale;
231 for (i=2; i<n+1; i++)
233 normal[i][0] = cos(point)/cone_scale;
234 normal[i][1] = sin(point)/cone_scale;
235 normal[i][2] = nz/cone_scale;
237 cone[i][0] = cos(point)*cone_scale;
238 cone[i][1] = sin(point)*cone_scale;
239 cone[i][2] = -4*cone_scale + 1;
242 cone[n+1][0] = cone_scale; cone[n+1][1] = 0; cone[n+1][2] =-4*cone_scale + 1;
243 normal[n+1][0] = 1.0/cone_scale;
244 normal[n+1][1] = 0.0/cone_scale;
245 normal[n+1][2] = nz/cone_scale;
247 cone[n+2][0] = 0; cone[n+2][1] = 0; cone[n+2][2] = 0;
248 cone[n+3][0] = 0; cone[n+3][1] = 0; cone[n+3][2] = 1;
250 if (arrow_scaling_type == 0)
263 for (i=0; i<n+4; i++)
268 double M[3][3]= {{cos(theta)*cos(phi), -sin(theta), cos(theta)*sin(phi)},
269 {sin(theta)*cos(phi), cos(theta), sin(theta)*sin(phi)},
270 { -sin(phi), 0., cos(phi)}
272 double v[3] = { M[0][2]/xscale, M[1][2]/yscale, M[2][2]/zscale };
273 length /= sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);
275 for (i=0; i<n+4; i++)
279 coord[j] = cone[i][j] * length;
287 cone[i][k] += M[k][j] * coord[j];
293 cone[i][0] = cone[i][0]/xscale + px;
294 cone[i][1] = cone[i][1]/yscale + py;
295 cone[i][2] = cone[i][2]/zscale + pz;
298 for (i=0; i<=n+1; i++)
302 coord[j] = normal[i][j];
310 normal[i][k] += M[k][j] * coord[j];
313 normal[i][0] *= xscale;
314 normal[i][1] *= yscale;
315 normal[i][2] *= zscale;
318 builder.
glBegin(GL_TRIANGLE_FAN);
319 for (i=0; i<=n+1; i++)
335 Array<double> *mesh_level,
336 Array<double> *lsurf_levels)
347 if (OrthogonalProjection)
363 {{minx, miny, posz},{0.f, 0.f}},
364 {{maxx, miny, posz},{0.f, 0.f}},
365 {{maxx, maxy, posz},{1.f, 0.f}},
366 {{minx, maxy, posz},{1.f, 0.f}}
369 static const int border = 2;
375 {minx, miny, posz}, {maxx, miny, posz},
376 {maxx, miny, posz}, {maxx, maxy, posz},
377 {maxx, maxy, posz}, {minx, maxy, posz},
378 {minx, maxy, posz}, {minx, miny, posz}
381 else if (border == 2)
383 color_bar.addLine<
gl3::Vertex>({minx, miny, posz}, {minx, maxy, posz});
384 color_bar.addLine<
gl3::Vertex>({maxx, miny, posz}, {maxx, maxy, posz});
389 for (i = 0; i < lsurf_levels->Size(); i++)
391 float Y = miny + (maxy - miny) * LogUVal((*lsurf_levels)[i]);
392 color_bar.addLine<
gl3::Vertex>({minx, Y, posz}, {maxx, Y, posz});
397 for (i = 0; i < mesh_level->Size(); i++)
399 float Y = miny + (maxy - miny) * LogUVal((*mesh_level)[i]);
400 color_bar.addLine<
gl3::Vertex>({minx, Y, posz}, {maxx, Y, posz});
404 const double text_x = maxx + 0.4*(maxx-minx);
409 for (i = 0; i <= 4; i++)
411 Y = miny + i * (maxy-miny) / 4;
413 val = ULogVal(i / 4.0);
416 buf << setprecision(4) << val;
417 color_bar.addText(text_x,Y,posz, buf.str());
422 for (i = 0; i < mesh_level->Size(); i++)
424 val = (*mesh_level)[i];
425 Y = miny + (maxy - miny) * LogUVal(val);
428 buf << setprecision(4) << val;
429 color_bar.addText(text_x,Y,posz, buf.str());
435 for (i = 0; i < lsurf_levels->Size(); i++)
437 val = (*lsurf_levels)[i];
438 Y = miny + (maxy - miny) * LogUVal(val);
441 buf << setprecision(4) << val;
442 color_bar.addText(text_x,Y,posz, buf.str());
445 updated_bufs.emplace_back(&color_bar);
452 colorbar = (colorbar ? empty+1 : !empty);
461 caption_buf.addText(0, 0, 0, caption);
462 updated_bufs.emplace_back(&caption_buf);
477 cout <<
"Enter new caption: " << flush;
485 vsdata -> ToggleScaling();
491 vsdata -> ToggleDrawAxes();
497 if (state & KMOD_CTRL)
499 static const char *autoscale_modes[] = {
"off",
"on",
"value",
"mesh" };
501 autoscale = (autoscale + 1)%4;
502 cout <<
"Autoscale: " << flush;
504 cout << autoscale_modes[autoscale] << endl;
542 vsdata -> key_r_state = 0;
556 if (state & KMOD_CTRL)
573 static void KeyF5Pressed()
578 cout <<
"Enter min : " << flush;
580 cout <<
"Enter max : " << flush;
582 cout <<
"Enter n : " << flush;
585 vsdata -> SetLevelLines (min, max, n, 0);
587 vsdata -> UpdateLevelLines();
594 cout <<
"Palette is repeated " << RepeatPaletteTimes <<
" times.\n"
595 <<
"(Negative value means the palette is flipped.)\n"
596 <<
"Enter new value: " << flush;
597 cin >> RepeatPaletteTimes;
598 if (RepeatPaletteTimes == 0)
600 RepeatPaletteTimes = 1;
602 cout <<
"Palette will be repeated " << RepeatPaletteTimes
603 <<
" times now.\n\n";
610 cout <<
"\nPalette is using " << colors_used <<
" colors.\n"
611 <<
"Enter new value (0 = use original " << palette_size
612 <<
" colors): " << flush;
614 if (colors_used == 1) { colors_used = 0; }
621 cout <<
"Palette will be using " << colors_used <<
" colors now.\n";
629 if (state & KMOD_SHIFT)
631 cout <<
"Current bounding box:\n"
636 <<
"Enter new bounding box:\n"
637 <<
"x_min = " << flush;
639 cout <<
"y_min = " << flush;
641 cout <<
"z_min = " << flush;
643 cout <<
"x_max = " << flush;
645 cout <<
"y_max = " << flush;
647 cout <<
"z_max = " << flush;
649 cout <<
"New bounding box:\n"
661 <<
"New value for minv: " << flush;
663 cout <<
"New value for maxv: " << flush;
674 cout <<
"Enter light source position\n(0,0,1,w) - from camera\n"
675 "(0,1,0,w) - from above\n(1,0,0,w) - from the right\n"
676 "w = 0/1 defines directional/spot light\n";
677 cout <<
"x = " << flush;
679 cout <<
"y = " << flush;
681 cout <<
"z = " << flush;
683 cout <<
"w = " << flush;
697 cout <<
"New material/light : " << ml << endl;
720 vsdata -> EventUpdateColors();
753 cout <<
"Multisampling/Antialiasing: "
804 cout <<
"The range [" << minv <<
',' << maxv
805 <<
"] is not appropriate for logarithmic scale!" << endl;
813 if (logscale || LogscaleRange())
815 logscale = !logscale;
816 palette.SetUseLogscale(logscale);
818 SetLevelLines(minv, maxv, nl);
823 PrintLogscale(
false);
835 ruler_on = (ruler_on + 1) % 3;
841 cout <<
"Current ruler position: (" << ruler_x <<
','
842 << ruler_y <<
',' << ruler_z <<
")\n";
843 cout <<
"x = " << flush; cin >> ruler_x;
844 cout <<
"y = " << flush; cin >> ruler_y;
845 cout <<
"z = " << flush; cin >> ruler_z;
846 if (ruler_x < bb.x[0])
850 else if (ruler_x > bb.x[1])
854 if (ruler_y < bb.y[0])
858 else if (ruler_y > bb.y[1])
862 if (ruler_z < bb.z[0])
866 else if (ruler_z > bb.z[1])
870 cout <<
"New ruler position: (" << ruler_x <<
','
871 << ruler_y <<
',' << ruler_z <<
")" << endl;
877 float pos_z = LogVal(ruler_z, log_z);
878 float x_f[2] = {(float) bb.x[0], (
float) bb.x[1]};
879 float y_f[2] = {(float) bb.y[0], (
float) bb.y[1]};
880 float z_f[2] = {(float) bb.z[0], (
float) bb.z[1]};
881 float ruler_x_f = (float) ruler_x,
882 ruler_y_f = (
float) ruler_y;
886 std::array<uint8_t, 4> color =
gl3::ColorU8(0.8, 0.8, 0.8, 1.0);
887 std::array<float, 3> norm = { 0, 0, 1 };
889 {{x_f[0], y_f[0], pos_z},norm,color},
890 {{x_f[1], y_f[0], pos_z},norm,color},
891 {{x_f[1], y_f[1], pos_z},norm,color},
892 {{x_f[0], y_f[1], pos_z},norm,color}
895 std::array<float, 3> norm_2 = { 0, 1, 0 };
897 {{x_f[0], ruler_y_f, z_f[0]},norm_2,color},
898 {{x_f[0], ruler_y_f, z_f[1]},norm_2,color},
899 {{x_f[1], ruler_y_f, z_f[1]},norm_2,color},
900 {{x_f[1], ruler_y_f, z_f[0]},norm_2,color}
903 std::array<float, 3> norm_3 = { 1, 0, 0 };
905 {{ruler_x_f, y_f[0], z_f[0]},norm_3,color},
906 {{ruler_x_f, y_f[1], z_f[0]},norm_3,color},
907 {{ruler_x_f, y_f[1], z_f[1]},norm_3,color},
908 {{ruler_x_f, y_f[0], z_f[1]},norm_3,color}
913 {x_f[0], y_f[0], pos_z}, {x_f[1], y_f[0], pos_z},
914 {x_f[1], y_f[0], pos_z}, {x_f[1], y_f[1], pos_z},
915 {x_f[1], y_f[1], pos_z}, {x_f[0], y_f[1], pos_z},
916 {x_f[0], y_f[1], pos_z}, {x_f[0], y_f[0], pos_z},
918 {x_f[0], ruler_y_f, z_f[0]}, {x_f[1], ruler_y_f, z_f[0]},
919 {x_f[1], ruler_y_f, z_f[0]}, {x_f[1], ruler_y_f, z_f[1]},
920 {x_f[1], ruler_y_f, z_f[1]}, {x_f[0], ruler_y_f, z_f[1]},
921 {x_f[0], ruler_y_f, z_f[1]}, {x_f[0], ruler_y_f, z_f[0]},
923 {ruler_x_f, y_f[0], z_f[0]}, {ruler_x_f, y_f[1], z_f[0]},
924 {ruler_x_f, y_f[1], z_f[0]}, {ruler_x_f, y_f[1], z_f[1]},
925 {ruler_x_f, y_f[1], z_f[1]}, {ruler_x_f, y_f[0], z_f[1]},
926 {ruler_x_f, y_f[0], z_f[1]}, {ruler_x_f, y_f[0], z_f[0]}
932 {x_f[0], ruler_y_f, pos_z},
933 {x_f[1], ruler_y_f, pos_z},
934 {ruler_x_f, y_f[0], pos_z},
935 {ruler_x_f, y_f[1], pos_z},
936 {ruler_x_f, ruler_y_f, z_f[0]},
937 {ruler_x_f, ruler_y_f, z_f[1]}
940 updated_bufs.emplace_back(&ruler_buf);
947 translmat = newrot.
mtx;
955 newrot.
rotate(-90.0, 1.0f, 0.0f, 0.0f);
959 newrot.
rotate(-90.0, 1.0f, 0.0f, 0.0f);
960 newrot.
rotate(-90.0, 0.0f, 0.0f, 1.0f);
964 newrot.
rotate(-90.0, 1.0f, 0.0f, 0.0f);
965 newrot.
rotate(-180.0, 0.0f, 0.0f, 1.0f);
969 newrot.
rotate(-90.0, 1.0f, 0.0f, 0.0f);
970 newrot.
rotate(-270.0, 0.0f, 0.0f, 1.0f);
974 newrot.
rotate(180.0, 1.0f, 0.0f, 0.0f);
979 key_r_state = (key_r_state+1)%6;
990 updated_bufs.clear();
994 params.projection.identity();
995 params.mesh_material = BLK_MAT;
996 params.num_pt_lights = 0;
997 params.static_color = this->GetLineColor();
998 params.use_clip_plane =
false;
999 params.contains_translucent =
false;
1004 params.projection.mtx = proj_mtx;
1005 scene.queue.emplace_back(params, &color_bar);
1006 params.projection.identity();
1017 params.model_view.translate(-(
double)caption_w / gl_w,
1018 1.0 - 2 * v_pos * line_h / gl_h, 0.0);
1019 scene.queue.emplace_back(params, &caption_buf);
1021 params.contains_translucent =
true;
1022 if (drawaxes && drawaxes != 3)
1025 params.projection.ortho(-1.,1.,-1.,1.,-2.,2.);
1026 params.model_view.identity();
1027 params.model_view.translate(-1, -1, 0.0);
1028 params.model_view.scale(40.0 / w, 40.0 / h, 1);
1029 params.model_view.translate(2.0, 2.0, 0.0);
1030 params.model_view.mult(cam.RotMatrix());
1031 params.model_view.mult(rotmat);
1032 scene.queue.emplace_back(params, &coord_cross_buf);
1034 params.projection.mtx = proj_mtx;
1035 params.model_view.mtx = GetModelViewMtx();
1039 scene.queue.emplace_back(params, &axes_buf);
1041 params.contains_translucent =
false;
1045 params = GetMeshDrawParams();
1046 params.use_clip_plane =
false;
1047 params.contains_translucent =
false;
1048 scene.queue.emplace_back(params, &ruler_buf);
1060 auto box_node = AddModelNode(bld,
"Box");
1061 auto box_mesh = bld.
addMesh(
"Box Mesh");
1064 int nlines = AddLines(
1068 (drawaxes != 3) ? black_mat : white_mat,
1072 cout <<
"glTF export: no box found to export!" << endl;
1082 auto elements_node = AddModelNode(bld,
"Elements");
1083 auto elements_mesh = bld.
addMesh(
"Elements Mesh");
1086 int ntria = AddTriangles(
1094 cout <<
"glTF export: no elements found to export!" << endl;
1104 auto lines_node = AddModelNode(bld,
"Lines");
1105 auto lines_mesh = bld.
addMesh(
"Lines Mesh");
1108 int nlines = AddLines(
1116 cout <<
"glTF export: no mesh/level lines found to export!" << endl;
1122 cout <<
"glTF export is not yet implemented for this visualization mode."
1128 int isSmooth = palette.GetSmoothSetting();
1131 palette.UseDiscrete();
1132 cout <<
"Texture type : discrete" << endl;
1136 palette.UseSmooth();
1137 cout <<
"Texture type : smooth" << endl;
1143 if (autoscale != _autoscale)
1145 autoscale = _autoscale;
1151 Mesh & m, Vector & s)
1152 : a_label_x(
"x"), a_label_y(
"y"), a_label_z(
"z")
1243 glDisable(GL_MULTISAMPLE);
1411 buf << setprecision(4)
1412 <<
"(" <<
bb.x[0] <<
"," <<
bb.y[0] <<
"," <<
bb.z[0] <<
")" ;
1416 buf1 << setprecision(4)
1417 <<
"(" <<
bb.x[1] <<
"," <<
bb.y[1] <<
"," <<
bb.z[1] <<
")" ;
1422 constexpr
float len = 1.2f;
1423 constexpr
float l = .9f, cl = .27f, cb = l-cl;
1427 {0, 0, 0}, {0, 0, l},
1428 {0, 0, 0}, {0, l, 0},
1429 {0, 0, 0}, {l, 0, 0}
1441 gl3::GlBuilder& builder,
double * point,
int n, Array<double> &mesh_level,
1448 for (l = 0; l < mesh_level.Size(); l++)
1453 builder.
glBegin(GL_LINE_LOOP);
1454 curve =
LogVal(mesh_level[l], log_vals);
1455 for (k = 0; k < n; k++)
1458 if ( (curve <=point[4*k+3] && curve >= point[4*k1+3]) ||
1459 (curve >=point[4*k+3] && curve <= point[4*k1+3]) )
1461 if ((curve - point[4*k1+3]) == 0.)
1465 else if ((curve - point[4*k+3]) == 0.)
1471 t = (curve - point[4*k+3]) / (point[4*k1+3]-point[4*k+3]);
1473 p[0] = (1.0-t)*point[4*k+0]+t*point[4*k1+0];
1474 p[1] = (1.0-t)*point[4*k+1]+t*point[4*k1+1];
1475 p[2] = (1.0-t)*point[4*k+2]+t*point[4*k1+2];
1484 double min,
double max,
int n,
int adj)
1492 cout <<
"min set to minv : " << min << endl;
1497 cout <<
"max set to maxv : " << max << endl;
1502 for (i = 0; i <=
nl; i++)
1504 t = (double) i /
nl;
1505 level[i] = min * (1.0 - t) + t * max;
1512 level[
nl] = level[
nl] * (1.0 - eps) + level[
nl-1] * eps;
1517 for (i = 0; i <=
nl; i++)
1531 tan(M_PI / 8.) / tan(
ViewAngle * (M_PI / 360.0)))
1532 <<
"\nvaluerange " <<
minv <<
' ' <<
maxv;
1533 const float *r = glm::value_ptr(
rotmat);
1534 ios::fmtflags fmt = cout.flags();
1535 cout << fixed << showpos
1536 <<
"\nrotmat " << r[ 0] <<
' ' << r[ 1] <<
' ' << r[ 2] <<
' ' << r[ 3]
1537 <<
"\n " << r[ 4] <<
' ' << r[ 5] <<
' ' << r[ 6] <<
' ' << r[ 7]
1538 <<
"\n " << r[ 8] <<
' ' << r[ 9] <<
' ' << r[10] <<
' ' << r[11]
1539 <<
"\n " << r[12] <<
' ' << r[13] <<
' ' << r[14] <<
' ' << r[15]
1543 mesh->PrintInfo(cout);
1547 int i,
int fn,
int di)
1549 int dim =
mesh->Dimension();
1550 int sdim =
mesh->SpaceDimension();
1558 for (d = 0; d < sdim; d++)
1561 for (k = 0; k < pointmat.Width(); k++)
1563 cd += pointmat(d,k);
1565 cd /= pointmat.Width();
1567 for (k = 0; k < pointmat.Width(); k++)
1575 int attr =
mesh->GetBdrAttribute(i);
1576 for (
int k = 0; k < pointmat.Width(); k++)
1577 for (
int d = 0; d < sdim; d++)
1586 int attr, elem1, elem2;
1587 if (dim == 2 || sdim == 2)
1589 attr =
mesh->GetAttribute(i);
1593 mesh->GetFaceElements(fn, &elem1, &elem2);
1596 attr =
mesh->GetAttribute(elem1);
1600 attr =
mesh->GetAttribute(elem2);
1604 for (
int k = 0; k < pointmat.Width(); k++)
1605 for (
int d = 0; d < pointmat.Height(); d++)
1614 DenseMatrix pointmat;
1615 Vector nbdrc(
mesh->bdr_attributes.Max());
1616 int sdim =
mesh->SpaceDimension();
1618 bdrc.SetSize(sdim,
mesh->bdr_attributes.Max());
1622 for (
int i = 0; i <
mesh -> GetNBE(); i++)
1624 mesh->GetBdrPointMatrix(i, pointmat);
1625 nbdrc(
mesh->GetBdrAttribute(i)-1) += pointmat.Width();
1626 for (
int k = 0; k < pointmat.Width(); k++)
1627 for (
int d = 0; d < sdim; d++)
1629 bdrc(d,
mesh->GetBdrAttribute(i)-1) += pointmat(d,k);
1633 for (
int i = 0; i <
mesh->bdr_attributes.Max(); i++)
1635 for (
int d = 0; d < sdim; d++)
1637 bdrc(d,i) /= nbdrc(i);
1643 DenseMatrix pointmat;
1644 Vector nmatc(
mesh->attributes.Max());
1645 int sdim =
mesh->SpaceDimension();
1647 matc.SetSize(sdim,
mesh->attributes.Max());
1651 for (
int i = 0; i <
mesh -> GetNE(); i++)
1653 mesh->GetPointMatrix(i, pointmat);
1654 nmatc(
mesh->GetAttribute(i)-1) += pointmat.Width();
1655 for (
int k = 0; k < pointmat.Width(); k++)
1656 for (
int d = 0; d < sdim; d++)
1658 matc(d,
mesh->GetAttribute(i)-1) += pointmat(d,k);
1662 for (
int i = 0; i <
mesh->attributes.Max(); i++)
1664 for (
int d = 0; d < sdim; d++)
1666 matc(d,i) /= nmatc(i);
1678 CartesianToSpherical();
1683 bbox_diam = sqrt ( (x[1]-x[0])*(x[1]-x[0]) +
1684 (y[1]-y[0])*(y[1]-y[0]) +
1685 (z[1]-z[0])*(z[1]-z[0]) );
1687 x0 = (x[0]+x[1])/2.0;
1688 y0 = (y[0]+y[1])/2.0;
1689 z0 = (z[0]+z[1])/2.0;
1691 phi_step = M_PI / 36;
1692 theta_step = M_PI / 36;
1693 rho_step = bbox_diam / 200;
1696 void Plane::CartesianToSpherical()
1698 rho = sqrt(eqn[0]*eqn[0]+eqn[1]*eqn[1]+eqn[2]*eqn[2]);
1699 phi = asin(eqn[2]/rho);
1700 theta = atan2(eqn[1], eqn[0]);
1703 void Plane::SphericalToCartesian()
1705 eqn[0] = rho * cos(phi) * cos(theta);
1706 eqn[1] = rho * cos(phi) * sin(theta);
1707 eqn[2] = rho * sin(phi);
1708 eqn[3] = - (eqn[0] * x0 + eqn[1] * y0 + eqn[2] * z0);
1714 SphericalToCartesian();
1720 SphericalToCartesian();
1725 theta += theta_step;
1726 SphericalToCartesian();
1731 theta -= theta_step;
1732 SphericalToCartesian();
1737 double k = (rho_step) / (rho*rho);
1742 CartesianToSpherical();
1747 double k = (rho_step) / (rho*rho);
1752 CartesianToSpherical();
void SendExposeEvent()
Send expose event. In our case MyReshape is executed and Draw after it.
void identity()
Sets the matrix to the identity matrix.
void addLines(const std::vector< Vert > &verts)
void SetValueRange(double, double)
void ShrinkPoints(DenseMatrix &pointmat, int i, int fn, int di)
Shrink the set of points towards attributes centers of gravity.
struct VisualizationScene::@3 bb
Bounding box.
thread_local VisualizationSceneScalarData * vsdata
void glVertex3d(double x, double y, double z)
int Normalize(double v[])
void getGLDrawSize(int &w, int &h)
float getFontLineSpacing() const
int GetSize(int pal=-1) const
Gets the total number of colors in the current palette color array.
int GetNumColors(int pal=-1) const
Gets the number of colors used in the current palette color array.
thread_local SdlWindow * wnd
void PrepareColorBar(double minval, double maxval, Array< double > *level=NULL, Array< double > *levels=NULL)
void glColor3f(float r, float g, float b)
gl3::MeshRenderer & getRenderer()
virtual void ToggleLogscale(bool print)
virtual gl3::SceneInfo GetSceneObjs()
gl3::GlDrawable coord_cross_buf
double LogVal(const double &z, const bool &log_val)
virtual std::string GetHelpString() const
Plane(double A, double B, double C, double D)
void ComputeBdrAttrCenter()
Compute the center of gravity for each boundary attribute.
void glNormal3dv(const double *d)
float getFontDescender() const
std::array< uint8_t, 4 > ColorU8(float rgba[])
void DrawPolygonLevelLines(gl3::GlBuilder &builder, double *point, int n, Array< double > &level, bool log_vals)
void addText(float x, float y, float z, const std::string &text)
Adds a string at the given position in object coordinates.
void SetRepeatTimes(int rpt)
void PrintLogscale(bool warn)
virtual void EventUpdateColors()
void Arrow(gl3::GlBuilder &builder, double px, double py, double pz, double vx, double vy, double vz, double length, double cone_scale=0.075)
thread_local string plot_caption
int GetRepeatTimes() const
virtual void FindNewBox(bool prepare)=0
void getWindowSize(int &w, int &h)
double shrinkmat
Shrink factor with respect to the element (material) attributes centers.
double _ULogVal(const double &u)
void SetLevelLines(double min, double max, int n, int adj=1)
void addCone(float x, float y, float z, float vx, float vy, float vz, float cone_scale=0.075)
void glNormal3d(double nx, double ny, double nz)
virtual void EventUpdateBackground()
void SetLight0CustomPos(std::array< float, 4 > pos)
void Arrow2(gl3::GlBuilder &builder, double px, double py, double pz, double vx, double vy, double vz, double length, double cone_scale=0.075)
GlBuilder createBuilder()
virtual void glTF_Export()
void SetIndex(int num)
Sets the palette texture to bind.
void RemoveIdleFunc(void(*Func)(void))
mesh_id addMesh(const std::string &meshName)
virtual void PrintState()
std::string getSavedKeys() const
Returns the keyboard events that have been logged by the window.
void ToggleDrawColorbar()
void glTF_ExportElements(glTF_Builder &bld, glTF_Builder::buffer_id buffer, glTF_Builder::material_id palette_mat, const gl3::GlDrawable &gl_drawable)
void rotate(float angle, double x, double y, double z)
Applies a rotation transform to the matrix.
vector< gl3::GlDrawable * > updated_bufs
VisualizationSceneScalarData()
void Arrow3(gl3::GlBuilder &builder, double px, double py, double pz, double vx, double vy, double vz, double length, double cone_scale=0.075)
void Key_Mod_a_Pressed(GLenum state)
int auto_ref_max_surf_elem
void SetLightMatIdx(unsigned i)
SdlWindow * GetAppWindow()
Crude fixed-function OpenGL emulation helper.
void Init()
Initializes the palette textures.
void GenerateAlphaTexture()
thread_local string extra_caption
static constexpr unsigned INVALID_ID
void SetNumColors(int numColors)
Sets the number of colors to use in the current palette color array.
void addNodeMesh(node_id node, mesh_id mesh)
void getObjectSize(const std::string &text, int &w, int &h)
Get the width and height of the bounding box containing the rendered text.
void glTF_ExportBox(glTF_Builder &bld, glTF_Builder::buffer_id buffer, glTF_Builder::material_id black_mat)
void KeyF7Pressed(GLenum state)
void SetAutoscale(int _autoscale)
void glTF_ExportMesh(glTF_Builder &bld, glTF_Builder::buffer_id buffer, glTF_Builder::material_id black_mat, const gl3::GlDrawable &gl_drawable)
void DoAutoscaleValue(bool prepare)
void glVertex3dv(const double *d)
vector< GlDrawable * > needs_buffering
virtual void SetNewScalingFromBox()
const char * strings_off_on[]
void clear()
Clears the drawable object.
virtual void UpdateValueRange(bool prepare)=0
void setOnKeyDown(int key, Delegate func)
void SetAxisLabels(const char *a_x, const char *a_y, const char *a_z)
virtual void PrepareRuler()
void ComputeElemAttrCenter()
Compute the center of gravity for each element attribute.
virtual ~VisualizationSceneScalarData()
void KeyBackslashPressed()
void setAntialiasing(bool aa_status)
thread_local VisualizationScene * locscene
void KeypPressed(GLenum state)
void DoAutoscale(bool prepare)
void Cone(gl3::GlBuilder &builder, glm::mat4 transform)