Files
geomative/GeomativeStudio/cpp/ProblemZone/MediumS3P.cpp
T
coco df489d5640 a
2026-07-03 16:05:30 +08:00

215 lines
5.5 KiB
C++

// MediumCustom2D.cpp: implementation of the CMediumCustom2D class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumS3P.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern int g_iUILanguage;
CMediumS3P::CMediumS3P(int iAR) : CMedium(iAR)
{
}
CMediumS3P::~CMediumS3P()
{
}
void CMediumS3P::SetParamVal(const void* pVal)
{
m_uiStartElecID = ((int*)pVal)[0];
m_uiMinN = ((int*)pVal)[1];
m_uiMaxN = ((int*)pVal)[2];
}
float CMediumS3P::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fK = (float)VAL_ZERO;
//在这里也可以将K值的公司改成K=2*pai*n*(n+1)*a
//由于AM=MN=1,所以也可以换算成K=4*pai*a
fK = (float)(4 * VAL_PI*(fX - fA));
return fK;
}
int CMediumS3P::CalculateSptLevel(int iM, int iN)
{
return abs(iN - iM);
}
bool CMediumS3P::GenerateSptRecElecVal(int iEAmount, int* pMaxLevel, 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;
}
pSptRecArray->RemoveAll();
CString strLog;
int iC1 = 0, iC2 = -1, iP1 = 0, iP2 = m_uiStartElecID;
int j, k;
int iIndex = 0;
CSptRecord* pSptRec = NULL;
//B无穷,取值固定
//N取值
for (int i = iP2; i < iEAmount - m_uiMaxN; i++)
{
//M取值
iP2 = i;
iP1 = iP2 + 1;
strLog.Format(_T("P2=%d,P1=%d\n"), iP2, iP1);
OutputDebugString(strLog);
//A取值从M之后一次遍历
//for (k = iP1 + m_uiMinN; k < iEAmount - m_uiMaxN; k++)
{
for (j = iP1 + m_uiMinN; (j <= iP1 + m_uiMaxN) && (j <= iEAmount); j++)
{
iC1 = j;
iIndex++;
strLog.Format(_T("iIndex=%d,N(P2)=%d,M(P1)=%d,A=%d\n"), iIndex, iP2, iP1, iC1, iC2);
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 = CalculateSptLevel(iP1, iP2);
pSptRec->m_colorREF = RGB(0, 255, 0);
pSptRec->m_iN = 1;
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = iIndex;
pSptRecArray->Add(pSptRec);
}
}
}
*pPtAmount = pSptRecArray->GetSize();
*pMaxLevel = iEAmount - 1;
/*
CString strVal = _T("");
CString strText = _T("");
int iTsn = 0;
CDialCustomSptInput* pCustomSptDlg = new CDialCustomSptInput();
pCustomSptDlg->Create(IDD_DIALOG_CUSTOMSPT_MANUAL_INPUT, AfxGetMainWnd());
pCustomSptDlg->ShowWindow(SW_SHOW);
int iRet = pCustomSptDlg->RunModalLoop(MLF_SHOWONIDLE); // 开始非模态窗口模态循环
int iMaxLevel = 0;
if (RET_OK == iRet)
{
int iCnt = pCustomSptDlg->GetListCount();
for (int i = 0; i < iCnt; i++)
{
pSptRec = new CSptRecord();
strVal.Empty();
strVal = pCustomSptDlg->GetListItemText(i, 1);
if (strVal.IsEmpty())
{
strText.Empty();
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 1"), i);
AfxMessageBox(strText);
return false;
}
pSptRec->m_iC1 = atoi(strVal);
strVal.Empty();
strVal = pCustomSptDlg->GetListItemText(i, 2);
if (strVal.IsEmpty())
{
strText.Empty();
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 2"), i);
AfxMessageBox(strText);
return false;
}
pSptRec->m_iC2 = atoi(strVal);
strVal.Empty();
strVal = pCustomSptDlg->GetListItemText(i, 3);
if (strVal.IsEmpty())
{
strText.Empty();
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 3"), i);
AfxMessageBox(strText);
return false;
}
pSptRec->m_iP1 = atoi(strVal);
strVal.Empty();
strVal = pCustomSptDlg->GetListItemText(i, 4);
if (strVal.IsEmpty())
{
strText.Empty();
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 4"), i);
AfxMessageBox(strText);
return false;
}
pSptRec->m_iP2 = atoi(strVal);
strVal.Empty();
strVal = pCustomSptDlg->GetListItemText(i, 5);
if (strVal.IsEmpty())
{
strText.Empty();
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 5"), i);
AfxMessageBox(strText);
return false;
}
pSptRec->m_fK = atof(strVal);
strVal.Empty();
strVal = pCustomSptDlg->GetListItemText(i, 6);
if (strVal.IsEmpty())
{
strText.Empty();
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 6"), i);
AfxMessageBox(strText);
return false;
}
pSptRec->m_iN = atoi(strVal);
strVal.Empty();
strVal = pCustomSptDlg->GetListItemText(i, 7);
if (strVal.IsEmpty())
{
strText.Empty();
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 7"), i);
AfxMessageBox(strText);
return false;
}
pSptRec->m_iLevel = atoi(strVal);
if (iMaxLevel < pSptRec->m_iLevel)
{
iMaxLevel = pSptRec->m_iLevel;
}
pSptRec->m_bIsSel = TRUE;
//pSptRec->m_iPtNum = 0;
pSptRec->m_iTsn = ++iTsn;
pSptRecArray->Add(pSptRec);
}
pCustomSptDlg->DestroyWindow();
delete pCustomSptDlg;
*pMaxLevel = iMaxLevel;
*pPtAmount = pSptRecArray->GetSize();
return true;
}
else
return false;*/
}