1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
 
#include <map>
#include <list>
#include <vector>
#include "cv.h"
 
typedef struct STU_PROFILE_POSITION_
{    
    int            iSide;
    int            iScan;
    int            iIndex;
    int            nMin;
    int            nMax;
    CPoint        point;
    BOOL        bFindPos;    
 
public:
    STU_PROFILE_POSITION_()
    {        
        iSide = iScan = iIndex = 0;
        nMin = nMax = 0;
        point = CPoint(-1,-1);
        bFindPos = FALSE;    
    }    
}STU_PROFILE_POSITION, *pSTU_PROFILE_POSITION;
 
using namespace std;
class AFX_EXT_CLASS CProfileCADProc
{
public:
    CProfileCADProc(void);
    virtual ~CProfileCADProc(void);
 
public:
    void        SetProfileData(std::multimap<int, CPoint*> *pmapProfile,std::multimap<int, CPoint*> *pmapAlignProfile);
    void        SetProfileOrigin(CPoint ptOrigin);
    int            MakeProfileCAD(int iSide,CString strFile);
    BOOL        WriteProfileData(CString strFile,CString strImg=_T(""));
    BOOL        ReadProfileData(CString strFile);    
    BOOL        RotateProfileData(CvPoint2D32f ptFirst,CvPoint2D32f ptSecond,CvPoint2D32f ptOffset);
    BOOL        GetProfilePosition(std::vector< pair<int,STU_PROFILE_POSITION*> > &vecProfile);
    CPoint        GetProfileOrigin(){return m_pointMasterMin;}
    CPoint        GetProfileMax(){return m_pointMasterMax;}
    CPoint        FindCADPoint(CvPoint2D32f ptCenter,double dTheta,int nRange);
    CPoint        FindCADPoint(CvPoint2D32f ptCenter,double dTheta,int nRange,LPBYTE    lpImg,int nWidth,int nHeight,CPoint &ptGlass,CPoint &ptChamfer,int nGlassthres,int nChamferThres);
    CPoint        FindCADPointY(int nX,BOOL bStart);
    CPoint        FindCADPointY(int nX,BOOL bStart,LPBYTE    lpImg,int nWidth,int nHeight,CPoint &ptGlass,CPoint &ptChamfer,int nGlassthres,int nChamferThres);
    BOOL        FindGlassLine(CPoint ptOrigin,int nRange,double dTheta,LPBYTE lpImg,int nWidth,int nHeight,int nGlassThres,int nChamferThres,CPoint &ptGlass,CPoint &ptChamfer);
    void        Reset();
 
protected:
    int            FindProfileLine(CSISBuffer &BufCad);
    BOOL        SaveImageJPG(CString strFile,CSISBuffer &buffer);
 
protected:
    BOOL        m_bLoadMaster;
    std::multimap<int, CPoint*> *m_pmapProfile;        
    std::multimap<int, CPoint*> *m_pmapAlignProfile;        
    CPoint        m_ptOrigin;
    CPoint        m_pointMasterMax;
    CPoint        m_pointMasterMin;
    double        m_dTheta;
    CPoint        m_ptOffset;
    CPoint        m_ptAlign;
    CPoint        m_ptOriginOffset;
};