4953 lines
112 KiB
C++
4953 lines
112 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbEwPipe.h"
|
|
#include "dbgrip.h"
|
|
#include "AecGripCback.h"
|
|
#include "KTCADUtilityEx.h"
|
|
#include "KTSetting.h"
|
|
#include "coretools.h"
|
|
#include "AecDbX3dPartEntity.h"
|
|
#include "AcGiViewDraw.h"
|
|
#include "encryption.h"
|
|
#include "AecCoverBooleanOper.h"
|
|
#include "HlrCutOption.h"
|
|
#include "entityfilter.h"
|
|
#include "acgiexplodedraw.h"
|
|
|
|
#pragma region EWPIPE
|
|
|
|
extern double PixelToWcs(int nPixel);
|
|
extern BOOL Is2DView();
|
|
extern AcGeVector3d GetUcsZvt();
|
|
extern void PushGripMessage(GripMessage&);
|
|
|
|
extern void transfromRegion(AcDbRegion *pRegion, const AcGePoint3d &ptOnRegion, const AcGeVector3d &vtNormal, const AcGePoint3d &ptOnPlan);
|
|
extern AcDbPolyline* FormatPolyline(AcGePoint3d* ppPts,int nCount);
|
|
extern AcDbPolyline *FormatPolyline(const AcGePoint3dArray &arPts);
|
|
extern int GetOrthoProjectedCurve(AcDbRegion* pReg,AcGePlane& plan,AcDbVoidPtrArray& arCurPtrs,bool bMerge);
|
|
extern AcGePoint3d MidPoint(const AcGePoint3d& pt1, const AcGePoint3d& pt2);
|
|
extern BOOL DLLIMPEXP GetDimGripOff();
|
|
|
|
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;
|
|
|
|
#ifndef GRIPPT_RESP_FROM_EWFIT
|
|
#define GRIPPT_RESP_FROM_EWFIT 1394
|
|
#endif
|
|
|
|
static AcGePoint3d Mid(const AcGePoint3d& ptGe1,const AcGePoint3d& ptGe2)
|
|
{
|
|
return AcGePoint3d( (ptGe1.x + ptGe2.x) / 2.0,
|
|
(ptGe1.y + ptGe2.y) / 2.0,
|
|
(ptGe1.z + ptGe2.z) / 2.0);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool getPipeSysInfoByEnt(const bool &bCenter
|
|
, const AecDbObjXDataMap &xData
|
|
, int &clr
|
|
, double &dw
|
|
, AcDbObjectId &idLy
|
|
, AcDbObjectId &idLt)
|
|
{
|
|
BOOL bRel(FALSE);
|
|
if (bCenter)
|
|
{
|
|
bRel = xData.GetAt(PIPE_COLOR, clr);
|
|
if (!bRel) return false;
|
|
bRel = xData.GetAt(PIPE_LINETYPE, idLt);
|
|
if (!bRel) return false;
|
|
bRel = xData.GetAt(PIPE_LINEWIDTH, dw);
|
|
if (!bRel) return false;
|
|
bRel = xData.GetAt(PIPE_LINELAYER, idLy);
|
|
if (!bRel) return false;
|
|
}
|
|
else
|
|
{
|
|
bRel = xData.GetAt(PIPE_COLOR_OUT, clr);
|
|
if (!bRel) return false;
|
|
bRel = xData.GetAt(PIPE_LINETYPE_OUT, idLt);
|
|
if (!bRel) return false;
|
|
bRel = xData.GetAt(PIPE_LINEWIDTH_OUT, dw);
|
|
if (!bRel) return false;
|
|
bRel = xData.GetAt(PIPE_LINELAYER_OUT, idLy);
|
|
if (!bRel) return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
namespace
|
|
{
|
|
// 方便备份DC状态
|
|
int g_Clr;
|
|
AcDbObjectId g_Ly;
|
|
AcDbObjectId g_Lt;
|
|
AcDb::LineWeight g_Lw;
|
|
|
|
void backupDc(AcGiDraw &dc)
|
|
{
|
|
g_Clr = dc.GetColor();
|
|
g_Ly = dc.GetLayerId();
|
|
g_Lt = dc.GetLineTypeId();
|
|
g_Lw = dc.GetLineWeight();
|
|
}
|
|
|
|
void recoverDc(AcGiDraw &dc)
|
|
{
|
|
dc.SetColor(g_Clr);
|
|
dc.SetLayer(g_Ly);
|
|
dc.SetLineType(g_Lt);
|
|
dc.SetLineWeight(g_Lw);
|
|
}
|
|
|
|
|
|
void setInfo2Dc(LPCTSTR sSys, AcGiDraw &dc, const bool &bCenter, const AecDbObjXDataMap &xData)
|
|
{
|
|
int clr;
|
|
double dw;
|
|
AcDbObjectId idLt, idLy;
|
|
if (!getPipeSysInfoByEnt(bCenter, xData, clr, dw, idLy, idLt))
|
|
{
|
|
clr = CoreTools::getColorByPipeSys(sSys, bCenter);
|
|
idLy = CoreTools::getLyByPipeSys(sSys, bCenter);
|
|
idLt = CoreTools::getLtByPipeSys(sSys, bCenter);
|
|
}
|
|
dc.SetColor(clr);
|
|
dc.SetLineType(idLt);
|
|
dc.SetLayer(idLy);
|
|
}
|
|
|
|
void setInfo2Ent(LPCTSTR sSys, AcDbEntity *pEnt, const bool &bCenter, const AecDbObjXDataMap &xData)
|
|
{
|
|
int clr = kColorByLayer;
|
|
double dw;
|
|
AcDbObjectId idLt, idLy;
|
|
if (!getPipeSysInfoByEnt(bCenter, xData, clr, dw, idLy, idLt))
|
|
{
|
|
clr = CoreTools::getColorByPipeSys(sSys, bCenter);
|
|
idLy = CoreTools::getLyByPipeSys(sSys, bCenter);
|
|
idLt = CoreTools::getLtByPipeSys(sSys, bCenter);
|
|
dw = CoreTools::getLwByPipeSys(sSys, bCenter);
|
|
}
|
|
pEnt->setColorIndex(clr);
|
|
pEnt->setLinetype(idLt);
|
|
AcDbPolyline *pPoly = AcDbPolyline::cast(pEnt);
|
|
if (pPoly)
|
|
{
|
|
pPoly->setConstantWidth(0);
|
|
if (pPoly && dw > 1.e-3)
|
|
pPoly->setConstantWidth(dw);
|
|
}
|
|
pEnt->setLayer(idLy);
|
|
}
|
|
|
|
}
|
|
|
|
Adesk::UInt32 AecDbEwPipe::kCurrentVersionNumber = 1;
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbEwPipe, AecDbEwPipeBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_EWPIPE,
|
|
"AecDbEwPipe"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
|
|
AecDbEwPipe::AecDbEwPipe(void)
|
|
{
|
|
m_mapSpecXData.SetAt(KEY_NAME,_T("管线"));
|
|
}
|
|
|
|
AecDbEwPipe::~AecDbEwPipe(void)
|
|
{
|
|
}
|
|
|
|
// 设置开始点,如果是LINE管子
|
|
Acad::ErrorStatus AecDbEwPipe::SetStartPoint(const AcGePoint3d& ptSta)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (m_pBaseCurve == NULL)
|
|
m_pBaseCurve = new AcDbLine;
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
AcGePoint3d ptFr = pLine->startPoint();
|
|
AcGePoint3d ptTo = pLine->endPoint();
|
|
AcGeVector3d vt2 = ptTo - ptFr;
|
|
|
|
pLine->setStartPoint(ptSta);
|
|
|
|
if (vt2.isZeroLength())
|
|
return Acad::eOk;
|
|
|
|
CString sIndex;
|
|
AcGePoint3d ptGe;
|
|
AcGeVector3d vtNew = pLine->endPoint() - pLine->startPoint();
|
|
vtNew.normalize();
|
|
|
|
if (!vtNew.isCodirectionalTo(vt2))
|
|
{
|
|
for (int i = 0;i < PIPE_BROKENNUM;i++)
|
|
{
|
|
sIndex.Format(_T("BKOP%d"),i);
|
|
m_mapSpecXData.RemoveAt(sIndex);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGeVector3d vt = ptSta - ptFr;
|
|
|
|
if (!vt.isCodirectionalTo(vt2))//增加
|
|
{
|
|
for (int i = 0;i < PIPE_BROKENNUM;i++)
|
|
{
|
|
sIndex.Format(_T("BKOP%d"),i);
|
|
if (m_mapSpecXData.GetAt(sIndex,ptGe))
|
|
{
|
|
ptGe.x += vt.length();
|
|
m_mapSpecXData.SetAt(sIndex,ptGe);
|
|
}
|
|
}
|
|
}
|
|
else//减少
|
|
{
|
|
AcGeVector3d vt3;
|
|
vt2.normalize();
|
|
for (int i = 0;i < PIPE_BROKENNUM;i++)
|
|
{
|
|
sIndex.Format(_T("BKOP%d"),i);
|
|
if (m_mapSpecXData.GetAt(sIndex,ptGe))
|
|
{
|
|
ptTo = ptFr + ptGe.x * vt2;
|
|
vt3 = ptTo - ptSta;
|
|
|
|
if (vt3.isCodirectionalTo(vt2))
|
|
{
|
|
ptGe.x -= vt.length();
|
|
m_mapSpecXData.SetAt(sIndex,ptGe);
|
|
}
|
|
else
|
|
{
|
|
m_mapSpecXData.RemoveAt(sIndex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
AcGePoint3d AecDbEwPipe::StartPoint() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptSta;
|
|
getStartPoint(ptSta);
|
|
|
|
return ptSta;
|
|
}
|
|
|
|
// 设置端点 如果是LINE管子
|
|
Acad::ErrorStatus AecDbEwPipe::SetEndPoint(const AcGePoint3d& ptEnd)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (m_pBaseCurve == NULL)
|
|
m_pBaseCurve = new AcDbLine;
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
pLine->setEndPoint(ptEnd);
|
|
|
|
AcGePoint3d ptFr = pLine->startPoint();
|
|
AcGeVector3d vt = ptEnd -ptFr;
|
|
vt.normalize();
|
|
|
|
CString sIndex;
|
|
AcGePoint3d ptGe,ptTo;
|
|
AcGeVector3d vt2;
|
|
|
|
for (int i = 0;i < PIPE_BROKENNUM;i++)
|
|
{
|
|
sIndex.Format(_T("BKOP%d"),i);
|
|
if (m_mapSpecXData.GetAt(sIndex,ptGe))
|
|
{
|
|
ptTo = ptFr + ptGe.x * vt;
|
|
vt2 = ptEnd - ptTo;
|
|
if (!vt2.isCodirectionalTo(vt))
|
|
{
|
|
m_mapSpecXData.RemoveAt(sIndex);
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
void AecDbEwPipe::SetElevation(double dEl)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLine->startPoint();
|
|
AcGePoint3d ptEnd = pLine->endPoint();
|
|
|
|
if (fabs(ptSta.z - ptEnd.z) < 1.e-2)
|
|
{
|
|
ptSta.z = dEl;ptEnd.z = dEl;
|
|
pLine->setStartPoint(ptSta);
|
|
pLine->setEndPoint(ptEnd);
|
|
m_mapSpecXData.SetAt(PIPE_EL,dEl);
|
|
}
|
|
}
|
|
}
|
|
|
|
AcGePoint3d AecDbEwPipe::EndPoint() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptE;
|
|
getEndPoint(ptE);
|
|
|
|
return ptE;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::CheckBrokenOpen()
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
CString sIndex;
|
|
AcGePoint3d ptGe;
|
|
|
|
AcGePoint3d ptGeSta = StartPoint();
|
|
AcGePoint3d ptGeEnd = EndPoint();
|
|
double dLen = ptGeSta.distanceTo(ptGeEnd);
|
|
|
|
for (int i = 0;i < PIPE_BROKENNUM;i++)
|
|
{
|
|
sIndex.Format(_T("BKOP%d"),i);
|
|
if (m_mapSpecXData.GetAt(sIndex,ptGe))
|
|
{
|
|
if (ptGe.x - dLen > 1.e-10)
|
|
{
|
|
m_mapSpecXData.RemoveAt(sIndex);
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbEwPipe::SetPipeParam(WPipe::PipeParam* pParam)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (pParam != NULL)
|
|
{
|
|
m_mapSpecXData.SetAt(PIPE_EAPP, (int)pParam->m_app);
|
|
m_mapSpecXData.SetAt(PIPE_DRAWDIR,pParam->m_eD); //绘制类型
|
|
m_mapSpecXData.SetAt(KEY_2DSTYLE,2); //双线
|
|
m_mapSpecXData.SetAt(KEY_SINGLE,0);
|
|
m_mapSpecXData.SetAt(PIPE_D,pParam->m_dD);
|
|
SetSection(pParam->m_dD,pParam->m_dThick);
|
|
|
|
m_mapSpecXData.SetAt(PIPE_DN,pParam->m_dDN);
|
|
m_mapSpecXData.SetAt(PIPE_OD,pParam->m_dOD);
|
|
m_mapSpecXData.SetAt(PIPE_TDN,pParam->m_dDN);
|
|
m_mapSpecXData.SetAt(PIPE_TOD,pParam->m_dOD);
|
|
m_mapSpecXData.SetAt(PIPE_RATIO,pParam->m_dRRatio);
|
|
m_mapSpecXData.SetAt(KEY_RadRatio, pParam->m_nRadioOn);
|
|
m_mapSpecXData.SetAt(PIPE_THICK,pParam->m_dThick);
|
|
m_mapSpecXData.SetAt(PIPE_MATERIAL,pParam->szMertial);
|
|
m_mapSpecXData.SetAt(PIPE_MATERIALFT,pParam->szMertialFit);
|
|
|
|
m_mapSpecXData.SetAt(PIPE_ELBOWFLG,FALSE);
|
|
m_mapSpecXData.SetAt(PIPE_BWELDDOT,FALSE);
|
|
m_mapSpecXData.SetAt(DOC_PLOTWIDTH,1.0);
|
|
m_mapSpecXData.SetAt(DOC_WELDDIA,2.0);
|
|
m_mapSpecXData.SetAt(PIPE_ZONE,pParam->szZoneNo);
|
|
m_mapSpecXData.SetAt(PIPE_INSTHICK,10.0);
|
|
m_mapSpecXData.SetAt(PIPE_NO,pParam->szPipeno);
|
|
m_mapSpecXData.SetAt(KEY_NO, pParam->szNo);
|
|
m_mapSpecXData.SetAt(DOC_INSMATER,pParam->szInsMtr);
|
|
m_mapSpecXData.SetAt(PIPE_DESCR,pParam->szDescr);
|
|
m_mapSpecXData.SetAt(PIPE_SYS,pParam->szSys);
|
|
m_mapSpecXData.SetAt(PIPE_PIDD,100.0);//设置pid画法的直径
|
|
m_mapSpecXData.SetAt(PIPE_LEVEL,pParam->szLevel);
|
|
|
|
m_mapSpecXData.SetAt(PIPE_CONNECT,pParam->m_nConnectType);
|
|
m_mapSpecXData.SetAt(PIPE_INTERFACED,pParam->m_dInterfaceD);
|
|
m_mapSpecXData.SetAt(PIPE_INTERFACED2,pParam->m_dInterfaceD2);
|
|
m_mapSpecXData.SetAt(PIPE_INTERFACEL,pParam->m_dInterfaceL);
|
|
m_mapSpecXData.SetAt(PIPE_INTERFACEL2,pParam->m_dInterfaceL2);
|
|
|
|
m_mapSpecXData.SetAt(PIPE_FLANGF, pParam->m_szEndF);
|
|
m_mapSpecXData.SetAt(PIPE_GASKET, pParam->m_szGastInf);
|
|
|
|
//设置标高
|
|
//如果是水平管子
|
|
AcGePoint3d ptS = StartPoint();
|
|
AcGePoint3d ptE = EndPoint();
|
|
AcGeVector3d vt = ptE - ptS;
|
|
AcGeLine3d ln(ptS,vt);
|
|
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
|
{
|
|
SetElevation(pParam->m_dEl);
|
|
}
|
|
}
|
|
}
|
|
|
|
//param 单位换算成米单位
|
|
void DLLIMPEXP PipeParamConvert2UnitMeters(WPipe::PipeParam* pParam)
|
|
{
|
|
if (pParam == NULL)
|
|
return;
|
|
|
|
//当前的图纸单位,仅仅转换米单位
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"), &rb);
|
|
if (rb.resval.rint == AcDb::kUnitsMeters)
|
|
{
|
|
//确认原来是毫米单位,没有转换
|
|
if (pParam->m_dDN > 5.0 )//最小公程直径 6
|
|
{
|
|
double dScale = 0.001;
|
|
pParam->m_dD *= dScale;
|
|
pParam->m_dDN *= dScale;
|
|
pParam->m_dOD *= dScale;
|
|
pParam->m_dThick *= dScale;
|
|
pParam->m_dEl *= dScale;//
|
|
pParam->m_dW *= dScale;
|
|
pParam->m_dH *= dScale;
|
|
|
|
pParam->m_dInterfaceL *= dScale;
|
|
pParam->m_dInterfaceD *= dScale;
|
|
pParam->m_dInterfaceD2 *= dScale;
|
|
pParam->m_dInterfaceL2 *= dScale;
|
|
|
|
pParam->m_dWh *= dScale;
|
|
pParam->m_dWn *= dScale;
|
|
pParam->m_dWh2 *= dScale;
|
|
pParam->m_dWn2 *= dScale;
|
|
|
|
pParam->m_dInsThk *= dScale;
|
|
pParam->m_dInterfaceL3 *= dScale;
|
|
}
|
|
}
|
|
}
|
|
|
|
//param 单位换算成毫米单位
|
|
void DLLIMPEXP PipeParamConvert2UnitMmeters(WPipe::PipeParam* pParam)
|
|
{
|
|
if (pParam == NULL)
|
|
return;
|
|
|
|
struct resbuf rbU;
|
|
acedGetVar(_T("INSUNITS"), &rbU);
|
|
|
|
double dScale = 1.0;
|
|
if (rbU.resval.rint == AcDb::kUnitsMeters )
|
|
{
|
|
//说明是米单位
|
|
dScale = 1000.0;
|
|
}
|
|
else if(rbU.resval.rint == AcDb::kUnitsDecimeters)//分米
|
|
{
|
|
//说明是米单位
|
|
dScale = 100.0;
|
|
}
|
|
else if(rbU.resval.rint == AcDb::kUnitsCentimeters)//厘米
|
|
{
|
|
//说明是米单位
|
|
dScale = 10.0;
|
|
}
|
|
|
|
pParam->m_dD *= dScale;
|
|
pParam->m_dDN *= dScale;
|
|
pParam->m_dOD *= dScale;
|
|
pParam->m_dThick *= dScale;
|
|
pParam->m_dEl *= dScale;//
|
|
pParam->m_dW *= dScale;
|
|
pParam->m_dH *= dScale;
|
|
|
|
pParam->m_dInterfaceL *= dScale;
|
|
pParam->m_dInterfaceD *= dScale;
|
|
pParam->m_dInterfaceD2 *= dScale;
|
|
pParam->m_dInterfaceL2 *= dScale;
|
|
|
|
pParam->m_dWh *= dScale;
|
|
pParam->m_dWn *= dScale;
|
|
pParam->m_dWh2 *= dScale;
|
|
pParam->m_dWn2 *= dScale;
|
|
|
|
pParam->m_dInsThk *= dScale;
|
|
pParam->m_dInterfaceL3 *= dScale;
|
|
}
|
|
|
|
static bool IsPlasticsMat(int nPos,CString& sMaterial, CString &sODNo)
|
|
{
|
|
sODNo = _T("A");
|
|
const CString sPlastic = _T("UPVC CPVC PVC-C PP-H (PE) PE100 HDPE");
|
|
|
|
CStringArray arTxts;
|
|
CoreTools::SplitStrintToArray(sPlastic, arTxts, _T(' '));
|
|
|
|
for (int i = 0; i < arTxts.GetSize(); i++)
|
|
{
|
|
if (sMaterial.Find(arTxts.GetAt(i)) != -1)
|
|
{
|
|
sODNo = arTxts.GetAt(i);
|
|
//以下 PVC-C PP-H PE100 的国标数据 替代 PVC
|
|
if (sODNo.CompareNoCase(_T("PVC-C")) == 0)
|
|
sODNo = _T("CPVC");
|
|
|
|
if (sODNo.CompareNoCase(_T("(PE)")) == 0)
|
|
sODNo = _T("PE");
|
|
|
|
if (sODNo.CompareNoCase(_T("PE100")) == 0)
|
|
sODNo = _T("PE");
|
|
|
|
if (sODNo.CompareNoCase(_T("(PE100)")) == 0)
|
|
sODNo = _T("PE");
|
|
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void DLLIMPEXP XDataMapToPipeParam(const AecDbObjXDataMap* pXDataMapSrc,WPipe::PipeParam* pParamL)
|
|
{
|
|
if (pXDataMapSrc != NULL && pParamL != NULL)
|
|
{
|
|
//D
|
|
double dVal = 100.0;
|
|
pXDataMapSrc->GetAt(PIPE_D,dVal);
|
|
pParamL->m_dD = dVal;
|
|
|
|
//eD
|
|
int nDir = 0;
|
|
pXDataMapSrc->GetAt(PIPE_DRAWDIR,nDir);
|
|
pParamL->m_eD = (WPipe::EDia)(nDir);
|
|
|
|
//DN
|
|
dVal = 100.0;
|
|
pXDataMapSrc->GetAt(PIPE_DN,dVal);
|
|
pParamL->m_dDN = dVal;
|
|
|
|
//OD
|
|
dVal = 100.0;
|
|
pXDataMapSrc->GetAt(PIPE_OD,dVal);
|
|
pParamL->m_dOD = dVal;
|
|
|
|
//Thick
|
|
dVal = 100.0;
|
|
pXDataMapSrc->GetAt(PIPE_THICK,dVal);
|
|
pParamL->m_dThick = dVal;
|
|
|
|
//补充风管壁厚
|
|
dVal = 0.0;
|
|
if ( pXDataMapSrc->GetAt(DUCT_THICK, dVal) )
|
|
pParamL->m_dThick = dVal;
|
|
|
|
//EL
|
|
|
|
//Ratio
|
|
dVal = 1.5;
|
|
pXDataMapSrc->GetAt(PIPE_RATIO,dVal);
|
|
pParamL->m_dRRatio = dVal;
|
|
|
|
pXDataMapSrc->GetAt(KEY_RadRatio,pParamL->m_nRadioOn);
|
|
pXDataMapSrc->GetAt(PIPE_PIPCMD, pParamL->nPIPCmd);
|
|
pXDataMapSrc->GetAt(PIPE_ODSN, pParamL->szODSn);
|
|
pXDataMapSrc->GetAt(PIPE_FLANGNOBOM, pParamL->m_bFlangNoBom);
|
|
|
|
//dW
|
|
dVal = 0.0;
|
|
pXDataMapSrc->GetAt(DUCT_W, dVal);
|
|
pParamL->m_dW = dVal;
|
|
|
|
//dH
|
|
dVal = 0.0;
|
|
pXDataMapSrc->GetAt(DUCT_H, dVal);
|
|
pParamL->m_dH = dVal;
|
|
|
|
//app
|
|
nDir = 0;
|
|
pXDataMapSrc->GetAt(PIPE_EAPP, nDir);
|
|
pParamL->m_app = (WPipe::EApp)nDir;
|
|
|
|
//nConnectType
|
|
nDir = 0;
|
|
pXDataMapSrc->GetAt(PIPE_CONNECT,nDir);
|
|
pParamL->m_nConnectType = nDir;
|
|
|
|
//dInterfaceL
|
|
dVal = 0.0;
|
|
pXDataMapSrc->GetAt(PIPE_INTERFACEL,dVal);
|
|
pParamL->m_dInterfaceL = dVal;
|
|
|
|
//dInterfaceD
|
|
dVal = 0.0;
|
|
pXDataMapSrc->GetAt(PIPE_INTERFACED,dVal);
|
|
pParamL->m_dInterfaceD = dVal;
|
|
|
|
//dInterfaceD2
|
|
dVal = 0.0;
|
|
pXDataMapSrc->GetAt(PIPE_INTERFACED2,dVal);
|
|
pParamL->m_dInterfaceD2 = dVal;
|
|
|
|
//dInterfaceL2
|
|
dVal = 0.0;
|
|
pXDataMapSrc->GetAt(PIPE_INTERFACEL2,dVal);
|
|
pParamL->m_dInterfaceL2 = dVal;
|
|
|
|
//dInsThk
|
|
dVal = 1.0;
|
|
pXDataMapSrc->GetAt(PIPE_INSTHICK,dVal);
|
|
pParamL->m_dInsThk = dVal;
|
|
|
|
//dInterfaceL3
|
|
dVal = 0.0;
|
|
pXDataMapSrc->GetAt(PIPE_INTERFACEL3,dVal);
|
|
pParamL->m_dInterfaceL3 = dVal;
|
|
|
|
CString sVal;
|
|
pXDataMapSrc->GetAt(PIPE_FLANGF, sVal);
|
|
_tcscpy(pParamL->m_szEndF, sVal);
|
|
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_GASKET, sVal);
|
|
_tcscpy(pParamL->m_szGastInf, sVal);
|
|
|
|
//m_eRed
|
|
//m_vtECCen
|
|
//m_vtDir
|
|
//m_eElBase
|
|
|
|
//szPipeno
|
|
pXDataMapSrc->GetAt(PIPE_NO,sVal);
|
|
_tcscpy(pParamL->szPipeno,sVal);
|
|
|
|
//szMertial
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_MATERIAL,sVal);
|
|
_tcscpy(pParamL->szMertial,sVal);
|
|
|
|
//兼容旧图
|
|
if (_tcslen(pParamL->szODSn) == 0)
|
|
{
|
|
CString sODSn = _T("B");
|
|
if (IsPlasticsMat(0, sVal, sODSn))
|
|
{
|
|
_tcscpy(pParamL->szODSn, sODSn);
|
|
pParamL->m_eD = WPipe::eOD;
|
|
pParamL->m_nRadioOn = 1;
|
|
pParamL->m_nConnectType = 1;
|
|
}
|
|
}
|
|
|
|
//szMertialFit
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_MATERIALFT,sVal);
|
|
_tcscpy(pParamL->szMertialFit,sVal);
|
|
|
|
//szZoneNo
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_ZONE,sVal);
|
|
_tcscpy(pParamL->szZoneNo,sVal);
|
|
|
|
//UNITNO
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_UNITNO, sVal);
|
|
_tcscpy(pParamL->szUnitNo, sVal);
|
|
|
|
//szInsMtr
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(DOC_INSMATER,sVal);
|
|
_tcscpy(pParamL->szInsMtr,sVal);
|
|
|
|
//szDescr
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_DESCR,sVal);
|
|
_tcscpy(pParamL->szDescr,sVal);
|
|
|
|
//szSys
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_SYS,sVal);
|
|
_tcscpy(pParamL->szSys,sVal);
|
|
|
|
nDir = 0;
|
|
pXDataMapSrc->GetAt(PIPE_COLOR,nDir);
|
|
pParamL->m_nPipeColor = nDir;
|
|
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_ODSN, sVal);
|
|
_tcscpy(pParamL->szODSn, sVal);
|
|
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_SHTNO, sVal);
|
|
_tcscpy(pParamL->szShtNo, sVal);
|
|
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_STDNO, sVal);
|
|
_tcscpy(pParamL->szStdNo, sVal);
|
|
|
|
//m_nGroupID
|
|
//?
|
|
|
|
//LEVEL
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_LEVEL,sVal);
|
|
_tcscpy(pParamL->szLevel,sVal);
|
|
|
|
pXDataMapSrc->GetAt(PID_PIPE_DPRESS,pParamL->m_dPress);
|
|
|
|
//szZone
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_ZONE,sVal);
|
|
_tcscpy(pParamL->szZone,sVal);
|
|
|
|
//szMedia
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_MEDIA,sVal);
|
|
_tcscpy(pParamL->szMedia,sVal);
|
|
|
|
//pipeno
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_NO,sVal);
|
|
_tcscpy(pParamL->szPipeno,sVal);
|
|
|
|
//szno
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(KEY_NO, sVal);
|
|
_tcscpy(pParamL->szNo, sVal);
|
|
|
|
//Spec
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_SPEC,sVal);
|
|
_tcscpy(pParamL->szSpec,sVal);
|
|
|
|
//LineNo
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_LINENO,sVal);
|
|
_tcscpy(pParamL->szLineNo,sVal);
|
|
|
|
//szInsTag
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_INSTAG,sVal);
|
|
_tcscpy(pParamL->szInsTag,sVal);
|
|
|
|
//szInsDim
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(DOC_INSDIM,sVal);
|
|
_tcscpy(pParamL->szInsDim,sVal);
|
|
|
|
//szInsMateral
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(DOC_INSMATER,sVal);
|
|
_tcscpy(pParamL->szInsMateral,sVal);
|
|
|
|
//szInsSpec
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(DOC_INSSPEC,sVal);
|
|
_tcscpy(pParamL->szInsSpec,sVal);
|
|
|
|
//DOC_TRAMTOINF
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(DOC_TRAMTOINF,sVal);
|
|
_tcscpy(pParamL->szTraMtoInfo,sVal);
|
|
|
|
//szTraDescr
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(DOC_TRADESCR,sVal);
|
|
_tcscpy(pParamL->szTraDescr,sVal);
|
|
|
|
//szFitType
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_FITTYPE,sVal);
|
|
_tcscpy(pParamL->szFitType,sVal);
|
|
|
|
//szMtoInfo
|
|
sVal = _T("");
|
|
pXDataMapSrc->GetAt(PIPE_MTOALL,sVal);
|
|
_tcscpy(pParamL->szMtoInfo,sVal);
|
|
|
|
//以下是全局设置信息,Param中没有对应
|
|
nDir = 0;
|
|
pXDataMapSrc->GetAt(KEY_2DSTYLE,nDir);
|
|
//??
|
|
|
|
nDir = 0;
|
|
pXDataMapSrc->GetAt(KEY_SINGLE,nDir);
|
|
//??
|
|
|
|
pXDataMapSrc->GetAt(PIPE_TDN,dVal);
|
|
//??
|
|
|
|
dVal = 100.0;
|
|
pXDataMapSrc->GetAt(PIPE_TOD,dVal);
|
|
//??
|
|
|
|
nDir = 0;
|
|
pXDataMapSrc->GetAt(PIPE_ELBOWFLG,nDir);
|
|
//??
|
|
|
|
nDir = 0;
|
|
pXDataMapSrc->GetAt(PIPE_BWELDDOT,nDir);
|
|
//??
|
|
|
|
dVal = 1.0;
|
|
pXDataMapSrc->GetAt(DOC_PLOTWIDTH,dVal);
|
|
//??
|
|
|
|
dVal = 1.0;
|
|
pXDataMapSrc->GetAt(DOC_WELDDIA,dVal);
|
|
//??
|
|
|
|
pXDataMapSrc->GetAt(PIPE_PIDD,dVal);
|
|
//??
|
|
}
|
|
}
|
|
|
|
WPipe::PipeParam* AecDbEwPipe::GetPipeParam() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
WPipe::PipeParam* pParamL = new WPipe::PipeParam;
|
|
memset(pParamL, 0, sizeof(WPipe::PipeParam));
|
|
|
|
const AecDbObjXDataMap* pXDataMapSrc = &m_mapSpecXData;
|
|
|
|
XDataMapToPipeParam(pXDataMapSrc,pParamL);
|
|
|
|
AcGePoint3d pts;
|
|
getStartPoint(pts);
|
|
pParamL->m_dEl = pts.z;
|
|
|
|
return pParamL;
|
|
}
|
|
|
|
//获取位置标高0 中心 1顶部 2内底部 3 外底部 4内顶部
|
|
float AecDbEwPipe::GetElevation(int nPos) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//默认是管子水平
|
|
AcGePoint3d pts;
|
|
getStartPoint(pts);
|
|
|
|
double dOD = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_OD,dOD);
|
|
|
|
double dt = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_THICK,dt);
|
|
|
|
double dEl = pts.z;
|
|
switch(nPos)
|
|
{
|
|
case 0://中心
|
|
{
|
|
break;
|
|
}
|
|
case 1://顶部
|
|
{
|
|
dEl += dOD * 0.5;
|
|
break;
|
|
}
|
|
case 2://内底部
|
|
{
|
|
dEl -= dOD * 0.5;
|
|
dEl += dt;
|
|
|
|
break;
|
|
}
|
|
case 3://外底部
|
|
{
|
|
dEl -= dOD * 0.5;
|
|
break;
|
|
}
|
|
case 4://内顶部
|
|
{
|
|
dEl += dOD * 0.5;
|
|
dEl -= dt;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return (float)dEl;
|
|
}
|
|
|
|
bool AecDbEwPipe::IsShowFlowDir() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_bShowFlowDir;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::ShowFlowDir(bool bShowDir)
|
|
{
|
|
assertWriteEnabled();
|
|
m_bShowFlowDir = bShowDir;
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool AecDbEwPipe::IsMainPipe() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_bIsMainLock;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::SetMainPipe(bool bIsMain)
|
|
{
|
|
assertWriteEnabled();
|
|
m_bIsMainLock = bIsMain;
|
|
if (bIsMain)
|
|
{
|
|
m_bIsMinLock = false;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool AecDbEwPipe::IsMinorPipe() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_bIsMinLock;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::SetMinorPipe(bool bIsMinor)
|
|
{
|
|
assertWriteEnabled();
|
|
m_bIsMinLock = bIsMinor;
|
|
if (bIsMinor)
|
|
{
|
|
m_bIsMainLock = false;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbEwPipe::SetLayerByXDataMap()
|
|
{
|
|
AssertWriteEnabled();
|
|
CString sSys(_T(""));
|
|
m_mapSpecXData.GetAt(PIPE_SYS, sSys);
|
|
if (sSys.IsEmpty()) return;
|
|
|
|
AcDbObjectId idCenLay, idOutLay, idSingle, idDash, idCen;
|
|
|
|
idCenLay = CoreTools::getLyByPipeSys(sSys, true);
|
|
idOutLay = CoreTools::getLyByPipeSys(sSys, false);
|
|
|
|
AcDbObjectId idPipeLayer(CoreTools::getLyForPipe(sSys));
|
|
if (idPipeLayer.isValid())
|
|
setLayer(idPipeLayer);
|
|
|
|
idSingle = CoreTools::AecInitLayerEx(LAY_PIPE_SINGLE, sSys, 7, _T("Continuous"), NULL);
|
|
|
|
m_mapSpecXData.SetAt(PIPE_CENTLAY, idCenLay);
|
|
m_mapSpecXData.SetAt(PIPE_OUTDLAY, idOutLay);
|
|
m_mapSpecXData.SetAt(PIPE_SINGLAY, idSingle);
|
|
|
|
idDash = CoreTools::AecInitLayerEx(LAY_PIPE_DASH, sSys, 8, _T("dash"), NULL);
|
|
SetDashLayer(idDash);
|
|
SetCenterLayer(idCenLay);
|
|
SetDoubleLayer(idOutLay);
|
|
SetSingleLayer(idCenLay);
|
|
int nColor = CoreTools::getPipeColorBySystem(sSys);
|
|
m_mapSpecXData.SetAt(PIPE_COLOR, nColor);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::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 > AecDbEwPipe::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::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 (AecDbEwPipe::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbEwPipe::subList() const
|
|
{
|
|
acutPrintf(_T("\n管线:"));
|
|
AecDbEwPipeBase::subList();
|
|
}
|
|
|
|
bool AecDbEwPipe::GetBimInfoTip(CString& sInfoTip) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
WPipe::PipeParam* pParam = GetPipeParam();
|
|
if (pParam != NULL)
|
|
{
|
|
if (CoreTools::IsMetersUnit())
|
|
{
|
|
pParam->m_dDN *= 1000;
|
|
pParam->m_dOD *= 1000;
|
|
pParam->m_dThick *= 1000;
|
|
}
|
|
|
|
CString sField,sFmt;
|
|
LPCTSTR psTypes[] = {_T("焊接"),_T("承插"),_T("螺纹"),_T("法兰管"),_T("卡箍管线"),_T("沟槽管线"),NULL};
|
|
|
|
sField = _T("管线:\n");
|
|
sInfoTip += sField;
|
|
|
|
MAKEFIELD(_T("公称直径(mm)"),_T("%d"),(int)(pParam->m_dDN + 0.5),sInfoTip);
|
|
|
|
MAKEFIELD(_T("外径(mm)"),_T("%d"),(int)(pParam->m_dOD + 0.5),sInfoTip);
|
|
|
|
MAKEFIELD(_T("壁厚(mm)"),_T("%.1f"),pParam->m_dThick,sInfoTip);
|
|
|
|
MAKEFIELD(_T("弯头曲率"),_T("%.1f"),pParam->m_dRRatio,sInfoTip);
|
|
|
|
AcGeVector3d vt = EndPoint() - StartPoint();
|
|
if (vt.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
MAKEFIELD(_T("起点标高"),_T("%.1f"), StartPoint().z,sInfoTip);
|
|
MAKEFIELD(_T("终点标高"), _T("%.1f"), EndPoint().z, sInfoTip);
|
|
}
|
|
else
|
|
{
|
|
MAKEFIELD(_T("中心标高"), _T("%.1f"), pParam->m_dEl, sInfoTip);
|
|
MAKEFIELD(_T("管底标高"), _T("%.1f"), pParam->m_dEl - 0.5 * pParam->m_dOD, sInfoTip);
|
|
}
|
|
|
|
//0 焊接 1: 承插 2 螺纹 3 法兰管
|
|
if (pParam->m_nConnectType >= 0 && pParam->m_nConnectType < sizeof(psTypes) / sizeof(psTypes[0]))
|
|
{
|
|
MAKEFIELD(_T("类型"), _T("%s"), psTypes[pParam->m_nConnectType], sInfoTip);
|
|
}
|
|
|
|
MAKEFIELD(_T("材质"),_T("%s"),pParam->szMertial,sInfoTip);
|
|
|
|
MAKEFIELD(_T("系统"),_T("%s"),pParam->szSys,sInfoTip);
|
|
|
|
MAKEFIELD(_T("压力"),_T("%.1f"),pParam->m_dPress,sInfoTip);
|
|
|
|
MAKEFIELD(_T("管号"),_T("%s"),pParam->szPipeno,sInfoTip);
|
|
|
|
MAKEFIELD(_T("区号"),_T("%s"),pParam->szZone,sInfoTip);
|
|
|
|
MAKEFIELD(_T("介质"),_T("%s"),pParam->szMedia,sInfoTip);
|
|
|
|
MAKEFIELD(_T("序号"),_T("%s"),pParam->szNo,sInfoTip);
|
|
|
|
MAKEFIELD(_T("用途"),_T("%s"),pParam->szSpec,sInfoTip);
|
|
|
|
MAKEFIELD(_T("描述"),_T("%s"),pParam->szDescr,sInfoTip);
|
|
|
|
MAKEFIELD(_T("等级"),_T("%s"),pParam->szLevel,sInfoTip);
|
|
|
|
MAKEFIELD(_T("外径系列"), _T("%s"), pParam->szODSn, sInfoTip);
|
|
|
|
MAKEFIELD(_T("保温层厚"),_T("%.1f"),pParam->m_dInsThk,sInfoTip);
|
|
|
|
MAKEFIELD(_T("保温材料"),_T("%s"),pParam->szInsMtr,sInfoTip);
|
|
|
|
delete pParam;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
EPosition AecDbEwPipe::ExplainGripIndex(int nIndex) const
|
|
{
|
|
EPosition ePos = eStart;
|
|
switch(nIndex)
|
|
{
|
|
case 0:
|
|
{
|
|
ePos = eStart;
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
ePos = eMid;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
ePos = eEnd;
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
ePos = eCommand0;
|
|
break;
|
|
}
|
|
case 4:
|
|
{
|
|
ePos = eCommand1;
|
|
break;
|
|
}
|
|
case 5:
|
|
{
|
|
ePos = eCommand2;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return ePos;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::ImpGetGripPonts(AcGePoint3dArray& gripPoints,const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
const int nStbitflags = GRIPPT_RESP_FROM_EWFIT;
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
//直线管
|
|
AcDbLine *pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta, ptEnd;
|
|
m_pBaseCurve->getStartPoint(ptSta);
|
|
m_pBaseCurve->getEndPoint(ptEnd);
|
|
|
|
double dSta = 0.0, dEnd = 0.0;
|
|
m_pBaseCurve->getStartParam(dSta);
|
|
m_pBaseCurve->getEndParam(dEnd);
|
|
|
|
AcGeVector3d vtDir = ptEnd - ptSta;
|
|
vtDir.normalize();
|
|
|
|
AcGePoint3d ptMid;
|
|
m_pBaseCurve->getPointAtParam((dSta + dEnd) / 2.0, ptMid);
|
|
|
|
CString sCrossSectionScr = _T("");
|
|
m_mapSpecXData.GetAt(_T("m_sCrossSectionScr"), sCrossSectionScr);
|
|
if (!sCrossSectionScr.IsEmpty())
|
|
{
|
|
double dOD = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_OD, dOD);
|
|
|
|
AcGeVector3d vtPer = vtDir.perpVector();
|
|
vtPer *= 0.5 * dOD;
|
|
ptMid += vtPer;
|
|
|
|
gripPoints.append(ptMid);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
gripPoints.append(ptSta);
|
|
gripPoints.append(ptMid);
|
|
gripPoints.append(ptEnd);
|
|
|
|
if (bitflags == nStbitflags)
|
|
return Acad::eOk;
|
|
|
|
AcGeVector3d vtPerv = vtDir.perpVector();
|
|
AcGeVector3d vtNorm = vtDir.crossProduct(vtPerv);
|
|
vtNorm.normalize();
|
|
|
|
AcGePoint3d ptGe[4];
|
|
AcGeVector3d vtLine = ptEnd - ptSta;
|
|
vtLine.normalize();
|
|
|
|
AcGeVector3d vtVer = vtLine;
|
|
vtVer.normalize();
|
|
vtVer.rotateBy(PI / 2.0, vtNorm);
|
|
|
|
//增加三个命令夹点
|
|
AcGePoint3d ptCmd[3]; //Cmd 0,1
|
|
vtLine.normalize();
|
|
|
|
//按 15 个像素点
|
|
double dCmd = PixelToWcs(15);
|
|
|
|
if (vtLine.isParallelTo(AcGeVector3d::kZAxis))//立管
|
|
{
|
|
vtLine = AcGeVector3d::kXAxis;
|
|
|
|
ptCmd[0] = ptSta - dCmd * vtLine;
|
|
ptCmd[1] = ptEnd + dCmd * vtLine;
|
|
ptCmd[2] = ptMid + dCmd * AcGeVector3d::kYAxis;
|
|
}
|
|
else
|
|
{
|
|
ptCmd[0] = ptSta - dCmd * vtLine;
|
|
ptCmd[1] = ptEnd + dCmd * vtLine;
|
|
ptCmd[2] = ptMid + dCmd * vtVer;
|
|
}
|
|
|
|
gripPoints.append(ptCmd[0]);
|
|
gripPoints.append(ptCmd[1]);
|
|
gripPoints.append(ptCmd[2]);
|
|
|
|
//后面的是断管符号
|
|
//断管符号
|
|
AcGePoint3d ptGeBK, ptGeT;
|
|
CString sIndex;
|
|
for (int i = 0; i < PIPE_BROKENNUM; i++)
|
|
{
|
|
sIndex.Format(_T("BKOP%d"), i);
|
|
if (m_mapSpecXData.GetAt(sIndex, ptGeBK))
|
|
{
|
|
//开始
|
|
ptGeT = ptSta + vtDir * ptGeBK.x;
|
|
gripPoints.append(ptGeT);
|
|
|
|
//中间
|
|
ptGeT += vtDir * ptGeBK.y * 0.5;
|
|
gripPoints.append(ptGeT);
|
|
|
|
//结束
|
|
ptGeT += vtDir * ptGeBK.y * 0.5;
|
|
gripPoints.append(ptGeT);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AcGePoint3d ptSta, ptEnd,ptMid;
|
|
m_pBaseCurve->getStartPoint(ptSta);
|
|
m_pBaseCurve->getEndPoint(ptEnd);
|
|
|
|
//增加三个命令夹点
|
|
AcGePoint3d ptCmd[3]; //Cmd 0,1
|
|
|
|
//按 15 个像素点
|
|
double dCmd = PixelToWcs(15);
|
|
|
|
double dSta = 0.0, dEnd = 0.0;
|
|
m_pBaseCurve->getStartParam(dSta);
|
|
m_pBaseCurve->getEndParam(dEnd);
|
|
|
|
AcGeVector3d vtS, vtE;
|
|
m_pBaseCurve->getFirstDeriv(dSta,vtS);
|
|
m_pBaseCurve->getFirstDeriv(dEnd,vtE);
|
|
m_pBaseCurve->getPointAtParam((dSta + dEnd) / 2.0, ptMid);
|
|
|
|
vtS.normalize(); vtE.normalize();
|
|
ptCmd[0] = ptSta - dCmd * vtS;
|
|
ptCmd[1] = ptEnd + dCmd * vtE;
|
|
|
|
gripPoints.append(ptSta);
|
|
gripPoints.append(ptMid);
|
|
gripPoints.append(ptEnd);
|
|
|
|
gripPoints.append(ptCmd[0]);
|
|
gripPoints.append(ptCmd[1]);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#if ARX>16
|
|
Acad::ErrorStatus AecDbEwPipe::subGetGripPoints( AcDbGripDataPtrArray& grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d& curViewDir,
|
|
const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcGePoint3dArray gripPoints;
|
|
ImpGetGripPonts(gripPoints,bitflags);
|
|
|
|
int nColor = kWhite;
|
|
AcDbGripData* pGripData = NULL;
|
|
if ( bitflags >= 1394)
|
|
{
|
|
memset(&m_pGripAppData[0],0,sizeof(AecGripData));
|
|
m_pGripAppData[0].nIndex = 0;
|
|
m_pGripAppData[0].ePos = eFlag;
|
|
m_pGripAppData[0].nColor = nColor;
|
|
m_pGripAppData[0].ptGrip = gripPoints.at(0);
|
|
m_pGripAppData[0].pOwner = (AcDbEntity*)this;
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(gripPoints.at(0));
|
|
pGripData->setAppData((void*)&m_pGripAppData[0]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
_tcscpy(m_pGripAppData[0].szTip,_T("点击定位造族<管道>记录"));
|
|
_tcscpy(m_pGripAppData[0].szID,m_sGUID);
|
|
grips.append(pGripData);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
CString sCmd = GetGripCmd();//绘制管道
|
|
EPosition ePos;
|
|
for (int i = 0;i < GRIP_MAXNUM && i < gripPoints.length();i++)
|
|
{
|
|
ePos = ExplainGripIndex(i);
|
|
if (ePos >= eCommand0 && ePos <= eCommand19)
|
|
{
|
|
memset(&m_pGripAppData[i],0,sizeof(AecGripData));
|
|
m_pGripAppData[i].nIndex = i;
|
|
m_pGripAppData[i].ePos = ePos;
|
|
m_pGripAppData[i].nColor = nColor;
|
|
m_pGripAppData[i].ptGrip = gripPoints.at(i);
|
|
_tcscpy(m_pGripAppData[i].szTip,sCmd);
|
|
_tcscpy(m_pGripAppData[i].szID,m_sGUID);
|
|
m_pGripAppData[i].pOwner = (AcDbEntity*)this;
|
|
m_pGripAppData[i].idHost = this->objectId();
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(gripPoints.at(i));
|
|
pGripData->setAppData((void*)&m_pGripAppData[i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
}
|
|
else
|
|
{
|
|
memset(&m_pGripAppData[i],0,sizeof(AecGripData));
|
|
m_pGripAppData[i].nIndex = i;
|
|
m_pGripAppData[i].ePos = ePos;
|
|
m_pGripAppData[i].nColor = nColor;
|
|
m_pGripAppData[i].ptGrip = gripPoints.at(i);
|
|
_tcscpy(m_pGripAppData[i].szTip,_T("管道拉伸夹点"));
|
|
_tcscpy(m_pGripAppData[i].szID,m_sGUID);
|
|
m_pGripAppData[i].pOwner = (AcDbEntity*)this;
|
|
m_pGripAppData[i].idHost = this->objectId();
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(gripPoints.at(i));
|
|
pGripData->setAppData((void*)&m_pGripAppData[i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
}
|
|
grips.append(pGripData);
|
|
}
|
|
|
|
//调用基类加入单击修改
|
|
SubAddHitEditGrip(grips);
|
|
|
|
//动态标注
|
|
//直线,半径 标注风格
|
|
if (!grips.isEmpty())
|
|
{
|
|
SubAddDimPoints(grips,curViewDir);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::SubAddDimPoints(AcDbGripDataPtrArray& grips,const AcGeVector3d& curViewDir) const
|
|
{
|
|
if (GetDimGripOff())
|
|
return Acad::eOk;
|
|
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
//长度
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
AcGeVector3d vtL = ptEnd - ptSta;
|
|
vtL.normalize();
|
|
AcGePoint3d ptMid = MidPoint(ptSta,ptEnd);
|
|
|
|
double dDn = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_DN,dDn);
|
|
|
|
double dOD = 0.0,dt = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_THICK,dt);
|
|
m_mapSpecXData.GetAt(PIPE_OD,dOD);
|
|
|
|
if (vtL.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
ptSta.x -= dDn;
|
|
ptEnd.x -= dDn;
|
|
ptMid.x -= dDn;
|
|
|
|
AddDimPoints(grips,curViewDir,ptSta,ptEnd,ptMid,0);
|
|
|
|
ptSta.x -= dDn;
|
|
ptEnd.x -= dDn;
|
|
ptMid.x -= dDn;
|
|
|
|
AddDimPoints(grips,curViewDir,ptSta,ptEnd,ptMid,4,dOD,dt);
|
|
}
|
|
else
|
|
{
|
|
ptSta.z -= dDn;
|
|
ptEnd.z -= dDn;
|
|
ptMid.z -= 10.0 * 100.0;//标注文字位置
|
|
ptMid -= vtL * 2.0 * dDn;
|
|
AddDimPoints(grips,curViewDir,ptSta,ptEnd,ptMid,0);
|
|
|
|
AcGeVector3d vtv = vtL;
|
|
vtv.rotateBy(-PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
ptSta += vtv * dDn;
|
|
ptEnd += vtv * dDn;
|
|
ptMid += vtv * dDn;
|
|
|
|
AddDimPoints(grips,curViewDir,ptSta,ptEnd,ptMid,4,dOD,dt);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::subMoveGripPointsAt(const AcDbVoidPtrArray& gripAppData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecGripData* pAppData = NULL;
|
|
AcDbIntArray arIndex;
|
|
|
|
if (HitOnGripEdit(gripAppData))
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
if ( !gripAppData.isEmpty() )
|
|
{
|
|
pAppData = (AecGripData*)gripAppData.first();
|
|
arIndex.append(pAppData->nIndex);
|
|
}
|
|
else
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int nGripIndex = arIndex.first();
|
|
EPosition ePos = ExplainGripIndex(nGripIndex);
|
|
|
|
bool bMsgSendToAllInfs = false;
|
|
AcGeVector3d vtOffset = offset;
|
|
if(Is2DView())//如果是2D视图
|
|
{
|
|
//投影到XY
|
|
vtOffset = offset.orthoProject(GetUcsZvt());
|
|
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
//小于10度的按照投影处理
|
|
//在夹角小于10度,认为是橡皮筋拉伸
|
|
AcGeVector3d vtLn = pLn->endPoint() - pLn->startPoint();
|
|
if (ePos == eStart || ePos == eEnd)
|
|
{
|
|
double dAngle = vtOffset.angleTo(vtLn);
|
|
dAngle *= 180.0 / PI;
|
|
//acutPrintf(_T("\nAngle = %g"),dAngle);
|
|
if ( ( (dAngle - 10.0 ) < 1.e-6 ) ||
|
|
( (180.0 - dAngle - 10.0 ) < 1.e-6) )
|
|
{
|
|
//认为是橡皮筋拉伸
|
|
AcGeVector3d vtNorm = vtLn;
|
|
vtNorm.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
AcGeVector3d vtOffsetOnLn = vtOffset.orthoProject(vtNorm);
|
|
vtOffsetOnLn.normalize();
|
|
vtOffsetOnLn *= vtOffset.length();
|
|
vtOffset = vtOffsetOnLn;
|
|
|
|
//仅仅本端口
|
|
bMsgSendToAllInfs = false;
|
|
}
|
|
else
|
|
{
|
|
bMsgSendToAllInfs = true;
|
|
}
|
|
}
|
|
else if (ePos == eMid)
|
|
{
|
|
AcGeVector3d vtNorm = vtLn;
|
|
vtLn.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
double dAngle = vtOffset.angleTo(vtLn);
|
|
dAngle *= 180.0 / PI;
|
|
|
|
//acutPrintf(_T("\nAngle = %g"),dAngle);
|
|
if ( ( (dAngle - 10.0 ) < 1.e-6 ) ||
|
|
( (180.0 - dAngle - 10.0 ) < 1.e-6) )
|
|
{
|
|
//认为是橡皮筋拉伸
|
|
AcGeVector3d vtOffsetOnLn = vtOffset.orthoProject(vtNorm);
|
|
vtOffsetOnLn.normalize();
|
|
vtOffsetOnLn *= vtOffset.length();
|
|
vtOffset = vtOffsetOnLn;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtOffset);
|
|
|
|
if (nGripIndex > 5) //断管符号移动
|
|
{
|
|
nGripIndex -= 6;
|
|
return moveGripBrokenOpen(nGripIndex,offset);
|
|
}
|
|
|
|
GripMessage msg;
|
|
memset(&msg,0,sizeof(GripMessage));
|
|
//reset
|
|
msg.nSegindex = -1;
|
|
msg.nType = -1;
|
|
msg.idHost.setNull();
|
|
msg.pParam = 0;
|
|
msg.nData = -1;
|
|
_tcscpy(msg.szLockId, _T("0"));//锁定id,如果有
|
|
msg.fData = 0;
|
|
msg.nSegindex = 0;
|
|
msg.nSubSegIndex = 0;
|
|
msg.vtOffset.set(0,0,0);
|
|
msg.ptGrip.set(0,0,0);
|
|
|
|
AecInterface inf;
|
|
switch (ePos)
|
|
{
|
|
case eStart:
|
|
{
|
|
TransformAssocInf(0,xformM);
|
|
|
|
msg.nType = ePos;
|
|
msg.nData = bMsgSendToAllInfs ? -1 : 0;//控制消息源
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
//如果是shift键落发消息
|
|
bool bShift=(GetKeyState(VK_CAPITAL)&-128)!=0;
|
|
if (bShift)
|
|
{
|
|
PushGripMessage(msg);
|
|
break;
|
|
}
|
|
|
|
break;
|
|
}
|
|
case eEnd:
|
|
{
|
|
TransformAssocInf(1,xformM);
|
|
|
|
msg.nType = ePos;
|
|
msg.nData = bMsgSendToAllInfs ? -1 : 1;//控制消息源
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
//如果是shift键落发消息
|
|
bool bShift=(GetKeyState(VK_CAPITAL)&-128)!=0;
|
|
if (bShift)
|
|
{
|
|
PushGripMessage(msg);
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
case eMid:
|
|
{
|
|
TransformBy(xformM);
|
|
|
|
msg.nType = ePos;
|
|
msg.nData = -1;
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
//如果是shift键落下,不发消息
|
|
bool bShift=(GetKeyState(VK_CAPITAL)&-128)!=0;
|
|
if (bShift)
|
|
{
|
|
break;
|
|
}
|
|
|
|
PushGripMessage(msg);
|
|
|
|
TransformHole(xformM);
|
|
|
|
break;
|
|
}
|
|
case eCommand0:
|
|
{
|
|
msg.nType = eCommand0;
|
|
msg.nData = 0;
|
|
GetInterface(msg.nData,inf);
|
|
msg.ptGrip = inf.ptPos;
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
CString sCmd = GetGripCmd();
|
|
if (!sCmd.IsEmpty())
|
|
{
|
|
acedPostCommand(_T("\x03"));
|
|
sCmd += _T("\n");
|
|
acedPostCommand(sCmd);
|
|
}
|
|
break;
|
|
}
|
|
case eCommand1:
|
|
{
|
|
msg.nType = eCommand1;
|
|
msg.nData = 1;
|
|
GetInterface(msg.nData,inf);
|
|
msg.ptGrip = inf.ptPos;
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
CString sCmd = GetGripCmd();
|
|
if (!sCmd.IsEmpty())
|
|
{
|
|
acedPostCommand(_T("\x03"));
|
|
sCmd += _T("\n");
|
|
acedPostCommand(sCmd);
|
|
}
|
|
break;
|
|
}
|
|
case eCommand2:
|
|
{
|
|
msg.nType = eCommand0;
|
|
msg.nData = 0;//按0接口
|
|
msg.ptGrip = pAppData->ptGrip;
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
CString sCmd = GetGripCmd();
|
|
if (!sCmd.IsEmpty())
|
|
{
|
|
acedPostCommand(_T("\x03"));
|
|
sCmd += _T("\n");
|
|
acedPostCommand(sCmd);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::TransformHole(const AcGeMatrix3d& xform)
|
|
{
|
|
//套管,洞口联动
|
|
if (objectId().isValid())//确认变换时处理
|
|
{
|
|
AcDbObjectIdArray arHoles;
|
|
|
|
//获取所有的套管,判断中心在管子上
|
|
struct resbuf* pRb = acutBuildList(RTDXF0, _T("AEC_X3DPART"), 0);
|
|
|
|
ads_name ss,ent;
|
|
acedSSGet(_T("A"),NULL,NULL,pRb,ss);
|
|
acutRelRb(pRb);
|
|
|
|
AcDbObjectId id;
|
|
Adesk::Int32 nLen = 0;
|
|
acedSSLength(ss,&nLen);
|
|
|
|
AcDbCurve* pBaseCrv = m_pBaseCurve;
|
|
|
|
AcGePoint3d ptOrg;
|
|
CString sName;
|
|
AcDbEntity* pEnt = NULL;
|
|
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
acedSSName(ss,i,ent);
|
|
acdbGetObjectId(id,ent);
|
|
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead))
|
|
{
|
|
AecDbX3dPartEntity* pPart = AecDbX3dPartEntity::cast(pEnt);
|
|
if (pPart != NULL)
|
|
{
|
|
sName = pPart->GetName();
|
|
if (sName.Find(_T("开洞")) != -1 ||
|
|
sName.Find(_T("套管")) != -1)
|
|
{
|
|
ptOrg = pPart->GetOrgPoint(true);
|
|
ptOrg.transformBy(xform);
|
|
|
|
double dParm = 0.0;
|
|
if ( Acad::eOk == pBaseCrv->getParamAtPoint(ptOrg,dParm))
|
|
{
|
|
arHoles.append(id);
|
|
}
|
|
}
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
|
|
acedSSFree(ss);
|
|
|
|
//关联的洞口和套管联动
|
|
/*
|
|
AecDbObjXDataMap::It it = m_mapSpecXData.Begin();
|
|
AecDbObjXDataMap::It end = m_mapSpecXData.End();
|
|
|
|
CString sKey;
|
|
AecXData cVal;
|
|
memset(&cVal,0,sizeof(AecXData));
|
|
|
|
AcDbObjectId idSrc,idCloned;
|
|
for (; it != end;)
|
|
{
|
|
if (!m_mapSpecXData.GetNext(it, sKey, cVal)) break;
|
|
if (sKey.Find(_T("$H")) != -1 && cVal.nVt == VT_BSTR)//可能的实体句柄
|
|
{
|
|
AcDbHandle handle(cVal.pszVal);
|
|
|
|
AcDbObjectId idHole;
|
|
acdbCurDwg()->getAcDbObjectId(idHole,false,handle);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,idHole,AcDb::kForWrite))
|
|
{
|
|
pEnt->transformBy(xform);
|
|
pEnt->close();
|
|
}
|
|
}
|
|
}*/
|
|
|
|
AcDbObjectId idHole;
|
|
for (int n = 0;n < arHoles.length();n++)
|
|
{
|
|
idHole = arHoles.at(n);
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,idHole,AcDb::kForWrite))
|
|
{
|
|
pEnt->transformBy(xform);
|
|
pEnt->close();
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::moveGripBrokenOpen(int nBrokenGrip,const AcGeVector3d& offset)
|
|
{
|
|
AssertWriteEnabled();
|
|
AcGePoint3d ptSta = StartPoint();
|
|
AcGePoint3d ptEnd = EndPoint();
|
|
AcDbLine ln(ptSta,ptEnd);
|
|
|
|
AcGeVector3d vtDir = ptEnd - ptSta;
|
|
vtDir.normalize();
|
|
|
|
int nBrokenindex = nBrokenGrip / 3;
|
|
int nBrokenHit = nBrokenGrip % 3;
|
|
|
|
//断管符号
|
|
double dLen;
|
|
AcGePoint3d ptGeT,ptGeBK,ptGe1,ptGe2,ptGe3;
|
|
AcGePoint3dArray arPoints;
|
|
CString sIndex;
|
|
|
|
for(int i = 0;i < PIPE_BROKENNUM;i++)
|
|
{
|
|
sIndex.Format(_T("BKOP%d"),i);
|
|
if (m_mapSpecXData.GetAt(sIndex,ptGeBK))
|
|
{
|
|
if (nBrokenindex == i)
|
|
{
|
|
//开始
|
|
ptGe1 = ptSta + vtDir * ptGeBK.x;
|
|
|
|
//中间
|
|
ptGe2 = ptGe1 + vtDir * ptGeBK.y * 0.5;
|
|
|
|
//结束
|
|
ptGe3 = ptGe2 + vtDir * ptGeBK.y * 0.5;
|
|
|
|
switch(nBrokenHit)
|
|
{
|
|
case 0: //改长度和断开长度
|
|
{
|
|
ptGe1 += offset;
|
|
ln.getClosestPointTo(ptGe1,ptGe1);
|
|
|
|
ptGeBK.x = ptGe1.distanceTo(ptSta);
|
|
if (ptGeBK.x - ptSta.distanceTo(ptEnd) > 1.e-10)
|
|
{
|
|
//超出算删除
|
|
m_mapSpecXData.RemoveAt(sIndex);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
ptGeBK.y = ptGe3.distanceTo(ptGe1);
|
|
m_mapSpecXData.SetAt(sIndex,ptGeBK);
|
|
|
|
break;
|
|
}
|
|
case 1: // 改长度
|
|
{
|
|
ptGe1 += offset;
|
|
ln.getClosestPointTo(ptGe1,ptGe1);
|
|
|
|
dLen = ptGe3.distanceTo(ptSta);
|
|
if (dLen - ptSta.distanceTo(ptEnd) > 1.e-10)
|
|
{
|
|
//超出算删除
|
|
m_mapSpecXData.RemoveAt(sIndex);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
ptGeBK.x = ptGe1.distanceTo(ptSta);
|
|
m_mapSpecXData.SetAt(sIndex,ptGeBK);
|
|
break;
|
|
}
|
|
case 2://改断开长度
|
|
{
|
|
ptGe3 += offset;
|
|
ln.getClosestPointTo(ptGe3,ptGe3);
|
|
|
|
dLen = ptGe3.distanceTo(ptSta);
|
|
if (dLen - ptSta.distanceTo(ptEnd) > 1.e-10)
|
|
{
|
|
//超出算删除
|
|
m_mapSpecXData.RemoveAt(sIndex);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
dLen = ptGe3.distanceTo(ptGe1);
|
|
ptGeBK.y = dLen;
|
|
m_mapSpecXData.SetAt(sIndex,ptGeBK);
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbEwPipe::GetGripText(int nPos, CString& sText)
|
|
{
|
|
sText = _T("夹点");
|
|
}
|
|
#endif
|
|
|
|
//只针对管子
|
|
Acad::ErrorStatus AecDbEwPipe::Draw2dSingleSegment(AcGiDraw &dc,AcDbPolyline* pPl) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbObjectId idCurLay = dc.GetLayerId();
|
|
AcDbObjectId idCurLty = dc.GetLineTypeId();
|
|
|
|
if (pPl != NULL)
|
|
{
|
|
double dW = 0.0;
|
|
if (m_pRegion != NULL)
|
|
{
|
|
//region水平投影放置为准
|
|
AcDbExtents ext;
|
|
m_pRegion->getGeomExtents(ext);
|
|
dW = fabs(ext.maxPoint().x - ext.minPoint().x);
|
|
}
|
|
|
|
dc.SetLayer(m_idSingleLayer);
|
|
|
|
//单线 使用实线
|
|
//dc.SetLineType(m_idSingleLnType);
|
|
dc.SetLineType(KTSetting::InitLineStyle(_T("Continuous")));
|
|
|
|
double dWt = 0.0;
|
|
pPl->getConstantWidth(dWt);
|
|
|
|
int nType = 0;
|
|
m_mapSpecXData.GetAt(PIPE_CONNECTTYPE,nType);
|
|
EPipeConnect eType = (EPipeConnect)nType;
|
|
|
|
double dDn = dW;
|
|
m_mapSpecXData.GetAt(PIPE_DN,dDn);
|
|
|
|
double dEnd = 0.0,dLen = 0.0,dSta = 0.0;
|
|
pPl->getEndParam(dEnd);
|
|
pPl->getDistAtParam(dEnd,dLen);
|
|
pPl->getStartParam(dSta);
|
|
|
|
AcGePoint3d ptGe[4],ptPos;
|
|
AcGeVector3d vtDir;
|
|
pPl->getFirstDeriv(dSta,vtDir);
|
|
vtDir.normalize();
|
|
|
|
AcGeVector3d vtDirY = vtDir;
|
|
vtDirY.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
int nSteps = 0;
|
|
double dGbLen = 10.0;//10米
|
|
switch(eType)
|
|
{
|
|
case eButtWeld: //焊接管-->燃气
|
|
{
|
|
break;
|
|
}
|
|
case eSanitary: //承插管-->供水
|
|
case eFlangeTube: //法兰管-->热力
|
|
{
|
|
//多少米?
|
|
m_mapSpecXData.GetAt(PIPE_GBLEN,dGbLen);
|
|
nSteps = (int)(dLen / dGbLen);
|
|
|
|
for (int i = 1;i < nSteps;i++)
|
|
{
|
|
if ( Acad::eOk == pPl->getPointAtDist(i * dGbLen,ptPos) )
|
|
{
|
|
// 绘制 [
|
|
ptGe[2] = ptPos;
|
|
ptGe[2] += vtDirY * 0.5 * dDn;
|
|
|
|
ptGe[3] = ptGe[2] + vtDir * 0.2 * dDn;//r/2
|
|
ptGe[1] = ptPos;
|
|
ptGe[1] -= vtDirY * 0.5 * dDn;
|
|
|
|
ptGe[0] = ptGe[1] + vtDir * 0.2 * dDn;//r/2
|
|
|
|
AcDbPolyline* pPl2 = new AcDbPolyline;
|
|
for (int k = 0;k < 4;k++)
|
|
{
|
|
pPl2->addVertexAt(k,ptGe[k].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl2->setConstantWidth(dWt);
|
|
pPl2->setLayer(m_idSingleLayer);
|
|
pPl2->setLinetype(KTSetting::InitLineStyle(_T("Continuous")));
|
|
|
|
dc.DrawEntity(pPl2);
|
|
Add2DBuffer(pPl2);
|
|
//m_ar2DDrableBufPtrs.append(pPl2);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case eShieldEW:
|
|
{
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
pPl->setLayer(m_idSingleLayer);
|
|
|
|
//pPl->setLinetype(KTSetting::InitLineStyle(_T("Continuous")));
|
|
//dc.SetLayer(m_idSingleLayer);
|
|
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
//m_ar2DDrableBufPtrs.append(pPl);
|
|
|
|
dc.SetLayer(idCurLay);
|
|
dc.SetLineType(idCurLty);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
double GetPipeDoubleLineMaxD();
|
|
void MakeShortCurve(AcDbCurve *pCurve, double dFL, int nPos);
|
|
AcDbCurve *FormatLine(AcDbCurve *pBaseCur);
|
|
void ConverToPolyline(AcDbCurve *&pCurve, double dWidth);
|
|
AcDbCurve *FormatPolyline(AcDbCurve *pBaseCur);
|
|
AcDbCurve *FormatPolyline(const AcGePoint3d &ptFr, const AcGePoint3d &ptTo);
|
|
Acad::ErrorStatus AecDbEwPipe::BaseDraw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
if (g_BALock::instance().Draw() != BIT_SUCCESS)
|
|
return Acad::eOk;
|
|
|
|
//管线系统屏蔽掉
|
|
if (dc.IsDragging())
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
AcDbObjectId idCurLay = dc.GetLayerId();
|
|
AcDbObjectId idCurLty = dc.GetLineTypeId();
|
|
Adesk::UInt16 nCrBk = colorIndex();
|
|
|
|
//双线,宽度
|
|
int nStyle = 0, nShape = 0;
|
|
m_mapSpecXData.GetAt(KEY_2DSTYLE, nStyle);
|
|
|
|
m_mapSpecXData.GetAt(KEY_SECSHAPE, nShape);
|
|
|
|
double dSingleW = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_SINGLEW, dSingleW);
|
|
|
|
double dDbLineW = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_DBLINEW, dDbLineW);
|
|
|
|
//是否绘制坡度线
|
|
int nDrawGradient = 0;
|
|
m_mapSpecXData.GetAt(KEY_DRAWGRAD, nDrawGradient);
|
|
|
|
//double dXDrawScale = 1.0;//dSingleW已经含有
|
|
//dSingleW *= dXDrawScale;
|
|
|
|
AcGeVector3d vtDir(0, 0, 1);
|
|
AcDbCurve *pBaseCurXY = GetBaseCurve(true);
|
|
if (pBaseCurXY == NULL)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
if (m_pBaseCurve == NULL)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//如果是衬塑管
|
|
double dGast = GetGasketThick();
|
|
AcDbLine *pLn = AcDbLine::cast(pBaseCurXY);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptS = pLn->startPoint();
|
|
AcGePoint3d ptE = pLn->endPoint();
|
|
|
|
AcGeVector3d vt = ptE - ptS;
|
|
vt.normalize();
|
|
|
|
ptS += vt * 0.5 * dGast;
|
|
ptE -= vt * 0.5 * dGast;
|
|
pLn->setStartPoint(ptS);
|
|
pLn->setEndPoint(ptE);
|
|
}
|
|
|
|
if (Has2DBuffer())
|
|
{
|
|
AcDbObjectId oldLy = dc.GetLayerId();
|
|
AcDbObjectId oldLt = dc.GetLineTypeId();
|
|
int oldClr = dc.GetColor();
|
|
AcDb::LineWeight oldLw = dc.GetLineWeight();
|
|
|
|
AcDbEntity *pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0; i < ar2D.length(); i++)
|
|
{
|
|
pEnt = (AcDbEntity *)ar2D.at(i);
|
|
dc.SetColor(pEnt->colorIndex());
|
|
dc.SetLineType(pEnt->linetypeId());
|
|
dc.SetLayer(pEnt->layerId());
|
|
dc.SetLineWeight(pEnt->lineWeight());
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
|
|
dc.SetLayer(oldLy);
|
|
dc.SetLineType(oldLt);
|
|
dc.SetColor(oldClr);
|
|
dc.SetLineWeight(oldLw);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int nColor = nCrBk;
|
|
if (m_mapSpecXData.GetAt(_T("COLOR"), nColor))//中心线颜色
|
|
{
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
//取起点切向量
|
|
double dSta = 0.0;
|
|
m_pBaseCurve->getStartParam(dSta);
|
|
m_pBaseCurve->getFirstDeriv(dSta, vtDir);
|
|
vtDir.normalize();
|
|
|
|
double dDn = 0.0, dD = 0.0;
|
|
if (m_mapSpecXData.GetAt(PIPE_DN, dDn))
|
|
{
|
|
if (dDn - GetPipeDoubleLineMaxD() > 1.e-3)
|
|
{
|
|
nStyle = 2;
|
|
}
|
|
else
|
|
{
|
|
nStyle = 1;
|
|
}
|
|
}
|
|
double dOd = 0.0, dThk = 0.0, dEl = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_OD, dOd);
|
|
m_mapSpecXData.GetAt(PIPE_THICK, dThk);
|
|
int nDir = 0;
|
|
m_mapSpecXData.GetAt(PIPE_DRAWDIR, nDir);
|
|
dD = dDn;
|
|
|
|
//绘制设置的半径
|
|
WPipe::EDia eDir = (WPipe::EDia)nDir;
|
|
if (eDir == WPipe::eOD)
|
|
{
|
|
dD = dOd;
|
|
}
|
|
else if (eDir == WPipe::eID)
|
|
{
|
|
dD = dOd - 2.0 * dThk;
|
|
}
|
|
|
|
AcDbCurve *pTemp = NULL;
|
|
AcGeLine3d ln3d(AcGePoint3d::kOrigin, 10.0 * vtDir);
|
|
|
|
AcGeVector3d vtDrawPlanNorm = AcGeVector3d::kZAxis;
|
|
AcGePlane planXY;
|
|
dc.GetDraw2DPlan(planXY);
|
|
vtDrawPlanNorm = planXY.normal();
|
|
|
|
DrawContext dcCon;
|
|
dcCon.dD = dD;
|
|
dcCon.vtDrawPlanNorm = vtDrawPlanNorm;
|
|
dcCon.dSingleW = dSingleW;
|
|
dcCon.dDbLineW = dDbLineW;
|
|
dcCon.nShape = nShape;
|
|
dcCon.nDrawGradient = nDrawGradient;
|
|
dcCon.nColor = nColor;
|
|
dcCon.idCurLay = idCurLay;
|
|
dcCon.idCurLty = idCurLty;
|
|
dcCon.nCrBk = nCrBk;
|
|
dcCon.vtDir = vtDir;
|
|
dcCon.pBaseCurXY = pBaseCurXY;
|
|
|
|
dc.SetLineWidth(0);
|
|
dc.SetLineWeight(AcDb::kLnWt000);
|
|
|
|
switch (nStyle)
|
|
{
|
|
case 0://单线
|
|
case 1://单线
|
|
{
|
|
DrawSingle2d(dc, dcCon);
|
|
break;
|
|
}
|
|
case 2://双线
|
|
{
|
|
DrawDouble2d(dc, dcCon);
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//可能的绘制法兰管子
|
|
DrawFlangInf2d(dc);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::DrawDouble2d(AcGiDraw &dc, DrawContext &dcCon) const
|
|
{
|
|
CString sSys;
|
|
m_mapSpecXData.GetAt(PIPE_SYS, sSys);
|
|
backupDc(dc);
|
|
if (dcCon.vtDir.isParallelTo(dcCon.vtDrawPlanNorm))//口向上下
|
|
{
|
|
if (dcCon.nShape == eCircle)
|
|
{
|
|
AcGePoint3d ptSta;
|
|
m_pBaseCurve->getStartPoint(ptSta);
|
|
ptSta.z = 0.0;//在0标高上绘制立管
|
|
|
|
double dD = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_SIZE1, dD);
|
|
m_mapSpecXData.GetAt(PIPE_D, dD);
|
|
|
|
AcGePoint3d ptCen = ptSta;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN, ptCen);//可能偏心绘制
|
|
|
|
AcGeMatrix3d xformMove;
|
|
AcGeVector3d vtM = ptCen.asVector();
|
|
xformMove.setToTranslation(vtM);
|
|
|
|
CString sHandle;
|
|
m_mapSpecXData.GetAt(PIPE_CONNECT, sHandle);
|
|
|
|
//绘制标记+
|
|
double dCmd = 5.0;//毫米
|
|
if (CoreTools::IsMetersUnit())
|
|
dCmd *= .001;
|
|
|
|
AcGePoint3d pt[2];
|
|
pt[0] = ptSta; pt[0].x -= dCmd;
|
|
pt[1] = ptSta; pt[1].x += dCmd;
|
|
|
|
AcDbLine *pLn = new AcDbLine(pt[0], pt[1]);
|
|
pLn->setColorIndex(dcCon.nColor);
|
|
pLn->setLayer(layerId());
|
|
m_mapSpecXData.Write(pLn, BIMDATA_APP);
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
pt[0] = ptSta; pt[0].y -= dCmd;
|
|
pt[1] = ptSta; pt[1].y += dCmd;
|
|
pLn = new AcDbLine(pt[0], pt[1]);
|
|
pLn->setLayer(layerId());
|
|
pLn->setColorIndex(dcCon.nColor);
|
|
m_mapSpecXData.Write(pLn, BIMDATA_APP);
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
|
|
//没有关联关系,立管才绘制圆
|
|
BOOL bZNDraw = 0;
|
|
m_mapSpecXData.GetAt(PIPE_Z2DDRAW, bZNDraw);
|
|
if (bZNDraw)
|
|
{
|
|
AcDbCircle *pCir = new AcDbCircle;
|
|
pCir->setRadius(0.5 * dD);
|
|
pCir->setCenter(ptSta);
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
pCir->transformBy(xformMove);
|
|
|
|
AcDbPolyline *pPoly = CoreTools::MakePolyline(pCir);
|
|
DELETE_PTR(pCir);
|
|
if (pPoly)
|
|
{
|
|
m_mapSpecXData.Write(pPoly, BIMDATA_APP);
|
|
setInfo2Ent(sSys, pPoly, false, m_mapSpecXData);
|
|
setInfo2Dc(sSys, dc, false, m_mapSpecXData);
|
|
dc.DrawEntity(pPoly);
|
|
Add2DBuffer(pPoly);
|
|
recoverDc(dc);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//中心线
|
|
//加入中心线
|
|
AcDbCurve *pCenCrv = GetBaseCurve(false);
|
|
if (pCenCrv != NULL)
|
|
{
|
|
pCenCrv->setLayer(m_idCenterLayer);
|
|
pCenCrv->setColorIndex(dcCon.nColor);
|
|
pCenCrv->setLinetype(KTSetting::InitLineStyle(_T("CENTER2")));
|
|
m_mapSpecXData.Write(pCenCrv, BIMDATA_APP);
|
|
setInfo2Ent(sSys, pCenCrv, true, m_mapSpecXData);
|
|
setInfo2Dc(sSys, dc, true, m_mapSpecXData);
|
|
dc.DrawEntity(pCenCrv);
|
|
recoverDc(dc);
|
|
Add2DBuffer(pCenCrv);
|
|
}
|
|
}
|
|
else//方管,获其他截面管
|
|
{
|
|
if (m_pRegion != NULL)
|
|
{
|
|
AcGePoint3d ptCen;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN, ptCen);
|
|
|
|
AcDbRegion *pRegCln = (AcDbRegion *)m_pRegion->clone();
|
|
|
|
double dAngle = 0.0;
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
if (m_mapSpecXData.GetAt(KEY_ROTATION, dAngle))
|
|
{
|
|
if (pRegCln != NULL)
|
|
{
|
|
AcGeMatrix3d xformR;
|
|
xformR.setToRotation(dAngle, AcGeVector3d::kZAxis);//pi-dangle
|
|
pRegCln->transformBy(xformR);
|
|
pRegCln->explode(arCurPtrs);
|
|
|
|
//绘制方向->测试
|
|
/*AcGePoint3d pt1,pt2;
|
|
dcCon.pBaseCurXY->getStartPoint(pt1);
|
|
pt1.z = 0.0;//在0标高上绘制立管
|
|
pt2 = pt1;
|
|
|
|
AcGeVector3d vt(1,0,0);
|
|
vt.rotateBy(dAngle,AcGeVector3d::kZAxis);
|
|
pt2 = pt1 + vt * 300.0;
|
|
|
|
AcDbLine* pLnT = new AcDbLine(pt1,pt2);
|
|
dc.DrawEntity(pLnT);
|
|
Add2DBuffer(pLnT);*/
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pRegCln->explode(arCurPtrs);
|
|
}
|
|
delete pRegCln;
|
|
|
|
AcGePoint3d ptSta;
|
|
AcGeMatrix3d xformMove;
|
|
dcCon.pBaseCurXY->getStartPoint(ptSta);
|
|
ptSta.z = 0.0;//在0标高上绘制立管
|
|
|
|
//移到sta位置
|
|
AcGeVector3d vtM = ptSta - ptCen;
|
|
xformMove.setToTranslation(vtM);
|
|
|
|
AcDbEntity *pSubEnt = NULL;
|
|
for (int n = 0; n < arCurPtrs.length(); n++)
|
|
{
|
|
pSubEnt = (AcDbEntity *)arCurPtrs.at(n);
|
|
pSubEnt->transformBy(xformMove);
|
|
pSubEnt->setColorIndex(dcCon.nColor);
|
|
pSubEnt->setLayer(layerId());
|
|
m_mapSpecXData.Write(pSubEnt, BIMDATA_APP);
|
|
dc.DrawEntity(pSubEnt);
|
|
Add2DBuffer(pSubEnt);
|
|
}
|
|
|
|
//中心线
|
|
//加入中心线
|
|
AcDbCurve *pCenCrv = GetBaseCurve(false);
|
|
if (pCenCrv != NULL)
|
|
{
|
|
pCenCrv->setLayer(m_idCenterLayer);
|
|
pCenCrv->setColorIndex(dcCon.nColor);
|
|
pCenCrv->setLinetype(KTSetting::InitLineStyle(_T("CENTER2")));
|
|
|
|
m_mapSpecXData.Write(pCenCrv, BIMDATA_APP);
|
|
dc.DrawEntity(pCenCrv);
|
|
Add2DBuffer(pCenCrv);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else //水平或者斜管
|
|
{
|
|
AcGeLine3d ln3d(AcGePoint3d::kOrigin, 10.0 * dcCon.vtDir);
|
|
AcGePlane planXY;
|
|
dc.GetDraw2DPlan(planXY);
|
|
|
|
//斜度不是平行XY面的投影到XY面
|
|
if (!ln3d.isParallelTo(planXY))//斜管
|
|
{
|
|
//绘制梯度线
|
|
if (dcCon.nDrawGradient > 0)
|
|
{
|
|
DrawGradient(dc, m_pBaseCurve);
|
|
}
|
|
}
|
|
|
|
AcGePoint3d ptSta, ptFr;
|
|
AcGePoint3d ptEnd;
|
|
AcGeVector3d vtTmp;
|
|
dcCon.pBaseCurXY->getStartPoint(ptSta);
|
|
dcCon.pBaseCurXY->getEndPoint(ptEnd);
|
|
|
|
double dEl = ptSta.z;
|
|
m_mapSpecXData.GetAt(PIPE_EL, dEl);
|
|
|
|
ptSta.z = 0.0;
|
|
ptEnd.z = 0.0;
|
|
|
|
//避开一个法兰的位置
|
|
double dFL = 0.0;
|
|
int nConnectType = 0;//焊接0 承插1 螺纹2 法兰管3
|
|
m_mapSpecXData.GetAt(PIPE_CONNECT, nConnectType);
|
|
if (nConnectType == 3)
|
|
{
|
|
m_mapSpecXData.GetAt(PIPE_INTERFACEL, dFL);
|
|
vtTmp = ptEnd - ptSta;
|
|
vtTmp.normalize();
|
|
}
|
|
|
|
//断管符号
|
|
AcDbPolyline *pPl = NULL;
|
|
AcGePoint3d ptGeT, ptGeBK;
|
|
AcGePoint3dArray arPoints;
|
|
CString sIndex;
|
|
dcCon.vtDir.normalize();
|
|
for (int i = 0; i < PIPE_BROKENNUM; i++)
|
|
{
|
|
sIndex.Format(_T("BKOP%d"), i);
|
|
if (m_mapSpecXData.GetAt(sIndex, ptGeBK))
|
|
{
|
|
ptGeT = ptSta + dcCon.vtDir * ptGeBK.x;//开始位置
|
|
ptGeT.z = 0.0;
|
|
arPoints.append(ptGeT);
|
|
|
|
ptGeT += dcCon.vtDir * ptGeBK.y;//断开长度
|
|
ptGeT.z = 0.0;
|
|
arPoints.append(ptGeT);
|
|
}
|
|
}
|
|
|
|
//遮挡虚线
|
|
AcGePoint3dArray arDashBreak;
|
|
for (int n = 0; n < m_arBreaks.length(); n++)
|
|
{
|
|
const BreakPos &brp = m_arBreaks.at(n);
|
|
if (brp.nType == -1)//虚段
|
|
{
|
|
m_pBaseCurve->getClosestPointTo(brp.ptGe, ptGeT);
|
|
ptGeT.z = 0.0;
|
|
|
|
arDashBreak.append(ptGeT);
|
|
ptGeT -= 0.5 * brp.dLen * dcCon.vtDir;
|
|
arPoints.append(ptGeT);
|
|
|
|
ptGeT += brp.dLen * dcCon.vtDir;
|
|
arPoints.append(ptGeT);
|
|
}
|
|
}
|
|
|
|
BOOL bStaBrk = FALSE;
|
|
BOOL bEndBrk = FALSE;
|
|
//排序
|
|
if (arPoints.length() > 0)
|
|
{
|
|
AcDbLine ln(ptSta, ptEnd);
|
|
AecCoverBooleanOper::SortPoints(arPoints, &ln);
|
|
|
|
if (arPoints.first().distanceTo(ptSta) < 1.e-3)
|
|
{
|
|
bStaBrk = TRUE;
|
|
}
|
|
|
|
if (arPoints.last().distanceTo(ptEnd) < 1.e-3)
|
|
{
|
|
bEndBrk = TRUE;
|
|
}
|
|
|
|
//STA+END
|
|
arPoints.insertAt(0, ptSta);
|
|
arPoints.append(ptEnd);
|
|
}
|
|
|
|
AecComplexCurve cplCurve;
|
|
AcGeVector3d vt1, vt2;
|
|
//sta- 1...2-3...4-5...end
|
|
for (int i = 0; i < arPoints.length() - 1; i++)
|
|
{
|
|
ptFr = arPoints.at(i);
|
|
ptGeBK = arPoints.at(i + 1);
|
|
|
|
if (i % 2 == 0) //偶数,后面绘制
|
|
{
|
|
//...
|
|
}
|
|
else
|
|
{
|
|
bool bDash = false;
|
|
for (int nn = 0; nn < arDashBreak.length(); nn++)
|
|
{
|
|
ptGeT = arDashBreak.at(nn);
|
|
|
|
vt1 = ptGeT - ptFr;
|
|
vt2 = ptGeT - ptGeBK;
|
|
if (!vt1.isCodirectionalTo(vt2))
|
|
{
|
|
//是虚线
|
|
bDash = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (bDash)
|
|
{
|
|
DrawDashSegment(dc, ptFr, ptGeBK, dcCon.dD, cplCurve);
|
|
}
|
|
else
|
|
{
|
|
DrawBrokenOpen(dc, ptFr, ptGeBK, dcCon.dD, cplCurve);
|
|
}
|
|
}
|
|
}
|
|
|
|
//断符号绘制
|
|
AecComplexCurveDraw draw2d;
|
|
draw2d.SetEdage(cplCurve);
|
|
draw2d.Draw2d(dc);
|
|
|
|
AcDbCurve *pCurveT = NULL;
|
|
for (int kk = 0; kk < cplCurve.length(); kk++)
|
|
{
|
|
pCurveT = cplCurve.segat(kk);
|
|
if (pCurveT != NULL)
|
|
{
|
|
Add2DBuffer(pCurveT);
|
|
}
|
|
}
|
|
|
|
//中心线
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
if (arPoints.length() > 2)
|
|
{
|
|
//STA+END
|
|
arPoints.removeFirst();
|
|
arPoints.removeLast();
|
|
|
|
dcCon.pBaseCurXY->getSplitCurves(arPoints, arCurPtrs);
|
|
DELETE_PTR(dcCon.pBaseCurXY);
|
|
dcCon.pBaseCurXY = NULL;
|
|
}
|
|
else
|
|
{
|
|
arCurPtrs.append(dcCon.pBaseCurXY);
|
|
}
|
|
|
|
//外线 截面
|
|
AcGePoint3d ptCen;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN, ptCen);
|
|
double dUW = 0.0, dDW = 0.0, dW = 0.0;
|
|
if (m_pRegion != NULL)
|
|
{
|
|
//region水平投影放置为准
|
|
AcDbExtents ext;
|
|
m_pRegion->getGeomExtents(ext);
|
|
|
|
dW = ext.maxPoint().x - ext.minPoint().x;
|
|
|
|
//dUW 原点到最小点的距离 正
|
|
//dDW 原点到最大点的距离 负
|
|
//正负按照AcDbCurve::getOffsetCurves(dOff 要求
|
|
|
|
dUW = -ext.minPoint().x;
|
|
dDW = -ext.maxPoint().x;
|
|
}
|
|
|
|
//1.中心线
|
|
//统一Format polyline 线
|
|
dc.SetLayer(layerId());
|
|
dc.SetLineType(linetypeId());
|
|
|
|
AcDbCurve *pCurTmp = NULL, *pTemp = NULL;
|
|
AcDbLine *pLnPl = NULL;
|
|
|
|
int nCenNDraw = 0;
|
|
m_mapSpecXData.GetAt(KEY_CENNODRAW, nCenNDraw);
|
|
|
|
for (int j = 0; j < arCurPtrs.length(); j++)
|
|
{
|
|
pCurTmp = (AcDbCurve *)arCurPtrs.at(j);
|
|
|
|
//绘制中心线,是否需要
|
|
//统一Format polyline 线
|
|
if (nCenNDraw == FALSE)//绘制中心线
|
|
{
|
|
//pTemp = FormatPolyline(pCurTmp);
|
|
pTemp = FormatLine(pCurTmp);
|
|
pLnPl = AcDbLine::cast(pTemp);
|
|
if (pLnPl != NULL)
|
|
{
|
|
AcDbPolyline *pPoly = (AcDbPolyline*)FormatPolyline(pLnPl->startPoint(), pLnPl->endPoint());
|
|
DELETE_PTR(pLnPl);
|
|
if (pPoly)
|
|
{
|
|
|
|
AecDbObjXDataMap xData;
|
|
xData.CopyFrom(&m_mapSpecXData);
|
|
xData.SetAt(PIPE_EL, dEl);
|
|
xData.Write(pPoly, BIMDATA_APP);
|
|
setInfo2Ent(sSys, pPoly, true, m_mapSpecXData);
|
|
setInfo2Dc(sSys, dc, true, m_mapSpecXData);
|
|
dc.DrawEntity(pPoly);
|
|
Add2DBuffer(pPoly);
|
|
recoverDc(dc);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pPl = AcDbPolyline::cast(pTemp);
|
|
if (pPl != NULL)
|
|
{
|
|
|
|
AecDbObjXDataMap xData;
|
|
xData.CopyFrom(&m_mapSpecXData);
|
|
xData.SetAt(PIPE_EL, dEl);
|
|
xData.Write(pPl, BIMDATA_APP);
|
|
|
|
setInfo2Ent(sSys, pPl, true, m_mapSpecXData);
|
|
setInfo2Dc(sSys, dc, true, m_mapSpecXData);
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
recoverDc(dc);
|
|
}
|
|
}
|
|
}
|
|
else//不绘制中心线
|
|
{
|
|
//...
|
|
}
|
|
|
|
//2. 绘制外线
|
|
if (j % 2 == 0) //偶数
|
|
{
|
|
dc.SetColor(dcCon.nCrBk);
|
|
|
|
//2.外边线
|
|
//统一Format polyline 线
|
|
dc.SetLayer(m_idDoubleLayer);
|
|
dc.SetLineType(linetypeId());
|
|
dc.SetColor(kColorByLayer);
|
|
|
|
AcDbVoidPtrArray arUCurPtrs, arDCurPtrs;
|
|
if (dcCon.vtDrawPlanNorm.isCodirectionalTo(AcGeVector3d::kZAxis))
|
|
{
|
|
pCurTmp->getOffsetCurves(dUW, arUCurPtrs);
|
|
pCurTmp->getOffsetCurves(dDW, arDCurPtrs);
|
|
}
|
|
else
|
|
{
|
|
//绘制投影面
|
|
pCurTmp->getOffsetCurvesGivenPlaneNormal(dcCon.vtDrawPlanNorm, dUW, arUCurPtrs);
|
|
pCurTmp->getOffsetCurvesGivenPlaneNormal(dcCon.vtDrawPlanNorm, dDW, arDCurPtrs);
|
|
}
|
|
//DELETE_PTR(pCurTmp);
|
|
|
|
//中间是否被节点打断???
|
|
AcGePoint3d ptTmp;
|
|
AcGePoint3dArray arPtSta, arPtEnd;
|
|
AcDbCurve *pCurve = NULL;
|
|
for (int i = 0; i < arUCurPtrs.length(); i++)
|
|
{
|
|
pCurve = (AcDbCurve *)arUCurPtrs.at(i);
|
|
|
|
if (i == 0)
|
|
{
|
|
pCurve->getStartPoint(ptTmp);
|
|
arPtSta.append(ptTmp);
|
|
|
|
if (dFL > 1.e-3)//有法兰,外线少画一个厚度
|
|
{
|
|
MakeShortCurve(pCurve, dFL, 0);
|
|
}
|
|
}
|
|
|
|
if (i == arUCurPtrs.length() - 1)
|
|
{
|
|
pCurve->getEndPoint(ptTmp);
|
|
arPtEnd.append(ptTmp);
|
|
|
|
if (dFL > 1.e-3)//有法兰,外线少画一个厚度
|
|
{
|
|
MakeShortCurve(pCurve, dFL, 1);
|
|
}
|
|
}
|
|
|
|
ConverToPolyline(pCurve, dcCon.dDbLineW);
|
|
|
|
setInfo2Ent(sSys, pCurve, false, m_mapSpecXData);
|
|
setInfo2Dc(sSys, dc, false, m_mapSpecXData);
|
|
pCurve->setLayer(m_idDoubleLayer);
|
|
pCurve->setColorIndex(kColorByLayer);
|
|
dc.DrawEntity(pCurve);
|
|
Add2DBuffer(pCurve);
|
|
recoverDc(dc);
|
|
}
|
|
|
|
for (int i = 0; i < arDCurPtrs.length(); i++)
|
|
{
|
|
pCurve = (AcDbCurve *)arDCurPtrs.at(i);
|
|
|
|
if (i == 0)
|
|
{
|
|
pCurve->getStartPoint(ptTmp);
|
|
arPtSta.append(ptTmp);
|
|
|
|
if (dFL > 1.e-3)//有法兰,外线少画一个厚度
|
|
{
|
|
MakeShortCurve(pCurve, dFL, 0);
|
|
}
|
|
}
|
|
|
|
if (i == arDCurPtrs.length() - 1)
|
|
{
|
|
pCurve->getEndPoint(ptTmp);
|
|
arPtEnd.append(ptTmp);
|
|
|
|
if (dFL > 1.e-3)//有法兰,外线少画一个厚度
|
|
{
|
|
MakeShortCurve(pCurve, dFL, 1);
|
|
}
|
|
}
|
|
|
|
ConverToPolyline(pCurve, dcCon.dDbLineW);
|
|
setInfo2Ent(sSys, pCurve, false, m_mapSpecXData);
|
|
setInfo2Dc(sSys, dc, false, m_mapSpecXData);
|
|
pCurve->setLayer(m_idDoubleLayer);
|
|
pCurve->setColorIndex(kColorByLayer);
|
|
dc.DrawEntity(pCurve);
|
|
Add2DBuffer(pCurve);
|
|
recoverDc(dc);
|
|
}
|
|
|
|
//封开始端口
|
|
if (j == 0 && arPtSta.length() == 2 && !bStaBrk)
|
|
{
|
|
vtTmp = arPtSta.last() - arPtSta.first();
|
|
vtTmp.normalize();
|
|
//arPtSta.first() -= vtTmp * 0.5 * dcCon.dDbLineW;
|
|
//arPtSta.last() += vtTmp * 0.5 * dcCon.dDbLineW;
|
|
|
|
pPl = FormatPolyline(arPtSta.asArrayPtr(),2);
|
|
setInfo2Ent(sSys, pPl, false, m_mapSpecXData);
|
|
setInfo2Dc(sSys, dc, false, m_mapSpecXData);
|
|
pPl->setConstantWidth(.0);
|
|
pPl->setLayer(m_idDoubleLayer);
|
|
pPl->setColorIndex(kColorByLayer);
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
recoverDc(dc);
|
|
|
|
}
|
|
|
|
//封末端端口
|
|
if (j == (arCurPtrs.length() - 1) && arPtEnd.length() == 2 && !bEndBrk)
|
|
{
|
|
//市政封口线为细线
|
|
vtTmp = arPtEnd.last() - arPtEnd.first();
|
|
vtTmp.normalize();
|
|
//arPtEnd.first() -= vtTmp * 0.5 * dcCon.dDbLineW;
|
|
//arPtEnd.last() += vtTmp * 0.5 * dcCon.dDbLineW;
|
|
pPl = FormatPolyline(arPtEnd.asArrayPtr(),2);
|
|
setInfo2Ent(sSys, pPl, false, m_mapSpecXData);
|
|
setInfo2Dc(sSys, dc, false, m_mapSpecXData);
|
|
pPl->setConstantWidth(.0);
|
|
pPl->setLayer(m_idDoubleLayer);
|
|
pPl->setColorIndex(kColorByLayer);
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
recoverDc(dc);
|
|
}
|
|
}
|
|
}
|
|
|
|
FreeBuffer(0, arCurPtrs);
|
|
dc.SetColor(dcCon.nCrBk);
|
|
dc.SetLayer(dcCon.idCurLay);
|
|
dc.SetLineType(dcCon.idCurLty);
|
|
}
|
|
|
|
recoverDc(dc);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::DrawSingle2d(AcGiDraw &dc, DrawContext &dcCon) const
|
|
{
|
|
CString sSys;
|
|
m_mapSpecXData.GetAt(PIPE_SYS, sSys);
|
|
backupDc(dc);
|
|
if (dcCon.vtDir.isParallelTo(dcCon.vtDrawPlanNorm))//立管
|
|
{
|
|
if (dcCon.nShape == eCircle)
|
|
{
|
|
AcGePoint3d ptSta;
|
|
m_pBaseCurve->getStartPoint(ptSta);
|
|
ptSta.z = 0.0;//在0标高上绘制立管
|
|
|
|
double dD = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_SIZE1, dD);
|
|
m_mapSpecXData.GetAt(PIPE_D, dD);
|
|
|
|
AcGePoint3d ptCen;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN, ptCen);//可能偏心绘制
|
|
|
|
AcGeMatrix3d xformMove;
|
|
AcGeVector3d vtM = ptCen.asVector();
|
|
xformMove.setToTranslation(vtM);
|
|
|
|
//没有关联关系,立管才绘制圆
|
|
BOOL bZNDraw = 0;
|
|
m_mapSpecXData.GetAt(PIPE_Z2DDRAW, bZNDraw);
|
|
if (bZNDraw)
|
|
{
|
|
AcDbCircle *pCir = new AcDbCircle;
|
|
pCir->setRadius(0.5 * dD);
|
|
pCir->setCenter(ptSta);
|
|
pCir->setNormal(dcCon.vtDrawPlanNorm);
|
|
pCir->transformBy(xformMove);
|
|
|
|
AcDbPolyline *pPoly = CoreTools::MakePolyline(pCir);
|
|
DELETE_PTR(pCir);
|
|
if (pPoly)
|
|
{
|
|
m_mapSpecXData.Write(pCir, BIMDATA_APP);
|
|
setInfo2Ent(sSys, pPoly, true, m_mapSpecXData);
|
|
setInfo2Dc(sSys, dc, true, m_mapSpecXData);
|
|
dc.DrawEntity(pCir);
|
|
Add2DBuffer(pCir);
|
|
recoverDc(dc);
|
|
}
|
|
|
|
}
|
|
|
|
//中心线
|
|
//加入中心线
|
|
AcDbCurve *pCenCrv = GetBaseCurve(false);
|
|
if (pCenCrv != NULL)
|
|
{
|
|
pCenCrv->setLayer(m_idCenterLayer);
|
|
m_mapSpecXData.Write(pCenCrv, BIMDATA_APP);
|
|
dc.DrawEntity(pCenCrv);
|
|
Add2DBuffer(pCenCrv);
|
|
}
|
|
}
|
|
else//其他形状
|
|
{
|
|
if (m_pRegion != NULL)
|
|
{
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
double dAngle = 0.0;
|
|
if (m_mapSpecXData.GetAt(KEY_ROTATION, dAngle))
|
|
{
|
|
AcDbRegion *pRegnCln = (AcDbRegion *)m_pRegion->clone();
|
|
if (pRegnCln != NULL)
|
|
{
|
|
AcGeMatrix3d xformR;
|
|
xformR.setToRotation(dAngle, dcCon.vtDrawPlanNorm);
|
|
pRegnCln->transformBy(xformR);
|
|
pRegnCln->explode(arCurPtrs);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_pRegion->explode(arCurPtrs);
|
|
}
|
|
|
|
AcGePoint3d ptSta;
|
|
dcCon.pBaseCurXY->getStartPoint(ptSta);
|
|
ptSta.z = 0.0;//在0标高上绘制立管
|
|
|
|
AcGePoint3d ptCen = ptSta;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN, ptCen);//可能偏心绘制
|
|
|
|
AcGeMatrix3d xformOffset;
|
|
AcGeVector3d vtM = ptCen.asVector();
|
|
xformOffset.setToTranslation(vtM);
|
|
AcGeMatrix3d xformMove;
|
|
xformMove.setToTranslation(ptSta.asVector());
|
|
|
|
AcDbEntity *pSubEnt = NULL;
|
|
for (int n = 0; n < arCurPtrs.length(); n++)
|
|
{
|
|
pSubEnt = (AcDbEntity *)arCurPtrs.at(n);
|
|
pSubEnt->transformBy(xformOffset);
|
|
pSubEnt->transformBy(xformMove);
|
|
pSubEnt->setColorIndex(dcCon.nColor);
|
|
m_mapSpecXData.Write(pSubEnt, BIMDATA_APP);
|
|
dc.DrawEntity(pSubEnt);
|
|
Add2DBuffer(pSubEnt);
|
|
}
|
|
|
|
//中心线
|
|
//加入中心线
|
|
AcDbCurve *pCenCrv = GetBaseCurve(false);
|
|
if (pCenCrv != NULL)
|
|
{
|
|
pCenCrv->setLayer(m_idCenterLayer);
|
|
m_mapSpecXData.Write(pCenCrv, BIMDATA_APP);
|
|
dc.DrawEntity(pCenCrv);
|
|
Add2DBuffer(pCenCrv);
|
|
}
|
|
}
|
|
}
|
|
DELETE_PTR(dcCon.pBaseCurXY);
|
|
dcCon.pBaseCurXY = NULL;
|
|
}
|
|
else //单线,水平或倾斜
|
|
{
|
|
AcGeLine3d ln3d(AcGePoint3d::kOrigin, 10.0 * dcCon.vtDir);
|
|
AcGePlane planXY;
|
|
dc.GetDraw2DPlan(planXY);
|
|
|
|
//斜度不是平行XY面的投影到XY面
|
|
if (!ln3d.isParallelTo(planXY))
|
|
{
|
|
//绘制梯度线
|
|
if (dcCon.nDrawGradient > 0)
|
|
{
|
|
DrawGradient(dc, m_pBaseCurve);
|
|
}
|
|
}
|
|
|
|
AcGePoint3d ptSta, ptFr;
|
|
AcGePoint3d ptEnd;
|
|
m_pBaseCurve->getStartPoint(ptSta);
|
|
m_pBaseCurve->getEndPoint(ptEnd);
|
|
|
|
double dEl = ptSta.z;//中心标高
|
|
m_mapSpecXData.GetAt(PIPE_EL, dEl);
|
|
|
|
ptSta.z = 0.0;
|
|
ptEnd.z = 0.0;
|
|
|
|
//断管符号
|
|
AcDbPolyline *pPl = NULL;
|
|
AcGePoint3d ptGeT, ptGeBK;
|
|
AcGePoint3dArray arPoints;
|
|
CString sIndex;
|
|
for (int i = 0; i < PIPE_BROKENNUM; i++)
|
|
{
|
|
sIndex.Format(_T("BKOP%d"), i);
|
|
if (m_mapSpecXData.GetAt(sIndex, ptGeBK))
|
|
{
|
|
ptGeT = ptSta + dcCon.vtDir * ptGeBK.x;
|
|
arPoints.append(ptGeT);
|
|
|
|
ptGeT += dcCon.vtDir * ptGeBK.y;
|
|
arPoints.append(ptGeT);
|
|
}
|
|
}
|
|
|
|
//排序
|
|
if (arPoints.length() > 0)
|
|
{
|
|
AcDbLine ln(ptSta, ptEnd);
|
|
AecCoverBooleanOper::SortPoints(arPoints, &ln);
|
|
|
|
BOOL bStaBrk = FALSE;
|
|
if (arPoints.first().distanceTo(ptSta) < 1.e-3)
|
|
{
|
|
bStaBrk = TRUE;
|
|
}
|
|
|
|
BOOL bEndBrk = FALSE;
|
|
if (arPoints.last().distanceTo(ptEnd) < 1.e-3)
|
|
{
|
|
bEndBrk = TRUE;
|
|
}
|
|
|
|
arPoints.insertAt(0, ptSta);
|
|
arPoints.append(ptEnd);
|
|
}
|
|
|
|
if (arPoints.length() > 0)
|
|
{
|
|
AecDbObjXDataMap xData;
|
|
xData.SetAt(PIPE_EL, dEl);
|
|
xData.CopyFrom(&m_mapSpecXData);
|
|
|
|
AcDbCurve *pTemp = NULL;
|
|
AecComplexCurve cplCurve;
|
|
//sta- 1...2-3...4-5...end
|
|
for (int i = 0; i < arPoints.length() - 1; i++)
|
|
{
|
|
ptFr = arPoints.at(i);
|
|
ptGeBK = arPoints.at(i + 1);
|
|
|
|
if (i % 2 == 0) //偶数
|
|
{
|
|
pTemp = FormatPolyline(ptFr, ptGeBK);
|
|
pPl = AcDbPolyline::cast(pTemp);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setConstantWidth(dcCon.dSingleW);
|
|
pPl->setLayer(m_idSingleLayer);
|
|
//pPl->setLinetype(m_idSingleLnType);
|
|
pPl->setLinetype(KTSetting::InitLineStyle(_T("Continuous")));
|
|
pPl->setColorIndex(dcCon.nColor);
|
|
xData.Write(pPl, BIMDATA_APP);
|
|
Draw2dSingleSegment(dc, pPl);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DrawBrokenOpen(dc, ptFr, ptGeBK, dcCon.dD, cplCurve);
|
|
}
|
|
}
|
|
|
|
AecComplexCurveDraw draw2d;
|
|
draw2d.SetEdage(cplCurve);
|
|
draw2d.Draw2d(dc);
|
|
|
|
AcDbCurve *pCurveT = NULL;
|
|
for (int kk = 0; kk < cplCurve.length(); kk++)
|
|
{
|
|
pCurveT = cplCurve.segat(kk);
|
|
if (pCurveT != NULL)
|
|
{
|
|
Add2DBuffer(pCurveT);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AcDbCurve *pCrv = FormatPolyline(dcCon.pBaseCurXY);
|
|
|
|
AcDbPolyline *pPl = AcDbPolyline::cast(pCrv);
|
|
if (pPl != NULL)
|
|
{
|
|
AecDbObjXDataMap xData;
|
|
xData.CopyFrom(&m_mapSpecXData);
|
|
xData.SetAt(PIPE_EL, dEl);
|
|
xData.Write(pPl, BIMDATA_APP);
|
|
|
|
setInfo2Ent(sSys, pPl, true, m_mapSpecXData);
|
|
setInfo2Dc(sSys, dc, true, m_mapSpecXData);
|
|
Draw2dSingleSegment(dc, pPl);
|
|
recoverDc(dc);
|
|
}
|
|
else
|
|
{
|
|
setInfo2Ent(sSys, dcCon.pBaseCurXY, true, m_mapSpecXData);
|
|
setInfo2Dc(sSys, dc, true, m_mapSpecXData);
|
|
AecDbObjXDataMap xData;
|
|
xData.CopyFrom(&m_mapSpecXData);
|
|
xData.SetAt(PIPE_EL, dEl);
|
|
xData.Write(dcCon.pBaseCurXY, BIMDATA_APP);
|
|
dc.DrawEntity(*dcCon.pBaseCurXY);
|
|
Add2DBuffer(dcCon.pBaseCurXY);
|
|
dcCon.pBaseCurXY = NULL;
|
|
recoverDc(dc);
|
|
}
|
|
}
|
|
}
|
|
|
|
recoverDc(dc);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es = BaseDraw2d(dc);
|
|
|
|
return es;
|
|
}
|
|
|
|
void AecDbEwPipe::GetPipeLineInfo(const bool &bCenter
|
|
, int &clr
|
|
, double &dW
|
|
, AcDbObjectId &idLy
|
|
, AcDbObjectId &idLt) const
|
|
{
|
|
getPipeSysInfoByEnt(bCenter, m_mapSpecXData, clr, dW, idLy, idLt);
|
|
}
|
|
|
|
void processHlrResult_EW( const AecDbObjXDataMap *pXData
|
|
, const BOOL &bBold
|
|
, const double &dW
|
|
, const AcArray<AcDbEntity*> &ar
|
|
, const std::map<AcDbEntity*, AcArray<AcDbEntity*>> &preAr
|
|
, AcArray<AcDbEntity*> &output)
|
|
{
|
|
if (!pXData) return;
|
|
|
|
int clr_out, clr_cen;
|
|
double dW_out, dW_cen;
|
|
AcDbObjectId idLy_out, idLt_out, idLy_cen, idLt_cen;
|
|
getPipeSysInfoByEnt(true, *pXData, clr_cen, dW_cen, idLy_cen, idLt_cen);
|
|
getPipeSysInfoByEnt(false, *pXData, clr_out, dW_out, idLy_out, idLt_out);
|
|
|
|
// ar 都是外边线
|
|
for (int i(0); i < ar.length(); ++i)
|
|
{
|
|
AcDbEntity *pEnt((AcDbEntity *)ar[i]->clone());
|
|
if (!pEnt) continue;
|
|
AcDbEntity *p(pEnt);
|
|
AcDbPolyline *pL = CoreTools::MakePolyline((AcDbCurve *)pEnt);
|
|
if (pL)
|
|
{
|
|
pL->setConstantWidth(bBold ? dW : dW_out);
|
|
p = pL;
|
|
DELETE_PTR(pEnt);
|
|
}
|
|
|
|
p->setColorIndex(clr_out);
|
|
p->setLayer(idLy_out);
|
|
p->setLinetype(idLt_out);
|
|
|
|
if (pXData)
|
|
pXData->Write(p, BIMDATA_APP);
|
|
|
|
output.append(p);
|
|
}
|
|
|
|
// prAr 里面都是 中心线和梯度线,如果是法兰管线,还可能有法兰线
|
|
std::map<AcDbEntity *, AcArray<AcDbEntity *>>::const_iterator it(preAr.begin());
|
|
AecDbObjXDataMap xData;
|
|
bool bFlang = false;
|
|
for (; it != preAr.end(); ++it)
|
|
{
|
|
//for (; it != preAr.end(); ++it)
|
|
//arCen.append(it->second);
|
|
|
|
// 判断一下,是不是法兰管线,如果是法兰管线,绘制为外边线
|
|
xData.Empty();
|
|
bFlang = false;
|
|
if (xData.Read(it->first, _T("_is_flang_")))
|
|
bFlang = true;
|
|
|
|
for (int i(0); i < it->second.length(); ++i)
|
|
{
|
|
AcDbEntity *pEnt((AcDbEntity *)it->second[i]->clone());
|
|
if (!pEnt) continue;
|
|
AcDbEntity *p(pEnt);
|
|
AcDbPolyline *pL = CoreTools::MakePolyline((AcDbCurve *)pEnt);
|
|
if (pL)
|
|
{
|
|
//pL->setConstantWidth(bBold ? dW : dW_cen);
|
|
double dd(.0);
|
|
pL->getConstantWidth(dd);
|
|
p = pL;
|
|
DELETE_PTR(pEnt);
|
|
}
|
|
|
|
if (!bFlang)
|
|
{
|
|
p->setColorIndex(clr_cen);
|
|
p->setLayer(idLy_cen);
|
|
p->setLinetype(idLt_cen);
|
|
}
|
|
else
|
|
{
|
|
p->setColorIndex(clr_out);
|
|
p->setLayer(idLy_out);
|
|
p->setLinetype(idLt_out);
|
|
}
|
|
|
|
if (pXData)
|
|
pXData->Write(p, BIMDATA_APP);
|
|
output.append(p);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void AecDbEwPipe::ProcessHlrResult(const AcArray<AcDbEntity*> &ar
|
|
, const std::map<AcDbEntity*, AcArray<AcDbEntity*>> &preAr
|
|
, AcArray<AcDbEntity*> &output) const
|
|
{
|
|
const AecDbObjXDataMap *pXData(GetSpecialtyData());
|
|
const_cast<AecDbObjXDataMap *>(pXData)->SetAt(HLR_CALC, FALSE);
|
|
double dSameW(.25);
|
|
processHlrResult_EW(pXData
|
|
, HlrCutOption::getHlrLW_PipeSys(dSameW)
|
|
, dSameW
|
|
, ar
|
|
, preAr
|
|
, output);
|
|
}
|
|
|
|
namespace
|
|
{
|
|
// 合并多条共线的segments,返回合并后的segments
|
|
bool MergeCollinearSegments(const std::vector<AcGeLineSeg3d> &inputSegs, AcGeLineSeg3d &resultSeg)
|
|
{
|
|
// 检查输入是否为空
|
|
if (inputSegs.empty())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// 如果只有一条线段,直接返回该线段
|
|
if (inputSegs.size() == 1)
|
|
{
|
|
resultSeg = inputSegs[0];
|
|
return true;
|
|
}
|
|
|
|
// 获取参考点(取第一条线段的起点)
|
|
AcGePoint3d refPt = inputSegs[0].startPoint();
|
|
|
|
// 获取参考方向向量
|
|
AcGeVector3d dir = inputSegs[0].endPoint() - refPt;
|
|
|
|
// 容错处理:防止第一条线段是长度为0的退化线段
|
|
if (dir.isZeroLength())
|
|
{
|
|
// 如果你需要处理这种异常,这里可以做进一步的遍历来寻找有效方向
|
|
// 为了保持逻辑清晰,这里如果第一条线无效,直接返回失败
|
|
return false;
|
|
}
|
|
|
|
// 将方向向量单位化
|
|
dir.normalize();
|
|
|
|
// 初始化最小和最大投影参数
|
|
// 我们用一个极大值和极小值来初始化,以便在遍历中被替换
|
|
double minParam = 1.0e20;
|
|
double maxParam = -1.0e20;
|
|
|
|
// 遍历所有线段(C++98 风格的 for 循环)
|
|
for (size_t i = 0; i < inputSegs.size(); ++i)
|
|
{
|
|
AcGePoint3d ptStart = inputSegs[i].startPoint();
|
|
AcGePoint3d ptEnd = inputSegs[i].endPoint();
|
|
|
|
// 使用点乘 (dotProduct) 获取起点和终点在基准方向上的投影参数
|
|
double paramStart = (ptStart - refPt).dotProduct(dir);
|
|
double paramEnd = (ptEnd - refPt).dotProduct(dir);
|
|
|
|
// 更新最小参数
|
|
if (paramStart < minParam)
|
|
{
|
|
minParam = paramStart;
|
|
}
|
|
if (paramEnd < minParam)
|
|
{
|
|
minParam = paramEnd;
|
|
}
|
|
|
|
// 更新最大参数
|
|
if (paramStart > maxParam)
|
|
{
|
|
maxParam = paramStart;
|
|
}
|
|
if (paramEnd > maxParam)
|
|
{
|
|
maxParam = paramEnd;
|
|
}
|
|
}
|
|
|
|
// 根据找到的极值参数,计算出最终的两个最远端点
|
|
AcGePoint3d finalStart = refPt + dir * minParam;
|
|
AcGePoint3d finalEnd = refPt + dir * maxParam;
|
|
|
|
// 生成新的合并线段
|
|
resultSeg.set(finalStart, finalEnd);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool MergeCollinearSegments(AcGeLineSeg3d &seg1, AcGeLineSeg3d &seg2, AcGeLineSeg3d &resultSeg)
|
|
{
|
|
std::vector<AcGeLineSeg3d> ar;
|
|
ar.push_back(seg1);
|
|
ar.push_back(seg2);
|
|
return MergeCollinearSegments(ar, resultSeg);
|
|
}
|
|
|
|
// 判断seg是否在pln法线一侧,1-同侧,2-异侧,0-相交
|
|
int onSide(const AcGePlane &pln, const AcGePoint3d &pt)
|
|
{
|
|
if (pln.isOn(pt)) return 0;
|
|
|
|
AcGePoint3d ptOrtho = pt.orthoProject(pln);
|
|
AcGeVector3d vt(pln.normal());
|
|
AcGeVector3d vt2(pt - ptOrtho);
|
|
|
|
if ((pt - ptOrtho).isCodirectionalTo(vt)) return 1;
|
|
|
|
return 2;
|
|
}
|
|
|
|
int onSide( const AcGePlane &pln, const AcGeLineSeg3d &seg )
|
|
{
|
|
AcGePoint3d ptInsc;
|
|
if (seg.intersectWith(pln, ptInsc))
|
|
return 0;
|
|
|
|
AcGePoint3d ptStart(seg.startPoint())
|
|
, ptEnd(seg.endPoint());
|
|
|
|
if (onSide(pln, ptStart) == 1 && onSide(pln, ptEnd) == 1)
|
|
return 1;
|
|
|
|
if (onSide(pln, ptStart) == 2 && onSide(pln, ptEnd) == 2)
|
|
return 2;
|
|
|
|
if ((onSide(pln, ptStart) == 1 && onSide(pln, ptEnd) == 2)
|
|
|| (onSide(pln, ptStart) == 2 && onSide(pln, ptEnd) == 1))
|
|
{
|
|
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
bool getOrthoProject(const AcGePlane &pln, const AcGeLineSeg3d &seg, AcGeLineSeg3d &segOut)
|
|
{
|
|
segOut.set(seg.startPoint().orthoProject(pln), seg.endPoint().orthoProject(pln));
|
|
return true;
|
|
}
|
|
|
|
// 得到管道对于pln法向方向的边线
|
|
// seg1是离pln近的线段,seg2离pln远的线段
|
|
// 如果管道与剖面相交,那么seg1和seg2的起点在pln一侧,终点在pln另一侧
|
|
void getOuterLine(const AcGeLineSeg3d ¢er
|
|
, const double &dDN
|
|
, const AcGePlane &pln
|
|
, AcGeLineSeg3d &seg1
|
|
, AcGeLineSeg3d &seg2 )
|
|
{
|
|
double dR(dDN * .5);
|
|
|
|
AcGePoint3d ptStart(center.startPoint())
|
|
, ptEnd(center.endPoint());
|
|
|
|
AcGeVector3d vtDir(ptEnd - ptStart);
|
|
AcGeVector3d vtAxis = pln.normal().crossProduct(vtDir);
|
|
vtDir.rotateBy(PI * .5, vtAxis);
|
|
vtDir.normalize();
|
|
vtDir *= dR;
|
|
|
|
AcGePoint3d ptS_Max(ptStart + vtDir)
|
|
, ptS_Min(ptStart - vtDir)
|
|
, ptE_Max(ptEnd + vtDir)
|
|
, ptE_Min(ptEnd - vtDir);
|
|
|
|
seg1.set(ptS_Max, ptE_Max);
|
|
seg2.set(ptS_Min, ptE_Min);
|
|
|
|
// 如果管线与剖面相交,调整一下seg1和seg2,让在pln一侧的点变为起点
|
|
if (!center.isParallelTo(pln) && onSide(pln, center) == 0)
|
|
{
|
|
AcGePoint3d pt1(seg1.startPoint()), pt2(seg1.endPoint());
|
|
if (onSide(pln, pt1) == 2 && onSide(pln, pt2) == 1)
|
|
seg1.set(pt2, pt1);
|
|
|
|
pt1 = seg2.startPoint(); pt2 = seg2.endPoint();
|
|
if (onSide(pln, pt1) == 2 && onSide(pln, pt2) == 1)
|
|
seg2.set(pt2, pt1);
|
|
|
|
return;
|
|
}
|
|
|
|
// 如果两条线都在剖面的一侧,调整一下,seg1和seg2的顺序,让seg1离剖面更近一些
|
|
if (onSide(pln, seg1) == 1 && onSide(pln, seg2) == 1)
|
|
{
|
|
AcGePoint3d pt1(seg1.startPoint()), pt2(seg2.startPoint());
|
|
if (pln.distanceTo(pt1) > pln.distanceTo(pt2))
|
|
std::swap(seg1, seg2);
|
|
return;
|
|
}
|
|
|
|
// 如果剖面在seg1、seg2中间,那么调整一下
|
|
// 先得到seg1在剖面上的投影seg
|
|
// 再让seg1为seg,seg2变为在剖面方向一侧的线段
|
|
if ((onSide(pln, seg1) == 1 && onSide(pln, seg2) == 2)
|
|
|| (onSide(pln, seg1) == 2 && onSide(pln, seg2) == 1))
|
|
{
|
|
AcGeLineSeg3d seg;
|
|
if (onSide(pln, seg1) == 1)
|
|
{
|
|
getOrthoProject(pln, seg1, seg);
|
|
seg2 = seg1;
|
|
seg1 = seg;
|
|
}
|
|
else
|
|
{
|
|
getOrthoProject(pln, seg2, seg);
|
|
seg1 = seg;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool IsSingleLine(const AecDbEwPipe *pPipe)
|
|
{
|
|
double dDn = 0.0, dD = 0.0;
|
|
if (pPipe->GetAt(PIPE_DN, dDn))
|
|
return dDn - GetPipeDoubleLineMaxD() <= 1.e-3;
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
bool getCenterLineForHlrCut(const AcGeLineSeg3d &seg
|
|
, const double &dDN
|
|
, const AcGePlane &pln
|
|
, AcGeLineSeg3d &segOut)
|
|
{
|
|
/*
|
|
这个函数的目的在剖切过程中生成一条中心线
|
|
|
|
用剖切方向去碰撞管道,得到两条边线seg1和seg2,其中seg1是离剖面近的线段,seg2是离剖面远的线段
|
|
|
|
剖切面与管道有一下几种位置关系:
|
|
1. 管道全部在剖面的剖切方向另一侧,返回false,不处理
|
|
2. 管道全部在剖面的剖切方向一侧,或者与剖面相交,直接把seg1返回进行运算
|
|
3. 剖面在管道中间,把在剖面一侧的边线投影到剖面上
|
|
*/
|
|
|
|
|
|
// 判断一下,管道是否在剖切的范围内
|
|
AcGeLineSeg3d seg1, seg2;
|
|
getOuterLine(seg, dDN, pln, seg1, seg2);
|
|
|
|
// 都在剖面方向的另一侧,不处理
|
|
if (onSide(pln, seg1) == 2 && onSide(pln, seg2) == 2)
|
|
return false;
|
|
|
|
// 其他情况下,seg1要么在剖面方向一侧且剖面最近,要么就直接在剖面上了,都直接返回seg1进行运算
|
|
segOut = seg1;
|
|
return true;
|
|
}
|
|
|
|
// 管线和管件不需要判断实体是否在剖切范围内,因为PreprocessForHlr生成的线都贴着实体
|
|
// hlr计算的时候会处理
|
|
void AecDbEwPipe::PreprocessForHlr(const AcGePoint3d &ptPlnO
|
|
, const AcGeVector3d &vtPlnN
|
|
, AcArray<AcDbEntity *> &ar) const
|
|
{
|
|
if (!m_pRegion) return;
|
|
if (!m_pBaseCurve) return;
|
|
|
|
AcGePlane pln(ptPlnO, vtPlnN);
|
|
|
|
// 先求一下真实直径
|
|
AcDbExtents ext;
|
|
m_pRegion->getGeomExtents(ext);
|
|
double dW = ext.maxPoint().x - ext.minPoint().x;
|
|
|
|
double dSta(.0), dEta(.0), dLen(.0);
|
|
m_pBaseCurve->getStartParam(dSta);
|
|
|
|
// 只要是剖切,都绘制为实心管道
|
|
const AecDbObjXDataMap *pMap(&m_mapSpecXData);
|
|
const_cast<AecDbObjXDataMap *>(pMap)->SetAt(HLR_CALC, 1981);
|
|
|
|
AcGeLineSeg3d seg;
|
|
if (!getCenterLineForHlrCut(AcGeLineSeg3d(StartPoint(), EndPoint()), dW, pln, seg))
|
|
return;
|
|
|
|
AcDbLine *pLine(new AcDbLine(seg.startPoint(), seg.endPoint()));
|
|
AcArray<AcDbEntity*> &arPtrs(ar);
|
|
arPtrs.append(pLine);
|
|
|
|
AcGeVector3d vtDir;
|
|
bool bShowDir(false);
|
|
m_pBaseCurve->getFirstDeriv(dSta, vtDir);
|
|
vtDir.normalize();
|
|
AcGeLine3d ln3d(AcGePoint3d::kOrigin, 10.0 * vtDir);
|
|
if (!vtDir.isParallelTo(AcGeVector3d::kZAxis) // 管道方向不垂直XY面
|
|
&& !ln3d.isParallelTo(AcGePlane::kXYPlane)) // 并且不平行XY面
|
|
bShowDir = true;
|
|
|
|
|
|
//斜度不是平行XY面的投影到XY面
|
|
if (bShowDir)//斜管
|
|
{ // 需要显示流向
|
|
|
|
|
|
AcGeEntity3d *pGe = seg.orthoProject(pln);
|
|
if (!pGe) return;
|
|
AcGeLineSeg3d *pOrthSeg((AcGeLineSeg3d *)pGe);
|
|
AcGeVector3d vtOrth(pOrthSeg->direction());
|
|
AcGeVector3d vtAxis = vtOrth.crossProduct(seg.direction());
|
|
double dAnglePipeWithPln = vtOrth.angleTo(vtDir, vtAxis);
|
|
|
|
AcGeMatrix3d mat;
|
|
mat.setToRotation(dAnglePipeWithPln, vtAxis, pOrthSeg->startPoint());
|
|
DELETE_PTR(pGe);
|
|
AcGeVector3d vtNormal(pln.normal());
|
|
vtNormal.transformBy(mat); // 这就是绘制箭头的法向
|
|
// 根据法向,得到箭头斜边的两个方向,箭头夹角60度
|
|
AcGeVector3d vt1(-vtDir), vt2(-vtDir);
|
|
vt1.rotateBy(PI / 6, vtNormal);
|
|
vt2.rotateBy(-PI / 6, vtNormal);
|
|
vt1.normalize();
|
|
vt2.normalize();
|
|
vt1 *= dW * .5;
|
|
vt2 *= dW * .5;
|
|
|
|
// pPipeLine 分n段,画n-1个箭头
|
|
int nSeg(10);
|
|
double dDist(seg.length() / nSeg);
|
|
|
|
AcGePoint3d pt;
|
|
for (int i(0); i< nSeg - 1; ++i)
|
|
{
|
|
pLine->getPointAtDist((i + 1) * dDist, pt);
|
|
arPtrs.append(new AcDbLine(pt, pt + vt1));
|
|
arPtrs.append(new AcDbLine(pt, pt + vt2));
|
|
}
|
|
}
|
|
|
|
// 双线
|
|
if (!IsSingleLine(this))
|
|
{
|
|
AcDbVoidPtrArray arFlang;
|
|
AcGiExplodeDraw exdc(arFlang);
|
|
DrawFlangInf3d(exdc);
|
|
|
|
for (int i = 0; i < arFlang.length(); i++)
|
|
{
|
|
AcDbEntity *pEnt = (AcDbEntity *)arFlang[i];
|
|
if (pEnt)
|
|
{
|
|
// 为pEnt添加标记
|
|
AecDbObjXDataMap xdata;
|
|
xdata.SetAt(_T("_is_flang_"), 1);
|
|
xdata.Write(pEnt, _T("_is_flang_"));
|
|
ar.append(pEnt);
|
|
}
|
|
}
|
|
|
|
// DrawFlangInf3d会在类的3d缓存里存放AcDb3dSolid,清空一下
|
|
Clean3DBufferNoDel();
|
|
}
|
|
else
|
|
{
|
|
// 单线时,接口上直接绘制一个圆形面域
|
|
AcArray<AecInterface> infs;
|
|
GetInterface(infs);
|
|
WPipe::PipeParam* pParam = GetPipeParam();
|
|
if (pParam)
|
|
{
|
|
for (int i(0); i < infs.length(); ++i)
|
|
{
|
|
AecInterface &inf(infs[i]);
|
|
AcDbCircle cir(inf.ptPos, inf.vtDir, pParam->m_dInterfaceD * .5);
|
|
AcDbRegion *pReg = CoreTools::createRegion(&cir);
|
|
if (pReg)
|
|
{
|
|
AecDbObjXDataMap xdata;
|
|
xdata.SetAt(_T("_is_flang_"), 1);
|
|
xdata.Write(pReg, _T("_is_flang_"));
|
|
ar.append(pReg);
|
|
}
|
|
}
|
|
DELETE_PTR(pParam);
|
|
}
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
BOOL bHlrCalc(FALSE);
|
|
m_mapSpecXData.GetAt(HLR_CALC, bHlrCalc);
|
|
if (bHlrCalc == 1981 && m_pRegion)
|
|
{
|
|
// 如果 bHlrCalc 为1981,说明要绘制实心管道
|
|
// 会在ProcessHlrResult函数设置回来
|
|
|
|
if (IsSingleLine(this))
|
|
{
|
|
CString sSys;
|
|
GetAt(PIPE_SYS, sSys);
|
|
|
|
AcGePoint3d ptS, ptE;
|
|
if (getStartPoint(ptS) != Acad::eOk || getEndPoint(ptE) != Acad::eOk)
|
|
return Acad::eOk;
|
|
|
|
double dEl = ptS.z;//中心标高
|
|
m_mapSpecXData.GetAt(PIPE_EL, dEl);
|
|
|
|
AcDbCurve *pBaseCrv = GetBaseCurve(false);
|
|
AcDbPolyline *pPl = CoreTools::MakePolyline(pBaseCrv);
|
|
if (!pPl) return Acad::eOk;
|
|
|
|
AecDbObjXDataMap xData;
|
|
xData.CopyFrom(&m_mapSpecXData);
|
|
xData.SetAt(PIPE_EL, dEl);
|
|
xData.Write(pPl, BIMDATA_APP);
|
|
|
|
setInfo2Ent(sSys, pPl, true, m_mapSpecXData);
|
|
setInfo2Dc(sSys, dc, true, m_mapSpecXData);
|
|
Draw2dSingleSegment(dc, pPl);
|
|
|
|
}
|
|
else
|
|
{
|
|
// 炸碎region,应该是两个圆,一个是外圆,一个是内圆,用外圆的边界来绘制实心管道
|
|
AcDbVoidPtrArray ar;
|
|
m_pRegion->explode(ar);
|
|
if (ar.isEmpty()) return Acad::eOk;
|
|
|
|
AcDbEntity *pEnt1(NULL), *pEnt2(NULL);
|
|
if (ar.length() > 0) pEnt1 = (AcDbEntity *)ar[0];
|
|
if (ar.length() > 1) pEnt2 = (AcDbEntity *)ar[1];
|
|
|
|
AcDbCircle *pCir1(NULL), *pCir2(NULL);
|
|
if (pEnt1) pCir1 = AcDbCircle::cast(pEnt1);
|
|
if (pEnt2) pCir2 = AcDbCircle::cast(pEnt2);
|
|
|
|
if (pCir1 && pCir2)
|
|
{
|
|
// 两个圆都存在,找出哪个是外圆
|
|
AcDbCircle *pOuter = (pCir1->radius() >= pCir2->radius()) ? pCir1 : pCir2;
|
|
AcDbEntity *p3dEnt = dc.DrawPipe(StartPoint(), EndPoint(), pOuter->radius(), 0.0);
|
|
if (p3dEnt)
|
|
{
|
|
//m_mapSpecXData.Write(p3dEnt, BIMDATA_APP);
|
|
dc.DrawEntity(p3dEnt);
|
|
}
|
|
}
|
|
else if (pCir1 || pCir2)
|
|
{
|
|
// 只有一个圆,直接用它来绘制
|
|
AcDbCircle *pOuter = pCir1 ? pCir1 : pCir2;
|
|
AcDbEntity *p3dEnt = dc.DrawPipe(StartPoint(), EndPoint(), pOuter->radius(), 0.0);
|
|
if (p3dEnt)
|
|
{
|
|
//m_mapSpecXData.Write(p3dEnt, BIMDATA_APP);
|
|
dc.DrawEntity(p3dEnt);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus es = AecDbEwPipeBase::Draw3d(dc);
|
|
|
|
return es;
|
|
|
|
////管线系统屏蔽掉
|
|
if ( dc.IsDragging() )
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
FreeBuffer(0,m_arDrawBuffer3d2);
|
|
|
|
AcGePoint3d ptSta = StartPoint();
|
|
AcGePoint3d ptEnd = EndPoint();
|
|
|
|
AcGeVector3d vtDir = EndPoint() - StartPoint();
|
|
vtDir.normalize();
|
|
|
|
//如果是衬塑管
|
|
double dGast = GetGasketThick();
|
|
ptSta += vtDir * 0.5 * dGast;
|
|
ptEnd -= vtDir * 0.5 * dGast;
|
|
|
|
Adesk::Int16 nCr = dc.GetColor();
|
|
|
|
if (IsActive())
|
|
{
|
|
AcDbEntity* p3dEnt = NULL;
|
|
double dOD = 0.0;
|
|
if (m_mapSpecXData.GetAt(PIPE_OD,dOD))
|
|
{
|
|
dc.SetColor(kMagenta);
|
|
//p3dEnt = dc.DrawPipe(ptSta,ptEnd,0.5 * dOD,0.0);
|
|
//if (p3dEnt != NULL)
|
|
//{
|
|
// DrawSubAxis(dc,p3dEnt);
|
|
// m_arDrawBuffer3d2.append(p3dEnt);
|
|
//}
|
|
}
|
|
}
|
|
|
|
AcGePoint3d ptGeFr,ptGeTo;
|
|
if (m_bShowFlowDir)//流向
|
|
{
|
|
dc.SetColor(kMagenta);//kMagenta
|
|
|
|
vtDir.normalize();
|
|
vtDir *= PixelToWcs(30);
|
|
|
|
//clinder
|
|
ptGeFr = Mid(ptSta,ptEnd);
|
|
ptGeTo = ptGeFr + vtDir;
|
|
|
|
double dDn = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_DN,dDn);
|
|
|
|
ptGeFr.z += 1.1 * dDn;
|
|
ptGeTo.z += 1.1 * dDn;
|
|
AcDbEntity* p3d = dc.DrawCone(ptGeFr,PixelToWcs(1),ptGeTo,PixelToWcs(1));
|
|
if (p3d != NULL)
|
|
{
|
|
m_arDrawBuffer3d2.append(p3d);
|
|
}
|
|
|
|
//arrow
|
|
ptGeFr = ptGeTo;
|
|
vtDir.normalize();
|
|
ptGeTo += vtDir * PixelToWcs(15);
|
|
p3d = dc.DrawCone(ptGeFr,PixelToWcs(5),ptGeTo,1.e-3);
|
|
if (p3d != NULL)
|
|
{
|
|
m_arDrawBuffer3d2.append(p3d);
|
|
}
|
|
}
|
|
dc.SetColor(nCr);
|
|
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::DrawFlangInf3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int nConnectType = 0;//焊接0 承插1 螺纹2 法兰管3
|
|
m_mapSpecXData.GetAt(PIPE_CONNECT,nConnectType);
|
|
|
|
AcGePoint3dArray arPnts;
|
|
if (nConnectType == 3 || nConnectType == 5)
|
|
{
|
|
WPipe::PipeParam* pPipeParam = GetPipeParam();
|
|
if (pPipeParam != NULL)
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
GetInterface(arInfs);
|
|
|
|
if ( (pPipeParam->m_dInterfaceL3 - AS_MUNIT(100.0)) > 1.e-6)
|
|
{
|
|
for (int i = 0;i < arInfs.length();i++)
|
|
{
|
|
AecInterface &inf = arInfs.at(i);
|
|
|
|
inf.ptPos -= inf.vtDir * 0.5 * GetGasketThick();
|
|
inf.ptPos -= inf.vtDir * pPipeParam->m_dInterfaceL;
|
|
DrawFlangInf3d(dc, inf.ptPos, inf.vtDir);
|
|
}
|
|
}
|
|
DELETE_PTR(pPipeParam);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::DrawFlangInf3d(AcGiDraw &dc,const AcGePoint3d& ptPos,const AcGeVector3d& vtInf) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
WPipe::PipeParam* pPipeParam = GetPipeParam();
|
|
if (pPipeParam != NULL)
|
|
{
|
|
AcGePoint3d ptSta = ptPos;
|
|
AcGePoint3d ptEnd = ptSta + vtInf * pPipeParam->m_dInterfaceL;
|
|
|
|
AcGePoint3d ptCen(0, 0, 0);
|
|
|
|
AecDbEwPipe pipeT;
|
|
pipeT.SetSection(pPipeParam->m_dInterfaceD, 0.0);
|
|
AcDbRegion* pRegion = pipeT.GetSection();
|
|
if (pRegion != NULL)
|
|
{
|
|
AcDbLine ln;
|
|
ln.setStartPoint(ptSta);
|
|
ln.setEndPoint(ptEnd);
|
|
|
|
AcDbEntity* p3dEnt = dc.DrawPipe(&ln, pRegion, ptCen);
|
|
if (p3dEnt != NULL)
|
|
{
|
|
Add3DBuffer(p3dEnt);
|
|
}
|
|
DELETE_PTR(pRegion);
|
|
}
|
|
DELETE_PTR(pPipeParam);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
static BOOL IsGSFMaterial(LPCTSTR pszMertial)
|
|
{
|
|
CString sMertial = pszMertial;
|
|
//目前只能按照材质判断
|
|
if (sMertial.Find(_T("衬塑")) != -1 ||
|
|
sMertial.Find(_T("SRPE")) != -1 ||
|
|
sMertial.Find(_T("HG/T 20538")) != -1)
|
|
{
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::DrawFlangInf2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
backupDc(dc);
|
|
|
|
dc.SetLayer(m_idDoubleLayer);
|
|
dc.SetLineType(linetypeId());
|
|
dc.SetColor(kColorByLayer);
|
|
|
|
CString sys;
|
|
m_mapSpecXData.GetAt(PIPE_SYS, sys);
|
|
|
|
int nConnectType = 0;//焊接0 承插1 螺纹2 法兰管3
|
|
m_mapSpecXData.GetAt(PIPE_CONNECT,nConnectType);
|
|
|
|
int nTrade = 0;
|
|
m_mapSpecXData.GetAt(DOC_TRADE,nTrade);
|
|
|
|
AcGePoint3dArray arPnts;
|
|
if (nConnectType == 3 || nConnectType == 5)
|
|
{
|
|
WPipe::PipeParam* pPipeParam = GetPipeParam();
|
|
if (pPipeParam != NULL)
|
|
{
|
|
//是否是衬塑钢管
|
|
BOOL bIsGSF = IsGSFMaterial(pPipeParam->szMertial);
|
|
|
|
double dMinT = 100.0;
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"), &rb);
|
|
if (rb.resval.rint == AcDb::kUnitsMeters)
|
|
{
|
|
dMinT /= 1000.0;
|
|
}
|
|
|
|
if ( (pPipeParam->m_dInterfaceL3 - dMinT) > 1.e-6)
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
GetInterface(arInfs);
|
|
|
|
if ((pPipeParam->m_dInterfaceL3 - AS_MUNIT(100.0)) > 1.e-6)
|
|
{
|
|
for (int i = 0; i < arInfs.length(); i++)
|
|
{
|
|
AecInterface &inf = arInfs.at(i);
|
|
|
|
//向内画法兰
|
|
inf.ptPos -= inf.vtDir * 0.5 * GetGasketThick();
|
|
inf.ptPos -= inf.vtDir * pPipeParam->m_dInterfaceL;
|
|
|
|
DrawFlangInf2d(dc, inf.ptPos, inf.vtDir);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
recoverDc(dc);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int AecDbEwPipe::GetFlangeCount(BOOL bIsBomCall) const
|
|
{
|
|
assertReadEnabled();
|
|
int nFlangs = 0;
|
|
|
|
int nConnectType = 0;//焊接0 承插1 螺纹2 法兰管3 沟槽法兰 5
|
|
m_mapSpecXData.GetAt(PIPE_CONNECT, nConnectType);
|
|
|
|
AcGePoint3dArray arPnts;
|
|
if (nConnectType == 3 || nConnectType == 5)
|
|
{
|
|
if (bIsBomCall)
|
|
{
|
|
nFlangs = 2;
|
|
|
|
//不统计
|
|
int nFGNbom = 0;
|
|
m_mapSpecXData.GetAt(PIPE_FLANGNOBOM, nFGNbom);
|
|
if (nFGNbom)
|
|
{
|
|
nFlangs = 0;
|
|
return nFlangs;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
WPipe::PipeParam *pPipeParam = GetPipeParam();
|
|
if (pPipeParam != NULL)
|
|
{
|
|
double dLen = 0.0, dEnd = 0.0, dSta = 0.0, dP = 0.0;
|
|
m_pBaseCurve->getEndParam(dEnd);
|
|
m_pBaseCurve->getDistAtParam(dEnd, dLen);
|
|
|
|
double dMinT = 100;
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"), &rb);
|
|
if (rb.resval.rint == AcDb::kUnitsMeters)
|
|
{
|
|
dMinT /= 1000.0;
|
|
}
|
|
|
|
//最少100 mm 分段!!!
|
|
if ((pPipeParam->m_dInterfaceL3 - dMinT) > 1.e-6)
|
|
{
|
|
int nLen = (int)(dLen);
|
|
int nInfL = (int)(pPipeParam->m_dInterfaceL3);
|
|
|
|
nFlangs = (nLen / nInfL) * 2;
|
|
int nSE = nLen % nInfL;
|
|
|
|
nFlangs += nSE > 0 ? 2 : 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//衬塑
|
|
CString sMat;
|
|
m_mapSpecXData.GetAt(PIPE_MATERIAL, sMat);
|
|
if (IsGSFMaterial(sMat) && bIsBomCall)//衬塑管不统计
|
|
{
|
|
nFlangs = 0;
|
|
}
|
|
}
|
|
return nFlangs;
|
|
}
|
|
|
|
int AecDbEwPipe::GetBreakFlangePipes(AcDbVoidPtrArray& arPipes)
|
|
{
|
|
int nFlgs = GetFlangeCount(FALSE);
|
|
if (nFlgs > 2)//必须大于2个法兰
|
|
{
|
|
WPipe::PipeParam *pPipeParam = GetPipeParam();
|
|
double dGasket = GetGasketThick();
|
|
|
|
AcGePoint3d ptSta = StartPoint();
|
|
AcGePoint3d ptEnd = EndPoint();
|
|
AcGeVector3d vtDir = ptEnd - ptSta;
|
|
vtDir.normalize();
|
|
|
|
double dLen = 0.0, dEnd = 0.0, dSta = 0.0, dP = 0.0;
|
|
m_pBaseCurve->getEndParam(dEnd);
|
|
m_pBaseCurve->getDistAtParam(dEnd, dLen);
|
|
|
|
double dMinT = 100.0;
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"), &rb);
|
|
if (rb.resval.rint == AcDb::kUnitsMeters)
|
|
{
|
|
dMinT /= 1000.0;
|
|
}
|
|
|
|
if ((pPipeParam->m_dInterfaceL3 - dMinT) > 1.e-6)
|
|
{
|
|
AcGePoint3d ptStaT = ptSta;
|
|
AcGePoint3d ptEndT;
|
|
AcGeVector3d vt;
|
|
|
|
WPipe::PipeParam *pPipeCopy = new WPipe::PipeParam;
|
|
memcpy(pPipeCopy, pPipeParam, sizeof(WPipe::PipeParam));
|
|
pPipeCopy->m_dInterfaceL3 = 0;
|
|
|
|
int nLen = (int)(dLen);
|
|
int nInfL = (int)(pPipeParam->m_dInterfaceL3);
|
|
|
|
int nBreaks = nLen / nInfL ;
|
|
int nSE = nLen % nInfL;
|
|
nBreaks += nSE > 0 ? 1 : 0;
|
|
|
|
AecDbEwPipe *pPipeT = NULL;
|
|
for(int i = 0;i < nBreaks;i++)
|
|
{
|
|
if (i == nBreaks - 1)//最后一段
|
|
{
|
|
SetStartPoint(ptStaT);
|
|
arPipes.append(this);
|
|
}
|
|
else
|
|
{
|
|
if (i == 0)//开始段
|
|
{
|
|
ptEndT = ptStaT + vtDir * pPipeParam->m_dInterfaceL3;
|
|
|
|
pPipeT = new AecDbEwPipe;
|
|
pPipeT->copyFrom(this);
|
|
pPipeT->SetPipeParam(pPipeCopy);
|
|
pPipeT->SetStartPoint(ptStaT);
|
|
pPipeT->SetEndPoint(ptEndT);
|
|
arPipes.append(pPipeT);
|
|
|
|
ptStaT = ptEndT;
|
|
}
|
|
else//中间段
|
|
{
|
|
ptEndT = ptStaT + vtDir * pPipeParam->m_dInterfaceL3;
|
|
|
|
pPipeT = new AecDbEwPipe;
|
|
pPipeT->copyFrom(this);
|
|
pPipeT->SetPipeParam(pPipeCopy);
|
|
pPipeT->SetStartPoint(ptStaT);
|
|
pPipeT->SetEndPoint(ptEndT);
|
|
arPipes.append(pPipeT);
|
|
|
|
ptStaT = ptEndT;
|
|
}
|
|
}
|
|
}
|
|
delete pPipeCopy;
|
|
}
|
|
}
|
|
return arPipes.length();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::DrawFlangInf2d(AcGiDraw &dc,const AcGePoint3d& ptPos,const AcGeVector3d& vtInf) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
backupDc(dc);
|
|
CString sys;
|
|
m_mapSpecXData.GetAt(PIPE_SYS, sys);
|
|
|
|
WPipe::PipeParam* pPipeParam = GetPipeParam();
|
|
if (pPipeParam != NULL)
|
|
{
|
|
int nDir = 1;
|
|
AcGePoint3d ptSta = ptPos;
|
|
AcGePoint3d ptEnd = ptSta + vtInf * nDir * pPipeParam->m_dInterfaceL;
|
|
|
|
AcDbLine ln;
|
|
ln.setStartPoint(ptSta);
|
|
ln.setEndPoint(ptEnd);
|
|
|
|
AcGeVector3d vtV = vtInf;
|
|
|
|
AcGeLine3d ln3d;
|
|
ln3d.set(AcGePoint3d::kOrigin,vtInf);
|
|
|
|
int nStyle = 0;
|
|
m_mapSpecXData.GetAt(KEY_2DSTYLE,nStyle);
|
|
|
|
if (ln3d.isParallelTo(AcGePlane::kXYPlane))
|
|
{
|
|
vtV = vtInf;
|
|
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtV.normalize();
|
|
|
|
AcGePoint3d ptGe[5];
|
|
ptGe[0] = ptSta;
|
|
ptGe[0] += vtV * 0.5 * pPipeParam->m_dInterfaceD;
|
|
|
|
ptGe[1] = ptEnd;
|
|
ptGe[1] += vtV * 0.5 * pPipeParam->m_dInterfaceD;
|
|
|
|
ptGe[3] = ptSta;
|
|
ptGe[3] -= vtV * 0.5 * pPipeParam->m_dInterfaceD;
|
|
|
|
ptGe[2] = ptEnd;
|
|
ptGe[2] -= vtV * 0.5 * pPipeParam->m_dInterfaceD;
|
|
|
|
ptGe[4] = ptGe[0];
|
|
|
|
int nCrBk = dc.GetColor();
|
|
int nColor = nCrBk;
|
|
if ( m_mapSpecXData.GetAt(_T("COLOR"),nColor) )
|
|
{
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
/*AcDbLine* pLn = NULL;
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
pLn = new AcDbLine(ptGe[i],ptGe[i+1]);
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
}*/
|
|
|
|
|
|
AcDbPolyline *pPl(NULL);
|
|
if (nStyle != 2)
|
|
{ // 单线管,用一条线表示法兰
|
|
AcGePoint3dArray pts;
|
|
pts.append(ptEnd + vtV * .5 * pPipeParam->m_dInterfaceD);
|
|
pts.append(ptEnd - vtV * .5 * pPipeParam->m_dInterfaceD);
|
|
pPl = FormatPolyline(pts);
|
|
}
|
|
else
|
|
{
|
|
pPl = FormatPolyline(ptGe, 5);
|
|
pPl->setClosed(Adesk::kTrue);
|
|
}
|
|
|
|
|
|
DrawPlotPolyline(dc,pPl,nStyle,TRUE,TRUE);
|
|
|
|
if (nStyle == 2)
|
|
{
|
|
double dMinT = 6.0;
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"), &rb);
|
|
if (rb.resval.rint == AcDb::kUnitsMeters)
|
|
{
|
|
dMinT /= 1000.0;
|
|
}
|
|
|
|
setInfo2Dc(sys, dc, false, m_mapSpecXData);
|
|
|
|
//绘制螺栓线
|
|
ptGe[0] -= vtV * 0.1 * pPipeParam->m_dInterfaceD;
|
|
ptGe[1] -= vtV * 0.1 * pPipeParam->m_dInterfaceD;
|
|
ptGe[0] -= vtInf * dMinT;
|
|
ptGe[1] += vtInf * dMinT;
|
|
|
|
AcDbLine *pLn = new AcDbLine(ptGe[0], ptGe[1]);
|
|
setInfo2Ent(sys, pLn, false, m_mapSpecXData);
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
|
|
ptGe[2] += vtV * 0.1 * pPipeParam->m_dInterfaceD;
|
|
ptGe[3] += vtV * 0.1 * pPipeParam->m_dInterfaceD;
|
|
ptGe[2] += vtInf * dMinT;
|
|
ptGe[3] -= vtInf * dMinT;
|
|
|
|
pLn = new AcDbLine(ptGe[2], ptGe[3]);
|
|
setInfo2Ent(sys, pLn, false, m_mapSpecXData);
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
|
|
dc.SetColor(nCrBk);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (vtInf.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
//绘制圆,省略.由上下弯头定
|
|
}
|
|
else
|
|
{
|
|
//...斜管法兰绘制
|
|
AcGePoint3d ptSta = ptPos;
|
|
AcGePoint3d ptEnd = ptSta + vtInf * nDir * pPipeParam->m_dInterfaceL;
|
|
ptEnd.z = ptSta.z;//
|
|
AcGeVector3d vtInfXY = vtInf;
|
|
vtInfXY.z = 0.0;//XY
|
|
|
|
AcDbLine ln;
|
|
ln.setStartPoint(ptSta);
|
|
ln.setEndPoint(ptEnd);
|
|
|
|
AcGeVector3d vtV = vtInfXY;
|
|
|
|
AcGeLine3d ln3d;
|
|
ln3d.set(AcGePoint3d::kOrigin,vtInfXY);
|
|
|
|
int nStyle = 0;
|
|
m_mapSpecXData.GetAt(KEY_2DSTYLE,nStyle);
|
|
|
|
//if (ln3d.isParallelTo(AcGePlane::kXYPlane))
|
|
{
|
|
vtV = vtInfXY;
|
|
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtV.normalize();
|
|
|
|
AcGePoint3d ptGe[5];
|
|
ptGe[0] = ptSta;
|
|
ptGe[0] += vtV * 0.5 * pPipeParam->m_dInterfaceD;
|
|
|
|
ptGe[1] = ptEnd;
|
|
ptGe[1] += vtV * 0.5 * pPipeParam->m_dInterfaceD;
|
|
|
|
ptGe[3] = ptSta;
|
|
ptGe[3] -= vtV * 0.5 * pPipeParam->m_dInterfaceD;
|
|
|
|
ptGe[2] = ptEnd;
|
|
ptGe[2] -= vtV * 0.5 * pPipeParam->m_dInterfaceD;
|
|
|
|
ptGe[4] = ptGe[0];
|
|
|
|
int nCrBk = dc.GetColor();
|
|
int nColor = nCrBk;
|
|
if ( m_mapSpecXData.GetAt(_T("COLOR"),nColor) )
|
|
{
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
/*AcDbLine* pLn = NULL;
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
pLn = new AcDbLine(ptGe[i],ptGe[i+1]);
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
}*/
|
|
|
|
AcDbPolyline* pPl = FormatPolyline(ptGe,5);
|
|
pPl->setClosed(Adesk::kTrue);
|
|
DrawPlotPolyline(dc,pPl,nStyle,TRUE,TRUE);
|
|
|
|
double dMinT = 6.0;
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"), &rb);
|
|
if (rb.resval.rint == AcDb::kUnitsMeters)
|
|
{
|
|
dMinT /= 1000.0;
|
|
}
|
|
setInfo2Dc(sys, dc, false, m_mapSpecXData);
|
|
|
|
//绘制螺栓线
|
|
ptGe[0] -= vtV * 0.1 * pPipeParam->m_dInterfaceD;
|
|
ptGe[1] -= vtV * 0.1 * pPipeParam->m_dInterfaceD;
|
|
ptGe[0] -= vtInfXY * dMinT;
|
|
ptGe[1] += vtInfXY * dMinT;
|
|
|
|
AcDbLine* pLn = new AcDbLine(ptGe[0],ptGe[1]);
|
|
setInfo2Ent(sys, pLn, false, m_mapSpecXData);
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
|
|
ptGe[2] += vtV * 0.1 * pPipeParam->m_dInterfaceD;
|
|
ptGe[3] += vtV * 0.1 * pPipeParam->m_dInterfaceD;
|
|
ptGe[2] += vtInfXY * dMinT;
|
|
ptGe[3] -= vtInfXY * dMinT;
|
|
|
|
pLn = new AcDbLine(ptGe[2],ptGe[3]);
|
|
setInfo2Ent(sys, pLn, false, m_mapSpecXData);
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
|
|
dc.SetColor(nCrBk);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
recoverDc(dc);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwPipe::DrawPlotPolyline(AcGiDraw &dc,AcDbCurve* pCurve,int nStyle,BOOL bDraw/* = TRUE*/,BOOL bIsSE/* = FALSE*/) const
|
|
{
|
|
double dSingleW = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_SINGLEW, dSingleW);
|
|
|
|
double dDbLineW = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_DBLINEW,dDbLineW);
|
|
|
|
if (nStyle < 2)//单线
|
|
{
|
|
if (dSingleW < 1.e-3)
|
|
{
|
|
pCurve->setLayer(m_idSingleLayer);
|
|
pCurve->setLinetype(m_idSingleLnType);
|
|
dc.DrawEntity(pCurve);
|
|
Add2DBuffer(pCurve);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(pCurve);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setConstantWidth(dSingleW);
|
|
pPl->setLayer(m_idSingleLayer);
|
|
pPl->setLinetype(m_idSingleLnType);
|
|
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
else
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(pCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
pPl = new AcDbPolyline;
|
|
pPl->addVertexAt(0,pLn->startPoint().convert2d(AcGePlane::kXYPlane));
|
|
pPl->addVertexAt(1,pLn->endPoint().convert2d(AcGePlane::kXYPlane));
|
|
|
|
pPl->setConstantWidth(dSingleW);
|
|
pPl->setLayer(m_idSingleLayer);
|
|
pPl->setLinetype(m_idSingleLnType);
|
|
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
|
|
delete pLn;
|
|
pCurve = NULL;
|
|
}
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(pCurve);
|
|
if (pArc != NULL)
|
|
{
|
|
AcDbVoidPtrArray arpCurve,arpResult;
|
|
arpCurve.append(pCurve);
|
|
|
|
AcDbCurve* pCrvPl = KTCADUtilityEx::ConvertBoundCurve(arpCurve,arpResult);
|
|
if (pCrvPl != NULL)
|
|
{
|
|
pPl = AcDbPolyline::cast(pCrvPl);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setConstantWidth(dSingleW);
|
|
pPl->setLayer(m_idSingleLayer);
|
|
pPl->setLinetype(m_idSingleLnType);
|
|
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
|
|
delete pArc;
|
|
}
|
|
}
|
|
pCurve = NULL;
|
|
}
|
|
|
|
AcDbCircle* pCir = AcDbCircle::cast(pCurve);
|
|
if (pCir != NULL)
|
|
{
|
|
AcGePoint3d pt = pCir->center();
|
|
pt.x += pCir->radius();
|
|
|
|
pPl = new AcDbPolyline;
|
|
pPl->addVertexAt(0,pt.convert2d(AcGePlane::kXYPlane),1.0);
|
|
|
|
pt.x -= 2.0 * pCir->radius();
|
|
pPl->addVertexAt(1,pt.convert2d(AcGePlane::kXYPlane),1.0);
|
|
|
|
pt.x += 2.0 * pCir->radius();
|
|
pPl->addVertexAt(2,pt.convert2d(AcGePlane::kXYPlane));
|
|
|
|
pPl->setConstantWidth(dSingleW);
|
|
pPl->setLayer(m_idSingleLayer);
|
|
pPl->setLinetype(m_idSingleLnType);
|
|
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
|
|
delete pCir;
|
|
pCurve = NULL;
|
|
}
|
|
}
|
|
}
|
|
else //双线
|
|
{
|
|
if (dDbLineW < 1.e-3 || bIsSE)
|
|
{
|
|
pCurve->setLayer(m_idDoubleLayer);
|
|
pCurve->setLinetype(m_idDoubleLnType);
|
|
dc.DrawEntity(pCurve);
|
|
Add2DBuffer(pCurve);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(pCurve);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setConstantWidth(dDbLineW);
|
|
pPl->setLayer(m_idDoubleLayer);
|
|
pPl->setLinetype(m_idDoubleLnType);
|
|
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
else
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(pCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
pPl = new AcDbPolyline;
|
|
pPl->addVertexAt(0,pLn->startPoint().convert2d(AcGePlane::kXYPlane));
|
|
pPl->addVertexAt(1,pLn->endPoint().convert2d(AcGePlane::kXYPlane));
|
|
|
|
pPl->setConstantWidth(dDbLineW);
|
|
pPl->setLayer(m_idDoubleLayer);
|
|
pPl->setLinetype(m_idDoubleLnType);
|
|
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
|
|
delete pLn;
|
|
pCurve = NULL;
|
|
}
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(pCurve);
|
|
if (pArc != NULL)
|
|
{
|
|
AcDbVoidPtrArray arpCurve,arpResult;
|
|
arpCurve.append(pCurve);
|
|
|
|
AcDbCurve* pCrvPl = KTCADUtilityEx::ConvertBoundCurve(arpCurve,arpResult);
|
|
if (pCrvPl != NULL)
|
|
{
|
|
pPl = AcDbPolyline::cast(pCrvPl);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setConstantWidth(dDbLineW);
|
|
pPl->setLayer(m_idDoubleLayer);
|
|
pPl->setLinetype(m_idDoubleLnType);
|
|
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
|
|
delete pArc;
|
|
}
|
|
}
|
|
pCurve = NULL;
|
|
}
|
|
|
|
AcDbCircle* pCir = AcDbCircle::cast(pCurve);
|
|
if (pCir != NULL)
|
|
{
|
|
AcGePoint3d pt = pCir->center();
|
|
pt.x += pCir->radius();
|
|
|
|
pPl = new AcDbPolyline;
|
|
pPl->addVertexAt(0,pt.convert2d(AcGePlane::kXYPlane),1.0);
|
|
|
|
pt.x -= 2.0 * pCir->radius();
|
|
pPl->addVertexAt(1,pt.convert2d(AcGePlane::kXYPlane),1.0);
|
|
|
|
pt.x += 2.0 * pCir->radius();
|
|
pPl->addVertexAt(2,pt.convert2d(AcGePlane::kXYPlane));
|
|
|
|
pPl->setConstantWidth(dDbLineW);
|
|
pPl->setLayer(m_idDoubleLayer);
|
|
pPl->setLinetype(m_idDoubleLnType);
|
|
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
|
|
delete pCir;
|
|
pCurve = NULL;
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool AecDbEwPipe::TransformAssocInf(int nInf,const AcGeMatrix3d& xform)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcArray<AecInterface> arInf;
|
|
GetInterface(arInf);
|
|
|
|
double dUnits = 1.0;//默认毫米
|
|
if (CoreTools::IsMetersUnit())
|
|
dUnits *= .001;
|
|
|
|
double dAssoc = (dUnits*1.e-3 + 1.1 * GetGasketThick());
|
|
|
|
if (nInf > -1 && nInf < arInf.length() )
|
|
{
|
|
AecInterface& inf = arInf.at(nInf);
|
|
|
|
AcGePoint3d ptGe = inf.ptPos;
|
|
ptGe.transformBy(xform);
|
|
|
|
AcGeVector3d vtM = ptGe - inf.ptPos;
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)//直管
|
|
{
|
|
AcGePoint3d ptSta,ptEnd;
|
|
ptSta = pLine->startPoint();
|
|
ptEnd = pLine->endPoint();
|
|
AcGeVector3d vtL = ptEnd - ptSta;
|
|
|
|
AcGeVector3d vtSta = vtL; vtSta.negate();
|
|
AcGeVector3d vtEnd = vtL;
|
|
vtSta.normalize(); vtEnd.normalize();
|
|
|
|
AcGePoint3d ptStaI = ptSta;
|
|
AcGePoint3d ptEndI = ptEnd;
|
|
|
|
if (inf.ptPos.distanceTo(ptStaI) < dAssoc )//
|
|
{
|
|
pLine->setStartPoint(ptGe);//新位置z
|
|
|
|
AcGeVector3d vtL2 = ptEnd - ptGe;
|
|
if (!vtL2.isParallelTo(vtL))
|
|
{
|
|
ptEnd.transformBy(xform);
|
|
pLine->setEndPoint(ptEnd);
|
|
|
|
//联动洞口套管
|
|
TransformHole(xform);
|
|
|
|
return true;//继续发消息
|
|
}
|
|
return false;//不再继续发消息
|
|
}
|
|
|
|
if (inf.ptPos.distanceTo(ptEndI) < dAssoc)
|
|
{
|
|
pLine->setEndPoint(ptGe);//新位置
|
|
|
|
AcGeVector3d vtL2 = ptGe - ptSta;
|
|
if (!vtL.isParallelTo(vtL2))
|
|
{
|
|
ptSta.transformBy(xform);
|
|
pLine->setStartPoint(ptSta);
|
|
|
|
//联动洞口套管
|
|
TransformHole(xform);
|
|
|
|
return true;//继续发消息
|
|
}
|
|
return false;//不再继续发消息
|
|
}
|
|
}
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(m_pBaseCurve);//弧管
|
|
if (pArc != NULL)
|
|
{
|
|
AcGePoint3d ptSta,ptEnd,ptMid;
|
|
pArc->getStartPoint(ptSta);
|
|
pArc->getEndPoint(ptEnd);
|
|
|
|
double dSta = 0.0,dEnd = 0.0;
|
|
pArc->getStartParam(dSta);
|
|
pArc->getEndParam(dEnd);
|
|
double dMid = (dSta + dEnd) / 2.0;
|
|
pArc->getPointAtParam(dMid,ptMid);
|
|
|
|
if (inf.ptPos.distanceTo(ptSta) < 1.e-1)
|
|
{
|
|
AcDbArc* pArc2 = KTCADUtilityEx::FormatArc(ptGe,ptMid,ptEnd);
|
|
if (pArc2 != NULL)
|
|
{
|
|
pArc->setStartAngle(pArc2->startAngle());
|
|
pArc->setEndAngle(pArc2->endAngle());
|
|
pArc->setCenter(pArc2->center());
|
|
pArc->setRadius(pArc2->radius());
|
|
DELETE_PTR(pArc2);
|
|
}
|
|
return false;//不在继续发消息
|
|
}
|
|
|
|
if (inf.ptPos.distanceTo(ptEnd) < dAssoc)
|
|
{
|
|
AcDbArc* pArc2 = KTCADUtilityEx::FormatArc(ptSta,ptMid,ptGe);
|
|
if (pArc2 != NULL)
|
|
{
|
|
pArc->setStartAngle(pArc2->startAngle());
|
|
pArc->setEndAngle(pArc2->endAngle());
|
|
pArc->setCenter(pArc2->center());
|
|
pArc->setRadius(pArc2->radius());
|
|
DELETE_PTR(pArc2);
|
|
}
|
|
return false;//不在继续发消息
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
LPCTSTR AecDbEwPipe::GetGripCmd() const
|
|
{
|
|
assertReadEnabled();
|
|
return _T("PL_wpipeadd");
|
|
}
|
|
|
|
bool AecDbEwPipe::GetSectionDraw(AcGePlane& plan,const AcGeVector3d& vtTo,AcDbVoidPtrArray& arRegionPtrs) const
|
|
{
|
|
AcGeMatrix3d xform;
|
|
xform.setToPlaneToWorld(plan);
|
|
xform.invert();
|
|
|
|
AcDbVoidPtrArray arSubPtrs;
|
|
AecDbEwPipe* pFit = (AecDbEwPipe *)clone();
|
|
if (pFit != NULL)
|
|
{
|
|
//标高继承
|
|
AcGePoint3d ptS = StartPoint();
|
|
AcGePoint3d ptE = EndPoint();
|
|
AcGeVector3d vt = ptE - ptS;
|
|
vt.normalize();
|
|
|
|
AcGeLine3d ln(AcGePoint3d::kOrigin,vt);
|
|
if (AcGePlane::kXYPlane.isParallelTo(ln))
|
|
{
|
|
pFit->GetSpecialtyData()->SetAt(PIPE_EL,ptS.z);
|
|
}
|
|
|
|
//剖切立管绘制圆
|
|
pFit->GetSpecialtyData()->SetAt(PIPE_Z2DDRAW,TRUE);
|
|
|
|
//由于pl的空间变换出错,剖切一律绘制单线
|
|
double dSingleW = 0.0;
|
|
pFit->GetSpecialtyData()->GetAt(KEY_SINGLEW,dSingleW);
|
|
pFit->GetSpecialtyData()->SetAt(KEY_SINGLEW,0.0);
|
|
|
|
pFit->transformBy(xform);
|
|
|
|
ads_point pt,pt0;
|
|
struct resbuf rb;
|
|
acedGetVar(_T("VIEWDIR"), &rb);
|
|
ads_point_set(rb.resval.rpoint, pt);
|
|
|
|
AcGeVector3d vtViewDir;// = asPnt3d(pt).asVector();
|
|
acdbUcs2Wcs(pt, pt0, true);
|
|
vtViewDir = asPnt3d(pt0).asVector();
|
|
AcGePlane planDraw;
|
|
planDraw.set(AcGePoint3d::kOrigin,vtViewDir);
|
|
|
|
AcGeVector3d vtNorm = plan.normal();
|
|
|
|
//如果是俯视图剖切,则管子的绘制投影面为XY面
|
|
AcGiViewDraw dc(NULL, NULL);
|
|
if (vtViewDir.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
dc.SetDraw2DPlan( planDraw );
|
|
}
|
|
else
|
|
{
|
|
//剖切面为 管子的绘制投影面 是否有其他问题,待定
|
|
dc.SetDraw2DPlan( plan );
|
|
}
|
|
|
|
pFit->Draw2d(dc);
|
|
|
|
pFit->GetDraw2dables(0,arSubPtrs);
|
|
|
|
AecDbObjXDataMap xData;
|
|
AcDbEntity *pEnt = NULL;
|
|
for (int i = 0;i < arSubPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arSubPtrs.at(i);
|
|
if (xData.Read(pEnt,BIMDATA_APP))
|
|
{
|
|
int nVt = 0;
|
|
if (xData.HasKey(KEY_SINGLEW,nVt))
|
|
{
|
|
xData.SetAt(KEY_SINGLEW, dSingleW);
|
|
xData.Write(pEnt, BIMDATA_APP);
|
|
}
|
|
}
|
|
}
|
|
|
|
arRegionPtrs.append(arSubPtrs);
|
|
|
|
delete pFit;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
int AecDbEwPipe::ComparedTo(AecDbCurveBase* pCurOther) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDbEwPipe* pPipeOther = AecDbEwPipe::cast(pCurOther);
|
|
if (pPipeOther != NULL)
|
|
{
|
|
WPipe::PipeParam* pParam = NULL;
|
|
pParam = GetPipeParam();
|
|
|
|
WPipe::PipeParam* pParam2 = NULL;
|
|
pParam2 = pPipeOther->GetPipeParam();
|
|
|
|
if ( fabs(pParam->m_dDN - pParam2->m_dDN ) > 1.e-1)
|
|
return 1;
|
|
|
|
if ( fabs(pParam->m_dOD - pParam2->m_dOD ) > 1.e-1)
|
|
return 1;
|
|
|
|
if ( fabs(pParam->m_dThick - pParam2->m_dThick ) > 1.e-1)
|
|
return 1;
|
|
|
|
delete pParam;
|
|
delete pParam2;
|
|
|
|
AcGePoint3d ptSta,ptEnd;
|
|
getStartPoint(ptSta);
|
|
getEndPoint(ptEnd);
|
|
|
|
AcGePoint3d ptSta2,ptEnd2;
|
|
pPipeOther->getStartPoint(ptSta2);
|
|
pPipeOther->getEndPoint(ptEnd2);
|
|
|
|
if (ptSta.distanceTo(ptSta2) > 2.0)//误差2毫米
|
|
return 1;
|
|
|
|
if (ptEnd.distanceTo(ptEnd2) > 2.0)//误差2毫米
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
//局部Line变虚
|
|
void AecDbEwPipe::AddLineDashedSegment(AcGePoint3d& pt1,AcGePoint3d& pt2)
|
|
{
|
|
assertWriteEnabled();
|
|
Clean2DBuffer();
|
|
|
|
BreakPos bp;
|
|
bp.ptGe = MidPoint(pt1,pt2);
|
|
bp.nType = -1;
|
|
bp.dW = 0.0;
|
|
bp.dLen = pt1.distanceTo(pt2);
|
|
m_arBreaks.append(bp);
|
|
|
|
//先去除此处可能的续断
|
|
AcGePoint3d ptSta;
|
|
AcGePoint3d ptEnd;
|
|
m_pBaseCurve->getStartPoint(ptSta);
|
|
m_pBaseCurve->getEndPoint(ptEnd);
|
|
AcGeVector3d vtDir = ptEnd - ptSta;
|
|
vtDir.normalize();
|
|
AcGeVector3d vt1, vt2;
|
|
|
|
//判断此处是否有断管符号
|
|
CString sIndex;
|
|
AcGePoint3d ptGe,ptM;
|
|
for (int i = 0; i < PIPE_BROKENNUM; i++)
|
|
{
|
|
sIndex.Format(_T("BKOP%d"), i);
|
|
if (m_mapSpecXData.GetAt(sIndex, ptGe))
|
|
{
|
|
//x doffFrSta y dSize z dTrueSize
|
|
ptM = ptSta + vtDir * ptGe.x;
|
|
|
|
vt1 = ptM - pt1;
|
|
vt2 = ptM - pt2;
|
|
|
|
if (vt1.dotProduct(vt2) < -1.e-10)//相反
|
|
{
|
|
m_mapSpecXData.RemoveAt(sIndex);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void AecDbEwPipe::RemoveLineDashedSegment(AcGePoint3d& pt1)
|
|
{
|
|
assertWriteEnabled();
|
|
Clean2DBuffer();
|
|
|
|
AcGeVector3d vtDir,vt1,vt2;
|
|
AcGePoint3d pt2,pt3,ptGeT;
|
|
for (int i = 0;i < m_arBreaks.length();i++)
|
|
{
|
|
BreakPos& brp = m_arBreaks.at(i);
|
|
|
|
m_pBaseCurve->getClosestPointTo(brp.ptGe,ptGeT);
|
|
m_pBaseCurve->getFirstDeriv(ptGeT,vtDir);
|
|
vtDir.normalize();
|
|
|
|
pt2 = ptGeT - vtDir * 0.5 * brp.dLen;
|
|
pt3 = ptGeT + vtDir * 0.5 * brp.dLen;
|
|
|
|
m_pBaseCurve->getClosestPointTo(pt1,ptGeT);
|
|
vt1 = pt1 - pt2;
|
|
vt2 = pt1 - pt3;
|
|
|
|
if (!vt1.isCodirectionalTo(vt2))
|
|
{
|
|
m_arBreaks.removeAt(i);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void AecDbEwPipe::RemoveLineDashedSegment(int nIndex)
|
|
{
|
|
assertWriteEnabled();
|
|
Clean2DBuffer();
|
|
|
|
if (nIndex > -1 && nIndex < m_arBreaks.length())
|
|
{
|
|
m_arBreaks.removeAt(nIndex);
|
|
}
|
|
else if (nIndex == -1)
|
|
{
|
|
m_arBreaks.removeAll();
|
|
}
|
|
}
|
|
|
|
SHJson::WValue& AecDbEwPipe::ToJson(bool bExprotGeo) const
|
|
{
|
|
assertReadEnabled();
|
|
return AecDbEwPipeBase::ToJson(bExprotGeo);
|
|
}
|
|
|
|
bool AecDbEwPipe::ByJson(const SHJson::WValue &v)
|
|
{
|
|
AssertWriteEnabled();
|
|
return AecDbEwPipeBase::ByJson(v);
|
|
}
|
|
|
|
void AecDbEwPipe::UpdatePipeSystem(const int &outClr
|
|
, const AcDbObjectId &outLt
|
|
, const double &outWd
|
|
, const AcDbObjectId &outLy
|
|
, const int &innClr
|
|
, const AcDbObjectId &innLt
|
|
, const double &innWd
|
|
, const AcDbObjectId &innLy)
|
|
{
|
|
AssertWriteEnabled();
|
|
// color
|
|
GetSpecialtyData(AcDb::kForWrite)->SetAt(PIPE_COLOR, innClr);
|
|
GetSpecialtyData(AcDb::kForWrite)->SetAt(PIPE_COLOR_OUT, outClr);
|
|
|
|
// line type
|
|
GetSpecialtyData(AcDb::kForWrite)->SetAt(PIPE_LINETYPE, innLt);
|
|
GetSpecialtyData(AcDb::kForWrite)->SetAt(PIPE_LINETYPE_OUT, outLt);
|
|
|
|
// line width
|
|
GetSpecialtyData(AcDb::kForWrite)->SetAt(PIPE_LINEWIDTH, innWd);
|
|
GetSpecialtyData(AcDb::kForWrite)->SetAt(PIPE_LINEWIDTH_OUT, outWd);
|
|
|
|
// line layer
|
|
GetSpecialtyData(AcDb::kForWrite)->SetAt(PIPE_LINELAYER, innLy);
|
|
GetSpecialtyData(AcDb::kForWrite)->SetAt(PIPE_LINELAYER_OUT, outLy);
|
|
|
|
}
|
|
|
|
#pragma endregion
|
|
|
|
#pragma region EXPORT
|
|
/*
|
|
导出几个函数,为的是配合 wfOutdoor 工程的 “管线碰撞” 命令
|
|
*/
|
|
|
|
extern "C"
|
|
{
|
|
__declspec(dllexport) AcGePoint3d MidPoint(ads_name ent)
|
|
{
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecDbEwPipe, pPipe)
|
|
{
|
|
if (!pPipe) return AcGePoint3d::kOrigin;
|
|
return Mid(pPipe->StartPoint(), pPipe->EndPoint());
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
|
|
__declspec(dllexport) AcGePoint3d GetStartPoint(ads_name ent)
|
|
{
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecDbEwPipe, pPipe)
|
|
{
|
|
if (!pPipe) return AcGePoint3d::kOrigin;
|
|
return pPipe->StartPoint();
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
|
|
__declspec(dllexport) void SetStartPoint(ads_name ent, const AcGePoint3d &pt)
|
|
{
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AecDbEwPipe, pPipe)
|
|
{
|
|
if (!pPipe) return;
|
|
pPipe->SetStartPoint(pt);
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
|
|
__declspec(dllexport) AcGePoint3d GetEndPoint(ads_name ent)
|
|
{
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecDbEwPipe, pPipe)
|
|
{
|
|
if (!pPipe) return AcGePoint3d::kOrigin;
|
|
return pPipe->EndPoint();
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
|
|
__declspec(dllexport) void SetEndPoint(ads_name ent, const AcGePoint3d &pt)
|
|
{
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AecDbEwPipe, pPipe)
|
|
{
|
|
if (!pPipe) return;
|
|
pPipe->SetEndPoint(pt);
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
|
|
namespace
|
|
{
|
|
const WPipe::PipeParam* getPipeParamPtr(ads_name ent)
|
|
{
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecDbEwPipe, pPipe)
|
|
{
|
|
if (!pPipe) return NULL;
|
|
return pPipe->GetPipeParam();
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
}
|
|
|
|
__declspec(dllexport) double GetDnDiameter(ads_name ent)
|
|
{
|
|
double dDn(.0);
|
|
const WPipe::PipeParam *pParam(getPipeParamPtr(ent));
|
|
if (!pParam) return dDn;
|
|
dDn = pParam->m_dDN;
|
|
DELETE_PTR(pParam);
|
|
return dDn;
|
|
}
|
|
|
|
__declspec(dllexport) double GetPipeOutDByDn(ads_name ent)
|
|
{
|
|
double dOd(.0);
|
|
const WPipe::PipeParam *pParam(getPipeParamPtr(ent));
|
|
if (!pParam) return dOd;
|
|
dOd = pParam->m_dOD;
|
|
DELETE_PTR(pParam);
|
|
return dOd;
|
|
}
|
|
|
|
__declspec(dllexport) int GetFlowDir(ads_name ent)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
__declspec(dllexport) double GetPipeDjByDn(ads_name ent)
|
|
{
|
|
double dDj(.0);
|
|
const WPipe::PipeParam *pParam(getPipeParamPtr(ent));
|
|
if (!pParam) return dDj;
|
|
dDj = pParam->m_dOD - 2 * pParam->m_dThick;
|
|
DELETE_PTR(pParam);
|
|
return dDj;
|
|
}
|
|
|
|
__declspec(dllexport) double GetPipeThick(ads_name ent)
|
|
{
|
|
double dT(.0);
|
|
const WPipe::PipeParam *pParam(getPipeParamPtr(ent));
|
|
if (!pParam) return dT;
|
|
dT = pParam->m_dThick;
|
|
DELETE_PTR(pParam);
|
|
return dT;
|
|
}
|
|
|
|
__declspec(dllexport) double GetPipeGradient(ads_name ent)
|
|
{
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecDbEwPipe, pPipe)
|
|
{
|
|
if (!pPipe) return .0;
|
|
AcGePoint3d ptStart = pPipe->StartPoint();
|
|
AcGePoint3d ptEnd = pPipe->EndPoint();
|
|
return (ptStart.z - ptEnd.z) / ptStart.distanceTo(ptEnd);
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
|
|
__declspec(dllexport) int GetSysType(ads_name ent)
|
|
{
|
|
return 19;
|
|
}
|
|
|
|
__declspec(dllexport) AcDbObjectId getID(ads_name ent)
|
|
{
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecDbEwPipe, pPipe)
|
|
{
|
|
if (pPipe) return pPipe->id();
|
|
}
|
|
OPENOBJ_END()
|
|
return AcDbObjectId::kNull;
|
|
}
|
|
|
|
}
|
|
|
|
#pragma endregion |