FrontISTR  5.8.0
Large-scale structural analysis program with finit element method
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 
14 int 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 
30 int 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 
40 void get_string_item(char *para, char *buf, int *start_location,
41  char *para2) {
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 
63 int 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 
91 double 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 
118 int 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 
138 static 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
171 int 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 
201 static 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 
270 static 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 
410 static 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 
461 void 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("temporary 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 if (strncmp(para1, "EXODUS", 6) == 0)
847  sf[k].output_type = 18;
848  else if (strncmp(para1, "STEP_EXODUS", 11) == 0)
849  sf[k].output_type = 19;
850  else {
851  fprintf(stderr,
852  "ERROR: HEC-MW-VIS-E1001: output_type is not "
853  "correct\n");
855  "AVS or BMP or VIS_FEMAP_NEUTRAL or "
856  "FSTR_FEMAP_NEUTRAL or VTK or BIN_VTK or EXODUS or STEP_EXODUS");
857  }
858  break;
859  case 21:
860  sf[k].range_output = 1;
861  get_string_item(para, buf, &location,
862  sf[k].range_filename);
863  break;
864  case 22:
865  sf[k].normalize_flag = get_int_item(para, buf, &location);
866  break;
867  case 23:
868  sr->xr = get_int_item(para, buf, &location);
869  break;
870  case 24:
871  sr->yr = get_int_item(para, buf, &location);
872  break;
873  case 25:
874  sr->num_of_lights = get_int_item(para, buf, &location);
875  break;
876  case 26:
877  sr->light_point = (double *)HECMW_calloc(
878  sr->num_of_lights * 3, sizeof(double));
879  if (sr->light_point == NULL)
880  HECMW_vis_memory_exit("sr: light_point");
881 
882  for (i = 0; i < sr->num_of_lights; i++) {
883  sr->light_point[i * 3] =
884  get_double_item(para, buf, &location);
885  sr->light_point[i * 3 + 1] =
886  get_double_item(para, buf, &location);
887  sr->light_point[i * 3 + 2] =
888  get_double_item(para, buf, &location);
889  }
890  break;
891  case 27:
892  for (i = 0; i < 3; i++) {
893  sr->view_point_d[i] =
894  get_double_item(para, buf, &location);
895  }
896 
897  break;
898  case 28:
899  for (i = 0; i < 3; i++) {
900  sr->screen_point[i] =
901  get_double_item(para, buf, &location);
902  }
903  break;
904  case 29:
905  for (i = 0; i < 3; i++) {
906  sr->up[i] = get_double_item(para, buf, &location);
907  }
908  break;
909  case 30:
910  sr->k_ads[0] = get_double_item(para, buf, &location);
911  break;
912  case 31:
913  sr->k_ads[1] = get_double_item(para, buf, &location);
914  break;
915  case 32:
916 
917  sr->k_ads[2] = get_double_item(para, buf, &location);
918  break;
919  case 33:
920  sr->color_mapping_style =
921  get_int_item(para, buf, &location);
922  if (sr->color_mapping_style == 1) {
923  sr->interval_mapping_num = 1;
924  } else if (sr->color_mapping_style == 2) {
925  sr->interval_mapping_num = 1;
926  } else if (sr->color_mapping_style == 4) {
927  sr->interval_mapping_num = 10;
928  }
929  break;
930  case 34:
931 
933  get_int_item(para, buf, &location);
934  break;
935  case 35:
936  if (sr->color_mapping_style == 2) {
937  sr->interval_point =
938  (double *)HECMW_calloc(2, sizeof(double));
939 
940  if (sr->interval_point == NULL)
941  HECMW_vis_memory_exit("interval_point");
942 
943  sr->interval_point[0] =
944  get_double_item(para, buf, &location);
945  sr->interval_point[1] =
946  get_double_item(para, buf, &location);
947  } else if (sr->color_mapping_style == 3) {
948  sr->interval_point = (double *)HECMW_calloc(
949  2 * (sr->interval_mapping_num + 1), sizeof(double));
950  if (sr->interval_point == NULL)
951  HECMW_vis_memory_exit("interval_point");
952 
953  for (i = 0; i < 2 * ((sr->interval_mapping_num) + 1);
954  i++) {
955  sr->interval_point[i] =
956  get_double_item(para, buf, &location);
957  }
958  }
959  break;
960  case 36:
961  sr->rotate_style = get_int_item(para, buf, &location);
962  break;
963  case 37:
965  get_int_item(para, buf, &location);
966  break;
967  case 38:
969  get_int_item(para, buf, &location);
970  break;
971  case 39:
972  sr->scale_marking_on = get_int_item(para, buf, &location);
973  break;
974  case 40:
975  for (i = 0; i < 3; i++) {
976  sr->background_color[i] =
977  get_double_item(para, buf, &location);
978  }
979  break;
980  case 41:
981  for (i = 0; i < 3; i++) {
982  sr->font_color[i] =
983  get_double_item(para, buf, &location);
984  }
985  break;
986  case 42:
987  sr->color_system_type =
988  get_int_item(para, buf, &location);
989  break;
990  case 43:
991  sr->font_size = get_double_item(para, buf, &location);
992  break;
993  case 44:
994  sr->color_bar_style = get_int_item(para, buf, &location);
995  break;
996  case 45:
997  sr->fixed_range_on = get_int_item(para, buf, &location);
998  break;
999  case 46:
1000  for (i = 0; i < 2; i++) {
1001  sr->range_value[i] =
1002  get_double_item(para, buf, &location);
1003  }
1004 
1005  break;
1006  case 47:
1007  sr->num_of_scale = get_int_item(para, buf, &location);
1008  break;
1009  case 48:
1010  sr->mark_0_on = get_int_item(para, buf, &location);
1011  break;
1012  case 49:
1014  get_int_item(para, buf, &location);
1015 
1016  if (sr->transfer_function_style != 1) sr->opa_value = 0.0;
1017  if ((sr->transfer_function_style != 3) &&
1018  (sr->transfer_function_style != 4)) {
1019  sr->num_of_features = 0;
1020  }
1021  break;
1022  case 50:
1023  sr->opa_value = get_double_item(para, buf, &location);
1024 
1025  break;
1026  case 51:
1027  sr->num_of_features = get_int_item(para, buf, &location);
1028  break;
1029  case 52:
1030  if (sr->transfer_function_style == 3)
1031  sr->fea_point = (double *)HECMW_calloc(
1032  sr->num_of_features * 3, sizeof(double));
1033 
1034  else if (sr->transfer_function_style == 4)
1035  sr->fea_point = (double *)HECMW_calloc(
1036  sr->num_of_features * 3, sizeof(double));
1037  if (sr->fea_point == NULL)
1038  HECMW_vis_memory_exit("sr: fea_point");
1039 
1040  if (sr->transfer_function_style == 3) {
1041  for (i = 0; i < sr->num_of_features * 3; i++) {
1042  sr->fea_point[i] =
1043  get_double_item(para, buf, &location);
1044  }
1045  }
1046  if (sr->transfer_function_style == 4) {
1047  for (i = 0; i < sr->num_of_features * 3; i++) {
1048  sr->fea_point[i] =
1049  get_double_item(para, buf, &location);
1050  }
1051  }
1052  break;
1053  case 53:
1054  get_string_item(para, buf, &location, sr->name_lookup);
1055  break;
1056  case 54:
1057  sr->histogram_on = get_int_item(para, buf, &location);
1058  break;
1059  case 55:
1060  sr->boundary_line_on = get_int_item(para, buf, &location);
1061  break;
1062  case 56:
1063  for (i = 0; i < 3; i++) {
1064  sr->isoline_color[i] =
1065  get_double_item(para, buf, &location);
1066  }
1067  break;
1068  case 57:
1069  sr->time_mark_on = get_int_item(para, buf, &location);
1070  break;
1071  case 58:
1072  sr->fixed_scale_mark = get_int_item(para, buf, &location);
1073  break;
1074  case 59:
1075  sf[k].deform_display_on =
1076  get_int_item(para, buf, &location);
1077  break;
1078  case 60:
1079  sf[k].disp_scale = get_double_item(para, buf, &location);
1080  break;
1081  case 61:
1082  sf[k].initial_style = get_int_item(para, buf, &location);
1083  break;
1084  case 62:
1085  sf[k].deform_style = get_int_item(para, buf, &location);
1086  break;
1087  case 63:
1088  get_string_item(para, buf, &location,
1089  sf[k].disp_comp_name);
1090  break;
1091  case 64:
1092  sf[k].disp_comp = get_int_item(para, buf, &location);
1093  break;
1094  case 65:
1095  for (i = 0; i < 3; i++) {
1096  sf[k].initial_line_color[i] =
1097  get_double_item(para, buf, &location);
1098  }
1099  break;
1100  case 66:
1101  for (i = 0; i < 3; i++) {
1102  sf[k].deform_line_color[i] =
1103  get_double_item(para, buf, &location);
1104  }
1105  break;
1106  case 67:
1107  sr->deform_num_of_frames =
1108  get_int_item(para, buf, &location);
1109  break;
1110  case 68:
1111  sr->smooth_shading = get_int_item(para, buf, &location);
1112  break;
1113  case 69:
1114  sf[k].real_disp_scale =
1115  get_double_item(para, buf, &location);
1116  break;
1117  case 70:
1118  for (i = 0; i < 6; i++) {
1119  sr->fixed_mesh_range[i] =
1120  get_double_item(para, buf, &location);
1121  }
1122  break;
1123  case 71:
1124  sr->start_time = get_double_item(para, buf, &location);
1125  break;
1126  case 72:
1127  sr->time_interval = get_double_item(para, buf, &location);
1128  break;
1129  }
1130  }
1131  while (cont_flag) {
1132  if (fgets(buf, MAX_LINE_LEN, fp) != NULL) {
1133  if ((is_blank_line(buf) == 0) &&
1134  (is_comment_line(buf) == 0))
1135  break;
1136  } else
1137  cont_flag = 0;
1138  }
1139  if (cont_flag == 0) break;
1140  }
1141  /* check the parameters for the surface k */
1142  if (stat_para[0] == 0) sf[k].surface_style = 1;
1143  if ((sf[k].surface_style < 1) || (sf[k].surface_style > 3))
1145  "ERROR: HEC-MW-VIS-E1002: surface_style only can be 1, 2 or "
1146  "3");
1147 
1148  if (sf[k].surface_style == 1) { /* boundary and group surface */
1149  /* if(stat_para[1]==0) {
1150 fprintf(stderr, "Please specify the group name for the boundary surace
1151 generateion; if to find the whole boundary, please input boundary\n");
1152 exit(0);
1153 }
1154  */
1155  if (stat_para[2] == 0) { /* default value */
1156  sf[k].defined_style = 2;
1157  }
1158  }
1159  if (sf[k].surface_style == 2) { /* iso-surfaces */
1160  if ((stat_para[3] == 0) && (stat_para[4] == 0))
1161  sf[k].data_comp = 0;
1162  if ((stat_para[5] == 0) && (stat_para[6] == 0))
1163  sf[k].data_subcomp = 1;
1164  if (stat_para[7] == 0)
1166  "ERROR: HEC-MW-VIS-E1002: iso_value should be defined for "
1167  "isosurfaces");
1168  }
1169  if (sf[k].surface_style ==
1170  3) { /* arbitrary surfaces defined by equation */
1171  if (stat_para[8] == 0) sf[k].method = 5;
1172  if (sf[k].method == 1) {
1173  if (stat_para[9] == 0) {
1174  sf[k].point[0] = 0.0, sf[k].point[1] = 0.0;
1175  sf[k].point[2] = 0.0;
1176  if (mynode == 0)
1177  fprintf(
1178  stderr,
1179  "The default center point (0.0, 0.0, 0.0) is used\n");
1180  }
1181  if (stat_para[10] == 0) {
1182  sf[k].radius = 1.0;
1183  if (mynode == 0)
1184  fprintf(stderr, "The default radius 1.0 is used\n");
1185  }
1186  } else if ((sf[k].method == 2) || (sf[k].method == 3) ||
1187  (sf[k].method == 4)) {
1188  if (stat_para[9] == 0) {
1189  sf[k].point[0] = 0.0;
1190  sf[k].point[1] = 0.0;
1191  sf[k].point[2] = 0.0;
1192  if (mynode == 0)
1193  fprintf(
1194  stderr,
1195  "The default center point (0.0, 0.0, 0.0) is used\n");
1196  }
1197  if (stat_para[11] == 0) {
1198  sf[k].length[0] = 1.0;
1199  sf[k].length[1] = 1.0;
1200  sf[k].length[2] = 1.0;
1201  if (mynode == 0)
1202  fprintf(stderr,
1203  "The default length (1.0, 1.0, 1.0) is used\n");
1204  }
1205  } else if (sf[k].method == 5) {
1206  if (stat_para[12] == 0) {
1207  if (mynode == 0)
1208  fprintf(stderr,
1209  "ERROR: HEC-MW-VIS-E1003:The 10 coefficients of "
1210  "the equation should be defined \n");
1211  HECMW_vis_print_exit("Please re-input and run again");
1212  }
1213  }
1214  }
1215 
1216  if (stat_para[13] == 0) sf[k].display_method = 1;
1217  if ((sf[k].display_method <= 0) || (sf[k].display_method > 5)) {
1218  if (mynode == 0)
1219  fprintf(stderr,
1220  "ERROR: HEC-MW-VIS-E1004:display_method is not in the "
1221  "reasonable range\n");
1222  HECMW_vis_print_exit("Please re-input and run again");
1223  }
1224  if (sf[k].display_method != 4) {
1225  if ((stat_para[14] == 0) && (stat_para[15] == 0))
1226  sf[k].color_comp = 0;
1227  if ((stat_para[16] == 0) && (stat_para[17] == 0))
1228  sf[k].color_subcomp = 1;
1229  }
1230  if ((sf[k].display_method == 2) || (sf[k].display_method == 3) ||
1231  (sf[k].display_method == 5)) {
1232  if (stat_para[18] == 0) {
1233  if (mynode == 0)
1234  fprintf(stderr,
1235  "No value for the number of isolines. Now using the "
1236  "default value 10");
1237  sf[k].isoline_number = 10;
1238  }
1239  }
1240  if (sf[k].display_method == 4) {
1241  if (stat_para[19] == 0) {
1242  if (mynode == 0) {
1243  fprintf(
1244  stderr,
1245  "The number of specified_color has not been defined\n");
1246  fprintf(stderr, "Now using the default value 0.5\n");
1247  }
1248  sf[k].specified_color = 0.5;
1249  }
1250  }
1251  if (stat_para[20] == 0) sf[k].output_type = 1;
1252  if ((sf[k].output_type < 1) || (sf[k].output_type > 19)) {
1253  if (mynode == 0)
1254  fprintf(stderr, "the output_type only can be 1 -- 19\n");
1255  HECMW_vis_print_exit("pls input and run again");
1256  }
1257  if (stat_para[22] == 0) sf[k].normalize_flag = 0;
1258  if (stat_para[59] == 0) sf[k].deform_display_on = 0;
1259  if ((sf[k].deform_display_on < 0) ||
1260  (sf[k].deform_display_on > 1)) {
1261  fprintf(stderr,
1262  "ERROR: HEC-MW-VIS-E1037: deform_display_on should be 0 "
1263  "or 1");
1264  HECMW_vis_print_exit("Please re-input again");
1265  }
1266  if (sf[k].deform_display_on == 0) sr->deform_num_of_frames = 1;
1267  if ((sf[k].deform_display_on == 1) && (stat_para[67] == 0))
1268  sr->deform_num_of_frames = 8;
1269  /* if((sf[k].deform_display_on==1) &&
1270 (sr->deform_num_of_frames==1)) {
1271 fprintf(stderr, "For deformation display, the deform_num_of_frames should be
1272 greater than 1\n");
1273 fprintf(stderr, "The default value 8 will be used\n");
1274 sr->deform_num_of_frames = 8;
1275 }
1276  */
1277  if (stat_para[60] == 0) sf[k].disp_scale = -1.0;
1278  /* if(sf[k].disp_scale<0.0) {
1279 fprintf(stderr, "ERROR: HEC-MW-VIS-E1037: deform_scale should be greater than
1280 0.0");
1281 HECMW_vis_print_exit("Please re-input again");
1282 }
1283  */
1284  if (stat_para[61] == 0) sf[k].initial_style = 4;
1285  if (stat_para[62] == 0) sf[k].deform_style = 1;
1286  if ((sf[k].initial_style < 0) || (sf[k].initial_style > 4)) {
1287  fprintf(stderr,
1288  "ERROR: HEC-MW-VIS-E1037: initial_display_style should "
1289  "be in (0, 4)");
1290  HECMW_vis_print_exit("Please re-input again");
1291  }
1292  if ((sf[k].deform_style < 0) || (sf[k].deform_style > 4)) {
1293  fprintf(stderr,
1294  "ERROR: HEC-MW-VIS-E1037: deform_display_style should be "
1295  "in (0, 4)");
1296  HECMW_vis_print_exit("Please re-input again");
1297  }
1298  if ((stat_para[63] == 0) && (stat_para[64] == 0))
1299  sprintf(sf[k].disp_comp_name, "%s", "DISPLACEMENT");
1300  if (stat_para[65] == 0) {
1301  sf[k].initial_line_color[0] = 0.2;
1302  sf[k].initial_line_color[1] = 0.2;
1303  sf[k].initial_line_color[2] = 1.0;
1304  }
1305  if (stat_para[66] == 0) {
1306  sf[k].deform_line_color[0] = 1.0;
1307  sf[k].deform_line_color[1] = 1.0;
1308  sf[k].deform_line_color[2] = 0.0;
1309  }
1310  for (i = 0; i < 3; i++) {
1311  if (sf[k].initial_line_color[i] < 0.0)
1312  sf[k].initial_line_color[i] = 0.0;
1313  if (sf[k].initial_line_color[i] > 1.0)
1314  sf[k].initial_line_color[i] = 1.0;
1315  if (sf[k].deform_line_color[i] < 0.0)
1316  sf[k].deform_line_color[i] = 0.0;
1317  if (sf[k].deform_line_color[i] > 1.0)
1318  sf[k].deform_line_color[i] = 1.0;
1319  }
1320 
1321  if (cont_flag == 0)
1322  break;
1323  else if (get_keyword_visual(buf) > 0) {
1324  visual_method = get_keyword_visual(buf);
1325  break;
1326  }
1327  }
1328  } /* end of loop k */
1329  /* fprintf(stderr, "the group name of three is 1: %s 2: %s 3:%s\n",
1330  * sf[1].group_name, sf[2].group_name, sf[3].group_name);
1331  */
1332 
1333  /* start reading rendering parameters if output_type==BMP */
1334 
1335  /* check and set default */
1336  if (sf[1].output_type == 3) {
1337  if (stat_para[23] == 0) {
1338  /* use default value 256 */
1339  if (mynode == 0)
1340  fprintf(stderr, "No value for xr. Now use the default value 512\n");
1341  sr->xr = 512;
1342  }
1343  /* check xr whether can be divided by 8 */
1344  sr->xr = (int)(sr->xr / 8) * 8;
1345 
1346  if (stat_para[24] == 0) {
1347  if (mynode == 0)
1348  fprintf(stderr, "No value for yr. Now use the default value 512\n");
1349  sr->yr = 512;
1350  }
1351  if (sr->xr <= 20) {
1353  "ERROR: HEC-MW-VIS-E1005: The x_resolution should be greater "
1354  "than 20");
1355  }
1356  if (sr->yr <= 20) {
1357  fprintf(stderr,
1358  "ERROR: HEC-MW-VIS-E1006: The y_resolution should be greater "
1359  "than 20\n");
1360  HECMW_vis_print_exit("Please re-input a correct one");
1361  }
1362  if (stat_para[25] == 0) {
1363  if (mynode == 0)
1364  fprintf(
1365  stderr,
1366  "No value for num_of_lights. Now use the default value 1\n");
1367  sr->num_of_lights = 1;
1368  stat_para[25] = 1;
1369  }
1370  if ((stat_para[25] == 1) && (sr->num_of_lights <= 0)) {
1372  "ERROR: HEC-MW-VIS-E1007: The number of light sources should be "
1373  "greater than 0");
1374  }
1375  if (stat_para[29] == 0) {
1376  stat_para[29] = 1;
1377  if (mynode == 0)
1378  fprintf(stderr,
1379  "No value for up_direction. The default value (0.0, 0.0, "
1380  "1.0) is used\n");
1381  sr->up[0] = 0.0;
1382  sr->up[1] = 0.0;
1383  sr->up[2] = 1.0;
1384  }
1385  if (stat_para[30] == 0) {
1386  stat_para[30] = 1;
1387  sr->k_ads[0] = 0.5;
1388  }
1389  if ((stat_para[30] == 1) && (sr->k_ads[0] < 0)) {
1390  fprintf(stderr,
1391  "ERROR: HEC-MW-VIS-E1008: The ambient_coef is not correct. "
1392  "Should be >=0.0\n");
1394  "Please re-input the ambient_coef in your control file");
1395  }
1396  if (stat_para[31] == 0) {
1397  stat_para[31] = 1;
1398  sr->k_ads[1] = 0.5;
1399  }
1400  if ((stat_para[31] == 1) && (sr->k_ads[1] < 0)) {
1401  fprintf(stderr,
1402  "ERROR: HEC-MW-VIS-E1009: The diffuse_coef is not correct. "
1403  "Should be >=0.0\n");
1405  "Please re-input the diffuse_coef in your control file");
1406  }
1407  if (stat_para[32] == 0) {
1408  stat_para[32] = 1;
1409  sr->k_ads[2] = 0.6;
1410  }
1411  if ((stat_para[32] == 1) && (sr->k_ads[2] < 0)) {
1412  fprintf(stderr,
1413  "ERROR: HEC-MW-VIS-E1010: The specular_coef is not correct. "
1414  "Should be >=0.0\n");
1416  "Please re-input the specular_coef in your control file");
1417  }
1418  if (stat_para[33] == 0) {
1419  stat_para[33] = 1;
1420  sr->color_mapping_style = 1;
1421  }
1422  if ((sr->color_mapping_style < 1) || (sr->color_mapping_style > 4)) {
1423  fprintf(stderr,
1424  "ERROR: HEC-MW-VIS-E1011: color_mapping_style should be "
1425  "between 1 and 4\n");
1426  HECMW_vis_print_exit("Please re-input it and run again\n");
1427  }
1428  if ((sr->color_mapping_style == 3) && (stat_para[34] == 0)) {
1429  fprintf(stderr,
1430  "ERROR: HEC-MW-VIS-E1012:For color_mapping_style 3, "
1431  "interval_mapping_num is required\n");
1433  "Please re-input the value of interval_mapping_num");
1434  }
1435  if ((stat_para[34] == 1) && (sr->interval_mapping_num <= 0)) {
1437  "ERROR: HEC-MW-VIS-E1013: For color_mapping_style 3, the "
1438  "interval_mapping_num should be greater than 0");
1439  }
1440  if (((sr->color_mapping_style == 2) ||
1441  (sr->color_mapping_style == 3)) &&
1442  (stat_para[35] == 0)) {
1443  fprintf(stderr,
1444  "ERROR: HEC-MW-VIS-E1014: For color_mapping_style =2 or 3, "
1445  "the interval_point should be defined\n");
1446  HECMW_vis_print_exit("Please re-input the interval_point");
1447  }
1448  if (stat_para[36] == 0) {
1449  sr->rotate_style = 0;
1450  sr->rotate_num_of_frames = 1;
1451  }
1452  if ((sr->rotate_style >= 1) && (sr->rotate_style <= 4)) {
1453  if (stat_para[37] == 0) sr->rotate_num_of_frames = 8;
1454  if (sr->rotate_num_of_frames <= 0) {
1455  fprintf(stderr,
1456  "ERROR: HEC-MW-VIS-E1015: The parameter "
1457  "rotate_num_of_frames cannot be less than 1.\n");
1458  HECMW_vis_print_exit("Please re-input and run again");
1459  }
1460  if (sr->rotate_style == 4) sr->rotate_num_of_frames = 8;
1461  }
1462 
1463  if (stat_para[38] == 0) sr->color_mapping_bar_on = 0;
1464  if ((sr->color_mapping_bar_on < 0) || (sr->color_mapping_bar_on > 1)) {
1465  fprintf(stderr,
1466  "ERROR: HEC-MW-VIS-E1016: color_mapping_bar_on parameter "
1467  "only can be defined as 0 or 1\n");
1468  HECMW_vis_print_exit("Please re-input it and run again");
1469  }
1470  if (stat_para[39] == 0) sr->scale_marking_on = 0;
1471  if ((sr->scale_marking_on < 0) || (sr->scale_marking_on > 1)) {
1472  fprintf(stderr,
1473  "ERROR: HEC-MW-VIS-E1017: scale_marking_on parameter only "
1474  "can be defined as 0 or 1\n");
1475  HECMW_vis_print_exit("Please re-input it and run again");
1476  }
1477 
1478  if ((sr->color_mapping_bar_on == 1) && (sr->xr < 40)) {
1479  fprintf(stderr,
1480  "ERROR: HEC-MW-VIS-E1018: x resolution should be larger than "
1481  "40 for adding color_mapping_bar case\n");
1482  HECMW_vis_print_exit("please reinput x resolution");
1483  }
1484  if ((sr->scale_marking_on == 1) && (sr->xr < 65)) {
1485  fprintf(stderr,
1486  "ERROR: HEC-MW-VIS-E1019: x resolution should be larger than "
1487  "65 for adding color_mapping and scale marking case\n");
1488  HECMW_vis_print_exit("please re-input x resolution again");
1489  }
1490  if (stat_para[40] == 0)
1491  sr->background_color[0] = sr->background_color[1] =
1492  sr->background_color[2] = 0.0;
1493  if (stat_para[41] == 0)
1494  sr->font_color[0] = sr->font_color[1] = sr->font_color[2] = 1.0;
1495  if (stat_para[42] == 0) sr->color_system_type = 1;
1496  if ((sr->color_system_type <= 0) || (sr->color_system_type > 3)) {
1497  fprintf(stderr,
1498  "ERROR: HEC-MW-VIS-E1020:color_system_type should be between "
1499  "1 and 3\n");
1500  HECMW_vis_print_exit("Please re-input and run again");
1501  }
1502  if ((sr->background_color[0] < -EPSILON) ||
1503  (sr->background_color[0] > 1.0 + EPSILON) ||
1504  (sr->background_color[1] < -EPSILON) ||
1505  (sr->background_color[1] > 1.0 + EPSILON) ||
1506  (sr->background_color[2] < -EPSILON) ||
1507  (sr->background_color[2] > 1.0 + EPSILON)) {
1508  fprintf(stderr,
1509  "ERROR: HEC-MW-VIS-E1021:The background color should be in "
1510  "the interval of (0.0, 1.0)\n");
1511  HECMW_vis_print_exit("Please re-input and run again");
1512  }
1513  if ((sr->font_color[0] < -EPSILON) ||
1514  (sr->font_color[0] > 1.0 + EPSILON) ||
1515  (sr->font_color[1] < -EPSILON) ||
1516  (sr->font_color[1] > 1.0 + EPSILON) ||
1517  (sr->font_color[2] < -EPSILON) ||
1518  (sr->font_color[2] > 1.0 + EPSILON)) {
1519  fprintf(stderr,
1520  "ERROR: HEC-MW-VIS-E1022: The font color should be in the "
1521  "interval of (0.0, 1.0)\n");
1522  HECMW_vis_print_exit("Please re-input and run again");
1523  }
1524  if (stat_para[43] == 0) sr->font_size = 1.0;
1525  if (sr->font_size < 1.0 - EPSILON) {
1526  fprintf(stderr,
1527  "ERROR: HEC-MW-VIS-E1023: font_size parameters cannot be "
1528  "between 1.0 and 4.0\n");
1529  HECMW_vis_print_exit("Please re-input and run again");
1530  }
1531  if (sr->font_size > 4.0) sr->font_size = 4.0;
1532  if (stat_para[44] == 0) sr->color_bar_style = 2;
1533  if ((sr->color_bar_style < 1) || (sr->color_bar_style > 2)) {
1534  fprintf(
1535  stderr,
1536  "ERROR: HEC-MW-VIS-E1024: color_bar_style only can be 1 or 2\n");
1537  HECMW_vis_print_exit("Please input and run again");
1538  }
1539  if (stat_para[45] == 0) sr->fixed_range_on = 0;
1540  if ((sr->fixed_range_on < 0) || (sr->fixed_range_on > 1)) {
1541  fprintf(stderr, "fixed_range_on only can be 0 or 1\n");
1542  HECMW_vis_print_exit("Please input and run again");
1543  }
1544  if (stat_para[47] == 0) sr->num_of_scale = 3;
1545  if (sr->num_of_scale <= 0) {
1546  fprintf(stderr,
1547  "ERROR: HEC-MW-VIS-E1025: num_of_scale only can be greater "
1548  "than 0\n");
1549  HECMW_vis_print_exit("Please input and run again");
1550  }
1551  if ((sr->fixed_range_on == 1) && (stat_para[46] == 0)) {
1552  fprintf(stderr,
1553  "ERROR: HEC-MW-VIS-E1026: range_value is required for "
1554  "fixed_range_on style\n");
1555  HECMW_vis_print_exit("Please re-input and run again");
1556  }
1557  if (stat_para[48] == 0) sr->mark_0_on = 0;
1558  if ((sr->mark_0_on < 0) || (sr->mark_0_on > 1)) {
1559  fprintf(stderr,
1560  "ERROR: HEC-MW-VIS-E1027: mark_0_on only can be 0 or 1\n");
1561  HECMW_vis_print_exit("Please input and run again");
1562  }
1563 
1564  if (stat_para[49] == 0) {
1565  stat_para[49] = 1;
1566  sr->transfer_function_style = 1;
1567  stat_para[50] = 1;
1568  sr->opa_value = 1.0;
1569  }
1570  if ((sr->transfer_function_style < 1) ||
1571  (sr->transfer_function_style > 9)) {
1572  fprintf(stderr,
1573  "ERROR: HEC-MW-VIS-E1028: transfer_function_style should be "
1574  "between 1 and 8\n");
1575  HECMW_vis_print_exit("Please re-input and run again");
1576  }
1577  if ((stat_para[50] == 1) && (sr->opa_value < 0)) {
1578  fprintf(stderr,
1579  "ERROR: HEC-MW-VIS-E1029: opacity_value cannot be less than "
1580  "0.0\n");
1581  HECMW_vis_print_exit("Please re-input and run again");
1582  }
1583  if (((sr->transfer_function_style == 3) ||
1584  (sr->transfer_function_style == 4)) &&
1585  (stat_para[51] == 0)) {
1586  fprintf(stderr,
1587  "ERROR: HEC-MW-VIS-E1030:When transfer_function_style =3 or "
1588  "4, num_of_features should be defined\n");
1589  HECMW_vis_print_exit("Please re-input the num_of_features");
1590  }
1591  if ((stat_para[51] == 1) && (sr->num_of_features <= 0)) {
1592  fprintf(stderr,
1593  "ERROR: HEC-MW-VIS-E1031: When transfer_function_style =3 or "
1594  "4, num_of_features should be greater than 0\n");
1595  HECMW_vis_print_exit("Please re-input and run again");
1596  }
1597  if ((stat_para[51] == 1) && (stat_para[52] == 0)) {
1598  fprintf(stderr,
1599  "ERROR: HEC-MW-VIS-E1032:For transfer_function_style =3 or "
1600  "4, feature_points should be defined\n");
1601  HECMW_vis_print_exit("Please re-input your control file");
1602  }
1603  if ((sr->transfer_function_style == 8) && (stat_para[53] == 0)) {
1604  fprintf(stderr,
1605  "ERROR: HEC-MW-VIS-E1033:For transfer_function_style=8, "
1606  "lookup_filename should be specified\n");
1607  HECMW_vis_print_exit("Please re-input the filename");
1608  }
1609  if (stat_para[54] == 0) sr->histogram_on = 0;
1610  if ((sr->histogram_on < 0) || (sr->histogram_on > 2)) {
1611  fprintf(stderr,
1612  "ERROR: HEC-MW-VIS-E1034: histogram_on value should be 0,1, "
1613  "or 2\n");
1614  HECMW_vis_print_exit("Please re-input again");
1615  }
1616  if (stat_para[55] == 0) sr->boundary_line_on = 0;
1617  if ((sr->boundary_line_on < 0) || (sr->boundary_line_on > 1)) {
1618  fprintf(
1619  stderr,
1620  "ERROR: HEC-MW-VIS-E1035: histogram_on value should be 0 or 1");
1621  HECMW_vis_print_exit("Please re-input again");
1622  }
1623  if (stat_para[56] == 0) {
1624  sr->isoline_color[0] = 0.0;
1625  sr->isoline_color[1] = 0.0;
1626  sr->isoline_color[2] = 0.0;
1627  }
1628  if (stat_para[57] == 0) sr->time_mark_on = 0;
1629  if ((sr->time_mark_on < 0) || (sr->time_mark_on > 1)) {
1630  fprintf(
1631  stderr,
1632  "ERROR: HEC-MW-VIS-E1036: time_mark_on value should be 0 or 1");
1633  HECMW_vis_print_exit("Please re-input again");
1634  }
1635  if (stat_para[58] == 0) sr->fixed_scale_mark = 0;
1636  if ((sr->fixed_scale_mark < 0) || (sr->fixed_scale_mark > 1)) {
1637  fprintf(stderr,
1638  "ERROR: HEC-MW-VIS-E1037: fixed_scale_mark value should be 0 "
1639  "or 1");
1640  HECMW_vis_print_exit("Please re-input again");
1641  }
1642  if (stat_para[68] == 0) sr->smooth_shading = 0;
1643 
1644  /* fprintf(stderr, "resolution is %d %d\n", sr->xr,
1645 sr->yr);
1646 fprintf(stderr, "color_mapping style is %d\n", sr->color_mapping_style);
1647 fprintf(stderr, "view_point==%lf %lf %lf\n", sr->view_point_d[0],
1648 sr->view_point_d[1], sr->view_point_d[2]);
1649  */
1650  }
1651  /* copy the parameters for PSF into psf link */
1652  p1 = psf->next_psf;
1653  p1->num_of_psf = sf[0].surface_style;
1654  p1->sr = sr;
1655  p1->sf = sf;
1656  /* fprintf(stderr, "******** color_comp_name =%s\n",
1657 sf[1].color_comp_name);
1658 fprintf(stderr, "******** surface_style=%d\n", sf[1].surface_style);
1659 fprintf(stderr, "*********current PSF number= %d\n", psf->num_of_psf);
1660  */
1661 
1662  for (i = 0; i < NUM_CONTROL_PSF; i++) p1->stat_para[i] = stat_para[i];
1663  for (i = 0; i < NUM_CONTROL_PSF; i++) HECMW_free(parameters[i]);
1664  HECMW_free(parameters);
1665  HECMW_free(stat_para);
1666  HECMW_free(len_para);
1667 
1668  } /*end if visual_method=1 */
1669  else if ((visual_method == 2) && (cont_flag == 1)) {
1670  visual_method = 0;
1671  vr = (Parameter_vr *)HECMW_malloc(sizeof(Parameter_vr));
1672  if (vr == NULL) HECMW_vis_memory_exit("PVR parameters: vr");
1673  vr->projection_style = 1;
1674 
1675  for (i = 0; i < NUM_CONTROL_PVR; i++) {
1676  parameters = (char **)HECMW_calloc(NUM_CONTROL_PVR, sizeof(char *));
1677  len_para = (int *)HECMW_calloc(NUM_CONTROL_PVR, sizeof(int));
1678  stat_para = (int *)HECMW_calloc(NUM_CONTROL_PVR, sizeof(int));
1679  parameters[i] = (char *)HECMW_calloc(128, sizeof(char));
1680  if (parameters[i] == NULL)
1681  HECMW_vis_memory_exit("temporary variable parameters");
1682  }
1683  vr->opa_value = 0.0;
1684  vr->color_comp = -1;
1685  vr->color_subcomp = -1;
1686  strcpy(parameters[0], "maximum_refinement");
1687  len_para[0] = 18;
1688  strcpy(parameters[1], "x_resolution");
1689  strcpy(parameters[2], "y_resolution");
1690  len_para[1] = len_para[2] = 12;
1691  strcpy(parameters[3], "num_of_lights");
1692  len_para[3] = 13;
1693  strcpy(parameters[4], "position_of_lights");
1694  len_para[4] = 18;
1695  strcpy(parameters[5], "viewpoint");
1696  len_para[5] = 9;
1697  strcpy(parameters[6], "look_at_point");
1698  len_para[6] = 13;
1699  strcpy(parameters[7], "up_direction");
1700  len_para[7] = 12;
1701  strcpy(parameters[8], "ambient_coef");
1702  len_para[8] = 12;
1703  strcpy(parameters[9], "diffuse_coef");
1704  len_para[9] = 12;
1705  strcpy(parameters[10], "specular_coef");
1706  len_para[10] = 13;
1707  strcpy(parameters[11], "surface_on");
1708  len_para[11] = 10;
1709  strcpy(parameters[12], "surface_opacity");
1710  len_para[12] = 15;
1711  strcpy(parameters[13], "color_mapping_style");
1712  len_para[13] = 19;
1713  strcpy(parameters[14], "interval_mapping_num");
1714  len_para[14] = 20;
1715  strcpy(parameters[15], "interval_mapping");
1716  len_para[15] = 16;
1717  strcpy(parameters[16], "opacity_mapping_style");
1718  len_para[16] = 21;
1719  strcpy(parameters[17], "opacity_value");
1720  len_para[17] = 13;
1721  strcpy(parameters[18], "num_of_features");
1722  len_para[18] = 14;
1723  strcpy(parameters[19], "feature_points");
1724  len_para[19] = 14;
1725  strcpy(parameters[20], "lookup_filename");
1726  len_para[20] = 15;
1727  strcpy(parameters[21], "rotate_style");
1728  len_para[21] = 12;
1729  strcpy(parameters[22], "voxel_filename");
1730  len_para[22] = 10;
1731  strcpy(parameters[23], "color_mapping_bar_on");
1732  len_para[23] = 17;
1733  strcpy(parameters[24], "scale_marking_on");
1734  len_para[24] = 15;
1735  strcpy(parameters[25], "color_comp_name");
1736  len_para[25] = 14;
1737  strcpy(parameters[26], "color_subcomp_name");
1738  len_para[26] = 17;
1739  strcpy(parameters[27], "n_voxel_x");
1740  len_para[27] = 9;
1741  strcpy(parameters[28], "n_voxel_y");
1742  len_para[28] = 9;
1743  strcpy(parameters[29], "n_voxel_z");
1744  len_para[29] = 9;
1745  strcpy(parameters[30], "surface_filename");
1746  len_para[30] = 12;
1747  strcpy(parameters[31], "num_of_frames");
1748  len_para[31] = 12;
1749  strcpy(parameters[32], "background_color");
1750  len_para[32] = 12;
1751  strcpy(parameters[33], "font_color");
1752  len_para[33] = 9;
1753  strcpy(parameters[34], "color_system_type");
1754  len_para[34] = 12;
1755  strcpy(parameters[35], "font_size");
1756  len_para[35] = 8;
1757  strcpy(parameters[36], "color_bar_style");
1758  len_para[36] = 13;
1759  strcpy(parameters[37], "fixed_range_on");
1760  len_para[37] = 11;
1761  strcpy(parameters[38], "range_value");
1762  len_para[38] = 11;
1763  strcpy(parameters[39], "num_of_scale");
1764  len_para[39] = 11;
1765  strcpy(parameters[40], "mark_0_on");
1766  len_para[40] = 9;
1767  strcpy(parameters[41], "remove_0_display_on");
1768  len_para[41] = 17;
1769  strcpy(parameters[42], "x_specified_level");
1770  len_para[42] = 15;
1771  strcpy(parameters[43], "y_specified_level");
1772  len_para[43] = 15;
1773  strcpy(parameters[44], "z_specified_level");
1774  len_para[44] = 15;
1775  strcpy(parameters[45], "histogram_on");
1776  len_para[45] = 10;
1777  strcpy(parameters[46], "display_range");
1778  len_para[46] = 13;
1779  strcpy(parameters[47], "time_mark_on");
1780  len_para[47] = 10;
1781  strcpy(parameters[48], "fixed_scale_mark");
1782  len_para[48] = 15;
1783  strcpy(parameters[49], "color_comp");
1784  len_para[49] = 9;
1785  strcpy(parameters[50], "color_subcomp");
1786  len_para[50] = 12;
1787 
1788  for (i = 0; i < NUM_CONTROL_PVR; i++) {
1789  stat_para[i] = 0;
1790  }
1791  vr->projection_style = 1;
1792  vr->color_comp = -1;
1793  vr->color_subcomp = -1;
1794  sprintf(vr->color_comp_name, "%s", "NULL");
1795  sprintf(vr->color_subcomp_name, "%s", "NULL");
1796 
1797  if (cont_flag == 1)
1798  while (get_keyword_visual(buf) == 0) {
1799  hit = -1;
1800  location = get_keyword_item(buf, para);
1801  len_tmp = strlen(para);
1802  for (ii = 0; ii < len_tmp; ii++) {
1803  para[ii] = tolower(para[ii]);
1804  }
1805  for (i = 0; i < NUM_CONTROL_PVR; i++) {
1806  if ((strncmp(para, parameters[i], len_para[i])) == 0) {
1807  hit = i;
1808  stat_para[i] = 1;
1809  break;
1810  }
1811  }
1812  /* fprintf(stderr, "para=%s hit=%d\n", para, hit);
1813  */
1814 
1815  if ((hit >= 0) && (hit < NUM_CONTROL_PVR)) {
1816  switch (hit) {
1817  case 0:
1818  vr->max_level = get_int_item(para, buf, &location);
1819  break;
1820  case 1:
1821  vr->xr = get_int_item(para, buf, &location);
1822  break;
1823  case 2:
1824  vr->yr = get_int_item(para, buf, &location);
1825  break;
1826  case 3:
1827  vr->num_of_lights = get_int_item(para, buf, &location);
1828  break;
1829  case 4:
1830  vr->light_point = (double *)HECMW_calloc(vr->num_of_lights * 3,
1831  sizeof(double));
1832  if (vr->light_point == NULL)
1833  HECMW_vis_memory_exit("Parameter vr: light_point");
1834 
1835  for (i = 0; i < vr->num_of_lights; i++) {
1836  vr->light_point[i * 3] =
1837  get_double_item(para, buf, &location);
1838  vr->light_point[i * 3 + 1] =
1839  get_double_item(para, buf, &location);
1840  vr->light_point[i * 3 + 2] =
1841  get_double_item(para, buf, &location);
1842  }
1843  break;
1844  case 5:
1845  for (i = 0; i < 3; i++) {
1846  vr->view_point_d[i] = get_double_item(para, buf, &location);
1847  }
1848 
1849  break;
1850  case 6:
1851  for (i = 0; i < 3; i++) {
1852  vr->screen_point[i] = get_double_item(para, buf, &location);
1853  }
1854  break;
1855  case 7:
1856  for (i = 0; i < 3; i++) {
1857  vr->up[i] = get_double_item(para, buf, &location);
1858  }
1859  break;
1860  case 8:
1861 
1862  vr->k_ads[0] = get_double_item(para, buf, &location);
1863  break;
1864  case 9:
1865  vr->k_ads[1] = get_double_item(para, buf, &location);
1866  break;
1867  case 10:
1868 
1869  vr->k_ads[2] = get_double_item(para, buf, &location);
1870  break;
1871  case 11:
1872 
1873  break;
1874  case 12:
1875  break;
1876  case 13:
1877  vr->color_mapping_style = get_int_item(para, buf, &location);
1878  if (vr->color_mapping_style == 1) {
1879  vr->interval_mapping_num = 1;
1880  } else if (vr->color_mapping_style == 2) {
1881  vr->interval_mapping_num = 1;
1882  } else if (vr->color_mapping_style == 4) {
1883  vr->interval_mapping_num = 10;
1884  }
1885  break;
1886  case 14:
1887 
1888  vr->interval_mapping_num = get_int_item(para, buf, &location);
1889  break;
1890  case 15:
1891  if (vr->color_mapping_style == 2) {
1892  vr->interval_point =
1893  (double *)HECMW_calloc(2, sizeof(double));
1894 
1895  if (vr->interval_point == NULL)
1896  HECMW_vis_memory_exit("interval point");
1897 
1898  vr->interval_point[0] = get_double_item(para, buf, &location);
1899  vr->interval_point[1] = get_double_item(para, buf, &location);
1900  } else if (vr->color_mapping_style == 3) {
1901  vr->interval_point = (double *)HECMW_calloc(
1902  2 * (vr->interval_mapping_num + 1), sizeof(double));
1903  if (vr->interval_point == NULL)
1904  HECMW_vis_memory_exit("interval point");
1905 
1906  for (i = 0; i < 2 * ((vr->interval_mapping_num) + 1); i++) {
1907  vr->interval_point[i] =
1908  get_double_item(para, buf, &location);
1909  }
1910  }
1911  break;
1912  case 16:
1914  get_int_item(para, buf, &location);
1915  if (vr->transfer_function_style != 1) vr->opa_value = 0.0;
1916  if ((vr->transfer_function_style != 3) &&
1917  (vr->transfer_function_style != 4)) {
1918  vr->num_of_features = 0;
1919  }
1920  break;
1921  case 17:
1922  vr->opa_value = get_double_item(para, buf, &location);
1923 
1924  break;
1925  case 18:
1926  vr->num_of_features = get_int_item(para, buf, &location);
1927  break;
1928  case 19:
1929  if (vr->transfer_function_style == 3)
1930  vr->fea_point = (double *)HECMW_calloc(
1931  vr->num_of_features * 3, sizeof(double));
1932 
1933  else if (vr->transfer_function_style == 4)
1934  vr->fea_point = (double *)HECMW_calloc(
1935  vr->num_of_features * 3, sizeof(double));
1936  if (vr->fea_point == NULL)
1937  HECMW_vis_memory_exit("vr: fea_point");
1938 
1939  if (vr->transfer_function_style == 3) {
1940  for (i = 0; i < vr->num_of_features * 3; i++) {
1941  vr->fea_point[i] = get_double_item(para, buf, &location);
1942  }
1943  }
1944  if (vr->transfer_function_style == 4) {
1945  for (i = 0; i < vr->num_of_features * 3; i++) {
1946  vr->fea_point[i] = get_double_item(para, buf, &location);
1947  }
1948  }
1949  break;
1950  case 20:
1951  get_string_item(para, buf, &location, vr->name_lookup);
1952  break;
1953  case 21:
1954  vr->rotate_style = get_int_item(para, buf, &location);
1955  break;
1956  case 22:
1957  get_string_item(para, buf, &location, vr->name_voxelfile);
1958  break;
1959  case 23:
1960  vr->color_mapping_bar_on = get_int_item(para, buf, &location);
1961  break;
1962  case 24:
1963  vr->scale_marking_on = get_int_item(para, buf, &location);
1964  break;
1965  case 25:
1966  get_string_item(para, buf, &location, vr->color_comp_name);
1967  break;
1968  case 26:
1969  get_string_item(para, buf, &location, vr->color_subcomp_name);
1970  break;
1971  case 27:
1972  vr->nv_xyz[0] = get_int_item(para, buf, &location);
1973  break;
1974  case 28:
1975  vr->nv_xyz[1] = get_int_item(para, buf, &location);
1976  break;
1977  case 29:
1978  vr->nv_xyz[2] = get_int_item(para, buf, &location);
1979  break;
1980  case 30:
1981  break;
1982  case 31:
1983  vr->num_of_frames = get_int_item(para, buf, &location);
1984  break;
1985  case 32:
1986  for (i = 0; i < 3; i++) {
1987  vr->background_color[i] =
1988  get_double_item(para, buf, &location);
1989  }
1990  break;
1991  case 33:
1992  for (i = 0; i < 3; i++) {
1993  vr->font_color[i] = get_double_item(para, buf, &location);
1994  }
1995  break;
1996  case 34:
1997  vr->color_system_type = get_int_item(para, buf, &location);
1998  break;
1999  case 35:
2000  vr->font_size = get_double_item(para, buf, &location);
2001  break;
2002  case 36:
2003  vr->color_bar_style = get_int_item(para, buf, &location);
2004  break;
2005  case 37:
2006  vr->fixed_range_on = get_int_item(para, buf, &location);
2007  break;
2008  case 38:
2009  for (i = 0; i < 2; i++) {
2010  vr->range_value[i] = get_double_item(para, buf, &location);
2011  }
2012 
2013  break;
2014  case 39:
2015  vr->num_of_scale = get_int_item(para, buf, &location);
2016  break;
2017  case 40:
2018  vr->mark_0_on = get_int_item(para, buf, &location);
2019  break;
2020  case 41:
2021  vr->remove_0_display_on = get_int_item(para, buf, &location);
2022  break;
2023  case 42:
2024  vr->specified_level[0] = get_int_item(para, buf, &location);
2025  break;
2026  case 43:
2027  vr->specified_level[1] = get_int_item(para, buf, &location);
2028  break;
2029  case 44:
2030  vr->specified_level[2] = get_int_item(para, buf, &location);
2031  break;
2032  case 45:
2033  vr->histogram_on = get_int_item(para, buf, &location);
2034  break;
2035  case 46:
2036  for (i = 0; i < 6; i++) {
2037  vr->display_range[i] = get_double_item(para, buf, &location);
2038  }
2039  break;
2040  case 47:
2041  vr->time_mark_on = get_int_item(para, buf, &location);
2042  break;
2043  case 48:
2044  vr->fixed_scale_mark = get_int_item(para, buf, &location);
2045  break;
2046  case 49:
2047  vr->color_comp = get_int_item(para, buf, &location);
2048  break;
2049  case 50:
2050  vr->color_subcomp = get_int_item(para, buf, &location);
2051  break;
2052  }
2053  }
2054  while (cont_flag) {
2055  if (fgets(buf, MAX_LINE_LEN, fp) != NULL) {
2056  if ((is_blank_line(buf) == 0) && (is_comment_line(buf) == 0))
2057  break;
2058  } else
2059  cont_flag = 0;
2060  }
2061  if (cont_flag == 0)
2062  break;
2063  else if (get_keyword_visual(buf) > 0) {
2064  visual_method = get_keyword_visual(buf);
2065  break;
2066  }
2067  }
2068  /* check the parameters */
2069  if (stat_para[0] == 0) {
2070  /* set default value */
2071  vr->max_level = 100;
2072  }
2073  if ((vr->max_level <= 0) && (stat_para[0] == 1)) {
2074  fprintf(stderr,
2075  "ERROR: HEC-MW-VIS-E1038: maximum_refinement parameter should "
2076  "be greater than 0\n");
2077  HECMW_vis_print_exit("Please re-input the value");
2078  }
2079  if (stat_para[1] == 0) {
2080  /* use default value 256 */
2081  vr->xr = 256;
2082  }
2083  /* check xr whether can be divided by 8 */
2084  vr->xr = (int)(vr->xr / 8) * 8;
2085 
2086  if (stat_para[2] == 0) {
2087  vr->yr = 256;
2088  }
2089  if (vr->xr <= 20) {
2090  fprintf(stderr,
2091  "ERROR: HEC-MW-VIS-E1005: The x_resolution should be greater "
2092  "than 20\n");
2093  HECMW_vis_print_exit("Please re-input a correct one");
2094  }
2095  if (vr->yr <= 20) {
2096  fprintf(stderr,
2097  "ERROR: HEC-MW-VIS-E1006: The y_resolution should be greater "
2098  "than 20\n");
2099  HECMW_vis_print_exit("Please re-input a correct one");
2100  }
2101  if (stat_para[3] == 0) {
2102  vr->num_of_lights = 1;
2103  stat_para[3] = 1;
2104  }
2105  if ((stat_para[3] == 1) && (vr->num_of_lights <= 0)) {
2107  "ERROR: HEC-MW-VIS-E1007: The number of light sources should be "
2108  "greater than 0");
2109  }
2110  if (stat_para[7] == 0) {
2111  stat_para[7] = 1;
2112  vr->up[0] = 0.0;
2113  vr->up[1] = 1.0;
2114  vr->up[2] = 0.0;
2115  }
2116  if (stat_para[8] == 0) {
2117  stat_para[8] = 1;
2118  vr->k_ads[0] = 0.5;
2119  }
2120  if ((stat_para[8] == 1) && (vr->k_ads[0] < 0)) {
2121  fprintf(stderr,
2122  "ERROR: HEC-MW-VIS-E1008: The ambient_coef is not correct. "
2123  "Should be >=0.0\n");
2125  "Please re-input the ambient_coef in your control file");
2126  }
2127  if (stat_para[9] == 0) {
2128  stat_para[9] = 1;
2129  vr->k_ads[1] = 0.8;
2130  }
2131  if ((stat_para[9] == 1) && (vr->k_ads[1] < 0)) {
2132  fprintf(stderr,
2133  "ERROR: HEC-MW-VIS-E1009: The diffuse_coef is not correct. "
2134  "Should be >=0.0\n");
2136  "Please re-input the diffuse_coef in your control file");
2137  }
2138  if (stat_para[10] == 0) {
2139  stat_para[10] = 1;
2140  vr->k_ads[2] = 0.6;
2141  }
2142  if ((stat_para[10] == 1) && (vr->k_ads[2] < 0)) {
2143  fprintf(stderr,
2144  "ERROR: HEC-MW-VIS-E1010: The specular_coef is not correct. "
2145  "Should be >=0.0\n");
2147  "Please re-input the specular_coef in your control file");
2148  }
2149  /* if(stat_para[11]==0) {
2150  stat_para[11]=1;
2151  vr->surface_on=0;
2152  pvr->surface_on=0;
2153 }
2154 
2155 if((stat_para[11]==1) && ((vr->surface_on<0) || (vr->surface_on>1))) {
2156  fprintf(stderr, "surface_on parameter only can be defined as 0 or 1\n");
2157  fprintf(stderr, "Please re-input it and run again\n");
2158  exit(0);
2159 }
2160 if((vr->surface_on==1) && (stat_para[12]==0))
2161  vr->surface_opacity=0.2;
2162 if((stat_para[12]==1) && (vr->surface_opacity<0.0)) {
2163  fprintf(stderr, "surface_opacity parameter cannot be less than 0.0\n");
2164  fprintf(stderr, "Please re-input it and run again\n");
2165  exit(0);
2166 }
2167  */
2168  if (stat_para[13] == 0) {
2169  stat_para[13] = 1;
2170  vr->color_mapping_style = 1;
2171  }
2172  if ((vr->color_mapping_style < 1) || (vr->color_mapping_style > 4)) {
2173  fprintf(stderr,
2174  "ERROR: HEC-MW-VIS-E1011:color_mapping_style should be between "
2175  "1 and 4\n");
2176  HECMW_vis_print_exit("Please re-input it and run again");
2177  }
2178  if ((vr->color_mapping_style == 3) && (stat_para[14] == 0)) {
2179  fprintf(stderr,
2180  "ERROR: HEC-MW-VIS-E1012:For color_mapping_style 3, the "
2181  "parameter interval_mapping_num is required\n");
2183  "Please re-input the value of interval_mapping_num");
2184  }
2185  if ((stat_para[14] == 1) && (vr->interval_mapping_num <= 0)) {
2187  "ERROR: HEC-MW-VIS-E1013:For color_mapping_style 3, the "
2188  "interval_mapping_num should be greater than 0");
2189  }
2190  if (((vr->color_mapping_style == 2) || (vr->color_mapping_style == 3)) &&
2191  (stat_para[15] == 0)) {
2192  fprintf(stderr,
2193  "ERROR: HEC-MW-VIS-E1014:For color_mapping_style =2 or 3, the "
2194  "interval_point should be defined\n");
2195  HECMW_vis_print_exit("Please re-input the interval_point");
2196  }
2197  if (stat_para[16] == 0) {
2198  stat_para[16] = 1;
2199  vr->transfer_function_style = 1;
2200  stat_para[17] = 1;
2201  vr->opa_value = 0.05;
2202  }
2203  if ((vr->transfer_function_style < 1) ||
2204  (vr->transfer_function_style > 8)) {
2205  fprintf(stderr,
2206  "ERROR: HEC-MW-VIS-E1028:transfer_function_style should be "
2207  "between 1 and 8\n");
2208  HECMW_vis_print_exit("Please re-input and run again");
2209  }
2210  if ((stat_para[17] == 1) && (vr->opa_value < 0)) {
2211  fprintf(
2212  stderr,
2213  "ERROR: HEC-MW-VIS-E1029:opacity_value cannot be less than 0.0\n");
2214  fprintf(stderr, "Please re-input and run again\n");
2215  exit(0);
2216  }
2217  if (((vr->transfer_function_style == 3) ||
2218  (vr->transfer_function_style == 4)) &&
2219  (stat_para[18] == 0)) {
2220  fprintf(stderr,
2221  "ERROR: HEC-MW-VIS-E1030:When transfer_function_style =3 or 4, "
2222  "num_of_features should be defined\n");
2223  HECMW_vis_print_exit("Please re-input the num_of_features");
2224  }
2225  if ((stat_para[18] == 1) && (vr->num_of_features <= 0)) {
2226  fprintf(stderr,
2227  "ERROR: HEC-MW-VIS-E1031:When transfer_function_style =3 or 4, "
2228  "num_of_features should be greater than 0\n");
2229  HECMW_vis_print_exit("Please re-input and run again");
2230  }
2231  if ((stat_para[18] == 1) && (stat_para[19] == 0)) {
2232  fprintf(stderr,
2233  "ERROR: HEC-MW-VIS-E1032:For transfer_function_style =3 or 4, "
2234  "feature_points should be defined\n");
2235  HECMW_vis_print_exit("Please re-input your control file");
2236  }
2237  if ((vr->transfer_function_style == 8) && (stat_para[20] == 0)) {
2238  fprintf(stderr,
2239  "ERROR: HEC-MW-VIS-E1033:For transfer_function_style=8, "
2240  "lookup_filename should be specified\n");
2241  HECMW_vis_print_exit("Please re-input the filename");
2242  }
2243  if (stat_para[21] == 0) vr->rotate_style = 0;
2244  if ((vr->rotate_style < 0) || (vr->rotate_style > 4)) {
2246  "ERROR: HEC-MW-VIS-E1039:The rotate_style parameter is wrong. "
2247  "Please input one within (0, 4)");
2248  }
2249  if (stat_para[23] == 0) vr->color_mapping_bar_on = 0;
2250  if ((vr->color_mapping_bar_on < 0) || (vr->color_mapping_bar_on > 1)) {
2251  fprintf(stderr,
2252  "ERROR: HEC-MW-VIS-E1016:color_mapping_bar_on parameter only "
2253  "can be defined as 0 or 1\n");
2254  HECMW_vis_print_exit("Please re-input it and run again");
2255  }
2256  if (stat_para[24] == 0) vr->scale_marking_on = 0;
2257  if ((vr->scale_marking_on < 0) || (vr->scale_marking_on > 1)) {
2258  fprintf(stderr,
2259  "ERROR: HEC-MW-VIS-E1017:scale_marking_on parameter only can "
2260  "be defined as 0 or 1\n");
2261  HECMW_vis_print_exit("Please re-input it and run again");
2262  }
2263 
2264  if ((vr->color_mapping_bar_on == 1) && (vr->xr < 40)) {
2265  fprintf(stderr,
2266  "ERROR: HEC-MW-VIS-E1018:x resolution should be larger than 40 "
2267  "for adding color_mapping_bar case\n");
2268  HECMW_vis_print_exit("please reinput x resolution");
2269  }
2270  if ((vr->scale_marking_on == 1) && (vr->xr < 65)) {
2271  fprintf(stderr,
2272  " ERROR: HEC-MW-VIS-E1019: x resolution should be larger than "
2273  "65 for adding color_mapping and scale marking case\n");
2274  HECMW_vis_print_exit("please re-input x resolution again");
2275  }
2276  if (stat_para[25] == 0) {
2277  sprintf(vr->color_comp_name, "%s", "NULL");
2278  }
2279  if (stat_para[26] == 0) {
2280  sprintf(vr->color_subcomp_name, "%s", "norm");
2281  }
2282  if (stat_para[22] == 1) {
2283  vr->nv_xyz[0] = pesize;
2284  vr->nv_xyz[1] = 1;
2285  vr->nv_xyz[2] = 1;
2286  } else if (stat_para[22] == 0) {
2287  if ((stat_para[27] == 0) && (stat_para[28] == 0) &&
2288  (stat_para[29] == 0)) {
2289  vr->nv_xyz[0] = pesize;
2290 
2291  vr->nv_xyz[1] = 1;
2292  vr->nv_xyz[2] = 1;
2293  } else if ((stat_para[27] == 0) || (stat_para[28] == 0) ||
2294  (stat_para[29] == 0)) {
2296  "ERROR: HEC-MW-VIS-E1040: please define all the n_voxel_x, "
2297  "n_voxel_y, n_voxel_z parameters");
2298  } else if (vr->nv_xyz[0] * vr->nv_xyz[1] * vr->nv_xyz[2] != pesize) {
2299  fprintf(stderr,
2300  "ERROR: HEC-MW-VIS-E1041: n_voxel_x*n_voxel_y*n_voxel_z "
2301  "should be equal to the number of pes\n");
2302  HECMW_vis_print_exit("Please re-input again");
2303  } else if ((vr->nv_xyz[0] <= 0) || (vr->nv_xyz[1] <= 0) ||
2304  (vr->nv_xyz[2] <= 0)) {
2305  fprintf(stderr,
2306  "ERROR: HEC-MW-VIS-E1042: n_voxel_x,n_voxel_y, and n_voxel_z "
2307  "cannot be less or equal to 0\n");
2308  HECMW_vis_print_exit("Please re-input again");
2309  }
2310  }
2311  /* if((vr->surface_on==1) && (stat_para[30]==0)) {
2312  fprintf(stderr, "The surface_filename should be defined in the surface
2313 on case\n");
2314  fprintf(stderr, "Please input again\n");
2315  exit(0);
2316 }
2317  */
2318  if ((vr->rotate_style >= 1) && (vr->rotate_style <= 4)) {
2319  if (stat_para[31] == 0) vr->num_of_frames = 8;
2320  if (vr->num_of_frames <= 0) {
2321  fprintf(stderr,
2322  "ERROR: HEC-MW-VIS-E1015: The parameter num_of_frames cannot "
2323  "be less than 1.\n");
2324  HECMW_vis_print_exit("Please re-input and run again");
2325  }
2326  if (vr->rotate_style == 4) vr->num_of_frames = 8;
2327  }
2328  if (stat_para[32] == 0)
2329  vr->background_color[0] = vr->background_color[1] =
2330  vr->background_color[2] = 0.0;
2331  if (stat_para[33] == 0)
2332  vr->font_color[0] = vr->font_color[1] = vr->font_color[2] = 1.0;
2333  if (stat_para[34] == 0) vr->color_system_type = 1;
2334  if ((vr->color_system_type <= 0) || (vr->color_system_type > 3)) {
2335  fprintf(stderr,
2336  "ERROR: HEC-MW-VIS-E1020: color_system_type should be between "
2337  "1 and 3\n");
2338  HECMW_vis_print_exit("Please re-input and run again");
2339  }
2340  if ((vr->background_color[0] < -EPSILON) ||
2341  (vr->background_color[0] > 1.0 + EPSILON) ||
2342  (vr->background_color[1] < -EPSILON) ||
2343  (vr->background_color[1] > 1.0 + EPSILON) ||
2344  (vr->background_color[2] < -EPSILON) ||
2345  (vr->background_color[2] > 1.0 + EPSILON)) {
2346  fprintf(stderr,
2347  "ERROR: HEC-MW-VIS-E1021: The background color should be in "
2348  "the interval of (0.0, 1.0)\n");
2349  HECMW_vis_print_exit("Please re-input and run again");
2350  }
2351  if ((vr->font_color[0] < -EPSILON) ||
2352  (vr->font_color[0] > 1.0 + EPSILON) ||
2353  (vr->font_color[1] < -EPSILON) ||
2354  (vr->font_color[1] > 1.0 + EPSILON) ||
2355  (vr->font_color[2] < -EPSILON) ||
2356  (vr->font_color[2] > 1.0 + EPSILON)) {
2357  fprintf(stderr,
2358  "ERROR: HEC-MW-VIS-E1022: The font color should be in the "
2359  "interval of (0.0, 1.0)\n");
2360  HECMW_vis_print_exit("Please re-input and run again");
2361  }
2362  if (stat_para[35] == 0) vr->font_size = 1.0;
2363  if (vr->font_size < 1.0 - EPSILON) {
2364  fprintf(stderr,
2365  "ERROR: HEC-MW-VIS-E1023: font_size parameters cannot be "
2366  "between 1.0 and 4.0\n");
2367  HECMW_vis_print_exit("Please re-input and run again");
2368  }
2369  if (vr->font_size > 4.0) vr->font_size = 4.0;
2370  if (stat_para[36] == 0) vr->color_bar_style = 2;
2371  if ((vr->color_bar_style < 1) || (vr->color_bar_style > 2)) {
2372  fprintf(
2373  stderr,
2374  "ERROR: HEC-MW-VIS-E1024: color_bar_style only can be 1 or 2\n");
2375  HECMW_vis_print_exit("Please input and run again");
2376  }
2377  if (stat_para[37] == 0) vr->fixed_range_on = 0;
2378  if ((vr->fixed_range_on < 0) || (vr->fixed_range_on > 1)) {
2379  fprintf(stderr,
2380  "ERROR: HEC-MW-VIS-E1043: fixed_range_on only can be 0 or 1\n");
2381  HECMW_vis_print_exit("Please input and run again");
2382  }
2383  if (stat_para[39] == 0) vr->num_of_scale = 3;
2384  if (vr->num_of_scale <= 0) {
2385  fprintf(stderr,
2386  "ERROR: HEC-MW-VIS-E1025: num_of_scale only can be greater "
2387  "than 0\n");
2388  HECMW_vis_print_exit("Please input and run again");
2389  }
2390  if ((stat_para[37] == 1) && (stat_para[38] == 0)) {
2391  fprintf(stderr,
2392  "ERROR: HEC-MW-VIS-E1026:Please input range_value for "
2393  "fixed_range_on style\n");
2394  HECMW_vis_print_exit("Please re-input and run again");
2395  }
2396  if (stat_para[40] == 0) vr->mark_0_on = 0;
2397  if ((vr->mark_0_on < 0) || (vr->mark_0_on > 1)) {
2398  fprintf(stderr,
2399  "ERROR: HEC-MW-VIS-E1044:mark_0_on only can be 0 or 1\n");
2400  HECMW_vis_print_exit("Please input and run again");
2401  }
2402  if (stat_para[41] == 0) vr->remove_0_display_on = 0;
2403  if ((vr->remove_0_display_on < 0) || (vr->remove_0_display_on > 1)) {
2404  fprintf(
2405  stderr,
2406  "ERROR: HEC-MW-VIS-E1045:remove_0_display_on only can be 0 or 1\n");
2407  HECMW_vis_print_exit("Please input and run again");
2408  }
2409  if (stat_para[42] == 0) vr->specified_level[1] = 0;
2410  if (vr->specified_level[0] < 0) {
2411  fprintf(stderr,
2412  "ERROR: HEC-MW-VIS-E1046: x_specified_level should be greater "
2413  "than 0\n");
2414  HECMW_vis_print_exit("Please input and run again");
2415  }
2416  if (stat_para[43] == 0) vr->specified_level[1] = 0;
2417  if (vr->specified_level[1] < 0) {
2418  fprintf(stderr,
2419  "ERROR: HEC-MW-VIS-E1047: y_specified_level should be greater "
2420  "than 0\n");
2421  HECMW_vis_print_exit("Please input and run again");
2422  }
2423  if (stat_para[44] == 0) vr->specified_level[2] = 0;
2424  if (vr->specified_level[2] < 0) {
2425  fprintf(stderr,
2426  "ERROR: HEC-MW-VIS-E1048: z_specified_level should be greater "
2427  "than 0\n");
2428  HECMW_vis_print_exit("Please input and run again");
2429  }
2430  if (stat_para[45] == 0) vr->histogram_on = 0;
2431  if (stat_para[47] == 0) vr->time_mark_on = 0;
2432  if ((vr->time_mark_on < 0) || (vr->time_mark_on > 1)) {
2433  fprintf(stderr,
2434  "ERROR: HEC-MW-VIS-E1050: time_mark_on value should be 0 or 1");
2435  HECMW_vis_print_exit("Please re-input again");
2436  }
2437  if (stat_para[48] == 0) vr->fixed_scale_mark = 0;
2438  if ((vr->fixed_scale_mark < 0) || (vr->fixed_scale_mark > 1)) {
2439  fprintf(
2440  stderr,
2441  "ERROR: HEC-MW-VIS-E1049: fixed_scale_mark value should be 0 or 1");
2442  HECMW_vis_print_exit("Please re-input again");
2443  }
2444  t1 = pvr->next_pvr;
2445  t1->vr = vr;
2446 
2447  for (i = 0; i < NUM_CONTROL_PVR; i++) t1->stat_para[i] = stat_para[i];
2448  for (i = 0; i < NUM_CONTROL_PVR; i++) HECMW_free(parameters[i]);
2449  HECMW_free(parameters);
2450  HECMW_free(stat_para);
2451  HECMW_free(len_para);
2452  } /*end if visual_method=2 */
2453 
2454  } /*end if visual_method>0 */
2455  /* print some control information */
2456  return;
2457 }
2458 
2459 #if 0
2460 void set_default_vr( Parameter_vr *vr,int stat_para[NUM_CONTROL_PVR], int pesize)
2461 {
2462  int i;
2463  stat_para[0]=stat_para[1]=stat_para[2]=0;
2464  vr->max_level=64;
2465  vr->xr=256;
2466  vr->yr=256;
2467  stat_para[3]=1;
2468  vr->num_of_lights=1;
2469  stat_para[4]=stat_para[5]=stat_para[6]=0;
2470  stat_para[7]=1;
2471  vr->up[0]=0.0;
2472  vr->up[1]=1.0;
2473  vr->up[2]=0.0;
2474  stat_para[8]=stat_para[9]=stat_para[10]=1;
2475  vr->k_ads[0]=0.5;
2476  vr->k_ads[1]=0.8;
2477  vr->k_ads[2]=0.6;
2478  stat_para[11]=1;
2479  /* vr->surface_on=0;
2480  */ stat_para[12]=0;
2481  stat_para[13]=1;
2482  vr->color_mapping_style=1;
2483  stat_para[14]=stat_para[15]=0;
2484  stat_para[16]=stat_para[17]=1;
2485  stat_para[46]=0;
2487  vr->opa_value=0.1;
2488  for(i=18;i<NUM_CONTROL_PVR;i++)
2489  stat_para[i]=0;
2490  vr->color_mapping_bar_on=0;
2491  vr->scale_marking_on=0;
2492  vr->rotate_style=0;
2493  vr->color_system_type=1;
2494  sprintf(vr->color_comp_name,"%s", "NULL");
2495  sprintf(vr->color_subcomp_name,"%s", "norm");
2496  vr->nv_xyz[0]=pesize;
2497  vr->nv_xyz[1]=1;
2498  vr->nv_xyz[2]=1;
2499  vr->font_size=1.0;
2500  vr->color_bar_style=2;
2501  vr->fixed_range_on=0;
2502  vr->num_of_scale=3;
2503  vr->mark_0_on=0;
2504  vr->remove_0_display_on=0;
2505  for(i=0;i<3;i++)
2506  vr->specified_level[i]=0;
2507  vr->histogram_on=0;
2508  return;
2509 }
2510 
2511 
2512 void read_lookup_table(Parameter_vr *vr, double *opa_table)
2513 {
2514  int i;
2515  FILE *opa_fp;
2516  if((opa_fp=fopen(vr->name_lookup,"r"))== NULL) {
2517  fprintf(stderr, "There is not such a opacity file:\n");
2518  exit (0);
2519  }
2520  for(i=0;i<256;i++)
2521  fscanf(opa_fp, "%lf", &(opa_table[i]));
2522  return;
2523 }
2524 #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)
PVR_link * pvr
PSF_link * psf
void tolower(char *s)
Definition: hecd_util.cpp:56
void toupper(char *s)
Definition: hecd_util.cpp:37
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]