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. 3.6 7 */ 8 9 #ifndef CHECDB_VisualH 10 #define CHECDB_VisualH 11 12 #include "CHECDataBlock.h" 13 14 // parameters for screen 15 class CVis_ViewParams { 16 public: 17 // screen 18 19 int x_resolution; // default:512 20 int y_resolution; // default:512 21 int num_of_lights; // default:1 22 double* position_of_lights; // (default:NULL--not specified) 23 double viewpoint[3]; 24 bool fg_viewpoint; // (inner use, default:false); 25 double look_at_point[3]; 26 bool fg_look_at_point; // (inner use, default:false); 27 double up_direction[3]; // default:{0,0,1} 28 double ambient_coef; // default:0.3 29 double diffuse_coef; // default:0.7 30 double specular_coef; // default:0.6 31 int color_mapping_style; 32 enum { 33 color_mapping_style_linear = 1, // default; 34 color_mapping_style_clipped_linear, 35 color_mapping_style_nonlinear, 36 color_mapping_style_automatic 37 }; 38 int interval_mapping_num; // (default:0) 39 double* interval_mapping; // (default:NULL -- not specified) 40 41 int rotate_style; 42 enum { 43 rotate_style_none = 0, // default ( inner use ) 44 rotate_style_x, 45 rotate_style_y, 46 rotate_style_z, 47 rotate_style_view_point 48 }; 49 int num_of_frame; // default:8 50 int color_mapping_bar_on; // default:0 51 int scale_marking_on; // default:0 52 int num_of_scales; // default:3 53 double font_size; // default:1 54 double font_color[3]; // default:{1,1,1} 55 double background_color[3]; // default:{0,0,0} 56 57 int color_system_type; 58 enum { 59 color_system_type_blue_red = 1, // default 60 color_system_type_rainbow, 61 color_system_type_block_white 62 }; 63 int fixed_range_on; // default:0 64 double range_value[2]; 65 bool fg_range_value; // (inner use, default:false) 66 67 public: 68 // methods 69 CVis_ViewParams(); 70 virtual ~CVis_ViewParams(); 71 virtual void Init(); 72 virtual void Write(class CHECData* hecd); 73 static void WriteVisParam(class CHECData* hecd, const char* name, 74 const char* fmt, ...); 75 static void WriteVisPArry(class CHECData* hecd, const char* name, char type, 76 int n, void* p); // for array 77 78 template <class T> 79 static int ReadVisValueT(char* s, int n, T* value, const char* fmt); 80 static int ReadVisValue(char* s, int n, int* value); 81 static int ReadVisValue(char* s, int n, double* value); 82 static int ReadVisValue( 83 char* s, int n, char* value); // n:sizeof(value), return:strlen(value) 84 template <class T> 85 static T* ReadVisPArry(char* s, int& n, const char* fmt); 86 87 virtual bool ReadData(const char* line); 88 virtual bool Read(class CHECData* hecd); 89 }; 90 91 //----------------------------------------------------------------------------- 92 93 class CVis_PSR : public CVis_ViewParams { 94 public: 95 // common ------------------------------------------------ 96 97 int surface_style; 98 enum { 99 surface_style_boundary = 1, // default 100 surface_style_equivalent, 101 surface_style_user 102 }; 103 int display_method; 104 enum { 105 display_method_color = 1, // default 106 display_method_boundary, 107 display_method_color_and_boundary, 108 display_method_mono_tone, 109 display_method_contour 110 }; 111 char color_comp_name[100]; 112 char color_subcomp_name[4]; // "norm", "x"(default), "y" or "z" 113 int color_comp; // default:0 114 int color_subcomp; // default:1 115 int iso_number; // default:5 116 double specified_color; // effective if display_method == 4 117 int deform_display_on; // 1:on, 0:off, default:0 118 char deform_comp_name[100]; 119 int deform_comp; // default:0 120 double deform_scale; 121 bool fg_deform_scale; // is deform_scale set? (inner use) default:false 122 int initial_style; 123 enum { 124 initial_style_none = 0, // default 125 initial_style_mesh, 126 initial_style_fill, 127 initial_style_shading, 128 initial_style_dot_mesh 129 }; 130 int deform_style; 131 enum { 132 deform_style_none = 0, 133 deform_style_mesh, 134 deform_style_fill, 135 deform_style_shading, 136 deform_style_dot_mesh // default 137 }; 138 double initial_line_color[3]; // default:{0,0,1} 139 double deform_line_color[3]; // default:{0,0,1} 140 char output_type[3]; // "AVS"(default), "BMP" 141 142 // for surface_style == surface_style_equivalent --------- 143 144 char data_comp_name[100]; 145 char data_subcomp_name[4]; // "norm", "x"(default), "y" or "z" 146 int data_comp; // default:0 147 int data_subcomp; // default:1 148 double iso_value; 149 150 // for surface_style == surface_style_user --------------- 151 152 int method; 153 enum { 154 method_sphere = 1, 155 method_ellipsoid, 156 method_hyperbola, 157 method_parabola, 158 method_quadric // default 159 }; 160 double point[3]; // default:{0,0,0} 161 double radius; // default:1.0 162 double length; // (default:1.0) 163 double coef[10]; // (default:0.0) 164 165 // rendering parameters(output_type == "BMP") ------------ 166 // parameters defined in CVis_ScreenParams and followings 167 168 double isoline_color[3]; 169 bool fg_isoline_color; // (inner use, default:false ) 170 int boundary_line_on; // default:0 171 172 public: 173 // methods 174 CVis_PSR(); 175 virtual ~CVis_PSR(); 176 virtual void Init(); 177 virtual void Write(class CHECData* hecd); 178 virtual bool ReadData(const char* line); 179 }; 180 181 //----------------------------------------------------------------------------- 182 183 class CVis_PVR : public CVis_ViewParams { 184 public: 185 // for dividing ------------------------------------------ 186 187 int maximum_refinement; // default:100 188 int n_voxel_x; 189 bool fg_n_voxel_x; // (inner use, default:false) 190 int n_voxel_y; 191 bool fg_n_voxel_y; // (inner use, default:false) 192 int n_voxel_z; 193 bool fg_n_voxel_z; // (inner use, default:false) 194 char voxel_filename[100]; // default:"" 195 int x_specified_level; // default:100 196 int y_specified_level; // default:100 197 int z_specified_level; // default:100 198 199 // for opacity 200 201 int transfer_function_type; // default:1 202 double opa_value; // default:0.02 203 int num_of_features; // (default:0) 204 double* fea_point; // (default:NULL (no set)) 205 char name_lookup[100]; // (default:"" (no set)) 206 207 // parameters defined in CVis_ViewParams and followings 208 209 int histogram_on; // default:0 210 double display_range[6]; // (default:0) 211 bool fg_display_range; // (inner use, default:false) 212 213 public: 214 // methods 215 CVis_PVR(); 216 virtual ~CVis_PVR(); 217 virtual void Init(); 218 virtual void Write(class CHECData* hecd); 219 virtual bool ReadData(const char* line); 220 }; 221 222 //----------------------------------------------------------------------------- 223 // CHECDB_Visual 224 //----------------------------------------------------------------------------- 225 226 class CHECDB_Visual : public CHECDataBlock { 227 public: 228 int visual_start_step; 229 int visual_interval_step; 230 int visual_end_step; 231 232 int surface_num; 233 std::vector<CVis_PSR*> psr; // psr.size() == surface_num 234 235 CVis_PVR* pvr; // single instance 236 237 CHECDB_Visual(); 238 virtual ~CHECDB_Visual(); 239 virtual void Clear(); 240 virtual void Write(class CHECData* hecd); 241 virtual bool Read(class CHECData* hecd, char* header_line); 242 }; 243 244 #endif 245