28 #if defined(HAVE_CONFIG_H)
31 #if defined(HAVE_GL_GL_H)
33 #elif defined(HAVE_OPENGL_GL_H)
34 #include <OpenGL/gl.h>
56 for (kk = 0; kk < 2; kk++) {
58 for (ii = 0; ii < 3; ii++)
59 vec0[kk] +=
axis2d[kk][ii] * vec[ii];
62 for (kk = 0; kk < 3; kk++)vec[kk] = vec0[kk];
74 GLfloat snorm, norm, thr = 0.001f;
77 for (ii = 0; ii < 3; ii++) snorm +=
secvec[ii] *
secvec[ii];
81 for (ii = 0; ii < 3; ii++) {
82 for (jj = 0; jj < 3; jj++)
axis2d[0][jj] = 0.0;
87 for (jj = 0; jj < 3; jj++) norm +=
axis2d[0][jj] *
axis2d[0][jj];
90 for (jj = 0; jj < 3; jj++)
axis2d[0][jj] /= norm;
101 for (jj = 0; jj < 3; jj++) norm +=
axis2d[1][jj] *
axis2d[1][jj];
103 for (jj = 0; jj < 3; jj++)
axis2d[1][jj] /= norm;
110 GLfloat
bragg[26][3],
120 int kbr, i, lbr, nbr0;
121 GLfloat bmat[3][3], rhs[3], prod, thr, det;
125 for (kbr = nbr0; kbr <
nbragg; ++kbr) {
128 for (i = 0; i<3; ++i) bmat[0][i] =
secvec[i];
129 for (i = 0; i<3; ++i) bmat[1][i] =
bragg[jbr][i];
130 for (i = 0; i<3; ++i) bmat[2][i] =
bragg[kbr][i];
136 thr = sqrtf(rhs[0] * rhs[1] * rhs[2]) * 0.001f;
142 if (fabsf(det) < thr)
continue;
146 prod = (vert2[0] - rhs[0]) * (vert2[0] - rhs[0])
147 + (vert2[1] - rhs[1]) * (vert2[1] - rhs[1])
148 + (vert2[2] - rhs[2]) * (vert2[2] - rhs[2]);
149 if (prod < thr)
continue;
154 for (lbr = 0; lbr <
nbragg; ++lbr) {
155 prod =
bragg[lbr][0] * rhs[0]
156 +
bragg[lbr][1] * rhs[1]
157 +
bragg[lbr][2] * rhs[2];
159 if (prod >
brnrm[lbr] + thr) {
167 for (i = 0; i<3; ++i) vert[i] = rhs[i];
182 int jbr, nbr, i, j, lvert, ibzl;
183 GLfloat vert[2][3], vec[26][2][3], prod, thr;
193 for (jbr = 0; jbr <
nbragg; ++jbr) {
195 for (i = 0; i < 3; ++i) vert[1][i] = 0.0;
198 if (lvert == 0)
continue;
202 if (lvert == 0)
continue;
204 for (i = 0; i < 2; ++i)
for (j = 0; j < 3; ++j) vec[
nbzl2d][i][j] = vert[i][j];
210 for (i = 0; i < 3; i++)
bzl2d[0][i] = vec[0][0][i];
211 for (i = 0; i < 3; i++)
bzl2d[1][i] = vec[0][1][i];
212 for (ibzl = 0; ibzl <
nbzl2d; ibzl++) {
215 for (j = 0; j < 2; j++)
for (i = 0; i < 3; i++) thr +=
bzl2d[j][i] *
bzl2d[j][i];
219 for (j = 0; j < 2; j++)
for (i = 0; i < 3; i++)
220 prod += (
bzl2d[j][i] - vec[ibzl][j][i]) * (
bzl2d[j][i] - vec[ibzl][j][i]);
222 for (j = 0; j < 2; j++)
for (i = 0; i < 3; i++) vec[ibzl][j][i] = 0.0;
225 for (j = 0; j < 2; j++)
for (i = 0; i < 3; i++)
226 prod += (
bzl2d[1 - j][i] - vec[ibzl][j][i]) * (
bzl2d[1 - j][i] - vec[ibzl][j][i]);
228 for (j = 0; j < 2; j++)
for (i = 0; i < 3; i++) vec[ibzl][j][i] = 0.0;
231 for (jbr = 1; jbr <
nbzl2d - 1; jbr++) {
234 for (j = 0; j < 2; j++)
for (i = 0; i < 3; i++) thr +=
bzl2d[jbr][i] *
bzl2d[jbr][i];
238 for (ibzl = 0; ibzl <
nbzl2d; ibzl++)
for (i = 0; i < 3; i++)
239 prod += vec[ibzl][0][i] * vec[ibzl][0][i];
245 for (ibzl = 1; ibzl <
nbzl2d; ibzl++) {
246 prod = (
bzl2d[jbr][0] - vec[ibzl][0][0]) * (
bzl2d[jbr][0] - vec[ibzl][0][0])
247 + (
bzl2d[jbr][1] - vec[ibzl][0][1]) * (
bzl2d[jbr][1] - vec[ibzl][0][1])
248 + (
bzl2d[jbr][2] - vec[ibzl][0][2]) * (
bzl2d[jbr][2] - vec[ibzl][0][2]);
250 for (i = 0; i < 3; i++)
bzl2d[jbr + 1][i] = vec[ibzl][1][i];
251 for (j = 0; j < 2; j++)
for (i = 0; i < 3; i++) vec[ibzl][j][i] = 0.0;
254 prod = (
bzl2d[jbr][0] - vec[ibzl][1][0]) * (
bzl2d[jbr][0] - vec[ibzl][1][0])
255 + (
bzl2d[jbr][1] - vec[ibzl][1][1]) * (
bzl2d[jbr][1] - vec[ibzl][1][1])
256 + (
bzl2d[jbr][2] - vec[ibzl][1][2]) * (
bzl2d[jbr][2] - vec[ibzl][1][2]);
258 for (i = 0; i < 3; i++)
bzl2d[jbr + 1][i] = vec[ibzl][0][i];
259 for (j = 0; j < 2; j++)
for (i = 0; i < 3; i++) vec[ibzl][j][i] = 0.0;
266 for (ibzl = 0; ibzl <
nbzl2d; ibzl++) {
277 int i, j, ib, itri, ithread, n2d0;
278 std::vector<std::vector<std::vector<std::vector<GLfloat> > > > kv2d_v, clr2d_v;
285 *
terminal << wxT(
" band # of Fermi-line\n");
286 for (ib = 0; ib <
nb; ib++) {
288 #pragma omp parallel default(none) \
289 shared(nb,ib,clr,clr2d_v,kvp,kv2d_v,ntri,secvec,secscale,axis2d) \
290 private(itri,i,j,ithread)
293 GLfloat norm[3], a[3][3];
294 std::vector<std::vector<GLfloat> > kv2d_0, clr2d_0;
298 for (i = 0; i < 2; i++) {
299 kv2d_0.at(i).resize(3);
300 clr2d_0.at(i).resize(4);
304 kv2d_v.at(ithread).resize(0);
305 clr2d_v.at(ithread).resize(0);
308 for (itri = 0; itri <
ntri[ib]; ++itri) {
310 for (i = 0; i < 3; i++) {
315 for (i = 0; i < 3; ++i) {
316 for (j = 0; j < 3; ++j) {
317 a[i][j] = (0.0f - norm[sw[j]]) / (norm[sw[i]] - norm[sw[j]]);
321 if ((norm[sw[0]] < 0.0 && 0.0 <= norm[sw[1]]) || (norm[sw[0]] <= 0.0 && 0.0 < norm[sw[1]])) {
322 for (i = 0; i < 3; ++i) {
324 =
kvp[ib][itri][sw[1]][i] * a[1][0] +
kvp[ib][itri][sw[0]][i] * a[0][1];
326 =
kvp[ib][itri][sw[2]][i] * a[2][0] +
kvp[ib][itri][sw[0]][i] * a[0][2];
328 for (i = 0; i < 4; ++i) {
330 =
clr[ib][i + 4 * sw[1] + 12 * itri] * a[1][0]
331 +
clr[ib][i + 4 * sw[0] + 12 * itri] * a[0][1];
333 =
clr[ib][i + 4 * sw[2] + 12 * itri] * a[2][0]
334 +
clr[ib][i + 4 * sw[0] + 12 * itri] * a[0][2];
338 kv2d_v.at(ithread).push_back(kv2d_0);
339 clr2d_v.at(ithread).push_back(clr2d_0);
341 else if ((norm[sw[1]] < 0.0 && 0.0 <= norm[sw[2]]) || (norm[sw[1]] <= 0.0 && 0.0 < norm[sw[2]])) {
342 for (i = 0; i < 3; ++i) {
344 =
kvp[ib][itri][sw[2]][i] * a[2][0] +
kvp[ib][itri][sw[0]][i] * a[0][2];
346 =
kvp[ib][itri][sw[2]][i] * a[2][1] +
kvp[ib][itri][sw[1]][i] * a[1][2];
348 for (i = 0; i < 4; ++i) {
350 =
clr[ib][i + 4 * sw[2] + 12 * itri] * a[2][0]
351 +
clr[ib][i + 4 * sw[0] + 12 * itri] * a[0][2];
353 =
clr[ib][i + 4 * sw[2] + 12 * itri] * a[2][1]
354 +
clr[ib][i + 4 * sw[1] + 12 * itri] * a[1][2];
358 kv2d_v.at(ithread).push_back(kv2d_0);
359 clr2d_v.at(ithread).push_back(clr2d_0);
367 for (ithread = 0; ithread <
nthreads; ithread++)
368 n2d[ib] += kv2d_v.at(ithread).size();
370 *
terminal << wxString::Format(wxT(
" %d %d\n"), ib + 1,
n2d[ib]);
371 kv2d[ib] =
new GLfloat[6 *
n2d[ib]];
372 clr2d[ib] =
new GLfloat[8 *
n2d[ib]];
375 for (ithread = 0; ithread <
nthreads; ithread++) {
376 for (itri = 0; itri < kv2d_v.at(ithread).size(); itri++) {
377 for (i = 0; i < 2; i++) {
378 for (j = 0; j < 3; j++) {
379 kv2d[ib][j + i * 3 + 6 * n2d0] = kv2d_v.at(ithread).at(itri).at(i).at(j);
381 for (j = 0; j < 3; j++) {
382 clr2d[ib][j + i * 4 + 8 * n2d0] = clr2d_v.at(ithread).at(itri).at(i).at(j);