/*
# %M% %Y% %I%
# The latest update : %G% at %U%
#
#%Z% mrcImageMasking ver %I%
#%Z% Created by 
#%Z%
#%Z% Usage : mrcImageMasking
#%Z% Attention
#%Z%
*/
static char __sccs_id[] = "%Z%mrcImageMasking ver%I%; Date:%D% %Z%";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>                  
#define GLOBAL_DECLARATION
#include "../inc/config.h"
#undef DEBUG
#include "genUtil.h"
#include "mrcImage.h"
#include "lmrcImageMasking.h"
#include "lmrcImageNormalizing.h"

void
main(int argc, char* argv[]) 
{
	long status;
	mrcImageMaskingInfo info;
	mrcImage in;
	mrcImage nor;
	mrcImage out;
	lmrcImageMaskingInfo linfo;
	lmrcImageNormalizingInfo lninfo;

	init0(&info);
    argCheck(&info, argc, argv);
    init1(&info);
	mrcFileRead(&in, info.In, "from main routine", 0);	

	if(info.flagnx) {
		linfo.n.x = info.nx;
	} else {
		linfo.n.x = in.HeaderN.x;
	}
	if(info.flagny) {
		linfo.n.y = info.ny;
	} else {
		linfo.n.y = in.HeaderN.y;
	}
	linfo.shape = info.Shape;

	if(info.flagNormalize) {
		lninfo.Mode = info.Normalize;	
		lmrcImageNormalizing(&nor, &in, &lninfo, 0);
	} else {
		nor = in;
	}
	lmrcImageMasking(&out, &nor, &linfo, 0);
	
	mrcStatDataSet(&out, 0);
	mrcFileWrite(&out, info.Out, "from main routine", 0);	
	exit(EXIT_SUCCESS);
}

void
additionalUsage()
{
	fprintf(stderr, "----- -Shape Option ----- \n");
	fprintf(stderr, "    -Shape 0 : Circle : radius(nx, ny)\n");
}

