Files
envi-code/SourceCode/Code2026/tg_shs/shs_outdoor/ElevationCheck.cpp
T

153 lines
3.5 KiB
C++
Raw Normal View History

2026-10-04 00:04:20 +08:00
#include "StdAfx.h"
2026-09-28 15:28:50 +08:00
#include "SSearchPipeList.h"
#include <vector>
#include "Dbwell.h"
#include "ElevationCheckDlg.h"
//***************************************************************************************************
2026-10-04 00:04:20 +08:00
// 标高检查
2026-09-28 15:28:50 +08:00
//***************************************************************************************************
2026-10-04 00:04:20 +08:00
// 检查管网,将不符合要求的管道id保存在容器内
2026-09-28 15:28:50 +08:00
void CheckPipeSys(SSearchPipeList *pList, std::vector<AcDbObjectId> &vecPipeIds)
{
if (pList != NULL)
{
if (pList->m_iType == 0)
{
2026-10-04 00:04:20 +08:00
//屏蔽一端不连井的管线 zxl 2011.10.27 add
SSearchPipeList *pListWell = pList->m_lstNode[0];//不连井的管线末端为堵头节点
2026-09-28 15:28:50 +08:00
if (pListWell->m_iType != 3 && pListWell->m_iType != 4)
{
return;
}
TDbPipe *pPipe = NULL;
AcDbEntity *pEnt = NULL;
AcDbObjectId idPipe = pList->m_ID;
acdbOpenAcDbEntity(pEnt, idPipe, AcDb::kForRead);
if (pEnt != NULL)
{
pPipe = (TDbPipe *) pEnt;
if (pPipe != NULL)
{
if(pPipe->GetPipeGradient() > 0.000001)
{
2026-10-04 00:04:20 +08:00
bool bChangeEle = false; //不符合要求的管道标识
2026-09-28 15:28:50 +08:00
double dLen = pPipe->GetPlanLength();
double dCalcEle = 0.0;
double dMeter = 1.0;
if(!DocGetMeterUnitDraw())
{
dMeter = 1000;
}
TPipeSys::FlowDirection dir = pPipe->GetFlowDir();
if(dir == TPipeSys::kFromStart)
{
dCalcEle = pPipe->StartPoint().z / dMeter;
}
else
{
dCalcEle = pPipe->EndPoint().z / dMeter;
}
dCalcEle = dCalcEle - dLen * pPipe->GetPipeGradient();
if(dir == TPipeSys::kFromStart)
{
if(fabs(pPipe->EndPoint().z - dCalcEle * dMeter) > 0.001 * dMeter)
{
bChangeEle = true;
}
}
else
{
if(fabs(pPipe->StartPoint().z - dCalcEle * dMeter) > 0.001 * dMeter)
{
bChangeEle = true;
}
}
if (bChangeEle)
{
vecPipeIds.push_back(pList->m_ID);
}
}
}
pPipe->Close();
}
else
{
pEnt->close();
}
}
for (int i = 0; i < pList->m_lstNode.Length(); i++)
{
CheckPipeSys(pList->m_lstNode[i], vecPipeIds);
}
}
}
2026-10-04 00:04:20 +08:00
// 标高检查主函数
2026-09-28 15:28:50 +08:00
void ElevationCheck()
{
2026-10-04 00:04:20 +08:00
// 选择排出井
2026-09-28 15:28:50 +08:00
RBList rbMask(RTDXF0, _T("ATS_WELL"), NULL);
Entity entMain;
2026-10-04 00:04:20 +08:00
if (SelectEntity(_T("\n请选择排出井<退出>:"), entMain, rbMask) != RTNORM)
2026-09-28 15:28:50 +08:00
{
return;
}
2026-10-04 00:04:20 +08:00
// 搜索管网系统
2026-09-28 15:28:50 +08:00
SSearchPipeList *pList = new SSearchPipeList();
PickSet ssAll(SS_FREE);
ssAll += entMain;
if (!SearchSprinkPipeSys(entMain, NULL, pList, ssAll))
{
2026-10-04 00:04:20 +08:00
acutPrintf(_T("管网有环路存在!"));
2026-09-28 15:28:50 +08:00
delete pList;
return;
}
if (pList != NULL)
{
pList->m_iType = 3;
}
2026-10-04 00:04:20 +08:00
// 检查管网是否满足连接规则
2026-09-28 15:28:50 +08:00
std::vector<AcDbObjectId> vecPipeIds;
CheckPipeSys(pList, vecPipeIds);
2026-10-04 00:04:20 +08:00
if (!vecPipeIds.empty()) // 存在不符合要求的管道
2026-09-28 15:28:50 +08:00
{
2026-10-04 00:04:20 +08:00
// 高亮显示并闪动不符合要求的管道
2026-09-28 15:28:50 +08:00
CTemporaryResourceOverride vTemp;
CElevationCheckDlg *pDlg = NULL;
pDlg = new CElevationCheckDlg;
pDlg->SetPipeName(vecPipeIds);
pDlg->Create(IDD_ELEVATION_CHECK);
pDlg->ShowWindow(SW_SHOW);
int nNum = vecPipeIds.size();
CString sNote = _T("");
2026-10-04 00:04:20 +08:00
sNote.Format(_T("总共发现%d根管段标高有误!"), nNum);
2026-09-28 15:28:50 +08:00
acutPrintf(sNote);
TCHAR sz[10];
2026-10-04 00:04:20 +08:00
acedGetString(0, _T("\n回车退出!"),sz);
2026-09-28 15:28:50 +08:00
pDlg->DestroyWindow();
delete pDlg;
pDlg = NULL;
}
2026-10-04 00:04:20 +08:00
else // 管网系统符合要求
2026-09-28 15:28:50 +08:00
{
2026-10-04 00:04:20 +08:00
// 提示管网满足要求
acutPrintf(_T("管网中各管段标高符合要求!"));
2026-09-28 15:28:50 +08:00
}
delete pList;
}