622 lines
20 KiB
C++
622 lines
20 KiB
C++
// MediumWenAndSch.cpp: implementation of the CMediumStrongWenAndSch class.
|
||
//
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
#include "geomative.h"
|
||
#include "MediumStrongWenAndSch.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
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
CMediumStrongWenAndSch::CMediumStrongWenAndSch(int iAR) : CMedium(iAR)
|
||
{
|
||
m_fEOffsetR = 0.5;
|
||
m_fLOffsetR = 0;
|
||
}
|
||
|
||
CMediumStrongWenAndSch::~CMediumStrongWenAndSch()
|
||
{
|
||
|
||
}
|
||
|
||
int CMediumStrongWenAndSch::MOD(int x, int y)
|
||
{
|
||
long n;
|
||
int f;
|
||
|
||
if ((x == 0) || (y == 0))
|
||
{
|
||
return x;
|
||
}
|
||
f = x / y;
|
||
n = (long)f;
|
||
|
||
if (n>f)
|
||
{
|
||
n = n - 1;
|
||
}
|
||
f = x - n*y;
|
||
|
||
return f;
|
||
}
|
||
|
||
bool CMediumStrongWenAndSch::GenerateSptRecElecVal(int iEAmount, int* pMaxLevel, int* pPtAmount, CPtrArray* pSptRecArray)
|
||
{
|
||
if (iEAmount < 1)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("Wenner_Schlumber中EA_MOUNT的数目是错误的!"));
|
||
else
|
||
MessageBoxEx(NULL, _T("The number of EA_MOUNT in Wenner_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;
|
||
}
|
||
/*生成脚本之前需要得到所有层数的层数号(i, j),以及每一层的第一个装置。其中i为大层数,j为小层数。
|
||
该脚本代码的层数逻辑比较复杂。当电极数目确定之后,层数便可以确定。层数确定的逻辑如下:
|
||
相关参数:
|
||
1,小于或等于电极数目N,且可以被3整除的整数的个数:〖nBL〗_ 。〖nBL〗_ 即为外围层数,或大层数。(即N个电极时,i的取值为1到〖nBL〗_ )
|
||
2,当i≤8时,第i大层中的总的小层数为[i / 2](这里的[]表示向正无穷大方向取整)。即j的取值为1到[i / 2]。当i>8时,小层数为3, 4, 5每四个大层一循环
|
||
举例:
|
||
N = 20;
|
||
小于或等于20,且可以被3整除的整数有:
|
||
3, 6, 9, 12, 15, 18;〖nBL〗_ = 6,表示有6个大层;
|
||
每个整数对应的小层数:
|
||
i->j
|
||
1 -> 1
|
||
2 -> 1
|
||
3 -> 2
|
||
4 -> 2
|
||
5 -> 3
|
||
6 -> 3
|
||
因此,层数总共有1 + 1 + 2 + 2 + 3 + 3 = 12层
|
||
|
||
N = 65;
|
||
小于或等于65,且可以被3整除的整数有:
|
||
3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63。〖nBL〗_ = 21,表示有21个大层;
|
||
每个整数对应的小层数:
|
||
i->j
|
||
1 -> 1
|
||
2 -> 1
|
||
3 -> 2
|
||
4 -> 2
|
||
5 -> 3
|
||
6 -> 3
|
||
7 -> 4
|
||
8 -> 4
|
||
9 -> 3
|
||
10 -> 3
|
||
11 -> 3
|
||
12 -> 3
|
||
13 -> 4
|
||
14 -> 4
|
||
15 -> 4
|
||
16 -> 4
|
||
17 -> 5
|
||
18 -> 5
|
||
19 -> 5
|
||
20 -> 5
|
||
21 -> 3
|
||
|
||
大层数的奇偶决定了该大层内的a的奇偶性。小层数决定了a的具体值。但有如下几个分类:
|
||
(1)当i≤8时,a值从1和2开始,间隔为2.
|
||
第1 - 1层:1 - 2 - 3 - 4 (a = 1)
|
||
第2 - 1层:1 - 3 - 5 - 7 (a = 2)
|
||
第3 - 1层:1 - 5 - 6 - 10 (a = 1)
|
||
第3 - 2层:1 - 4 - 7 - 10 (a = 3)
|
||
第4 - 1层:1 - 6 - 8 - 13 (a = 2)
|
||
第4 - 2层:1 - 5 - 9 - 13 (a = 4)
|
||
第5 - 1层:1 - 8 - 9 - 16 (a = 1)
|
||
第5 - 2层:1 - 7 - 10 - 16 (a = 3)
|
||
第5 - 3层:1 - 6 - 11 - 16 (a = 5)
|
||
第6 - 1层:1 - 9 - 11 - 19 (a = 2)
|
||
第6 - 2层:1 - 8 - 12 - 19 (a = 4)
|
||
第6 - 3层:1 - 7 - 13 - 19 (a = 6)
|
||
第7 - 1层:1 - 11 - 12 - 22 (a = 1)
|
||
第7 - 2层:1 - 10 - 13 - 22 (a = 3)
|
||
第7 - 3层:1 - 9 - 14 - 22 (a = 5)
|
||
第7 - 4层:1 - 8 - 15 - 22 (a = 7)
|
||
第8 - 1层:1 - 12 - 14 - 25 (a = 2)
|
||
第8 - 2层:1 - 11 - 15 - 25 (a = 4)
|
||
第8 - 3层:1 - 10 - 16 - 25 (a = 6)
|
||
第8 - 4层:1 - 9 - 17 - 25 (a = 8)
|
||
|
||
(2)当8<i≤16时,a值从3和4开始,间隔为4.
|
||
第9 - 1层: 1 - 13 - 16 - 28 (a = 3)
|
||
第9 - 2层: 1 - 11 - 18 - 28 (a = 7)
|
||
第9 - 3层: 1 - 9 - 20 - 28 (a = 11)
|
||
第10 - 1层:1 - 14 - 18 - 31 (a = 4)
|
||
第10 - 2层:1 - 12 - 20 - 31 (a = 8)
|
||
第10 - 3层:1 - 10 - 22 - 31 (a = 12)
|
||
第11 - 1层:1 - 16 - 19 - 34 (a = 3)
|
||
第11 - 2层:1 - 14 - 21 - 34 (a = 7)
|
||
第11 - 3层:1 - 12 - 23 - 34 (a = 11)
|
||
第12 - 1层:1 - 17 - 21 - 37 (a = 4)
|
||
第12 - 2层:1 - 15 - 23 - 37 (a = 8)
|
||
第12 - 3层:1 - 13 - 25 - 37 (a = 12)
|
||
第13 - 1层:1 - 19 - 22 - 40 (a = 3)
|
||
第13 - 2层:1 - 17 - 24 - 40 (a = 7)
|
||
第13 - 3层:1 - 15 - 26 - 40 (a = 11)
|
||
第13 - 4层:1 - 13 - 28 - 40 (a = 15)
|
||
……
|
||
(3)当16<i≤24时,a值从7和8开始,间隔为4.
|
||
(4)当24<i≤32时,a值从11和12开始,间隔为6.
|
||
(5)当32<i≤40时,a值从15和16开始,间隔为8.
|
||
(6)当40<i≤48时,a值从19和20开始,间隔为8.
|
||
(7)当i>48时,a值从29和30开始,间隔为12.*/
|
||
/////////////////////////使用新算法 by quyx 20190125//////////////////////////////////////////////////
|
||
pSptRecArray->RemoveAll();
|
||
int iC1Pos, iC2Pos, iP1Pos, iP2Pos;
|
||
int iXParam = 1;
|
||
int iTsn = 0;
|
||
CSptRecord *pSptRec = NULL;
|
||
int iLayer = 0, iTailorLayer = 0;
|
||
|
||
//输入电极数目->计算小于等于N且可以被3整除的数
|
||
int nBL = 0;
|
||
for (int i = 1; i <= iEAmount; i++)
|
||
{
|
||
if (MOD(i, 3) == 0)
|
||
{
|
||
//res(j) = i;
|
||
nBL = nBL + 1;
|
||
}
|
||
}
|
||
int nSL[4096];
|
||
for (int i = 1; i <= nBL; i++)
|
||
{
|
||
if (i < 9)
|
||
nSL[i] = ceil(i / 2.0);
|
||
else
|
||
nSL[i] = ceil((i - 8) / 4.0) - 3 * (ceil((ceil((i - 8) / 4.0)) / 3.0) - 1) + 2;
|
||
}
|
||
//应用方案提供的Mablab公式
|
||
for (int i = 1; i <= nBL; i++)
|
||
{
|
||
for (int j = 1; j <= nSL[i]; j++)
|
||
{
|
||
if (i <= 8)
|
||
{
|
||
iC1Pos = 1;
|
||
iC2Pos = 3 * i + 1;
|
||
iP1Pos = floor((3 * i + 1) / 2) - j + 1;
|
||
iP2Pos = floor((3 * i + 1) / 2) - j + 1 + 2 - i % 2 + 2 * (j - 1);
|
||
}
|
||
else if (i > 8 & i <= 16)
|
||
{
|
||
iC1Pos = 1;
|
||
iC2Pos = 3 * i + 1;
|
||
iP1Pos = floor((3 * i + 1) / 2) - 2 * j + 2 - 1;
|
||
iP2Pos = floor((3 * i + 1) / 2) - 2 * j + 2 - 1 + 4 - i % 2 + 4 * (j - 1);
|
||
}
|
||
else if (i > 16 & i <= 24)
|
||
{
|
||
iC1Pos = 1;
|
||
iC2Pos = 3 * i + 1;
|
||
iP1Pos = floor((3 * i + 1) / 2) - 2 * j + 2 - 3;
|
||
iP2Pos = floor((3 * i + 1) / 2) - 2 * j + 2 - 3 + 8 - i % 2 + 4 * (j - 1);
|
||
}
|
||
else if (i > 24 & i <= 32)
|
||
{
|
||
iC1Pos = 1;
|
||
iC2Pos = 3 * i + 1;
|
||
iP1Pos = floor((3 * i + 1) / 2) - 3 * j + 3 - 5;
|
||
iP2Pos = floor((3 * i + 1) / 2) - 3 * j + 3 - 5 + 12 - i % 2 + 6 * (j - 1);
|
||
}
|
||
else if (i > 32 & i <= 40)
|
||
{
|
||
iC1Pos = 1;
|
||
iC2Pos = 3 * i + 1;
|
||
iP1Pos = floor((3 * i + 1) / 2) - 4 * j + 4 - 7;
|
||
iP2Pos = floor((3 * i + 1) / 2) - 4 * j + 4 - 7 + 16 - i % 2 + 8 * (j - 1);
|
||
}
|
||
else if (i > 40 & i <= 48)
|
||
{
|
||
iC1Pos = 1;
|
||
iC2Pos = 3 * i + 1;
|
||
iP1Pos = floor((3 * i + 1) / 2) - 5 * j + 5 - 9;
|
||
iP2Pos = floor((3 * i + 1) / 2) - 5 * j + 5 - 9 + 20 - i % 2 + 10 * (j - 1);
|
||
}
|
||
else if (i > 48)
|
||
{
|
||
iC1Pos = 1;
|
||
iC2Pos = 3 * i + 1;
|
||
iP1Pos = floor((3 * i + 1) / 2) - 6 * j + 6 - 14;
|
||
iP2Pos = floor((3 * i + 1) / 2) - 6 * j + 6 - 14 + 30 - i % 2 + 12 * (j - 1);
|
||
}
|
||
|
||
if (iC2Pos > iEAmount)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
pSptRec = new CSptRecord();
|
||
pSptRec->m_iC1 = iC1Pos;
|
||
pSptRec->m_iC2 = iC2Pos;
|
||
pSptRec->m_iP1 = iP1Pos;
|
||
pSptRec->m_iP2 = iP2Pos;
|
||
pSptRec->m_fK = CalculateCESptKVal(iC1Pos, iC2Pos, iP1Pos, iP2Pos);
|
||
|
||
pSptRec->m_iPtNum = iP1Pos + iXParam / 2;
|
||
pSptRec->m_iLevel = iLayer + 1; //GenSptRecLevel(iC1Pos, iC2Pos, iP1Pos, iP2Pos); //
|
||
pSptRec->m_colorREF = RGB(0, 255, 0);
|
||
pSptRec->m_iN = 1;
|
||
pSptRec->m_bIsSel = TRUE;
|
||
pSptRec->m_iTsn = ++iTsn;
|
||
pSptRecArray->Add(pSptRec);
|
||
|
||
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 = CalculateCESptKVal(iC1Pos, iC2Pos, iP1Pos, iP2Pos);
|
||
|
||
pSptRec->m_iPtNum = iP1Pos + iXParam / 2;
|
||
pSptRec->m_iLevel = iLayer + 1; //GenSptRecLevel(iC1Pos, iC2Pos, iP1Pos, iP2Pos); //
|
||
pSptRec->m_colorREF = RGB(0, 255, 0);
|
||
pSptRec->m_iN = 1;
|
||
pSptRec->m_bIsSel = TRUE;
|
||
pSptRec->m_iTsn = ++iTsn;
|
||
|
||
pSptRecArray->Add(pSptRec);
|
||
}
|
||
iLayer++;
|
||
}
|
||
}
|
||
|
||
*pPtAmount = pSptRecArray->GetSize();
|
||
*pMaxLevel = iLayer;// -1;
|
||
return true;
|
||
|
||
////////////////////modifyed by lsq 20160510//////////////////////////////////////////////////////
|
||
//AM=BN,当AM间隔选择为5或者5的倍数时,此时的下一层点的MN间间距每隔五层增加2个电极点距(MN间间距按1、3、5、7…等间隔增加),
|
||
//并且AM的间隔会暂停增加一次,测量时,AM,NB间电极间距按隔离系数由小到大的顺序等间隔增加,
|
||
// 第一层时,A=#1,M=#2, N=#3, B=#4 … → … A=#57,M=#58,N=#59,B=#60
|
||
// 第二层时,A=#1,M=#3, N=#4, B=#6 … → … A=#55,M=#57,N=#58,B=#60
|
||
// 第三层时,A=#1,M=#4, N=#5, B=#8 … → … A=#53,M=#56,N=#57,B=#60
|
||
// 第四层时,A=#1,M=#5, N=#6, B=#10 … → … A=#51,M=#55,N=#56,B=#60
|
||
// 第五层时,A=#1,M=#6, N=#7, B=#12 … → … A=#49,M=#54,N=#55,B=#60
|
||
// 第六层时,A=#1, M=#6, N=#9, B=#14 … → … A=#47,M=#52,N=#55,B=#60
|
||
// 第七层时,A=#1,M=#7, N=#10,B=#16 … → … A=#45,M=#51,N=#54,B=#60
|
||
// 第八层时,A=#1,M=#8, N=#11,B=#18 … → … A=#43,M=#50,N=#53,B=#60
|
||
// 第九层时,A=#1,M=#9, N=#12,B=#20 … → … A=#41,M=#49,N=#52,B=#60
|
||
// 第十层时,A=#1,M=#10,N=#13,B=#22 … → … A=#39,M=#48,N=#51,B=#60
|
||
// 第十一层时,A=#1, M=#10,N=#15,B=#24 … → … A=#37,M=#46,N=#51,B=#60
|
||
|
||
//while(TRUE)
|
||
//{
|
||
// iLayer++;
|
||
// //iTailorLayer = (iLayer-1)/5;
|
||
// iTailorLayer = (iLayer - 1) / 6; //使用新的算法6的间隔 by quyx 20180929
|
||
// iC1Pos = 1;
|
||
// iP1Pos = iC1Pos + iLayer - iTailorLayer;
|
||
// //iXParam = 1 + iTailorLayer*2;
|
||
// iXParam = 1 + iTailorLayer; //使用新的算法暂不跳跃 by quyx 20180929
|
||
// iP2Pos = iP1Pos + iXParam;
|
||
// iC2Pos = iP2Pos + iLayer - iTailorLayer;;
|
||
// if (iC2Pos > iEAmount)
|
||
// {
|
||
// break;
|
||
// }
|
||
|
||
// //确定好每一层的电极初始位置之后,开始横向往右测量,此时每测一次,电极向右平移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 = CalculateCESptKVal(iC1Pos, iC2Pos, iP1Pos, iP2Pos);
|
||
// //在这里这么计算是因为在修改规则之后,无法通过层数判断MN之间的间距,用这种计算方法,
|
||
// //由于iXParam为奇数,所以m_iPtNum的位置距离MN真实中点的位置只差0.5个电极间距
|
||
// pSptRec->m_iPtNum = iP1Pos + iXParam/2;
|
||
// pSptRec->m_iLevel = GenSptRecLevel(iC1Pos, iC2Pos, iP1Pos, iP2Pos);
|
||
// pSptRec->m_colorREF = RGB(0, 255, 0);
|
||
// pSptRec->m_iN = 1;
|
||
// pSptRec->m_bIsSel = TRUE;
|
||
// pSptRec->m_iTsn = ++iTsn;
|
||
// pSptRecArray->Add(pSptRec);
|
||
|
||
// iC1Pos++;
|
||
// iC2Pos++;
|
||
// iP1Pos++;
|
||
// iP2Pos++;
|
||
// }
|
||
//}
|
||
|
||
//*pPtAmount = pSptRecArray->GetSize();
|
||
//*pMaxLevel = iLayer-1;
|
||
//return true;
|
||
}
|
||
|
||
float CMediumStrongWenAndSch::CalculateCESptKVal(float fA, float fB, float fX, float fY)
|
||
{
|
||
//这里K值的计算公式为: k = n(n+x)*pai*a/x
|
||
//其中a为最小电极间距,我们默认为1,由GD10主机设置
|
||
//n:指的是AM之间的间隔系数(即AM=n*a)
|
||
//x:指的是MN之间的间隔系数(即MN=x*a)
|
||
if (fX == fY)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("MN的距离不能为零!"));
|
||
else
|
||
MessageBoxEx(NULL, _T("The distance between M and N can not be zero,please check!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return 0;
|
||
}
|
||
float fNparam = fX - fA;
|
||
float fXParam = fY - fX;
|
||
return (VAL_PI*fNparam*(fNparam + fXParam)) / fXParam;
|
||
|
||
}
|
||
|
||
|
||
void CMediumStrongWenAndSch::CalculateSptPtLoc(int iMul, CSptRecord* pSptRecord)
|
||
{
|
||
int iOffsetL = (int)VAL_ZERO;
|
||
int iOffsetR = (int)VAL_ZERO;
|
||
|
||
int iLevel = pSptRecord->m_iLevel;
|
||
int iPtNum = pSptRecord->m_iPtNum;
|
||
|
||
//此时的OFFSETL相当于每一层第一次ABMN中的点的矩形初始位置,其中X轴的坐标间距为8
|
||
//46为坐标轴起始点在X方向的距离
|
||
//其中46+ (6+2)*iMul+ 4*iMul*(iLevel-1)*2就是M的起始位置
|
||
//iOffsetL = (6+2)*iMul+50+4*iMul*(iLevel-1)*2+(iMul-2);
|
||
// iOffsetL = 46+ (6+2)*iMul+ 4*iMul*(iLevel-1)*2 + iMul* ((pSptRecord->m_iP2 - pSptRecord->m_iP1)*(6+2)/2 - 3) ;
|
||
// iOffsetR = iOffsetL+6*iMul;
|
||
iOffsetL = 46;
|
||
iOffsetR = iOffsetL + 6 * iMul;
|
||
|
||
//矩形的X轴的位置有OFFSETL 再加上向右的偏移距离组成,向右的偏移距离即是全部电极每测一次向右偏移的距离
|
||
//举例来说,此时OFFSETL相当于此时的中心点的起始位置,iPtNum-1则相当于此时向右偏移的次数
|
||
//其中圆点的半径为3,在这里加4是因为iPtNum距离真正中心点的位置差半个电极间距,
|
||
pSptRecord->m_recPtArea.left = iOffsetL + (6 + 2)*iMul*(iPtNum - 1) + (4 - 3)*iMul;
|
||
pSptRecord->m_recPtArea.top = 50 + (6 + 2)*iMul*(iLevel - 1);
|
||
pSptRecord->m_recPtArea.right = iOffsetR + (6 + 2)*iMul*(iPtNum - 1) + (4 - 3)*iMul;
|
||
pSptRecord->m_recPtArea.bottom = (50 + 6 * iMul) + (6 + 2)*iMul*(iLevel - 1);
|
||
|
||
pSptRecord->m_fPtCenterX = (float)(pSptRecord->m_recPtArea.left + pSptRecord->m_recPtArea.right) / 2;
|
||
pSptRecord->m_fPtCenterY = (float)(pSptRecord->m_recPtArea.top + pSptRecord->m_recPtArea.bottom) / 2;
|
||
pSptRecord->m_fPtRadius = (float)(abs((int)(pSptRecord->m_fPtCenterX) - pSptRecord->m_recPtArea.left));
|
||
}
|
||
|
||
int CMediumStrongWenAndSch::GetMaxLevelByEAmount(int iEAmount)
|
||
{
|
||
if (iEAmount < 4)
|
||
{
|
||
return 0;
|
||
}
|
||
int iC1Pos, iC2Pos, iP1Pos, iP2Pos;
|
||
int iXParam = 1;
|
||
int iLayer = 0, iTailorLayer = 0;
|
||
while (TRUE)
|
||
{
|
||
iLayer++;
|
||
iTailorLayer = (iLayer - 1) / 5;
|
||
iC1Pos = 1;
|
||
iP1Pos = iC1Pos + iLayer - iTailorLayer;
|
||
iXParam = 1 + iTailorLayer * 2;
|
||
iP2Pos = iP1Pos + iXParam;
|
||
iC2Pos = iP2Pos + iLayer - iTailorLayer;
|
||
if (iC2Pos > iEAmount)
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
return iLayer - 1;
|
||
|
||
}
|
||
|
||
void CMediumStrongWenAndSch::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;
|
||
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);
|
||
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);
|
||
|
||
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
|
||
//iLOffset和iEOffset用来计算中间点和测点之间的偏差
|
||
//比如AMN模式中,点在MN的中点位置,此时m_iPosInLevel取得是M点的位置,
|
||
//那么iLOffset和iEOffset则用来计算M和中点位置之间的偏差
|
||
iEOffset = (int)((iSmWidth - 1)*m_fEOffsetR);
|
||
iLOffset = (int)((iSmWidth - 1)*m_fLOffsetR);
|
||
|
||
while (iIndex < pTdRecArray->GetSize())
|
||
{
|
||
pRsp2DTdRecord = (CRsp2DTdRecord*)(pTdRecArray->GetAt(iIndex));
|
||
|
||
iLevel = pRsp2DTdRecord->m_iLevel - 1;
|
||
iPos = pRsp2DTdRecord->m_iPosInLevel - 1 - m_iStartPole + 1;
|
||
pRsp2DTdRecord->m_recPtArea.SetRectEmpty();
|
||
pRsp2DTdRecord->m_recPtArea.SetRect(lRect.left + iEOffset + iLOffset*(int)(iLevel / 3) + (iSmWidth - 1)*iPos, lRect.top + (iSmHeight - 1)*iLevel,
|
||
lRect.left + iEOffset + iLOffset*(int)(iLevel / 3) + (iSmWidth - 1)*iPos + iSmWidth, lRect.top + (iSmHeight - 1)*iLevel + iSmHeight);
|
||
iIndex++;
|
||
}
|
||
}
|
||
|
||
void CMediumStrongWenAndSch::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++)
|
||
{
|
||
if (iIndex > vtLayerOrderInfo[i - 1].vtIndex.size() - 1)
|
||
{
|
||
continue;
|
||
}
|
||
int iOrderIndex = vtLayerOrderInfo[i - 1].vtIndex[iIndex];
|
||
pSptRecord = (CSptRecord*)f_ptr->GetAt(iOrderIndex);
|
||
newPtArr.Add(pSptRecord);
|
||
}
|
||
}
|
||
|
||
if (newPtArr.GetSize() != f_ptr->GetSize())
|
||
{
|
||
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);
|
||
}
|
||
} |