27 #if defined(HAVE_CONFIG_H)
31 #include "wx/glcanvas.h"
32 #if defined(HAVE_GL_GL_H)
34 #elif defined(HAVE_OPENGL_GL_H)
35 #include <OpenGL/gl.h>
51 int ib, a0, a1, a2, ia;
59 for (ia = 0; ia < 3; ia++) kshift[ia] =
bvec[0][ia] * a0 +
bvec[1][ia] * a1 +
bvec[2][ia] * a2;
60 #pragma omp parallel default(none) \
61 shared(nb,draw_band,ntri,rot,nmlp,arw,nmlp_rot,kvp,kvp_rot,arw_rot,trans,side,kshift) \
66 for (ib = 0; ib <
nb; ib++) {
68 #pragma omp for nowait
69 for (itri = 0; itri <
ntri[ib]; ++itri) {
70 for (i = 0; i < 3; ++i) {
71 for (j = 0; j < 3; ++j) {
72 kvp_rot[ib][j + 3 * i + 9 * itri]
73 =
rot[j][0] * (
kvp[ib][itri][i][0] + kshift[0])
74 +
rot[j][1] * (
kvp[ib][itri][i][1] + kshift[1])
75 +
rot[j][2] * (
kvp[ib][itri][i][2] + kshift[2])
78 =
rot[j][0] *
nmlp[ib][itri][i][0]
79 +
rot[j][1] *
nmlp[ib][itri][i][1]
80 +
rot[j][2] *
nmlp[ib][itri][i][2];
82 for (l = 0; l < 2; ++l) {
83 arw_rot[ib][j + 3 * l + 6 * i + 18 * itri]
84 =
rot[j][0] * (
arw[ib][itri][i][l][0] + kshift[0])
85 +
rot[j][1] * (
arw[ib][itri][i][l][1] + kshift[1])
86 +
rot[j][2] * (
arw[ib][itri][i][l][2] + kshift[2])
98 glEnableClientState(GL_NORMAL_ARRAY);
99 glEnableClientState(GL_COLOR_ARRAY);
100 for (ib = 0; ib <
nb; ib++) {
102 glVertexPointer(3, GL_FLOAT, 0,
kvp_rot[ib]);
103 glNormalPointer(GL_FLOAT, 0,
nmlp_rot[ib]);
104 glColorPointer(4, GL_FLOAT, 0,
clr[ib]);
105 glDrawArrays(GL_TRIANGLES, 0,
ntri[ib] * 3);
108 glDisableClientState(GL_NORMAL_ARRAY);
109 glDisableClientState(GL_COLOR_ARRAY);
113 glNormal3f(0.0f, 0.0f, 1.0f);
115 for (ib = 0; ib <
nb; ib++) {
117 glColor3f(1.0 -
clr[ib][0], 1.0 -
clr[ib][1], 1.0 -
clr[ib][2]);
118 glVertexPointer(3, GL_FLOAT, 0,
arw_rot[ib]);
119 glDrawArrays(GL_LINES, 0,
ntri[ib] * 3 * 2);
130 #pragma omp parallel default(none) \
131 shared(nb,draw_band,nnl,rot,trans,kvnl,kvnl_rot,kshift) \
136 for (ib = 0; ib <
nb; ib++) {
139 #pragma omp for nowait
140 for (itri = 0; itri <
nnl[ib]; ++itri) {
141 for (i = 0; i < 2; ++i) {
143 for (j = 0; j < 3; ++j)
145 =
rot[j][0] * (
kvnl[ib][itri][i][0] + kshift[0])
146 +
rot[j][1] * (
kvnl[ib][itri][i][1] + kshift[1])
147 +
rot[j][2] * (
kvnl[ib][itri][i][2] + kshift[2])
149 kvnl_rot[ib][2 + 3 * i + 6 * itri] += 0.001f;
159 glNormal3f(0.0f, 0.0f, 1.0f);
160 for (ib = 0; ib <
nb; ib++) {
162 glVertexPointer(3, GL_FLOAT, 0,
kvnl_rot[ib]);
163 glDrawArrays(GL_LINES, 0, 2 *
nnl[ib]);
174 #pragma omp parallel default(none) \
175 shared(nb,draw_band,nequator,rot,trans,kveq,kveq_rot,kshift) \
180 for (ib = 0; ib <
nb; ib++) {
183 #pragma omp for nowait
184 for (itri = 0; itri <
nequator[ib]; ++itri) {
185 for (i = 0; i < 2; ++i) {
187 for (j = 0; j < 3; ++j)
189 =
rot[j][0] * (
kveq[ib][itri][i][0] + kshift[0])
190 +
rot[j][1] * (
kveq[ib][itri][i][1] + kshift[1])
191 +
rot[j][2] * (
kveq[ib][itri][i][2] + kshift[2])
193 kveq_rot[ib][2 + 3 * i + 6 * itri] += 0.001f;
203 glNormal3f(0.0f, 0.0f, 1.0f);
204 for (ib = 0; ib <
nb; ib++) {
206 glVertexPointer(3, GL_FLOAT, 0,
kveq_rot[ib]);
207 glDrawArrays(GL_LINES, 0, 2 *
nequator[ib]);
219 int ibzl, i, j, a0, a1, a2, ia, icount;
220 GLfloat bzl2[3], bvec2[3][3], linecolor[4], secvec2[3], kshift[3], arrow_c[3];
221 GLfloat vertices[300], sphere_v2[1140];
225 for (i = 0; i < 4; i++) linecolor[i] =
LineColor[i];
231 for (ia = 0; ia < 3; ia++) kshift[ia] =
bvec[0][ia] * a0 +
bvec[1][ia] * a1 +
bvec[2][ia] * a2;
236 for (ibzl = 0; ibzl <
nbzl; ++ibzl) {
237 for (i = 0; i < 2; ++i) {
238 for (j = 0; j < 3; ++j)
239 bzl2[j] =
rot[j][0] * (
bzl[ibzl][i][0] + kshift[0])
240 +
rot[j][1] * (
bzl[ibzl][i][1] + kshift[1])
241 +
rot[j][2] * (
bzl[ibzl][i][2] + kshift[2])
243 for (j = 0; j < 3; j++) vertices[j + 3 * i] = bzl2[j];
245 glColor3fv(linecolor);
246 glNormal3f(0.0f, 0.0f, 1.0f);
247 glVertexPointer(3, GL_FLOAT, 0, vertices);
248 glDrawArrays(GL_LINES, 0, 2);
255 for (i = 0; i < 3; ++i) {
256 for (j = 0; j < 3; ++j) {
257 bvec2[i][j] =
rot[j][0] *
bvec[i][0]
262 for (i = 0; i < 3; ++i) vertices[i] =
trans[i];
263 for (i = 0; i < 3; ++i) vertices[i + 3] =
trans[i] + bvec2[0][i];
264 for (i = 0; i < 3; ++i) vertices[i + 3 * 2] =
trans[i] + bvec2[0][i] + bvec2[1][i];
265 for (i = 0; i < 3; ++i) vertices[i + 3 * 3] =
trans[i] + bvec2[0][i] + bvec2[1][i] + bvec2[2][i];
266 for (i = 0; i < 3; ++i) vertices[i + 3 * 4] =
trans[i] + bvec2[1][i] + bvec2[2][i];
267 for (i = 0; i < 3; ++i) vertices[i + 3 * 5] =
trans[i] + bvec2[1][i];
268 for (i = 0; i < 3; ++i) vertices[i + 3 * 6] =
trans[i];
269 for (i = 0; i < 3; ++i) vertices[i + 3 * 7] =
trans[i] + bvec2[2][i];
270 for (i = 0; i < 3; ++i) vertices[i + 3 * 8] =
trans[i] + bvec2[0][i] + bvec2[2][i];
271 for (i = 0; i < 3; ++i) vertices[i + 3 * 9] =
trans[i] + bvec2[0][i] + bvec2[1][i] + bvec2[2][i];
272 for (i = 0; i < 3; ++i) vertices[i + 3 * 10] =
trans[i] + bvec2[0][i] + bvec2[2][i];
273 for (i = 0; i < 3; ++i) vertices[i + 3 * 11] =
trans[i] + bvec2[0][i];
274 for (i = 0; i < 3; ++i) vertices[i + 3 * 12] =
trans[i];
275 for (i = 0; i < 3; ++i) vertices[i + 3 * 13] =
trans[i] + bvec2[2][i];
276 for (i = 0; i < 3; ++i) vertices[i + 3 * 14] =
trans[i] + bvec2[1][i] + bvec2[2][i];
277 for (i = 0; i < 3; ++i) vertices[i + 3 * 15] =
trans[i] + bvec2[1][i];
278 for (i = 0; i < 3; ++i) vertices[i + 3 * 16] =
trans[i] + bvec2[0][i] + bvec2[1][i];
279 for (i = 0; i < 17; ++i) {
280 for (j = 0; j < 3; ++j) {
281 vertices[j + 3 * i] = vertices[j + 3 * i]
282 +
rot[j][0] * kshift[0]
283 +
rot[j][1] * kshift[1]
284 +
rot[j][2] * kshift[2];
287 glColor3fv(linecolor);
288 glNormal3f(0.0f, 0.0f, 1.0f);
289 glVertexPointer(3, GL_FLOAT, 0, vertices);
290 glDrawArrays(GL_LINE_STRIP, 0, 17);
298 for (i = 0; i < 2; ++i) {
299 for (j = 0; j < 3; ++j)
303 for (j = 0; j < 3; ++j)
304 vertices[j + 3 * i] =
rot[j][0] * arrow_c[0]
305 +
rot[j][1] * arrow_c[1]
306 +
rot[j][2] * arrow_c[2]
309 glColor3fv(linecolor);
310 glNormal3f(0.0f, 0.0f, 1.0f);
311 glVertexPointer(3, GL_FLOAT, 0, vertices);
312 glDrawArrays(GL_LINES, 0, 2);
317 for (j = 0; j < 3; ++j)
321 for (ibzl = 0; ibzl <
nbzl2d; ++ibzl) {
322 for (j = 0; j < 3; ++j)
323 bzl2[j] =
rot[j][0] *
bzl2d[ibzl][0]
327 for (j = 0; j < 3; j++)vertices[j + 3 * ibzl] = bzl2[j];
330 glNormal3fv(secvec2);
331 glVertexPointer(3, GL_FLOAT, 0, vertices);
332 glDrawArrays(GL_TRIANGLE_FAN, 0,
nbzl2d);
337 for (ibzl = 0; ibzl < 190; ibzl++) {
338 for (i = 0; i < 2; ++i) {
339 for (j = 0; j < 3; ++j)
340 sphere_v2[j + 3 * i + 6 * ibzl] =
rot[j][0] *
sphere_v[ibzl][i][0]
346 glColor3fv(linecolor);
347 glNormal3f(0.0f, 0.0f, 1.0f);
348 glVertexPointer(3, GL_FLOAT, 0, sphere_v2);
349 glDrawArrays(GL_LINES, 0, 380);
358 GLfloat mat2, vertices[366], colors[488], vector[18], vector_color[24],
361 glEnableClientState(GL_COLOR_ARRAY);
365 for (i = 0; i < 6; i++) {
366 vector[3 * i] = -1.2f;
367 vector[3 * i + 1] = -1.05f;
368 vector[3 * i + 2] = 0.0f;
370 for (i = 0; i < 3; i++) {
372 for (j = 0; j < 3; j++) {
376 +
rot[j][2] *
bvec[i][2]) * 0.2f / norm;
378 for (j = 0; j < 4; j++) {
379 vector_color[j + 8 * i] =
BarColor[i * 2][j];
380 vector_color[j + 8 * i + 4] =
BarColor[i * 2][j];
384 glNormal3f(0.0f, 0.0f, 1.0f);
385 glVertexPointer(3, GL_FLOAT, 0, vector);
386 glColorPointer(4, GL_FLOAT, 0, vector_color);
387 glDrawArrays(GL_LINES, 0, 6);
391 for (i = 0; i < 6; i++) {
392 vector[3 * i] = 1.2f;
393 vector[3 * i + 1] = -1.05f;
394 vector[3 * i + 2] = 0.0f;
396 for (i = 0; i < 3; i++) {
397 for (j = 0; j < 3; j++) {
398 vector[j + 6 * i] +=
rot[j][i] * 0.2f;
400 for (j = 0; j < 4; j++) {
401 vector_color[j + 8 * i] =
BarColor[i * 2][j];
402 vector_color[j + 8 * i + 4] =
BarColor[i * 2][j];
406 glNormal3f(0.0f, 0.0f, 1.0f);
407 glVertexPointer(3, GL_FLOAT, 0, vector);
408 glColorPointer(4, GL_FLOAT, 0, vector_color);
409 glDrawArrays(GL_LINES, 0, 6);
414 for (i = 0; i < 5; i++) {
415 for (j = 0; j < 2; j++) {
416 vertices[0 + j * 3 + i * 6] = -1.0f + 0.5f*(GLfloat)i;
417 vertices[1 + j * 3 + i * 6] = -1.0f - 0.1f*(GLfloat)j;
418 vertices[2 + j * 3 + i * 6] = 0.0f;
419 for (k = 0; k < 4; k++) colors[k + 4 * j + 8 * i] =
BarColor[i][k];
422 glNormal3f(0.0f, 0.0f, 1.0f);
423 glVertexPointer(3, GL_FLOAT, 0, vertices);
424 glColorPointer(4, GL_FLOAT, 0, colors);
425 glDrawArrays(GL_TRIANGLE_STRIP, 0, 10);
436 for (i = 0; i <= 60; i++) {
438 mat2 = (GLfloat)i / 60.0f * 6.0f;
441 for (j = 0; j<4; ++j) colors[j + 4 * (i + 1)] =
yellow[j] * mat2 +
red[j] * (1.0f - mat2);
443 else if (mat2 <= 2.0) {
445 for (j = 0; j<4; ++j) colors[j + 4 * (i + 1)] =
green[j] * mat2 +
yellow[j] * (1.0f - mat2);
447 else if (mat2 <= 3.0) {
449 for (j = 0; j<4; ++j) colors[j + 4 * (i + 1)] =
cyan[j] * mat2 +
green[j] * (1.0f - mat2);
451 else if (mat2 <= 4.0) {
453 for (j = 0; j<4; ++j) colors[j + 4 * (i + 1)] =
blue[j] * mat2 +
cyan[j] * (1.0f - mat2);
455 else if (mat2 <= 5.0) {
457 for (j = 0; j<4; ++j) colors[j + 4 * (i + 1)] =
magenta[j] * mat2 +
blue[j] * (1.0f - mat2);
461 for (j = 0; j<4; ++j) colors[j + 4 * (i + 1)] =
red[j] * mat2 +
magenta[j] * (1.0f - mat2);
464 vertices[0 + 3 * (i + 1)] = 0.2f * cosf((GLfloat)i / 60.0f * 6.283185307f);
465 vertices[1 + 3 * (i + 1)] = 0.2f * sinf((GLfloat)i / 60.0f * 6.283185307f) - 1.0f;
466 vertices[2 + 3 * (i + 1)] = 0.0f;
468 glNormal3f(0.0f, 0.0f, 1.0f);
469 glVertexPointer(3, GL_FLOAT, 0, vertices);
470 glColorPointer(4, GL_FLOAT, 0, colors);
471 glDrawArrays(GL_TRIANGLE_FAN, 0, 62);
474 for (i = 0; i < 2; i++) {
475 for (j = 0; j < 2; j++) {
476 vertices[0 + j * 3 + i * 6] = -1.0f + 2.0f*(GLfloat)i;
477 vertices[1 + j * 3 + i * 6] = -1.0f - 0.1f*(GLfloat)j;
478 vertices[2 + j * 3 + i * 6] = 0.0f;
479 if (i == 0)
for (k = 0; k < 4; k++) colors[k + 4 * j + 8 * i] =
bgray[k];
480 else if (i == 1)
for (k = 0; k < 4; k++) colors[k + 4 * j + 8 * i] =
wgray[k];
483 glNormal3f(0.0f, 0.0f, 1.0f);
484 glVertexPointer(3, GL_FLOAT, 0, vertices);
485 glColorPointer(4, GL_FLOAT, 0, colors);
486 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
488 glDisableClientState(GL_COLOR_ARRAY);
497 GLfloat r, vertices[66];
501 vertices[0] = 0.7f - dx2d;
504 for (i = 0; i <= 20; i++) {
505 vertices[0 + (i + 1) * 3] = r * cosf((GLfloat)i / 20.0f * 6.283185307f) + 0.7f - dx2d;
506 vertices[1 + (i + 1) * 3] = r * sinf((GLfloat)i / 20.0f * 6.283185307f) +
scl;
507 vertices[2 + (i + 1) * 3] = 0.0f;
509 glNormal3f(0.0f, 0.0f, 1.0f);
511 glVertexPointer(3, GL_FLOAT, 0, vertices);
512 glDrawArrays(GL_TRIANGLE_FAN, 0, 22);
514 for (i = 0; i < 22; i++) vertices[3 * i] += -1.4f;
515 glVertexPointer(3, GL_FLOAT, 0, vertices);
516 glDrawArrays(GL_TRIANGLE_FAN, 0, 22);
523 GLfloat vertices[60];
528 for (ibzl = 0; ibzl <
nbzl2d; ++ibzl) {
529 for (i = 0; i < 3; i++) vertices[i + 3 * ibzl] =
bzl2d_proj[ibzl][i];
531 glNormal3f(0.0f, 0.0f, 1.0f);
533 glVertexPointer(3, GL_FLOAT, 0, vertices);
534 glDrawArrays(GL_LINE_LOOP, 0,
nbzl2d);
539 glEnableClientState(GL_COLOR_ARRAY);
540 glNormal3f(0.0f, 0.0f, 1.0f);
541 for (ib = 0; ib <
nb; ib++) {
543 glVertexPointer(3, GL_FLOAT, 0,
kv2d[ib]);
544 glColorPointer(4, GL_FLOAT, 0,
clr2d[ib]);
545 glDrawArrays(GL_LINES, 0, 2 *
n2d[ib]);
548 glDisableClientState(GL_COLOR_ARRAY);
556 GLfloat pos[] = { 1.0f, 1.0f, 1.0f, 0.0f };
557 GLfloat amb[] = { 0.2f, 0.2f, 0.2f, 0.0f };
558 GLfloat dx, dx2d, theta, posz, phi;
559 GLfloat pos1[4], pos2[4];
561 char command_name[256];
577 theta = 3.1416f / 180.0f * 2.5f;
580 phi = atanf(posz / dx) - theta;
581 theta = (3.1416f * 0.5f - phi) / 3.1416f * 180.0f;
583 pos1[0] = posz * cosf(phi) - dx;
585 pos1[2] = posz * sinf(phi);
588 pos2[0] = -posz * cosf(phi) + dx;
590 pos2[2] = posz * sinf(phi);
597 theta = -3.1416f / 180.0f * 2.0f;
601 pos1[0] = posz * sinf(theta) - dx;
603 pos1[2] = posz * cosf(theta);
606 pos2[0] = -posz * sinf(theta) + dx;
608 pos2[2] = posz * cosf(theta);
620 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
625 glTranslatef(0.0, 0.0, -5.0);
631 glLightfv(GL_LIGHT0, GL_POSITION, pos);
632 glTranslatef(-dx2d, 0.0, 0.0);
639 glLightfv(GL_LIGHT0, GL_POSITION, pos1);
641 glTranslatef(-dx-dx2d, 0.0, 0.0);
642 glRotatef(theta, 0.0, 1.0, 0.0);
644 glLightfv(GL_LIGHT1, GL_AMBIENT, amb);
663 glTranslatef(0.0, 0.0, -5.0);
665 glLightfv(GL_LIGHT0, GL_POSITION, pos2);
667 glTranslatef(dx-dx2d, 0.0, 0.0);
668 glRotatef(-theta, 0.0, 1.0, 0.0);
682 glTranslatef(0.0, 0.0, -5.0);
684 glLightfv(GL_LIGHT0, GL_POSITION, pos);
686 if (
lstereo == 1) glTranslatef(dx2d, 0.0, 0.0);
687 else glTranslatef(2.0f * dx2d, 0.0, 0.0);
697 char file2[256], batch2[256];
700 strncpy(batch2, (
const char*)
batch_name.mb_str(wxConvUTF8), 255);
701 sprintf(command_name,
"import -window \"%s\" %s.png", file2, batch2);
702 ierr = system(command_name);