#pragma once

#include "blobx.h"

//#include <cali\areacal.h>

#define TD_MIN_TEXTURE_BLOCK   3

typedef struct __td_generic_criteria
{
	int size;          //分块小尺寸
	int grayThresh;   //合并块条件的平均灰度阈值
	int stdvarThresh; //合并块条件的方差灰度阈值
	RvRange grayRange;    //灰度范围
	RvRange stdvarRange;  //变化范围
	int blockSizeThresh; //缺陷大小阈值
}TD_GENERIC_CRITERIA;


class BLOBX_API CTextureDefect :	public CAreaCal
{
public:
	CTextureDefect(void);
	virtual ~CTextureDefect(void);

	enum DETECT_TYPE
	{
		TD_DEFAULT =0,  //默认
	    TD_MURA,        //LCD MURA   		
	};

	virtual BOOL Serialize(HANDLE device, BOOL bIn ) ;
    virtual CUCObj* Clone(  CUCObj *twin) ;
	virtual void Show(CDelegate* pDelegate,int mode, BOOL bForce) ;

	virtual RV_BOOL Inspect(int* pErrCode=NULL);
	 
	virtual void Reset();

	int  GetDetectType();
	void SetDetectType(DETECT_TYPE type);

		
public:
	int   m_nDetectType;

	union{
		TD_GENERIC_CRITERIA  def;
	}m_criteria;

protected:
	RV_HANDLE DrawDefects(HGDC dc, int offsetx, int offsety,  BOOL bIgnoreAlign, RV_HANDLE hStroke);
	BOOL DetectDefault(int* pErrcode);

	void RemoveAllDefects();

	int      m_nDefectCount;  //缺陷点数量
	RvPoint* m_pDefectArray;  //缺陷点位置

};

