FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
hecmw_vis_pvr_main.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 <stdio.h>
9#include <stdlib.h>
10#include <math.h>
11#include "hecmw_vis_mem_util.h"
12#include "hecmw_vis_comm_util.h"
13#include "hecmw_vis_bmp.h"
15#include "hecmw_vis_ucd_trans.h"
23#include "hecmw_malloc.h"
24
27double *extent;
28
30 struct hecmwST_result_data *data, int *timestep,
31 int *init_flag, int num_of_pvr, Parameter_vr *vr,
32 int stat_para[NUM_CONTROL_PVR], char *outfile,
33 HECMW_Comm VIS_COMM) {
34 int mynode, pesize;
35 char fname[HECMW_FILENAME_LEN];
36
37 FILE *FP;
38
39 In_surface *surface;
40 int time_step;
41 double t1, t2, t3;
42 int n_voxel;
43 /*
44int max_level, xr, yr, projection_style, num_of_lights, color_mapping_style,
45interval_mapping_num,
46 num_of_features, rotate_style, transfer_function_style,
47color_mapping_bar_on, scale_marking_on, num_of_frames,
48 color_system_type,color_bar_style, fixed_range_on, num_of_scale, mark_0_on,
49specified_level[3],
50 nv_xyz[3], remove_0_display_on, histogram_on;
51char name_lookup[128], name_voxelfile[128],color_comp_name[128],
52color_subcomp_name[5];
53
54double *light_point, view_point_d[3], screen_point[3], up[3], k_ads[3],
55*interval_point, opa_value, *fea_point,
56 background_color[3], font_color[3], font_size, range_value[2],
57display_range[6];
58 */
59 double view_n[3], nview_n;
60 double vertex[3 * 8];
61 double point_s[3], point_o[3], ray_direction[3];
62 int i, j, k, m;
63 double range[6], xd, yd;
64 double coff_matrix[3][3], n_vertex[3 * 8], inv_matrix[3][3];
65 double mincolor, maxcolor, view_point[3], scr_area[4], x, y, nn;
66 double tmincolor, tmaxcolor, trange[6], svertex[3 * 8], sn_vertex[3 * 8],
67 sscr_area[4];
68 int intersection;
69 double accum_rgba[4];
70 double grad_minmax[2], dis_minmax[2], feap_minmax[2], feai_minmax[2];
71 double tfeap_minmax[2];
72 double *opa_table;
73 extern void HECMW_vis_memory_exit(char *var);
74 extern void HECMW_vis_print_exit(char *var);
75 double *accum_opa;
76 double *image;
77 double center[3], dis_c_v, *ndis_c_v, tmpd;
78 int *pe_id, tmpi, pix_num, pix0_num, pixn;
79 double *n_subimage, *n_subopa, *subimage, *subopa;
80 double *subimage1, *subopa1;
81 double first_p[3];
82 HECMW_Status stat;
83 int starti, startj, endi, endj;
84 int start_x, start_y;
85 double minx, miny, minz, maxx, maxy, maxz, tminx, tminy, tminz, tmaxx, tmaxy,
86 tmaxz;
87 double av_length, tav_length;
88 int first_ijk[3];
89 int num_img, ii, base_x, base_y;
90 double o_v_point[3], m_scr[4];
91 int trace_flag;
92 BITMAPFILEHEADER header; /* File header */
93
94 unsigned char r, g, b;
95 int ri, gi, bi;
97 int scale, scale_type;
98
99 char timestep_str[128], rotate_str[128];
100
101 /* --------new variables for vectorization --------*/
102
103 double *node1;
104 /*
105double *voxel_dxyz;
106double *voxel_orig_xyz;
107int *level;
108int *voxel_n_neighbor_pe;
109int **voxel_neighbor_pe;
110 */
111 int x_specified_l, y_specified_l, z_specified_l;
112
113 int nx, ny, nz, *empty_flag;
114 double *var, *grad_var;
115 int r_level[3];
116 double r_dxyz[3], dxyz[3], orig_xyz[3];
117 double org_mincolor, org_maxcolor;
118
119 HECMW_Comm_size(VIS_COMM, &pesize);
120 HECMW_Comm_rank(VIS_COMM, &mynode);
121 n_voxel = pesize;
122 /* if(*init_flag==1) {
123contfile1[0] = '\0';
124 j=0;
125while (contfile[j] == ' ')
126 j++;
127k = 0;
128while (contfile[j] != ' ') {
129 contfile1[k] = contfile[j];
130 k++;
131 j++;
132}
133contfile1[k] = '\0';
134if((contfp=fopen(contfile1,"r"))== NULL) {
135 fprintf(stderr, "There is not such a control file:%s\n", contfile1);
136 exit (0);
137 }
138vr=(Parameter_vr *)HECMW_malloc(sizeof(Parameter_vr));
139 if(vr==NULL)
140 HECMW_vis_memory_exit("vr");
141
142
143if(strncmp(contfile1, "NULL", 4)==0)
144 set_default_vr(vr, stat_para, pesize);
145else {
146if((contfp=fopen(contfile1,"r"))== NULL)
147 HECMW_vis_print_exit("There is not such a control file:\n");
148read_control_file(contfp, vr, stat_para, pesize);
149fprintf(stderr, "max_level=%d xr=%d yr=%d num_of_light=%d\n", vr->max_level,
150vr->xr, vr->yr, vr->num_of_lights);
151fclose(contfp);
152}
153 */
154
155 if ((*init_flag == 1) || (num_of_pvr > 1)) {
156 voxel_dxyz = (double *)HECMW_calloc(pesize * 3, sizeof(double));
157 voxel_orig_xyz = (double *)HECMW_calloc(pesize * 3, sizeof(double));
158 level = (int *)HECMW_calloc(pesize * 3, sizeof(int));
159 voxel_n_neighbor_pe = (int *)HECMW_calloc(pesize, sizeof(int));
160 voxel_neighbor_pe = (int **)HECMW_calloc(pesize, sizeof(int *));
161 if ((voxel_dxyz == NULL) || (voxel_orig_xyz == NULL) || (level == NULL) ||
163 HECMW_vis_memory_exit("voxel information");
164
165 for (j = 0; j < pesize; j++) {
166 voxel_neighbor_pe[j] = (int *)HECMW_calloc(pesize, sizeof(int));
167 if (voxel_neighbor_pe[j] == NULL)
168 HECMW_vis_memory_exit("voxel_neighbor_pe[j]");
169 for (k = 0; k < pesize; k++) voxel_neighbor_pe[j][k] = 0;
170 }
171 n_voxel = pesize;
172
173 if (stat_para[22] == 1) {
174 /* fprintf(stderr, "voxel file is %s\n", vr->name_voxelfile);
175 */
178 }
179 } /* end of *init_flag=1 */
180
181 node1 = (double *)HECMW_calloc(mesh->n_node, sizeof(double));
182
183 transform_ucd_pvr(data, node1, mesh, vr, mynode, pesize, VIS_COMM, voxel_dxyz,
185 voxel_neighbor_pe, stat_para[22], stat_para[46], *init_flag,
186 num_of_pvr);
187 surface = NULL;
188 /* if(pvr->surface_on==1) {
189surface=(In_surface *)HECMW_malloc(sizeof(In_surface));
190if(surface==NULL) {
191 fprintf(stderr, "There is no enough memory for surface\n");
192 exit(0);
193}
194}
195 */
196 if (*init_flag == 1) {
197 extent = (double *)HECMW_calloc(mesh->n_elem * 6, sizeof(double));
198 if (extent == NULL) HECMW_vis_memory_exit("extent");
200
202 VIS_COMM);
203 if (mynode == 0)
204 for (i = 0; i < n_voxel; i++)
205 fprintf(stderr, "voxel %d level: %d %d %d \n", i, level[i * 3],
206 level[i * 3 + 1], level[i * 3 + 2]);
207 if (vr->specified_level[0] > 0) {
208 x_specified_l = vr->specified_level[0];
209 for (i = 0; i < n_voxel; i++) level[i * 3] = x_specified_l;
210 } else if (vr->max_level > 0) {
211 for (i = 0; i < n_voxel; i++) {
212 if (level[i * 3] > vr->max_level) level[i * 3] = vr->max_level;
213 }
214 }
215 if (vr->specified_level[1] > 0) {
216 y_specified_l = vr->specified_level[1];
217 for (i = 0; i < n_voxel; i++) level[i * 3 + 1] = y_specified_l;
218 } else if (vr->max_level > 0) {
219 for (i = 0; i < n_voxel; i++) {
220 if (level[i * 3 + 1] > vr->max_level) level[i * 3 + 1] = vr->max_level;
221 }
222 }
223 if (vr->specified_level[2] > 0) {
224 z_specified_l = vr->specified_level[2];
225 for (i = 0; i < n_voxel; i++) level[i * 3 + 2] = z_specified_l;
226 } else if (vr->max_level > 0) {
227 for (i = 0; i < n_voxel; i++) {
228 if (level[i * 3 + 2] > vr->max_level) level[i * 3 + 2] = vr->max_level;
229 }
230 }
231 }
232
233#ifdef slow
234 phi_x = (double *)HECMW_calloc(n_node, sizeof(double));
235 phi_y = (double *)HECMW_calloc(n_node, sizeof(double));
236 phi_z = (double *)HECMW_calloc(n_node, sizeof(double));
237 for (i = 0; i < n_node; i++) {
238 phi_x[i] = 0.0;
239 phi_y[i] = 0.0;
240 phi_z[i] = 0.0;
241 }
242
243#endif
244 HECMW_Barrier(VIS_COMM);
245 /* t2=HECMW_Wtime();
246if (mynode == 0){
247fprintf(stderr, "finish reading files\n");
248fprintf(stderr, "the time for reading file is %lf the total time up to now is
249%lf\n", t2-t1, t2-t1);
250}
251 */
252 t1 = HECMW_Wtime();
253 if (mynode == 0) {
254 fprintf(stderr, "Start parallel volume rendering module\n");
255 }
256 t2 = t1;
257
258 if (mynode == 0) fprintf(stderr, "calc_gradient\n");
259#ifdef slow
260 calc_gradient(n_node, n_internal, n_elem, node, elem, node1, n_neighbor_pe,
261 neighbor_pe, import_index, import_node, export_index,
262 export_node, phi_x, phi_y, phi_z, mynode, VIS_COMM);
263 t3 = HECMW_Wtime();
264 if (mynode == 0) {
265 fprintf(stderr,
266 "The time for computing gradient is %lf the total time up to now "
267 "is %lf\n",
268 t3 - t2, t3 - t1);
269 t2 = t3;
270 }
271 HECMW_Barrier(VIS_COMM);
272 fprintf(stderr, "refinement\n");
273#endif
274 nx = level[mynode * 3];
275 ny = level[mynode * 3 + 1];
276 nz = level[mynode * 3 + 2];
277 empty_flag = (int *)HECMW_calloc((nx + 1) * (ny + 1) * (nz + 1), sizeof(int));
278 var = (double *)HECMW_calloc((nx + 1) * (ny + 1) * (nz + 1), sizeof(double));
279#ifdef slow
280 grad_var = (double *)HECMW_calloc((nx + 1) * (ny + 1) * (nz + 1) * 3,
281 sizeof(double));
282 if ((grad_var == NULL) || (var == NULL) || (empty_flag == NULL)) {
283 fprintf(stderr, "There is no enough memory: empty_flag, var, gradient\n");
284 exit(0);
285 }
286
287#endif
288 refinement(mesh, node1, n_voxel, voxel_dxyz, voxel_orig_xyz, level,
289 voxel_n_neighbor_pe, voxel_neighbor_pe, extent, mynode, VIS_COMM,
290 empty_flag, var);
291#ifdef slow
292 HECMW_free(phi_x);
293 HECMW_free(phi_y);
294 HECMW_free(phi_z);
295#endif
296 HECMW_Barrier(VIS_COMM);
297
298 t3 = HECMW_Wtime();
299 if (mynode == 0) {
300 fprintf(stderr, " Finish refinement now, refinement level: \n");
301 fprintf(stderr,
302 " The time for refinement is %lf the total time up to now is %lf\n",
303 t3 - t2, t3 - t1);
304 t2 = t3;
305 }
306 HECMW_free(node1);
307 mincolor = tmincolor = 1.0E17;
308 maxcolor = tmaxcolor = -1.0E17;
309 find_color_minmax_vr(var, empty_flag, nx, ny, nz, &mincolor, &maxcolor);
310 HECMW_Barrier(VIS_COMM);
311 if (pesize > 1) {
312 HECMW_Allreduce(&mincolor, &tmincolor, 1, HECMW_DOUBLE, HECMW_MIN,
313 VIS_COMM);
314 HECMW_Allreduce(&maxcolor, &tmaxcolor, 1, HECMW_DOUBLE, HECMW_MAX,
315 VIS_COMM);
316 } else {
317 tmincolor = mincolor;
318 tmaxcolor = maxcolor;
319 }
320 org_mincolor = tmincolor;
321 org_maxcolor = tmaxcolor;
322 if (vr->fixed_range_on == 1) {
323 tmincolor = vr->range_value[0];
324 tmaxcolor = vr->range_value[1];
325 }
326
327 /* fprintf(stderr, "mincolor= %lf maxcolor= %lf\n", tmincolor, tmaxcolor);
328 */
329 if (vr->histogram_on == 1)
330 output_histogram_vr(tmincolor, tmaxcolor, var, empty_flag, nx, ny, nz,
331 mynode, pesize, VIS_COMM);
332 if (vr->histogram_on == 2)
333 generate_histogram_graph_vr(tmincolor, tmaxcolor, var, empty_flag, nx, ny,
334 nz, mynode, pesize, VIS_COMM,
336 if (vr->color_mapping_style == 4)
337 generate_interval_point_vr(tmincolor, tmaxcolor, var, empty_flag, nx, ny,
338 nz, mynode, pesize, VIS_COMM,
339 vr->interval_point);
340
342 for (i = 0; i < 6; i++) trange[i] = 0.0;
343 minx = range[0];
344 maxx = range[1];
345 miny = range[2];
346 maxy = range[3];
347 minz = range[4];
348 maxz = range[5];
349 HECMW_Barrier(VIS_COMM);
350 if (pesize > 1) {
351 HECMW_Allreduce(&minx, &tminx, 1, HECMW_DOUBLE, HECMW_MIN, VIS_COMM);
352
353 HECMW_Allreduce(&maxx, &tmaxx, 1, HECMW_DOUBLE, HECMW_MAX, VIS_COMM);
354 HECMW_Allreduce(&miny, &tminy, 1, HECMW_DOUBLE, HECMW_MIN, VIS_COMM);
355 HECMW_Allreduce(&maxy, &tmaxy, 1, HECMW_DOUBLE, HECMW_MAX, VIS_COMM);
356 HECMW_Allreduce(&minz, &tminz, 1, HECMW_DOUBLE, HECMW_MIN, VIS_COMM);
357 HECMW_Allreduce(&maxz, &tmaxz, 1, HECMW_DOUBLE, HECMW_MAX, VIS_COMM);
358 } else {
359 tminx = minx;
360 tmaxx = maxx;
361 tminy = miny;
362 tmaxy = maxy;
363 tminz = minz;
364 tmaxz = maxz;
365 }
366 if (mynode == 0)
367 fprintf(stderr, "the range of the field is %lf %lf %lf %lf %lf %lf\n",
368 tminx, tmaxx, tminy, tmaxy, tminz, tmaxz);
369 trange[0] = tminx;
370 trange[1] = tmaxx;
371 trange[2] = tminy;
372 trange[3] = tmaxy;
373 trange[4] = tminz;
374 trange[5] = tmaxz;
375 if ((*init_flag == 1) || (num_of_pvr > 1)) {
376 if (stat_para[4] == 0) {
377 vr->light_point = (double *)HECMW_calloc(3, sizeof(double));
378 if (vr->light_point == NULL) HECMW_vis_memory_exit("light_point");
379
380 vr->light_point[0] = (tminx + tmaxx) / 2.0;
381 vr->light_point[1] = tmaxy + 0.1 * (tmaxy - tminy);
382 vr->light_point[2] = tmaxz + (tmaxz - tminz) * 2.0;
383 }
384 if (stat_para[5] == 0) {
385 vr->view_point_d[0] = (tminx + tmaxx) / 2.0;
386 vr->view_point_d[1] = tmaxy + 1.5 * (tmaxy - tminy);
387 vr->view_point_d[2] = tmaxz + 1.5 * (tmaxz - tminz);
388 }
389 if (stat_para[6] == 0) {
390 vr->screen_point[0] = (tminx + tmaxx) / 2.0;
391 vr->screen_point[1] = (tminy + tmaxy) / 2.0;
392 vr->screen_point[2] = (tminz + tmaxz) / 2.0;
393 }
394 }
395 HECMW_Barrier(VIS_COMM);
396
397 /*----------------------------------------
398Define the sampling and projection parameters
399 */
400 /* First, define the equation of screen */
401 if (vr->rotate_style == 0)
402 num_img = 1;
403 else if ((vr->rotate_style >= 1) && (vr->rotate_style <= 4)) {
404 num_img = vr->num_of_frames;
405 for (i = 0; i < 3; i++)
406 vr->screen_point[i] = (trange[i * 2] + trange[i * 2 + 1]) / 2.0;
407 /*find the range of projection */
408 for (i = 0; i < 3; i++) o_v_point[i] = vr->view_point_d[i];
409 m_scr[0] = m_scr[2] = 1.0E+17;
410 m_scr[1] = m_scr[3] = -1.0E+17;
411
412 for (ii = 0; ii < num_img; ii++) {
413 if (ii != 0)
415 vr->view_point_d, vr->screen_point,
416 vr->num_of_lights, vr->light_point, vr->up,
417 trange);
418 for (i = 0; i < 3; i++)
419 view_n[i] = vr->screen_point[i] - vr->view_point_d[i];
420 nview_n = sqrt(SQR(view_n[0]) + SQR(view_n[1]) + SQR(view_n[2]));
421 if (fabs(nview_n) > EPSILON)
422 for (i = 0; i < 3; i++) view_n[i] /= nview_n;
423 transform_range_vertex(trange, vertex);
424
426 coff_matrix);
427 transform_frame(vr->screen_point, vertex, coff_matrix, n_vertex);
428 for (i = 0; i < 3; i++)
429 view_point[i] = vr->view_point_d[i] - vr->screen_point[i];
430 transform2_frame(coff_matrix, view_point);
431 find_projection_range(view_point, n_vertex, scr_area);
432 if (scr_area[0] < m_scr[0]) m_scr[0] = scr_area[0];
433 if (scr_area[1] > m_scr[1]) m_scr[1] = scr_area[1];
434 if (scr_area[2] < m_scr[2]) m_scr[2] = scr_area[2];
435 if (scr_area[3] > m_scr[3]) m_scr[3] = scr_area[3];
436 }
437
438 for (i = 0; i < 3; i++) vr->view_point_d[i] = o_v_point[i];
439 }
440
441 for (ii = 0; ii < num_img; ii++) {
442 if (ii != 0)
444 vr->view_point_d, vr->screen_point, vr->up,
445 vr->num_of_lights, vr->light_point, trange);
446 for (i = 0; i < 3; i++)
447 view_n[i] = vr->screen_point[i] - vr->view_point_d[i];
448 nview_n = sqrt(SQR(view_n[0]) + SQR(view_n[1]) + SQR(view_n[2]));
449 if (fabs(nview_n) > EPSILON)
450 for (i = 0; i < 3; i++) view_n[i] /= nview_n;
451 /* for(i=0;i<3;i++)
452p_screen[i]=view_n[i];
453p_screen[3]=-view_n[0]*vr->screen_point[0]-view_n[1]*vr->screen_point[1]-
454view_n[2]*vr->screen_point[2];
455 */
456
457 /* Second, find the projection of the dataset in each PE */
458 transform_range_vertex(trange, vertex);
459 if (mynode == 0)
460 fprintf(stderr,
461 "viewpoint=%lf %lf %lf screen_point=%lf %lf %lfup=%lf %lf %lf\n",
462 vr->view_point_d[0], vr->view_point_d[1], vr->view_point_d[2],
463 vr->screen_point[0], vr->screen_point[1], vr->screen_point[2],
464 vr->up[0], vr->up[1], vr->up[2]);
466 coff_matrix);
467 transform_frame(vr->screen_point, vertex, coff_matrix, n_vertex);
468 /* if(mynode==0){
469for(i=0;i<3;i++)
470for(j=0;j<3;j++)
471}
472 */
473 for (i = 0; i < 3; i++)
474 view_point[i] = vr->view_point_d[i] - vr->screen_point[i];
475 transform2_frame(coff_matrix, view_point);
476 find_projection_range(view_point, n_vertex, scr_area);
477 /* for multi-PEs, should find minx, maxx, miny, maxy in scr_area for all PE
478 */
479 if (ii == 0) {
480 if ((vr->color_mapping_bar_on == 0) && (vr->scale_marking_on == 0)) {
481 start_x = 10;
482 start_y = 10;
483 /* if((vr->xr<=20) || (vr->yr<=20)) {
484fprintf(stderr, "The resolution cannot be less than 20\n");
485exit(0);
486}
487 */
488 if (num_img == 1) {
489 xd = (scr_area[1] - scr_area[0]) / (vr->xr - 20);
490 yd = (scr_area[3] - scr_area[2]) / (vr->yr - 20);
491 }
492 if (num_img > 1) {
493 xd = (m_scr[1] - m_scr[0]) / (vr->xr - 20);
494 yd = (m_scr[3] - m_scr[2]) / (vr->yr - 20);
495 }
496 if (xd >= yd) {
497 yd = xd;
498 if (num_img == 1)
499 vr->yr =
500 (int)((int)(20 + (scr_area[3] - scr_area[2]) / yd) / 10) * 10 +
501 10;
502 else if (num_img > 1)
503 vr->yr =
504 (int)((int)(20 + (m_scr[3] - m_scr[2]) / yd) / 10) * 10 + 10;
505 }
506 if (xd < yd) {
507 xd = yd;
508 if (num_img == 1)
509 vr->xr =
510 (int)((int)(20 + (scr_area[1] - scr_area[0]) / xd) / 8) * 8 + 8;
511 else if (num_img > 1)
512 vr->xr = (int)((int)(20 + (m_scr[1] - m_scr[0]) / xd) / 8) * 8 + 8;
513 }
514 } else if ((vr->color_mapping_bar_on == 1) &&
515 (vr->scale_marking_on == 0)) {
516 start_x = 30;
517 start_y = 10;
518 if (num_img == 1) {
519 xd = (scr_area[1] - scr_area[0]) / (vr->xr - 40);
520 yd = (scr_area[3] - scr_area[2]) / (vr->yr - 20);
521 } else if (num_img > 1) {
522 xd = (m_scr[1] - m_scr[0]) / (vr->xr - 40);
523 yd = (m_scr[3] - m_scr[2]) / (vr->yr - 20);
524 }
525
526 if (xd >= yd) {
527 yd = xd;
528 if (num_img == 1)
529 vr->yr =
530 (int)((int)(20 + (scr_area[3] - scr_area[2]) / yd) / 10) * 10 +
531 10;
532 else if (num_img > 1)
533 vr->yr =
534 (int)((int)(20 + (m_scr[3] - m_scr[2]) / yd) / 10) * 10 + 10;
535 } else if (xd < yd) {
536 xd = yd;
537 if (num_img == 1)
538 vr->xr =
539 (int)((int)(40 + (scr_area[1] - scr_area[0]) / xd) / 8) * 8 + 8;
540 else if (num_img > 1)
541 vr->xr = (int)((int)(40 + (m_scr[1] - m_scr[0]) / xd) / 8) * 8 + 8;
542 }
543 } else if ((vr->color_mapping_bar_on == 1) &&
544 (vr->scale_marking_on == 1)) {
545 scale = (int)vr->font_size;
546 if ((vr->font_size - scale) < 0.5 - EPSILON)
547 scale_type = 1;
548 else
549 scale_type = 2;
550 if (scale_type == 1) {
551 start_x = 10 + 45 * scale;
552 if (vr->color_bar_style == 2) start_x = 10 + 45 * scale + 15;
553 } else if (scale_type == 2) {
554 start_x = 10 + 63 * scale;
555 if (vr->color_bar_style == 2) start_x = 10 + 63 * scale + 15;
556 }
557
558 start_y = 10;
559 if (vr->xr < start_x + 10) {
560 fprintf(stderr,
561 "The image x_resolution cannot write such size charaters\n");
562 fprintf(stderr,
563 "Please reduce the font size or enlarge x_resolution and run "
564 "again\n");
565 exit(0);
566 }
567 if (num_img == 1) {
568 xd = (scr_area[1] - scr_area[0]) / (vr->xr - (start_x + 10));
569 yd = (scr_area[3] - scr_area[2]) / (vr->yr - 20);
570 } else if (num_img > 1) {
571 xd = (m_scr[1] - m_scr[0]) / (vr->xr - (start_x + 10));
572 yd = (m_scr[3] - m_scr[2]) / (vr->yr - 20);
573 }
574
575 if (xd >= yd) {
576 yd = xd;
577 if (num_img == 1)
578 vr->yr =
579 (int)((int)(20 + (scr_area[3] - scr_area[2]) / yd) / 10) * 10 +
580 10;
581 else if (num_img > 1)
582 vr->yr =
583 (int)((int)(20 + (m_scr[3] - m_scr[2]) / yd) / 10) * 10 + 10;
584 } else if (xd < yd) {
585 xd = yd;
586 if (num_img == 1)
587 vr->xr =
588 (int)((int)(start_x + 10 + (scr_area[1] - scr_area[0]) / xd) /
589 8) *
590 8 +
591 8;
592 else if (num_img > 1)
593 vr->xr =
594 (int)((int)(start_x + 10 + (m_scr[1] - m_scr[0]) / xd) / 8) *
595 8 +
596 8;
597 }
598 }
599 }
600 if (ii > 0) {
601 start_x -= base_x;
602 start_y -= base_y;
603 }
604 if (num_img > 1) {
605 base_x = (int)((scr_area[0] - m_scr[0]) / xd);
606 base_y = (int)((scr_area[2] - m_scr[2]) / yd);
607
608 start_x += base_x;
609 start_y += base_y;
610 }
611 /* find the subimage range for this PE */
612 transform_range_vertex(range, svertex);
613 /* output_frame(vr, view_point, n_vertex, scr_area, xd, yd);
614 */
615 transform_frame(vr->screen_point, svertex, coff_matrix, sn_vertex);
616 find_projection_range(view_point, sn_vertex, sscr_area);
617 /* starti=(int)((sscr_area[0]-scr_area[0]+EPSILON)/xd);
618endi=(int)((sscr_area[1]-scr_area[0]-EPSILON)/xd)+1;
619startj=(int)((sscr_area[2]-scr_area[2]+EPSILON)/yd);
620endj=(int)((sscr_area[3]-scr_area[2]-EPSILON)/yd)+1;
621if(starti<0) starti=0;
622if(startj<0) startj=0;
623if(endi>vr->xr) endi=vr->xr;
624if(endj>vr->yr) endj=vr->yr;
625 */
626 starti = (int)((sscr_area[0] - scr_area[0]) / xd) + start_x - 1;
627 endi = (int)((sscr_area[1] - scr_area[0]) / xd) + start_x + 1;
628 startj = (int)((sscr_area[2] - scr_area[2]) / yd) + start_y - 1;
629 endj = (int)((sscr_area[3] - scr_area[2]) / yd) + start_y + 1;
630
631 HECMW_Barrier(VIS_COMM);
632 grad_minmax[0] = 1.0E17;
633 grad_minmax[1] = -1.0E17;
634 if (vr->transfer_function_style == 2) {
635 /* find_grad_minmax(vr, grad_var, nx, ny, nz, grad_minmax);
636 HECMW_Barrier(VIS_COMM);
637 HECMW_Allreduce(&grad_minmax[0], &tgrad_minmax[0], 1, HECMW_DOUBLE, HECMW_MIN, VIS_COMM);
638 HECMW_Allreduce(&grad_minmax[1], &tgrad_minmax[1], 1, HECMW_DOUBLE, HECMW_MAX, VIS_COMM);
639 grad_minmax[0]=tgrad_minmax[0]; grad_minmax[1]=tgrad_minmax[1];
640 */ }
641 feap_minmax[0] = 1.0E17;
642 feap_minmax[1] = -1.0E17;
643 if (vr->transfer_function_style == 3) {
645 tmincolor, tmaxcolor, feap_minmax);
646 HECMW_Barrier(VIS_COMM);
647 HECMW_Allreduce(&feap_minmax[0], &tfeap_minmax[0], 1,
648 HECMW_DOUBLE, HECMW_MIN, VIS_COMM);
649 HECMW_Allreduce(&feap_minmax[1], &tfeap_minmax[1], 1,
650 HECMW_DOUBLE, HECMW_MAX, VIS_COMM);
651 feap_minmax[0] = tfeap_minmax[0];
652 feap_minmax[1] = tfeap_minmax[1];
653 }
654 feai_minmax[0] = 1.0E17;
655 feai_minmax[1] = -1.0E17;
656 if (vr->transfer_function_style == 4) {
657 /* find_feai_minmax(num_of_features, fea_point,
658 tmincolor, tmaxcolor, feai_minmax);
659 HECMW_Barrier(VIS_COMM);
660 HECMW_Allreduce(&feai_minmax[0], &tfeai_minmax[0], 1, HECMW_DOUBLE,
661 HECMW_MIN, VIS_COMM);
662 HECMW_Allreduce(&feai_minmax[1], &tfeai_minmax[1], 1, HECMW_DOUBLE,
663 HECMW_MAX, VIS_COMM);
664 feai_minmax[0]=tfeai_minmax[0]; feai_minmax[1]=tfeai_minmax[1];
665 */
666 }
667 dis_minmax[0] = 1.0E17;
668 dis_minmax[1] = -1.0E17;
669 if ((vr->transfer_function_style == 5) ||
670 (vr->transfer_function_style == 6))
671 find_dis_minmax(vr->view_point_d, vertex, dis_minmax);
672 /* HECMW_Allreduce(&dis_minmax[0], &dis_minmax[0],
673 1, HECMW_DOUBLE, HECMW_MIN, VIS_COMM);
674 if(time_step==0) {
675
676 if(transfer_function_style==7) {
677 opa_table=(double *)HECMW_calloc(256, sizeof(double));
678 if(opa_table==NULL) {
679 fprintf(stderr, " There is no enough memory:
680 opa_table\n");
681 exit(0);
682 }
683 if(mynode==0)
684 read_lookup_table(name_lookup, opa_table);
685 HECMW_Bcast(opa_table, 256, HECMW_DOUBLE, 0, VIS_COMM);
686 }
687
688 } */
689 /*if(time_step==0) {
690 num_refine=1;
691 for(i=0;i<vd->leveltot;i++)
692 num_refine*=2;
693 */
694 av_length = sqrt(SQR(voxel_dxyz[mynode * 3] / nx) +
695 SQR(voxel_dxyz[mynode * 3 + 1] / ny) +
696 SQR(voxel_dxyz[mynode * 3 + 2] / nz));
697
698 HECMW_Barrier(VIS_COMM);
699 if (pesize > 1)
700 HECMW_Allreduce(&av_length, &tav_length, 1,
701 HECMW_DOUBLE, HECMW_MAX, VIS_COMM);
702 else
703 tav_length = av_length;
704
705 /* Build hierachical tree*/
706 image = (double *)HECMW_calloc(vr->xr * vr->yr * 3,
707 sizeof(double));
708 if (image == NULL) HECMW_vis_memory_exit("image");
709 accum_opa = (double *)HECMW_calloc(vr->xr * vr->yr,
710 sizeof(double));
711 if (accum_opa == NULL)
712 HECMW_vis_memory_exit("accum_opa");
713 /*}
714 */
715 /*---------new change for vec ---------*/
716 for (j = 0; j < vr->yr * vr->xr * 3; j++)
717 image[j] = 0.0;
718 for (j = 0; j < vr->yr * vr->xr; j++)
719 accum_opa[j] = 0.0;
720
721 HECMW_Barrier(VIS_COMM);
722 t3 = HECMW_Wtime();
723 if (mynode == 0) {
724 fprintf(stderr,
725 "The time for preprocessing of pvr is %lf, "
726 "the total time up to now is %lf\n",
727 t3 - t2, t3 - t1);
728 t2 = t3;
729 }
730 find_inverse_matrix(coff_matrix, inv_matrix);
731 for (i = 0; i < 3; i++) {
732 r_level[i] = level[mynode * 3 + i];
733 dxyz[i] = voxel_dxyz[mynode * 3 + i];
734 r_dxyz[i] = dxyz[i] / r_level[i];
735 orig_xyz[i] = voxel_orig_xyz[mynode * 3 + i];
736 }
737 /* fprintf(stderr, "projection range is %d %d %d %d",
738 * starti, endi, startj, endj);
739 */
740 mincolor = tmincolor;
741 maxcolor = tmaxcolor;
742 if (vr->color_mapping_style == 2) {
743 mincolor = vr->interval_point[0];
744 maxcolor = vr->interval_point[1];
745 }
746 if (vr->color_mapping_style == 3) {
747 mincolor = vr->interval_point[0];
748 maxcolor =
750 }
751
752 for (j = startj; j < endj; j++)
753 for (i = starti; i < endi; i++) {
754 /* for(j=0;j<yr;j++)
755 for(i=0;i<vr;i++) {
756
757 */
758 /* for Multi-PEs, first must judge whether it is
759 within the PE projection range
760
761 */
762 x = xd * (i - start_x + 0.5) + scr_area[0];
763 y = yd * (j - start_y + 0.5) + scr_area[2];
764 /*transform to the original frame */
765 point_s[0] = x;
766 point_s[1] = y;
767 point_s[2] = 0.0;
769 inv_matrix, point_o);
770 /*find the first intersected voxel*/
771 for (m = 0; m < 3; m++)
772 ray_direction[m] =
773 point_o[m] - vr->view_point_d[m];
774 /* new---here----to remove the overlap pixel
775 * computation */
776 trace_flag = 1;
777 if (fabs(ray_direction[0]) < EPSILON) {
778 if (fabs(orig_xyz[0] + dxyz[0] -
779 vr->view_point_d[0]) < EPSILON) {
780 trace_flag = 0;
781 }
782 } else if (fabs(ray_direction[1]) < EPSILON) {
783 if (fabs(orig_xyz[1] + dxyz[1] -
784 vr->view_point_d[1]) < EPSILON) {
785 trace_flag = 0;
786 }
787 } else if (fabs(ray_direction[2]) < EPSILON) {
788 if (fabs(orig_xyz[2] + dxyz[2] -
789 vr->view_point_d[2]) < EPSILON) {
790 trace_flag = 0;
791 }
792 }
793 if (trace_flag == 1) {
794 nn = sqrt(SQR(ray_direction[0]) +
795 SQR(ray_direction[1]) +
796 SQR(ray_direction[2]));
797 if (fabs(nn) > EPSILON) {
798 for (m = 0; m < 3; m++) ray_direction[m] /= nn;
799 }
800 /*
801 intersection=find_first_inter(point_o, vr, vd, root_tree, &voxel_p,
802 ray_direction, first_p);
803 if(intersection==1) {
804 int connect[8][6];
805 ray_trace(vr, vd, root_tree, voxel_p, first_p, ray_direction,
806 tmincolor, tmaxcolor, connect,
807 local_face, accum_rgba, grad_minmax, feap_minmax, feai_minmax,
808 dis_minmax,
809 opa_table, tav_length,time_step);
810 */
811 intersection = find_first_inter(
812 point_o, vr->view_point_d, r_level, orig_xyz,
813 dxyz, r_dxyz, ray_direction, first_p,
814 first_ijk);
815 if (intersection == 1) {
816 ray_trace(
820 vr->num_of_features, vr->fea_point,
823 vr->light_point, vr->k_ads, orig_xyz, dxyz,
824 r_dxyz, r_level, empty_flag, var, grad_var,
825 first_p, first_ijk, ray_direction, mincolor,
826 maxcolor, accum_rgba, grad_minmax,
827 feap_minmax, feai_minmax, dis_minmax,
828 opa_table, tav_length, time_step, i, j);
829
830 for (m = 0; m < 3; m++)
831 image[(j * vr->xr + i) * 3 + m] =
832 accum_rgba[m];
833 accum_opa[j * vr->xr + i] = accum_rgba[3];
834 }
835 }
836 }
837
838 HECMW_Barrier(VIS_COMM);
839 if (mynode == 0) {
840 fprintf(stderr, "Finish the computing on each PE\n");
841 t3 = HECMW_Wtime();
842 fprintf(stderr,
843 "The volume rendering on each PE is %lf the "
844 "total time up to now is %lf\n",
845 t3 - t2, t3 - t1);
846 t2 = t3;
847 }
848
849 if (pesize > 1) {
850 pix_num = (int)(vr->xr * vr->yr / pesize);
851 pix0_num = vr->xr * vr->yr - pix_num * (pesize - 1);
852 if (mynode == 0) pixn = pix0_num;
853 if (mynode != 0) pixn = pix_num;
854 n_subimage = (double *)HECMW_calloc(pesize * pixn * 3,
855 sizeof(double));
856 n_subopa = (double *)HECMW_calloc(pesize * pixn,
857 sizeof(double));
858 if ((n_subimage == NULL) || (n_subopa == NULL))
859 HECMW_vis_memory_exit("n_subimage, n_subopa");
860
861 for (j = 0; j < pixn * 3; j++) {
862 if (mynode == 0)
863 n_subimage[j] = image[j];
864 else if (mynode != 0)
865 n_subimage[mynode * pixn * 3 + j] =
866 image[pix0_num * 3 +
867 (mynode - 1) * pix_num * 3 + j];
868 }
869 if (mynode == 0)
870 for (j = 0; j < pixn; j++)
871 n_subopa[j] = accum_opa[j];
872 else if (mynode != 0)
873 for (j = 0; j < pixn; j++)
874 n_subopa[mynode * pixn + j] =
875 accum_opa[pix0_num + (mynode - 1) * pix_num +
876 j];
877
878 subimage =
879 (double *)HECMW_calloc(pixn * 3, sizeof(double));
880 subopa = (double *)HECMW_calloc(pixn, sizeof(double));
881 if ((subimage == NULL) || (subopa == NULL))
882 HECMW_vis_memory_exit("subimage, subopa");
883 HECMW_Barrier(VIS_COMM);
884
885 for (i = 0; i < pesize; i++) {
886 if (mynode == i) {
887 /* fprintf(stderr, "in
888 * PE=%d \n", mynode);
889 */
890 for (k = 0; k < pesize; k++) {
891 if (k != i) {
892 if (k == 0) {
893 subimage1 = (double *)HECMW_calloc(
894 pix0_num * 3, sizeof(double));
895 subopa1 = (double *)HECMW_calloc(
896 pix0_num, sizeof(double));
897 } else if (k != 0) {
898 subimage1 = (double *)HECMW_calloc(
899 pix_num * 3, sizeof(double));
900 subopa1 = (double *)HECMW_calloc(
901 pix_num, sizeof(double));
902 }
903
904 if ((subimage1 == NULL) || (subopa1 == NULL))
905 HECMW_vis_memory_exit("subimage1, subopa1");
906 if (k == 0) {
907 for (j = 0; j < pix0_num * 3; j++)
908 subimage1[j] = image[j];
909 for (j = 0; j < pix0_num; j++)
910 subopa1[j] = accum_opa[j];
911 } else if (k != 0) {
912 for (j = 0; j < pix_num * 3; j++)
913 subimage1[j] =
914 image[pix0_num * 3 +
915 (k - 1) * pix_num * 3 + j];
916 for (j = 0; j < pix_num; j++)
917 subopa1[j] =
918 accum_opa[pix0_num +
919 (k - 1) * pix_num + j];
920 }
921 if (k == 0) {
922 HECMW_Send(subimage1, pix0_num * 3,
923 HECMW_DOUBLE, k, 0, VIS_COMM);
924 HECMW_Send(subopa1, pix0_num, HECMW_DOUBLE,
925 k, 0, VIS_COMM);
926 } else if (k != 0) {
927 HECMW_Send(subimage1, pix_num * 3,
928 HECMW_DOUBLE, k, 0, VIS_COMM);
929 HECMW_Send(subopa1, pix_num, HECMW_DOUBLE,
930 k, 0, VIS_COMM);
931 }
932
933 HECMW_free(subimage1);
934 HECMW_free(subopa1);
935 } /*if k!=i */
936 } /*loop k*/
937 }
938 if (mynode != i) {
939 HECMW_Recv(subimage, pixn * 3, HECMW_DOUBLE, i,
940 HECMW_ANY_TAG, VIS_COMM, &stat);
941 HECMW_Recv(subopa, pixn, HECMW_DOUBLE, i,
942 HECMW_ANY_TAG, VIS_COMM, &stat);
943 for (j = 0; j < pixn * 3; j++)
944 n_subimage[i * pixn * 3 + j] = subimage[j];
945 for (j = 0; j < pixn; j++)
946 n_subopa[i * pixn + j] = subopa[j];
947 }
948 HECMW_Barrier(VIS_COMM);
949 }
950
951 /* if(time_step==0) {
952 */
953 for (i = 0; i < 3; i++)
954 center[i] = orig_xyz[i] + dxyz[i] / 2.0;
955 dis_c_v = sqrt(SQR(center[0] - vr->view_point_d[0]) +
956 SQR(center[1] - vr->view_point_d[1]) +
957 SQR(center[2] - vr->view_point_d[2]));
958 if (mynode != 0) {
959 HECMW_Send(&dis_c_v, 1, HECMW_DOUBLE, MASTER_PE, 0,
960 VIS_COMM);
961 pe_id = (int *)HECMW_calloc(pesize, sizeof(int));
962 if (pe_id == NULL) HECMW_vis_memory_exit("pe_id");
963 HECMW_Recv(pe_id, pesize, HECMW_INT, MASTER_PE,
964 HECMW_ANY_TAG, VIS_COMM, &stat);
965 }
966 if (mynode == 0) {
967 ndis_c_v =
968 (double *)HECMW_calloc(pesize, sizeof(double));
969 if (ndis_c_v == NULL)
970 HECMW_vis_memory_exit("ndis_c_v");
971 ndis_c_v[0] = dis_c_v;
972 for (i = 1; i < pesize; i++) {
973 HECMW_Recv(&dis_c_v, 1, HECMW_DOUBLE, i,
974 HECMW_ANY_TAG, VIS_COMM, &stat);
975 ndis_c_v[i] = dis_c_v;
976 }
977 pe_id = (int *)HECMW_calloc(pesize, sizeof(int));
978 if (pe_id == NULL) HECMW_vis_memory_exit("pe_id");
979 for (i = 0; i < pesize; i++) pe_id[i] = i;
980 for (i = 0; i < pesize - 1; i++)
981 for (j = i + 1; j < pesize; j++) {
982 if (ndis_c_v[i] > ndis_c_v[j]) {
983 tmpd = ndis_c_v[i];
984 ndis_c_v[i] = ndis_c_v[j];
985 ndis_c_v[j] = tmpd;
986 tmpi = pe_id[i];
987 pe_id[i] = pe_id[j];
988 pe_id[j] = tmpi;
989 }
990 }
991 for (i = 1; i < pesize; i++)
992 HECMW_Send(pe_id, pesize, HECMW_INT, i, 0,
993 VIS_COMM);
994 }
995 /* }
996 */
997
998 composite_subimage_vr(pesize, pe_id, pixn, n_subimage,
999 n_subopa, subimage);
1000 HECMW_free(n_subimage);
1001 HECMW_free(n_subopa);
1002 HECMW_free(subopa);
1003 /*send subimage to master PE */
1004 if (mynode != 0)
1005 HECMW_Send(subimage, pixn * 3, HECMW_DOUBLE, 0, 0,
1006 VIS_COMM);
1007 if (mynode == 0) {
1008 for (j = 0; j < pix0_num * 3; j++)
1009 image[j] = subimage[j];
1010 for (i = 1; i < pesize; i++) {
1011 HECMW_Recv(subimage, pix_num * 3, HECMW_DOUBLE, i,
1012 HECMW_ANY_TAG, VIS_COMM, &stat);
1013 for (j = 0; j < pix_num * 3; j++)
1014 image[pix0_num * 3 + (i - 1) * pix_num * 3 +
1015 j] = subimage[j];
1016 }
1017 }
1018 HECMW_free(subimage);
1019 }
1020 if (mynode == 0) {
1021 fprintf(stderr, " Finish combining \n");
1022 t3 = HECMW_Wtime();
1023 fprintf(stderr,
1024 "The combining time is %lf the total time up "
1025 "to now is %lf\n",
1026 t3 - t2, t3 - t1);
1027 t2 = t3;
1028 if (vr->fixed_scale_mark == 1)
1030 vr->scale_marking_on, vr->font_size,
1031 vr->color_bar_style, vr->mark_0_on,
1032 vr->color_mapping_bar_on, vr->xr, vr->yr,
1036 tmincolor, tmaxcolor, tmincolor, tmaxcolor,
1037 image);
1038 else if (vr->fixed_scale_mark == 0)
1040 vr->scale_marking_on, vr->font_size,
1041 vr->color_bar_style, vr->mark_0_on,
1042 vr->color_mapping_bar_on, vr->xr, vr->yr,
1046 tmincolor, tmaxcolor, org_mincolor,
1047 org_maxcolor, image);
1048
1049 /* outfile1[0] = '\0';
1050 j=0;
1051 while (outfile[j] == ' ')
1052 j++;
1053 k = 0;
1054 while (outfile[j] != ' ') {
1055 outfile1[k] = outfile[j];
1056 k++;
1057 j++;
1058 }
1059
1060 outfile1[k] = '\0';
1061
1062 sprintf(fname, "%s.%d.%d.bmp", outfile1, *timestep, ii);
1063 */
1064 if (*timestep >= 1000)
1065 sprintf(timestep_str, "%d", *timestep);
1066 else if (*timestep >= 100)
1067 sprintf(timestep_str, "0%d", *timestep);
1068 else if (*timestep >= 10)
1069 sprintf(timestep_str, "00%d", *timestep);
1070 else
1071 sprintf(timestep_str, "000%d", *timestep);
1072 if (ii >= 10)
1073 sprintf(rotate_str, "%d", ii);
1074 else
1075 sprintf(rotate_str, "0%d", ii);
1076 sprintf(fname, "%s.%s.%s.bmp", outfile, timestep_str,
1077 rotate_str);
1078
1079 FP = fopen(fname, "wb");
1080
1081 if (!FP)
1083 "ERROR: HEC-MW-VIS-E0009: Cannot open output "
1084 "file");
1085
1086 header.bfSize = 54 + 3 * vr->xr * vr->yr;
1087#ifdef CONVERSE_ORDER
1089 54 + 3 * vr->xr * vr->yr);
1090#endif
1091 header.bfReserved1 = 0;
1092#ifdef CONVERSE_ORDER
1094#endif
1095
1096 header.bfReserved2 = 0;
1097#ifdef CONVERSE_ORDER
1099#endif
1100
1101 header.bfOffBits = 54;
1102#ifdef CONVERSE_ORDER
1104#endif
1105
1106 info.biBitCount = 24;
1107#ifdef CONVERSE_ORDER
1109#endif
1110
1111 info.biSize = 40;
1112#ifdef CONVERSE_ORDER
1114#endif
1115
1116 info.biWidth = vr->xr;
1117#ifdef CONVERSE_ORDER
1118 info.biWidth = change_int_order(vr->xr);
1119#endif
1120
1121 info.biHeight = vr->yr;
1122#ifdef CONVERSE_ORDER
1123 info.biHeight = change_int_order(vr->yr);
1124#endif
1125
1126 info.biSizeImage = 3 * vr->xr * vr->yr;
1127#ifdef CONVERSE_ORDER
1128 info.biSizeImage =
1129 change_unsigned_int_order(3 * vr->xr * vr->yr);
1130#endif
1131
1132 info.biClrImportant = 0;
1133#ifdef CONVERSE_ORDER
1135#endif
1136
1137 info.biClrUsed = 0;
1138#ifdef CONVERSE_ORDER
1140#endif
1141
1142 info.biCompression = 0;
1143#ifdef CONVERSE_ORDER
1145#endif
1146
1147 info.biPlanes = 1;
1148#ifdef CONVERSE_ORDER
1150#endif
1151
1152 info.biXPelsPerMeter = 3780;
1153#ifdef CONVERSE_ORDER
1154 info.biXPelsPerMeter = change_int_order(3780);
1155#endif
1156
1157 info.biYPelsPerMeter = 3780;
1158#ifdef CONVERSE_ORDER
1159 info.biYPelsPerMeter = change_int_order(3780);
1160#endif
1161
1162 putc('B', FP);
1163 putc('M', FP);
1164 fwrite(&(header.bfSize), sizeof(unsigned int), 1, FP);
1165 fwrite(&header.bfReserved1,
1166 sizeof(unsigned short int), 1, FP);
1167 fwrite(&header.bfReserved2,
1168 sizeof(unsigned short int), 1, FP);
1169 fwrite(&header.bfOffBits, sizeof(unsigned int), 1,
1170 FP);
1171 fwrite(&info, 40, 1, FP);
1172 for (j = 0; j < vr->yr; j++)
1173 for (i = vr->xr - 1; i >= 0; i--) {
1174 if ((image[(j * vr->xr + i) * 3] < 0.1) &&
1175 (image[(j * vr->xr + i) * 3 + 1] < 0.1) &&
1176 (image[(j * vr->xr + i) * 3 + 2] < 0.1)) {
1177 ri = (int)(vr->background_color[0] * 256);
1178 gi = (int)(vr->background_color[1] * 256);
1179 bi = (int)(vr->background_color[2] * 256);
1180 } else {
1181 ri = (int)(image[(j * vr->xr + i) * 3] * 256);
1182 gi = (int)(image[(j * vr->xr + i) * 3 + 1] *
1183 256);
1184 bi = (int)(image[(j * vr->xr + i) * 3 + 2] *
1185 256);
1186 }
1187 if (ri < 0) ri = 0;
1188 if (ri > 255) ri = 255;
1189 if (gi < 0) gi = 0;
1190 if (gi > 255) gi = 255;
1191 if (bi < 0) bi = 0;
1192 if (bi > 255) bi = 255;
1193 r = ri;
1194 g = gi;
1195 b = bi;
1196 putc(b, FP);
1197 putc(g, FP);
1198 putc(r, FP);
1199 }
1200
1201 fclose(FP);
1202 }
1203 }
1204 HECMW_free(var);
1205#ifdef slow
1206 HECMW_free(grad_var);
1207#endif
1208 HECMW_free(empty_flag);
1210 HECMW_free(accum_opa);
1211 if (num_of_pvr > 1) {
1218 }
1219 if (mynode == 0) {
1220 fprintf(stderr, " Finish the module\n");
1221 t3 = HECMW_Wtime();
1222 fprintf(stderr,
1223 " the time for output is %lf the total time of the module is %lf\n",
1224 t3 - t2, t3 - t1);
1225 }
1226 return;
1227}
if(!(yy_init))
Definition: hecmw_ablex.c:1305
int HECMW_Comm_rank(HECMW_Comm comm, int *rank)
Definition: hecmw_comm.c:18
int HECMW_Comm_size(HECMW_Comm comm, int *size)
Definition: hecmw_comm.c:37
int HECMW_Allreduce(void *sendbuf, void *recvbuf, int count, HECMW_Datatype datatype, HECMW_Op op, HECMW_Comm comm)
Definition: hecmw_comm.c:364
int HECMW_Send(void *buffer, int count, HECMW_Datatype datatype, int dest, int tag, HECMW_Comm comm)
Definition: hecmw_comm.c:193
int HECMW_Barrier(HECMW_Comm comm)
Definition: hecmw_comm.c:95
int HECMW_Recv(void *buffer, int count, HECMW_Datatype datatype, int source, int tag, HECMW_Comm comm, HECMW_Status *status)
Definition: hecmw_comm.c:235
#define HECMW_INT
Definition: hecmw_config.h:48
#define HECMW_FILENAME_LEN
Definition: hecmw_config.h:72
#define HECMW_MAX
Definition: hecmw_config.h:56
MPI_Status HECMW_Status
Definition: hecmw_config.h:36
#define HECMW_DOUBLE
Definition: hecmw_config.h:50
MPI_Comm HECMW_Comm
Definition: hecmw_config.h:30
#define HECMW_MIN
Definition: hecmw_config.h:54
int HECMW_ANY_TAG
struct hecmwST_local_mesh * mesh
Definition: hecmw_repart.h:71
#define NULL
#define HECMW_calloc(nmemb, size)
Definition: hecmw_malloc.h:21
#define HECMW_free(ptr)
Definition: hecmw_malloc.h:24
#define MASTER_PE
Definition: hecmw_repart.h:17
double HECMW_Wtime(void)
Definition: hecmw_time.c:8
#define EPSILON
void find_projection_range(double view_point[3], double n_vertex[24], double scr_area[4])
void view1_parameter_define(int ii, int num_of_frames, int rotate_style, double view_point_d[3], double screen_point[3], int num_of_lights, double *light_point, double up[3], double trange[6])
void tranverse_transform(double screen_point[3], double point_s[3], double inv_matrix[3][3], double point_o[3])
void find_inverse_matrix(double coff_matrix[3][3], double inv_matrix[3][3])
void get_frame_transform_matrix(double view_point_d[3], double screen_point[3], double up[3], double coff_matrix[3][3])
void view_parameter_define(int ii, int num_of_frames, int rotate_style, double view_point_d[3], double screen_point[3], double up[3], int num_of_lights, double *light_point, double trange[6])
void transform2_frame(double coff_matrix[3][3], double view_point[3])
void transform_range_vertex(double range[6], double vertex[24])
void transform_frame(double screen_point[3], double vertex[24], double coff_matrix[3][3], double n_vertex[24])
int change_int_order(int n)
unsigned short int change_short_int_order(unsigned short int n)
void generate_color_bar(int scale_marking_on, double font_size, int color_bar_style, int mark_0_on, int color_mapping_bar_on, int xr, int yr, double font_color[3], int color_system_type, int color_mapping_style, double *interval_point, int interval_mapping_num, int num_of_scale, double tmincolor, double tmaxcolor, double org_mincolor, double org_maxcolor, double *image)
unsigned int change_unsigned_int_order(unsigned int n)
void generate_interval_point_vr(double tmincolor, double tmaxcolor, double *var, int *empty_flag, int nx, int ny, int nz, int mynode, int pesize, HECMW_Comm VIS_COMM, double *interval_point)
void find_color_minmax_vr(double *var, int *empty_flag, int nx, int ny, int nz, double *mincolor, double *maxcolor)
void find_dis_minmax(double view_point_d[3], double vertex[24], double dis_minmax[2])
void find_feap_minmax(int num_of_features, double *fea_point, double mincolor, double maxcolor, double feap_minmax[2])
void output_histogram_vr(double tmincolor, double tmaxcolor, double *var, int *empty_flag, int nx, int ny, int nz, int mynode, int pesize, HECMW_Comm VIS_COMM)
void generate_histogram_graph_vr(double tmincolor, double tmaxcolor, double *var, int *empty_flag, int nx, int ny, int nz, int mynode, int pesize, HECMW_Comm VIS_COMM, int color_system_type)
void find_minmax_vr(double *voxel_dxyz, double *voxel_orig_xyz, int mynode, double range[6])
void HECMW_vis_print_exit(char *var)
void HECMW_vis_memory_exit(char *var)
int calc_voxel_level(int n_voxel, struct hecmwST_local_mesh *mesh, double *voxel_dxyz, double *voxel_orig_xyz, double *extent, int *level, HECMW_Comm VIS_COMM)
int calc_extent(struct hecmwST_local_mesh *mesh, double *extent)
void refinement(struct hecmwST_local_mesh *mesh, double *node1, int n_voxel, double *voxel_dxyz, double *voxel_orig_xyz, int *level, int *voxel_n_neighbor_pe, int **voxel_neighbor_pe, double *extent, int my_rank, HECMW_Comm VIS_COMM, int *empty_flag, double *var)
#define SQR(x)
int ** voxel_neighbor_pe
int * voxel_n_neighbor_pe
void HECMW_vis_pvr_rendering(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, int *timestep, int *init_flag, int num_of_pvr, Parameter_vr *vr, int stat_para[NUM_CONTROL_PVR], char *outfile, HECMW_Comm VIS_COMM)
double * voxel_dxyz
double * extent
double * voxel_orig_xyz
int * level
int find_first_inter(double point_o[3], 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])
void ray_trace(int remove_0_display_on, int color_mapping_style, double *interval_point, int transfer_function_style, double opa_value, int num_of_features, double *fea_point, double view_point_d[3], int interval_mapping_num, int color_system_type, int num_of_lights, double *light_point, double k_ads[3], double orig_xyz[3], double dxyz[3], double r_dxyz[3], int r_level[3], int *empty_flag, double *var, double *grad_var, double first_p[3], int first_ijk[3], double ray_direction[3], double mincolor, double maxcolor, double accum_rgba[4], double grad_minmax[2], double feap_minmax[2], double feai_minmax[2], double dis_minmax[2], double *opa_table, double tav_length, int time_step, int test_i, int test_j)
#define NUM_CONTROL_PVR
int read_voxel_file(char *filename, int n_voxel, double *voxel_dxyz, double *voxel_orig_xyz, int *level, int *voxel_n_neighbor_pe, int **voxel_neighbor_pe)
double * image
void composite_subimage_vr(int pesize, int *pe_id, int pixn, double *n_subimage, double *n_subopa, double *subimage)
void transform_ucd_pvr(struct hecmwST_result_data *data, double *node1, struct hecmwST_local_mesh *mesh, Parameter_vr *vr, int my_rank, int pe_size, HECMW_Comm VIS_COMM, double *voxel_dxyz, double *voxel_orig_xyz, int *level, int *voxel_n_neighbor_pe, int **voxel_neighbor_pe, int voxel_on, int display_range_on, int init_flag, int num_of_pvr)
CNFData data
unsigned short bfReserved1
Definition: hecmw_vis_bmp.h:12
unsigned short bfReserved2
Definition: hecmw_vis_bmp.h:13
unsigned int bfSize
Definition: hecmw_vis_bmp.h:11
unsigned int bfOffBits
Definition: hecmw_vis_bmp.h:14
unsigned int biCompression
Definition: hecmw_vis_bmp.h:25
unsigned int biSizeImage
Definition: hecmw_vis_bmp.h:26
unsigned short biBitCount
Definition: hecmw_vis_bmp.h:24
unsigned short biPlanes
Definition: hecmw_vis_bmp.h:23
unsigned int biClrUsed
Definition: hecmw_vis_bmp.h:29
unsigned int biSize
Definition: hecmw_vis_bmp.h:20
unsigned int biClrImportant
Definition: hecmw_vis_bmp.h:30