144 lines
3.8 KiB
C++
144 lines
3.8 KiB
C++
// MediumTwoSideAMN.cpp: implementation of the CMediumTwoSideAMN class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "geomative.h"
|
|
#include "MediumTwoSideAMN.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
extern int g_iUILanguage;
|
|
CMediumTwoSideAMN::CMediumTwoSideAMN(int iAR): CMedium(iAR)
|
|
{
|
|
m_iMaxSepInterval = 0;
|
|
|
|
}
|
|
|
|
CMediumTwoSideAMN::~CMediumTwoSideAMN()
|
|
{
|
|
|
|
}
|
|
|
|
int CMediumTwoSideAMN::GenSptRecLevel(int iA, int iB, int iM, int iN)
|
|
{
|
|
if (iM > iA)
|
|
{
|
|
return iM - iA;
|
|
}
|
|
else
|
|
{
|
|
return iA - iN;
|
|
}
|
|
}
|
|
|
|
|
|
bool CMediumTwoSideAMN::GenerateSptRecElecVal(int iEAmount, int* pMaxLevel, int* pPtAmount, CPtrArray* pSptRecArray)
|
|
{
|
|
if (iEAmount < 3)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("双边三极数组的个数是错误的!!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("The number of Double Side 3P Array 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 (m_iMaxSepInterval < 1)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("最大间隔误差"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Max seprate interval error."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return false;
|
|
}
|
|
pSptRecArray->RemoveAll();
|
|
//装置的位置顺序为AMNB
|
|
int iC1Pos = 1, iC2Pos = -1,iP1Pos = 2,iP2Pos = 3;
|
|
int iTsn = 0;
|
|
CSptRecord *pSptRec = NULL;
|
|
//此时AMN方向的移动
|
|
while((iC1Pos+m_iMaxSepInterval+1) <= iEAmount)
|
|
{
|
|
for (int i = 1; i <= m_iMaxSepInterval; i++)
|
|
{
|
|
iP1Pos = iC1Pos + i;
|
|
iP2Pos = iP1Pos + 1;
|
|
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);
|
|
//由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0
|
|
pSptRec->m_iPtNum = 0;
|
|
// pSptRec->m_iPtNum = iC1Pos;
|
|
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++;
|
|
}
|
|
//此时MNA的移动
|
|
iC1Pos = 2 + m_iMaxSepInterval;
|
|
while(iC1Pos <= iEAmount)
|
|
{
|
|
for (int i = 1; i <= m_iMaxSepInterval; i++)
|
|
{
|
|
iP2Pos = iC1Pos - i;
|
|
iP1Pos = iP2Pos - 1;
|
|
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);
|
|
//由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0
|
|
pSptRec->m_iPtNum = 0;
|
|
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++;
|
|
}
|
|
|
|
*pPtAmount = pSptRecArray->GetSize();
|
|
*pMaxLevel = m_iMaxSepInterval;
|
|
return true;
|
|
}
|
|
|
|
float CMediumTwoSideAMN::CalculateCESptKVal(float fA, float fB, float fX, float fY)
|
|
{
|
|
float fAM = fabs(fX - fA);
|
|
float fAN = fabs(fY - fA);
|
|
if (0 == fAM || 0 ==fAN)
|
|
{
|
|
return 0;
|
|
// AfxMessageBox(_T("Calcualte K value error.value = "))
|
|
}
|
|
return fabs(2*VAL_PI/(1.0/fAM - 1.0/fAN));
|
|
}
|
|
|
|
int CMediumTwoSideAMN::GetMaxLevelByEAmount(int iEAmount)
|
|
{
|
|
return 0;
|
|
} |