Files
envi-code/SourceCode/Code2026/Dimension/RainCalc.cpp
T
2026-09-28 15:28:50 +08:00

1550 lines
41 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "stdafx.h"
#include "globalFunc.h"
#include "AcDbObjectPtr.h"
#include "DbWell.h"
#include "MSWORD8.h"
#include "xtext.h"
#include "DbPool.h"
#include "Dbpipe.h"
#include "layerdef.h"
#include "EntitySet.h"
#include "RBGroups.h"
#include "PickEntSet.h"
//#include "CalcSheetDlg.h"
//#include "TWordFormulasTemplet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//extern int DoSerialNumber(SSearchPipeList *pListLast, int idx, BOOL IsMainNode);
//extern double CalcPipeV(double nDn, double nI, double n);
//extern double CalcPipeV(double nQ, double nDn, double nI, double n);
//extern BOOL CheckWellSys(SSearchPipeList *pListAll, BOOL bChcekPool);
//
extern void SetPipeLabelType(CDbPipe *pPipe);
namespace
{
double CalcPipeV(double nDn, double nI, double n)
{
double nTemp = 1 / n;
nI = pow(nI, 0.5);
double nR = pow(0.25 * nDn, 2.0 / 3.0);
return nTemp * nI * nR;
}
double CalcPipeV(double nQ, double nDn, double nI, double n)
{
double nRet(-1);
double nTemp = 1 / n;
nI = pow(nI, 0.5);
double nR = pow(0.25 * nDn, 2.0 / 3.0);
nRet = nTemp * nI * nR;
double nTempQ = (0.25 * nDn * nDn * PI) * nRet;
if (nTempQ < nQ && nDn < 2.750)
return -1;
return nRet;
// double nRet(-1);
// double nArea(0);
// nArea = PI/4.0 * nDn * nDn;
// nRet = nQ / nArea;
// return nRet;
}
}
//***************************************************************************************************
// 显示面积
//***************************************************************************************************
int g_iShowRainArea = 1;
int GetRainAreaState()
{
ads_retint(g_iShowRainArea);
return RTNORM;
}
/*int SetRainAreaState()
{
CString csAreaLayer = LAY_CALC_AREA; // 8.0发行之前要修改过来
if(g_iShowRainArea == 1)
g_iShowRainArea = 0;
else
g_iShowRainArea = 1;
TDocLock vLock;
RBList rbMask(RTDXF0, _T("ATS_SPACE"), 8, csAreaLayer, NULL);
PickSet ssAll(SS_FREE);
ssAll.Get(_T("X"), NULL, NULL, rbMask);
for(long j=0;j<ssAll.Length();j++){
Entity ent = ssAll[j];
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbSpace, pSpace);
if(pSpace){
if(g_iShowRainArea == 1)
pSpace->setVisibility(AcDb::kVisible);
else
pSpace->setVisibility(AcDb::kInvisible);
pSpace->SetHighlight(TRUE);
}
OPENOBJ_END();
}
SetLayerOnOff(csAreaLayer, g_iShowRainArea);
return GetRainAreaState();
}*/
extern void UpdateRainWellArea();
//***************************************************************************************************
// 雨水水力
//***************************************************************************************************
//extern void GlobalFunc::GetPipeSpecList(DList<int> &lstSpec, const TCHAR* szMat);
int DoPlusRainDn(int dn, BOOL bPlus)
{
int ret(0);
if (bPlus) { //增大一级管径
if (dn <= 250)
ret = 300;
else if (dn == 300)
ret = 350;
else if (dn == 350)
ret = 400;
else if (dn == 400)
ret = 450;
else if (dn == 450)
ret = 500;
else if (dn == 500)
ret = 600;
else if (dn == 600)
ret = 700;
else if (dn == 700)
ret = 800;
else if (dn == 800)
ret = 900;
else if (dn == 900)
ret = 1000;
else if (dn == 1000)
ret = 1100;
else if (dn == 1100)
ret = 1200;
else if (dn == 1200)
ret = 1350;
else if (dn == 1350)
ret = 1500;
else if (dn == 1500)
ret = 1650;
else if (dn == 1650)
ret = 1800;
else if (dn == 1800)
ret = 2000;
else if (dn == 2000)
ret = 2100;
else if (dn == 2100)
ret = 2200;
else if (dn == 2200)
ret = 2300;
else if (dn == 2300)
ret = 2400;
else if (dn == 2400)
ret = 2500;
else if (dn == 2500)
ret = 2600;
else if (dn == 2600)
ret = 2700;
else if (dn == 2700)
ret = 2800;
else if (dn == 2800)
ret = 2900;
else if (dn == 2900)
ret = 3000;
else
ret = 3000;
}
else {
if (dn <= 300)
ret = 250;
else if (dn == 350)
ret = 300;
else if (dn == 400)
ret = 350;
else if (dn == 450)
ret = 400;
else if (dn == 500)
ret = 450;
else if (dn == 600)
ret = 500;
else if (dn == 700)
ret = 600;
else if (dn == 800)
ret = 700;
else if (dn == 900)
ret = 800;
else if (dn == 1000)
ret = 900;
else if (dn == 1100)
ret = 1000;
else if (dn == 1200)
ret = 1100;
else if (dn == 1350)
ret = 1200;
else if (dn == 1500)
ret = 1350;
else if (dn == 1650)
ret = 1500;
else if (dn == 1800)
ret = 1650;
else if (dn == 2000)
ret = 1800;
else if (dn == 2100)
ret = 2000;
else if (dn == 2200)
ret = 2100;
else if (dn == 2300)
ret = 2200;
else if (dn == 2400)
ret = 2300;
else if (dn == 2500)
ret = 2400;
else if (dn == 2600)
ret = 2500;
else if (dn == 2700)
ret = 2600;
else if (dn == 2800)
ret = 2700;
else if (dn == 2900)
ret = 2800;
else if (dn == 3000)
ret = 2900;
}
return ret;
}
int GetDnBySpecList(int dn)
{
DList<int> lstSpec;
GlobalFunc::GetPipeSpecList(lstSpec, _T("钢筋混凝土管"));
int idx = -1;
int len = lstSpec.Length();
for (int j = 0; j < lstSpec.Length(); j++) {
int iDnTmp = *lstSpec[j];
if (iDnTmp == dn)
return dn;
if (iDnTmp > dn)
return iDnTmp;
}
return dn;
}
int PlusRainDn(int dn, BOOL bPlus)
{
DList<int> lstSpec;
GlobalFunc::GetPipeSpecList(lstSpec, _T("钢筋混凝土管"));
int idx = -1;
int len = lstSpec.Length();
for (int j = 0; j < lstSpec.Length(); j++) {
int iDnTmp = *lstSpec[j];
if (iDnTmp == dn) {
idx = j;
break;
}
if (iDnTmp > dn && bPlus) {
return iDnTmp;
}
else if (iDnTmp > dn && !bPlus && j > 1) {
iDnTmp = *lstSpec[j - 1];
return iDnTmp;
}
}
int ret(dn);
if (bPlus && idx != len - 1)
ret = *lstSpec[idx + 1];
else if (!bPlus && idx != 0)
ret = *lstSpec[idx - 1];
return ret;
}
// 根据<<给水排水管网系统>> P55 按充满度为1 进行计算管径
int GetFirstPipeDnByQ2(double nQ, double nN, double nI, double &nRetV)
{
int dn = 300;//小区道路最小是300
double dTmp = pow(nQ / 1000.0, 3.0 / 8.0);
double dTmp2 = pow(nI / 1000.0, 3.0 / 16.0);
dTmp = dTmp / dTmp2 * 0.304 * 1000;
dTmp -= 0.1;
if (dTmp < 300)
dn = 300;
else if (dTmp < 350)
dn = 350;
else if (dTmp < 400)
dn = 400;
else if (dTmp < 450)
dn = 450;
else if (dTmp < 500)
dn = 500;
else if (dTmp < 600)
dn = 600;
else if (dTmp < 700)
dn = 700;
else if (dTmp < 800)
dn = 800;
else if (dTmp < 900)
dn = 900;
else if (dTmp < 1000)
dn = 1000;
else if (dTmp < 1100)
dn = 1100;
else if (dTmp < 1200)
dn = 1200;
else if (dTmp < 1350)
dn = 1350;
else if (dTmp < 1500)
dn = 1500;
else if (dTmp < 1650)
dn = 1650;
else if (dTmp < 1800)
dn = 1800;
else if (dTmp < 2000)
dn = 2000;
else if (dTmp < 2100)
dn = 2100;
else if (dTmp < 2200)
dn = 2200;
else if (dTmp < 2300)
dn = 2300;
else if (dTmp < 2400)
dn = 2400;
else if (dTmp < 2500)
dn = 2500;
else if (dTmp < 2600)
dn = 2600;
else if (dTmp < 2700)
dn = 2700;
else
dn = 2800;
double nRadius = (double)dn / 1000;
nRetV = CalcPipeV(nQ / 1000.0, nRadius, nI / 1000.0, nN);
return dn;
}
// 初算管径 已知坡度
// 已知流量 以及 粗糙系数 根据 流速不能小于 0.6 原则, 给出最大管径
int GetFirstPipeDnByQ3(double nQ, double nN, double nI, double &nRetV)
{
BOOL bMetal = FALSE;
if (fabs(nN - 0.012) < 0.001 || fabs(nN - 0.013) < 0.001 || fabs(nN - 0.014) < 0.001)
bMetal = TRUE;
//以下数字出自:《给水排水管网系统》P217 主要针对于污水管,所以经验流量×1。5 (污水充满度55%)
int dn = 300;//小区道路最小是300
if (nQ < 23.9)
dn = 300;
else if (nQ < 39.72 * 1.8)
dn = 350;
else if (nQ < 51.88 * 1.8)
dn = 400;
else if (nQ < 65.66 * 1.8)
dn = 450;
else if (nQ < 88.08 * 1.8)
dn = 500;
else if (nQ < 126.84 * 1.8)
dn = 600;
else if (nQ < 172.65 * 1.8)
dn = 700;
else if (nQ < 222.5 * 1.8)
dn = 800;
else if (nQ < 285.39 * 1.8)
dn = 900;
else if (nQ < 379.11 * 1.8)
dn = 1000;
else if (nQ < 458.72 * 1.8)
dn = 1100;
else if (nQ < 545.92 * 1.8)
dn = 1200;
else if (nQ < 690.93 * 1.8)
dn = 1350;
else if (nQ < 853 * 1.8)
dn = 1500;
else if (nQ < 1032.13 * 1.8)
dn = 1650;
else
dn = 1800;
nI = nI / 1000;
nQ = nQ / 1000;// 把L/S 转化为 M3/S
double nSlowV = 0.7;
dn = GetDnBySpecList(dn);
while (1) {
double nV(0);
double nRadius = (double)dn / 1000;
nV = CalcPipeV(nQ, nRadius, nI, nN);
while (nV < nSlowV || (nV > 10 && bMetal) || (nV > 5 && !bMetal)) {
if (nV > nSlowV)
dn = PlusRainDn(dn, FALSE);
else
dn = PlusRainDn(dn, TRUE);
nRadius = (double)dn / 1000;
nV = CalcPipeV(nQ, nRadius, nI, nN);
if (dn == 250) {
nRetV = nV;
return dn;
}
if (nV < 0) {
dn = PlusRainDn(dn, TRUE);
nRadius = (double)dn / 1000;
nV = CalcPipeV(nRadius, nI, nN);
break;
}
}
nRetV = nV;
double nTempQ = (0.25 * nRadius * nRadius * PI) * nV;
double nTmp = nTempQ - nQ;
if (nTempQ < nQ && dn < 3000) {
dn = PlusRainDn(dn, TRUE); //设计流量不够,管径加大一号
continue;
}
if (dn == 300)
break;
//把当前管径小2号,计算设计流量,如果设计流量仍然大于计算流量,就把当前管径小1号
int iTempDn = PlusRainDn(dn, FALSE);
iTempDn = PlusRainDn(iTempDn, FALSE);
double nTempDn = (double)iTempDn / 1000;
nTempQ = (0.25 * nTempDn * nTempDn * PI) * nV;
if (nTempQ > nQ && dn > 300) {
dn = PlusRainDn(dn, FALSE);
break;
}
else
break;
if (dn == 300)
break;
}
return dn;
}
// 初算管径
// 已知流量 以及 粗糙系数 根据 流速不能小于 0.6 原则, 给出最大管径
int GetFirstPipeDnByQ(double nQ, double nN, double &nRetI, double &nRetV)
{
BOOL bMetal = FALSE;
if (fabs(nN - 0.012) < 0.001 || fabs(nN - 0.013) < 0.001 || fabs(nN - 0.014) < 0.001)
bMetal = TRUE;
double nTempI = 0.003;
//以下数字出自:《给水排水管网系统》P217 主要针对于污水管,所以经验流量×1。5 (污水充满度55%)
int dn = 300;//小区道路最小是300
if (nQ < 23.9)
dn = 300;
// else if(nQ < 39.72*1.8)
// dn = 350;
else if (nQ < 51.88 * 1.8) {
dn = 400;
nTempI = 0.0025;
}
// else if(nQ < 65.66*1.8){
// dn = 450;
// nTempI = 0.002;
// }
else if (nQ < 88.08 * 1.8) {
dn = 500;
nTempI = 0.0015;
}
else if (nQ < 126.84 * 1.8) {
dn = 600;
nTempI = 0.0015;
}
else if (nQ < 172.65 * 1.8) {
dn = 700;
nTempI = 0.001;
}
else if (nQ < 222.5 * 1.8) {
dn = 800;
nTempI = 0.001;
}
else if (nQ < 285.39 * 1.8) {
dn = 900;
nTempI = 0.001;
}
else if (nQ < 379.11 * 1.8) {
dn = 1000;
nTempI = 0.001;
}
else if (nQ < 458.72 * 1.8) {
dn = 1100;
nTempI = 0.001;
}
else if (nQ < 545.92 * 1.8) {
dn = 1200;
nTempI = 0.0005;
}
else if (nQ < 690.93 * 1.8) {
dn = 1350;
nTempI = 0.0005;
}
else if (nQ < 853 * 1.8) {
dn = 1500;
nTempI = 0.0005;
}
else if (nQ < 1032.13 * 1.8) {
dn = 1650;
nTempI = 0.0005;
}
else {
dn = 1800;
nTempI = 0.0005;
}
nQ = nQ / 1000;// 把L/S 转化为 M3/S
double nSlowV = 0.7;
dn = GetDnBySpecList(dn);
while (1) {
double nV(0);
double nI = nTempI - 0.0005;
double nRadius = (double)dn / 1000;
while (nV < nSlowV || (nV > 10 && bMetal) || (nV > 5 && !bMetal)) {
nI += 0.0005;
nV = CalcPipeV(nRadius, nI, nN);
if (dn == 300 && nRetI > 0.003) {
nI = 0.003;
nV = CalcPipeV(nRadius, nI, nN);
}
}
nRetI = nI;
nRetV = nV;
double nTempQ = (0.25 * nRadius * nRadius * PI) * nV;
double nTmp = nTempQ - nQ;
if (nTempQ < nQ && dn < 3000) {
int dn2 = dn;
dn = PlusRainDn(dn2, TRUE); //设计流量不够,管径加大一号
if (dn == dn2)
break;
continue;
}
if (dn == 300)
break;
//把当前管径小2号,计算设计流量,如果设计流量仍然大于计算流量,就把当前管径小1号
int iTempDn = PlusRainDn(dn, FALSE);
iTempDn = PlusRainDn(iTempDn, FALSE);
double nTempDn = (double)iTempDn / 1000;
nTempQ = (0.25 * nTempDn * nTempDn * PI) * nV;
if (nTempQ > nQ && dn > 300) {
dn = PlusRainDn(dn, FALSE);
if (dn == 300)
break;
else
continue;
}
else
break;
if (dn == 300)
break;
}
return dn;
}
//计算本节点往后有多少井
void CalcWellNum(SSearchPipeList *pListAll)
{
AcDbObjectId id = NULL;
id = pListAll->m_ID;
pListAll->m_iNum = 0;
if (pListAll->m_iType == 3)
pListAll->m_iNum = 1;
ads_name ent;
acdbGetAdsName(ent, id);
long len = pListAll->m_lstNode.Length();
for (long i = 0; i < len; i++) {
SSearchPipeList *pList = pListAll->m_lstNode[i];
CalcWellNum(pList);
pListAll->m_iNum += pList->m_iNum;
}
}
extern void ShowPipe(const AcDbObjectId &idPipe);
extern bool HandlePipeDimType(CDbPipe *pPipe, int &nSelType);
bool g_bPipeShow = false; // cet 2012.1.9 add 图面赋值控制变量
int g_nSelType = -1; // cet 2012.1.9 add 图面赋值控制变量
//将初算结果标注在图中 管径 & 坡度
void DimRainCalcResult(SSearchPipeList *pListAll)
{
BOOL bDrawLabel = false; // cet 2012.1.10 add 管线是否显示标注
AcDbObjectId id = NULL;
id = pListAll->m_ID;
if (pListAll->m_iType == 0) {
ads_name ent;
acdbGetAdsName(ent, id);
XPoint ptStart, ptEnd;
GlobalFunc::GetPipePoint(ent, ptStart, ptEnd);
//对于接雨水口的支管,不需要标注
BOOL bIsLink2Gully = FALSE;
OPENOBJ_BEGIN(ent, AcDb::kForWrite, CDbPipe, pPipe);
if (pPipe) {
bDrawLabel = pPipe->IsDrawLabel(); // cet 2012.1.10 add 记录原始设置
AcDbObjectId idNode1 = pPipe->GetNode(0);
OPENOBJ_BEGIN(idNode1, AcDb::kForRead, CDbEquipment, pEquip);
if (pEquip) {
TCHAR* szLay = pEquip->layer();
if (_tcsicmp(szLay, LAY_TWT_GULLY) == 0)
bIsLink2Gully = TRUE;
delete[] szLay;
}
OPENOBJ_END();
AcDbObjectId idNode2 = pPipe->GetNode(1);
OPENOBJ_BEGIN(idNode2, AcDb::kForRead, CDbEquipment, pEquip);
if (pEquip) {
TCHAR* szLay = pEquip->layer();
if (_tcsicmp(szLay, LAY_TWT_GULLY) == 0)
bIsLink2Gully = TRUE;
delete[] szLay;
}
OPENOBJ_END();
}
OPENOBJ_END();
if (!bIsLink2Gully)
GlobalFunc::DoDimPipeDn(ent, pListAll->m_iDn, _T("自动"), g_Option::instance().g_nPipeDnHeight, FALSE, FALSE);
BOOL bReverse = FALSE;
if (pListAll->m_pPrevious != NULL) { //得到前一节点
AcDbObjectId idFront = pListAll->m_pPrevious->m_ID;
XPoint ptNode;
OPENOBJ_BEGIN(idFront, AcDb::kForRead, CDbPipeNode, pNode);
if (pNode) {
ptNode = pNode->GetLocation();
}
OPENOBJ_END();
if (ptStart == ptNode)
bReverse = TRUE; //如果前一节点位置等于本管线的起点位置,说明管线画反了
}
if (pListAll->m_nI > 0) {
OPENOBJ_BEGIN(ent, AcDb::kForWrite, CDbPipe, pPipe);
if (pPipe) {
pPipe->SetPipeGradient(pListAll->m_nI / 1000);
}
OPENOBJ_END();
}
// cet 2012.1.10 add 在管线信息更新完毕后设置管线标注以防计算标注信息长度有误
OPENOBJ_BEGIN(ent, AcDb::kForWrite, CDbPipe, pPipe);
if (pPipe != NULL)
{
pPipe->EnableDrawLabel(bDrawLabel); // 设置为管线原有标注设置
if (!pPipe->IsDrawLabel())
{
SetPipeLabelType(pPipe);
}
else
{
g_bPipeShow = HandlePipeDimType(pPipe, g_nSelType);
}
if (static_cast<int>(pPipe->GetSpare()) == -1)
{
pPipe->EnableDrawLabel(FALSE);
}
else
{
pPipe->EnableDrawLabel(TRUE);
}
}
OPENOBJ_END();
// 显示交叉线
if (g_bPipeShow)
{
ShowPipe(id);
GlobalFunc::AnyKeyReturn(_T("\n按任意键继续查找下一段待修改管标注..."));
}
}
else if (pListAll->m_iType == 3) {
if (pListAll->m_pPrevious != NULL) {
ads_name ent;
acdbGetAdsName(ent, pListAll->m_ID);
GlobalFunc::WriteXdata(ent, _T("TG-DIRTWELLQ"), XString(_T("%.2f"), pListAll->m_pPrevious->m_nPipeQ));
}
}
long len = pListAll->m_lstNode.Length();
for (long i = 0; i < len; i++) {
SSearchPipeList *pList = pListAll->m_lstNode[i];
DimRainCalcResult(pList);
}
}
//将每个井的汇流面积写入链表
// m_nDang 记录本井汇流面积
// m_nStartPress 记录总汇流面积
// m_iNum 记录径流系数
BOOL SetWellArea(SSearchPipeList *pListAll, BOOL &bHasArea)
{
BOOL bRet = TRUE;
AcDbObjectId id = NULL;
id = pListAll->m_ID;
if (GlobalFunc::IsWell(id))
pListAll->m_iType = 3;
if (pListAll->m_iType == 3) {
ads_name ent;
acdbGetAdsName(ent, id);
CString csArea = GlobalFunc::ReadXdata(ent, _T("TG-WELLAREA"));
CString csFactor = GlobalFunc::ReadXdata(ent, _T("TG-RAINWELLFACTOR"));
CString csP = GlobalFunc::ReadXdata(ent, _T("TG-RAINWELLP"));
CString csTime = GlobalFunc::ReadXdata(ent, _T("TG-WELLTIME"));
int iFactor = int(_tstof(csFactor) * 1000);
pListAll->m_nDang = _tstof(csArea);
pListAll->m_iNum = iFactor;
pListAll->m_iSpare = _ttoi(csP);
if (csTime != _T("") && pListAll->m_lstNode.Length() == 0)//必须是末端井
pListAll->m_nLost = _tstof(csTime);
if (pListAll->m_nDang > 0.01)
bHasArea = TRUE;
pListAll->m_nStartPress = _tstof(csArea);
}
else if (pListAll->m_iType == 0) {
OPENOBJ_BEGIN(id, AcDb::kForRead, CDbPipe, pPipe);
if (pPipe) {
pListAll->m_nLength = pPipe->Length();
// if(!DocGetMeterUnitDraw())
// pListAll->m_nLength = pListAll->m_nLength/1000;
}
OPENOBJ_END();
}
long len = pListAll->m_lstNode.Length();
for (long i = 0; i < len; i++) {
SSearchPipeList *pList = pListAll->m_lstNode[i];
bRet = SetWellArea(pList, bHasArea);
pListAll->m_nStartPress += pList->m_nStartPress; //m_nStartPress记录总汇流面积
}
return bRet;
}
BOOL IsDirtPool(AcDbObjectId idNode)
{
if (!idNode)
return FALSE;
OPENOBJ_BEGIN(idNode, AcDb::kForRead, CDbPool, pEquip);
if (pEquip)
return TRUE;
else
return FALSE;
OPENOBJ_END();
}
//将井编号写入链表
BOOL SetWellName(SSearchPipeList *pListAll)
{
BOOL bRet = TRUE;
AcDbObjectId id = NULL;
id = pListAll->m_ID;
if (GlobalFunc::IsWell(id))
pListAll->m_iType = 3;
if (IsDirtPool(id))
pListAll->m_iType = 4;
if (pListAll->m_iType == 3) {
pListAll->m_csName = GlobalFunc::GetWellName(id);
if (pListAll->m_csName == _T(""))
return FALSE;
}
if (pListAll->m_iType == 4) {
pListAll->m_csName = _T("HC");
}
long len = pListAll->m_lstNode.Length();
for (long i = 0; i < len; i++) {
SSearchPipeList *pList = pListAll->m_lstNode[i];
bRet = SetWellName(pList);
if (!bRet)
return FALSE;
}
return bRet;
}
//返回用户选择的最远井所在链表的位置
SSearchPipeList *GetWellNode(SSearchPipeList *pListAll, Entity entLongWell, SSearchPipeList *pNode)
{
AcDbObjectId id = NULL;
id = pListAll->m_ID;
ads_name ent;
acdbGetAdsName(ent, id);
Entity entTmp = ent;
if (entTmp == entLongWell)
return pListAll;
long len = pListAll->m_lstNode.Length();
for (long i = 0; i < len; i++) {
SSearchPipeList *pList = pListAll->m_lstNode[i];
pNode = GetWellNode(pList, entLongWell, pNode);
}
return pNode;
}
//得到下一个计算支路的起点节点 根据流量是否为0且最远
SSearchPipeList *GetNextCalcWell(SSearchPipeList *pListAll, SSearchPipeList *pDisadvantage)
{
AcDbObjectId id = NULL;
id = pListAll->m_ID;
double nCurPipeLength(0);
if (pListAll->m_nPipeQ == 0 && pListAll->m_iType == 3) {
nCurPipeLength = pListAll->m_nLength;
if (pDisadvantage) {
if (nCurPipeLength > pDisadvantage->m_nLength)
pDisadvantage = pListAll;
}
else
pDisadvantage = pListAll; //条件3: 临时节点为空
}
int len = pListAll->m_lstNode.Length();
for (long i = 0; i < len; i++) {
SSearchPipeList *pList = pListAll->m_lstNode[i];
pDisadvantage = GetNextCalcWell(pList, pDisadvantage);
}
return pDisadvantage;
}
CString TransformDouble2String(double dDouble, int iPre)
{
CString csRet;
CString csNote;
csNote.Format(_T("%d"), iPre--);
CString sFormat = _T("%.") + csNote + _T("f");
csRet.Format(sFormat, dDouble);
while (csRet.ReverseFind(_T('0')) > 0 && iPre >= 0)
{
csNote.Format(_T("%d"), iPre--);
CString sFormat = _T("%.") + csNote + _T("f");
csRet.Format(sFormat, dDouble);
}
return csRet;
}
//输出计算书函数
/*
void ImportRainCalcWord(DList<SSearchPipeList> &lstNode, DList<SSearchPipeList> &lstWell, CCalcRainWellDlg &dlg)
{
int len = lstNode.Length();
if(len < 1)
return;
int len2 = lstWell.Length();
if(len2 < 1)
return;
// 打开公式模板 zxl 2013.12.31 add
TWordFormulasTemplet wdFormula;
CString sPathName = g_csSysPath;
sPathName += _T("formula.doc");
if (!wdFormula.OpenWordFormulasTempletFile(sPathName))
{
return;
}
//初始化
COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR), vtTrue((short)TRUE), vtFalse((short)FALSE);
_Application wordApplication;
Documents wordDocuments;
_Document activeDocument;
Paragraphs wordParagraphs;
Selection wordSelection;
if (!wordApplication.CreateDispatch(_T("Word.Application")))
{
AfxMessageBox(_T("不能执行Microsoft Word 8.0!"));
return;
}
wordApplication.SetVisible(TRUE);
wordDocuments = wordApplication.GetDocuments();
activeDocument = wordDocuments.Add(vtOptional,vtOptional);
wordSelection = wordApplication.GetSelection();
wordParagraphs = wordSelection.GetParagraphs();
wordParagraphs.SetAlignment(1); // 0: 居左 1:居中 2:居右
CString csFisrt = lstWell[0]->m_csName;
CString csLast = lstWell[len2-1]->m_csName;
CString csTitle = _T("室外雨水井") + csFisrt + _T(" ~ ") + csLast + _T("水力计算书\n\n");
wordSelection.TypeText(csTitle);
//写一行字
wordSelection = wordApplication.GetSelection();
wordParagraphs = wordSelection.GetParagraphs();
wordParagraphs.SetAlignment(0); // 0: 居左 1:居中 2:居右
// zxl 2014.01.03 add
_Font font;
font = wordSelection.GetFont();
wordSelection.TypeText(_T("计算原理参照《室外排水设计规范》GB 50014-2006(2011版),《给水排水设计手册》(第五册城镇排水) \n"));
wordSelection.TypeText(_T("一、基本计算公式 \n"));
wordSelection.TypeText(_T("1、降雨强度公式: \n"));
wordSelection.TypeText(_T(" "));
wdFormula.InsertFormula(WORD_FORMULA30, wordSelection);
wordSelection.TypeText(_T("mm/min"));
wordSelection.TypeText(_T(""));
wordSelection.TypeText(_T("\n 式中: i —— 降雨强度(mm/min)"));
wordSelection.TypeText(_T("\n 其中:1mm/min=1L/(m"));
font.SetSuperscript(2); //处理上标
wordSelection.TypeText(_T("2"));
font.SetSuperscript(0);
wordSelection.TypeText(_T("·min)= 10000L/(min·公顷)"));
wordSelection.TypeText(_T("\n t —— 降雨历时(min)"));
wordSelection.TypeText(_T("\n 雨水管渠的设计降雨历时公式:"));
wordSelection.TypeText(_T("\n "));
wdFormula.InsertFormula(WORD_FORMULA31, wordSelection);
wordSelection.TypeText(_T("\n t —— 降雨历时(min);"));
wordSelection.TypeText(_T("\n t"));
font.SetSubscript(2); //处理下标
wordSelection.TypeText(_T("1"));
font.SetSubscript(0);
wordSelection.TypeText(_T(" —— 地面集水时间(min),视距离长短、地形坡度和地面铺盖情"));
wordSelection.TypeText(_T(" 况而定,一般采用5~10min"));
wordSelection.TypeText(_T("\n m —— 折减系数"));
wordSelection.TypeText(_T("\n t"));
font.SetSubscript(2); //处理下标
wordSelection.TypeText(_T("2"));
font.SetSubscript(0);
wordSelection.TypeText(_T(" —— 管渠内雨水流行时间(min)\n "));
wdFormula.InsertFormula(WORD_FORMULA32, wordSelection);
wordSelection.TypeText(_T("\n L"));
font.SetSubscript(2); //处理下标
wordSelection.TypeText(_T("i"));
font.SetSubscript(0);
wordSelection.TypeText(_T(" —— 为设计断面上游各管道的长度(m)"));
wordSelection.TypeText(_T("\n v"));
font.SetSubscript(2); //处理下标
wordSelection.TypeText(_T("i"));
font.SetSubscript(0);
wordSelection.TypeText(_T(" —— 为上游管段的设计流速(m/s)"));
wordSelection.TypeText(_T("\n P —— 设计重现期(年)"));
wordSelection.TypeText(_T("\n A,C,n,B —— 参数,根据统计方法进行计算确定."));
wordSelection.TypeText(_T("\n2、暴雨强度公式:"));
wordSelection.TypeText(_T("\n "));
wdFormula.InsertFormula(WORD_FORMULA33, wordSelection);
wordSelection.TypeText(_T(" L/(s·公顷)"));
wordSelection.TypeText(_T("\n 式中: q —— 设计暴雨强度L/(s·公顷)、L/(s·hm"));
font.SetSuperscript(2); //处理上标
wordSelection.TypeText(_T("2"));
font.SetSuperscript(0);
wordSelection.TypeText(_T(")、L/(s·10"));
font.SetSuperscript(2); //处理上标
wordSelection.TypeText(_T("4"));
font.SetSuperscript(0);
wordSelection.TypeText(_T("m"));
font.SetSuperscript(2); //处理上标
wordSelection.TypeText(_T("2"));
font.SetSuperscript(0);
wordSelection.TypeText(_T(")"));
wordSelection.TypeText(_T("\n3、雨水设计流量公式:"));
wordSelection.TypeText(_T("\n "));
wdFormula.InsertFormula(WORD_FORMULA34, wordSelection);
wordSelection.TypeText(_T("\n 式中:"));
wordSelection.TypeText(_T(" Q —— 雨水设计流量(L/s)"));
wordSelection.TypeText(_T("\n q —— 设计降雨强度 L/(s·公顷)"));
wordSelection.TypeText(_T("\n ψ—— 径流系数"));
wordSelection.TypeText(_T("\n F —— 汇水面积(ha 、10"));
font.SetSuperscript(2); //处理上标
wordSelection.TypeText(_T("4"));
font.SetSuperscript(0);
wordSelection.TypeText(_T("m"));
font.SetSuperscript(2); //处理上标
wordSelection.TypeText(_T("2"));
font.SetSuperscript(0);
wordSelection.TypeText(_T(")"));
wordSelection.TypeText(_T("\n4、流速公式:"));
wordSelection.TypeText(_T("\n "));
wdFormula.InsertFormula(WORD_FORMULA35, wordSelection);
wordSelection.TypeText(_T("\n 式中:"));
wordSelection.TypeText(_T(" V —— 流速(m/s)"));
wordSelection.TypeText(_T("\n R —— 水力半径(m)"));
wordSelection.TypeText(_T("\n I —— 水力坡度"));
wordSelection.TypeText(_T("\n n —— 粗糙系数"));
wordSelection.TypeText(_T("\n5、泄流量公式:"));
wordSelection.TypeText(_T("\n "));
wdFormula.InsertFormula(WORD_FORMULA36, wordSelection);
wordSelection.TypeText(_T("\n 式中:"));
wordSelection.TypeText(_T(" Q —— 泄流量(m"));
font.SetSuperscript(2); //处理上标
wordSelection.TypeText(_T("3"));
font.SetSuperscript(0);
wordSelection.TypeText(_T("/s)"));
wordSelection.TypeText(_T("\n V —— 流速(m/s)"));
wordSelection.TypeText(_T("\n A —— 管截面积(m"));
font.SetSuperscript(2); //处理上标
wordSelection.TypeText(_T("2"));
font.SetSuperscript(0);
wordSelection.TypeText(_T(")"));
wordSelection.TypeText(_T("\n二、计算参数"));
wordSelection.TypeText(_T("\n1、地区:"));
wordSelection.TypeText(dlg.m_csProvince);
wordSelection.TypeText(_T(" "));
wordSelection.TypeText(dlg.m_csCity);
wdFormula.CloseFile();
Selection wSelection = wordApplication.GetSelection();
wSelection.TypeParagraph();
//画表格
int nrows(2), ncolumns(4);
wSelection = wordApplication.GetSelection();
Range oRange = wSelection.GetRange();
Tables oTables = activeDocument.GetTables();
_Table oTable = oTables.Add(oRange, nrows, ncolumns);
Borders oBordersn = oTable.GetBorders();
oBordersn.SetInsideLineStyle(1); // 设置表格线型
oBordersn.SetOutsideLineStyle(1);
Columns oColumns;
Column oColumn;
oColumns = oTable.GetColumns();
oColumn = oColumns.Item(1);
oColumn.SetWidth(110, 0); // 0 = wdAdjustNone
oColumn = oColumns.Item(2);
oColumn.SetWidth(110, 0);
oColumn = oColumns.Item(3);
oColumn.SetWidth(110, 0);
oColumn = oColumns.Item(4);
oColumn.SetWidth(110, 0);
Cell oCell;
oCell = oTable.Cell(1, 1);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("A"));
oCell = oTable.Cell(1, 2);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("B"));
oCell = oTable.Cell(1, 3);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("C"));
oCell = oTable.Cell(1, 4);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("n"));
oCell = oTable.Cell(2, 1);
oRange = oCell.GetRange();
oRange.InsertAfter(dlg.m_csA);
oCell = oTable.Cell(2, 2);
oRange = oCell.GetRange();
oRange.InsertAfter(dlg.m_csB);
oCell = oTable.Cell(2, 3);
oRange = oCell.GetRange();
oRange.InsertAfter(dlg.m_csC);
oCell = oTable.Cell(2, 4);
oRange = oCell.GetRange();
oRange.InsertAfter(dlg.m_csN);
wordSelection = wordApplication.GetSelection();
wordSelection.GoTo(COleVariant((short)3), // 3 = wdGoToLine
COleVariant((short)-1),vtOptional,vtOptional); // -1 = wdGoToLast
wordSelection.TypeText(XString(_T("2、重现期:%s年"), TransformDouble2String(dlg.m_nP, 3)));
wordSelection.TypeText(XString(_T("\n3、汇流时间:%smin"), TransformDouble2String(dlg.m_dTime, 3)));
wordSelection.TypeText(XString(_T("\n4、径流系数:%s"), TransformDouble2String(dlg.m_nFactor, 3)));
wordSelection.TypeText(XString(_T("\n5、折减系数:%s"), TransformDouble2String(dlg.m_dM, 3)));
wordSelection.TypeText(_T("\n6、粗糙系数:"));
wSelection = wordApplication.GetSelection();
wSelection.TypeParagraph();
//画表格
nrows = dlg.m_mapMeratialN.size() + 1, ncolumns = 2;
wSelection = wordApplication.GetSelection();
oRange = wSelection.GetRange();
oTables = activeDocument.GetTables();
oTable = oTables.Add(oRange, nrows, ncolumns);
oBordersn = oTable.GetBorders();
oBordersn.SetInsideLineStyle(1); // 设置表格线型
oBordersn.SetOutsideLineStyle(1);
oColumns = oTable.GetColumns();
oColumn = oColumns.Item(1);
oColumn.SetWidth(200, 0); // 0 = wdAdjustNone
oColumn = oColumns.Item(2);
oColumn.SetWidth(100, 0);
oCell = oTable.Cell(1, 1);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("管材"));
oCell = oTable.Cell(1, 2);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("粗糙系数"));
std::map<CString, double>::iterator it;
int iIndex = 0;
for ( it = dlg.m_mapMeratialN.begin(); it != dlg.m_mapMeratialN.end(); it++)
{
oCell = oTable.Cell(iIndex+2, 1);
oRange = oCell.GetRange();
oRange.InsertAfter(it->first);
oCell = oTable.Cell(iIndex+2, 2);
oRange = oCell.GetRange();
oRange.InsertAfter(XString(_T("%.3f"), it->second));
iIndex++;
}
wordSelection = wordApplication.GetSelection();
wordSelection.GoTo(COleVariant((short)3), // 3 = wdGoToLine
COleVariant((short)-1),vtOptional,vtOptional); // -1 = wdGoToLast
wSelection = wordApplication.GetSelection();
wSelection.TypeParagraph();
wordSelection.TypeText(_T("三、计算结果:"));
Selection wSelection2 = wordApplication.GetSelection();
wSelection2.TypeParagraph();
wordSelection.TypeText(_T("主干管线信息:\n")); //画表格
int rows(len+1), columns(7);
wSelection = wordApplication.GetSelection();
oRange = wSelection.GetRange();
oTables = activeDocument.GetTables();
oTable = oTables.Add(oRange, rows, columns);
// cet 2010.3.25 add
Borders oBorders = oTable.GetBorders();
oBorders.SetInsideLineStyle(1); // 设置表格线型
oBorders.SetOutsideLineStyle(1);
oColumns = oTable.GetColumns();
oColumn = oColumns.Item(1);
oColumn.SetWidth(60, 0); // 0 = wdAdjustNone
oColumn = oColumns.Item(2);
oColumn.SetWidth(60, 0);
oColumn = oColumns.Item(3);
oColumn.SetWidth(70, 0);
oColumn = oColumns.Item(4);
oColumn.SetWidth(50, 0);
oColumn = oColumns.Item(5);
oColumn.SetWidth(50, 0);
oColumn = oColumns.Item(6);
oColumn.SetWidth(65, 0);
oColumn = oColumns.Item(7);
oColumn.SetWidth(75, 0);
oCell = oTable.Cell(1, 1);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("管段名称"));
oCell = oTable.Cell(1, 2);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("管径mm"));
oCell = oTable.Cell(1, 3);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("管道流量L/s"));
oCell = oTable.Cell(1, 4);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("管长m"));
oCell = oTable.Cell(1, 5);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("流速m/s"));
oCell = oTable.Cell(1, 6);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("水力坡降‰"));
oCell = oTable.Cell(1, 7);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("管材"));
for(int i=0; i<len; i++){
CString csTmp;
oCell = oTable.Cell(i+2, 1); //管段名称
oRange = oCell.GetRange();
oRange.InsertAfter(lstNode[i]->m_csName);
csTmp.Format(_T("%d"), lstNode[i]->m_iDn);
oCell = oTable.Cell(i+2, 2);
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nPipeQ);
oCell = oTable.Cell(i+2, 3); //管道流量L/s
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
// if(DocGetMeterUnitDraw())
// csTmp.Format(_T("%.2f"), lstNode[i]->m_nLength);
// else
csTmp.Format(_T("%.2f"), lstNode[i]->m_nLength);
oCell = oTable.Cell(i+2, 4); //管长m
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstNode[i]->m_nV);
oCell = oTable.Cell(i+2, 5); //流速m/s
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.3f"), lstNode[i]->m_nI);
oCell = oTable.Cell(i+2, 6); //水力坡降mH2O/m
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
OPENOBJ_BEGIN(lstNode[i]->m_ID, AcDb::kForRead, CDbPipe, pPipe);
if(pPipe){
csTmp = GetPipeMaterialByIdx(pPipe->GetMaterial());
}
OPENOBJ_END();
oCell = oTable.Cell(i+2, 7); //管材
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
}
wordSelection = wordApplication.GetSelection();
wordSelection.GoTo(COleVariant((short)3), // 3 = wdGoToLine
COleVariant((short)-1),vtOptional,vtOptional); // -1 = wdGoToLast
wSelection = wordApplication.GetSelection();
wSelection.TypeParagraph();
wordSelection.TypeText(_T("主要井信息:\n"));
//画表格
rows = len2+1;
columns = 6;
wSelection = wordApplication.GetSelection();
oRange = wSelection.GetRange();
oTables = activeDocument.GetTables();
oTable = oTables.Add(oRange, rows, columns);
// cet 2010.3.25 add
oBorders = oTable.GetBorders();
oBorders.SetInsideLineStyle(1); // 设置表格线型
oBorders.SetOutsideLineStyle(1);
oColumns = oTable.GetColumns();
oColumn = oColumns.Item(1);
oColumn.SetWidth(50, 0); // 0 = wdAdjustNone
oColumn = oColumns.Item(2);
oColumn.SetWidth(55, 0);
oColumn = oColumns.Item(3);
oColumn.SetWidth(85, 0);
oColumn = oColumns.Item(4);
oColumn.SetWidth(85, 0);
oColumn = oColumns.Item(5);
oColumn.SetWidth(75, 0);
oColumn = oColumns.Item(6);
oColumn.SetWidth(88, 0);
oCell = oTable.Cell(1, 1);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("井编号"));
oCell = oTable.Cell(1, 2);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("流量L/s"));
oCell = oTable.Cell(1, 3);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("汇流面积平方米"));
oCell = oTable.Cell(1, 4);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("总面积平方米"));
oCell = oTable.Cell(1, 5);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("汇流时间min"));
oCell = oTable.Cell(1, 6);
oRange = oCell.GetRange();
oRange.InsertAfter(_T("暴雨强度L/s/顷"));
for(i=0; i<len2; i++){
CString csTmp;
oCell = oTable.Cell(i+2, 1); //管段名称
oRange = oCell.GetRange();
oRange.InsertAfter(lstWell[i]->m_csName);
csTmp.Format(_T("%.2f"), lstWell[i]->m_nPipeQ);
oCell = oTable.Cell(i+2, 2); //管道流量L/s
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.0f"), lstWell[i]->m_nDang);
oCell = oTable.Cell(i+2, 3); //当量长度m
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.0f"), lstWell[i]->m_nStartPress);
oCell = oTable.Cell(i+2, 4);
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstWell[i]->m_nLost);
oCell = oTable.Cell(i+2, 5);
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
csTmp.Format(_T("%.2f"), lstWell[i]->m_nSpare);
oCell = oTable.Cell(i+2, 6); //暴雨强度
oRange = oCell.GetRange();
oRange.InsertAfter(csTmp);
}
wordSelection = wordApplication.GetSelection();
wordSelection.GoTo(COleVariant((short)3), // 3 = wdGoToLine
COleVariant((short)-1),vtOptional,vtOptional); // -1 = wdGoToLast
wSelection = wordApplication.GetSelection();
wSelection.TypeParagraph();
}
*/
//将其它井加入输出列表
void GetOtherWellNode(SSearchPipeList *pListAll, DList<SSearchPipeList> &lstWell)
{
if (pListAll->m_iType == 3) {
SSearchPipeList *pNodeNew = new SSearchPipeList();
pNodeNew->m_iDn = pListAll->m_iDn;
pNodeNew->m_csName = pListAll->m_csName;
pNodeNew->m_nLength = pListAll->m_nLength;
pNodeNew->m_nPipeQ = pListAll->m_nPipeQ;
pNodeNew->m_nDang = pListAll->m_nDang;
pNodeNew->m_nStartPress = pListAll->m_nStartPress;
pNodeNew->m_nI = pListAll->m_nI;
pNodeNew->m_nV = pListAll->m_nV;
pNodeNew->m_nLost = pListAll->m_nLost;
pNodeNew->m_nSpare = pListAll->m_nSpare;
int len = lstWell.Length();
BOOL bFlag = FALSE;
for (int i = 0; i < len; i++) {
if (pNodeNew->m_csName == lstWell[i]->m_csName) {
bFlag = TRUE;
break;
}
}
if (!bFlag)
lstWell.Append(pNodeNew);
}
long len = pListAll->m_lstNode.Length();
for (long i = 0; i < len; i++) {
SSearchPipeList *pList = pListAll->m_lstNode[i];
GetOtherWellNode(pList, lstWell);
}
}
//得到下一个标注节点 根据节点编号是否为空
//3个条件
SSearchPipeList *GetLongestWell(SSearchPipeList *pListAll, SSearchPipeList *pDisadvantage)
{
AcDbObjectId id = NULL;
id = pListAll->m_ID;
double nCurPipeLength(0);
nCurPipeLength = pListAll->m_nLength;
if (pListAll->m_csName == _T("") && pListAll->m_iType == 3) {
int idx = GlobalFunc::GetFirstAncestorSerial(pListAll);
if (pDisadvantage) {
int idx2 = GlobalFunc::GetFirstAncestorSerial(pDisadvantage);
if (idx < idx2) { //条件1: 当前节点的祖先编号小于临时节点的祖先编号
pDisadvantage = pListAll;
}
else if (idx == 0) { //条件2:
if (pDisadvantage && nCurPipeLength > pDisadvantage->m_nLength)
pDisadvantage = pListAll;
}
else if (idx == idx2) {//条件3: 当前节点的祖先编号等于临时节点的祖先编号, 但离起始节点最远
int iParentIdx1 = GlobalFunc::GetAncestorSerial(pListAll);
int iParentIdx2 = GlobalFunc::GetAncestorSerial(pDisadvantage);
if (iParentIdx1 == iParentIdx2) {
if (pDisadvantage && nCurPipeLength > pDisadvantage->m_nLength)
pDisadvantage = pListAll;
}
else if (iParentIdx1 < iParentIdx2 || iParentIdx2 == idx2) {
pDisadvantage = pListAll;
}
}
}
else
pDisadvantage = pListAll; //条件3: 临时节点为空
}
int len = pListAll->m_lstNode.Length();
for (long i = 0; i < len; i++) {
SSearchPipeList *pList = pListAll->m_lstNode[i];
pDisadvantage = GetLongestWell(pList, pDisadvantage);
}
return pDisadvantage;
}
extern BOOL SetWellData(SSearchPipeList *pListAll, BOOL bFeedSys);
//主函数
/*void RainCalc()
{
Entity entMainPipe, entLongWell;
//RBList rbMaskPipe(RTDXF0, _T("AEC_ZT_PIPE"), 8, LAY_PIPE_RAIN, NULL);
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
RBList rbMaskMain = ads_buildlist( -4, _T("<or"),
-4, _T("<and"), RTDXF0, _T("AEC_ZT_PIPE"), 8, LAY_PIPE_RAIN, -4, _T("and>"),
-4, _T("<and"), RTDXF0, _T("AEC_ZT_WELL"), 8, LAY_WELL_RAIN, -4, _T("and>"),
-4, _T("or>"), NULL);
if(GlobalFunc::SelectEntity(_T("\n请选择排出干管或排出井<退出>"), entMainPipe, rbMaskMain) != RTNORM) {
return;
}
SSearchPipeList *pListAll = new SSearchPipeList();
PickSet ssAll(SS_FREE);
ssAll += entMainPipe;
if(!GlobalFunc::SearchSprinkPipeSys(entMainPipe, NULL, pListAll, ssAll)){
AfxMessageBox(_T("雨水系统有回路!"));
delete pListAll;
return;
}
if(!GlobalFunc::CalcLstPipeLength(pListAll, NULL, ssAll)){
AfxMessageBox(_T("雨水系统没有标注管径,请先执行命令[管径标注]"));
delete pListAll;
return;
}
if(pListAll->m_lstNode.Length() == 2 && entMainPipe.Is(_T("AEC_ZT_PIPE"))){
ssAll.Free();
//计算源头应为节点,而不是管线. 以下计算管线2节点哪个是源头
CalcWellNum(pListAll);
SSearchPipeList *p1 = pListAll->m_lstNode[0];
SSearchPipeList *p2 = pListAll->m_lstNode[1];
SSearchPipeList *p3 = p1->m_iNum > p2->m_iNum ? p2 : p1;
ads_name ent;
acdbGetAdsName(ent, p3->m_ID);
delete pListAll;
pListAll = new SSearchPipeList();
//重新搜索系统
if(!GlobalFunc::SearchSprinkPipeSys(ent, NULL, pListAll, ssAll)){
AfxMessageBox(_T("雨水系统有回路!"));
delete pListAll;
return;
}
GlobalFunc::CalcLstPipeLength(pListAll, NULL, ssAll);
pListAll->m_iType = GlobalFunc::GetNodeType(ent);
}
XPoint ptLow, ptUp;
ssAll.GetExtend(ptLow, ptUp);
GlobalFunc::AssureInCurrentView(ptLow, ptUp);
//UpdateRainWellArea(); zxl 20131218 del 汇流面积新实体能实时更新井的汇流面积
ssAll.Redraw(3);
SSearchPipeList *pNodeLong = GetLongestWell(pListAll, NULL);
if(pNodeLong == NULL){
ssAll.Redraw(4);
delete pListAll;
return;
}
if(!SetWellName(pListAll)){
AfxMessageBox(_T("没有完整输入井编号!"));
delete pListAll;
return;
}
BOOL bHasArea(FALSE);
SetWellArea(pListAll, bHasArea);
if(!bHasArea){
AfxMessageBox(_T("没有完整输入汇流面积!"));
delete pListAll;
return;
}
if(CheckWellSys(pListAll, TRUE) == FALSE){
ssAll.Redraw(4);
delete pListAll;
return;
}
CString csDwb = g_csDwbPath + _T("TwtSys");
XString xsTmp;
Entity entBlk;
if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000069"), xsTmp) != RTNORM ){
delete pListAll;
return;
}
OPENOBJ_BEGIN(pNodeLong->m_ID, AcDb::kForRead, CDbPipeNode, pNode);
if(pNode){
XPoint pt = pNode->GetLocation();
GlobalFunc::InsertBlock((const TCHAR*)xsTmp, asPnt3d(pt), 20*GlobalFunc::DocGetPScale(), 20*GlobalFunc::DocGetPScale(), 0, _T("0"));
entBlk.GetLast();
}
OPENOBJ_END();
if(GlobalFunc::SelectEntity(_T("\n请选择最远井<系统搜索>:"), entLongWell, rbMask) != RTNORM || !entLongWell.In(&ssAll)) {
AcDbObjectId id = pNodeLong->m_ID;
ads_name entTmp;
acdbGetAdsName(entTmp, id);
entLongWell = entTmp;
}
DoDimPipeSerialNumber(pListAll);
//2008-6-5 SB 改到对话框参数实现
// ssAll.Redraw(3);
// double nTime(10);
// ads_getreal(_T("\n请输入最远井汇流时间<10分钟>:"), &nTime);
// ssAll.Redraw(4);
// GlobalFunc::WriteXdata(entLongWell, _T("TG-WELLTIME"), XString(_T("%.1f"), nTime));
pNodeLong = GetWellNode(pListAll, entLongWell, NULL);
// pNodeLong->m_nLost = nTime;
// ssAll.Redraw(4);
entBlk.Erase();
CTemporaryResourceOverride vTemp;
CCalcRainWellDlg dlg;
dlg.m_pListAll = pListAll;
dlg.m_ssAll += ssAll;
dlg.m_pNodeLong = pNodeLong;
if(dlg.DoModal() != IDOK){
delete pListAll;
return;
}
delete pListAll;
return;
}
*/