9394 lines
232 KiB
C++
9394 lines
232 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbShEarthWorm.h"
|
|
#include "KTCADUtilityEx.h"
|
|
#include "AecDb3dRoadAxisLine.h"
|
|
#include "AecDbEarthWormFitting.h"
|
|
#include "AcDbX3dSolid.h"
|
|
#include "ImpMD5.h"
|
|
#include <vector>
|
|
#include <algorithm>
|
|
#include <fstream>
|
|
#include "AecDbPortRoom.h"
|
|
#include "KTCadUtility.h"
|
|
#include "AecDbXXXDoghouse.h"
|
|
#include "KTModelLayoutXData.h"
|
|
#include "KTSetting.h"
|
|
#include "dbgrip.h"
|
|
#include "AecDbEarthWorm.h"
|
|
#include "CoreTools.h"
|
|
#include "AcGiViewDraw.h"
|
|
|
|
#ifndef EW_EARTHWORMINIT
|
|
#define EW_EARTHWORMINIT _T("EW_EARTHWORMINIT")
|
|
#endif
|
|
|
|
extern Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEnt, AcDbDatabase* pDb = NULL, bool bClose = true);
|
|
int DLLIMPEXP GetConnectedShWorms(const AecDbShEarthWorm* pEW, AcDbObjectIdArray& arIds);
|
|
void DLLIMPEXP OrthoProjected3DSolid(AcDb3dSolid* pSolidClone,const AcGePlane& plan,AcGeMatrix3d& xformPlanToWorld,AcDbVoidPtrArray& arEntPtrs);
|
|
extern AcGePoint3d MidPoint(const AcGePoint3d& pt1,const AcGePoint3d& pt2);
|
|
extern AcGePoint3d MidPoint(AcGePoint2d& pt1,AcGePoint2d& pt2);
|
|
extern void MidPoint(ads_point pt1,ads_point pt2,ads_point ptMid);
|
|
extern double PixelToWcs(int nPixel);
|
|
extern void PushGripMessage(GripMessage&);
|
|
|
|
extern void NameFromEFnctType(EFnctType eType,CString& sTip);
|
|
std::map<CString,PVOID> g_mapSHProMode2Fit; //异型建模数据 和对象映射,加快速度用
|
|
std::map<std::string,PVOID> g_mapSHProModeMD52Fit; //异型建模数据 和对象映射,加快速度用
|
|
Adesk::UInt32 AecDbShEarthWorm::kCurrentVersionNumber = 1;
|
|
extern void transfromRegion(AcDbRegion *pRegion, const AcGePoint3d &ptOnRegion, const AcGeVector3d &vtNormal, const AcGePoint3d &ptOnPlan);
|
|
extern void transfromPoint(AcGePoint3d& ptOn,const AcGePoint3d& ptOnRegion,const AcGeVector3d &vtNormal,const AcGePoint3d &ptOnPlan);
|
|
extern void transfromPointEx(AcGePoint3d& ptOn,const AcGeVector3d &vtNormal,const AcGePoint3d &ptOnPlan);
|
|
|
|
static const Adesk::UInt16 kColorByBlock = 0;
|
|
static const Adesk::UInt16 kRed = 1;
|
|
static const Adesk::UInt16 kYellow = 2;
|
|
static const Adesk::UInt16 kGreen = 3;
|
|
static const Adesk::UInt16 kCyan = 4;
|
|
static const Adesk::UInt16 kBlue = 5;
|
|
static const Adesk::UInt16 kMagenta = 6;
|
|
static const Adesk::UInt16 kWhite = 7;
|
|
static const Adesk::UInt16 kColorByLayer = 256;
|
|
|
|
using namespace GripCback;
|
|
|
|
static void FreeBuffer(int n,AcDbVoidPtrArray& arEntPtrs)
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
while(arEntPtrs.length() > n )
|
|
{
|
|
pEnt = (AcDbEntity*)arEntPtrs.last();
|
|
if (pEnt != NULL)
|
|
{
|
|
pEnt->erase();
|
|
pEnt->close();
|
|
arEntPtrs.removeLast();
|
|
DELETE_PTR(pEnt);
|
|
}
|
|
}
|
|
}
|
|
#define GRIP_MAXNUM_SHEW 2048
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbShEarthWorm, AecDbEwPipeBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_SEARTHWORM,
|
|
"AecDbShEarthWorm"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
AecDbShEarthWorm::AecDbShEarthWorm(void)
|
|
{
|
|
m_bShowTableHead = true; //是否显示表格标题
|
|
|
|
m_nSectionDrawStyle = 0; //俯视0 纵断1 横断 2
|
|
m_nLookDwonDrawStyle = 1; //俯视图,总图单线 0 舱素线(双线) 1
|
|
|
|
m_dSingleLnWidth = AS_MUNITF(1.5f); //总图单线单线绘制线宽 1.5
|
|
m_dBoundaryWidth = AS_MUNITF(1.5f); //舱素线俯视图线宽 1.5
|
|
m_dCtrlDimLineLen = AS_MUNITF(500.0f);//控制点十字长度
|
|
|
|
m_dXDrawScale = 100.0f; //纵向出图比例
|
|
m_dYDrawScale = 100.0f; //横向出图比例;一般不用
|
|
|
|
m_nDraw3DStyle = 0; //全三维 0; 局部剖视(1/4) 1; 水平剖视(1/2) 2;垂直剖视(1/2) 3;
|
|
m_mapSpecXData.SetAt(KEY_SECTIONDRAWSTYLE,0);
|
|
m_mapSpecXData.SetAt(KEY_ADDTIONSHOW_SHORT,TRUE);
|
|
}
|
|
|
|
AecDbShEarthWorm::~AecDbShEarthWorm(void)
|
|
{
|
|
//释放缓存
|
|
if (!cloneMeForDragging())
|
|
{
|
|
FreeBuffer(0,m_ar2DDrableBufPtrs2);
|
|
}
|
|
g_arSHELongParams.removeAll();
|
|
}
|
|
|
|
bool AecDbShEarthWorm::MakeMapBufferFast(byte* pProModel,int nProModelBufLen,LPCTSTR pszLockID)
|
|
{
|
|
if (pProModel == NULL || pszLockID == NULL)
|
|
return false;
|
|
|
|
ImpMD5 md5(pProModel,nProModelBufLen);
|
|
std::string sMd5 = md5.toString();
|
|
|
|
std::map<std::string,PVOID>::iterator it;
|
|
it = g_mapSHProModeMD52Fit.find(sMd5);
|
|
|
|
AecDbEarthWormFitting* pEWFit = NULL;
|
|
if (it != g_mapSHProModeMD52Fit.end())//已经序列化过
|
|
{
|
|
pEWFit = (AecDbEarthWormFitting*)it->second;
|
|
|
|
CString sLockID = pszLockID;
|
|
g_mapSHProMode2Fit.insert(std::make_pair(sLockID,pEWFit));
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
CMemFile file;
|
|
file.Attach((BYTE*)pProModel,nProModelBufLen);
|
|
|
|
pEWFit = new AecDbEarthWormFitting;
|
|
pEWFit->ReadFrom(&file);
|
|
|
|
CString sLockID = pszLockID;
|
|
g_mapSHProMode2Fit.insert(std::make_pair(sLockID,pEWFit));
|
|
|
|
file.Detach();
|
|
g_mapSHProModeMD52Fit.insert(std::make_pair(sMd5,pEWFit));
|
|
}
|
|
catch (...)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = AecDbEwPipeBase::dwgInFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
|
|
//----- Object version number needs to be read first
|
|
Adesk::UInt32 version =0 ;
|
|
if ( (es =pFiler->readUInt32 (&version)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
if ( version > AecDbShEarthWorm::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy) ;
|
|
|
|
Adesk::Int32 nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
AcGePoint3d pt;
|
|
m_arRoadCenPts.removeAll();
|
|
for(int i = 0;i < nLen;i++)
|
|
{
|
|
pFiler->readPoint3d(&pt);
|
|
m_arRoadCenPts.append(pt);
|
|
}
|
|
|
|
nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
m_arOldRoadCenPtrs.removeAll();
|
|
for(int i = 0;i < nLen;i++)
|
|
{
|
|
pFiler->readPoint3d(&pt);
|
|
m_arOldRoadCenPtrs.append(pt);
|
|
}
|
|
|
|
//纵断表格头
|
|
pFiler->readBool(&m_bShowTableHead);
|
|
|
|
//管廊显示俯视图 2D
|
|
pFiler->readUInt16(&m_nSectionDrawStyle);
|
|
pFiler->readUInt16(&m_nLookDwonDrawStyle);
|
|
|
|
//float m_dSingleLnWidth; //总图单线单线绘制线宽 1.5 mm
|
|
pFiler->readBytes(&m_dSingleLnWidth,sizeof(float));
|
|
|
|
//float m_dBoundaryWidth; //舱素线俯视图线宽 0.5 mm
|
|
pFiler->readBytes(&m_dBoundaryWidth,sizeof(float));
|
|
|
|
//float m_dCtrlDimLineLen; //控制线十字长度 500.0 mm
|
|
pFiler->readBytes(&m_dCtrlDimLineLen,sizeof(float));
|
|
|
|
//float m_dXDrawScale; //纵向出图比例;
|
|
pFiler->readBytes(&m_dXDrawScale,sizeof(float));
|
|
|
|
//float m_dYDrawScale; //横向出图比例;一般不用
|
|
pFiler->readBytes(&m_dYDrawScale,sizeof(float));
|
|
|
|
//管廊显示 3D样式
|
|
pFiler->readUInt16(&m_nDraw3DStyle);
|
|
|
|
nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
pFiler->readPoint3d(&pt);
|
|
m_arWaterwaySize.append(pt);
|
|
}
|
|
|
|
//float m_dWaterwayGrad; //排水沟地面梯度
|
|
pFiler->readBytes(&m_dWaterwayGrad,sizeof(float));
|
|
|
|
//3.桩号点
|
|
m_arStackPts.removeAll();
|
|
|
|
nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
EWStackPoint sp;
|
|
memset(&sp,0,sizeof(EWStackPoint));
|
|
|
|
Adesk::Int32 nSizeBuf = 0;
|
|
TCHAR* pszTxt = NULL;
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
pFiler->readPoint3d(&sp.ptPos);
|
|
|
|
pFiler->readString(&pszTxt);
|
|
if (pszTxt != NULL)
|
|
{
|
|
_tcscpy(sp.szStake,pszTxt);
|
|
acutDelString(pszTxt);
|
|
pszTxt = NULL;
|
|
}
|
|
|
|
pFiler->readString(&pszTxt);
|
|
if (pszTxt != NULL)
|
|
{
|
|
_tcscpy(sp.szRever,pszTxt);
|
|
acutDelString(pszTxt);
|
|
pszTxt = NULL;
|
|
}
|
|
|
|
nSizeBuf = 0;
|
|
pFiler->readInt32(&nSizeBuf);
|
|
|
|
if (nSizeBuf > 0)
|
|
{
|
|
sp.pFnNode = new EWFnctNode;
|
|
memset(sp.pFnNode,0,sizeof(EWFnctNode));
|
|
pFiler->readBytes(sp.pFnNode,sizeof(EWFnctNode));
|
|
|
|
nSizeBuf = 0;
|
|
pFiler->readInt32(&nSizeBuf);
|
|
|
|
if (nSizeBuf > 0)
|
|
{
|
|
sp.pFnNode->nProModelBufLen = nSizeBuf;
|
|
sp.pFnNode->pProModelBuffer = new byte[sp.pFnNode->nProModelBufLen];
|
|
|
|
memset(sp.pFnNode->pProModelBuffer,0,sp.pFnNode->nProModelBufLen);
|
|
pFiler->readBytes(sp.pFnNode->pProModelBuffer,sp.pFnNode->nProModelBufLen);
|
|
}
|
|
}
|
|
m_arStackPts.append(sp);
|
|
}
|
|
|
|
//外部关联
|
|
Adesk::Int32 nPortRoomIds = 0;
|
|
pFiler->readInt32(&nPortRoomIds);
|
|
|
|
AcDbSoftPointerId id;
|
|
m_arPortRoomIds.removeAll();
|
|
for (int i = 0;i < nPortRoomIds;i++)
|
|
{
|
|
pFiler->readSoftPointerId(&id);
|
|
m_arPortRoomIds.append(id);
|
|
}
|
|
|
|
//预留数据
|
|
nPortRoomIds = 0;
|
|
pFiler->readInt32(&nPortRoomIds);
|
|
|
|
m_arIDAddtions.removeAll();
|
|
for (int i = 0;i < nPortRoomIds;i++)
|
|
{
|
|
pFiler->readSoftPointerId(&id);
|
|
m_arIDAddtions.append(id);
|
|
}
|
|
|
|
TCHAR * pszStr = NULL;
|
|
pFiler->readString(&pszStr);
|
|
if (pszStr != NULL)
|
|
{
|
|
_tcscpy(m_szReserved,pszStr);
|
|
acutDelString(pszStr);
|
|
}
|
|
|
|
m_arPtReserved.removeAll();
|
|
nPortRoomIds = 0;
|
|
pFiler->readInt32(&nPortRoomIds);
|
|
|
|
AcGePoint3d ptGe;
|
|
for (int i = 0;i < nPortRoomIds;i++)
|
|
{
|
|
pFiler->readPoint3d(&ptGe);
|
|
m_arPtReserved.append(ptGe);
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//----- Save parent class information first.
|
|
Acad::ErrorStatus es = AecDbEwPipeBase::dwgOutFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
|
|
//----- Object version number needs to be saved first
|
|
if ( (es =pFiler->writeUInt32 (AecDbShEarthWorm::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
Adesk::Int32 nLen = 0;
|
|
nLen = m_arRoadCenPts.length();
|
|
|
|
pFiler->writeInt32(nLen);
|
|
for(int i = 0;i < m_arRoadCenPts.length();i++)
|
|
{
|
|
const AcGePoint3d& pt = m_arRoadCenPts.at(i);
|
|
pFiler->writePoint3d(pt);
|
|
}
|
|
|
|
nLen = m_arOldRoadCenPtrs.length();
|
|
pFiler->writeInt32(nLen);
|
|
for(int i = 0;i < m_arOldRoadCenPtrs.length();i++)
|
|
{
|
|
const AcGePoint3d& pt = m_arOldRoadCenPtrs.at(i);
|
|
pFiler->writePoint3d(pt);
|
|
}
|
|
|
|
//纵断表格头
|
|
pFiler->writeBool(m_bShowTableHead);
|
|
|
|
//管廊显示俯视图 2D
|
|
pFiler->writeUInt16(m_nSectionDrawStyle);
|
|
pFiler->writeUInt16(m_nLookDwonDrawStyle);
|
|
|
|
//float m_dSingleLnWidth; //总图单线单线绘制线宽 1.5 mm
|
|
pFiler->writeBytes(&m_dSingleLnWidth,sizeof(float));
|
|
|
|
//float m_dBoundaryWidth; //舱素线俯视图线宽 0.5 mm
|
|
pFiler->writeBytes(&m_dBoundaryWidth,sizeof(float));
|
|
|
|
//float m_dCtrlDimLineLen; //控制线十字长度 500.0 mm
|
|
pFiler->writeBytes(&m_dCtrlDimLineLen,sizeof(float));
|
|
|
|
//float m_dXDrawScale; //纵向出图比例;
|
|
pFiler->writeBytes(&m_dXDrawScale,sizeof(float));
|
|
|
|
//float m_dYDrawScale; //横向出图比例;一般不用
|
|
pFiler->writeBytes(&m_dYDrawScale,sizeof(float));
|
|
|
|
|
|
//管廊显示 3D样式
|
|
pFiler->writeUInt16(m_nDraw3DStyle);
|
|
|
|
pFiler->writeInt32(m_arWaterwaySize.length());
|
|
for (int i = 0;i < m_arWaterwaySize.length();i++)
|
|
{
|
|
pFiler->writePoint3d(m_arWaterwaySize.at(i));
|
|
}
|
|
|
|
//float m_dWaterwayGrad; //排水沟地面梯度
|
|
pFiler->writeBytes(&m_dWaterwayGrad,sizeof(float));
|
|
|
|
//3.写入桩号控制点
|
|
nLen = m_arStackPts.length();
|
|
pFiler->writeInt32(nLen);
|
|
|
|
int nSizeBuf = 0;
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
const EWStackPoint& sp = m_arStackPts.at(i);
|
|
|
|
pFiler->writePoint3d(sp.ptPos);
|
|
pFiler->writeString(sp.szStake);
|
|
pFiler->writeString(sp.szRever);
|
|
|
|
//只写 EWFnctNode 本级别,不考虑pNext
|
|
if (sp.pFnNode != NULL)
|
|
{
|
|
pFiler->writeInt32(sizeof(EWFnctNode));
|
|
pFiler->writeBytes(sp.pFnNode,sizeof(EWFnctNode));
|
|
|
|
if (sp.pFnNode->nProModelBufLen > 0 && sp.pFnNode->pProModelBuffer != NULL)
|
|
{
|
|
pFiler->writeInt32(sp.pFnNode->nProModelBufLen);
|
|
pFiler->writeBytes(sp.pFnNode->pProModelBuffer,sp.pFnNode->nProModelBufLen);
|
|
}
|
|
else
|
|
{
|
|
nSizeBuf = 0;
|
|
pFiler->writeInt32(nSizeBuf);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
nSizeBuf = 0;
|
|
pFiler->writeInt32(nSizeBuf);
|
|
}
|
|
}
|
|
|
|
//外部关联
|
|
//AcDbObjectIdArray m_arPortRoomIds; //接口的外部房子,可以像门窗那样删减移动
|
|
pFiler->writeInt32(m_arPortRoomIds.length());
|
|
for (int i = 0;i < m_arPortRoomIds.length();i++)
|
|
{
|
|
pFiler->writeSoftPointerId(m_arPortRoomIds.at(i));
|
|
}
|
|
|
|
//预留数据
|
|
pFiler->writeInt32(m_arIDAddtions.length());
|
|
for (int i = 0;i < m_arIDAddtions.length();i++)
|
|
{
|
|
pFiler->writeSoftPointerId(m_arIDAddtions.at(i));
|
|
}
|
|
|
|
pFiler->writeString(m_szReserved);
|
|
|
|
pFiler->writeInt32(m_arPtReserved.length());
|
|
for (int i = 0;i < m_arPtReserved.length();i++)
|
|
{
|
|
pFiler->writePoint3d(m_arPtReserved.at(i));
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::copyFrom(const AcRxObject* pSrc)
|
|
{
|
|
AecDbEwPipeBase::copyFrom(pSrc);
|
|
|
|
AecDbShEarthWorm* pSrcSh = AecDbShEarthWorm::cast(pSrc);
|
|
if (pSrcSh != NULL)
|
|
{
|
|
m_arRoadCenPts.removeAll();
|
|
m_arRoadCenPts.append(pSrcSh->m_arRoadCenPts);//设计 道路中心线 pt.z 为标高
|
|
|
|
m_arOldRoadCenPtrs.removeAll();
|
|
m_arOldRoadCenPtrs.append(pSrcSh->m_arOldRoadCenPtrs);//现状 道路中心线 pt.z 为标高
|
|
|
|
m_bShowTableHead = pSrcSh->m_bShowTableHead;//是否显示表格标题
|
|
|
|
|
|
m_nSectionDrawStyle = pSrcSh->m_nSectionDrawStyle;//俯视0 纵断1 横断 2
|
|
m_nLookDwonDrawStyle = pSrcSh->m_nLookDwonDrawStyle;//俯视图,总图单线 0 舱素线(双线) 1
|
|
m_dSingleLnWidth = pSrcSh->m_dSingleLnWidth;//总图单线单线绘制线宽 1.5 mm
|
|
m_dBoundaryWidth = pSrcSh->m_dBoundaryWidth;//舱素线俯视图线宽 0.5 mm
|
|
m_dCtrlDimLineLen = pSrcSh->m_dCtrlDimLineLen; //控制线十字长度 500.0 mm
|
|
m_dXDrawScale = pSrcSh->m_dXDrawScale; //纵向出图比例;
|
|
m_dYDrawScale = pSrcSh->m_dYDrawScale; //横向出图比例;一般不用
|
|
|
|
|
|
m_nDraw3DStyle = pSrcSh->m_nDraw3DStyle;// 全三维 0; 局部剖视(1/4) 1; 水平剖视(1/2) 2;垂直剖视(1/2) 3;
|
|
|
|
|
|
m_arWaterwaySize.removeAll(); //排水沟尺寸位置 x 款,y高 z室位置索引 左0 右1
|
|
m_arWaterwaySize.append(pSrcSh->m_arWaterwaySize);
|
|
|
|
m_dWaterwayGrad = pSrcSh->m_dWaterwayGrad;//排水沟地面梯度
|
|
|
|
m_arStackPts.removeAll(); //节点桩号位置点
|
|
m_arStackPts.append(pSrcSh->m_arStackPts);
|
|
|
|
|
|
m_arPortRoomIds.removeAll(); //接口的外部房子,可以像门窗那样删减移动
|
|
m_arPortRoomIds.append(pSrcSh->m_arPortRoomIds);
|
|
|
|
|
|
m_arIDAddtions.removeAll(); //附属构件
|
|
m_arIDAddtions.append(pSrcSh->m_arIDAddtions);
|
|
|
|
_tcscpy(m_szReserved,pSrcSh->m_szReserved); //预留数据
|
|
m_arPtReserved.removeAll(); //预留数据
|
|
m_arPtReserved.append(pSrcSh->m_arPtReserved);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#if ARX>16
|
|
Acad::ErrorStatus AecDbShEarthWorm::subExplode(AcDbVoidPtrArray& entitySet) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbShEarthWorm::subList() const
|
|
{
|
|
acutPrintf(_T("\n隧道实体..."));
|
|
acutPrintf(_T("\n管廊里程总长:%g 米"),GetLength());
|
|
acutPrintf(_T("\n管廊截面:"));
|
|
|
|
//获取垂直切外径和上下厚度
|
|
AcGePoint2d ptrODtTop,ptrODtBom;
|
|
GetODAndID(ptrODtTop,ptrODtBom);
|
|
|
|
acutPrintf(_T("\n管廊截面垂直方向顶部直径:%d"),ptrODtTop.x);
|
|
acutPrintf(_T("\n管廊截面垂直方向顶部壁厚:%d"),ptrODtTop.y);
|
|
acutPrintf(_T("\n管廊截面垂直方向底部直径:%d"),ptrODtBom.x);
|
|
acutPrintf(_T("\n管廊截面垂直方向底部壁厚:%d"),ptrODtBom.y);
|
|
|
|
double dDistFrom = 0.0;
|
|
AcGePoint3d ptOn;
|
|
AecDb3dRoadAxisLine* pRodLine = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRodLine != NULL)
|
|
{
|
|
for (int i = 0;i < m_arStackPts.length();i++)
|
|
{
|
|
const EWStackPoint& sp = m_arStackPts.at(i);
|
|
acutPrintf(_T("\n节点:"));
|
|
acutPrintf(_T("\n节点桩号:%s"),sp.szStake);
|
|
|
|
pRodLine->getClosestPointTo(sp.ptPos,ptOn);
|
|
dDistFrom = 0.0;
|
|
pRodLine->getDistAtPoint(ptOn,dDistFrom);
|
|
acutPrintf(_T("\n节点里程:%g 米"),dDistFrom);
|
|
|
|
if (sp.pFnNode != NULL)
|
|
{
|
|
switch (sp.pFnNode->eFnType)
|
|
{
|
|
case kVerticalWell:
|
|
{
|
|
acutPrintf(_T("\n节点名称:竖井"));
|
|
break;
|
|
}
|
|
case kProModel:
|
|
{
|
|
acutPrintf(_T("\n节点名称:自定义节点"));
|
|
break;
|
|
}
|
|
}
|
|
acutPrintf(_T("\n节点功能定义:%s"),sp.pFnNode->szNodeDefSpec);
|
|
acutPrintf(_T("\n节点功能描述:%s"),sp.pFnNode->szNodeSpec);
|
|
}
|
|
}
|
|
}
|
|
GetSpecialtyData()->List();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::subGetOsnapPoints(AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& pickPoint,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
assertReadEnabled();
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray& ar2D = Get2DBuffer();
|
|
|
|
AcGePoint3dArray arPts1;
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(i);
|
|
pEnt->getOsnapPoints(osnapMode,gsSelectionMark,pickPoint,lastPoint,viewXform,arPts1,geomIds);
|
|
}
|
|
|
|
if (!arPts1.isEmpty()) snapPoints.append(arPts1);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::subIntersectWith(const AcDbEntity* pEnt,
|
|
AcDb::Intersect intType,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
assertReadEnabled();
|
|
AcDbEntity* pEntT = NULL;
|
|
|
|
if (m_ar2DDrableBufPtrs2.isEmpty())
|
|
{
|
|
const AcDbVoidPtrArray& ar2D = Get2DBuffer();
|
|
AcGePoint3dArray arPts1;
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEntT = (AcDbEntity*)ar2D.at(i);
|
|
pEntT->intersectWith(pEnt,intType,points,thisGsMarker,otherGsMarker);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
const AcDbVoidPtrArray& ar2D = m_ar2DDrableBufPtrs2;
|
|
AcGePoint3dArray arPts1;
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEntT = (AcDbEntity*)ar2D.at(i);
|
|
pEntT->intersectWith(pEnt,intType,points,thisGsMarker,otherGsMarker);
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::subIntersectWith(const AcDbEntity* pEnt,
|
|
AcDb::Intersect intType,
|
|
const AcGePlane& projPlane,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_ar2DDrableBufPtrs2.isEmpty())
|
|
{
|
|
AcDbEntity* pEntT = NULL;
|
|
const AcDbVoidPtrArray& ar2D = Get2DBuffer();
|
|
|
|
AcGePoint3dArray arPts1;
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEntT = (AcDbEntity*)ar2D.at(i);
|
|
pEntT->intersectWith(pEnt,intType,projPlane,points,thisGsMarker,otherGsMarker);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AcDbEntity* pEntT = NULL;
|
|
const AcDbVoidPtrArray& ar2D = m_ar2DDrableBufPtrs2;
|
|
|
|
AcGePoint3dArray arPts1;
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEntT = (AcDbEntity*)ar2D.at(i);
|
|
pEntT->intersectWith(pEnt,intType,projPlane,points,thisGsMarker,otherGsMarker);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::subGetGripPoints(AcDbGripDataPtrArray& grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d& curViewDir,
|
|
const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//如果三维,不显示夹点
|
|
if ( GetDrawDimCur() == 3)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcArray<GripPtSpec> gripPoints;
|
|
ImpGetGripPonts(gripPoints,bitflags);
|
|
|
|
AcGeVector3d vtDir;
|
|
AcGePoint3d ptTmp;
|
|
|
|
//俯视图夹点
|
|
int nIndex = 0;
|
|
bool bIsStart = false;
|
|
double dDistFr = 0.0;
|
|
AcDbGripData* pGripData = NULL;
|
|
for (int i = 0;i < gripPoints.length();i++)
|
|
{
|
|
const GripPtSpec& ptSpec = gripPoints.at(i);
|
|
if (ptSpec.nSpec == kVerticalWell)
|
|
{
|
|
//修改点
|
|
m_pBaseCurve->getFirstDeriv(ptSpec.ptOn,vtDir);
|
|
vtDir.normalize();
|
|
pGripData = NewAcDbGripData(ptSpec.ptOn,vtDir,nIndex++,kVerticalWell,ptSpec.szLockID);
|
|
if (pGripData != NULL) grips.append(pGripData);
|
|
|
|
//删除点
|
|
ptTmp = ptSpec.ptOn + vtDir * PixelToWcs(10);
|
|
pGripData = NewAcDbGripData(ptTmp,vtDir,nIndex++,kGripCtrlErase,ptSpec.szLockID);
|
|
if (pGripData != NULL) grips.append(pGripData);
|
|
}
|
|
else if (ptSpec.nSpec == kProModel)
|
|
{
|
|
//删除点
|
|
m_pBaseCurve->getFirstDeriv(ptSpec.ptOn,vtDir);
|
|
vtDir.normalize();
|
|
pGripData = NewAcDbGripData(ptSpec.ptOn,vtDir,nIndex++,kGripCtrlErase,ptSpec.szLockID);
|
|
if (pGripData != NULL) grips.append(pGripData);
|
|
}
|
|
else
|
|
{
|
|
//托拽点
|
|
m_pBaseCurve->getFirstDeriv(ptSpec.ptOn,vtDir);
|
|
m_pBaseCurve->getDistAtPoint(ptSpec.ptOn,dDistFr);
|
|
vtDir.normalize();
|
|
pGripData = NewAcDbGripData(ptSpec.ptOn,vtDir,nIndex++,kSegCtrlOffset,ptSpec.szLockID);
|
|
if (pGripData != NULL) grips.append(pGripData);
|
|
|
|
if (ptSpec.nSpec == kGripPoint)
|
|
{
|
|
if (!bIsStart)
|
|
{
|
|
ptTmp = ptSpec.ptOn - vtDir * PixelToWcs(10);
|
|
pGripData = NewAcDbGripData(ptTmp,vtDir,nIndex++,kStartOrEnd,dDistFr);
|
|
if (pGripData != NULL) grips.append(pGripData);
|
|
bIsStart = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//2.纵断夹点-> 标高点,坡度点,拖拽点
|
|
AcGePoint3dArray arPts;
|
|
ImpGetVSecGripPonts(arPts,bitflags);
|
|
|
|
AecDbObjXDataMap xData;
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbIntArray osnapModes,geomIds;
|
|
|
|
AcDbCurve* pCurveCen = NULL;
|
|
const AcDbVoidPtrArray &ar2DCrv = Get2DBuffer();
|
|
for (int i = 0;i < ar2DCrv.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2DCrv.at(i);
|
|
if ( xData.Read(pEnt,_T("VERSECCEN") ) )
|
|
{
|
|
pCurveCen = AcDbCurve::cast(pEnt);
|
|
if (pCurveCen != NULL)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
dDistFr = -1.0;
|
|
vtDir = acdbCurDwg()->ucsxdir();
|
|
for (int i = 0;i < arPts.length();i++)
|
|
{
|
|
ptTmp = arPts.at(i);
|
|
|
|
if (pCurveCen != NULL)
|
|
{
|
|
pCurveCen->getDistAtPoint(ptTmp,dDistFr);
|
|
}
|
|
|
|
//标高
|
|
ptTmp -= vtDir * PixelToWcs(15);
|
|
pGripData = NewAcDbGripData(ptTmp,vtDir,nIndex++,kSegElevation,dDistFr);
|
|
if (pGripData != NULL) grips.append(pGripData);
|
|
|
|
//拖拽
|
|
ptTmp += vtDir * PixelToWcs(15);
|
|
pGripData = NewAcDbGripData(ptTmp,vtDir,nIndex++,kSegCtrlOffset,dDistFr);
|
|
if (pGripData != NULL) grips.append(pGripData);
|
|
|
|
//坡度
|
|
//ptTmp += vtDir * PixelToWcs(15);
|
|
//pGripData = NewAcDbGripData(ptTmp,vtDir,nIndex++,kSegGradient,dDistFr);
|
|
//if (pGripData != NULL) grips.append(pGripData);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::subMoveGripPointsAt(const AcDbVoidPtrArray& appData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGeVector3d vtDirX = acdbCurDwg()->ucsxdir();//end-start
|
|
vtDirX.z = 0.0;
|
|
vtDirX.normalize();
|
|
|
|
AcGeVector3d vtOffZ;
|
|
AcGeVector3d vtDirY = vtDirX;
|
|
vtDirY.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
AcGePoint3d ptOn;
|
|
//if (bitflags & AcDbGripOperations::kGripPointsOnly)
|
|
{
|
|
CString sVal;
|
|
if (appData.length() > 0)
|
|
{
|
|
AecGripData* pGripData = (AecGripData*)appData.first();
|
|
if (pGripData != NULL)
|
|
{
|
|
switch (pGripData->nPos)//位置
|
|
{
|
|
case kStartOrEnd:
|
|
{
|
|
//起始标高
|
|
GripMessage msg;
|
|
memset(&msg,0,sizeof(GripMessage));
|
|
msg.nType = 3;
|
|
|
|
msg.idHost = pGripData->idHost;
|
|
msg.nData = pGripData->nIndex;
|
|
msg.pParam = NULL;
|
|
msg.fData = pGripData->ptGrip.z;
|
|
msg.ptGrip = pGripData->ptGrip;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
acedPostCommand(_T("\x03"));
|
|
acedPostCommand(_T("SH_MELE\n"));
|
|
|
|
break;
|
|
}
|
|
case kSegElevation:
|
|
{
|
|
//起始标高
|
|
GripMessage msg;
|
|
memset(&msg,0,sizeof(GripMessage));
|
|
msg.nType = 5;
|
|
|
|
msg.idHost = pGripData->idHost;
|
|
msg.nData = pGripData->nSegIndex;
|
|
msg.pParam = NULL;
|
|
msg.ptGrip = pGripData->ptGrip;
|
|
msg.fData = (float)pGripData->dDistAtPoint;
|
|
|
|
if (Acad::eOk == m_pBaseCurve->getPointAtDist(pGripData->dDistAtPoint,ptOn))
|
|
{
|
|
msg.ptGrip = ptOn;
|
|
PushGripMessage(msg);
|
|
acedPostCommand(_T("\33"));
|
|
acedPostCommand(_T("SH_MSEGE\n"));
|
|
}
|
|
|
|
break;
|
|
}
|
|
case kSegGradient:
|
|
{
|
|
//修改坡度
|
|
GripMessage msg;
|
|
memset(&msg,0,sizeof(GripMessage));
|
|
msg.nType = 6;
|
|
|
|
msg.idHost = pGripData->idHost;
|
|
msg.nData = pGripData->nSegIndex;
|
|
msg.pParam = NULL;
|
|
msg.fData = pGripData->ptGrip.z;
|
|
msg.ptGrip = pGripData->ptGrip;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
acedPostCommand(_T("\x03"));
|
|
acedPostCommand(_T("SH_MSEGG\n"));
|
|
|
|
break;
|
|
}
|
|
case kProModel:
|
|
case kVerticalWell:
|
|
{
|
|
//点击编辑节点
|
|
//acutPrintf(_T("\nLockid = %s"),pGripData->szLockId);
|
|
EWFnctNode* pNode = ImpGetNodeAtLockid(pGripData->szLockId);
|
|
if (pNode != NULL)
|
|
{
|
|
pNode->pFncNodeNext = NULL;
|
|
EWFnctNode* pNewNode = new EWFnctNode;
|
|
memcpy(pNewNode,pNode,sizeof(EWFnctNode) );
|
|
pNewNode->nRoomIndex = pGripData->nRoomIndex;
|
|
|
|
GripMessage msg;
|
|
memset(&msg,0,sizeof(GripMessage));
|
|
msg.nType = 0;
|
|
msg.idHost = pGripData->idHost;
|
|
msg.pParam = pNewNode;
|
|
PushGripMessage(msg);
|
|
|
|
acedPostCommand(_T("\x03"));
|
|
acedPostCommand(_T("SH_MNODE\n"));
|
|
}
|
|
break;
|
|
}
|
|
case kSegCtrlOffset:
|
|
{
|
|
if (pGripData->nSubSegIndex == 1)//纵断
|
|
{
|
|
vtOffZ = offset.orthoProject(vtDirX);//投影到vtDirY上
|
|
ImpMoveGripPointsAt(pGripData,vtOffZ);
|
|
}
|
|
else
|
|
{
|
|
ImpMoveGripPointsAt(pGripData,offset);
|
|
}
|
|
break;
|
|
}
|
|
case kGripCtrlErase://删除
|
|
{
|
|
//acutPrintf(_T("\nLockid = %s"),pGripData->szLockId);
|
|
AecGripData* pNewGrip = new AecGripData;
|
|
memcpy(pNewGrip,pGripData,sizeof(AecGripData));
|
|
pNewGrip->nRoomIndex = pGripData->nRoomIndex;
|
|
|
|
GripMessage msg;
|
|
memset(&msg,0,sizeof(GripMessage));
|
|
msg.nType = 1;
|
|
msg.idHost = pGripData->idHost;
|
|
|
|
msg.pParam = pNewGrip;
|
|
PushGripMessage(msg);
|
|
|
|
acedPostCommand(_T("\x03"));
|
|
acedPostCommand(_T("SH_ENODE\n"));
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
#endif
|
|
|
|
EWFnctNode* AecDbShEarthWorm::ImpGetNodeAtLockid(LPCTSTR pszLockId)
|
|
{
|
|
assertReadEnabled();
|
|
|
|
for (int i = 0;i < m_arStackPts.length();i++)
|
|
{
|
|
EWStackPoint& sp = m_arStackPts.at(i);
|
|
if (sp.pFnNode != NULL && _tcscmp(sp.pFnNode->szLockId,pszLockId) == 0)
|
|
{
|
|
EWFnctNode* pFn = new EWFnctNode;
|
|
memcpy(pFn,sp.pFnNode,sizeof(EWFnctNode));
|
|
return pFn;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::ImpMoveGripPointsAt(AecGripData* pGripData,const AcGeVector3d& offset)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::AdjustVertexZ(double dDistAtPoint,double dZAdd)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::MakeTangentArc(const AcGePoint3d& pt1,const AcGePoint3d& pt2)
|
|
{
|
|
AecDb3dRoadAxisLine* pRoadLn = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadLn != NULL)
|
|
{
|
|
double dDn = 0.0,dRatio = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_RATIO,dRatio);
|
|
m_mapSpecXData.GetAt(PIPE_DN,dDn);
|
|
|
|
AecDbObjXDataMap xData;
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbCurve* pCurveCen = NULL;
|
|
const AcDbVoidPtrArray &ar2DCrv = Get2DBuffer();
|
|
for (int i = 0;i < ar2DCrv.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2DCrv.at(i);
|
|
if ( xData.Read(pEnt,_T("VERSECCEN") ) )
|
|
{
|
|
pCurveCen = AcDbCurve::cast(pEnt);
|
|
if (pCurveCen != NULL)
|
|
{
|
|
AcGePoint3d pt11,pt22;
|
|
pCurveCen->getClosestPointTo(pt1,pt11);
|
|
pCurveCen->getClosestPointTo(pt2,pt22);
|
|
|
|
double dDist1 = 0.0,dDist2 = 0.0;
|
|
pCurveCen->getDistAtPoint(pt11,dDist1);
|
|
pCurveCen->getDistAtPoint(pt22,dDist2);
|
|
|
|
if (Acad::eOk == pRoadLn->getPointAtDist(dDist1,pt11) &&
|
|
Acad::eOk == pRoadLn->getPointAtDist(dDist2,pt22))
|
|
{
|
|
AssertWriteEnabled();
|
|
return pRoadLn->MarkeArcSegFit(pt11,pt22,dDn,dRatio);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
AcDbGripData* AecDbShEarthWorm::NewAcDbGripData(const AcGePoint3d& ptOn,const AcGeVector3d& vtDir,int nIndex,EFnctType nGripType,LPCTSTR pszLockID) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (nIndex < GRIP_MAXNUM_SHEW)
|
|
{
|
|
m_pGripAppData[nIndex].ptGrip = ptOn;
|
|
m_pGripAppData[nIndex].vtDir = vtDir;
|
|
m_pGripAppData[nIndex].nIndex = nIndex;
|
|
m_pGripAppData[nIndex].nPos = nGripType;
|
|
m_pGripAppData[nIndex].idHost = objectId();
|
|
m_pGripAppData[nIndex].nRoomIndex = 0;
|
|
m_pGripAppData[nIndex].nSegIndex = 0;
|
|
m_pGripAppData[nIndex].nSubSegIndex = 0;//俯视0
|
|
|
|
if (pszLockID != NULL)
|
|
{
|
|
_tcscpy(m_pGripAppData[nIndex].szLockId,pszLockID);
|
|
}
|
|
|
|
CString sTip = _T("");
|
|
NameFromEFnctType(nGripType,sTip);
|
|
|
|
if (!sTip.IsEmpty())
|
|
{
|
|
_tcscpy(m_pGripAppData[nIndex].szTip,sTip);
|
|
}
|
|
|
|
//一下信息保存在dwg中,改变GripAppData的结构将对以往图纸产生影响
|
|
AcDbGripData* pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(ptOn);
|
|
pGripData->setAppData((void*)&m_pGripAppData[nIndex]);
|
|
pGripData->setWorldDraw(GripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(GripCback::GripToolTipFunc);
|
|
return pGripData;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbGripData* AecDbShEarthWorm::NewAcDbGripData(const AcGePoint3d& ptOn,const AcGeVector3d& vtDir,int nIndex,EFnctType nGripType,double dDistFr) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (nIndex < GRIP_MAXNUM_SHEW)
|
|
{
|
|
m_pGripAppData[nIndex].ptGrip = ptOn;
|
|
m_pGripAppData[nIndex].vtDir = vtDir;
|
|
m_pGripAppData[nIndex].nIndex = nIndex;
|
|
m_pGripAppData[nIndex].nPos = nGripType;
|
|
m_pGripAppData[nIndex].idHost = objectId();
|
|
m_pGripAppData[nIndex].nRoomIndex = 0;
|
|
m_pGripAppData[nIndex].nSegIndex = 0;
|
|
m_pGripAppData[nIndex].nSubSegIndex = 1;//纵断1
|
|
m_pGripAppData[nIndex].dDistAtPoint = dDistFr;
|
|
|
|
_tcscpy(m_pGripAppData[nIndex].szLockId,_T("*"));
|
|
|
|
CString sTip = _T("");
|
|
NameFromEFnctType(nGripType,sTip);
|
|
|
|
if (!sTip.IsEmpty())
|
|
{
|
|
_tcscpy(m_pGripAppData[nIndex].szTip,sTip);
|
|
}
|
|
|
|
//一下信息保存在dwg中,改变GripAppData的结构将对以往图纸产生影响
|
|
AcDbGripData* pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(ptOn);
|
|
pGripData->setAppData((void*)&m_pGripAppData[nIndex]);
|
|
pGripData->setWorldDraw(GripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(GripCback::GripToolTipFunc);
|
|
return pGripData;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::ImpGetGripPonts(AcArray<GripPtSpec>& gripPoints,const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
//1.节点
|
|
GripPtSpec ptSpec;
|
|
AcGePoint3d ptOn;
|
|
for (int i = 0;i < m_arStackPts.length();i++)
|
|
{
|
|
const EWStackPoint& sp = m_arStackPts.at(i);
|
|
m_pBaseCurve->getClosestPointTo(sp.ptPos,ptOn);
|
|
|
|
ptSpec.ptOn = ptOn;
|
|
ptSpec.nSpec = sp.pFnNode->eFnType;
|
|
gripPoints.append(ptSpec);
|
|
}
|
|
|
|
//2.夹点
|
|
AcGePoint3dArray arPts;
|
|
AcDbIntArray osnapModes,geomIds;
|
|
m_pBaseCurve->getGripPoints(arPts,osnapModes,geomIds);
|
|
|
|
for (int j = 0;j < arPts.length();j++)
|
|
{
|
|
ptSpec.ptOn = arPts.at(j);
|
|
ptSpec.nSpec = kGripPoint;//夹点
|
|
gripPoints.append(ptSpec);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::ImpGetVSecGripPonts(AcGePoint3dArray& arPts,const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptGe;
|
|
AecDbObjXDataMap xData;
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbIntArray osnapModes,geomIds;
|
|
|
|
AcDbPolyline* pPl = NULL;
|
|
const AcDbVoidPtrArray &ar2DCrv = Get2DBuffer();
|
|
for (int i = 0;i < ar2DCrv.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2DCrv.at(i);
|
|
|
|
if ( xData.Read(pEnt,_T("VERSECCEN") ) )
|
|
{
|
|
pPl = AcDbPolyline::cast(pEnt);
|
|
if (pPl != NULL)
|
|
{
|
|
for (int ii = 0;ii < pPl->numVerts();ii++)
|
|
{
|
|
pPl->getPointAt(ii,ptGe);
|
|
arPts.append(ptGe);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbShEarthWorm::AppendPortRoomIds(const AcDbObjectId& id)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
int nFoundAt = -1;
|
|
if (!m_arPortRoomIds.find(id,nFoundAt))
|
|
m_arPortRoomIds.append(id);
|
|
}
|
|
|
|
void AecDbShEarthWorm::GetPortRoomIds(AcDbObjectIdArray& arIds) const
|
|
{
|
|
assertReadEnabled();
|
|
if (m_arPortRoomIds.length() > 0)
|
|
{
|
|
arIds.append(m_arPortRoomIds);
|
|
}
|
|
}
|
|
|
|
int AecDbShEarthWorm::ImpGetSection(AcDb3dSolid* pSolidDraw, const AcGePoint3d& ptFr,const AcGePoint3d& ptTo,const AcGeVector3d& vtViewDir,const AcGeVector3d& vtTo,AcDbVoidPtrArray& arRegionPtrs) const
|
|
{
|
|
if (pSolidDraw == NULL)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int nCount = 0;
|
|
AcGePlane plan;
|
|
AcGeVector3d vtU = ptTo - ptFr;
|
|
|
|
Acad::ErrorStatus es;
|
|
plan.set(ptFr,vtU,vtViewDir);
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToPlaneToWorld(plan);
|
|
xform.invert();
|
|
|
|
AcDbExtents ext;
|
|
pSolidDraw->getGeomExtents(ext);
|
|
|
|
double dX = ext.maxPoint().x - ext.minPoint().x;
|
|
double dY = ext.maxPoint().y - ext.minPoint().y;
|
|
double dz = ext.maxPoint().z - ext.minPoint().z;
|
|
double dMaxL = __max(dX,dY);
|
|
dMaxL = __max(dMaxL,dz);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
|
|
ptGe[0] = ptFr;
|
|
ptGe[1] = ptTo;
|
|
ptGe[2] = ptTo + vtTo;
|
|
ptGe[3] = ptFr + vtTo;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcGeVector3d vt1 = ptGe[3] - ptGe[0];
|
|
AcGeVector3d vt2 = ptGe[1] - ptGe[0];
|
|
|
|
AcGeVector3d vtUp = vt1.crossProduct(vt2);
|
|
vtUp.normalize();
|
|
vtUp *= (2.0 * dMaxL);
|
|
|
|
for (int k = 0;k < 5;k++)
|
|
{
|
|
ptGe[k] += vtUp;
|
|
}
|
|
|
|
AcDbRegion* pRegionT = AecDbEarthWorm::CreatePolygonRegionOnly(ptGe,5);
|
|
if (pRegionT != NULL)
|
|
{
|
|
AcDbLine ln;
|
|
ln.setStartPoint(ptGe[0]);
|
|
ln.setEndPoint(ptGe[0] - 4 * dMaxL * vtUp);
|
|
|
|
AcDb3dSolid* pSolidBox = new AcDb3dSolid;
|
|
if ( Acad::eOk == (es = pSolidBox->extrudeAlongPath(pRegionT,&ln) ) )
|
|
{
|
|
pSolidBox->setColorIndex(kRed);
|
|
}
|
|
|
|
AcDb3dSolid* pSolidCln = (AcDb3dSolid*)pSolidDraw->clone();
|
|
es = pSolidCln->booleanOper(AcDb::kBoolIntersect,pSolidBox);
|
|
pSolidCln->setRecordHistory(true);
|
|
OrthoProjected3DSolid(pSolidCln,plan,xform,arRegionPtrs);
|
|
|
|
//TEST
|
|
//pSolidCln->setColorIndex(kRed);
|
|
//AddToModelSpace(pSolidCln);
|
|
DELETE_PTR(pSolidCln);
|
|
|
|
DELETE_PTR(pRegionT);
|
|
DELETE_PTR(pSolidBox);
|
|
}
|
|
return arRegionPtrs.length();
|
|
}
|
|
|
|
int AecDbShEarthWorm::GetSection(const AcGePoint3d& ptFr,const AcGePoint3d& ptTo,const AcGeVector3d& vtViewDir,const AcGeVector3d& vtTo,AcDbVoidPtrArray& arRegionPtrs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (!Has3DBuffer())
|
|
{
|
|
AcGiViewDraw dc(NULL,NULL);
|
|
Draw3d(dc);
|
|
}
|
|
|
|
int nCount = 0;
|
|
AcGePlane plan;
|
|
AcGeVector3d vtU = ptTo - ptFr;
|
|
|
|
Acad::ErrorStatus es;
|
|
plan.set(ptFr,vtU,vtViewDir);
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToPlaneToWorld(plan);
|
|
xform.invert();
|
|
|
|
const AcDbVoidPtrArray &ar3D = Get3DBuffer();
|
|
AcDb3dSolid* pSolidDraw = NULL;
|
|
for (int i = 0;i < ar3D.length();i++)
|
|
{
|
|
pSolidDraw = (AcDb3dSolid*)ar3D.at(i);
|
|
if (pSolidDraw != NULL)
|
|
{
|
|
ImpGetSection(pSolidDraw,ptFr,ptTo,vtViewDir,vtTo,arRegionPtrs);
|
|
}
|
|
}
|
|
|
|
return arRegionPtrs.length();
|
|
|
|
//old version
|
|
AcDb3dSolid* pSolid = NULL;
|
|
AcDbRegion* pRegion = NULL;
|
|
for (int i = 0;i < ar3D.length();i++)
|
|
{
|
|
pSolid = (AcDb3dSolid*)ar3D.at(i);
|
|
if (pSolid != NULL)
|
|
{
|
|
es = pSolid->getSection(plan,pRegion);
|
|
|
|
if (pRegion != NULL)
|
|
{
|
|
pRegion->transformBy(xform);
|
|
arRegionPtrs.append(pRegion);
|
|
nCount += 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
//AcGeVector3d vtTo(0,0,0);
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arPortRoomIds.length();i++)
|
|
{
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,m_arPortRoomIds.at(i),AcDb::kForRead))
|
|
{
|
|
AecDbPortRoom* pRoom = AecDbPortRoom::cast(pEnt);
|
|
if (pRoom != NULL)
|
|
{
|
|
pRoom->GetSectionDraw(ptFr,ptTo,vtViewDir,vtTo,arRegionPtrs);
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
|
|
//创建裁减Region
|
|
//vtViewDir方向上放 20 米
|
|
AcGePoint3d ptGe[5];
|
|
|
|
ptGe[0] = ptFr;
|
|
ptGe[0] += vtViewDir * AS_MUNIT(20000.0);
|
|
|
|
ptGe[1] = ptTo;
|
|
ptGe[1] += vtViewDir * AS_MUNIT(20000.0);
|
|
|
|
ptGe[2] = ptTo;
|
|
ptGe[2] -= vtViewDir * AS_MUNIT(20000.0);
|
|
|
|
ptGe[3] = ptFr;
|
|
ptGe[3] -= vtViewDir * AS_MUNIT(20000.0);
|
|
|
|
ptGe[4] = ptGe[0];
|
|
AcDbRegion* pRegExt = NULL;
|
|
|
|
for (int i = 0;i < arRegionPtrs.length();i++)
|
|
{
|
|
pRegion = (AcDbRegion* )arRegionPtrs.at(i);
|
|
if (pRegion != NULL)
|
|
{
|
|
pRegExt = AecDbEarthWorm::CreatePolygonRegionOnly(ptGe,5);
|
|
if (pRegExt != NULL)
|
|
{
|
|
pRegExt->transformBy(xform);
|
|
if ( Acad::eOk != pRegion->booleanOper(AcDb::kBoolIntersect,pRegExt) )
|
|
{
|
|
DELETE_PTR(pRegExt);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return nCount;
|
|
}
|
|
|
|
void AecDbShEarthWorm::GetLoftingLines(AcDbVoidPtrArray& arPlines) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDb3dRoadAxisLine* pRoad = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoad != NULL)
|
|
{
|
|
AcDbCurve* pCurve = pRoad->GetBaseCurve(true);
|
|
if (pCurve != NULL)
|
|
{
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(pCurve);
|
|
if (pPl != NULL)
|
|
{
|
|
arPlines.append(pPl);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::subErase(Adesk::Boolean erasing)
|
|
{
|
|
if (erasing)
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arPortRoomIds.length();i++)
|
|
{
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,m_arPortRoomIds.at(i),AcDb::kForWrite))
|
|
{
|
|
pEnt->erase();
|
|
pEnt->close();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arPortRoomIds.length();i++)
|
|
{
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,m_arPortRoomIds.at(i),AcDb::kForWrite,true))
|
|
{
|
|
pEnt->erase(erasing);
|
|
pEnt->close();
|
|
}
|
|
}
|
|
}
|
|
return AcDbCurve::subErase(erasing);
|
|
}
|
|
|
|
bool AecDbShEarthWorm::GetPortRoomId(LPCTSTR pszLockID,AcDbObjectId& idPortRoom) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (pszLockID == NULL)
|
|
return false;
|
|
|
|
AcDbObjectId id;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arPortRoomIds.length();i++)
|
|
{
|
|
id = m_arPortRoomIds.at(i);
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead ) )
|
|
{
|
|
AecDbPortRoom* pRoom = AecDbPortRoom::cast(pEnt);
|
|
if (pRoom != NULL)
|
|
{
|
|
EWFnctNode node = pRoom->GetEWFnctNode();
|
|
if (_tcscmp(node.szLockId,pszLockID) == 0)
|
|
{
|
|
idPortRoom = id;
|
|
}
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
return idPortRoom.isValid();
|
|
}
|
|
|
|
//三维剖视图
|
|
void AecDbShEarthWorm::SetDraw3DStyle(Adesk::UInt16 nDraw3DStyle)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_nDraw3DStyle = nDraw3DStyle;
|
|
}
|
|
|
|
Adesk::UInt16 AecDbShEarthWorm::GetDraw3DStyle() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nDraw3DStyle;
|
|
}
|
|
|
|
//二维俯视图样式
|
|
void AecDbShEarthWorm::SetLookDwonDrawStyle(Adesk::UInt16 nLookDwonDrawStyle)
|
|
{
|
|
AssertWriteEnabled();
|
|
//俯视图,总图单线 0 舱素线俯视图 1
|
|
m_nLookDwonDrawStyle = nLookDwonDrawStyle;
|
|
m_nSectionDrawStyle = 0;//俯视
|
|
}
|
|
|
|
Adesk::UInt16 AecDbShEarthWorm::GetLookDwonDrawStyle() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nLookDwonDrawStyle;
|
|
}
|
|
|
|
//纵断 横断 俯视 切换
|
|
//俯视0 纵断1 横断 2
|
|
void AecDbShEarthWorm::SetSectionDrawStyle(Adesk::UInt16 nSectionDrawStyle)
|
|
{
|
|
if (m_nSectionDrawStyle == nSectionDrawStyle)
|
|
return;
|
|
|
|
AssertWriteEnabled();
|
|
m_nSectionDrawStyle = nSectionDrawStyle;
|
|
if (nSectionDrawStyle != 1)
|
|
{
|
|
g_arSHELongParams.removeAll();
|
|
}
|
|
}
|
|
|
|
Adesk::UInt16 AecDbShEarthWorm::GetSectionDrawStyle() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nSectionDrawStyle;
|
|
}
|
|
|
|
//插入桩号点
|
|
Acad::ErrorStatus AecDbShEarthWorm::InsertStackPos(int nIndex,const EWStackPoint& stackPt)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_arStackPts.insertAt(nIndex,stackPt);
|
|
SortStackPosByDistFrom();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::AppendStackPos(const EWStackPoint& stackPt)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_arStackPts.append(stackPt);
|
|
SortStackPosByDistFrom();
|
|
g_arSHELongParams.removeAll();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbShEarthWorm::SortStackPosByDistFrom()
|
|
{
|
|
assertWriteEnabled();
|
|
}
|
|
|
|
//去除桩号点
|
|
Acad::ErrorStatus AecDbShEarthWorm::RemoveStackPos(LPCTSTR pszStack)
|
|
{
|
|
AssertWriteEnabled();
|
|
for(int i = 0;i < m_arStackPts.length();i++)
|
|
{
|
|
EWStackPoint& sp = m_arStackPts.at(i);
|
|
if (_tcscmp(sp.szStake,pszStack) == 0)
|
|
{
|
|
m_arStackPts.removeAt(i);
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
//获取桩号点
|
|
int AecDbShEarthWorm::GetStackPosSize() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_arStackPts.length();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::GetStackPos(int nIndex,EWStackPoint& stackPt) const
|
|
{
|
|
assertReadEnabled();
|
|
if (nIndex > -1 && nIndex < m_arStackPts.length())
|
|
{
|
|
stackPt = m_arStackPts.at(nIndex);
|
|
return Acad::eOk;
|
|
}
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::GetStackPos(LPCTSTR pszStack,EWStackPoint& stackPt) const
|
|
{
|
|
assertReadEnabled();
|
|
for(int i = 0;i < m_arStackPts.length();i++)
|
|
{
|
|
const EWStackPoint& sp = m_arStackPts.at(i);
|
|
if (_tcscmp(sp.szStake,pszStack) == 0)
|
|
{
|
|
stackPt = m_arStackPts.at(i);
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
AcGePoint2d AecDbShEarthWorm::VStartPoint() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_ptVStart;
|
|
}
|
|
|
|
AcGePoint2d AecDbShEarthWorm::VEndPoint() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint2d ptEnd = m_ptVStart;
|
|
AcGePoint3d pt;
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbCurve* pCurveCen = NULL;
|
|
|
|
AecDbObjXDataMap xData;
|
|
const AcDbVoidPtrArray &ar2DCrv = Get2DBuffer();
|
|
for (int i = 0;i < ar2DCrv.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2DCrv.at(i);
|
|
if ( xData.Read(pEnt,_T("VERSECCEN") ) )
|
|
{
|
|
pCurveCen = AcDbCurve::cast(pEnt);
|
|
if (pCurveCen != NULL)
|
|
{
|
|
pCurveCen->getEndPoint(pt);
|
|
ptEnd.set(pt.x,pt.y);
|
|
}
|
|
}
|
|
}
|
|
return ptEnd;
|
|
}
|
|
|
|
float AecDbShEarthWorm::StartElevation() const
|
|
{
|
|
assertReadEnabled();
|
|
AcGePoint3d ptSta;
|
|
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
//acutPrintf(_T("\nclass %s"),m_pBaseCurve->desc()->name());
|
|
AecDb3dRoadAxisLine* pRoadLn = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadLn != NULL)
|
|
{
|
|
pRoadLn->getStartPoint(ptSta);
|
|
}
|
|
}
|
|
return (float)ptSta.z;
|
|
}
|
|
|
|
float AecDbShEarthWorm::EndElevation() const
|
|
{
|
|
assertReadEnabled();
|
|
AcGePoint3d ptSta;
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AecDb3dRoadAxisLine* pRoadLn = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadLn != NULL)
|
|
{
|
|
pRoadLn->getEndPoint(ptSta);
|
|
}
|
|
}
|
|
return (float)ptSta.z;
|
|
}
|
|
|
|
//管廊混泥土体积
|
|
double AecDbShEarthWorm::GetVolume() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pRegion != NULL)
|
|
{
|
|
double dArea = 0.0;
|
|
m_pRegion->getArea(dArea);
|
|
double dLen = GetLength();
|
|
|
|
return dLen * dArea;
|
|
}
|
|
return 0.0;
|
|
}
|
|
|
|
//管廊腔体体积 nRoom = 999 全部
|
|
double AecDbShEarthWorm::GetCavityVolume(int nRoom) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_arRegionRooms.isEmpty())
|
|
{
|
|
ExtractRegionRooms(m_arRegionRooms,m_pRegion);
|
|
}
|
|
|
|
double dArea = 0.0,dTemp = 0.0;
|
|
double dEnd = 0.0,dLen = 0.0;
|
|
dLen = GetLength();
|
|
|
|
AcDbRegion* pReg = NULL;
|
|
for (int i = 0;i < m_arRegionRooms.length();i++)
|
|
{
|
|
pReg = (AcDbRegion*)m_arRegionRooms.at(i);
|
|
pReg->getArea(dTemp);
|
|
dArea += dTemp;
|
|
}
|
|
|
|
return (dLen * dArea);
|
|
}
|
|
|
|
//管廊总挖土方,与道路标高先有关 0 现状 1 设计
|
|
double AecDbShEarthWorm::GetDigVolume(int nRoadType) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
double dVol = 0.0;
|
|
if (g_arSHELongParams.isEmpty())
|
|
{
|
|
AcArray<ELongParam> arELongParams;
|
|
CalEarthWork(arELongParams);
|
|
}
|
|
|
|
if (!g_arSHELongParams.isEmpty())
|
|
{
|
|
for (int i = 0;i < g_arSHELongParams.length();i++)
|
|
{
|
|
const ELongParam& lparm = g_arSHELongParams.at(i);
|
|
dVol += lparm.dDigVol;
|
|
}
|
|
}
|
|
return dVol;
|
|
}
|
|
|
|
//管廊填埋土方,与道路标高先有关
|
|
double AecDbShEarthWorm::GetFillVolume() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
double dVol = 0.0;
|
|
if (g_arSHELongParams.isEmpty())
|
|
{
|
|
AcArray<ELongParam> arELongParams;
|
|
CalEarthWork(arELongParams);
|
|
}
|
|
|
|
if (!g_arSHELongParams.isEmpty())
|
|
{
|
|
for (int i = 0;i < g_arSHELongParams.length();i++)
|
|
{
|
|
const ELongParam& lparm = g_arSHELongParams.at(i);
|
|
dVol += lparm.dEVolCover;
|
|
}
|
|
}
|
|
return dVol;
|
|
}
|
|
|
|
//管廊外表面积
|
|
double AecDbShEarthWorm::GetOutSideArea() const
|
|
{
|
|
assertReadEnabled();
|
|
if (m_pRegion != NULL)
|
|
{
|
|
AcDbRegion* pReg = GetBigRegion();
|
|
if (pReg != NULL)
|
|
{
|
|
double dOLen = 0.0,dEnd = 0.0,dLen = 0.0;
|
|
AcDbVoidPtrArray arCurPtrs,arReslut;
|
|
pReg->explode(arCurPtrs);
|
|
|
|
AcDbCurve* pOut = KTCADUtilityEx::ConvertBoundCurve(arCurPtrs,arReslut);
|
|
if (pOut != NULL)
|
|
{
|
|
pOut->getEndParam(dEnd);
|
|
pOut->getDistAtParam(dEnd,dOLen);
|
|
delete pOut;
|
|
}
|
|
dLen = GetLength();
|
|
return (dLen * dOLen);
|
|
}
|
|
}
|
|
return 0.0;
|
|
}
|
|
|
|
//管廊舱室内表面积
|
|
double AecDbShEarthWorm::GetInSideArea() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pRegion != NULL)
|
|
{
|
|
if (m_arRegionRooms.isEmpty())
|
|
{
|
|
ExtractRegionRooms(m_arRegionRooms,m_pRegion);
|
|
}
|
|
|
|
double dOutLen = 0.0,dTemp = 0.0;
|
|
double dEnd = 0.0,dLen = 0.0;
|
|
dLen = GetLength();
|
|
|
|
AcDbRegion* pReg = NULL;
|
|
AcDbVoidPtrArray arCurPtrs,arReslut;
|
|
for (int i = 0;i < m_arRegionRooms.length();i++)
|
|
{
|
|
pReg = (AcDbRegion*)m_arRegionRooms.at(i);
|
|
|
|
arCurPtrs.removeAll();
|
|
arReslut.removeAll();
|
|
pReg->explode(arCurPtrs);
|
|
|
|
AcDbCurve* pOut = KTCADUtilityEx::ConvertBoundCurve(arCurPtrs,arReslut);
|
|
if (pOut != NULL)
|
|
{
|
|
pOut->getEndParam(dEnd);
|
|
pOut->getDistAtParam(dEnd,dTemp);
|
|
delete pOut;
|
|
dOutLen += dTemp;
|
|
}
|
|
}
|
|
return (dLen * dOutLen);
|
|
}
|
|
return 0.0;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::DrawBuffer(AcGiDraw &dc) const
|
|
{
|
|
return Acad::eInvalidInput;//原因缓存没有显示
|
|
assertReadEnabled();
|
|
AcDbEntity* pEnt = NULL;
|
|
|
|
//总图 纵断
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(i);
|
|
if (pEnt != NULL)
|
|
{
|
|
AcDb::Visibility eVisi = pEnt->visibility();
|
|
if (eVisi == AcDb::kInvisible)
|
|
{
|
|
pEnt->setLayer(_T("0"));
|
|
pEnt->setVisibility(AcDb::kVisible);
|
|
//acutPrintf(_T("\nInvisible !!!"));
|
|
eVisi = pEnt->visibility();
|
|
//acutPrintf(_T("\n%d"),eVisi);
|
|
}
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
}
|
|
|
|
//纵断--总图显示
|
|
for (int i = 0;i < m_ar2DDrableBufPtrs2.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_ar2DDrableBufPtrs2.at(i);
|
|
if (pEnt != NULL)
|
|
{
|
|
AcDb::Visibility eVisi = pEnt->visibility();
|
|
if (eVisi == AcDb::kInvisible)
|
|
{
|
|
pEnt->setVisibility(AcDb::kVisible);
|
|
//acutPrintf(_T("\nInvisible !!!"));
|
|
}
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
}
|
|
|
|
//纵断
|
|
const AcDbVoidPtrArray &ar2D2 = Get2DBuffer();
|
|
for (int i = 0;i < ar2D2.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D2.at(i);
|
|
if (pEnt != NULL)
|
|
{
|
|
AcDb::Visibility eVisi = pEnt->visibility();
|
|
if (eVisi == AcDb::kInvisible)
|
|
{
|
|
pEnt->setVisibility(AcDb::kVisible);
|
|
//acutPrintf(_T("\nInvisible !!!"));
|
|
}
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//获取二维视图显示的图形[出图]
|
|
int AecDbShEarthWorm::GetDraw2dables(Adesk::UInt16 nSectionDrawStyle, AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (nSectionDrawStyle != 2)
|
|
{
|
|
if (m_nSectionDrawStyle != nSectionDrawStyle )
|
|
{
|
|
acutPrintf(_T("\n请选择正确的二维视图出图!"));
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
if (!Has2DBuffer())
|
|
{
|
|
AcGiViewDraw dc(NULL,NULL);
|
|
Draw2d(dc);
|
|
}
|
|
|
|
AcDbEntity* pEntClone = NULL;
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(i);
|
|
pEntClone = (AcDbEntity*)pEnt->clone();
|
|
if (pEntClone != NULL)
|
|
{
|
|
arEntPtrs.append(pEntClone);
|
|
}
|
|
}
|
|
|
|
if (nSectionDrawStyle == 2)//全部
|
|
{
|
|
for (int i = 0;i < m_ar2DDrableBufPtrs2.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_ar2DDrableBufPtrs2.at(i);
|
|
pEntClone = (AcDbEntity*)pEnt->clone();
|
|
if (pEntClone != NULL)
|
|
{
|
|
arEntPtrs.append(pEntClone);
|
|
}
|
|
}
|
|
}
|
|
return arEntPtrs.length();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//管线系统屏蔽掉
|
|
if ( dc.IsDragging() )
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//图层
|
|
AcDbObjectId idLay = dc.GetLayerId();
|
|
dc.SetLayer(layerId());
|
|
//dc.SetSelectionMarker(1);
|
|
|
|
int nOld = dc.GetColor();
|
|
dc.SetColor(kColorByLayer);
|
|
|
|
if ( Acad::eOk != DrawBuffer(dc) )
|
|
{
|
|
//总图
|
|
Clean2DBuffer();
|
|
|
|
//预制,纵断 表格
|
|
FreeBuffer(0,m_ar2DPrefbrtBufPtrs);
|
|
m_ar2DPrefbrtBufPtrs.removeAll();
|
|
|
|
//纵断
|
|
FreeBuffer(0,m_ar2DDrableBufPtrs2);
|
|
m_ar2DDrableBufPtrs2.removeAll();
|
|
}
|
|
else
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
static int nCrIdx = 0;
|
|
static int nColor[] = {kRed,kYellow,kGreen};
|
|
|
|
int nSectionDrawStyle = m_nSectionDrawStyle;
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
switch(m_nSectionDrawStyle)
|
|
{
|
|
case 0://俯视0
|
|
{
|
|
es = DrawTopView2d(dc);
|
|
break;
|
|
}
|
|
case 1://纵断1
|
|
{
|
|
if (nCrIdx > 2) nCrIdx = 0;
|
|
nOld = dc.GetColor();
|
|
dc.SetColor(nColor[nCrIdx]);
|
|
|
|
//同时绘制主视图,作为参考
|
|
es = DrawTopView2d(dc);
|
|
|
|
m_ar2DDrableBufPtrs2.removeAll();
|
|
m_ar2DDrableBufPtrs2.append(Get2DBuffer());
|
|
|
|
Clean2DBufferNoDel();
|
|
|
|
es = DrawVerSection(dc);
|
|
|
|
nCrIdx++;
|
|
dc.SetColor(nOld);
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
dc.SetColor(nOld);
|
|
dc.SetLayer(idLay);
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::DrawTopView2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int nStyle = 0;
|
|
m_mapSpecXData.GetAt(KEY_2DSTYLE,nStyle);
|
|
|
|
double dSingleW = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_SINGLEW,dSingleW);
|
|
|
|
AcDbCurve* pCurve = NULL,*pBaseCurve = NULL;
|
|
AecDb3dRoadAxisLine* pRoad = NULL;
|
|
AcDbPolyline* pPlRoad = NULL;
|
|
AcDbVoidPtrArray arCurPtrs,arpResult;
|
|
|
|
switch(nStyle)
|
|
{
|
|
case 1://总图单线
|
|
{
|
|
pRoad = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoad != NULL)//盾构必须是AecDb3dRoadAxisLine线
|
|
{
|
|
for (int i = 0;i < pRoad->GetCurveSegCount();i++)
|
|
{
|
|
pCurve = pRoad->GetCurveSeg(i);
|
|
if (pCurve != NULL)
|
|
{
|
|
arCurPtrs.append((AcDbCurve*)pCurve->clone());
|
|
}
|
|
}
|
|
|
|
|
|
pBaseCurve = KTCADUtilityEx::ConvertBoundCurve(arCurPtrs, arpResult);
|
|
if (pBaseCurve != NULL)
|
|
{
|
|
pPlRoad = AcDbPolyline::cast(pBaseCurve);
|
|
if (pPlRoad != NULL)
|
|
{
|
|
pPlRoad->setConstantWidth(m_dSingleLnWidth * m_dXDrawScale);//默认1:100
|
|
pPlRoad->setLayer(layerId());
|
|
pPlRoad->setNormal(AcGeVector3d::kZAxis);
|
|
dc.DrawPolyline(*pPlRoad);
|
|
Add2DBuffer(pPlRoad);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case 2://舱素线双线
|
|
{
|
|
//1.获取中心线
|
|
pRoad = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoad != NULL)//盾构必须是AecDb3dRoadAxisLine线
|
|
{
|
|
pBaseCurve = pRoad->GetBaseCurve(true);
|
|
//acutPrintf(_T("\nclass = %s"),pBaseCurve->isA()->name());
|
|
}
|
|
else
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGePoint2d ptODt;
|
|
GetODAndThick(ptODt);
|
|
|
|
//2.向两侧偏移 厚度线
|
|
pPlRoad = AcDbPolyline::cast(pBaseCurve);
|
|
if (pPlRoad != NULL)
|
|
{
|
|
AcDbVoidPtrArray arTop,arBom;
|
|
pPlRoad->getOffsetCurves( 0.5 * ptODt.x,arTop);
|
|
pPlRoad->getOffsetCurves(-0.5 * ptODt.x,arBom);
|
|
|
|
AcDbVoidPtrArray arTop1,arBom1;
|
|
if (ptODt.y > 1.e-2)
|
|
{
|
|
pPlRoad->getOffsetCurves( 0.5 * (ptODt.x - 2.0 * ptODt.y),arTop1);
|
|
pPlRoad->getOffsetCurves(-0.5 * (ptODt.x - 2.0 * ptODt.y),arBom1);
|
|
}
|
|
|
|
if (!arTop.isEmpty() && !arBom.isEmpty())
|
|
{
|
|
AcDbVoidPtrArray arPres;
|
|
AcDbCurve* pTopCrv = KTCADUtilityEx::ConvertBoundCurve(arTop,arPres);
|
|
|
|
arPres.removeAll();
|
|
AcDbCurve* pBomCrv = KTCADUtilityEx::ConvertBoundCurve(arBom,arPres);
|
|
|
|
//中间节点
|
|
for (int i = 0;i < m_arStackPts.length();i++)
|
|
{
|
|
const EWStackPoint& sp = m_arStackPts.at(i);
|
|
DrawStackPointTopView(dc,sp,pPlRoad);
|
|
}
|
|
|
|
//
|
|
AcDbPolyline* pPlTop = AcDbPolyline::cast(pTopCrv);
|
|
if (pPlTop != NULL)
|
|
{
|
|
pPlTop->setConstantWidth(m_dBoundaryWidth * m_dXDrawScale);
|
|
|
|
pPlTop->setLayer(layerId());
|
|
dc.DrawPolyline(*pPlTop);
|
|
Add2DBuffer(pPlTop);
|
|
}
|
|
|
|
AcDbPolyline* pPlBom = AcDbPolyline::cast(pBomCrv);
|
|
if (pPlBom != NULL)
|
|
{
|
|
pPlBom->setConstantWidth(m_dBoundaryWidth * m_dXDrawScale);
|
|
|
|
pPlBom->setLayer(layerId());
|
|
dc.DrawPolyline(*pPlBom);
|
|
Add2DBuffer(pPlBom);
|
|
}
|
|
|
|
//封口
|
|
AcGePoint3d ptSta[2],ptEnd[2];
|
|
pTopCrv->getStartPoint(ptSta[0]);
|
|
pBomCrv->getStartPoint(ptSta[1]);
|
|
|
|
pTopCrv->getEndPoint(ptEnd[0]);
|
|
pBomCrv->getEndPoint(ptEnd[1]);
|
|
|
|
AcDbPolyline* pPlSta = new AcDbPolyline;
|
|
pPlSta->addVertexAt(0,ptSta[0].convert2d(AcGePlane::kXYPlane));
|
|
pPlSta->addVertexAt(1,ptSta[1].convert2d(AcGePlane::kXYPlane));
|
|
pPlSta->setLayer(layerId());
|
|
pPlSta->setConstantWidth(m_dBoundaryWidth * m_dXDrawScale);
|
|
dc.DrawPolyline(*pPlSta);
|
|
Add2DBuffer(pPlSta);
|
|
|
|
AcDbPolyline* pPlEnd = new AcDbPolyline;
|
|
pPlEnd->addVertexAt(0,ptEnd[0].convert2d(AcGePlane::kXYPlane));
|
|
pPlEnd->addVertexAt(1,ptEnd[1].convert2d(AcGePlane::kXYPlane));
|
|
pPlEnd->setLayer(layerId());
|
|
pPlEnd->setConstantWidth(m_dBoundaryWidth * m_dXDrawScale);
|
|
dc.DrawPolyline(*pPlEnd);
|
|
Add2DBuffer(pPlEnd);
|
|
|
|
//壁厚虚线
|
|
if (arTop1.length() == 1 && arBom1.length() == 1)
|
|
{
|
|
pTopCrv = (AcDbCurve*)arTop1.first();
|
|
pBomCrv = (AcDbCurve*)arBom1.first();
|
|
|
|
pPlTop = AcDbPolyline::cast(pTopCrv);
|
|
if (pPlTop != NULL)
|
|
{
|
|
pPlTop->setConstantWidth(0.0);
|
|
pPlTop->setLinetype(KTSetting::InitLineStyle(_T("DASHED2")));
|
|
|
|
pPlTop->setLayer(layerId());
|
|
dc.DrawPolyline(*pPlTop);
|
|
Add2DBuffer(pPlTop);
|
|
}
|
|
|
|
pPlBom = AcDbPolyline::cast(pBomCrv);
|
|
if (pPlBom != NULL)
|
|
{
|
|
pPlBom->setConstantWidth(0.0);
|
|
pPlBom->setLinetype(KTSetting::InitLineStyle(_T("DASHED2")));
|
|
|
|
pPlBom->setLayer(layerId());
|
|
dc.DrawPolyline(*pPlBom);
|
|
Add2DBuffer(pPlBom);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
acutPrintf(_T("\n创建隧道边线出错!"));
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::DrawStackPointTopView(AcGiDraw &dc,const EWStackPoint& sp,const AcDbPolyline* pRoadCenLine) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (sp.pFnNode != NULL)
|
|
{
|
|
AcGePoint3d ptOn = sp.ptPos;
|
|
if ( pRoadCenLine != NULL)
|
|
{
|
|
pRoadCenLine->getClosestPointTo(sp.ptPos,ptOn);
|
|
}
|
|
|
|
if (sp.pFnNode->eFnType == kVerticalWell)
|
|
{
|
|
if (sp.pFnNode->nFlag == 0)//圆井
|
|
{
|
|
AcGeVector3d vtDirX;
|
|
pRoadCenLine->getFirstDeriv(ptOn,vtDirX);
|
|
vtDirX.z = 0.0;//井垂直放置,vtDir水平
|
|
|
|
AcGeVector3d vtDirY = vtDirX;
|
|
vtDirY.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtDirY.normalize();
|
|
ptOn += vtDirY * sp.pFnNode->fNodeDef[5];
|
|
|
|
AcGePoint3d ptGe[2];
|
|
AcDbCircle* pCir = new AcDbCircle;
|
|
if (pCir != NULL)
|
|
{
|
|
pCir->setCenter(ptOn);
|
|
pCir->setRadius(0.5 * sp.pFnNode->fNodeDef[0]);
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
dc.DrawEntity(pCir);
|
|
Add2DBuffer(pCir);
|
|
}
|
|
}
|
|
else if (sp.pFnNode->nFlag == 1)
|
|
{
|
|
//方井
|
|
double dL = sp.pFnNode->fNodeDef[0];//外长
|
|
double dW = sp.pFnNode->fNodeDef[1];//外宽
|
|
|
|
AcGeVector3d vtDirX;
|
|
pRoadCenLine->getFirstDeriv(ptOn,vtDirX);
|
|
vtDirX.z = 0.0;//井垂直放置,vtDir水平
|
|
|
|
AcGeVector3d vtDirY = vtDirX;
|
|
vtDirY.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtDirX.normalize();vtDirY.normalize();
|
|
|
|
ptOn += vtDirY * sp.pFnNode->fNodeDef[6];
|
|
|
|
AcDbLine* pLn1 = NULL;
|
|
|
|
AcGePoint3d ptGe[5];
|
|
ptGe[0] = ptOn;
|
|
ptGe[0] -= 0.5 * vtDirX * dL;
|
|
ptGe[0] += 0.5 * vtDirY * dW;
|
|
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1] += vtDirX * dL;
|
|
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2] -= vtDirY * dW;
|
|
|
|
ptGe[3] = ptGe[2];
|
|
ptGe[3] -= vtDirX * dL;
|
|
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
pLn1 = new AcDbLine(ptGe[i],ptGe[i+1]);
|
|
pLn1->setNormal(AcGeVector3d::kZAxis);
|
|
dc.DrawEntity(pLn1);
|
|
Add2DBuffer(pLn1);
|
|
}
|
|
}
|
|
}
|
|
else if (sp.pFnNode->eFnType == kProModel)
|
|
{
|
|
AcGeVector3d vtDirX;
|
|
pRoadCenLine->getFirstDeriv(ptOn,vtDirX);
|
|
vtDirX.z = 0.0;//井垂直放置,vtDir水平
|
|
|
|
AcGePoint3d ptGe8[13];
|
|
|
|
//异型决定
|
|
AecDbEarthWormFitting fit;
|
|
AecDbEarthWormFitting* pFit = NULL;
|
|
|
|
std::map<CString,PVOID>::const_iterator it;
|
|
if (g_mapSHProMode2Fit.end() != ( it = g_mapSHProMode2Fit.find(sp.pFnNode->szLockId) ) )
|
|
{
|
|
pFit = (AecDbEarthWormFitting*)(*it).second;
|
|
}
|
|
else
|
|
{
|
|
CMemFile file;
|
|
file.Attach((BYTE*)sp.pFnNode->pProModelBuffer,sp.pFnNode->nProModelBufLen);
|
|
fit.ReadFrom(&file);
|
|
pFit = &fit;
|
|
file.Detach();
|
|
}
|
|
|
|
if (pFit != NULL)
|
|
{
|
|
double dLeft = 0.5 * pFit->GetLen();
|
|
pFit->GetSpecialtyData()->GetAt(_T("dLeft"),dLeft);
|
|
|
|
AcGePoint3d ptPos = ptOn;
|
|
ptPos += ( sp.pFnNode->dDistFromPre - dLeft ) * vtDirX;
|
|
|
|
AcGiViewDraw dcTmp(NULL,NULL);
|
|
pFit->Draw3d(dcTmp);
|
|
|
|
AcDbVoidPtrArray ar2DEntPtrs;
|
|
pFit->GetDraw2d(ar2DEntPtrs,0);
|
|
AecDbEarthWormFitting::Transformby(ar2DEntPtrs,ptPos,vtDirX);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbRegion* pReg = NULL;
|
|
for (int kkk = 0;kkk < ar2DEntPtrs.length();kkk++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2DEntPtrs.at(kkk);
|
|
pReg = AcDbRegion::cast(pEnt);
|
|
if (pReg == NULL)//俯视图
|
|
{
|
|
dc.DrawEntity(*pEnt);
|
|
Add2DBuffer(pEnt);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
static void AppendTempVerts(AcGePoint3dArray& arVerts,const AcGePoint3d& pt1,const AcGePoint3d& pt2)
|
|
{
|
|
if (!arVerts.isEmpty())
|
|
{
|
|
if (arVerts.last().distanceTo(pt1) < 1.e-3)
|
|
{
|
|
arVerts.append(pt2);
|
|
}
|
|
else
|
|
{
|
|
arVerts.append(pt1);
|
|
}
|
|
}
|
|
}
|
|
|
|
extern AcDbArc* FormatArc(const AcGePoint3d& ptGe1,const AcGePoint3d& ptGe2,const AcGePoint3d& ptGe3);
|
|
AcDbPolyline* AecDbShEarthWorm::GetVerSectionPolyline(const AcGePoint2d& ptLast,double dOffset,bool bUseRoadFit) const
|
|
{
|
|
AecDb3dRoadAxisLine* pRodLine = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRodLine != NULL)
|
|
{
|
|
double dDn = 0.0,dRatio = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_RATIO,dRatio);
|
|
m_mapSpecXData.GetAt(PIPE_DN,dDn);
|
|
|
|
AecDb3dRoadAxisLine* pRoadFitLine = pRodLine;
|
|
if (bUseRoadFit)
|
|
{
|
|
pRoadFitLine = pRodLine->GetFittedRoadAxisLine(dDn,dRatio);
|
|
if (pRoadFitLine == NULL)
|
|
{
|
|
pRoadFitLine = pRodLine;
|
|
}
|
|
}
|
|
|
|
AcGeVector3d vtDirX = acdbCurDwg()->ucsxdir();//end-start
|
|
vtDirX.z = 0.0;
|
|
vtDirX.normalize();
|
|
|
|
AcGeVector3d vtDirY = vtDirX;
|
|
vtDirY.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);//???
|
|
|
|
AcDbVoidPtrArray arCurPtrs,arpResult;
|
|
|
|
AcDbLine* pLn1 = NULL;
|
|
AcDbArc* pArc1 = NULL;
|
|
AcDbCurve* pCurve = NULL;
|
|
AcGePoint3d ptGe[3],ptTemp;
|
|
AcGeVector3d vtNorm;
|
|
double dLen = 0.0;
|
|
|
|
AcGePoint3d ptTail(ptLast.x,ptLast.y,0.0);
|
|
AcGePoint3dArray arTail,arVerts;
|
|
|
|
pRoadFitLine->getStartPoint(ptGe[0]);
|
|
arVerts.append(ptGe[0]);
|
|
|
|
//获取曲线的序
|
|
CurveDir curDir;
|
|
AcArray<CurveDir> arCurveDir;
|
|
pRoadFitLine->GetCurveDirs(arCurveDir);
|
|
|
|
for (int i = 0;i < pRoadFitLine->GetCurveSegCount();i++)
|
|
{
|
|
pCurve = pRoadFitLine->GetCurveSeg(i);
|
|
curDir = arCurveDir.at(i);
|
|
|
|
AcDbLine* pLn = AcDbLine::cast(pCurve);
|
|
if ( pLn != NULL)
|
|
{
|
|
ptGe[0] = pLn->startPoint();
|
|
ptGe[1] = pLn->endPoint();
|
|
|
|
//追加首尾连接点,用户确定圆弧的方向
|
|
AppendTempVerts(arVerts,ptGe[0],ptGe[1]);
|
|
|
|
dLen = ptGe[0].distanceTo(ptGe[1]);
|
|
if (arTail.isEmpty())
|
|
{
|
|
ptTemp = ptTail;
|
|
ptTemp += dLen * vtDirX;
|
|
|
|
if (curDir.bDir)
|
|
{
|
|
ptTemp += (ptGe[1].z - ptGe[0].z) * vtDirY;
|
|
}
|
|
else
|
|
{
|
|
ptTemp += (ptGe[0].z - ptGe[1].z) * vtDirY;
|
|
}
|
|
|
|
arTail.append(ptTemp);
|
|
|
|
pLn1 = new AcDbLine(ptTail,ptTemp);
|
|
pLn1->setNormal(AcGeVector3d::kZAxis);
|
|
arCurPtrs.append(pLn1);
|
|
}
|
|
else
|
|
{
|
|
ptTail = arTail.last();
|
|
ptTemp = ptTail;
|
|
ptTemp += dLen * vtDirX;
|
|
|
|
if (curDir.bDir)
|
|
{
|
|
ptTemp += (ptGe[1].z - ptGe[0].z) * vtDirY;
|
|
}
|
|
else
|
|
{
|
|
ptTemp += (ptGe[0].z - ptGe[1].z) * vtDirY;
|
|
}
|
|
|
|
arTail.append(ptTemp);
|
|
|
|
pLn1 = new AcDbLine(ptTail,ptTemp);
|
|
pLn1->setNormal(AcGeVector3d::kZAxis);
|
|
arCurPtrs.append(pLn1);
|
|
}
|
|
}
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(pCurve);
|
|
if (pArc != NULL)
|
|
{
|
|
pArc->getStartPoint(ptGe[0]);
|
|
pArc->getEndPoint(ptGe[2]);
|
|
|
|
double dSta = 0.0,dEnd = 0.0;
|
|
pArc->getStartParam(dSta);
|
|
pArc->getEndParam(dEnd);
|
|
pArc->getPointAtParam((dSta+dEnd)/2.0,ptGe[1]);
|
|
|
|
double dLen = 0.0;
|
|
pArc->getDistAtParam(dEnd,dLen);
|
|
|
|
vtNorm = pArc->normal();
|
|
if (vtNorm.isParallelTo(AcGeVector3d::kZAxis))//平行XY面的弧,展开为直线
|
|
{
|
|
if (!arTail.isEmpty())
|
|
{
|
|
ptTail = arTail.last();
|
|
}
|
|
|
|
ptTemp = ptTail;
|
|
ptTemp += dLen * vtDirX;//展开
|
|
|
|
if (curDir.bDir)
|
|
{
|
|
ptTemp += (ptGe[2].z - ptGe[0].z) * vtDirY;
|
|
}
|
|
else
|
|
{
|
|
ptTemp += (ptGe[0].z - ptGe[2].z) * vtDirY;
|
|
}
|
|
|
|
arTail.append(ptTemp);
|
|
|
|
pLn1 = new AcDbLine(ptTail,ptTemp);
|
|
pLn1->setNormal(AcGeVector3d::kZAxis);
|
|
arCurPtrs.append(pLn1);
|
|
}
|
|
else
|
|
{
|
|
AcGeLine3d ln3d;
|
|
ln3d.set(AcGePoint3d::kOrigin,vtNorm);
|
|
|
|
if (AcGePlane::kXYPlane.isParallelTo(ln3d))//垂直于XY面的弧,纵断仍为弧
|
|
{
|
|
if (!arTail.isEmpty())
|
|
{
|
|
ptTail = arTail.last();
|
|
}
|
|
|
|
double dZ1 = ptGe[1].z - ptGe[0].z;
|
|
double dZ2 = ptGe[2].z - ptGe[1].z;
|
|
|
|
ptGe[0].z = 0.0;ptGe[1].z = 0.0;ptGe[2].z = 0.0;
|
|
double dX1 = ptGe[1].distanceTo(ptGe[0]);//fabs(ptGe[1].x - ptGe[0].x);//向X+方向
|
|
double dX2 = ptGe[2].distanceTo(ptGe[1]);//fabs(ptGe[2].x - ptGe[1].x);//向X+方向
|
|
|
|
pArc->getStartPoint(ptGe[0]);
|
|
pArc->getEndPoint(ptGe[2]);
|
|
if (arVerts.last().distanceTo(ptGe[0]) <1.e-3)//和弧起点连续
|
|
{
|
|
ptTemp = ptTail;
|
|
ptGe[0] = ptTemp;
|
|
|
|
ptGe[1] = ptTemp;
|
|
ptGe[1] += dZ1 * vtDirY;
|
|
ptGe[1] += dX1 * vtDirX;
|
|
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2] += dZ2 * vtDirY;
|
|
ptGe[2] += dX2 * vtDirX;
|
|
|
|
arTail.append(ptGe[2]);
|
|
}
|
|
else
|
|
{
|
|
ptTemp = ptTail;
|
|
ptGe[2] = ptTemp;
|
|
|
|
ptGe[1] = ptTemp;
|
|
ptGe[1] -= dZ2 * vtDirY;
|
|
ptGe[1] += dX2 * vtDirX;
|
|
|
|
ptGe[0] = ptGe[1];
|
|
ptGe[0] -= dZ1 * vtDirY;
|
|
ptGe[0] += dX1 * vtDirX;
|
|
|
|
arTail.append(ptGe[0]);
|
|
}
|
|
|
|
AcDbArc* pArcNew = FormatArc(ptGe[0],ptGe[1],ptGe[2]);
|
|
if (pArcNew != NULL)
|
|
{
|
|
arCurPtrs.append(pArcNew);
|
|
}
|
|
}
|
|
else//倾斜于XY面的弧,纵断仍为椭圆弧
|
|
{
|
|
|
|
//待定...
|
|
}
|
|
}
|
|
|
|
//追加首尾连接点
|
|
pArc->getStartPoint(ptGe[0]);
|
|
pArc->getEndPoint(ptGe[2]);
|
|
AppendTempVerts(arVerts,ptGe[0],ptGe[2]);
|
|
}
|
|
}
|
|
|
|
if (pRoadFitLine != pRodLine)
|
|
delete pRoadFitLine;
|
|
|
|
Acad::ErrorStatus es;
|
|
pCurve = KTCADUtilityEx::ConvertBoundCurve(arCurPtrs, arpResult);
|
|
if (pCurve != NULL)
|
|
{
|
|
AcDbPolyline* pPl =AcDbPolyline::cast(pCurve);
|
|
if (pPl != NULL)
|
|
{
|
|
if (fabs(dOffset) > 1.e-6)
|
|
{
|
|
arCurPtrs.removeAll();
|
|
es = pPl->getOffsetCurves(dOffset,arCurPtrs);
|
|
|
|
if (arCurPtrs.length() > 0)
|
|
{
|
|
pCurve = (AcDbCurve*)arCurPtrs.first();
|
|
pPl =AcDbPolyline::cast(pCurve);
|
|
return pPl;
|
|
}
|
|
else
|
|
{
|
|
//offset failed
|
|
//AddToModelSpace((AcDbEntity*)pPl->clone());
|
|
|
|
if (bUseRoadFit)//如果是拟合的方式偏移失败,则不拟合偏移然后再拟合
|
|
{
|
|
delete pPl;
|
|
pPl = GetVerSectionPolyline(ptLast,dOffset,false);
|
|
if (pPl != NULL)
|
|
{
|
|
arCurPtrs.removeAll();
|
|
pPl->explode(arCurPtrs);
|
|
|
|
AecDb3dRoadAxisLine road;
|
|
for (int kk = 0;kk < arCurPtrs.length();kk++)
|
|
{
|
|
pCurve = (AcDbCurve*)arCurPtrs.at(kk);
|
|
road.AppendCurveSeg(pCurve);
|
|
}
|
|
|
|
double dDn = 0.0,dRatio = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_RATIO,dRatio);
|
|
m_mapSpecXData.GetAt(PIPE_DN,dDn);
|
|
|
|
AecDb3dRoadAxisLine* pFitRoad = road.GetFittedRoadAxisLine(dDn,dRatio);
|
|
if (pFitRoad != NULL)
|
|
{
|
|
pPl = (AcDbPolyline*)pFitRoad->GetBaseCurve(true);
|
|
delete pFitRoad;
|
|
return pPl;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return pPl;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::DrawVerSection(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint2d ptrODtTop,ptrODtBom;
|
|
GetODAndID(ptrODtTop,ptrODtBom);
|
|
|
|
//绘制纵断
|
|
AecDb3dRoadAxisLine* pRodLine = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRodLine != NULL)
|
|
{
|
|
AcDbExtents ext;
|
|
pRodLine->getGeomExtents(ext);
|
|
|
|
AcGePoint3d ptFr;
|
|
pRodLine->getStartPoint(ptFr);
|
|
|
|
double dVSDrawOffset = ext.maxPoint().z - ext.minPoint().z;
|
|
AecDbObjXDataMap xDataMap;
|
|
KTModelLayoutXData::ReadModelXData(EW_EARTHWORMINIT, xDataMap);
|
|
if ( !xDataMap.GetAt(_T("m_dVSDrawOffset"),dVSDrawOffset) )
|
|
{
|
|
}
|
|
|
|
AcGePoint2d ptLast(ptFr.x,ptFr.y);
|
|
AcGePoint2d ptGe[2],ptVGe[4],ptEnd,ptSta;
|
|
AcGeVector2d vtDir,vtDirX,vtDirY;
|
|
|
|
vtDirX = acdbCurDwg()->ucsxdir().convert2d(AcGePlane::kXYPlane);//end-start
|
|
vtDirX.normalize();
|
|
|
|
vtDirY = vtDirX;
|
|
vtDirY.rotateBy(PI / 2.0);
|
|
|
|
//放大 向下移动一下,附属物位置不变
|
|
ptLast -= vtDirY * dVSDrawOffset;
|
|
m_ptVStart = ptLast;
|
|
|
|
//世界坐标系下的 AcDbPolyline
|
|
AcDbPolyline* pTopLine = GetVerSectionPolyline(ptLast,0.5 * ptrODtTop.x);
|
|
AcDbPolyline* pCenLine = GetVerSectionPolyline(ptLast,0.0);
|
|
AcDbPolyline* pBomLine = GetVerSectionPolyline(ptLast,-0.5 * ptrODtBom.x);
|
|
|
|
if (pBomLine != NULL && pTopLine != NULL)
|
|
{
|
|
//确认Top,Bom线位置
|
|
AcGePoint3d pt1,pt2;
|
|
ads_point pt11,pt22;
|
|
pTopLine->getStartPoint(pt1);
|
|
pBomLine->getStartPoint(pt2);
|
|
|
|
acdbWcs2Ucs(asDblArray(pt1),pt11,false);
|
|
acdbWcs2Ucs(asDblArray(pt2),pt22,false);
|
|
|
|
AcDbPolyline* pPlTmp = NULL;
|
|
if (pt22[Y] - pt11[Y] > 1.e-6)
|
|
{
|
|
//调换
|
|
pPlTmp = pTopLine;
|
|
pTopLine = pBomLine;
|
|
pBomLine = pPlTmp;
|
|
}
|
|
|
|
//1.绘制纵断的节点
|
|
AcArray<BreakPos> arBreakPts;//断开点
|
|
DrawVerSectionStack(dc,ptLast,ptrODtTop,ptrODtBom,arBreakPts,pCenLine);
|
|
|
|
//2.绘制纵断面线
|
|
pTopLine->setConstantWidth(m_dSingleLnWidth * m_dXDrawScale);//默认1:100
|
|
pTopLine->setLayer(layerId());
|
|
pTopLine->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
//外顶标高,底部中线为基准
|
|
WriteElXData(pTopLine,StartElevation() + ptrODtTop.x,1);//位置1
|
|
|
|
dc.DrawPolyline(*pTopLine);
|
|
Add2DBuffer(pTopLine);
|
|
|
|
pBomLine->setConstantWidth(m_dSingleLnWidth * m_dXDrawScale);//默认1:100
|
|
pBomLine->setLayer(layerId());
|
|
pBomLine->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
//管廊最底标高
|
|
WriteElXData(pBomLine,StartElevation(),2);//位置2
|
|
|
|
dc.DrawPolyline(*pBomLine);
|
|
Add2DBuffer(pBomLine);
|
|
|
|
//3.绘制封口线
|
|
pBomLine->getPointAt(0,ptVGe[0]);
|
|
pTopLine->getPointAt(0,ptVGe[1]);
|
|
AcDbPolyline* pStaL = new AcDbPolyline;
|
|
pStaL->addVertexAt(0,ptVGe[0]);
|
|
pStaL->addVertexAt(1,ptVGe[1]);
|
|
|
|
pStaL->setConstantWidth(m_dSingleLnWidth * m_dXDrawScale);//默认1:100
|
|
pStaL->setLayer(layerId());
|
|
pStaL->setNormal(AcGeVector3d::kZAxis);
|
|
dc.DrawPolyline(*pStaL);
|
|
|
|
EWFnctNode node;
|
|
memset(&node,0,sizeof(EWFnctNode));
|
|
_tcscpy(node.szStake,_T("Start"));
|
|
_tcscpy(node.szLockId,_T("Start"));
|
|
_tcscpy(node.szNodeSpec,_T("Start"));
|
|
EWDimData::writeXDataMap(pStaL, node);
|
|
Add2DBuffer(pStaL);
|
|
|
|
pBomLine->getPointAt(pBomLine->numVerts() - 1,ptVGe[2]);
|
|
pTopLine->getPointAt(pTopLine->numVerts() - 1,ptVGe[3]);
|
|
|
|
AcDbPolyline* pEndL = new AcDbPolyline;
|
|
pEndL->addVertexAt(0,ptVGe[2]);
|
|
pEndL->addVertexAt(1,ptVGe[3]);
|
|
|
|
pEndL->setConstantWidth(m_dSingleLnWidth * m_dXDrawScale);//默认1:100
|
|
pEndL->setLayer(layerId());
|
|
pEndL->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
_tcscpy(node.szStake,_T("End"));
|
|
_tcscpy(node.szLockId,_T("End"));
|
|
_tcscpy(node.szNodeSpec,_T("End"));
|
|
EWDimData::writeXDataMap(pEndL, node);
|
|
|
|
dc.DrawPolyline(*pEndL);
|
|
Add2DBuffer(pEndL);
|
|
}
|
|
|
|
if (pCenLine != NULL)
|
|
{
|
|
AecDbObjXDataMap xData;
|
|
xData.SetAt(_T("IDCEN"),1);
|
|
xData.Write(pCenLine, _T("VERSECCEN"));
|
|
pCenLine->setColorIndex(kMagenta);
|
|
dc.DrawPolyline(*pCenLine);
|
|
Add2DBuffer(pCenLine);
|
|
}
|
|
|
|
//绘制现状道路中心线
|
|
DrawVerSectionOldRoad(pCenLine,pRodLine,dc);
|
|
|
|
//绘制纵段视图下道路中心线
|
|
DrawVerSectionRoad(pCenLine,pRodLine,dc);
|
|
|
|
//绘制断面的管线示意
|
|
DrawVerSectionPipe(pCenLine,dc);
|
|
|
|
//4.绘制计算表格
|
|
double dHeight = dVSDrawOffset;
|
|
DrawVerSectionTbl(dc,ptLast,dHeight);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::WriteElXData(AcDbEntity* pPlEnt,double dStaEl,int nPos) const
|
|
{
|
|
assertReadEnabled();
|
|
if (pPlEnt != NULL)
|
|
{
|
|
AecDbObjXDataMap xData;
|
|
xData.SetAt(_T("StaEl"),dStaEl);
|
|
xData.SetAt(_T("ElPos"),nPos);
|
|
BOOL bSuccess = xData.Write(pPlEnt,_T("StaEl"));//起点标高
|
|
|
|
//acutPrintf(_T("\nWrite XData %d"),bSuccess);
|
|
return bSuccess ? Acad::eOk : Acad::eInvalidInput;
|
|
}
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
void AecDbShEarthWorm::RemoveAllPipePos()
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
struct resbuf* pTmp = acutNewRb(AcDb::kDxfRegAppName);
|
|
acutNewString(_T("PIPEPOS"),pTmp->resval.rstring);
|
|
pTmp->rbnext = NULL;
|
|
setXData(pTmp);
|
|
acutRelRb(pTmp);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::AddGripPoint(const AcGePoint3d& ptBr)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecDb3dRoadAxisLine* pRodLine = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRodLine != NULL)
|
|
{
|
|
return pRodLine->AddGripPoint(ptBr);
|
|
}
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::GetPipePos(AcArray<PipePos>& arPipePos) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
// 扩展数据
|
|
struct resbuf* pTmpRb = xData(_T("PIPEPOS"));
|
|
if (pTmpRb != NULL)
|
|
{
|
|
PipePos pps;
|
|
pps.pszLaySpec = NULL;
|
|
|
|
struct resbuf* pTmp = pTmpRb;
|
|
struct resbuf* pTmpDir = NULL;
|
|
struct resbuf* pTmpDn = NULL;
|
|
struct resbuf* pTmpLaySpec = NULL;
|
|
|
|
while(pTmp != NULL)
|
|
{
|
|
if (pTmp->restype == AcDb::kDxfXdXCoord)//点
|
|
{
|
|
pps.ptOn = asPnt3d(pTmp->resval.rpoint);
|
|
|
|
pTmpDir = pTmp->rbnext;
|
|
if (pTmpDir != NULL)
|
|
{
|
|
if (pTmpDir->restype == AcDb::kDxfXdXCoord)//向量
|
|
{
|
|
pps.vtDir = asPnt3d(pTmpDir->resval.rpoint).asVector();
|
|
}
|
|
|
|
pTmpDn = pTmpDir->rbnext;
|
|
if (pTmpDn != NULL )
|
|
{
|
|
if (pTmpDn->restype == AcDb::kDxfXdReal)//直径
|
|
{
|
|
pps.dDn = pTmpDn->resval.rreal;
|
|
arPipePos.append(pps);
|
|
}
|
|
|
|
pTmpLaySpec = pTmpDn->rbnext;
|
|
if (pTmpLaySpec != NULL)//指向直径
|
|
{
|
|
if (pTmpLaySpec->restype == AcDb::kDxfXdAsciiString)
|
|
{
|
|
acutNewString(pTmpLaySpec->resval.rstring,pps.pszLaySpec);
|
|
arPipePos.append(pps);
|
|
}
|
|
}
|
|
pTmp = pTmpLaySpec;
|
|
}
|
|
}
|
|
}
|
|
pTmp = pTmp->rbnext;//如果是直径,指向下段
|
|
}
|
|
acutRelRb(pTmpRb);
|
|
}
|
|
return !arPipePos.isEmpty();
|
|
}
|
|
|
|
bool AecDbShEarthWorm::AddPipePos(const AcArray<PipePos>& arPipePos)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
struct resbuf* pRb = NULL,*pTempNext = NULL;
|
|
struct resbuf* pTemp = NULL;
|
|
pTemp = acutNewRb(AcDb::kDxfRegAppName);
|
|
acutNewString(_T("PIPEPOS"),pTemp->resval.rstring);
|
|
pRb = pTemp;
|
|
|
|
for(int i = 0;i < arPipePos.length();i++)
|
|
{
|
|
const PipePos& pps = arPipePos.at(i);
|
|
|
|
//点
|
|
pTempNext = acutNewRb(AcDb::kDxfXdXCoord);
|
|
pTempNext->resval.rpoint[0] = pps.ptOn.x;
|
|
pTempNext->resval.rpoint[1] = pps.ptOn.y;
|
|
pTempNext->resval.rpoint[2] = pps.ptOn.z;
|
|
pTempNext->rbnext = NULL;
|
|
pTemp->rbnext = pTempNext;
|
|
pTemp = pTempNext;
|
|
pTempNext = NULL;
|
|
|
|
//向量
|
|
pTempNext = acutNewRb(AcDb::kDxfXdXCoord);
|
|
pTempNext->resval.rpoint[0] = pps.vtDir.x;
|
|
pTempNext->resval.rpoint[1] = pps.vtDir.y;
|
|
pTempNext->resval.rpoint[2] = pps.vtDir.z;
|
|
pTempNext->rbnext = NULL;
|
|
pTemp->rbnext = pTempNext;
|
|
pTemp = pTempNext;
|
|
pTempNext = NULL;
|
|
|
|
//直径
|
|
pTempNext = acutNewRb(AcDb::kDxfXdReal);
|
|
pTempNext->resval.rreal = pps.dDn;
|
|
pTempNext->rbnext = NULL;
|
|
pTemp->rbnext = pTempNext;
|
|
pTemp = pTempNext;
|
|
pTempNext = NULL;
|
|
|
|
//图层属性
|
|
pTempNext = acutNewRb(AcDb::kDxfXdAsciiString);
|
|
acutNewString(pps.pszLaySpec, pTempNext->resval.rstring);
|
|
pTempNext->rbnext = NULL;
|
|
pTemp->rbnext = pTempNext;
|
|
pTemp = pTempNext;
|
|
|
|
pTempNext = NULL;
|
|
}
|
|
|
|
// 扩展数据
|
|
struct resbuf* pTmpRb = xData(_T("PIPEPOS"));
|
|
if (pTmpRb != NULL)
|
|
{
|
|
//存在清空
|
|
struct resbuf* pTmp = acutNewRb(AcDb::kDxfRegAppName);
|
|
pTmp->rbnext = NULL;
|
|
acutNewString(_T("PIPEPOS"),pTmp->resval.rstring);
|
|
setXData(pTmp);
|
|
acutRelRb(pTmpRb);
|
|
acutRelRb(pTmp);
|
|
}
|
|
|
|
// 注册扩展数据链表
|
|
acdbRegApp(_T("PIPEPOS"));
|
|
Acad::ErrorStatus es = setXData(pRb);
|
|
acutRelRb(pRb);
|
|
return (es == Acad::eOk);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::DrawVerSectionPipe(AcDbPolyline* pPlCen,AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pBaseCurve == NULL || pPlCen == NULL)
|
|
return Acad::eOk;
|
|
|
|
//获取绘制表格的文字高度 图层 样式
|
|
//字体大小取 2.0 的倍数
|
|
//获取一个桩号
|
|
double dTxtH = 1.5;
|
|
double dTblH = 1.5;
|
|
|
|
CString sStyle = _T("Standard");
|
|
AcDbObjectId idStyle = acdbCurDwg()->textstyle();
|
|
AcDbObjectId idLayer = acdbCurDwg()->clayer();
|
|
double dAngle = AcGeVector3d::kXAxis.angleTo(acdbCurDwg()->ucsxdir(),AcGeVector3d::kZAxis);
|
|
|
|
AcArray<PipePos> arPipePos;
|
|
GetPipePos(arPipePos);
|
|
|
|
double dDist = 0.0,dEl = 0.0;
|
|
AcGePoint3d ptOn,ptOnVer;
|
|
ads_point ptUCS,ptWcs;
|
|
CString sTextSpec;
|
|
|
|
for (int i = 0;i < arPipePos.length();i++)
|
|
{
|
|
const PipePos& pps = arPipePos.at(i);
|
|
m_pBaseCurve->getClosestPointTo(pps.ptOn,ptOn);
|
|
|
|
dEl = pps.ptOn.z - ptOn.z;
|
|
|
|
m_pBaseCurve->getDistAtPoint(ptOn,dDist);
|
|
|
|
pPlCen->getPointAtDist(dDist,ptOnVer);
|
|
|
|
acdbWcs2Ucs(asDblArray(ptOnVer),ptUCS,false);
|
|
ptUCS[Y] += dEl;
|
|
acdbUcs2Wcs(ptUCS,ptWcs,false);
|
|
|
|
AcDbCircle* pCir = new AcDbCircle;
|
|
pCir->setCenter(asPnt3d(ptWcs));
|
|
pCir->setRadius(pps.dDn * 0.5);
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
pCir->setColorIndex(kMagenta);
|
|
|
|
dc.DrawEntity(pCir);
|
|
Add2DBuffer(pCir);
|
|
|
|
//绘制图层属性
|
|
if (pps.pszLaySpec != NULL)
|
|
{
|
|
sTextSpec.Format(_T("DN %d-%s"),(int)( AS_M2MM(pps.dDn) + 0.5),pps.pszLaySpec);
|
|
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(idStyle);
|
|
pText->setTextString(sTextSpec);//数据
|
|
pText->setHeight(dTxtH);
|
|
pText->setWidthFactor(0.5);
|
|
pText->setRotation(dAngle);
|
|
pText->setHorizontalMode(AcDb::kTextRight);
|
|
|
|
ptUCS[Y] -= 0.5 * pps.dDn;
|
|
ptUCS[Y] -= 0.5 * dTxtH;
|
|
ptUCS[X] += pps.dDn;
|
|
acdbUcs2Wcs(ptUCS,ptWcs,false);
|
|
|
|
pText->setPosition( asPnt3d(ptWcs));
|
|
pText->setAlignmentPoint(asPnt3d(ptWcs));
|
|
pText->setLayer(idLayer);
|
|
|
|
dc.DrawEntity(pText);
|
|
Add2DBuffer(pText);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//设计高程
|
|
Acad::ErrorStatus AecDbShEarthWorm::DrawVerSectionRoad(AcDbPolyline* pPlCen,AcDbCurve* pBaseCurve,AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
AcDbCurve* pRoadCurve = GetRoadCenline(true);
|
|
if (pRoadCurve == NULL)
|
|
return Acad::eInvalidInput;
|
|
|
|
if (pBaseCurve == NULL)
|
|
return Acad::eInvalidInput;
|
|
|
|
Acad::ErrorStatus es;
|
|
|
|
AcGePoint3d ptVSta;
|
|
es = pPlCen->getStartPoint(ptVSta);
|
|
|
|
//管廊基准线的标高
|
|
AcGePoint3d ptSta,ptEnd,ptRoadSta;
|
|
es = pBaseCurve->getStartPoint(ptSta);
|
|
es = pBaseCurve->getEndPoint(ptEnd);
|
|
|
|
pRoadCurve->getStartPoint(ptRoadSta);
|
|
double dRoadStaEl = ptRoadSta.z;
|
|
|
|
AcGePoint3d ptOnRoad;
|
|
es = pRoadCurve->getClosestPointTo(ptSta,AcGeVector3d::kZAxis,ptOnRoad);
|
|
|
|
double dDistFr = 0.0;
|
|
pRoadCurve->getDistAtPoint(ptOnRoad,dDistFr);
|
|
|
|
AcGeVector3d vtDirX = acdbCurDwg()->ucsxdir();//end-start
|
|
vtDirX.z = 0.0;
|
|
vtDirX.normalize();
|
|
|
|
AcGeVector3d vtDirY = vtDirX;
|
|
vtDirY.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
ptVSta -= vtDirX * dDistFr;//高程线的起点位置
|
|
|
|
double dZ =ptRoadSta.z - ptSta.z;
|
|
ptVSta += vtDirY * dZ;
|
|
|
|
struct resbuf rb;
|
|
acedGetVar(_T("useri3"),&rb);
|
|
if (rb.resval.rint == 1357)//特定情况下,绘制道路设计线,测试用
|
|
{
|
|
int nDrawHead = 0;
|
|
GetSpecialtyData()->GetAt(_T("DrawTblHead"),nDrawHead);
|
|
//if (nDrawHead == 1)
|
|
{
|
|
AcDbPolyline* pCurveRd = GetRoadCenlineVerSection( ptVSta );
|
|
if (pCurveRd != NULL)
|
|
{
|
|
int nOld = dc.GetColor();
|
|
dc.SetColor(kYellow);
|
|
dc.DrawPline(*pCurveRd);
|
|
dc.SetColor(nOld);
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
}
|
|
|
|
//管廊基线的开始和终点
|
|
AcGePoint3d ptOn1,ptOn2;
|
|
if ( Acad::eOk == (es = pRoadCurve->getClosestPointTo(ptSta,AcGeVector3d::kZAxis,ptOn1) ) &&
|
|
Acad::eOk == (es = pRoadCurve->getClosestPointTo(ptEnd,AcGeVector3d::kZAxis,ptOn2) ) )
|
|
{
|
|
dRoadStaEl = ptOn1.z;
|
|
double dDist1 = 0.0,dDist2 = 0.0;
|
|
es = pRoadCurve->getDistAtPoint(ptOn1,dDist1);
|
|
es = pRoadCurve->getDistAtPoint(ptOn2,dDist2);
|
|
|
|
AcDbPolyline* pRoadDesVerSec = GetRoadCenlineVerSection(ptVSta);
|
|
if (pRoadDesVerSec != NULL)
|
|
{
|
|
double dPar1 = 0.0,dPar2 = 0.0;
|
|
es = pRoadDesVerSec->getParamAtDist(dDist1,dPar1);
|
|
es = pRoadDesVerSec->getParamAtDist(dDist2,dPar2);
|
|
|
|
AcGeDoubleArray arParms;
|
|
arParms.append(dPar1);
|
|
arParms.append(dPar2);
|
|
|
|
AcGePoint3d ptMid;
|
|
es = pRoadDesVerSec->getPointAtDist((dDist1 + dDist2) / 2.0,ptMid);
|
|
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
es = pRoadDesVerSec->getSplitCurves(arParms,arCurPtrs);
|
|
|
|
double dMid = 0.0;
|
|
AcDbCurve* pCurve = NULL,*pThisRoadVerSec = NULL;
|
|
for (int k = 0;k < arCurPtrs.length();k++)
|
|
{
|
|
pCurve = (AcDbCurve*)arCurPtrs.at(k);
|
|
if (Acad::eOk == pCurve->getParamAtPoint(ptMid,dMid) )
|
|
{
|
|
pThisRoadVerSec = pCurve;
|
|
arCurPtrs.removeAt(k);
|
|
break;
|
|
}
|
|
}
|
|
FreeBuffer(0,arCurPtrs);
|
|
|
|
if (pThisRoadVerSec != NULL)
|
|
{
|
|
//蓝色显示
|
|
int nOld = dc.GetColor();
|
|
dc.SetColor(kYellow);
|
|
pThisRoadVerSec->setColorIndex(kYellow);
|
|
dc.DrawEntity(pThisRoadVerSec);
|
|
dc.SetColor(nOld);
|
|
|
|
pThisRoadVerSec->getStartPoint(ptRoadSta);
|
|
|
|
//设计道路中心线 起点标高
|
|
WriteElXData(pThisRoadVerSec,dRoadStaEl,0);//位置0
|
|
|
|
Add2DBuffer(pThisRoadVerSec);
|
|
//return Acad::eOk;
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//自然高程
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::DrawVerSectionOldRoad(AcDbPolyline* pPlCen,AcDbCurve* pBaseCurve,AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbCurve* pRoadCurve = GetOldRoadCenline(true);
|
|
if (pRoadCurve == NULL)
|
|
return Acad::eInvalidInput;
|
|
|
|
if (pBaseCurve == NULL)
|
|
return Acad::eInvalidInput;
|
|
|
|
Acad::ErrorStatus es;
|
|
|
|
AcGePoint3d ptVSta;
|
|
es = pPlCen->getStartPoint(ptVSta);
|
|
|
|
//管廊基准线的标高
|
|
AcGePoint3d ptSta,ptEnd,ptRoadSta;
|
|
es = pBaseCurve->getStartPoint(ptSta);
|
|
es = pBaseCurve->getEndPoint(ptEnd);
|
|
|
|
pRoadCurve->getStartPoint(ptRoadSta);
|
|
double dRoadStaEl = ptRoadSta.z;
|
|
|
|
AcGePoint3d ptOnRoad;
|
|
es = pRoadCurve->getClosestPointTo(ptSta,AcGeVector3d::kZAxis,ptOnRoad);
|
|
|
|
double dDistFr = 0.0;
|
|
pRoadCurve->getDistAtPoint(ptOnRoad,dDistFr);
|
|
|
|
AcGeVector3d vtDirX = acdbCurDwg()->ucsxdir();//end-start
|
|
vtDirX.z = 0.0;
|
|
vtDirX.normalize();
|
|
|
|
AcGeVector3d vtDirY = vtDirX;
|
|
vtDirY.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
ptVSta -= vtDirX * dDistFr;//高程线的起点位置
|
|
|
|
double dZ =ptRoadSta.z - ptSta.z;
|
|
ptVSta += vtDirY * dZ;
|
|
|
|
struct resbuf rb;
|
|
acedGetVar(_T("useri3"),&rb);
|
|
if (rb.resval.rint == 1357)//特定情况下,绘制道路设计线,测试用
|
|
{
|
|
int nDrawHead = 0;
|
|
GetSpecialtyData()->GetAt(_T("DrawTblHead"),nDrawHead);
|
|
//if (nDrawHead == 1)
|
|
{
|
|
AcDbPolyline* pCurveRd = GetOldRoadCenlineVerSection( ptVSta );
|
|
if (pCurveRd != NULL)
|
|
{
|
|
int nOld = dc.GetColor();
|
|
dc.SetColor(kGreen);
|
|
dc.DrawPline(*pCurveRd);
|
|
dc.SetColor(nOld);
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
}
|
|
|
|
//管廊基线的开始和终点
|
|
AcGePoint3d ptOn1,ptOn2;
|
|
if ( Acad::eOk == (es = pRoadCurve->getClosestPointTo(ptSta,AcGeVector3d::kZAxis,ptOn1) ) &&
|
|
Acad::eOk == (es = pRoadCurve->getClosestPointTo(ptEnd,AcGeVector3d::kZAxis,ptOn2) ) )
|
|
{
|
|
dRoadStaEl = ptOn1.z;
|
|
double dDist1 = 0.0,dDist2 = 0.0;
|
|
es = pRoadCurve->getDistAtPoint(ptOn1,dDist1);
|
|
es = pRoadCurve->getDistAtPoint(ptOn2,dDist2);
|
|
|
|
AcDbPolyline* pRoadDesVerSec = GetOldRoadCenlineVerSection(ptVSta);
|
|
if (pRoadDesVerSec != NULL)
|
|
{
|
|
double dPar1 = 0.0,dPar2 = 0.0;
|
|
es = pRoadDesVerSec->getParamAtDist(dDist1,dPar1);
|
|
es = pRoadDesVerSec->getParamAtDist(dDist2,dPar2);
|
|
|
|
AcGeDoubleArray arParms;
|
|
arParms.append(dPar1);
|
|
arParms.append(dPar2);
|
|
|
|
AcGePoint3d ptMid;
|
|
es = pRoadDesVerSec->getPointAtDist((dDist1 + dDist2) / 2.0,ptMid);
|
|
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
es = pRoadDesVerSec->getSplitCurves(arParms,arCurPtrs);
|
|
|
|
double dMid = 0.0;
|
|
AcDbCurve* pCurve = NULL,*pThisRoadVerSec = NULL;
|
|
for (int k = 0;k < arCurPtrs.length();k++)
|
|
{
|
|
pCurve = (AcDbCurve*)arCurPtrs.at(k);
|
|
if (Acad::eOk == pCurve->getParamAtPoint(ptMid,dMid) )
|
|
{
|
|
pThisRoadVerSec = pCurve;
|
|
arCurPtrs.removeAt(k);
|
|
break;
|
|
}
|
|
}
|
|
FreeBuffer(0,arCurPtrs);
|
|
|
|
if (pThisRoadVerSec != NULL)
|
|
{
|
|
//蓝色显示
|
|
int nOld = dc.GetColor();
|
|
dc.SetColor(kGreen);
|
|
pThisRoadVerSec->setColorIndex(kGreen);
|
|
dc.DrawEntity(pThisRoadVerSec);
|
|
dc.SetColor(nOld);
|
|
|
|
pThisRoadVerSec->getStartPoint(ptRoadSta);
|
|
|
|
//设计道路中心线 起点标高
|
|
WriteElXData(pThisRoadVerSec,dRoadStaEl,0);//位置0
|
|
|
|
Add2DBuffer(pThisRoadVerSec);
|
|
//return Acad::eOk;
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//异型结构
|
|
Acad::ErrorStatus AecDbShEarthWorm::DrawModelSection2d(AcGiDraw &dc,const EWFnctNode* pNext,double dGradient,double dDistFrom,double dHeight,const AcGePoint2d& ptLast,AcArray<BreakPos>& arBreaks,const AcDbPolyline* pCenLine) const
|
|
{
|
|
AecDb3dRoadAxisLine* pRodLine = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRodLine != NULL)
|
|
{
|
|
AcGeVector2d vtDirX,vtDirY;
|
|
vtDirX = acdbCurDwg()->ucsxdir().convert2d(AcGePlane::kXYPlane);//m_ptEnd - m_ptStart;
|
|
vtDirX.normalize();
|
|
|
|
vtDirY = vtDirX;
|
|
vtDirY.rotateBy(PI / 2.0);
|
|
vtDirY.normalize();
|
|
|
|
AcGeVector3d vtDirY3d(vtDirY.x,vtDirY.y,0.0);
|
|
vtDirY3d.normalize();
|
|
|
|
AcGeVector3d vtDir3d(vtDirX.x,vtDirX.y,0.0);
|
|
vtDir3d.normalize();
|
|
|
|
//定位到纵断中心线上
|
|
AcGePoint3d ptPos;
|
|
pCenLine->getPointAtDist(dDistFrom,ptPos);
|
|
|
|
//异型
|
|
AecDbEarthWormFitting fit;
|
|
AecDbEarthWormFitting* pFit = NULL;
|
|
std::map<CString,PVOID>::const_iterator it;
|
|
if (g_mapSHProMode2Fit.end() != ( it = g_mapSHProMode2Fit.find(pNext->szLockId) ) )
|
|
{
|
|
pFit = (AecDbEarthWormFitting*)(*it).second;
|
|
}
|
|
else
|
|
{
|
|
CMemFile file;
|
|
file.Attach((BYTE*)pNext->pProModelBuffer,pNext->nProModelBufLen);
|
|
fit.ReadFrom(&file);
|
|
pFit = &fit;
|
|
file.Detach();
|
|
}
|
|
|
|
double dLeft(.5 * pFit->GetLen());
|
|
pFit->GetSpecialtyData()->GetAt(_T("dLeft"),dLeft);
|
|
|
|
//ptPos += (pNext->dDistFromPre - 0.5 * pFit->GetLen() ) * vtDir3d;
|
|
ptPos += (pNext->dDistFromPre - dLeft ) * vtDir3d;//0.0-dLeft
|
|
ptPos += (pNext->dDistFromPre - dLeft ) * dGradient * 0.01 * vtDirY3d;////0.0-dLeft
|
|
|
|
//TEST
|
|
// AcDbCircle* pCir = new AcDbCircle;
|
|
// pCir->setCenter(ptPos);
|
|
// pCir->setRadius(10.0);
|
|
// pCir->setColorIndex(1);
|
|
// AddToModelSpace(pCir);
|
|
|
|
AcDbVoidPtrArray ar2DEntPtrs;
|
|
pFit->GetDraw2d(ar2DEntPtrs,1);
|
|
|
|
if (ar2DEntPtrs.isEmpty())
|
|
{
|
|
AcGiViewDraw dcTmp(NULL,NULL);
|
|
pFit->Draw3d(dcTmp);
|
|
pFit->GetDraw2d(ar2DEntPtrs,1);//已经clone
|
|
}
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbVoidPtrArray arRegPtrs;
|
|
/*for (int i = 0;i < ar2DEntPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2DEntPtrs.at(i);
|
|
struct resbuf* pRb2 = pEnt->xData(_T("DIM_DATA"));
|
|
AcDbEntity *pClone = (AcDbEntity*)pEnt->clone();
|
|
if (pRb2)
|
|
{
|
|
pClone->setXData(pRb2);
|
|
}
|
|
arRegPtrs.append(pEnt);
|
|
}*/
|
|
arRegPtrs.append(ar2DEntPtrs);
|
|
|
|
AecDbEarthWormFitting::Transformby(arRegPtrs,ptPos,vtDir3d);
|
|
|
|
CString sRoon,sVal,sText;
|
|
EWFnctNode node;
|
|
for (int i = 0;i < arRegPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arRegPtrs.at(i);
|
|
::memset(&node, 0, sizeof(EWFnctNode));
|
|
memcpy(&node, pNext, sizeof(EWFnctNode));
|
|
EWDimData::writeXDataMap(pEnt, node);
|
|
dc.DrawEntity(pEnt);
|
|
Add2DBuffer(pEnt);
|
|
//m_ar2DDrableBufPtrs.append(pEnt);
|
|
}
|
|
|
|
arRegPtrs.removeAll();
|
|
|
|
//提取附属物视图,寻找附属物
|
|
AcDbEntity* pSubEnt = NULL;
|
|
EWFnctNode fnNode;
|
|
for (int k = 0;k < m_arPortRoomIds.length();k++)
|
|
{
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,m_arPortRoomIds.at(k),AcDb::kForRead))
|
|
{
|
|
AecDbXXXDoghouse* pXXXHouse = AecDbXXXDoghouse::cast(pEnt);
|
|
if (pXXXHouse != NULL)
|
|
{
|
|
pXXXHouse->GetEWFnctNode(&fnNode);
|
|
if (_tcscmp(fnNode.szLockId,pNext->szLockId) == 0)
|
|
{
|
|
pXXXHouse->GetDraw2d(arRegPtrs,1);
|
|
|
|
AecDbEarthWormFitting::Transformby(arRegPtrs,ptPos,vtDir3d);
|
|
|
|
for (int i = 0;i < arRegPtrs.length();i++)
|
|
{
|
|
pSubEnt = (AcDbEntity*)arRegPtrs.at(i);
|
|
dc.DrawEntity(pSubEnt);
|
|
Add2DBuffer(pSubEnt);
|
|
//m_ar2DDrableBufPtrs.append(pSubEnt);
|
|
}
|
|
pEnt->close();
|
|
break;
|
|
}
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
|
|
//中心
|
|
AcGePoint2d ptL = ptPos.convert2d(AcGePlane::kXYPlane);
|
|
|
|
BreakPos bPs;
|
|
bPs.ptGe.set(ptL.x,ptL.y,0.0);
|
|
bPs.dLen = pFit->GetLen();
|
|
bPs.dW = 0.0;
|
|
arBreaks.append(bPs);
|
|
|
|
ptL += pFit->GetLen() * vtDirX;
|
|
//ptL += dLeft * vtDirX;
|
|
|
|
//中心
|
|
//ptPos += 0.5 * pFit->GetLen() * vtDir3d;
|
|
ptPos += dLeft * vtDir3d;
|
|
ptL = ptPos.convert2d(AcGePlane::kXYPlane);
|
|
|
|
//定位用
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->addVertexAt(0,ptL);
|
|
ptL += dHeight / 10.0 * vtDirX;
|
|
pPl->addVertexAt(1,ptL);
|
|
EWDimData::writeXDataMap(pPl, *pNext);
|
|
|
|
dc.DrawEntity(*pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::DrawVerSectionStack(AcGiDraw &dc,const AcGePoint2d& ptLast,const AcGePoint2d& ptrODtTop,const AcGePoint2d& ptrODtBom,AcArray<BreakPos>& arBreakPts,const AcDbPolyline* pCenLine) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
double dD = 0.0,dt = 0.0,dH = 0.0,dhb = 0.0,dBomt = 0.0;
|
|
double dL = 0.0,dW = 0.0;
|
|
|
|
double dDistFrom = 0.0;
|
|
AcGePoint2d ptPos2d;
|
|
AcGeVector2d vtDirX,vtDirY;
|
|
|
|
AcGePoint2d ptGe[5];
|
|
vtDirX = acdbCurDwg()->ucsxdir().convert2d(AcGePlane::kXYPlane);//end-start
|
|
vtDirX.normalize();
|
|
|
|
vtDirY = vtDirX;
|
|
vtDirY.rotateBy(PI / 2.0);
|
|
|
|
AecDb3dRoadAxisLine* pRodLine = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRodLine != NULL)
|
|
{
|
|
AcGePoint3d ptOn;
|
|
for (int i = 0;i < m_arStackPts.length();i++)
|
|
{
|
|
const EWStackPoint& sp = m_arStackPts.at(i);
|
|
if (sp.pFnNode != NULL)
|
|
{
|
|
pRodLine->getClosestPointTo(sp.ptPos,ptOn);
|
|
|
|
dDistFrom = 0.0;
|
|
pRodLine->getDistAtPoint(ptOn,dDistFrom);
|
|
|
|
//定位到纵断中心线上
|
|
pCenLine->getPointAtDist(dDistFrom,ptOn);
|
|
|
|
if (sp.pFnNode->eFnType == kVerticalWell)
|
|
{
|
|
if (sp.pFnNode->nFlag == 0)//圆井
|
|
{
|
|
dD = sp.pFnNode->fNodeDef[0];//外径
|
|
dt = sp.pFnNode->fNodeDef[1];//壁厚
|
|
dH = sp.pFnNode->fNodeDef[2];//总高度
|
|
dhb = sp.pFnNode->fNodeDef[3];//廊底下深深度,不含底厚度
|
|
dBomt = sp.pFnNode->fNodeDef[4];//底厚度
|
|
|
|
ptPos2d.set(ptOn.x,ptOn.y);
|
|
|
|
ptGe[0] = ptPos2d;
|
|
ptGe[0] -= vtDirX * 0.5 * dD;//D
|
|
ptGe[0] -= ptrODtBom.x * vtDirY;
|
|
ptGe[0] -= dhb * vtDirY;
|
|
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1] += vtDirY * dH;
|
|
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2] += vtDirX * dD;
|
|
|
|
ptGe[3] = ptGe[0] + vtDirX * dD;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
}
|
|
else//方井
|
|
{
|
|
dL = sp.pFnNode->fNodeDef[0];//外长
|
|
dW = sp.pFnNode->fNodeDef[1];//外宽
|
|
dt = sp.pFnNode->fNodeDef[2];//壁厚
|
|
dH = sp.pFnNode->fNodeDef[3];//总高度
|
|
dhb = sp.pFnNode->fNodeDef[4];//廊底下深深度,不含底厚度
|
|
dBomt = sp.pFnNode->fNodeDef[5];//底厚度
|
|
|
|
ptPos2d.set(ptOn.x,ptOn.y);
|
|
|
|
ptGe[0] = ptPos2d;
|
|
ptGe[0] -= vtDirX * 0.5 * dL;//D
|
|
ptGe[0] -= ptrODtBom.x * vtDirY;
|
|
ptGe[0] -= dhb * vtDirY;
|
|
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1] += vtDirY * dH;
|
|
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2] += vtDirX * dL;
|
|
|
|
ptGe[3] = ptGe[0] + vtDirX * dL;
|
|
ptGe[4] = ptGe[0];
|
|
}
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
pPl->setElevation(0.0);
|
|
for (int ii = 0;ii < 5;ii++)
|
|
{
|
|
pPl->addVertexAt(ii,ptGe[ii]);
|
|
}
|
|
|
|
EWDimData::writeXDataMap(pPl, *sp.pFnNode);
|
|
|
|
dc.DrawEntity(*pPl);
|
|
Add2DBuffer(pPl);
|
|
|
|
BreakPos bPos;
|
|
bPos.ptGe.set( 0.5 * (ptGe[1].x + ptGe[2].x),0.5 * (ptGe[1].y + ptGe[2].y),0.0);
|
|
bPos.dLen = ptGe[1].distanceTo(ptGe[2]);
|
|
bPos.dW = 0.0;
|
|
arBreakPts.append(bPos);
|
|
}
|
|
else if (sp.pFnNode->eFnType == kProModel)
|
|
{
|
|
pRodLine->getClosestPointTo(sp.ptPos,ptOn);
|
|
|
|
dDistFrom = 0.0;
|
|
pRodLine->getDistAtPoint(ptOn,dDistFrom);
|
|
|
|
//定位到纵断中心线上
|
|
pCenLine->getPointAtDist(dDistFrom,ptOn);
|
|
|
|
DrawModelSection2d(dc,sp.pFnNode,0.0,dDistFrom,0.0,ptLast,arBreakPts,pCenLine);
|
|
|
|
//定位用
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
ptGe[0] = ptOn.convert2d(AcGePlane::kXYPlane);
|
|
pPl->addVertexAt(0,ptGe[0]);
|
|
ptGe[0] += 0.1 * vtDirX;
|
|
pPl->addVertexAt(1,ptGe[0]);
|
|
|
|
if (pPl != NULL)
|
|
{
|
|
EWDimData::writeXDataMap(pPl, *sp.pFnNode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::MakeStake2UCSXPos() const
|
|
{
|
|
CString sStack;
|
|
ads_point pt;
|
|
double dXPos = 0.0;
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(i);
|
|
|
|
AecDbObjXDataMap xdata;
|
|
if (xdata.Read(pEnt,_T("DIM_DATA")))//读取桩号
|
|
{
|
|
if ( xdata.GetAt(_T("szStake"),sStack) )
|
|
{
|
|
AcDbCurve* pCurve = AcDbCurve::cast(pEnt);
|
|
if (pCurve != NULL)
|
|
{
|
|
AcGePoint3d ptSta;
|
|
pCurve->getStartPoint(ptSta);
|
|
|
|
acdbWcs2Ucs(asDblArray(ptSta),pt,false);
|
|
dXPos = pt[X];
|
|
m_mapStake2UCSXPos.SetAt(sStack,dXPos);
|
|
}
|
|
}
|
|
|
|
if ( xdata.GetAt(_T("szLockId"),sStack) )
|
|
{
|
|
AcDbCurve* pCurve = AcDbCurve::cast(pEnt);
|
|
if (pCurve != NULL)
|
|
{
|
|
AcGePoint3d ptSta;
|
|
pCurve->getStartPoint(ptSta);
|
|
|
|
acdbWcs2Ucs(asDblArray(ptSta),pt,false);
|
|
dXPos = pt[X];
|
|
m_mapStake2UCSXPos.SetAt(sStack,dXPos);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::FindStakeUCSXPos(LPCTSTR pszStake,double& dXPos,int nIDType) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (pszStake == NULL)
|
|
return false;
|
|
|
|
if (_tcslen(pszStake) == 0)
|
|
return false;
|
|
|
|
return m_mapStake2UCSXPos.Lookup(pszStake,dXPos) ? true : false;
|
|
}
|
|
|
|
|
|
//表格抬头
|
|
LPCTSTR g_pszSHGlobalLable[] = { _T("设计坡度与距离")
|
|
,_T("设计地面高程")
|
|
,_T("现状地面高程")
|
|
,_T("管廊外顶高程")
|
|
,_T("管廊内底高程")
|
|
,_T("管廊覆土")
|
|
,_T("盾构土方")
|
|
,_T("道路桩号")
|
|
,_T("管廊里程")
|
|
,_T("功能布置")
|
|
,_T("覆土高度")
|
|
,NULL };
|
|
|
|
extern bool GetDefaultTextStyleInfo(AcGePoint3d ptGeTxt0, AcGePoint3d ptGeTxt1, AcDbObjectId& idStyle, AcDbObjectId& idLayer, CString& sStyle, double& dTxtH, double& dTblH, double& dTblW);
|
|
static bool AvoidTextOverLap(AcArray<TextOnPoint>& arTextPts,AcGePoint3d& ptGeTxt,double dTxtH,LPCTSTR pszVal,int nKind)
|
|
{
|
|
int nMoveL = 0;
|
|
AcGePoint3d ptTmp;
|
|
CString sText;
|
|
AcDbText* pText = NULL;
|
|
|
|
for (int i = 0;i < arTextPts.length();i++)
|
|
{
|
|
ptTmp = arTextPts.at(i).ptPos;
|
|
pText = arTextPts.at(i).pText;
|
|
|
|
if (ptTmp.distanceTo(ptGeTxt) < dTxtH)//重叠一次
|
|
{
|
|
if (nKind == 4 && pText != NULL)//土方
|
|
{
|
|
LPCTSTR pszTxt = pText->textStringConst();
|
|
double dVal = _ttof(pszTxt) + _ttof(pszVal);
|
|
sText.Format(_T("%.3f"),dVal);
|
|
pText->setTextString(sText);
|
|
}
|
|
nMoveL++;
|
|
}
|
|
}
|
|
|
|
if (nMoveL > 0)
|
|
{
|
|
ads_point ptUcs;
|
|
acdbWcs2Ucs(asDblArray(ptGeTxt),ptUcs,false);
|
|
ptUcs[X] += nMoveL * dTxtH;
|
|
acdbUcs2Wcs(ptUcs,asDblArray(ptGeTxt),false);
|
|
}
|
|
return nMoveL > 0 ? true : false;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::MerageGradientAndDist(AcArray<TextOnPoint>& arTxtGrLen,AcDbObjectId& idStyle,AcDbObjectId& idLayer,double dTxtH,double dAngle,AcGiDraw &dc) const
|
|
{
|
|
//1.35%/678.234
|
|
if (arTxtGrLen.isEmpty())
|
|
return Acad::eInvalidInput;
|
|
CString sText;
|
|
TextOnPoint txtPtLast = arTxtGrLen.first();
|
|
CString sTextLast = txtPtLast.pText->textStringConst();
|
|
int nPos = sTextLast.Find(_T('/'));
|
|
if (nPos != -1)
|
|
{
|
|
CString sGrdL = sTextLast.Mid(0,nPos-1);
|
|
CString sLenL = sTextLast.Mid(nPos+1);
|
|
|
|
int nIndex = 1;
|
|
double dLen = _ttof(sLenL);
|
|
double dMax = dLen;
|
|
|
|
while(true)
|
|
{
|
|
if (nIndex >= arTxtGrLen.length() )
|
|
{
|
|
if (arTxtGrLen.length() == 1)//只有一段
|
|
{
|
|
TextOnPoint& txtPtNext = arTxtGrLen.at(0);
|
|
sTextLast = txtPtNext.pText->textStringConst();
|
|
nPos = sTextLast.Find(_T('/'));
|
|
if (nPos != -1)
|
|
{
|
|
CString sGrdN = sTextLast.Mid(0,nPos-1);
|
|
CString sLenN = sTextLast.Mid(nPos+1);
|
|
|
|
if ( fabs(_ttof(sGrdN) - _ttof(sGrdL) ) < 1.e-6)//认为相等
|
|
{
|
|
dMax = __max(dMax,_ttof(sLenN));
|
|
//if (0 == arTxtGrLen.length() - 1)
|
|
{
|
|
sText.Format(_T("%.3f%%/%.3f"),_ttof(sGrdN),dMax);
|
|
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(idStyle);
|
|
pText->setTextString(sText);//数据
|
|
pText->setHeight(dTxtH);
|
|
pText->setWidthFactor(0.5);
|
|
pText->setRotation(dAngle);
|
|
pText->setHorizontalMode(AcDb::kTextRight);
|
|
pText->setPosition( txtPtLast.ptPos);
|
|
pText->setAlignmentPoint(txtPtLast.ptPos);
|
|
pText->setLayer(idLayer);
|
|
|
|
AcGiTextStyle giStyle;
|
|
fromAcDbTextStyle(giStyle,idStyle);
|
|
CString sStyle = giStyle.styleName();
|
|
|
|
AcDbExtents extT;
|
|
CKTCadUtility::GetTextBox(extT,sText,sStyle,dTxtH,0.5);
|
|
|
|
AcGeVector3d vtDirx = AcGeVector3d::kXAxis;
|
|
vtDirx.rotateBy(dAngle,AcGeVector3d::kZAxis);
|
|
txtPtLast.ptPos -= vtDirx * (extT.maxPoint().x - extT.minPoint().x);
|
|
pText->setPosition( txtPtLast.ptPos);
|
|
pText->setAlignmentPoint(txtPtLast.ptPos);
|
|
|
|
dc.DrawEntity(*pText);
|
|
Add2DBuffer(pText);
|
|
|
|
//绘制坡度线
|
|
}
|
|
nIndex += 1;
|
|
}
|
|
else//不等,绘制上次
|
|
{
|
|
int nLast = nIndex - 1;
|
|
TextOnPoint& txtPtNext2 = arTxtGrLen.at(nLast);
|
|
sTextLast = txtPtNext2.pText->textStringConst();
|
|
nPos = sTextLast.Find(_T('/'));
|
|
if (nPos != -1)
|
|
{
|
|
CString sGrdN = sTextLast.Mid(0,nPos-1);
|
|
CString sLenN = sTextLast.Mid(nPos+1);
|
|
dMax = __max(dMax,_ttof(sLenN));
|
|
|
|
sText.Format(_T("%.3f%%/%.3f"),_ttof(sGrdN),dMax);
|
|
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(idStyle);
|
|
pText->setTextString(sText);//数据
|
|
pText->setHeight(dTxtH);
|
|
pText->setWidthFactor(0.5);
|
|
pText->setRotation(dAngle);
|
|
pText->setHorizontalMode(AcDb::kTextRight);
|
|
pText->setPosition(txtPtLast.ptPos);
|
|
pText->setAlignmentPoint(MidPoint(txtPtLast.ptPos,txtPtNext2.ptPos));
|
|
pText->setLayer(idLayer);
|
|
|
|
dc.DrawEntity(*pText);
|
|
Add2DBuffer(pText);
|
|
|
|
//绘制坡度线
|
|
}
|
|
|
|
txtPtLast = txtPtNext;
|
|
sTextLast = txtPtLast.pText->textStringConst();
|
|
int nPos = sTextLast.Find(_T('/'));
|
|
if (nPos != -1)
|
|
{
|
|
sGrdL = sTextLast.Mid(0,nPos-1);
|
|
sLenL = sTextLast.Mid(nPos+1);
|
|
|
|
dLen = _ttof(sLenL);
|
|
dMax = dLen;
|
|
}
|
|
nIndex += 1;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
|
|
TextOnPoint& txtPtNext = arTxtGrLen.at(nIndex);
|
|
sTextLast = txtPtNext.pText->textStringConst();
|
|
nPos = sTextLast.Find(_T('/'));
|
|
if (nPos != -1)
|
|
{
|
|
CString sGrdN = sTextLast.Mid(0,nPos-1);
|
|
CString sLenN = sTextLast.Mid(nPos+1);
|
|
|
|
if ( fabs(_ttof(sGrdN) - _ttof(sGrdL) ) < 1.e-6)//认为相等
|
|
{
|
|
dMax = __max(dMax,_ttof(sLenN));
|
|
if (nIndex == arTxtGrLen.length() - 1)
|
|
{
|
|
sText.Format(_T("%.3f%%/%.3f"),_ttof(sGrdN),dMax);
|
|
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(idStyle);
|
|
pText->setTextString(sText);//数据
|
|
pText->setHeight(dTxtH);
|
|
pText->setWidthFactor(0.5);
|
|
pText->setRotation(dAngle);
|
|
pText->setHorizontalMode(AcDb::kTextRight);
|
|
pText->setPosition( txtPtLast.ptPos);
|
|
pText->setAlignmentPoint( MidPoint(txtPtLast.ptPos,txtPtNext.ptPos));
|
|
pText->setLayer(idLayer);
|
|
|
|
dc.DrawEntity(*pText);
|
|
Add2DBuffer(pText);
|
|
|
|
//绘制坡度线
|
|
}
|
|
nIndex += 1;
|
|
}
|
|
else//不等,绘制上次
|
|
{
|
|
int nLast = nIndex - 1;
|
|
TextOnPoint& txtPtNext2 = arTxtGrLen.at(nLast);
|
|
sTextLast = txtPtNext2.pText->textStringConst();
|
|
nPos = sTextLast.Find(_T('/'));
|
|
if (nPos != -1)
|
|
{
|
|
CString sGrdN = sTextLast.Mid(0,nPos-1);
|
|
CString sLenN = sTextLast.Mid(nPos+1);
|
|
dMax = __max(dMax,_ttof(sLenN));
|
|
|
|
sText.Format(_T("%.3f%%/%.3f"),_ttof(sGrdN),dMax);
|
|
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(idStyle);
|
|
pText->setTextString(sText);//数据
|
|
pText->setHeight(dTxtH);
|
|
pText->setWidthFactor(0.5);
|
|
pText->setRotation(dAngle);
|
|
pText->setHorizontalMode(AcDb::kTextRight);
|
|
pText->setPosition(txtPtLast.ptPos);
|
|
pText->setAlignmentPoint(MidPoint(txtPtLast.ptPos,txtPtNext2.ptPos));
|
|
pText->setLayer(idLayer);
|
|
|
|
dc.DrawEntity(*pText);
|
|
Add2DBuffer(pText);
|
|
|
|
//绘制坡度线
|
|
}
|
|
|
|
txtPtLast = txtPtNext;
|
|
sTextLast = txtPtLast.pText->textStringConst();
|
|
int nPos = sTextLast.Find(_T('/'));
|
|
if (nPos != -1)
|
|
{
|
|
sGrdL = sTextLast.Mid(0,nPos-1);
|
|
sLenL = sTextLast.Mid(nPos+1);
|
|
|
|
dLen = _ttof(sLenL);
|
|
dMax = dLen;
|
|
}
|
|
nIndex += 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::DrawVerSectionTbl(AcGiDraw &dc,const AcGePoint2d& ptLast,double dHeight) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d pt1,pt2;
|
|
ads_point pt11,pt22,ptTmp;
|
|
ads_point ptTxt,ptL1,ptL2,pt3;
|
|
|
|
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtDirY = AcGeVector3d::kYAxis;
|
|
|
|
double dEnd = 0.0,dLen = 0.0;
|
|
AecDb3dRoadAxisLine* pRoadAxln = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadAxln != NULL)
|
|
{
|
|
pRoadAxln->getEndParam(dEnd);
|
|
pRoadAxln->getDistAtParam(dEnd,dLen);
|
|
}
|
|
|
|
AcGePoint3d ptVSta(ptLast.x,ptLast.y,0.0);
|
|
AcGePoint3d ptVEnd = ptVSta + dLen * vtDirX;
|
|
|
|
AcGePoint3d ptGe1(ptVSta.x,ptVSta.y,0.0);
|
|
AcGePoint3d ptGe2(ptVEnd.x,ptVEnd.y,0.0);
|
|
|
|
acdbWcs2Ucs(asDblArray(ptGe1),pt11,false);
|
|
acdbWcs2Ucs(asDblArray(ptGe2),pt22,false);
|
|
ptGe1.set(pt11[X],pt11[Y],pt11[Z]);
|
|
ptGe2.set(pt22[X],pt22[Y],pt22[Z]);
|
|
|
|
//选择文字
|
|
AcGePoint3d ptGeTxt[2];
|
|
ptGeTxt[0] = ptGe1 + vtDirY * dHeight;
|
|
ptGeTxt[1] = ptGe2 - vtDirY * dHeight;
|
|
|
|
//向下偏移 5 倍 dHeight
|
|
ptGe1 -= vtDirY * dHeight;
|
|
ptGe2 -= vtDirY * dHeight;
|
|
|
|
//绘制表格
|
|
//纵段计算土方
|
|
AcArray<ELongParam> arELongParams;
|
|
CalEarthWork(arELongParams);
|
|
|
|
if (arELongParams.isEmpty())
|
|
{
|
|
//acutPrintf(_T("\n没有设置道路中心线,计算土方失败!"));
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//是否绘制表格抬头
|
|
int nDrawHead = 1;
|
|
GetSpecialtyData()->GetAt(_T("DrawTblHead"),nDrawHead);
|
|
|
|
//提取自身计算数据
|
|
AcArray<ELongParam> arELongParamsThis;
|
|
for (int i = 0;i < arELongParams.length();i++)
|
|
{
|
|
ELongParam& lparm = arELongParams.at(i);
|
|
if (lparm.idOwner == objectId())
|
|
{
|
|
arELongParamsThis.append(lparm);
|
|
}
|
|
}
|
|
|
|
//获取绘制表格的文字高度 图层 样式
|
|
//字体大小取 2.5 的倍数
|
|
//获取一个桩号
|
|
static double dTxtH = 2.5;
|
|
static double dTblH = 2.5;
|
|
static double dTblW = 12.5;
|
|
static CString sStyle = _T("Standard");
|
|
static AcDbObjectId idStyle,idLayer;
|
|
|
|
if ( !idStyle.isValid() || idStyle.database() != acdbCurDwg() )
|
|
{
|
|
GetDefaultTextStyleInfo(ptGeTxt[0],ptGeTxt[1],idStyle,idLayer,sStyle,dTxtH,dTblH,dTblW);
|
|
}
|
|
|
|
double dXPos = 0.0,dTxtXPos = 0.0,dTxtLen = 0.0,dWScaleTmp = 0.0;
|
|
double dAngle = AcGeVector3d::kXAxis.angleTo(acdbCurDwg()->ucsxdir(),AcGeVector3d::kZAxis);
|
|
|
|
//文字中心位置
|
|
AcGePoint3d ptGeTxtMid = ptGe1;
|
|
ptGeTxtMid -= AcGeVector3d::kYAxis * 0.5 * dTblH;
|
|
ptGeTxtMid -= AcGeVector3d::kXAxis * 0.5 * dTblW;
|
|
|
|
AcGePoint3d ptGeHL[2];
|
|
AcGePoint3d ptGeVL[2];
|
|
|
|
//表格 抬头行线
|
|
ptGeHL[0] = ptGeTxtMid;
|
|
ptGeHL[0] += AcGeVector3d::kYAxis * 0.5 * dTblH;
|
|
ptGeHL[0] -= AcGeVector3d::kXAxis * 0.5 * dTblW;
|
|
ptGeHL[1] = ptGeHL[0] + AcGeVector3d::kXAxis * dTblW;
|
|
|
|
ptGeHL[0] -= AcGeVector3d::kXAxis * 1.5 * dTxtH;
|
|
ptGeHL[1] -= AcGeVector3d::kXAxis * 1.5 * dTxtH;
|
|
|
|
//向左偏移 1.5 倍txth,为了对齐
|
|
ptGeTxtMid -= AcGeVector3d::kXAxis * 1.5 * dTxtH;
|
|
ptGeTxtMid -= AcGeVector3d::kYAxis * 0.5 * dTxtH;
|
|
|
|
AcGePoint3d ptTxtAgn,ptPos;
|
|
AcGePoint3d ptRowL[2];
|
|
AcGePoint3d ptGeRV[2];
|
|
|
|
//绘制左边title
|
|
AcDbLine* pLine = NULL,*pLine0 = NULL,*pLine1 = NULL;
|
|
AcDbText* pText = NULL;
|
|
|
|
CString sTextVal,sStack;
|
|
CStringList lstStacks;
|
|
|
|
int nRows = sizeof(g_pszSHGlobalLable) / sizeof(LPCTSTR) - 1;
|
|
double dMaxX = 0.0;
|
|
|
|
static int nCrIdx = 0;
|
|
static int nColor[] = {kRed,kYellow,kGreen};
|
|
|
|
if (nCrIdx > 2) nCrIdx = 0;
|
|
int nOld = dc.GetColor();
|
|
dc.SetColor(nColor[nCrIdx]);
|
|
nCrIdx++;
|
|
|
|
//建立临时隐射
|
|
m_mapStake2UCSXPos.RemoveAll();
|
|
MakeStake2UCSXPos();
|
|
|
|
//上部网格开始线
|
|
AcGePoint3d ptNetCell[2];
|
|
AcArray<TextOnPoint> arTxtPts,arTxtGrLen;
|
|
|
|
for (int i = 0;i < nRows;i++)//抬头
|
|
{
|
|
acdbUcs2Wcs(asDblArray(ptGeHL[0]),ptL1,false);
|
|
acdbUcs2Wcs(asDblArray(ptGeHL[1]),ptL2,false);
|
|
|
|
if (nDrawHead > 0)
|
|
{
|
|
pLine = new AcDbLine(asPnt3d(ptL1),asPnt3d(ptL2));
|
|
pLine->setLayer(idLayer);
|
|
dc.DrawEntity(*pLine);
|
|
m_ar2DPrefbrtBufPtrs.append(pLine);
|
|
if (pLine0 == NULL) pLine0 = pLine;
|
|
}
|
|
|
|
ptTxtAgn = ptGeTxtMid;
|
|
acdbUcs2Wcs(asDblArray(ptTxtAgn),ptTxt,false);
|
|
|
|
if (nDrawHead > 0)
|
|
{
|
|
//绘制抬头
|
|
pText = new AcDbText;
|
|
pText->setTextStyle(idStyle);
|
|
pText->setTextString(g_pszSHGlobalLable[i]);//设计坡度与距离 ...
|
|
pText->setHeight(dTxtH);
|
|
pText->setWidthFactor(1.0);
|
|
pText->setRotation(dAngle);
|
|
pText->setHorizontalMode(AcDb::kTextMid);
|
|
pText->setVerticalMode(AcDb::kTextVertMid);
|
|
|
|
AcDbExtents extT;
|
|
CKTCadUtility::GetTextBox(extT, g_pszSHGlobalLable[i], sStyle, dTxtH);
|
|
ptPos = ptGeTxtMid;
|
|
ptPos -= AcGeVector3d::kXAxis * 0.5 * (extT.maxPoint().x - extT.minPoint().x);
|
|
|
|
acdbUcs2Wcs(asDblArray(ptPos),pt3,false);
|
|
pText->setPosition(asPnt3d(pt3));
|
|
|
|
pText->setAlignmentPoint(asPnt3d(ptTxt));
|
|
pText->setLayer(idLayer);
|
|
|
|
dc.DrawEntity(*pText);
|
|
m_ar2DPrefbrtBufPtrs.append(pText);
|
|
}
|
|
|
|
dMaxX = ptGeHL[0].x;
|
|
|
|
//绘制一行数据
|
|
//{_T("设计坡度与距离"),_T("设计地面高程"),_T("现状地面高程"),_T("管廊外顶高程"),_T("管廊内底高程"),_T("管廊覆土"),_T("盾构土方"),_T("道路桩号"),_T("管廊里程"),_T("功能布置"),_T("覆土高度"),NULL};
|
|
for (int ii = 0;ii < arELongParamsThis.length();ii++)
|
|
{
|
|
const ELongParam& lParam = arELongParamsThis.at(ii);
|
|
|
|
/*
|
|
typedef struct ELongParam
|
|
{
|
|
TCHAR szNodeSpec[MAX_PATH];//功能布置名称
|
|
TCHAR szStake[17]; //桩号
|
|
TCHAR szIDlock[65]; //内部id
|
|
double dEVolCover; //管廊覆土
|
|
double dDigVol; //挖土,如果是从地面开挖
|
|
double dShEwVol; //管廊体积,指盾构体积
|
|
double dRoofEl; //管廊外顶标高
|
|
double dFloorEl; //管廊内底标高
|
|
double dRoadEl; //现状地面高程
|
|
double dRoadDesEl; //设计地面高程
|
|
double dGradient; //坡度 n% +上升, -下降 两点的高程差与其水平距离的百分比
|
|
double dDistLen; //本段长度距离位置(相对)
|
|
double dDistStakeLen; //桩号对应的全局长度
|
|
AcDbObjectId idOwner; //临时使用
|
|
double dY; //临时使用
|
|
}ELONGPARAM;
|
|
*/
|
|
|
|
//根据桩号,找 X 定位
|
|
sStack = lParam.szStake;
|
|
if ( !FindStakeUCSXPos(lParam.szStake,dXPos,0) )
|
|
{
|
|
if ( !FindStakeUCSXPos(lParam.szIDlock,dXPos,1) )
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
sStack.TrimRight();
|
|
sStack.TrimLeft();
|
|
|
|
if (lstStacks.Find(lParam.szStake) != NULL )//没有找到
|
|
{
|
|
sTextVal = _T("");
|
|
}
|
|
else
|
|
{
|
|
lstStacks.AddTail(lParam.szStake);
|
|
}
|
|
|
|
sTextVal = _T("");
|
|
switch(i)
|
|
{
|
|
case 0://设计坡度与距离
|
|
{
|
|
sTextVal.Format(_T("%.2f%%/%.3f"),lParam.dGradient,lParam.dDistLen);
|
|
break;
|
|
}
|
|
case 1://设计地面高程
|
|
{
|
|
sTextVal.Format(_T("%.3f"),lParam.dRoadDesEl);
|
|
break;
|
|
}
|
|
case 2://现状地面高程
|
|
{
|
|
sTextVal.Format(_T("%.3f"),lParam.dRoadEl);
|
|
break;
|
|
}
|
|
case 3://管廊外顶高程
|
|
{
|
|
sTextVal.Format(_T("%.3f"),lParam.dRoofEl);
|
|
break;
|
|
}
|
|
case 4:
|
|
{
|
|
sTextVal.Format(_T("%.3f"),lParam.dFloorEl);
|
|
break;
|
|
}
|
|
case 5://管廊覆土
|
|
{
|
|
sTextVal.Format(_T("%.3f"),lParam.dEVolCover);
|
|
break;
|
|
}
|
|
case 6://盾构土方
|
|
{
|
|
sTextVal.Format(_T("%.3f"),lParam.dShEwVol);
|
|
break;
|
|
}
|
|
case 7://道路桩号
|
|
{
|
|
sTextVal = lParam.szStake;
|
|
break;
|
|
}
|
|
case 8:
|
|
{
|
|
//管廊里程
|
|
sTextVal.Format(_T("%.3f"),lParam.dDistStakeLen);
|
|
break;
|
|
}
|
|
case 9://功能布置
|
|
{
|
|
sTextVal = lParam.szNodeSpec;
|
|
sTextVal.TrimLeft(_T('|'));
|
|
sTextVal.Replace(_T('+'),_T(';'));
|
|
break;
|
|
}
|
|
case 10:// 覆土高度
|
|
{
|
|
sTextVal.Format(_T("%.3f"), lParam.dRoadDesEl - lParam.dRoofEl);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (!sTextVal.IsEmpty())
|
|
{
|
|
//文字底线
|
|
//绘制列计算数据
|
|
ptPos = ptGeHL[0];
|
|
ptPos -= AcGeVector3d::kYAxis * dTblH;
|
|
ptPos.x = dXPos;
|
|
|
|
if (dMaxX - dXPos < 1.e-10)
|
|
dMaxX = dXPos;
|
|
|
|
ptTxtAgn = ptPos;
|
|
acdbUcs2Wcs(asDblArray(ptTxtAgn),ptTxt,false);
|
|
|
|
//if (!sStack.IsEmpty())//可以绘制空桩号
|
|
{
|
|
pText = new AcDbText;
|
|
pText->setTextStyle(idStyle);
|
|
pText->setTextString(sTextVal);//数据
|
|
pText->setHeight(dTxtH);
|
|
|
|
if (i == 9)
|
|
{
|
|
pText->setWidthFactor(0.85);//功能布置
|
|
}
|
|
else
|
|
{
|
|
pText->setWidthFactor(0.5);
|
|
}
|
|
|
|
pText->setRotation(dAngle + PI / 2.0);
|
|
pText->setHorizontalMode(AcDb::kTextLeft);
|
|
pText->setVerticalMode(AcDb::kTextVertMid);
|
|
|
|
//文字距离底线 1/4 文字高间隙
|
|
ptPos += AcGeVector3d::kYAxis * 0.125 * dTxtH;//1 / 4
|
|
acdbUcs2Wcs(asDblArray(ptPos),pt3,false);
|
|
|
|
AcGePoint3d ptGeTxt = asPnt3d(pt3);
|
|
bool bHasOverLap = AvoidTextOverLap(arTxtPts,ptGeTxt,dTxtH,sTextVal,i);
|
|
//记住此位置,防止重叠
|
|
TextOnPoint txtPt;
|
|
txtPt.ptPos = asPnt3d(pt3);
|
|
txtPt.pText = pText;
|
|
arTxtPts.append(txtPt);
|
|
|
|
pText->setPosition(ptGeTxt);
|
|
dTxtXPos = pt3[X];
|
|
|
|
pText->setAlignmentPoint(ptGeTxt);
|
|
pText->setLayer(idLayer);
|
|
|
|
if (i == 8)// 功能布置
|
|
{
|
|
AcDbExtents ext2;
|
|
CKTCadUtility::GetTextBox(ext2,sTextVal,sStyle,pText->height(),pText->widthFactor());
|
|
|
|
dTxtLen = ext2.maxPoint().x - ext2.minPoint().x;
|
|
dWScaleTmp = dTxtLen / dTblH;
|
|
if (dWScaleTmp > 0.999)
|
|
{
|
|
pText->setWidthFactor(0.75 * 1.0 / dWScaleTmp);
|
|
}
|
|
}
|
|
|
|
acdbWcs2Ucs(pt3,ptTmp,false);
|
|
if (dMaxX < ptTmp[X])
|
|
dMaxX = ptTmp[X];
|
|
|
|
if (bHasOverLap)
|
|
{
|
|
if (i == 7 || i== 5)//管廊覆土,桩号
|
|
{
|
|
DELETE_PTR(pText);
|
|
pText = NULL;
|
|
arTxtPts.last().pText = NULL;
|
|
}
|
|
else
|
|
{
|
|
if (i > 0)
|
|
{
|
|
dc.DrawEntity(*pText);
|
|
m_ar2DPrefbrtBufPtrs.append(pText);
|
|
}
|
|
else
|
|
{
|
|
arTxtGrLen.append(txtPt);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (i > 0)
|
|
{
|
|
dc.DrawEntity(*pText);
|
|
m_ar2DPrefbrtBufPtrs.append(pText);
|
|
}
|
|
else
|
|
{
|
|
arTxtGrLen.append(txtPt);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}//一行数据循环结束
|
|
|
|
//绘制表格横线
|
|
ptPos = ptGeHL[0];
|
|
ptPos.x = dMaxX;
|
|
|
|
acdbUcs2Wcs(asDblArray(ptPos),ptL1,false);
|
|
acdbUcs2Wcs(asDblArray(ptGeHL[1]),ptL2,false);
|
|
|
|
pLine = new AcDbLine(asPnt3d(ptL1),asPnt3d(ptL2));
|
|
pLine->setLayer(idLayer);
|
|
dc.DrawEntity(*pLine);
|
|
m_ar2DPrefbrtBufPtrs.append(pLine);
|
|
|
|
if (i == 0)
|
|
{
|
|
ptNetCell[0] = asPnt3d(ptL1);
|
|
ptNetCell[1] = asPnt3d(ptL2);
|
|
}
|
|
|
|
//文字下移动一格
|
|
ptGeTxtMid -= AcGeVector3d::kYAxis * dTblH;
|
|
ptGeHL[0] -= AcGeVector3d::kYAxis * dTblH;
|
|
ptGeHL[1] -= AcGeVector3d::kYAxis * dTblH;
|
|
|
|
//如果绘制到 功能布置
|
|
if (i == nRows - 1) //补上最后一行
|
|
{
|
|
ptPos = ptGeHL[0];
|
|
ptPos.x = dMaxX;
|
|
|
|
acdbUcs2Wcs(asDblArray(ptPos),ptL1,false);
|
|
acdbUcs2Wcs(asDblArray(ptGeHL[1]),ptL2,false);
|
|
|
|
pLine = new AcDbLine(asPnt3d(ptL1),asPnt3d(ptL2));
|
|
pLine->setLayer(idLayer);
|
|
dc.DrawEntity(*pLine);
|
|
m_ar2DPrefbrtBufPtrs.append(pLine);
|
|
}
|
|
}
|
|
|
|
//合并坡度和距离,土方,并水平重新绘制
|
|
MerageGradientAndDist(arTxtGrLen,idStyle,idLayer,dTxtH,dAngle,dc);
|
|
for (int iii = 0;iii < arTxtGrLen.length();iii++)
|
|
{
|
|
AcDbText* pText = arTxtGrLen.at(iii).pText;
|
|
if (pText != NULL)
|
|
{
|
|
pText->erase();
|
|
DELETE_PTR(pText);
|
|
}
|
|
}
|
|
|
|
if (nDrawHead > 0)//首页表格,绘制标题上下线
|
|
{
|
|
acdbUcs2Wcs(asDblArray(ptGeHL[0]),ptL1,false);
|
|
acdbUcs2Wcs(asDblArray(ptGeHL[1]),ptL2,false);
|
|
pLine = new AcDbLine(asPnt3d(ptL1),asPnt3d(ptL2));
|
|
if (pLine1 == NULL)
|
|
pLine1 = pLine;
|
|
pLine->setLayer(idLayer);
|
|
dc.DrawEntity(*pLine);
|
|
m_ar2DPrefbrtBufPtrs.append(pLine);
|
|
|
|
//标题上线
|
|
pLine = new AcDbLine(pLine0->startPoint(),pLine1->startPoint());
|
|
pLine->setLayer(idLayer);
|
|
dc.DrawEntity(*pLine);
|
|
m_ar2DPrefbrtBufPtrs.append(pLine);
|
|
|
|
//标题下线
|
|
pLine = new AcDbLine(pLine0->endPoint(),pLine1->endPoint());
|
|
pLine->setLayer(idLayer);
|
|
dc.DrawEntity(*pLine);
|
|
m_ar2DPrefbrtBufPtrs.append(pLine);
|
|
}
|
|
dc.SetColor(nOld);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CalEarthWork(AcArray<ELongParam>& arELongParams) const
|
|
{
|
|
//计算土方
|
|
assertReadEnabled();
|
|
|
|
if (g_arSHELongParams.isEmpty())
|
|
{
|
|
//盾构只有一整段!!!!!
|
|
CalEarthWork();
|
|
}
|
|
|
|
arELongParams.removeAll();
|
|
arELongParams.append(g_arSHELongParams);
|
|
|
|
return arELongParams.length();
|
|
}
|
|
|
|
void AecDbShEarthWorm::SetRoadCenline(const AcGePoint3dArray& arPts)
|
|
{
|
|
assertWriteEnabled();
|
|
if (arPts.length() > 0)
|
|
{
|
|
m_arRoadCenPts.removeAll();
|
|
m_arRoadCenPts.append(arPts);
|
|
|
|
if ( m_arOldRoadCenPtrs.isEmpty() )
|
|
m_arOldRoadCenPtrs.append(arPts);
|
|
}
|
|
}
|
|
|
|
int AecDbShEarthWorm::GetRoadCenline(AcGePoint3dArray& arPts) const
|
|
{
|
|
assertReadEnabled();
|
|
if (m_arRoadCenPts.length() > 0)
|
|
{
|
|
arPts.append(m_arRoadCenPts);
|
|
}
|
|
return arPts.length();
|
|
}
|
|
|
|
extern AcDb3dPolyline* Format3dPolyline(const AcGePoint3dArray& arPts);
|
|
extern AcDbPolyline* FormatPolyline(const AcGePoint3dArray& arPts);
|
|
AcDbCurve* AecDbShEarthWorm::GetRoadCenline(bool b3d) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_arRoadCenPts.length() == 0)
|
|
return NULL;
|
|
|
|
if (b3d)
|
|
{
|
|
return Format3dPolyline(m_arRoadCenPts);
|
|
}
|
|
return FormatPolyline(m_arRoadCenPts);
|
|
}
|
|
|
|
void AecDbShEarthWorm::SetOldRoadCenline(const AcGePoint3dArray& arPts)
|
|
{
|
|
assertWriteEnabled();
|
|
if (arPts.length() > 0)
|
|
{
|
|
m_arOldRoadCenPtrs.removeAll();
|
|
m_arOldRoadCenPtrs.append(arPts);
|
|
}
|
|
}
|
|
|
|
int AecDbShEarthWorm::GetOldRoadCenline(AcGePoint3dArray& arPts) const
|
|
{
|
|
assertReadEnabled();
|
|
if (m_arRoadCenPts.length() > 0)
|
|
{
|
|
arPts.append(m_arOldRoadCenPtrs);
|
|
}
|
|
return arPts.length();
|
|
}
|
|
|
|
AcDbCurve* AecDbShEarthWorm::GetOldRoadCenline(bool b3d) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_arOldRoadCenPtrs.length() == 0)
|
|
return NULL;
|
|
|
|
if (b3d)
|
|
{
|
|
return Format3dPolyline(m_arOldRoadCenPtrs);
|
|
}
|
|
return FormatPolyline(m_arOldRoadCenPtrs);
|
|
}
|
|
|
|
AcDbPolyline* AecDbShEarthWorm::FormatVerSectionPolyline(const AcGePoint3dArray& arPoints,const AcGePoint3d& ptVSta) const
|
|
{
|
|
if (arPoints.isEmpty())
|
|
return NULL;
|
|
|
|
AcGeVector3d vtDirX = acdbCurDwg()->ucsxdir();//end-start
|
|
vtDirX.z = 0.0;
|
|
vtDirX.normalize();
|
|
|
|
AcGeVector3d vtDirY = vtDirX;
|
|
vtDirY.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
AcDbVoidPtrArray arCurPtrs,arpResult;
|
|
|
|
AcDbLine* pLn1 = NULL;
|
|
AcDbCurve* pCurve = NULL;
|
|
AcGePoint3d ptGe[3],ptTemp;
|
|
AcGeVector3d vtNorm;
|
|
double dLen = 0.0;
|
|
|
|
AcGePoint3d ptTail(ptVSta.x,ptVSta.y,0.0);
|
|
AcGePoint3dArray arTail,arVerts;
|
|
|
|
arVerts.append(arPoints.first());
|
|
|
|
for (int i = 0;i < arPoints.length() - 1;i++)
|
|
{
|
|
ptGe[0] = arPoints.at(i);
|
|
ptGe[1] = arPoints.at(i+1);
|
|
|
|
//追加首尾连接点,用户确定圆弧的方向
|
|
AppendTempVerts(arVerts,ptGe[0],ptGe[1]);
|
|
|
|
dLen = ptGe[0].distanceTo(ptGe[1]);
|
|
if (arTail.isEmpty())
|
|
{
|
|
ptTemp = ptTail;
|
|
ptTemp += dLen * vtDirX;
|
|
ptTemp += (ptGe[1].z - ptGe[0].z) * vtDirY;
|
|
|
|
arTail.append(ptTemp);
|
|
|
|
pLn1 = new AcDbLine(ptTail,ptTemp);
|
|
pLn1->setNormal(AcGeVector3d::kZAxis);
|
|
arCurPtrs.append(pLn1);
|
|
}
|
|
else
|
|
{
|
|
ptTail = arTail.last();
|
|
ptTemp = ptTail;
|
|
ptTemp += dLen * vtDirX;
|
|
ptTemp += (ptGe[1].z - ptGe[0].z) * vtDirY;
|
|
|
|
arTail.append(ptTemp);
|
|
|
|
pLn1 = new AcDbLine(ptTail,ptTemp);
|
|
pLn1->setNormal(AcGeVector3d::kZAxis);
|
|
arCurPtrs.append(pLn1);
|
|
}
|
|
}
|
|
|
|
pCurve = KTCADUtilityEx::ConvertBoundCurve(arCurPtrs, arpResult);
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(pCurve);
|
|
return pPl;
|
|
|
|
//原始位置复现高程线的纵断显示线
|
|
/*------------------------------------------------------------------
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
AcGePoint3d ptHead = arPoints.first();
|
|
pPl->addVertexAt(0,ptHead.convert2d(AcGePlane::kXYPlane));
|
|
|
|
ads_point ptLast;
|
|
acdbWcs2Ucs(asDblArray(ptHead),ptLast,false);
|
|
|
|
ads_point ptUcs,ptWcs;
|
|
AcGePoint3d ptGe;
|
|
double dDist = 0.0;
|
|
|
|
for (int i = 1;i < arPoints.length();i++)
|
|
{
|
|
ptGe = arPoints.at(i);
|
|
|
|
dDist = ptGe.distanceTo(arPoints.at(i - 1));
|
|
|
|
//UCS 下 Y 标高变化
|
|
ptUcs[X] = ptLast[X] + dDist;
|
|
ptUcs[Y] = ptLast[Y] + ptGe.z - arPoints.at(i - 1).z;
|
|
ptUcs[Z] = 0.0;
|
|
|
|
acdbUcs2Wcs(ptUcs,ptWcs,false);
|
|
pPl->addVertexAt(i,asPnt3d(ptWcs).convert2d(AcGePlane::kXYPlane));
|
|
|
|
ads_point_set(ptUcs,ptLast);
|
|
}
|
|
return pPl;
|
|
---------------------------------------------------------------------------*/
|
|
}
|
|
|
|
AcDbPolyline* AecDbShEarthWorm::GetRoadCenlineVerSection(const AcGePoint3d& ptVSta) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_arRoadCenPts.length() == 0)
|
|
return NULL;
|
|
|
|
AcDbPolyline* pPl = FormatVerSectionPolyline(m_arRoadCenPts,ptVSta);
|
|
return pPl;
|
|
}
|
|
|
|
AcDbPolyline* AecDbShEarthWorm::GetOldRoadCenlineVerSection(const AcGePoint3d& ptVSta) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_arOldRoadCenPtrs.length() == 0)
|
|
return NULL;
|
|
|
|
AcDbPolyline* pPl = FormatVerSectionPolyline(m_arOldRoadCenPtrs,ptVSta);
|
|
return pPl;
|
|
}
|
|
|
|
void AecDbShEarthWorm::SetCalEarthWorkResult(AcArray<ELongParam>& arELongParams) const
|
|
{
|
|
assertReadEnabled();
|
|
g_arSHELongParams.removeAll();
|
|
g_arSHELongParams.append(arELongParams);
|
|
}
|
|
|
|
bool AecDbShEarthWorm::GetRoofAndBoomElAtPoint(const AcGePoint3d& ptSta,AcGePoint2d& ptEl) const
|
|
{
|
|
assertReadEnabled();
|
|
AecDb3dRoadAxisLine* pRoadAxln = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadAxln == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
AcGePoint3d ptCenInRgn;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN,ptCenInRgn);
|
|
|
|
AcGePoint3d ptOn = ptSta;
|
|
pRoadAxln->getClosestPointTo(ptSta,ptOn);
|
|
|
|
AcGePoint3d pointOnCurve;
|
|
int nIndex = pRoadAxln->getClosestPointToIndex(ptOn,pointOnCurve);
|
|
if (nIndex != -1)
|
|
{
|
|
AcDbCurve* pCurve = pRoadAxln->GetCurveSeg(nIndex);
|
|
|
|
AcGeVector3d vtNormal(1,0,0);
|
|
pCurve->getFirstDeriv(pointOnCurve,vtNormal);
|
|
|
|
AcDbRegion *pCloneRegion = (AcDbRegion*)m_pRegion->clone();
|
|
transfromRegion(pCloneRegion, ptCenInRgn, vtNormal, pointOnCurve);
|
|
|
|
AcDbExtents ext;
|
|
pCloneRegion->getGeomExtents(ext);
|
|
|
|
ptEl.x = ext.maxPoint().z;
|
|
ptEl.y = ext.minPoint().z;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void AecDbShEarthWorm::SetAddtionScr(LPCTSTR pszScr)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_mapSpecXData.SetAt(KEY_ADDTIONSCR,pszScr);
|
|
}
|
|
|
|
void AecDbShEarthWorm::GetAddtionScr(CString& sScr) const
|
|
{
|
|
assertReadEnabled();
|
|
m_mapSpecXData.GetAt(KEY_ADDTIONSCR,sScr);
|
|
}
|
|
|
|
STSection* AecDbShEarthWorm::GetSTSection() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
STSection* pSection = new STSection;
|
|
pSection->pReg = (AcDbRegion*)m_pRegion->clone();
|
|
GetAddtionScr(pSection->sAddtionScr);
|
|
|
|
AcGePoint3d ptCen;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN,ptCen);
|
|
pSection->pt = ptCen;
|
|
|
|
m_mapSpecXData.GetAt(KEY_THICKT1,pSection->dThick[0]);
|
|
pSection->dThick[0] *= 1000.0;//毫米
|
|
m_mapSpecXData.GetAt(KEY_THICKT2,pSection->dThick[1]);
|
|
pSection->dThick[1] *= 1000.0;//毫米
|
|
m_mapSpecXData.GetAt(KEY_THICKT4,pSection->dThick[2]);
|
|
pSection->dThick[2] *= 1000.0;//毫米
|
|
m_mapSpecXData.GetAt(KEY_THICKT5,pSection->dThick[3]);
|
|
pSection->dThick[3] *= 1000.0;//毫米
|
|
|
|
return pSection;
|
|
}
|
|
|
|
void AecDbShEarthWorm::ShowAddtion(int nShow)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_mapSpecXData.SetAt(KEY_ADDTIONSHOW,nShow);
|
|
}
|
|
|
|
static bool SortRegParam(const RegionParam& rp1,const RegionParam& rp2)
|
|
{
|
|
if (rp1.dParam - rp2.dParam < 1.e-6)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
void AecDbShEarthWorm::SortRegionRooms( AcDbCircle* pCir,AcDbVoidPtrArray& arRegionRooms)
|
|
{
|
|
if (pCir == NULL)
|
|
return;
|
|
|
|
//延着整体圆排序
|
|
double perimeter;
|
|
double area;
|
|
AcGePoint2d centroid;
|
|
double momInertia[2];
|
|
double prodInertia;
|
|
double prinMoments[2];
|
|
AcGeVector2d prinAxes[2];
|
|
double radiiGyration[2];
|
|
AcGePoint2d extentsLow;
|
|
AcGePoint2d extentsHigh;
|
|
|
|
RegionParam regPar;
|
|
std::vector<RegionParam> vtRegPars;
|
|
|
|
AcGePoint3d ptCen,ptOn;
|
|
AcDbRegion* pRegion = NULL;
|
|
for (int i = 0;i < arRegionRooms.length();i++)
|
|
{
|
|
pRegion = (AcDbRegion*)arRegionRooms.at(i);
|
|
pRegion->getAreaProp(AcGePoint3d::kOrigin,AcGeVector3d::kXAxis,AcGeVector3d::kYAxis,
|
|
perimeter,
|
|
area,
|
|
centroid,
|
|
momInertia,
|
|
prodInertia,
|
|
prinMoments,
|
|
prinAxes,
|
|
radiiGyration,
|
|
extentsLow,
|
|
extentsHigh);
|
|
|
|
ptCen.set(centroid.x,centroid.y,0.0);
|
|
pCir->getClosestPointTo(ptCen,ptOn);
|
|
|
|
regPar.pRegion = pRegion;
|
|
pCir->getParamAtPoint(ptOn,regPar.dParam);
|
|
vtRegPars.push_back(regPar);
|
|
}
|
|
|
|
std::sort(vtRegPars.begin(),vtRegPars.end(),SortRegParam);
|
|
|
|
arRegionRooms.removeAll();
|
|
for (int ii = 0;ii < vtRegPars.size();ii++)
|
|
{
|
|
arRegionRooms.append(vtRegPars.at(ii).pRegion);
|
|
}
|
|
}
|
|
|
|
void AecDbShEarthWorm::ExtractRegionRooms(AcDbVoidPtrArray& arRegionRooms,const AcDbRegion* pRegSection)
|
|
{
|
|
if (pRegSection != NULL)
|
|
{
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
pRegSection->explode(arCurPtrs);
|
|
|
|
AcDbRegion* pRegMax = NULL;
|
|
AcDbVoidPtrArray arSubEntPtrs;
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arCurPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arCurPtrs.at(i);
|
|
if (pEnt->isKindOf(AcDbRegion::desc()))
|
|
{
|
|
pEnt->explode(arSubEntPtrs);
|
|
}
|
|
else
|
|
{
|
|
arSubEntPtrs.append(pEnt);
|
|
}
|
|
}
|
|
|
|
AcDbVoidPtrArray arRegPtrs;
|
|
AcDbRegion::createFromCurves(arSubEntPtrs,arRegPtrs);
|
|
FreeBuffer(0,arSubEntPtrs);
|
|
|
|
//去除最大的面域,和去掉最小面积小于0.5x0.5米
|
|
int nPos = -1;
|
|
double dAreaMax = -1.0,dArea = 0.0;
|
|
AcDbRegion* pRegionSub = NULL;
|
|
for (int i = 0;i < arRegPtrs.length();i++)
|
|
{
|
|
pRegionSub = (AcDbRegion*)arRegPtrs.at(i);
|
|
pRegionSub->getArea(dArea);
|
|
|
|
if (dAreaMax - dArea < 1.e-2)
|
|
{
|
|
dAreaMax = dArea;
|
|
pRegMax = pRegionSub;
|
|
nPos = i;
|
|
}
|
|
|
|
if (dArea - 0.25 < 1.e-10)
|
|
{
|
|
arRegPtrs.removeAt(i);
|
|
i--;
|
|
}
|
|
}
|
|
if (nPos != -1)
|
|
{
|
|
arRegPtrs.removeAt(nPos);
|
|
}
|
|
|
|
FreeBuffer(0,arRegionRooms);
|
|
arRegionRooms.append(arRegPtrs);
|
|
|
|
//延着整体圆排序
|
|
double perimeter;
|
|
double area;
|
|
AcGePoint2d centroid;
|
|
double momInertia[2];
|
|
double prodInertia;
|
|
double prinMoments[2];
|
|
AcGeVector2d prinAxes[2];
|
|
double radiiGyration[2];
|
|
AcGePoint2d extentsLow;
|
|
AcGePoint2d extentsHigh;
|
|
|
|
pRegSection->getAreaProp(AcGePoint3d::kOrigin,AcGeVector3d::kXAxis,AcGeVector3d::kYAxis,
|
|
perimeter,
|
|
area,
|
|
centroid,
|
|
momInertia,
|
|
prodInertia,
|
|
prinMoments,
|
|
prinAxes,
|
|
radiiGyration,
|
|
extentsLow,
|
|
extentsHigh);
|
|
|
|
double dD1 = extentsHigh.x - extentsLow.x;
|
|
double dD2 = extentsHigh.y - extentsLow.y;
|
|
double dD = __max(dD1,dD2);
|
|
|
|
AcDbCircle cir;
|
|
cir.setCenter(AcGePoint3d(centroid.x,centroid.y,0.0));
|
|
cir.setRadius(0.5 * dD);
|
|
cir.setNormal(AcGeVector3d::kZAxis);
|
|
|
|
SortRegionRooms(&cir,arRegionRooms);
|
|
}
|
|
}
|
|
|
|
int AecDbShEarthWorm::OffsetMapToSplitRoom(const CStringArray& arInf,ERoom& room,int nIndex) const
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::GetRoom(int nIndex,ERoom& room) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_arRegionRooms.isEmpty())
|
|
{
|
|
ExtractRegionRooms(m_arRegionRooms,m_pRegion);
|
|
}
|
|
|
|
if (nIndex > -1 && nIndex < m_arRegionRooms.length())
|
|
{
|
|
AcDbRegion* pRegion = (AcDbRegion*)m_arRegionRooms.at(nIndex);
|
|
if (pRegion != NULL)
|
|
{
|
|
//折算成外接矩形
|
|
AcDbExtents ext;
|
|
pRegion->getGeomExtents(ext);
|
|
|
|
double dW = ext.maxPoint().x - ext.minPoint().x;
|
|
double dH = ext.maxPoint().y - ext.minPoint().y;
|
|
|
|
room.ptGe[0] = ext.minPoint();
|
|
room.ptGe[0].z = 0.0;
|
|
|
|
room.ptGe[2] = ext.maxPoint();
|
|
room.ptGe[2].z = 0.0;
|
|
|
|
room.ptGe[1] = room.ptGe[0];
|
|
room.ptGe[1].x += dW;
|
|
|
|
room.ptGe[3] = room.ptGe[0];
|
|
room.ptGe[3].y += dH;
|
|
|
|
return TRUE;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
int AecDbShEarthWorm::GetRoomCount() const
|
|
{
|
|
assertReadEnabled();
|
|
if (m_arRegionRooms.isEmpty())
|
|
{
|
|
ExtractRegionRooms(m_arRegionRooms,m_pRegion);
|
|
}
|
|
return m_arRegionRooms.length();
|
|
}
|
|
|
|
//挂壁方法
|
|
int AecDbShEarthWorm::AlongRoomSide(AcGePoint3d& pt,int nRoomIndex,const AcGeVector3d& vtX) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_arRegionRooms.isEmpty())
|
|
{
|
|
ExtractRegionRooms(m_arRegionRooms,m_pRegion);
|
|
}
|
|
|
|
if (nRoomIndex > -1 && nRoomIndex < m_arRegionRooms.length())
|
|
{
|
|
AcDbRegion* pRegion = (AcDbRegion*)m_arRegionRooms.at(nRoomIndex);
|
|
if (pRegion != NULL)
|
|
{
|
|
AcDbVoidPtrArray arCurPtrs,arResult;
|
|
pRegion->explode(arCurPtrs);
|
|
|
|
|
|
AcDbPolyline* pPl = (AcDbPolyline*)KTCADUtilityEx::ConvertBoundCurve(arCurPtrs,arResult);
|
|
if (pPl != NULL)
|
|
{
|
|
//求交,得到距离pt最近的点
|
|
AcDbXline xln;
|
|
xln.setBasePoint(pt);
|
|
xln.setUnitDir(vtX);
|
|
|
|
AcGePoint3dArray arPt;
|
|
xln.intersectWith(pPl,AcDb::kOnBothOperands,arPt);
|
|
|
|
AcGePoint3d ptOn,ptOn2;
|
|
double dDist = -1.0,dMin = -1.0;
|
|
for (int i = 0;i < arPt.length();i++)
|
|
{
|
|
dDist = arPt.at(i).distanceTo(pt);
|
|
if (dMin < -1.e-10)
|
|
{
|
|
dMin = dDist;
|
|
ptOn = arPt.at(i);
|
|
}
|
|
else
|
|
{
|
|
if (dDist - dMin < 1.e-10 )
|
|
{
|
|
dMin = dDist;
|
|
ptOn = arPt.at(i);
|
|
}
|
|
}
|
|
}
|
|
|
|
/*AcGeVector3d vtDir = vtX;
|
|
vtDir.negate();
|
|
|
|
Acad::ErrorStatus es;
|
|
es = pPl->getClosestPointTo(pt,ptOn);
|
|
es = pPl->getClosestPointTo(pt,vtDir,ptOn2);
|
|
|
|
if (vtDir.isParallelTo(AcGeVector3d::kXAxis))
|
|
{
|
|
ptOn.y = ptOn2.y;//高度一致
|
|
}
|
|
else if (vtDir.isParallelTo(AcGeVector3d::kYAxis))
|
|
{
|
|
ptOn.x = ptOn2.x;//水平一致
|
|
}*/
|
|
|
|
pt = ptOn;
|
|
|
|
delete pPl;
|
|
//AddToModelSpace(pPl);
|
|
|
|
return TRUE;
|
|
}
|
|
FreeBuffer(0,arCurPtrs);
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
void AecDbShEarthWorm::GetSectionRoomsTo(AcGeLineSeg3d& ln, AcArray<ERoom>& arRooms, AcGePoint2d& ptThick) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
ERoom eRoom;
|
|
int nRoomCount = GetRoomCount();
|
|
for (int i = 0;i < nRoomCount;i++)
|
|
{
|
|
GetRoom(i,eRoom);
|
|
arRooms.append(eRoom);
|
|
}
|
|
|
|
AcGePoint2d ptODt;
|
|
GetODAndThick(ptODt);
|
|
ptThick.set(ptODt.y,ptODt.y);
|
|
|
|
AecDbEarthWorm::TransformRegionPerpToLine(arRooms,ln);
|
|
}
|
|
|
|
AcDbCurve* AecDbShEarthWorm::GetRoomRegion(int nRoomIndex) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_arRegionRooms.isEmpty())
|
|
{
|
|
ExtractRegionRooms(m_arRegionRooms,m_pRegion);
|
|
}
|
|
|
|
if (nRoomIndex > -1 && nRoomIndex < m_arRegionRooms.length())
|
|
{
|
|
AcDbRegion* pRegion = (AcDbRegion*)m_arRegionRooms.at(nRoomIndex);
|
|
if (pRegion != NULL)
|
|
{
|
|
AcDbVoidPtrArray arCurPtrs,arResult;
|
|
pRegion->explode(arCurPtrs);
|
|
|
|
AcDbCurve* pPl = KTCADUtilityEx::ConvertBoundCurve(arCurPtrs,arResult);
|
|
if (pPl != NULL)
|
|
{
|
|
return pPl;
|
|
}
|
|
FreeBuffer(0,arCurPtrs);
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::GetAddtionSection(AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
CString sScr;
|
|
if (m_mapSpecXData.GetAt(KEY_ADDTIONSCR,sScr) )
|
|
{
|
|
//解析附属物脚本
|
|
int nPos = sScr.Find(_T("EXT:"));
|
|
if (nPos != -1)
|
|
{
|
|
//EXT:
|
|
if (nPos + 4 < sScr.GetLength() )
|
|
{
|
|
CString sExt = sScr.Mid(nPos + 4);
|
|
//<><><><><><>.....
|
|
CString sScript;
|
|
|
|
int nSta = 0,nPos2 = 0;
|
|
nPos = sExt.Find(_T('<'),nSta);
|
|
while(nPos != -1)
|
|
{
|
|
nPos2 = sExt.Find(_T('>'),nPos + 1);
|
|
if (nPos2 == -1)
|
|
break;
|
|
|
|
//..<***>...
|
|
sScript = sExt.Mid(nPos + 1,nPos2 - nPos - 1);
|
|
|
|
if (sScript.Find( EW_HOLDER ) != -1)
|
|
{
|
|
CreateHolderSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_BOSS) != -1)
|
|
{
|
|
CreateBossSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find( EW_HANGER ) != -1)
|
|
{
|
|
CreateHangerSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_RINGS) != -1)
|
|
{
|
|
CreateRingsSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_LAMPS) != -1)
|
|
{
|
|
CreateLampsSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_FIREET) != -1)
|
|
{
|
|
CreateFileEETSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_GUTTERWAY) != -1)
|
|
{
|
|
CreateGutterwaySection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_FIREDOOR) != -1)
|
|
{
|
|
CreateFireDoorSection(sScript, arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_SECURITY) != -1)
|
|
{
|
|
CreateSecuritySection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_DRAFAN) != -1)
|
|
{
|
|
CreateDraFanSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_GASALARM) != -1)
|
|
{
|
|
CreateGasAlarmSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_ROOMSLAB) != -1)
|
|
{
|
|
CreateRoomSlabSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_ROOMNAME) != -1)
|
|
{
|
|
CreateRoomNameSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_SMOKALARM) != -1)
|
|
{
|
|
CreateSmokAlarmSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_TEMPALARM) != -1)
|
|
{
|
|
CreateTempAlarmSection(sScript, arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_COALARM) != -1)
|
|
{
|
|
CreateCoAlarmSection(sScript, arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_OXALARM) != -1)
|
|
{
|
|
CreateOxAlarmSection(sScript, arEntPtrs);
|
|
}
|
|
nSta += sScript.GetLength();
|
|
nPos = sExt.Find(_T('<'),nSta);
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateHolderSection(LPCTSTR pszScript,AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//HOLDER:房间|左右位置|层数|垂直间隙|水平间隙|距顶D|长度|宽度|厚度|材料|用途|偏移=(,,,)|编号
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_HOLDER);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript,arInf,_T('|'));
|
|
|
|
if (arInf.GetSize() >= 11)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nLRPos = _ttoi(arInf.GetAt(1));
|
|
int nRows = _ttoi(arInf.GetAt(2));
|
|
|
|
double dVSpace = _ttof(arInf.GetAt(3));
|
|
double dHSpace = _ttof(arInf.GetAt(4));
|
|
double dFrTop = _ttof(arInf.GetAt(5));
|
|
double dL = _ttof(arInf.GetAt(6));
|
|
double dW = _ttof(arInf.GetAt(7));
|
|
double dt = _ttof(arInf.GetAt(8));
|
|
CString sMa = arInf.GetAt(9);
|
|
CString sSpec = arInf.GetAt(10);
|
|
|
|
CString sNo = _T(""),sTemp;
|
|
if (arInf.GetSize() > 12)
|
|
{
|
|
sTemp = arInf.GetAt(12);
|
|
sNo.Format(_T("支架编号:%s"),sTemp);
|
|
}
|
|
|
|
ERoom room;
|
|
if ( GetRoom(nRoomIndex,room) )
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,11);
|
|
|
|
AcGePoint3d ptGe = nLRPos == 0 ? room.ptGe[3] : room.ptGe[2];
|
|
AcGeVector3d vtL = nLRPos == 0 ? AcGeVector3d::kXAxis : -AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtY = -AcGeVector3d::kYAxis;
|
|
|
|
AcGePoint3d ptFr = ptGe + vtY * dFrTop;
|
|
AlongRoomSide(ptFr,nRoomIndex,vtL);
|
|
|
|
AcGePoint3d ptSta = ptFr;
|
|
AcGePoint3d ptL[5],ptPos,ptCen,ptl[5];
|
|
|
|
//用途对于高压的识别
|
|
CString sText = sSpec;
|
|
sText.MakeLower();
|
|
int nFr = sText.Find(_T('('));
|
|
int nTo = sText.Find(_T(')'),nFr);
|
|
int nXKv = 0;
|
|
if (nFr != -1 && nTo != -1)
|
|
{
|
|
sText = sSpec.Mid(nFr,nTo - nFr + 1);
|
|
sSpec = sSpec.Left(nFr);
|
|
sText.TrimLeft(_T('('));
|
|
sText.TrimRight(_T(')'));
|
|
|
|
if (_ttoi(sText) > 30)
|
|
{
|
|
nXKv = 1;
|
|
}
|
|
}
|
|
|
|
for (int i = 0;i < nRows;i++)
|
|
{
|
|
AlongRoomSide(ptFr,nRoomIndex,vtL);
|
|
|
|
ptL[0] = ptFr;
|
|
ptL[1] = ptFr + vtL * AS_MUNIT(dL);
|
|
ptL[2] = ptL[1] + vtY * AS_MUNIT(dW);
|
|
ptL[3] = ptL[0] + vtY * AS_MUNIT(dW);
|
|
ptL[4] = ptL[0];
|
|
|
|
//绘制水平杆
|
|
AcDbPolyline* pPlRc = new AcDbPolyline;
|
|
for (int k = 0;k < 5;k++)
|
|
{
|
|
pPlRc->addVertexAt(k,ptL[k].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPlRc->setConstantWidth(m_dSingleLnWidth);
|
|
pPlRc->setNormal(AcGeVector3d::kZAxis);
|
|
pPlRc->setColorIndex(kGreen);//颜色区分参与三维显示
|
|
pPlRc->setClosed(Adesk::kTrue);
|
|
arEntPtrs.append(pPlRc);
|
|
|
|
//绘制三角斜边加强筋
|
|
ptl[0] = ptL[3];
|
|
ptl[0] += 0.1732 * vtY * AS_MUNIT(dL);
|
|
AlongRoomSide(ptl[0],nRoomIndex,vtL);
|
|
ptl[1] = ptL[3] + 0.3 * vtL * AS_MUNIT(dL);
|
|
|
|
pPlRc = new AcDbPolyline;
|
|
pPlRc->addVertexAt(0,ptl[0].convert2d(AcGePlane::kXYPlane));
|
|
pPlRc->addVertexAt(1,ptl[1].convert2d(AcGePlane::kXYPlane));
|
|
pPlRc->setConstantWidth(m_dSingleLnWidth);
|
|
pPlRc->setNormal(AcGeVector3d::kZAxis);
|
|
pPlRc->setColorIndex(kGreen);//颜色区分参与三维显示
|
|
arEntPtrs.append(pPlRc);
|
|
|
|
//用途
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(AS_MUNIT(dW));
|
|
|
|
ptPos = MidPoint(ptL[0],ptL[1]);
|
|
ptPos -= vtY * 2.0 * AS_MUNIT(dW);
|
|
pText->setPosition(ptPos);
|
|
pText->setRotation(0.0);
|
|
|
|
pText->setTextString(sSpec);
|
|
pText->setColorIndex(kCyan);//颜色区分不参与三维显示
|
|
arEntPtrs.append(pText);
|
|
|
|
if (nFr != -1 && nTo != -1)
|
|
{
|
|
if (nLRPos == 0)
|
|
{
|
|
pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(AS_MUNIT(dW));
|
|
|
|
ptPos = ptL[1];
|
|
ptPos += vtL * 0.2 * AS_MUNIT(dW);
|
|
pText->setPosition(ptPos);
|
|
pText->setRotation(0.0);
|
|
|
|
pText->setTextString(sText);
|
|
pText->setColorIndex(kCyan);//颜色区分不参与三维显示
|
|
arEntPtrs.append(pText);
|
|
}
|
|
else
|
|
{
|
|
AcDbExtents ext;
|
|
AcGiTextStyle txst;
|
|
fromAcDbTextStyle(txst,acdbCurDwg()->textstyle());
|
|
CKTCadUtility::GetTextBox(ext,sText,txst.styleName(),AS_MUNIT(dW));
|
|
|
|
pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(AS_MUNIT(dW));
|
|
|
|
ptPos = ptL[1];
|
|
ptPos += vtL * ( ext.maxPoint().x - ext.minPoint().x );
|
|
ptPos += vtL * 0.2 * AS_MUNIT(dW);
|
|
pText->setPosition(ptPos);
|
|
pText->setRotation(0.0);
|
|
|
|
pText->setTextString(sText);
|
|
pText->setColorIndex(kCyan);//颜色区分不参与三维显示
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
|
|
//一排圆管示意5 个,可能是品字形
|
|
//支架用途中有>=35kv 字样
|
|
AcDbCircle* pCir = NULL;
|
|
if (nFr != -1 && nTo != -1 && nXKv > 0)
|
|
{
|
|
ptCen = MidPoint(ptL[0],ptL[1]);
|
|
ptCen -= vtY * 0.5 * AS_MUNIT(dW);
|
|
ptCen -= vtL * 0.5 * AS_MUNIT(dW);
|
|
|
|
for (int j = 0;j < 2;j++)
|
|
{
|
|
pCir = new AcDbCircle;
|
|
pCir->setCenter(ptCen);
|
|
pCir->setRadius(0.5 * AS_MUNIT(dW));
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
pCir->setColorIndex(kCyan);//颜色区分不参与三维显示
|
|
arEntPtrs.append(pCir);
|
|
|
|
ptCen += vtL * AS_MUNIT(dW);
|
|
}
|
|
|
|
ptCen -= vtL * 1.5 * AS_MUNIT(dW);
|
|
ptCen -= vtY * 0.866 * AS_MUNIT(dW);
|
|
|
|
pCir = new AcDbCircle;
|
|
pCir->setCenter(ptCen);
|
|
pCir->setRadius(0.5 * AS_MUNIT(dW));
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
pCir->setColorIndex(kCyan);//颜色区分不参与三维显示
|
|
arEntPtrs.append(pCir);
|
|
}
|
|
else
|
|
{
|
|
////5个示意
|
|
ptCen = MidPoint(ptL[0],ptL[1]);
|
|
ptCen -= vtY * 0.5 * AS_MUNIT(dW);
|
|
ptCen -= vtL * (5 / 2.0 ) * AS_MUNIT(dW);
|
|
|
|
for (int j = 0;j < 5;j++)
|
|
{
|
|
pCir = new AcDbCircle;
|
|
pCir->setCenter(ptCen);
|
|
pCir->setRadius(0.5 * AS_MUNIT(dW));
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
pCir->setColorIndex(kCyan);//颜色区分不参与三维显示
|
|
arEntPtrs.append(pCir);
|
|
|
|
ptCen += vtL * AS_MUNIT(dW);
|
|
}
|
|
}
|
|
ptFr += vtY * ( dVSpace + AS_MUNIT(dW));
|
|
}
|
|
|
|
ptFr -= vtY * ( dVSpace + AS_MUNIT(dW));
|
|
if (!sNo.IsEmpty())
|
|
{
|
|
ptL[0] = ptFr;
|
|
ptL[0] += vtY * 0.5 * dVSpace;
|
|
ptL[0] += vtL * AS_MUNIT(dW);
|
|
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(AS_MUNIT(dW));
|
|
|
|
ptPos = ptL[0];
|
|
pText->setPosition(ptPos);
|
|
pText->setRotation(0.0);
|
|
|
|
pText->setTextString(sNo);
|
|
pText->setColorIndex(kCyan);//颜色区分不参与三维显示
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
}
|
|
return arEntPtrs.length();
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateBossSection(LPCTSTR pszScript,AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//BOSS: 房间|左右位置|侧间隙|水平间隙|宽|高|长|直径|用途|公称直径|壁厚|重量|管道材质|管道系统|颜色|线形|编号|支墩类型|偏移|行|间隙
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_BOSS);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript,arInf,_T('|'));
|
|
|
|
if (arInf.GetSize() >= 9)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nLRPos = _ttoi(arInf.GetAt(1));//米
|
|
double dPos = _ttof(arInf.GetAt(2));
|
|
double dXSpace = _ttof(arInf.GetAt(3));//米
|
|
double dW = _ttof(arInf.GetAt(4));
|
|
double dH = _ttof(arInf.GetAt(5));
|
|
double dL = _ttof(arInf.GetAt(6));
|
|
double dD = _ttof(arInf.GetAt(7));
|
|
CString sSpec = arInf.GetAt(8);
|
|
CString sNo(_T("0"));
|
|
if (arInf.GetSize() > 16)
|
|
sNo = arInf.GetAt(16);
|
|
|
|
ERoom room;
|
|
if ( GetRoom(nRoomIndex,room) )
|
|
{
|
|
//预留官位只能放在主舱室
|
|
//OffsetMapToSplitRoom(arInf,room, 18);
|
|
|
|
if (nLRPos == 1)//距离右侧,转换为距离左侧
|
|
{
|
|
dPos = room.ptGe[1].distanceTo(room.ptGe[0]) - dPos;
|
|
}
|
|
|
|
//if (!bOnlyAddBoss)
|
|
{
|
|
AcGePoint3d ptCen = room.ptGe[0];
|
|
AcGeVector3d vtDirX = room.ptGe[1] - room.ptGe[0];
|
|
vtDirX.normalize();
|
|
|
|
ptCen += dPos * vtDirX;
|
|
ptCen.y += AS_MUNIT(dH);
|
|
ptCen.y += 0.5 * dD;
|
|
|
|
//绘制管线圆示意
|
|
AcDbCircle* pCir = new AcDbCircle;
|
|
pCir->setCenter(ptCen);
|
|
pCir->setRadius(0.5 * dD);
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
AcGePoint3d ptGe[4];
|
|
|
|
ptGe[0] = room.ptGe[0];
|
|
ptGe[0] += (dPos - 0.5 * AS_MUNIT(dW) ) * vtDirX;
|
|
AlongRoomSide(ptGe[0],nRoomIndex,AcGeVector3d::kYAxis);
|
|
pPl->addVertexAt(0,ptGe[0].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[1] = ptGe[0] + AcGeVector3d::kYAxis * AS_MUNIT(dH);
|
|
pPl->addVertexAt(0,ptGe[1].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[2] = ptGe[1] + AS_MUNIT(dW) * vtDirX;
|
|
pPl->addVertexAt(0,ptGe[2].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[3] = ptGe[0] + AS_MUNIT(dW) * vtDirX;
|
|
AlongRoomSide(ptGe[3],nRoomIndex,AcGeVector3d::kYAxis);
|
|
pPl->addVertexAt(0,ptGe[3].convert2d(AcGePlane::kXYPlane));
|
|
arEntPtrs.append(pPl);
|
|
arEntPtrs.append(pCir);
|
|
|
|
//用途
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
|
|
ptCen = pCir->center();
|
|
pText->setPosition(ptCen);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sNo);
|
|
//pText->setAlignmentPoint(ptCen);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
pText->setColorIndex(kGreen);
|
|
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateHangerSection(LPCTSTR pszScript,AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//HANGER:房间|层数|垂直间隙|水平间隙|左侧距离|距顶D|长度|宽度|厚度|材料|用途|偏移(,,,)
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_HANGER);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript,arInf,_T('|'));
|
|
|
|
if (arInf.GetSize() >= 11)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nRows = _ttoi(arInf.GetAt(1));
|
|
|
|
double dVSpace = _ttof(arInf.GetAt(2));//米
|
|
double dHSpace = _ttof(arInf.GetAt(3));//米
|
|
double dX = _ttof(arInf.GetAt(4));//米
|
|
double dFrTop = _ttof(arInf.GetAt(5));//米
|
|
|
|
double dL = _ttof(arInf.GetAt(6));//mm
|
|
double dW = _ttof(arInf.GetAt(7));//mm
|
|
double dt = _ttof(arInf.GetAt(8));//mm
|
|
|
|
CString sMa = arInf.GetAt(9);
|
|
CString sSpec = arInf.GetAt(10);
|
|
|
|
CString sNo = _T(""), sTemp;
|
|
if (arInf.GetSize() >= 13)
|
|
{
|
|
sTemp = arInf.GetAt(12);
|
|
sNo.Format(_T("吊架编号:%s"), sTemp);
|
|
}
|
|
|
|
ERoom room;
|
|
if ( GetRoom(nRoomIndex,room) )
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,11);
|
|
|
|
AcGePoint3d ptGe = room.ptGe[3];
|
|
AcGeVector3d vtL = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtY = -AcGeVector3d::kYAxis;
|
|
AcGePoint3d ptFr = ptGe + vtL * dX;
|
|
//AlongRoomSide(ptFr,nRoomIndex,vtL);
|
|
|
|
AcGePoint3d ptSta = ptFr;
|
|
AcGePoint3d ptU[10],ptPos,ptCen,ptL[5],ptU2[10];
|
|
|
|
ptU[0] = ptFr;
|
|
ptU[1] = ptU[0] + vtY * ( (nRows - 1)* ( dVSpace + AS_MUNIT(dW) ) + dFrTop + AS_MUNIT(dW) );
|
|
ptU[2] = ptU[1] + vtL * AS_MUNIT(dL);
|
|
ptU[3] = ptU[0] + vtL * AS_MUNIT(dL);
|
|
|
|
ptU[4] = ptU[3] - vtL * AS_MUNIT(dW);
|
|
ptU[5] = ptU[4] + vtY * ( (nRows - 1)* ( dVSpace + AS_MUNIT(dW) ) + dFrTop );
|
|
ptU[6] = ptU[5] - vtL * (AS_MUNIT(dL) - 2.0 * AS_MUNIT(dW) );
|
|
ptU[7] = ptU[0] + vtL * AS_MUNIT(dW);
|
|
ptU[8] = ptU[0];
|
|
|
|
//3,4,7,8,0 备份
|
|
memcpy(ptU2,ptU,sizeof(AcGePoint3d) * 10);
|
|
AlongRoomSide(ptU[3],nRoomIndex,vtY);
|
|
AlongRoomSide(ptU[4],nRoomIndex,vtY);
|
|
AlongRoomSide(ptU[7],nRoomIndex,vtY);
|
|
AlongRoomSide(ptU[8],nRoomIndex,vtY);
|
|
AlongRoomSide(ptU[0],nRoomIndex,vtY);
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
for (int i = 0;i < 9;i++)
|
|
{
|
|
pPl->addVertexAt(i,ptU[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setConstantWidth(m_dSingleLnWidth);
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
memcpy(ptU,ptU2,sizeof(AcGePoint3d) * 10);
|
|
for (int k = 0;k < nRows - 1;k++)
|
|
{
|
|
ptL[0] = ptU[7] + vtY * ( k* dVSpace + dFrTop + k * AS_MUNIT(dW) );
|
|
ptL[1] = ptL[0] + vtL * (AS_MUNIT(dL) - 2.0 * AS_MUNIT(dW) );
|
|
ptL[2] = ptL[1] + vtY * AS_MUNIT(dW);
|
|
ptL[3] = ptL[0] + vtY * AS_MUNIT(dW);
|
|
ptL[4] = ptL[0];
|
|
|
|
pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
for (int ii = 0;ii < 5;ii++)
|
|
{
|
|
pPl->addVertexAt(ii,ptL[ii].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setConstantWidth(m_dSingleLnWidth);
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
}
|
|
|
|
if (!sNo.IsEmpty())
|
|
{
|
|
ptL[0] = ptFr;
|
|
ptL[0] += vtY * 0.5 * dVSpace;
|
|
ptL[0] += vtL * AS_MUNIT(dW);
|
|
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(AS_MUNIT(dW));
|
|
|
|
ptPos = ptL[0];
|
|
pText->setPosition(ptPos);
|
|
pText->setRotation(0.0);
|
|
|
|
pText->setTextString(sNo);
|
|
pText->setColorIndex(kCyan);//颜色区分不参与三维显示
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateRingsSection(LPCTSTR pszScript,AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//RINGS:房间|半径|大径|长度|位置|材料|用途|偏移
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_RINGS);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript,arInf,_T('|'));
|
|
|
|
if (arInf.GetSize() >= 8)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
|
|
double dr = _ttof(arInf.GetAt(1));//mm 粗
|
|
double dR = _ttof(arInf.GetAt(2));//mm
|
|
double dL = _ttof(arInf.GetAt(3));//mm
|
|
double dX = _ttof(arInf.GetAt(4));//米
|
|
|
|
CString sMa = arInf.GetAt(5);
|
|
CString sSpec = arInf.GetAt(6);
|
|
|
|
CString sNo(_T(""));
|
|
if (arInf.GetSize() >= 9)
|
|
{
|
|
sNo = arInf.GetAt(8);
|
|
}
|
|
|
|
ERoom room;
|
|
if ( GetRoom(nRoomIndex,room) )
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,7);
|
|
|
|
AcGeVector3d vtL = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtY = -AcGeVector3d::kYAxis;
|
|
|
|
AcGePoint3d ptGe[2];
|
|
ptGe[0] = room.ptGe[3];
|
|
ptGe[0] += vtL * dX;
|
|
AlongRoomSide(ptGe[0],nRoomIndex,vtY);
|
|
|
|
ptGe[1] = ptGe[0] + vtY * AS_MUNIT(dL);
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
pPl->addVertexAt(0,ptGe[0].convert2d(AcGePlane::kXYPlane));
|
|
pPl->addVertexAt(1,ptGe[1].convert2d(AcGePlane::kXYPlane));
|
|
pPl->setConstantWidth(AS_MUNIT(dr));//20mm粗
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
//带粗度的圆
|
|
double dRR = dR;
|
|
ptGe[1] += vtY * AS_MUNIT(dRR);
|
|
AcDbCircle* pCir = new AcDbCircle;
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
pCir->setCenter(ptGe[1]);
|
|
pCir->setRadius(AS_MUNIT(dRR));
|
|
pCir->setColorIndex(kGreen);
|
|
arEntPtrs.append(pCir);
|
|
|
|
pCir = new AcDbCircle;
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
pCir->setCenter(ptGe[1]);
|
|
dRR = dR - 2.0 * dr;
|
|
pCir->setRadius(AS_MUNIT(dRR));
|
|
pCir->setColorIndex(kGreen);
|
|
arEntPtrs.append(pCir);
|
|
|
|
//用途
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
|
|
//ptGe[0] -= vtY * 0.25;
|
|
ptGe[0] -= vtL * 0.15;
|
|
pText->setPosition(ptGe[0]);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(_T("吊环-编号:") + sNo);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptGe[0]);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateLampsSection(LPCTSTR pszScript, AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//LAMPS:房间|长度|宽度|厚度|左侧定位|纵向间距|瓦数|名称|型好|厂家|偏移
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_LAMPS);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript, arInf, _T('|'));
|
|
|
|
CString sNo(_T(""));
|
|
if (arInf.GetSize() >= 12)
|
|
{
|
|
sNo = arInf.GetAt(11);
|
|
}
|
|
|
|
if (arInf.GetSize() >= 10)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
double dL = _ttof(arInf.GetAt(1));//mm
|
|
double dW = _ttof(arInf.GetAt(2));//mm
|
|
double dt = _ttof(arInf.GetAt(3));//mm
|
|
|
|
double dX = _ttof(arInf.GetAt(4));//m
|
|
double dVSpace = _ttof(arInf.GetAt(5));//m
|
|
|
|
int nWt = _ttoi(arInf.GetAt(6));
|
|
CString sName = arInf.GetAt(7);
|
|
CString sTypeNo = arInf.GetAt(8);
|
|
CString sFact = arInf.GetAt(9);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
|
|
ERoom room;
|
|
if (GetRoom(nRoomIndex, room))
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,10);
|
|
|
|
AcGeVector3d vtL = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtY = -AcGeVector3d::kYAxis;
|
|
|
|
ptGe[0] = room.ptGe[3];
|
|
ptGe[0] += vtL * dX;
|
|
ptGe[0] -= vtL * 0.5 * AS_MUNIT(dW);
|
|
|
|
ptGe[1] = ptGe[0] + AS_MUNIT(dt) * vtY;
|
|
ptGe[2] = ptGe[1] + AS_MUNIT(dW) * vtL;
|
|
ptGe[3] = ptGe[0] + AS_MUNIT(dW) * vtL;
|
|
|
|
AlongRoomSide(ptGe[0],nRoomIndex,vtY);
|
|
AlongRoomSide(ptGe[3],nRoomIndex,vtY);
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
for (int i = 0; i < 4;i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
pPl->setConstantWidth(m_dSingleLnWidth);
|
|
arEntPtrs.append(pPl);
|
|
|
|
AcDbArc* pArc = new AcDbArc;
|
|
pArc->setCenter(MidPoint(ptGe[1],ptGe[2]));
|
|
pArc->setRadius(0.5 * AS_MUNIT(dW));
|
|
pArc->setNormal(AcGeVector3d::kZAxis);
|
|
pArc->setStartAngle(PI);
|
|
pArc->setEndAngle(2.0 * PI);
|
|
pArc->setColorIndex(kGreen);
|
|
arEntPtrs.append(pArc);
|
|
|
|
AcGePoint3d ptCen = pArc->center();
|
|
ptCen += vtY * 0.25 * AS_MUNIT(dW);
|
|
|
|
AcDbCircle* pCir = new AcDbCircle;
|
|
pCir->setCenter(ptCen);
|
|
pCir->setRadius(0.25 * AS_MUNIT(dW));
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
pCir->setColorIndex(kGreen);
|
|
arEntPtrs.append(pCir);
|
|
|
|
//用途
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
|
|
//ptGe[2] = MidPoint(ptGe[0], ptGe[3]);//居中
|
|
ptGe[2] = ptGe[0];
|
|
ptGe[2] -= vtY * 0.05;
|
|
pText->setPosition(ptGe[2]);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sName + _T("-编号:") + sNo);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptGe[2]);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateFileEETSection(LPCTSTR pszScript, AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//FIREET:房间|安装方式|安装位置|X直径L|Y直径H|上间隙TSP|下间隙DSP|填充量|工作温度|性能|型号|名称|类别|厂家|偏移
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_FIREET);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript, arInf, _T('|'));
|
|
|
|
if (arInf.GetSize() >= 13)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nSetupStyle = _ttoi(arInf.GetAt(1));
|
|
int nSetupPos = _ttoi(arInf.GetAt(2));
|
|
|
|
double dXR = _ttof(arInf.GetAt(3));
|
|
double dYR = _ttof(arInf.GetAt(4));
|
|
double dTSp = _ttof(arInf.GetAt(5));
|
|
double dDSp = _ttof(arInf.GetAt(6));
|
|
double dFill = _ttof(arInf.GetAt(7));
|
|
double dWorkt = _ttoi(arInf.GetAt(8));
|
|
CString sName = arInf.GetAt(11);
|
|
|
|
CString sNo(_T(""));
|
|
if (arInf.GetSize() >= 16)
|
|
{
|
|
sNo = arInf.GetAt(15);
|
|
}
|
|
|
|
double dr = 20.0;//mm 挂径示意
|
|
AcGePoint3d ptGe[5];
|
|
AcGeVector3d vtL = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtY = -AcGeVector3d::kYAxis;
|
|
|
|
ERoom room;
|
|
if (GetRoom(nRoomIndex, room))
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,14);
|
|
|
|
if (nSetupStyle == 0)//剧中垂直喷射安装
|
|
{
|
|
AcGePoint3d ptMid = MidPoint(room.ptGe[2], room.ptGe[3]);
|
|
|
|
AcGePoint3d ptText = ptMid;
|
|
ptText -= vtY * 0.15;
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
pText->setPosition(ptText);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sName + _T("-编号:") + sNo);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptGe[2]);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
|
|
ptGe[0] = ptMid - vtL * AS_MUNIT(dr);
|
|
ptGe[1] = ptGe[0] + vtY * AS_MUNIT(dTSp);
|
|
ptGe[2] = ptGe[1] + vtL * 2 * AS_MUNIT(dr);
|
|
ptGe[3] = ptGe[0] + vtL * 2 * AS_MUNIT(dr);
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kRed);
|
|
pPl->setConstantWidth(m_dSingleLnWidth);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptMid += vtY * (AS_MUNIT(dYR) + AS_MUNIT(dTSp));
|
|
|
|
AcDbEllipse* pCir = new AcDbEllipse;
|
|
pCir->set(ptMid, AcGeVector3d::kZAxis, AcGeVector3d(AS_MUNIT(dXR), 0, 0), dYR / dXR);
|
|
pCir->setColorIndex(kRed);
|
|
arEntPtrs.append(pCir);
|
|
|
|
ptMid += vtY * AS_MUNIT(dYR);
|
|
|
|
ptGe[0] = ptMid - vtL * 0.5 * AS_MUNIT(dr);
|
|
ptGe[1] = ptGe[0] + vtY * AS_MUNIT(dDSp);
|
|
ptGe[2] = ptGe[1] + vtL * AS_MUNIT(dr);
|
|
ptGe[3] = ptGe[0] + vtL * AS_MUNIT(dr);
|
|
|
|
pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kRed);
|
|
pPl->setConstantWidth(m_dSingleLnWidth);
|
|
arEntPtrs.append(pPl);
|
|
}
|
|
else
|
|
{
|
|
AcGePoint3d ptMid;
|
|
if (nSetupPos == 0)//左
|
|
{
|
|
ptMid = room.ptGe[3];
|
|
}
|
|
else
|
|
{
|
|
ptMid = room.ptGe[2];
|
|
vtL.negate();
|
|
}
|
|
|
|
AcGePoint3d ptText = ptMid;
|
|
ptText -= vtY * 0.15;
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
pText->setPosition(ptText);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sName + _T("-编号:") + sNo);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptGe[2]);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
|
|
ptMid += vtY * (AS_MUNIT(dXR) + AS_MUNIT(dr));
|
|
|
|
ptGe[0] = ptMid - vtY * AS_MUNIT(dr);
|
|
ptGe[1] = ptGe[0] + vtY * 2 * AS_MUNIT(dr);
|
|
ptGe[2] = ptGe[1] + vtL * AS_MUNIT(dTSp);
|
|
ptGe[3] = ptGe[0] + vtL * AS_MUNIT(dTSp);
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kRed);
|
|
pPl->setConstantWidth(m_dSingleLnWidth);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptMid += vtL * (AS_MUNIT(dXR) + AS_MUNIT(dTSp));
|
|
|
|
AcDbEllipse* pCir = new AcDbEllipse;
|
|
pCir->set(ptMid, AcGeVector3d::kZAxis, AcGeVector3d(AS_MUNIT(dXR), 0, 0), dYR / dXR);
|
|
pCir->setColorIndex(kRed);
|
|
arEntPtrs.append(pCir);
|
|
|
|
ptMid += vtL * AS_MUNIT(dXR);
|
|
|
|
ptGe[0] = ptMid - vtY * 0.5 * AS_MUNIT(dr);
|
|
ptGe[1] = ptGe[0] + vtY * AS_MUNIT(dr);
|
|
ptGe[2] = ptGe[1] + vtL * AS_MUNIT(dTSp);
|
|
ptGe[3] = ptGe[0] + vtL * AS_MUNIT(dTSp);
|
|
ptGe[4] = ptGe[0];
|
|
|
|
pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kRed);
|
|
pPl->setConstantWidth(m_dSingleLnWidth);
|
|
arEntPtrs.append(pPl);
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateGutterwaySection(LPCTSTR pszScript,AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//GUTTERWAY:1房间位置左右|中房间位置左右|末房间位置左右|排水沟宽|排水沟深H|坡度
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_GUTTERWAY);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript, arInf, _T('|'));
|
|
|
|
if (arInf.GetSize() >= 6)
|
|
{
|
|
int nPos1 = _ttoi(arInf.GetAt(0));
|
|
int nPos2 = _ttoi(arInf.GetAt(1));
|
|
int nPos3 = _ttoi(arInf.GetAt(2));
|
|
|
|
float dW = (float)_ttof(arInf.GetAt(3));
|
|
float dH = (float)_ttof(arInf.GetAt(4));
|
|
float dGr = (float)_ttof(arInf.GetAt(5));
|
|
|
|
CIntArray arPos;
|
|
int nCount = GetRoomCount();
|
|
for (int i = 0; i < nCount; i++)
|
|
{
|
|
if (i == 0)
|
|
arPos.Add(nPos1);
|
|
else if (i == nCount - 1)
|
|
arPos.Add(nPos2);
|
|
else
|
|
arPos.Add(nPos3);
|
|
}
|
|
|
|
AcGeVector3d vtL = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtY = AcGeVector3d::kYAxis;
|
|
double dX = 0.0;
|
|
AcGeVector3d vtX;
|
|
AcGePoint3d ptGe[2],ptL[4];
|
|
for (int i = 0; i < nCount; i++)
|
|
{
|
|
ERoom room;
|
|
GetRoom(i, room);
|
|
|
|
if (i == 0)
|
|
{
|
|
ptGe[0] = nPos1 == 0 ? room.ptGe[0] : room.ptGe[1];
|
|
ptGe[1] = nPos1 == 0 ? room.ptGe[1] : room.ptGe[0];
|
|
vtX = ptGe[1] - ptGe[0];
|
|
vtX.normalize();
|
|
|
|
dX = fabs(ptGe[1].x - ptGe[0].x);
|
|
|
|
ptL[0] = ptGe[0] + vtX * AS_MUNIT(dW);
|
|
ptL[1] = ptL[0] + vtY * AS_MUNIT(dH);
|
|
ptL[2] = ptGe[1];
|
|
ptL[2] += vtY * ( AS_MUNIT(dH) + dX * dGr * 0.01);
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
for (int ii = 0; ii < 3; ii++)
|
|
{
|
|
pPl->addVertexAt(ii, ptL[ii].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
pPl->setConstantWidth(m_dSingleLnWidth);
|
|
arEntPtrs.append(pPl);
|
|
}
|
|
else if (i == nCount - 1)
|
|
{
|
|
ptGe[0] = nPos3 == 0 ? room.ptGe[0] : room.ptGe[1];
|
|
ptGe[1] = nPos3 == 0 ? room.ptGe[1] : room.ptGe[0];
|
|
vtX = ptGe[1] - ptGe[0];
|
|
vtX.normalize();
|
|
|
|
dX = fabs(ptGe[1].x - ptGe[0].x);
|
|
|
|
ptL[0] = ptGe[0] + vtX * AS_MUNIT(dW);
|
|
ptL[1] = ptL[0] + vtY * AS_MUNIT(dH);
|
|
ptL[2] = ptGe[1];
|
|
ptL[2] += vtY * (AS_MUNIT(dH) + dX * dGr * 0.01);
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
for (int ii = 0; ii < 3; ii++)
|
|
{
|
|
pPl->addVertexAt(ii, ptL[ii].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
pPl->setConstantWidth(m_dSingleLnWidth);
|
|
arEntPtrs.append(pPl);
|
|
}
|
|
else
|
|
{
|
|
ptGe[0] = nPos2 == 0 ? room.ptGe[0] : room.ptGe[1];
|
|
ptGe[1] = nPos2 == 0 ? room.ptGe[1] : room.ptGe[0];
|
|
vtX = ptGe[1] - ptGe[0];
|
|
vtX.normalize();
|
|
|
|
dX = fabs(ptGe[1].x - ptGe[0].x);
|
|
|
|
ptL[0] = ptGe[0] + vtX * AS_MUNIT(dW);
|
|
ptL[1] = ptL[0] + vtY * AS_MUNIT(dH);
|
|
ptL[2] = ptGe[1];
|
|
ptL[2] += vtY * (AS_MUNIT(dH) + dX * dGr * 0.01);
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
for (int ii = 0; ii < 3; ii++)
|
|
{
|
|
pPl->addVertexAt(ii, ptL[ii].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
pPl->setConstantWidth(m_dSingleLnWidth);
|
|
arEntPtrs.append(pPl);
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateFireDoorSection(LPCTSTR pszScript, AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//FIREDOOR:房间|宽|高|位置|型号|厂家|偏移
|
|
double dXW = 0.05;//50mm示意
|
|
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_FIREDOOR);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript, arInf, _T('|'));
|
|
|
|
CString sNo(_T(""));
|
|
if (arInf.GetSize() >= 8)
|
|
{
|
|
sNo = arInf.GetAt(7);
|
|
}
|
|
|
|
if (arInf.GetSize() >= 5)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
double dW = _ttof(arInf.GetAt(1)) / 1000.0;
|
|
double dH = _ttof(arInf.GetAt(2)) / 1000.0;
|
|
double dX = _ttof(arInf.GetAt(3)) / 1000.0;
|
|
CString sSpec = arInf.GetAt(4);
|
|
|
|
ERoom room;
|
|
if (GetRoom(nRoomIndex, room))
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,6);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
AcGeVector3d vtX = room.ptGe[1] - room.ptGe[0];
|
|
vtX.normalize();
|
|
|
|
AcGeVector3d vtY = room.ptGe[2] - room.ptGe[1];
|
|
vtY.normalize();
|
|
|
|
ptGe[0] = MidPoint(room.ptGe[0],room.ptGe[1]);
|
|
ptGe[0] -= AcGeVector3d::kXAxis * 0.5 * dW;
|
|
//ptGe[0] += vtX * dX;//距离左侧无意义
|
|
ptGe[1] = ptGe[0] + vtX * dW;
|
|
|
|
ptGe[2] = ptGe[1] + vtY * dH;
|
|
ptGe[3] = ptGe[0] + vtY * dH;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcGeVector3d vtYY = AcGeVector3d::kYAxis;
|
|
AlongRoomSide(ptGe[0],nRoomIndex,vtYY);
|
|
AlongRoomSide(ptGe[1],nRoomIndex,vtYY);
|
|
AlongRoomSide(ptGe[4],nRoomIndex,vtYY);
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 5;i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptGe[0] = MidPoint(room.ptGe[0],room.ptGe[1]);
|
|
ptGe[0] -= AcGeVector3d::kXAxis * 0.5 * dW;
|
|
ptGe[0] += vtX * (dX + dXW);
|
|
ptGe[0] += vtY * dXW;
|
|
|
|
dW -= 2.0 * dXW;
|
|
dH -= 2.0 * dXW;
|
|
|
|
ptGe[1] = ptGe[0] + vtX * dW;
|
|
ptGe[2] = ptGe[1] + vtY * dH;
|
|
ptGe[3] = ptGe[0] + vtY * dH;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AlongRoomSide(ptGe[0],nRoomIndex,vtYY);
|
|
AlongRoomSide(ptGe[1],nRoomIndex,vtYY);
|
|
AlongRoomSide(ptGe[4],nRoomIndex,vtYY);
|
|
|
|
pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
arEntPtrs.append(pPl);
|
|
|
|
TCHAR szfileName[MAX_PATH],szFullPath[MAX_PATH];
|
|
GetModuleFileName(_hdllInstance,szfileName,MAX_PATH);
|
|
|
|
TCHAR drive[_MAX_DRIVE] = _T(""),
|
|
dir[_MAX_DIR] = _T(""),
|
|
fname[_MAX_FNAME] = _T(""),
|
|
ext[_MAX_EXT] = _T("");
|
|
|
|
//e:\,program files\autodesk\,myarx,exe
|
|
_tsplitpath(szfileName, drive, dir, fname, ext);
|
|
_tcscpy(szFullPath, drive);
|
|
_tcscat(szFullPath, dir);
|
|
|
|
CString sFullPath = szFullPath;
|
|
sFullPath.TrimRight(_T('\\'));
|
|
|
|
//上一级目录
|
|
int nPos = sFullPath.ReverseFind(_T('\\'));
|
|
CString sPath = sFullPath.Mid(0,nPos + 1);
|
|
|
|
sFullPath = sPath + _T("sys\\man.dwg");
|
|
|
|
//调入外部dwg
|
|
TCHAR szManDwgFile[MAX_PATH];
|
|
_tcscpy(szManDwgFile,sFullPath);
|
|
|
|
//if (RTNORM == acedFindFile( _T("man.dwg"), szManDwgFile) )
|
|
{
|
|
AcDbObjectId idRec;
|
|
AcDbBlockTable* pTbl = NULL;
|
|
acdbCurDwg()->getBlockTable(pTbl, AcDb::kForRead);
|
|
if (pTbl != NULL)
|
|
{
|
|
pTbl->getAt(_T("man.dwg"), idRec);
|
|
pTbl->close();
|
|
}
|
|
|
|
if (!idRec.isValid())
|
|
{
|
|
AcDbDatabase db(Adesk::kFalse);
|
|
if (Acad::eOk == db.readDwgFile(szManDwgFile))
|
|
{
|
|
acdbCurDwg()->insert(idRec, _T("man.dwg"), &db);
|
|
}
|
|
}
|
|
|
|
if (idRec.isValid())
|
|
{
|
|
AcGePoint3d ptIns = MidPoint(ptGe[0], ptGe[1]);
|
|
AcDbBlockReference* pRef = new AcDbBlockReference;
|
|
pRef->setBlockTableRecord(idRec);
|
|
pRef->setPosition(ptIns);
|
|
//pRef->explode(arEntPtrs);
|
|
arEntPtrs.append(pRef);
|
|
}
|
|
}
|
|
/*else
|
|
{
|
|
acutPrintf(_T("\n没有找到man.dwg图库文件!"));
|
|
}*/
|
|
|
|
AcGePoint3d ptText = MidPoint(ptGe[2], ptGe[3]);
|
|
ptText += vtY * 0.12;
|
|
|
|
//文字
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
pText->setPosition(ptText);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sSpec + _T("-编号:") + sNo);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptText);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateSecuritySection(LPCTSTR pszScript, AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//SECURITY:房间|大径|小径|高度|定位|间距|名称|型号|厂家|偏移
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_SECURITY);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript, arInf, _T('|'));
|
|
|
|
CString sNo(_T(""));
|
|
if (arInf.GetSize() >= 11)
|
|
{
|
|
sNo = arInf.GetAt(10);
|
|
}
|
|
|
|
if (arInf.GetSize() >= 9)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
double dD = _ttof(arInf.GetAt(1));
|
|
double dd = _ttof(arInf.GetAt(2));
|
|
double dH = _ttof(arInf.GetAt(3));
|
|
double dX = _ttof(arInf.GetAt(4));
|
|
double dSp = _ttof(arInf.GetAt(5));
|
|
CString sName = arInf.GetAt(6);
|
|
|
|
ERoom room;
|
|
if (GetRoom(nRoomIndex, room))
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,9);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
|
|
AcGeVector3d vtX = room.ptGe[1] - room.ptGe[0];
|
|
vtX.normalize();
|
|
|
|
AcGeVector3d vtY = room.ptGe[2] - room.ptGe[1];
|
|
vtY.normalize();
|
|
|
|
ptGe[0] = room.ptGe[3];
|
|
ptGe[0] += vtX * (dX - 0.5 * dD);
|
|
AlongRoomSide(ptGe[0],nRoomIndex,vtY);
|
|
|
|
ptGe[1] = ptGe[0] + dD * vtX;
|
|
AlongRoomSide(ptGe[1],nRoomIndex,vtY);
|
|
|
|
double dMinY = __min(ptGe[0].y,ptGe[1].y);
|
|
ptGe[0].y = dMinY;ptGe[1].y = dMinY;
|
|
|
|
ptGe[2] = ptGe[1] - vtY * dH;
|
|
ptGe[3] = ptGe[0] - vtY * dH;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
//添加竖杆
|
|
AcGePoint3d ptGeH[2];
|
|
ptGeH[0] = MidPoint(ptGe[0],ptGe[1]);
|
|
ptGeH[1] = ptGeH[0];
|
|
AlongRoomSide(ptGeH[1],nRoomIndex,vtY);
|
|
pPl = new AcDbPolyline;
|
|
pPl->addVertexAt(0,ptGeH[0].convert2d(AcGePlane::kXYPlane));
|
|
pPl->addVertexAt(1,ptGeH[1].convert2d(AcGePlane::kXYPlane));
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
AcDbArc* pArc = new AcDbArc;
|
|
ptGe[0] = MidPoint(ptGe[2], ptGe[3]);
|
|
pArc->setCenter(ptGe[0]);
|
|
pArc->setStartAngle(PI);
|
|
pArc->setEndAngle(2.0 * PI);
|
|
pArc->setRadius(0.5 * dd);
|
|
pArc->setColorIndex(kGreen);
|
|
arEntPtrs.append(pArc);
|
|
|
|
ptGe[0] -= vtY * 0.5 * dd;
|
|
ptGe[0] -= vtY * 0.12;
|
|
|
|
//文字
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
pText->setPosition(ptGeH[1]);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sName + _T("-编号:") + sNo);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptGe[0]);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateDraFanSection(LPCTSTR pszScript, AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//DRAFAN:房间|外径|长度|吊高|间距|风量|功率|机号|名称|型号|厂家|偏移
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_DRAFAN);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript, arInf, _T('|'));
|
|
|
|
if (arInf.GetSize() >= 11)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
double dD = _ttof(arInf.GetAt(1));
|
|
double dL = _ttof(arInf.GetAt(2));
|
|
double dh = _ttof(arInf.GetAt(3));
|
|
double dSp = _ttof(arInf.GetAt(4));
|
|
|
|
CString sName = arInf.GetAt(8);
|
|
|
|
CString sNo(_T(""));
|
|
if (arInf.GetSize() >= 13)
|
|
{
|
|
sNo = arInf.GetAt(12);
|
|
}
|
|
|
|
ERoom room;
|
|
if (GetRoom(nRoomIndex, room))
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,11);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
|
|
AcGeVector3d vtX = room.ptGe[1] - room.ptGe[0];
|
|
vtX.normalize();
|
|
|
|
AcGeVector3d vtY = room.ptGe[2] - room.ptGe[1];
|
|
vtY.normalize();
|
|
|
|
ptGe[0] = MidPoint(room.ptGe[3],room.ptGe[2]);
|
|
ptGe[1] = ptGe[0] - vtY * dh;
|
|
ptGe[4] = ptGe[0] + vtX * 0.5 * dD;
|
|
ptGe[0] -= vtX * 0.5 * dD;
|
|
AcGeVector3d vtT = ptGe[1] - ptGe[0];
|
|
double dA = vtT.length();
|
|
vtT.normalize();
|
|
|
|
AcGeVector3d vtT2 = ptGe[1] - ptGe[4];
|
|
vtT2.normalize();
|
|
|
|
ptGe[1] = ptGe[0] + vtT * (dA - 0.5 * dD);
|
|
ptGe[2] = ptGe[0];
|
|
ptGe[0] = ptGe[1];
|
|
ptGe[1] = ptGe[2];
|
|
ptGe[2] = ptGe[1] + vtX * dD;
|
|
ptGe[3] = ptGe[2] + vtT2 * (dA - 0.5 * dD);
|
|
|
|
AlongRoomSide(ptGe[1],nRoomIndex,vtY);
|
|
AlongRoomSide(ptGe[2],nRoomIndex,vtY);
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptGe[0] = ptGe[3] + vtT2 * 0.5 * dD;
|
|
AcDbCircle* pCir = new AcDbCircle;
|
|
pCir->setCenter(ptGe[0]);
|
|
pCir->setRadius(0.5 * dD);
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
pCir->setColorIndex(kGreen);
|
|
arEntPtrs.append(pCir);
|
|
|
|
ptGe[0] -= vtY * 0.5 * dD;
|
|
ptGe[0] -= vtY * 0.12;
|
|
|
|
//文字
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
pText->setPosition(ptGe[0]);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sName + _T("-编号:") + sNo);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptGe[0]);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateGasAlarmSection(LPCTSTR pszScript, AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//GASALARM:房间|位置|高度|长|宽|厚|间距|名称|等级|型号|厂家|偏移
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_GASALARM);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript, arInf, _T('|'));
|
|
|
|
if (arInf.GetSize() >= 11)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nPos = _ttoi(arInf.GetAt(1));
|
|
|
|
double dH = _ttof(arInf.GetAt(2));
|
|
double dl = _ttof(arInf.GetAt(3));
|
|
double dw = _ttof(arInf.GetAt(4));
|
|
double dt = _ttof(arInf.GetAt(5));
|
|
|
|
CString sName = arInf.GetAt(7);
|
|
|
|
CString sNo(_T(""));
|
|
if (arInf.GetSize() >= 13)
|
|
{
|
|
sNo = arInf.GetAt(12);
|
|
}
|
|
|
|
ERoom room;
|
|
if (GetRoom(nRoomIndex, room))
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,11);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
|
|
AcGeVector3d vtX = room.ptGe[1] - room.ptGe[0];
|
|
vtX.normalize();
|
|
|
|
AcGeVector3d vtY = room.ptGe[2] - room.ptGe[1];
|
|
vtY.normalize();
|
|
|
|
if (nPos > 0) vtX.negate();
|
|
|
|
ptGe[0] = (nPos == 0) ? room.ptGe[0] : room.ptGe[1];
|
|
ptGe[0] += vtY * dH;
|
|
ptGe[1] = ptGe[0] + dw * vtY;
|
|
ptGe[2] = ptGe[1] + dt * vtX;
|
|
ptGe[3] = ptGe[0] + dt * vtX;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptGe[2] = MidPoint(ptGe[0], ptGe[3]);
|
|
ptGe[2] -= vtX * 0.25 * dt;
|
|
ptGe[1] = ptGe[2] + vtX * 0.5 * dt;
|
|
ptGe[0] = ptGe[1] - vtY * dt;
|
|
ptGe[3] = ptGe[2] - vtY * dt;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptGe[0] -= vtY * dt;
|
|
ptGe[0] -= vtY * 0.12;
|
|
if (nPos > 0)
|
|
{
|
|
ptGe[0] += vtX * dl;
|
|
}
|
|
|
|
//文字
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
pText->setPosition(ptGe[0]);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sName + _T("-编号:") + sNo);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptGe[0]);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateBomAddSection(LPCTSTR pszScript, AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
return 0;//没有底部壁厚增加
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateRoomSlabSection(LPCTSTR pszScript, AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
return 0;//没有专门的分舱
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateRoomNameSection(LPCTSTR pszScript, AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//ROOMNAME: 房间|中心x|中心y|名称 -->x,y放大100倍
|
|
//<ROOMNAME:%d|%d|%d|%s>
|
|
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_ROOMNAME);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript, arInf, _T('|'));
|
|
|
|
AcGePoint3d ptPos;
|
|
if (arInf.GetSize() >= 4)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
double dX = _ttoi(arInf.GetAt(1)) * 0.01;
|
|
double dY = _ttoi(arInf.GetAt(2)) * 0.01;
|
|
CString sName = arInf.GetAt(3);
|
|
|
|
AcGePoint3d ptPos(dX,dY,0.0);
|
|
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.175);
|
|
pText->setPosition(ptPos);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sName);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptText);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateSmokAlarmSection(LPCTSTR pszScript,AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//SMOKALARM:房间|位置|间距|外径|高度|名称|编号|规格|厂家|偏移
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_SMOKALARM);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript, arInf, _T('|'));
|
|
|
|
if (arInf.GetSize() >= 10)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
double dX = _ttof(arInf.GetAt(1));
|
|
double dD = _ttof(arInf.GetAt(3));
|
|
double dH = _ttof(arInf.GetAt(4));
|
|
CString sName = arInf.GetAt(5);
|
|
|
|
CString sNo(_T(""));
|
|
if (arInf.GetSize() >= 11)
|
|
{
|
|
sNo = arInf.GetAt(10);
|
|
}
|
|
|
|
ERoom room;
|
|
if (GetRoom(nRoomIndex, room))
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,9);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
|
|
AcGeVector3d vtX = room.ptGe[1] - room.ptGe[0];
|
|
vtX.normalize();
|
|
|
|
AcGeVector3d vtY = room.ptGe[2] - room.ptGe[1];
|
|
vtY.normalize();
|
|
|
|
ptGe[0] = room.ptGe[3];
|
|
ptGe[0] += vtX * dX;
|
|
ptGe[0] -= vtX * 0.5 * AS_MUNIT(dD);
|
|
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1] += vtX * AS_MUNIT(dD);
|
|
|
|
AlongRoomSide(ptGe[0],nRoomIndex,vtY);
|
|
AlongRoomSide(ptGe[1],nRoomIndex,vtY);
|
|
double dYmin = __min(ptGe[0].y,ptGe[1].y);
|
|
ptGe[0].y = dYmin;ptGe[1].y = dYmin;
|
|
|
|
ptGe[2] = ptGe[1] - vtY * 0.5 * AS_MUNIT(dH);
|
|
ptGe[3] = ptGe[2] - vtX * AS_MUNIT(dD);
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
//竖撑
|
|
AcGePoint3d ptGeH[2];
|
|
ptGeH[0] = MidPoint(ptGe[0],ptGe[1]);
|
|
ptGeH[1] = ptGeH[0];
|
|
AlongRoomSide(ptGeH[1],nRoomIndex,vtY);
|
|
pPl = new AcDbPolyline;
|
|
pPl->addVertexAt(0, ptGeH[0].convert2d(AcGePlane::kXYPlane));
|
|
pPl->addVertexAt(1, ptGeH[1].convert2d(AcGePlane::kXYPlane));
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptGe[0] = MidPoint(ptGe[2],ptGe[3]);
|
|
ptGe[0] -= vtX * 0.25 * AS_MUNIT(dD);
|
|
ptGe[1] = ptGe[0] + vtX * 0.5 * AS_MUNIT(dD);
|
|
ptGe[2] = ptGe[1] - vtY * 0.5 * AS_MUNIT(dH);
|
|
ptGe[3] = ptGe[0] - vtY * 0.5 * AS_MUNIT(dH);
|
|
ptGe[4] = ptGe[0];
|
|
|
|
pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptGe[0] = MidPoint(ptGe[2],ptGe[3]);
|
|
ptGe[0] -= vtY * 0.15;
|
|
//文字
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
pText->setPosition(ptGe[0]);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sName + _T("-编号:") + sNo);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptGe[0]);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateTempAlarmSection(LPCTSTR pszScript,AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//TEMPALARM:房间|左右侧|位置|间距|宽度|高度|厚度|名称|编号|规格|厂家|偏移
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_TEMPALARM);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript, arInf, _T('|'));
|
|
|
|
if (arInf.GetSize() >= 12)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nPos = _ttoi(arInf.GetAt(1));
|
|
|
|
double dY = _ttof(arInf.GetAt(2));
|
|
double dW = _ttof(arInf.GetAt(4));
|
|
double dH = _ttof(arInf.GetAt(5));
|
|
double dt = _ttof(arInf.GetAt(6));
|
|
CString sName = arInf.GetAt(7);
|
|
|
|
CString sNo(_T(""));
|
|
if (arInf.GetSize() >= 13)
|
|
{
|
|
sNo = arInf.GetAt(12);
|
|
}
|
|
|
|
ERoom room;
|
|
if (GetRoom(nRoomIndex, room))
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,11);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
|
|
AcGeVector3d vtX = room.ptGe[1] - room.ptGe[0];
|
|
vtX.normalize();
|
|
|
|
AcGeVector3d vtY = room.ptGe[2] - room.ptGe[1];
|
|
vtY.normalize();
|
|
|
|
if (nPos > 0) vtX.negate();
|
|
|
|
ptGe[0] = nPos == 0 ? room.ptGe[3] : room.ptGe[2];
|
|
ptGe[0] -= vtY * dY;
|
|
AlongRoomSide(ptGe[0],nRoomIndex,vtX);
|
|
|
|
ptGe[1] = ptGe[0] + vtX * AS_MUNIT(dt);
|
|
ptGe[2] = ptGe[1] - vtY * AS_MUNIT(dH);
|
|
ptGe[3] = ptGe[0] - vtY * AS_MUNIT(dH);
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptGe[0] = ptGe[3] + 0.5 * vtX * AS_MUNIT(dt);
|
|
ptGe[1] = ptGe[0] - vtY * AS_MUNIT(dH);
|
|
|
|
pPl = new AcDbPolyline;
|
|
pPl->addVertexAt(0, ptGe[0].convert2d(AcGePlane::kXYPlane));
|
|
pPl->addVertexAt(1, ptGe[1].convert2d(AcGePlane::kXYPlane));
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptGe[0] = MidPoint(ptGe[0],ptGe[1]);
|
|
|
|
//文字
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
pText->setPosition(ptGe[0]);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sName + _T("-编号:") + sNo);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptGe[0]);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateCoAlarmSection(LPCTSTR pszScript, AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//COALARM:房间|左右侧|位置|间距|宽度|高度|厚度|名称|浓度|偏移
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_COALARM);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript, arInf, _T('|'));
|
|
|
|
if (arInf.GetSize() >= 10)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nPos = _ttoi(arInf.GetAt(1));
|
|
|
|
double dY = _ttof(arInf.GetAt(2));
|
|
double dW = _ttof(arInf.GetAt(4));
|
|
double dH = _ttof(arInf.GetAt(5));
|
|
double dt = _ttof(arInf.GetAt(6));
|
|
CString sName = arInf.GetAt(7);
|
|
|
|
CString sNo(_T(""));
|
|
if (arInf.GetSize() >= 12)
|
|
{
|
|
sNo = arInf.GetAt(11);
|
|
}
|
|
|
|
ERoom room;
|
|
if (GetRoom(nRoomIndex, room))
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,10);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
|
|
AcGeVector3d vtX = room.ptGe[1] - room.ptGe[0];
|
|
vtX.normalize();
|
|
|
|
AcGeVector3d vtY = room.ptGe[2] - room.ptGe[1];
|
|
vtY.normalize();
|
|
|
|
if (nPos > 0) vtX.negate();
|
|
|
|
ptGe[0] = nPos == 0 ? room.ptGe[3] : room.ptGe[2];
|
|
ptGe[0] -= vtY * dY;
|
|
AlongRoomSide(ptGe[0],nRoomIndex,vtX);
|
|
|
|
ptGe[1] = ptGe[0] + vtX * AS_MUNIT(dt);
|
|
ptGe[2] = ptGe[1] - vtY * AS_MUNIT(dH);
|
|
ptGe[3] = ptGe[0] - vtY * AS_MUNIT(dH);
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptGe[0] = ptGe[3] + 0.5 * vtX * AS_MUNIT(dt);
|
|
ptGe[1] = ptGe[0] - vtY * AS_MUNIT(dH);
|
|
|
|
pPl = new AcDbPolyline;
|
|
pPl->addVertexAt(0, ptGe[0].convert2d(AcGePlane::kXYPlane));
|
|
pPl->addVertexAt(1, ptGe[1].convert2d(AcGePlane::kXYPlane));
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptGe[0] = MidPoint(ptGe[0],ptGe[1]);
|
|
|
|
//文字
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
pText->setPosition(ptGe[0]);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sName + _T("-编号:") + sNo);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptGe[0]);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CreateOxAlarmSection(LPCTSTR pszScript,AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
//OXALARM:房间|左右侧|位置|间距|宽度|高度|厚度|名称|采样方式|测量精度|厂家|偏移
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_OXALARM);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript, arInf, _T('|'));
|
|
|
|
if (arInf.GetSize() >= 12)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nPos = _ttoi(arInf.GetAt(1));
|
|
|
|
double dY = _ttof(arInf.GetAt(2));
|
|
double dW = _ttof(arInf.GetAt(4));
|
|
double dH = _ttof(arInf.GetAt(5));
|
|
double dt = _ttof(arInf.GetAt(6));
|
|
CString sName = arInf.GetAt(7);
|
|
|
|
CString sNo(_T(""));
|
|
if (arInf.GetSize() >= 13)
|
|
{
|
|
sNo = arInf.GetAt(12);
|
|
}
|
|
|
|
ERoom room;
|
|
if (GetRoom(nRoomIndex, room))
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,11);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
|
|
AcGeVector3d vtX = room.ptGe[1] - room.ptGe[0];
|
|
vtX.normalize();
|
|
|
|
AcGeVector3d vtY = room.ptGe[2] - room.ptGe[1];
|
|
vtY.normalize();
|
|
|
|
if (nPos > 0) vtX.negate();
|
|
|
|
ptGe[0] = nPos == 0 ? room.ptGe[3] : room.ptGe[2];
|
|
ptGe[0] -= vtY * dY;
|
|
AlongRoomSide(ptGe[0],nRoomIndex,vtX);
|
|
|
|
ptGe[1] = ptGe[0] + vtX * AS_MUNIT(dt);
|
|
ptGe[2] = ptGe[1] - vtY * AS_MUNIT(dH);
|
|
ptGe[3] = ptGe[0] - vtY * AS_MUNIT(dH);
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptGe[0] = MidPoint(ptGe[2],ptGe[3]);
|
|
ptGe[0] -= vtX * 0.25 * AS_MUNIT(dt);
|
|
ptGe[1] = ptGe[0] + vtX * 0.5 * AS_MUNIT(dt);
|
|
ptGe[2] = ptGe[1] - vtY * 2 * AS_MUNIT(dt);
|
|
ptGe[3] = ptGe[0] - vtY * 2 * AS_MUNIT(dt);
|
|
ptGe[4] = ptGe[0];
|
|
|
|
pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setColorIndex(kGreen);
|
|
arEntPtrs.append(pPl);
|
|
|
|
ptGe[0] = MidPoint(ptGe[1],ptGe[2]);
|
|
|
|
//文字
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setTextStyle(acdbCurDwg()->textstyle());
|
|
pText->setHeight(0.06);
|
|
pText->setPosition(ptGe[0]);
|
|
pText->setRotation(0.0);
|
|
pText->setTextString(sName + _T("-编号:") + sNo);
|
|
pText->setColorIndex(kGreen);
|
|
//pText->setAlignmentPoint(ptGe[0]);
|
|
//pText->setHorizontalMode(AcDb::kTextMid);
|
|
arEntPtrs.append(pText);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::CalEarthWork() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if ( m_arRoadCenPts.length() == 0)
|
|
{
|
|
acutPrintf(_T("\n没有设置道路中心线,计算土方失败!"));
|
|
return -1;//没有道路中心线
|
|
}
|
|
|
|
AcDbCurve* pRoadLine = GetRoadCenline(true);
|
|
if (pRoadLine == NULL)
|
|
return 0;
|
|
|
|
AcDbCurve* pOldRoadLine = GetOldRoadCenline(true);
|
|
if (pOldRoadLine == NULL)
|
|
{
|
|
struct resbuf rb;
|
|
acedGetVar(_T("useri3"),&rb);
|
|
if (rb.resval.rint == 1357)//特定情况下,提取表格数据
|
|
{
|
|
AcDbEntity* pCln = (AcDbEntity*)pOldRoadLine->clone();
|
|
pCln->setColorIndex(kMagenta);
|
|
AddToModelSpace(pCln);
|
|
}
|
|
pOldRoadLine = pRoadLine;
|
|
}
|
|
|
|
AecDb3dRoadAxisLine* pRoadAxln = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadAxln == NULL)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
//上次清空
|
|
g_arSHELongParams.removeAll();
|
|
|
|
//两侧拓宽,和下多挖
|
|
AecDbObjXDataMap xDataMap;
|
|
KTModelLayoutXData::ReadModelXData(EW_EARTHWORMINIT, xDataMap, NULL);
|
|
double _dX(.0), _dH(.0);
|
|
xDataMap.GetAt(_T("m_dX"), _dX);
|
|
xDataMap.GetAt(_T("m_dH"), _dH);
|
|
|
|
AcGePoint3d ptSta,ptEnd,ptOn;
|
|
AcDbObjectId id;
|
|
double dLen = 0.0,dArea = 0.0;
|
|
double dVol = 0.0,dVolLast = 0.0,dVolThisAll = 0.0;
|
|
AcDbEntity* pEnt = NULL;
|
|
AcGeVector3d vtDir;
|
|
AcDbExtents ext;
|
|
|
|
//1.开始点数据
|
|
ELongParam lPa;
|
|
memset(&lPa,0,sizeof(ELongParam));
|
|
|
|
_tcscpy(lPa.szNodeSpec,_T(" "));
|
|
_tcscpy(lPa.szStake,_T("Start"));
|
|
_tcscpy(lPa.szIDlock,_T("Start"));
|
|
lPa.idOwner = objectId();
|
|
lPa.dDistLen = 0.0;
|
|
lPa.dDistStakeLen = 0.0;
|
|
|
|
AcGePoint2d ptrODtTop,ptrODtBom;
|
|
pRoadAxln->getStartPoint(ptSta);
|
|
|
|
//获取垂直切外径和上下壁厚度
|
|
GetODAndID(ptrODtTop,ptrODtBom);
|
|
|
|
//现状地面高程
|
|
Acad::ErrorStatus es;
|
|
if (pOldRoadLine != NULL)
|
|
{
|
|
es = pOldRoadLine->getClosestPointTo(ptSta,AcGeVector3d::kZAxis,ptOn);
|
|
lPa.dRoadEl = ptOn.z;
|
|
}
|
|
|
|
//设计地面高程
|
|
if (pRoadLine != NULL)
|
|
{
|
|
es = pRoadLine->getClosestPointTo(ptSta,AcGeVector3d::kZAxis,ptOn);
|
|
lPa.dRoadDesEl = ptOn.z;
|
|
}
|
|
|
|
AcGePoint2d ptEl;
|
|
GetRoofAndBoomElAtPoint(ptSta,ptEl);
|
|
lPa.dRoofEl = ptEl.x;
|
|
lPa.dFloorEl = ptEl.y + ptrODtBom.y;
|
|
|
|
if (m_arStackPts.isEmpty())
|
|
{
|
|
pRoadAxln->getEndPoint(ptOn);
|
|
}
|
|
else
|
|
{
|
|
const EWStackPoint& sp1 = m_arStackPts.at(1);
|
|
pRoadAxln->getClosestPointTo(sp1.ptPos,ptOn);
|
|
}
|
|
if (fabs(ptOn.x - ptSta.x) > 1.e-6)
|
|
{
|
|
lPa.dGradient = (ptOn.z - ptSta.z) / fabs((ptOn.x - ptSta.x)) * 100.0;
|
|
}
|
|
|
|
g_arSHELongParams.append(lPa);
|
|
|
|
//2.后续数据---------------------------------------------
|
|
//arIds 已经排序
|
|
double dEVolCover = 0.0; //管廊覆土
|
|
double dDigVol = 0.0; //挖土,如果是从地面开挖
|
|
double dShEwVol = 0.0; //管廊体积,指盾构体积
|
|
double dSub = 0.0,dH = 0.0,dW = 0.0,dHOld = 0.0,dHDes = 0.0;
|
|
|
|
//折算为宽
|
|
AcDbExtents extSect;
|
|
m_pRegion->getGeomExtents(extSect);
|
|
dW = extSect.maxPoint().x - extSect.minPoint().x;
|
|
dH = extSect.maxPoint().y - extSect.minPoint().y;
|
|
dArea = CalBigRegionArea();
|
|
|
|
//放大系数
|
|
double dAreaExt = (dH + 2.0 * _dH) * (dW + 2.0 * _dX);
|
|
double dAreaFact = dAreaExt / (dW * dH);
|
|
dArea *= dAreaFact;
|
|
|
|
memset(&lPa,0,sizeof(ELongParam));
|
|
lPa.idOwner = objectId();
|
|
|
|
int nCount = 0;
|
|
double dElBom = 0.0;
|
|
|
|
pRoadAxln = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadAxln != NULL)
|
|
{
|
|
for (int j = 0;j < m_arStackPts.length();j++)
|
|
{
|
|
const EWStackPoint& sp = m_arStackPts.at(j);
|
|
|
|
//现状地面高程
|
|
if (pOldRoadLine != NULL)
|
|
{
|
|
pOldRoadLine->getClosestPointTo(sp.ptPos,AcGeVector3d::kZAxis,ptOn);
|
|
lPa.dRoadEl = ptOn.z;
|
|
}
|
|
|
|
//设计地面高程
|
|
if (pRoadLine != NULL)
|
|
{
|
|
pRoadLine->getClosestPointTo(sp.ptPos,AcGeVector3d::kZAxis,ptOn);
|
|
lPa.dRoadDesEl = ptOn.z;
|
|
}
|
|
|
|
//节点距离开始长度
|
|
pRoadAxln->getClosestPointTo(sp.ptPos,AcGeVector3d::kZAxis,ptOn);
|
|
pRoadAxln->getDistAtPoint(ptOn,dLen);
|
|
|
|
GetRoofAndBoomElAtPoint(ptOn,ptEl);
|
|
lPa.dRoofEl = ptEl.x;
|
|
lPa.dFloorEl = ptEl.y + ptrODtBom.y;
|
|
|
|
lPa.dDistLen = dLen;
|
|
lPa.dDistStakeLen = dLen;
|
|
|
|
//盾构累积体积
|
|
dShEwVol += dArea * dLen;//盾构累积体积
|
|
|
|
//积分计算计算挖土//dDigVol,每1米单元累积
|
|
if (pOldRoadLine != NULL)
|
|
{
|
|
nCount = (int)(dLen / 1.0);
|
|
dSub = dLen = nCount * 1.0;//余下
|
|
|
|
for (int k = 0;k < nCount;k++)
|
|
{
|
|
pRoadAxln->getPointAtDist(k+1,ptOn);
|
|
|
|
GetRoofAndBoomElAtPoint(ptOn,ptEl);
|
|
|
|
dElBom = ptEl.x;//底部标高
|
|
dHOld = lPa.dRoadEl - dElBom;//总高 = 现状地面高程 - 底部标高
|
|
dEVolCover += dHOld * dW * 1.0;//微分体积 = 总高x总宽x1米
|
|
}
|
|
|
|
//挖土累积余下 + 总高 * 总宽 * 余下部分长
|
|
dDigVol += dHOld * dW * dSub;
|
|
}
|
|
|
|
lPa.dDigVol = dDigVol;//挖土土方
|
|
lPa.dShEwVol = dShEwVol;//盾构土方
|
|
lPa.dEVolCover = dDigVol - dShEwVol;//覆土土方 = 总挖体积-管廊体积
|
|
|
|
_tcscpy(lPa.szStake,sp.szStake);
|
|
_tcscpy(lPa.szIDlock,sp.szRever);
|
|
if (sp.pFnNode != NULL)
|
|
{
|
|
_tcscpy(lPa.szNodeSpec,sp.pFnNode->szNodeSpec);
|
|
}
|
|
g_arSHELongParams.append(lPa);
|
|
}
|
|
}
|
|
|
|
//3.结尾点数据
|
|
memset(&lPa,0,sizeof(ELongParam));
|
|
_tcscpy(lPa.szNodeSpec,_T(" "));
|
|
_tcscpy(lPa.szStake,_T("End"));
|
|
_tcscpy(lPa.szIDlock,_T("End"));
|
|
lPa.idOwner = objectId();
|
|
lPa.dDistLen = GetLength();
|
|
lPa.dDistStakeLen = GetLength();
|
|
|
|
pRoadAxln->getEndPoint(ptSta);
|
|
GetRoofAndBoomElAtPoint(ptSta,ptEl);
|
|
lPa.dRoofEl = ptEl.x;
|
|
lPa.dFloorEl = ptEl.y + ptrODtBom.y;
|
|
|
|
pRoadAxln->getDistAtPoint(ptSta,dLen);
|
|
dShEwVol = dArea * dLen;
|
|
|
|
GetRoofAndBoomElAtPoint(ptSta,ptEl);
|
|
lPa.dRoofEl = ptEl.x;
|
|
lPa.dFloorEl = ptEl.y + ptrODtBom.y;
|
|
|
|
nCount = (int)(dLen / 1.0);
|
|
dSub = dLen = nCount * 1.0;//余下
|
|
|
|
dEVolCover = 0.0;
|
|
dDigVol = 0.0;
|
|
for (int k = 0;k < nCount;k++)
|
|
{
|
|
pRoadAxln->getPointAtDist(k+1,ptOn);
|
|
|
|
GetRoofAndBoomElAtPoint(ptOn,ptEl);
|
|
|
|
dElBom = ptEl.x;
|
|
dHOld = lPa.dRoadEl - dElBom;
|
|
dEVolCover += dHOld * dW * 1.0;
|
|
}
|
|
dDigVol += dHOld * dW * dSub;
|
|
|
|
lPa.dDigVol = dDigVol;
|
|
lPa.dShEwVol = dShEwVol;
|
|
lPa.dEVolCover = dDigVol - dShEwVol;//总挖体积-管廊体积
|
|
lPa.idOwner = objectId();
|
|
g_arSHELongParams.append(lPa);
|
|
|
|
if (pRoadLine != NULL)
|
|
DELETE_PTR(pRoadLine);
|
|
|
|
if (pRoadLine != pOldRoadLine && pOldRoadLine != NULL)
|
|
DELETE_PTR(pOldRoadLine);
|
|
|
|
return (int)g_arSHELongParams.length();
|
|
}
|
|
|
|
extern double GetMaxPointToCen(AcDbRay& rayTop,const AcDbVoidPtrArray& arCurPtrs,const AcGePoint3d& ptCen);
|
|
|
|
int AecDbShEarthWorm::GetEWStackPointOn(const AcGePoint3d& ptPos) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptOn;
|
|
int nIndex = -1;
|
|
AecDb3dRoadAxisLine* pRoadLn = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadLn != NULL)
|
|
{
|
|
if ( -1 != (nIndex = pRoadLn->getClosestPointToIndex(ptPos,ptOn) ) )
|
|
{
|
|
}
|
|
}
|
|
return nIndex;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::CreateAddtion3d(AcDbVoidPtrArray& arOther3dPtrs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
CString sScr;
|
|
if (m_mapSpecXData.GetAt(KEY_ADDTIONSCR,sScr) )
|
|
{
|
|
//解析附属物脚本
|
|
int nPos = sScr.Find(_T("EXT:"));
|
|
if (nPos != -1)
|
|
{
|
|
//EXT:
|
|
if (nPos + 4 < sScr.GetLength() )
|
|
{
|
|
CString sExt = sScr.Mid(nPos + 4);
|
|
//<><><><><><>.....
|
|
CString sScript;
|
|
|
|
int nSta = 0,nPos2 = 0;
|
|
nPos = sExt.Find(_T('<'),nSta);
|
|
while(nPos != -1)
|
|
{
|
|
nPos2 = sExt.Find(_T('>'),nPos + 1);
|
|
if (nPos2 == -1)
|
|
break;
|
|
|
|
//..<***>...
|
|
sScript = sExt.Mid(nPos + 1,nPos2 - nPos - 1);
|
|
|
|
if (sScript.Find( EW_HOLDER ) != -1)
|
|
{
|
|
CreateHolder3d(sScript,arOther3dPtrs);
|
|
}
|
|
else if (sScript.Find(EW_BOSS) != -1)
|
|
{
|
|
CreateBoss3d(sScript,arOther3dPtrs);
|
|
}
|
|
else if (sScript.Find( EW_HANGER ) != -1)
|
|
{
|
|
CreateHanger3d(sScript,arOther3dPtrs);
|
|
}
|
|
else if (sScript.Find(EW_RINGS) != -1)
|
|
{
|
|
//CreateRingsSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_LAMPS) != -1)
|
|
{
|
|
//CreateLampsSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_FIREET) != -1)
|
|
{
|
|
//CreateFileEETSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_GUTTERWAY) != -1)
|
|
{
|
|
//CreateGutterwaySection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_FIREDOOR) != -1)
|
|
{
|
|
//CreateFireDoorSection(sScript, arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_SECURITY) != -1)
|
|
{
|
|
//CreateSecuritySection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_DRAFAN) != -1)
|
|
{
|
|
//CreateDraFanSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_GASALARM) != -1)
|
|
{
|
|
//CreateGasAlarmSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_ROOMSLAB) != -1)
|
|
{
|
|
//CreateRoomSlabSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_ROOMNAME) != -1)
|
|
{
|
|
//CreateRoomNameSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_SMOKALARM) != -1)
|
|
{
|
|
//CreateSmokAlarmSection(sScript,arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_TEMPALARM) != -1)
|
|
{
|
|
//CreateTempAlarmSection(sScript, arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_COALARM) != -1)
|
|
{
|
|
//CreateCoAlarmSection(sScript, arEntPtrs);
|
|
}
|
|
else if (sScript.Find(EW_OXALARM) != -1)
|
|
{
|
|
//CreateOxAlarmSection(sScript, arEntPtrs);
|
|
}
|
|
nSta += sScript.GetLength();
|
|
nPos = sExt.Find(_T('<'),nSta);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDbRegion* createRegFromCurve(AcDbCurve* pCurve)
|
|
{
|
|
AcDbVoidPtrArray arCurPtrs,arRegPtrs;
|
|
arCurPtrs.append(pCurve);
|
|
|
|
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
|
|
|
AcDbRegion* pRegion = NULL;
|
|
if (arRegPtrs.length())
|
|
{
|
|
pRegion = (AcDbRegion*)arRegPtrs.first();
|
|
}
|
|
return pRegion;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::IsUserStackPointHear(const AcGePoint3d& ptPos) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//5米范围避让
|
|
const double s_dSpace = 5.0;//
|
|
for (int i = 0;i < m_arStackPts.length();i++)
|
|
{
|
|
const EWStackPoint& sp = m_arStackPts.at(i);
|
|
|
|
if ( fabs( sp.ptPos.distanceTo(ptPos) - s_dSpace ) < 1.e-3)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//2.创建支架三维
|
|
Acad::ErrorStatus AecDbShEarthWorm::CreateHolder3d(LPCTSTR pszScript,AcDbVoidPtrArray& arOther3dPtrs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//HOLDER:房间|左右位置|层数|垂直间隙|水平间隙|距顶D|长度|宽度|厚度|材料|用途|偏移=(,,,)|编号
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_HOLDER);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript,arInf,_T('|'));
|
|
|
|
if (arInf.GetSize() >= 11)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nLRPos = _ttoi(arInf.GetAt(1));
|
|
int nRows = _ttoi(arInf.GetAt(2));
|
|
|
|
double dVSpace = _ttof(arInf.GetAt(3));
|
|
double dHSpace = _ttof(arInf.GetAt(4));
|
|
double dFrTop = _ttof(arInf.GetAt(5));
|
|
double dL = _ttof(arInf.GetAt(6));
|
|
double dW = _ttof(arInf.GetAt(7));
|
|
double dt = _ttof(arInf.GetAt(8));
|
|
CString sMa = arInf.GetAt(9);
|
|
CString sSpec = arInf.GetAt(10);
|
|
|
|
CString sNo = _T(""),sTemp;
|
|
if (arInf.GetSize() > 12)
|
|
{
|
|
sTemp = arInf.GetAt(12);
|
|
sNo.Format(_T("支架编号:%s"),sTemp);
|
|
}
|
|
|
|
ERoom room;
|
|
if ( GetRoom(nRoomIndex,room) )
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,11);
|
|
|
|
AcGePoint3d ptGe = nLRPos == 0 ? room.ptGe[3] : room.ptGe[2];
|
|
AcGeVector3d vtL = nLRPos == 0 ? AcGeVector3d::kXAxis : -AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtY = -AcGeVector3d::kYAxis;
|
|
AcGeVector3d vtV;
|
|
|
|
AcGePoint3d ptFr = ptGe + vtY * dFrTop;
|
|
AlongRoomSide(ptFr,nRoomIndex,vtL);
|
|
|
|
AcGePoint3d ptSta = ptFr;
|
|
AcGePoint3d ptL[5],ptPos,ptCen,ptl[5];
|
|
|
|
//用途对于高压的识别
|
|
CString sText = sSpec;
|
|
sText.MakeLower();
|
|
int nFr = sText.Find(_T('('));
|
|
int nTo = sText.Find(_T(')'),nFr);
|
|
int nXKv = 0;
|
|
if (nFr != -1 && nTo != -1)
|
|
{
|
|
sText = sSpec.Mid(nFr,nTo - nFr + 1);
|
|
sSpec = sSpec.Left(nFr);
|
|
sText.TrimLeft(_T('('));
|
|
sText.TrimRight(_T(')'));
|
|
|
|
if (_ttoi(sText) > 30)
|
|
{
|
|
nXKv = 1;
|
|
}
|
|
}
|
|
|
|
AcGePoint3d ptCenInRgn;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN,ptCenInRgn);
|
|
BOOL bShorDraw = FALSE;
|
|
m_mapSpecXData.GetAt(KEY_ADDTIONSHOW_SHORT,bShorDraw);
|
|
|
|
AcGeVector3d vtDir;
|
|
double dPos = 0.0;
|
|
double dLen = 0.0,dEnd = 0.0;
|
|
m_pBaseCurve->getEndParam(dEnd);
|
|
m_pBaseCurve->getDistAtParam(dEnd,dLen);
|
|
int nCols = (int)(dLen / dHSpace);
|
|
AcGeVector3d vtNormal(1,0,0);
|
|
|
|
Acad::ErrorStatus es;
|
|
for (int i = 0;i < nRows;i++)
|
|
{
|
|
AlongRoomSide(ptFr,nRoomIndex,vtL);
|
|
|
|
ptL[0] = ptFr;
|
|
ptL[1] = ptFr + vtL * AS_MUNIT(dL);
|
|
ptL[2] = ptL[1] + vtY * AS_MUNIT(dW);
|
|
ptL[3] = ptL[0] + vtY * AS_MUNIT(dW);
|
|
ptL[4] = ptL[0];
|
|
|
|
//绘制水平杆
|
|
AcDbPolyline* pPlRc = new AcDbPolyline;
|
|
pPlRc->setNormal(AcGeVector3d::kZAxis);
|
|
for (int k = 0;k < 5;k++)
|
|
{
|
|
pPlRc->addVertexAt(k,ptL[k].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
|
|
AcDbRegion* pRegionH = createRegFromCurve(pPlRc);
|
|
delete pPlRc;
|
|
|
|
//绘制三角斜边加强筋
|
|
ptl[0] = ptL[3];
|
|
ptl[0] += 0.1732 * vtY * AS_MUNIT(dL);
|
|
AlongRoomSide(ptl[0],nRoomIndex,vtL);
|
|
ptl[1] = ptL[3] + 0.3 * vtL * AS_MUNIT(dL);
|
|
|
|
vtV = ptl[1] - ptl[0];
|
|
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtV.normalize();
|
|
|
|
ptl[2] = ptl[1];
|
|
ptl[2] += vtV * AS_MUNIT(dW);
|
|
|
|
ptl[3] = ptl[0];
|
|
ptl[3] += vtV * AS_MUNIT(dW);
|
|
|
|
ptl[0] -= 0.5 * vtV * AS_MUNIT(dW);
|
|
ptl[1] -= 0.5 * vtV * AS_MUNIT(dW);
|
|
|
|
ptl[4] = ptl[0];
|
|
|
|
pPlRc = new AcDbPolyline;
|
|
pPlRc->setNormal(AcGeVector3d::kZAxis);
|
|
for (int k = 0;k < 5;k++)
|
|
{
|
|
pPlRc->addVertexAt(k,ptl[k].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
|
|
AcDbRegion* pRegionL = createRegFromCurve(pPlRc);
|
|
delete pPlRc;
|
|
|
|
if (pRegionH != NULL && pRegionL != NULL)
|
|
{
|
|
es = pRegionH->booleanOper(AcDb::kBoolUnite,pRegionL);
|
|
}
|
|
|
|
AcDb3dSolid* pSolid = NULL;
|
|
AcDbLine lnPath;
|
|
AcDbRegion* pRegionHCln = NULL;
|
|
AcDbRegion* pRegionLCln = NULL;
|
|
for (int j = 1;j < nCols;j++)
|
|
{
|
|
if (bShorDraw)
|
|
{
|
|
if ( j > 2 && i < (nCols - 2))
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ( j > 5 && i < (nCols - 5))
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
dPos = j * dHSpace;
|
|
m_pBaseCurve->getPointAtDist(dPos,ptPos);
|
|
|
|
//判断ptPos 附近是否有节点,如果有节点,则取消
|
|
if (IsUserStackPointHear(ptPos))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
m_pBaseCurve->getFirstDeriv(ptPos,vtNormal);
|
|
vtNormal.normalize();
|
|
|
|
if (pRegionH != NULL)
|
|
{
|
|
pRegionHCln = (AcDbRegion*)pRegionH->clone();
|
|
transfromRegion(pRegionHCln, ptCenInRgn, vtNormal, ptPos);
|
|
}
|
|
|
|
lnPath.setStartPoint(ptPos);
|
|
lnPath.setEndPoint(ptPos + vtNormal * AS_MUNIT(dW));
|
|
|
|
if (pRegionHCln != NULL)
|
|
{
|
|
pSolid = new AcDb3dSolid;
|
|
es = pSolid->extrudeAlongPath(pRegionHCln,&lnPath);
|
|
if ( Acad::eOk == es)
|
|
{
|
|
arOther3dPtrs.append(pSolid);
|
|
}
|
|
else
|
|
{
|
|
delete pSolid;
|
|
}
|
|
}
|
|
|
|
if (pRegionHCln != NULL) delete pRegionHCln;
|
|
pRegionHCln = NULL;
|
|
}
|
|
|
|
if (pRegionH != NULL) delete pRegionH;
|
|
pRegionH = NULL;
|
|
|
|
|
|
|
|
//下一个位置
|
|
ptFr += vtY * ( dVSpace + AS_MUNIT(dW));
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//3.创建支墩三维
|
|
Acad::ErrorStatus AecDbShEarthWorm::CreateBoss3d(LPCTSTR pszScript,AcDbVoidPtrArray& arOther3dPtrs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//BOSS: 房间|左右位置|侧间隙|水平间隙|宽|高|长|直径|用途|公称直径|壁厚|重量|管道材质|管道系统|颜色|线形|编号|支墩类型|偏移|行|间隙
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_BOSS);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript,arInf,_T('|'));
|
|
|
|
if (arInf.GetSize() >= 9)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nLRPos = _ttoi(arInf.GetAt(1));//米
|
|
double dPos = _ttof(arInf.GetAt(2));
|
|
double dXSpace = _ttof(arInf.GetAt(3));//米
|
|
double dW = _ttof(arInf.GetAt(4));
|
|
double dH = _ttof(arInf.GetAt(5));
|
|
double dL = _ttof(arInf.GetAt(6));
|
|
double dD = _ttof(arInf.GetAt(7));
|
|
CString sSpec = arInf.GetAt(8);
|
|
|
|
CString sNo(_T("0"));
|
|
if (arInf.GetSize() > 16)
|
|
sNo = arInf.GetAt(16);
|
|
|
|
int nKind = 0;
|
|
if (arInf.GetSize() > 17)
|
|
nKind = _ttoi(arInf.GetAt(17));
|
|
|
|
int nRows = 1;
|
|
if (arInf.GetSize() > 19)
|
|
nRows = _ttoi(arInf.GetAt(19));
|
|
|
|
double dSpace = 0.0;
|
|
if (arInf.GetSize() > 20)
|
|
dSpace = _ttof(arInf.GetAt(20));
|
|
|
|
AcGeVector3d vtDir;
|
|
double dLen = 0.0,dEnd = 0.0;
|
|
m_pBaseCurve->getEndParam(dEnd);
|
|
m_pBaseCurve->getDistAtParam(dEnd,dLen);
|
|
|
|
int nCols = (int)(dLen / dXSpace);
|
|
AcGeVector3d vtNormal(1,0,0);
|
|
|
|
BOOL bShorDraw = FALSE;
|
|
m_mapSpecXData.GetAt(KEY_ADDTIONSHOW_SHORT,bShorDraw);
|
|
|
|
ERoom room;
|
|
if ( GetRoom(nRoomIndex,room) )
|
|
{
|
|
//预留官位只能放在主舱室
|
|
//OffsetMapToSplitRoom(arInf,room, 18);
|
|
|
|
if (nLRPos == 1)//距离右侧,转换为距离左侧
|
|
{
|
|
dPos = room.ptGe[1].distanceTo(room.ptGe[0]) - dPos;
|
|
}
|
|
|
|
//if (!bOnlyAddBoss)
|
|
{
|
|
AcGePoint3d ptCen = room.ptGe[0];
|
|
AcGeVector3d vtDirX = room.ptGe[1] - room.ptGe[0];
|
|
vtDirX.normalize();
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
AcGePoint3d ptGe[10],ptPos;
|
|
|
|
ptGe[0] = room.ptGe[0];
|
|
ptGe[0] += (dPos - 0.5 * AS_MUNIT(dW) ) * vtDirX;
|
|
AlongRoomSide(ptGe[0],nRoomIndex,AcGeVector3d::kYAxis);
|
|
|
|
pPl->addVertexAt(0,ptGe[0].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[1] = ptGe[0] + AcGeVector3d::kYAxis * AS_MUNIT(dH);
|
|
pPl->addVertexAt(1,ptGe[1].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[2] = ptGe[1] + AS_MUNIT(dW) * vtDirX;
|
|
pPl->addVertexAt(2,ptGe[2].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[3] = ptGe[0] + AS_MUNIT(dW) * vtDirX;
|
|
AlongRoomSide(ptGe[3],nRoomIndex,AcGeVector3d::kYAxis);
|
|
pPl->addVertexAt(3,ptGe[3].convert2d(AcGePlane::kXYPlane));
|
|
|
|
double dLx = nKind == 0 ? AS_MUNIT(dL) : AS_MUNIT(50.0);
|
|
if (nKind == 0)//支墩
|
|
{
|
|
pPl->addVertexAt(4,ptGe[0].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
else//支架 角钢宽度示意 50mm
|
|
{
|
|
ptGe[4] = ptGe[3] - AS_MUNIT(50.0) * vtDirX;
|
|
pPl->addVertexAt(4,ptGe[4].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[5] = ptGe[2] - AS_MUNIT(50.0) * vtDirX;
|
|
ptGe[5] -= AcGeVector3d::kYAxis * AS_MUNIT(50.0);
|
|
pPl->addVertexAt(5,ptGe[5].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[6] = ptGe[1] + AS_MUNIT(50.0) * vtDirX;
|
|
ptGe[6] -= AcGeVector3d::kYAxis * AS_MUNIT(50.0);
|
|
pPl->addVertexAt(6,ptGe[6].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[7] = ptGe[0] + AS_MUNIT(50.0) * vtDirX;
|
|
pPl->addVertexAt(7,ptGe[7].convert2d(AcGePlane::kXYPlane));
|
|
|
|
pPl->addVertexAt(8,ptGe[0].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
|
|
AcGePoint3d ptCenInRgn;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN,ptCenInRgn);
|
|
|
|
Acad::ErrorStatus es;
|
|
AcDbRegion* pRegionA = createRegFromCurve(pPl);
|
|
if (pRegionA != NULL)
|
|
{
|
|
delete pPl;
|
|
pPl = NULL;
|
|
|
|
if (nKind > 0)
|
|
{
|
|
double dYMax = ptGe[0].y;
|
|
for (int k = 0;k < nRows;k++)
|
|
{
|
|
ptGe[0] += AcGeVector3d::kYAxis * AS_MUNIT(dSpace);
|
|
if (ptGe[0].y - dYMax > 1.e-10)
|
|
{
|
|
break;
|
|
}
|
|
|
|
pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
pPl->addVertexAt(0,ptGe[0].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[1] = ptGe[0] + AS_MUNIT(dW) * vtDirX;
|
|
pPl->addVertexAt(1,ptGe[1].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[2] = ptGe[1] + AcGeVector3d::kYAxis * AS_MUNIT(50.0);
|
|
pPl->addVertexAt(2,ptGe[2].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[3] = ptGe[0] + AcGeVector3d::kYAxis * AS_MUNIT(50.0);
|
|
pPl->addVertexAt(3,ptGe[3].convert2d(AcGePlane::kXYPlane));
|
|
|
|
ptGe[4] = ptGe[0];
|
|
pPl->addVertexAt(4,ptGe[4].convert2d(AcGePlane::kXYPlane));
|
|
|
|
AcDbRegion* pRegionL = createRegFromCurve(pPl);
|
|
if (pRegionL != NULL)
|
|
{
|
|
es = pRegionA->booleanOper(AcDb::kBoolUnite,pRegionL);
|
|
}
|
|
delete pPl;
|
|
pPl = NULL;
|
|
}
|
|
}
|
|
|
|
//创建体
|
|
AcDb3dSolid* pSolid = NULL;
|
|
AcDbLine lnPath;
|
|
AcDbRegion* pRegionHCln = NULL;
|
|
for (int j = 1;j < nCols;j++)
|
|
{
|
|
if (bShorDraw)
|
|
{
|
|
if ( j > 2 && j < nCols - 2)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
dPos = j * dXSpace;
|
|
m_pBaseCurve->getPointAtDist(dPos,ptPos);
|
|
|
|
//判断ptPos 附近是否有节点,如果有节点,则取消
|
|
if (IsUserStackPointHear(ptPos))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
m_pBaseCurve->getFirstDeriv(ptPos,vtNormal);
|
|
vtNormal.normalize();
|
|
|
|
lnPath.setStartPoint(ptPos);
|
|
lnPath.setEndPoint(ptPos + vtNormal * dLx);
|
|
|
|
if (pRegionA != NULL)
|
|
{
|
|
pRegionHCln = (AcDbRegion*)pRegionA->clone();
|
|
transfromRegion(pRegionHCln, ptCenInRgn, vtNormal, ptPos);
|
|
}
|
|
|
|
if (pRegionHCln != NULL)
|
|
{
|
|
pSolid = new AcDb3dSolid;
|
|
es = pSolid->extrudeAlongPath(pRegionHCln,&lnPath);
|
|
if ( Acad::eOk == es)
|
|
{
|
|
arOther3dPtrs.append(pSolid);
|
|
}
|
|
else
|
|
{
|
|
delete pSolid;
|
|
pSolid = NULL;
|
|
}
|
|
delete pRegionHCln;
|
|
pRegionHCln = NULL;
|
|
}
|
|
}
|
|
|
|
if (pRegionA != NULL) delete pRegionA;
|
|
pRegionA = NULL;
|
|
//AddToModelSpace(pRegionA);//????
|
|
}
|
|
|
|
if (pPl != NULL) delete pPl;
|
|
pPl = NULL;
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//4.创建吊架三维
|
|
Acad::ErrorStatus AecDbShEarthWorm::CreateHanger3d(LPCTSTR pszScript,AcDbVoidPtrArray& arOther3dPtrs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//HANGER:房间|层数|垂直间隙|水平间隙|左侧距离|距顶D|长度|宽度|厚度|材料|用途|偏移(,,,)
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_HANGER);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript,arInf,_T('|'));
|
|
|
|
if (arInf.GetSize() >= 11)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nRows = _ttoi(arInf.GetAt(1));
|
|
|
|
double dVSpace = _ttof(arInf.GetAt(2));//米
|
|
double dHSpace = _ttof(arInf.GetAt(3));//米
|
|
double dX = _ttof(arInf.GetAt(4));//米
|
|
double dFrTop = _ttof(arInf.GetAt(5));//米
|
|
|
|
double dL = _ttof(arInf.GetAt(6));//mm
|
|
double dW = _ttof(arInf.GetAt(7));//mm
|
|
double dt = _ttof(arInf.GetAt(8));//mm
|
|
|
|
CString sMa = arInf.GetAt(9);
|
|
CString sSpec = arInf.GetAt(10);
|
|
|
|
CString sNo = _T(""), sTemp;
|
|
if (arInf.GetSize() >= 13)
|
|
{
|
|
sTemp = arInf.GetAt(12);
|
|
sNo.Format(_T("吊架编号:%s"), sTemp);
|
|
}
|
|
|
|
AcGePoint3d ptCenInRgn;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN,ptCenInRgn);
|
|
|
|
AcGeVector3d vtDir;
|
|
double dPos = 0.0;
|
|
double dLen = 0.0,dEnd = 0.0;
|
|
m_pBaseCurve->getEndParam(dEnd);
|
|
m_pBaseCurve->getDistAtParam(dEnd,dLen);
|
|
int nCols = (int)(dLen / dHSpace);
|
|
AcGeVector3d vtNormal(1,0,0);
|
|
|
|
BOOL bShorDraw = FALSE;
|
|
m_mapSpecXData.GetAt(KEY_ADDTIONSHOW_SHORT,bShorDraw);
|
|
|
|
ERoom room;
|
|
if ( GetRoom(nRoomIndex,room) )
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,11);
|
|
|
|
AcGePoint3d ptGe = room.ptGe[3];
|
|
AcGeVector3d vtL = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtY = -AcGeVector3d::kYAxis;
|
|
AcGePoint3d ptFr = ptGe + vtL * dX;
|
|
//AlongRoomSide(ptFr,nRoomIndex,vtL);
|
|
|
|
AcGePoint3d ptSta = ptFr;
|
|
AcGePoint3d ptU[10],ptPos,ptCen,ptL[5],ptU2[10];
|
|
|
|
ptU[0] = ptFr;
|
|
ptU[1] = ptU[0] + vtY * ( (nRows - 1)* ( dVSpace + AS_MUNIT(dW) ) + dFrTop + AS_MUNIT(dW) );
|
|
ptU[2] = ptU[1] + vtL * AS_MUNIT(dL);
|
|
ptU[3] = ptU[0] + vtL * AS_MUNIT(dL);
|
|
|
|
ptU[4] = ptU[3] - vtL * AS_MUNIT(dW);
|
|
ptU[5] = ptU[4] + vtY * ( (nRows - 1)* ( dVSpace + AS_MUNIT(dW) ) + dFrTop );
|
|
ptU[6] = ptU[5] - vtL * (AS_MUNIT(dL) - 2.0 * AS_MUNIT(dW) );
|
|
ptU[7] = ptU[0] + vtL * AS_MUNIT(dW);
|
|
ptU[8] = ptU[0];
|
|
|
|
//3,4,7,8,0 备份
|
|
memcpy(ptU2,ptU,sizeof(AcGePoint3d) * 10);
|
|
AlongRoomSide(ptU[3],nRoomIndex,vtY);
|
|
AlongRoomSide(ptU[4],nRoomIndex,vtY);
|
|
AlongRoomSide(ptU[7],nRoomIndex,vtY);
|
|
AlongRoomSide(ptU[8],nRoomIndex,vtY);
|
|
AlongRoomSide(ptU[0],nRoomIndex,vtY);
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
for (int i = 0;i < 9;i++)
|
|
{
|
|
pPl->addVertexAt(i,ptU[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
AcDbRegion* pRegionH = createRegFromCurve(pPl);
|
|
delete pPl;
|
|
|
|
Acad::ErrorStatus es;
|
|
AcDbRegion* pRegionL = NULL;
|
|
memcpy(ptU,ptU2,sizeof(AcGePoint3d) * 10);
|
|
for (int k = 0;k < nRows - 1;k++)
|
|
{
|
|
ptL[0] = ptU[7] + vtY * ( k* dVSpace + dFrTop + k * AS_MUNIT(dW) );
|
|
ptL[1] = ptL[0] + vtL * (AS_MUNIT(dL) - 2.0 * AS_MUNIT(dW) );
|
|
|
|
ptL[2] = ptL[1] + vtY * AS_MUNIT(dW);
|
|
ptL[3] = ptL[0] + vtY * AS_MUNIT(dW);
|
|
ptL[4] = ptL[0];
|
|
|
|
pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
for (int ii = 0;ii < 5;ii++)
|
|
{
|
|
pPl->addVertexAt(ii,ptL[ii].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pRegionL = createRegFromCurve(pPl);
|
|
|
|
if (pRegionL != NULL)
|
|
{
|
|
es = pRegionH->booleanOper(AcDb::kBoolUnite,pRegionL);
|
|
}
|
|
delete pPl;
|
|
}
|
|
|
|
AcDb3dSolid* pSolid = NULL;
|
|
AcDbLine lnPath;
|
|
AcDbRegion* pRegionHCln = NULL;
|
|
AcDbRegion* pRegionLCln = NULL;
|
|
for (int j = 1;j < nCols;j++)
|
|
{
|
|
if (bShorDraw)
|
|
{
|
|
if (j > 2 && j < nCols - 2)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
dPos = j * dHSpace;
|
|
m_pBaseCurve->getPointAtDist(dPos,ptPos);
|
|
|
|
//判断ptPos 附近是否有节点,如果有节点,则取消
|
|
if (IsUserStackPointHear(ptPos))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
m_pBaseCurve->getFirstDeriv(ptPos,vtNormal);
|
|
vtNormal.normalize();
|
|
|
|
lnPath.setStartPoint(ptPos);
|
|
lnPath.setEndPoint(ptPos + vtNormal * AS_MUNIT(dW));
|
|
|
|
if (pRegionH != NULL)
|
|
{
|
|
pRegionHCln = (AcDbRegion*)pRegionH->clone();
|
|
transfromRegion(pRegionHCln, ptCenInRgn, vtNormal, ptPos);
|
|
}
|
|
|
|
if (pRegionHCln != NULL)
|
|
{
|
|
pSolid = new AcDb3dSolid;
|
|
es = pSolid->extrudeAlongPath(pRegionHCln,&lnPath);
|
|
if ( Acad::eOk == es)
|
|
{
|
|
arOther3dPtrs.append(pSolid);
|
|
}
|
|
else
|
|
{
|
|
delete pSolid;
|
|
pSolid = NULL;
|
|
}
|
|
delete pRegionHCln;
|
|
pRegionHCln = NULL;
|
|
}
|
|
}
|
|
|
|
if (pRegionH != NULL) delete pRegionH;
|
|
pRegionH = NULL;
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbShEarthWorm::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
////管线系统屏蔽掉
|
|
if ( dc.IsDragging() )
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
if (m_pBaseCurve == NULL)
|
|
return Acad::eInvalidInput;
|
|
|
|
//图层
|
|
AcDbObjectId idLay = dc.GetLayerId();
|
|
dc.SetLayer(layerId());
|
|
|
|
int nCrBk = dc.GetColor();
|
|
|
|
DrawInfArrow(dc);
|
|
|
|
int nColor = nCrBk;
|
|
if ( m_mapSpecXData.GetAt(_T("COLOR"),nColor) )
|
|
{
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
int nSegIndex = m_nInfActive / 2;
|
|
if (m_nInfActive < 0)
|
|
nSegIndex = -1;
|
|
|
|
if (Has3DBuffer())
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar3D = Get3DBuffer();
|
|
for (int i = 0;i < ar3D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar3D.at(i);
|
|
if (nSegIndex == i)//线缆段
|
|
{
|
|
pEnt->setColorIndex(kMagenta);
|
|
}
|
|
else
|
|
{
|
|
pEnt->setColorIndex(nColor);
|
|
}
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
|
|
dc.SetLayer(idLay);
|
|
dc.SetColor(nCrBk);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGePoint2d ptrODtTop,ptrODtBom;
|
|
GetODAndID(ptrODtTop,ptrODtBom);
|
|
|
|
AcDbVoidPtrArray arSubtract3dPtrs,arOther3dPtrs;
|
|
|
|
AcGePoint2d ptTopAndBomEl;
|
|
AcDb3dSolid* pSolidSubCell = NULL,*pPipeSolid = NULL;
|
|
|
|
AcDbVoidPtrArray arSolidPtrs;
|
|
int nCount = GetCreatPipe3dSolid(arSolidPtrs);
|
|
|
|
int nIndex = 0;
|
|
if (nCount > 0)
|
|
{
|
|
//1.和插入的节点做布尔运算
|
|
for (int i = 0; i < m_arStackPts.length();i++)
|
|
{
|
|
pSolidSubCell = NULL;
|
|
const EWStackPoint& sp = m_arStackPts.at(i);
|
|
|
|
nIndex = GetEWStackPointOn(sp.ptPos);
|
|
if (nIndex != -1 && nIndex < arSolidPtrs.length())
|
|
{
|
|
if (sp.pFnNode != NULL)
|
|
{
|
|
switch(sp.pFnNode->eFnType)
|
|
{
|
|
case kVerticalWell:
|
|
{
|
|
arSubtract3dPtrs.removeAll();
|
|
GetRoofAndBoomElAtPoint(sp.ptPos,ptTopAndBomEl);
|
|
CreateVerticalWell3d(sp,arSubtract3dPtrs,arOther3dPtrs,ptTopAndBomEl);
|
|
break;
|
|
}
|
|
case kProModel:
|
|
{
|
|
arSubtract3dPtrs.removeAll();
|
|
GetRoofAndBoomElAtPoint(sp.ptPos,ptTopAndBomEl);
|
|
CreateProModel3d(sp,arSubtract3dPtrs,arOther3dPtrs,ptTopAndBomEl);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
acutPrintf(_T("\nEWStack point not on roadaxis line..."));
|
|
}
|
|
}
|
|
}
|
|
|
|
//2.创建支架三维
|
|
const AecDbObjXDataMap* pXDataMap = GetSpecialtyData();
|
|
if (pXDataMap != NULL)
|
|
{
|
|
int nShow = 0;
|
|
pXDataMap->GetAt(KEY_ADDTIONSHOW,nShow);
|
|
if (nShow > 0)
|
|
{
|
|
CreateAddtion3d(arOther3dPtrs);
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
AcDb3dSolid* pSolid = NULL;
|
|
AcDb3dSolid* pSolidCln = NULL;
|
|
|
|
for (int k = 0;k < arSolidPtrs.length();k++)
|
|
{
|
|
pPipeSolid = (AcDb3dSolid*)arSolidPtrs.at(k);
|
|
for (int iii = 0;iii < arSubtract3dPtrs.length();iii++)
|
|
{
|
|
pSolid = (AcDb3dSolid*)arSubtract3dPtrs.at(iii);
|
|
|
|
pSolidCln = (AcDb3dSolid*)pSolid->clone();
|
|
es = pPipeSolid->booleanOper(AcDb::kBoolSubtract,pSolidCln);
|
|
}
|
|
}
|
|
FreeBuffer(0,arSubtract3dPtrs);
|
|
|
|
//绘制
|
|
for (int i = 0;i < arSolidPtrs.length();i++)
|
|
{
|
|
pSolid = (AcDb3dSolid*)arSolidPtrs.at(i);
|
|
assert(pSolid != NULL);
|
|
dc.DrawEntity(*pSolid);
|
|
Add3DBuffer(pSolid);
|
|
}
|
|
|
|
//其他绘制
|
|
for (int i = 0;i < arOther3dPtrs.length();i++)
|
|
{
|
|
pSolid = (AcDb3dSolid*)arOther3dPtrs.at(i);
|
|
assert(pSolid != NULL);
|
|
|
|
dc.DrawEntity(*pSolid);
|
|
Add3DBuffer(pSolid);
|
|
}
|
|
|
|
dc.SetLayer(idLay);
|
|
dc.SetColor(nCrBk);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//三维导出
|
|
int AecDbShEarthWorm::GetDraw3dables(AcDbVoidPtrArray& arEntPtrs,bool bWriteBimInfo) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (!Has3DBuffer())
|
|
{
|
|
AcGiViewDraw dc(NULL,NULL);
|
|
Draw3d(dc);
|
|
}
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbEntity* pEntClone = NULL;
|
|
const AcDbVoidPtrArray &ar3D = Get3DBuffer();
|
|
for (int i = 0;i < ar3D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar3D.at(i);
|
|
pEntClone = (AcDbEntity*)pEnt->clone();
|
|
pEntClone->setLayer(layerId());
|
|
if (bWriteBimInfo)
|
|
{
|
|
m_mapSpecXData.Write(pEntClone,_T("BIMDATA"),FALSE,TRUE);
|
|
}
|
|
arEntPtrs.append(pEntClone);
|
|
}
|
|
|
|
return arEntPtrs.length();
|
|
}
|
|
|
|
bool AecDbShEarthWorm::CreateVerticalWell3d(const EWStackPoint& sp,AcDbVoidPtrArray& arSubtract3dPtrs,AcDbVoidPtrArray& arOther3dPtrs,AcGePoint2d& ptTopAndBomEl ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptOn,ptOnBk;
|
|
AecDb3dRoadAxisLine* pRoadAx = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
pRoadAx->getClosestPointTo(sp.ptPos,ptOn);
|
|
ptOnBk = ptOn;
|
|
|
|
AcGeVector3d vtDir,vtDirBk;
|
|
pRoadAx->getFirstDeriv(ptOn,vtDir);
|
|
vtDirBk = vtDir;
|
|
vtDirBk.normalize();
|
|
|
|
if (sp.pFnNode != NULL)
|
|
{
|
|
if (sp.pFnNode->eFnType == kVerticalWell)
|
|
{
|
|
//float fNodeDef[64]; //节点尺寸
|
|
if (sp.pFnNode->nFlag == 0)//圆
|
|
{
|
|
double dD = sp.pFnNode->fNodeDef[0];//外径
|
|
double dt = sp.pFnNode->fNodeDef[1];//壁厚
|
|
double dH = sp.pFnNode->fNodeDef[2];//总高度
|
|
double dhb = sp.pFnNode->fNodeDef[3];//廊底下深深度,不含底厚度
|
|
double dBomt = sp.pFnNode->fNodeDef[4];//底厚度
|
|
double dOffY = sp.pFnNode->fNodeDef[5];//偏移位置
|
|
|
|
vtDir.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtDir.normalize();
|
|
ptOn += vtDir * dOffY;
|
|
|
|
AcGePoint3d ptCen = ptOn;
|
|
ptCen.z = ptTopAndBomEl.y;//底部标高
|
|
ptCen.z -= dhb;
|
|
ptCen.z -= dBomt;
|
|
|
|
AcDbCircle* pCir = new AcDbCircle;
|
|
pCir->setRadius(0.5 * dD);
|
|
pCir->setCenter(ptCen);
|
|
pCir->setNormal(AcGeVector3d::kZAxis);//垂直井
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
arCurPtrs.append(pCir);
|
|
|
|
AcDbLine lnPath;
|
|
lnPath.setStartPoint(ptCen);
|
|
lnPath.setEndPoint(ptCen + dH * AcGeVector3d::kZAxis);
|
|
|
|
AcDbVoidPtrArray arRegPtrs;
|
|
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
|
|
|
if (!arRegPtrs.isEmpty())
|
|
{
|
|
AcDb3dSolid* pSolidOD = NULL;
|
|
AcDbRegion* pRegion = (AcDbRegion*)arRegPtrs.first();
|
|
if (pRegion != NULL)
|
|
{
|
|
AcGeVector3d vtNorm;
|
|
pRegion->getNormal(vtNorm);
|
|
|
|
pSolidOD = new AcDb3dSolid;
|
|
pSolidOD->extrudeAlongPath(pRegion,&lnPath);
|
|
delete pRegion;
|
|
|
|
if (pSolidOD != NULL)
|
|
{
|
|
arSubtract3dPtrs.append(pSolidOD->clone());
|
|
}
|
|
}
|
|
|
|
arRegPtrs.removeAll();
|
|
|
|
ptCen = lnPath.startPoint();
|
|
ptCen.z += dBomt;
|
|
lnPath.setStartPoint(ptCen);
|
|
pCir->setRadius(0.5 * dD - dt);
|
|
pCir->setCenter(ptCen);
|
|
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
|
|
|
AcDb3dSolid* pSolidID = NULL;
|
|
if (!arRegPtrs.isEmpty())
|
|
{
|
|
pRegion = (AcDbRegion*)arRegPtrs.first();
|
|
if (pRegion != NULL)
|
|
{
|
|
pSolidID = new AcDb3dSolid;
|
|
pSolidID->extrudeAlongPath(pRegion,&lnPath);
|
|
delete pRegion;
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus es;
|
|
if (pSolidOD != NULL && pSolidID != NULL)
|
|
{
|
|
es = pSolidOD->booleanOper(AcDb::kBoolSubtract,pSolidID);
|
|
arOther3dPtrs.append(pSolidOD);
|
|
}
|
|
|
|
//腔体裁剪,速度慢暂注释掉
|
|
/*
|
|
AcDbRegion* pRegMax = GeCavityRegion();
|
|
if (pRegMax != NULL)
|
|
{
|
|
AcGePoint3d ptCen;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN,ptCen);
|
|
|
|
AecDbEwPipeBase dbPipe;
|
|
dbPipe.SetSection(pRegMax,ptCen);
|
|
lnPath.setStartPoint(ptOnBk - vtDirBk * 0.6 * dD);
|
|
lnPath.setEndPoint(ptOnBk + vtDirBk * 0.6 * dD);
|
|
dbPipe.SetBaseCurve(&lnPath);
|
|
|
|
AcDb3dSolid* pSolidPipe = dbPipe.GetCreatPipe3dSolid();
|
|
if (pSolidPipe != NULL)
|
|
{
|
|
es = pSolidOD->booleanOper(AcDb::kBoolSubtract,pSolidPipe);
|
|
arOther3dPtrs.append(pSolidOD);
|
|
}
|
|
}*/
|
|
}
|
|
delete pCir;
|
|
return true;
|
|
}
|
|
else//方井
|
|
{
|
|
double dL = sp.pFnNode->fNodeDef[0];//外长
|
|
double dW = sp.pFnNode->fNodeDef[1];//外宽
|
|
double dt = sp.pFnNode->fNodeDef[2];//壁厚
|
|
double dH = sp.pFnNode->fNodeDef[3];//总高度
|
|
double dhb = sp.pFnNode->fNodeDef[4];//廊底下深深度,不含底厚度
|
|
double dBomt = sp.pFnNode->fNodeDef[5];//底厚度
|
|
double dOffY = sp.pFnNode->fNodeDef[6];//偏移位置
|
|
|
|
vtDir.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtDir.normalize();
|
|
ptOn += vtDir * dOffY;
|
|
|
|
AcGePoint3d ptCen = ptOn;
|
|
ptCen.z = ptTopAndBomEl.y;//底部标高
|
|
ptCen.z -= dhb;
|
|
ptCen.z -= dBomt;
|
|
|
|
AcGeVector3d vtDirX;
|
|
pRoadAx->getFirstDeriv(ptOn,vtDirX);
|
|
vtDirX.z = 0.0;//井垂直放置,vtDir水平
|
|
|
|
AcGeVector3d vtDirY = vtDirX;
|
|
vtDirY.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtDirX.normalize();vtDirY.normalize();
|
|
|
|
AcDbLine* pLn1 = NULL;
|
|
|
|
AcGePoint3d ptGe[5];
|
|
ptGe[0] = ptCen;
|
|
ptGe[0] -= 0.5 * vtDirX * dL;
|
|
ptGe[0] += 0.5 * vtDirY * dW;
|
|
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1] += vtDirX * dL;
|
|
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2] -= vtDirY * dW;
|
|
|
|
ptGe[3] = ptGe[2];
|
|
ptGe[3] -= vtDirX * dL;
|
|
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
pLn1 = new AcDbLine(ptGe[i],ptGe[i+1]);
|
|
pLn1->setNormal(AcGeVector3d::kZAxis);
|
|
arCurPtrs.append(pLn1);
|
|
}
|
|
|
|
AcDbLine lnPath;
|
|
lnPath.setStartPoint(ptCen);
|
|
lnPath.setEndPoint(ptCen + dH * AcGeVector3d::kZAxis);
|
|
|
|
AcDbVoidPtrArray arRegPtrs;
|
|
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
|
|
|
if (!arRegPtrs.isEmpty())
|
|
{
|
|
AcDb3dSolid* pSolidOD = NULL;
|
|
AcDbRegion* pRegion = (AcDbRegion*)arRegPtrs.first();
|
|
if (pRegion != NULL)
|
|
{
|
|
pSolidOD = new AcDb3dSolid;
|
|
pSolidOD->extrudeAlongPath(pRegion,&lnPath);
|
|
delete pRegion;
|
|
|
|
if (pSolidOD != NULL)
|
|
{
|
|
arSubtract3dPtrs.append(pSolidOD->clone());
|
|
}
|
|
}
|
|
|
|
ptCen.z += dBomt;
|
|
lnPath.setStartPoint(ptCen);
|
|
|
|
ptGe[0] = ptCen;
|
|
ptGe[0] -= 0.5 * vtDirX * (dL - 2.0 * dt);
|
|
ptGe[0] += 0.5 * vtDirY * (dW - 2.0 * dt);
|
|
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1] += vtDirX * (dL - 2.0 * dt);
|
|
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2] -= vtDirY * (dW - 2.0 * dt);
|
|
|
|
ptGe[3] = ptGe[2];
|
|
ptGe[3] -= vtDirX * (dL - 2.0 * dt);
|
|
|
|
ptGe[4] = ptGe[0];
|
|
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
pLn1 = (AcDbLine*)arCurPtrs.at(i);
|
|
pLn1->setStartPoint(ptGe[i]);
|
|
pLn1->setEndPoint(ptGe[i+1]);
|
|
}
|
|
|
|
arRegPtrs.removeAll();
|
|
AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs);
|
|
|
|
AcDb3dSolid* pSolidID = NULL;
|
|
if (!arRegPtrs.isEmpty())
|
|
{
|
|
pRegion = (AcDbRegion*)arRegPtrs.first();
|
|
if (pRegion != NULL)
|
|
{
|
|
pSolidID = new AcDb3dSolid;
|
|
pSolidID->extrudeAlongPath(pRegion,&lnPath);
|
|
delete pRegion;
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus es;
|
|
if (pSolidOD != NULL && pSolidID != NULL)
|
|
{
|
|
es = pSolidOD->booleanOper(AcDb::kBoolSubtract,pSolidID);
|
|
if (es == Acad::eOk)
|
|
{
|
|
arOther3dPtrs.append(pSolidOD);
|
|
}
|
|
}
|
|
|
|
//腔体裁剪,速度慢暂注释掉
|
|
/*
|
|
AcDbRegion* pRegMax = GeCavityRegion();
|
|
if (pRegMax != NULL)
|
|
{
|
|
AcGePoint3d ptCen;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN,ptCen);
|
|
|
|
AecDbEwPipeBase dbPipe;
|
|
dbPipe.SetSection(pRegMax,ptCen);
|
|
lnPath.setStartPoint(ptOnBk - vtDirBk * 0.6 * dL);
|
|
lnPath.setEndPoint(ptOnBk + vtDirBk * 0.6 * dL);
|
|
dbPipe.SetBaseCurve(&lnPath);
|
|
|
|
Acad::ErrorStatus es;
|
|
AcDb3dSolid* pSolidPipe = dbPipe.GetCreatPipe3dSolid();
|
|
if (pSolidPipe != NULL)
|
|
{
|
|
es = pSolidOD->booleanOper(AcDb::kBoolSubtract,pSolidPipe);
|
|
arOther3dPtrs.append(pSolidOD);
|
|
}
|
|
}*/
|
|
|
|
FreeBuffer(0,arCurPtrs);
|
|
return true;
|
|
}
|
|
FreeBuffer(0,arCurPtrs);
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::CreateProModel3d(const EWStackPoint& sp,AcDbVoidPtrArray& arSubtract3dPtrs,AcDbVoidPtrArray& arOther3dPtrs,AcGePoint2d& ptTopAndBomEl ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (sp.pFnNode != NULL)
|
|
{
|
|
if (sp.pFnNode->pProModelBuffer == NULL)
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
EWFnctNode* pNext = sp.pFnNode;
|
|
|
|
AcGePoint3d ptOn;
|
|
AecDb3dRoadAxisLine* pRoadAx = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
Acad::ErrorStatus es = pRoadAx->getClosestPointTo(sp.ptPos,ptOn);
|
|
if (es != Acad::eOk)
|
|
{
|
|
acutPrintf(_T("\nClosestPointTo error : %d"),es);
|
|
return false;
|
|
}
|
|
|
|
AcGeVector3d vtDir;
|
|
pRoadAx->getFirstDeriv(ptOn,vtDir);
|
|
vtDir.normalize();
|
|
|
|
//ln和xy面的夹角
|
|
AcGeVector3d vtDirXY = vtDir.orthoProject(AcGeVector3d::kZAxis);
|
|
double dAngle = vtDirXY.angleTo(vtDir);
|
|
vtDirXY.normalize();
|
|
|
|
AcGePoint3d ptPos = ptOn;
|
|
vtDir.normalize();
|
|
|
|
double dL = 0.0,dW = 0.0,dH = 0.0;
|
|
|
|
AecDbEarthWormFitting fit;
|
|
AecDbEarthWormFitting* pFit = NULL;
|
|
|
|
std::map<CString,PVOID>::const_iterator it;
|
|
if (g_mapSHProMode2Fit.end() != ( it = g_mapSHProMode2Fit.find(pNext->szLockId) ) )
|
|
{
|
|
pFit = (AecDbEarthWormFitting*)(*it).second;
|
|
}
|
|
else
|
|
{
|
|
CMemFile file;
|
|
file.Attach((BYTE*)pNext->pProModelBuffer,pNext->nProModelBufLen);
|
|
fit.ReadFrom(&file);
|
|
pFit = &fit;
|
|
file.Detach();
|
|
}
|
|
|
|
if (pFit != NULL)
|
|
{
|
|
double dScale = 3.0;//放大系数
|
|
dL = pFit->GetLen();
|
|
|
|
if (m_pRegion == NULL)
|
|
return false;
|
|
|
|
AcDbExtents ext;
|
|
m_pRegion->getGeomExtents(ext);
|
|
dW = ext.maxPoint().x - ext.minPoint().x;//总宽
|
|
dH = ext.maxPoint().y - ext.minPoint().y;//总高
|
|
|
|
double dLeft(0.5 * pFit->GetLen());
|
|
pFit->GetSpecialtyData()->GetAt(_T("dLeft"),dLeft);
|
|
|
|
AcGePoint3d ptBreak = ptOn;
|
|
ptPos = ptOn;
|
|
ptBreak = ptOn;
|
|
ptBreak += 0.5 * dH * AcGeVector3d::kZAxis;
|
|
|
|
AcDbX3dSolid x3dSolid;
|
|
x3dSolid.Create(AcDbX3dSolid::kCylinder,ptBreak,vtDir,2,0.8 * __max(dH,dW),dL);
|
|
|
|
AcDb3dSolid* pSolidBreak = x3dSolid.GetDraw3dSolid();
|
|
if (pSolidBreak != NULL)
|
|
{
|
|
arSubtract3dPtrs.append(pSolidBreak);
|
|
|
|
//TEST
|
|
//pSolidBreak->setColorIndex(kRed);
|
|
//arOther3dPtrs.append(pSolidBreak);
|
|
//AcDb3dSolid* pSolidBkCln = (AcDb3dSolid*)pSolidBreak->clone();
|
|
//pSolidBkCln->setColorIndex(kRed);
|
|
//AddToModelSpace(pSolidBkCln);
|
|
}
|
|
|
|
AcGiViewDraw dc(NULL,NULL);
|
|
|
|
//和主管廊走向一致
|
|
pFit->Draw3d(dc);
|
|
|
|
AcDb3dSolid* pSolid = pFit->CreateDraw3dSolid(0,true);
|
|
if (pSolid != NULL)
|
|
{
|
|
ptPos -= vtDir * 0.5 * dL;//左对齐
|
|
AecDbEarthWormFitting::Transformby(pSolid,ptPos,vtDir);
|
|
arOther3dPtrs.append(pSolid);
|
|
|
|
//TEST
|
|
//AcDb3dSolid* pSolidBkCln = (AcDb3dSolid*)pSolid->clone();
|
|
//pSolidBkCln->setColorIndex(kGreen);
|
|
//AddToModelSpace(pSolidBkCln);
|
|
|
|
//显示管线
|
|
if (!m_arIDAddtions.isEmpty())
|
|
{
|
|
AcDbVoidPtrArray arSolidPtrs;
|
|
pFit->GetAddtionDraw3dSolid(arSolidPtrs,true);
|
|
|
|
for (int ii = 0;ii < arSolidPtrs.length();ii++)
|
|
{
|
|
pSolid = (AcDb3dSolid*)arSolidPtrs.at(ii);
|
|
AecDbEarthWormFitting::Transformby(pSolid,ptPos,vtDir);
|
|
arOther3dPtrs.append(pSolid);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::GetInterface(AcArray<AecInterface>& arInfs) const
|
|
{
|
|
assertReadEnabled();
|
|
return false;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::GetInterface(int nIndex,AecInterface& inf) const
|
|
{
|
|
assertReadEnabled();
|
|
return false;
|
|
}
|
|
|
|
int AecDbShEarthWorm::GetInterfaceCount() const
|
|
{
|
|
assertReadEnabled();
|
|
return 0;
|
|
}
|
|
|
|
int AecDbShEarthWorm::GetActiveInf() const
|
|
{
|
|
assertReadEnabled();
|
|
return -1;
|
|
}
|
|
|
|
void AecDbShEarthWorm::SetActiveInf(int nIndex)
|
|
{
|
|
assertWriteEnabled();
|
|
}
|
|
|
|
extern AcGePoint3d GetArcMidPoint(AcDbArc* pArc);
|
|
bool AecDbShEarthWorm::parseExtScript(LPCTSTR field, std::vector<std::vector<CString>> &items) const
|
|
{
|
|
CString sAddtionScr;
|
|
if (!m_mapSpecXData.GetAt(KEY_ADDTIONSCR,sAddtionScr) )
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int nPos = sAddtionScr.Find(_T("EXT:"));
|
|
if (nPos == -1) return false;
|
|
|
|
//EXT:
|
|
if (nPos + 4 >= sAddtionScr.GetLength()) return false;
|
|
|
|
CString sExt = sAddtionScr.Mid(nPos + 4);
|
|
//<><><><><><>.....
|
|
CString sScript;
|
|
|
|
int nSta = 0, nPos2 = 0;
|
|
nPos = sExt.Find(_T('<'), nSta);
|
|
while (nPos != -1)
|
|
{
|
|
nPos2 = sExt.Find(_T('>'), nPos + 1);
|
|
if (nPos2 == -1) break;
|
|
|
|
//..<***>...
|
|
sScript = sExt.Mid(nPos + 1, nPos2 - nPos - 1);
|
|
if (sScript.Find(field) != -1)
|
|
{
|
|
CString sScriptT = sScript;
|
|
sScriptT.TrimLeft(field);
|
|
sScriptT.TrimLeft(_T(':'));
|
|
std::vector<CString> arInf;
|
|
CoreTools::SplitStrintToArray(sScriptT, arInf, _T('|'));
|
|
if (!arInf.empty())
|
|
items.push_back(arInf);
|
|
}
|
|
|
|
nSta += sScript.GetLength();
|
|
nPos = sExt.Find(_T('<'), nSta);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::TransformRegionPerpToLine(AcGePoint3d& ptOnReg, AcGeLineSeg3d& ln,bool bDir)
|
|
{
|
|
AcGeVector3d vtNormal = ln.endPoint() - ln.startPoint();
|
|
vtNormal = vtNormal.orthoProject(AcGeVector3d::kZAxis);
|
|
if (bDir)
|
|
{
|
|
vtNormal.negate();//???
|
|
}
|
|
|
|
AcGePoint3d ptOrg = ln.startPoint();
|
|
|
|
AcGePlane plan;
|
|
plan.set(ptOrg,vtNormal);
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToPlaneToWorld(plan);
|
|
ptOnReg.transformBy(xform);
|
|
|
|
return true;
|
|
}
|
|
|
|
extern void TestPoint(AcGePoint3d& ptIns,int iColor);
|
|
|
|
bool AecDbShEarthWorm::GetBossPipeLineSegs(LPCTSTR pszScript,int nRoomIndex,AcArray<LineSeg>& arLnSegs,bool bAllRoom,bool bByWholeLine,int k) const
|
|
{
|
|
//BOSS: 房间|左右位置|侧间隙|水平间隙|宽|高|长|直径|用途|公称直径|壁厚|重量|管道材质|管道系统|颜色|线形|编号|支墩类型|偏移|行|间隙
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_BOSS);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript,arInf,_T('|'));
|
|
|
|
if (arInf.GetSize() >= 9)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nLRPos = _ttoi(arInf.GetAt(1));//米
|
|
double dPos = _ttof(arInf.GetAt(2));
|
|
double dXSpace = _ttof(arInf.GetAt(3));//米
|
|
double dW = _ttof(arInf.GetAt(4));
|
|
double dH = _ttof(arInf.GetAt(5));
|
|
double dL = _ttof(arInf.GetAt(6));
|
|
double dD = _ttof(arInf.GetAt(7));
|
|
CString sSpec = arInf.GetAt(8);
|
|
double dDn = _ttof(arInf.GetAt(9));
|
|
double dt = _ttof(arInf.GetAt(10));
|
|
double dWeight = _ttof(arInf[11]);//重量
|
|
CString sMat = arInf[12];// 材质
|
|
CString sSym = arInf[13];// 系统
|
|
int iClr = _ttoi(arInf[14]);// 颜色
|
|
CString sLType = arInf[15];//线型
|
|
int iNo = _ttoi(arInf[16]);// 编号
|
|
|
|
CString sNo(_T("0"));
|
|
if (arInf.GetSize() > 16)
|
|
sNo = arInf.GetAt(16);
|
|
|
|
int nKind = 0;
|
|
if (arInf.GetSize() > 17)
|
|
nKind = _ttoi(arInf.GetAt(17));
|
|
|
|
int nRows = 1;
|
|
if (arInf.GetSize() > 19)
|
|
nRows = _ttoi(arInf.GetAt(19));
|
|
|
|
double dSpace = 0.0;
|
|
if (arInf.GetSize() > 20)
|
|
dSpace = _ttof(arInf.GetAt(20));
|
|
|
|
AcGeVector3d vtDir;
|
|
double dLen = 0.0,dEnd = 0.0;
|
|
m_pBaseCurve->getEndParam(dEnd);
|
|
m_pBaseCurve->getDistAtParam(dEnd,dLen);
|
|
|
|
AcGeVector3d vtNormal(1,0,0);
|
|
ERoom room;
|
|
if ( GetRoom(nRoomIndex,room) )
|
|
{
|
|
//预留官位只能放在主舱室
|
|
//OffsetMapToSplitRoom(arInf,room, 18);
|
|
|
|
if (nLRPos == 1)//距离右侧,转换为距离左侧
|
|
{
|
|
dPos = room.ptGe[1].distanceTo(room.ptGe[0]) - dPos;
|
|
}
|
|
|
|
//if (!bOnlyAddBoss)
|
|
{
|
|
AcGePoint3d ptCen = room.ptGe[0];
|
|
AcGeVector3d vtDirX = room.ptGe[1] - room.ptGe[0];
|
|
vtDirX.normalize();
|
|
|
|
AcGePoint3d ptGe[10],ptPos,ptPipeCen;
|
|
|
|
ptGe[0] = room.ptGe[0];
|
|
ptGe[0] += (dPos - 0.5 * AS_MUNIT(dW) ) * vtDirX;
|
|
AlongRoomSide(ptGe[0],nRoomIndex,AcGeVector3d::kYAxis);
|
|
|
|
ptGe[1] = ptGe[0] + AcGeVector3d::kYAxis * AS_MUNIT(dH);
|
|
|
|
ptGe[2] = ptGe[1] + AS_MUNIT(dW) * vtDirX;
|
|
|
|
ptGe[3] = ptGe[0] + AS_MUNIT(dW) * vtDirX;
|
|
AlongRoomSide(ptGe[3],nRoomIndex,AcGeVector3d::kYAxis);
|
|
|
|
double dLx = nKind == 0 ? AS_MUNIT(dL) : AS_MUNIT(50.0);
|
|
if (nKind == 0)//支墩
|
|
{
|
|
ptPipeCen = MidPoint(ptGe[1],ptGe[2]);
|
|
//ptPipeCen += AcGeVector3d::kYAxis * 0.5 * dDn;//不需要调高,调用方已经调高
|
|
|
|
//点正确
|
|
//TestPoint(ptPipeCen,1);
|
|
}
|
|
else//支架 角钢宽度示意 50mm
|
|
{
|
|
ptPipeCen = ptGe[1];
|
|
ptPipeCen += 0.5 * dDn * vtDirX;
|
|
//ptPipeCen += AcGeVector3d::kYAxis * 0.5 * dDn;//不需要调高,调用方已经调高
|
|
}
|
|
|
|
AcGePoint3dArray arPtPipeCen;
|
|
arPtPipeCen.append(ptPipeCen);
|
|
|
|
AcGePoint3d ptCenInRgn;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN,ptCenInRgn);
|
|
|
|
if (nKind > 0)
|
|
{
|
|
double dYMax = ptGe[0].y;
|
|
for (int k = 0;k < nRows;k++)
|
|
{
|
|
ptGe[0] += AcGeVector3d::kYAxis * AS_MUNIT(dSpace);
|
|
if (ptGe[0].y - dYMax > 1.e-10)
|
|
{
|
|
break;
|
|
}
|
|
|
|
ptGe[1] = ptGe[0] + AS_MUNIT(dW) * vtDirX;
|
|
|
|
ptGe[2] = ptGe[1] + AcGeVector3d::kYAxis * AS_MUNIT(50.0);
|
|
|
|
ptGe[3] = ptGe[0] + AcGeVector3d::kYAxis * AS_MUNIT(50.0);
|
|
|
|
ptGe[4] = ptGe[0];
|
|
|
|
ptPipeCen = ptGe[1];
|
|
ptPipeCen += 0.5 * dDn * vtDirX;
|
|
//ptPipeCen += AcGeVector3d::kYAxis * 0.5 * dDn;//不需要调高,调用方已经调高
|
|
arPtPipeCen.append(ptPipeCen);
|
|
}
|
|
}
|
|
|
|
AecDb3dRoadAxisLine* pRodLine = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRodLine != NULL)
|
|
{
|
|
AcArray<CurveDir> curDirs;
|
|
pRodLine->GetCurveDirs(curDirs);
|
|
|
|
AcDbIntArray osnapModes,geomIds;
|
|
AcGePoint3dArray arGripPts;
|
|
pRodLine->getGripPoints(arGripPts,osnapModes,geomIds);
|
|
|
|
AcGePoint3d ptPipeCenNew[3];
|
|
double dBulge = 0.0;
|
|
|
|
LineSeg segbos;
|
|
segbos.dRate = 1.5;
|
|
|
|
AcDbCurve* pSeg = NULL;
|
|
for (int jj = 0;jj < curDirs.length();jj++)
|
|
{
|
|
pSeg = curDirs.at(jj).pCurve;
|
|
|
|
ptGe[0] = arGripPts.at(jj);
|
|
ptGe[2] = arGripPts.at(jj+1);
|
|
ptGe[1] = ptGe[2];
|
|
dBulge = 0.0;
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(pSeg);
|
|
if (pArc != NULL)
|
|
{
|
|
ptGe[1] = GetArcMidPoint(pArc);
|
|
dBulge = tan(0.25 * (pArc->endAngle() - pArc->startAngle()));
|
|
}
|
|
|
|
m_pBaseCurve->getFirstDeriv(ptGe[0],vtNormal);
|
|
vtNormal.normalize();
|
|
|
|
for (int n = 0;n < arPtPipeCen.length();n++)
|
|
{
|
|
ptPipeCen = arPtPipeCen.at(n);
|
|
transfromPoint(ptPipeCen,ptCenInRgn,vtNormal, ptGe[0]);
|
|
ptPipeCenNew[0] = ptPipeCen;
|
|
|
|
ptPipeCen = arPtPipeCen.at(n);
|
|
transfromPoint(ptPipeCen,ptCenInRgn,vtNormal, ptGe[1]);
|
|
ptPipeCenNew[1] = ptPipeCen;
|
|
|
|
ptPipeCen = arPtPipeCen.at(n);
|
|
transfromPoint(ptPipeCen,ptCenInRgn,vtNormal, ptGe[2]);
|
|
ptPipeCenNew[2] = ptPipeCen;
|
|
|
|
segbos.ptFr = ptPipeCenNew[0];
|
|
segbos.ptTo = ptPipeCenNew[2];
|
|
segbos.ptOn = ptPipeCenNew[1];
|
|
|
|
segbos.dBulge = dBulge;
|
|
segbos.dX = 0.0;
|
|
segbos.dDn = dDn; //画法直径 DN
|
|
segbos.dD = dD; //外径
|
|
segbos.dt = dt; //壁厚
|
|
_tcscpy(segbos.szMat, sMat); //材质
|
|
_tcscpy(segbos.szSys, sSym); //系统
|
|
_tcscpy(segbos.szLntype, sLType); //线型
|
|
segbos.nColor = iClr; //颜色
|
|
|
|
sNo.Format(_T("66%d%d"),n,k); //管子位置编号
|
|
segbos.nPosNo = _ttoi(sNo); //位置编号
|
|
|
|
arLnSegs.append(segbos);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return !arLnSegs.isEmpty();
|
|
}
|
|
|
|
bool AecDbShEarthWorm::GetPipeLineSegs(int nRoomIndex,AcArray<LineSeg>& arLnSegs, bool bAllRoom/* = false*/, bool bByWholeLine/* = false*/) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int k = 0;
|
|
CString sScr;
|
|
if (m_mapSpecXData.GetAt(KEY_ADDTIONSCR,sScr) )
|
|
{
|
|
//解析附属物脚本
|
|
int nPos = sScr.Find(_T("EXT:"));
|
|
if (nPos != -1)
|
|
{
|
|
//EXT:
|
|
if (nPos + 4 < sScr.GetLength() )
|
|
{
|
|
CString sExt = sScr.Mid(nPos + 4);
|
|
//<><><><><><>.....
|
|
CString sScript;
|
|
|
|
int nSta = 0,nPos2 = 0;
|
|
nPos = sExt.Find(_T('<'),nSta);
|
|
while(nPos != -1)
|
|
{
|
|
nPos2 = sExt.Find(_T('>'),nPos + 1);
|
|
if (nPos2 == -1)
|
|
break;
|
|
|
|
//..<***>...
|
|
sScript = sExt.Mid(nPos + 1,nPos2 - nPos - 1);
|
|
|
|
if (sScript.Find(EW_BOSS) != -1)
|
|
{
|
|
GetBossPipeLineSegs(sScript,nRoomIndex,arLnSegs,bAllRoom,bByWholeLine,k++);
|
|
}
|
|
|
|
nSta += sScript.GetLength();
|
|
nPos = sExt.Find(_T('<'),nSta);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::GetCableLineSegsForHolders(LPCTSTR pszScript,int nRoomIndex
|
|
, AcArray<LineSeg>& arLnSegs
|
|
, int idx // 编号
|
|
, int nFloor // 第几层
|
|
, int nCount // 此层画几条线缆
|
|
, double dDD // 每条线缆外径
|
|
, int nClr // 线缆颜色
|
|
, LPCTSTR ltypeString // 线缆线型
|
|
, double dSpace // 线缆间距
|
|
, bool bAllRoom/* = false*/
|
|
, bool bByWholeLine/* = false*/
|
|
, int k /*= 0*/) const
|
|
{
|
|
//HOLDER:房间|左右位置|层数|垂直间隙|水平间隙|距顶D|长度|宽度|厚度|材料|用途|偏移=(,,,)|编号
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_HOLDER);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript,arInf,_T('|'));
|
|
|
|
if (arInf.GetSize() >= 11)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nLRPos = _ttoi(arInf.GetAt(1));
|
|
int nRows = _ttoi(arInf.GetAt(2));
|
|
|
|
double dVSpace = _ttof(arInf.GetAt(3));
|
|
double dHSpace = _ttof(arInf.GetAt(4));
|
|
double dFrTop = _ttof(arInf.GetAt(5));
|
|
double dL = _ttof(arInf.GetAt(6));
|
|
double dW = _ttof(arInf.GetAt(7));
|
|
double dt = _ttof(arInf.GetAt(8));
|
|
CString sMa = arInf.GetAt(9);
|
|
CString sSpec = arInf.GetAt(10);
|
|
|
|
CString sNo = _T(""),sTemp;
|
|
if (arInf.GetSize() > 12)
|
|
{
|
|
sTemp = arInf.GetAt(12);
|
|
sNo.Format(_T("支架编号:%s"),sTemp);
|
|
}
|
|
|
|
ERoom room;
|
|
if ( GetRoom(nRoomIndex,room) )
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,11);
|
|
|
|
AcGePoint3d ptGe = nLRPos == 0 ? room.ptGe[3] : room.ptGe[2];
|
|
AcGeVector3d vtL = nLRPos == 0 ? AcGeVector3d::kXAxis : -AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtY = -AcGeVector3d::kYAxis;
|
|
AcGeVector3d vtV;
|
|
|
|
AcGePoint3d ptFr = ptGe + vtY * dFrTop;
|
|
AlongRoomSide(ptFr,nRoomIndex,vtL);
|
|
|
|
AcGePoint3d ptSta = ptFr;
|
|
AcGePoint3d ptL[5],ptPos,ptCen,ptl[5],ptPipeCen,ptGeT[3];
|
|
|
|
//用途对于高压的识别
|
|
CString sText = sSpec;
|
|
sText.MakeLower();
|
|
int nFr = sText.Find(_T('('));
|
|
int nTo = sText.Find(_T(')'),nFr);
|
|
int nXKv = 0;
|
|
if (nFr != -1 && nTo != -1)
|
|
{
|
|
sText = sSpec.Mid(nFr,nTo - nFr + 1);
|
|
sSpec = sSpec.Left(nFr);
|
|
sText.TrimLeft(_T('('));
|
|
sText.TrimRight(_T(')'));
|
|
|
|
if (_ttoi(sText) > 30)
|
|
{
|
|
nXKv = 1;
|
|
}
|
|
}
|
|
|
|
AcGePoint3d ptCenInRgn;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN,ptCenInRgn);
|
|
|
|
AcGeVector3d vtDir;
|
|
AcGeVector3d vtNormal(1,0,0);
|
|
AcGePoint3dArray arPtPipeCen;
|
|
|
|
for (int i = 0;i < nRows;i++)//层
|
|
{
|
|
AlongRoomSide(ptFr,nRoomIndex,vtL);
|
|
|
|
ptL[0] = ptFr;
|
|
ptL[1] = ptFr + vtL * AS_MUNIT(dL);
|
|
|
|
ptPipeCen = ptL[0];
|
|
ptPipeCen += 0.5 * dDD * vtL;
|
|
|
|
arPtPipeCen.removeAll();
|
|
if (nFloor == i + 1)//第几层
|
|
{
|
|
for (int j = 0;j < nCount;j++)
|
|
{
|
|
arPtPipeCen.append(ptPipeCen);
|
|
|
|
ptPipeCen += dDD * vtL;
|
|
ptPipeCen += dSpace * vtL;
|
|
}
|
|
|
|
AecDb3dRoadAxisLine* pRodLine = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRodLine != NULL)
|
|
{
|
|
AcArray<CurveDir> curDirs;
|
|
pRodLine->GetCurveDirs(curDirs);
|
|
|
|
AcDbIntArray osnapModes,geomIds;
|
|
AcGePoint3dArray arGripPts;
|
|
pRodLine->getGripPoints(arGripPts,osnapModes,geomIds);
|
|
|
|
AcGePoint3d ptPipeCenNew[3];
|
|
double dBulge = 0.0;
|
|
|
|
LineSeg segHolder;
|
|
segHolder.dRate = 1.5;
|
|
|
|
AcDbCurve* pSeg = NULL;
|
|
for (int jj = 0;jj < curDirs.length();jj++)
|
|
{
|
|
pSeg = curDirs.at(jj).pCurve;
|
|
|
|
ptGeT[0] = arGripPts.at(jj);
|
|
ptGeT[2] = arGripPts.at(jj+1);
|
|
ptGeT[1] = ptGeT[2];
|
|
dBulge = 0.0;
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(pSeg);
|
|
if (pArc != NULL)
|
|
{
|
|
ptGeT[1] = GetArcMidPoint(pArc);
|
|
dBulge = tan(0.25 * (pArc->endAngle() - pArc->startAngle()));
|
|
}
|
|
|
|
m_pBaseCurve->getFirstDeriv(ptGeT[0],vtNormal);
|
|
vtNormal.normalize();
|
|
|
|
for (int n = 0;n < arPtPipeCen.length();n++)
|
|
{
|
|
ptPipeCen = arPtPipeCen.at(n);
|
|
transfromPoint(ptPipeCen,ptCenInRgn,vtNormal, ptGeT[0]);
|
|
ptPipeCenNew[0] = ptPipeCen;
|
|
|
|
ptPipeCen = arPtPipeCen.at(n);
|
|
transfromPoint(ptPipeCen,ptCenInRgn,vtNormal, ptGeT[1]);
|
|
ptPipeCenNew[1] = ptPipeCen;
|
|
|
|
ptPipeCen = arPtPipeCen.at(n);
|
|
transfromPoint(ptPipeCen,ptCenInRgn,vtNormal, ptGeT[2]);
|
|
ptPipeCenNew[2] = ptPipeCen;
|
|
|
|
segHolder.ptFr = ptPipeCenNew[0];
|
|
segHolder.ptTo = ptPipeCenNew[2];
|
|
segHolder.ptOn = ptPipeCenNew[1];
|
|
segHolder.dBulge = dBulge;
|
|
segHolder.dD = dDD; //外径
|
|
_tcscpy(segHolder.szMat, sMa); //材质
|
|
_tcscpy(segHolder.szSys, sSpec); //用途
|
|
|
|
if (ltypeString != NULL)
|
|
_tcscpy(segHolder.szLntype, ltypeString);//线型
|
|
|
|
segHolder.nColor = nClr; //颜色
|
|
|
|
sNo.Format(_T("88%d%d%d"),i,k,n); //支架序号+线缆序号
|
|
segHolder.nPosNo = _ttoi(sNo); //位置编号
|
|
|
|
arLnSegs.append(segHolder);
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
//下一个位置
|
|
ptFr += vtY * ( dVSpace + AS_MUNIT(dW));
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// 提取线缆位置分段[支架处]
|
|
bool AecDbShEarthWorm::GetCableLineSegsForHolder(int nRoomIndex
|
|
, AcArray<LineSeg>& arLnSegs
|
|
, int idx // 编号
|
|
, int nFloor // 第几层
|
|
, int nCount // 此层画几条线缆
|
|
, double dDD // 每条线缆外径
|
|
, int nClr // 线缆颜色
|
|
, LPCTSTR ltypeString // 线缆线型
|
|
, double dSpace // 线缆间距
|
|
, bool bAllRoom/* = false*/
|
|
, bool bByWholeLine/* = false*/) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int k = 0;
|
|
CString sScr;
|
|
if (m_mapSpecXData.GetAt(KEY_ADDTIONSCR,sScr) )
|
|
{
|
|
//解析附属物脚本
|
|
int nPos = sScr.Find(_T("EXT:"));
|
|
if (nPos != -1)
|
|
{
|
|
//EXT:
|
|
if (nPos + 4 < sScr.GetLength() )
|
|
{
|
|
CString sExt = sScr.Mid(nPos + 4);
|
|
//<><><><><><>.....
|
|
CString sScript;
|
|
|
|
int nSta = 0,nPos2 = 0;
|
|
nPos = sExt.Find(_T('<'),nSta);
|
|
while(nPos != -1)
|
|
{
|
|
nPos2 = sExt.Find(_T('>'),nPos + 1);
|
|
if (nPos2 == -1)
|
|
break;
|
|
|
|
//..<***>...
|
|
sScript = sExt.Mid(nPos + 1,nPos2 - nPos - 1);
|
|
|
|
if (sScript.Find( EW_HOLDER ) != -1)
|
|
{
|
|
GetCableLineSegsForHolders(sScript,nRoomIndex,arLnSegs,idx,nFloor,nCount,dDD,nClr,ltypeString,dSpace,bAllRoom,bByWholeLine,k++);
|
|
}
|
|
|
|
nSta += sScript.GetLength();
|
|
nPos = sExt.Find(_T('<'),nSta);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::GetCableLineSegsForHangers(LPCTSTR pszScript,int nRoomIndex
|
|
, AcArray<LineSeg>& arLnSegs
|
|
, int idx // 编号
|
|
, int nFloor // 第几层
|
|
, int nCount // 此层画几条线缆
|
|
, double dDD // 每条线缆外径
|
|
, int nClr // 线缆颜色
|
|
, LPCTSTR ltypeString// 线缆线型
|
|
, double dSpace // 线缆间距
|
|
, bool bAllRoom/* = false*/
|
|
, bool bByWholeLine/* = false*/
|
|
, int kk/* = 0*/) const
|
|
{
|
|
//HANGER:房间|层数|垂直间隙|水平间隙|左侧距离|距顶D|长度|宽度|厚度|材料|用途|偏移(,,,)
|
|
CString sScript = pszScript;
|
|
sScript.TrimLeft(EW_HANGER);
|
|
sScript.TrimLeft(_T(':'));
|
|
|
|
CStringArray arInf;
|
|
CoreTools::SplitStrintToArray(sScript,arInf,_T('|'));
|
|
|
|
if (arInf.GetSize() >= 11)
|
|
{
|
|
int nRoomIndex = _ttoi(arInf.GetAt(0));
|
|
int nRows = _ttoi(arInf.GetAt(1));
|
|
|
|
double dVSpace = _ttof(arInf.GetAt(2));//米
|
|
double dHSpace = _ttof(arInf.GetAt(3));//米
|
|
double dX = _ttof(arInf.GetAt(4));//米
|
|
double dFrTop = _ttof(arInf.GetAt(5));//米
|
|
|
|
double dL = _ttof(arInf.GetAt(6));//mm
|
|
double dW = _ttof(arInf.GetAt(7));//mm
|
|
double dt = _ttof(arInf.GetAt(8));//mm
|
|
|
|
CString sMa = arInf.GetAt(9);
|
|
CString sSpec = arInf.GetAt(10);
|
|
|
|
CString sNo = _T(""), sTemp;
|
|
if (arInf.GetSize() >= 13)
|
|
{
|
|
sTemp = arInf.GetAt(12);
|
|
sNo.Format(_T("吊架编号:%s"), sTemp);
|
|
}
|
|
|
|
AcGePoint3d ptCenInRgn;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN,ptCenInRgn);
|
|
|
|
AcGeVector3d vtDir;
|
|
double dPos = 0.0;
|
|
double dLen = 0.0,dEnd = 0.0;
|
|
m_pBaseCurve->getEndParam(dEnd);
|
|
m_pBaseCurve->getDistAtParam(dEnd,dLen);
|
|
int nCols = (int)(dLen / dHSpace);
|
|
AcGeVector3d vtNormal(1,0,0);
|
|
|
|
ERoom room;
|
|
if ( GetRoom(nRoomIndex,room) )
|
|
{
|
|
OffsetMapToSplitRoom(arInf,room,11);
|
|
|
|
AcGePoint3d ptGe = room.ptGe[3];
|
|
AcGeVector3d vtL = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtY = -AcGeVector3d::kYAxis;
|
|
AcGePoint3d ptFr = ptGe + vtL * dX;
|
|
//AlongRoomSide(ptFr,nRoomIndex,vtL);
|
|
|
|
AcGePoint3d ptSta = ptFr;
|
|
AcGePoint3d ptU[10],ptPos,ptCen,ptL[5],ptU2[10],ptGeT[3];
|
|
|
|
ptU[0] = ptFr;
|
|
ptU[1] = ptU[0] + vtY * ( (nRows - 1)* ( dVSpace + AS_MUNIT(dW) ) + dFrTop + AS_MUNIT(dW) );
|
|
ptU[2] = ptU[1] + vtL * AS_MUNIT(dL);
|
|
ptU[3] = ptU[0] + vtL * AS_MUNIT(dL);
|
|
|
|
ptU[4] = ptU[3] - vtL * AS_MUNIT(dW);
|
|
ptU[5] = ptU[4] + vtY * ( (nRows - 1)* ( dVSpace + AS_MUNIT(dW) ) + dFrTop );
|
|
ptU[6] = ptU[5] - vtL * (AS_MUNIT(dL) - 2.0 * AS_MUNIT(dW) );
|
|
ptU[7] = ptU[0] + vtL * AS_MUNIT(dW);
|
|
ptU[8] = ptU[0];
|
|
|
|
//3,4,7,8,0 备份
|
|
memcpy(ptU2,ptU,sizeof(AcGePoint3d) * 10);
|
|
AlongRoomSide(ptU[3],nRoomIndex,vtY);
|
|
AlongRoomSide(ptU[4],nRoomIndex,vtY);
|
|
AlongRoomSide(ptU[7],nRoomIndex,vtY);
|
|
AlongRoomSide(ptU[8],nRoomIndex,vtY);
|
|
AlongRoomSide(ptU[0],nRoomIndex,vtY);
|
|
|
|
AcGePoint3d ptPipeCen;
|
|
AcGePoint3dArray arPtPipeCen;
|
|
memcpy(ptU,ptU2,sizeof(AcGePoint3d) * 10);
|
|
|
|
for (int k = 0;k < nRows - 1;k++)//层数
|
|
{
|
|
ptL[0] = ptU[7] + vtY * ( k * dVSpace + dFrTop + k * AS_MUNIT(dW) );
|
|
ptL[1] = ptL[0] + vtL * (AS_MUNIT(dL) - 2.0 * AS_MUNIT(dW) );
|
|
|
|
ptL[2] = ptL[1] + vtY * AS_MUNIT(dW);
|
|
ptL[3] = ptL[0] + vtY * AS_MUNIT(dW);
|
|
ptL[4] = ptL[0];
|
|
|
|
if (nFloor == k+1)//第几层
|
|
{
|
|
ptPipeCen = ptL[0];
|
|
ptPipeCen += 0.5 * dDD * vtL;
|
|
|
|
for (int j = 0;j < nCount;j++)
|
|
{
|
|
arPtPipeCen.append(ptPipeCen);
|
|
|
|
ptPipeCen += dDD * vtL;
|
|
ptPipeCen += dSpace * vtL;
|
|
}
|
|
|
|
|
|
AecDb3dRoadAxisLine* pRodLine = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRodLine != NULL)
|
|
{
|
|
AcArray<CurveDir> curDirs;
|
|
pRodLine->GetCurveDirs(curDirs);
|
|
|
|
AcDbIntArray osnapModes,geomIds;
|
|
AcGePoint3dArray arGripPts;
|
|
pRodLine->getGripPoints(arGripPts,osnapModes,geomIds);
|
|
|
|
AcGePoint3d ptPipeCenNew[3];
|
|
double dBulge = 0.0;
|
|
|
|
LineSeg segHolder;
|
|
segHolder.dRate = 1.5;
|
|
|
|
AcDbCurve* pSeg = NULL;
|
|
for (int jj = 0;jj < curDirs.length();jj++)
|
|
{
|
|
pSeg = curDirs.at(jj).pCurve;
|
|
|
|
ptGeT[0] = arGripPts.at(jj);
|
|
ptGeT[2] = arGripPts.at(jj+1);
|
|
ptGeT[1] = ptGeT[2];
|
|
dBulge = 0.0;
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(pSeg);
|
|
if (pArc != NULL)
|
|
{
|
|
ptGeT[1] = GetArcMidPoint(pArc);
|
|
dBulge = tan(0.25 * (pArc->endAngle() - pArc->startAngle()));
|
|
}
|
|
|
|
m_pBaseCurve->getFirstDeriv(ptGeT[0],vtNormal);
|
|
vtNormal.normalize();
|
|
|
|
for (int n = 0;n < arPtPipeCen.length();n++)
|
|
{
|
|
ptPipeCen = arPtPipeCen.at(n);
|
|
transfromPoint(ptPipeCen,ptCenInRgn,vtNormal, ptGeT[0]);
|
|
ptPipeCenNew[0] = ptPipeCen;
|
|
|
|
ptPipeCen = arPtPipeCen.at(n);
|
|
transfromPoint(ptPipeCen,ptCenInRgn,vtNormal, ptGeT[1]);
|
|
ptPipeCenNew[1] = ptPipeCen;
|
|
|
|
ptPipeCen = arPtPipeCen.at(n);
|
|
transfromPoint(ptPipeCen,ptCenInRgn,vtNormal, ptGeT[2]);
|
|
ptPipeCenNew[2] = ptPipeCen;
|
|
|
|
segHolder.ptFr = ptPipeCenNew[0];
|
|
segHolder.ptTo = ptPipeCenNew[2];
|
|
segHolder.ptOn = ptPipeCenNew[1];
|
|
segHolder.dBulge = dBulge;
|
|
segHolder.dD = dDD; //外径
|
|
_tcscpy(segHolder.szMat, sMa); //材质
|
|
_tcscpy(segHolder.szSys, sSpec); //用途
|
|
|
|
if (ltypeString != NULL)
|
|
_tcscpy(segHolder.szLntype, ltypeString);//线型
|
|
|
|
segHolder.nColor = nClr; //颜色
|
|
|
|
sNo.Format(_T("99%d%d%d"),k,kk,n); //支架序号+线缆序号
|
|
segHolder.nPosNo = _ttoi(sNo); //位置编号
|
|
|
|
arLnSegs.append(segHolder);
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::GetCableLineSegsForHanger(int nRoomIndex
|
|
, AcArray<LineSeg>& arLnSegs
|
|
, int idx // 编号
|
|
, int nFloor // 第几层
|
|
, int nCount // 此层画几条线缆
|
|
, double dDD // 每条线缆外径
|
|
, int nClr // 线缆颜色
|
|
, LPCTSTR ltypeString// 线缆线型
|
|
, double dSpace // 线缆间距
|
|
, bool bAllRoom/* = false*/
|
|
, bool bByWholeLine/* = false*/) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int k = 0;
|
|
CString sScr;
|
|
if (m_mapSpecXData.GetAt(KEY_ADDTIONSCR,sScr) )
|
|
{
|
|
//解析附属物脚本
|
|
int nPos = sScr.Find(_T("EXT:"));
|
|
if (nPos != -1)
|
|
{
|
|
//EXT:
|
|
if (nPos + 4 < sScr.GetLength() )
|
|
{
|
|
CString sExt = sScr.Mid(nPos + 4);
|
|
//<><><><><><>.....
|
|
CString sScript;
|
|
|
|
int nSta = 0,nPos2 = 0;
|
|
nPos = sExt.Find(_T('<'),nSta);
|
|
while(nPos != -1)
|
|
{
|
|
nPos2 = sExt.Find(_T('>'),nPos + 1);
|
|
if (nPos2 == -1)
|
|
break;
|
|
|
|
//..<***>...
|
|
sScript = sExt.Mid(nPos + 1,nPos2 - nPos - 1);
|
|
if (sScript.Find( EW_HANGER ) != -1)
|
|
{
|
|
GetCableLineSegsForHangers(sScript,nRoomIndex,arLnSegs,idx,nFloor,nCount,dDD,nClr,ltypeString,dSpace,bAllRoom,bByWholeLine,k++);
|
|
}
|
|
|
|
nSta += sScript.GetLength();
|
|
nPos = sExt.Find(_T('<'),nSta);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::HasAddtions(AcRxClass* pRxClass)
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbObjectId id;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arIDAddtions.length();i++)
|
|
{
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,m_arIDAddtions.at(i),AcDb::kForRead))
|
|
{
|
|
if (pEnt->isA() == pRxClass)
|
|
{
|
|
pEnt->close();
|
|
return true;
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::AddAddtion(const AcDbObjectId& idAdd)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (m_arIDAddtions.find(idAdd) == -1)
|
|
{
|
|
m_arIDAddtions.append(idAdd);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbShEarthWorm::RemoveAddtions(AcRxClass* pRxClass)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcDbObjectIdArray arIds;
|
|
AcDbObjectId id;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arIDAddtions.length();i++)
|
|
{
|
|
id = m_arIDAddtions.at(i);
|
|
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForWrite))
|
|
{
|
|
if ( _tcscmp( pEnt->isA()->name(),pRxClass->name() ) == 0 )
|
|
{
|
|
//;
|
|
//acutPrintf(_T("\nname = %s"),pEnt->isA()->name());
|
|
pEnt->erase();
|
|
}
|
|
else
|
|
{
|
|
arIds.append(id);
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
m_arIDAddtions.removeAll();
|
|
if (!arIds.isEmpty())
|
|
{
|
|
m_arIDAddtions.append(arIds);
|
|
}
|
|
return true;
|
|
} |