807 lines
21 KiB
C++
807 lines
21 KiB
C++
// MediumK.cpp: implementation of the CMediumK class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "geomative.h"
|
|
#include "MediumK.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
|
|
typedef struct ST_LAYER_ORDER_INDEX
|
|
{
|
|
int iLayer;
|
|
std::vector<int> vtIndex;
|
|
ST_LAYER_ORDER_INDEX()
|
|
{
|
|
iLayer = 0;
|
|
vtIndex.clear();
|
|
}
|
|
|
|
}STlayerOrderIndex;
|
|
|
|
extern int g_iUILanguage;
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
CMediumK::CMediumK(int iAR): CMedium(iAR)
|
|
{
|
|
m_fEOffsetR = 1;
|
|
m_fLOffsetR = 1;
|
|
m_iMNCtrlMethod = 0;
|
|
m_iMNSpace = 1;
|
|
}
|
|
|
|
CMediumK::~CMediumK()
|
|
{
|
|
|
|
}
|
|
|
|
bool CMediumK::GenerateSptRecElecVal(int iEAmount, //电极总数---in
|
|
int* pMaxLevel, //最大层---out
|
|
int* pPtAmount, //测点总数---out
|
|
CPtrArray* pSptRecArray //脚本记录集---out
|
|
) //函数功能:生成脚本电极记录集合
|
|
{
|
|
if (iEAmount < 1)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("Schlumberger中EA_MOUNT的数目为错误!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("The number of EA_MOUNT in Schlumberger is error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return false;
|
|
}
|
|
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;
|
|
}
|
|
|
|
if (1 == m_iMNCtrlMethod)
|
|
{
|
|
return GenerateSptRecElecVal_New(iEAmount, pMaxLevel, pPtAmount, pSptRecArray);
|
|
}
|
|
int iEqualValMove = (int)VAL_ZERO;
|
|
int iMaxSpace = (int)VAL_ZERO;
|
|
int iSpace = (int)VAL_ZERO;
|
|
int iTsn = (int)VAL_ZERO;
|
|
|
|
int iAVal = (int)VAL_ZERO;
|
|
int iBVal = (int)VAL_ZERO;
|
|
int iMVal = (int)VAL_ZERO;
|
|
int iNVal = (int)VAL_ZERO;
|
|
|
|
int iMAVal = (int)VAL_ZERO;
|
|
int iMMVal = (int)VAL_ZERO;
|
|
int iMNVal = (int)VAL_ZERO;
|
|
int iMBVal = (int)VAL_ZERO;
|
|
|
|
int iMMove = (int)VAL_ZERO;
|
|
int iAMove = (int)VAL_ZERO;
|
|
|
|
int iTotalMove = (int)VAL_ZERO;
|
|
|
|
int iMaxLevel = (int)VAL_ZERO;
|
|
|
|
CSptRecord* pSptRecord = NULL;
|
|
CString str = _T("");
|
|
|
|
iTotalMove = iEAmount / 2;
|
|
|
|
for (iMMVal = 2; iMMVal <= iTotalMove; iMMVal++)
|
|
{
|
|
iMAVal = 1;
|
|
iMNVal= iMMVal + m_iMNSpace;
|
|
iMBVal = iMNVal + iMMVal - iMAVal;
|
|
if (iMBVal > iEAmount)
|
|
{
|
|
break;
|
|
}
|
|
|
|
iAVal = iMAVal;
|
|
iMVal = iMMVal;
|
|
iNVal = iMNVal;
|
|
iBVal = iMBVal;
|
|
|
|
pSptRecord = NULL;
|
|
pSptRecord = new CSptRecord;
|
|
if (NULL != pSptRecord)
|
|
{
|
|
pSptRecord->m_iC1 = iAVal;
|
|
pSptRecord->m_iC2 = iBVal;
|
|
pSptRecord->m_iP1 = iMVal;
|
|
pSptRecord->m_iP2 = iNVal;
|
|
pSptRecord->m_iTsn = ++iTsn;
|
|
pSptRecord->m_fK = CalculateSptKVal(iAVal, iMVal, iNVal);
|
|
pSptRecord->m_iLevel = CalculateSptLevel(iAVal, iMVal);
|
|
pSptRecord->m_iPtNum = iAVal;
|
|
pSptRecord->m_colorREF = RGB(0, 255, 0);
|
|
pSptRecord->m_bIsSel = TRUE;
|
|
pSptRecord->m_iN = (int)VAL_ONE;
|
|
|
|
CalculateSptPtLoc(2, pSptRecord);
|
|
|
|
pSptRecArray->Add(pSptRecord);
|
|
|
|
if (pSptRecord->m_iLevel > iMaxLevel)
|
|
{
|
|
iMaxLevel = pSptRecord->m_iLevel;
|
|
}
|
|
}
|
|
|
|
while (iBVal < iEAmount)
|
|
{
|
|
iAVal++;
|
|
iNVal++;
|
|
iBVal++;
|
|
iMVal++;
|
|
|
|
pSptRecord = NULL;
|
|
pSptRecord = new CSptRecord;
|
|
|
|
if (NULL != pSptRecord)
|
|
{
|
|
pSptRecord->m_iC1 = iAVal;
|
|
pSptRecord->m_iC2 = iBVal;
|
|
pSptRecord->m_iP1 = iMVal;
|
|
pSptRecord->m_iP2 = iNVal;
|
|
pSptRecord->m_iTsn = ++iTsn;
|
|
pSptRecord->m_fK = CalculateSptKVal(iAVal, iMVal, iNVal);
|
|
pSptRecord->m_iLevel = CalculateSptLevel(iAVal, iMVal);
|
|
pSptRecord->m_iPtNum = iAVal;
|
|
pSptRecord->m_colorREF = RGB(0, 255, 0);
|
|
pSptRecord->m_bIsSel = TRUE;
|
|
|
|
pSptRecord->m_iN = (int)VAL_ONE;
|
|
|
|
CalculateSptPtLoc(2, pSptRecord);
|
|
|
|
pSptRecArray->Add(pSptRecord);
|
|
|
|
if (pSptRecord->m_iLevel > iMaxLevel)
|
|
{
|
|
iMaxLevel = pSptRecord->m_iLevel;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
*pMaxLevel = iMaxLevel;
|
|
|
|
*pPtAmount = pSptRecArray->GetSize();
|
|
|
|
return true;
|
|
}
|
|
|
|
float CMediumK::CalculateSptKVal(int iA, int iM, int iN)
|
|
{
|
|
float fK = (float)VAL_ZERO;
|
|
float fSpace = (float)VAL_ZERO;
|
|
|
|
fSpace = (iM-iA)*1.0/(iN-iM);
|
|
|
|
fK = (float)VAL_PI*fSpace*(fSpace+1)*(iN-iM);
|
|
return fK;
|
|
}
|
|
|
|
float CMediumK::CalculateCESptKVal(float fA, float fB, float fX, float fY)
|
|
{
|
|
return 0.0;
|
|
}
|
|
|
|
int CMediumK::CalculateSptLevel(int iA, int iM)
|
|
{
|
|
return iM-iA;
|
|
}
|
|
|
|
void CMediumK::CalculateSptPtLoc(int iMul, //倍数---in
|
|
CSptRecord* pSptRecord //脚本记录指针---out
|
|
) //函数功能:计算脚本测点位置
|
|
{
|
|
|
|
int iOffsetL = (int)VAL_ZERO;
|
|
int iOffsetR = (int)VAL_ZERO;
|
|
|
|
int iLevel = pSptRecord->m_iLevel;
|
|
int iPtNum = pSptRecord->m_iPtNum;
|
|
int iMN = pSptRecord->m_iP2 - pSptRecord->m_iP1;
|
|
|
|
//Auto模式
|
|
if (m_iIsolationLayers > 0)
|
|
iOffsetL = (6 + 2)*iMul + 50 + 4 * iMul*(iLevel - 1 - (iLevel-1)/m_iIsolationLayers) * 2 + (iMul - 2) + ((iMN - 1) / 2)*(6 + 2)*iMul;
|
|
//Fixed模式
|
|
else
|
|
iOffsetL = (6 + 2)*iMul + 50 + 4 * iMul*(iLevel - 1) * 2 + (iMul - 2) + ((iMN - 1) / 2)*(6 + 2)*iMul;
|
|
iOffsetR = iOffsetL+6*iMul;
|
|
|
|
pSptRecord->m_recPtArea.left = iOffsetL+(6+2)*iMul*(iPtNum-1);
|
|
pSptRecord->m_recPtArea.top = 50+(6+2)*iMul*(iLevel-1);
|
|
pSptRecord->m_recPtArea.right = iOffsetR+(6+2)*iMul*(iPtNum-1);
|
|
pSptRecord->m_recPtArea.bottom = (50+6*iMul)+(6+2)*iMul*(iLevel-1);
|
|
|
|
pSptRecord->m_fPtCenterX = (float)(iOffsetL+(6+2)*iMul*(iPtNum-1) + ((iOffsetR+(6+2)*iMul*(iPtNum-1)) - (iOffsetL+(6+2)*iMul*(iPtNum-1))) / 2);
|
|
pSptRecord->m_fPtCenterY = (float)(50+(6+2)*iMul*(iLevel-1) + (((50+6*iMul)+(6+2)*iMul*(iLevel-1)) - (50+(6+2)*iMul*(iLevel-1))) / 2);
|
|
pSptRecord->m_fPtRadius = (float)(abs((int)(pSptRecord->m_fPtCenterX) - pSptRecord->m_recPtArea.left));
|
|
}
|
|
|
|
|
|
int CMediumK::CalculateRecPosInlevel(int iA)
|
|
{
|
|
return iA;
|
|
}
|
|
|
|
|
|
int CMediumK::GenSptRecLevel(int iA, int iB, int iM, int iN)
|
|
{
|
|
return CalculateSptLevel(iA, iM);
|
|
}
|
|
|
|
int CMediumK::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
|
|
{
|
|
return CalculateRecPosInlevel(iA);
|
|
}
|
|
|
|
int CMediumK::GetMaxLevelByEAmount(int iEAmount)
|
|
{
|
|
if (1 == m_iMNCtrlMethod)
|
|
{
|
|
int iC1Pos,iC2Pos,iP1Pos,iP2Pos;
|
|
int iLayer = 0;
|
|
//AM的距离就是层数,MN的距离每隔6层增加 2个电极间距
|
|
while(TRUE)
|
|
{
|
|
iLayer++;
|
|
iC1Pos = 1;
|
|
iP1Pos = iC1Pos + iLayer;
|
|
iP2Pos = iP1Pos + 1 + ((iLayer-1)/6)*2;
|
|
iC2Pos = iP2Pos + iLayer ;
|
|
if (iC2Pos > iEAmount)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
return iLayer - 1;
|
|
}
|
|
// if (((iEAmount%12) == 0) && (0 != iEAmount))
|
|
// {
|
|
// return 5+(iEAmount/12-1)*6;
|
|
// }
|
|
// return 0;
|
|
//根据排列来推算,假设最大层数为x,那么此时收个1+x+1+x = iEAmount时,x即为最大层数
|
|
//由于x为整数,所以对此表达式取整即为最大层数
|
|
if (iEAmount > 0)
|
|
return (int)((iEAmount-2)/2);
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
void CMediumK::ReSortPoint(CPtrArray *f_ptr)
|
|
{
|
|
//在同一层内,取中点作为间隔点,左右两边分别跑跑,跑完后在取中间点
|
|
//例如总共有5个点时,序号分别为1-5,此时的跑极顺序为1,4,2,5,3
|
|
//在不同层时,按照层数的从小到大进行跑极
|
|
|
|
CSptRecord *pSptRecord = NULL;
|
|
CSptRecord *pTmp = NULL;
|
|
int iMaxLevel = ((CSptRecord *)(f_ptr->GetAt(f_ptr->GetSize()-1)))->m_iLevel;
|
|
if (0 == iMaxLevel)
|
|
{
|
|
return;
|
|
}
|
|
int nPreCnt = 0;
|
|
std::vector<STlayerOrderIndex> vtLayerOrderInfo;
|
|
vtLayerOrderInfo.clear();
|
|
|
|
int i = 1;
|
|
for (; i <= iMaxLevel; i++)
|
|
{
|
|
int nCurLayerCnt = 0;
|
|
for (int j = nPreCnt; j < f_ptr->GetSize(); j++)
|
|
{
|
|
pTmp = (CSptRecord*)(f_ptr->GetAt(j));
|
|
if (i == pTmp->m_iLevel)
|
|
{
|
|
nCurLayerCnt++;
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
//首先进行每一层的从中间依次往左右的排序
|
|
STlayerOrderIndex stLayerOrder;
|
|
stLayerOrder.iLayer = 1;
|
|
stLayerOrder.vtIndex.clear();
|
|
bool bIsOdd = (nCurLayerCnt %2 == 0) ? false : true;
|
|
int iMidIndex = 0;
|
|
if (bIsOdd)
|
|
{
|
|
iMidIndex = (nCurLayerCnt+1)/2;
|
|
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex-1);
|
|
for (int iIndex = 1; iIndex <iMidIndex; iIndex++)
|
|
{
|
|
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex-iIndex-1);
|
|
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex+iIndex-1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
iMidIndex = nCurLayerCnt/2;
|
|
for (int iIndex = 1; iIndex <= iMidIndex; iIndex++)
|
|
{
|
|
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex-(iIndex-1)-1);
|
|
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex+iIndex-1);
|
|
}
|
|
}
|
|
vtLayerOrderInfo.push_back(stLayerOrder);
|
|
nPreCnt += nCurLayerCnt;
|
|
}
|
|
CPtrArray newPtArr;
|
|
newPtArr.RemoveAll();
|
|
int iMaxIndex = vtLayerOrderInfo[0].vtIndex.size();
|
|
//然后将每次排好序的序号根据层从小到大从每层选取一个排好序的点加入到新的链表中,直到取完每层所有的点
|
|
for (int iIndex = 0; iIndex < iMaxIndex; iIndex++)
|
|
{
|
|
for (i = 1; i <= iMaxLevel; i++)
|
|
{
|
|
int iSize = vtLayerOrderInfo[i-1].vtIndex.size()-1;
|
|
if (iIndex > iSize)
|
|
{
|
|
continue;
|
|
}
|
|
int iOrderIndex = vtLayerOrderInfo[i-1].vtIndex[iIndex];
|
|
pSptRecord = (CSptRecord*)f_ptr->GetAt(iOrderIndex);
|
|
newPtArr.Add(pSptRecord);
|
|
}
|
|
}
|
|
|
|
if (newPtArr.GetSize() != f_ptr->GetSize())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("数据重排错误!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Resort data error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return;
|
|
}
|
|
f_ptr->RemoveAll();
|
|
int iTsn = 0;
|
|
for (int k = 0; k < newPtArr.GetSize(); k++)
|
|
{
|
|
pSptRecord = (CSptRecord*)newPtArr.GetAt(k);
|
|
pSptRecord->m_iTsn = ++iTsn;
|
|
f_ptr->Add(pSptRecord);
|
|
}
|
|
}
|
|
|
|
/*
|
|
void CMediumK::ReSortPoint(CPtrArray *f_ptr)
|
|
{
|
|
//在同一层内,取中点作为间隔点,左右两边分别跑跑,跑完后在取中间点
|
|
//例如总共有5个点时,序号分别为1-5,此时的跑极顺序为1,4,2,5,3
|
|
//在不同层时,按照层数的从小到大进行跑极
|
|
|
|
CSptRecord *pSptRecord = NULL;
|
|
CSptRecord *pTmp = NULL;
|
|
CPtrArray newPtArr;
|
|
newPtArr.RemoveAll();
|
|
int iMaxLevel = ((CSptRecord *)(f_ptr->GetAt(f_ptr->GetSize()-1)))->m_iLevel;
|
|
if (0 == iMaxLevel)
|
|
{
|
|
return;
|
|
}
|
|
int nPreCnt = 0;
|
|
for (int i = 1; i <= iMaxLevel; i++)
|
|
{
|
|
int nCurLayerCnt = 0;
|
|
for (int j = nPreCnt; j < f_ptr->GetSize(); j++)
|
|
{
|
|
pTmp = (CSptRecord*)(f_ptr->GetAt(j));
|
|
if (i == pTmp->m_iLevel)
|
|
{
|
|
nCurLayerCnt++;
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
bool bIsOdd = (nCurLayerCnt %2 == 0) ? false : true;
|
|
int iMidIndex = (nCurLayerCnt+1)/2;
|
|
int iMidDataCnt = (bIsOdd == true) ? iMidIndex : iMidIndex+1;
|
|
for (int iIndex = 1; iIndex <iMidDataCnt; iIndex++)
|
|
{
|
|
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+iIndex-1));
|
|
newPtArr.Add(pSptRecord);
|
|
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+iIndex+iMidIndex-1));
|
|
newPtArr.Add(pSptRecord);
|
|
}
|
|
//如果是奇数的话,则需要加上中间的点
|
|
if (bIsOdd)
|
|
{
|
|
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+iMidIndex-1));
|
|
newPtArr.Add(pSptRecord);
|
|
}
|
|
|
|
nPreCnt += nCurLayerCnt;
|
|
}
|
|
if (newPtArr.GetSize() != f_ptr->GetSize())
|
|
{
|
|
AfxMessageBox(_T("resort data error!"));
|
|
return;
|
|
}
|
|
f_ptr->RemoveAll();
|
|
for (int k = 0; k < newPtArr.GetSize(); k++)
|
|
{
|
|
pSptRecord = (CSptRecord*)newPtArr.GetAt(k);
|
|
pSptRecord->m_iTsn = k+1;
|
|
f_ptr->Add(pSptRecord);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void CMediumK::ReSortPoint(CPtrArray *f_ptr)
|
|
{
|
|
// 1、每层,间隔3个点进行测试,测试完成后返回到前面未测试的点,再继续间隔三个点进行测试。本层测试完成后,再测试下一层。
|
|
// 2、当某层的点数,少于7个点时。先测两边的点,再测试中间的点。逐渐往中间靠拢。
|
|
|
|
CSptRecord *pSptRecord = NULL;
|
|
CSptRecord *pTmp = NULL;
|
|
CPtrArray newPtArr;
|
|
newPtArr.RemoveAll();
|
|
int iMaxLevel = ((CSptRecord *)(f_ptr->GetAt(f_ptr->GetSize()-1)))->m_iLevel;
|
|
if (0 == iMaxLevel)
|
|
{
|
|
return;
|
|
}
|
|
int nPreCnt = 0;
|
|
for (int i = 1; i <= iMaxLevel; i++)
|
|
{
|
|
int nCurLayerCnt = 0;
|
|
for (int j = nPreCnt; j < f_ptr->GetSize(); j++)
|
|
{
|
|
pTmp = (CSptRecord*)(f_ptr->GetAt(j));
|
|
if (i == pTmp->m_iLevel)
|
|
{
|
|
nCurLayerCnt++;
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
//如果小于7个点,则从两端靠近
|
|
//int nTmpTsn = 0;
|
|
if (nCurLayerCnt < 7)
|
|
{
|
|
int nCnt = (nCurLayerCnt+1)/2;
|
|
|
|
for (int iIndex = 1; iIndex <= nCnt; iIndex++)
|
|
{
|
|
if (iIndex == nCnt)
|
|
{
|
|
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+iIndex-1));
|
|
newPtArr.Add(pSptRecord);
|
|
|
|
//pSptRecord->m_iTsn = nPreCnt + (++nTmpTsn);
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+iIndex-1));
|
|
newPtArr.Add(pSptRecord);
|
|
//pSptRecord->m_iTsn = nPreCnt + (++nTmpTsn);
|
|
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+nCurLayerCnt-iIndex));
|
|
newPtArr.Add(pSptRecord);
|
|
//pSptRecord->m_iTsn = nPreCnt + (++nTmpTsn);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int iIndex = 1; iIndex <= 4; iIndex++)
|
|
{
|
|
int iTmpIndex = iIndex;
|
|
while(iTmpIndex <= nCurLayerCnt)
|
|
{
|
|
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+iTmpIndex-1));
|
|
newPtArr.Add(pSptRecord);
|
|
// pSptRecord->m_iTsn = nPreCnt + (++nTmpTsn);
|
|
iTmpIndex += 4;
|
|
}
|
|
}
|
|
}
|
|
nPreCnt += nCurLayerCnt;
|
|
}
|
|
if (newPtArr.GetSize() != f_ptr->GetSize())
|
|
{
|
|
AfxMessageBox(_T("resort data error!"));
|
|
return;
|
|
}
|
|
f_ptr->RemoveAll();
|
|
for (int k = 0; k < newPtArr.GetSize(); k++)
|
|
{
|
|
pSptRecord = (CSptRecord*)newPtArr.GetAt(k);
|
|
pSptRecord->m_iTsn = k+1;
|
|
f_ptr->Add(pSptRecord);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void CMediumK::ReSortPoint(CPtrArray *f_ptr)
|
|
{
|
|
CSptRecord *pSptRecord = NULL;
|
|
CSptRecord *pTmp = NULL;
|
|
|
|
int nTsn = 1;
|
|
|
|
int nStart = 0;
|
|
int nWidth = 0;
|
|
|
|
int nId = 0; //取得每一个元素
|
|
int nId_two = 0; //记录算法需要取得的测点序号
|
|
int nId_thr = 0; //记录算法循环的次数
|
|
|
|
for (nId = 0; nId < f_ptr->GetSize(); nId++)
|
|
{
|
|
pSptRecord = (CSptRecord*)f_ptr->GetAt(nId);
|
|
|
|
if (nId + 1 < f_ptr->GetSize())
|
|
{
|
|
pTmp = (CSptRecord*)f_ptr->GetAt(nId + 1);
|
|
}
|
|
else
|
|
{
|
|
//最后一个点不处理
|
|
continue;
|
|
}
|
|
|
|
nWidth++; //记录每行测点的数量
|
|
if (pSptRecord->m_iLevel != pTmp->m_iLevel)
|
|
{
|
|
nStart = nId - ( nWidth - 1 );//每一行的起点,nid索引为0起始
|
|
nTsn = nStart + 1; //TSN从每一行起点算起,nStart是索引
|
|
|
|
for (int n = 0; n < 3; n++)
|
|
{
|
|
nId_two = 0;
|
|
nId_thr = 0;
|
|
|
|
while(TRUE)
|
|
{
|
|
nId_two = n + 3 * nId_thr;
|
|
|
|
if (nId_two + 1 > nWidth) //索引跟宽度比较应该增加1
|
|
break;
|
|
|
|
pSptRecord = (CSptRecord*)f_ptr->GetAt(nId_two + nStart);
|
|
pSptRecord->m_iTsn = nTsn++;
|
|
nId_thr++;
|
|
}
|
|
}
|
|
|
|
//对数组中的元素全部重新进行排序
|
|
for (nStart; nStart < nId; nStart++)
|
|
{
|
|
pSptRecord = (CSptRecord *)f_ptr->GetAt(nStart);
|
|
|
|
if (pSptRecord->m_iTsn != nStart + 1)
|
|
{
|
|
for (int n = nStart + 1; n < f_ptr->GetSize(); n++)
|
|
{
|
|
pSptRecord = (CSptRecord *)f_ptr->GetAt(n);
|
|
|
|
if (pSptRecord->m_iTsn == nStart + 1)
|
|
{
|
|
f_ptr->InsertAt(nStart, pSptRecord);
|
|
f_ptr->RemoveAt(n + 1); //上一行代码插入一个元素,故 + 1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
nWidth = 0; //置0,记录下一行测点的数量
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
*/
|
|
bool CMediumK::GenerateSptRecElecVal_New(int iEAmount,
|
|
int* pMaxLevel,
|
|
int* pPtAmount,
|
|
CPtrArray* pSptRecArray)
|
|
{
|
|
|
|
pSptRecArray->RemoveAll();
|
|
int iC1Pos,iC2Pos,iP1Pos,iP2Pos;
|
|
int iTsn = 0;
|
|
CSptRecord *pSptRec = NULL;
|
|
int iLayer = 0;
|
|
int iSaveLastP1Pos = 0;
|
|
int iLayerGrowth = 0;
|
|
////////////////////modifyed by lsq 20160510//////////////////////////////////////////////////////
|
|
//AM的距离就是层数,MN的距离每隔6层增加 2个电极间距
|
|
CString strLog;
|
|
while(TRUE)
|
|
{
|
|
iLayer++;
|
|
//下一次开始计算
|
|
if ((iLayer > m_iIsolationLayers)
|
|
&& ((iLayer - 1) / m_iIsolationLayers != 0)
|
|
&& ((iLayer - 1) % m_iIsolationLayers == 0))//跳层
|
|
{
|
|
iC1Pos = 1;
|
|
iP1Pos = iSaveLastP1Pos;//当满足跳层时,AM等于上一个值.
|
|
}
|
|
else
|
|
{
|
|
iC1Pos = 1;
|
|
iLayerGrowth++;
|
|
iSaveLastP1Pos = iP1Pos = iC1Pos + iLayerGrowth;
|
|
}
|
|
iP2Pos = iP1Pos + 1 + ((iLayer - 1) / m_iIsolationLayers) * 2;
|
|
iC2Pos = iP2Pos + abs(iC1Pos - iP1Pos);//B = AM+N
|
|
|
|
if (iC2Pos > iEAmount)
|
|
{
|
|
break;
|
|
}
|
|
strLog.Format(_T("zm:Layer=%d,第一个点数据 A=%d,M=%d,N=%d,B=%d,\n"), iLayer, iC1Pos, iP1Pos, iP2Pos, iC2Pos);
|
|
OutputDebugString(strLog);
|
|
|
|
//确定好每一层的电极初始位置之后,开始横向往右测量,此时每测一次,电极向右平移1
|
|
while(iC2Pos <= iEAmount)
|
|
{
|
|
pSptRec = new CSptRecord();
|
|
pSptRec->m_iC1 = iC1Pos;
|
|
pSptRec->m_iC2 = iC2Pos;
|
|
pSptRec->m_iP1 = iP1Pos;
|
|
pSptRec->m_iP2 = iP2Pos;
|
|
pSptRec->m_fK = CalculateSptKVal(iC1Pos, iP1Pos, iP2Pos);
|
|
pSptRec->m_iPtNum = iC1Pos;
|
|
pSptRec->m_iLevel = iLayer;//GenSptRecLevel(iC1Pos, iC2Pos, iP1Pos, iP2Pos);
|
|
pSptRec->m_colorREF = RGB(0, 255, 0);
|
|
pSptRec->m_iN = 1;
|
|
pSptRec->m_bIsSel = TRUE;
|
|
pSptRec->m_iTsn = ++iTsn;
|
|
CalculateSptPtLoc(2, pSptRec);
|
|
pSptRecArray->Add(pSptRec);
|
|
//strLog.Format(_T("zm:TSN=%d,Layer=%d数据 A=%d,M=%d,N=%d,B=%d,\n"), iTsn, iLayer, iC1Pos, iP1Pos, iP2Pos, iC2Pos);
|
|
//OutputDebugString(strLog);
|
|
|
|
iC1Pos++;
|
|
iC2Pos++;
|
|
iP1Pos++;
|
|
iP2Pos++;
|
|
}
|
|
}
|
|
|
|
*pPtAmount = pSptRecArray->GetSize();
|
|
*pMaxLevel = iLayer-1;
|
|
return true;
|
|
|
|
}
|
|
|
|
void CMediumK::CalculateTdPtLoc(const CRect& vRect, const int& iEAmount, int& iMaxLevel, CRect& lRect, int& iSmWidth, int& iSmHeight, CPtrArray* pTdRecArray)
|
|
{
|
|
int iTop = 0;
|
|
int iBottom = 0;
|
|
int iLeft = 0;
|
|
int iRight = 0;
|
|
|
|
int iRectWidth = 0;
|
|
int iRectHeight = 0;
|
|
|
|
iSmWidth = 0;
|
|
iSmHeight = 0;
|
|
|
|
int iLevel = 0;
|
|
int iPos = 0;
|
|
int iIndex = 0;
|
|
|
|
int iEOffset = 0;
|
|
int iLOffset = 0;
|
|
m_iMNCtrlMethod = 0;
|
|
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
|
|
while (iIndex < pTdRecArray->GetSize())
|
|
{
|
|
pRsp2DTdRecord = (CRsp2DTdRecord*)(pTdRecArray->GetAt(iIndex));
|
|
if (1 < abs(pRsp2DTdRecord->m_iP2 - pRsp2DTdRecord->m_iP1))
|
|
{
|
|
m_iMNCtrlMethod = 1;
|
|
break;
|
|
}
|
|
iIndex++;
|
|
}
|
|
int iNewEAmount = iEAmount;
|
|
if (iEAmount%ELECTRODE_AMOUNT_PERCABLE != 0)
|
|
{
|
|
iNewEAmount =ELECTRODE_AMOUNT_PERCABLE * (1 + iEAmount/ELECTRODE_AMOUNT_PERCABLE);
|
|
}
|
|
iMaxLevel = this->GetMaxLevelByEAmount(iNewEAmount);
|
|
int iXEAmount = (m_iEndPole > m_iStartPole) ? m_iEndPole - m_iStartPole +1 : iEAmount;
|
|
lRect = vRect;
|
|
//已此时的CRect的中心移动边来缩小输入的rect的大小
|
|
lRect.DeflateRect(141, 40, 61, 40);
|
|
//返回大于或者等于指定表达式的最小整数,value 如果有小数部分则进一位
|
|
|
|
//iEAmount为电极的个数,非测点总数,第一层的测点数是最接近电极数的,在倒三角的剖面中
|
|
iSmWidth = (int)ceil(lRect.Width()*1.0/iXEAmount);
|
|
// float fCellHeight = lRect.Height()*1.0/iMaxLevel;
|
|
// iSmHeight = lRect.Height()/iMaxLevel;
|
|
// if (fCellHeight - iSmHeight > 0.8)
|
|
// {
|
|
// iSmHeight++;
|
|
// }
|
|
iSmHeight = (int)ceil(lRect.Height()*1.0/iMaxLevel);
|
|
//将iSmWidth变成奇数,那么iSmWidth-1此时将成为偶数,再用它去乘以任何数也都将是偶数
|
|
if (fmod((double)iSmWidth, 2.0) == 0.0)
|
|
{
|
|
iSmWidth++;
|
|
}
|
|
//由于极端的AM装置中,那么在第一层的最后一个位置,此时AM的点的坐标将会超过X轴的坐标系,
|
|
//所以此时要留有一个装置的余量
|
|
iRectWidth = iSmWidth+(iSmWidth-1)*(iXEAmount-1);
|
|
//iRectWidth = iSmWidth+(iSmWidth-1)*(iEAmount-2);
|
|
|
|
if (fmod((double)iSmHeight, 2.0) == 0.0)
|
|
{
|
|
iSmHeight++;
|
|
}
|
|
|
|
iRectHeight = iSmHeight+(iSmHeight-1)*(iMaxLevel-1);
|
|
|
|
if (fmod(lRect.Width()-iRectWidth, 2.0) == 0.0)
|
|
{
|
|
iLeft = (lRect.Width()-iRectWidth)/2;
|
|
iRight = (lRect.Width()-iRectWidth)/2;
|
|
}
|
|
else
|
|
{
|
|
iLeft = (lRect.Width()-iRectWidth)/2+1;
|
|
iRight = (lRect.Width()-iRectWidth)/2;
|
|
}
|
|
|
|
if (fmod(lRect.Height()-iRectHeight, 2.0) == 0.0)
|
|
{
|
|
iTop = (lRect.Height()-iRectHeight)/2;
|
|
iBottom = (lRect.Height()-iRectHeight)/2;
|
|
}
|
|
else
|
|
{
|
|
iTop = (lRect.Height()-iRectHeight)/2+1;
|
|
iBottom = (lRect.Height()-iRectHeight)/2;
|
|
}
|
|
|
|
lRect.DeflateRect(iLeft, iTop, iRight, iBottom);
|
|
|
|
pRsp2DTdRecord = NULL;
|
|
//iLOffset和iEOffset用来计算中间点和测点之间的偏差
|
|
//比如AMN模式中,点在MN的中点位置,此时m_iPosInLevel取得是M点的位置,
|
|
//那么iLOffset和iEOffset则用来计算M和中点位置之间的偏差
|
|
iEOffset = (int)((iSmWidth-1)*m_fEOffsetR);
|
|
iLOffset = (int)((iSmWidth-1)*m_fLOffsetR);
|
|
iIndex = 0;
|
|
while (iIndex < pTdRecArray->GetSize())
|
|
{
|
|
pRsp2DTdRecord = (CRsp2DTdRecord*)(pTdRecArray->GetAt(iIndex));
|
|
|
|
iLevel = pRsp2DTdRecord->m_iLevel-1;
|
|
int iMN = abs(pRsp2DTdRecord->m_iP2 - pRsp2DTdRecord->m_iP1);
|
|
|
|
iPos = pRsp2DTdRecord->m_iPosInLevel-1 -m_iStartPole + 1;
|
|
pRsp2DTdRecord->m_recPtArea.SetRectEmpty();
|
|
pRsp2DTdRecord->m_recPtArea.SetRect(lRect.left+iEOffset+iLOffset*iLevel+(iSmWidth-1)*(iPos+(iMN-1)/2), lRect.top+(iSmHeight-1)*iLevel,
|
|
lRect.left+iEOffset+iLOffset*iLevel+(iSmWidth-1)*(iPos+(iMN-1)/2)+iSmWidth, lRect.top+(iSmHeight-1)*iLevel+iSmHeight-1);
|
|
iIndex++;
|
|
}
|
|
} |