1612 lines
37 KiB
C++
1612 lines
37 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbHvacDuct.h"
|
|
#include "dbgrip.h"
|
|
#include "AecGripCback.h"
|
|
#include "KTCADUtilityEx.h"
|
|
#include "KTSetting.h"
|
|
#include "AcGiViewDraw.h"
|
|
|
|
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 int GetOrthoProjectedCurve(AcDbRegion* pReg,AcGePlane& plan,AcDbVoidPtrArray& arCurPtrs,bool bMerge);
|
|
extern Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEnt,AcDbDatabase* pDb = NULL,bool bClose = true);
|
|
extern DLLIMPEXP AcDbCurve* GetOffsetCurve(AcDbCurve* pCurve,double dOffset,bool bGetInSide);
|
|
|
|
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(AcGePoint3d& ptGe1,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);
|
|
}
|
|
}
|
|
}
|
|
|
|
Adesk::UInt32 AecDbHvacDuct::kCurrentVersionNumber = 1;
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbHvacDuct, AecDbEwPipeBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_DBDUCT,
|
|
"AecDbHvacDuct"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
|
|
AecDbHvacDuct::AecDbHvacDuct(void)
|
|
{
|
|
m_mapSpecXData.SetAt(KEY_NAME,_T("风管"));
|
|
}
|
|
|
|
AecDbHvacDuct::~AecDbHvacDuct(void)
|
|
{
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacDuct::SetStartPoint(const AcGePoint3d& ptSta)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (m_pBaseCurve == NULL)
|
|
m_pBaseCurve = new AcDbLine;
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
pLine->setStartPoint(ptSta);
|
|
return Acad::eOk;
|
|
}
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
AcGePoint3d AecDbHvacDuct::StartPoint() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptSta;
|
|
getStartPoint(ptSta);
|
|
|
|
return ptSta;
|
|
}
|
|
|
|
// 设置端点 如果是LINE管子
|
|
Acad::ErrorStatus AecDbHvacDuct::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);
|
|
return Acad::eOk;
|
|
}
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
AcGePoint3d AecDbHvacDuct::EndPoint() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptSta;
|
|
getEndPoint(ptSta);
|
|
|
|
return ptSta;
|
|
}
|
|
|
|
bool AecDbHvacDuct::SetDuctParam(const AecHvac::DuctParam* pData)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
double dL = 0.0,dW = 0.0,dt = 0.0;
|
|
double dD = 0.0;
|
|
m_mapSpecXData.SetAt(HVAC_SectType,pData->eType);
|
|
m_mapSpecXData.SetAt(KEY_MATERIAL,pData->szMat);
|
|
m_mapSpecXData.SetAt(KEY_FACTORY,pData->szFat);
|
|
m_mapSpecXData.SetAt(KEY_RRATIO,pData->m_dRatio);
|
|
m_mapSpecXData.SetAt(KEY_FULLPER,pData->m_dFullPer);
|
|
m_mapSpecXData.SetAt(KEY_SN,pData->szNo);
|
|
m_mapSpecXData.SetAt(KEY_TYPE,pData->szType);
|
|
m_mapSpecXData.SetAt(KEY_EXT,pData->szExt);
|
|
m_mapSpecXData.SetAt(PIPE_SYS,pData->szSys);
|
|
m_mapSpecXData.SetAt(KEY_COVER,pData->m_bCover);
|
|
m_mapSpecXData.SetAt(KEY_SPART,pData->m_bSpart);
|
|
|
|
m_mapSpecXData.SetAt(KEY_AirLoadUnit,pData->iALUnit);
|
|
m_mapSpecXData.SetAt(KEY_AirLoad,pData->dAirload);
|
|
|
|
m_mapSpecXData.SetAt(DV_AIRVOL,pData->m_dR);
|
|
m_mapSpecXData.SetAt(DV_WAYRESIS,pData->m_dPy);
|
|
m_mapSpecXData.SetAt(DV_VELOCITY,pData->m_dV);
|
|
|
|
m_mapSpecXData.SetAt(KEY_CENNODRAW,!pData->m_bCenDraw);//中心线
|
|
m_mapSpecXData.SetAt(KEY_REM,pData->szRem);
|
|
m_mapSpecXData.SetAt(HVAC_FlowDirect,pData->m_nFlowDir);
|
|
m_mapSpecXData.SetAt(HVAC_PlusEdge,pData->m_dPlusEdge);//咬口法兰翻边余量
|
|
m_mapSpecXData.SetAt(KEY_NORMAL,pData->m_vtNrom);
|
|
|
|
//设置标高
|
|
//如果是水平管子
|
|
AcGePoint3d ptS = StartPoint();
|
|
AcGePoint3d ptE = EndPoint();
|
|
AcGeVector3d vt = ptE - ptS;
|
|
AcGeLine3d ln(ptS,vt);
|
|
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
|
{
|
|
SetElevation(pData->m_dEl);
|
|
}
|
|
|
|
switch(pData->eType)
|
|
{
|
|
case eRect:
|
|
{
|
|
dL = pData->dSize[0];
|
|
dW = pData->dSize[1];
|
|
dt = pData->dSize[2];
|
|
|
|
if (dL > 1.e-6 && dW > 1.e-6 )
|
|
{
|
|
SetSection(dL,dW,dt);
|
|
return true;
|
|
}
|
|
break;
|
|
}
|
|
case eCircle:
|
|
{
|
|
dD = pData->dSize[0];
|
|
dt = pData->dSize[2];
|
|
|
|
if (dD > 1.e-6 )
|
|
{
|
|
SetSection(dD,dt);
|
|
return true;
|
|
}
|
|
break;
|
|
}
|
|
case eOblate:
|
|
{
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
void AecDbHvacDuct::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-3)
|
|
{
|
|
ptSta.z = dEl;ptEnd.z = dEl;
|
|
pLine->setStartPoint(ptSta);
|
|
pLine->setEndPoint(ptEnd);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool AecDbHvacDuct::IsArcDuct() const
|
|
{
|
|
AcDbArc* pArc = AcDbArc::cast(m_pBaseCurve);
|
|
if (pArc != NULL)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
bool AecDbHvacDuct::IsVertical() const
|
|
{
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLine->startPoint();
|
|
AcGePoint3d ptEnd = pLine->endPoint();
|
|
AcGeVector3d vt = ptEnd - ptSta;
|
|
if (vt.isParallelTo(AcGeVector3d::kZAxis))
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void AecDbHvacDuct::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);
|
|
|
|
}
|
|
|
|
void AecDbHvacDuct::GetDuctParam(AecHvac::DuctParam& data) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
memset(&data,0,sizeof(AecHvac::DuctParam));
|
|
|
|
int nType = 0;
|
|
m_mapSpecXData.GetAt(KEY_SECSHAPE,nType);
|
|
data.eType = (ESection)nType;
|
|
|
|
ESection eType = (ESection)nType;
|
|
switch(eType)
|
|
{
|
|
case eRect:
|
|
{
|
|
m_mapSpecXData.GetAt(KEY_SIZE1,data.dSize[0]); //L
|
|
m_mapSpecXData.GetAt(KEY_SIZE2,data.dSize[1]); //w
|
|
m_mapSpecXData.GetAt(PIPE_THICK,data.dSize[2]);//t
|
|
break;
|
|
}
|
|
case eCircle:
|
|
{
|
|
m_mapSpecXData.GetAt(KEY_SIZE1,data.dSize[0]); //D
|
|
data.dSize[1] = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_THICK,data.dSize[2]);//t
|
|
break;
|
|
}
|
|
case eOblate:
|
|
{
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//假设是平行XY
|
|
data.m_dEl = StartPoint().z;
|
|
|
|
m_mapSpecXData.GetAt(KEY_NORMAL,data.m_vtNrom);
|
|
|
|
data.m_dRatio = 1.0;
|
|
m_mapSpecXData.GetAt(KEY_RRATIO,data.m_dRatio);
|
|
if (data.m_dRatio < 1.e-2)
|
|
data.m_dRatio = 1.0;
|
|
|
|
m_mapSpecXData.GetAt(KEY_FULLPER,data.m_dFullPer);
|
|
m_mapSpecXData.GetAt(HVAC_PlusEdge,data.m_dPlusEdge);//咬口法兰翻边余量
|
|
m_mapSpecXData.GetAt(KEY_NORMAL,data.m_vtNrom);
|
|
|
|
m_mapSpecXData.GetAt(KEY_AirLoadUnit,data.iALUnit);
|
|
m_mapSpecXData.GetAt(KEY_AirLoad,data.dAirload);
|
|
|
|
m_mapSpecXData.GetAt(DV_AIRVOL,data.m_dR);
|
|
m_mapSpecXData.GetAt(DV_WAYRESIS,data.m_dPy);
|
|
m_mapSpecXData.GetAt(DV_VELOCITY,data.m_dV);
|
|
|
|
int nNDraw = 0;
|
|
m_mapSpecXData.GetAt(KEY_CENNODRAW,nNDraw);//中心线
|
|
data.m_bCenDraw = !nNDraw;
|
|
|
|
data.m_nAlign = 1;//居中
|
|
|
|
CString sTemp;
|
|
m_mapSpecXData.GetAt(KEY_SN,sTemp);
|
|
_tcscpy(data.szNo,(LPCTSTR)sTemp);
|
|
|
|
sTemp = _T("");
|
|
m_mapSpecXData.GetAt(KEY_TYPE,sTemp);
|
|
_tcscpy(data.szType,(LPCTSTR)sTemp);
|
|
|
|
sTemp = _T("");
|
|
m_mapSpecXData.GetAt(KEY_EXT,sTemp);
|
|
_tcscpy(data.szExt,(LPCTSTR)sTemp);
|
|
|
|
sTemp = _T("");
|
|
m_mapSpecXData.GetAt(HVAC_System,sTemp);
|
|
_tcscpy(data.szSys,(LPCTSTR)sTemp);
|
|
|
|
sTemp = _T("");
|
|
m_mapSpecXData.GetAt(PIPE_SYS,sTemp);
|
|
_tcscpy(data.szSys,(LPCTSTR)sTemp);
|
|
|
|
m_mapSpecXData.GetAt(KEY_COVER,data.m_bCover);
|
|
m_mapSpecXData.GetAt(KEY_SPART,data.m_bSpart);
|
|
|
|
sTemp = _T("");
|
|
m_mapSpecXData.GetAt(KEY_MATERIAL,sTemp);
|
|
_tcscpy(data.szMat,(LPCTSTR)sTemp);
|
|
|
|
sTemp = _T("");
|
|
m_mapSpecXData.GetAt(KEY_FACTORY,sTemp);
|
|
_tcscpy(data.szFat,(LPCTSTR)sTemp);
|
|
|
|
sTemp = _T("");
|
|
m_mapSpecXData.GetAt(KEY_REM,sTemp);
|
|
_tcscpy(data.szRem,(LPCTSTR)sTemp);
|
|
|
|
sTemp = _T("");
|
|
m_mapSpecXData.GetAt(PIPE_LEVEL,sTemp);
|
|
_tcscpy(data.szLevel,(LPCTSTR)sTemp);
|
|
}
|
|
|
|
AcGeVector3d AecDbHvacDuct::GetNormal() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGeVector3d vtNorm(0,0,1);
|
|
m_mapSpecXData.GetAt(KEY_NORMAL,vtNorm);
|
|
if (vtNorm.isZeroLength())
|
|
{
|
|
AcGeVector3d vt = EndPoint() - StartPoint();
|
|
AcGeLine3d ln(AcGePoint3d::kOrigin, vt);
|
|
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
|
vtNorm.set(0, 0, 1);
|
|
else
|
|
{
|
|
if (vt.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
vtNorm = vt;
|
|
vtNorm.rotateBy(GetSectionRotation(), AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
{
|
|
vtNorm = vt.perpVector();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AcGeVector3d vt = EndPoint() - StartPoint();
|
|
if (vtNorm.isParallelTo(vt))
|
|
{
|
|
//error
|
|
AcGeLine3d ln(AcGePoint3d::kOrigin, vt);
|
|
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
|
vtNorm.set(0, 0, 1);
|
|
else
|
|
{
|
|
if (vt.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
vtNorm = vt;
|
|
vtNorm.rotateBy(GetSectionRotation(), AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
{
|
|
vtNorm = vt.perpVector();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return vtNorm;
|
|
}
|
|
|
|
void AecDbHvacDuct::setNormal(const AcGeVector3d& vtNorm)
|
|
{
|
|
assertWriteEnabled();
|
|
m_mapSpecXData.SetAt(KEY_NORMAL,vtNorm);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacDuct::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 > AecDbHvacDuct::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacDuct::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 (AecDbHvacDuct::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacDuct::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacDuct::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#if ARX>16
|
|
|
|
void AecDbHvacDuct::subList() const
|
|
{
|
|
assertReadEnabled();
|
|
AecDbEwPipeBase::subList();
|
|
}
|
|
|
|
bool AecDbHvacDuct::GetBimInfoTip(CString& sInfoTip) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecHvac::DuctParam data;
|
|
memset(&data,0,sizeof(AecHvac::DuctParam));
|
|
|
|
GetDuctParam(data);
|
|
|
|
CString sField,sFmt;
|
|
sField = _T("风管:\n");
|
|
sInfoTip += sField;
|
|
|
|
LPCTSTR pszAirload[] = {_T("kg/h"),_T("kg/s"),_T("m^3/h"),_T("m^3/s"),_T("L/h"),_T("L/s"),0};
|
|
|
|
switch(data.eType)
|
|
{
|
|
case eRect:
|
|
{
|
|
MAKEFIELD(_T("矩形截面长"),_T("%.1f"),data.dSize[0],sInfoTip);
|
|
MAKEFIELD(_T("矩形截面宽"),_T("%.1f"),data.dSize[1],sInfoTip);
|
|
|
|
MAKEFIELD(_T("风管壁厚"),_T("%.1f"),data.dSize[2],sInfoTip);
|
|
MAKEFIELD(_T("弯头曲率"),_T("%.1f"),data.m_dRatio,sInfoTip);
|
|
MAKEFIELD(_T("卷边长度"),_T("%.1f"),data.m_dPlusEdge,sInfoTip);
|
|
|
|
MAKEFIELD(_T("风量"),_T("%.1f"),data.dAirload,sInfoTip);
|
|
MAKEFIELD(_T("单位"),_T("%s"),pszAirload[data.iALUnit],sInfoTip);
|
|
|
|
MAKEFIELD(_T("管顶标高"),_T("%.1f"),data.m_dEl + 0.5 * data.dSize[1],sInfoTip);
|
|
|
|
MAKEFIELD(_T("风速"),_T("%.2f"),data.m_dV,sInfoTip);
|
|
MAKEFIELD(_T("比摩阻"),_T("%.2f"),data.m_dR,sInfoTip);
|
|
MAKEFIELD(_T("沿层阻力"),_T("%.2f"),data.m_dPy,sInfoTip);
|
|
|
|
MAKEFIELD(_T("类型"),_T("%s"),data.szType,sInfoTip);
|
|
MAKEFIELD(_T("材料"),_T("%s"),data.szMat,sInfoTip);
|
|
|
|
MAKEFIELD(_T("编号"),_T("%s"),data.szNo,sInfoTip);
|
|
MAKEFIELD(_T("厂家"),_T("%s"),data.szFat,sInfoTip);
|
|
|
|
break;
|
|
}
|
|
case eCircle:
|
|
{
|
|
MAKEFIELD(_T("截面直径"),_T("%.1f"),data.dSize[0],sInfoTip);
|
|
|
|
MAKEFIELD(_T("风管壁厚"),_T("%.1f"),data.dSize[2],sInfoTip);
|
|
MAKEFIELD(_T("弯头曲率"),_T("%.1f"),data.m_dRatio,sInfoTip);
|
|
MAKEFIELD(_T("卷边长度"),_T("%.1f"),data.m_dPlusEdge,sInfoTip);
|
|
|
|
MAKEFIELD(_T("风量"),_T("%.1f"),data.dAirload,sInfoTip);
|
|
MAKEFIELD(_T("单位"),_T("%s"),pszAirload[data.iALUnit],sInfoTip);
|
|
|
|
MAKEFIELD(_T("管顶标高"),_T("%.1f"),data.m_dEl + 0.5 * data.dSize[1],sInfoTip);
|
|
|
|
MAKEFIELD(_T("风速"),_T("%.2f"),data.m_dV,sInfoTip);
|
|
MAKEFIELD(_T("比摩阻"),_T("%.2f"),data.m_dR,sInfoTip);
|
|
MAKEFIELD(_T("沿层阻力"),_T("%.2f"),data.m_dPy,sInfoTip);
|
|
|
|
MAKEFIELD(_T("类型"),_T("%s"),data.szType,sInfoTip);
|
|
MAKEFIELD(_T("材料"),_T("%s"),data.szMat,sInfoTip);
|
|
|
|
MAKEFIELD(_T("编号"),_T("%s"),data.szNo,sInfoTip);
|
|
MAKEFIELD(_T("厂家"),_T("%s"),data.szFat,sInfoTip);
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
EPosition AecDbHvacDuct::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 AecDbHvacDuct::ImpGetGripPonts(AcGePoint3dArray& gripPoints,const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
const int nStbitflags = GRIPPT_RESP_FROM_EWFIT;
|
|
if (m_pBaseCurve != 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);
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacDuct::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 = _T("EW_HZFG");//绘制管道
|
|
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);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacDuct::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;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
break;
|
|
}
|
|
case eEnd:
|
|
{
|
|
TransformAssocInf(1,xformM);
|
|
|
|
msg.nType = ePos;
|
|
msg.nData = bMsgSendToAllInfs ? -1 : 1;//控制消息源
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
break;
|
|
}
|
|
case eMid:
|
|
{
|
|
TransformBy(xformM);
|
|
|
|
msg.nType = ePos;
|
|
msg.nData = -1;
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
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 AecDbHvacDuct::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 AecDbHvacDuct::GetGripText(int nPos, CString& sText)
|
|
{
|
|
sText = _T("夹点");
|
|
}
|
|
|
|
#endif
|
|
|
|
Acad::ErrorStatus AecDbHvacDuct::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es = AecDbEwPipeBase::Draw2d(dc);
|
|
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacDuct::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es = AecDbEwPipeBase::Draw3d(dc);
|
|
|
|
FreeBuffer(0,m_arDrawBuffer3d2);
|
|
|
|
AcGePoint3d ptSta = StartPoint();
|
|
AcGePoint3d ptEnd = EndPoint();
|
|
|
|
AcGeVector3d vtDir = EndPoint() - StartPoint();
|
|
vtDir.normalize();
|
|
|
|
Adesk::Int16 nCr = dc.GetColor();
|
|
|
|
if (IsActive())
|
|
{
|
|
AcDbEntity* p3dEnt = NULL;
|
|
double dOD = 0.0;
|
|
if (m_mapSpecXData.GetAt(KEY_SIZE1,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(KEY_SIZE1,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 Acad::eOk;
|
|
}
|
|
|
|
bool AecDbHvacDuct::TransformAssocInf(int nInf,const AcGeMatrix3d& xform)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcArray<AecInterface> arInf;
|
|
GetInterface(arInf);
|
|
|
|
if (nInf > -1 && nInf < arInf.length() )
|
|
{
|
|
AecInterface& inf = arInf.at(nInf);
|
|
|
|
AcGePoint3d ptGe = inf.ptPos;
|
|
ptGe.transformBy(xform);
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)//直管
|
|
{
|
|
AcGePoint3d ptSta,ptEnd;
|
|
ptSta = pLine->startPoint();
|
|
ptEnd = pLine->endPoint();
|
|
AcGeVector3d vtL = ptEnd - ptSta;
|
|
|
|
if (inf.ptPos.distanceTo(ptSta) < 1.e-3)
|
|
{
|
|
pLine->setStartPoint(ptGe);//新位置z
|
|
|
|
AcGeVector3d vtL2 = ptEnd - ptGe;
|
|
if (!vtL2.isParallelTo(vtL))
|
|
{
|
|
ptEnd.transformBy(xform);
|
|
pLine->setEndPoint(ptEnd);
|
|
return true;//继续发消息
|
|
}
|
|
return false;//不再继续发消息
|
|
}
|
|
|
|
if (inf.ptPos.distanceTo(ptEnd) < 1.e-3)
|
|
{
|
|
pLine->setEndPoint(ptGe);//新位置
|
|
|
|
AcGeVector3d vtL2 = ptGe - ptSta;
|
|
if (!vtL.isParallelTo(vtL2))
|
|
{
|
|
ptSta.transformBy(xform);
|
|
pLine->setStartPoint(ptSta);
|
|
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-3)
|
|
{
|
|
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) < 1.e-3)
|
|
{
|
|
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 AecDbHvacDuct::GetGripCmd() const
|
|
{
|
|
assertReadEnabled();
|
|
return _T("HA_ductadd");
|
|
}
|
|
|
|
bool AecDbHvacDuct::GetSectionDraw(AcGePlane& plan,const AcGeVector3d& vtTo,AcDbVoidPtrArray& arRegionPtrs) const
|
|
{
|
|
AcGeMatrix3d xform;
|
|
xform.setToPlaneToWorld(plan);
|
|
xform.invert();
|
|
|
|
AcDbVoidPtrArray arSubPtrs;
|
|
AecDbHvacDuct* pFit = (AecDbHvacDuct *)clone();
|
|
if (pFit != NULL)
|
|
{
|
|
pFit->transformBy(xform);
|
|
|
|
AcGiViewDraw dc(NULL, NULL);
|
|
pFit->Draw2d(dc);
|
|
|
|
pFit->GetDraw2dables(0,arSubPtrs);
|
|
|
|
arRegionPtrs.append(arSubPtrs);
|
|
delete pFit;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
SHJson::WValue &AecDbHvacDuct::ToJson(bool bExprotGeo) const
|
|
{
|
|
assertReadEnabled();
|
|
return AecDbEwPipeBase::ToJson(bExprotGeo);
|
|
}
|
|
|
|
bool AecDbHvacDuct::ByJson(const SHJson::WValue &v)
|
|
{
|
|
AssertWriteEnabled();
|
|
return AecDbEwPipeBase::ByJson(v);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacDuct::DrawFlangInf3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int nSection = 0;
|
|
m_mapSpecXData.GetAt(KEY_SECSHAPE,nSection);
|
|
|
|
double dAng = GetSectionRotation();
|
|
|
|
//临时绘制一个板
|
|
//方板或圆板
|
|
double dPlusEdge = 0.0;
|
|
GetSpecialtyData()->GetAt(HVAC_PlusEdge, dPlusEdge);
|
|
|
|
if (dPlusEdge < 1.e-3)
|
|
return Acad::eOk;
|
|
|
|
AcGePoint3d ptSta = StartPoint();
|
|
AcGePoint3d ptEnd = EndPoint();
|
|
|
|
AcGeVector3d vt = ptEnd - ptSta;
|
|
vt.normalize();
|
|
AcGeLine3d ln3d(AcGePoint3d::kOrigin,vt);
|
|
|
|
AecHvac::DuctParam data;
|
|
memset(&data,0,sizeof(AecHvac::DuctParam));
|
|
GetDuctParam(data);
|
|
|
|
double dL = data.dSize[2];
|
|
data.dSize[2] += dPlusEdge;
|
|
|
|
AecDbHvacDuct ductTmp;
|
|
if (nSection == eRect)
|
|
{
|
|
data.m_dPlusEdge = 0.0;
|
|
data.dSize[0] += 2.0 * dPlusEdge;
|
|
data.dSize[1] += 2.0 * dPlusEdge;
|
|
}
|
|
else if (nSection == eCircle)
|
|
{
|
|
data.m_dPlusEdge = 0.0;
|
|
data.dSize[0] += 2.0 * dPlusEdge;
|
|
data.dSize[1] += 2.0 * dPlusEdge;
|
|
}
|
|
|
|
AcGePoint3d ptS,ptE;
|
|
ptE = ptEnd;
|
|
ptS = ptE - vt * dL;//厚度
|
|
|
|
ductTmp.SetStartPoint(ptS);
|
|
ductTmp.SetEndPoint(ptE);
|
|
|
|
ductTmp.SetDoubleLayer((AcDbObjectId&)m_idDoubleLayer);
|
|
ductTmp.SetCenterLayer((AcDbObjectId&)m_idCenterLayer);
|
|
ductTmp.setLayer(layerId());
|
|
ductTmp.SetDuctParam(&data);
|
|
ductTmp.SetSectionRotation(dAng);
|
|
ductTmp.Draw3d(dc);
|
|
|
|
Add3DBuffer(ductTmp.Get3DBuffer());
|
|
ductTmp.Clean3DBufferNoDel();
|
|
|
|
ptS = ptSta;
|
|
ptE = ptS + vt * dL;//厚度
|
|
|
|
ductTmp.SetStartPoint(ptS);
|
|
ductTmp.SetEndPoint(ptE);
|
|
|
|
ductTmp.SetDuctParam(&data);
|
|
ductTmp.Draw3d(dc);
|
|
|
|
Add3DBuffer(ductTmp.Get3DBuffer());
|
|
ductTmp.Clean3DBufferNoDel();
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacDuct::DrawFlangInf2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//绘制两头竖线
|
|
double dPlusEdge = 0.0;
|
|
GetSpecialtyData()->GetAt(HVAC_PlusEdge, dPlusEdge);
|
|
|
|
if (dPlusEdge < 1.e-3)
|
|
return Acad::eOk;
|
|
|
|
AcGePoint3d ptSta = StartPoint();
|
|
AcGePoint3d ptEnd = EndPoint();
|
|
|
|
AcGeVector3d vt = ptEnd - ptSta;
|
|
AcGeLine3d ln3d(AcGePoint3d::kOrigin,vt);
|
|
|
|
AecHvac::DuctParam param;
|
|
memset(¶m,0,sizeof(AecHvac::DuctParam));
|
|
GetDuctParam(param);
|
|
|
|
if (ln3d.isParallelTo(AcGePlane::kXYPlane))//水平
|
|
{
|
|
AcGeVector3d vtV = vt;
|
|
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtV.normalize();
|
|
|
|
AcGePoint3d ptGe[2];
|
|
ptGe[0] = ptSta + vtV * ( 0.5 * param.dSize[0] + dPlusEdge);
|
|
ptGe[1] = ptSta - vtV * ( 0.5 * param.dSize[0] + dPlusEdge);
|
|
|
|
AcDbLine* pLn = new AcDbLine(ptGe[0],ptGe[1]);
|
|
pLn->setLayer(layerId());
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
|
|
ptGe[0] = ptEnd + vtV * ( 0.5 * param.dSize[0] + dPlusEdge);
|
|
ptGe[1] = ptEnd - vtV * ( 0.5 * param.dSize[0] + dPlusEdge);
|
|
pLn = new AcDbLine(ptGe[0],ptGe[1]);
|
|
pLn->setLayer(layerId());
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
}
|
|
else
|
|
{
|
|
//垂直,只绘制截面
|
|
int nSection = 0;
|
|
m_mapSpecXData.GetAt(KEY_SECSHAPE,nSection);
|
|
|
|
AcGeVector3d vtNorm;
|
|
m_mapSpecXData.GetAt(KEY_NORMAL,vtNorm);
|
|
vtNorm.normalize();
|
|
|
|
double dAngle = GetSectionRotation();
|
|
|
|
AcGeLine3d ln3d2(AcGePoint3d::kOrigin,vtNorm);
|
|
if (ln3d2.isParallelTo(AcGePlane::kXYPlane))
|
|
{
|
|
//old code 2022-2-24
|
|
AcGeVector3d vtV = vtNorm;
|
|
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
if (nSection == eRect)
|
|
{
|
|
AcGePoint3d ptSta;
|
|
AcGeMatrix3d xformMove;
|
|
m_pBaseCurve->getStartPoint(ptSta);
|
|
ptSta.z = 0.0;
|
|
|
|
AcGePoint3d ptCen;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN,ptCen);
|
|
|
|
//移到sta位置
|
|
AcGeVector3d vtM = ptSta - ptCen;
|
|
xformMove.setToTranslation(vtM);
|
|
|
|
AcDbRegion* pRegCln = (AcDbRegion*)m_pRegion->clone();
|
|
|
|
AcDbVoidPtrArray arCurPtrs,arRes;
|
|
|
|
AcGeMatrix3d xformR;
|
|
xformR.setToRotation(dAngle,AcGeVector3d::kZAxis);
|
|
|
|
pRegCln->transformBy(xformR);
|
|
pRegCln->transformBy(xformMove);
|
|
pRegCln->explode(arCurPtrs);
|
|
|
|
delete pRegCln;
|
|
|
|
AcDbCurve* pCur = KTCADUtilityEx::ConvertBoundCurve(arCurPtrs,arRes);
|
|
if (pCur != NULL)
|
|
{
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(pCur);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setClosed(Adesk::kTrue);
|
|
AcDbCurve* pPlNew = GetOffsetCurve(pPl,dPlusEdge,false);
|
|
if (pPlNew != NULL)
|
|
{
|
|
pPlNew->setLayer(m_idDoubleLayer);
|
|
dc.DrawEntity(*pPlNew);
|
|
Add2DBuffer(pPlNew);
|
|
}
|
|
}
|
|
delete pCur;
|
|
}
|
|
|
|
/*ptGe[0] = ptSta;
|
|
ptGe[0] += (0.5 * param.dSize[1] + dPlusEdge) * vtNorm; //H方向
|
|
ptGe[0] += (0.5 * param.dSize[0] + dPlusEdge) * vtV;
|
|
|
|
ptGe[1] = ptGe[0] - vtV * (param.dSize[0] + 2.0 * dPlusEdge);
|
|
ptGe[2] = ptGe[1] - vtNorm * (param.dSize[1] + 2.0 * dPlusEdge);
|
|
ptGe[3] = ptGe[0] - vtNorm * (param.dSize[1] + 2.0 * dPlusEdge);
|
|
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcGeMatrix3d xforR;
|
|
xforR.setToRotation(dAng,AcGeVector3d::kZAxis,ptSta);
|
|
for (int ii = 0;ii < 5;ii++)
|
|
{
|
|
ptGe[ii].transformBy(xforR);
|
|
}
|
|
|
|
AcDbPolyline* pPl = FormatPolyline(ptGe,5);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setLayer(m_idDoubleLayer);
|
|
dc.DrawEntity(*pPl);
|
|
Add2DBuffer(pPl);
|
|
}*/
|
|
}
|
|
else if (nSection == eCircle)
|
|
{
|
|
AcDbCircle* pCir = new AcDbCircle;
|
|
pCir->setCenter(ptSta);
|
|
pCir->setRadius(0.5 * param.dSize[0] + dPlusEdge);
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
pCir->setLayer(m_idDoubleLayer);
|
|
|
|
dc.DrawEntity(*pCir);
|
|
Add2DBuffer(pCir);
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacDuct::CheckBrokenOpen()
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int AecDbHvacDuct::ComparedTo(AecDbCurveBase* pCurOther) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDbHvacDuct* pPipeOther = AecDbHvacDuct::cast(pCurOther);
|
|
if (pPipeOther != NULL)
|
|
{
|
|
AecHvac::DuctParam dpThis;
|
|
GetDuctParam(dpThis);
|
|
|
|
AecHvac::DuctParam dpThat;
|
|
pPipeOther->GetDuctParam(dpThat);
|
|
|
|
if (dpThis.eType != dpThat.eType)
|
|
return 1;
|
|
|
|
if ( fabs(dpThis.dSize[0] - dpThat.dSize[0]) > 0.1)
|
|
return 1;
|
|
|
|
if ( fabs(dpThis.dSize[1] - dpThat.dSize[1]) > 0.1)
|
|
return 1;
|
|
|
|
if ( fabs(dpThis.dSize[2] - dpThat.dSize[2]) > 0.1)
|
|
return 1;
|
|
|
|
if ( fabs(dpThis.m_dEl - dpThat.m_dEl) > 0.1)
|
|
return 1;
|
|
|
|
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;
|
|
}
|
|
|
|
#include "HlrCutOption.h"
|
|
void AecDbHvacDuct::ProcessHlrResult(const AcArray<AcDbEntity *> &ar, const std::map<AcDbEntity *, AcArray<AcDbEntity *>> &preAr, AcArray<AcDbEntity *> &output) const
|
|
{
|
|
double dW;
|
|
HlrCutOption::ProcessHlrResult(this
|
|
, HlrCutOption::getHlrLW_HvacSys(dW)
|
|
, dW
|
|
, FALSE
|
|
, ar
|
|
, preAr
|
|
, output);
|
|
} |