/* Initialize pseudo-color mapping table for the current view. This color assignment will vary with each set of IR data read so as to map the full range of data to the full spectrum of colors. This means that a given color will not necessarily have the same temperature mapping for different views of the vehicle, but is only valid for display of the current view. */ int init_Temp_To_RGB(void) { int temp, i; RGBpixel rgb; if ((ir_aperture = fb_getwidth(fbiop)/grid_sz) < 1) { bu_log("Grid too large for IR application, max. is %d.\n", IR_DATA_WID ); return 0; } sample_sz = pow(ir_aperture, 2); if (ir_table != (RGBpixel *)RGBPIXEL_NULL) /* Table already initialized presumably from another view, since range may differ we must create a different table of color assignment, so free storage and re- initialize. */ free((char *) ir_table); ir_table = (RGBpixel *) malloc((unsigned)(sizeof(RGBpixel)*((ir_max-ir_min)+1))); if (ir_table == (RGBpixel *)RGBPIXEL_NULL) { Malloc_Bomb(sizeof(RGBpixel)*((ir_max-ir_min)+1)); fatal_error = TRUE; return 0; } for (temp = ir_min, i = 0; temp <= ir_max; temp++, i++) { temp_To_RGB(rgb, temp); COPYRGB(ir_table[i], rgb); } ir_max_index = i - 1; return 1; }
Octree * new_Octant(Octree *parentp, Octree **childpp, int bitv, int level) { register Octree *childp; fastf_t delta = modl_radius / pow_Of_2( level ); register float *origin = parentp->o_points->c_point; /* Create child node, filling in parent's pointer. */ if ( ! NewOctree( *childpp ) ) { Malloc_Bomb(sizeof(Octree)); fatal_error = TRUE; return OCTREE_NULL; } /* Fill in fields in child node. */ childp = *childpp; childp->o_bitv = bitv; childp->o_temp = ABSOLUTE_ZERO; /* Unclaimed by temperature. */ childp->o_triep = TRIE_NULL; /* Unclaimed by region. */ childp->o_sibling = OCTREE_NULL; /* End of sibling chain. */ childp->o_child = OCTREE_NULL; /* No children yet. */ /* Create list node for origin of leaf octant. */ if ( ! NewPoint( childp->o_points ) ) { Malloc_Bomb(sizeof(PtList)); fatal_error = TRUE; return OCTREE_NULL; } childp->o_points->c_next = PTLIST_NULL; /* End of pt. chain. */ /* Compute origin relative to parent, based on bit vector. */ if ( bitv & 1<<X ) childp->o_points->c_point[X] = origin[X] + delta; else childp->o_points->c_point[X] = origin[X] - delta; if ( bitv & 1<<Y ) childp->o_points->c_point[Y] = origin[Y] + delta; else childp->o_points->c_point[Y] = origin[Y] - delta; if ( bitv & 1<<Z ) childp->o_points->c_point[Z] = origin[Z] + delta; else childp->o_points->c_point[Z] = origin[Z] - delta; return childp; }
int append_PtList(fastf_t *pt, PtList *ptlist) { for (; ptlist->c_next != PTLIST_NULL; ptlist = ptlist->c_next ) { if ( SamePoint( ptlist->c_next->c_point, pt, F2D_EPSILON ) ) { /* Point already in list. */ return 1; } } if ( ! NewPoint( ptlist->c_next ) ) { Malloc_Bomb(sizeof(PtList)); fatal_error = TRUE; return 0; } ptlist = ptlist->c_next; VMOVE( ptlist->c_point, pt ); ptlist->c_next = PTLIST_NULL; return 1; }
/* * F B _ I O I N I T * * This initialization routine must be called before any buffered * I/O routines in this file are used. */ int fb_ioinit(register FBIO *ifp) { if ( ifp->if_debug & FB_DEBUG_BIO ) { fb_log( "fb_ioinit( 0x%lx )\n", (unsigned long)ifp ); } ifp->if_pno = -1; /* Force _fb_pgin() initially. */ ifp->if_pixcur = 0L; /* Initialize pixel number. */ if ( ifp->if_pbase == PIXEL_NULL ) { /* Only allocate buffer once. */ ifp->if_ppixels = PAGE_PIXELS; /* Pixels/page. */ if ( ifp->if_ppixels > ifp->if_width * ifp->if_height ) ifp->if_ppixels = ifp->if_width * ifp->if_height; if ( (ifp->if_pbase = (unsigned char *)malloc( ifp->if_ppixels * sizeof(RGBpixel) )) == PIXEL_NULL ) { Malloc_Bomb(ifp->if_ppixels * sizeof(RGBpixel)); return -1; } } ifp->if_pcurp = ifp->if_pbase; /* Initialize pointer. */ ifp->if_pendp = ifp->if_pbase+ifp->if_ppixels*sizeof(RGBpixel); return 0; }
static OcList * copy_OcList(OcList *orp) /* Input list read pointer. */ { OcList *oclistp = OCLIST_NULL; /* Output list pointer. */ OcList **owpp = &oclistp; /* Write pointer. */ /* Make copy of Octree pointer list. */ for ( owpp = &oclistp; orp != OCLIST_NULL; orp = orp->p_next, owpp = &(*owpp)->p_next ) { if ( (*owpp = (OcList *) malloc( sizeof(OcList) )) == OCLIST_NULL ) { Malloc_Bomb(sizeof(OcList)); fatal_error = TRUE; return OCLIST_NULL; } (*owpp)->p_octp = orp->p_octp; (*owpp)->p_next = OCLIST_NULL; } return oclistp; }
Octree * add_Region_Octree(Octree *parentp, fastf_t *pt, Trie *triep, int temp, int level) { Octree *newp; /* Traverse to octant leaf node containing "pt". */ if ( (newp = find_Octant( parentp, pt, &level )) == OCTREE_NULL ) { bu_log( "find_Octant() returned NULL!\n" ); return OCTREE_NULL; } /* Decide where to put datum. */ if ( newp->o_points->c_next == PTLIST_NULL ) { /* Octant empty, so place region here. */ newp->o_triep = triep; if ( ! NewPoint( newp->o_points->c_next ) ) { Malloc_Bomb(sizeof(PtList)); fatal_error = TRUE; return OCTREE_NULL; } VMOVE( newp->o_points->c_next->c_point, pt ); newp->o_points->c_next->c_next = PTLIST_NULL; if ( temp != AMBIENT-1 ) newp->o_temp = temp; return newp; } else /* Octant occupied. */ if ( triep != newp->o_triep ) { /* Region collision, must subdivide octant. */ if ( ! subdivide_Octree( newp, level )) return OCTREE_NULL; return add_Region_Octree( newp, pt, triep, temp, level ); } else if ( temp != AMBIENT-1 ) { /* We are assigning a temperature. */ if ( newp->o_temp < AMBIENT ) { /* Temperature not assigned yet. */ newp->o_temp = temp; if ( ! append_PtList( pt, newp->o_points ) ) return OCTREE_NULL; } else if ( Abs(newp->o_temp - temp) < ir_noise ) { /* Temperatures close enough. */ if ( ! append_PtList( pt, newp->o_points ) ) return OCTREE_NULL; } else if ( newp->o_points->c_next->c_next == PTLIST_NULL && SamePoint( newp->o_points->c_next->c_point, pt, F2D_EPSILON ) ) /* Only point in leaf node is this point. */ newp->o_temp = temp; else { /* Temperature collision, must subdivide. */ if ( ! subdivide_Octree( newp, level ) ) return OCTREE_NULL; return add_Region_Octree( newp, pt, triep, temp, level ); } } else /* Region pointers match, so append coordinate to list. */ if ( ! append_PtList( pt, newp->o_points ) ) return OCTREE_NULL; return newp; }