xp_comm_proj/build3d_2/build3d_2.c
/*----------------------------------------------------------------------
 * the public entry point (update method in bd3dmods.v)
 */
the public entry point (update method in bd3dmods.v)
the public entry point ( update method in bd3dmods . v )
int Build3D_2_Core_update(OMobj_id elem_id, OMevent_mask event_mask, int seq_num)
{
  OMobj_id file_id;
  char *filename = NULL;
  int rb_val,  format, result;
  int start, end, out_format;
  file_id = OMfind_subobj(elem_id, OMstr_to_name("filename"), OM_OBJ_RD);
  if (OMis_null_obj(file_id) || OMget_str_val(file_id, &filename, 0) != OM_STAT_SUCCESS)
    return(0);
  if (strchr(filename, '%')==NULL)
    ERR_RETURN("Filename does not contain a format specifier");
  if (OMget_name_int_val(elem_id, OMstr_to_name("format"), &rb_val) != OM_STAT_SUCCESS)
    rb_val = 0;
  if (rb_val < 0 || rb_val > sizeof(FUNCread_map) / sizeof(read_map))
    format = DV_IMAGE_FORMAT_UNKNOWN;
  else if (rb_val == 0)
    format = DV_IMAGE_FORMAT_AUTO;
  else
    format = FUNCread_map[rb_val-1].dv_val;
  if (OMget_name_int_val(elem_id, OMstr_to_name("start"), &start) != OM_STAT_SUCCESS)
    ERR_RETURN("Image start index is not valid.");
  if (OMget_name_int_val(elem_id, OMstr_to_name("end"), &end) != OM_STAT_SUCCESS)
    ERR_RETURN("Image end index is not valid.");
  if (start>=end)
    ERR_RETURN("Starting image index must be greater than ending image index.");
  if (OMget_name_int_val(elem_id, OMstr_to_name("out_format"), &rb_val) != OM_STAT_SUCCESS)
    rb_val = LUMI_OUT_FORMAT;
  if (rb_val < 0 || rb_val >= NUM_OUT_FORMATS)
    out_format = ARGB_OUT_FORMAT;
  else
    out_format = rb_val;
  format = FUNCcheck_image_formats(filename, start, end, format);
  result = 0;
  switch (format)
  {
    case DV_IMAGE_FORMAT_AVSX:
    case DV_IMAGE_FORMAT_BMP:
    case DV_IMAGE_FORMAT_GIF:
    case DV_IMAGE_FORMAT_JPEG:
    case DV_IMAGE_FORMAT_PBM:
    case DV_IMAGE_FORMAT_SGIRGB:
    case DV_IMAGE_FORMAT_SUNRAS:
    case DV_IMAGE_FORMAT_TIFF:
    {
      result = FUNCread_volume(filename, format, start, end, out_format, elem_id);
      break;
    }
    case DV_IMAGE_FORMAT_NOFILE: break;
    case DV_IMAGE_FORMAT_UNKNOWN: break;
    case DV_IMAGE_FORMAT_MISMATCH: break;
    default:
      ERRerror("Build3D_2_Core", 0, ERR_ORIG, "File format is not supported");
      break;
  }
  if (filename)
    free(filename);
  return(result);
}
int Build3D_2_Core_update ( OMobj_id elem_id , OMevent_mask event_mask , int seq_num ) { OMobj_id file_id ; char * filename = NULL ; int rb_val , format , result ; int start , end , out_format ; file_id = OMfind_subobj ( elem_id , OMstr_to_name ( " " ) , OM_OBJ_RD ) ; if ( OMis_null_obj ( file_id ) || OMget_str_val ( file_id , & filename , 0 ) != OM_STAT_SUCCESS ) return ( 0 ) ; if ( strchr ( filename , ' ' ) == NULL ) ERR_RETURN ( " " ) ; if ( OMget_name_int_val ( elem_id , OMstr_to_name ( " " ) , & rb_val ) != OM_STAT_SUCCESS ) rb_val = 0 ; if ( rb_val < 0 || rb_val > sizeof ( FUNCread_map ) / sizeof ( read_map ) ) format = DV_IMAGE_FORMAT_UNKNOWN ; else if ( rb_val == 0 ) format = DV_IMAGE_FORMAT_AUTO ; else format = FUNCread_map [ rb_val - 1 ] . dv_val ; if ( OMget_name_int_val ( elem_id , OMstr_to_name ( " " ) , & start ) != OM_STAT_SUCCESS ) ERR_RETURN ( " " ) ; if ( OMget_name_int_val ( elem_id , OMstr_to_name ( " " ) , & end ) != OM_STAT_SUCCESS ) ERR_RETURN ( " " ) ; if ( start >= end ) ERR_RETURN ( " " ) ; if ( OMget_name_int_val ( elem_id , OMstr_to_name ( " " ) , & rb_val ) != OM_STAT_SUCCESS ) rb_val = LUMI_OUT_FORMAT ; if ( rb_val < 0 || rb_val >= NUM_OUT_FORMATS ) out_format = ARGB_OUT_FORMAT ; else out_format = rb_val ; format = FUNCcheck_image_formats ( filename , start , end , format ) ; result = 0 ; switch ( format ) { case DV_IMAGE_FORMAT_AVSX : case DV_IMAGE_FORMAT_BMP : case DV_IMAGE_FORMAT_GIF : case DV_IMAGE_FORMAT_JPEG : case DV_IMAGE_FORMAT_PBM : case DV_IMAGE_FORMAT_SGIRGB : case DV_IMAGE_FORMAT_SUNRAS : case DV_IMAGE_FORMAT_TIFF : { result = FUNCread_volume ( filename , format , start , end , out_format , elem_id ) ; break ; } case DV_IMAGE_FORMAT_NOFILE : break ; case DV_IMAGE_FORMAT_UNKNOWN : break ; case DV_IMAGE_FORMAT_MISMATCH : break ; default : ERRerror ( " " , 0 , ERR_ORIG , " " ) ; break ; } if ( filename ) free ( filename ) ; return ( result ) ; }
the public entry point (update method in bd3dmods.v)
the public entry point ( update method in bd3dmods . v )
/*from_format,*/ /* Get filename specification string */ /* Get input file format parameter */ /* map format UIradiobox val to internal def */ /* Get start and end parameters */ /* Get output data format parameter */ /* map format UIradiobox val to internal def */ /* Check all files to ensure that they exist and that they are all of the same
   * format.  If we haven't explicitly stated a format then store the returned format.
   */ /* now go read the file of particular format */