#pragma once

#include "blobx.h"


//#define RV_UC_PART_SEPERATER    2122

//前景对象与背景按照长度区分
//提取检测区内最长的一个物品
//用在流水线上物体计数等
//粗分定位。
//检测取必须容纳一个零件，但少于两个零件
class BLOBX_API CPartSeperater :	public CAreaCal
{
public:
	enum{
		PS_HORI =0,
		PS_VERT ,
		PS_FREE  ,
	};

public:

	CPartSeperater(void);
	virtual ~CPartSeperater(void);


	virtual BOOL Serialize(HANDLE device, BOOL bIn ) ;
    virtual CUCObj* Clone( CUCObj* twin) ;

	virtual void Reset();
	virtual void Show(CDelegate* pDelegate, int mode,BOOL bForce);
	 
	//如果找到合适的面，返回TRUE.
	virtual RV_BOOL Inspect(int* pErrCode) ;

	//外部程序需要删除该图像
	RvImage GetWorkImage();
	int     GetLength(){ return m_nEndPos - m_nStartPos; };
	BOOL    IsPartExist(){ return m_bPartExist; };
	int GetStartPos(){ return m_nStartPos; };
	int GetEndPos(){ return m_nEndPos; };

	static void CalcCurvDiff(int space, UINT* pData, int size);

public :
	virtual void OnEndTrack(CDelegate* pDelegate, HGPD hCur,  GPoint point, int type)  ;
	
public:
	
	int   m_nTargetLen;
	int   m_nTransitSpace;
	float m_nLenToler;
	UINT   m_nStrengthThres;
	BOOL   m_bRelative;

protected:
	BOOL       m_bPartExist;
	int        m_nStartPos, m_nEndPos;
	 
 
	
};

