17 double *mincolor,
double *maxcolor) {
21 for (i = 0; i < (nx + 1) * (ny + 1) * (nz + 1); i++) {
22 if (empty_flag[i] == 1) {
24 if (value < *mincolor) *mincolor = value;
25 if (value > *maxcolor) *maxcolor = value;
31 double *var,
int *empty_flag,
int nx,
int ny,
32 int nz,
int mynode,
int pesize,
35 double delta, value, color[3];
36 int count[500], t_count[500], max_number, max_length, start_x, end_x, start_y;
41 unsigned char r, g, b;
45 int start_xs, start_ys;
49 delta = (tmaxcolor - tmincolor) / 500.0;
50 for (i = 0; i < 500; i++) {
54 for (i = 0; i < (nx + 1) * (ny + 1) * (nz + 1); i++) {
55 if (empty_flag[i] == 1) {
56 j = (int)((var[i] - tmincolor) / delta);
65 for (i = 0; i < 500; i++) t_count[i] = count[i];
68 fp = fopen(
"histogram.bmp",
"wb");
71 graph = (
double *)
HECMW_calloc(400 * 530 * 3,
sizeof(
double));
73 for (i = 0; i < 400 * 530 * 3; i++) graph[i] = 0.0;
75 for (i = 0; i < 500; i++) {
76 if (t_count[i] > max_number) max_number = t_count[i];
80 "ERROR: HEC-MW-VIS-E2003:Cannot generate histogram graph, the number "
82 max_length = (int)(400 - 30 - 5 - 45 * 1.5);
83 start_x = (int)(5 + 45 * 1.5 + 15);
85 for (j = 0; j < 500; j++) {
87 (int)((
double)t_count[j] * (double)max_length / (
double)max_number +
92 for (i = start_x; i < end_x; i++) {
93 graph[((j + 15) * 400 + i) * 3] = color[0];
94 graph[((j + 15) * 400 + i) * 3 + 1] = color[1];
95 graph[((j + 15) * 400 + i) * 3 + 2] = color[2];
100 for (k = 0; k < 11; k++) {
101 value = tmincolor + (tmaxcolor - tmincolor) / 10.0 * k;
102 start_ys = start_y + (int)((
double)500.0 / 10 * k) - (
int)7 / 2;
104 snprintf(buf,
sizeof(buf),
"%3.2E", value);
105 for (m = 0; m < 9; m++) {
107 for (j = 0; j < 7; j++)
108 for (i = 0; i < 7; i++) {
109 graph[((start_ys + j) * 400 + start_xs - i) * 3] =
110 (double)output7[6 - j][i];
111 graph[((start_ys + j) * 400 + start_xs - i) * 3 + 1] =
112 (double)output7[6 - j][i];
113 graph[((start_ys + j) * 400 + start_xs - i) * 3 + 2] =
114 (double)output7[6 - j][i];
117 if ((value >= 0) && (m == 0)) start_xs -= 7;
119 if ((k != 0) && (k != 10)) {
120 start_ys += (int)7 / 2;
122 for (i = start_x; i < start_x + 5; i++)
123 for (j = 0; j < 3; j++) graph[(start_ys * 400 + i) * 3 + j] = 1.0;
126 header.
bfSize = 54 + 3 * 400 * 530;
127 #ifdef CONVERSE_ORDER
131 #ifdef CONVERSE_ORDER
136 #ifdef CONVERSE_ORDER
141 #ifdef CONVERSE_ORDER
146 #ifdef CONVERSE_ORDER
151 #ifdef CONVERSE_ORDER
156 #ifdef CONVERSE_ORDER
161 #ifdef CONVERSE_ORDER
166 #ifdef CONVERSE_ORDER
171 #ifdef CONVERSE_ORDER
176 #ifdef CONVERSE_ORDER
181 #ifdef CONVERSE_ORDER
186 #ifdef CONVERSE_ORDER
191 #ifdef CONVERSE_ORDER
196 #ifdef CONVERSE_ORDER
202 fwrite(&(header.
bfSize),
sizeof(
unsigned int), 1, fp);
203 fwrite(&header.
bfReserved1,
sizeof(
unsigned short int), 1, fp);
204 fwrite(&header.
bfReserved2,
sizeof(
unsigned short int), 1, fp);
205 fwrite(&header.
bfOffBits,
sizeof(
unsigned int), 1, fp);
206 fwrite(&info, 40, 1, fp);
207 for (j = 0; j < 530; j++)
208 for (i = 400 - 1; i >= 0; i--) {
209 ri = (int)(graph[(j * 400 + i) * 3] * 256);
210 gi = (int)(graph[(j * 400 + i) * 3 + 1] * 256);
211 bi = (int)(graph[(j * 400 + i) * 3 + 2] * 256);
213 if (ri > 255) ri = 255;
215 if (gi > 255) gi = 255;
217 if (bi > 255) bi = 255;
233 int *empty_flag,
int nx,
int ny,
int nz,
235 double *interval_point) {
238 int count[500], t_count[500], tmp_count[500], sum_count, interv_count, sum,
240 delta = (tmaxcolor - tmincolor) / 500.0;
241 for (i = 0; i < 500; i++) {
245 for (i = 0; i < (nx + 1) * (ny + 1) * (nz + 1); i++) {
246 if (empty_flag[i] == 1) {
247 j = (int)((var[i] - tmincolor) / delta);
249 if (j > 499) j = 499;
256 for (i = 0; i < 500; i++) t_count[i] = count[i];
259 for (i = 0; i < 500; i++) {
260 sum_count += t_count[i];
261 tmp_count[i] = t_count[i];
263 interv_count = (int)sum_count / 10;
265 interval_point[0] = tmincolor;
266 interval_point[1] = 0.0;
267 for (i = 1; i < 10; i++) {
268 interval_point[i * 2 + 1] = (double)i / 10.0;
271 while ((j < 500) && (sum < interv_count)) {
276 interval_point[i * 2] =
279 (1.0 - (
double)(sum - interv_count) / (
double)tmp_count[j])) *
280 (tmaxcolor - tmincolor) +
282 t_count[j] = sum - interv_count;
285 interval_point[20] = tmaxcolor;
286 interval_point[21] = 1.0;
287 fprintf(stderr,
"The automatic color mapping set is :\n");
288 for (i = 0; i < 11; i++)
289 fprintf(stderr,
"%lf %lf \n", interval_point[i * 2],
290 interval_point[i * 2 + 1]);
295 int *empty_flag,
int nx,
int ny,
int nz,
int mynode,
299 int count[100], t_count[100];
302 delta = (tmaxcolor - tmincolor) / 100.0;
303 for (i = 0; i < 100; i++) {
307 for (i = 0; i < (nx + 1) * (ny + 1) * (nz + 1); i++) {
308 if (empty_flag[i] == 1) {
309 j = (int)((var[i] - tmincolor) / delta);
318 for (i = 0; i < 100; i++) t_count[i] = count[i];
321 fp = fopen(
"histogram.file",
"w");
324 for (i = 0; i < 100; i++)
325 fprintf(fp,
"%d %d -----(%lf --- %lf)\n", i, t_count[i],
326 tmincolor + i * delta, tmincolor + (i + 1) * delta);
335 for (i = 0; i < 6; i++)
342 double dis_minmax[2]) {
345 dis_minmax[0] = dis_minmax[1] =
346 sqrt(
SQR(vertex[0]) +
SQR(vertex[1]) +
SQR(vertex[2]));
347 for (i = 0; i < 8; i++) {
348 dis = sqrt(
SQR(vertex[i * 3] - view_point_d[0]) +
349 SQR(vertex[i * 3 + 1] - view_point_d[1]) +
350 SQR(vertex[i * 3 + 2] - view_point_d[2]));
351 if (dis < dis_minmax[0]) dis_minmax[0] = dis;
352 if (dis > dis_minmax[1]) dis_minmax[1] = dis;
358 double maxcolor,
double feap_minmax[2]) {
360 double t, mint, color;
362 for (i = 0; i <= 255; i++) {
363 color = mincolor + (maxcolor - mincolor) * i / 255.0;
365 for (j = 0; j < num_of_features; j++) {
366 t = fabs(color - fea_point[j]);
367 if (t < mint) mint = t;
369 if (mint > feap_minmax[1]) feap_minmax[1] = mint;
371 feap_minmax[0] = 0.0;
376 double maxcolor,
double feai_minmax[2]) {
378 double t, t1, t2, mint, color;
380 for (i = 0; i <= 255; i++) {
381 color = mincolor + (maxcolor - mincolor) * i / 255.0;
383 for (j = 0; j < num_of_features; j++) {
384 if ((t >= fea_point[j * 2]) && (t <= fea_point[j * 2 + 1]))
387 t1 = fabs(color - fea_point[j * 2]);
388 t2 = fabs(color - fea_point[j * 2 + 1]);
394 if (t < mint) mint = t;
396 if (mint > feai_minmax[1]) feai_minmax[1] = mint;
398 feai_minmax[0] = 0.0;
int HECMW_Allreduce(void *sendbuf, void *recvbuf, int count, HECMW_Datatype datatype, HECMW_Op op, HECMW_Comm comm)
#define HECMW_calloc(nmemb, size)
int change_int_order(int n)
void value2_to_rgb(double value, double color[3], int color_system_type)
void font7_generate(char input, int output[7][7])
unsigned short int change_short_int_order(unsigned short int n)
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_feai_minmax(int num_of_features, double *fea_point, double mincolor, double maxcolor, double feai_minmax[2])
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)
unsigned short bfReserved1
unsigned short bfReserved2
unsigned int biCompression
unsigned short biBitCount
unsigned int biClrImportant