8 #include "GmshConfig.h"
21 #if defined(HAVE_FLTK)
34 glEnable(GL_POLYGON_OFFSET_FILL);
36 if(type == GL_POINTS && opt->
pointType > 0) {
42 #if defined(HAVE_VISUDEV)
52 glPointSize((
float)s);
56 glVertex3d(p[0], p[1], p[2]);
64 else if(type == GL_LINES && opt->
lineType > 0) {
68 double x[2] = {p0[0], p1[0]}, y[2] = {p0[1], p1[1]},
69 z[2] = {p0[2], p1[2]};
72 #if defined(HAVE_VISUDEV)
86 float l = std::sqrt((p0[0] - p1[0]) * (p0[0] - p1[0]) +
87 (p0[1] - p1[1]) * (p0[1] - p1[1]) +
88 (p0[2] - p1[2]) * (p0[2] - p1[2]));
89 #if defined(HAVE_VISUDEV)
97 float dir[3] = {(p1[0] - p0[0]) / l, (p1[1] - p0[1]) / l,
99 printf(
"%g %g %g %g %g %g\n", v0, v1, p0[0], p0[1], p1[0], p1[1]);
100 ctx->
drawVector(1, 0, p0[0] - dir[1] * v0, p0[1] + dir[0] * v0, 0.0,
101 p1[0] - dir[1] * v1, p1[1] + dir[0] * v1, 0.0,
109 glEnable(GL_LINE_STIPPLE);
115 glEnableClientState(GL_VERTEX_ARRAY);
117 glEnable(GL_LIGHTING);
119 glEnableClientState(GL_NORMAL_ARRAY);
122 glDisableClientState(GL_NORMAL_ARRAY);
124 glEnableClientState(GL_COLOR_ARRAY);
126 glDisableClientState(GL_VERTEX_ARRAY);
127 glDisableClientState(GL_NORMAL_ARRAY);
128 glDisableClientState(GL_COLOR_ARRAY);
131 glDisable(GL_LINE_STIPPLE);
137 glDisable(GL_POLYGON_OFFSET_FILL);
138 glDisable(GL_LIGHTING);
150 double lmax = opt->
tmpMax;
154 for(
int j = 0; j < 3; j++) {
156 double l = std::sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
157 double l2 = std::min(1., l / lmax);
158 for(
int k = 0; k < 3; k++) { vv[j][k] = v[k] / l * (
scale * l2 + lmin); }
178 double vv[3] = {v[0], v[1], v[2]};
179 double l = sqrt(vv[0] * vv[0] + vv[1] * vv[1] + vv[2] * vv[2]);
180 double lmax = opt->
tmpMax;
190 double px =
scale * v[0];
191 double py =
scale * v[1];
192 double pz =
scale * v[2];
195 if(opt->
vectorType == 6 || fabs(px) > 1. || fabs(py) > 1. ||
198 double dx = px * d, dy = py * d, dz = pz * d;
199 double x = s[0], y = s[1],
z = s[2];
223 sprintf(label, format, d[0]);
224 else if(numComp == 3) {
226 sprintf(str[0], format, d[0]);
227 sprintf(str[1], format, d[1]);
228 sprintf(str[2], format, d[2]);
229 sprintf(label,
"(%s,%s,%s)", str[0], str[1], str[2]);
231 else if(numComp == 9)
232 sprintf(label, format,
norm);
233 return std::string(label);
237 int numComp,
double **xyz,
double **val)
240 double d[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.};
246 for(
int i = 0; i < numNodes; i++) {
247 pc +=
SPoint3(xyz[i][0], xyz[i][1], xyz[i][2]);
248 for(
int j = 0; j < numComp; j++) d[j] += val[i][j];
250 pc /= (double)numNodes;
251 for(
int j = 0; j < numComp; j++) d[j] /= (
double)numNodes;
253 if(v >= vmin && v <= vmax) {
254 unsigned int col = opt->
getColor(v, vmin, vmax,
false, opt->
nbIso);
255 glColor4ubv((GLubyte *)&col);
258 pc.
x(), pc.
y(), pc.
z());
261 pc.
x(), pc.
y(), pc.
z());
268 for(
int i = 0; i < numNodes; i++) {
270 if(v >= vmin && v <= vmax) {
271 unsigned int col = opt->
getColor(v, vmin, vmax,
false, opt->
nbIso);
272 glColor4ubv((GLubyte *)&col);
276 xyz[i][1], xyz[i][2]);
280 xyz[i][1], xyz[i][2]);
283 xyz[i][0], xyz[i][1], xyz[i][2]);
290 double **xyz,
double **val)
295 for(
int i = 0; i < numNodes; i++)
296 pc +=
SPoint3(xyz[i][0], xyz[i][1], xyz[i][2]);
297 pc /= (double)numNodes;
299 SVector3 t1(xyz[1][0] - xyz[0][0], xyz[1][1] - xyz[0][1],
300 xyz[1][2] - xyz[0][2]);
301 SVector3 t2(xyz[2][0] - xyz[0][0], xyz[2][1] - xyz[0][1],
302 xyz[2][2] - xyz[0][2]);
306 for(
int i = 0; i < 3; i++)
310 n[1], n[2], opt->
light);
314 double **xyz,
double **val)
318 SPoint3 p0(xyz[0][0], xyz[0][1], xyz[0][2]);
319 SPoint3 p1(xyz[1][0], xyz[1][1], xyz[1][2]);
323 for(
int i = 0; i < 3; i++)
327 t[1], t[2], opt->
light);
332 static int numNodesError = 0;
342 Msg::Debug(
"drawing extra glyphs (this is slow...)");
345 #if defined(HAVE_FLTK) && defined(__APPLE__)
350 if(gl_texture_pile_height() < numStrings)
351 gl_texture_pile_height(numStrings);
357 double **xyz =
new double *[NMAX];
358 double **val =
new double *[NMAX];
359 for(
int i = 0; i < NMAX; i++) {
360 xyz[i] =
new double[3];
361 val[i] =
new double[9];
373 if(numNodes > NMAX) {
375 for(
int j = 0; j < NMAX; j++) {
382 xyz =
new double *[NMAX];
383 val =
new double *[NMAX];
384 for(
int j = 0; j < NMAX; j++) {
385 xyz[j] =
new double[3];
386 val[j] =
new double[9];
390 if(numNodesError != numNodes) {
391 numNodesError = numNodes;
393 "Fields with %d nodes per element cannot be displayed: "
394 "either force the field type or select 'Adapt visualization "
395 "grid' if the field is high-order",
401 for(
int j = 0; j < numNodes; j++) {
407 if(comp >= 0 && comp < numComp)
414 for(
int k = 0; k < numComp; k++)
428 for(
int j = 0; j < NMAX; j++) {
477 glColor4ubv((GLubyte *)&opt->
color.
axes);
492 for(
int i = 0; i < 6; i++)
493 if(opt->
clip & (1 << i))
494 glEnable((GLenum)(GL_CLIP_PLANE0 + i));
496 glDisable((GLenum)(GL_CLIP_PLANE0 + i));
502 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
506 glDisable(GL_DEPTH_TEST);
510 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
538 glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
543 if(opt->
lightTwoSide) glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
560 double x, y,
z, style;
569 glEnable(GL_DEPTH_TEST);
572 for(
int i = 0; i < 6; i++) glDisable((GLenum)(GL_CLIP_PLANE0 + i));
595 if(bb.
empty())
return;
604 glColor3d(1., 0., 0.);
605 for(
int i = 0; i < 6; i++)
606 if(opt->
clip & (1 << i))
628 for(std::size_t i = 0; i <
PView::list.size(); i++) {
630 if(changed)
Msg::Debug(
"post-pro vertex arrays have changed");
631 #if defined(HAVE_FLTK) && defined(__APPLE__)
633 if(changed) gl_texture_pile_height(gl_texture_pile_height());