2334 lines
52 KiB
C++
2334 lines
52 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbHvacFitting.h"
|
|
#include "dbgrip.h"
|
|
#include "AecGripCback.h"
|
|
#include "MFCDbDwgFiler.h"
|
|
|
|
#include "ImpHvacElbow.h"
|
|
#include "ImpHvacTee.h"
|
|
#include "ImpHvacCross.h"
|
|
#include "ImpHvacReducer.h"
|
|
#include "ImpHvacOffset.h"
|
|
#include "AcGiViewDraw.h"
|
|
|
|
#ifndef WCAP_END_HR
|
|
#define WCAP_END_HR 0.2541
|
|
#endif
|
|
|
|
#ifndef MESH_N
|
|
#define MESH_N 20
|
|
#endif
|
|
|
|
#define CAPENDRADIUS 0.254
|
|
|
|
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;
|
|
|
|
extern CString IDCreate();
|
|
extern double PixelToWcs(int nPixel);
|
|
extern BOOL Is2DView();
|
|
extern AcGeVector3d GetUcsZvt();
|
|
extern AcDbCurve* FormatPolyline(AcDbCurve* pBaseCur);
|
|
extern void PushGripMessage(GripMessage&);
|
|
|
|
extern AcDbPolyline* FormatPolyline(AcGePoint3d* ppPts,int nCount);
|
|
extern AcGePoint3d MidPoint(const AcGePoint3d& pt1,const AcGePoint3d& pt2);
|
|
extern AcDbArc* FormatArc(AcGePoint3d& ptGe1,AcGePoint3d& ptGe2,AcGePoint3d& ptGe3);
|
|
extern AcDbRegion* PolylineToRegion( AcDbPolyline* pPl);
|
|
extern DLLIMPEXP bool MakeBlockRefSet(AcDbVoidPtrArray &arEntPtrs, const AcDbObjectId &idLay,Adesk::Boolean bDoSubent, LPCTSTR pszName, AcDbDatabase *pDb = NULL);
|
|
|
|
Adesk::UInt32 AecDbHvacFitting::kCurrentVersionNumber = 1;
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbHvacFitting, AecDbEntityBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_DBHVACFIT,
|
|
"AecDbHvacFitting"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
AecDbHvacFitting::AecDbHvacFitting(void)
|
|
{
|
|
m_nInfActive = -1;
|
|
m_bActive = false;
|
|
m_sGUID = IDCreate();
|
|
m_pGripAppData = new AecGripData[GRIP_MAXNUM];
|
|
m_mapSpecXData.SetAt(KEY_NO,m_sGUID);
|
|
m_mapSpecXData.SetAt(KEY_NAME,_T("风管管件"));
|
|
}
|
|
|
|
AecDbHvacFitting::~AecDbHvacFitting(void)
|
|
{
|
|
Clean3DBuffer();
|
|
Clean2DBuffer();
|
|
delete [] m_pGripAppData;
|
|
}
|
|
|
|
bool AecDbHvacFitting::SetDuctParam(const AecHvac::DuctParam& data)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
double dL = 0.0,dW = 0.0,dt = 0.0;
|
|
double dD = 0.0;
|
|
|
|
m_mapSpecXData.SetAt(KEY_SECSHAPE,(int)data.eType);
|
|
m_mapSpecXData.SetAt(KEY_MATERIAL,data.szMat);
|
|
m_mapSpecXData.SetAt(KEY_FACTORY,data.szFat);
|
|
m_mapSpecXData.SetAt(KEY_RRATIO,data.m_dRatio);
|
|
m_mapSpecXData.SetAt(KEY_FULLPER,data.m_dFullPer);
|
|
m_mapSpecXData.SetAt(KEY_SN,data.szNo);
|
|
m_mapSpecXData.SetAt(KEY_TYPE,data.szType);
|
|
m_mapSpecXData.SetAt(KEY_EXT,data.szExt);
|
|
m_mapSpecXData.SetAt(PIPE_SYS,data.szSys);
|
|
m_mapSpecXData.SetAt(KEY_COVER,data.m_bCover);
|
|
m_mapSpecXData.SetAt(KEY_SPART,data.m_bSpart);
|
|
m_mapSpecXData.SetAt(KEY_CENNODRAW,!data.m_bCenDraw);//中心线
|
|
m_mapSpecXData.SetAt(KEY_REM,data.szRem);
|
|
m_mapSpecXData.SetAt(HVAC_FlowDirect,data.m_nFlowDir);
|
|
m_mapSpecXData.SetAt(HVAC_PlusEdge,data.m_dPlusEdge);//咬口法兰翻边余量
|
|
|
|
m_mapSpecXData.SetAt(KEY_AirLoadUnit,data.iALUnit);
|
|
m_mapSpecXData.SetAt(KEY_AirLoad,data.dAirload);
|
|
|
|
m_mapSpecXData.SetAt(DV_AIRVOL,data.m_dR);
|
|
m_mapSpecXData.SetAt(DV_WAYRESIS,data.m_dPy);
|
|
m_mapSpecXData.SetAt(DV_VELOCITY,data.m_dV);
|
|
|
|
m_mapSpecXData.SetAt(KEY_SIZE1,data.dSize[0]); //L
|
|
m_mapSpecXData.SetAt(KEY_SIZE2,data.dSize[1]); //w
|
|
m_mapSpecXData.SetAt(PIPE_THICK,data.dSize[2]);//t
|
|
m_mapSpecXData.SetAt(KEY_SIZE3,data.dSize[3]);//w1,变径用
|
|
|
|
return true;
|
|
}
|
|
|
|
void AecDbHvacFitting::GetDuctParam(AecHvac::DuctParam& data) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
memset(&data,0,sizeof(AecHvac::DuctParam));
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
|
|
int nType = 0;
|
|
if (!m_mapSpecXData.GetAt(KEY_SECSHAPE, nType))
|
|
{
|
|
//原有的变径没有保存 KEY_SECSHAPE
|
|
m_mapSpecXData.GetAt(HRED_StartSectType, nType);
|
|
}
|
|
data.eType = (ESection)nType;
|
|
|
|
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);
|
|
|
|
int nNDraw = 0;
|
|
m_mapSpecXData.GetAt(KEY_CENNODRAW,nNDraw);//中心线
|
|
data.m_bCenDraw = nNDraw != 0 ? 0 : 1;
|
|
|
|
m_mapSpecXData.GetAt(HVAC_FlowDirect,data.m_nFlowDir);
|
|
|
|
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);
|
|
|
|
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
|
|
m_mapSpecXData.GetAt(KEY_SIZE3,data.dSize[3]);//w1,变径用
|
|
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);
|
|
|
|
m_mapSpecXData.GetAt(KEY_COVER,data.m_bCover);
|
|
m_mapSpecXData.GetAt(KEY_SPART,data.m_bSpart);
|
|
m_mapSpecXData.GetAt(HVAC_PlusEdge,data.m_dPlusEdge);//咬口法兰翻边余量
|
|
|
|
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);
|
|
}
|
|
|
|
void AecDbHvacFitting::SetSingleLayer(AcDbObjectId& idLayer)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_idSingleLayer = idLayer;
|
|
}
|
|
|
|
AcDbObjectId AecDbHvacFitting::GetSingleLayer() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_idSingleLayer;
|
|
}
|
|
|
|
void AecDbHvacFitting::SetSingleLineType(AcDbObjectId& idLt)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_idSingleLnType = idLt;
|
|
}
|
|
|
|
AcDbObjectId AecDbHvacFitting::GetSingleLineType() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_idSingleLnType;
|
|
}
|
|
|
|
void AecDbHvacFitting::SetDoubleLayer(AcDbObjectId& idLayer)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_idDoubleLayer = idLayer;
|
|
}
|
|
|
|
AcDbObjectId AecDbHvacFitting::GetDoubleLayer() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_idDoubleLayer;
|
|
}
|
|
|
|
void AecDbHvacFitting::SetDoubleLineType(AcDbObjectId& idLt)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_idDoubleLnType = idLt;
|
|
}
|
|
|
|
AcDbObjectId AecDbHvacFitting::GetDoubleLineType() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_idDoubleLnType;
|
|
}
|
|
|
|
void AecDbHvacFitting::SetCenterLayer(AcDbObjectId& idLayer)
|
|
{
|
|
assertWriteEnabled();
|
|
m_idCenterLayer = idLayer;
|
|
}
|
|
|
|
AcDbObjectId AecDbHvacFitting::GetCenterLayer() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_idCenterLayer;
|
|
}
|
|
|
|
void AecDbHvacFitting::SetDashLayer(AcDbObjectId& idLayer)
|
|
{
|
|
assertWriteEnabled();
|
|
m_idDashLayer = idLayer;
|
|
}
|
|
|
|
AcDbObjectId AecDbHvacFitting::GetDashLayer() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_idDashLayer;
|
|
}
|
|
|
|
void AecDbHvacFitting::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);
|
|
|
|
m_idDoubleLnType = outLt;
|
|
|
|
// 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
|
|
m_idCenterLayer = innLy;
|
|
GetSpecialtyData(AcDb::kForWrite)->SetAt(PIPE_LINELAYER, innLy);
|
|
|
|
m_idDoubleLayer = outLy;
|
|
GetSpecialtyData(AcDb::kForWrite)->SetAt(PIPE_LINELAYER_OUT, outLy);
|
|
}
|
|
|
|
void AecDbHvacFitting::AssertWriteEnabled(Adesk::Boolean autoUndo,Adesk::Boolean recordModified )
|
|
{
|
|
//if (objectId().isValid())
|
|
{
|
|
//FreeBuffer(0,m_ar2DDrableBufPtrs);
|
|
//FreeBuffer(0,m_ar3DDrableBufPtrs);
|
|
//m_ar3DDrableBufPtrs.removeAll();
|
|
|
|
Clean3DBuffer();
|
|
Clean2DBuffer();
|
|
|
|
//m_ar2DDrableBufPtrs.removeAll();
|
|
|
|
AecDbEntityBase::AssertWriteEnabled(autoUndo, recordModified);
|
|
//assertWriteEnabled();
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if ( !pFiler->isKindOf(CMFCDbDwgFiler::desc()))
|
|
{
|
|
es = AecDbEntityBase::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 > AecDbHvacFitting::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy);
|
|
|
|
m_mapSpecXData.dwgInFields(pFiler);
|
|
|
|
pFiler->readInt16(&m_nInfActive);
|
|
|
|
TCHAR* pszTmp = NULL;
|
|
pFiler->readString(&pszTmp);
|
|
if (pszTmp != NULL)
|
|
{
|
|
m_sGUID = pszTmp;
|
|
}
|
|
|
|
pFiler->readSoftPointerId((AcDbSoftPointerId*)&m_idSingleLayer);
|
|
pFiler->readSoftPointerId((AcDbSoftPointerId*)&m_idSingleLnType);
|
|
|
|
pFiler->readSoftPointerId((AcDbSoftPointerId*)&m_idDoubleLayer);
|
|
pFiler->readSoftPointerId((AcDbSoftPointerId*)&m_idDoubleLnType);
|
|
|
|
pFiler->readSoftPointerId((AcDbSoftPointerId*)&m_idDashLayer);
|
|
pFiler->readSoftPointerId((AcDbSoftPointerId*)&m_idCenterLayer);
|
|
|
|
return (pFiler->filerStatus());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//----- Save parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if ( !pFiler->isKindOf(CMFCDbDwgFiler::desc()))
|
|
{
|
|
es = AecDbEntityBase::dwgOutFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
}
|
|
|
|
//----- Object version number needs to be saved first
|
|
if ( (es =pFiler->writeUInt32 (AecDbHvacFitting::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
m_mapSpecXData.dwgOutFields(pFiler);
|
|
|
|
pFiler->writeInt16(m_nInfActive);
|
|
pFiler->writeString((LPCTSTR)m_sGUID);
|
|
|
|
pFiler->writeSoftPointerId(m_idSingleLayer);
|
|
pFiler->writeSoftPointerId(m_idSingleLnType);
|
|
|
|
pFiler->writeSoftPointerId(m_idDoubleLayer);
|
|
pFiler->writeSoftPointerId(m_idDoubleLnType);
|
|
|
|
pFiler->writeSoftPointerId(m_idDashLayer);
|
|
pFiler->writeSoftPointerId(m_idCenterLayer);
|
|
|
|
return (pFiler->filerStatus());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
AssertWriteEnabled();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbHvacFitting::SetActive(bool bActive)
|
|
{
|
|
assertWriteEnabled();
|
|
m_bActive = bActive;
|
|
}
|
|
|
|
bool AecDbHvacFitting::IsActive() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_bActive;
|
|
}
|
|
|
|
void AecDbHvacFitting::NewGUID()
|
|
{
|
|
assertWriteEnabled();
|
|
m_sGUID = IDCreate();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::subExplode(AcDbVoidPtrArray& entitySet) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
/*
|
|
AcDbObjectId idReal = layerId();
|
|
AcDbObjectId idDash = m_idDashLayer;
|
|
AcDbObjectId idCent = m_idCenterLayer;
|
|
|
|
//绘制
|
|
ImpHvacElbow impElbow;
|
|
ImpHvacReducer impReducer;
|
|
ImpHvacTee impTee;
|
|
ImpHvacCross impCross;
|
|
ImpHvacOffset impOffset;
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapSpecXData;
|
|
|
|
switch(nKind)
|
|
{
|
|
case eElbow:
|
|
{
|
|
impElbow.m_pXDataMap = pXDataMap;
|
|
impElbow.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impElbow.m_idDashLayer = m_idDashLayer;
|
|
impElbow.m_idCenterLayer = m_idCenterLayer;
|
|
impElbow.Draw2d(dc);
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
impReducer.m_pXDataMap = pXDataMap;
|
|
impReducer.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impReducer.m_idDashLayer = m_idDashLayer;
|
|
impReducer.m_idCenterLayer = m_idCenterLayer;
|
|
impReducer.Draw2d(dc);
|
|
break;
|
|
}
|
|
break;
|
|
case eTee:
|
|
{
|
|
impTee.m_pXDataMap = pXDataMap;
|
|
impTee.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impTee.m_idDashLayer = m_idDashLayer;
|
|
impTee.m_idCenterLayer = m_idCenterLayer;
|
|
impTee.Draw2d(dc);
|
|
break;
|
|
}
|
|
case eCross:
|
|
{
|
|
impCross.m_pXDataMap = pXDataMap;
|
|
impCross.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impCross.m_idDashLayer = m_idDashLayer;
|
|
impCross.m_idCenterLayer = m_idCenterLayer;
|
|
impCross.Draw2d(dc);
|
|
break;
|
|
}
|
|
case eOffset:
|
|
{
|
|
impOffset.m_pXDataMap = pXDataMap;
|
|
impOffset.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impOffset.m_idDashLayer = m_idDashLayer;
|
|
impOffset.m_idCenterLayer = m_idCenterLayer;
|
|
impOffset.Draw2d(dc);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (m_pSpecFitting != NULL)
|
|
{
|
|
BOOL bWeight = FALSE;
|
|
m_XDataMap.GetAt(KEY_EDAGEWEIGHT,bWeight);
|
|
|
|
BOOL bCenWeight = FALSE;
|
|
m_XDataMap.GetAt(KEY_CENLWEIGHT,bCenWeight);
|
|
|
|
AcDbObjectId idReal = ((TDbInterfacesObj*)m_pOwnerEnt)->layerId();
|
|
AcDbObjectId idDash = ((TDbInterfacesObj*)m_pOwnerEnt)->DashLayer();
|
|
AcDbObjectId idCent = ((TDbInterfacesObj*)m_pOwnerEnt)->CenterLayer();
|
|
|
|
if (m_arDbExtEdgs.GetCount() == 0)
|
|
{
|
|
TComplexCurve compOutSide;
|
|
m_pSpecFitting->MakeCurves(compOutSide);
|
|
TExtentsEdge edgeOut;
|
|
edgeOut.SetEdage(compOutSide);
|
|
edgeOut.explode(entitySet,idReal,idDash,idCent,NULL,bWeight,bCenWeight);
|
|
|
|
// 画减去虚段后剩下的实图元段;
|
|
TComplexCurve compInside;
|
|
GetCurvesInSide(compInside);
|
|
|
|
TExtentsEdge edge;
|
|
edge.SetEdage(compInside);
|
|
edge.explode(entitySet,idReal,idDash,idCent,NULL,bWeight,bCenWeight);
|
|
}
|
|
else
|
|
{
|
|
// 获取实体自身原来的pl边界对象[源];
|
|
TComplexCurve compCurve,compInside;
|
|
MakeCurves(compCurve);
|
|
GetCurvesInSide(compInside);
|
|
|
|
Aec::TCurveElement elTmpl;
|
|
memset(&elTmpl,0,sizeof(Aec::TCurveElement));
|
|
if (compInside.length() > 0)
|
|
elTmpl = compInside.first();
|
|
|
|
// 画被虚图元段.该部分由外部计算传入;
|
|
for (int i = 0;i < m_arDbExtEdgs.GetCount();i++)
|
|
{
|
|
// 然后[源]实边界对象减去虚图元段;]
|
|
if (TCoverBooleanOper::BoolSubtract(compCurve,m_arDbExtEdgs.GetAt(i)))
|
|
{
|
|
// 画虚图元部分[被遮挡]
|
|
m_arDbExtEdgs.GetAt(i).explode(entitySet,idReal,idDash,idCent,&elTmpl,bWeight,bCenWeight);
|
|
}
|
|
|
|
// 内部的中心线等分布线减去被遮挡的部分
|
|
TCoverBooleanOper::BoolSubtract(compInside,m_arDbExtEdgs.GetAt(i));
|
|
}
|
|
|
|
// 画减去虚段后剩下的实图元段;
|
|
TExtentsEdge edge;
|
|
edge.SetEdage(compCurve);
|
|
edge.explode(entitySet,idReal,idDash,idCent,NULL,bWeight,bCenWeight);
|
|
|
|
// 画内部的中心线等分布线
|
|
edge.SetEdage(compInside);
|
|
edge.explode(entitySet,idReal,idDash,idCent,NULL,bWeight,bCenWeight);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
|
|
|
|
//绘制接口法兰连接
|
|
DrawInfCap2d(dc);
|
|
|
|
|
|
*/
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbHvacFitting::subList() const
|
|
{
|
|
assertReadEnabled();
|
|
AecDbEntityBase::subList();
|
|
|
|
ImpHvacElbow impElbow;
|
|
ImpHvacReducer impReducer;
|
|
ImpHvacTee impTee;
|
|
ImpHvacCross impCross;
|
|
ImpHvacOffset impOffset;
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapSpecXData;
|
|
|
|
switch(nKind)
|
|
{
|
|
case eElbow:
|
|
{
|
|
impElbow.m_pXDataMap = pXDataMap;
|
|
impElbow.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impElbow.m_idDashLayer = m_idDashLayer;
|
|
impElbow.m_idCenterLayer = m_idCenterLayer;
|
|
impElbow.list();
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
impReducer.m_pXDataMap = pXDataMap;
|
|
impReducer.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impReducer.m_idDashLayer = m_idDashLayer;
|
|
impReducer.m_idCenterLayer = m_idCenterLayer;
|
|
impReducer.list();
|
|
break;
|
|
}
|
|
case eTee:
|
|
{
|
|
impTee.m_pXDataMap = pXDataMap;
|
|
impTee.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impTee.m_idDashLayer = m_idDashLayer;
|
|
impTee.m_idCenterLayer = m_idCenterLayer;
|
|
impTee.list();
|
|
break;
|
|
}
|
|
case eCross:
|
|
{
|
|
impCross.m_pXDataMap = pXDataMap;
|
|
impCross.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impCross.m_idDashLayer = m_idDashLayer;
|
|
impCross.m_idCenterLayer = m_idCenterLayer;
|
|
impCross.list();
|
|
break;
|
|
}
|
|
case eOffset:
|
|
{
|
|
impOffset.m_pXDataMap = pXDataMap;
|
|
impOffset.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impOffset.m_idDashLayer = m_idDashLayer;
|
|
impOffset.m_idCenterLayer = m_idCenterLayer;
|
|
impOffset.list();
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
acutPrintf(_T("\n详细属性数据:"));
|
|
m_mapSpecXData.List();
|
|
acutPrintf(_T("\n"));
|
|
}
|
|
|
|
bool AecDbHvacFitting::GetBimInfoTip(CString& sInfoTip) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecHvac::DuctParam data;
|
|
memset(&data,0,sizeof(AecHvac::DuctParam));
|
|
|
|
GetDuctParam(data);
|
|
|
|
LPCTSTR pszAirload[] = {_T("kg/h"),_T("kg/s"),_T("m^3/h"),_T("m^3/s"),_T("L/h"),_T("L/s"),0};
|
|
|
|
CString sField,sFmt;
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
double dVal = 0.0;
|
|
|
|
switch(nKind)
|
|
{
|
|
case eElbow:
|
|
{
|
|
sField = _T("风管弯头:\n");
|
|
sInfoTip += sField;
|
|
|
|
if (data.eType == eRect)
|
|
{
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HELB_StartWidth, dVal);
|
|
MAKEFIELD(_T("始端宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HELB_EndWidth, dVal);
|
|
MAKEFIELD(_T("末端宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HELB_Thick, dVal);
|
|
MAKEFIELD(_T("厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
}
|
|
else if (data.eType == eCircle)
|
|
{
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HELB_Diameter, dVal);
|
|
MAKEFIELD(_T("直径"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HELB_Thick, dVal);
|
|
MAKEFIELD(_T("厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
}
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_RRATIO,dVal);
|
|
MAKEFIELD(_T("弯头曲率"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
sField = _T("风管变径:\n");
|
|
sInfoTip += sField;
|
|
|
|
if (data.eType == eRect)
|
|
{
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HRED_StartWidth, dVal);
|
|
MAKEFIELD(_T("始端宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HRED_StartThick, dVal);
|
|
MAKEFIELD(_T("始端厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HRED_EndWidth, dVal);
|
|
MAKEFIELD(_T("末端宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HRED_EndThick, dVal);
|
|
MAKEFIELD(_T("末端厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
}
|
|
else if (data.eType == eCircle)
|
|
{
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HRED_StartDiameter, dVal);
|
|
MAKEFIELD(_T("始端直径"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HRED_EndDiameter, dVal);
|
|
MAKEFIELD(_T("末端直径"),_T("%.1f"),dVal,sInfoTip);
|
|
}
|
|
break;
|
|
}
|
|
break;
|
|
case eTee:
|
|
{
|
|
sField = _T("风管三通:\n");
|
|
sInfoTip += sField;
|
|
|
|
if (data.eType == eRect)
|
|
{
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HTEE_StartWidth, dVal);
|
|
MAKEFIELD(_T("始端宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HRED_EndWidth, dVal);
|
|
MAKEFIELD(_T("末端宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HTEE_Thick, dVal);
|
|
MAKEFIELD(_T("末端厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HTEE_BranchWidth, dVal);
|
|
MAKEFIELD(_T("支管宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HTEE_BranchThick, dVal);
|
|
MAKEFIELD(_T("支管厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HTEE_EndThick, dVal);
|
|
MAKEFIELD(_T("末端厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
}
|
|
else if (data.eType == eCircle)
|
|
{
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HRED_StartDiameter, dVal);
|
|
MAKEFIELD(_T("始端直径"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HRED_EndDiameter, dVal);
|
|
MAKEFIELD(_T("末端直径"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HTEE_BranchDiameter, dVal);
|
|
MAKEFIELD(_T("支管直径"),_T("%.1f"),dVal,sInfoTip);
|
|
}
|
|
|
|
m_mapSpecXData.GetAt(HTEE_RadRatio, dVal);
|
|
MAKEFIELD(_T("曲率值"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
break;
|
|
}
|
|
case eCross:
|
|
{
|
|
sField = _T("风管四通:\n");
|
|
sInfoTip += sField;
|
|
|
|
if (data.eType == eRect)
|
|
{
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HTEE_StartWidth, dVal);
|
|
MAKEFIELD(_T("始端宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HCRS_EndWidth, dVal);
|
|
MAKEFIELD(_T("末端宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HCRS_Thick, dVal);
|
|
MAKEFIELD(_T("末端厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HCRS_Branch1Width, dVal);
|
|
MAKEFIELD(_T("支管1宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HCRS_Branch1Thick, dVal);
|
|
MAKEFIELD(_T("支管1厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HCRS_Branch2Width, dVal);
|
|
MAKEFIELD(_T("支管2宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HCRS_Branch2Thick, dVal);
|
|
MAKEFIELD(_T("支管2厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
}
|
|
else if(data.eType == eCircle)
|
|
{
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HCRS_StartDiameter, dVal);
|
|
MAKEFIELD(_T("始端直径"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HCRS_EndDiameter, dVal);
|
|
MAKEFIELD(_T("末端直径"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HCRS_Branch1Diameter, dVal);
|
|
MAKEFIELD(_T("支管1直径"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HCRS_Branch2Diameter, dVal);
|
|
MAKEFIELD(_T("支管2直径"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HCRS_Thick, dVal);
|
|
MAKEFIELD(_T("厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
}
|
|
|
|
break;
|
|
}
|
|
case eOffset:
|
|
{
|
|
sField = _T("风管乙弯头:\n");
|
|
sInfoTip += sField;
|
|
|
|
if (data.eType == eRect)
|
|
{
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HOFF_StartWidth, dVal);
|
|
MAKEFIELD(_T("始端宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HOFF_EndWidth, dVal);
|
|
MAKEFIELD(_T("末端宽度"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HOFF_Thick, dVal);
|
|
MAKEFIELD(_T("厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
}
|
|
else if (data.eType == eCircle)
|
|
{
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HOFF_Diameter, dVal);
|
|
MAKEFIELD(_T("直径"),_T("%.1f"),dVal,sInfoTip);
|
|
|
|
dVal = 0.0;
|
|
m_mapSpecXData.GetAt(HOFF_Thick, dVal);
|
|
MAKEFIELD(_T("厚度"),_T("%.1f"),dVal,sInfoTip);
|
|
}
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
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);
|
|
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::copyFrom(const AcRxObject* pSrc)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecDbHvacFitting* pFit = AecDbHvacFitting::cast(pSrc);
|
|
if (pFit != NULL)
|
|
{
|
|
m_mapSpecXData.Empty();
|
|
m_mapSpecXData.CopyFrom(&pFit->m_mapSpecXData);
|
|
|
|
m_nInfActive = pFit->m_nInfActive;
|
|
m_sGUID = IDCreate();
|
|
m_bActive = pFit->m_bActive;
|
|
|
|
m_idSingleLayer = pFit->m_idSingleLayer;
|
|
m_idSingleLnType = pFit->m_idSingleLnType;
|
|
|
|
m_idDoubleLayer = pFit->m_idDoubleLayer;
|
|
m_idDoubleLnType = pFit->m_idDoubleLnType;
|
|
|
|
m_idDashLayer = pFit->m_idDashLayer;
|
|
m_idCenterLayer = pFit->m_idCenterLayer;
|
|
|
|
//发送提资需要相同的ID
|
|
extern CString IDCreate();
|
|
Adesk::Int16 nVal = acdbCurDwg()->useri4();
|
|
if (nVal != KEY_NOPROTECT)
|
|
{
|
|
int nVt = 0;
|
|
if (m_mapSpecXData.HasKey(KEY_NO, nVt))
|
|
m_mapSpecXData.SetAt(KEY_NO, m_sGUID);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
ImpHvacElbow impElbow;
|
|
ImpHvacReducer impReducer;
|
|
ImpHvacTee impTee;
|
|
ImpHvacCross impCross;
|
|
ImpHvacOffset impOffset;
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapSpecXData;
|
|
|
|
switch(nKind)
|
|
{
|
|
case eElbow:
|
|
{
|
|
impElbow.m_pXDataMap = pXDataMap;
|
|
impElbow.transformBy(xform);
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
impReducer.m_pXDataMap = pXDataMap;
|
|
impReducer.transformBy(xform);
|
|
}
|
|
break;
|
|
case eTee:
|
|
{
|
|
impTee.m_pXDataMap = pXDataMap;
|
|
impTee.transformBy(xform);
|
|
break;
|
|
}
|
|
case eCross:
|
|
{
|
|
impCross.m_pXDataMap = pXDataMap;
|
|
impCross.transformBy(xform);
|
|
break;
|
|
}
|
|
case eOffset:
|
|
{
|
|
impOffset.m_pXDataMap = pXDataMap;
|
|
impOffset.transformBy(xform);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
#if ARX>16
|
|
Acad::ErrorStatus AecDbHvacFitting::subGetGripPoints(AcDbGripDataPtrArray& grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d& curViewDir,
|
|
const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
ImpHvacElbow impElbow;
|
|
ImpHvacReducer impReducer;
|
|
ImpHvacTee impTee;
|
|
ImpHvacCross impCross;
|
|
ImpHvacOffset impOffset;
|
|
|
|
AcArray<AecInterface> arInfs;
|
|
AcGePoint3d ptMid;
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapSpecXData;
|
|
|
|
switch(nKind)
|
|
{
|
|
case eElbow:
|
|
{
|
|
impElbow.m_pXDataMap = pXDataMap;
|
|
impElbow.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impElbow.GetInterface(arInfs);
|
|
pXDataMap->GetAt(HELB_CornerPoint, ptMid);
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
impReducer.m_pXDataMap = pXDataMap;
|
|
impReducer.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impReducer.GetInterface(arInfs);
|
|
|
|
if (arInfs.length() == 2)
|
|
{
|
|
ptMid = MidPoint(arInfs.first().ptPos,arInfs.last().ptPos);
|
|
}
|
|
}
|
|
break;
|
|
case eTee:
|
|
{
|
|
impTee.m_pXDataMap = pXDataMap;
|
|
impTee.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impTee.GetInterface(arInfs);
|
|
ptMid = impTee.GetCenterPt();
|
|
|
|
break;
|
|
}
|
|
case eCross:
|
|
{
|
|
impCross.m_pXDataMap = pXDataMap;
|
|
impCross.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impCross.GetInterface(arInfs);
|
|
ptMid = impCross.GetCenterPt();
|
|
break;
|
|
}
|
|
case eOffset:
|
|
{
|
|
impOffset.m_pXDataMap = pXDataMap;
|
|
impOffset.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impOffset.GetInterface(arInfs);
|
|
|
|
if (arInfs.length() == 2)
|
|
{
|
|
ptMid = MidPoint(arInfs.first().ptPos,arInfs.last().ptPos);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
CString sCmd = GetGripCmd();
|
|
AcDbGripData* pGripData = NULL;
|
|
|
|
EPosition ePos = eCommand0;
|
|
int i(0);
|
|
for (i = 0;i < arInfs.length();i++)
|
|
{
|
|
pGripData = new AcDbGripData;
|
|
|
|
memset(&m_pGripAppData[i],0,sizeof(AecGripData));
|
|
|
|
m_pGripAppData[i].nIndex = i;
|
|
m_pGripAppData[i].ePos = ePos;
|
|
m_pGripAppData[i].ptGrip = arInfs.at(i).ptPos;
|
|
_tcscpy(m_pGripAppData[i].szTip,sCmd);
|
|
m_pGripAppData[i].pOwner = (AcDbEntity*)this;
|
|
m_pGripAppData[i].idHost = objectId();
|
|
|
|
pGripData->setGripPoint(arInfs.at(i).ptPos);
|
|
pGripData->setAppData((void*)&m_pGripAppData[i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
grips.append(pGripData);
|
|
}
|
|
|
|
pGripData = new AcDbGripData;
|
|
memset(&m_pGripAppData[i],0,sizeof(AecGripData));
|
|
m_pGripAppData[i].nIndex = i;
|
|
m_pGripAppData[i].ePos = eMid;
|
|
m_pGripAppData[i].ptGrip = ptMid;
|
|
_tcscpy(m_pGripAppData[i].szTip,_T("位置夹点"));
|
|
m_pGripAppData[i].pOwner = (AcDbEntity*)this;
|
|
m_pGripAppData[i].idHost = objectId();
|
|
|
|
pGripData->setGripPoint(ptMid);
|
|
pGripData->setAppData((void*)&m_pGripAppData[i]);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
grips.append(pGripData);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::subGetStretchPoints(AcGePoint3dArray& stretchPoints) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
ImpHvacElbow impElbow;
|
|
ImpHvacReducer impReducer;
|
|
ImpHvacTee impTee;
|
|
ImpHvacCross impCross;
|
|
ImpHvacOffset impOffset;
|
|
|
|
AcArray<AecInterface> arInfs;
|
|
AcGePoint3d ptMid;
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapSpecXData;
|
|
|
|
switch(nKind)
|
|
{
|
|
case eElbow:
|
|
{
|
|
impElbow.m_pXDataMap = pXDataMap;
|
|
impElbow.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impElbow.GetInterface(arInfs);
|
|
pXDataMap->GetAt(HELB_CornerPoint, ptMid);
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
impReducer.m_pXDataMap = pXDataMap;
|
|
impReducer.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impReducer.GetInterface(arInfs);
|
|
|
|
if (arInfs.length() == 2)
|
|
{
|
|
ptMid = MidPoint(arInfs.first().ptPos,arInfs.last().ptPos);
|
|
}
|
|
}
|
|
break;
|
|
case eTee:
|
|
{
|
|
impTee.m_pXDataMap = pXDataMap;
|
|
impTee.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impTee.GetInterface(arInfs);
|
|
ptMid = impTee.GetCenterPt();
|
|
|
|
break;
|
|
}
|
|
case eCross:
|
|
{
|
|
impCross.m_pXDataMap = pXDataMap;
|
|
impCross.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impCross.GetInterface(arInfs);
|
|
ptMid = impCross.GetCenterPt();
|
|
break;
|
|
}
|
|
case eOffset:
|
|
{
|
|
impOffset.m_pXDataMap = pXDataMap;
|
|
impOffset.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impOffset.GetInterface(arInfs);
|
|
|
|
if (arInfs.length() == 2)
|
|
{
|
|
ptMid = MidPoint(arInfs.first().ptPos,arInfs.last().ptPos);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
stretchPoints.append(ptMid);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::subMoveGripPointsAt(const AcDbVoidPtrArray& gripAppData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecGripData* pAppData = NULL;
|
|
AcDbIntArray arIndex;
|
|
|
|
if ( !gripAppData.isEmpty() )
|
|
{
|
|
pAppData = (AecGripData*)gripAppData.first();
|
|
arIndex.append(pAppData->nIndex);
|
|
}
|
|
else
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
AcGeVector3d vtOffset = offset;
|
|
if(Is2DView())
|
|
{
|
|
vtOffset = offset.orthoProject(GetUcsZvt());
|
|
}
|
|
|
|
AecInterface inf;
|
|
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);
|
|
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtOffset);
|
|
|
|
int nGripIndex = arIndex.first();
|
|
if (nGripIndex < GetInterfaceCount())
|
|
{
|
|
msg.nType = eCommand0;
|
|
msg.nData = nGripIndex;
|
|
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);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TransformBy(xformM);
|
|
|
|
//按接口关系更新相关联对象
|
|
msg.nType = eMid;
|
|
msg.nData = -1;
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
PushGripMessage(msg);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::subMoveStretchPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (indices.length() > 0)
|
|
{
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(offset);
|
|
transformBy(xform);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbHvacFitting::GetGripText(int nPos, CString& sText)
|
|
{
|
|
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::subGetOsnapPoints(AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& pickPoint,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
if (Has2DBuffer())
|
|
{
|
|
AcDbEntity* pSubEnt = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pSubEnt = (AcDbEntity*)ar2D.at(i);
|
|
pSubEnt->getOsnapPoints(osnapMode,gsSelectionMark,pickPoint,lastPoint,viewXform,snapPoints,geomIds);
|
|
}
|
|
|
|
AcArray<AecInterface> arInfs;
|
|
GetInterface(arInfs);
|
|
|
|
for (int i = 0; i < arInfs.length(); i++)
|
|
{
|
|
const AecInterface &inf = arInfs.at(i);
|
|
snapPoints.append(inf.ptPos);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::subGetGeomExtents(AcDbExtents& extents) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbExtents ext1;
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar3D = Get3DBuffer();
|
|
for (int i = 0;i < ar3D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar3D.at(i);
|
|
pEnt->getGeomExtents(ext1);
|
|
extents.addExt(ext1);
|
|
}
|
|
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int j = 0;j < ar2D.length();j++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(j);
|
|
pEnt->getGeomExtents(ext1);
|
|
extents.addExt(ext1);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::subIntersectWith(const AcDbEntity* pEnt,
|
|
AcDb::Intersect intType,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (Has2DBuffer())
|
|
{
|
|
AcDbEntity* pSubEnt = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pSubEnt = (AcDbEntity*)ar2D.at(i);
|
|
pSubEnt->intersectWith(pEnt,intType,points,thisGsMarker,otherGsMarker);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::subIntersectWith(const AcDbEntity* pEnt,
|
|
AcDb::Intersect intType,
|
|
const AcGePlane& projPlane,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (Has2DBuffer())
|
|
{
|
|
AcDbEntity* pSubEnt = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pSubEnt = (AcDbEntity*)ar2D.at(i);
|
|
pSubEnt->intersectWith(pEnt,intType,projPlane,points,thisGsMarker,otherGsMarker);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#endif
|
|
|
|
int AecDbHvacFitting::GetDraw2dables(Adesk::UInt16 nDrawStyle, AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDbObjXDataMap xData;
|
|
|
|
AcDbEntity* pEnt = NULL,*pEntCln = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(i);
|
|
pEntCln = (AcDbEntity*)pEnt->clone();
|
|
|
|
if (xData.Read(pEnt,BIMDATA_APP))
|
|
{
|
|
xData.SetAt(KEY_ID,m_sGUID);
|
|
xData.Write(pEntCln,BIMDATA_APP);
|
|
}
|
|
arEntPtrs.append(pEntCln);
|
|
}
|
|
return arEntPtrs.length();
|
|
}
|
|
|
|
int AecDbHvacFitting::GetDraw3dables(AcDbVoidPtrArray& arEntPtrs,bool bWriteBimInfo) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbEntity* pEnt = NULL,*pEntClone = NULL;
|
|
const AcDbVoidPtrArray &ar3D = Get3DBuffer();
|
|
for (int i = 0;i < ar3D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar3D.at(i);
|
|
pEntClone = (AcDbEntity*)pEnt->clone();
|
|
|
|
int nColor = 0;
|
|
if ( m_mapSpecXData.GetAt(_T("COLOR"),nColor) )
|
|
{
|
|
pEntClone->setColorIndex(nColor);
|
|
}
|
|
else
|
|
{
|
|
pEntClone->setColorIndex(colorIndex());
|
|
}
|
|
pEntClone->setLayer(layerId());
|
|
if (bWriteBimInfo)
|
|
{
|
|
m_mapSpecXData.Write(pEntClone,_T("BIMDATA"));
|
|
}
|
|
arEntPtrs.append(pEntClone);
|
|
}
|
|
return arEntPtrs.length();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//管线系统屏蔽掉
|
|
if ( dc.IsDragging() )
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
//缓存
|
|
AcDbObjectId idOld = dc.GetLayerId();
|
|
AcDbObjectId idOldLt = dc.GetLineTypeId();
|
|
int nCrBk = dc.GetColor();
|
|
if (Has2DBuffer())
|
|
{
|
|
AcDbObjectId idLn = linetypeId();
|
|
AcDbObjectId idLay = layerId();
|
|
int nColorE = nCrBk;
|
|
AcDbEntity* pEnt = NULL;
|
|
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(i);
|
|
|
|
nColorE = pEnt->colorIndex();
|
|
idLn = pEnt->linetypeId();
|
|
idLay = pEnt->layerId();
|
|
|
|
dc.SetLayer(idLay);
|
|
dc.SetLineType(idLn);
|
|
dc.SetColor(nColorE);
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
dc.SetLayer(idOld);
|
|
dc.SetLineType(idOldLt);
|
|
dc.SetColor(nCrBk);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//绘制
|
|
ImpHvacElbow impElbow;
|
|
ImpHvacReducer impReducer;
|
|
ImpHvacTee impTee;
|
|
ImpHvacCross impCross;
|
|
ImpHvacOffset impOffset;
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapSpecXData;
|
|
|
|
switch(nKind)
|
|
{
|
|
case eElbow:
|
|
{
|
|
impElbow.m_pXDataMap = pXDataMap;
|
|
impElbow.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impElbow.m_idDashLayer = m_idDashLayer;
|
|
impElbow.m_idCenterLayer = m_idCenterLayer;
|
|
impElbow.m_idDoubleLayer = m_idDoubleLayer;
|
|
impElbow.m_idDoubleLnType = m_idDoubleLnType;
|
|
impElbow.Draw2d(dc);
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
impReducer.m_pXDataMap = pXDataMap;
|
|
impReducer.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impReducer.m_idDashLayer = m_idDashLayer;
|
|
impReducer.m_idCenterLayer = m_idCenterLayer;
|
|
impReducer.m_idDoubleLayer = m_idDoubleLayer;
|
|
impReducer.m_idDoubleLnType = m_idDoubleLnType;
|
|
impReducer.Draw2d(dc);
|
|
break;
|
|
}
|
|
break;
|
|
case eTee:
|
|
{
|
|
impTee.m_pXDataMap = pXDataMap;
|
|
impTee.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impTee.m_idDashLayer = m_idDashLayer;
|
|
impTee.m_idCenterLayer = m_idCenterLayer;
|
|
impTee.m_idDoubleLayer = m_idDoubleLayer;
|
|
impTee.m_idDoubleLnType = m_idDoubleLnType;
|
|
impTee.Draw2d(dc);
|
|
break;
|
|
}
|
|
case eCross:
|
|
{
|
|
impCross.m_pXDataMap = pXDataMap;
|
|
impCross.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impCross.m_idDashLayer = m_idDashLayer;
|
|
impCross.m_idCenterLayer = m_idCenterLayer;
|
|
impCross.m_idDoubleLayer = m_idDoubleLayer;
|
|
impCross.m_idDoubleLnType = m_idDoubleLnType;
|
|
impCross.Draw2d(dc);
|
|
break;
|
|
}
|
|
case eOffset:
|
|
{
|
|
impOffset.m_pXDataMap = pXDataMap;
|
|
impOffset.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impOffset.m_idDashLayer = m_idDashLayer;
|
|
impOffset.m_idCenterLayer = m_idCenterLayer;
|
|
impOffset.m_idDoubleLayer = m_idDoubleLayer;
|
|
impOffset.m_idDoubleLnType = m_idDoubleLnType;
|
|
impOffset.Draw2d(dc);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//绘制接口法兰连接
|
|
DrawInfCap2d(dc);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGeVector3d AecDbHvacFitting::normal() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGeVector3d vtNorm(0,0,1);
|
|
//绘制
|
|
ImpHvacElbow impElbow;
|
|
ImpHvacReducer impReducer;
|
|
ImpHvacTee impTee;
|
|
ImpHvacCross impCross;
|
|
ImpHvacOffset impOffset;
|
|
AcDbVoidPtrArray ar3DBuf;
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapSpecXData;
|
|
|
|
switch(nKind)
|
|
{
|
|
case eElbow:
|
|
{
|
|
impElbow.m_pXDataMap = pXDataMap;
|
|
vtNorm = impElbow.normal();
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
impReducer.m_pXDataMap = pXDataMap;
|
|
vtNorm = impReducer.normal();
|
|
break;
|
|
}
|
|
case eTee:
|
|
{
|
|
impTee.m_pXDataMap = pXDataMap;
|
|
vtNorm = impTee.normal();
|
|
break;
|
|
}
|
|
case eCross:
|
|
{
|
|
impCross.m_pXDataMap = pXDataMap;
|
|
vtNorm = impCross.normal();
|
|
break;
|
|
}
|
|
case eOffset:
|
|
{
|
|
impOffset.m_pXDataMap = pXDataMap;
|
|
vtNorm = impOffset.normal();
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return vtNorm;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//管线系统屏蔽掉
|
|
if ( dc.IsDragging() )
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
//图层
|
|
AcDbObjectId idLay = dc.GetLayerId();
|
|
dc.SetLayer(m_idDoubleLayer);
|
|
//dc.SetSelectionMarker(1);
|
|
|
|
DrawInfArrow(dc);
|
|
|
|
int nCrBk = dc.GetColor();
|
|
int nColor = nCrBk;
|
|
if ( m_mapSpecXData.GetAt(PIPE_COLOR_OUT,nColor) )
|
|
{
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
if (IsActive())
|
|
{
|
|
nColor = kMagenta;
|
|
m_mapSpecXData.GetAt(KEY_ACTIVECR,nColor);
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
if (Has3DBuffer())
|
|
{
|
|
AcDbEntity* pSubEnt = NULL;
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar3D = Get3DBuffer();
|
|
for (int i = 0;i < ar3D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar3D.at(i);
|
|
if ( IsActive() )
|
|
{
|
|
pSubEnt = pEnt;
|
|
BackupColorIndex(pEnt);
|
|
pEnt->setColorIndex(nColor);
|
|
}
|
|
else
|
|
{
|
|
SetBackupColorIndex(pEnt);
|
|
}
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
|
|
if (pSubEnt != NULL)
|
|
{
|
|
DrawSubAxis(dc,pSubEnt);
|
|
}
|
|
|
|
dc.SetLayer(idLay);
|
|
dc.SetColor(nCrBk);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//绘制
|
|
ImpHvacElbow impElbow;
|
|
ImpHvacReducer impReducer;
|
|
ImpHvacTee impTee;
|
|
ImpHvacCross impCross;
|
|
ImpHvacOffset impOffset;
|
|
AcDbVoidPtrArray ar3DBuf;
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapSpecXData;
|
|
|
|
switch(nKind)
|
|
{
|
|
case eElbow:
|
|
{
|
|
impElbow.m_pXDataMap = pXDataMap;
|
|
impElbow.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impElbow.m_idDashLayer = m_idDashLayer;
|
|
impElbow.m_idCenterLayer = m_idCenterLayer;
|
|
impElbow.m_idDoubleLayer = m_idDoubleLayer;
|
|
impElbow.m_idDoubleLnType = m_idDoubleLnType;
|
|
impElbow.Draw3d(dc);
|
|
|
|
if (impElbow.Has3DBuffer())
|
|
{
|
|
impElbow.Move3DBuffer(ar3DBuf);
|
|
Add3DBuffer(ar3DBuf);
|
|
}
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
impReducer.m_pXDataMap = pXDataMap;
|
|
impReducer.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impReducer.m_idDashLayer = m_idDashLayer;
|
|
impReducer.m_idCenterLayer = m_idCenterLayer;
|
|
impReducer.m_idDoubleLayer = m_idDoubleLayer;
|
|
impReducer.m_idDoubleLnType = m_idDoubleLnType;
|
|
impReducer.Draw3d(dc);
|
|
|
|
if (impReducer.Has3DBuffer())
|
|
{
|
|
impReducer.Move3DBuffer(ar3DBuf);
|
|
Add3DBuffer(ar3DBuf);
|
|
}
|
|
}
|
|
break;
|
|
case eTee:
|
|
{
|
|
impTee.m_pXDataMap = pXDataMap;
|
|
impTee.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impTee.m_idDashLayer = m_idDashLayer;
|
|
impTee.m_idCenterLayer = m_idCenterLayer;
|
|
impTee.m_idDoubleLayer = m_idDoubleLayer;
|
|
impTee.m_idDoubleLnType = m_idDoubleLnType;
|
|
impTee.Draw3d(dc);
|
|
|
|
if (impTee.Has3DBuffer())
|
|
{
|
|
impTee.Move3DBuffer(ar3DBuf);
|
|
Add3DBuffer(ar3DBuf);
|
|
}
|
|
break;
|
|
}
|
|
case eCross:
|
|
{
|
|
impCross.m_pXDataMap = pXDataMap;
|
|
impCross.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impCross.m_idDashLayer = m_idDashLayer;
|
|
impCross.m_idCenterLayer = m_idCenterLayer;
|
|
impCross.m_idDoubleLayer = m_idDoubleLayer;
|
|
impCross.m_idDoubleLnType = m_idDoubleLnType;
|
|
impCross.Draw3d(dc);
|
|
|
|
if (impCross.Has3DBuffer())
|
|
{
|
|
impCross.Move3DBuffer(ar3DBuf);
|
|
Add3DBuffer(ar3DBuf);
|
|
}
|
|
break;
|
|
}
|
|
case eOffset:
|
|
{
|
|
impOffset.m_pXDataMap = pXDataMap;
|
|
impOffset.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impOffset.m_idDashLayer = m_idDashLayer;
|
|
impOffset.m_idCenterLayer = m_idCenterLayer;
|
|
impOffset.m_idDoubleLayer = m_idDoubleLayer;
|
|
impOffset.m_idDoubleLnType = m_idDoubleLnType;
|
|
impOffset.Draw3d(dc);
|
|
|
|
if (impOffset.Has3DBuffer())
|
|
{
|
|
impOffset.Move3DBuffer(ar3DBuf);
|
|
Add3DBuffer(ar3DBuf);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//绘制接口法兰连接
|
|
DrawInfCap3d(dc);
|
|
|
|
dc.SetLayer(idLay);
|
|
dc.SetColor(nCrBk);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AecDbObjXDataMap* AecDbHvacFitting::GetSpecialtyData(AcDb::OpenMode bMode)
|
|
{
|
|
switch(bMode)
|
|
{
|
|
case AcDb::kForRead:
|
|
{
|
|
assertReadEnabled();
|
|
break;
|
|
}
|
|
case AcDb::kForWrite:
|
|
{
|
|
if (!isWriteEnabled())
|
|
{
|
|
upgradeOpen();
|
|
}
|
|
assertWriteEnabled();
|
|
break;
|
|
}
|
|
case AcDb::kForNotify:
|
|
{
|
|
assertReadEnabled();
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return &m_mapSpecXData;
|
|
}
|
|
|
|
const AecDbObjXDataMap * AecDbHvacFitting::GetSpecialtyData() const
|
|
{
|
|
assertReadEnabled();
|
|
return &m_mapSpecXData;
|
|
}
|
|
|
|
//接口重载
|
|
bool AecDbHvacFitting::GetInterface(AcArray<AecInterface>& arInfs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
ImpHvacElbow impElbow;
|
|
ImpHvacReducer impReducer;
|
|
ImpHvacTee impTee;
|
|
ImpHvacCross impCross;
|
|
ImpHvacOffset impOffset;
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapSpecXData;
|
|
|
|
switch(nKind)
|
|
{
|
|
case eElbow:
|
|
{
|
|
impElbow.m_pXDataMap = pXDataMap;
|
|
impElbow.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impElbow.GetInterface(arInfs);
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
impReducer.m_pXDataMap = pXDataMap;
|
|
impReducer.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impReducer.GetInterface(arInfs);
|
|
}
|
|
break;
|
|
case eTee:
|
|
{
|
|
impTee.m_pXDataMap = pXDataMap;
|
|
impTee.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impTee.GetInterface(arInfs);
|
|
break;
|
|
}
|
|
case eCross:
|
|
{
|
|
impCross.m_pXDataMap = pXDataMap;
|
|
impCross.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impCross.GetInterface(arInfs);
|
|
break;
|
|
}
|
|
case eOffset:
|
|
{
|
|
impOffset.m_pXDataMap = pXDataMap;
|
|
impOffset.m_pOwnerEnt = (AecDbEntityBase*)this;
|
|
impOffset.GetInterface(arInfs);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
for (int n = 0;n < arInfs.length();n++)
|
|
{
|
|
AecInterface &inf = arInfs.at(n);
|
|
inf.dGasket = 0;
|
|
}
|
|
return !arInfs.isEmpty();
|
|
}
|
|
|
|
bool AecDbHvacFitting::GetInterface(int nIndex,AecInterface& inf) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcArray<AecInterface> arInfs;
|
|
GetInterface(arInfs);
|
|
|
|
if (nIndex > -1 && nIndex < arInfs.length())
|
|
{
|
|
inf = arInfs.at(nIndex);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
int AecDbHvacFitting::GetInterfaceCount() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
|
|
switch(nKind)
|
|
{
|
|
case eElbow:
|
|
{
|
|
return 2;
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
return 2;
|
|
}
|
|
break;
|
|
case eTee:
|
|
{
|
|
return 3;
|
|
}
|
|
case eCross:
|
|
{
|
|
return 4;
|
|
}
|
|
case eOffset:
|
|
{
|
|
return 2;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int AecDbHvacFitting::GetActiveInf() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nInfActive;
|
|
}
|
|
|
|
void AecDbHvacFitting::SetActiveInf(int nIndex)
|
|
{
|
|
assertWriteEnabled();
|
|
m_nInfActive = nIndex;
|
|
}
|
|
|
|
void AecDbHvacFitting::LockInf(int nInf)
|
|
{
|
|
bool bUpgraded = false;
|
|
if (!isWriteEnabled())
|
|
{
|
|
upgradeOpen();
|
|
bUpgraded = true;
|
|
}
|
|
|
|
CString sKey;
|
|
if (nInf == -1)
|
|
{
|
|
int nCnt = GetInterfaceCount();
|
|
for (int k = 0;k < nCnt;k++)
|
|
{
|
|
sKey.Format(_T("LK_%d"),k);
|
|
m_mapSpecXData.RemoveAt(sKey);
|
|
}
|
|
|
|
if (bUpgraded)
|
|
{
|
|
downgradeOpen();
|
|
}
|
|
return;
|
|
}
|
|
|
|
sKey.Format(_T("LK_%d"),nInf);
|
|
m_mapSpecXData.SetAt(sKey,nInf);
|
|
|
|
if (bUpgraded)
|
|
{
|
|
downgradeOpen();
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::TransformBy(const AcGeMatrix3d xform)
|
|
{
|
|
AssertWriteEnabled();
|
|
return subTransformBy(xform);
|
|
}
|
|
|
|
bool AecDbHvacFitting::TransformAssocInf(int nInf,const AcGeMatrix3d& xform)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//FITTING件没有橡皮拉伸特征,固定整体移动
|
|
AecInterface inf;
|
|
if ( GetInterface(nInf,inf) )
|
|
{
|
|
AcGeVector3d vtDir = inf.vtDir;
|
|
AcGePoint3d pt1 = inf.ptPos;
|
|
pt1.transformBy(xform);
|
|
|
|
//AcGeVector3d vt2 = pt1 - inf.ptPos;
|
|
//if (vt2.isParallelTo(vtDir))
|
|
//{
|
|
// return false;
|
|
//}
|
|
|
|
TransformBy(xform);
|
|
return true;//继续发消息
|
|
}
|
|
return false;//不继续发消息
|
|
}
|
|
|
|
bool AecDbHvacFitting::GetFittingName(CString &sName) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int nKind = -1;
|
|
m_mapSpecXData.GetAt(KEY_RUNTIME, nKind);
|
|
|
|
switch (nKind)
|
|
{
|
|
case eElbow:
|
|
{
|
|
sName = _T("风管弯头");
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
sName = _T("风管大小头");
|
|
break;
|
|
}
|
|
case eTee:
|
|
{
|
|
sName = _T("风管三通");
|
|
break;
|
|
}
|
|
case eCross:
|
|
{
|
|
sName = _T("风管四通");
|
|
break;
|
|
}
|
|
case eOffset:
|
|
{
|
|
sName = _T("风管乙字弯");
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbHvacFitting::GetSectionDraw(AcGePlane& plan,const AcGeVector3d& vtTo,AcDbVoidPtrArray& arRegionPtrs) const
|
|
{
|
|
AcGeMatrix3d xform;
|
|
xform.setToPlaneToWorld(plan);
|
|
xform.invert();
|
|
|
|
AcDbVoidPtrArray arSubPtrs;
|
|
AecDbHvacFitting* pFit = (AecDbHvacFitting*)clone();
|
|
if (pFit != NULL)
|
|
{
|
|
pFit->transformBy(xform);
|
|
|
|
AcGiViewDraw dc(NULL, NULL);
|
|
pFit->Draw2d(dc);
|
|
|
|
pFit->GetDraw2dables(0,arSubPtrs);
|
|
|
|
CString sName;
|
|
GetFittingName(sName);
|
|
MakeBlockRefSet(arSubPtrs, layerId(),Adesk::kTrue,sName);
|
|
|
|
AcDbEntity *pSubEnt = NULL;
|
|
AcDbPolyline *pPl = NULL;
|
|
for (int i = 0; i < arSubPtrs.length(); i++)
|
|
{
|
|
pSubEnt = (AcDbEntity *)arSubPtrs.at(i);
|
|
pPl = AcDbPolyline::cast(pSubEnt);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->explode(arRegionPtrs);
|
|
delete pPl;
|
|
}
|
|
else
|
|
{
|
|
arRegionPtrs.append(pSubEnt);
|
|
}
|
|
}
|
|
delete pFit;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
int AecDbHvacFitting::GetSectionDraw(const AcGePoint3d& ptFr,const AcGePoint3d& ptTo,const AcGeVector3d& vtViewDir,const AcGeVector3d& vtTo, AcDbVoidPtrArray& arRegionPtrs) const
|
|
{
|
|
AcGePlane plan;
|
|
AcGeVector3d vtU = ptTo - ptFr;
|
|
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
plan.set(ptFr,vtU,vtViewDir);
|
|
|
|
int nCount = arRegionPtrs.length();
|
|
GetSectionDraw(plan,vtTo,arRegionPtrs);
|
|
|
|
int nCoundPre = arRegionPtrs.length();
|
|
return (nCount - nCoundPre);
|
|
}
|
|
|
|
LPCTSTR AecDbHvacFitting::GetGripCmd() const
|
|
{
|
|
assertReadEnabled();
|
|
return _T("HA_ductadd");
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHvacFitting::DrawInfArrow(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_nInfActive >= 0 )
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
GetInterface(arInfs);
|
|
|
|
FreeBuffer(0,m_arDrawBuffer3d1);
|
|
|
|
if ( m_nInfActive < arInfs.length() )
|
|
{
|
|
AecInterface& inf = arInfs.at(m_nInfActive);
|
|
|
|
AcGeVector3d vtDir = inf.vtDir;
|
|
vtDir.normalize();
|
|
|
|
Adesk::Int16 nCr = dc.GetColor();
|
|
|
|
dc.SetColor(kYellow);//red
|
|
|
|
vtDir.normalize();
|
|
vtDir *= PixelToWcs(30);
|
|
|
|
//clinder
|
|
AcGePoint3d ptGeFr = inf.ptPos;
|
|
AcGePoint3d ptGeTo = ptGeFr + vtDir;
|
|
AcDbEntity* p3d = dc.DrawCone(ptGeFr,PixelToWcs(1),ptGeTo,PixelToWcs(1));
|
|
if (p3d != NULL)
|
|
{
|
|
m_arDrawBuffer3d1.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_arDrawBuffer3d1.append(p3d);
|
|
}
|
|
dc.SetColor(nCr);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbHvacFitting::DrawInfCap2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
}
|
|
|
|
void AecDbHvacFitting::DrawInfCap3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
}
|
|
|
|
void AecDbHvacFitting::DrawSubAxis(AcGiDraw &dc,AcDbEntity* pEnt) const
|
|
{
|
|
if (pEnt != NULL)
|
|
{
|
|
AcDb3dSolid* pSolid = AcDb3dSolid::cast(pEnt);
|
|
if (pSolid != NULL)
|
|
{
|
|
double dVol = 0.0,momInertia[3],prodInertia[3],prinMoments[3],radiiGyration[3];
|
|
AcGePoint3d ptOrg;
|
|
AcGeVector3d prinAxes[3];
|
|
AcDbExtents extents;
|
|
|
|
//然后变换到0,0,0点
|
|
pSolid->getMassProp(dVol,ptOrg,momInertia,prodInertia,prinMoments,prinAxes,radiiGyration,extents);
|
|
|
|
AcGeVector3dArray arVtAxis;
|
|
arVtAxis.append(AcGeVector3d::kXAxis);
|
|
arVtAxis.append(AcGeVector3d::kYAxis);
|
|
arVtAxis.append(AcGeVector3d::kZAxis);
|
|
|
|
AcGeVector3d vtDir;
|
|
for (int i = 0;i < arVtAxis.length();i++)
|
|
{
|
|
vtDir = arVtAxis.at(i);
|
|
|
|
if (vtDir.isZeroLength())
|
|
continue;
|
|
|
|
vtDir.normalize();
|
|
|
|
Adesk::Int16 nCr = dc.GetColor();
|
|
|
|
if (i == 0)
|
|
dc.SetColor(1);//red
|
|
else if (i == 1)
|
|
dc.SetColor(3);//gree
|
|
else if (i == 2)
|
|
dc.SetColor(5);//blue
|
|
else
|
|
dc.SetColor(i+1);
|
|
|
|
vtDir.normalize();
|
|
vtDir *= PixelToWcs(30);
|
|
|
|
//clinder
|
|
AcGePoint3d ptGeFr = ptOrg;
|
|
AcGePoint3d ptGeTo = ptGeFr + vtDir;
|
|
AcDbEntity* p3d = dc.DrawCone(ptGeFr,PixelToWcs(2),ptGeTo,PixelToWcs(2));
|
|
if (p3d != NULL)
|
|
{
|
|
|
|
}
|
|
|
|
//arrow
|
|
ptGeFr = ptGeTo;
|
|
vtDir.normalize();
|
|
ptGeTo += vtDir * PixelToWcs(15);
|
|
p3d = dc.DrawCone(ptGeFr,PixelToWcs(5),ptGeTo,0.001);
|
|
if (p3d != NULL)
|
|
{
|
|
|
|
}
|
|
dc.SetColor(nCr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SHJson::WValue &AecDbHvacFitting::ToJson(bool bExprotGeo) const
|
|
{
|
|
using namespace SHJson;
|
|
assertReadEnabled();
|
|
WValue &v = AecDbEntityBase::ToJson(bExprotGeo);
|
|
addMember(v, _T("__nInfActive__"), m_nInfActive);
|
|
addMember(v, _T("__sGUID__"), m_sGUID);
|
|
addMember(v, _T("__bActive__"), m_bActive);
|
|
return v;
|
|
}
|
|
|
|
bool AecDbHvacFitting::ByJson(const SHJson::WValue &v)
|
|
{
|
|
using namespace SHJson;
|
|
AssertWriteEnabled();
|
|
|
|
MCIt it1(v.FindMember(_T("__nInfActive__")))
|
|
, it2(v.FindMember(_T("__sGUID__")))
|
|
, it3(v.FindMember(_T("__bActive__")));
|
|
if (it1 != v.MemberEnd() && it2 != v.MemberEnd() && it3 != v.MemberEnd())
|
|
{
|
|
m_nInfActive = it1->value.GetInt();
|
|
m_sGUID = it2->value.GetString();
|
|
m_bActive = it3->value.GetBool();
|
|
}
|
|
|
|
return AecDbEntityBase::ByJson(v);
|
|
}
|
|
|
|
int AecDbHvacFitting::ComparedTo(AecDbEntityBase* pCurOther) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDbHvacFitting* pPipeOther = AecDbHvacFitting::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(0,0,0);
|
|
m_mapSpecXData.GetAt(KEY_MID, ptSta);
|
|
|
|
AcGePoint3d ptSta2(0,0,0);
|
|
pPipeOther->GetSpecialtyData()->GetAt(KEY_MID, ptSta2);
|
|
|
|
if (ptSta.distanceTo(ptSta2) > 2.0)//误差2毫米
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
#include "HlrCutOption.h"
|
|
void AecDbHvacFitting::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
|
|
, HlrCutOption::getHlrBLK_FITTING()
|
|
, ar
|
|
, preAr
|
|
, output);
|
|
} |