a
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
// OperMediumPt.cpp: implementation of the COperMediumPt class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geomative.h"
|
||||
#include "OperMediumPt.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
extern int g_iUILanguage;
|
||||
COperMediumPt::COperMediumPt(int iAR)
|
||||
{
|
||||
m_iAR = iAR;
|
||||
m_mapDepthSort.clear();
|
||||
|
||||
}
|
||||
|
||||
COperMediumPt::~COperMediumPt()
|
||||
{
|
||||
m_mapDepthSort.clear();
|
||||
|
||||
}
|
||||
|
||||
bool COperMediumPt::InitiSortInfo(int iMethod)
|
||||
{
|
||||
if (1 == iMethod )
|
||||
{
|
||||
if ((m_iAR > 16 && m_iAR < 39) || AR_CROSS_HOLE_TYPE == m_iAR || AR_BIPOLE_HOLE_SPT == m_iAR)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("不支持深度排序"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Unsupport sort by depth medium"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
m_mapDepthSort.clear();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("未知排序方法"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Unknow sort method"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool COperMediumPt::AddSortPtInfo(int iA, int iB, int iM, int iN, int iLayer,int iIndex)
|
||||
{
|
||||
STDepthSortKey stDepSortKey;
|
||||
stDepSortKey.fXPos = GetUniSptXPos(iA, iB, iM, iN);
|
||||
stDepSortKey.iLayer = iLayer;
|
||||
m_mapDepthSort[stDepSortKey] = iIndex;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
float COperMediumPt::GetUniSptXPos(int iA, int iB, int iM, int iN)
|
||||
{
|
||||
|
||||
int iMin = 100000, iMax = 0, iTotalVal = 0;
|
||||
int iDataArr[4] = {iA, iB, iM, iN};
|
||||
int iNegativeCnt = 0;//非正整数的个数
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (iDataArr[i] > 0)
|
||||
{
|
||||
if (iDataArr[i] > iMax)
|
||||
{
|
||||
iMax = iDataArr[i];
|
||||
}
|
||||
if (iDataArr[i] < iMin)
|
||||
{
|
||||
iMin = iDataArr[i];
|
||||
}
|
||||
iTotalVal += iDataArr[i];
|
||||
}
|
||||
else
|
||||
iNegativeCnt++;
|
||||
}
|
||||
//如果全部是正整数(四级装置),则此时iTotalVal表示的是四个数的总和,那么需要剪掉最大的和最小的
|
||||
if (0 == iNegativeCnt)
|
||||
return (iTotalVal-iMin-iMax)*1.0/2;
|
||||
|
||||
//如果此时是三级装置,那么此时只需要减掉最小值即可
|
||||
if (1 == iNegativeCnt)
|
||||
return (iTotalVal-iMin)*1.0/2;
|
||||
|
||||
//如果是二级装置,则不需进行再处理
|
||||
if (2 == iNegativeCnt)
|
||||
return iTotalVal*1.0/2;
|
||||
|
||||
CString strErr;
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
strErr.Format(_T("GetUniSptXPos错误,负数为%d"), iNegativeCnt);
|
||||
AfxMessageBox(strErr);
|
||||
}
|
||||
else
|
||||
{
|
||||
strErr.Format(_T("GetUniSptXPos error,number of negative is %d"), iNegativeCnt);
|
||||
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int COperMediumPt::GetFirstSortID(int iMethod)
|
||||
{
|
||||
m_iterSortDepth = m_mapDepthSort.begin();
|
||||
if (m_iterSortDepth == m_mapDepthSort.end())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return m_iterSortDepth->second;
|
||||
|
||||
}
|
||||
|
||||
int COperMediumPt::GetNextSortID()
|
||||
{
|
||||
m_iterSortDepth++;
|
||||
if (m_iterSortDepth == m_mapDepthSort.end())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return m_iterSortDepth->second;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user