• R/O
  • HTTP
  • SSH
  • HTTPS

fermisurfer: Commit

fermisurfer Git


Commit MetaInfo

Revisionec1eeadc34b92b5d45daca43200281a2f220e00b (tree)
Zeit2018-02-16 11:55:07
Autormitsuaki1987 <kawamitsuaki@gmai...>
Commitermitsuaki1987

Log Message

Backup

Ändern Zusammenfassung

Diff

--- a/src/draw.c
+++ b/src/draw.c
@@ -285,7 +285,7 @@ static void draw_colorbar()
285285 int i, j, k;
286286 GLfloat mat2, barcolor[4], vertices[366], normals[366], colors[488];
287287 /**/
288- if (fcscl == 1 || fcscl == 2 || fcscl == 5 || fcscl == 6) {
288+ if (color_scale == 1 || color_scale == 3) {
289289 for (i = 0; i < 5; i++) {
290290 for (j = 0; j < 2; j++) {
291291 for (k = 0; k < 2; k++) normals[k + j*3 + i * 6] = 0.0f;
@@ -304,11 +304,19 @@ static void draw_colorbar()
304304 glNormalPointer(GL_FLOAT, 0, normals);
305305 glColorPointer(4, GL_FLOAT, 0, colors);
306306 glDrawArrays(GL_TRIANGLE_STRIP, 0, 10);
307- }/*if (fcscl == 1 || fcscl == 2)*/
308- else if (fcscl == 4) {
307+ }/*if (color_scale == 1 || color_scale == 3)*/
308+ else if (color_scale == 2) {
309309 /*
310310 Periodic color scale
311311 */
312+ vertices[0] = 0.0f;
313+ vertices[1] = -1.0f;
314+ vertices[2] = 0.0f;
315+ normals[0] = 0.0f;
316+ normals[1] = 0.0f;
317+ normals[2] = 1.0f;
318+ for (j = 0; j < 4; j++) colors[j] = white[j];
319+ /**/
312320 for (i = 0; i <= 60; i++) {
313321 /**/
314322 mat2 = (GLfloat)i / 60.0f * 6.0f;
@@ -337,23 +345,19 @@ static void draw_colorbar()
337345 for (j = 0; j<4; ++j) barcolor[j] = red[j] * mat2 + magenta[j] * (1.0f - mat2);
338346 }
339347 /**/
340- vertices[0 + 0 * 3 + 6 * i] = 0.15f * cosf((GLfloat)i / 60.0f * 6.283185307f);
341- vertices[1 + 0 * 3 + 6 * i] = 0.15f * sinf((GLfloat)i / 60.0f * 6.283185307f) - 1.0f;
342- vertices[0 + 1 * 3 + 6 * i] = 0.2f * cosf((GLfloat)i / 60.0f * 6.283185307f);
343- vertices[1 + 1 * 3 + 6 * i] = 0.2f * sinf((GLfloat)i / 60.0f * 6.283185307f) - 1.0f;
344- for (k = 0; k < 2; k++) {
345- vertices[2 + k * 3 + 6 * i] = 0.0f;
346- for (j = 0; j < 2; j++) normals[j + k * 3 + 6 * i] = 0.0f;
347- normals[2 + k * 3 + 6 * i] = 1.0f;
348- for (j = 0; j < 4; j++) colors[j + k * 4 + 8 * i] = barcolor[j];
349- }/*for (i = 0; i < 10; i++)*/
348+ vertices[0 + 3 * (i + 1)] = 0.2f * cosf((GLfloat)i / 60.0f * 6.283185307f);
349+ vertices[1 + 3 * (i + 1)] = 0.2f * sinf((GLfloat)i / 60.0f * 6.283185307f) - 1.0f;
350+ vertices[2 + 3 * (i + 1)] = 0.0f;
351+ for (j = 0; j < 2; j++) normals[j + 3 * (i + 1)] = 0.0f;
352+ normals[2 + 3 * (i + 1)] = 1.0f;
353+ for (j = 0; j < 4; j++) colors[j + 4 * (i + 1)] = barcolor[j];
350354 }/*for (i = 0; i <= 60; i++)*/
351355 glVertexPointer(3, GL_FLOAT, 0, vertices);
352356 glNormalPointer(GL_FLOAT, 0, normals);
353357 glColorPointer(4, GL_FLOAT, 0, colors);
354- glDrawArrays(GL_TRIANGLE_STRIP, 0, 122);
355- }/*else if (fcscl == 4)*/
356- else if (fcscl == 7 || fcscl == 8) {
358+ glDrawArrays(GL_TRIANGLE_FAN, 0, 62);
359+ }/*else if (color_scale == 2)*/
360+ else if (color_scale == 5 || color_scale == 6) {
357361 for (i = 0; i < 2; i++) {
358362 for (j = 0; j < 2; j++) {
359363 for (k = 0; k < 2; k++) normals[k + j * 3 + i * 6] = 0.0f;
@@ -369,7 +373,7 @@ static void draw_colorbar()
369373 glNormalPointer(GL_FLOAT, 0, normals);
370374 glColorPointer(4, GL_FLOAT, 0, colors);
371375 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
372- }/*if (fcscl == 7 || fcscl == 8)*/
376+ }/*if (color_scale == 7 || color_scale == 8)*/
373377
374378 }/*void draw_colorbar*/
375379 /**
--- a/src/free_patch.c
+++ b/src/free_patch.c
@@ -123,70 +123,79 @@ void free_patch() {
123123 Modify : ::clr
124124 */
125125 void max_and_min() {
126- int itri, ierr, ithread;
127- GLfloat matmax, matmin, absmax, *max_th, *min_th, *abs_th;
126+ int itri, ithread;
127+ GLfloat *max_th, *min_th;
128128
129129 max_th = (GLfloat*)malloc(nthreads * sizeof(GLfloat));
130130 min_th = (GLfloat*)malloc(nthreads * sizeof(GLfloat));
131- abs_th = (GLfloat*)malloc(nthreads * sizeof(GLfloat));
132131
133132 printf("\n");
134- if (fcscl == 1) printf(" ## Full color scale mode #############\n");
135- else if (fcscl == 2) printf(" ## Manual color scale mode #############\n");
136- else if (fcscl == 3) printf(" ## Uni-color mode #############\n");
137- else if (fcscl == 4) printf(" ## Periodic color scale mode #############\n");
138- else if (fcscl == 5 || fcscl == 6) printf(" ## Color as Fermi velocity #############\n");
139- else if (fcscl == 7 || fcscl == 8) printf(" ## Gray scale mode #############\n");
133+ if (color_scale == 1) printf(" ## Color Scale as Input Quantity (Real) #############\n");
134+ else if (color_scale == 2) printf(" ## Color Scale as Input Quantity (Complex) #############\n");
135+ else if (color_scale == 3) printf(" ## Color Scale as Fermi Velocity #############\n");
136+ else if (color_scale == 4) printf(" ## Color Scale as Band Index #############\n");
137+ else if (color_scale == 5) printf(" ## Gray Scale as Input Quantity (Real) #############\n");
138+ else if (color_scale == 6) printf(" ## Gray Scale as Fermi Velocity #############\n");
140139 printf("\n");
141-
142- if (fcscl == 1 || fcscl == 2 || fcscl == 7 || fcscl == 8) {
140+ /*
141+ Search max and min.
142+ */
143+ if (color_scale == 1 || color_scale == 5) {
143144 #pragma omp parallel default(none) \
144-shared(nb,ntri,matp,max_th,min_th,abs_th) private(itri,ithread)
145+shared(nb,ntri,matp,max_th,min_th) private(itri,ithread)
145146 {
146147 int i, ib;
147- GLfloat abs;
148148
149149 ithread = get_thread();
150150 max_th[ithread] = -1.0e10f;
151151 min_th[ithread] = 1.0e10f;
152- abs_th[ithread] = -1.0e10f;
153152
154153 for (ib = 0; ib < nb; ib++) {
155154 #pragma omp for
156155 for (itri = 0; itri < ntri[ib]; ++itri) {
157156 for (i = 0; i < 3; ++i) {
158- abs = sqrtf(matp[ib][itri][i][0] * matp[ib][itri][i][0]
159- + matp[ib][itri][i][1] * matp[ib][itri][i][1]);
160157 if (matp[ib][itri][i][0] > max_th[ithread]) max_th[ithread] = matp[ib][itri][i][0];
161158 if (matp[ib][itri][i][0] < min_th[ithread]) min_th[ithread] = matp[ib][itri][i][0];
162- if (abs > abs_th[ithread]) abs_th[ithread] = abs;
163159 }
164160 }/*for (itri = 0; itri < ntri[ib]; ++itri)*/
165161 }/*for (ib = 0; ib < nb; ib++)*/
166162 }/*End of parallel region*/
167163 /**/
168- matmax = max_th[0];
169- matmin = min_th[0];
170- absmax = abs_th[0];
164+ patch_max = max_th[0];
165+ patch_min = min_th[0];
171166 for (ithread = 1; ithread < nthreads; ithread++) {
172- if (max_th[ithread] > matmax) matmax = max_th[ithread];
173- if (min_th[ithread] < matmin) matmin = min_th[ithread];
174- if (abs_th[ithread] > absmax) absmax = abs_th[ithread];
167+ if (max_th[ithread] > patch_max) patch_max = max_th[ithread];
168+ if (min_th[ithread] < patch_min) patch_min = min_th[ithread];
175169 }
176- printf(" Max. value : %f\n", matmax);
177- printf(" Min. value : %f\n\n", matmin);
178- printf(" Max. absolute value : %f\n", absmax);
179- /**/
180- if (fcscl == 2 || fcscl == 8) {
181- printf(" Set min. value : ");
182- ierr = scanf("%f", &matmin);
183- if (ierr == 0) printf("error ! reading min");
184- printf(" Set max. value : ");
185- ierr = scanf("%f", &matmax);
186- if (ierr == 0) printf("error ! reading max");
187- }/*if (fcscl == 2)*/
188- }/*if (fcscl == 1 || fcscl == 2)*/
189- else if (fcscl == 5 || fcscl == 6) {
170+ }/*if (color_scale == 0 || color_scale == 4)*/
171+ else if (color_scale == 2) {
172+#pragma omp parallel default(none) \
173+shared(nb,ntri,matp,max_th) private(itri,ithread)
174+ {
175+ int i, ib;
176+ GLfloat abs;
177+
178+ ithread = get_thread();
179+ max_th[ithread] = -1.0e10f;
180+
181+ for (ib = 0; ib < nb; ib++) {
182+#pragma omp for
183+ for (itri = 0; itri < ntri[ib]; ++itri) {
184+ for (i = 0; i < 3; ++i) {
185+ abs = sqrtf(matp[ib][itri][i][0] * matp[ib][itri][i][0]
186+ + matp[ib][itri][i][1] * matp[ib][itri][i][1]);
187+ if (abs > max_th[ithread]) max_th[ithread] = abs;
188+ }
189+ }/*for (itri = 0; itri < ntri[ib]; ++itri)*/
190+ }/*for (ib = 0; ib < nb; ib++)*/
191+ }/*End of parallel region*/
192+ /**/
193+ patch_max = max_th[0];
194+ for (ithread = 1; ithread < nthreads; ithread++) {
195+ if (max_th[ithread] > patch_max) patch_max = max_th[ithread];
196+ }
197+ }/*if (color_scale == 3)*/
198+ else if (color_scale == 3 || color_scale == 6) {
190199 #pragma omp parallel default(none) \
191200 shared(nb,ntri,nmlp,max_th,min_th) private(itri,ithread)
192201 {
@@ -212,62 +221,170 @@ shared(nb,ntri,nmlp,max_th,min_th) private(itri,ithread)
212221 }/*for (ib = 0; ib < nb; ib++)*/
213222 }/*End of parallel region*/
214223 /**/
215- matmax = max_th[0];
216- matmin = min_th[0];
224+ patch_max = max_th[0];
225+ patch_min = min_th[0];
217226 for (ithread = 1; ithread < nthreads; ithread++) {
218- if (max_th[ithread] > matmax) matmax = max_th[ithread];
219- if (min_th[ithread] > matmin) matmin = min_th[ithread];
220- }
221- printf(" Max. value : %f\n", matmax);
222- printf(" Min. value : %f\n\n", matmin);
223- /**/
224- if (fcscl == 6) {
225- printf(" Set min. value : ");
226- ierr = scanf("%f", &matmin);
227- if (ierr == 0) printf("error ! reading min");
228- printf(" Set max. value : ");
229- ierr = scanf("%f", &matmax);
230- if (ierr == 0) printf("error ! reading max");
231- }/*if (fcscl == 2)*/
232- }/*if (fcscl == 5 || fcscl == 6)*/
233- /**/
234- if (fcscl == 1 || fcscl == 2) {
227+ if (max_th[ithread] > patch_max) patch_max = max_th[ithread];
228+ if (min_th[ithread] < patch_min) patch_min = min_th[ithread];
229+ }
230+ }/*if (color_scale == 5 || color_scale == 6)*/
231+
232+ free(max_th);
233+ free(min_th);
234+
235+ if (color_scale == 1 || color_scale == 3
236+ || color_scale == 5 || color_scale == 6) {
237+ printf(" Min. value : %f\n\n", patch_min);
238+ printf(" Max. value : %f\n", patch_max);
239+ }
240+ else if (color_scale == 2) {
241+ printf(" Max. absolute value : %f\n", patch_max);
242+ }
243+}/* max_and_min */
244+ /**
245+ @brief Compute Max. & Min. of matrix elements.
246+ Compute color of each patch
247+
248+ Modify : ::clr
249+ */
250+void paint()
251+{
252+ int itri;
253+
254+ if (color_scale == 1) {
235255 #pragma omp parallel default(none) \
236-shared(nb,ntri,matp,clr,cyan,blue,green,yellow,red,matmax,matmin) \
256+shared(nb,ntri,matp,clr,cyan,blue,green,yellow,red,patch_max,patch_min) \
237257 private(itri)
238258 {
239- int i, j, ib;
240- GLfloat mat2;
259+ int i, j, ib;
260+ GLfloat mat2;
241261
242262 for (ib = 0; ib < nb; ib++) {
243263 #pragma omp for nowait
244264 for (itri = 0; itri < ntri[ib]; ++itri) {
245265 for (i = 0; i < 3; ++i) {
246266 /**/
247- mat2 = (matp[ib][itri][i][0] - matmin) / (matmax - matmin);
267+ mat2 = (matp[ib][itri][i][0] - patch_min) / (patch_max - patch_min);
268+ mat2 = mat2 * 4.0f;
269+ /**/
270+ if (mat2 <= 1.0) {
271+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = cyan[j] * mat2 + blue[j] * (1.0f - mat2);
272+ }
273+ else if (mat2 <= 2.0) {
274+ mat2 = mat2 - 1.0f;
275+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = green[j] * mat2 + cyan[j] * (1.0f - mat2);
276+ }
277+ else if (mat2 <= 3.0) {
278+ mat2 = mat2 - 2.0f;
279+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = yellow[j] * mat2 + green[j] * (1.0f - mat2);
280+ }
281+ else {
282+ mat2 = mat2 - 3.0f;
283+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = red[j] * mat2 + yellow[j] * (1.0f - mat2);
284+ }
285+ }/*for (i = 0; i < 3; ++i)*/
286+ }/*for (itri = 0; itri < ntri[ib]; ++itri)*/
287+ }/*for (ib = 0; ib < nb; ib++)*/
288+ }/*End of parallel region*/
289+ }/*if (color_scale == 1 || color_scale == 2)*/
290+ else if (color_scale == 2) {
291+#pragma omp parallel default(none) \
292+shared(nb,ntri,matp,clr,cyan,blue,green,yellow,red,magenta,bgray,wgray,blackback,patch_max) \
293+private(itri)
294+ {
295+ int i, j, ib;
296+ GLfloat theta, abs, theta2;
297+
298+ for (ib = 0; ib < nb; ib++) {
299+ for (itri = 0; itri < ntri[ib]; ++itri) {
300+ for (i = 0; i < 3; ++i) {
301+ /**/
302+ abs = sqrtf(matp[ib][itri][i][0] * matp[ib][itri][i][0]
303+ + matp[ib][itri][i][1] * matp[ib][itri][i][1]);
304+ if (abs / patch_max < 0.00001) theta = 0.0f;
305+ else if (matp[ib][itri][i][1] > 0.0) theta = acosf(matp[ib][itri][i][0] / abs);
306+ else theta = -acosf(matp[ib][itri][i][0] / abs);
307+ abs /= patch_max;
308+ theta = 3.0f * theta / acosf(-1.0f);
309+ /**/
310+ if (-3.0f <= theta && theta < -2.0f) {
311+ theta2 = theta + 3.0f;
312+ for (j = 0; j < 4; ++j)
313+ clr[ib][j + 4 * i + 12 * itri] = blue[j] * theta2 + cyan[j] * (1.0f - theta2);
314+ }
315+ else if (-2.0f <= theta && theta < -1.0f) {
316+ theta2 = theta + 2.0f;
317+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = magenta[j] * theta2 + blue[j] * (1.0f - theta2);
318+ }
319+ else if (-1.0f <= theta && theta < 0.0f) {
320+ theta2 = theta;
321+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = red[j] * theta2 + magenta[j] * (1.0f - theta2);
322+ }
323+ else if (0.0f <= theta && theta < 1.0f) {
324+ theta2 = theta - 1.0f;
325+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = yellow[j] * theta2 + red[j] * (1.0f - theta2);
326+ }
327+ else if (1.0f <= theta && theta < 2.0f) {
328+ theta2 = theta - 2.0f;
329+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = green[j] * theta2 + yellow[j] * (1.0f - theta2);
330+ }
331+ else {
332+ theta2 = theta - 3.0f;
333+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = cyan[j] * theta2 + green[j] * (1.0f - theta2);
334+ }
335+ if (blackback == 1) {
336+ for (j = 0; j < 4; ++j)
337+ clr[ib][j + 4 * i + 12 * itri] = clr[ib][j + 4 * i + 12 * itri] * abs + wgray[j] * (1.0f - abs);
338+ }
339+ else {
340+ for (j = 0; j < 4; ++j)
341+ clr[ib][j + 4 * i + 12 * itri] = clr[ib][j + 4 * i + 12 * itri] * abs + bgray[j] * (1.0f - abs);
342+ }
343+ }/*for (i = 0; i < 3; ++i)*/
344+ }/*for (itri = 0; itri < ntri[ib]; ++itri)*/
345+ }/*for (ib = 0; ib < nb; ib++)*/
346+ }/*End of parallel region*/
347+ }/*if (color_scale == 4)*/
348+ else if (color_scale == 3) {
349+#pragma omp parallel default(none) \
350+shared(nb,ntri,nmlp,clr,cyan,blue,green,yellow,red,patch_max,patch_min) \
351+private(itri)
352+ {
353+ int i, j, ib;
354+ GLfloat mat2;
355+
356+ for (ib = 0; ib < nb; ib++) {
357+ #pragma omp for nowait
358+ for (itri = 0; itri < ntri[ib]; ++itri) {
359+ for (i = 0; i < 3; ++i) {
360+ /**/
361+ mat2 = 0.0f;
362+ for (j = 0; j < 3; ++j) mat2 += nmlp[ib][itri][i][j] * nmlp[ib][itri][i][j];
363+ mat2 = sqrtf(mat2);
364+ mat2 = (mat2 - patch_min) / (patch_max - patch_min);
248365 mat2 = mat2 * 4.0f;
249366 /**/
250367 if (mat2 <= 1.0) {
251- for (j = 0; j < 4; ++j) clr[ib][j+4*i+12*itri] = cyan[j] * mat2 + blue[j] * (1.0f - mat2);
368+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = cyan[j] * mat2 + blue[j] * (1.0f - mat2);
252369 }
253370 else if (mat2 <= 2.0) {
254371 mat2 = mat2 - 1.0f;
255- for (j = 0; j < 4; ++j) clr[ib][j+4*i+12*itri] = green[j] * mat2 + cyan[j] * (1.0f - mat2);
372+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = green[j] * mat2 + cyan[j] * (1.0f - mat2);
256373 }
257374 else if (mat2 <= 3.0) {
258375 mat2 = mat2 - 2.0f;
259- for (j = 0; j < 4; ++j) clr[ib][j+4*i+12*itri] = yellow[j] * mat2 + green[j] * (1.0f - mat2);
376+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = yellow[j] * mat2 + green[j] * (1.0f - mat2);
260377 }
261378 else {
262379 mat2 = mat2 - 3.0f;
263- for (j = 0; j < 4; ++j) clr[ib][j+4*i+12*itri] = red[j] * mat2 + yellow[j] * (1.0f - mat2);
380+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = red[j] * mat2 + yellow[j] * (1.0f - mat2);
264381 }
265382 }/*for (i = 0; i < 3; ++i)*/
266383 }/*for (itri = 0; itri < ntri[ib]; ++itri)*/
267384 }/*for (ib = 0; ib < nb; ib++)*/
268385 }/*End of parallel region*/
269- }/*if (fcscl == 1 || fcscl == 2)*/
270- else if (fcscl == 3) {
386+ }/*if (color_scale == 3)*/
387+ else if (color_scale == 4) {
271388 #pragma omp parallel default(none) \
272389 shared(nb,ntri,matp,clr,cyan,blue,green,yellow,red) \
273390 private(itri)
@@ -318,54 +435,31 @@ private(itri)
318435 }
319436 }/*for (ib = 0; ib < nb; ib++*/
320437 }/*End of parallel region*/
321- }/*if (fcscl == 3)*/
322- else if (fcscl == 4) {
438+ }/*if (color_scale == 4)*/
439+ else if (color_scale == 5) {
323440 #pragma omp parallel default(none) \
324-shared(nb,ntri,matp,clr,cyan,blue,green,yellow,red,magenta) \
441+shared(nb,ntri,matp,clr,bgray,wgray,patch_max,patch_min) \
325442 private(itri)
326443 {
327- int i, j, ib;
328- GLfloat mat2;
444+ int i, j, ib;
445+ GLfloat mat2;
329446
330447 for (ib = 0; ib < nb; ib++) {
448+#pragma omp for nowait
331449 for (itri = 0; itri < ntri[ib]; ++itri) {
332450 for (i = 0; i < 3; ++i) {
333451 /**/
334- mat2 = matp[ib][itri][i][0] / 6.283185307f;
335- mat2 = mat2 - floorf(mat2);
336- mat2 = mat2 * 6.0f;
452+ mat2 = (matp[ib][itri][i][0] - patch_min) / (patch_max - patch_min);
337453 /**/
338- if (mat2 <= 1.0) {
339- for (j = 0; j < 4; ++j) clr[ib][j+4*i+12*itri] = yellow[j] * mat2 + red[j] * (1.0f - mat2);
340- }
341- else if (mat2 <= 2.0) {
342- mat2 = mat2 - 1.0f;
343- for (j = 0; j < 4; ++j) clr[ib][j+4*i+12*itri] = green[j] * mat2 + yellow[j] * (1.0f - mat2);
344- }
345- else if (mat2 <= 3.0) {
346- mat2 = mat2 - 2.0f;
347- for (j = 0; j < 4; ++j) clr[ib][j+4*i+12*itri] = cyan[j] * mat2 + green[j] * (1.0f - mat2);
348- }
349- else if (mat2 <= 4.0) {
350- mat2 = mat2 - 3.0f;
351- for (j = 0; j < 4; ++j) clr[ib][j+4*i+12*itri] = blue[j] * mat2 + cyan[j] * (1.0f - mat2);
352- }
353- else if (mat2 <= 5.0) {
354- mat2 = mat2 - 4.0f;
355- for (j = 0; j < 4; ++j) clr[ib][j+4*i+12*itri] = magenta[j] * mat2 + blue[j] * (1.0f - mat2);
356- }
357- else {
358- mat2 = mat2 - 5.0f;
359- for (j = 0; j < 4; ++j) clr[ib][j+4*i+12*itri] = red[j] * mat2 + magenta[j] * (1.0f - mat2);
360- }
454+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = wgray[j] * mat2 + bgray[j] * (1.0f - mat2);
361455 }/*for (i = 0; i < 3; ++i)*/
362456 }/*for (itri = 0; itri < ntri[ib]; ++itri)*/
363457 }/*for (ib = 0; ib < nb; ib++)*/
364458 }/*End of parallel region*/
365- }/*if (fcscl == 4)*/
366- else if (fcscl == 5 || fcscl == 6) {
459+ }/*if (color_scale == 7 || color_scale == 8)*/
460+ else if (color_scale == 6) {
367461 #pragma omp parallel default(none) \
368-shared(nb,ntri,nmlp,clr,cyan,blue,green,yellow,red,matmax,matmin) \
462+shared(nb,ntri,nmlp,clr,bgray,wgray,patch_max,patch_min) \
369463 private(itri)
370464 {
371465 int i, j, ib;
@@ -376,54 +470,16 @@ private(itri)
376470 for (itri = 0; itri < ntri[ib]; ++itri) {
377471 for (i = 0; i < 3; ++i) {
378472 /**/
379- mat2 = 0.0f;
473+ mat2 = 0.0f;
380474 for (j = 0; j < 3; ++j) mat2 += nmlp[ib][itri][i][j] * nmlp[ib][itri][i][j];
381475 mat2 = sqrtf(mat2);
382- mat2 = (mat2 - matmin) / (matmax - matmin);
383- mat2 = mat2 * 4.0f;
476+ mat2 = (mat2 - patch_min) / (patch_max - patch_min);
384477 /**/
385- if (mat2 <= 1.0) {
386- for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = cyan[j] * mat2 + blue[j] * (1.0f - mat2);
387- }
388- else if (mat2 <= 2.0) {
389- mat2 = mat2 - 1.0f;
390- for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = green[j] * mat2 + cyan[j] * (1.0f - mat2);
391- }
392- else if (mat2 <= 3.0) {
393- mat2 = mat2 - 2.0f;
394- for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = yellow[j] * mat2 + green[j] * (1.0f - mat2);
395- }
396- else {
397- mat2 = mat2 - 3.0f;
398- for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = red[j] * mat2 + yellow[j] * (1.0f - mat2);
399- }
478+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = wgray[j] * mat2 + bgray[j] * (1.0f - mat2);
400479 }/*for (i = 0; i < 3; ++i)*/
401480 }/*for (itri = 0; itri < ntri[ib]; ++itri)*/
402481 }/*for (ib = 0; ib < nb; ib++)*/
403482 }/*End of parallel region*/
404- }/*if (fcscl == 5)*/
405- else if (fcscl == 7 || fcscl == 8) {
406-#pragma omp parallel default(none) \
407-shared(nb,ntri,matp,clr,bgray,wgray,matmax,matmin) \
408-private(itri)
409- {
410- int i, j, ib;
411- GLfloat mat2;
483+ }/*if (color_scale == 7 || color_scale == 8)*/
412484
413- for (ib = 0; ib < nb; ib++) {
414-#pragma omp for nowait
415- for (itri = 0; itri < ntri[ib]; ++itri) {
416- for (i = 0; i < 3; ++i) {
417- /**/
418- mat2 = (matp[ib][itri][i][0] - matmin) / (matmax - matmin);
419- /**/
420- for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = wgray[j] * mat2 + bgray[j] * (1.0f - mat2);
421- }/*for (i = 0; i < 3; ++i)*/
422- }/*for (itri = 0; itri < ntri[ib]; ++itri)*/
423- }/*for (ib = 0; ib < nb; ib++)*/
424- }/*End of parallel region*/
425- }/*if (fcscl == 7 || fcscl == 8)*/
426-
427- free(max_th);
428- free(min_th);
429-}/* max_and_min */
485+}/* paint */
--- a/src/free_patch.h
+++ b/src/free_patch.h
@@ -24,3 +24,5 @@ THE SOFTWARE.
2424
2525 void free_patch();
2626 void max_and_min();
27+void paint();
28+
--- a/src/initialize.c
+++ b/src/initialize.c
@@ -264,14 +264,14 @@ void max_and_min_bz() {
264264 /**
265265 @brief Initialize global variables
266266
267- Modify : ::blackback, ::fcscl, ::fbz, ::nodeline, ::lcolorbar, ::lstereo, ::lmouse,
267+ Modify : ::blackback, ::color_scale, ::fbz, ::nodeline, ::lcolorbar, ::lstereo, ::lmouse,
268268 ::lsection, ::itet, ::scl, ::trans, ::rot, ::thetax, ::thetay, ::thetaz,
269269 ::black, ::gray, ::white, ::cyan, ::magenta, ::yellow, ::red, ::green, ::blue,
270270 ::EF, ::interpol
271271 */
272272 void initialize_val() {
273273 blackback = 1;
274- fcscl = 1;
274+ color_scale = 1;
275275 fbz = 1;
276276 nodeline = 0;
277277 lcolorbar = 1;
--- a/src/menu.c
+++ b/src/menu.c
@@ -49,6 +49,7 @@ void compute_patch_segment() {
4949 query = 1; fermi_patch();
5050 query = 0; fermi_patch();
5151 max_and_min();
52+ paint();
5253 query = 1; calc_nodeline();
5354 query = 0; calc_nodeline();
5455 query = 1; calc_section();
@@ -79,11 +80,13 @@ static void menu_background(
7980 if (value == 1 && blackback != 1) {
8081 glClearColor(0.0, 0.0, 0.0, 0.0);
8182 blackback = 1;
83+ if (color_scale == 4) paint();
8284 glutPostRedisplay();
8385 }
8486 else if (value == 0 && blackback != 0) {
8587 glClearColor(1.0, 1.0, 1.0, 0.0);
8688 blackback = 0;
89+ if (color_scale == 4) paint();
8790 glutPostRedisplay();
8891 }
8992 }/* bgcolor change*/
@@ -133,15 +136,40 @@ static void menu_colorbar(
133136 glutPostRedisplay();
134137 } /* menu_colorbar */
135138 /**
136- @brief Change color scale mode (::fcscl)
139+ @brief Change color scale mode (::color_scale)
137140 */
138141 static void menu_colorscale(
139142 int value //!<[in] Selected menu
140143 )
141144 {
142- if (value != fcscl) {
143- fcscl = value;
145+ int ierr;
146+
147+ if (value == 0) {
148+ max_and_min();
149+ if (color_scale == 1 || color_scale == 3
150+ || color_scale == 5 || color_scale == 3) {
151+ printf(" Set min. value for scale : ");
152+ ierr = scanf("%f", &patch_min);
153+ if (ierr == 0) printf("error ! reading min");
154+ printf(" Set max. value for scale : ");
155+ ierr = scanf("%f", &patch_max);
156+ if (ierr == 0) printf("error ! reading max");
157+ }
158+ else if (color_scale == 2) {
159+ printf(" Set max. value for scale: ");
160+ ierr = scanf("%f", &patch_max);
161+ if (ierr == 0) printf("error ! reading max");
162+ }
163+ else {
164+ printf(" No color scale in this case.\n");
165+ }
166+ paint();
167+ glutPostRedisplay();
168+ }
169+ else if (value != color_scale) {
170+ color_scale = value;
144171 max_and_min();
172+ paint();
145173 glutPostRedisplay();
146174 }
147175 } /* menu_colorscale */
@@ -532,23 +560,20 @@ void FS_ModifyMenu(
532560 Color scale mode
533561 */
534562 glutSetMenu(imenu_colorscale);
535- for (ib = 0; ib < 8; ib++) glutRemoveMenuItem(1);
536- if (fcscl == 1) glutAddMenuEntry("[x] Auto", 1);
537- else glutAddMenuEntry("[ ] Auto", 1);
538- if (fcscl == 2) glutAddMenuEntry("[x] Manual", 2);
539- else glutAddMenuEntry("[ ] Manual", 2);
540- if (fcscl == 3) glutAddMenuEntry("[x] Unicolor", 3);
541- else glutAddMenuEntry("[ ] Unicolor", 3);
542- if (fcscl == 4) glutAddMenuEntry("[x] Periodic", 4);
543- else glutAddMenuEntry("[ ] Periodic", 4);
544- if (fcscl == 5) glutAddMenuEntry("[x] Fermi velocity (Auto)", 5);
545- else glutAddMenuEntry("[ ] Fermi velocity (Auto)", 5);
546- if (fcscl == 6) glutAddMenuEntry("[x] Fermi velocity (Manual)", 6);
547- else glutAddMenuEntry("[ ] Fermi velocity (Manual)", 6);
548- if (fcscl == 7) glutAddMenuEntry("[x] Gray scale (Auto)", 7);
549- else glutAddMenuEntry("[ ] Gray scale (Auto)", 7);
550- if (fcscl == 8) glutAddMenuEntry("[x] Gray scale (Manual)", 8);
551- else glutAddMenuEntry("[ ] Gray scale (Manual)", 8);
563+ for (ib = 0; ib < 7; ib++) glutRemoveMenuItem(1);
564+ glutAddMenuEntry("Max/Min of Scale", 0);
565+ if (color_scale == 1) glutAddMenuEntry("[x] Input (Real)", 1);
566+ else glutAddMenuEntry("[ ] Input (Real)", 1);
567+ if (color_scale == 2) glutAddMenuEntry("[x] Input (Complex)", 2);
568+ else glutAddMenuEntry("[ ] Input (Complex)", 2);
569+ if (color_scale == 3) glutAddMenuEntry("[x] Fermi Velocity", 3);
570+ else glutAddMenuEntry("[ ] Fermi Velocity", 3);
571+ if (color_scale == 4) glutAddMenuEntry("[x] Band Index", 4);
572+ else glutAddMenuEntry("[ ] Band Index", 4);
573+ if (color_scale == 5) glutAddMenuEntry("[x] Input (Real, Gray Scale)", 5);
574+ else glutAddMenuEntry("[ ] Input (Real, Gray Scale)", 5);
575+ if (color_scale == 6) glutAddMenuEntry("[x] Fermi Velocity (Gray Scale)", 6);
576+ else glutAddMenuEntry("[ ] Fermi Velocity (Gray Scale)", 6);
552577 /*
553578 Equator
554579 */
@@ -695,22 +720,19 @@ void FS_CreateMenu()
695720 Color scale mode
696721 */
697722 imenu_colorscale = glutCreateMenu(menu_colorscale);
698- if (fcscl == 1) glutAddMenuEntry("[x] Auto", 1);
699- else glutAddMenuEntry("[ ] Auto", 1);
700- if (fcscl == 2) glutAddMenuEntry("[x] Manual", 2);
701- else glutAddMenuEntry("[ ] Manual", 2);
702- if (fcscl == 3) glutAddMenuEntry("[x] Unicolor", 3);
703- else glutAddMenuEntry("[ ] Unicolor", 3);
704- if (fcscl == 4) glutAddMenuEntry("[x] Periodic", 4);
705- else glutAddMenuEntry("[ ] Periodic", 4);
706- if (fcscl == 5) glutAddMenuEntry("[x] Fermi velocity (Auto)", 5);
707- else glutAddMenuEntry("[ ] Fermi velocity (Auto)", 5);
708- if (fcscl == 6) glutAddMenuEntry("[x] Fermi velocity (Manual)", 6);
709- else glutAddMenuEntry("[ ] Fermi velocity (Manual)", 6);
710- if (fcscl == 7) glutAddMenuEntry("[x] Gray scale (Auto)", 7);
711- else glutAddMenuEntry("[ ] Gray scale (Auto)", 7);
712- if (fcscl == 8) glutAddMenuEntry("[x] Gray scale (Manual)", 8);
713- else glutAddMenuEntry("[ ] Gray scale (Manual)", 8);
723+ glutAddMenuEntry("Max/Min of Scale", 0);
724+ if (color_scale == 1) glutAddMenuEntry("[x] Input (Real)", 1);
725+ else glutAddMenuEntry("[ ] Input (Real)", 1);
726+ if (color_scale == 2) glutAddMenuEntry("[x] Input (Complex)", 2);
727+ else glutAddMenuEntry("[ ] Input (Complex)", 2);
728+ if (color_scale == 3) glutAddMenuEntry("[x] Fermi Velocity", 3);
729+ else glutAddMenuEntry("[ ] Fermi Velocity", 3);
730+ if (color_scale == 4) glutAddMenuEntry("[x] Band Index", 4);
731+ else glutAddMenuEntry("[ ] Band Index", 4);
732+ if (color_scale == 5) glutAddMenuEntry("[x] Input (Real, Gray Scale)", 5);
733+ else glutAddMenuEntry("[ ] Input (Real, Gray Scale)", 5);
734+ if (color_scale == 6) glutAddMenuEntry("[x] Fermi Velocity (Gray Scale)", 6);
735+ else glutAddMenuEntry("[ ] Fermi Velocity (Gray Scale)", 6);
714736 /*
715737 Equator
716738 */
--- a/src/read_file.c
+++ b/src/read_file.c
@@ -208,7 +208,7 @@ void read_file(
208208 mat0[ib][ii0][ii1][ii2][1] = 0.0;
209209 }
210210 else
211- ierr = fscanf(fp, "%e%e", &mat0[ib][ii0][ii1][ii2][0], &mat0[ib][ii0][ii1][ii2][2]);
211+ ierr = fscanf(fp, "%e%e", &mat0[ib][ii0][ii1][ii2][0], &mat0[ib][ii0][ii1][ii2][1]);
212212 mat0[ib][ii0][ii1][ii2][2] = 0.0;
213213 }/*for (i2 = 0; i2 < ng0[2]; ++i2)*/
214214 }/*for (i1 = 0; i1 < ng0[1]; ++i1)*/
@@ -235,7 +235,7 @@ void read_batch(
235235 for (ib = 0; ib < nb; ib++)
236236 ierr = fscanf(fp, "%d", &draw_band[ib]);
237237 ierr = fscanf(fp, "%d", &lcolorbar);
238- ierr = fscanf(fp, "%d", &fcscl);
238+ ierr = fscanf(fp, "%d", &color_scale);
239239 ierr = fscanf(fp, "%d", &lequator);
240240 if (lequator == 1)
241241 ierr = fscanf(fp, "%f %f %f", &eqvec[0], &eqvec[1], &eqvec[2]);
--- a/src/variable.h
+++ b/src/variable.h
@@ -53,24 +53,24 @@ GLfloat *****mat0; //!< Matrix element [::nb][::ng0[0]][::ng0[1]][::ng0[2]][3]
5353 /*
5454 Interpolation
5555 */
56-int ng[3]; //!< @b Interpolated @f$k@f$-grids
57-GLfloat ****eig; //!< Eigenvalues @f$\varepsilon_{n k}@f$ [::nb][::ng[0]][::ng[1]][::ng[2]]
56+int ng[3]; //!< @b Interpolated @f$k@f$-grids
57+GLfloat ****eig; //!< Eigenvalues @f$\varepsilon_{n k}@f$ [::nb][::ng[0]][::ng[1]][::ng[2]]
5858 GLfloat *****mat; //!< Matrix element @f$\delta_{n k}@f$ [::nb][::ng[0]][::ng[1]][::ng[2]][3]
59-GLfloat *****vf; //!< Matrix element @f$\{\bf v}_{{\rm f} n k}@f$ [::nb][::ng[0]][::ng[1]][::ng[2]][3]
60-int interpol; //!< Ratio of interpolation
59+GLfloat *****vf; //!< Matrix element @f$\{\bf v}_{{\rm f} n k}@f$ [::nb][::ng[0]][::ng[1]][::ng[2]][3]
60+int interpol; //!< Ratio of interpolation
6161 /*
6262 Switch for some modes
6363 */
64-int blackback; //!< Switch for black background
65-int fcscl; //!< Switch for full color scale mode
66-int fbz; //!< Switch for 1st Brillouin zone mode
67-int nodeline; //!< Switch for node lines
68-int lcolorbar; //!< Switch for colorbar
69-int lstereo; //!< Switch for the stereogram
70-int lmouse; //!< Switch for the mouse function
71-int lsection; //!< Switch for the 2D Fermi lines
72-int lside; //!< Switch for lighting
73-int lequator; //!< Switch for equator
64+int blackback; //!< Switch for black background
65+int color_scale; //!< Switch for full color scale mode
66+int fbz; //!< Switch for 1st Brillouin zone mode
67+int nodeline; //!< Switch for node lines
68+int lcolorbar; //!< Switch for colorbar
69+int lstereo; //!< Switch for the stereogram
70+int lmouse; //!< Switch for the mouse function
71+int lsection; //!< Switch for the 2D Fermi lines
72+int lside; //!< Switch for lighting
73+int lequator; //!< Switch for equator
7474 /*
7575 Menu
7676 */
@@ -100,6 +100,8 @@ GLfloat ****matp; //!< Matrix elements of points [::nb][::ntri][3][3]
100100 GLfloat **clr; //!< Colors of points [::nb][::ntri*3*4]
101101 int itet; //!< Counter for tetrahedron
102102 GLfloat side; //!< Which side is lighted
103+GLfloat patch_max; //!< Max value across patch
104+GLfloat patch_min; //!< Max value across patch
103105 /*
104106 Variables for nodeline
105107 */
Show on old repository browser