17 static int find_out_point(
double orig_xyz[3],
double r_dxyz[3],
int ijk[3],
18 double in_point[3],
double ray_direction[3],
19 int face_sect[3],
double out_point[3]);
20 static void find_next_cell(
int ijkn[3],
int current_ijk[3],
int face_sect[3],
21 double vv[3],
int next_ijk[3]);
23 static int find_first_inter_point(
double view_p[3],
double ray_direction[3],
24 double orig_xyz[3],
double dxyz[3],
27 double minmax[6], t[6], mint;
29 for (i = 0; i < 3; i++) {
30 minmax[i * 2] = orig_xyz[i];
31 minmax[i * 2 + 1] = orig_xyz[i] + dxyz[i];
33 for (i = 0; i < 3; i++) {
34 if (fabs(ray_direction[i]) <
EPSILON) {
36 t[i * 2 + 1] = 1.0E+17;
38 t[i * 2] = (minmax[i * 2] - view_p[i]) / ray_direction[i];
39 t[i * 2 + 1] = (minmax[i * 2 + 1] - view_p[i]) / ray_direction[i];
45 for (i = 0; i < 6; i++) {
46 if ((mint > t[i]) && (t[i] >
EPSILON)) {
47 for (j = 0; j < 3; j++) first_p[j] = view_p[j] + t[i] * ray_direction[j];
48 if ((first_p[0] >= minmax[0] -
EPSILON) &&
49 (first_p[0] <= minmax[1] +
EPSILON) &&
50 (first_p[1] >= minmax[2] -
EPSILON) &&
51 (first_p[1] <= minmax[3] +
EPSILON) &&
52 (first_p[2] >= minmax[4] -
EPSILON) &&
53 (first_p[2] <= minmax[5] +
EPSILON)) {
59 if ((mincomp >= 0) && (mincomp <= 5)) {
60 for (i = 0; i < 3; i++) first_p[i] = view_p[i] + mint * ray_direction[i];
74 double dxyz[3],
double r_dxyz[3],
double ray_direction[3],
75 double first_p[3],
int ijk[3]) {
77 int ini_face, intersection, con1, next_ijk[3], face_sect[3];
80 ini_face = find_first_inter_point(view_point_d, ray_direction, orig_xyz, dxyz,
86 for (i = 0; i < 3; i++)
87 ijk[i] = (
int)((first_p[i] - orig_xyz[i] -
EPSILON) / r_dxyz[i]);
88 if ((ijk[0] < 0) || (ijk[0] > r_level[0] - 1) || (ijk[1] < 0) ||
89 (ijk[1] > r_level[1] - 1) || (ijk[2] < 0) || (ijk[2] > r_level[2] - 1))
91 "ERROR: HEC-MW-VIS-E2006:There is something wrong on finding the "
93 for (i = 0; i < 3; i++) out_point[i] = 0.0;
94 con1 = find_out_point(orig_xyz, r_dxyz, ijk, first_p, ray_direction,
95 face_sect, out_point);
98 find_next_cell(r_level, ijk, face_sect, ray_direction, next_ijk);
99 if ((next_ijk[0] < 0) || (next_ijk[0] > r_level[0] - 1) ||
100 (next_ijk[1] < 0) || (next_ijk[1] > r_level[1] - 1) ||
101 (next_ijk[2] < 0) || (next_ijk[2] > r_level[2] - 1))
104 for (i = 0; i < 3; i++) ijk[i] = next_ijk[i];
110 static int find_out_point(
double orig_xyz[3],
double r_dxyz[3],
int ijk[3],
111 double in_point[3],
double ray_direction[3],
112 int face_sect[3],
double out_point[3]) {
113 int i, j, mincomp, intersection;
114 double minmax[6], t[3], mint;
116 for (i = 0; i < 3; i++) face_sect[i] = -1;
117 for (i = 0; i < 6; i++) {
120 minmax[i] = orig_xyz[i1] + (ijk[i1] + j1) * r_dxyz[i1];
122 for (i = 0; i < 3; i++) {
123 if (ray_direction[i] > 0)
124 t[i] = (minmax[i * 2 + 1] - in_point[i]) / (ray_direction[i] +
EPSILON);
125 else if (ray_direction[i] < 0)
126 t[i] = (in_point[i] - minmax[i * 2]) / (-ray_direction[i] +
EPSILON);
131 for (i = 0; i < 3; i++) {
132 if ((mint > t[i]) && (t[i] >
EPSILON)) {
133 for (j = 0; j < 3; j++)
134 out_point[j] = in_point[j] + t[i] * ray_direction[j];
135 if ((out_point[0] >= minmax[0] -
EPSILON) &&
136 (out_point[0] <= minmax[1] +
EPSILON) &&
137 (out_point[1] >= minmax[2] -
EPSILON) &&
138 (out_point[1] <= minmax[3] +
EPSILON) &&
139 (out_point[2] >= minmax[4] -
EPSILON) &&
140 (out_point[2] <= minmax[5] +
EPSILON)) {
146 if ((mincomp >= 0) && (mincomp <= 2)) {
148 for (i = 0; i < 3; i++)
149 out_point[i] = in_point[i] + mint * ray_direction[i];
152 for (i = 0; i < 3; i++) out_point[i] = in_point[i];
154 for (i = 0; i < 3; i++) {
155 if (fabs(out_point[i] - minmax[i * 2]) <
EPSILON)
156 face_sect[i] = i * 2;
157 else if (fabs(out_point[i] - minmax[i * 2 + 1]) <
EPSILON)
158 face_sect[i] = i * 2 + 1;
161 return (intersection);
164 static void find_next_cell(
int ijkn[3],
int current_ijk[3],
int face_sect[3],
165 double vv[3],
int next_ijk[3])
171 for (j = 0; j < 3; j++) face1_sect[j] = face_sect[j];
172 for (j = 0; j < 3; j++) next_ijk[j] = current_ijk[j];
173 for (m = 0; m < 3; m++) {
174 if (face_sect[m] != -1) {
175 if (face_sect[m] == 0) {
177 next_ijk[0] = current_ijk[0] - 1;
179 if (next_ijk[0] < 0)
break;
181 }
else if (face_sect[m] == 1) {
183 next_ijk[0] = current_ijk[0] + 1;
185 if (next_ijk[0] > ijkn[0] - 1)
break;
187 }
else if (face_sect[m] == 2) {
189 next_ijk[1] = current_ijk[1] - 1;
191 if (next_ijk[1] < 0)
break;
193 }
else if (face_sect[m] == 3) {
195 next_ijk[1] = current_ijk[1] + 1;
197 if (next_ijk[1] > ijkn[1] - 1)
break;
199 }
else if (face_sect[m] == 4) {
201 next_ijk[2] = current_ijk[2] - 1;
203 if (next_ijk[2] < 0)
break;
205 }
else if (face_sect[m] == 5) {
207 next_ijk[2] = current_ijk[2] + 1;
209 if (next_ijk[2] > ijkn[2] - 1)
break;
215 for (m = 0; m < 3; m++) face_sect[m] = face1_sect[m];
220 static int find_next_point(
double orig_xyz[3],
double r_dxyz[3],
int r_level[3],
221 int current_ijk[3],
double in_point[3],
222 double out_point[3],
double ray_direction[3],
224 int flag, face_sect[3];
227 flag = find_out_point(orig_xyz, r_dxyz, current_ijk, in_point, ray_direction,
228 face_sect, out_point);
232 "ERROR: HEC-MW-VIS-E2007:There is some problem in finding intersection "
241 find_next_cell(r_level, current_ijk, face_sect, ray_direction, next_ijk);
242 if ((next_ijk[0] < 0) || (next_ijk[0] > r_level[0] - 1) ||
243 (next_ijk[1] < 0) || (next_ijk[1] > r_level[1] - 1) ||
244 (next_ijk[2] < 0) || (next_ijk[2] > r_level[2] - 1))
250 void ray_trace(
int color_mapping_style,
double *interval_point,
251 int transfer_function_style,
double opa_value,
252 int num_of_features,
double *fea_point,
int interval_mapping_num,
253 int color_system_type,
double k_ads[3],
double orig_xyz[3],
254 double r_dxyz[3],
int r_level[3],
int *empty_flag,
double *var,
255 double first_p[3],
int first_ijk[3],
double ray_direction[3],
256 double mincolor,
double maxcolor,
double accum_rgba[4],
271 double in_point[3], out_point[3];
272 int flag, single_empty_flag, value_flag, index, current_ijk[3], next_ijk[3];
274 for (i = 0; i < 4; i++) accum_rgba[i] = 0.0;
276 for (i = 0; i < 3; i++) in_point[i] = first_p[i];
277 for (i = 0; i < 3; i++) current_ijk[i] = first_ijk[i];
278 while ((accum_rgba[3] < 0.99) && (flag == 1)) {
284 flag = find_next_point(orig_xyz, r_dxyz, r_level, current_ijk, in_point,
285 out_point, ray_direction, next_ijk);
287 single_empty_flag = 1;
296 for (i = 0; i < 8; i++) {
298 index = (current_ijk[2] + (int)(i / 4)) * (r_level[0] + 1) *
300 (current_ijk[1] + (
int)(j / 2)) * (r_level[0] + 1) +
301 current_ijk[0] + j % 2;
302 if (empty_flag[index] == 0) single_empty_flag = 0;
331 if ((single_empty_flag == 1) && (flag != 0) && (value_flag == 1))
333 transfer_function_style, opa_value, num_of_features,
334 fea_point, interval_mapping_num, color_system_type,
335 k_ads, r_level, orig_xyz, r_dxyz, var, accum_rgba,
336 mincolor, maxcolor, in_point, out_point, tav_length);
338 for (i = 0; i < 3; i++) in_point[i] = out_point[i];
339 for (i = 0; i < 3; i++) current_ijk[i] = next_ijk[i];
void compute_color_vr(int current_ijk[3], int color_mapping_style, double *interval_point, int transfer_function_style, double opa_value, int num_of_features, double *fea_point, int interval_mapping_num, int color_system_type, double k_ads[3], int r_level[3], double orig_xyz[3], double r_dxyz[3], double *var, double accum_rgba[4], double mincolor, double maxcolor, double in_point[3], double out_point[3], double tav_length)
void HECMW_vis_print_exit(char *var)
void ray_trace(int color_mapping_style, double *interval_point, int transfer_function_style, double opa_value, int num_of_features, double *fea_point, int interval_mapping_num, int color_system_type, double k_ads[3], double orig_xyz[3], double r_dxyz[3], int r_level[3], int *empty_flag, double *var, double first_p[3], int first_ijk[3], double ray_direction[3], double mincolor, double maxcolor, double accum_rgba[4], double tav_length)
int find_first_inter(double view_point_d[3], int r_level[3], double orig_xyz[3], double dxyz[3], double r_dxyz[3], double ray_direction[3], double first_p[3], int ijk[3])