a
This commit is contained in:
@@ -0,0 +1,302 @@
|
||||
// MediumStrongGradient.cpp: implementation of the CMediumStrongGradient class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geomative.h"
|
||||
#include "MediumStrongGradient.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
extern int g_iUILanguage;
|
||||
CMediumStrongGradient::CMediumStrongGradient(int iAR): CMedium(iAR)
|
||||
{
|
||||
|
||||
}
|
||||
CMediumStrongGradient::~CMediumStrongGradient()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CMediumStrongGradient::SetParamVal(const void* pVal)
|
||||
{
|
||||
m_bStrongGradient = *(BYTE*)pVal;
|
||||
}
|
||||
|
||||
float CMediumStrongGradient::CalculateSptKVal(int iM, int iN)
|
||||
{
|
||||
float fK = (float)VAL_ZERO;
|
||||
fK = (float)(2 * VAL_PI*(iN - iM));
|
||||
return fK;
|
||||
}
|
||||
|
||||
float CMediumStrongGradient::CalculateCESptKVal(float fA, float fB, float fX, float fY)
|
||||
{
|
||||
float fAM = fabs(fX - fA);
|
||||
float fAN = fabs(fY - fA);
|
||||
float fBM = fabs(fB - fX);
|
||||
float fBN = fabs(fB - fY);
|
||||
if (0 == fAM || 0 == fAN || 0 == fBM || 0 == fBN)
|
||||
{
|
||||
return 0;
|
||||
// AfxMessageBox(_T("Calcualte K value error.value = "))
|
||||
}
|
||||
return fabs(2 * VAL_PI / (1.0 / fAM - 1.0 / fAN - 1.0 / fBM + 1.0 / fBN));
|
||||
}
|
||||
|
||||
int CMediumStrongGradient::CalculateSptLevel(int iM, int iN)
|
||||
{
|
||||
return iN - iM;
|
||||
}
|
||||
|
||||
bool CMediumStrongGradient::GenerateSptRecElecVal(int iEAmount, int* pMaxLevel, int* pPtAmount, CPtrArray* pSptRecArray)
|
||||
{
|
||||
if (NULL == pSptRecArray)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("pSptRecArray不能为空!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("pSptRecArray can't be NULL!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
pSptRecArray->RemoveAll();
|
||||
|
||||
int i =0,j = 0;
|
||||
int a = 1;
|
||||
int iIndex = 0;
|
||||
int iMaxLevel = 0;
|
||||
const int iMaxA = 3; //a取值1~3
|
||||
const int iFixedNValue = (iEAmount-1)/8; //n固定10
|
||||
//const int iMaxS = 4;//S的意思是AB最多移動四次
|
||||
const int iMaxS = 4;//S的意思是AB每次移动四个电极
|
||||
CString strLog;
|
||||
//只考虑a=1的情况即MN=1 P1P2=1
|
||||
//OutputDebugString(_T("打印新装置测点\n"));
|
||||
CSptRecord* pSptRec = NULL;
|
||||
//int iC1 = 3, iC2 = 6, iP1 = 1, iP2 = 2;
|
||||
int iC1 = 1, iC2 = 4, iP1 = 2, iP2 = 3;
|
||||
int iTempC1 = iC1;
|
||||
//strLog.Format(_T("\n\n----------------------iFixedNValue取值%d\n"), iFixedNValue);
|
||||
//OutputDebugString(strLog);
|
||||
//正序遍历
|
||||
for (a = 1; a <= iMaxA; a++)
|
||||
{
|
||||
iC1 = iTempC1;//a值修改,第二轮巡
|
||||
strLog.Format(_T("A点取值%d,a=%d\n"), iC1,a);
|
||||
OutputDebugString(strLog);
|
||||
for (iC2 = iC1 + (iFixedNValue + 2)*a; iC2 <= iEAmount;) //B点轮循环
|
||||
{
|
||||
strLog.Format(_T("B点取值iC1=%d,iC2=%d %d+(%d+2)*%d=%d\n"), iC1, iC2, iC1, iFixedNValue, a, (iFixedNValue + 2)*a);
|
||||
OutputDebugString(strLog);
|
||||
for (iP1 = 1; iP1 <= iEAmount - a; iP1++)
|
||||
{
|
||||
if ((iP1 + a) == iC2 || (iP1 + a) == iC1 || iP1 == iC1 || iP1 == iC2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//MN均小于A点
|
||||
if (iP1+a < iC1)
|
||||
{
|
||||
for (iP1 = 1; iP1 + a < iC1; iP1++)
|
||||
{
|
||||
iP2 = iP1 + a;
|
||||
strLog.Format(_T("MN均小于A点index=%d A=%d,B=%d,M=%d,N=%d\n"), ++iIndex, iC1, iC2, iP1, iP2);
|
||||
OutputDebugString(strLog);
|
||||
pSptRec = new CSptRecord();
|
||||
pSptRec->m_iC1 = iC1;
|
||||
pSptRec->m_iC2 = iC2;
|
||||
pSptRec->m_iP1 = iP1;
|
||||
pSptRec->m_iP2 = iP2;
|
||||
pSptRec->m_iN = 1;
|
||||
pSptRec->m_fK = CalculateCESptKVal(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
pSptRec->m_iLevel = 1;// CalculateSptLevel(pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
pSptRec->m_fSptXPos = GetUniSptXPos(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
if (iMaxLevel < pSptRec->m_iLevel)
|
||||
{
|
||||
iMaxLevel = pSptRec->m_iLevel;
|
||||
}
|
||||
pSptRec->m_bIsSel = TRUE;
|
||||
pSptRec->m_iTsn = iIndex;
|
||||
pSptRecArray->Add(pSptRec);
|
||||
}
|
||||
}
|
||||
|
||||
//MN大于A点,小于B点
|
||||
if (iP1 > iC1 && iP1 + a < iC2)
|
||||
{
|
||||
for (iP1 = iC1 + 1; iP1 < iC2 - a; iP1++)
|
||||
{
|
||||
iP2 = iP1 + a;
|
||||
strLog.Format(_T("MN在AB之间index=%d A=%d,B=%d,M=%d,N=%d\n"), ++iIndex, iC1, iC2, iP1, iP2);
|
||||
OutputDebugString(strLog);
|
||||
pSptRec = new CSptRecord();
|
||||
pSptRec->m_iC1 = iC1;
|
||||
pSptRec->m_iC2 = iC2;
|
||||
pSptRec->m_iP1 = iP1;
|
||||
pSptRec->m_iP2 = iP2;
|
||||
pSptRec->m_iN = 1;
|
||||
pSptRec->m_fK = CalculateCESptKVal(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
pSptRec->m_iLevel = 1;// CalculateSptLevel(pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
pSptRec->m_fSptXPos = GetUniSptXPos(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
if (iMaxLevel < pSptRec->m_iLevel)
|
||||
{
|
||||
iMaxLevel = pSptRec->m_iLevel;
|
||||
}
|
||||
pSptRec->m_bIsSel = TRUE;
|
||||
pSptRec->m_iTsn = iIndex;
|
||||
pSptRecArray->Add(pSptRec);
|
||||
}
|
||||
}
|
||||
|
||||
//MN大于B点
|
||||
if (iP1 > iC2)
|
||||
{
|
||||
for (iP1 = iC2 + 1; iP1 + a <= iEAmount; iP1++)
|
||||
{
|
||||
iP2 = iP1 + a;
|
||||
strLog.Format(_T("MN大于B点index=%d A=%d,B=%d,M=%d,N=%d\n"), ++iIndex, iC1, iC2, iP1, iP2);
|
||||
OutputDebugString(strLog);
|
||||
pSptRec = new CSptRecord();
|
||||
pSptRec->m_iC1 = iC1;
|
||||
pSptRec->m_iC2 = iC2;
|
||||
pSptRec->m_iP1 = iP1;
|
||||
pSptRec->m_iP2 = iP2;
|
||||
pSptRec->m_iN = 1;
|
||||
pSptRec->m_fK = CalculateCESptKVal(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
pSptRec->m_iLevel = 1;// CalculateSptLevel(pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
pSptRec->m_fSptXPos = GetUniSptXPos(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
if (iMaxLevel < pSptRec->m_iLevel)
|
||||
{
|
||||
iMaxLevel = pSptRec->m_iLevel;
|
||||
}
|
||||
pSptRec->m_bIsSel = TRUE;
|
||||
pSptRec->m_iTsn = iIndex;
|
||||
pSptRecArray->Add(pSptRec);
|
||||
}
|
||||
}
|
||||
}
|
||||
//iC1 = iC1+iMaxS;//每次平移4个电极
|
||||
iC1 = iC2;
|
||||
iC2 = iC1 + (iFixedNValue + 2)*a;
|
||||
}
|
||||
}
|
||||
|
||||
//反序遍历
|
||||
if (m_bStrongGradient != 0)
|
||||
{
|
||||
int iTempC2 = iC2 = iEAmount;
|
||||
for (a = 1; a <= iMaxA; a++)
|
||||
{
|
||||
iC2 = iTempC2;//a值修改,第二轮巡
|
||||
//strLog.Format(_T("A点取值%d,a=%d\n"), iC2, a);
|
||||
//OutputDebugString(strLog);
|
||||
for (iC1 = iC2 - (iFixedNValue + 2)*a; iC1 >= 1;)
|
||||
{
|
||||
//iTempSCount++;
|
||||
//strLog.Format(_T("B点取值iC1=%d,iC2=%d %d+(%d+2)*%d=%d\n"), iC1, iC2, iC1, iFixedNValue, a, (iFixedNValue + 2)*a);
|
||||
//OutputDebugString(strLog);
|
||||
for (iP1 = iEAmount - a; iP1 >= 1; iP1--)
|
||||
{
|
||||
if ((iP1 - a) == iC2 || (iP1 - a) == iC1 || iP1 == iC1 || iP1 == iC2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//MN均小于A点
|
||||
if (iP1 + a < iC1)
|
||||
{
|
||||
for (iP1 = iC1 - 1 - a; iP1 >= 1; iP1--)
|
||||
{
|
||||
iP2 = iP1 + a;
|
||||
strLog.Format(_T("MN均小于A点index=%d A=%d,B=%d,M=%d,N=%d\n"), ++iIndex, iC1, iC2, iP1, iP2);
|
||||
OutputDebugString(strLog);
|
||||
pSptRec = new CSptRecord();
|
||||
pSptRec->m_iC1 = iC1;
|
||||
pSptRec->m_iC2 = iC2;
|
||||
pSptRec->m_iP1 = iP1;
|
||||
pSptRec->m_iP2 = iP2;
|
||||
pSptRec->m_iN = 1;
|
||||
pSptRec->m_fK = CalculateCESptKVal(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
pSptRec->m_iLevel = 1;// CalculateSptLevel(pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
pSptRec->m_fSptXPos = GetUniSptXPos(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
if (iMaxLevel < pSptRec->m_iLevel)
|
||||
{
|
||||
iMaxLevel = pSptRec->m_iLevel;
|
||||
}
|
||||
pSptRec->m_bIsSel = TRUE;
|
||||
pSptRec->m_iTsn = iIndex;
|
||||
pSptRecArray->Add(pSptRec);
|
||||
}
|
||||
}
|
||||
|
||||
//MN大于A点,小于B点
|
||||
if (iP1 > iC1 && iP1 + a < iC2)
|
||||
{
|
||||
for (iP1 = iC2 - a - 1; iP1 > iC1; iP1--)
|
||||
{
|
||||
iP2 = iP1 + a;
|
||||
strLog.Format(_T("MN在AB之间index=%d A=%d,B=%d,M=%d,N=%d\n"), ++iIndex, iC1, iC2, iP1, iP2);
|
||||
OutputDebugString(strLog);
|
||||
pSptRec = new CSptRecord();
|
||||
pSptRec->m_iC1 = iC1;
|
||||
pSptRec->m_iC2 = iC2;
|
||||
pSptRec->m_iP1 = iP1;
|
||||
pSptRec->m_iP2 = iP2;
|
||||
pSptRec->m_iN = 1;
|
||||
pSptRec->m_fK = CalculateCESptKVal(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
pSptRec->m_iLevel = 1;// CalculateSptLevel(pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
pSptRec->m_fSptXPos = GetUniSptXPos(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
if (iMaxLevel < pSptRec->m_iLevel)
|
||||
{
|
||||
iMaxLevel = pSptRec->m_iLevel;
|
||||
}
|
||||
pSptRec->m_bIsSel = TRUE;
|
||||
pSptRec->m_iTsn = iIndex;
|
||||
pSptRecArray->Add(pSptRec);
|
||||
}
|
||||
}
|
||||
|
||||
//MN大于B点
|
||||
if (iP1 > iC2)
|
||||
{
|
||||
for (iP1 = iEAmount - a; iP1 > iC2; iP1--)
|
||||
{
|
||||
iP2 = iP1 + a;
|
||||
strLog.Format(_T("MN大于B点index=%d A=%d,B=%d,M=%d,N=%d\n"), ++iIndex, iC1, iC2, iP1, iP2);
|
||||
OutputDebugString(strLog);
|
||||
pSptRec = new CSptRecord();
|
||||
pSptRec->m_iC1 = iC1;
|
||||
pSptRec->m_iC2 = iC2;
|
||||
pSptRec->m_iP1 = iP1;
|
||||
pSptRec->m_iP2 = iP2;
|
||||
pSptRec->m_iN = 1;
|
||||
pSptRec->m_fK = CalculateCESptKVal(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
pSptRec->m_iLevel = 1;// CalculateSptLevel(pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
pSptRec->m_fSptXPos = GetUniSptXPos(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
|
||||
if (iMaxLevel < pSptRec->m_iLevel)
|
||||
{
|
||||
iMaxLevel = pSptRec->m_iLevel;
|
||||
}
|
||||
pSptRec->m_bIsSel = TRUE;
|
||||
pSptRec->m_iTsn = iIndex;
|
||||
pSptRecArray->Add(pSptRec);
|
||||
}
|
||||
}
|
||||
}
|
||||
//iC1 = iC1+iMaxS;//每次平移4个电极
|
||||
iC2 = iC1;
|
||||
iC1 = iC2 - (iFixedNValue + 2)*a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*pMaxLevel = iMaxLevel;
|
||||
*pPtAmount = pSptRecArray->GetSize();
|
||||
}
|
||||
Reference in New Issue
Block a user