// MediumLogging.cpp: implementation of the CMediumLogging class. // ////////////////////////////////////////////////////////////////////// #include "geomative.h" #include "MediumLandfillDiagonally.h" #include #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif extern int g_iUILanguage; ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CMediumLandfillDiagonally::CMediumLandfillDiagonally(int iAR) : CMedium3D(iAR) { } CMediumLandfillDiagonally::~CMediumLandfillDiagonally() { } void CMediumLandfillDiagonally::SetParamVal(const void* pVal) { } float CMediumLandfillDiagonally::CalculateCESptKVal(float fA, float fB, float fX, float fY) { float fAM = fabs(fX - fA); float fAN = fabs(fY - fA); float fBM = fabs(fB - fX); float fBN = fabs(fB - fY); if (0 == fAM || 0 == fAN || 0 == fBM || 0 == fBN) { return 0; // AfxMessageBox(_T("Calcualte K value error.value = ")) } return fabs(2 * VAL_PI / (1.0 / fAM - 1.0 / fAN - 1.0 / fBM + 1.0 / fBN)); } bool CMediumLandfillDiagonally::GenerateSptRecElecVal3D(int nSplittedNum, CScript3D *pScript, int* pPtAmount, CPtrArray* pSptRecArray) { 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; } int Id = 0; //m_PointNum的大小是128,可查看其定义 memset(pScript->m_PointNum, 0, sizeof(pScript->m_PointNum)); pSptRecArray->RemoveAll(); m_iXGridSzie = m_rect.x1 - m_rect.x0 + 1; m_iYGridSize = m_rect.y1 - m_rect.y0 + 1; int iStartIndex = 0; int iChangeParam = 0; int iTsn = 0; CSptRecord *pSptRec = NULL; //按照Y轴进行X轴的跑极 CString strLog; int i, j, k; vector> vecElecNum; vector vecX, vecLastX, vecNextX; for (i = 0; i < m_iYGridSize; i++) { vecX.clear(); for (j = i*m_iXGridSzie + 1; j <= (i + 1)*m_iXGridSzie; j++) { strLog.Format(_T("j=%d,"), j); OutputDebugString(strLog); vecX.push_back(j); } OutputDebugString(_T("\n")); vecElecNum.push_back(vecX); } int iC1 = 1, iC2 = m_iXGridSzie*m_iYGridSize + 1, iP1 = 0, iP2 = m_iXGridSzie*m_iYGridSize; strLog.Format(_T("C2(B)=%d\n"), iC2); OutputDebugString(strLog); vecX.clear(); vecX = vecElecNum.at(0); int iRawCount = vecElecNum.size(); int iColCount = vecX.size(); //大于24个电极,需要取中点 int iMidPoint = -1; if (pScript->m_iEAmount > 24) { iMidPoint = m_iXGridSzie / 2; } //C1(A)取值 for (j = 0; j < iRawCount; j = j + iRawCount - 1) { strLog.Format(_T("\n\nC1(A)=%d\n"), iC1); OutputDebugString(strLog); //第一行和最后一行,找到A的几个取值,根据A点找到N点,再依次遍历生成M点 if (j == 0 || j == iRawCount - 1) { for (k = 0; k < iColCount; k++) { if (k == 0 || k == iColCount - 1 || k == iMidPoint) { if (k == iMidPoint) { vecX.clear(); vecX = vecElecNum[j]; iC1 = vecX[k - 1]; vecX.clear(); vecX = vecElecNum[iRawCount - 1 - j]; iP2 = vecX[k - 1]; } else { vecX.clear(); vecX = vecElecNum[j]; iC1 = vecX[k]; vecX.clear(); vecX = vecElecNum[iRawCount - 1 - j]; iP2 = vecX[iColCount - 1 - k]; } //P1(M)取值 for (i = 1; i < iC2; i++) { if (i == iC1 || i == iP2) { continue; } iP1 = i; strLog.Format(_T("C1=%d,C2=%d,P1=%d,P2=%d\n"), iC1, iC2, iP1, iP2); OutputDebugString(strLog); pSptRec = new CSptRecord(); pSptRec->m_iC1 = iC1; pSptRec->m_iC2 = iC2; pSptRec->m_iP1 = iP1; pSptRec->m_iP2 = iP2; pSptRec->m_fK = CalculateCESptKVal(iC1, iC2, iP1, iP2); //由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0 pSptRec->m_iPtNum = 0; // pSptRec->m_iPtNum = iC1Pos; pSptRec->m_iLevel = GenSptRecLevel(iC1, iC2, iP1, iP2); pSptRec->m_colorREF = RGB(0, 255, 0); pSptRec->m_iN = 1; pSptRec->m_bIsSel = TRUE; pSptRec->m_iTsn = ++iTsn; pSptRec->m_SubScriptIndex = Id; pSptRecArray->Add(pSptRec); (pScript->m_PointNum[Id])++; } } } } } *pPtAmount = pSptRecArray->GetSize(); return true; }