int
ir_Chk_Table(void)
{
    if (ir_table == (RGBpixel *)PIXEL_NULL) {
	get_Input(input_ln, MAX_LN, "Enter minimum temperature : ");
	if (sscanf(input_ln, "%d", &ir_min) != 1) {
	    prnt_Scroll("Could not read minimum temperature.");
	    return 0;
	}
	get_Input(input_ln, MAX_LN, "Enter maximum temperature : ");
	if (sscanf(input_ln, "%d", &ir_max) != 1) {
	    prnt_Scroll("Could not read maximum temperature.");
	    return 0;
	}
	if (! init_Temp_To_RGB())
	    return 0;
    }
    return 1;
}
int
read_IR(FILE *fp)
{
    int fy;
    int rx, ry;
    int min, max;
    if (fread((char *) &min, (int) sizeof(int), 1, fp) != 1
	||	fread((char *) &max, (int) sizeof(int), 1, fp) != 1
	)
    {
	bu_log("Can't read minimum and maximum temperatures.\n");
	return 0;
    } else {
	bu_log("IR data temperature range is %d to %d\n",
	       min, max
	    );
	if (ir_min == ABSOLUTE_ZERO) {
	    /* Temperature range not set.			*/
	    ir_min = min;
	    ir_max = max;
	} else {
	    /* Merge with existing range.			*/
	    V_MIN(ir_min, min);
	    V_MAX(ir_max, max);
	    bu_log("Global temperature range is %d to %d\n",
		   ir_min, ir_max
		);
	}
	(void) fflush(stdout);
    }
    if (! init_Temp_To_RGB()) {
	return 0;
    }
    for (ry = 0, fy = grid_sz-1; ; ry += ir_aperture, fy--) {
	if (fb_seek(fbiop, 0, fy) == -1) {
	    bu_log("\"%s\"(%d) fb_seek to pixel <%d, %d> failed.\n",
		   __FILE__, __LINE__, 0, fy
		);
	    return 0;
	}
	for (rx = 0; rx < IR_DATA_WID; rx += ir_aperture) {
	    int fah;
	    int sum = 0;
	    int i;
	    int lgtindex;
	    RGBpixel *pixel;
	    for (i = 0; i < ir_aperture; i++) {
		int j;
		for (j = 0; j < ir_aperture; j++) {
		    if (get_IR(rx+j, ry+i, &fah, fp))
			sum += fah < ir_min ? ir_min : fah;
		    else {
			/* EOF */
			if (ir_octree.o_temp == ABSOLUTE_ZERO)
			    ir_octree.o_temp = AMBIENT - 1;
			display_Temps(grid_sz/8, 0);
			return 1;
		    }
		}
	    }
	    fah = Avg_Fah(sum);
	    if ((lgtindex = fah-ir_min) > ir_max_index || lgtindex < 0) {
		bu_log("temperature out of range (%d)\n",
		       fah
		    );
		return 0;
	    }
	    pixel = (RGBpixel *) ir_table[lgtindex];
	    (void) fb_wpixel(fbiop, (unsigned char *)pixel);
	}
    }
}
Beispiel #3
0
int
read_Trie(FILE *fp)
{
    static char	name_buf[MAX_TRIE_LEVEL+1];
    Trie	*triep;
    F_Hdr_Ptlist	hdr_ptlist;
    int		min, max;
    /* Read temperature range information.				*/
    if (	fread( (char *) &min, (int) sizeof(int), 1, fp ) != 1
		||	fread( (char *) &max, (int) sizeof(int), 1, fp ) != 1
	)
    {
	bu_log( "Could not read min/max info.\n" );
	rewind( fp );
    }
    else
    {
	bu_log( "IR data base temperature range is %d to %d\n",
		min, max
	    );
	if ( ir_min == ABSOLUTE_ZERO )
	{
	    /* Temperature range not set.			*/
	    ir_min = min;
	    ir_max = max;
	}
	else
	{
	    /* Merge with existing range.			*/
	    V_MIN( ir_min, min );
	    V_MAX( ir_max, max );
	    bu_log(	"Global temperature range is %d to %d\n",
			ir_min, ir_max
		);
	    (void) fflush( stdout );
	}
    }
    if ( ! init_Temp_To_RGB() )
    {
	return	0;
    }
    while ( bu_fgets( name_buf, MAX_TRIE_LEVEL, fp ) != NULL )
    {
	name_buf[strlen(name_buf)-1] = '\0'; /* Clobber new-line.*/
	triep = add_Trie( name_buf, &reg_triep );
	if ( fread( (char *) &hdr_ptlist, (int) sizeof(F_Hdr_Ptlist), 1, fp )
	     != 1
	    )
	{
	    bu_log( "\"%s\"(%d) Read failed!\n", __FILE__, __LINE__ );
	    return	0;
	}
	for (; hdr_ptlist.f_length > 0; hdr_ptlist.f_length-- )
	{
	    fastf_t		point[3];
	    float		c_point[3];
	    Octree		*octreep;
	    if ( fread( (char *) c_point, (int) sizeof(c_point), 1, fp ) != 1 )
	    {
		bu_log(	"\"%s\"(%d) Read failed.\n",
			__FILE__, __LINE__ );
		return	0;
	    }
	    VMOVE( point, c_point );
	    if ( (octreep = add_Region_Octree(	&ir_octree,
						point,
						triep,
						hdr_ptlist.f_temp,
						0
		      )
		     ) != OCTREE_NULL
		)
		append_Octp( triep, octreep );
	}
    }
    return	1;
}