1 /*****************************************************************************
2  * Copyright (c) 2019 FrontISTR Commons
3  * This software is released under the MIT License, see LICENSE.txt
4  *****************************************************************************/
5 
6 #ifndef HECMW_VIS_RAY_TRACE_H_INCLUDED
7 #define HECMW_VIS_RAY_TRACE_H_INCLUDED
8 
9 /*
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <math.h>
13 #include <string.h>
14 #include    <memory.h>
15 #include <ctype.h>
16 #include "hecmw_vis_resampling.h"
17 #include "hecmw_vis_bmp.h"
18 #include "hecmw_vis_comm_util.h"
19 */
20 #define MASTER_PE 0
21 /*
22 #define CONVERSE_ORDER
23 
24 #include    <sys/types.h>
25 #include    <sys/timeb.h>
26 #include    <time.h>
27 #include    "glos.h"
28 #include    <GL/gl.h>
29 #include    <GL/glu.h>
30 #include    <GL/glaux.h>
31  */
32 
33 #define EPSILON 0.00000001
34 #define PI 3.1415926
35 /*#define TABLE_SIZE 	100
36 #define	VERTEX_PACK	50
37 #define POLYGON_PACK	100
38 #define VERTEX_KIND	27
39 
40 #define HEX_N_NODE	8
41 #define HEX_N_FACE	6
42 #define HEX_NODE_INDEX	255
43 #define HEX_FACE_INDEX	63
44  */
45 #define SQR(x) (x) * (x)
46 #define HASH_TABLE_SIZE 10000
47 /*#define  ResSize 1
48 #define  PixelSize 1
49  */
50 #define DIGN_PE 2
51 
52 #define BAR_WIDTH 10
53 #define NUM_CONTROL_PVR 51
54 #define MAX_N_NODE 20
55 
56 typedef struct _vr_parameter_struct {
57   int max_level;
58   int xr;
59   int yr;
60   int projection_style;
61   int num_of_lights;
62   double *light_point;
63 
64   double view_point_d[3];
65   double screen_point[3];
66 
67   double up[3];
68 
69   double k_ads[3];
70   int surface_on;
71   double surface_opacity;
72 
73   int color_mapping_style;
74 
75   int interval_mapping_num;
76 
77   double *interval_point; /* 2:mincolor, maxcolor 3: interval_mapping_num*2
78                              (value, mark_value) */
79 
80   int transfer_function_style;
81   /*  1: constant    input: value
82 2: first-order derivatives  input: none
83   3: feature points  input:  num_of_featurepoints, point[num]
84   4: feature intervals  input: num_of_intervals  point[num*2]
85   5: distance inverse
86   6: distance proportional
87   7: look-up table      input: name of the look-up table file
88    */
89   double opa_value;
90   int num_of_features;
91   double *fea_point;
92   char name_lookup[128];
93 
94   int rotate_style;
95   int color_mapping_bar_on;
96   int scale_marking_on;
97   int num_of_frames;
98   char name_voxelfile[128];
99   double background_color[3];
100   double font_color[3];
101   int color_system_type;
102   double font_size;
103   int color_bar_style;
104   int fixed_range_on;
105   double range_value[2];
106   int num_of_scale;
107   int mark_0_on;
108   int histogram_on;
109 
110   int remove_0_display_on;
111   int specified_level[3];
112   char color_comp_name[100];
113   int color_comp;
114   char color_subcomp_name[5];
115   int color_subcomp;
116   int nv_xyz[3];
117   double display_range[6];
118   int time_mark_on;
119   int fixed_scale_mark;
120 } Parameter_vr;
121 
122 typedef struct _pvr_link_struct {
123   int num_of_pvr;
124 
125   Parameter_vr *vr;
126   struct _pvr_link_struct *next_pvr;
127   int stat_para[NUM_CONTROL_PVR];
128   int visual_start_step;
129   int visual_end_step;
130   int visual_interval_step;
131 } PVR_link;
132 
133 typedef struct surface_info_struct {
134   int num;
135   double *surf_data;
136 } Surface_info;
137 
138 typedef struct _data_structured_vr_struct {
139   double dxyz[3];
140   int leveltot;
141   int varnumtot;
142   char **varname;
143   int nxyz[3];
144   double xyz0[3];
145   int voxtotadd;
146   int voxtotall;
147   /*	int *rlevel;
148   int *parent;
149    */
150   int r_nxyz[3];
151   double r_dxyz[3];
152   int *empty_flag;
153   double *var;
154   double *grad_var;
155   Surface_info *surface;
156 } VR_data;
157 
158 typedef struct _tree_pointer_struct {
159   int cell_id[8];
160   int surf_id;
161   int level;
162   double bound_box[6];
163   int local_child_no;
164   int local_face_in;
165   int local_face_out;
166   struct _tree_pointer_struct *child;
167   struct _tree_pointer_struct *parent;
168 } Tree_pointer;
169 
170 typedef Tree_pointer *Tree_pointer_ptr;
171 /*
172 typedef struct _ray_volume_struct {
173         Elem_no elem_id;
174         int     face_id;
175     double  p[3];
176         struct _ray_volume_struct *next_elem;
177         } Ray_volume;
178 
179 typedef struct _head_ray_volume_struct {
180         int elem_num;
181         Ray_volume *next_elem;
182 } Head_ray_volume;
183  */
184 
185 int find_first_inter(double point_o[3], double view_point_d[3], int r_level[3],
186                      double orig_xyz[3], double dxyz[3], double r_dxyz[3],
187                      double ray_direction[3], double first_p[3], int ijk[3]);
188 void ray_trace(int remove_0_display_on, int color_mapping_style,
189                double *interval_point, int transfer_function_style,
190                double opa_value, int num_of_features, double *fea_point,
191                double view_point_d[3], int interval_mapping_num,
192                int color_system_type, int num_of_lights, double *light_point,
193                double k_ads[3], double orig_xyz[3], double dxyz[3],
194                double r_dxyz[3], int r_level[3], int *empty_flag, double *var,
195                double *grad_var, double first_p[3], int first_ijk[3],
196                double ray_direction[3], double mincolor, double maxcolor,
197                double accum_rgba[4], double grad_minmax[2],
198                double feap_minmax[2], double feai_minmax[2],
199                double dis_minmax[2], double *opa_table, double tav_length,
200                int time_step, int test_i, int test_j);
201 
202 #endif /* HECMW_VIS_RAY_TRACE_H_INCLUDED */
203