FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
hecmw_vis_read_control.c
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright (c) 2019 FrontISTR Commons
3 * This software is released under the MIT License, see LICENSE.txt
4 *****************************************************************************/
5
7
8#include <stdlib.h>
9#include <string.h>
10#include <ctype.h>
11#include "hecmw_vis_mem_util.h"
12#include "hecmw_malloc.h"
13
14int is_blank_line(char *buf) {
15 int i;
16 int flag;
17
18 i = 0;
19 flag = 1;
20 while (buf[i] != '\n') {
21 if (buf[i] != ' ') {
22 flag = 0;
23 break;
24 }
25 i++;
26 }
27 return (flag);
28}
29
30int is_comment_line(char *buf) {
31 int flag;
32 flag = 0;
33 if (buf[0] == '#')
34 flag = 1;
35 else if ((buf[0] == '!') && (buf[1] == '!'))
36 flag = 1;
37 return (flag);
38}
39
40void get_string_item(char *para, char *buf, int *start_location,
41 char para2[128]) {
42 int i, j;
43
44 i = *start_location;
45 while ((buf[i] == ',') || (buf[i] == ' ') || (buf[i] == '=')) i++;
46 if (buf[i] == '\n') {
47 fprintf(stderr, "No string value for %s\n", para);
49 "ERROR: HEC-MW-VIS-E0002: The control parameter format error: should "
50 "start from !");
51 }
52 j = 0;
53 while ((buf[i] != ' ') && (buf[i] != ',') && (buf[i] != '\n')) {
54 para2[j] = buf[i];
55 i++;
56 j++;
57 }
58 para2[j] = '\0';
59 *start_location = i;
60 return;
61}
62
63int get_int_item(char *para, char *buf, int *start_location) {
64 int value;
65 int i, j;
66 char para2[128];
67
68 i = *start_location;
69 while ((buf[i] == ',') || (buf[i] == ' ') || (buf[i] == '=')) i++;
70 if (buf[i] == '\n') {
72 "ERROR: HEC-MW-VIS-E0003:The control parameter format error:No integer "
73 "value for %s");
74 }
75 j = 0;
76 while ((buf[i] != ' ') && (buf[i] != ',') && (buf[i] != '\n')) {
77 para2[j] = buf[i];
78 i++;
79 j++;
80 }
81 para2[j] = '\0';
82 if ((isdigit(para2[0]) == 0) && (para2[0] != '+') && (para2[0] != '-')) {
83 fprintf(stderr, "ERROR: HEC-MW-VIS-E0004: %s should be integer \n", para);
84 HECMW_vis_print_exit("Please re-input and run again!");
85 }
86 value = atoi(para2);
87 *start_location = i;
88 return (value);
89}
90
91double get_double_item(char *para, char *buf, int *start_location) {
92 double value;
93 int i, j;
94 char para2[128];
95
96 i = *start_location;
97 while ((buf[i] == ',') || (buf[i] == ' ') || (buf[i] == '=')) i++;
98 if (buf[i] == '\n') {
99 fprintf(stderr, "No integer value for %s\n", para);
100 HECMW_vis_print_exit("The control parameter format error:!");
101 }
102 j = 0;
103 while ((buf[i] != ' ') && (buf[i] != ',') && (buf[i] != '\n')) {
104 para2[j] = buf[i];
105 i++;
106 j++;
107 }
108 para2[j] = '\0';
109 if ((isdigit(para2[0]) == 0) && (para2[0] != '+') && (para2[0] != '-')) {
110 fprintf(stderr, "ERROR: HEC-MW-VIS-E0005:%s should be a real \n", para);
111 HECMW_vis_print_exit("Please re-input and run again!");
112 }
113 value = atof(para2);
114 *start_location = i;
115 return (value);
116}
117
118int get_keyword_item(char *buf, char *para) {
119 int i, j;
120 i = 0;
121 while (buf[i] == ' ') i++;
122 if (buf[i] != '!') {
123 fprintf(stderr, "Please check the line %s\n", buf);
124 HECMW_vis_print_exit("The control parameter format error:!");
125 }
126 i++;
127 j = 0;
128 while ((buf[i] != ' ') && (buf[i] != '=') && (buf[i] != ',') &&
129 (buf[i] != '\n')) {
130 para[j] = buf[i];
131 i++;
132 j++;
133 }
134 para[j] = '\0';
135 return (i);
136}
137
138static int identify_surface(char *buf) {
139 int i, j, ii, len_tmp;
140 int flag;
141 char para[128], para1[128];
142 i = 0;
143 while (buf[i] == ' ') i++;
144 if (buf[i] != '!')
146 "ERROR: HEC-MW-VIS-E0002: The control parameter format error: should "
147 "start from !");
148 i = i + 1;
149 j = 0;
150 while ((buf[i] != ' ') && (buf[i] != ',') && (buf[i] != '\n')) {
151 para[j] = buf[i];
152 i++;
153 j++;
154 }
155 para[j] = '\0';
156 flag = 1;
157 len_tmp = strlen(para);
158 sprintf(para1, "%s", para);
159 for (ii = 0; ii < len_tmp; ii++) {
160 para[ii] = tolower(para1[ii]);
161 }
162 if (strlen(para) > 8)
163 flag = 0;
164 else if ((strncmp(para, "SURFACE", 7) != 0) &&
165 (strncmp(para, "surface", 7) != 0))
166 flag = 0;
167 return (flag);
168}
169
170#if 0
171int identify_rendering(char *buf) {
172 int i,j, ii, len_tmp;
173 int flag;
174 char para[128];
175 i=0;
176 while(buf[i]==' ')
177 i++;
178 if(buf[i]!='!')
179 HECMW_vis_print_exit("ERROR: HEC-MW-VIS-E0002: The control parameter format error: should start from !");
180 i=i+1; j=0;
181 while((buf[i]!=' ') && (buf[i]!=',') && (buf[i]!='\n')) {
182 para[j]=buf[i];
183 i++;
184 j++;
185 }
186 para[j]='\0';
187 flag=1;
188 len_tmp=strlen(para);
189 for(ii=0;ii<len_tmp;ii++) {
190 para[ii]=tolower(para[ii]);
191 }
192
193 if(strlen(para)>8)
194 flag=0;
195 else if((strncmp(para, "SURFACE", 7)!=0) && (strncmp(para, "surface", 7)!=0))
196 flag=0;
197 return (flag);
198}
199#endif
200
201static int get_keyword_visual(char *buf) {
202 int i, j, ii, len_tmp;
203 int flag;
204 char para[128];
205
206 i = 0;
207 while (buf[i] == ' ') i++;
208 if (buf[i] != '!')
210 "ERROR: HEC-MW-VIS-E0002: The control parameter format error: should "
211 "start from !");
212 i = i + 1;
213 j = 0;
214 while ((buf[i] != ' ') && (buf[i] != ',') && (buf[i] != '\n')) {
215 para[j] = buf[i];
216 i++;
217 j++;
218 }
219 flag = 0;
220 para[j] = '\0';
221 len_tmp = strlen(para);
222 for (ii = 0; ii < len_tmp; ii++) {
223 para[ii] = tolower(para[ii]);
224 }
225
226 if ((strncmp(para, "VISUAL", 6) != 0) && (strncmp(para, "visual", 6) != 0)) {
227 flag = 0;
228 return (flag);
229 }
230 while ((buf[i] != '=') && (buf[i] != '\n')) i++;
231 if (buf[i] == '\n')
233 "ERROR: HEC-MW-VIS-E0006:The control parameter format error: visual "
234 "ID");
235 i++;
236 while ((buf[i] == ' ') && (buf[i] != '\n')) i++;
237 if (buf[i] == '\n')
239 "ERROR: HEC-MW-VIS-E0006:The control parameter format error: visual "
240 "ID");
241 j = 0;
242 while ((buf[i] != ' ') && (buf[i] != ',') && (buf[i] != '=') &&
243 (buf[i] != '\n')) {
244 para[j] = buf[i];
245 i++;
246 j++;
247 }
248 para[j] = '\0';
249 len_tmp = strlen(para);
250 for (ii = 0; ii < len_tmp; ii++) {
251 para[ii] = tolower(para[ii]);
252 }
253
254 if ((strncmp(para, "PSR", 3) == 0) || (strncmp(para, "psr", 3) == 0)) {
255 flag = 1;
256 return (flag);
257 }
258
259 if ((strncmp(para, "PVR", 3) == 0) || (strncmp(para, "pvr", 3) == 0)) {
260 flag = 2;
261 return (flag);
262 }
263
265 "ERROR: HEC-MW-VIS-E0007:The control parameter format error: method only "
266 "can be PSR or PVR");
267 return (flag);
268}
269
270static int set_keyword_visual(char *buf, PSF_link *psf, PVR_link *pvr) {
271 int i, j, ii, len_tmp;
272 int flag;
273 char para[128];
274 PSF_link *p1, *p2;
275 PVR_link *t1, *t2;
276 i = 0;
277 while (buf[i] == ' ') i++;
278 if (buf[i] != '!')
280 "ERROR: HEC-MW-VIS-E0002: The control parameter format error: should "
281 "start from !");
282 i = i + 1;
283 j = 0;
284 while ((buf[i] != ' ') && (buf[i] != ',') && (buf[i] != '\n')) {
285 para[j] = buf[i];
286 i++;
287 j++;
288 }
289 para[j] = '\0';
290 flag = 0;
291 len_tmp = strlen(para);
292 for (ii = 0; ii < len_tmp; ii++) {
293 para[ii] = tolower(para[ii]);
294 }
295
296 if ((strncmp(para, "VISUAL", 6) != 0) && (strncmp(para, "visual", 6) != 0)) {
297 flag = 0;
298 return (flag);
299 }
300 while ((buf[i] != '=') && (buf[i] != '\n')) i++;
301 if (buf[i] == '\n')
303 "ERROR: HEC-MW-VIS-E0006:The control parameter format error: visual "
304 "ID");
305 i++;
306 while ((buf[i] == ' ') && (buf[i] != '\n')) i++;
307 if (buf[i] == '\n')
309 "ERROR: HEC-MW-VIS-E0006:The control parameter format error: visual "
310 "ID");
311 j = 0;
312 while ((buf[i] != ' ') && (buf[i] != ',') && (buf[i] != '=') &&
313 (buf[i] != '\n')) {
314 para[j] = buf[i];
315 i++;
316 j++;
317 }
318 para[j] = '\0';
319 len_tmp = strlen(para);
320 for (ii = 0; ii < len_tmp; ii++) {
321 para[ii] = tolower(para[ii]);
322 }
323
324 if ((strncmp(para, "PSR", 3) == 0) || (strncmp(para, "psr", 3) == 0)) {
325 flag = 1;
326 p1 = (PSF_link *)HECMW_calloc(1, sizeof(PSF_link));
327 if (p1 == NULL) HECMW_vis_memory_exit("PSF_link: p1");
328 p2 = psf->next_psf;
329 psf->next_psf = p1;
330 p1->next_psf = p2;
331 psf->num_of_psf++;
332 p1->visual_start_step = -1;
333 p1->visual_end_step = -1;
334 p1->visual_interval_step = 1;
335
336 while ((buf[i] == ',') || (buf[i] == ' ')) i++;
337 while (buf[i] != '\n') {
338 j = 0;
339 while ((buf[i] != ' ') && (buf[i] != ',') && (buf[i] != '=') &&
340 (buf[i] != '\n')) {
341 para[j] = buf[i];
342 i++;
343 j++;
344 }
345 para[j] = '\0';
346 len_tmp = strlen(para);
347 for (ii = 0; ii < len_tmp; ii++) {
348 para[ii] = tolower(para[ii]);
349 }
350
351 if (strncmp(para, "visual_start_step", 12) == 0)
352 p1->visual_start_step = get_int_item(para, buf, &i);
353 else if (strncmp(para, "visual_end_step", 10) == 0)
354 p1->visual_end_step = get_int_item(para, buf, &i);
355 else if (strncmp(para, "visual_interval_step", 14) == 0)
356 p1->visual_interval_step = get_int_item(para, buf, &i);
357 while ((buf[i] == ',') || (buf[i] == ' ')) i++;
358 }
359
360 if ((p1->visual_end_step >= 1) && (p1->visual_start_step == -1))
361 p1->visual_start_step = 1;
362 return (flag);
363 }
364 if ((strncmp(para, "PVR", 3) == 0) || (strncmp(para, "pvr", 3) == 0)) {
365 flag = 2;
366 t1 = (PVR_link *)HECMW_malloc(sizeof(PVR_link));
367 if (t1 == NULL) HECMW_vis_memory_exit("PVR_link: t1");
368 t2 = pvr->next_pvr;
369 pvr->next_pvr = t1;
370 t1->next_pvr = t2;
371 pvr->num_of_pvr++;
372 t1->visual_start_step = -1;
373 t1->visual_end_step = -1;
374 t1->visual_interval_step = 1;
375
376 while ((buf[i] == ',') || (buf[i] == ' ')) i++;
377 while (buf[i] != '\n') {
378 j = 0;
379 while ((buf[i] != ' ') && (buf[i] != ',') && (buf[i] != '=') &&
380 (buf[i] != '\n')) {
381 para[j] = buf[i];
382 i++;
383 j++;
384 }
385 para[j] = '\0';
386 len_tmp = strlen(para);
387 for (ii = 0; ii < len_tmp; ii++) {
388 para[ii] = tolower(para[ii]);
389 }
390
391 if (strncmp(para, "visual_start_step", 12) == 0)
392 t1->visual_start_step = get_int_item(para, buf, &i);
393 else if (strncmp(para, "visual_end_step", 10) == 0)
394 t1->visual_end_step = get_int_item(para, buf, &i);
395 else if (strncmp(para, "visual_interval_step", 14) == 0)
396 t1->visual_interval_step = get_int_item(para, buf, &i);
397 while ((buf[i] == ',') || (buf[i] == ' ')) i++;
398 }
399 if ((t1->visual_end_step >= 1) && (t1->visual_start_step == -1))
400 t1->visual_start_step = 1;
401 return (flag);
402 }
403
405 "ERROR: HEC-MW-VIS-E0007:The control parameter format error: method only "
406 "can be PSR or PVR");
407 return (flag);
408}
409
410static int get_keyword_surface_num(char *buf) {
411 int i, j, ii, len_tmp;
412 char para[128];
413 int surface_num;
414
415 if (buf[0] != '!')
417 "ERROR: HEC-MW-VIS-E0002: The control parameter format error: should "
418 "start from !");
419 i = 1;
420 j = 0;
421 while ((buf[i] != ' ') && (buf[i] != '=') && (buf[i] != ',') &&
422 (buf[i] != '\n')) {
423 para[j] = buf[i];
424 i++;
425 j++;
426 }
427 para[j] = '\0';
428 len_tmp = strlen(para);
429 for (ii = 0; ii < len_tmp; ii++) {
430 para[ii] = tolower(para[ii]);
431 }
432 if ((strncmp(para, "surface_num", 11) != 0) &&
433 (strncmp(para, "SURFACE_NUM", 6) != 0)) {
435 "ERROR: HEC-MW-VIS-E0008:The control parameter format error: "
436 "surface_num should be defined");
437 }
438 while ((buf[i] != '=') && (buf[i] != '\n')) i++;
439 if (buf[i] == '\n')
441 "ERROR: HEC-MW-VIS-E0008:The control parameter format error: "
442 "surface_num should be defined");
443 i++;
444 while ((buf[i] == ' ') && (buf[i] != '\n')) i++;
445 if (buf[i] == '\n')
447 "ERROR: HEC-MW-VIS-E0008:The control parameter format error: "
448 "surface_num should be defined");
449 j = 0;
450 while ((buf[i] != ' ') && (buf[i] != ',') && (buf[i] != '\n')) {
451 para[j] = buf[i];
452 i++;
453 j++;
454 }
455 para[j] = '\0';
456 surface_num = atoi(para);
457
458 return (surface_num);
459}
460
461void HECMW_vis_read_control(FILE *fp, int pesize, int mynode, PSF_link *psf,
462 PVR_link *pvr) {
463 int i, j, k, ii, len_tmp;
464 char buf[MAX_LINE_LEN];
465 char **parameters;
466 int *len_para;
467
468 char para[128], para1[128];
469 int hit;
470 int surface_num;
471 int *stat_para;
472 int location, visual_method;
473 PSF_link *p1;
474 struct surface_module *sf;
476 PVR_link *t1;
477 Parameter_vr *vr;
478 int cont_flag;
479
480 cont_flag = 1;
481 while (cont_flag) {
482 if (fgets(buf, MAX_LINE_LEN, fp) != NULL) {
483 if ((is_blank_line(buf) == 0) && (is_comment_line(buf) == 0)) break;
484 } else
485 cont_flag = 0;
486 }
487 /* fseek(fp, offset, SEEK_SET);
488 */
489
490 hit = 0;
491 visual_method = 0;
492 if (cont_flag == 1) visual_method = get_keyword_visual(buf);
493 while ((visual_method > 0) && (cont_flag == 1)) {
494 set_keyword_visual(buf, psf, pvr);
495 while (cont_flag) {
496 if (fgets(buf, MAX_LINE_LEN, fp) != NULL) {
497 if ((is_blank_line(buf) == 0) && (is_comment_line(buf) == 0)) break;
498 } else
499 cont_flag = 0;
500 }
501 if ((visual_method == 1) && (cont_flag == 1)) {
502 visual_method = 0;
503 surface_num = get_keyword_surface_num(buf);
504 sf = (struct surface_module *)HECMW_calloc(surface_num + 1,
505 sizeof(struct surface_module));
506 if (sf == NULL) HECMW_vis_memory_exit("surface parameters: sf");
507 sf[0].surface_style = surface_num;
509 if (sr == NULL) HECMW_vis_memory_exit("rendering parameters: sr");
510 sr->projection_style = 1;
511 parameters = (char **)HECMW_calloc(NUM_CONTROL_PSF, sizeof(char *));
512 len_para = (int *)HECMW_calloc(NUM_CONTROL_PSF, sizeof(int));
513 stat_para = (int *)HECMW_calloc(NUM_CONTROL_PSF, sizeof(int));
514 for (i = 0; i < NUM_CONTROL_PSF; i++) {
515 parameters[i] = (char *)HECMW_calloc(128, sizeof(char));
516 if (parameters[i] == NULL)
517 HECMW_vis_memory_exit("tempory parameters: Parameter");
518 }
519 strcpy(parameters[0], "surface_style");
520 len_para[0] = 12;
521 strcpy(parameters[1], "group_name");
522 len_para[1] = 10;
523 strcpy(parameters[2], "defined_style");
524 len_para[2] = 12;
525 strcpy(parameters[3], "data_comp_name");
526 len_para[3] = 12;
527 strcpy(parameters[4], "data_comp");
528 len_para[4] = 9;
529 strcpy(parameters[5], "data_subcomp_name");
530 len_para[5] = 14;
531 strcpy(parameters[6], "data_subcomp");
532 len_para[6] = 12;
533 strcpy(parameters[7], "iso_value");
534 len_para[7] = 9;
535 strcpy(parameters[8], "method");
536 len_para[8] = 6;
537 strcpy(parameters[9], "point");
538 len_para[9] = 5;
539 strcpy(parameters[10], "radius");
540 len_para[10] = 6;
541 strcpy(parameters[11], "length");
542 len_para[11] = 6;
543 strcpy(parameters[12], "coef");
544 len_para[12] = 4;
545 strcpy(parameters[13], "display_method");
546 len_para[13] = 14;
547 strcpy(parameters[14], "color_comp_name");
548 len_para[14] = 14;
549 strcpy(parameters[15], "color_comp");
550 len_para[15] = 10;
551 strcpy(parameters[16], "color_subcomp_name");
552 len_para[16] = 18;
553 strcpy(parameters[17], "color_subcomp");
554 len_para[17] = 13;
555 strcpy(parameters[18], "isoline_number");
556 len_para[18] = 14;
557 strcpy(parameters[19], "specified_color");
558 len_para[19] = 14;
559 strcpy(parameters[20], "output_type");
560 len_para[20] = 11;
561 strcpy(parameters[21], "range_filename");
562 len_para[21] = 10;
563 strcpy(parameters[22], "normalize_on");
564 len_para[22] = 12;
565
566 strcpy(parameters[23], "x_resolution");
567 strcpy(parameters[24], "y_resolution");
568 len_para[23] = len_para[24] = 12;
569 strcpy(parameters[25], "num_of_lights");
570 len_para[25] = 13;
571 strcpy(parameters[26], "position_of_lights");
572 len_para[26] = 18;
573 strcpy(parameters[27], "viewpoint");
574 len_para[27] = 9;
575 strcpy(parameters[28], "look_at_point");
576 len_para[28] = 13;
577 strcpy(parameters[29], "up_direction");
578 len_para[29] = 12;
579 strcpy(parameters[30], "ambient_coef");
580 len_para[30] = 12;
581 strcpy(parameters[31], "diffuse_coef");
582 len_para[31] = 12;
583 strcpy(parameters[32], "specular_coef");
584 len_para[32] = 13;
585 strcpy(parameters[33], "color_mapping_style");
586 len_para[33] = 19;
587 strcpy(parameters[34], "interval_mapping_num");
588 len_para[34] = 20;
589 strcpy(parameters[35], "interval_mapping");
590 len_para[35] = 16;
591 strcpy(parameters[36], "rotate_style");
592 len_para[36] = 12;
593 strcpy(parameters[37], "rotate_num_of_frames");
594 len_para[37] = 15;
595 strcpy(parameters[38], "color_mapping_bar_on");
596 len_para[38] = 17;
597 strcpy(parameters[39], "scale_marking_on");
598 len_para[39] = 15;
599 strcpy(parameters[40], "background_color");
600 len_para[40] = 12;
601 strcpy(parameters[41], "font_color");
602 len_para[41] = 9;
603 strcpy(parameters[42], "color_system_type");
604 len_para[42] = 12;
605 strcpy(parameters[43], "font_size");
606 len_para[43] = 8;
607 strcpy(parameters[44], "color_bar_style");
608 len_para[44] = 13;
609 strcpy(parameters[45], "fixed_range_on");
610 len_para[45] = 11;
611 strcpy(parameters[46], "range_value");
612 len_para[46] = 11;
613 strcpy(parameters[47], "num_of_scale");
614 len_para[47] = 11;
615 strcpy(parameters[48], "mark_0_on");
616 len_para[48] = 9;
617 strcpy(parameters[49], "opacity_mapping_style");
618 len_para[49] = 21;
619 strcpy(parameters[50], "opa_value");
620 len_para[50] = 8;
621 strcpy(parameters[51], "num_of_features");
622 len_para[51] = 14;
623 strcpy(parameters[52], "fea_point");
624 len_para[52] = 8;
625 strcpy(parameters[53], "lookup_filename");
626 len_para[53] = 15;
627 strcpy(parameters[54], "histogram_on");
628 len_para[54] = 11;
629 strcpy(parameters[55], "boundary_line_on");
630 len_para[55] = 11;
631 strcpy(parameters[56], "isoline_color");
632 len_para[56] = 12;
633 strcpy(parameters[57], "time_mark_on");
634 len_para[57] = 10;
635 strcpy(parameters[58], "fixed_scale_mark");
636 len_para[58] = 15;
637 strcpy(parameters[59], "deform_display_on");
638 len_para[59] = 13;
639 strcpy(parameters[60], "deform_scale");
640 len_para[60] = 11;
641 strcpy(parameters[61], "initial_style");
642 len_para[61] = 12;
643 strcpy(parameters[62], "deform_style");
644 len_para[62] = 11;
645 strcpy(parameters[63], "deform_comp_name");
646 len_para[63] = 15;
647 strcpy(parameters[64], "deform_comp");
648 len_para[64] = 11;
649 strcpy(parameters[65], "initial_line_color");
650 len_para[65] = 15;
651 strcpy(parameters[66], "deform_line_color");
652 len_para[66] = 15;
653 strcpy(parameters[67], "deform_num_of_frames");
654 len_para[67] = 15;
655 strcpy(parameters[68], "smooth_shading_on");
656 len_para[68] = 15;
657 strcpy(parameters[69], "real_deform_scale");
658 len_para[69] = 16;
659 strcpy(parameters[70], "fixed_mesh_range");
660 len_para[70] = 14;
661 strcpy(parameters[71], "start_time");
662 len_para[71] = 9;
663 strcpy(parameters[72], "time_interval");
664 len_para[72] = 9;
665
666 for (i = 0; i < NUM_CONTROL_PSF; i++) {
667 stat_para[i] = 0;
668 }
669
670 while (cont_flag == 1) {
671 if (fgets(buf, MAX_LINE_LEN, fp) != NULL) {
672 if ((is_blank_line(buf) == 0) && (is_comment_line(buf) == 0)) break;
673 } else
674 cont_flag = 0;
675 }
676 for (k = 1; k < surface_num + 1; k++) {
677 sprintf(sf[k].data_comp_name, "%s", "NULL");
678 sprintf(sf[k].color_comp_name, "%s", "NULL");
679 sprintf(sf[k].data_subcomp_name, "%s", "NULL");
680 sprintf(sf[k].color_subcomp_name, "%s", "NULL");
681 sprintf(sf[k].disp_comp_name, "%s", "NULL");
682 sf[k].data_comp = -1;
683 sf[k].data_subcomp = -1;
684 sf[k].color_comp = -1;
685 sf[k].color_subcomp = -1;
686 sf[k].isoline_number = 0;
687 sf[k].range_output = 0;
688 sf[k].normalize_flag = 1;
689 sf[k].disp_comp = -1;
690 for (i = 0; i < 23; i++) {
691 stat_para[i] = 0;
692 }
693 for (i = 59; i < 67; i++) stat_para[i] = 0;
694 if (cont_flag == 1)
695 if ((get_keyword_visual(buf) == 0) && (identify_surface(buf) == 1)) {
696 while (cont_flag == 1) {
697 if (fgets(buf, MAX_LINE_LEN, fp) != NULL) {
698 if ((is_blank_line(buf) == 0) && (is_comment_line(buf) == 0))
699 break;
700 } else
701 cont_flag = 0;
702 }
703 if (cont_flag == 1)
704 while ((get_keyword_visual(buf) == 0) &&
705 (identify_surface(buf) == 0)) {
706 hit = -1;
707 location = get_keyword_item(buf, para);
708 len_tmp = strlen(para);
709 for (ii = 0; ii < len_tmp; ii++) {
710 para[ii] = tolower(para[ii]);
711 }
712 for (i = 0; i < NUM_CONTROL_PSF; i++) {
713 if ((strncmp(para, parameters[i], len_para[i])) == 0) {
714 hit = i;
715 stat_para[i] = 1;
716 break;
717 }
718 }
719 /* fprintf(stderr, "para=%s hit=%d\n", para, hit);
720 */
721 if ((hit >= 0) && (hit < NUM_CONTROL_PSF)) {
722 switch (hit) {
723 case 0:
724 sf[k].surface_style = get_int_item(para, buf, &location);
725 break;
726 case 1:
727 get_string_item(para, buf, &location, sf[k].group_name);
728 break;
729 case 2:
730 sf[k].defined_style = get_int_item(para, buf, &location);
731 break;
732 case 3:
733 get_string_item(para, buf, &location,
734 sf[k].data_comp_name);
735 break;
736 case 4:
737 sf[k].data_comp = get_int_item(para, buf, &location);
738 break;
739 case 5:
740 get_string_item(para, buf, &location,
741 sf[k].data_subcomp_name);
742 break;
743
744 case 6:
745 sf[k].data_subcomp = get_int_item(para, buf, &location);
746 break;
747 case 7:
748 sf[k].iso_value = get_double_item(para, buf, &location);
749 break;
750 case 8:
751
752 sf[k].method = get_int_item(para, buf, &location);
753 break;
754 case 9:
755 for (j = 0; j < 3; j++) {
756 sf[k].point[j] = get_double_item(para, buf, &location);
757 }
758 break;
759
760 case 10:
761
762 sf[k].radius = get_double_item(para, buf, &location);
763 break;
764 case 11:
765 for (j = 0; j < 3; j++) {
766 sf[k].length[j] = get_double_item(para, buf, &location);
767 }
768 break;
769 case 12:
770 for (j = 0; j < 10; j++) {
771 sf[k].coef[j] = get_double_item(para, buf, &location);
772 }
773 break;
774 case 13:
775 sf[k].display_method = get_int_item(para, buf, &location);
776 break;
777 case 14:
778 get_string_item(para, buf, &location,
779 sf[k].color_comp_name);
780 break;
781 case 15:
782 sf[k].color_comp = get_int_item(para, buf, &location);
783 break;
784 case 16:
785 get_string_item(para, buf, &location,
786 sf[k].color_subcomp_name);
787 break;
788 case 17:
789 sf[k].color_subcomp = get_int_item(para, buf, &location);
790 break;
791 case 18:
792 sf[k].isoline_number = get_int_item(para, buf, &location);
793 /* fprintf(stderr, "isoline_number is
794 * %d\n", sf[k].isoline_number);
795 */
796 break;
797 case 19:
798 sf[k].specified_color =
799 get_double_item(para, buf, &location);
800
801 break;
802 case 20:
803 get_string_item(para, buf, &location, para1);
804 len_tmp = strlen(para1);
805 for (ii = 0; ii < len_tmp; ii++) {
806 para1[ii] = toupper(para1[ii]);
807 }
808 if (strncmp(para1, "AVS", 3) == 0)
809 sf[k].output_type = 1;
810 else if (strncmp(para1, "GPPVIEW", 7) == 0)
811 sf[k].output_type = 2;
812 else if (strncmp(para1, "BMP", 3) == 0)
813 sf[k].output_type = 3;
814 else if (strncmp(para1, "VIS_FEMAP_NEUTRAL", 17) == 0)
815 sf[k].output_type = 4;
816 else if (strncmp(para1, "FSTR_FEMAP_NEUTRAL", 18) == 0)
817 sf[k].output_type = 5;
818 else if (strncmp(para1, "COMPLETE_AVS", 12) == 0)
819 sf[k].output_type = 6;
820 else if (strncmp(para1, "BIN_COMPLETE_AVS", 16) == 0)
821 sf[k].output_type = 7;
822 else if (strncmp(para1, "COMPLETE_REORDER_AVS", 20) == 0)
823 sf[k].output_type = 8;
824 else if (strncmp(para1, "COMPLETE_MICROAVS", 17) == 0)
825 sf[k].output_type = 9;
826 else if (strncmp(para1, "SEPARATE_COMPLETE_AVS", 21) == 0)
827 sf[k].output_type = 10;
828 else if (strncmp(para1, "BIN_COMPLETE_REORDER_AVS", 24) ==
829 0)
830 sf[k].output_type = 11;
831 else if (strncmp(para1, "BIN_SEPARATE_COMPLETE_AVS",
832 25) == 0)
833 sf[k].output_type = 12;
834 else if (strncmp(para1, "COMP_COMPLETE_REORDER_AVS",
835 25) == 0)
836 sf[k].output_type = 13;
837 else if (strncmp(para1, "COMP_SEPARATE_COMPLETE_AVS",
838 26) == 0)
839 sf[k].output_type = 14;
840 else if (strncmp(para1, "VTK", 3) == 0)
841 sf[k].output_type = 15;
842 else if (strncmp(para1, "BIN_VTK", 7) == 0)
843 sf[k].output_type = 16;
844 else if (strncmp(para1, "COMP_VTK", 8) == 0)
845 sf[k].output_type = 17;
846 else {
847 fprintf(stderr,
848 "ERROR: HEC-MW-VIS-E1001: output_type is not "
849 "correct\n");
851 "AVS or BMP or VIS_FEMAP_NEUTRAL or "
852 "FSTR_FEMAP_NEUTRAL");
853 }
854 break;
855 case 21:
856 sf[k].range_output = 1;
857 get_string_item(para, buf, &location,
858 sf[k].range_filename);
859 break;
860 case 22:
861 sf[k].normalize_flag = get_int_item(para, buf, &location);
862 break;
863 case 23:
864 sr->xr = get_int_item(para, buf, &location);
865 break;
866 case 24:
867 sr->yr = get_int_item(para, buf, &location);
868 break;
869 case 25:
870 sr->num_of_lights = get_int_item(para, buf, &location);
871 break;
872 case 26:
873 sr->light_point = (double *)HECMW_calloc(
874 sr->num_of_lights * 3, sizeof(double));
875 if (sr->light_point == NULL)
876 HECMW_vis_memory_exit("sr: light_point");
877
878 for (i = 0; i < sr->num_of_lights; i++) {
879 sr->light_point[i * 3] =
880 get_double_item(para, buf, &location);
881 sr->light_point[i * 3 + 1] =
882 get_double_item(para, buf, &location);
883 sr->light_point[i * 3 + 2] =
884 get_double_item(para, buf, &location);
885 }
886 break;
887 case 27:
888 for (i = 0; i < 3; i++) {
889 sr->view_point_d[i] =
890 get_double_item(para, buf, &location);
891 }
892
893 break;
894 case 28:
895 for (i = 0; i < 3; i++) {
896 sr->screen_point[i] =
897 get_double_item(para, buf, &location);
898 }
899 break;
900 case 29:
901 for (i = 0; i < 3; i++) {
902 sr->up[i] = get_double_item(para, buf, &location);
903 }
904 break;
905 case 30:
906 sr->k_ads[0] = get_double_item(para, buf, &location);
907 break;
908 case 31:
909 sr->k_ads[1] = get_double_item(para, buf, &location);
910 break;
911 case 32:
912
913 sr->k_ads[2] = get_double_item(para, buf, &location);
914 break;
915 case 33:
917 get_int_item(para, buf, &location);
918 if (sr->color_mapping_style == 1) {
919 sr->interval_mapping_num = 1;
920 } else if (sr->color_mapping_style == 2) {
921 sr->interval_mapping_num = 1;
922 } else if (sr->color_mapping_style == 4) {
923 sr->interval_mapping_num = 10;
924 }
925 break;
926 case 34:
927
929 get_int_item(para, buf, &location);
930 break;
931 case 35:
932 if (sr->color_mapping_style == 2) {
933 sr->interval_point =
934 (double *)HECMW_calloc(2, sizeof(double));
935
936 if (sr->interval_point == NULL)
937 HECMW_vis_memory_exit("interval_point");
938
939 sr->interval_point[0] =
940 get_double_item(para, buf, &location);
941 sr->interval_point[1] =
942 get_double_item(para, buf, &location);
943 } else if (sr->color_mapping_style == 3) {
944 sr->interval_point = (double *)HECMW_calloc(
945 2 * (sr->interval_mapping_num + 1), sizeof(double));
946 if (sr->interval_point == NULL)
947 HECMW_vis_memory_exit("interval_point");
948
949 for (i = 0; i < 2 * ((sr->interval_mapping_num) + 1);
950 i++) {
951 sr->interval_point[i] =
952 get_double_item(para, buf, &location);
953 }
954 }
955 break;
956 case 36:
957 sr->rotate_style = get_int_item(para, buf, &location);
958 break;
959 case 37:
961 get_int_item(para, buf, &location);
962 break;
963 case 38:
965 get_int_item(para, buf, &location);
966 break;
967 case 39:
968 sr->scale_marking_on = get_int_item(para, buf, &location);
969 break;
970 case 40:
971 for (i = 0; i < 3; i++) {
972 sr->background_color[i] =
973 get_double_item(para, buf, &location);
974 }
975 break;
976 case 41:
977 for (i = 0; i < 3; i++) {
978 sr->font_color[i] =
979 get_double_item(para, buf, &location);
980 }
981 break;
982 case 42:
984 get_int_item(para, buf, &location);
985 break;
986 case 43:
987 sr->font_size = get_double_item(para, buf, &location);
988 break;
989 case 44:
990 sr->color_bar_style = get_int_item(para, buf, &location);
991 break;
992 case 45:
993 sr->fixed_range_on = get_int_item(para, buf, &location);
994 break;
995 case 46:
996 for (i = 0; i < 2; i++) {
997 sr->range_value[i] =
998 get_double_item(para, buf, &location);
999 }
1000
1001 break;
1002 case 47:
1003 sr->num_of_scale = get_int_item(para, buf, &location);
1004 break;
1005 case 48:
1006 sr->mark_0_on = get_int_item(para, buf, &location);
1007 break;
1008 case 49:
1010 get_int_item(para, buf, &location);
1011
1012 if (sr->transfer_function_style != 1) sr->opa_value = 0.0;
1013 if ((sr->transfer_function_style != 3) &&
1014 (sr->transfer_function_style != 4)) {
1015 sr->num_of_features = 0;
1016 }
1017 break;
1018 case 50:
1019 sr->opa_value = get_double_item(para, buf, &location);
1020
1021 break;
1022 case 51:
1023 sr->num_of_features = get_int_item(para, buf, &location);
1024 break;
1025 case 52:
1026 if (sr->transfer_function_style == 3)
1027 sr->fea_point = (double *)HECMW_calloc(
1028 sr->num_of_features * 3, sizeof(double));
1029
1030 else if (sr->transfer_function_style == 4)
1031 sr->fea_point = (double *)HECMW_calloc(
1032 sr->num_of_features * 3, sizeof(double));
1033 if (sr->fea_point == NULL)
1034 HECMW_vis_memory_exit("sr: fea_point");
1035
1036 if (sr->transfer_function_style == 3) {
1037 for (i = 0; i < sr->num_of_features * 3; i++) {
1038 sr->fea_point[i] =
1039 get_double_item(para, buf, &location);
1040 }
1041 }
1042 if (sr->transfer_function_style == 4) {
1043 for (i = 0; i < sr->num_of_features * 3; i++) {
1044 sr->fea_point[i] =
1045 get_double_item(para, buf, &location);
1046 }
1047 }
1048 break;
1049 case 53:
1050 get_string_item(para, buf, &location, sr->name_lookup);
1051 break;
1052 case 54:
1053 sr->histogram_on = get_int_item(para, buf, &location);
1054 break;
1055 case 55:
1056 sr->boundary_line_on = get_int_item(para, buf, &location);
1057 break;
1058 case 56:
1059 for (i = 0; i < 3; i++) {
1060 sr->isoline_color[i] =
1061 get_double_item(para, buf, &location);
1062 }
1063 break;
1064 case 57:
1065 sr->time_mark_on = get_int_item(para, buf, &location);
1066 break;
1067 case 58:
1068 sr->fixed_scale_mark = get_int_item(para, buf, &location);
1069 break;
1070 case 59:
1071 sf[k].deform_display_on =
1072 get_int_item(para, buf, &location);
1073 break;
1074 case 60:
1075 sf[k].disp_scale = get_double_item(para, buf, &location);
1076 break;
1077 case 61:
1078 sf[k].initial_style = get_int_item(para, buf, &location);
1079 break;
1080 case 62:
1081 sf[k].deform_style = get_int_item(para, buf, &location);
1082 break;
1083 case 63:
1084 get_string_item(para, buf, &location,
1085 sf[k].disp_comp_name);
1086 break;
1087 case 64:
1088 sf[k].disp_comp = get_int_item(para, buf, &location);
1089 break;
1090 case 65:
1091 for (i = 0; i < 3; i++) {
1092 sf[k].initial_line_color[i] =
1093 get_double_item(para, buf, &location);
1094 }
1095 break;
1096 case 66:
1097 for (i = 0; i < 3; i++) {
1098 sf[k].deform_line_color[i] =
1099 get_double_item(para, buf, &location);
1100 }
1101 break;
1102 case 67:
1104 get_int_item(para, buf, &location);
1105 break;
1106 case 68:
1107 sr->smooth_shading = get_int_item(para, buf, &location);
1108 break;
1109 case 69:
1110 sf[k].real_disp_scale =
1111 get_double_item(para, buf, &location);
1112 break;
1113 case 70:
1114 for (i = 0; i < 6; i++) {
1115 sr->fixed_mesh_range[i] =
1116 get_double_item(para, buf, &location);
1117 }
1118 break;
1119 case 71:
1120 sr->start_time = get_double_item(para, buf, &location);
1121 break;
1122 case 72:
1123 sr->time_interval = get_double_item(para, buf, &location);
1124 break;
1125 }
1126 }
1127 while (cont_flag) {
1128 if (fgets(buf, MAX_LINE_LEN, fp) != NULL) {
1129 if ((is_blank_line(buf) == 0) &&
1130 (is_comment_line(buf) == 0))
1131 break;
1132 } else
1133 cont_flag = 0;
1134 }
1135 if (cont_flag == 0) break;
1136 }
1137 /* check the parameters for the surface k */
1138 if (stat_para[0] == 0) sf[k].surface_style = 1;
1139 if ((sf[k].surface_style < 1) || (sf[k].surface_style > 3))
1141 "ERROR: HEC-MW-VIS-E1002: surface_style only can be 1, 2 or "
1142 "3");
1143
1144 if (sf[k].surface_style == 1) { /* boundary and group surface */
1145 /* if(stat_para[1]==0) {
1146fprintf(stderr, "Please specify the group name for the boundary surace
1147generateion; if to find the whole boundary, please input boundary\n");
1148exit(0);
1149}
1150 */
1151 if (stat_para[2] == 0) { /* default value */
1152 sf[k].defined_style = 2;
1153 }
1154 }
1155 if (sf[k].surface_style == 2) { /* iso-surfaces */
1156 if ((stat_para[3] == 0) && (stat_para[4] == 0))
1157 sf[k].data_comp = 0;
1158 if ((stat_para[5] == 0) && (stat_para[6] == 0))
1159 sf[k].data_subcomp = 1;
1160 if (stat_para[7] == 0)
1162 "ERROR: HEC-MW-VIS-E1002: iso_value should be defined for "
1163 "isosurfaces");
1164 }
1165 if (sf[k].surface_style ==
1166 3) { /* arbitrary surfaces defined by equation */
1167 if (stat_para[8] == 0) sf[k].method = 5;
1168 if (sf[k].method == 1) {
1169 if (stat_para[9] == 0) {
1170 sf[k].point[0] = 0.0, sf[k].point[1] = 0.0;
1171 sf[k].point[2] = 0.0;
1172 if (mynode == 0)
1173 fprintf(
1174 stderr,
1175 "The default center point (0.0, 0.0, 0.0) is used\n");
1176 }
1177 if (stat_para[10] == 0) {
1178 sf[k].radius = 1.0;
1179 if (mynode == 0)
1180 fprintf(stderr, "The default radius 1.0 is used\n");
1181 }
1182 } else if ((sf[k].method == 2) || (sf[k].method == 3) ||
1183 (sf[k].method == 4)) {
1184 if (stat_para[9] == 0) {
1185 sf[k].point[0] = 0.0;
1186 sf[k].point[1] = 0.0;
1187 sf[k].point[2] = 0.0;
1188 if (mynode == 0)
1189 fprintf(
1190 stderr,
1191 "The default center point (0.0, 0.0, 0.0) is used\n");
1192 }
1193 if (stat_para[11] == 0) {
1194 sf[k].length[0] = 1.0;
1195 sf[k].length[1] = 1.0;
1196 sf[k].length[2] = 1.0;
1197 if (mynode == 0)
1198 fprintf(stderr,
1199 "The default length (1.0, 1.0, 1.0) is used\n");
1200 }
1201 } else if (sf[k].method == 5) {
1202 if (stat_para[12] == 0) {
1203 if (mynode == 0)
1204 fprintf(stderr,
1205 "ERROR: HEC-MW-VIS-E1003:The 10 coefficients of "
1206 "the equation should be defined \n");
1207 HECMW_vis_print_exit("Please re-input and run again");
1208 }
1209 }
1210 }
1211
1212 if (stat_para[13] == 0) sf[k].display_method = 1;
1213 if ((sf[k].display_method <= 0) || (sf[k].display_method > 5)) {
1214 if (mynode == 0)
1215 fprintf(stderr,
1216 "ERROR: HEC-MW-VIS-E1004:display_method is not in the "
1217 "reasonable range\n");
1218 HECMW_vis_print_exit("Please re-input and run again");
1219 }
1220 if (sf[k].display_method != 4) {
1221 if ((stat_para[14] == 0) && (stat_para[15] == 0))
1222 sf[k].color_comp = 0;
1223 if ((stat_para[16] == 0) && (stat_para[17] == 0))
1224 sf[k].color_subcomp = 1;
1225 }
1226 if ((sf[k].display_method == 2) || (sf[k].display_method == 3) ||
1227 (sf[k].display_method == 5)) {
1228 if (stat_para[18] == 0) {
1229 if (mynode == 0)
1230 fprintf(stderr,
1231 "No value for the number of isolines. Now using the "
1232 "default value 10");
1233 sf[k].isoline_number = 10;
1234 }
1235 }
1236 if (sf[k].display_method == 4) {
1237 if (stat_para[19] == 0) {
1238 if (mynode == 0) {
1239 fprintf(
1240 stderr,
1241 "The number of specified_color has not been defined\n");
1242 fprintf(stderr, "Now using the default value 0.5\n");
1243 }
1244 sf[k].specified_color = 0.5;
1245 }
1246 }
1247 if (stat_para[20] == 0) sf[k].output_type = 1;
1248 if ((sf[k].output_type < 1) || (sf[k].output_type > 16)) {
1249 if (mynode == 0)
1250 fprintf(stderr, "the output_type only can be 1 -- 16\n");
1251 HECMW_vis_print_exit("pls input and run again");
1252 }
1253 if (stat_para[22] == 0) sf[k].normalize_flag = 0;
1254 if (stat_para[59] == 0) sf[k].deform_display_on = 0;
1255 if ((sf[k].deform_display_on < 0) ||
1256 (sf[k].deform_display_on > 1)) {
1257 fprintf(stderr,
1258 "ERROR: HEC-MW-VIS-E1037: deform_display_on should be 0 "
1259 "or 1");
1260 HECMW_vis_print_exit("Please re-input again");
1261 }
1262 if (sf[k].deform_display_on == 0) sr->deform_num_of_frames = 1;
1263 if ((sf[k].deform_display_on == 1) && (stat_para[67] == 0))
1264 sr->deform_num_of_frames = 8;
1265 /* if((sf[k].deform_display_on==1) &&
1266(sr->deform_num_of_frames==1)) {
1267fprintf(stderr, "For deformation display, the deform_num_of_frames should be
1268greater than 1\n");
1269fprintf(stderr, "The default value 8 will be used\n");
1270sr->deform_num_of_frames = 8;
1271}
1272 */
1273 if (stat_para[60] == 0) sf[k].disp_scale = -1.0;
1274 /* if(sf[k].disp_scale<0.0) {
1275fprintf(stderr, "ERROR: HEC-MW-VIS-E1037: deform_scale should be greater than
12760.0");
1277HECMW_vis_print_exit("Please re-input again");
1278}
1279 */
1280 if (stat_para[61] == 0) sf[k].initial_style = 4;
1281 if (stat_para[62] == 0) sf[k].deform_style = 1;
1282 if ((sf[k].initial_style < 0) || (sf[k].initial_style > 4)) {
1283 fprintf(stderr,
1284 "ERROR: HEC-MW-VIS-E1037: initial_display_style should "
1285 "be in (0, 4)");
1286 HECMW_vis_print_exit("Please re-input again");
1287 }
1288 if ((sf[k].deform_style < 0) || (sf[k].deform_style > 4)) {
1289 fprintf(stderr,
1290 "ERROR: HEC-MW-VIS-E1037: deform_display_style should be "
1291 "in (0, 4)");
1292 HECMW_vis_print_exit("Please re-input again");
1293 }
1294 if ((stat_para[63] == 0) && (stat_para[64] == 0))
1295 sprintf(sf[k].disp_comp_name, "%s", "DISPLACEMENT");
1296 if (stat_para[65] == 0) {
1297 sf[k].initial_line_color[0] = 0.2;
1298 sf[k].initial_line_color[1] = 0.2;
1299 sf[k].initial_line_color[2] = 1.0;
1300 }
1301 if (stat_para[66] == 0) {
1302 sf[k].deform_line_color[0] = 1.0;
1303 sf[k].deform_line_color[1] = 1.0;
1304 sf[k].deform_line_color[2] = 0.0;
1305 }
1306 for (i = 0; i < 3; i++) {
1307 if (sf[k].initial_line_color[i] < 0.0)
1308 sf[k].initial_line_color[i] = 0.0;
1309 if (sf[k].initial_line_color[i] > 1.0)
1310 sf[k].initial_line_color[i] = 1.0;
1311 if (sf[k].deform_line_color[i] < 0.0)
1312 sf[k].deform_line_color[i] = 0.0;
1313 if (sf[k].deform_line_color[i] > 1.0)
1314 sf[k].deform_line_color[i] = 1.0;
1315 }
1316
1317 if (cont_flag == 0)
1318 break;
1319 else if (get_keyword_visual(buf) > 0) {
1320 visual_method = get_keyword_visual(buf);
1321 break;
1322 }
1323 }
1324 } /* end of loop k */
1325 /* fprintf(stderr, "the group name of three is 1: %s 2: %s 3:%s\n",
1326 * sf[1].group_name, sf[2].group_name, sf[3].group_name);
1327 */
1328
1329 /* start reading rendering parameters if output_type==BMP */
1330
1331 /* check and set default */
1332 if (sf[1].output_type == 3) {
1333 if (stat_para[23] == 0) {
1334 /* use default value 256 */
1335 if (mynode == 0)
1336 fprintf(stderr, "No value for xr. Now use the default value 512\n");
1337 sr->xr = 512;
1338 }
1339 /* check xr whether can be divided by 8 */
1340 sr->xr = (int)(sr->xr / 8) * 8;
1341
1342 if (stat_para[24] == 0) {
1343 if (mynode == 0)
1344 fprintf(stderr, "No value for yr. Now use the default value 512\n");
1345 sr->yr = 512;
1346 }
1347 if (sr->xr <= 20) {
1349 "ERROR: HEC-MW-VIS-E1005: The x_resolution should be greater "
1350 "than 20");
1351 }
1352 if (sr->yr <= 20) {
1353 fprintf(stderr,
1354 "ERROR: HEC-MW-VIS-E1006: The y_resolution should be greater "
1355 "than 20\n");
1356 HECMW_vis_print_exit("Please re-input a correct one");
1357 }
1358 if (stat_para[25] == 0) {
1359 if (mynode == 0)
1360 fprintf(
1361 stderr,
1362 "No value for num_of_lights. Now use the default value 1\n");
1363 sr->num_of_lights = 1;
1364 stat_para[25] = 1;
1365 }
1366 if ((stat_para[25] == 1) && (sr->num_of_lights <= 0)) {
1368 "ERROR: HEC-MW-VIS-E1007: The number of light sources should be "
1369 "greater than 0");
1370 }
1371 if (stat_para[29] == 0) {
1372 stat_para[29] = 1;
1373 if (mynode == 0)
1374 fprintf(stderr,
1375 "No value for up_direction. The default value (0.0, 0.0, "
1376 "1.0) is used\n");
1377 sr->up[0] = 0.0;
1378 sr->up[1] = 0.0;
1379 sr->up[2] = 1.0;
1380 }
1381 if (stat_para[30] == 0) {
1382 stat_para[30] = 1;
1383 sr->k_ads[0] = 0.5;
1384 }
1385 if ((stat_para[30] == 1) && (sr->k_ads[0] < 0)) {
1386 fprintf(stderr,
1387 "ERROR: HEC-MW-VIS-E1008: The ambient_coef is not correct. "
1388 "Should be >=0.0\n");
1390 "Please re-input the ambient_coef in your control file");
1391 }
1392 if (stat_para[31] == 0) {
1393 stat_para[31] = 1;
1394 sr->k_ads[1] = 0.5;
1395 }
1396 if ((stat_para[31] == 1) && (sr->k_ads[1] < 0)) {
1397 fprintf(stderr,
1398 "ERROR: HEC-MW-VIS-E1009: The diffuse_coef is not correct. "
1399 "Should be >=0.0\n");
1401 "Please re-input the diffuse_coef in your control file");
1402 }
1403 if (stat_para[32] == 0) {
1404 stat_para[32] = 1;
1405 sr->k_ads[2] = 0.6;
1406 }
1407 if ((stat_para[32] == 1) && (sr->k_ads[2] < 0)) {
1408 fprintf(stderr,
1409 "ERROR: HEC-MW-VIS-E1010: The specular_coef is not correct. "
1410 "Should be >=0.0\n");
1412 "Please re-input the specular_coef in your control file");
1413 }
1414 if (stat_para[33] == 0) {
1415 stat_para[33] = 1;
1416 sr->color_mapping_style = 1;
1417 }
1418 if ((sr->color_mapping_style < 1) || (sr->color_mapping_style > 4)) {
1419 fprintf(stderr,
1420 "ERROR: HEC-MW-VIS-E1011: color_mapping_style should be "
1421 "between 1 and 4\n");
1422 HECMW_vis_print_exit("Please re-input it and run again\n");
1423 }
1424 if ((sr->color_mapping_style == 3) && (stat_para[34] == 0)) {
1425 fprintf(stderr,
1426 "ERROR: HEC-MW-VIS-E1012:For color_mapping_style 3, "
1427 "interval_mapping_num is required\n");
1429 "Please re-input the value of interval_mapping_num");
1430 }
1431 if ((stat_para[34] == 1) && (sr->interval_mapping_num <= 0)) {
1433 "ERROR: HEC-MW-VIS-E1013: For color_mapping_style 3, the "
1434 "interval_mapping_num should be greater than 0");
1435 }
1436 if (((sr->color_mapping_style == 2) ||
1437 (sr->color_mapping_style == 3)) &&
1438 (stat_para[35] == 0)) {
1439 fprintf(stderr,
1440 "ERROR: HEC-MW-VIS-E1014: For color_mapping_style =2 or 3, "
1441 "the interval_point should be defined\n");
1442 HECMW_vis_print_exit("Please re-input the interval_point");
1443 }
1444 if (stat_para[36] == 0) {
1445 sr->rotate_style = 0;
1446 sr->rotate_num_of_frames = 1;
1447 }
1448 if ((sr->rotate_style >= 1) && (sr->rotate_style <= 4)) {
1449 if (stat_para[37] == 0) sr->rotate_num_of_frames = 8;
1450 if (sr->rotate_num_of_frames <= 0) {
1451 fprintf(stderr,
1452 "ERROR: HEC-MW-VIS-E1015: The parameter "
1453 "rotate_num_of_frames cannot be less than 1.\n");
1454 HECMW_vis_print_exit("Please re-input and run again");
1455 }
1456 if (sr->rotate_style == 4) sr->rotate_num_of_frames = 8;
1457 }
1458
1459 if (stat_para[38] == 0) sr->color_mapping_bar_on = 0;
1460 if ((sr->color_mapping_bar_on < 0) || (sr->color_mapping_bar_on > 1)) {
1461 fprintf(stderr,
1462 "ERROR: HEC-MW-VIS-E1016: color_mapping_bar_on parameter "
1463 "only can be defined as 0 or 1\n");
1464 HECMW_vis_print_exit("Please re-input it and run again");
1465 }
1466 if (stat_para[39] == 0) sr->scale_marking_on = 0;
1467 if ((sr->scale_marking_on < 0) || (sr->scale_marking_on > 1)) {
1468 fprintf(stderr,
1469 "ERROR: HEC-MW-VIS-E1017: scale_marking_on parameter only "
1470 "can be defined as 0 or 1\n");
1471 HECMW_vis_print_exit("Please re-input it and run again");
1472 }
1473
1474 if ((sr->color_mapping_bar_on == 1) && (sr->xr < 40)) {
1475 fprintf(stderr,
1476 "ERROR: HEC-MW-VIS-E1018: x resolution should be larger than "
1477 "40 for adding color_mapping_bar case\n");
1478 HECMW_vis_print_exit("please reinput x resolution");
1479 }
1480 if ((sr->scale_marking_on == 1) && (sr->xr < 65)) {
1481 fprintf(stderr,
1482 "ERROR: HEC-MW-VIS-E1019: x resolution should be larger than "
1483 "65 for adding color_mapping and scale marking case\n");
1484 HECMW_vis_print_exit("please re-input x resolution again");
1485 }
1486 if (stat_para[40] == 0)
1487 sr->background_color[0] = sr->background_color[1] =
1488 sr->background_color[2] = 0.0;
1489 if (stat_para[41] == 0)
1490 sr->font_color[0] = sr->font_color[1] = sr->font_color[2] = 1.0;
1491 if (stat_para[42] == 0) sr->color_system_type = 1;
1492 if ((sr->color_system_type <= 0) || (sr->color_system_type > 3)) {
1493 fprintf(stderr,
1494 "ERROR: HEC-MW-VIS-E1020:color_system_type should be between "
1495 "1 and 3\n");
1496 HECMW_vis_print_exit("Please re-input and run again");
1497 }
1498 if ((sr->background_color[0] < -EPSILON) ||
1499 (sr->background_color[0] > 1.0 + EPSILON) ||
1500 (sr->background_color[1] < -EPSILON) ||
1501 (sr->background_color[1] > 1.0 + EPSILON) ||
1502 (sr->background_color[2] < -EPSILON) ||
1503 (sr->background_color[2] > 1.0 + EPSILON)) {
1504 fprintf(stderr,
1505 "ERROR: HEC-MW-VIS-E1021:The background color should be in "
1506 "the interval of (0.0, 1.0)\n");
1507 HECMW_vis_print_exit("Please re-input and run again");
1508 }
1509 if ((sr->font_color[0] < -EPSILON) ||
1510 (sr->font_color[0] > 1.0 + EPSILON) ||
1511 (sr->font_color[1] < -EPSILON) ||
1512 (sr->font_color[1] > 1.0 + EPSILON) ||
1513 (sr->font_color[2] < -EPSILON) ||
1514 (sr->font_color[2] > 1.0 + EPSILON)) {
1515 fprintf(stderr,
1516 "ERROR: HEC-MW-VIS-E1022: The font color should be in the "
1517 "interval of (0.0, 1.0)\n");
1518 HECMW_vis_print_exit("Please re-input and run again");
1519 }
1520 if (stat_para[43] == 0) sr->font_size = 1.0;
1521 if (sr->font_size < 1.0 - EPSILON) {
1522 fprintf(stderr,
1523 "ERROR: HEC-MW-VIS-E1023: font_size paramters cannot be "
1524 "between 1.0 and 4.0\n");
1525 HECMW_vis_print_exit("Please re-input and run again");
1526 }
1527 if (sr->font_size > 4.0) sr->font_size = 4.0;
1528 if (stat_para[44] == 0) sr->color_bar_style = 2;
1529 if ((sr->color_bar_style < 1) || (sr->color_bar_style > 2)) {
1530 fprintf(
1531 stderr,
1532 "ERROR: HEC-MW-VIS-E1024: color_bar_style only can be 1 or 2\n");
1533 HECMW_vis_print_exit("Please input and run again");
1534 }
1535 if (stat_para[45] == 0) sr->fixed_range_on = 0;
1536 if ((sr->fixed_range_on < 0) || (sr->fixed_range_on > 1)) {
1537 fprintf(stderr, "fixed_range_on only can be 0 or 1\n");
1538 HECMW_vis_print_exit("Please input and run again");
1539 }
1540 if (stat_para[47] == 0) sr->num_of_scale = 3;
1541 if (sr->num_of_scale <= 0) {
1542 fprintf(stderr,
1543 "ERROR: HEC-MW-VIS-E1025: num_of_scale only can be greater "
1544 "than 0\n");
1545 HECMW_vis_print_exit("Please input and run again");
1546 }
1547 if ((sr->fixed_range_on == 1) && (stat_para[46] == 0)) {
1548 fprintf(stderr,
1549 "ERROR: HEC-MW-VIS-E1026: range_value is required for "
1550 "fixed_range_on style\n");
1551 HECMW_vis_print_exit("Please re-input and run again");
1552 }
1553 if (stat_para[48] == 0) sr->mark_0_on = 0;
1554 if ((sr->mark_0_on < 0) || (sr->mark_0_on > 1)) {
1555 fprintf(stderr,
1556 "ERROR: HEC-MW-VIS-E1027: mark_0_on only can be 0 or 1\n");
1557 HECMW_vis_print_exit("Please input and run again");
1558 }
1559
1560 if (stat_para[49] == 0) {
1561 stat_para[49] = 1;
1563 stat_para[50] = 1;
1564 sr->opa_value = 1.0;
1565 }
1566 if ((sr->transfer_function_style < 1) ||
1567 (sr->transfer_function_style > 9)) {
1568 fprintf(stderr,
1569 "ERROR: HEC-MW-VIS-E1028: transfer_function_style should be "
1570 "between 1 and 8\n");
1571 HECMW_vis_print_exit("Please re-input and run again");
1572 }
1573 if ((stat_para[50] == 1) && (sr->opa_value < 0)) {
1574 fprintf(stderr,
1575 "ERROR: HEC-MW-VIS-E1029: opacity_value cannot be less than "
1576 "0.0\n");
1577 HECMW_vis_print_exit("Please re-input and run again");
1578 }
1579 if (((sr->transfer_function_style == 3) ||
1580 (sr->transfer_function_style == 4)) &&
1581 (stat_para[51] == 0)) {
1582 fprintf(stderr,
1583 "ERROR: HEC-MW-VIS-E1030:When transfer_function_style =3 or "
1584 "4, num_of_features should be defined\n");
1585 HECMW_vis_print_exit("Please re-input the num_of_features");
1586 }
1587 if ((stat_para[51] == 1) && (sr->num_of_features <= 0)) {
1588 fprintf(stderr,
1589 "ERROR: HEC-MW-VIS-E1031: When transfer_function_style =3 or "
1590 "4, num_of_features should be greater than 0\n");
1591 HECMW_vis_print_exit("Please re-input and run again");
1592 }
1593 if ((stat_para[51] == 1) && (stat_para[52] == 0)) {
1594 fprintf(stderr,
1595 "ERROR: HEC-MW-VIS-E1032:For transfer_function_style =3 or "
1596 "4, feature_points should be defined\n");
1597 HECMW_vis_print_exit("Please re-input your control file");
1598 }
1599 if ((sr->transfer_function_style == 8) && (stat_para[53] == 0)) {
1600 fprintf(stderr,
1601 "ERROR: HEC-MW-VIS-E1033:For transfer_function_style=8, "
1602 "lookup_filename should be specified\n");
1603 HECMW_vis_print_exit("Please re-input the filename");
1604 }
1605 if (stat_para[54] == 0) sr->histogram_on = 0;
1606 if ((sr->histogram_on < 0) || (sr->histogram_on > 2)) {
1607 fprintf(stderr,
1608 "ERROR: HEC-MW-VIS-E1034: histogram_on value should be 0,1, "
1609 "or 2\n");
1610 HECMW_vis_print_exit("Please re-input again");
1611 }
1612 if (stat_para[55] == 0) sr->boundary_line_on = 0;
1613 if ((sr->boundary_line_on < 0) || (sr->boundary_line_on > 1)) {
1614 fprintf(
1615 stderr,
1616 "ERROR: HEC-MW-VIS-E1035: histogram_on value should be 0 or 1");
1617 HECMW_vis_print_exit("Please re-input again");
1618 }
1619 if (stat_para[56] == 0) {
1620 sr->isoline_color[0] = 0.0;
1621 sr->isoline_color[1] = 0.0;
1622 sr->isoline_color[2] = 0.0;
1623 }
1624 if (stat_para[57] == 0) sr->time_mark_on = 0;
1625 if ((sr->time_mark_on < 0) || (sr->time_mark_on > 1)) {
1626 fprintf(
1627 stderr,
1628 "ERROR: HEC-MW-VIS-E1036: time_mark_on value should be 0 or 1");
1629 HECMW_vis_print_exit("Please re-input again");
1630 }
1631 if (stat_para[58] == 0) sr->fixed_scale_mark = 0;
1632 if ((sr->fixed_scale_mark < 0) || (sr->fixed_scale_mark > 1)) {
1633 fprintf(stderr,
1634 "ERROR: HEC-MW-VIS-E1037: fixed_scale_mark value should be 0 "
1635 "or 1");
1636 HECMW_vis_print_exit("Please re-input again");
1637 }
1638 if (stat_para[68] == 0) sr->smooth_shading = 0;
1639
1640 /* fprintf(stderr, "resolution is %d %d\n", sr->xr,
1641sr->yr);
1642fprintf(stderr, "color_mapping style is %d\n", sr->color_mapping_style);
1643fprintf(stderr, "view_point==%lf %lf %lf\n", sr->view_point_d[0],
1644sr->view_point_d[1], sr->view_point_d[2]);
1645 */
1646 }
1647 /* copy the parameters for PSF into psf link */
1648 p1 = psf->next_psf;
1649 p1->num_of_psf = sf[0].surface_style;
1650 p1->sr = sr;
1651 p1->sf = sf;
1652 /* fprintf(stderr, "******** color_comp_name =%s\n",
1653sf[1].color_comp_name);
1654fprintf(stderr, "******** surface_style=%d\n", sf[1].surface_style);
1655fprintf(stderr, "*********current PSF number= %d\n", psf->num_of_psf);
1656 */
1657
1658 for (i = 0; i < NUM_CONTROL_PSF; i++) p1->stat_para[i] = stat_para[i];
1659 for (i = 0; i < NUM_CONTROL_PSF; i++) HECMW_free(parameters[i]);
1660 HECMW_free(parameters);
1661 HECMW_free(stat_para);
1662 HECMW_free(len_para);
1663
1664 } /*end if visual_method=1 */
1665 else if ((visual_method == 2) && (cont_flag == 1)) {
1666 visual_method = 0;
1667 vr = (Parameter_vr *)HECMW_malloc(sizeof(Parameter_vr));
1668 if (vr == NULL) HECMW_vis_memory_exit("PVR parameters: vr");
1669 vr->projection_style = 1;
1670
1671 for (i = 0; i < NUM_CONTROL_PVR; i++) {
1672 parameters = (char **)HECMW_calloc(NUM_CONTROL_PVR, sizeof(char *));
1673 len_para = (int *)HECMW_calloc(NUM_CONTROL_PVR, sizeof(int));
1674 stat_para = (int *)HECMW_calloc(NUM_CONTROL_PVR, sizeof(int));
1675 parameters[i] = (char *)HECMW_calloc(128, sizeof(char));
1676 if (parameters[i] == NULL)
1677 HECMW_vis_memory_exit("tempory variable parameters");
1678 }
1679 vr->opa_value = 0.0;
1680 vr->color_comp = -1;
1681 vr->color_subcomp = -1;
1682 strcpy(parameters[0], "maximum_refinement");
1683 len_para[0] = 18;
1684 strcpy(parameters[1], "x_resolution");
1685 strcpy(parameters[2], "y_resolution");
1686 len_para[1] = len_para[2] = 12;
1687 strcpy(parameters[3], "num_of_lights");
1688 len_para[3] = 13;
1689 strcpy(parameters[4], "position_of_lights");
1690 len_para[4] = 18;
1691 strcpy(parameters[5], "viewpoint");
1692 len_para[5] = 9;
1693 strcpy(parameters[6], "look_at_point");
1694 len_para[6] = 13;
1695 strcpy(parameters[7], "up_direction");
1696 len_para[7] = 12;
1697 strcpy(parameters[8], "ambient_coef");
1698 len_para[8] = 12;
1699 strcpy(parameters[9], "diffuse_coef");
1700 len_para[9] = 12;
1701 strcpy(parameters[10], "specular_coef");
1702 len_para[10] = 13;
1703 strcpy(parameters[11], "surface_on");
1704 len_para[11] = 10;
1705 strcpy(parameters[12], "surface_opacity");
1706 len_para[12] = 15;
1707 strcpy(parameters[13], "color_mapping_style");
1708 len_para[13] = 19;
1709 strcpy(parameters[14], "interval_mapping_num");
1710 len_para[14] = 20;
1711 strcpy(parameters[15], "interval_mapping");
1712 len_para[15] = 16;
1713 strcpy(parameters[16], "opacity_mapping_style");
1714 len_para[16] = 21;
1715 strcpy(parameters[17], "opacity_value");
1716 len_para[17] = 13;
1717 strcpy(parameters[18], "num_of_features");
1718 len_para[18] = 14;
1719 strcpy(parameters[19], "feature_points");
1720 len_para[19] = 14;
1721 strcpy(parameters[20], "lookup_filename");
1722 len_para[20] = 15;
1723 strcpy(parameters[21], "rotate_style");
1724 len_para[21] = 12;
1725 strcpy(parameters[22], "voxel_filename");
1726 len_para[22] = 10;
1727 strcpy(parameters[23], "color_mapping_bar_on");
1728 len_para[23] = 17;
1729 strcpy(parameters[24], "scale_marking_on");
1730 len_para[24] = 15;
1731 strcpy(parameters[25], "color_comp_name");
1732 len_para[25] = 14;
1733 strcpy(parameters[26], "color_subcomp_name");
1734 len_para[26] = 17;
1735 strcpy(parameters[27], "n_voxel_x");
1736 len_para[27] = 9;
1737 strcpy(parameters[28], "n_voxel_y");
1738 len_para[28] = 9;
1739 strcpy(parameters[29], "n_voxel_z");
1740 len_para[29] = 9;
1741 strcpy(parameters[30], "surface_filename");
1742 len_para[30] = 12;
1743 strcpy(parameters[31], "num_of_frames");
1744 len_para[31] = 12;
1745 strcpy(parameters[32], "background_color");
1746 len_para[32] = 12;
1747 strcpy(parameters[33], "font_color");
1748 len_para[33] = 9;
1749 strcpy(parameters[34], "color_system_type");
1750 len_para[34] = 12;
1751 strcpy(parameters[35], "font_size");
1752 len_para[35] = 8;
1753 strcpy(parameters[36], "color_bar_style");
1754 len_para[36] = 13;
1755 strcpy(parameters[37], "fixed_range_on");
1756 len_para[37] = 11;
1757 strcpy(parameters[38], "range_value");
1758 len_para[38] = 11;
1759 strcpy(parameters[39], "num_of_scale");
1760 len_para[39] = 11;
1761 strcpy(parameters[40], "mark_0_on");
1762 len_para[40] = 9;
1763 strcpy(parameters[41], "remove_0_display_on");
1764 len_para[41] = 17;
1765 strcpy(parameters[42], "x_specified_level");
1766 len_para[42] = 15;
1767 strcpy(parameters[43], "y_specified_level");
1768 len_para[43] = 15;
1769 strcpy(parameters[44], "z_specified_level");
1770 len_para[44] = 15;
1771 strcpy(parameters[45], "histogram_on");
1772 len_para[45] = 10;
1773 strcpy(parameters[46], "display_range");
1774 len_para[46] = 13;
1775 strcpy(parameters[47], "time_mark_on");
1776 len_para[47] = 10;
1777 strcpy(parameters[48], "fixed_scale_mark");
1778 len_para[48] = 15;
1779 strcpy(parameters[49], "color_comp");
1780 len_para[49] = 9;
1781 strcpy(parameters[50], "color_subcomp");
1782 len_para[50] = 12;
1783
1784 for (i = 0; i < NUM_CONTROL_PVR; i++) {
1785 stat_para[i] = 0;
1786 }
1787 vr->projection_style = 1;
1788 vr->color_comp = -1;
1789 vr->color_subcomp = -1;
1790 sprintf(vr->color_comp_name, "%s", "NULL");
1791 sprintf(vr->color_subcomp_name, "%s", "NULL");
1792
1793 if (cont_flag == 1)
1794 while (get_keyword_visual(buf) == 0) {
1795 hit = -1;
1796 location = get_keyword_item(buf, para);
1797 len_tmp = strlen(para);
1798 for (ii = 0; ii < len_tmp; ii++) {
1799 para[ii] = tolower(para[ii]);
1800 }
1801 for (i = 0; i < NUM_CONTROL_PVR; i++) {
1802 if ((strncmp(para, parameters[i], len_para[i])) == 0) {
1803 hit = i;
1804 stat_para[i] = 1;
1805 break;
1806 }
1807 }
1808 /* fprintf(stderr, "para=%s hit=%d\n", para, hit);
1809 */
1810
1811 if ((hit >= 0) && (hit < NUM_CONTROL_PVR)) {
1812 switch (hit) {
1813 case 0:
1814 vr->max_level = get_int_item(para, buf, &location);
1815 break;
1816 case 1:
1817 vr->xr = get_int_item(para, buf, &location);
1818 break;
1819 case 2:
1820 vr->yr = get_int_item(para, buf, &location);
1821 break;
1822 case 3:
1823 vr->num_of_lights = get_int_item(para, buf, &location);
1824 break;
1825 case 4:
1826 vr->light_point = (double *)HECMW_calloc(vr->num_of_lights * 3,
1827 sizeof(double));
1828 if (vr->light_point == NULL)
1829 HECMW_vis_memory_exit("Parameter vr: light_point");
1830
1831 for (i = 0; i < vr->num_of_lights; i++) {
1832 vr->light_point[i * 3] =
1833 get_double_item(para, buf, &location);
1834 vr->light_point[i * 3 + 1] =
1835 get_double_item(para, buf, &location);
1836 vr->light_point[i * 3 + 2] =
1837 get_double_item(para, buf, &location);
1838 }
1839 break;
1840 case 5:
1841 for (i = 0; i < 3; i++) {
1842 vr->view_point_d[i] = get_double_item(para, buf, &location);
1843 }
1844
1845 break;
1846 case 6:
1847 for (i = 0; i < 3; i++) {
1848 vr->screen_point[i] = get_double_item(para, buf, &location);
1849 }
1850 break;
1851 case 7:
1852 for (i = 0; i < 3; i++) {
1853 vr->up[i] = get_double_item(para, buf, &location);
1854 }
1855 break;
1856 case 8:
1857
1858 vr->k_ads[0] = get_double_item(para, buf, &location);
1859 break;
1860 case 9:
1861 vr->k_ads[1] = get_double_item(para, buf, &location);
1862 break;
1863 case 10:
1864
1865 vr->k_ads[2] = get_double_item(para, buf, &location);
1866 break;
1867 case 11:
1868
1869 break;
1870 case 12:
1871 break;
1872 case 13:
1873 vr->color_mapping_style = get_int_item(para, buf, &location);
1874 if (vr->color_mapping_style == 1) {
1875 vr->interval_mapping_num = 1;
1876 } else if (vr->color_mapping_style == 2) {
1877 vr->interval_mapping_num = 1;
1878 } else if (vr->color_mapping_style == 4) {
1879 vr->interval_mapping_num = 10;
1880 }
1881 break;
1882 case 14:
1883
1884 vr->interval_mapping_num = get_int_item(para, buf, &location);
1885 break;
1886 case 15:
1887 if (vr->color_mapping_style == 2) {
1888 vr->interval_point =
1889 (double *)HECMW_calloc(2, sizeof(double));
1890
1891 if (vr->interval_point == NULL)
1892 HECMW_vis_memory_exit("interval point");
1893
1894 vr->interval_point[0] = get_double_item(para, buf, &location);
1895 vr->interval_point[1] = get_double_item(para, buf, &location);
1896 } else if (vr->color_mapping_style == 3) {
1897 vr->interval_point = (double *)HECMW_calloc(
1898 2 * (vr->interval_mapping_num + 1), sizeof(double));
1899 if (vr->interval_point == NULL)
1900 HECMW_vis_memory_exit("interval point");
1901
1902 for (i = 0; i < 2 * ((vr->interval_mapping_num) + 1); i++) {
1903 vr->interval_point[i] =
1904 get_double_item(para, buf, &location);
1905 }
1906 }
1907 break;
1908 case 16:
1910 get_int_item(para, buf, &location);
1911 if (vr->transfer_function_style != 1) vr->opa_value = 0.0;
1912 if ((vr->transfer_function_style != 3) &&
1913 (vr->transfer_function_style != 4)) {
1914 vr->num_of_features = 0;
1915 }
1916 break;
1917 case 17:
1918 vr->opa_value = get_double_item(para, buf, &location);
1919
1920 break;
1921 case 18:
1922 vr->num_of_features = get_int_item(para, buf, &location);
1923 break;
1924 case 19:
1925 if (vr->transfer_function_style == 3)
1926 vr->fea_point = (double *)HECMW_calloc(
1927 vr->num_of_features * 3, sizeof(double));
1928
1929 else if (vr->transfer_function_style == 4)
1930 vr->fea_point = (double *)HECMW_calloc(
1931 vr->num_of_features * 3, sizeof(double));
1932 if (vr->fea_point == NULL)
1933 HECMW_vis_memory_exit("vr: fea_point");
1934
1935 if (vr->transfer_function_style == 3) {
1936 for (i = 0; i < vr->num_of_features * 3; i++) {
1937 vr->fea_point[i] = get_double_item(para, buf, &location);
1938 }
1939 }
1940 if (vr->transfer_function_style == 4) {
1941 for (i = 0; i < vr->num_of_features * 3; i++) {
1942 vr->fea_point[i] = get_double_item(para, buf, &location);
1943 }
1944 }
1945 break;
1946 case 20:
1947 get_string_item(para, buf, &location, vr->name_lookup);
1948 break;
1949 case 21:
1950 vr->rotate_style = get_int_item(para, buf, &location);
1951 break;
1952 case 22:
1953 get_string_item(para, buf, &location, vr->name_voxelfile);
1954 break;
1955 case 23:
1956 vr->color_mapping_bar_on = get_int_item(para, buf, &location);
1957 break;
1958 case 24:
1959 vr->scale_marking_on = get_int_item(para, buf, &location);
1960 break;
1961 case 25:
1962 get_string_item(para, buf, &location, vr->color_comp_name);
1963 break;
1964 case 26:
1965 get_string_item(para, buf, &location, vr->color_subcomp_name);
1966 break;
1967 case 27:
1968 vr->nv_xyz[0] = get_int_item(para, buf, &location);
1969 break;
1970 case 28:
1971 vr->nv_xyz[1] = get_int_item(para, buf, &location);
1972 break;
1973 case 29:
1974 vr->nv_xyz[2] = get_int_item(para, buf, &location);
1975 break;
1976 case 30:
1977 break;
1978 case 31:
1979 vr->num_of_frames = get_int_item(para, buf, &location);
1980 break;
1981 case 32:
1982 for (i = 0; i < 3; i++) {
1983 vr->background_color[i] =
1984 get_double_item(para, buf, &location);
1985 }
1986 break;
1987 case 33:
1988 for (i = 0; i < 3; i++) {
1989 vr->font_color[i] = get_double_item(para, buf, &location);
1990 }
1991 break;
1992 case 34:
1993 vr->color_system_type = get_int_item(para, buf, &location);
1994 break;
1995 case 35:
1996 vr->font_size = get_double_item(para, buf, &location);
1997 break;
1998 case 36:
1999 vr->color_bar_style = get_int_item(para, buf, &location);
2000 break;
2001 case 37:
2002 vr->fixed_range_on = get_int_item(para, buf, &location);
2003 break;
2004 case 38:
2005 for (i = 0; i < 2; i++) {
2006 vr->range_value[i] = get_double_item(para, buf, &location);
2007 }
2008
2009 break;
2010 case 39:
2011 vr->num_of_scale = get_int_item(para, buf, &location);
2012 break;
2013 case 40:
2014 vr->mark_0_on = get_int_item(para, buf, &location);
2015 break;
2016 case 41:
2017 vr->remove_0_display_on = get_int_item(para, buf, &location);
2018 break;
2019 case 42:
2020 vr->specified_level[0] = get_int_item(para, buf, &location);
2021 break;
2022 case 43:
2023 vr->specified_level[1] = get_int_item(para, buf, &location);
2024 break;
2025 case 44:
2026 vr->specified_level[2] = get_int_item(para, buf, &location);
2027 break;
2028 case 45:
2029 vr->histogram_on = get_int_item(para, buf, &location);
2030 break;
2031 case 46:
2032 for (i = 0; i < 6; i++) {
2033 vr->display_range[i] = get_double_item(para, buf, &location);
2034 }
2035 break;
2036 case 47:
2037 vr->time_mark_on = get_int_item(para, buf, &location);
2038 break;
2039 case 48:
2040 vr->fixed_scale_mark = get_int_item(para, buf, &location);
2041 break;
2042 case 49:
2043 vr->color_comp = get_int_item(para, buf, &location);
2044 break;
2045 case 50:
2046 vr->color_subcomp = get_int_item(para, buf, &location);
2047 break;
2048 }
2049 }
2050 while (cont_flag) {
2051 if (fgets(buf, MAX_LINE_LEN, fp) != NULL) {
2052 if ((is_blank_line(buf) == 0) && (is_comment_line(buf) == 0))
2053 break;
2054 } else
2055 cont_flag = 0;
2056 }
2057 if (cont_flag == 0)
2058 break;
2059 else if (get_keyword_visual(buf) > 0) {
2060 visual_method = get_keyword_visual(buf);
2061 break;
2062 }
2063 }
2064 /* check the parameters */
2065 if (stat_para[0] == 0) {
2066 /* set default value */
2067 vr->max_level = 100;
2068 }
2069 if ((vr->max_level <= 0) && (stat_para[0] == 1)) {
2070 fprintf(stderr,
2071 "ERROR: HEC-MW-VIS-E1038: maximum_refinement parameter should "
2072 "be greater than 0\n");
2073 HECMW_vis_print_exit("Please re-input the value");
2074 }
2075 if (stat_para[1] == 0) {
2076 /* use default value 256 */
2077 vr->xr = 256;
2078 }
2079 /* check xr whether can be divided by 8 */
2080 vr->xr = (int)(vr->xr / 8) * 8;
2081
2082 if (stat_para[2] == 0) {
2083 vr->yr = 256;
2084 }
2085 if (vr->xr <= 20) {
2086 fprintf(stderr,
2087 "ERROR: HEC-MW-VIS-E1005: The x_resolution should be greater "
2088 "than 20\n");
2089 HECMW_vis_print_exit("Please re-input a correct one");
2090 }
2091 if (vr->yr <= 20) {
2092 fprintf(stderr,
2093 "ERROR: HEC-MW-VIS-E1006: The y_resolution should be greater "
2094 "than 20\n");
2095 HECMW_vis_print_exit("Please re-input a correct one");
2096 }
2097 if (stat_para[3] == 0) {
2098 vr->num_of_lights = 1;
2099 stat_para[3] = 1;
2100 }
2101 if ((stat_para[3] == 1) && (vr->num_of_lights <= 0)) {
2103 "ERROR: HEC-MW-VIS-E1007: The number of light sources should be "
2104 "greater than 0");
2105 }
2106 if (stat_para[7] == 0) {
2107 stat_para[7] = 1;
2108 vr->up[0] = 0.0;
2109 vr->up[1] = 1.0;
2110 vr->up[2] = 0.0;
2111 }
2112 if (stat_para[8] == 0) {
2113 stat_para[8] = 1;
2114 vr->k_ads[0] = 0.5;
2115 }
2116 if ((stat_para[8] == 1) && (vr->k_ads[0] < 0)) {
2117 fprintf(stderr,
2118 "ERROR: HEC-MW-VIS-E1008: The ambient_coef is not correct. "
2119 "Should be >=0.0\n");
2121 "Please re-input the ambient_coef in your control file");
2122 }
2123 if (stat_para[9] == 0) {
2124 stat_para[9] = 1;
2125 vr->k_ads[1] = 0.8;
2126 }
2127 if ((stat_para[9] == 1) && (vr->k_ads[1] < 0)) {
2128 fprintf(stderr,
2129 "ERROR: HEC-MW-VIS-E1009: The diffuse_coef is not correct. "
2130 "Should be >=0.0\n");
2132 "Please re-input the diffuse_coef in your control file");
2133 }
2134 if (stat_para[10] == 0) {
2135 stat_para[10] = 1;
2136 vr->k_ads[2] = 0.6;
2137 }
2138 if ((stat_para[10] == 1) && (vr->k_ads[2] < 0)) {
2139 fprintf(stderr,
2140 "ERROR: HEC-MW-VIS-E1010: The specular_coef is not correct. "
2141 "Should be >=0.0\n");
2143 "Please re-input the specular_coef in your control file");
2144 }
2145 /* if(stat_para[11]==0) {
2146 stat_para[11]=1;
2147 vr->surface_on=0;
2148 pvr->surface_on=0;
2149}
2150
2151if((stat_para[11]==1) && ((vr->surface_on<0) || (vr->surface_on>1))) {
2152 fprintf(stderr, "surface_on parameter only can be defined as 0 or 1\n");
2153 fprintf(stderr, "Please re-input it and run again\n");
2154 exit(0);
2155}
2156if((vr->surface_on==1) && (stat_para[12]==0))
2157 vr->surface_opacity=0.2;
2158if((stat_para[12]==1) && (vr->surface_opacity<0.0)) {
2159 fprintf(stderr, "surface_opacity parameter cannot be less than 0.0\n");
2160 fprintf(stderr, "Please re-input it and run again\n");
2161 exit(0);
2162}
2163 */
2164 if (stat_para[13] == 0) {
2165 stat_para[13] = 1;
2166 vr->color_mapping_style = 1;
2167 }
2168 if ((vr->color_mapping_style < 1) || (vr->color_mapping_style > 4)) {
2169 fprintf(stderr,
2170 "ERROR: HEC-MW-VIS-E1011:color_mapping_style should be between "
2171 "1 and 4\n");
2172 HECMW_vis_print_exit("Please re-input it and run again");
2173 }
2174 if ((vr->color_mapping_style == 3) && (stat_para[14] == 0)) {
2175 fprintf(stderr,
2176 "ERROR: HEC-MW-VIS-E1012:For color_mapping_style 3, the "
2177 "parameter interval_mapping_num is required\n");
2179 "Please re-input the value of interval_mapping_num");
2180 }
2181 if ((stat_para[14] == 1) && (vr->interval_mapping_num <= 0)) {
2183 "ERROR: HEC-MW-VIS-E1013:For color_mapping_style 3, the "
2184 "interval_mapping_num should be greater than 0");
2185 }
2186 if (((vr->color_mapping_style == 2) || (vr->color_mapping_style == 3)) &&
2187 (stat_para[15] == 0)) {
2188 fprintf(stderr,
2189 "ERROR: HEC-MW-VIS-E1014:For color_mapping_style =2 or 3, the "
2190 "interval_point should be defined\n");
2191 HECMW_vis_print_exit("Please re-input the interval_point");
2192 }
2193 if (stat_para[16] == 0) {
2194 stat_para[16] = 1;
2196 stat_para[17] = 1;
2197 vr->opa_value = 0.05;
2198 }
2199 if ((vr->transfer_function_style < 1) ||
2200 (vr->transfer_function_style > 8)) {
2201 fprintf(stderr,
2202 "ERROR: HEC-MW-VIS-E1028:transfer_function_style should be "
2203 "between 1 and 8\n");
2204 HECMW_vis_print_exit("Please re-input and run again");
2205 }
2206 if ((stat_para[17] == 1) && (vr->opa_value < 0)) {
2207 fprintf(
2208 stderr,
2209 "ERROR: HEC-MW-VIS-E1029:opacity_value cannot be less than 0.0\n");
2210 fprintf(stderr, "Please re-input and run again\n");
2211 exit(0);
2212 }
2213 if (((vr->transfer_function_style == 3) ||
2214 (vr->transfer_function_style == 4)) &&
2215 (stat_para[18] == 0)) {
2216 fprintf(stderr,
2217 "ERROR: HEC-MW-VIS-E1030:When transfer_function_style =3 or 4, "
2218 "num_of_features should be defined\n");
2219 HECMW_vis_print_exit("Please re-input the num_of_features");
2220 }
2221 if ((stat_para[18] == 1) && (vr->num_of_features <= 0)) {
2222 fprintf(stderr,
2223 "ERROR: HEC-MW-VIS-E1031:When transfer_function_style =3 or 4, "
2224 "num_of_features should be greater than 0\n");
2225 HECMW_vis_print_exit("Please re-input and run again");
2226 }
2227 if ((stat_para[18] == 1) && (stat_para[19] == 0)) {
2228 fprintf(stderr,
2229 "ERROR: HEC-MW-VIS-E1032:For transfer_function_style =3 or 4, "
2230 "feature_points should be defined\n");
2231 HECMW_vis_print_exit("Please re-input your control file");
2232 }
2233 if ((vr->transfer_function_style == 8) && (stat_para[20] == 0)) {
2234 fprintf(stderr,
2235 "ERROR: HEC-MW-VIS-E1033:For transfer_function_style=8, "
2236 "lookup_filename should be specified\n");
2237 HECMW_vis_print_exit("Please re-input the filename");
2238 }
2239 if (stat_para[21] == 0) vr->rotate_style = 0;
2240 if ((vr->rotate_style < 0) || (vr->rotate_style > 4)) {
2242 "ERROR: HEC-MW-VIS-E1039:The rotate_style parameter is wrong. "
2243 "Please input one within (0, 4)");
2244 }
2245 if (stat_para[23] == 0) vr->color_mapping_bar_on = 0;
2246 if ((vr->color_mapping_bar_on < 0) || (vr->color_mapping_bar_on > 1)) {
2247 fprintf(stderr,
2248 "ERROR: HEC-MW-VIS-E1016:color_mapping_bar_on parameter only "
2249 "can be defined as 0 or 1\n");
2250 HECMW_vis_print_exit("Please re-input it and run again");
2251 }
2252 if (stat_para[24] == 0) vr->scale_marking_on = 0;
2253 if ((vr->scale_marking_on < 0) || (vr->scale_marking_on > 1)) {
2254 fprintf(stderr,
2255 "ERROR: HEC-MW-VIS-E1017:scale_marking_on parameter only can "
2256 "be defined as 0 or 1\n");
2257 HECMW_vis_print_exit("Please re-input it and run again");
2258 }
2259
2260 if ((vr->color_mapping_bar_on == 1) && (vr->xr < 40)) {
2261 fprintf(stderr,
2262 "ERROR: HEC-MW-VIS-E1018:x resolution should be larger than 40 "
2263 "for adding color_mapping_bar case\n");
2264 HECMW_vis_print_exit("please reinput x resolution");
2265 }
2266 if ((vr->scale_marking_on == 1) && (vr->xr < 65)) {
2267 fprintf(stderr,
2268 " ERROR: HEC-MW-VIS-E1019: x resolution should be larger than "
2269 "65 for adding color_mapping and scale marking case\n");
2270 HECMW_vis_print_exit("please re-input x resolution again");
2271 }
2272 if (stat_para[25] == 0) {
2273 sprintf(vr->color_comp_name, "%s", "NULL");
2274 }
2275 if (stat_para[26] == 0) {
2276 sprintf(vr->color_subcomp_name, "%s", "norm");
2277 }
2278 if (stat_para[22] == 1) {
2279 vr->nv_xyz[0] = pesize;
2280 vr->nv_xyz[1] = 1;
2281 vr->nv_xyz[2] = 1;
2282 } else if (stat_para[22] == 0) {
2283 if ((stat_para[27] == 0) && (stat_para[28] == 0) &&
2284 (stat_para[29] == 0)) {
2285 vr->nv_xyz[0] = pesize;
2286
2287 vr->nv_xyz[1] = 1;
2288 vr->nv_xyz[2] = 1;
2289 } else if ((stat_para[27] == 0) || (stat_para[28] == 0) ||
2290 (stat_para[29] == 0)) {
2292 "ERROR: HEC-MW-VIS-E1040: please define all the n_voxel_x, "
2293 "n_voxel_y, n_voxel_z parameters");
2294 } else if (vr->nv_xyz[0] * vr->nv_xyz[1] * vr->nv_xyz[2] != pesize) {
2295 fprintf(stderr,
2296 "ERROR: HEC-MW-VIS-E1041: n_voxel_x*n_voxel_y*n_voxel_z "
2297 "should be equal to the number of pes\n");
2298 HECMW_vis_print_exit("Please re-input again");
2299 } else if ((vr->nv_xyz[0] <= 0) || (vr->nv_xyz[1] <= 0) ||
2300 (vr->nv_xyz[2] <= 0)) {
2301 fprintf(stderr,
2302 "ERROR: HEC-MW-VIS-E1042: n_voxel_x,n_voxel_y, and n_voxel_z "
2303 "cannot be less or equal to 0\n");
2304 HECMW_vis_print_exit("Please re-input again");
2305 }
2306 }
2307 /* if((vr->surface_on==1) && (stat_para[30]==0)) {
2308 fprintf(stderr, "The surface_filename should be defined in the surface
2309on case\n");
2310 fprintf(stderr, "Please input again\n");
2311 exit(0);
2312}
2313 */
2314 if ((vr->rotate_style >= 1) && (vr->rotate_style <= 4)) {
2315 if (stat_para[31] == 0) vr->num_of_frames = 8;
2316 if (vr->num_of_frames <= 0) {
2317 fprintf(stderr,
2318 "ERROR: HEC-MW-VIS-E1015: The parameter num_of_frames cannot "
2319 "be less than 1.\n");
2320 HECMW_vis_print_exit("Please re-input and run again");
2321 }
2322 if (vr->rotate_style == 4) vr->num_of_frames = 8;
2323 }
2324 if (stat_para[32] == 0)
2325 vr->background_color[0] = vr->background_color[1] =
2326 vr->background_color[2] = 0.0;
2327 if (stat_para[33] == 0)
2328 vr->font_color[0] = vr->font_color[1] = vr->font_color[2] = 1.0;
2329 if (stat_para[34] == 0) vr->color_system_type = 1;
2330 if ((vr->color_system_type <= 0) || (vr->color_system_type > 3)) {
2331 fprintf(stderr,
2332 "ERROR: HEC-MW-VIS-E1020: color_system_type should be between "
2333 "1 and 3\n");
2334 HECMW_vis_print_exit("Please re-input and run again");
2335 }
2336 if ((vr->background_color[0] < -EPSILON) ||
2337 (vr->background_color[0] > 1.0 + EPSILON) ||
2338 (vr->background_color[1] < -EPSILON) ||
2339 (vr->background_color[1] > 1.0 + EPSILON) ||
2340 (vr->background_color[2] < -EPSILON) ||
2341 (vr->background_color[2] > 1.0 + EPSILON)) {
2342 fprintf(stderr,
2343 "ERROR: HEC-MW-VIS-E1021: The background color should be in "
2344 "the interval of (0.0, 1.0)\n");
2345 HECMW_vis_print_exit("Please re-input and run again");
2346 }
2347 if ((vr->font_color[0] < -EPSILON) ||
2348 (vr->font_color[0] > 1.0 + EPSILON) ||
2349 (vr->font_color[1] < -EPSILON) ||
2350 (vr->font_color[1] > 1.0 + EPSILON) ||
2351 (vr->font_color[2] < -EPSILON) ||
2352 (vr->font_color[2] > 1.0 + EPSILON)) {
2353 fprintf(stderr,
2354 "ERROR: HEC-MW-VIS-E1022: The font color should be in the "
2355 "interval of (0.0, 1.0)\n");
2356 HECMW_vis_print_exit("Please re-input and run again");
2357 }
2358 if (stat_para[35] == 0) vr->font_size = 1.0;
2359 if (vr->font_size < 1.0 - EPSILON) {
2360 fprintf(stderr,
2361 "ERROR: HEC-MW-VIS-E1023: font_size paramters cannot be "
2362 "between 1.0 and 4.0\n");
2363 HECMW_vis_print_exit("Please re-input and run again");
2364 }
2365 if (vr->font_size > 4.0) vr->font_size = 4.0;
2366 if (stat_para[36] == 0) vr->color_bar_style = 2;
2367 if ((vr->color_bar_style < 1) || (vr->color_bar_style > 2)) {
2368 fprintf(
2369 stderr,
2370 "ERROR: HEC-MW-VIS-E1024: color_bar_style only can be 1 or 2\n");
2371 HECMW_vis_print_exit("Please input and run again");
2372 }
2373 if (stat_para[37] == 0) vr->fixed_range_on = 0;
2374 if ((vr->fixed_range_on < 0) || (vr->fixed_range_on > 1)) {
2375 fprintf(stderr,
2376 "ERROR: HEC-MW-VIS-E1043: fixed_range_on only can be 0 or 1\n");
2377 HECMW_vis_print_exit("Please input and run again");
2378 }
2379 if (stat_para[39] == 0) vr->num_of_scale = 3;
2380 if (vr->num_of_scale <= 0) {
2381 fprintf(stderr,
2382 "ERROR: HEC-MW-VIS-E1025: num_of_scale only can be greater "
2383 "than 0\n");
2384 HECMW_vis_print_exit("Please input and run again");
2385 }
2386 if ((stat_para[37] == 1) && (stat_para[38] == 0)) {
2387 fprintf(stderr,
2388 "ERROR: HEC-MW-VIS-E1026:Please input range_value for "
2389 "fixed_range_on style\n");
2390 HECMW_vis_print_exit("Please re-input and run again");
2391 }
2392 if (stat_para[40] == 0) vr->mark_0_on = 0;
2393 if ((vr->mark_0_on < 0) || (vr->mark_0_on > 1)) {
2394 fprintf(stderr,
2395 "ERROR: HEC-MW-VIS-E1044:mark_0_on only can be 0 or 1\n");
2396 HECMW_vis_print_exit("Please input and run again");
2397 }
2398 if (stat_para[41] == 0) vr->remove_0_display_on = 0;
2399 if ((vr->remove_0_display_on < 0) || (vr->remove_0_display_on > 1)) {
2400 fprintf(
2401 stderr,
2402 "ERROR: HEC-MW-VIS-E1045:remove_0_display_on only can be 0 or 1\n");
2403 HECMW_vis_print_exit("Please input and run again");
2404 }
2405 if (stat_para[42] == 0) vr->specified_level[1] = 0;
2406 if (vr->specified_level[0] < 0) {
2407 fprintf(stderr,
2408 "ERROR: HEC-MW-VIS-E1046: x_specified_level should be greater "
2409 "than 0\n");
2410 HECMW_vis_print_exit("Please input and run again");
2411 }
2412 if (stat_para[43] == 0) vr->specified_level[1] = 0;
2413 if (vr->specified_level[1] < 0) {
2414 fprintf(stderr,
2415 "ERROR: HEC-MW-VIS-E1047: y_specified_level should be greater "
2416 "than 0\n");
2417 HECMW_vis_print_exit("Please input and run again");
2418 }
2419 if (stat_para[44] == 0) vr->specified_level[2] = 0;
2420 if (vr->specified_level[2] < 0) {
2421 fprintf(stderr,
2422 "ERROR: HEC-MW-VIS-E1048: z_specified_level should be greater "
2423 "than 0\n");
2424 HECMW_vis_print_exit("Please input and run again");
2425 }
2426 if (stat_para[45] == 0) vr->histogram_on = 0;
2427 if (stat_para[47] == 0) vr->time_mark_on = 0;
2428 if ((vr->time_mark_on < 0) || (vr->time_mark_on > 1)) {
2429 fprintf(stderr,
2430 "ERROR: HEC-MW-VIS-E1050: time_mark_on value should be 0 or 1");
2431 HECMW_vis_print_exit("Please re-input again");
2432 }
2433 if (stat_para[48] == 0) vr->fixed_scale_mark = 0;
2434 if ((vr->fixed_scale_mark < 0) || (vr->fixed_scale_mark > 1)) {
2435 fprintf(
2436 stderr,
2437 "ERROR: HEC-MW-VIS-E1049: fixed_scale_mark value should be 0 or 1");
2438 HECMW_vis_print_exit("Please re-input again");
2439 }
2440 t1 = pvr->next_pvr;
2441 t1->vr = vr;
2442
2443 for (i = 0; i < NUM_CONTROL_PVR; i++) t1->stat_para[i] = stat_para[i];
2444 for (i = 0; i < NUM_CONTROL_PVR; i++) HECMW_free(parameters[i]);
2445 HECMW_free(parameters);
2446 HECMW_free(stat_para);
2447 HECMW_free(len_para);
2448 } /*end if visual_method=2 */
2449
2450 } /*end if visual_method>0 */
2451 /* print some control information */
2452 return;
2453}
2454
2455#if 0
2456void set_default_vr( Parameter_vr *vr,int stat_para[NUM_CONTROL_PVR], int pesize)
2457{
2458 int i;
2459 stat_para[0]=stat_para[1]=stat_para[2]=0;
2460 vr->max_level=64;
2461 vr->xr=256;
2462 vr->yr=256;
2463 stat_para[3]=1;
2464 vr->num_of_lights=1;
2465 stat_para[4]=stat_para[5]=stat_para[6]=0;
2466 stat_para[7]=1;
2467 vr->up[0]=0.0;
2468 vr->up[1]=1.0;
2469 vr->up[2]=0.0;
2470 stat_para[8]=stat_para[9]=stat_para[10]=1;
2471 vr->k_ads[0]=0.5;
2472 vr->k_ads[1]=0.8;
2473 vr->k_ads[2]=0.6;
2474 stat_para[11]=1;
2475 /* vr->surface_on=0;
2476 */ stat_para[12]=0;
2477 stat_para[13]=1;
2478 vr->color_mapping_style=1;
2479 stat_para[14]=stat_para[15]=0;
2480 stat_para[16]=stat_para[17]=1;
2481 stat_para[46]=0;
2483 vr->opa_value=0.1;
2484 for(i=18;i<NUM_CONTROL_PVR;i++)
2485 stat_para[i]=0;
2487 vr->scale_marking_on=0;
2488 vr->rotate_style=0;
2489 vr->color_system_type=1;
2490 sprintf(vr->color_comp_name,"%s", "NULL");
2491 sprintf(vr->color_subcomp_name,"%s", "norm");
2492 vr->nv_xyz[0]=pesize;
2493 vr->nv_xyz[1]=1;
2494 vr->nv_xyz[2]=1;
2495 vr->font_size=1.0;
2496 vr->color_bar_style=2;
2497 vr->fixed_range_on=0;
2498 vr->num_of_scale=3;
2499 vr->mark_0_on=0;
2500 vr->remove_0_display_on=0;
2501 for(i=0;i<3;i++)
2502 vr->specified_level[i]=0;
2503 vr->histogram_on=0;
2504 return;
2505}
2506
2507
2508void read_lookup_table(Parameter_vr *vr, double *opa_table)
2509{
2510 int i;
2511 FILE *opa_fp;
2512 if((opa_fp=fopen(vr->name_lookup,"r"))== NULL) {
2513 fprintf(stderr, "There is not such a opacity file:\n");
2514 exit (0);
2515 }
2516 for(i=0;i<256;i++)
2517 fscanf(opa_fp, "%lf", &(opa_table[i]));
2518 return;
2519}
2520#endif
#define NULL
#define HECMW_calloc(nmemb, size)
Definition: hecmw_malloc.h:21
#define HECMW_free(ptr)
Definition: hecmw_malloc.h:24
#define HECMW_malloc(size)
Definition: hecmw_malloc.h:20
#define MAX_LINE_LEN
Definition: hecmw_repart.h:25
#define NUM_CONTROL_PSF
#define EPSILON
void HECMW_vis_print_exit(char *var)
void HECMW_vis_memory_exit(char *var)
#define NUM_CONTROL_PVR
int is_blank_line(char *buf)
int is_comment_line(char *buf)
double get_double_item(char *para, char *buf, int *start_location)
int get_int_item(char *para, char *buf, int *start_location)
int get_keyword_item(char *buf, char *para)
void HECMW_vis_read_control(FILE *fp, int pesize, int mynode, PSF_link *psf, PVR_link *pvr)
void get_string_item(char *para, char *buf, int *start_location, char para2[128])
PVR_link * pvr
PSF_link * psf
void tolower(char *s)
Definition: hecd_util.cpp:56
char data_comp_name[128]
char range_filename[128]
char color_subcomp_name[128]
char data_subcomp_name[128]
char group_name[128]
double deform_line_color[3]
double initial_line_color[3]
char color_comp_name[128]
char disp_comp_name[128]