#ifndef CAKERFCHECK_H_H
#define CAKERFCHECK_H_H

#include "calgorithm.h"
#include <QVector>
#include "cmpoint.h"
#include "export_kerf_base.h"
class KERF_BASE_EXPORT CAKerfCheck_H : public CAlgorithm
{
public:
    CAKerfCheck_H(const QString& name,int32_t id);
    int32_t exe(CMImage* pmimage);
    void showresult_shape(CImageContainer* pContainer);
    void showragion_static(CImageContainer* pContainer);
private:
    void showresult_XDirect(CImageContainer* pContainer);
    void showresult_YDirect(CImageContainer* pContainer);
    void showragion_static_XDirect(CImageContainer* pContainer);
    void showragion_static_YDirect(CImageContainer* pContainer);
    int32_t exe_XDirect(CMImage* pmimage);
    int32_t exe_YDirect(CMImage* pmimage);

    QVector<CMPointd> m_Data;

    void GetYDirectAvg(CMImage* pmimage);
	//计算图像中X方向的平均像素值并保存到 m_Data中
    void GetXDirectAvg(CMImage* pmimage);
    virtual void Serialize(QDataStream& stream,bool bwrite, int iVersion) override;
    void GetYThrough(int iThreshold,int iStart,int iEnd,int iStart1,int iEnd1,CMPointd& Center);
    void GetYThrough_single(int iThreshold,int iStart,int iEnd,CMPointd& Center);
	//在X方向找均匀的线，找黑色的划线
	//如果阈值范围小于iThreshold,则记录然后直到找到大于iThreshold停止，统计差值，判断是否在
	//Var_KerfCheck_H_Minlength 和 Var_KerfCheck_H_Maxlength范围内，在范围内则记录
	//iStart找到iStart1 再从iEnd1 找到iEnd 这个范围根据设定的最小最大范围控制
	//iStart	-----
	//iStart1	-----
	//Center	-----
	//iEnd1		-----
	//iEnd		-----
	//iStart = Center-MaxRange/2	iStart1=Center+MinRange/2
	//如果MinRange==0,则只会在iStart到iEnd之间找
	//如果MinRange>0，则iStart1到iEnd1之间的数据会跳过
    void GetXThrough(int iThreshold,int iStart,int iEnd,int iStart1,int iEnd1,CMPointd& Center);
	void GetXThroughSkipCenter(int iThreshold,int iStart,int iEnd, int iSkipBegin, int iSkipEnd, CMPointd& Center);
    void GetXThrough_single(int iThreshold,int iStart,int iEnd,CMPointd& Center);


    void GetYMount(int iThreshold,int iStart,int iEnd,int iStart1,int iEnd1,CMPointd& Center);
    void GetXMount(int iThreshold,int iStart,int iEnd,int iStart1,int iEnd1,CMPointd& Center);
};

#endif // CAKERFCHECK_H_H
