// file: $USFS/class/image_analysis/v3.0/imaga_write_0.cc
//

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

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

// method: write_cc
//
// arguments:
//
// return: a logical_1 value indicating status
//
// this method normalizes the frequency distributions and writes into the
// output file(model file)
//
logical_1 Image_analysis::write_cc() {
  
  // write into the output model file for histogram
  //
  if ((mode_d == IMAGA_MODE_TRAIN) && (algorithm_d == IMAGA_ALG_HISTOGRAM)) {
    if (hist_write_cc() == ISIP_FALSE) {
      error_handler_cc((char_1*)"write_cc",
		       (char_1*)"error while writing the histogram data");
      return ISIP_FALSE;
    }
  }

  // write the model file for the edge detection
  //
  if ((mode_d == IMAGA_MODE_TRAIN) && (algorithm_d == IMAGA_ALG_EDGEDET)) {
    if (edge_write_cc() == ISIP_FALSE) {
      error_handler_cc((char_1*)"write_cc",
		       (char_1*)"error while writing the edge detection data");
      return ISIP_FALSE;
    }
  }

  // write the model file for the factor analysis
  //
  if ((mode_d == IMAGA_MODE_TRAIN) &&
      (algorithm_d == IMAGA_ALG_FACTOR)) {
    if (pca_write_cc() == ISIP_FALSE) {
      error_handler_cc((char_1*)"write_cc",
		       (char_1*)"error while writing the HE data");
      return ISIP_FALSE;
    }
  }

  // write the model file for the sharpness
  //
  if ((mode_d == IMAGA_MODE_TRAIN) &&
      (algorithm_d == IMAGA_ALG_DIFF)) {
    if (dent_write_cc() == ISIP_FALSE) {
      error_handler_cc((char_1*)"write_cc",
		       (char_1*)"error while writing the DIFF data");
      return ISIP_FALSE;
    }
  }

  // write the model file for the standard deviation
  //
  if ((mode_d == IMAGA_MODE_TRAIN) &&
      (algorithm_d == IMAGA_ALG_SD)) {
    if (sd_write_cc() == ISIP_FALSE) {
      error_handler_cc((char_1*)"write_cc",
		       (char_1*)"error while writing the SD data");
      return ISIP_FALSE;
    }
  }

  // write the model file for the entropy
  //
  if ((mode_d == IMAGA_MODE_TRAIN) &&
      (algorithm_d == IMAGA_ALG_ENT)) {
    if (ent_write_cc() == ISIP_FALSE) {
      error_handler_cc((char_1*)"write_cc",
		       (char_1*)"error while writing the entropy data");
      return ISIP_FALSE;
    }
  }

  // write the model file for the run length coding
  //
  if ((mode_d == IMAGA_MODE_TRAIN) &&
      (algorithm_d == IMAGA_ALG_RLE)) {
    if (rle_write_cc() == ISIP_FALSE) {
      error_handler_cc((char_1*)"write_cc",
		       (char_1*)"error while writing the compression data");
      return ISIP_FALSE;
    }
  }
  
  // write the model file for the fractal dimension
  //
  if ((mode_d == IMAGA_MODE_TRAIN) &&
      (algorithm_d == IMAGA_ALG_FRACT)) {
    if (fract_write_cc() == ISIP_FALSE) {
      error_handler_cc((char_1*)"write_cc",
		       (char_1*)"error while writing the fractal dimensions");
      return ISIP_FALSE;
    }
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
