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