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