928 lines
19 KiB
C++
928 lines
19 KiB
C++
#include "stdafx.h"
|
|
#include "AecPipeLineModify.h"
|
|
#include "AecMInterfaces.h"
|
|
#include "AecDbECableTray.h"
|
|
#include "AecDbEcFitting.h"
|
|
|
|
#ifndef DXF_PIPE_ONLY
|
|
#define DXF_PIPE_ONLY _T("AEC_DBCABTRY")
|
|
#endif
|
|
|
|
AecPipeLineModify::AecPipeLineModify(void)
|
|
{
|
|
m_bTeeStop = FALSE;
|
|
m_bUpdateMat = FALSE;
|
|
m_bCrossStop = FALSE;
|
|
m_bElLock = false;
|
|
memset(&m_paramOld,0,sizeof(AecHvac::DuctParam));
|
|
}
|
|
|
|
AecPipeLineModify::~AecPipeLineModify(void)
|
|
{
|
|
}
|
|
|
|
void AecPipeLineModify::SetPipeParamOld(const AecHvac::DuctParam* pPipeParam)
|
|
{
|
|
if (pPipeParam != NULL)
|
|
{
|
|
memcpy(&m_paramOld,pPipeParam,sizeof(AecHvac::DuctParam));
|
|
}
|
|
}
|
|
|
|
void AecPipeLineModify::SetPipeNetIds(AcDbObjectIdArray& arNetIds)
|
|
{
|
|
m_arNetIds.append(arNetIds);
|
|
}
|
|
|
|
bool AecPipeLineModify::ModifyPipeLineParam(AcDbObjectIdArray& arPipeIds,AcDbObjectIdArray& arFitIds,AcDbObjectIdArray& arEquIds, AecHvac::DuctParam& paramNew,BOOL bUpdateMat)
|
|
{
|
|
m_bUpdateMat = bUpdateMat;
|
|
|
|
//1.记录统一改管子的尺寸的管子
|
|
ModifyPipeOnParam(arPipeIds, paramNew);
|
|
m_arPipeIds.append(arPipeIds);
|
|
|
|
AcDbObjectIdArray arFlangIds;
|
|
AcArray<AcDbObjectIdInf> arAssFlgs,arAssEquIds;
|
|
|
|
//2.先修改定位管件,定位管件的位置为绝对位置
|
|
//弯头,三通,四通,Wye,Lateral
|
|
//修改后导致接口位置改变,影响连接件
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbObjectId id1;
|
|
for (int i = 0;i < arFitIds.length();i++)
|
|
{
|
|
id1 = arFitIds.at(i);
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,id1,AcDb::kForRead))
|
|
{
|
|
AecDbEcFitting* pFit = AecDbEcFitting::cast(pEnt);
|
|
if (pFit != NULL)
|
|
{
|
|
int nType = 0;
|
|
pFit->GetSpecialtyData()->GetAt(KEY_RUNTIME,nType);
|
|
EFittingType eType = (EFittingType)nType;
|
|
|
|
AcArray<AecInterface> arInfs;
|
|
pFit->GetInterface(arInfs);
|
|
|
|
switch(eType)
|
|
{
|
|
case eElbow:
|
|
case eTee:
|
|
case eCross:
|
|
case eReduce:
|
|
case eOffset:
|
|
{
|
|
//改完Fit后,按接口对应改对接的管子或管件
|
|
if ( ModifyFitting(pFit,paramNew) )
|
|
{
|
|
AecMInterfaces* pMInfNew = static_cast<AecMInterfaces*>(pFit);
|
|
|
|
//按照接口路线修改
|
|
//一直到管子停止;
|
|
m_arNetIds.remove(id1);//修改一个移除当前Fit
|
|
pFit->LockInf(-1);
|
|
|
|
if ( !ModifyByInfAssoc(arInfs,pMInfNew,paramNew) )
|
|
{
|
|
pEnt->close();
|
|
return false;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void AecPipeLineModify::ModifyPipeOnNewInf(AecInterface& infOld,AecInterface& infTo)
|
|
{
|
|
AcGePoint3d ptS,ptE;
|
|
bool bSet = false;
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arPipeIds.length();i++)
|
|
{
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,m_arPipeIds.at(i),AcDb::kForRead))
|
|
{
|
|
AecDbECableTray* pPipe = AecDbECableTray::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
ptS = pPipe->StartPoint();
|
|
ptE = pPipe->EndPoint();
|
|
|
|
if (ptS.distanceTo(infOld.ptPos) < 1.e-1)
|
|
{
|
|
pPipe->upgradeOpen();
|
|
pPipe->SetStartPoint(infTo.ptPos);
|
|
pPipe->downgradeOpen();
|
|
bSet = true;
|
|
}
|
|
|
|
if (ptE.distanceTo(infOld.ptPos) < 1.e-1)
|
|
{
|
|
pPipe->upgradeOpen();
|
|
pPipe->SetEndPoint(infTo.ptPos);
|
|
pPipe->downgradeOpen();
|
|
bSet = true;
|
|
}
|
|
}
|
|
pEnt->close();
|
|
|
|
if (bSet)
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
AcDbObjectIdInf* ReverIdInf(AcDbObjectIdInf& idInf0)
|
|
{
|
|
AcArray<AcDbObjectIdInf*> arInfPtrs;
|
|
|
|
AcDbObjectIdInf* pNext = idInf0.pNext;
|
|
while(pNext != NULL)
|
|
{
|
|
arInfPtrs.append(pNext);
|
|
pNext = pNext->pNext;
|
|
}
|
|
arInfPtrs.reverse();
|
|
|
|
AcDbObjectIdInf* pLast = NULL,*pHead = NULL;
|
|
|
|
for (int i = 0;i < arInfPtrs.length();i++)
|
|
{
|
|
pNext = arInfPtrs.at(i);
|
|
|
|
if (pLast != NULL)
|
|
{
|
|
pLast->pNext = pNext;
|
|
pLast = pNext;
|
|
}
|
|
else
|
|
{
|
|
pLast = pNext;
|
|
pHead = pLast;
|
|
pLast->pNext = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
AcDbObjectIdInf* pLastBk = pLast;
|
|
if (pLast != NULL)
|
|
{
|
|
pLast->pNext = NULL;
|
|
|
|
pNext = new AcDbObjectIdInf;
|
|
pNext->id = idInf0.id;
|
|
pNext->infFr = idInf0.infFr;
|
|
pNext->vtMove = idInf0.vtMove;
|
|
pNext->pNext = NULL;
|
|
pLast->pNext = pNext;
|
|
pLast = pNext;
|
|
}
|
|
|
|
//Head由 idInf0代替
|
|
if (pHead != NULL)
|
|
{
|
|
idInf0.id = pHead->id;
|
|
idInf0.infFr = pHead->infFr;
|
|
idInf0.pNext = pHead->pNext;
|
|
delete pHead;
|
|
}
|
|
|
|
//TAIL
|
|
return pLast;
|
|
}
|
|
|
|
void ReverIdInfInf(AcDbObjectIdInf* pNext)
|
|
{
|
|
AecInterface inf0,inf1;
|
|
AcDbEntity* pEnt = NULL;
|
|
while(pNext != NULL)
|
|
{
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,pNext->id,AcDb::kForRead))
|
|
{
|
|
AecDbEcFitting* pFit = AecDbEcFitting::cast(pEnt);
|
|
if (pFit != NULL)
|
|
{
|
|
AecMInterfaces* pMInfNew = static_cast<AecMInterfaces*>(pFit);
|
|
if (pMInfNew->GetInterfaceCount() == 2)
|
|
{
|
|
pMInfNew->GetInterface(0,inf0);
|
|
pMInfNew->GetInterface(1,inf1);
|
|
|
|
if (inf0.vtDir.isCodirectionalTo(pNext->infFr.vtDir))
|
|
{
|
|
pNext->infFr = inf1;
|
|
}
|
|
else if (inf1.vtDir.isCodirectionalTo(pNext->infFr.vtDir))
|
|
{
|
|
pNext->infFr = inf0;
|
|
}
|
|
}
|
|
}
|
|
pEnt->close();
|
|
}
|
|
pNext = pNext->pNext;
|
|
}
|
|
}
|
|
|
|
bool AecPipeLineModify::ModifyFitting(AecDbEcFitting* pFitting,const AecHvac::DuctParam& paramNew)
|
|
{
|
|
AecHvac::DuctParam *pParam = (AecHvac::DuctParam *)¶mNew;
|
|
|
|
AecDbObjXDataMap* pXDataMap = pFitting->GetSpecialtyData(AcDb::kForRead);
|
|
|
|
int nType = 0,nLocked = -1;
|
|
pXDataMap->GetAt(KEY_RUNTIME,nType);
|
|
EFittingType eType = (EFittingType)nType;
|
|
|
|
CString sKey;
|
|
bool bSuccesed = false;
|
|
|
|
//弯头,三通,四通,变径
|
|
switch( eType )
|
|
{
|
|
case eElbow:
|
|
{
|
|
AecInterface inf0;
|
|
AecInterface inf1;
|
|
pFitting->GetInterface(0, inf0);
|
|
pFitting->GetInterface(1, inf1);
|
|
|
|
//电缆沟
|
|
pFitting->SetDuctParam(paramNew);
|
|
|
|
pFitting->ReCreateDraw2d();
|
|
pFitting->ReCreateDraw3d();
|
|
|
|
//记录修改后
|
|
AecInterface inf11, inf00;
|
|
pFitting->GetInterface(0, inf00);
|
|
pFitting->GetInterface(1, inf11);
|
|
|
|
AecInterfaceFrTo infFt;
|
|
|
|
infFt.infFr = inf0;
|
|
infFt.infTo = inf00;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf1;
|
|
infFt.infTo = inf11;
|
|
m_arFrTo.append(infFt);
|
|
|
|
bSuccesed = true;
|
|
break;
|
|
}
|
|
case eTee:
|
|
{
|
|
if (m_bTeeStop) //三通分支管径不改尺寸; 主接口可修改.分支锁定
|
|
{
|
|
TeeStop:
|
|
double dTDN = 0.0;
|
|
pXDataMap->GetAt(KEY_SIZE3,dTDN);
|
|
|
|
double dDN = 0.0;
|
|
pXDataMap->GetAt(KEY_SIZE1,dDN);
|
|
|
|
nLocked = -1;
|
|
for(int k = 0;k < 3;k++)
|
|
{
|
|
sKey.Format(_T("LK_%d"),k);
|
|
if ( pXDataMap->GetAt(sKey,nLocked) )
|
|
{
|
|
if (nLocked > -1)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (nLocked == 2)//分支锁定,改主管
|
|
{
|
|
if ( ( dTDN - pParam->dSize[0] ) > 1.e-2)
|
|
{
|
|
acutPrintf(_T("\n三通分支管径大于主管径!修改管径失败!"));
|
|
return false;
|
|
}
|
|
|
|
//主接口可修改.分支锁定
|
|
//原来的主接口
|
|
AecInterface inf0;
|
|
AecInterface inf1;
|
|
AecInterface inf2;
|
|
pFitting->GetInterface(0, inf0);
|
|
pFitting->GetInterface(1, inf1);
|
|
pFitting->GetInterface(2, inf2);
|
|
|
|
double dBrSize = 0;
|
|
pXDataMap->GetAt(KEY_SIZE3, dBrSize);//w1,三通,变径用 分支
|
|
pFitting->SetDuctParam(paramNew);
|
|
pXDataMap->SetAt(KEY_SIZE3, dBrSize);//w1,三通,变径用 分支
|
|
|
|
pFitting->ReCreateDraw2d();
|
|
pFitting->ReCreateDraw3d();
|
|
|
|
//记录修改后
|
|
AecInterface inf11, inf00, inf22;
|
|
pFitting->GetInterface(0, inf00);
|
|
pFitting->GetInterface(1, inf11);
|
|
pFitting->GetInterface(2, inf22);
|
|
|
|
AecInterfaceFrTo infFt;
|
|
|
|
infFt.infFr = inf0;
|
|
infFt.infTo = inf00;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf1;
|
|
infFt.infTo = inf11;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf2;
|
|
infFt.infTo = inf22;
|
|
m_arFrTo.append(infFt);
|
|
|
|
}
|
|
else //主管锁定,改分支
|
|
{
|
|
if ( ( pParam->dSize[0] - dDN) > 1.e-2)
|
|
{
|
|
acutPrintf(_T("\n三通分支管径大于主管径!修改管径失败!"));
|
|
return false;
|
|
}
|
|
|
|
AecInterface inf11, inf00;
|
|
pFitting->GetInterface(2, inf00);
|
|
|
|
double dSize1 = 0;
|
|
pXDataMap->GetAt(KEY_SIZE1, dSize1); //w
|
|
pFitting->SetDuctParam(paramNew);
|
|
pXDataMap->SetAt(KEY_SIZE1, dSize1); //w
|
|
|
|
pFitting->ReCreateDraw2d();
|
|
pFitting->ReCreateDraw3d();
|
|
|
|
////记录修改后
|
|
pFitting->GetInterface(2, inf11);
|
|
|
|
AecInterfaceFrTo infFt;
|
|
|
|
infFt.infFr = inf00;
|
|
infFt.infTo = inf11;
|
|
m_arFrTo.append(infFt);
|
|
}
|
|
bSuccesed = true;
|
|
}
|
|
else//全改,统一DN
|
|
{
|
|
double dDN = 0.0,dTDN = 0.0;
|
|
pXDataMap->GetAt(KEY_SIZE1,dDN);
|
|
pXDataMap->GetAt(KEY_SIZE3,dTDN);
|
|
|
|
if ( fabs(dTDN - dDN) > 1.e-2)
|
|
{
|
|
goto TeeStop;
|
|
break;
|
|
}
|
|
|
|
//原来的主接口
|
|
AecInterface inf0;
|
|
AecInterface inf1;
|
|
AecInterface inf2;
|
|
pFitting->GetInterface(0, inf0);
|
|
pFitting->GetInterface(1, inf1);
|
|
pFitting->GetInterface(2, inf2);
|
|
|
|
pFitting->SetDuctParam(paramNew);
|
|
|
|
pFitting->ReCreateDraw2d();
|
|
pFitting->ReCreateDraw3d();
|
|
|
|
//记录修改后
|
|
AecInterface inf11, inf00,inf22;
|
|
pFitting->GetInterface(0, inf00);
|
|
pFitting->GetInterface(1, inf11);
|
|
pFitting->GetInterface(2, inf22);
|
|
|
|
AecInterfaceFrTo infFt;
|
|
|
|
infFt.infFr = inf0;
|
|
infFt.infTo = inf00;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf1;
|
|
infFt.infTo = inf11;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf2;
|
|
infFt.infTo = inf22;
|
|
m_arFrTo.append(infFt);
|
|
|
|
bSuccesed = true;
|
|
}
|
|
break;
|
|
}
|
|
case eCross:
|
|
{
|
|
if (m_bCrossStop)//四通分支管径不改尺寸
|
|
{
|
|
CrossStop:
|
|
nLocked = -1;
|
|
for(int k = 0;k < 4;k++)
|
|
{
|
|
sKey.Format(_T("LK_%d"),k);
|
|
if ( pXDataMap->GetAt(sKey,nLocked) )
|
|
{
|
|
if (nLocked > -1)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (nLocked > 1)//分支锁定,改主管
|
|
{
|
|
double dSize3 = 0.0;
|
|
pXDataMap->GetAt(KEY_SIZE3, dSize3);
|
|
|
|
//记录分支前
|
|
//原来的主接口
|
|
AecInterface inf0;
|
|
AecInterface inf1;
|
|
AecInterface inf2;
|
|
AecInterface inf3;
|
|
|
|
pFitting->GetInterface(0, inf0);
|
|
pFitting->GetInterface(1, inf1);
|
|
pFitting->GetInterface(2, inf2);
|
|
pFitting->GetInterface(3, inf3);
|
|
|
|
pFitting->SetDuctParam(paramNew);
|
|
|
|
pXDataMap->SetAt(KEY_SIZE3,dSize3);
|
|
|
|
pFitting->ReCreateDraw2d();
|
|
pFitting->ReCreateDraw3d();
|
|
|
|
//记录主管后
|
|
AecInterface inf00, inf11, inf22, inf33;
|
|
pFitting->GetInterface(0, inf00);
|
|
pFitting->GetInterface(1, inf11);
|
|
pFitting->GetInterface(2, inf22);
|
|
pFitting->GetInterface(3, inf33);
|
|
|
|
AecInterfaceFrTo infFt;
|
|
infFt.infFr = inf0;
|
|
infFt.infTo = inf00;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf1;
|
|
infFt.infTo = inf11;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf2;
|
|
infFt.infTo = inf22;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf3;
|
|
infFt.infTo = inf33;
|
|
m_arFrTo.append(infFt);
|
|
}
|
|
else//主管锁定,改分支
|
|
{
|
|
double dSize1 = 0, dSize2 = 0;
|
|
pXDataMap->GetAt(KEY_SIZE1, dSize1);
|
|
pXDataMap->GetAt(KEY_SIZE2, dSize2);
|
|
|
|
//原来的主接口
|
|
AecInterface inf0;
|
|
AecInterface inf1;
|
|
AecInterface inf2;
|
|
AecInterface inf3;
|
|
|
|
pFitting->GetInterface(0, inf0);
|
|
pFitting->GetInterface(1, inf1);
|
|
pFitting->GetInterface(2, inf2);
|
|
pFitting->GetInterface(3, inf3);
|
|
|
|
pFitting->SetDuctParam(paramNew);
|
|
|
|
pXDataMap->SetAt(KEY_SIZE1, dSize1);
|
|
pXDataMap->SetAt(KEY_SIZE2, dSize2);
|
|
|
|
pFitting->ReCreateDraw2d();
|
|
pFitting->ReCreateDraw3d();
|
|
|
|
//记录主管后
|
|
AecInterface inf00, inf11, inf22, inf33;
|
|
pFitting->GetInterface(0, inf00);
|
|
pFitting->GetInterface(1, inf11);
|
|
pFitting->GetInterface(2, inf22);
|
|
pFitting->GetInterface(3, inf33);
|
|
|
|
AecInterfaceFrTo infFt;
|
|
infFt.infFr = inf0;
|
|
infFt.infTo = inf00;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf1;
|
|
infFt.infTo = inf11;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf2;
|
|
infFt.infTo = inf22;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf3;
|
|
infFt.infTo = inf33;
|
|
m_arFrTo.append(infFt);
|
|
}
|
|
bSuccesed = true;
|
|
}
|
|
else//全改,统一DN
|
|
{
|
|
double dDN = 0.0,dTDN = 0.0;
|
|
pXDataMap->GetAt(KEY_SIZE1,dDN);
|
|
pXDataMap->GetAt(KEY_SIZE3,dTDN);
|
|
|
|
if ( fabs(dTDN - dDN) > 1.e-2)
|
|
{
|
|
goto CrossStop;
|
|
break;
|
|
}
|
|
|
|
//原来的主接口
|
|
AecInterface inf0;
|
|
AecInterface inf1;
|
|
AecInterface inf2;
|
|
AecInterface inf3;
|
|
|
|
pFitting->GetInterface(0, inf0);
|
|
pFitting->GetInterface(1, inf1);
|
|
pFitting->GetInterface(2, inf2);
|
|
pFitting->GetInterface(3, inf3);
|
|
|
|
pFitting->SetDuctParam(paramNew);
|
|
|
|
pFitting->ReCreateDraw2d();
|
|
pFitting->ReCreateDraw3d();
|
|
|
|
//记录主管后
|
|
AecInterface inf00, inf11, inf22, inf33;
|
|
pFitting->GetInterface(0, inf00);
|
|
pFitting->GetInterface(1, inf11);
|
|
pFitting->GetInterface(2, inf22);
|
|
pFitting->GetInterface(3, inf33);
|
|
|
|
AecInterfaceFrTo infFt;
|
|
infFt.infFr = inf0;
|
|
infFt.infTo = inf00;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf1;
|
|
infFt.infTo = inf11;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf2;
|
|
infFt.infTo = inf22;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf3;
|
|
infFt.infTo = inf33;
|
|
m_arFrTo.append(infFt);
|
|
|
|
bSuccesed = true;
|
|
}
|
|
break;
|
|
}
|
|
case eReduce:
|
|
{
|
|
//double dL = 0.0;
|
|
//pXDataMap->GetAt(KEY_L,dL);
|
|
|
|
double dDN = 0.0;
|
|
pXDataMap->GetAt(KEY_SIZE1,dDN);
|
|
|
|
double dTDN = 0.0;
|
|
pXDataMap->GetAt(KEY_SIZE3,dTDN);
|
|
|
|
//主管改,不改分支
|
|
if ( fabs(m_paramOld.dSize[0] - dDN) < 1.e-2)//
|
|
{
|
|
if ( fabs( pParam->dSize[0] - dDN ) < 1.e-2)
|
|
{
|
|
acutPrintf(_T("\n分支管径等于主管径!修改管径取消!"));
|
|
return false;
|
|
}
|
|
|
|
//记录修改前
|
|
AecInterface inf0,inf1;
|
|
pFitting->GetInterface(0,inf0);
|
|
pFitting->GetInterface(1,inf1);
|
|
|
|
double dSize2 = 0;
|
|
pXDataMap->GetAt(KEY_SIZE2, dSize2);
|
|
|
|
pFitting->SetDuctParam(paramNew);
|
|
pXDataMap->SetAt(KEY_SIZE2, dSize2);
|
|
|
|
pFitting->ReCreateDraw2d();
|
|
pFitting->ReCreateDraw3d();
|
|
|
|
//记录修改后
|
|
AecInterface inf00,inf11;
|
|
pFitting->GetInterface(0,inf00);
|
|
pFitting->GetInterface(1,inf11);
|
|
|
|
AecInterfaceFrTo infFt;
|
|
|
|
infFt.infFr = inf0;
|
|
infFt.infTo = inf00;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf1;
|
|
infFt.infTo = inf11;
|
|
m_arFrTo.append(infFt);
|
|
}
|
|
else//主管不改,改分支
|
|
{
|
|
if ( fabs( pParam->dSize[0] - dTDN ) < 1.e-2)
|
|
{
|
|
acutPrintf(_T("\n分支管径等于主管径!修改管径取消!"));
|
|
return false;
|
|
}
|
|
|
|
double dSize1 = 0;
|
|
pXDataMap->GetAt(KEY_SIZE1, dSize1);
|
|
|
|
//记录修改前
|
|
AecInterface inf0, inf1;
|
|
pFitting->GetInterface(0, inf0);
|
|
pFitting->GetInterface(1, inf1);
|
|
|
|
pFitting->SetDuctParam(paramNew);
|
|
|
|
pFitting->ReCreateDraw2d();
|
|
pFitting->ReCreateDraw3d();
|
|
|
|
//记录修改后
|
|
AecInterface inf00, inf11;
|
|
pFitting->GetInterface(0, inf00);
|
|
pFitting->GetInterface(1, inf11);
|
|
|
|
AecInterfaceFrTo infFt;
|
|
|
|
infFt.infFr = inf0;
|
|
infFt.infTo = inf00;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf1;
|
|
infFt.infTo = inf11;
|
|
m_arFrTo.append(infFt);
|
|
}
|
|
|
|
bSuccesed = true;
|
|
|
|
break;
|
|
}
|
|
case eOffset:
|
|
{
|
|
AecInterface inf0;
|
|
AecInterface inf1;
|
|
pFitting->GetInterface(0, inf0);
|
|
pFitting->GetInterface(1, inf1);
|
|
|
|
//电缆沟
|
|
pFitting->SetDuctParam(paramNew);
|
|
|
|
pFitting->ReCreateDraw2d();
|
|
pFitting->ReCreateDraw3d();
|
|
|
|
//记录修改后
|
|
AecInterface inf11, inf00;
|
|
pFitting->GetInterface(0, inf00);
|
|
pFitting->GetInterface(1, inf11);
|
|
|
|
AecInterfaceFrTo infFt;
|
|
|
|
infFt.infFr = inf0;
|
|
infFt.infTo = inf00;
|
|
m_arFrTo.append(infFt);
|
|
|
|
infFt.infFr = inf1;
|
|
infFt.infTo = inf11;
|
|
m_arFrTo.append(infFt);
|
|
|
|
bSuccesed = true;
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return bSuccesed;
|
|
}
|
|
|
|
bool AecPipeLineModify::ModifyByInfAssoc(const AcArray<AecInterface>& arFitEquOldInfs,AecMInterfaces* pFitEquMInfNew,const AecHvac::DuctParam & paramNew)
|
|
{
|
|
//从 m_arNetIds 找
|
|
//移除一个,去除一个
|
|
//一直到inf锁定为止
|
|
//arFitEquOldInfs 和 pFitEquMInfNew 一一对应
|
|
|
|
AcArray<AecInterface> arNewInfs;
|
|
pFitEquMInfNew->GetInterface(arNewInfs);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
AecMInterfaces* pMInfMeetWith = NULL;
|
|
|
|
for (int i = 0;i < m_arNetIds.length();i++)
|
|
{
|
|
pMInfMeetWith = NULL;
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,m_arNetIds.at(i),AcDb::kForRead))
|
|
{
|
|
AecDbECableTray * pPipe = AecDbECableTray::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
pMInfMeetWith = static_cast<AecMInterfaces*>(pPipe);
|
|
}
|
|
|
|
if (pMInfMeetWith != NULL)
|
|
{
|
|
AcGeVector3d vtDir,vtDir2;
|
|
AcGePoint3d ptS,ptE,ptNew;
|
|
AecInterface infOn,infNew;
|
|
|
|
for (int j = 0;j < arFitEquOldInfs.length();j++)
|
|
{
|
|
const AecInterface& inf = arFitEquOldInfs.at(j);
|
|
|
|
if (pMInfMeetWith->GetInterface(inf.ptPos,infOn))
|
|
{
|
|
//碰上此接口
|
|
if (pPipe != NULL)
|
|
{
|
|
pPipe->upgradeOpen();
|
|
|
|
//改管子的长度
|
|
ptS = pPipe->StartPoint();
|
|
ptE = pPipe->EndPoint();
|
|
vtDir = ptE - ptS;
|
|
|
|
if (ptS.distanceTo(infOn.ptPos) < 1.e-1)//误差0.01
|
|
{
|
|
pFitEquMInfNew->GetInterface(j,infNew);
|
|
|
|
vtDir2 = ptE - infNew.ptPos;
|
|
if (!vtDir2.isCodirectionalTo(vtDir))
|
|
{
|
|
pEnt->close();
|
|
acutPrintf(_T("管线尺寸变更幅度过大!产生管线错位!变更失败!"));
|
|
return false;
|
|
}
|
|
|
|
pPipe->SetStartPoint( infNew.ptPos );
|
|
}
|
|
|
|
if (ptE.distanceTo(infOn.ptPos) < 1.e-1)
|
|
{
|
|
pFitEquMInfNew->GetInterface(j,infNew);
|
|
|
|
vtDir2 = infNew.ptPos - ptS;
|
|
if ( !vtDir2.isCodirectionalTo(vtDir) )
|
|
{
|
|
pEnt->close();
|
|
acutPrintf(_T("管线尺寸变更幅度过大!产生管线错位!变更失败!"));
|
|
return false;
|
|
}
|
|
|
|
pPipe->SetEndPoint( infNew.ptPos );
|
|
}
|
|
|
|
pPipe->downgradeOpen();
|
|
}
|
|
|
|
//对fit 无效,导致回溯
|
|
/*AecDbEwFitting* pFit = AecDbEwFitting::cast(pEnt);
|
|
if (pFit != NULL)
|
|
{
|
|
}*/
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecPipeLineModify::ModifyPipeOnParam(const AcDbObjectIdArray& arPipeIds,const AecHvac::DuctParam& paramNew)
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
for(int i = 0;i < arPipeIds.length();i++)
|
|
{
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,arPipeIds.at(i),AcDb::kForWrite))
|
|
{
|
|
AecDbECableTray* pPipe = AecDbECableTray::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
//公称 外径 壁厚 压了等级,曲率半径
|
|
AecHvac::DuctParam param;
|
|
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
|
pPipe->GetDuctParam(param);
|
|
|
|
double dOldEl = param.m_dEl;
|
|
|
|
AecHvac::DuctParam *pParam = ¶m;
|
|
memcpy(pParam, ¶mNew, sizeof(AecHvac::DuctParam));
|
|
if (m_bElLock)
|
|
{
|
|
pParam->m_dEl = dOldEl;
|
|
}
|
|
pPipe->SetDuctParam(pParam);
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecPipeLineModify::AddjustTInfAssoc()
|
|
{
|
|
//主要是管子
|
|
if (!m_arFrTo.isEmpty())
|
|
{
|
|
//选择管线,管件
|
|
struct resbuf* pRb = acutBuildList(RTDXF0, DXF_PIPE_ONLY, 0);
|
|
|
|
ads_name ss,ent;
|
|
acedSSGet(_T("A"),NULL,NULL,pRb,ss);
|
|
|
|
Adesk::Int32 nLen = 0;
|
|
acedSSLength(ss,&nLen);
|
|
|
|
AcGePoint3d ptS,ptE;
|
|
|
|
AcDbObjectId id;
|
|
AcDbEntity* pEnt = NULL;
|
|
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
if (m_arFrTo.isEmpty())
|
|
{
|
|
break;
|
|
}
|
|
|
|
acedSSName(ss,i,ent);
|
|
acdbGetObjectId(id,ent);
|
|
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead))
|
|
{
|
|
AecDbECableTray * pPipe = AecDbECableTray::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
ptS = pPipe->StartPoint();
|
|
ptE = pPipe->EndPoint();
|
|
|
|
for (int k = 0;k < m_arFrTo.length();k++)
|
|
{
|
|
AecInterfaceFrTo& infFrTo = m_arFrTo.at(k);
|
|
if (infFrTo.infFr.ptPos.distanceTo(ptS) < 1.e-1 )
|
|
{
|
|
pPipe->upgradeOpen();
|
|
pPipe->SetStartPoint(infFrTo.infTo.ptPos);
|
|
pPipe->downgradeOpen();
|
|
m_arFrTo.removeAt(k);
|
|
k -= 1;
|
|
break;
|
|
}
|
|
|
|
if (infFrTo.infFr.ptPos.distanceTo(ptE) < 1.e-1)
|
|
{
|
|
pPipe->upgradeOpen();
|
|
pPipe->SetEndPoint(infFrTo.infTo.ptPos);
|
|
pPipe->downgradeOpen();
|
|
m_arFrTo.removeAt(k);
|
|
k -= 1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
|
|
acedSSFree(ss);
|
|
acutRelRb(pRb);
|
|
}
|
|
return true;
|
|
} |