a
This commit is contained in:
@@ -0,0 +1,237 @@
|
||||
// MediumB.cpp: implementation of the CMediumB class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geomative.h"
|
||||
#include "MediumB.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
extern BOOL DoEvent(HWND hWnd);
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMediumB::CMediumB(int iAR): CMedium(iAR)
|
||||
{
|
||||
m_fEOffsetR = 1.0;
|
||||
m_fLOffsetR = 1.5;
|
||||
}
|
||||
|
||||
CMediumB::~CMediumB()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CMediumB::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 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("");
|
||||
|
||||
while ((iEAmount - iEqualValMove - 1) % 3)
|
||||
{
|
||||
iEqualValMove++;
|
||||
}
|
||||
|
||||
iMaxSpace = (iEAmount - iEqualValMove -1) / 3;
|
||||
|
||||
iTotalMove = iEAmount - 4;
|
||||
|
||||
for (iMBVal = 2; iMBVal <= 2+iTotalMove; iMBVal++)
|
||||
{
|
||||
if (iMBVal <= (iMaxSpace + 1))
|
||||
{
|
||||
iMAVal = 1;
|
||||
iSpace++;
|
||||
}
|
||||
else if ((iMBVal > (iMaxSpace + 1)) && (iMBVal <= ((iMaxSpace + 1)+iEqualValMove)))
|
||||
{
|
||||
iSpace = iMaxSpace;
|
||||
iMAVal = iMBVal-iSpace;
|
||||
}
|
||||
else if (iMBVal > ((iMaxSpace + 1)+iEqualValMove))
|
||||
{
|
||||
if (iMNVal == iEAmount)
|
||||
{
|
||||
iSpace--;
|
||||
}
|
||||
iMAVal = iMBVal-iSpace;
|
||||
}
|
||||
iMMVal = iMBVal+iSpace;
|
||||
iMNVal = iMBVal+2*iSpace;
|
||||
|
||||
iAVal = iMAVal;
|
||||
iBVal = iMBVal;
|
||||
iMVal = iMMVal;
|
||||
iNVal = iMNVal;
|
||||
|
||||
pSptRecord = NULL;
|
||||
pSptRecord = new CSptRecord;
|
||||
if (NULL != pSptRecord)
|
||||
{
|
||||
pSptRecord->m_iC2 = iAVal;
|
||||
pSptRecord->m_iP2 = iNVal;
|
||||
pSptRecord->m_iC1 = iBVal;
|
||||
pSptRecord->m_iP1 = iMVal;
|
||||
pSptRecord->m_iTsn = ++iTsn;
|
||||
pSptRecord->m_fK = CalculateSptKVal(iMVal, iNVal);
|
||||
pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
iAMove = iBVal - iAVal;
|
||||
while (iAMove > 1)
|
||||
{
|
||||
iAVal++;
|
||||
iMVal--;
|
||||
iNVal = iNVal-2;
|
||||
iAMove--;
|
||||
|
||||
pSptRecord = NULL;
|
||||
pSptRecord = new CSptRecord;
|
||||
|
||||
if (NULL != pSptRecord)
|
||||
{
|
||||
pSptRecord->m_iC2 = iAVal;
|
||||
pSptRecord->m_iP2 = iNVal;
|
||||
pSptRecord->m_iC1 = iBVal;
|
||||
pSptRecord->m_iP1 = iMVal;
|
||||
pSptRecord->m_iTsn = ++iTsn;
|
||||
pSptRecord->m_fK = CalculateSptKVal(iMVal, iNVal);
|
||||
|
||||
pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
|
||||
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 CMediumB::CalculateSptKVal(int iM, int iN)
|
||||
{
|
||||
float fK = (float)VAL_ZERO;
|
||||
fK = (float)(6*VAL_PI*(iN-iM));
|
||||
|
||||
return fK;
|
||||
}
|
||||
|
||||
float CMediumB::CalculateCESptKVal(float fA, float fB, float fX, float fY)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
int CMediumB::CalculateSptLevel(int iM, int iN)
|
||||
{
|
||||
return iN-iM;
|
||||
}
|
||||
|
||||
void CMediumB::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-1)*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));
|
||||
}
|
||||
|
||||
int CMediumB::CalculateRecPosInlevel(int iA)
|
||||
{
|
||||
return iA;
|
||||
}
|
||||
|
||||
int CMediumB::GenSptRecLevel(int iA, int iB, int iM, int iN)
|
||||
{
|
||||
return CalculateSptLevel(iM, iN);
|
||||
}
|
||||
|
||||
int CMediumB::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
|
||||
{
|
||||
return CalculateRecPosInlevel(iA);
|
||||
}
|
||||
|
||||
int CMediumB::GetMaxLevelByEAmount(int iEAmount)
|
||||
{
|
||||
// if (((iEAmount%12) == 0) && (0 != iEAmount))
|
||||
// {
|
||||
// return 3+(iEAmount/12-1)*4;
|
||||
// }
|
||||
//跟进排列来推算,假设最大层数为x,那么此时收个1+3x = iEAmount时,x即为最大层数
|
||||
//由于x为整数,所以对此表达式取整即为最大层数
|
||||
if (iEAmount > 0)
|
||||
return (int)((iEAmount-1)/3);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user