// file: $USFS/class/sbe_eval/v1.0/sbe_combine_0.cc
//

// isip include files
//
#include "sbe_eval.h"

#include "sbe_eval_constants.h"
#include <integral_constants.h>

// program to combine the result files and assign them
//
logical_1 Sbe_eval::combine_cc(FILE** fp_in, FILE** fp_out) {

  // declare local variables
  //
  float sbe_lsbe = 0;
  float sbe_msbe = 0;
  float sbe_hsbe = 0;
  float min;
  int index;
  
  // declare buf space
  //
  char temp_buf[ISIP_MAX_STRING_LENGTH];
  
  for (int i=0; i < no_of_images_d; i++) {
    
    fscanf(fp_in[0], "%s%f", temp_buf, &sbe_lsbe);
    fscanf(fp_in[1], "%s%f", temp_buf, &sbe_msbe);
    fscanf(fp_in[2], "%s%f", temp_buf, &sbe_hsbe);
    
    min = sbe_lsbe;
    index = 1;

    // checking for the minimum distance
    //
    if (sbe_msbe < min) {
      min = sbe_msbe;
      index = 2;
    }
    
    if (sbe_hsbe < min) {
      min = sbe_hsbe;
      index = 3;
    }
    
    fprintf(fp_out[0], "%s\t%d\n", temp_buf, index);
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
    
