SDC C-Project CF Review 프로그램
kojingeun
2023-07-14 f77e8008cac062596058fca2aeddda62b80bedbf
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#include "StdAfx.h"
#include "PitchStat.h"
#include "PitchStat2d.h"
#include "MosisAssem/AssemUtil.h"
 
CPitchStat2d::CPitchStat2d(void) :m_bPitchMade(FALSE)
{
}
 
CPitchStat2d::~CPitchStat2d(void)
{
}
 
BOOL CPitchStat2d::CheckPitch2d(CMosisBuffer &buff, CRect &rect, stPitchParam &param)
{
    return CheckPitch2d(buff.GetDataAddress(), buff.GetDataWidth(), buff.GetHeight(), rect, param);
}
 
void CPitchStat2d::ResetConvBuff(int size)
{
    if (size < 1) size = 1;
    size = (size + 32) * 16;    // vertÀÇ °æ¿ì 16¹èÀÇ Conv Buff°¡ ÇÊ¿äÇÏ´Ù.
 
    m_ConvBlock.SetSize(size);
    m_ConvBlock2.SetSize(size);
}
 
void CPitchStat2d::AddPitch(int xx, int yy, int pitch16, int xTimes, int yTimes)
{
    xx = xx >> 4; yy = yy >> 4;
    for (int y = 0; y < yTimes; y++)
    {
        for (int x = 0; x < xTimes; x++)
        {
            *GetData(xx + x, yy + y) = pitch16;
        }
    }
}
 
BOOL CPitchStat2d::WritePitch2d(char* fileName)
{
    char str[100];
    FILE *pFile;
    fopen_s(&pFile, fileName, "w");
    if (pFile == NULL)    return FALSE;
 
    int xn = m_xInterval >> 4;// m_xInterval, m_yInterval ´Â 16ÀÇ ¹è¼ö
    int yn = m_yInterval >> 4;
 
    int sx = (m_xStart), ex = (m_xEnd);
    int sy = (m_yStart), ey = (m_yEnd);
 
    sx = 0; ex = GetWidth();
    sy = 0; ey = GetHeight();
    float pitch;
    for (int y = sy; y < ey; y += yn)
    {
        sprintf_s(str, "%d:%t", y*m_yInterval);
        fprintf(pFile, str);
        for (int x = sx; x < ex; x += xn)
        {
            pitch = ((float)*GetData(x, y)) / 16;
            sprintf_s(str, "%.3f\t", pitch);
            fprintf(pFile, str);
        }
        sprintf_s(str, "\n");
        fprintf(pFile, str);
    }
 
    fclose(pFile);
 
    return TRUE;
}
 
void CPitchStat2d::VerifyPitch(int x, int x2, int y, int y2, int exWidth, int eyHeight)
{
    m_xStart = x >> 4; m_yStart = y >> 4;
    m_xEnd = x2 >> 4; m_yEnd = y2 >> 4;
 
    int pitch;
    int sx, ex, sy, ey;
 
    exWidth = exWidth >> 4;
    eyHeight = eyHeight >> 4;
 
    sx = m_xStart - exWidth;
    if (sx < 0)        sx = 0;
    ex = m_xEnd + exWidth;
    if (ex >= GetWidth()) ex = GetWidth() - 1;
    sy = m_yStart - eyHeight;
    if (sy < 0)    sy = 0;
    ey = m_yEnd + eyHeight;
    if (ey >= GetHeight()) ey = GetHeight() - 1;
 
    m_sxExtend = sx; m_exExtend = ex;
    m_syExtend = sy; m_eyExtend = ey;
 
    for (y = m_yStart; y <= m_yEnd; y++)
    {
        pitch = *GetData(m_xEnd, y);
        for (x = m_xEnd + 1; x <= ex; x++)
        {
            *GetData(x, y) = pitch;
        }
    }
 
    for (y = m_yStart; y <= m_yEnd; y++)
    {
        pitch = *GetData(m_xStart, y);
        for (x = sx; x < m_xStart; x++)
        {
            *GetData(x, y) = pitch;
        }
    }
 
    int width = ex - sx + 1;
    for (y = sy; y < m_yStart; y++)
    {
        memcpy(GetData(sx, y), GetData(sx, m_yStart), sizeof(int)*width);
    }
    for (y = m_yEnd + 1; y <= ey; y++)
    {
        memcpy(GetData(sx, y), GetData(sx, m_yEnd), sizeof(int)*width);
    }
}
 
BOOL CPitchStat2d::MakePitchSpace(int x, int y)
{
    return SetSize(x / 16 + 4, y / 16 + 4);// Pitch Á¤º¸´Â 16 byte¿¡ Çѹø¾¿ ÀúÀåÇÔ.
}
 
BOOL CPitchStat2d::CheckPitch2d(BYTE *pData, int dataWidth, int height, CRect &rect, stPitchParam &param)
{
    //  interval °ú dist¸¦ 16ÀÇ ¹è¼ö·Î ¸¸µç´Ù.
    int dist = param.Dist;
    int interval = param.Interval;
    interval = interval >> 4 << 4;    if (interval < 16) interval = 16;
    dist = dist >> 4 << 4;            if (dist < 16) dist = 16;
 
    m_bPitchMade = FALSE;
    m_Rect = rect;
 
    MakePitchSpace(dataWidth, height);
 
    int start, end;
    int start2, end2;
    int basePitch;
    int pitch16;
    int iPitch, spr;
    int xTimes, yTimes;
 
    basePitch = pitch16 = _DI16(param.PitchStart);
 
    if (param.Direction == stPitchParam::PP_HORIZONTAL)
    {
        ResetConvBuff(rect.Width());
 
        m_xInterval = interval;
        m_yInterval = dist;
 
        xTimes = interval >> 4;// 32 Pixel¿¡ Çѹø Ã£´Â´Ù¸é, Çѹø¿¡ 2°³¾¿ ÀúÀåÇØ¾ßÇÔ(data´Â 16 Çȼ¿¿¡ Çѹø¾¿ Ã¤¿ò)
        yTimes = dist >> 4;
        start = rect.left;
        end = (int)(rect.right - param.Width - param.PitchEnd - interval);
        start2 = rect.top;
        end2 = rect.bottom - param.Height - dist;
        CAssemUtil::CheckPitchSmall16(pitch16, _DI16(param.GetPitchRange()), rect.left, rect.top, param.Width, param.Height, pData, dataWidth, param.ZeroBack, pitch16, iPitch, spr);
 
        //AddPitch(start, start2, pitch16);
        int x, y;
        for (y = start2; y < end2; y += dist)
        {
            for (x = start; x < end; x += interval)
            {
                CAssemUtil::CheckPitchSmall16(pitch16, 1, x, y, param.Width, param.Height, pData, dataWidth, param.ZeroBack, pitch16, iPitch, spr);
                AddPitch(x, y, pitch16, xTimes, yTimes);
            }
        }
        VerifyPitch(start, x - interval, start2, y - dist, 1600, 1600);
        m_bPitchMade = TRUE;
        return m_bPitchMade;
    }
 
    // 
    ResetConvBuff(rect.Height());
 
    start = rect.top;
    end = (int)(rect.bottom - param.Height - param.PitchEnd - interval);
    start2 = rect.left;
    end2 = rect.right - param.Width - dist;
 
    CAssemUtil::CheckPitchSmallVert16(pitch16, _DI16(param.GetPitchRange()), rect.left, rect.top, param.Width, param.Height, pData, dataWidth, param.ZeroBack, pitch16, iPitch, spr);
 
    m_xInterval = dist;
    m_yInterval = interval;
    xTimes = dist >> 4;
    yTimes = interval >> 4;// 32 Pixel¿¡ Çѹø Ã£´Â´Ù¸é, Çѹø¿¡ 2°³¾¿ ÀúÀåÇØ¾ßÇÔ(data´Â 16 Çȼ¿¿¡ Çѹø¾¿ ÀúÀå)
    for (int x = start2; x < end2; x += dist)
    {
        for (int y = start; y < end; y += interval)
        {
            CAssemUtil::CheckPitchSmallVert16(pitch16, _DI16(param.GetPitchRange()), x, y, param.Width, param.Height, pData, dataWidth, param.ZeroBack, pitch16, iPitch, spr);
            AddPitch(x, y, pitch16, xTimes, yTimes);
        }
    }
    VerifyPitch(start, end, start2, end2, 16, 16);
    m_bPitchMade = TRUE;
    return TRUE;
}