FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
CHECDB_Visual.cpp
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 /*
6  CHECDB_Visual Ver.1.0
7 */
8 
9 #include <stdarg.h>
10 #include <vector>
11 #include "CHECDB.h"
12 #include "CHECDB_Visual.h"
13 #include "CHECData.h"
14 #include "hecd_util.h"
15 
16 using namespace std;
17 using namespace hecd_util;
18 
19 //*****************************************************************************
20 // CVis_ViewParams
21 //*****************************************************************************
22 
24  : position_of_lights(0), interval_mapping(0) {
25  Init();
26 }
27 
29  delete position_of_lights;
30  delete interval_mapping;
31 }
32 
34  x_resolution = 512;
35  y_resolution = 512;
36  num_of_lights = 1;
37  delete position_of_lights;
39  viewpoint[0] = viewpoint[1] = viewpoint[2] = 0;
40  fg_viewpoint = false;
41  look_at_point[0] = look_at_point[1] = look_at_point[2] = 0;
42  fg_look_at_point = false;
43  up_direction[0] = 0;
44  up_direction[1] = 0;
45  up_direction[2] = 1;
46  ambient_coef = 0.3;
47  diffuse_coef = 0.7;
48  specular_coef = 0.6;
51  delete[] interval_mapping;
52  interval_mapping = 0;
53  interval_mapping = 0;
55  num_of_frame = 8;
57  scale_marking_on = 0;
58  num_of_scales = 3;
59  font_size = 1;
60  font_color[0] = font_color[1] = font_color[2] = 1;
63  fixed_range_on = 0;
64  range_value[0] = range_value[1] = 0;
65  fg_range_value = false;
66 }
67 
68 void CVis_ViewParams::WriteVisParam(class CHECData *hecd, const char *name,
69  const char *fmt, ...) {
70  va_list va;
71  va_start(va, fmt);
72  char buff[256];
73  size_t len = snprintf(buff, sizeof(buff), "!%s", name);
74  int n = strlen(fmt);
75 
76  if (n > 1) {
77  len += snprintf(buff + len, sizeof(buff) - len, " =");
78  }
79 
80  for (int i = 0; i < n; i++) {
81  len += snprintf(buff + len, sizeof(buff) - len, " ");
82  char c = fmt[i];
83 
84  switch (c) {
85  case 'S':
86  len += snprintf(buff + len, sizeof(buff) - len, "%s", va_arg(va, char *));
87  break;
88 
89  case 'I':
90  len += snprintf(buff + len, sizeof(buff) - len, "%d", va_arg(va, int));
91  break;
92 
93  case 'F':
94  len += snprintf(buff + len, sizeof(buff) - len, "%lg", va_arg(va, double));
95  break;
96 
97  default:
98  assert(0);
99  }
100  }
101 
102  hecd->WriteLine(buff);
103  va_end(va);
104 }
105 
106 void CVis_ViewParams::WriteVisPArry(class CHECData *hecd, const char *name,
107  char type, int n, void *p) {
108  char buff[256];
109  int *ip;
110  double *dp;
111  size_t len = snprintf(buff, sizeof(buff), "!%s", name);
112 
113  if (n > 1) {
114  len += snprintf(buff + len, sizeof(buff) - len, " =");
115  }
116 
117  ip = (int *)p;
118  dp = (double *)p;
119 
120  for (int i = 0; i < n; i++) {
121  len += snprintf(buff + len, sizeof(buff) - len, ", ");
122 
123  switch (type) {
124  case 'I':
125  len += snprintf(buff + len, sizeof(buff) - len, "%d", *ip);
126  ip++;
127  break;
128 
129  case 'F':
130  len += snprintf(buff + len, sizeof(buff) - len, "%lg", *dp);
131  dp++;
132  break;
133 
134  default:
135  assert(0);
136  }
137  }
138 
139  hecd->WriteLine(buff);
140 }
141 
142 void CVis_ViewParams::Write(class CHECData *hecd) {
143  WriteVisParam(hecd, "x_resolution", "I", x_resolution);
144  WriteVisParam(hecd, "y_resolution", "I", y_resolution);
145  WriteVisParam(hecd, "num_of_lights", "I", num_of_lights);
146 
147  if (num_of_lights > 0 && position_of_lights) {
148  WriteVisPArry(hecd, "position_of_lights", 'F', num_of_lights,
150  }
151 
152  if (fg_viewpoint) WriteVisPArry(hecd, "viewpoint", 'F', 3, viewpoint);
153 
154  if (fg_look_at_point)
155  WriteVisPArry(hecd, "look_at_point", 'F', 3, look_at_point);
156 
157  WriteVisParam(hecd, "up_direction", "F", 3, up_direction);
158  WriteVisParam(hecd, "ambient_coef", "F", ambient_coef);
159  WriteVisParam(hecd, "diffuse_coef", "F", diffuse_coef);
160  WriteVisParam(hecd, "specular_coef", "F", specular_coef);
161  WriteVisParam(hecd, "color_mapping_style", "I", color_mapping_style);
162  WriteVisParam(hecd, "interval_mapping_num", "I", interval_mapping_num);
163 
164  if (interval_mapping_num > 0) {
165  if (!interval_mapping) assert(0);
166 
167  WriteVisPArry(hecd, "nterval_mapping", 'F', interval_mapping_num * 2,
169  }
170 
172  WriteVisParam(hecd, "rotate_style", "I", rotate_style);
173 
174  WriteVisParam(hecd, "num_of_frame", "I", num_of_frame);
175  WriteVisParam(hecd, "color_mapping_bar_on", "I", color_mapping_bar_on);
176  WriteVisParam(hecd, "scale_marking_on", "I", scale_marking_on);
177  WriteVisParam(hecd, "num_of_scales", "I", num_of_scales);
178  WriteVisParam(hecd, "font_size", "F", font_size);
179  WriteVisPArry(hecd, "font_color", 'F', 3, font_color);
180  WriteVisPArry(hecd, "font_color", 'F', 3, font_color);
181  WriteVisPArry(hecd, "background_color", 'F', 3, background_color);
182  WriteVisParam(hecd, "color_system_type", "I", color_system_type);
183  WriteVisParam(hecd, "fixed_range_on", "I", fixed_range_on);
184 
185  if (fg_range_value) WriteVisPArry(hecd, "range_value", 'F', 3, range_value);
186 }
187 
188 //-----------------------------------------------------------------------------
189 
190 template <class T>
191 int CVis_ViewParams::ReadVisValueT(char *s, int n, T *value, const char *fmt) {
192  const char *delim = ", \t\r\n";
193  int i = 0;
194  char *token = strtok(s, delim);
195 
196  while (token && i < n) {
197  if (sscanf(token, fmt, &value[i]) != 1) return -(i + 1);
198 
199  token = strtok(0, delim);
200  i++;
201  }
202 
203  return i;
204 }
205 
206 int CVis_ViewParams::ReadVisValue(char *s, int n, int *value) {
207  return ReadVisValueT<int>(s, n, value, "%d");
208 }
209 
210 int CVis_ViewParams::ReadVisValue(char *s, int n, double *value) {
211  return ReadVisValueT<double>(s, n, value, "%lf");
212 }
213 
214 int CVis_ViewParams::ReadVisValue(char *s, int n, char *value) {
215  // Handle NULL pointer case (when called from strtok continuation)
216  if (s == NULL) {
217  return 0;
218  }
219 
220  cleanup_token(s);
221  int len = strlen(s);
222 
223  if (len >= n) return 0;
224 
225  snprintf(value, n, "%s", s);
226  return len;
227 }
228 
229 template <class T>
230 T *CVis_ViewParams::ReadVisPArry(char *s, int &n, const char *fmt) {
231  const int max_data_n = 200;
232  T buff[max_data_n];
233  const char *delim = ", \t\r\n";
234  n = 0;
235  int i = 0;
236  char *token = strtok(s, delim);
237 
238  while (token) {
239  if (max_data_n >= i) assert(0);
240 
241  T x;
242 
243  if (sscanf(token, fmt, &x) != 1) {
244  return 0;
245  }
246 
247  buff[i] = x;
248  token = strtok(0, delim);
249  i++;
250  }
251 
252  n = i;
253  T *data = new T[n];
254 
255  for (i = 0; i < n; i++) {
256  data[i] = buff[i];
257  }
258 
259  return data;
260 }
261 
262 bool CVis_ViewParams::ReadData(const char *line) {
263  char buff[256];
264  snprintf(buff, sizeof(buff), "%s", line);
265  char *header = strtok(buff, " =,\r\n\t");
266 
267  if (header[0] == 0 || header[0] != '!') return false;
268 
269  tolower(header);
270 #define GENERATE_CODE(x, n, fg) \
271  else if (strcmp(#x, header) == 0) { \
272  int r = ReadVisValue(0, n, &x); \
273  fg = (r > 0); \
274  return fg; \
275  }
276 #define GENERATE_CODEA(x, n, fg) \
277  else if (strcmp(#x, header) == 0) { \
278  int r = ReadVisValue(0, n, x); \
279  fg = (r > 0); \
280  return fg; \
281  }
282  bool dummy;
283 
284  if (false)
285  ; // dummy
286 
287  GENERATE_CODE(x_resolution, 1, dummy)
288  GENERATE_CODE(y_resolution, 1, dummy)
291  GENERATE_CODEA(up_direction, 3, dummy)
292  GENERATE_CODE(ambient_coef, 1, dummy)
293  GENERATE_CODE(diffuse_coef, 1, dummy)
294  GENERATE_CODE(specular_coef, 1, dummy)
296  GENERATE_CODE(rotate_style, 1, dummy)
297  GENERATE_CODE(num_of_frame, 1, dummy)
300  GENERATE_CODE(num_of_scales, 1, dummy)
301  GENERATE_CODE(font_size, 1, dummy)
302  GENERATE_CODEA(font_color, 3, dummy)
305  GENERATE_CODE(fixed_range_on, 1, dummy)
307 #undef GENERATE_CODE
308 #undef GENERATE_CODEA
309 #define GENERATE_CODE(x, n, type, fmt) \
310  else if (strcmp(#x, header) == 0) { \
311  delete[] x; \
312  x = 0; \
313  x = ReadVisPArry<type>(0, n, fmt); \
314  return x != 0; \
315  }
316 
317  if (false)
318  ;
319 
322 #undef GENERATE_CODE
323  return false;
324 }
325 
327  char line[256];
328 
329  while (1) {
330  if (!hecd->ReadLine(line)) break;
331 
332  if (!ReadData(line)) {
333  hecd->PushReadLine(line);
334  break;
335  }
336  }
337 
338  return true;
339 }
340 
341 //*****************************************************************************
342 // CVis_PSR
343 //*****************************************************************************
344 
346 
348 
350  // common ------------------------------------------------
353  color_comp_name[0] = 0;
354  snprintf(color_subcomp_name, sizeof(color_subcomp_name), "x");
355  color_comp = 0;
356  color_subcomp = 1;
357  iso_number = 5;
358  specified_color = 0;
359  deform_display_on = 0;
360  deform_comp_name[0] = 0;
361  deform_comp = 0;
362  deform_scale = 0;
363  fg_deform_scale = false;
366  initial_line_color[0] = 0;
367  initial_line_color[1] = 0;
368  initial_line_color[2] = 1;
369  deform_line_color[0] = 0;
370  deform_line_color[1] = 0;
371  deform_line_color[2] = 1;
372  snprintf(output_type, sizeof(output_type), "AVS");
373  // for surface_style == surface_style_equivalent ---------
374  data_comp_name[0] = 0;
375  snprintf(data_subcomp_name, sizeof(data_subcomp_name), "x");
376  data_comp = 0;
377  data_subcomp = 1;
378  iso_value = 0;
379  // for surface_style == surface_style_user ---------------
381  point[0] = point[1] = point[2] = 0;
382  radius = 1;
383  length = 1;
384 
385  for (int i = 0; i < 10; i++) coef[i] = 0;
386 
387  // rendering parameters(output_type == "BMP") ------------
389  isoline_color[0] = isoline_color[1] = isoline_color[2] = 0;
390  fg_isoline_color = false;
391  boundary_line_on = 0;
392 }
393 
394 void CVis_PSR::Write(class CHECData *hecd) {
395  // common ------------------------------------------------
396  hecd->WriteLine("!!common of PSR ----------------------------------");
397  WriteVisParam(hecd, "surface_style", "I", surface_style);
398  WriteVisParam(hecd, "display_method", "I", display_method);
399 
400  if (color_comp_name[0] != 0)
401  WriteVisParam(hecd, "display_method", "S", color_comp_name);
402 
403  if (color_subcomp_name[0] != 0)
404  WriteVisParam(hecd, "color_subcomp_name", "S", color_subcomp_name);
405 
406  WriteVisParam(hecd, "color_comp", "I", color_comp);
407  WriteVisParam(hecd, "color_subcomp", "I", color_subcomp);
408  WriteVisParam(hecd, "iso_number", "I", iso_number);
409  WriteVisParam(hecd, "specified_color", "F", specified_color);
410  WriteVisParam(hecd, "deform_display_on", "I", deform_display_on);
411 
412  if (deform_comp_name[0] != 0)
413  WriteVisParam(hecd, "deform_comp_name", "S", deform_comp_name);
414 
415  WriteVisParam(hecd, "deform_comp", "I", deform_comp);
416 
417  if (fg_deform_scale) WriteVisParam(hecd, "deform_scale", "F", deform_scale);
418 
420  WriteVisParam(hecd, "initial_style", "I", initial_style);
421 
423  WriteVisParam(hecd, "deform_style", "I", deform_style);
424 
425  WriteVisPArry(hecd, "initial_line_color", 'F', 3, initial_line_color);
426  WriteVisPArry(hecd, "deform_line_color", 'F', 3, deform_line_color);
427  WriteVisParam(hecd, "output_type", "S", output_type);
428  // for surface_style == surface_style_equivalent ---------
429  hecd->WriteLine("!!for equivalent value surface -------------------");
430 
431  if (data_comp_name[0] != 0)
432  WriteVisParam(hecd, "data_comp_name", "S", data_comp_name);
433 
434  WriteVisParam(hecd, "data_subcomp_name", "S", data_subcomp_name);
435  WriteVisParam(hecd, "data_comp", "I", data_comp);
436  WriteVisParam(hecd, "data_subcomp", "I", data_subcomp);
437  WriteVisParam(hecd, "iso_value", "F", iso_value);
438  // for surface_style == surface_style_user ---------------
439  hecd->WriteLine("!!for surface of user defined equation -----------");
440  WriteVisParam(hecd, "method", "I", method);
441  WriteVisPArry(hecd, "point", 'F', 3, point);
442  WriteVisParam(hecd, "radius", "F", radius);
443  WriteVisParam(hecd, "length", "F", length);
444  WriteVisPArry(hecd, "coef", 'F', 10, coef);
445  // rendering parameters(output_type == "BMP") ------------
446  // parameters defined in CVis_ScreenParams and followings
447  hecd->WriteLine("!!for BMP output ---------------------------------");
449 
450  if (fg_isoline_color)
451  WriteVisPArry(hecd, "isoline_color", 'F', 3, isoline_color);
452 
453  WriteVisParam(hecd, "boundary_line_on", "I", boundary_line_on);
454 }
455 
456 bool CVis_PSR::ReadData(const char *line) {
457  if (CVis_ViewParams::ReadData(line)) return true;
458 
459  char buff[256];
460  snprintf(buff, sizeof(buff), "%s", line);
461  char *header = strtok(buff, " =,\r\n\t");
462 
463  if (header[0] == 0 || header[0] != '!') return false;
464 
465  tolower(header);
466 #define GENERATE_CODE(x, n, fg) \
467  else if (strcmp(#x, header) == 0) { \
468  int r = ReadVisValue(0, n, &x); \
469  fg = (r > 0); \
470  return fg; \
471  }
472 #define GENERATE_CODEA(x, n, fg) \
473  else if (strcmp(#x, header) == 0) { \
474  int r = ReadVisValue(0, n, x); \
475  fg = (r > 0); \
476  return fg; \
477  }
478  bool dummy;
479 
480  if (false)
481  ; // dummy
482 
483  GENERATE_CODE(surface_style, 1, dummy)
484  GENERATE_CODE(display_method, 1, dummy)
485  GENERATE_CODEA(color_comp_name, 100, dummy)
487  GENERATE_CODE(color_comp, 1, dummy)
488  GENERATE_CODE(color_subcomp, 1, dummy)
489  GENERATE_CODE(iso_number, 1, dummy)
490  GENERATE_CODE(specified_color, 1, dummy)
492  GENERATE_CODEA(deform_comp_name, 100, dummy)
493  GENERATE_CODE(deform_comp, 1, dummy)
495  GENERATE_CODE(initial_style, 1, dummy)
496  GENERATE_CODE(deform_style, 1, dummy)
499  GENERATE_CODEA(output_type, 4, dummy)
500  // for surface_style == surface_style_equivalent ---------
501  GENERATE_CODEA(data_comp_name, 100, dummy)
503  GENERATE_CODE(data_comp, 1, dummy)
504  GENERATE_CODE(data_subcomp, 1, dummy)
505  GENERATE_CODE(iso_value, 1, dummy)
506  // for surface_style == surface_style_user ---------------
507  GENERATE_CODE(method, 1, dummy)
508  GENERATE_CODEA(point, 3, dummy)
509  GENERATE_CODE(radius, 1, dummy)
510  GENERATE_CODE(length, 1, dummy)
511  GENERATE_CODEA(coef, 10, dummy)
512  // rendering parameters(output_type == "BMP") ------------
513  // parameters defined in CVis_ScreenParams and followings
516 #undef GENERATE_CODE
517 #undef GENERATE_CODEA
518  return false;
519 }
520 
521 //*****************************************************************************
522 // CVis_PVR
523 //*****************************************************************************
524 
525 CVis_PVR::CVis_PVR() : CVis_ViewParams(), fea_point(0) { Init(); }
526 
528 
530  // for dividing ------------------------------------------
531  maximum_refinement = 100;
532  n_voxel_x = 0;
533  fg_n_voxel_x = false;
534  n_voxel_y = 0;
535  fg_n_voxel_y = false;
536  n_voxel_z = 0;
537  fg_n_voxel_z = false;
538  voxel_filename[0] = 0;
539  x_specified_level = 100;
540  y_specified_level = 100;
541  z_specified_level = 100;
542  // for opacity
544  opa_value = 0.02;
545  num_of_features = 0;
546  delete fea_point;
547  fea_point = 0;
548  name_lookup[0] = 0;
549  // parameters defined in CVis_ViewParams and followings
551  histogram_on = 0;
552 
553  for (int i = 0; i < 6; i++) display_range[i] = 0;
554 
555  fg_display_range = false;
556 }
557 
558 void CVis_PVR::Write(class CHECData *hecd) {
559  // for dividing ------------------------------------------
560  hecd->WriteLine("!!for dividing -----------------------------------");
561  WriteVisParam(hecd, "maximum_refinement", "I", maximum_refinement);
562 
563  if (fg_n_voxel_x) WriteVisParam(hecd, "n_voxel_x", "I", n_voxel_x);
564 
565  if (fg_n_voxel_y) WriteVisParam(hecd, "n_voxel_y", "I", n_voxel_y);
566 
567  if (fg_n_voxel_z) WriteVisParam(hecd, "n_voxel_z", "I", n_voxel_z);
568 
569  if (voxel_filename[0] != 0)
570  WriteVisParam(hecd, "voxel_filename", "S", voxel_filename);
571 
572  WriteVisParam(hecd, "x_specified_level", "I", x_specified_level);
573  WriteVisParam(hecd, "y_specified_level", "I", y_specified_level);
574  WriteVisParam(hecd, "z_specified_level", "I", z_specified_level);
575  // for opacity -------------------------------------------
576  hecd->WriteLine("!!for opacity ------------------------------------");
577  WriteVisParam(hecd, "transfer_function_type", "I", transfer_function_type);
578  WriteVisParam(hecd, "opa_value", "F", opa_value);
579  WriteVisParam(hecd, "num_of_features", "I", num_of_features);
580 
581  if (num_of_features > 0 && fea_point)
582  WriteVisPArry(hecd, "fea_point", 'F', 3 * num_of_features, fea_point);
583 
584  if (name_lookup[0] != 0) WriteVisParam(hecd, "name_lookup", "S", name_lookup);
585 
586  // parameters defined in CVis_ViewParams and followings
587  hecd->WriteLine("!!view params ------------------------------------");
589  WriteVisParam(hecd, "histogram_on", "I", histogram_on);
590 
591  if (fg_display_range)
592  WriteVisPArry(hecd, "display_range", 'F', 6, display_range);
593 }
594 
595 bool CVis_PVR::ReadData(const char *line) {
596  if (CVis_ViewParams::ReadData(line)) return true;
597 
598  char buff[256];
599  snprintf(buff, sizeof(buff), "%s", line);
600  char *header = strtok(buff, " =,\r\n\t");
601 
602  if (header[0] == 0 || header[0] != '!') return false;
603 
604  tolower(header);
605 #define GENERATE_CODE(x, n, fg) \
606  else if (strcmp(#x, header) == 0) { \
607  int r = ReadVisValue(0, n, &x); \
608  fg = (r > 0); \
609  return fg; \
610  }
611 #define GENERATE_CODEA(x, n, fg) \
612  else if (strcmp(#x, header) == 0) { \
613  int r = ReadVisValue(0, n, x); \
614  fg = (r > 0); \
615  return fg; \
616  }
617  bool dummy;
618 
619  if (false)
620  ; // dummy
621 
622  // for dividing ------------------------------------------
627  GENERATE_CODEA(voxel_filename, 100, dummy)
631  // for opacity
633  GENERATE_CODE(opa_value, 1, dummy)
634  GENERATE_CODE(num_of_features, 1, dummy)
635  GENERATE_CODEA(name_lookup, 100, dummy)
636  // parameters defined in CVis_ViewParams and followings
637  GENERATE_CODE(histogram_on, 1, dummy)
639 #undef GENERATE_CODE
640 #undef GENERATE_CODEA
641 #define GENERATE_CODE(x, n, type, fmt) \
642  else if (strcmp(#x, header) == 0) { \
643  delete[] x; \
644  x = 0; \
645  x = ReadVisPArry<type>(0, n, fmt); \
646  return x != 0; \
647  }
648 
649  if (num_of_features <= 0) return false;
650 
651  int f_data_size = 3 * num_of_features;
652 
653  if (false)
654  ;
655 
656  GENERATE_CODE(fea_point, f_data_size, double, "%lf");
657 #undef GENERATE_CODE
658  return false;
659 }
660 
661 //-----------------------------------------------------------------------------
662 // CHECDB_Visual
663 //-----------------------------------------------------------------------------
664 
666  visual_start_step = -1;
668  visual_end_step = -1;
669  surface_num = 0;
670 }
671 
673 
675  visual_start_step = -1;
677  visual_end_step = -1;
678  surface_num = 0;
679  vector<CVis_PSR *>::iterator is;
680 
681  for (is = psr.begin(); is != psr.end(); is++) {
682  delete *is;
683  }
684 
685  psr.clear();
686  delete pvr;
687  pvr = 0;
688 }
689 
690 void CHECDB_Visual::Write(class CHECData *hecd) {
691  surface_num = psr.size();
692 
693  if (surface_num > 0) {
694  hecd->WriteHeader("!VISUAL", "SIII", "method", "PSR", "visual_start_step",
695  visual_start_step, "visual_interval_step",
696  visual_interval_step, "visual_end_step", visual_end_step);
697  CVis_ViewParams::WriteVisParam(hecd, "surface_num", "I", surface_num);
698  vector<CVis_PSR *>::iterator is;
699 
700  for (is = psr.begin(); is != psr.end(); is++) {
701  hecd->WriteLine("!SURFACE");
702  (*is)->Write(hecd);
703  }
704  }
705 
706  if (pvr) {
707  hecd->WriteHeader("!VISUAL", "SIII", "method", "PVR", "visual_start_step",
708  visual_start_step, "visual_interval_step",
709  visual_interval_step, "visual_end_step", visual_end_step);
710  pvr->Write(hecd);
711  }
712 }
713 
714 bool CHECDB_Visual::Read(CHECData *hecd, char *header_line) {
715  char s[256];
716  char method_s[256];
717  int rcode[10];
718 
719  if (!hecd->ParseHeader(header_line, rcode, "SIII", "method", s,
720  "visual_start_step", &visual_start_step,
721  "visual_interval_step", &visual_interval_step,
722  "visual_end_step", &visual_end_step))
723  return false;
724 
725  cleanup_token(s, method_s);
726  toupper(method_s);
727  bool fg_psr = (strcmp("PSR", method_s) == 0);
728 
729  if (fg_psr) {
730  if (!hecd->ReadParameter(rcode, "I", "surface_num", &surface_num))
731  return false;
732 
733  for (int i = 0; i < surface_num; i++) {
734  if (!hecd->ReadLine(s)) return false;
735 
736  cleanup_token(s);
737  toupper(s);
738 
739  if (strcmp("!SURFACE", s) != 0) return false;
740 
741  CVis_PSR *vis_psr = new CVis_PSR();
742 
743  if (!vis_psr->Read(hecd)) {
744  delete vis_psr;
745  return false;
746  }
747 
748  psr.push_back(vis_psr);
749  }
750 
751  } else {
752  delete pvr;
753  pvr = new CVis_PVR();
754 
755  if (!pvr->Read(hecd)) {
756  delete pvr;
757  pvr = 0;
758  return false;
759  }
760  }
761 
762  return true;
763 }
@ HECDB_VISUAL
Definition: CHECDB.h:28
#define GENERATE_CODEA(x, n, fg)
#define GENERATE_CODE(x, n, fg)
int visual_interval_step
virtual ~CHECDB_Visual()
virtual void Write(class CHECData *hecd)
CVis_PVR * pvr
virtual void Clear()
virtual bool Read(class CHECData *hecd, char *header_line)
std::vector< CVis_PSR * > psr
virtual bool ParseHeader(char *header_line, int *rcode, const char *fmt,...)
Definition: CHECData.cpp:494
virtual bool ReadLine(char *s, int size=256)
Definition: CHECData.cpp:295
virtual bool ReadParameter(int *rcode, const char *fmt,...)
Definition: CHECData.cpp:513
virtual void WriteHeader(const char *name, const char *fmt="",...)
Definition: CHECData.cpp:68
virtual void WriteLine(const char *s)
Definition: CHECData.cpp:58
virtual void PushReadLine(const char *s)
Definition: CHECData.cpp:316
char color_subcomp_name[5]
char deform_comp_name[100]
double radius
int data_subcomp
char output_type[4]
double length
int deform_display_on
virtual ~CVis_PSR()
int display_method
@ deform_style_none
int color_comp
virtual bool ReadData(const char *line)
int surface_style
Definition: CHECDB_Visual.h:97
double iso_value
char color_comp_name[100]
double deform_line_color[3]
double deform_scale
bool fg_isoline_color
int iso_number
int initial_style
double initial_line_color[3]
double specified_color
int deform_comp
int color_subcomp
double isoline_color[3]
bool fg_deform_scale
int boundary_line_on
virtual void Init()
char data_subcomp_name[5]
@ surface_style_boundary
Definition: CHECDB_Visual.h:99
@ display_method_color
double coef[10]
@ initial_style_none
virtual void Write(class CHECData *hecd)
int deform_style
double point[3]
char data_comp_name[100]
int transfer_function_type
bool fg_n_voxel_z
double opa_value
double * fea_point
bool fg_n_voxel_x
int maximum_refinement
int z_specified_level
int histogram_on
virtual void Init()
virtual ~CVis_PVR()
double display_range[6]
virtual void Write(class CHECData *hecd)
bool fg_display_range
char voxel_filename[100]
int num_of_features
bool fg_n_voxel_y
virtual bool ReadData(const char *line)
int x_specified_level
int y_specified_level
char name_lookup[100]
virtual bool Read(class CHECData *hecd)
double up_direction[3]
Definition: CHECDB_Visual.h:27
virtual bool ReadData(const char *line)
double range_value[2]
Definition: CHECDB_Visual.h:64
double specular_coef
Definition: CHECDB_Visual.h:30
static void WriteVisParam(class CHECData *hecd, const char *name, const char *fmt,...)
double * position_of_lights
Definition: CHECDB_Visual.h:22
static T * ReadVisPArry(char *s, int &n, const char *fmt)
virtual void Write(class CHECData *hecd)
static void WriteVisPArry(class CHECData *hecd, const char *name, char type, int n, void *p)
virtual void Init()
double font_color[3]
Definition: CHECDB_Visual.h:54
static int ReadVisValueT(char *s, int n, T *value, const char *fmt)
double look_at_point[3]
Definition: CHECDB_Visual.h:25
double * interval_mapping
Definition: CHECDB_Visual.h:39
virtual ~CVis_ViewParams()
double background_color[3]
Definition: CHECDB_Visual.h:55
static int ReadVisValue(char *s, int n, int *value)
double viewpoint[3]
Definition: CHECDB_Visual.h:23
#define NULL
PVR_link * pvr
void tolower(char *s)
Definition: hecd_util.cpp:57
void toupper(char *s)
Definition: hecd_util.cpp:38
void cleanup_token(char *s)
Definition: hecd_util.cpp:13
CNFData data