#ifndef CLUSTERFLOW2_H_
#define CLUSTERFLOW2_H_

/**
 * \file viflow.h
 * \brief a header for viflow.c
 *
 *
 * \ingroup corefiles
 * \date Apr 20, 2009
 * \author Alexander Pimenov
 */


#ifdef __cplusplus
	extern "C" {
#endif

#include "signatures.h"
#include "flow.h"
#include "rectification.h"

/**
 * \brief This structure stores the cortage that stores where in particular was the the signature
 *
 */
typedef struct Cortage_TAG {
	uint32_t signature;    /**< \brief The signature itself */
	vector2Du16 point;     /**< \brief The position of the area with the signature */
} cortage;


/**
 * \brief This structure stores the cortage list for sorting and quick search
 *
 */
typedef struct CortageList_TAG {
	int h;                 /**< Height of the buffer for which the cortages are generated*/
	int w;                 /**< Width of the buffer for which the cortages are generated**/
	uint32_t number;       /**< \brief The length of the list. The memory allocated for it */
	uint32_t active;       /**< \brief The number of the active signatures. This is always less or equal to the .number */
	cortage* cortages;     /**< \brief The array of the coratges */
} CortageList;

FlowBuffer* calculateTheFlow (signaturesBuffer *S1, signaturesBuffer *S2, int cutout, int doWizeMatch);

FlowBuffer* calculateTheFlowSimple (signaturesBuffer *S1, signaturesBuffer *S2, int cutout);

FlowBuffer *filterFlow (FlowBuffer *flow, int zonesize, int local, int displimit, int displimitarea);

FlowBuffer *filterFlowSimple (FlowBuffer *flow, int zonesize, int hittres, int hitslimit);

CortageList *cortageListGenerate (signaturesBuffer *S);

void cortageListDelete (CortageList *toDelete);

void cortageListResort(CortageList *list);

int coratgeListDifferentSignatures(CortageList *list);

int cortageListSortedGetSignature(CortageList *list, signature_t sig);

FlowBuffer* matchCortagesWize (CortageList *L1, CortageList *L2, int cutout);

void generateCorrespondanceList(FlowBuffer *flow, Correspondance **correspondanceList, int *correspondanceNumber);

#ifdef __cplusplus
	} // 	extern "C"
#endif
#endif /* CLUSTERFLOW2_H_ */
