302 lines
7.2 KiB
C++
302 lines
7.2 KiB
C++
// MediumZC.cpp: implementation of the CMediumZC class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "geomative.h"
|
|
#include "MediumZC.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
CMediumZC::CMediumZC(int iAR)
|
|
{
|
|
m_iAR = iAR;
|
|
m_fEOffsetR = 0.5;
|
|
m_fLOffsetR = 0.5;
|
|
m_fIntervalCof = 6;
|
|
}
|
|
|
|
CMediumZC::~CMediumZC()
|
|
{
|
|
|
|
}
|
|
bool CMediumZC::GenerateSptRecElecVal(int iEAmount, //电极总数---in
|
|
int* pMaxLevel, //最大层---out
|
|
int* pPtAmount, //测点总数---out
|
|
CPtrArray* pSptRecArray //脚本记录集---out
|
|
) //函数功能:生成脚本电极记录集合
|
|
{
|
|
// 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 iDisTance = 0;
|
|
int iStep = 0;
|
|
// 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("");
|
|
|
|
iMaxSpace = iEAmount - 3; //BM之间的最大电极间距,(例如第一个电极和最后一个电极相聚N - 1米,第二个电极 和 倒数第二个电极相聚 N - 1 - 1 - 1米)
|
|
|
|
iTotalMove = iEAmount - 4; //AB总共需要移动的次数
|
|
//在这里之前都是按照ABMN来计算的
|
|
for (iMBVal = 2; iMBVal <= 2+iTotalMove; iMBVal++)
|
|
{
|
|
iMAVal = iMBVal - 1; //A始终在B前面一个位置
|
|
iMBVal = iMBVal;
|
|
iMMVal = iMBVal + 1;
|
|
iMNVal = iMMVal + 1;
|
|
|
|
iAVal = iMAVal;
|
|
iBVal = iMBVal;
|
|
iMVal = iMMVal;
|
|
iNVal = iMNVal;
|
|
|
|
pSptRecord = NULL;
|
|
pSptRecord = new CSptRecord;
|
|
if (NULL != pSptRecord)
|
|
{
|
|
pSptRecord->m_iC1 = iBVal;
|
|
pSptRecord->m_iP2 = iNVal;
|
|
pSptRecord->m_iC2 = iAVal;
|
|
pSptRecord->m_iP1 = iMVal;
|
|
pSptRecord->m_iTsn = ++iTsn;
|
|
pSptRecord->m_fK = CalculateSptKVal(iAVal,iBVal,iMVal,iNVal);
|
|
pSptRecord->m_iLevel = CalculateSptLevel(iMBVal, iMMVal);
|
|
|
|
pSptRecord->m_iPtNum = iBVal;
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
iMMVal += 1;
|
|
for (iMMVal; iMMVal < iEAmount; iMMVal++)
|
|
{
|
|
iMMVal = iMMVal;
|
|
iMNVal = iMMVal + 1;//其他测点位置没有改变
|
|
|
|
iAVal = iMAVal;
|
|
iBVal = iMBVal;
|
|
iMVal = iMMVal;
|
|
iNVal = iMNVal;
|
|
float fInterval = (1.0*(iMVal - iBVal))/(iNVal - iMVal);
|
|
if (fInterval > m_fIntervalCof)//BM间距大于6倍AB时,AB之间的距离要增加
|
|
{
|
|
// iDisTance = (iMVal - iBVal)/(iNVal - iMVal);
|
|
|
|
iStep = fInterval / m_fIntervalCof;
|
|
|
|
if (fmod(fInterval,m_fIntervalCof) < 0.00001)
|
|
{
|
|
iStep -= 1;
|
|
}
|
|
|
|
iBVal = iBVal + iStep;
|
|
iMVal = iMVal + iStep;
|
|
iNVal = iNVal + (iStep*2);//因为M向后移动了N个单位,导致N要向后移动2倍的N才能将与M的间距扩大为N
|
|
|
|
if (iNVal > iEAmount)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
/*暂时屏蔽,改用新算法
|
|
if (iMVal - iBVal > m_iIntervalCof)//BM间距大于6倍AB时,AB之间的距离要增加
|
|
{
|
|
iDisTance = (iMVal - iBVal)/(iNVal - iMVal);
|
|
|
|
iStep = iDisTance / m_iIntervalCof;
|
|
|
|
if (iDisTance % m_iIntervalCof == 0)
|
|
{
|
|
iStep -= 1;
|
|
}
|
|
|
|
iBVal = iBVal + iStep;
|
|
iMVal = iMVal + iStep;
|
|
iNVal = iNVal + (iStep*2);//因为M向后移动了N个单位,导致N要向后移动2倍的N才能将与M的间距扩大为N
|
|
|
|
if (iNVal > iEAmount)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
*/
|
|
|
|
pSptRecord = NULL;
|
|
pSptRecord = new CSptRecord;
|
|
|
|
if (NULL != pSptRecord)
|
|
{
|
|
pSptRecord->m_iC1 = iBVal;
|
|
pSptRecord->m_iP2 = iNVal;
|
|
pSptRecord->m_iC2 = iAVal;
|
|
pSptRecord->m_iP1 = iMVal;
|
|
pSptRecord->m_iTsn = ++iTsn;
|
|
pSptRecord->m_fK = CalculateSptKVal(iAVal,iBVal,iMVal, iNVal);
|
|
pSptRecord->m_iLevel = CalculateSptLevel(iMBVal, iMMVal);
|
|
pSptRecord->m_iPtNum = iBVal;
|
|
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;
|
|
}
|
|
|
|
void CMediumZC::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;
|
|
|
|
iOffsetL = (6+2)*iMul+50+4*iMul*(iLevel-3)+(iMul-2);
|
|
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));
|
|
|
|
return;
|
|
}
|
|
|
|
int CMediumZC::GenSptRecLevel(int iA, int iB, int iM, int iN)
|
|
{
|
|
return iM-iA;
|
|
}
|
|
|
|
int CMediumZC::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
|
|
{
|
|
return (int)iA;
|
|
}
|
|
|
|
int CMediumZC::GetMaxLevelByEAmount(int iEAmount)
|
|
{
|
|
int iLayer = 0;
|
|
int iNPos = 0;
|
|
int iTmp = 0;
|
|
//在这里iTmp指的是BA的距离,而BA = MN
|
|
//每一层的第一个点都是从1开始
|
|
while(TRUE)
|
|
{
|
|
iLayer++;
|
|
iTmp = 1 + (iLayer-1)/6;
|
|
iNPos = 1 + iTmp + iLayer + iTmp;
|
|
if (iNPos > iEAmount)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
return iLayer -1;
|
|
}
|
|
|
|
float CMediumZC::CalculateDepth(float fA, float fFactor)
|
|
{
|
|
// return (float)(fabs(fA)*fFactor);
|
|
return (float)((fabs(fA)/0.5)*fFactor);
|
|
}
|
|
|
|
float CMediumZC::CalculateCESptKVal(float fA, float fB, float fX, float fY)
|
|
{
|
|
float fK = (float)VAL_ZERO;
|
|
fK = (float)(VAL_PI * fB * ((fB * fB) * (fA * fA) - 1));
|
|
|
|
return fK;
|
|
}
|
|
|
|
// float CMediumZC::CalculateSptKVal(int iM, int iN)
|
|
// {
|
|
// //iN:传进来M的位置
|
|
// //IM:传进来B的位置
|
|
//
|
|
// float fK = (float)VAL_ZERO;
|
|
// int n = iN - iM ;
|
|
// fK = (float)( VAL_PI * n * (n+1) * (n + 2) * 1 );
|
|
//
|
|
// return fK;
|
|
//}
|
|
|
|
float CMediumZC::CalculateSptKVal(int iA, int iB, int iM, int iN)
|
|
{
|
|
|
|
float fK = 0;
|
|
int a = iB - iA;
|
|
int na = iM - iB;
|
|
float n = na*1.0 / a;
|
|
fK = (float)( VAL_PI * n * (n+1) * (n + 2) * a );
|
|
|
|
return fK;
|
|
|
|
}
|
|
|
|
int CMediumZC::CalculateSptLevel(int iM, int iN)
|
|
{
|
|
return iN - iM;
|
|
}
|
|
|
|
void CMediumZC::ReSortPoint(CPtrArray *f_ptr)
|
|
{
|
|
return;
|
|
}
|