// MediumLogging.cpp: implementation of the CMediumLogging class. // ////////////////////////////////////////////////////////////////////// #include "geomative.h" #include "MediumLandfillAdjacent.h" #include #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif extern int g_iUILanguage; ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CMediumLandfillAdjacent::CMediumLandfillAdjacent(int iAR) : CMedium3D(iAR) { } CMediumLandfillAdjacent::~CMediumLandfillAdjacent() { } void CMediumLandfillAdjacent::SetParamVal(const void* pVal) { } float CMediumLandfillAdjacent::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 CMediumLandfillAdjacent::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(); //根据AB两点依次上下组合MN点 for (j = 0; j < iRawCount; j = j++) { //strLog.Format(_T("\n\nC1(A)=%d\n"), iC1); //OutputDebugString(strLog); //第一行和最后一行,找到A的几个取值,根据A点找到N点,再依次遍历生成M点 //取偶数行 if (j % 2 == 1) { k = 0; if (j == 1) { k = 1; } vecLastX = vecElecNum[j - 1]; vecX = vecElecNum[j]; vecNextX = vecElecNum[j + 1]; if (j + 1 >= iRawCount) { vecNextX.clear(); } iColCount = vecX.size(); for (; k < iColCount - 1; k++) { iC1 = vecX[k]; iC2 = vecX[k + 1]; iP1 = vecLastX[k]; iP2 = vecLastX[k + 1]; 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])++; //过滤最后一行的MN取值 if (vecNextX.size() > 0) { iC1 = vecX[k]; iC2 = vecX[k + 1]; iP1 = vecNextX[k]; iP2 = vecNextX[k + 1]; 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; }