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

833 lines
21 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 <map>
#include "globalFunc.h"
#include <functional>
#include "AcDbObjectPtr.h"
#include "DbPipe.h"
#include "Dbwell.h"
#include "dbGridSheet.h"
#include "PickEntSet.h"
#include "RBGroups.h"
extern CString GetLayerNames(const TCHAR * szTgSubName);
typedef struct
{
CString strPipeType; // 管道类型
CString strPipeSpec; // 管道规格
CString strPipeHigh; // 管道高程
CString strHighType; // 标高类型
CString strOppositePos; // 相对位置
}PIPEINFO;
typedef struct
{
CString strNum; // 交点编号
PIPEINFO pipeInfo1;
PIPEINFO pipeInfo2;
CString strDist; // 垂直净距
CString strRemark; // 备注
}TABLEIFO;
//用于比较编号大小
class LESS
{
public:
bool operator() (const CString &strA, const CString &strB) const
{
CString strChA, strChB, strNumA, strNumB;
SplitString(strA, strChA, strNumA);
SplitString(strB, strChB, strNumB);
if (strChA < strChB)
{
return true;
}
else if (strChA > strChB)
{
return false;
}
else
{
int nA = 0, nB = 0;
nA = _ttoi(strNumA);
nB = _ttoi(strNumB);
if (nA <= nB)
{
return true;
}
return false;
}
return true;
}
private:
void SplitString(const CString &str, CString &strCh, CString &strNum) const
{
int nLen = str.GetLength();
int i = nLen - 1;
TCHAR ch;
for (; i >= 0; i--)
{
ch = str.GetAt(i);
if (ch >= _T('0') && ch <= _T('9'))
{
continue;
}
break;
}
strNum = str.Right(nLen - i - 1);
strCh = str.Left(i + 1);
}
};
// 获取管道高程
// 输入: strPipeTye 管道类型; ptIns 交叉编号图块插入点
// 输出: dHigh 管道高程; strHighType 标高类型
void GetPipeElevation(const CDbPipe *pPipe, const XPoint &ptIns, const CString &strPipeType, double &dHigh, CString &strHighType)
{
if (pPipe != NULL)
{
// cet 2013.1.24 modify 给水、中水、消防有低中高三种类型,名称不同
// if(strPipeType.Compare(_T("给水")) == 0 || strPipeType.Compare(_T("中水")) == 0
// || strPipeType.Compare(_T("消防")) == 0)
// zxl 2013.07.05 modify 其他管线都为压力流
// if(strPipeType.Find(_T("给水")) != -1 || strPipeType.Find(_T("中水")) != -1
// || strPipeType.Find(_T("消防")) != -1 || strPipeType.Find(_T("喷淋")) != -1)
// {
strHighType = _T("CEN"); // 管子中心的标高
// }
// else
if (strPipeType.Compare(_T("污水")) == 0 || strPipeType.Compare(_T("废水")) == 0
|| strPipeType.Compare(_T("雨水")) == 0 || strPipeType.Compare(_T("其它管")) == 0)
{
strHighType = _T("BOT"); // 管内底标高
}
double dUnitMeter = 1000;
if(GlobalFunc::DocGetMeterUnitDraw())
{
dUnitMeter = 1;
}
double dI = pPipe->GetPipeGradient();
double dn = pPipe->GetDnDiameter();
int iMaterial = pPipe->GetMaterial();
CString csMat = GlobalFunc::GetPipeMaterialByIdx(iMaterial);
dn = GlobalFunc::GetPipeDjByDn(csMat, (int)dn); //内径
// zxl modify 2013.07.04
// TPipeSys::FlowDirection dir = pPipe->GetFlowDir();
// XPoint ptWell;
// if(dir == TPipeSys::kFromStart)
// {
// if (strHighType.Compare(_T("CEN")) == 0)
// {
// dHigh = pPipe->StartPoint().z / dUnitMeter;
// }
// else
// {
// dHigh = pPipe->StartPoint().z / dUnitMeter - dn / 2;
// }
// ptWell = pPipe->StartPoint();
// }
// else
// {
// if (strHighType.Compare(_T("CEN")) == 0)
// {
// dHigh = pPipe->EndPoint().z / dUnitMeter;
// }
// else
// {
// dHigh = pPipe->EndPoint().z / dUnitMeter - dn / 2;
// }
// ptWell = pPipe->EndPoint();
// }
// ptWell.z = 0;
// double nDistWell = ads_distance(ptIns, ptWell) / dUnitMeter;
// dHigh = dHigh - nDistWell * dI;
AcGePoint3d pt = ptIns;
pt.z = 100;
AcDbLine line(pt, ptIns);
AcGePoint3dArray arrays;
arrays.setLogicalLength(0);
line.intersectWith(pPipe, AcDb::kExtendBoth, arrays);
if (arrays.length() == 1)
{
pt = arrays[0];
}
if (strHighType.Compare(_T("CEN")) == 0)
{
dHigh = pt.z / dUnitMeter;
}
else
{
dHigh = pt.z / dUnitMeter - dn / 2;
}
}
}
// 获取图块插入点和编号
// zxl 2013.07.05 modify
// void GetBlockPosNum(Entity &ent, XPoint &ptIns, CString& strNum)
void GetBlockPosNum(Entity &ent, XPoint &ptIns, CString& strNum, double &dSc)
{
AcDbBlockReference *pRef = NULL;
AcDbObjectId ident;
acdbGetObjectId(ident, ent);
acdbOpenObject(pRef, ident, AcDb::kForRead);
if (pRef != NULL)
{
ptIns = pRef->position();
// zxl 2013.07.05 add
AcGeScale3d sc = pRef->scaleFactors();
dSc = sc[0];
AcDbObjectIterator *pIter=pRef->attributeIterator();
if (pIter != NULL)
{
AcDbObjectId idAtt = AcDbObjectId::kNull;
for (pIter->start(); !pIter->done(); pIter->step())
{
idAtt = pIter->objectId();
AcDbEntity *pEntAtrri = NULL;
Acad::ErrorStatus stus = acdbOpenAcDbEntity(pEntAtrri, idAtt, AcDb::kForWrite);
if (stus == Acad::eOk)
{
AcDbAttribute *pAtt = AcDbAttribute::cast(pEntAtrri);
if (pAtt != NULL)
{
TCHAR *pszName = pAtt->tag(); //得到标记
if(_tcsicmp(pszName, _T("交点编号")) == 0)
{
strNum = pAtt->textString();
}
}
pEntAtrri->close();
}
}
delete pIter;
pIter = NULL;
}
pRef->close();
}
}
// 获取两管相对位置
void GetPipeOppositePos(const AcDbObjectId id1, const AcDbObjectId id2, CString &strPos1, CString &strPos2)
{
CDbPipe *pPipe1 = NULL, *pPipe2 = NULL;
AcGePoint3d ptS1, ptS2, ptE1, ptE2;
double dDia1 = 0.0, dDia2 = 0.0;
acdbOpenObject(pPipe1, id1, AcDb::kForRead);
if (pPipe1 != NULL)
{
ptS1 = pPipe1->StartPoint();
ptE1 = pPipe1->EndPoint();
dDia1 = GlobalFunc::GetPipeOutDByDn(pPipe1->GetMaterial(), pPipe1->GetDnDiameter());
pPipe1->close();
}
acdbOpenObject(pPipe2, id2, AcDb::kForRead);
if (pPipe2 != NULL)
{
ptS2 = pPipe2->StartPoint();
ptE2 = pPipe2->EndPoint();
dDia2 = GlobalFunc::GetPipeOutDByDn(pPipe2->GetMaterial(), pPipe2->GetDnDiameter());
pPipe2->close();
}
// 构造经过原点的平面
AcGeVector3d vePipe1, vePipe2;
vePipe1 = ptE1 - ptS1;
vePipe2 = ptE2 - ptS2;
AcGePlane plan(AcGePoint3d::kOrigin, vePipe1, vePipe2);
AcGePoint3d pt1, pt2;
pt1 = ptS1.orthoProject(plan); // 获得管线上的一点到平面的投影
pt2 = ptS2.orthoProject(plan);
double dDist1 = 0.0, dDist2 = 0.0;
dDist1 = pt1.distanceTo(ptS1);
dDist2 = pt2.distanceTo(ptS2);
if (dDist1 >= dDist2)
{
strPos1 = _T("上行");
strPos2 = _T("下行");
}
else
{
strPos1 = _T("下行");
strPos2 = _T("上行");
}
}
// 垂直净距
// 重新定义垂直净距 zxl 2013.07.04 modify
// double Get2PipeDistance(const AcDbObjectId id1, const AcDbObjectId id2)
double Get2PipeDistance(const AcDbObjectId id1, const AcDbObjectId id2, const AcGePoint3d ptInt)
{
double dDist = 0.0;
CDbPipe *pPipe1 = NULL, *pPipe2 = NULL;
AcGePoint3d ptS1, ptS2, ptE1, ptE2;
double dDia1 = 0.0, dDia2 = 0.0;
AcGePoint3d pt = ptInt;
pt.z = 100;
AcDbLine line(ptInt, pt);
AcGePoint3dArray arrays;
acdbOpenObject(pPipe1, id1, AcDb::kForRead);
if (pPipe1 != NULL)
{
// zxl 2013.07.04 modify
// ptS1 = pPipe1->StartPoint();
// ptE1 = pPipe1->EndPoint();
arrays.setLogicalLength(0);
line.intersectWith(pPipe1, AcDb::kExtendBoth, arrays);
if (arrays.length() == 1)
{
pt = arrays[0];
}
dDia1 = GlobalFunc::GetPipeOutDByDn(pPipe1->GetMaterial(), pPipe1->GetDnDiameter());
pPipe1->close();
}
acdbOpenObject(pPipe2, id2, AcDb::kForRead);
if (pPipe2 != NULL)
{
// zxl 2013.07.04 modify
// ptS2 = pPipe2->StartPoint();
// ptE2 = pPipe2->EndPoint();
arrays.setLogicalLength(0);
line.intersectWith(pPipe2, AcDb::kExtendBoth, arrays);
if (arrays.length() == 1)
{
ptS2 = arrays[0];
}
dDia2 = GlobalFunc::GetPipeOutDByDn(pPipe2->GetMaterial(), pPipe2->GetDnDiameter());
pPipe2->close();
}
// zxl 2013.07.04 modify
// AcGeVector3d vePipe1, vePipe2;
// vePipe1 = ptE1 - ptS1;
// vePipe2 = ptE2 - ptS2;
// AcGePlane plan(ptS1, vePipe1, vePipe2);
// AcGePoint3d pt;
// pt = ptS2.orthoProject(plan);
double dUnitMeter = 1;
if(GlobalFunc::DocGetMeterUnitDraw())
{
dUnitMeter = 1000;
}
dDist = pt.distanceTo(ptS2) - (dDia1 + dDia2) / (2 * dUnitMeter);
// 转换为m
if (!GlobalFunc::DocGetMeterUnitDraw())
{
dDist /= 1000;
}
return dDist;
}
void InsPerpeDistTable(std::multimap<CString, TABLEIFO, LESS> &mapData)
{
double nTextSize = g_Option::instance().g_nSheetHeight; //字高
double nTableHeight = g_Option::instance().g_nSheetHeight+2;
XPoint pt;
if(acedGetPoint(NULL, _T("\n点取表格左上角位置"), pt) != RTNORM)
{
return;
}
AcDbObjectId idTextStyle=GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csSheetStyle);
CDbSheet *pSheet = new CDbSheet;
GridStyle gridStyle;
gridStyle.SetOverrideAll(TRUE);
gridStyle.SetTextHeight(nTextSize);
gridStyle.SetTextStyleId(idTextStyle);
SheetTitle &title=pSheet->GetTitle();
title.SetHeight(7.0);
title.SetText(_T("管道交叉垂距表"));
GridStyle &gridStyle2=title.GetGridStyle();
gridStyle2.SetTextHeight(nTextSize);
gridStyle2.SetTextStyleId(idTextStyle);
DividerStyle &style=title.GetDividerStyle();
style.SetDividerFlag(DividerStyle::kNone);
gridStyle.SetHorMode(AcDb::kTextCenter);
gridStyle.SetVerMode(AcDb::kTextVertMid);
gridStyle.SetLineSpaceFactor(0.2);
gridStyle.SetTextWrap(FALSE);
pSheet->SetGridStyle(gridStyle);
pSheet->SetRowHeight(nTableHeight);
pSheet->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0));
int nAllRow(0);
nAllRow = (int)mapData.size() * 2;
pSheet->InitSheet(nAllRow + 1, 8, nTableHeight, 50);
SheetColumn column;
column.SetWidth(15); //交点编号
pSheet->SetColumnAt(0, column);
column.SetWidth(15); //管道类型
pSheet->SetColumnAt(1, column);
column.SetWidth(15); //管道规格
pSheet->SetColumnAt(2, column);
column.SetWidth(20); //管道高程
pSheet->SetColumnAt(3, column);
column.SetWidth(15); //标高类型
pSheet->SetColumnAt(4, column);
column.SetWidth(15); //相对位置
pSheet->SetColumnAt(5, column);
column.SetWidth(20); //垂直净距
pSheet->SetColumnAt(6, column);
column.SetWidth(15); //备注
pSheet->SetColumnAt(7, column);
GridCell &cell=*(*pSheet)(0, 0);
cell.SetText(_T("交点编号"));
GridCell &cell2=*(*pSheet)(0, 1);
cell2.SetText(_T("管道类型"));
GridCell &cell3=*(*pSheet)(0, 2);
cell3.SetText(_T("管道规格"));
GridCell &cell4=*(*pSheet)(0, 3);
cell4.SetText(_T("管道高程(m)"));
GridCell &cell5=*(*pSheet)(0, 4);
cell5.SetText(_T("标高类型"));
GridCell &cell6=*(*pSheet)(0, 5);
cell6.SetText(_T("相对位置"));
GridCell &cell7=*(*pSheet)(0, 6);
cell7.SetText(_T("垂直净距(m)"));
GridCell &cell8=*(*pSheet)(0, 7);
cell8.SetText(_T("备注"));
pSheet->SetLocation(GlobalFunc::Ucs2Wcs(pt));
int index=0;
std::multimap<CString, TABLEIFO, LESS>::iterator iter;
TABLEIFO info;
for(iter = mapData.begin(); iter != mapData.end(); iter++)
{
info = (*iter).second;
index++;
index++;
pSheet->MergeCells(index - 1, 0, index, 0);
GridCell &Cell11=*(*pSheet)(index, 0);
Cell11.SetText(info.strNum);
GridCell &Cell12=*(*pSheet)(index - 1, 1);
Cell12.SetText(info.pipeInfo1.strPipeType);
GridCell &Cell22=*(*pSheet)(index, 1);
Cell22.SetText(info.pipeInfo2.strPipeType);
GridCell &Cell13=*(*pSheet)(index - 1, 2);
Cell13.SetText(info.pipeInfo1.strPipeSpec);
GridCell &Cell23=*(*pSheet)(index, 2);
Cell23.SetText(info.pipeInfo2.strPipeSpec);
GridCell &Cell14=*(*pSheet)(index - 1, 3);
Cell14.SetText(info.pipeInfo1.strPipeHigh);
GridCell &Cell24=*(*pSheet)(index, 3);
Cell24.SetText(info.pipeInfo2.strPipeHigh);
GridCell &Cell15=*(*pSheet)(index - 1, 4);
Cell15.SetText(info.pipeInfo1.strHighType);
GridCell &Cell25=*(*pSheet)(index, 4);
Cell25.SetText(info.pipeInfo2.strHighType);
GridCell &Cell16=*(*pSheet)(index - 1, 5);
Cell16.SetText(info.pipeInfo1.strOppositePos);
GridCell &Cell26=*(*pSheet)(index, 5);
Cell26.SetText(info.pipeInfo2.strOppositePos);
pSheet->MergeCells(index - 1, 6, index, 6);
GridCell &Cell17=*(*pSheet)(index, 6);
Cell17.SetText(info.strDist);
pSheet->MergeCells(index - 1, 7, index,7);
GridCell &Cell18=*(*pSheet)(index, 7);
Cell18.SetText(info.strRemark);
}
GlobalFunc::AddToCurrentSpace(pSheet, Adesk::kTrue);
}
// 改变图块颜色
void SetBlockColor(const AcDbObjectId idBlock, int nColor)
{
AcDbBlockReference *pRef = NULL;
Acad::ErrorStatus sts = acdbOpenObject(pRef, idBlock, AcDb::kForWrite);
if (pRef != NULL)
{
//设置块颜色
pRef->setColorIndex(nColor);
AcDbObjectId idBlkRec = AcDbObjectId::kNull;
idBlkRec = pRef->blockTableRecord();
if (!idBlkRec.isValid())
{
return;
}
//设置块引用颜色
AcDbBlockTableRecord *pBlkRec = NULL;
Acad::ErrorStatus st = acdbOpenObject(pBlkRec, idBlkRec, AcDb::kForWrite);
if (pBlkRec != NULL)
{
AcDbBlockTableRecordIterator *pItr = NULL;
pBlkRec->newIterator(pItr);
AcDbEntity *pEnt = NULL;
for (pItr->start(); !pItr->done(); pItr->step())
{
pItr->getEntity(pEnt, AcDb::kForWrite);
if (pEnt != NULL)
{
pEnt->setColorIndex(nColor);
pEnt->close();
}
}
pBlkRec->close();
delete pItr;
pItr = NULL;
}
//设置属性字颜色
AcDbObjectIterator *pIter=pRef->attributeIterator();
if (pIter != NULL)
{
AcDbObjectId idAtt = AcDbObjectId::kNull;
for (pIter->start(); !pIter->done();pIter->step())
{
idAtt = pIter->objectId();
AcDbEntity *pEntAtrri = NULL;
Acad::ErrorStatus stus = acdbOpenAcDbEntity(pEntAtrri, idAtt, AcDb::kForWrite);
if (stus == Acad::eOk)
{
AcDbAttribute *pAtt = AcDbAttribute::cast(pEntAtrri);
if (pAtt != NULL)
{
pAtt->setColorIndex(nColor);
}
pEntAtrri->close();
}
}
delete pIter;
pIter = NULL;
}
pRef->close();
}
}
// 检查有几根管线经过ptIns点,并将经过ptIns点的管线保存于ssSel中
void CheckIsPtOnPipe(XPoint ptIns, PickSet& ssSel)
{
Entity ent;
XPoint pt1, pt2, pt3;
ptIns.z = 0;
PickSet ssAll(SS_FREE);
for (long i = 0; i < ssSel.Length(); i++)
{
ent = ssSel[i];
GlobalFunc::GetPipePoint(ent, pt1, pt2);
pt1.z = 0;
pt2.z = 0;
AcDbLine line(pt1, pt2);
line.getClosestPointTo(ptIns, pt3);
if (ptIns.Distance(pt3) < 1e-3)
{
ssAll += ent;
}
}
ssSel.Free();
ssSel += ssAll;
}
// 垂距表
void PerpeDistanceTable()
{
// 选择交点编号
RBList rbMask(RTDXF0, _T("INSERT"), 8, _T("TWT_室外"), NULL);
PickSet ssAll(SS_FREE);
int nStatus(0);
TCHAR chKey;
INITGET_BEG(0, _T("P"));
nStatus = GlobalFunc::SelectEntities(_T("\n请框选范围{选择闭合pline线(P)}:<整张图>"), ssAll, rbMask, _T("P"), chKey);
INITGET_END();
if (nStatus == RTKWORD) //选择关键字
{
Entity entPoly;
RBList rbMask2(RTDXF0, _T("LWPOLYLINE"), 8, _T("*"), NULL);
if(GlobalFunc::SelectEntity(_T("\n请选择表示范围的闭合PLINE:<退出>"), entPoly, rbMask2) != RTNORM)
{
return;
}
AcDbObjectId idLine;
acdbGetObjectId(idLine, entPoly);
AcDbPolyline *pPLine = NULL;
acdbOpenObject(pPLine, idLine, AcDb::kForRead);
if (pPLine != NULL)
{
if (!pPLine->isClosed())
{
pPLine->close();
return;
}
pPLine->close();
}
XPoly2D poly2(entPoly);
XPoint ptLow3, ptUp3;
poly2.GetExtend(ptLow3, ptUp3);
poly2.TransUCS(RBGroups(0), RBGroups(1)); //RBGroups(0) wcs, RBGroups(1) ucs
RBList rbFence = poly2.Fence();
GlobalFunc::AssureInCurrentView(ptLow3, ptUp3);
ssAll.Get(_T("CP"), rbFence, NULL, rbMask);
}
else if (nStatus == RTERROR) //默认选择
{
acedSSGet(_T("A"), NULL, NULL, rbMask, ssAll);
}
else if(nStatus != RTNORM)
{
return;
}
if (ssAll.Length() == 0)
{
return;
}
Entity ent;
AcDbObjectId idPipe1, idPipe2;
Entity entPipe1, entPipe2;
AcDbObjectId idBlock;
std::multimap<CString, TABLEIFO, LESS> mapData;
for (long i = 0; i < ssAll.Length(); i++)
{
ent = ssAll[i];
acdbGetObjectId(idBlock, ent);
// 获取图块插入点和属性字编号
XPoint ptIns;
CString strNum;
// zxl 2013.07.05 modify
// GetBlockPosNum(ent, ptIns, strNum);
double dScale = 0.0;
GetBlockPosNum(ent, ptIns, strNum, dScale);
ptIns.z = 0;
// 获取交点编号处的管子
XPoint pt1, pt2, pt3, pt4;
// zxl 2013.07.05 modify
//const double dLen = 2 * DocGetPScale();
const double dLen = 2 * dScale;
ptIns = GlobalFunc::Wcs2Ucs(ptIns);
pt1 = ptIns - AcGeVector3d::kXAxis * dLen + AcGeVector3d::kYAxis * dLen;
pt2 = ptIns - AcGeVector3d::kXAxis * dLen - AcGeVector3d::kYAxis * dLen;
pt3 = pt2 + AcGeVector3d::kXAxis * 2 * dLen;
pt4 = pt1 + AcGeVector3d::kXAxis * 2 * dLen;
ptIns = GlobalFunc::Ucs2Wcs(ptIns);
PickSet ssSel(SS_FREE);
RBList rbMask2(RTDXF0, _T("AEC_ZT_PIPE"), 8, GetLayerNames(_T("管线")), NULL);
RBList rbPt = acutBuildList(RTPOINT,&pt1,RTPOINT,&pt2,RTPOINT,&pt3,RTPOINT,&pt4,NULL);
acedSSGet(_T("CP"),rbPt,NULL,rbMask2,ssSel);
if (ssSel.Length() == 2)
{
entPipe1 = ssSel[0l];
entPipe2 = ssSel[1l];
}
else if (ssSel.Length() > 2)
{
// 检查有几根管线经过ptIns点
CheckIsPtOnPipe(ptIns, ssSel);
if (ssSel.Length() != 2)
{
TABLEIFO info;
info.strNum = strNum;
info.strRemark = _T("错误");
mapData.insert(std::make_pair(strNum, info));
continue;
}
entPipe1 = ssSel[0l];
entPipe2 = ssSel[1l];
}
else
{
TABLEIFO info;
info.strNum = strNum;
info.strRemark = _T("错误");
mapData.insert(std::make_pair(strNum, info));
continue;
}
acdbGetObjectId(idPipe1, entPipe1);
acdbGetObjectId(idPipe2, entPipe2);
// 求交点
GlobalFunc::GetPipePoint(entPipe1, pt1, pt2); // 获取管线起始点
GlobalFunc::GetPipePoint(entPipe2, pt3, pt4);
pt1[Z] = 0;
pt2[Z] = 0;
pt3[Z] = 0;
pt4[Z] = 0;
AcDbLine l1(pt1, pt2), l2(pt3, pt4);
AcGePoint3dArray arPt;
l1.intersectWith(&l2, AcDb::kOnBothOperands, arPt);
AcGePoint3d ptInt;
if (arPt.length() == 1) // 相交
{
ptInt = arPt[0];
}
else // 无交点
{
TABLEIFO info;
info.strNum = strNum;
info.strRemark = _T("错误");
mapData.insert(std::make_pair(strNum, info));
continue;
}
// 获取管子信息
CDbPipe *pPipe1 = NULL;
TPipeSys::SysType sys1;
CString strPipeType1; // 管道类型
CString strPipeSpec1; // 管道规格
double dHigh1 = 0.0; // 管道高程
CString strType1; // 标高类型
acdbOpenObject(pPipe1, idPipe1, AcDb::kForRead);
if (pPipe1 != NULL)
{
sys1 = pPipe1->GetSysType();
CString strLabel = pPipe1->GetLabel();
double dPipeDia = pPipe1->GetDnDiameter();
CString strTmp;
strTmp.Format(_T("%.0f"), dPipeDia);
strPipeSpec1 = strLabel + strTmp;
strPipeType1 = GlobalFunc::GetPipeNameBySys(sys1);
GetPipeElevation(pPipe1, ptInt, strPipeType1, dHigh1, strType1);
pPipe1->close();
}
CDbPipe *pPipe2 = NULL;
TPipeSys::SysType sys2;
CString strPipeType2; // 管道类型
CString strPipeSpec2; // 管道规格
double dHigh2 = 0.0; // 管道高程
CString strType2; // 标高类型
acdbOpenObject(pPipe2, idPipe2, AcDb::kForRead);
if (pPipe2 != NULL)
{
sys2 = pPipe2->GetSysType();
CString strLabel = pPipe2->GetLabel();
double dPipeDia = pPipe2->GetDnDiameter();
CString strTmp;
strTmp.Format(_T("%.0f"), dPipeDia);
strPipeSpec2 = strLabel + strTmp;
strPipeType2 = GlobalFunc::GetPipeNameBySys(sys2);
GetPipeElevation(pPipe2, ptInt, strPipeType2, dHigh2, strType2);
pPipe2->close();
}
CString strPos1, strPos2;
double dDist = 0.0;
// 求两管相对位置: 上行, 下行
// GetPipeOppositePos(idPipe1, idPipe2, strPos1, strPos2); zxl 2013.07.05 modify
if (dHigh1 >= dHigh2)
{
strPos1 = _T("上行");
strPos2 = _T("下行");
}
else
{
strPos1 = _T("下行");
strPos2 = _T("上行");
}
// 求垂直净距
// 重新定义垂直净距 zxl 2013.07.04 modify
// dDist = Get2PipeDistance(idPipe1, idPipe2);
dDist = Get2PipeDistance(idPipe1, idPipe2, ptInt);
// 保存信息
TABLEIFO info;
int nNum = _ttoi(strNum);
info.strNum = strNum;
CString strTmp;
if (strPos1.Compare(_T("上行")) == 0)
{
info.pipeInfo1.strPipeType = strPipeType1;
info.pipeInfo2.strPipeType = strPipeType2;
info.pipeInfo1.strPipeSpec = strPipeSpec1;
info.pipeInfo2.strPipeSpec = strPipeSpec2;
strTmp.Format(_T("%.3f"), dHigh1);
info.pipeInfo1.strPipeHigh = strTmp;
strTmp.Format(_T("%.3f"), dHigh2);
info.pipeInfo2.strPipeHigh = strTmp;
info.pipeInfo1.strHighType = strType1;
info.pipeInfo2.strHighType = strType2;
info.pipeInfo1.strOppositePos = strPos1;
info.pipeInfo2.strOppositePos = strPos2;
}
else
{
info.pipeInfo1.strPipeType = strPipeType2;
info.pipeInfo2.strPipeType = strPipeType1;
info.pipeInfo1.strPipeSpec = strPipeSpec2;
info.pipeInfo2.strPipeSpec = strPipeSpec1;
strTmp.Format(_T("%.3f"), dHigh2);
info.pipeInfo1.strPipeHigh = strTmp;
strTmp.Format(_T("%.3f"), dHigh1);
info.pipeInfo2.strPipeHigh = strTmp;
info.pipeInfo1.strHighType = strType2;
info.pipeInfo2.strHighType = strType1;
info.pipeInfo1.strOppositePos = strPos2;
info.pipeInfo2.strOppositePos = strPos1;
}
if (dDist > 0.0)
{
strTmp.Format(_T("%.3f"), dDist);
info.strDist = strTmp;
}
else
{
info.strDist = _T("相交");
}
mapData.insert(std::make_pair(strNum, info));
}
// 生成表格
InsPerpeDistTable(mapData);
}