153 lines
3.5 KiB
C++
153 lines
3.5 KiB
C++
#include "StdAfx.h"
|
|
#include "SSearchPipeList.h"
|
|
#include <vector>
|
|
#include "Dbwell.h"
|
|
#include "ElevationCheckDlg.h"
|
|
|
|
//***************************************************************************************************
|
|
// 标高检查
|
|
//***************************************************************************************************
|
|
|
|
// 检查管网,将不符合要求的管道id保存在容器内
|
|
void CheckPipeSys(SSearchPipeList *pList, std::vector<AcDbObjectId> &vecPipeIds)
|
|
{
|
|
if (pList != NULL)
|
|
{
|
|
if (pList->m_iType == 0)
|
|
{
|
|
//屏蔽一端不连井的管线 zxl 2011.10.27 add
|
|
SSearchPipeList *pListWell = pList->m_lstNode[0];//不连井的管线末端为堵头节点
|
|
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)
|
|
{
|
|
bool bChangeEle = false; //不符合要求的管道标识
|
|
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);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// 标高检查主函数
|
|
void ElevationCheck()
|
|
{
|
|
// 选择排出井
|
|
RBList rbMask(RTDXF0, _T("ATS_WELL"), NULL);
|
|
|
|
Entity entMain;
|
|
if (SelectEntity(_T("\n请选择排出井<退出>:"), entMain, rbMask) != RTNORM)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// 搜索管网系统
|
|
SSearchPipeList *pList = new SSearchPipeList();
|
|
PickSet ssAll(SS_FREE);
|
|
ssAll += entMain;
|
|
|
|
if (!SearchSprinkPipeSys(entMain, NULL, pList, ssAll))
|
|
{
|
|
acutPrintf(_T("管网有环路存在!"));
|
|
delete pList;
|
|
return;
|
|
}
|
|
|
|
if (pList != NULL)
|
|
{
|
|
pList->m_iType = 3;
|
|
}
|
|
|
|
// 检查管网是否满足连接规则
|
|
std::vector<AcDbObjectId> vecPipeIds;
|
|
CheckPipeSys(pList, vecPipeIds);
|
|
if (!vecPipeIds.empty()) // 存在不符合要求的管道
|
|
{
|
|
// 高亮显示并闪动不符合要求的管道
|
|
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("");
|
|
sNote.Format(_T("总共发现%d根管段标高有误!"), nNum);
|
|
acutPrintf(sNote);
|
|
|
|
TCHAR sz[10];
|
|
acedGetString(0, _T("\n回车退出!"),sz);
|
|
pDlg->DestroyWindow();
|
|
delete pDlg;
|
|
pDlg = NULL;
|
|
}
|
|
else // 管网系统符合要求
|
|
{
|
|
// 提示管网满足要求
|
|
acutPrintf(_T("管网中各管段标高符合要求!"));
|
|
}
|
|
delete pList;
|
|
} |