Files
envi-code/SourceCode/Code2026/tg_shs/shs_pipebase/TEImpCabCross.cpp
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

5946 lines
158 KiB
C++

#include "stdafx.h"
#include "TEImpCabCross.h"
#include "TDbInterfaceRecord.h"
#include "TDbXDataMap.h"
#include "TDbInterfaceMsgWrite.h"
#include "math.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
TEImpCabCross::TEImpCabCross()
{
}
TEImpCabCross::~TEImpCabCross()
{
}
Adesk::Boolean acedPostCommand( const TCHAR * );
// 接口描述对象
BOOL TEImpCabCross::GetInterface(int nIndex,TInterface& pipeInterface) const
{
if (m_pXDataMap != NULL)
{
AcDbObjectId id1,id2,id3,id4;
AcGePoint3d ptGeM,ptGeS,ptGeE,ptGeTop,ptGeDown;
AcGeVector3d vtDir,vtNormal,vtMajNor,vtMinNor,vtPreCross;
double dLen = 0.0,dH = 0.0;
int nStyle = 0;
if (!m_pXDataMap->GetAt(KEY_MID,ptGeM) ||
!m_pXDataMap->GetAt(KEY_L,dLen) ||
!m_pXDataMap->GetAt(KEY_NORMAL,vtNormal))
{
return FALSE;
}
m_pXDataMap->GetAt(KEY_CROSS,nStyle);
dLen /= 2.0;
switch(nStyle)
{
case TDb::eOldCbotHorEqualCross:
case TDb::eCbotHorEqualCross:
{
BOOL bIncline = FALSE;
m_pXDataMap->GetAt(KEY_INCLINE_FIT, bIncline);
if (bIncline)
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
m_pXDataMap->GetAt(KEY_MINBR,vtPreCross);
}
else
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtNormal = vtDir;
vtNormal.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
}
vtPreCross = vtDir;
vtPreCross.rotateBy(PI / 2.0,vtNormal);
}
vtDir.normalize();
vtPreCross.normalize();
ptGeS = ptGeM - vtDir * dLen;
ptGeE = ptGeM + vtDir * dLen;
ptGeTop = ptGeM + vtPreCross * dLen;
ptGeDown = ptGeM - vtPreCross * dLen;
break;
}
case TDb::eCrossForSpace:
{
m_pXDataMap->GetAt(KEY_MAJNOR,vtMajNor);
m_pXDataMap->GetAt(KEY_MINNOR,vtMinNor);
m_pXDataMap->GetAt(KEY_H,dH);
vtMajNor.normalize();
vtMinNor.normalize();
vtPreCross = vtMajNor;
ptGeS = ptGeM - vtMinNor*dLen - vtMajNor*dH/2;
ptGeE = ptGeM + vtMinNor*dLen - vtMajNor*dH/2;
ptGeTop = ptGeM - vtMajNor*dLen - vtMinNor*dH/2;
ptGeDown = ptGeM + vtMajNor*dLen - vtMinNor*dH/2;
ptGeM -= vtMajNor*dH/2 + vtMinNor*dH/2;
break;
}
default:
break;
}
switch(nIndex)
{
case 0:
{
AcGeVector3d vtDir = ptGeS - ptGeM;
if (m_pXDataMap->GetAt(KEY_IDCNT1,id1))
{
if (MakesureInterfaceValidate(id1,ptGeS,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT2,id2))
{
if (MakesureInterfaceValidate(id2,ptGeS,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT3,id3))
{
if (MakesureInterfaceValidate(id3,ptGeTop,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT4,id4))
{
if (MakesureInterfaceValidate(id4,ptGeTop,vtDir,pipeInterface))
{
return TRUE;
}
}
pipeInterface.SetOutDir(vtDir);
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
pipeInterface.SetPosition(ptGeS);
return TRUE;
}
case 1:
{
AcGeVector3d vtDir = ptGeE - ptGeM;
if (m_pXDataMap->GetAt(KEY_IDCNT1,id1))
{
if (MakesureInterfaceValidate(id1,ptGeE,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT2,id2))
{
if (MakesureInterfaceValidate(id2,ptGeE,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT3,id3))
{
if (MakesureInterfaceValidate(id3,ptGeTop,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT4,id4))
{
if (MakesureInterfaceValidate(id4,ptGeTop,vtDir,pipeInterface))
{
return TRUE;
}
}
pipeInterface.SetOutDir(vtDir);
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
pipeInterface.SetPosition(ptGeE);
return TRUE;
}
case 2:
{
AcGeVector3d vtDir = ptGeTop - ptGeM;
if (m_pXDataMap->GetAt(KEY_IDCNT3,id3))
{
if (MakesureInterfaceValidate(id3,ptGeTop,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT4,id4))
{
if (MakesureInterfaceValidate(id4,ptGeTop,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT3,id3))
{
if (MakesureInterfaceValidate(id3,ptGeS,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT4,id4))
{
if (MakesureInterfaceValidate(id4,ptGeS,vtDir,pipeInterface))
{
return TRUE;
}
}
pipeInterface.SetOutDir(vtDir);
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
pipeInterface.SetPosition(ptGeTop);
return TRUE;
}
case 3:
{
AcGeVector3d vtDir = ptGeDown - ptGeM;
if (m_pXDataMap->GetAt(KEY_IDCNT3,id3))
{
if (MakesureInterfaceValidate(id3,ptGeDown,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT4,id4))
{
if (MakesureInterfaceValidate(id4,ptGeDown,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT3,id3))
{
if (MakesureInterfaceValidate(id3,ptGeS,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT4,id4))
{
if (MakesureInterfaceValidate(id4,ptGeS,vtDir,pipeInterface))
{
return TRUE;
}
}
pipeInterface.SetOutDir(vtDir);
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
pipeInterface.SetPosition(ptGeDown);
return TRUE;
}
default:
break;
}
}
return FALSE;
}
BOOL TEImpCabCross::GetInterface(const AcGePoint3d& ptCon,TInterface& pipeInterface) const
{
if (m_pXDataMap != NULL)
{
AcGePoint3d ptGeM,ptGeS,ptGeE,ptGeTop,ptGeDown;
AcGeVector3d vtDir,vtNormal,vtMajNor,vtMinNor,vtPreCross;
double dLen = 0.0,dH = 0.0;
int nStyle = 0;
if (!m_pXDataMap->GetAt(KEY_MID,ptGeM) ||
!m_pXDataMap->GetAt(KEY_L,dLen) ||
!m_pXDataMap->GetAt(KEY_NORMAL,vtNormal))
{
return FALSE;
}
m_pXDataMap->GetAt(KEY_CROSS,nStyle);
dLen /= 2.0;
switch(nStyle)
{
case TDb::eOldCbotHorEqualCross:
case TDb::eCbotHorEqualCross:
{
BOOL bIncline = FALSE;
m_pXDataMap->GetAt(KEY_INCLINE_FIT, bIncline);
if (bIncline)
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
m_pXDataMap->GetAt(KEY_MINBR,vtPreCross);
}
else
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtNormal = vtDir;
vtNormal.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
}
vtPreCross = vtDir;
vtPreCross.rotateBy(PI / 2.0,vtNormal);
}
vtDir.normalize();
vtPreCross.normalize();
ptGeS = ptGeM - vtDir * dLen;
ptGeE = ptGeM + vtDir * dLen;
ptGeTop = ptGeM + vtPreCross * dLen;
ptGeDown = ptGeM - vtPreCross * dLen;
break;
}
case TDb::eCrossForSpace:
{
m_pXDataMap->GetAt(KEY_MAJNOR,vtMajNor);
m_pXDataMap->GetAt(KEY_MINNOR,vtMinNor);
m_pXDataMap->GetAt(KEY_H,dH);
vtMajNor.normalize();
vtMinNor.normalize();
vtPreCross = vtMajNor;
ptGeS = ptGeM - vtMinNor*dLen - vtMajNor*dH/2;
ptGeE = ptGeM + vtMinNor*dLen - vtMajNor*dH/2;
ptGeTop = ptGeM - vtMajNor*dLen - vtMinNor*dH/2;
ptGeDown = ptGeM + vtMajNor*dLen - vtMinNor*dH/2;
break;
}
default:
break;
}
AcDbObjectId id1,id2,id3,id4;
double dDis1 = ptCon.distanceTo(ptGeS);
double dDis2 = ptCon.distanceTo(ptGeE);
double dDis3 = ptCon.distanceTo(ptGeTop);
double dDis4 = ptCon.distanceTo(ptGeDown);
if (dDis1 < 1.e-3 ||
dDis2 < 1.e-3 ||
dDis3 < 1.e-3 ||
dDis4 < 1.e-3 )
{
//判断点是否在接口对象上
vtDir = ptCon - ptGeM;
BOOL bSuc = FALSE;
BOOL bSign = FALSE;
if (m_pXDataMap->GetAt(KEY_IDCNT1,id1))
{
bSuc = MakesureInterfaceValidate(id1,ptCon,vtDir,pipeInterface);
if (bSuc)
{
return bSuc;
}
bSign = TRUE;
}
if (m_pXDataMap->GetAt(KEY_IDCNT2,id2))
{
bSuc = MakesureInterfaceValidate(id2,ptCon,vtDir,pipeInterface);
if (bSuc)
{
return bSuc;
}
bSign = TRUE;
}
if (m_pXDataMap->GetAt(KEY_IDCNT3,id3))
{
bSuc = MakesureInterfaceValidate(id3,ptCon,vtDir,pipeInterface);
if (bSuc)
{
return bSuc;
}
bSign = TRUE;
}
if (m_pXDataMap->GetAt(KEY_IDCNT4,id4))
{
bSuc = MakesureInterfaceValidate(id4,ptCon,vtDir,pipeInterface);
if (bSuc)
{
return bSuc;
}
bSign = TRUE;
}
if (bSign)
{
return bSuc;
}
if (dDis1 < 1.e-3)
{
vtDir = ptGeS - ptGeM;
pipeInterface.SetOutDir(vtDir);
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
pipeInterface.SetPosition(ptGeS);
}
if (dDis2 < 1.e-3)
{
vtDir = ptGeE - ptGeM;
pipeInterface.SetOutDir(vtDir);
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
pipeInterface.SetPosition(ptGeE);
}
if (dDis3 < 1.e-3)
{
vtDir = ptGeTop - ptGeM;
pipeInterface.SetOutDir(vtDir);
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
pipeInterface.SetPosition(ptGeTop);
}
if (dDis4 < 1.e-3)
{
vtDir = ptGeDown - ptGeM;
pipeInterface.SetOutDir(vtDir);
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
pipeInterface.SetPosition(ptGeDown);
}
return TRUE;
}
}
return FALSE;
}
BOOL TEImpCabCross::HasInterface(const AcGePoint3d& ptCon,const AcGeVector3d& vtDir)
{
if (m_pXDataMap != NULL)
{
AcGePoint3d ptGeM,ptGeS,ptGeE,ptGeTop,ptGeDown;
AcGeVector3d vtDir,vtNormal,vtMajNor,vtMinNor,vtPreCross;
double dLen = 0.0,dH = 0.0;
int nStyle = 0;
if (!m_pXDataMap->GetAt(KEY_MID,ptGeM) ||
!m_pXDataMap->GetAt(KEY_L,dLen) ||
!m_pXDataMap->GetAt(KEY_NORMAL,vtNormal))
{
return FALSE;
}
m_pXDataMap->GetAt(KEY_CROSS,nStyle);
dLen /= 2.0;
switch(nStyle)
{
case TDb::eOldCbotHorEqualCross:
case TDb::eCbotHorEqualCross:
{
BOOL bIncline = FALSE;
m_pXDataMap->GetAt(KEY_INCLINE_FIT, bIncline);
if (bIncline)
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
m_pXDataMap->GetAt(KEY_MINBR,vtPreCross);
}
else
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtNormal = vtDir;
vtNormal.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
}
vtPreCross = vtDir;
vtPreCross.rotateBy(PI / 2.0,vtNormal);
}
vtDir.normalize();
vtPreCross.normalize();
ptGeS = ptGeM - vtDir * dLen;
ptGeE = ptGeM + vtDir * dLen;
ptGeTop = ptGeM + vtPreCross * dLen;
ptGeDown = ptGeM - vtPreCross * dLen;
break;
}
case TDb::eCrossForSpace:
{
m_pXDataMap->GetAt(KEY_MAJNOR,vtMajNor);
m_pXDataMap->GetAt(KEY_MINNOR,vtMinNor);
m_pXDataMap->GetAt(KEY_H,dH);
vtMajNor.normalize();
vtMinNor.normalize();
vtPreCross = vtMajNor;
ptGeS = ptGeM - vtMinNor*dLen - vtMajNor*dH/2;
ptGeE = ptGeM + vtMinNor*dLen - vtMajNor*dH/2;
ptGeTop = ptGeM - vtMajNor*dLen - vtMinNor*dH/2;
ptGeDown = ptGeM + vtMajNor*dLen - vtMinNor*dH/2;
break;
}
default:
break;
}
double dDis1 = ptCon.distanceTo(ptGeS);
double dDis2 = ptCon.distanceTo(ptGeE);
double dDis3 = ptCon.distanceTo(ptGeTop);
double dDis4 = ptCon.distanceTo(ptGeDown);
if (dDis1 < 1.e-3 ||
dDis2 < 1.e-3 ||
dDis3 < 1.e-3 ||
dDis4 < 1.e-3)
{
AcGeVector3d vtT = ptCon - ptGeM;
if (vtT.isParallelTo(vtDir) || (vtT.isParallelTo(vtPreCross)))
{
return TRUE;
}
}
}
return FALSE;
}
int TEImpCabCross::GetInterfaceCount() const
{
return 4;
}
BOOL TEImpCabCross::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
{
if ( !idConnect.isValid() )
return FALSE;
BOOL bSuccess = FALSE;
int nStyle;
if (m_pXDataMap != NULL)
{
AcGePoint3d ptGeM,ptGeS,ptGeE,ptGeTop,ptGeDown;
AcGeVector3d vtDir,vtNormal,vtMajNor,vtMinNor;
double dLen = 0.0,dH = 0.0;
if (!m_pXDataMap->GetAt(KEY_MID,ptGeM) ||
!m_pXDataMap->GetAt(KEY_L,dLen) ||
!m_pXDataMap->GetAt(KEY_NORMAL,vtNormal))
{
return Acad::eKeyNotFound;
}
m_pXDataMap->GetAt(KEY_CROSS,nStyle);
dLen /= 2.0;
switch(nStyle)
{
case TDb::eOldCbotHorEqualCross:
case TDb::eCbotHorEqualCross:
{
AcGeVector3d vtPreCross;
BOOL bIncline = FALSE;
m_pXDataMap->GetAt(KEY_INCLINE_FIT, bIncline);
if (bIncline)
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
m_pXDataMap->GetAt(KEY_MINBR,vtPreCross);
}
else
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtNormal = vtDir;
vtNormal.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
}
vtPreCross = vtDir;
vtPreCross.rotateBy(PI / 2.0,vtNormal);
}
vtDir.normalize();
vtPreCross.normalize();
ptGeS = ptGeM - vtDir * dLen;
ptGeE = ptGeM + vtDir * dLen;
ptGeTop = ptGeM + vtPreCross * dLen;
ptGeDown = ptGeM - vtPreCross * dLen;
break;
}
case TDb::eCrossForSpace:
{
m_pXDataMap->GetAt(KEY_MAJNOR,vtMajNor);
m_pXDataMap->GetAt(KEY_MINNOR,vtMinNor);
m_pXDataMap->GetAt(KEY_H,dH);
vtMajNor.normalize();
vtMinNor.normalize();
ptGeS = ptGeM - vtMinNor*dLen - vtMajNor*dH/2;
ptGeE = ptGeM + vtMinNor*dLen - vtMajNor*dH/2;
ptGeTop = ptGeM - vtMajNor*dLen - vtMinNor*dH/2;
ptGeDown = ptGeM + vtMajNor*dLen - vtMinNor*dH/2;
ptGeM -= vtMajNor*dH/2 + vtMinNor*dH/2;
break;
}
default:
break;
}
double dDis1 = ptConnect.distanceTo(ptGeS);
double dDis2 = ptConnect.distanceTo(ptGeE);
double dDis3 = ptConnect.distanceTo(ptGeTop);
double dDis4 = ptConnect.distanceTo(ptGeDown);
if (dDis1 < 1.e-3 || dDis2 < 1.e-3 || dDis3 < 1.e-3 || dDis4 < 1.e-3)
{
AcGeVector3d vtT = ptConnect - ptGeM;
AcDbEntity* pEnt = NULL;
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,idConnect,AcDb::kForRead))
{
TDbPipeBase* pPipe = TDbPipeBase::cast(pEnt);
if (pPipe != NULL)
{
if (pPipe->HasInterface(ptConnect,vtT))
{
if (dDis1 < 1.e-3) m_pXDataMap->SetAt(KEY_IDCNT1,idConnect);
if (dDis2 < 1.e-3) m_pXDataMap->SetAt(KEY_IDCNT2,idConnect);
if (dDis3 < 1.e-3) m_pXDataMap->SetAt(KEY_IDCNT3,idConnect);
if (dDis4 < 1.e-3) m_pXDataMap->SetAt(KEY_IDCNT4,idConnect);
bSuccess = TRUE;
}
}
TDbFittingBase* pFitting = TDbFittingBase::cast(pEnt);
if (pFitting != NULL)
{
if (pFitting->HasInterface(ptConnect,vtT))
{
if (dDis1 < 1.e-3) m_pXDataMap->SetAt(KEY_IDCNT1,idConnect);
if (dDis2 < 1.e-3) m_pXDataMap->SetAt(KEY_IDCNT2,idConnect);
if (dDis3 < 1.e-3) m_pXDataMap->SetAt(KEY_IDCNT3,idConnect);
if (dDis4 < 1.e-3) m_pXDataMap->SetAt(KEY_IDCNT4,idConnect);
bSuccess = TRUE;
}
}
pEnt->close();
}
}
}
return bSuccess;
}
BOOL TEImpCabCross::RemoveInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
{
//浅层次删除; 命名字典中的关系,需要外面移除关系,只移除内部关系
AcDbObjectId id1,id2,id3,id4;
if (m_pXDataMap != NULL)
{
m_pXDataMap->GetAt(KEY_IDCNT1,id1);
m_pXDataMap->GetAt(KEY_IDCNT2,id2);
m_pXDataMap->GetAt(KEY_IDCNT3,id3);
m_pXDataMap->GetAt(KEY_IDCNT4,id4);
AcDbObjectId idNull;
BOOL bRemoved = FALSE;
if (id1 == idConnect)
{
m_pXDataMap->SetAt(KEY_IDCNT1,idNull);
bRemoved = TRUE;
}
else if (id2 == idConnect)
{
m_pXDataMap->SetAt(KEY_IDCNT2,idNull);
bRemoved = TRUE;
}
else if (id3 == idConnect)
{
m_pXDataMap->SetAt(KEY_IDCNT3,idNull);
bRemoved = TRUE;
}
else if (id4 == idConnect)
{
m_pXDataMap->SetAt(KEY_IDCNT4,idNull);
bRemoved = TRUE;
}
return bRemoved;
}
return FALSE;
}
BOOL TEImpCabCross::NotifyInterfaceToModify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
{
BOOL bMsgTranslate = FALSE;
//接口更改通知
TDb::InterfaceOper eOper = iModiMsg.GetInterfaceOper();
switch(eOper)
{
case TDb::eMoveGripPoint:
{
bMsgTranslate = OnMoveGripPointMsgNotify(iModiMsg,iModiMsgs);
break;
}
case TDb::eTransformBy:
{
bMsgTranslate = OnTransformByMsgNotify(iModiMsg,iModiMsgs);
break;
}
case TDb::eSize:
{
bMsgTranslate = OnSizeMsgNotify(iModiMsg,iModiMsgs);
break;
}
default:
break;
}
if (m_pOwnerEnt != NULL) m_pOwnerEnt->recordGraphicsModified();
return bMsgTranslate;
}
BOOL TEImpCabCross::OnSizeMsgNotify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
{
//尺寸更改涉及到相关接口的更改
return FALSE;
}
BOOL TEImpCabCross::MakeCurves(TComplexCurve& cplCurve) const
{
int nNum = MakeCurvesBase(cplCurve);
if (cplCurve.length() > 0 && m_pXDataMap != NULL)
{
// 是否显示连接线
int nCnt = -1;
m_pXDataMap->GetAt(KEY_SHOWCNTLINE,nCnt);
if (nCnt == 0)
{
int nSize = cplCurve.length();
NoneConectLineIfNeed(cplCurve);
nSize -= cplCurve.length();
nNum -= nSize;
}
// 设置边线宽
double dWidth = 0.0;
m_pXDataMap->GetAt(KEY_EDAGEWIDTH,dWidth);
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int j = 0;j < nNum;j++)
{
el = cplCurve[j];
el.dWidth = dWidth;
cplCurve.setAt(j,el);
}
// 设置边线颜色
int nColor = -1;
if (m_pXDataMap->GetAt(KEY_BORLINECOLOR,nColor))
{
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int j = 0;j < nNum;j++)
{
el = cplCurve[j];
el.nColorIndex = nColor;
cplCurve.setAt(j,el);
}
}
return TRUE;
}
return FALSE;
}
int TEImpCabCross::MakeCurvesBase(TComplexCurve& cplCurve) const
{
int nNum = 0;
if (m_pXDataMap != NULL)
{
AcGeVector3d vtNor;
int nCrossStyle = 0;
m_pXDataMap->GetAt(KEY_NORMAL,vtNor);
m_pXDataMap->GetAt(KEY_CROSS,nCrossStyle);
vtNor.normalize();
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNor);
if (nCrossStyle == TDb::eCrossForSpace)
{
nNum = MakeCurvesForSpace(cplCurve);
}
if (nCrossStyle == TDb::eCbotHorEqualCross ||
nCrossStyle == TDb::eOldCbotHorEqualCross)
{
if (line.isPerpendicularTo(AcGePlane::kXYPlane))//Z轴法向量
{
nNum = MakeCurvesZNor(cplCurve);
}
else // 其他
{
nNum = MakeCurvesNoZNor(cplCurve);
}
}
}
return nNum;
}
int TEImpCabCross::MakeCurvesZNor(TComplexCurve& cplCurve) const
{
int nNum = 0;
/************************************************************************/
/* ptGes
12 +----+13
| |
11 + + 14
10 / \ 15 (16)
9 +---+ +---+ 0 ---------- vtPreCross
ptDown | | ptTop |
8 +---+ +---+ 1 |
7 \ / 2 |
6 + + 3 ↓vtDir
| |
5 +----+ 4
ptGeE
/************************************************************************/
AcGePoint3d ptGeM;
AcGeVector3d vtNormal,vtDir;
AcGeVector3d vtBrDir; // 分支向量 add by wzh 2012/11/20
int nCover = 0;
double dHeight = 0.0,dB = 0.0,dLen = 0.0;
m_pXDataMap->GetAt(KEY_MID,ptGeM);
m_pXDataMap->GetAt(KEY_L,dLen);
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
m_pXDataMap->GetAt(KEY_MINBR,vtBrDir); //
m_pXDataMap->GetAt(KEY_B,dB);
m_pXDataMap->GetAt(KEY_H,dHeight);
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal);
m_pXDataMap->GetAt(KEY_COVER,nCover);
// 变径四通 add by sps 2012/12/19
BOOL bTransCross = FALSE; // 变径四通
double dMajB(0.0), dMinB(0.0); // 主次分支宽度
double dB3(0.0),dB4(0.0); //B3,B4宽度
m_pXDataMap->GetAt(KEY_TRANS_FIT, bTransCross);
if (bTransCross)
{
// m_pXDataMap->GetAt(KEY_MAJBR_B, dMajB);
// m_pXDataMap->GetAt(KEY_MINBR_B, dMinB);
m_pXDataMap->GetAt(KEY_DB1,dMajB);//KEY_MAJBR_B == KEY_B1
m_pXDataMap->GetAt(KEY_DB2,dMinB);//KEY_MINBR_B == KEY_B2
m_pXDataMap->GetAt(KEY_DB3,dB3);
m_pXDataMap->GetAt(KEY_DB4,dB4);
if (dMajB == 0)
{
m_pXDataMap->GetAt(KEY_MAJBR_B, dMajB);
m_pXDataMap->SetAt(KEY_DB1, dMajB);
}
if (dMinB == 0)
{
m_pXDataMap->GetAt(KEY_MINBR_B, dMinB);
m_pXDataMap->SetAt(KEY_DB2, dMinB);
}
//兼容以前版本
if (dB3 == 0)
{
dB3 = dMajB;
m_pXDataMap->SetAt(KEY_DB3, dB3);
}
if (dB4 == 0)
{
dB4 = dMinB;
m_pXDataMap->SetAt(KEY_DB4,dB4);
}
}
dLen /= 2;
int nLinNum = 0;
AcGePoint3d ptGe[17];
double dAngle = PI / 2.0;
AcGeVector3d vtPreCross = vtDir;
vtPreCross.rotateBy(dAngle,vtNormal);
vtDir.normalize();
vtBrDir.normalize();
vtPreCross.normalize();
// 斜向四通 add by wzh 2012/11/19
if (!vtDir.isParallelTo(vtBrDir) && !vtDir.isPerpendicularTo(vtBrDir))
{
nNum = makeCurvesForIncline(cplCurve);
return nNum;
}
/////////////////////////////////
m_pXDataMap->SetAt(KEY_MINBR,vtPreCross);//axc add 2013-10-24
// 四个端点
AcGePoint3d ptGeS = ptGeM - vtDir * dLen;
AcGePoint3d ptGeE = ptGeM + vtDir * dLen;
AcGePoint3d ptGeTop = ptGeM + vtPreCross * dLen;
AcGePoint3d ptGeDown = ptGeM - vtPreCross * dLen;
//axc add 2013-12-03
m_pXDataMap->SetAt(KEY_CONNECT_PT1,ptGeS);
m_pXDataMap->SetAt(KEY_CONNECT_PT2,ptGeE);
m_pXDataMap->SetAt(KEY_CONNECT_PT3,ptGeTop);
m_pXDataMap->SetAt(KEY_CONNECT_PT4,ptGeDown);
double dTemp(0.0);
//变径四通 add by sps 2012/12/19
if (bTransCross)
{
ptGe[13] = ptGeS + vtPreCross * (dMajB / 2.0);//B1
ptGe[12] = ptGeS - vtPreCross * (dMajB / 2.0);//B1
//ptGe[4] = ptGeE + vtPreCross * (dMajB / 2.0);
//ptGe[5] = ptGeE - vtPreCross * (dMajB / 2.0);
ptGe[4] = ptGeE + vtPreCross * (dB3 / 2.0);//B3
ptGe[5] = ptGeE - vtPreCross * (dB3 / 2.0);//B3
ptGe[1] = ptGeTop + vtDir * (dMinB / 2.0);//B2
ptGe[0] = ptGeTop - vtDir * (dMinB / 2.0);//B2
//ptGe[8] = ptGeDown + vtDir * (dMinB / 2.0);
//ptGe[9] = ptGeDown - vtDir * (dMinB / 2.0);
ptGe[8] = ptGeDown + vtDir * (dB4 / 2.0);//B4
ptGe[9] = ptGeDown - vtDir * (dB4 / 2.0);//B4
ptGe[16] = ptGe[0];
double dTemp = 0.5 * (dLen - 0.5 * dMajB);
ptGe[15] = ptGe[0] - vtPreCross * dTemp;
ptGe[10] = ptGe[9] + vtPreCross * dTemp;
//dTemp = 0.5 * (dLen - 0.5 * dMajB);
ptGe[2] = ptGe[1] - vtPreCross * dTemp;
ptGe[7] = ptGe[8] + vtPreCross * dTemp;
dTemp = 0.5 * (dLen - 0.5 * dMajB);
ptGe[3] = ptGe[4] - vtDir * dTemp;
ptGe[14] = ptGe[13] + vtDir * dTemp;
//dTemp = 0.5 * (dLen - 0.5 * dMinB);
ptGe[6] = ptGe[5] - vtDir * dTemp;
ptGe[11] = ptGe[12] + vtDir * dTemp;
}
else
{
ptGe[13] = ptGeS + vtPreCross * (dB / 2.0);
ptGe[12] = ptGeS - vtPreCross * (dB / 2.0);
ptGe[4] = ptGeE + vtPreCross * (dB / 2.0);
ptGe[5] = ptGeE - vtPreCross * (dB / 2.0);
ptGe[1] = ptGeTop + vtDir * (dB / 2.0);
ptGe[0] = ptGeTop - vtDir * (dB / 2.0);
ptGe[8] = ptGeDown + vtDir * (dB / 2.0);
ptGe[9] = ptGeDown - vtDir * (dB / 2.0);
ptGe[16] = ptGe[0];
dTemp = 0.5 * (dLen - 0.5 * dB);
ptGe[15] = ptGe[0] - vtPreCross * dTemp;
ptGe[10] = ptGe[9] + vtPreCross * dTemp;
dTemp = 0.5 * (dLen - 0.5 * dB);
ptGe[2] = ptGe[1] - vtPreCross * dTemp;
ptGe[7] = ptGe[8] + vtPreCross * dTemp;
dTemp = 0.5 * (dLen - 0.5 * dB);
ptGe[3] = ptGe[4] - vtDir * dTemp;
ptGe[14] = ptGe[13] + vtDir * dTemp;
dTemp = 0.5 * (dLen - 0.5 * dB);
ptGe[6] = ptGe[5] - vtDir * dTemp;
ptGe[11] = ptGe[12] + vtDir * dTemp;
}
nNum = 16;
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
// 曲线风格
int nModel = -1;
m_pXDataMap->GetAt(KEY_CORNER,nModel);
if (nModel == TDb::eArc || nModel == TDb::eDblArc)
{
// 四通变径 add by sps 2012/12/19
AcGePoint3d ptBase23, ptBase67,ptBaseAB, ptBaseEF;
AcGeLine3d lineL, lineR;
if (bTransCross)
{
lineR.set(ptGe[4], -vtDir);
lineL.set(ptGe[1], -vtPreCross);
lineL.intersectWith(lineR, ptBase23);
lineL.set(ptGe[5], -vtDir);
lineR.set(ptGe[8], vtPreCross);
lineL.intersectWith(lineR, ptBase67);
lineR.set(ptGe[12], vtDir);
lineL.set(ptGe[9], vtPreCross);
lineL.intersectWith(lineR, ptBaseAB);
lineL.set(ptGe[13], vtDir);
lineR.set(ptGe[16], -vtPreCross);
lineL.intersectWith(lineR, ptBaseEF);
double dDis1 = ptBase23.distanceTo(ptGe[1]);
double dDis2 = ptBase23.distanceTo(ptGe[4]);
if (dDis2 < dDis1)
dDis1 = dDis2;
ptGe[2] = ptBase23 + 0.5 * dDis1 * vtPreCross;
ptGe[3] = ptBase23 + 0.5 * dDis1 * vtDir;
dDis1 = ptBase67.distanceTo(ptGe[5]);
dDis2 = ptBase67.distanceTo(ptGe[8]);
if (dDis2 < dDis1)
dDis1 = dDis2;
ptGe[6] = ptBase67 + 0.5 * dDis1 * vtDir;
ptGe[7] = ptBase67 - 0.5 * dDis1 * vtPreCross;
dDis1 = ptBaseAB.distanceTo(ptGe[9]);
dDis2 = ptBaseAB.distanceTo(ptGe[12]);
if (dDis2 < dDis1)
dDis1 = dDis2;
ptGe[10] = ptBaseAB - 0.5 * dDis1 * vtPreCross;
ptGe[11] = ptBaseAB - 0.5 * dDis1 * vtDir;
dDis1 = ptBaseEF.distanceTo(ptGe[13]);
dDis2 = ptBaseEF.distanceTo(ptGe[16]);
if (dDis2 < dDis1)
dDis1 = dDis2;
ptGe[14] = ptBaseEF - 0.5 * dDis1 * vtDir;
ptGe[15] = ptBaseEF + 0.5 * dDis1 * vtPreCross;
}
///////////////////////
for (int i = 0;i < nNum;i++)
{
el.ptGe[0] = ptGe[i];
el.ptGe[1] = ptGe[i + 1];
el.ptGe[2] = ptGe[i + 1];
cplCurve.append(el);
}
if (bTransCross)
{
el = cplCurve[2];
el.ptGe[1] = GetPolyCurMidPoint(ptGe[3], ptGe[2], ptBase23, PI / 2);
cplCurve.setAt(2,el);
el = cplCurve[6];
el.ptGe[1] = GetPolyCurMidPoint(ptGe[7], ptGe[6], ptBase67, PI / 2);
cplCurve.setAt(6,el);
el = cplCurve[10];
el.ptGe[1] = GetPolyCurMidPoint(ptGe[11], ptGe[10], ptBaseAB, PI / 2);
cplCurve.setAt(10,el);
el = cplCurve[14];
el.ptGe[1] = GetPolyCurMidPoint(ptGe[15], ptGe[14], ptBaseEF, PI / 2);
cplCurve.setAt(14,el);
}
else
{
el = cplCurve[2];
el.ptGe[1] = GetPolyCurMidPoint(ptGe[2],ptGe[3],ptGeM);
cplCurve.setAt(2,el);
el = cplCurve[6];
el.ptGe[1] = GetPolyCurMidPoint(ptGe[6],ptGe[7],ptGeM);
cplCurve.setAt(6,el);
el = cplCurve[10];
el.ptGe[1] = GetPolyCurMidPoint(ptGe[10],ptGe[11],ptGeM);
cplCurve.setAt(10,el);
el = cplCurve[14];
el.ptGe[1] = GetPolyCurMidPoint(ptGe[14],ptGe[15],ptGeM);
cplCurve.setAt(14,el);
}
}
else if (nModel == TDb::eNLine)
{
dTemp = dLen - dB / 2;
ptGe[2] = ptGe[1] - vtPreCross * dTemp;
ptGe[3] = ptGe[4];
ptGe[4] = ptGe[5];
ptGe[5] = ptGe[4] - vtDir * dTemp;
ptGe[6] = ptGe[8];
ptGe[7] = ptGe[9];
ptGe[8] = ptGe[7] + vtPreCross * dTemp;
ptGe[9] = ptGe[12];
ptGe[10] = ptGe[13];
ptGe[11] = ptGe[10] + vtDir * dTemp;
ptGe[12] = ptGe[0];
nNum = 12;
for (int i = 0;i < nNum;i++)
{
el.ptGe[0] = ptGe[i];
el.ptGe[1] = ptGe[i + 1];
el.ptGe[2] = ptGe[i + 1];
cplCurve.append(el);
}
}
else
{
// 直线风格
for (int i = 0;i < nNum;i++)
{
el.ptGe[0] = ptGe[i];
el.ptGe[1] = ptGe[i + 1];
el.ptGe[2] = ptGe[i + 1];
cplCurve.append(el);
}
}
return nNum;
}
int TEImpCabCross::MakeCurvesForSpace(TComplexCurve& cplCurve) const
{
AcGePoint3d ptM,ptL,ptR;
double dTemp,dH,dLen,dB;
AcGeVector3d vtMinDir,vtTemp;
m_pXDataMap->GetAt(KEY_MID,ptM);
m_pXDataMap->GetAt(KEY_L,dLen);
m_pXDataMap->GetAt(KEY_B,dB);
m_pXDataMap->GetAt(KEY_H,dH);
//m_pXDataMap->GetAt(KEY_MAJNOR,vtMinDir);
m_pXDataMap->GetAt(KEY_MAINDIR,vtMinDir); //axc alter 2014-01-24
dTemp = (dLen - dH) / 4;
vtTemp = vtMinDir;
vtTemp.rotateBy(PI/2,AcGeVector3d::kZAxis);
vtMinDir.normalize();
vtTemp.normalize();
ptL = ptM - vtMinDir*dLen/2;
ptR = ptM + vtMinDir*dLen/2;
AcGePoint3d arpts[6];
arpts[0] = ptL - vtTemp*dB/2;
arpts[1] = arpts[0] + vtMinDir*dTemp;
arpts[2] = arpts[1] + vtMinDir*dTemp;
arpts[3] = arpts[2] + vtMinDir*dH;
arpts[4] = arpts[3] + vtMinDir*dTemp;
arpts[5] = arpts[4] + vtMinDir*dTemp;
AcGePoint3d arpts2[6];
int i = 0;
for (i = 0;i < 6;i++)
{
arpts2[i] = arpts[i] + vtTemp*dB;
}
int nNum = 6;
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
el.nColorIndex = m_pOwnerEnt->colorIndex();
for (i = 0;i < nNum;i++)
{
el.ptGe[0] = arpts[i];
el.ptGe[1] = arpts2[i];
el.ptGe[2] = arpts2[i];
cplCurve.append(el);
}
el.ptGe[0] = arpts[0];
el.ptGe[1] = arpts[5];
el.ptGe[2] = arpts[5];
cplCurve.append(el);
nNum++;
el.ptGe[0] = arpts2[0];
el.ptGe[1] = arpts2[5];
el.ptGe[2] = arpts2[5];
cplCurve.append(el);
nNum++;
return nNum;
}
//
int TEImpCabCross::makeCurvesForIncline(TComplexCurve& cplCurve) const
{
/************************************************************************/
/*
斜向系统示意图
1
Top +
+ \
(12) 0 + \
\ +
+ \
11 \ \ 2
10 +-----+----+ +-----+----+ 3
| |
ptGeS + + + ptGeE
| ptMid |
9 +------+------+ +---+---+ 4
8 \ \ 5
\ +
------> + \
vtMinBr \ + 6
\ +
+ Down
7
*/
/************************************************************************/
if (m_pXDataMap == NULL)
{
return 0;
}
int nNum = 0;
AcGePoint3d ptGeM;
AcGeVector3d vtMajBr, vtMinBr, vtMajNor;
AcGeVector3d vtMajVer, vtMinVer;
int nCover = 0;
double dH = 0.0, dB = 0.0, dL = 0.0;
double dB3 = 0,dB4 = 0;//变径斜向四通B3,B4宽度
m_pXDataMap->GetAt(KEY_MID, ptGeM);
m_pXDataMap->GetAt(KEY_MAJBR, vtMajBr);
m_pXDataMap->GetAt(KEY_MINBR, vtMinBr);
m_pXDataMap->GetAt(KEY_NORMAL,vtMajNor);
m_pXDataMap->GetAt(KEY_B, dB);
m_pXDataMap->GetAt(KEY_H, dH);
m_pXDataMap->GetAt(KEY_L, dL);
m_pXDataMap->GetAt(KEY_COVER, nCover);
// 变径斜向四通 add by sps 2012/12/19
BOOL bTransCross = FALSE; // 变径斜向四通
double dMajB(0.0), dMinB(0.0); // 主次分支宽度
m_pXDataMap->GetAt(KEY_TRANS_FIT, bTransCross);
if (bTransCross)
{
// m_pXDataMap->GetAt(KEY_MAJBR_B, dMajB);
// m_pXDataMap->GetAt(KEY_MINBR_B, dMinB);
//axc add 2014-08-06 增加四通的各个不同宽度,方便修改某一宽度后进行变化
m_pXDataMap->GetAt(KEY_DB1, dMajB);//KEY_MAJBR_B == KEY_B1
m_pXDataMap->GetAt(KEY_DB2, dMinB);//KEY_MINBR_B == KEY_B2
m_pXDataMap->GetAt(KEY_DB3, dB3);
m_pXDataMap->GetAt(KEY_DB4, dB4);
//由四通变三通再变回四通时 KEY_B1,KEY_B2值被清空了
if (dMajB == 0)
{
m_pXDataMap->GetAt(KEY_MAJBR_B, dMajB);
m_pXDataMap->SetAt(KEY_DB1, dMajB);
}
if (dMinB == 0)
{
m_pXDataMap->GetAt(KEY_MINBR_B, dMinB);
m_pXDataMap->SetAt(KEY_DB2, dMinB);
}
//兼容以前版本
if (dB3 == 0)
{
dB3 = dMajB;
m_pXDataMap->SetAt(KEY_DB3, dB3);
}
if (dB4 == 0)
{
dB4 = dMinB;
m_pXDataMap->SetAt(KEY_DB4,dB4);
}
}
vtMajBr.normalize();
vtMinBr.normalize();
vtMajNor.normalize();
// 修正主向量
double dAngle = vtMajBr.angleTo(vtMinBr);
double dAngleT = dAngle * 180 / PI; //cs
AcGeVector3d vtIncline = vtMinBr;
vtIncline.rotateBy(dAngle, vtMajNor);
vtIncline.normalize();
if (!vtIncline.isParallelTo(vtMajBr))
{
vtIncline = vtMinBr;
vtIncline.rotateBy(PI - dAngle, vtMajNor);
vtIncline.normalize();
}
vtMajBr = vtIncline;
// 端点
AcGePoint3d ptGeS = ptGeM - vtMinBr*(dL/2);
AcGePoint3d ptGeE = ptGeM + vtMinBr*(dL/2);
AcGePoint3d ptGeTop = ptGeM + vtMajBr*(dL/2);
AcGePoint3d ptGeDown = ptGeM - vtMajBr*(dL/2);
//axc add 2013-12-03
m_pXDataMap->SetAt(KEY_CONNECT_PT1,ptGeTop);
m_pXDataMap->SetAt(KEY_CONNECT_PT2,ptGeDown);
m_pXDataMap->SetAt(KEY_CONNECT_PT3,ptGeE);
m_pXDataMap->SetAt(KEY_CONNECT_PT4,ptGeS);
// 顶点
AcGePoint3d arPtVer[17]; // 单线/双线(13个点), 单弧/双弧(17个点)
vtMajVer = vtMajBr;
vtMajVer.rotateBy(PI/2, vtMajNor);
vtMinVer = vtMinBr;
vtMinVer.rotateBy(PI/2, vtMajNor);
vtMajVer.normalize();
vtMinVer.normalize();
if (bTransCross)
{
arPtVer[10] = ptGeS + vtMinVer*(dB4/2);
arPtVer[9] = arPtVer[10] - vtMinVer*dB4;
arPtVer[3] = ptGeE + vtMinVer*(dMinB/2);
arPtVer[4] = arPtVer[3] - vtMinVer*dMinB;
arPtVer[0] = ptGeTop + vtMajVer*(dMajB/2);
arPtVer[1] = arPtVer[0] - vtMajVer*dMajB;
arPtVer[7] = arPtVer[0] - vtMajBr*dL;
arPtVer[6] = arPtVer[7] - vtMajVer*dMajB;
//修正arPtVer[6],arPtVer[7]点
AcGeVector3d vtDir = arPtVer[7] - arPtVer[6];
vtDir.normalize();
arPtVer[7] = ptGeDown + vtDir * (dB3 / 2);
arPtVer[6] = ptGeDown - vtDir * (dB3 / 2);
// arPtVer[10] = ptGeS + vtMinVer*(dMinB/2);
// arPtVer[9] = arPtVer[10] - vtMinVer*dMinB;
// arPtVer[3] = arPtVer[10] + vtMinBr*dL;
// arPtVer[4] = arPtVer[9] + vtMinBr*dL;
//
// arPtVer[0] = ptGeTop + vtMajVer*(dMajB/2);
// arPtVer[1] = arPtVer[0] - vtMajVer*dMajB;
// arPtVer[7] = arPtVer[0] - vtMajBr*dL;
// arPtVer[6] = arPtVer[7] - vtMajVer*dMajB;
}
else
{
arPtVer[10] = ptGeS + vtMinVer*(dB/2);
arPtVer[9] = arPtVer[10] - vtMinVer*dB;
arPtVer[3] = arPtVer[10] + vtMinBr*dL;
arPtVer[4] = arPtVer[9] + vtMinBr*dL;
arPtVer[0] = ptGeTop + vtMajVer*(dB/2);
arPtVer[1] = arPtVer[0] - vtMajVer*dB;
arPtVer[7] = arPtVer[0] - vtMajBr*dL;
arPtVer[6] = arPtVer[7] - vtMajVer*dB;
}
arPtVer[12] = arPtVer[0];
AcGeLine3d line1, line2;
line1.set(arPtVer[10], vtMinBr);
line2.set(arPtVer[0], -vtMajBr);
line1.intersectWith(line2, arPtVer[11]);
line1.set(arPtVer[3], -vtMinBr);
line2.set(arPtVer[1], -vtMajBr);
line1.intersectWith(line2, arPtVer[2]);
line1.set(arPtVer[9], vtMinBr);
line2.set(arPtVer[7], vtMajBr);
line1.intersectWith(line2, arPtVer[8]);
line1.set(arPtVer[4], -vtMinBr);
line2.set(arPtVer[6], vtMajBr);
line1.intersectWith(line2, arPtVer[5]);
nNum = 12;
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
// 曲线风格
int nModel = -1;
m_pXDataMap->GetAt(KEY_CORNER,nModel);
if (nModel == TDb::eArc || nModel == TDb::eDblArc)
{
// 单弧/双弧
AcGePoint3d ptBase11 = arPtVer[11];
AcGePoint3d ptBase8 = arPtVer[8];
AcGePoint3d ptBase5 = arPtVer[5];
AcGePoint3d ptBase2 = arPtVer[2];
arPtVer[16] = arPtVer[0];
// 取最短距离
//double dSeg = (dL2 - dB)/2;
// LT
double dDis1110 = ptBase11.distanceTo(arPtVer[10]); //
double dDis110 = ptBase11.distanceTo(arPtVer[0]); //
if (dDis1110 < dDis110)
{
arPtVer[14] = TAuxTools::Mid(ptBase11, arPtVer[10]);
arPtVer[15] = ptBase11 + vtMajBr*(dDis1110/2);
}
else
{
arPtVer[15] = TAuxTools::Mid(ptBase11, arPtVer[0]);
arPtVer[14] = ptBase11 - vtMinBr*(dDis110/2);
}
arPtVer[13] = arPtVer[10];
arPtVer[12] = arPtVer[9];
// LB
double dDis89 = ptBase8.distanceTo(arPtVer[9]); //
double dDis87 = ptBase8.distanceTo(arPtVer[7]); //
if (dDis89 < dDis87)
{
arPtVer[11] = TAuxTools::Mid(ptBase8, arPtVer[9]);
arPtVer[10] = ptBase8 - vtMajBr*(dDis89/2);
}
else
{
arPtVer[10] = TAuxTools::Mid(ptBase8, arPtVer[7]);
arPtVer[11] = ptBase8 - vtMinBr*(dDis87/2);
}
arPtVer[9] = arPtVer[7];
arPtVer[8] = arPtVer[6];
// RB
double dDis56 = ptBase5.distanceTo(arPtVer[6]); //
double dDis54 = ptBase5.distanceTo(arPtVer[4]); //
if (dDis56 < dDis54)
{
arPtVer[7] = TAuxTools::Mid(ptBase5, arPtVer[6]);
arPtVer[6] = ptBase5 + vtMinBr*(dDis56/2);
}
else
{
arPtVer[6] = TAuxTools::Mid(ptBase5, arPtVer[4]);
arPtVer[7] = ptBase5 - vtMajBr*(dDis54/2);
}
arPtVer[5] = arPtVer[4];
arPtVer[4] = arPtVer[3];
// RT
double dDis23 = ptBase2.distanceTo(arPtVer[3]); //
double dDis21 = ptBase2.distanceTo(arPtVer[1]); //
if (dDis23 < dDis21)
{
arPtVer[3] = TAuxTools::Mid(ptBase2, arPtVer[3]);
arPtVer[2] = ptBase2 + vtMajBr*(dDis23/2);
}
else
{
arPtVer[2] = TAuxTools::Mid(ptBase2, arPtVer[1]);
arPtVer[3] = ptBase2 + vtMinBr*(dDis21/2);
}
nNum = 16;
for (int i = 0; i < nNum; ++i)
{
el.ptGe[0] = arPtVer[i];
el.ptGe[1] = arPtVer[i + 1];
el.ptGe[2] = arPtVer[i + 1];
cplCurve.append(el);
}
double dAng = (-vtMajBr).angleTo(-vtMinBr);
el = cplCurve[14];
el.ptGe[1] = GetPolyCurMidPoint(arPtVer[14], arPtVer[15], ptBase11, PI - dAng);
cplCurve.setAt(14,el);
el = cplCurve[10];
el.ptGe[1] = GetPolyCurMidPoint(arPtVer[10], arPtVer[11], ptBase8, dAng);
cplCurve.setAt(10,el);
el = cplCurve[6];
el.ptGe[1] = GetPolyCurMidPoint(arPtVer[6], arPtVer[7], ptBase5, PI - dAng);
cplCurve.setAt(6,el);
el = cplCurve[2];
el.ptGe[1] = GetPolyCurMidPoint(arPtVer[2], arPtVer[3], ptBase2, dAng);
cplCurve.setAt(2,el);
}
else if (nModel == TDb::eLine || nModel == TDb::eDblLine)
{
// 单线/双线
for (int i = 0; i < nNum; ++i)
{
el.ptGe[0] = arPtVer[i];
el.ptGe[1] = arPtVer[i + 1];
el.ptGe[2] = arPtVer[i + 1];
cplCurve.append(el);
}
}
return nNum;
}
AcGePoint3d TEImpCabCross::GetPolyCurMidPoint(const AcGePoint3d& pt1,const AcGePoint3d& pt2,const AcGePoint3d& ptGeM) const
{
AcDbLine line(pt1, pt2);
AcGePoint3d ptOnLine;
line.getClosestPointTo(ptGeM, ptOnLine);
AcGeVector3d vtT = ptOnLine - ptGeM;
vtT.normalize();
// 获取圆弧的圆心
double dL = pt1.distanceTo(pt2);
AcGePoint3d ptOri = ptOnLine + vtT * dL / 2;
double dR = ptOri.distanceTo(pt1);
return ptOri - vtT * dR;
}
int TEImpCabCross::MakeCurvesNoZNor(TComplexCurve& cplCurve) const
{
int nNum = 0;
/***********************************************************************
1 6 0 5 8
+-----+-----+ +-----+-----+ 4
| | | | | |
2 +-----+-----+--+--+-----+-----+ 3
7 10 11 9
************************************************************************/
AcGePoint3d ptGeM;
AcGeVector3d vtNormal,vtDir;
int nCover = 0;
double dHeight = 0.0,dB = 0.0,dLen = 0.0;
m_pXDataMap->GetAt(KEY_MID,ptGeM);
m_pXDataMap->GetAt(KEY_L,dLen);
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
m_pXDataMap->GetAt(KEY_B,dB);
m_pXDataMap->GetAt(KEY_H,dHeight);
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal);
m_pXDataMap->GetAt(KEY_COVER,nCover);
dLen /= 2;
int nLinNum = 0;
double dAngle = PI / 2.0;
AcGeVector3d vtPerRe = vtDir;
vtPerRe.rotateBy(dAngle,vtNormal);
vtPerRe.normalize();
vtDir.normalize();
AcGePoint3d* pVer = new AcGePoint3d[12];
if (pVer == NULL) return nNum;
pVer[2] = ptGeM - vtDir * dLen;
pVer[1] = ptGeM + vtPerRe * dHeight;
pVer[3] = ptGeM + vtDir * dLen;
pVer[4] = pVer[2] + vtPerRe * dHeight;
double dT = (dLen - dB / 2) / 2;
pVer[6] = pVer[1] + vtDir * dT;
pVer[7] = pVer[2] + vtDir * dT;
pVer[0] = pVer[6] + vtDir * dT;
pVer[10] = pVer[7] + vtDir * dT;
pVer[8] = pVer[4] - vtDir * dT;
pVer[9] = pVer[3] - vtDir * dT;
pVer[5] = pVer[8] - vtDir * dT;
pVer[11] = pVer[9] - vtDir * dT;
nNum = 5;
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int i = 0;i < nNum;i++)
{
el.ptGe[0] = pVer[i];
el.ptGe[1] = pVer[i + 1];
el.ptGe[2] = pVer[i + 1];
cplCurve.append(el);
}
el.ptGe[0] = pVer[6];
el.ptGe[1] = pVer[7];
el.ptGe[2] = pVer[7];
cplCurve.append(el);
el.ptGe[0] = pVer[8];
el.ptGe[1] = pVer[9];
el.ptGe[2] = pVer[9];
cplCurve.append(el);
el.ptGe[0] = pVer[10];
el.ptGe[1] = pVer[0];
el.ptGe[2] = pVer[0];
cplCurve.append(el);
el.ptGe[0] = pVer[11];
el.ptGe[1] = pVer[5];
el.ptGe[2] = pVer[5];
cplCurve.append(el);
if (nCover == TDb::eCover)
{
el.ptGe[0] = pVer[0];
el.ptGe[1] = pVer[5];
el.ptGe[2] = pVer[5];
cplCurve.append(el);
}
delete []pVer;
pVer = NULL;
return nNum;
}
void TEImpCabCross::GetCurvesInSideForSpace(TComplexCurve& compCurve) const
{
if (m_pXDataMap == NULL) return;
AcGePoint3d ptGeM,ptGeS,ptGeE,ptGeTop,ptGeDown;
AcGeVector3d vtMajNor,vtMinNor;
double dLen = 0.0,dH = 0.0;
m_pXDataMap->GetAt(KEY_MID,ptGeM);
m_pXDataMap->GetAt(KEY_MAJNOR,vtMajNor);
m_pXDataMap->GetAt(KEY_MINNOR,vtMinNor);
m_pXDataMap->GetAt(KEY_H,dH);
m_pXDataMap->GetAt(KEY_L,dLen);
vtMajNor.normalize();
vtMinNor.normalize();
dLen /= 2;
ptGeS = ptGeM - vtMinNor*dLen - vtMajNor*dH/2;
ptGeE = ptGeM + vtMinNor*dLen - vtMajNor*dH/2;
ptGeTop = ptGeM - vtMajNor*dLen - vtMinNor*dH/2;
ptGeDown = ptGeM + vtMajNor*dLen - vtMinNor*dH/2;
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
el.ptGe[0] = ptGeS;
el.ptGe[1] = ptGeE;
el.ptGe[2] = ptGeE;
el.gsMark = -1;
compCurve.append(el);
el.ptGe[0] = ptGeTop;
el.ptGe[1] = ptGeDown;
el.ptGe[2] = ptGeDown;
el.gsMark = -1;
compCurve.append(el);
}
void TEImpCabCross::GetCurvesInSideZNor(TComplexCurve& compCurve) const
{
if (m_pXDataMap == NULL) return;
//该函数用于处理遮挡关系时提供Polyline线;
AcGePoint3d ptGeM;
AcGeVector3d vtDir,vtNormal;
double dLen = 0.0,dB = 0.0;
if ( m_pXDataMap->GetAt(KEY_MID,ptGeM) &&
m_pXDataMap->GetAt(KEY_L,dLen) &&
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) &&
m_pXDataMap->GetAt(KEY_B,dB) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal))
{
dLen /= 2.0;
AcGeVector3d vtPreCross = vtDir;
// 2012/11/20 alter by wzh
AcGeVector3d vtMinBr;
m_pXDataMap->GetAt(KEY_MINBR, vtMinBr);
if (!vtDir.isParallelTo(vtMinBr) && !vtDir.isPerpendicularTo(vtMinBr))
{
// 斜向四通
vtPreCross = vtMinBr;
}
else
{
vtPreCross.rotateBy(PI / 2.0,vtNormal);
}
///////////////////////////
// vtPreCross.rotateBy(PI / 2.0,vtNormal); // 2012/11/20 comemnt by wzh
vtDir.normalize();
vtPreCross.normalize();
AcGePoint3d ptGeS = ptGeM - vtDir * dLen;
AcGePoint3d ptGeE = ptGeM + vtDir * dLen;
AcGePoint3d ptGeTop = ptGeM + vtPreCross * dLen;
AcGePoint3d ptGeBot = ptGeM - vtPreCross * dLen;
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
el.ptGe[0] = ptGeS;
el.ptGe[1] = ptGeE;
el.ptGe[2] = ptGeE;
el.gsMark = -1;
compCurve.append(el);
el.ptGe[0] = ptGeTop;
el.ptGe[1] = ptGeBot;
el.ptGe[2] = ptGeBot;
el.gsMark = -1;
compCurve.append(el);
}
}
void TEImpCabCross::GetCurvesInSideNoZNor(TComplexCurve& compCurve) const
{
TComplexCurve cplCurve;
int nNum = MakeCurvesNoZNor(cplCurve);
if (cplCurve.length() > 0)
{
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
int nSize = cplCurve.length();
for (int i = nNum;i < nSize;i++)
{
el = cplCurve.at(i);
el.gsMark = -1;
compCurve.append(el);
}
}
}
AcDbPolyline* TEImpCabCross::MakePolyCurve() const
{
AcDbPolyline* pPl = new AcDbPolyline;
TComplexCurve cplCurve;
int nNum = MakeCurvesBase(cplCurve);
int nStyle = -1;
m_pXDataMap->GetAt(KEY_CORNER,nStyle);
if (nStyle == TDb::eArc || nStyle == TDb::eDblArc)
{
FormatArcPolyline(pPl,cplCurve,nNum);
}
else
{
FormatPolyline(pPl,cplCurve,nNum);
}
if (pPl != NULL && pPl->numVerts() == 0)
{
delete pPl;
pPl = NULL;
}
return pPl;
}
void TEImpCabCross::FormatPolyline(AcDbPolyline*& pPl,TComplexCurve& cplCurve,int nNum) const
{
if (cplCurve.length() < 3)
{
return;
}
AcGePlane plan(cplCurve.at(0).ptGe[0],cplCurve.at(1).ptGe[0],cplCurve.at(2).ptGe[0]);
AcGePoint3d ptOrth = AcGePoint3d::kOrigin.orthoProject(plan);
plan.set(ptOrth,plan.normal());
double dEl = ptOrth.asVector().length();
if (!ptOrth.asVector().isCodirectionalTo(plan.normal()))
{
dEl *= -1.0;
}
for (int i = 0;i < nNum;i++)
{
pPl->addVertexAt(i,cplCurve.at(i).ptGe[0].convert2d(plan));
}
pPl->setClosed(Adesk::kTrue);
pPl->setElevation(dEl);
pPl->setNormal(plan.normal());
}
void TEImpCabCross::FormatArcPolyline(AcDbPolyline*& pPl,TComplexCurve& cplCurve,int nNum) const
{
if (cplCurve.length() < 3)
{
return;
}
AcGePlane plan(cplCurve.at(0).ptGe[0],cplCurve.at(1).ptGe[0],cplCurve.at(2).ptGe[0]);
AcGePoint3d ptOrth = AcGePoint3d::kOrigin.orthoProject(plan);
plan.set(ptOrth,plan.normal());
double dEl = ptOrth.asVector().length();
if (!ptOrth.asVector().isCodirectionalTo(plan.normal()))
{
dEl *= -1.0;
}
for (int i = 0;i < nNum;i++)
{
pPl->addVertexAt(i,cplCurve.at(i).ptGe[0].convert2d(plan));
}
pPl->setBulgeAt(2,tan(PI / 8));
pPl->setBulgeAt(6,tan(PI / 8));
pPl->setBulgeAt(10,tan(PI / 8));
pPl->setBulgeAt(14,tan(PI / 8));
pPl->setClosed(Adesk::kTrue);
pPl->setElevation(dEl);
pPl->setNormal(plan.normal());
}
BOOL TEImpCabCross::GetCurvesInSide(TComplexCurve& compCurve) const
{
int nShowCenLine = 0;
m_pXDataMap->GetAt(KEY_HASCENLINE,nShowCenLine);
if (nShowCenLine)
{
if (m_pXDataMap != NULL)
{
AcGeVector3d vtNor;
int nCrossType = 0;
m_pXDataMap->GetAt(KEY_NORMAL,vtNor);
m_pXDataMap->GetAt(KEY_CROSS,nCrossType);
vtNor.normalize();
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNor);
if (nCrossType == TDb::eCrossForSpace)
{
GetCurvesInSideForSpace(compCurve);
}
else
{
if (line.isPerpendicularTo(AcGePlane::kXYPlane))//Z轴法向量
{
GetCurvesInSideZNor(compCurve);
}
else // 其他
{
GetCurvesInSideNoZNor(compCurve);
}
}
}
if (compCurve.length() > 0)
{
// 设置中心线宽
double dWidth = 0.0;
m_pXDataMap->GetAt(KEY_CENLWIDTH,dWidth);
if (dWidth > 0)
{
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int j = 0;j < compCurve.length();j++)
{
el = compCurve[j];
el.dWidth = dWidth;
compCurve.setAt(j,el);
}
}
return TRUE;
}
}
return FALSE;
}
BOOL TEImpCabCross::MakePolyCurveFaces(AcDbVoidPtrArray& arFaces)
{
if (m_pXDataMap != NULL)
{
AcGeVector3d vtNor;
m_pXDataMap->GetAt(KEY_NORMAL,vtNor);
vtNor.normalize();
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNor);
if (line.isPerpendicularTo(AcGePlane::kXYPlane))//Z轴法向量
{
MakePolyCurveFaceZNor(arFaces);
}
else // 其他
{
MakePolyCurveFaceNoZNor(arFaces);
}
}
return arFaces.length() > 0;
}
void TEImpCabCross::MakePolyCurveFaceZNor(AcDbVoidPtrArray& arFaces)
{
if (m_pXDataMap != NULL)
{
TComplexCurve cplCurve;
MakeCurvesBase(cplCurve);
if (cplCurve.length() > 0)
{
int nStyle = -1;
m_pXDataMap->GetAt(KEY_CORNER,nStyle);
if (nStyle == TDb::eArc || nStyle == TDb::eDblArc)
{
if (cplCurve.length() < 16)
return;
AcGePoint3d ptGeM;
m_pXDataMap->GetAt(KEY_MID,ptGeM);
arFaces.append(CreateAcDbFace(cplCurve.at(0).ptGe[0],cplCurve.at(0).ptGe[2],
cplCurve.at(1).ptGe[2],cplCurve.at(15).ptGe[0]));
arFaces.append(CreateAcDbFace(cplCurve.at(3).ptGe[0],cplCurve.at(3).ptGe[2],
cplCurve.at(5).ptGe[0],cplCurve.at(5).ptGe[2]));
arFaces.append(CreateAcDbFace(cplCurve.at(7).ptGe[0],cplCurve.at(7).ptGe[2],
cplCurve.at(9).ptGe[0],cplCurve.at(9).ptGe[2]));
arFaces.append(CreateAcDbFace(cplCurve.at(10).ptGe[2],cplCurve.at(11).ptGe[2],
cplCurve.at(13).ptGe[0],cplCurve.at(13).ptGe[2]));
CreateAcDbArcFace(arFaces,cplCurve.at(2).ptGe[0],cplCurve.at(2).ptGe[2],ptGeM);
CreateAcDbArcFace(arFaces,cplCurve.at(6).ptGe[0],cplCurve.at(6).ptGe[2],ptGeM);
CreateAcDbArcFace(arFaces,cplCurve.at(10).ptGe[0],cplCurve.at(10).ptGe[2],ptGeM);
CreateAcDbArcFace(arFaces,cplCurve.at(14).ptGe[0],cplCurve.at(14).ptGe[2],ptGeM);
arFaces.append(CreateAcDbFace(cplCurve.at(15).ptGe[0],cplCurve.at(1).ptGe[2],
ptGeM,ptGeM));
arFaces.append(CreateAcDbFace(cplCurve.at(2).ptGe[2],cplCurve.at(5).ptGe[2],
ptGeM,ptGeM));
arFaces.append(CreateAcDbFace(cplCurve.at(6).ptGe[2],cplCurve.at(9).ptGe[2],
ptGeM,ptGeM));
arFaces.append(CreateAcDbFace(cplCurve.at(10).ptGe[2],cplCurve.at(13).ptGe[2],
ptGeM,ptGeM));
}
else
{
//add by lsd 2013-11-5
//添加对斜向四通的支持
if(cplCurve.length() == 12)//斜向四通,num = 12
{
arFaces.append(CreateAcDbFace(cplCurve.at(0).ptGe[0],cplCurve.at(0).ptGe[2],
cplCurve.at(6).ptGe[0],cplCurve.at(6).ptGe[2]));
arFaces.append(CreateAcDbFace(cplCurve.at(3).ptGe[0],cplCurve.at(3).ptGe[2],
cplCurve.at(9).ptGe[0],cplCurve.at(9).ptGe[2]));
}
//end
if (cplCurve.length() < 15)
return;
arFaces.append(CreateAcDbFace(cplCurve.at(0).ptGe[0],cplCurve.at(0).ptGe[2],
cplCurve.at(8).ptGe[0],cplCurve.at(8).ptGe[2]));
arFaces.append(CreateAcDbFace(cplCurve.at(11).ptGe[0],cplCurve.at(11).ptGe[2],
cplCurve.at(13).ptGe[0],cplCurve.at(13).ptGe[2]));
arFaces.append(CreateAcDbFace(cplCurve.at(3).ptGe[0],cplCurve.at(3).ptGe[2],
cplCurve.at(5).ptGe[0],cplCurve.at(5).ptGe[2]));
arFaces.append(CreateAcDbFace(cplCurve.at(14).ptGe[0],cplCurve.at(14).ptGe[2],
cplCurve.at(10).ptGe[0],cplCurve.at(10).ptGe[2]));
arFaces.append(CreateAcDbFace(cplCurve.at(2).ptGe[0],cplCurve.at(2).ptGe[2],
cplCurve.at(6).ptGe[0],cplCurve.at(6).ptGe[2]));
}
}
}
}
void TEImpCabCross::MakePolyCurveFaceNoZNor(AcDbVoidPtrArray& arFaces)
{
TComplexCurve cplCurve;
MakeCurvesBase(cplCurve);
if (cplCurve.length() > 3)
{
arFaces.append(CreateAcDbFace(cplCurve.at(1).ptGe[0],cplCurve.at(1).ptGe[1],
cplCurve.at(3).ptGe[0],cplCurve.at(3).ptGe[1]));
}
}
AcDbFace* TEImpCabCross::CreateAcDbFace(const AcGePoint3d& pt1,const AcGePoint3d& pt2,const AcGePoint3d& pt3,const AcGePoint3d& pt4)
{
AcDbFace* pFace = NULL;
pFace = new AcDbFace;
if (pFace != NULL)
{
pFace->setVertexAt(0, pt1);
pFace->setVertexAt(1, pt2);
pFace->setVertexAt(2, pt3);
pFace->setVertexAt(3, pt4);
}
return pFace;
}
AcDbFace* TEImpCabCross::CreateAcDbFace2(const AcGePoint3d& pt1,const AcGePoint3d& pt2,const AcGePoint3d& pt3,const AcGePoint3d& pt4) const
{
AcDbFace* pFace = NULL;
pFace = new AcDbFace;
if (pFace != NULL)
{
pFace->setVertexAt(0, pt1);
pFace->setVertexAt(1, pt2);
pFace->setVertexAt(2, pt3);
pFace->setVertexAt(3, pt4);
}
return pFace;
}
// 只支持圆弧对应圆心角为90度角
BOOL TEImpCabCross::CreateAcDbArcFace(AcDbVoidPtrArray& arFaces,const AcGePoint3d& ptSta,const AcGePoint3d& ptEnd,const AcGePoint3d& ptMid)
{
AcDbLine line(ptSta, ptEnd);
AcGePoint3d ptOnLine;
line.getClosestPointTo(ptMid, ptOnLine);
AcGeVector3d vtT = ptOnLine - ptMid;
vtT.normalize();
// 获取圆弧的圆心
double dL = ptSta.distanceTo(ptEnd);
AcGePoint3d ptOri = ptOnLine + vtT * dL / 2;
double dT = dL / 10.0;
// 圆半径
double dR = dL * cos(PI / 4);
AcGePoint3d ptTemp,ptTemp2;
AcGeVector3d vtSE = ptEnd - ptSta;
vtSE.normalize();
for (int i = 0;i < 10;i++)
{
ptTemp = ptSta + vtSE * i * dT;
vtT = ptTemp - ptOri;
vtT.normalize();
ptTemp = ptOri + dR * vtT;
ptTemp2 = ptSta + vtSE * (i + 1) * dT;
vtT = ptTemp2 - ptOri;
vtT.normalize();
ptTemp2 = ptOri + dR * vtT;
arFaces.append(CreateAcDbFace(ptTemp,ptTemp2,ptMid,ptMid));
}
return TRUE;
}
void TEImpCabCross::FreeBuffer(AcDbVoidPtrArray& arCurves)
{
for (int i = 0;i < arCurves.length();i++)
{
AcDbEntity* pEnt = (AcDbEntity*)arCurves.at(i);
if (pEnt != NULL)
{
delete pEnt;
}
}
arCurves.setLogicalLength(0);
}
TDb::Position TEImpCabCross::ExplainGripIndex(int nIndex) const
{
AcGeVector3d vtNormal;
TDb::Position ePos = TDb::eBr1;
switch(nIndex)
{
case 1:
{
ePos = TDb::eMid;
break;
}
case 2:
{
ePos = TDb::eBr2;
break;
}
case 3:
{
ePos = TDb::eBr3;
break;
}
case 4:
{
ePos = TDb::eBr4;
break;
}
case 5:
{
ePos = TDb::eCommand0;
break;
}
case 6:
{
ePos = TDb::eCommand1;
break;
}
case 7:
{
ePos = TDb::eCommand2;
break;
}
case 8:
{
ePos = TDb::eCommand3;
break;
}
default:
break;
}
return ePos;
}
void TEImpCabCross::GetKindName(CString& sName)
{
sName = _T("TCH_ECROSS");
}
BOOL TEImpCabCross::OnTransformByMsgNotify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
{
// 不考虑其所属的接口的关系,变化后相当于断开关系
// 新位置的关系建立,由外部管理对象处理;
AcGePoint3d ptSta,ptEnd,ptGeM;
BOOL bMsgTranslate = FALSE;
if (m_pXDataMap != NULL)
{
AcGeMatrix3d xform = iModiMsg.GetTransform();
AcGePoint3d ptGeM;
AcGeVector3d vtDir,vtNormal;
double dLen = 0.0;
if (!m_pXDataMap->GetAt(KEY_MID,ptGeM) ||
!m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) ||
!m_pXDataMap->GetAt(KEY_L,dLen) ||
!m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) )
{
return FALSE;
}
dLen /= 2.0;
AcGeVector3d vtPreCross = vtDir;
vtPreCross.rotateBy(PI / 2.0,vtNormal);
vtDir.normalize();
vtPreCross.normalize();
AcGePoint3d ptGeS = ptGeM + vtDir * dLen;
AcGePoint3d ptGeE = ptGeM - vtDir * dLen;
AcGePoint3d ptGeTop = ptGeM - vtPreCross * dLen;
AcGePoint3d ptGeDown = ptGeM + vtPreCross * dLen;
AcGeVector3d vtS = ptGeS - ptGeM;
AcGeVector3d vtE = ptGeE - ptGeM;
AcGeVector3d vtT = ptGeTop - ptGeM;
AcGeVector3d vtD = ptGeDown - ptGeM;
ptGeM.transformBy(xform);
m_pXDataMap->SetAt(KEY_MID,ptGeM);
//产生新的接口消息
AcDbObjectId id1,id2,id3,id4;
m_pXDataMap->GetAt(KEY_IDCNT1,id1);
m_pXDataMap->GetAt(KEY_IDCNT2,id2);
m_pXDataMap->GetAt(KEY_IDCNT3,id3);
m_pXDataMap->GetAt(KEY_IDCNT4,id4);
// 构造接口消息传递 开始端检查
AcDbObjectId idT;
if (FindConnect(ptGeS,vtS,m_pOwnerEnt->objectId(),idT)) // sta 点的接口
{
if (idT == id1 || idT == id2)
{
TInterfaceModifyMsg msg;
msg.SetMsgPoint(ptGeS);
msg.SetTransform(xform);
msg.SetMsgOperateOn(idT);
iModiMsgs.append(msg);
bMsgTranslate = TRUE;
}
}
// 构造接口消息传递 末端检查
if (FindConnect(ptGeE,vtE,m_pOwnerEnt->objectId(),idT)) // end 点的接口
{
if (idT == id1 || idT == id2)
{
TInterfaceModifyMsg msg;
msg.SetMsgPoint(ptGeE);
msg.SetTransform(xform);
msg.SetMsgOperateOn(idT);
iModiMsgs.append(msg);
bMsgTranslate = TRUE;
}
}
if (FindConnect(ptGeTop,vtT,m_pOwnerEnt->objectId(),idT)) // top 点的接口
{
if (idT == id3 || idT == id4)
{
TInterfaceModifyMsg msg;
msg.SetMsgPoint(ptGeTop);
msg.SetTransform(xform);
msg.SetMsgOperateOn(idT);
iModiMsgs.append(msg);
bMsgTranslate = TRUE;
}
}
if (FindConnect(ptGeDown,vtD,m_pOwnerEnt->objectId(),idT)) // down 点的接口
{
if (idT == id3 || idT == id4)
{
TInterfaceModifyMsg msg;
msg.SetMsgPoint(ptGeDown);
msg.SetTransform(xform);
msg.SetMsgOperateOn(idT);
iModiMsgs.append(msg);
bMsgTranslate = TRUE;
}
}
if (m_pOwnerEnt->objectId().isValid())
{
//更新接口记录接口信息
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
}
}
return bMsgTranslate;
}
BOOL TEImpCabCross::OnMoveGripPointMsgNotify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
{
BOOL bMsgTranslate = FALSE;
AcDbObjectId id = iModiMsg.GetMsgOperateOn();
if (id == m_pOwnerEnt->objectId()) // 消息发送目标正确
{
AcGeVector3d vtOffset = iModiMsg.GetMoveGripOffset();
if (vtOffset.isZeroLength()) return FALSE;
AcGePoint3d ptGeM;
AcGeVector3d vtDir,vtNormal;
int nType = 0;
double dLen = 0.0;
if ( m_pXDataMap->GetAt(KEY_MID,ptGeM) &&
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) &&
m_pXDataMap->GetAt(KEY_L,dLen) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) &&
m_pXDataMap->GetAt(KEY_CROSS,nType))
{
dLen /= 2.0;
AcGeVector3d vtPreCross = vtDir;
vtPreCross.rotateBy(PI / 2.0,vtNormal);
BOOL bIncline = FALSE;
m_pXDataMap->GetAt(KEY_INCLINE_FIT, bIncline);
if (bIncline)
{
//如果是斜向四通
m_pXDataMap->GetAt(KEY_MINBR,vtPreCross);
}
vtDir.normalize();
vtPreCross.normalize();
AcGePoint3d ptGeS = ptGeM - vtDir * dLen;
AcGePoint3d ptGeE = ptGeM + vtDir * dLen;
AcGePoint3d ptGeTop = ptGeM + vtPreCross * dLen;
AcGePoint3d ptGeDown = ptGeM - vtPreCross * dLen;
int nPos = iModiMsg.GetGripPosition();
switch (nPos)
{
case TDb::eStart:
case TDb::eEnd:
case TDb::eBr1:
case TDb::eBr2:
case TDb::eBr3:
case TDb::eBr4:
case TDb::eMid:
{
AcGeVector3d vtTemp = ptGeS - ptGeM;
AcGeVector3d vtTemp2 = ptGeE - ptGeM;
AcGeVector3d vtTemp3 = ptGeTop - ptGeM;
AcGeVector3d vtTemp4 = ptGeDown - ptGeM;
// if ( vtOffset.isParallelTo(vtTemp) ||
// vtOffset.isPerpendicularTo(vtTemp)) //平行或者垂直
// {
ptGeM += vtOffset;
m_pXDataMap->SetAt(KEY_MID,ptGeM);
AcDbObjectId id1,id2,id3,id4;
m_pXDataMap->GetAt(KEY_IDCNT1,id1);
m_pXDataMap->GetAt(KEY_IDCNT2,id2);
m_pXDataMap->GetAt(KEY_IDCNT3,id3);
m_pXDataMap->GetAt(KEY_IDCNT4,id4);
// 构造接口消息传递 开始端检查
AcDbObjectId idT;
if (FindConnect(ptGeS,vtTemp,m_pOwnerEnt->objectId(),idT)) // sta 点的接口
{
if ((idT == id1 || idT == id2) && !idT.isNull())
{
TInterfaceModifyMsg msg;
msg.SetMsgPoint(ptGeS);
msg.SetTransform(vtOffset);
msg.SetMsgOperateOn(idT);
iModiMsgs.append(msg);
bMsgTranslate = TRUE;
}
}
// 构造接口消息传递 下一个端口检查
if (FindConnect(ptGeE,vtTemp2,m_pOwnerEnt->objectId(),idT)) // 下个端口的接口
{
if ((idT == id1 || idT == id2) && !idT.isNull())
{
TInterfaceModifyMsg msg;
msg.SetMsgPoint(ptGeE);
msg.SetTransform(vtOffset);
msg.SetMsgOperateOn(idT);
iModiMsgs.append(msg);
bMsgTranslate = TRUE;
}
}
if (FindConnect(ptGeTop,vtTemp3,m_pOwnerEnt->objectId(),idT)) // top 点的接口
{
if ((idT == id3 || idT == id4) && !idT.isNull())
{
TInterfaceModifyMsg msg;
msg.SetMsgPoint(ptGeTop);
msg.SetTransform(vtOffset);
msg.SetMsgOperateOn(idT);
iModiMsgs.append(msg);
bMsgTranslate = TRUE;
}
}
if (FindConnect(ptGeDown,vtTemp4,m_pOwnerEnt->objectId(),idT)) // down 点的接口
{
if ((idT == id3 || idT == id4) && !idT.isNull())
{
TInterfaceModifyMsg msg;
msg.SetMsgPoint(ptGeDown);
msg.SetTransform(vtOffset);
msg.SetMsgOperateOn(idT);
iModiMsgs.append(msg);
bMsgTranslate = TRUE;
}
}
// 更新模型空间的扩展字典的注册的接口数据
AcGeMatrix3d xform;
xform.setToTranslation(vtOffset);
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
return bMsgTranslate;
// }
// else // 倾斜,不传递消息,只改变自身
// {
// ptGeM += vtOffset;
//
// m_pXDataMap->SetAt(KEY_MID,ptGeM);
//
// // 更新模型空间的扩展字典的注册的接口数据
// AcGeMatrix3d xform;
// xform.setToTranslation(vtOffset);
// UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
// return FALSE;
// }
break;
}
default:
break;
}
}
}
return bMsgTranslate;
}
Acad::ErrorStatus TEImpCabCross::ExplodeOrDraw3d(XExplodeDraw &mode) const
{
Acad::ErrorStatus errorState = Acad::eOk;
if (m_pXDataMap == NULL)
return Acad::eNotImplementedYet;
int nStyle = eC;
m_pXDataMap->GetAt(KEY_STYLE,nStyle);
switch (nStyle)
{
case TDb::eP:// 盘式桥架
{
errorState = ExplodeOrDraw3dOfP(mode);
break;
}
case TDb::eC:// 槽式桥架
{
errorState = ExplodeOrDraw3dOfC(mode);
break;
}
case TDb::eT:// 梯式桥架
{
errorState = ExplodeOrDraw3dOfT(mode);
break;
}
default:
break;
}
return errorState;
}
Acad::ErrorStatus TEImpCabCross::ExplodeOrDraw3dOfC(XExplodeDraw &mode) const
{
int nStyle = 0;
m_pXDataMap->GetAt(KEY_CROSS,nStyle);
Acad::ErrorStatus es = Acad::eInvalidInput;
switch(nStyle)
{
case TDb::eOldCbotHorEqualCross:
case TDb::eCbotHorEqualCross:
{
es = Draw3dCrossForPlaneOfC(mode);
}
case TDb::eCrossForSpace:
{
es = Draw3dCrossForSpaceOfC(mode);
}
default:
break;
}
return es;
}
Acad::ErrorStatus TEImpCabCross::ExplodeOrDraw3dOfP(XExplodeDraw &mode) const
{
int nStyle = 0;
m_pXDataMap->GetAt(KEY_CROSS,nStyle);
Acad::ErrorStatus es = Acad::eInvalidInput;
switch(nStyle)
{
case TDb::eOldCbotHorEqualCross:
case TDb::eCbotHorEqualCross:
{
es = Draw3dCrossForPlaneOfP(mode);
}
case TDb::eCrossForSpace:
{
es = Draw3dCrossForSpaceOfP(mode);
}
default:
break;
}
return es;
}
Acad::ErrorStatus TEImpCabCross::ExplodeOrDraw3dOfT(XExplodeDraw &mode) const
{
int nStyle = 0;
m_pXDataMap->GetAt(KEY_CROSS,nStyle);
Acad::ErrorStatus es = Acad::eInvalidInput;
switch(nStyle)
{
case TDb::eOldCbotHorEqualCross:
case TDb::eCbotHorEqualCross:
{
es = Draw3dCrossForPlaneOfT(mode);
}
case TDb::eCrossForSpace:
{
es = Draw3dCrossForSpaceOfT(mode);
}
default:
break;
}
return es;
}
Acad::ErrorStatus TEImpCabCross::Draw3dCrossForPlaneOfP(XExplodeDraw &mode) const
{
return Draw3dCrossForPlaneOfC(mode);
}
Acad::ErrorStatus TEImpCabCross::Draw3dCrossForSpaceOfP(XExplodeDraw &mode) const
{
return Draw3dCrossForSpaceOfC(mode);
}
Acad::ErrorStatus TEImpCabCross::Draw3dCrossForPlaneOfC(XExplodeDraw &mode) const
{
if (m_pXDataMap == NULL)
return Acad::eNotImplementedYet;
/************************************************************************/
/* 0 1
16 +----+
| |
15 + + 2
14 / \ 3
13 +---+ 1 +---+ 4
| M |
12 +---+ +---+ 5
11 \ / 6
10 + + 7
| |
9 +----+ 8
/************************************************************************/
TComplexCurve cplCurve;
int nModel = -1;
m_pXDataMap->GetAt(KEY_CORNER,nModel);
m_pXDataMap->SetAt(KEY_CORNER,TDb::eLine);
int nNum = MakeCurvesZNor(cplCurve);
m_pXDataMap->SetAt(KEY_CORNER,nModel);
if (cplCurve.length() < 16)
{
return ExplodeOrDraw3dNLine(mode);
}
int nCover = -1;
AcGeVector3d vtNormal;
double dH = 0.0;
m_pXDataMap->GetAt(KEY_COVER,nCover);
m_pXDataMap->GetAt(KEY_H,dH);
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal);
AcGePoint3d* pVerBot = new AcGePoint3d[16];
AcGePoint3d* pVerCover = new AcGePoint3d[16];
if(pVerCover == NULL || pVerBot == NULL)
return Acad::eNotImplementedYet;
pVerBot[0] = cplCurve.at(0).ptGe[0];
pVerBot[1] = cplCurve.at(0).ptGe[1];
pVerBot[2] = cplCurve.at(1).ptGe[1];
pVerBot[3] = cplCurve.at(2).ptGe[1];
pVerBot[4] = cplCurve.at(3).ptGe[1];
pVerBot[5] = cplCurve.at(4).ptGe[1];
pVerBot[6] = cplCurve.at(5).ptGe[1];
pVerBot[7] = cplCurve.at(6).ptGe[1];
pVerBot[8] = cplCurve.at(7).ptGe[1];
pVerBot[9] = cplCurve.at(8).ptGe[1];
pVerBot[10] = cplCurve.at(9).ptGe[1];
pVerBot[11] = cplCurve.at(10).ptGe[1];
pVerBot[12] = cplCurve.at(11).ptGe[1];
pVerBot[13] = cplCurve.at(12).ptGe[1];
pVerBot[14] = cplCurve.at(13).ptGe[1];
pVerBot[15] = cplCurve.at(14).ptGe[1];
// Cover
pVerCover[0] = pVerBot[0] + vtNormal * dH;
pVerCover[1] = pVerBot[1] + vtNormal * dH;
pVerCover[2] = pVerBot[2] + vtNormal * dH;
pVerCover[3] = pVerBot[3] + vtNormal * dH;
pVerCover[4] = pVerBot[4] + vtNormal * dH;
pVerCover[5] = pVerBot[5] + vtNormal * dH;
pVerCover[6] = pVerBot[6] + vtNormal * dH;
pVerCover[7] = pVerBot[7] + vtNormal * dH;
pVerCover[8] = pVerBot[8] + vtNormal * dH;
pVerCover[9] = pVerBot[9] + vtNormal * dH;
pVerCover[10] = pVerBot[10] + vtNormal * dH;
pVerCover[11] = pVerBot[11] + vtNormal * dH;
pVerCover[12] = pVerBot[12] + vtNormal * dH;
pVerCover[13] = pVerBot[13] + vtNormal * dH;
pVerCover[14] = pVerBot[14] + vtNormal * dH;
pVerCover[15] = pVerBot[15] + vtNormal * dH;
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
mode.SetColor(curColor);
static Adesk::Int32 faceList[] = {16,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
mode.DrawShell(16,pVerBot,17,faceList);
//侧面
CreateFace(mode,pVerBot[1],pVerBot[2],pVerBot[3],pVerBot[4],
pVerCover[1],pVerCover[2],pVerCover[3],pVerCover[4]);
CreateFace(mode,pVerBot[13],pVerBot[14],pVerBot[15],pVerBot[0],
pVerCover[13],pVerCover[14],pVerCover[15],pVerCover[0]);
CreateFace(mode,pVerBot[9],pVerBot[10],pVerBot[11],pVerBot[12],
pVerCover[9],pVerCover[10],pVerCover[11],pVerCover[12]);
CreateFace(mode,pVerBot[5],pVerBot[6],pVerBot[7],pVerBot[8],
pVerCover[5],pVerCover[6],pVerCover[7],pVerCover[8]);
if (nCover == TDb::eCover)
{
static Adesk::Int32 faceList2[] = {16,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
mode.DrawShell(16,pVerCover,17,faceList2);
}
delete []pVerBot;
pVerBot = NULL;
delete []pVerCover;
pVerCover = NULL;
return Acad::eOk;
}
Acad::ErrorStatus TEImpCabCross::Draw3dCrossForPlaneOfT(XExplodeDraw &mode) const
{
if (m_pXDataMap == NULL)
return Acad::eNotImplementedYet;
/************************************************************************/
/* 0 1
16 +----+
| |
15 + + 2
14 / \ 3
13 +---+ +---+ 4
ptGeS | M | ptGeE
12 +---+ +---+ 5
11 \ / 6
10 + + 7
| |
9 +----+ 8
*/
/************************************************************************/
double dLadderWidth = 50; //梯宽
double dSideWidth = 30; //侧面宽
double dThick = 10; //梯厚度
AcGeVector3d vtNormal;
double dH = 0.0;
double dB = 0.0;
double dL = 0.0;
AcGePoint3d ptGeM;
m_pXDataMap->GetAt(KEY_MID,ptGeM);
m_pXDataMap->GetAt(KEY_H,dH);
m_pXDataMap->GetAt(KEY_B,dB);
m_pXDataMap->GetAt(KEY_L,dL);
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal);
// 判断 梯式斜向四通 2012/11/20 add by wzh
AcGeVector3d vtMajBr, vtMinBr;
m_pXDataMap->GetAt(KEY_MAJBR, vtMajBr);
m_pXDataMap->GetAt(KEY_MINBR, vtMinBr);
if (!vtMajBr.isParallelTo(vtMinBr) && !vtMajBr.isPerpendicularTo(vtMinBr))
{
return Draw3dCrossForInclineOfT(mode);
}
//////////////////////////////////////////
// 获取底面顶点集
TComplexCurve cplCurve;
int nModel = -1;
m_pXDataMap->GetAt(KEY_CORNER,nModel);
m_pXDataMap->SetAt(KEY_CORNER,TDb::eLine);
int nNum = MakeCurvesZNor(cplCurve);
m_pXDataMap->SetAt(KEY_CORNER,nModel);
if (cplCurve.length() < 16)
{
return ExplodeOrDraw3dNLine(mode);
}
AcGePoint3d* pVerBot = new AcGePoint3d[16];
if(pVerBot == NULL)
return Acad::eNotImplementedYet;
pVerBot[0] = cplCurve.at(0).ptGe[0];
pVerBot[1] = cplCurve.at(0).ptGe[1];
pVerBot[2] = cplCurve.at(1).ptGe[1];
pVerBot[3] = cplCurve.at(2).ptGe[1];
pVerBot[4] = cplCurve.at(3).ptGe[1];
pVerBot[5] = cplCurve.at(4).ptGe[1];
pVerBot[6] = cplCurve.at(5).ptGe[1];
pVerBot[7] = cplCurve.at(6).ptGe[1];
pVerBot[8] = cplCurve.at(7).ptGe[1];
pVerBot[9] = cplCurve.at(8).ptGe[1];
pVerBot[10] = cplCurve.at(9).ptGe[1];
pVerBot[11] = cplCurve.at(10).ptGe[1];
pVerBot[12] = cplCurve.at(11).ptGe[1];
pVerBot[13] = cplCurve.at(12).ptGe[1];
pVerBot[14] = cplCurve.at(13).ptGe[1];
pVerBot[15] = cplCurve.at(14).ptGe[1];
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
mode.SetColor(curColor);
// 计算参量
AcGeVector3d vtri = pVerBot[4] - pVerBot[3];
vtri.normalize();
AcGeVector3d vtrj = pVerBot[1] - pVerBot[2];
vtrj.normalize();
AcGePoint3dArray arPt;
// 绘制步骤1-N
// 1 RT 三个cube截面
AcDbLine lineA(pVerBot[2], pVerBot[3]);
AcGePoint3d ptOnLine;
Acad::ErrorStatus st;
st = lineA.getClosestPointTo(ptGeM, ptOnLine, Adesk::kTrue);
AcDbLine lineB;
if (st == Acad::eOk)
{
AcGeVector3d vtr = ptOnLine - ptGeM;
vtr.normalize();
lineA.setStartPoint(pVerBot[1] + vtri * dSideWidth);
lineA.setEndPoint(pVerBot[2] + vtri * dSideWidth);
lineB.setStartPoint(pVerBot[2] + vtr * dSideWidth);
lineB.setEndPoint(pVerBot[3] + vtr * dSideWidth);
arPt.setLogicalLength(0);
lineA.intersectWith(&lineB, AcDb::kExtendBoth, arPt);
if (arPt.length() == 1)
{
AcGePoint3d ptIns1 = arPt[0];
arPt.setLogicalLength(0);
lineA.setStartPoint(pVerBot[3] + vtrj * dSideWidth);
lineA.setEndPoint(pVerBot[4] + vtrj * dSideWidth);
arPt.setLogicalLength(0);
lineA.intersectWith(&lineB, AcDb::kExtendBoth, arPt);
if (arPt.length() == 1)
{
AcGePoint3d ptIns2 = arPt[0];
arPt.setLogicalLength(0);
arPt.append(pVerBot[1]);
arPt.append(pVerBot[2]);
arPt.append(pVerBot[1] + vtri * dSideWidth);
arPt.append(ptIns1);
DrawCube(mode, vtNormal, arPt, dH);
arPt.setLogicalLength(0);
arPt.append(pVerBot[2]);
arPt.append(pVerBot[3]);
arPt.append(ptIns1);
arPt.append(ptIns2);
DrawCube(mode, vtNormal, arPt, dH);
arPt.setLogicalLength(0);
arPt.append(pVerBot[3]);
arPt.append(pVerBot[4]);
arPt.append(ptIns2);
arPt.append(pVerBot[4] + vtrj * dSideWidth);
DrawCube(mode, vtNormal, arPt, dH);
}
}
}
// 2 RB 右下三个cube截面
lineA.setStartPoint(pVerBot[6]);
lineA.setEndPoint(pVerBot[7]);
st = lineA.getClosestPointTo(ptGeM, ptOnLine, Adesk::kTrue);
if (st == Acad::eOk)
{
AcGeVector3d vtr = ptOnLine - ptGeM;
vtr.normalize();
lineA.setStartPoint(pVerBot[5] - vtrj * dSideWidth);
lineA.setEndPoint(pVerBot[6] - vtrj * dSideWidth);
lineB.setStartPoint(pVerBot[6] + vtr * dSideWidth);
lineB.setEndPoint(pVerBot[7] + vtr * dSideWidth);
arPt.setLogicalLength(0);
lineA.intersectWith(&lineB, AcDb::kExtendBoth, arPt);
if (arPt.length() == 1)
{
AcGePoint3d ptIns1 = arPt[0];
arPt.setLogicalLength(0);
lineA.setStartPoint(pVerBot[7] + vtri * dSideWidth);
lineA.setEndPoint(pVerBot[8] + vtri * dSideWidth);
arPt.setLogicalLength(0);
lineA.intersectWith(&lineB, AcDb::kExtendBoth, arPt);
if (arPt.length() == 1)
{
AcGePoint3d ptIns2 = arPt[0];
arPt.setLogicalLength(0);
arPt.append(pVerBot[5]);
arPt.append(pVerBot[6]);
arPt.append(pVerBot[5] - vtrj * dSideWidth);
arPt.append(ptIns1);
DrawCube(mode, vtNormal, arPt, dH);
arPt.setLogicalLength(0);
arPt.append(pVerBot[6]);
arPt.append(pVerBot[7]);
arPt.append(ptIns1);
arPt.append(ptIns2);
DrawCube(mode, vtNormal, arPt, dH);
arPt.setLogicalLength(0);
arPt.append(pVerBot[7]);
arPt.append(pVerBot[8]);
arPt.append(ptIns2);
arPt.append(pVerBot[8] + vtri * dSideWidth);
DrawCube(mode, vtNormal, arPt, dH);
}
}
}
// 3 LB 左下三个cube截面
lineA.setStartPoint(pVerBot[10]);
lineA.setEndPoint(pVerBot[11]);
st = lineA.getClosestPointTo(ptGeM, ptOnLine, Adesk::kTrue);
if (st == Acad::eOk)
{
AcGeVector3d vtr = ptOnLine - ptGeM;
vtr.normalize();
lineA.setStartPoint(pVerBot[9] - vtri * dSideWidth);
lineA.setEndPoint(pVerBot[10] - vtri * dSideWidth);
lineB.setStartPoint(pVerBot[10] + vtr * dSideWidth);
lineB.setEndPoint(pVerBot[11] + vtr * dSideWidth);
arPt.setLogicalLength(0);
lineA.intersectWith(&lineB, AcDb::kExtendBoth, arPt);
if (arPt.length() == 1)
{
AcGePoint3d ptIns1 = arPt[0];
arPt.setLogicalLength(0);
lineA.setStartPoint(pVerBot[11] - vtrj * dSideWidth);
lineA.setEndPoint(pVerBot[12] - vtrj * dSideWidth);
arPt.setLogicalLength(0);
lineA.intersectWith(&lineB, AcDb::kExtendBoth, arPt);
if (arPt.length() == 1)
{
AcGePoint3d ptIns2 = arPt[0];
arPt.setLogicalLength(0);
arPt.append(pVerBot[9]);
arPt.append(pVerBot[10]);
arPt.append(pVerBot[9] - vtri * dSideWidth);
arPt.append(ptIns1);
DrawCube(mode, vtNormal, arPt, dH);
arPt.setLogicalLength(0);
arPt.append(pVerBot[10]);
arPt.append(pVerBot[11]);
arPt.append(ptIns1);
arPt.append(ptIns2);
DrawCube(mode, vtNormal, arPt, dH);
arPt.setLogicalLength(0);
arPt.append(pVerBot[11]);
arPt.append(pVerBot[12]);
arPt.append(ptIns2);
arPt.append(pVerBot[12] - vtrj * dSideWidth);
DrawCube(mode, vtNormal, arPt, dH);
}
}
}
// 4 LT 左上三个cube截面
lineA.setStartPoint(pVerBot[14]);
lineA.setEndPoint(pVerBot[15]);
st = lineA.getClosestPointTo(ptGeM, ptOnLine, Adesk::kTrue);
if (st == Acad::eOk)
{
AcGeVector3d vtr = ptOnLine - ptGeM;
vtr.normalize();
lineA.setStartPoint(pVerBot[13] + vtrj * dSideWidth);
lineA.setEndPoint(pVerBot[14] + vtrj * dSideWidth);
lineB.setStartPoint(pVerBot[14] + vtr * dSideWidth);
lineB.setEndPoint(pVerBot[15] + vtr * dSideWidth);
arPt.setLogicalLength(0);
lineA.intersectWith(&lineB, AcDb::kExtendBoth, arPt);
if (arPt.length() == 1)
{
AcGePoint3d ptIns1 = arPt[0];
arPt.setLogicalLength(0);
lineA.setStartPoint(pVerBot[15] - vtri * dSideWidth);
lineA.setEndPoint(pVerBot[0] - vtri * dSideWidth);
arPt.setLogicalLength(0);
lineA.intersectWith(&lineB, AcDb::kExtendBoth, arPt);
if (arPt.length() == 1)
{
AcGePoint3d ptIns2 = arPt[0];
arPt.setLogicalLength(0);
arPt.append(pVerBot[13]);
arPt.append(pVerBot[14]);
arPt.append(pVerBot[13] + vtrj * dSideWidth);
arPt.append(ptIns1);
DrawCube(mode, vtNormal, arPt, dH);
arPt.setLogicalLength(0);
arPt.append(pVerBot[14]);
arPt.append(pVerBot[15]);
arPt.append(ptIns1);
arPt.append(ptIns2);
DrawCube(mode, vtNormal, arPt, dH);
arPt.setLogicalLength(0);
arPt.append(pVerBot[15]);
arPt.append(pVerBot[0]);
arPt.append(ptIns2);
arPt.append(pVerBot[0] - vtri * dSideWidth);
DrawCube(mode, vtNormal, arPt, dH);
}
}
}
// 5 上下左右四个分支中cube截面
//上
arPt.setLogicalLength(0);
arPt.append(pVerBot[15]);
arPt.append(pVerBot[2]);
arPt.append(pVerBot[15] + vtrj * dLadderWidth);
arPt.append(pVerBot[2] + vtrj * dLadderWidth);
DrawCube(mode, vtNormal, arPt, dThick);
// 下
arPt.setLogicalLength(0);
arPt.append(pVerBot[10]);
arPt.append(pVerBot[7]);
arPt.append(pVerBot[10] - vtrj * dLadderWidth);
arPt.append(pVerBot[7] - vtrj * dLadderWidth);
DrawCube(mode, vtNormal, arPt, dThick);
// 右
arPt.setLogicalLength(0);
arPt.append(pVerBot[3]);
arPt.append(pVerBot[6]);
arPt.append(pVerBot[3] + vtri * dLadderWidth);
arPt.append(pVerBot[6] + vtri * dLadderWidth);
DrawCube(mode, vtNormal, arPt, dThick);
// 左
arPt.setLogicalLength(0);
arPt.append(pVerBot[11]);
arPt.append(pVerBot[14]);
arPt.append(pVerBot[11] - vtri * dLadderWidth);
arPt.append(pVerBot[14] - vtri * dLadderWidth);
DrawCube(mode, vtNormal, arPt, dThick);
// 6 四通中间“工”字 横线之一
AcDbLine line1(pVerBot[15] - vtri * dLadderWidth, pVerBot[10] - vtri * dLadderWidth);
AcDbLine line2(pVerBot[15], pVerBot[14]);
AcDbLine line3(pVerBot[11], pVerBot[10]);
arPt.setLogicalLength(0);
line1.intersectWith(&line2, AcDb::kOnBothOperands, arPt);
if (arPt.length() == 1)
{
AcGePoint3d ptIns1 = arPt[0];
arPt.setLogicalLength(0);
line1.intersectWith(&line3, AcDb::kOnBothOperands, arPt);
if (arPt.length() == 1)
{
AcGePoint3d ptIns2 = arPt[0];
arPt.setLogicalLength(0);
arPt.append(pVerBot[15]);
arPt.append(pVerBot[10]);
arPt.append(ptIns1);
arPt.append(ptIns2);
DrawCube(mode, vtNormal, arPt, dThick);
}
}
line1.setStartPoint(pVerBot[2] + vtri * dLadderWidth);
line1.setEndPoint(pVerBot[7] + vtri * dLadderWidth);
line2.setStartPoint(pVerBot[2]);
line2.setEndPoint(pVerBot[3]);
line3.setStartPoint(pVerBot[6]);
line3.setEndPoint(pVerBot[7]);
// 7 四通中间“工”字 横线之一
arPt.setLogicalLength(0);
line1.intersectWith(&line2, AcDb::kOnBothOperands, arPt);
if (arPt.length() == 1)
{
AcGePoint3d ptIns1 = arPt[0];
arPt.setLogicalLength(0);
line1.intersectWith(&line3, AcDb::kOnBothOperands, arPt);
if (arPt.length() == 1)
{
AcGePoint3d ptIns2 = arPt[0];
arPt.setLogicalLength(0);
arPt.append(pVerBot[2]);
arPt.append(pVerBot[7]);
arPt.append(ptIns1);
arPt.append(ptIns2);
DrawCube(mode, vtNormal, arPt, dThick);
}
}
// 8 四通中间“工”字 数线
arPt.setLogicalLength(0);
arPt.append(pVerBot[8] + vtrj * (dL - dLadderWidth) / 2);
arPt.append(pVerBot[9] + vtrj * (dL - dLadderWidth) / 2);
arPt.append(pVerBot[8] + vtrj * (dL - dLadderWidth) / 2 + vtrj * dLadderWidth);
arPt.append(pVerBot[9] + vtrj * (dL - dLadderWidth) / 2 + vtrj * dLadderWidth);
DrawCube(mode, vtNormal, arPt, dThick);
delete []pVerBot;
pVerBot = NULL;
return Acad::eOk;
}
// 梯式斜向四通 2012/11/20 add by wzh
Acad::ErrorStatus TEImpCabCross::Draw3dCrossForInclineOfT(XExplodeDraw &mode) const
{
/************************************************************************/
/*
斜向系统示意图
1
Top +
+ \
(12) 0 + \
\ +
+ \
11 \ \ 2
10 +-----+----+ +-----+----+ 3
| |
ptGeS + + + ptGeE
| ptMid |
9 +------+------+ +---+---+ 4
8 \ \ 5
\ +
------> + \
vtMinBr \ + 6
\ +
+ Down
7
*/
/************************************************************************/
int nNum = 0;
TComplexCurve cplCurve;
int nModel = -1;
m_pXDataMap->GetAt(KEY_CORNER,nModel);
m_pXDataMap->SetAt(KEY_CORNER,TDb::eLine);
nNum = MakeCurvesZNor(cplCurve);
m_pXDataMap->SetAt(KEY_CORNER,nModel);
double dLadderWidth = 50; //梯宽
double dSideWidth = 30; //侧面宽
double dThick = 10; //梯厚度
int nCover = 0;
AcGePoint3d ptGeM;
AcGeVector3d vtMajBr, vtMinBr, vtMajNor;
double dH = 0.0, dB = 0.0, dL = 0.0;
m_pXDataMap->GetAt(KEY_COVER, nCover);
m_pXDataMap->GetAt(KEY_MID,ptGeM);
m_pXDataMap->GetAt(KEY_MAJBR, vtMajBr);
m_pXDataMap->GetAt(KEY_MINBR, vtMinBr);
m_pXDataMap->GetAt(KEY_NORMAL,vtMajNor);
m_pXDataMap->GetAt(KEY_H,dH);
m_pXDataMap->GetAt(KEY_B,dB);
m_pXDataMap->GetAt(KEY_L,dL);
// 变径四通 add by sps 2012/12/19
BOOL bTransCross = FALSE; // 变径四通
double dMajB(0.0), dMinB(0.0); // 主次分支宽度
m_pXDataMap->GetAt(KEY_TRANS_FIT, bTransCross);
if (bTransCross)
{
m_pXDataMap->GetAt(KEY_MAJBR_B, dMajB);
m_pXDataMap->GetAt(KEY_MINBR_B, dMinB);
}
vtMajBr.normalize();
vtMinBr.normalize();
vtMajNor.normalize();
// 修正主向量
double dAngle = vtMajBr.angleTo(vtMinBr);
double dAngleT = dAngle * 180 / PI; //cs
AcGeVector3d vtIncline = vtMinBr;
vtIncline.rotateBy(dAngle, vtMajNor);
vtIncline.normalize();
if (!vtIncline.isParallelTo(vtMajBr))
{
vtIncline = vtMinBr;
vtIncline.rotateBy(PI - dAngle, vtMajNor);
vtIncline.normalize();
}
vtMajBr = vtIncline;
// 斜向参量
AcGeVector3d vtMajVer, vtMinVer;
vtMajVer = vtMajBr;
vtMajVer.rotateBy(PI/2, vtMajNor);
vtMinVer = vtMinBr;
vtMinVer.rotateBy(PI/2, vtMajNor);
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
mode.SetColor(curColor);
int nSize = 0;
AcGePoint3d arPtBot[12];
AcGePoint3d arPtCover[12];
// 底面点
nSize = 12;
arPtBot[0] = cplCurve.at(0).ptGe[0];
for (int i = 1; i < nSize; ++i)
{
arPtBot[i] = cplCurve.at(i-1).ptGe[1];
}
// 封盖
nSize = 12;
for (int j = 0; j < nSize; ++j)
{
arPtCover[j] = arPtBot[j] + vtMajNor*dH;
}
AcGeLine3d line1, lineL, lineR; // L和R 在局部范围内相对而言
AcGePoint3d ptTmpLB, ptTmpRB, ptTmpRT, ptTmpLT;
AcGePoint3d ptCrossLB, ptCrossRB, ptCrossRT, ptCrossLT; // 各点局部相对而言
AcGePoint3dArray arPt;
double dDisB = 0.0, dDis = 0.0;
// 1 次分支连接线 pt5-pt8 pt2-pt11
line1.set(arPtBot[8] - vtMinVer*dLadderWidth, arPtBot[5] - vtMinVer*dLadderWidth);
lineL.set(arPtBot[8], arPtBot[7]);
lineR.set(arPtBot[5], arPtBot[6]);
line1.intersectWith(lineL, ptCrossLB);
line1.intersectWith(lineR, ptCrossRB);
arPt.append(arPtBot[8]);
arPt.append(arPtBot[5]);
arPt.append(ptCrossLB);
arPt.append(ptCrossRB);
DrawCube(mode, vtMajNor, arPt, dThick);
ptTmpLB = ptCrossLB;
ptTmpRB = ptCrossRB;
dDisB = arPtBot[8].distanceTo(arPtBot[11]);
dDis = arPtBot[8].distanceTo(ptCrossLB);
ptCrossLT = ptCrossLB + vtMajBr*(dDisB + dDis*2);
ptCrossRT = ptCrossRB + vtMajBr*(dDisB + dDis*2);
arPt[0] = arPtBot[11];
arPt[1] = arPtBot[2];
arPt[2] = ptCrossLT;
arPt[3] = ptCrossRT;
DrawCube(mode, vtMajNor, arPt, dThick);
ptTmpRT = ptCrossRT;
ptTmpLT = ptCrossLT;
// modify by sps 2013.6.7 修正四通主方向的梯式支架
// 2 主分支中三个cube截面
nSize = 3; //支架数
double dDist = dL / (nSize + 1);
for (int m = 0; m < nSize; ++m)
{
arPt[0] = arPtBot[10]+ vtMinBr * (m + 1) * dDist;
arPt[1] = arPtBot[9] + vtMinBr * (m + 1) * dDist;
arPt[2] = arPt[0] + vtMinBr * dLadderWidth;
arPt[3] = arPt[1] + vtMinBr * dLadderWidth;
DrawCube(mode, vtMajNor, arPt, dThick);
}
// 3 上下分支中两个cube截面
// 下
lineL.set(arPtBot[8], arPtBot[7]);
lineR.set(arPtBot[5], arPtBot[6]);
AcGePoint3d ptMidLB, ptMidRB;
double dDistLB = arPtBot[8].distanceTo(arPtBot[7]);
double dDistRB = arPtBot[5].distanceTo(arPtBot[6]);
if (dDistLB > dDistRB)
{
ptMidRB = TAuxTools::Mid(arPtBot[6], arPtBot[5]);
if (ptMidRB.distanceTo(arPtBot[5]) < ptTmpRB.distanceTo(arPtBot[5]))
{
ptMidRB = ptTmpRB;
}
ptMidLB = lineL.closestPointTo(ptMidRB);
}
else
{
ptMidLB = TAuxTools::Mid(arPtBot[8], arPtBot[7]);
if (ptMidLB.distanceTo(arPtBot[8]) < ptTmpLB.distanceTo(arPtBot[8]))
{
ptMidLB = ptTmpLB;
}
ptMidRB = lineR.closestPointTo(ptMidLB);
}
arPt[0] = ptMidLB;
arPt[1] = ptMidRB;
arPt[2] = arPt[0] - vtMajBr*dLadderWidth;
arPt[3] = arPt[1] - vtMajBr*dLadderWidth;
DrawCube(mode, vtMajNor, arPt, dThick);
// 上
dDis = arPtBot[6].distanceTo(ptMidRB);
ptMidLB = arPtBot[0] - vtMajBr*dDis;
ptMidRB = arPtBot[1] - vtMajBr*dDis;
arPt[0] = ptMidLB;
arPt[1] = ptMidRB;
arPt[2] = arPt[0] - vtMajBr*dLadderWidth;
arPt[3] = arPt[1] - vtMajBr*dLadderWidth;
DrawCube(mode, vtMajNor, arPt, dThick);
// 4 R 上下各两个拐角cube截面
// 下
lineL.set(arPtBot[5] - vtMajVer*dSideWidth, arPtBot[6] - vtMajVer*dSideWidth);
lineR.set(arPtBot[5] - vtMinVer*dSideWidth, arPtBot[4] - vtMinVer*dSideWidth);
lineL.intersectWith(lineR, ptCrossRB);
arPt[0] = arPtBot[5];
arPt[1] = arPtBot[6];
arPt[2] = ptCrossRB;
arPt[3] = arPt[1] - vtMajVer*dSideWidth;
DrawCube(mode, vtMajNor, arPt, dH);
arPt[0] = arPtBot[5];
arPt[1] = arPtBot[4];
arPt[2] = ptCrossRB;
arPt[3] = arPt[1] - vtMinVer*dSideWidth;
DrawCube(mode, vtMajNor, arPt, dH);
// 上
lineL.set(arPtBot[2] - vtMajVer*dSideWidth, arPtBot[1] - vtMajVer*dSideWidth);
lineR.set(arPtBot[2] + vtMinVer*dSideWidth, arPtBot[3] + vtMinVer*dSideWidth);
lineL.intersectWith(lineR, ptCrossRT);
arPt[0] = arPtBot[2];
arPt[1] = arPtBot[1];
arPt[2] = ptCrossRT;
arPt[3] = arPt[1] - vtMajVer*dSideWidth;
DrawCube(mode, vtMajNor, arPt, dH);
arPt[0] = arPtBot[2];
arPt[1] = arPtBot[3];
arPt[2] = ptCrossRT;
arPt[3] = arPt[1] + vtMinVer*dSideWidth;
DrawCube(mode, vtMajNor, arPt, dH);
// 5 L 上下两个cube截面
// 下
lineL.set(arPtBot[8] - vtMinVer*dSideWidth, arPtBot[9] - vtMinVer*dSideWidth);
lineR.set(arPtBot[8] + vtMajVer*dSideWidth, arPtBot[7] + vtMajVer*dSideWidth);
lineL.intersectWith(lineR, ptCrossLB);
arPt[0] = arPtBot[8];
arPt[1] = arPtBot[9];
arPt[2] = ptCrossLB;
arPt[3] = arPt[1] - vtMinVer*dSideWidth;
DrawCube(mode, vtMajNor, arPt, dH);
arPt[0] = arPtBot[8];
arPt[1] = arPtBot[7];
arPt[2] = ptCrossLB;
arPt[3] = arPt[1] + vtMajVer*dSideWidth;
DrawCube(mode, vtMajNor, arPt, dH);
// 上
lineL.set(arPtBot[11] + vtMinVer*dSideWidth, arPtBot[10] + vtMinVer*dSideWidth);
lineR.set(arPtBot[11] + vtMajVer*dSideWidth, arPtBot[0] + vtMajVer*dSideWidth);
lineL.intersectWith(lineR, ptCrossLT);
arPt[0] = arPtBot[11];
arPt[1] = arPtBot[10];
arPt[2] = ptCrossLT;
arPt[3] = arPt[1] + vtMinVer*dSideWidth;
DrawCube(mode, vtMajNor, arPt, dH);
arPt[0] = arPtBot[11];
arPt[1] = arPtBot[0];
arPt[2] = ptCrossLT;
arPt[3] = arPt[1] + vtMajVer*dSideWidth;
DrawCube(mode, vtMajNor, arPt, dH);
return Acad::eOk;
}
void TEImpCabCross::DrawCube(XExplodeDraw &mode,const AcGeVector3d &vtDir, const AcGePoint3dArray &ptArr, double dThick) const
{
if (ptArr.length() == 4)
{
AcGePoint3d *pVerList1 = new AcGePoint3d[10];
int nRow = 0;
int nCol = 0;
if (pVerList1 != NULL)
{
nRow = 5;
nCol = 2;
pVerList1[0] = ptArr[0];
pVerList1[1] = ptArr[1];
pVerList1[2] = ptArr[2];
pVerList1[3] = ptArr[3];
pVerList1[4] = ptArr[2] + vtDir * dThick;
pVerList1[5] = ptArr[3] + vtDir * dThick;
pVerList1[6] = ptArr[0] + vtDir * dThick;
pVerList1[7] = ptArr[1] + vtDir * dThick;
pVerList1[8] = ptArr[0];
pVerList1[9] = ptArr[1];
mode.DrawMesh(nRow, nCol, pVerList1,NULL);
AcGePoint3d *pVerList2 = new AcGePoint3d[4];
if (pVerList2 != NULL)
{
nRow = 2;
nCol = 2;
pVerList2[0] = pVerList1[1];
pVerList2[1] = pVerList1[3];
pVerList2[2] = pVerList1[7];
pVerList2[3] = pVerList1[5];
mode.DrawMesh(nRow, nCol, pVerList2,NULL);
pVerList2[0] = pVerList1[0];
pVerList2[1] = pVerList1[2];
pVerList2[2] = pVerList1[6];
pVerList2[3] = pVerList1[4];
mode.DrawMesh(nRow, nCol, pVerList2,NULL);
delete []pVerList2;
pVerList2 = NULL;
}
delete []pVerList1;
pVerList1 = NULL;
}
}
}
Acad::ErrorStatus TEImpCabCross::ExplodeOrDraw3dNLine(XExplodeDraw &mode) const
{
TComplexCurve cplCurve;
int nModel = -1;
m_pXDataMap->GetAt(KEY_CORNER,nModel);
m_pXDataMap->SetAt(KEY_CORNER,TDb::eLine);
int nNum = MakeCurvesZNor(cplCurve);
m_pXDataMap->SetAt(KEY_CORNER,nModel);
if (cplCurve.length() < 12)
{
return Acad::eNotImplementedYet;
}
int nCover = -1;
AcGeVector3d vtNormal;
double dH = 0.0;
m_pXDataMap->GetAt(KEY_COVER,nCover);
m_pXDataMap->GetAt(KEY_H,dH);
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal);
AcGePoint3d* pVerBot = new AcGePoint3d[12];
AcGePoint3d* pVerCover = new AcGePoint3d[12];
if(pVerCover == NULL || pVerBot == NULL)
return Acad::eNotImplementedYet;
pVerBot[0] = cplCurve.at(0).ptGe[0];
pVerBot[1] = cplCurve.at(0).ptGe[1];
pVerBot[2] = cplCurve.at(1).ptGe[1];
pVerBot[3] = cplCurve.at(2).ptGe[1];
pVerBot[4] = cplCurve.at(3).ptGe[1];
pVerBot[5] = cplCurve.at(4).ptGe[1];
pVerBot[6] = cplCurve.at(5).ptGe[1];
pVerBot[7] = cplCurve.at(6).ptGe[1];
pVerBot[8] = cplCurve.at(7).ptGe[1];
pVerBot[9] = cplCurve.at(8).ptGe[1];
pVerBot[10] = cplCurve.at(9).ptGe[1];
pVerBot[11] = cplCurve.at(10).ptGe[1];
// Cover
pVerCover[0] = pVerBot[0] + vtNormal * dH;
pVerCover[1] = pVerBot[1] + vtNormal * dH;
pVerCover[2] = pVerBot[2] + vtNormal * dH;
pVerCover[3] = pVerBot[3] + vtNormal * dH;
pVerCover[4] = pVerBot[4] + vtNormal * dH;
pVerCover[5] = pVerBot[5] + vtNormal * dH;
pVerCover[6] = pVerBot[6] + vtNormal * dH;
pVerCover[7] = pVerBot[7] + vtNormal * dH;
pVerCover[8] = pVerBot[8] + vtNormal * dH;
pVerCover[9] = pVerBot[9] + vtNormal * dH;
pVerCover[10] = pVerBot[10] + vtNormal * dH;
pVerCover[11] = pVerBot[11] + vtNormal * dH;
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
mode.SetColor(curColor);
static Adesk::Int32 faceList[] = {12,0,1,2,3,4,5,6,7,8,9,10,11};
mode.DrawShell(12,pVerBot,13,faceList);
//侧面
CreateFace2(mode,pVerBot[1],pVerBot[2],pVerBot[3],
pVerCover[1],pVerCover[2],pVerCover[3]);
CreateFace2(mode,pVerBot[4],pVerBot[5],pVerBot[6],
pVerCover[4],pVerCover[5],pVerCover[6]);
CreateFace2(mode,pVerBot[7],pVerBot[8],pVerBot[9],
pVerCover[7],pVerCover[8],pVerCover[9]);
CreateFace2(mode,pVerBot[10],pVerBot[11],pVerBot[0],
pVerCover[10],pVerCover[11],pVerCover[0]);
if (nCover == TDb::eCover)
{
static Adesk::Int32 faceList2[] = {12,0,1,2,3,4,5,6,7,8,9,10,11};
mode.DrawShell(12,pVerCover,13,faceList2);
}
delete []pVerBot;
pVerBot = NULL;
delete []pVerCover;
pVerCover = NULL;
return Acad::eOk;
}
void TEImpCabCross::CreateFace(XExplodeDraw &mode,AcGePoint3d& pt1,AcGePoint3d& pt2,AcGePoint3d& pt3,AcGePoint3d& pt4,
AcGePoint3d& pt5,AcGePoint3d& pt6,AcGePoint3d& pt7,AcGePoint3d& pt8) const
{
AcGePoint3d* pVer = new AcGePoint3d[8];
if ( pVer == NULL ) return;
pVer[0] = pt1;
pVer[1] = pt2;
pVer[2] = pt3;
pVer[3] = pt4;
pVer[4] = pt5;
pVer[5] = pt6;
pVer[6] = pt7;
pVer[7] = pt8;
mode.DrawMesh(2,4,pVer);
delete []pVer;
pVer = NULL;
}
void TEImpCabCross::CreateFace2(XExplodeDraw &mode,AcGePoint3d& pt1,AcGePoint3d& pt2,AcGePoint3d& pt3,AcGePoint3d& pt4,
AcGePoint3d& pt5,AcGePoint3d& pt6) const
{
AcGePoint3d* pVer = new AcGePoint3d[8];
if ( pVer == NULL ) return;
pVer[0] = pt1;
pVer[1] = pt2;
pVer[2] = pt3;
pVer[3] = pt4;
pVer[4] = pt5;
pVer[5] = pt6;
mode.DrawMesh(2,3,pVer);
delete []pVer;
pVer = NULL;
}
Acad::ErrorStatus TEImpCabCross::ExplodeOrDraw2d(XExplodeDraw &mode) const
{
if (m_pXDataMap == NULL)
{
return Acad::eNotImplementedYet;
}
TComplexCurve cplCurve;
MakeCurves(cplCurve);
TDbExtentsEdge edage;
edage.SetEdage(cplCurve);
BOOL bWeight = FALSE;
m_pXDataMap->GetAt(KEY_EDAGEWEIGHT,bWeight);
AcDbObjectId idReal = ((TDbInterfacesObj*)m_pOwnerEnt)->layerId();
AcDbObjectId idDash = ((TDbInterfacesObj*)m_pOwnerEnt)->DashLayer();
AcDbObjectId idCent = ((TDbInterfacesObj*)m_pOwnerEnt)->CenterLayer();
edage.ExplodeOrDraw2d(mode,idReal,idDash,idCent,NULL,bWeight,FALSE);
/*TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int i = 0;i < cplCurve.length();i++)
{
el = cplCurve.at(i);
if (el.ptGe[1].distanceTo(el.ptGe[2]) < 1.e-10)
{
mode->geometry().polyline(2,el.ptGe);
}
else
{
if (el.ptGe[0].distanceTo(el.ptGe[1]) > 1.e-10 &&
el.ptGe[1].distanceTo(el.ptGe[2]) > 1.e-10)
{
mode->geometry().circularArc(el.ptGe[0],el.ptGe[1],el.ptGe[2]);
}
}
}*/
return Acad::eOk;
}
BOOL TEImpCabCross::NoneConectLineIfNeed(TComplexCurve& cplCurve) const
{
TInterface inf;
int nIndex = -1;
int nInfCount = GetInterfaceCount();
for (int i = 0;i < nInfCount;i++)
{
// 获取接口
if (GetInterface(i,inf))
{
// 判断是否有连接物
if (GetInterface(inf.GetPosition(),inf))
{
// 获取连接点所在的线段索引号
if (GetIndexOfPointIsOn(cplCurve,inf.GetPosition(),nIndex))
{
cplCurve.removeAt(nIndex);
}
}
}
}
return TRUE;
}
BOOL TEImpCabCross::GetIndexOfPointIsOn(TComplexCurve& cplCurv,const AcGePoint3d& ptOn,int& nIndex) const
{
AcDbLine line;
AcGePoint3d ptFind;
for (int i = 0;i < cplCurv.length();i++)
{
line.setStartPoint(cplCurv[i].ptGe[0]);
line.setEndPoint(cplCurv[i].ptGe[1]);
line.getClosestPointTo(ptOn,ptFind);
// 是否和最近点相同
if (ptOn.distanceTo(ptFind) < 1.0e-3)
{
nIndex = i;
return TRUE;
}
}
return FALSE;
}
Acad::ErrorStatus TEImpCabCross::getStretchPoints(AcGePoint3dArray& stretchPoints) const
{
if (m_pXDataMap != NULL)
{
AcGePoint3d ptGeM,ptGeS,ptGeE,ptGeTop,ptGeDown;
AcGeVector3d vtDir,vtNormal,vtMinDir,vtPreCross,vtMajNor,vtMinNor;
double dLen = 0.0,dH = 0.0;
if ( m_pXDataMap->GetAt(KEY_MID,ptGeM) &&
m_pXDataMap->GetAt(KEY_L,dLen) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal))
{
int nStyle = 0;
m_pXDataMap->GetAt(KEY_CROSS,nStyle);
dLen /= 2.0;
switch(nStyle)
{
case TDb::eOldCbotHorEqualCross:
case TDb::eCbotHorEqualCross:
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtNormal = vtDir;
vtNormal.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
}
// 2012/11/20 alter by wzh
vtDir.normalize();
vtMinDir.normalize();
if (!vtDir.isParallelTo(vtMinDir) && !vtDir.isPerpendicularTo(vtMinDir))
{
// 斜向四通
vtPreCross = vtMinDir;
vtPreCross.normalize();
}
else
{
vtPreCross = vtDir;
vtPreCross.rotateBy(PI / 2.0,vtNormal);
vtDir.normalize();
vtPreCross.normalize();
}
//////////////////////////////////////////////////////////////////////////
// 2012/11/20 comment by wzh
// vtPreCross = vtDir;
// vtPreCross.rotateBy(PI / 2.0,vtNormal);
// vtDir.normalize();
// vtPreCross.normalize();
ptGeS = ptGeM - vtDir * dLen;
ptGeE = ptGeM + vtDir * dLen;
ptGeTop = ptGeM + vtPreCross * dLen;
ptGeDown = ptGeM - vtPreCross * dLen;
break;
}
case TDb::eCrossForSpace:
{
m_pXDataMap->GetAt(KEY_MAJBR,vtDir);
m_pXDataMap->GetAt(KEY_MINBR,vtMinDir);
m_pXDataMap->GetAt(KEY_MAJNOR,vtMajNor);
m_pXDataMap->GetAt(KEY_MINNOR,vtMinNor);
m_pXDataMap->GetAt(KEY_H,dH);
vtDir.normalize();
vtMinDir.normalize();
vtMajNor.normalize();
vtMinNor.normalize();
vtPreCross = vtMinDir;
ptGeS = ptGeM - vtDir*dLen - vtMajNor*dH/2;
ptGeE = ptGeM + vtDir*dLen - vtMajNor*dH/2;
ptGeTop = ptGeM - vtMinDir*dLen - vtMinNor*dH/2;
ptGeDown = ptGeM + vtMinDir*dLen - vtMinNor*dH/2;
break;
}
default:
break;
}
//传统夹点
stretchPoints.append(ptGeS); //STA
stretchPoints.append(ptGeM); //MID
stretchPoints.append(ptGeE); //END
stretchPoints.append(ptGeTop); //TOP
stretchPoints.append(ptGeDown); //DOW
}
}
return Acad::eOk;
}
Acad::ErrorStatus TEImpCabCross::getGripPoints(AcGePoint3dArray& gripPoints,
AcDbIntArray& osnapModes,
AcDbIntArray& geomIds) const
{
if (m_pXDataMap != NULL)
{
AcGePoint3d ptGeM,ptGeS,ptGeE,ptGeTop,ptGeDown;
AcGeVector3d vtDir,vtNormal,vtMinDir,vtPreCross,vtMajNor,vtMinNor;
double dLen = 0.0,dH = 0.0;
if ( m_pXDataMap->GetAt(KEY_MID,ptGeM) &&
m_pXDataMap->GetAt(KEY_L,dLen) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal))
{
int nStyle = 0;
m_pXDataMap->GetAt(KEY_CROSS,nStyle);
dLen /= 2.0;
switch(nStyle)
{
case TDb::eOldCbotHorEqualCross:
case TDb::eCbotHorEqualCross:
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
m_pXDataMap->GetAt(KEY_MINBR,vtMinDir); // 2012/11/20 add by wzh
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtNormal = vtDir;
vtNormal.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
}
// 2012/11/20 alter by wzh
vtDir.normalize();
vtMinDir.normalize();
if (!vtDir.isParallelTo(vtMinDir) && !vtDir.isPerpendicularTo(vtMinDir))
{
// 斜向四通
vtPreCross = vtMinDir;
vtPreCross.normalize();
}
else
{
vtPreCross = vtDir;
vtPreCross.rotateBy(PI / 2.0,vtNormal);
vtDir.normalize();
vtPreCross.normalize();
}
//////////////////////////////////////////////////////////////////////////
// 2012/11/20 comment by wzh
// vtPreCross = vtDir;
// vtPreCross.rotateBy(PI / 2.0,vtNormal);
// vtDir.normalize();
// vtPreCross.normalize();
ptGeS = ptGeM - vtDir * dLen;
ptGeE = ptGeM + vtDir * dLen;
ptGeTop = ptGeM + vtPreCross * dLen;
ptGeDown = ptGeM - vtPreCross * dLen;
break;
}
case TDb::eCrossForSpace:
{
m_pXDataMap->GetAt(KEY_MAJBR,vtDir);
m_pXDataMap->GetAt(KEY_MINBR,vtMinDir);
m_pXDataMap->GetAt(KEY_MAJNOR,vtMajNor);
m_pXDataMap->GetAt(KEY_MINNOR,vtMinNor);
m_pXDataMap->GetAt(KEY_H,dH);
vtDir.normalize();
vtMinDir.normalize();
vtMajNor.normalize();
vtMinNor.normalize();
vtPreCross = vtMinDir;
ptGeS = ptGeM - vtDir*dLen - vtMajNor*dH/2;
ptGeE = ptGeM + vtDir*dLen - vtMajNor*dH/2;
ptGeTop = ptGeM - vtMinDir*dLen - vtMinNor*dH/2;
ptGeDown = ptGeM + vtMinDir*dLen - vtMinNor*dH/2;
break;
}
default:
break;
}
//传统夹点
gripPoints.append(ptGeS); //STA
gripPoints.append(ptGeM); //MID
gripPoints.append(ptGeE); //END
gripPoints.append(ptGeTop); //TOP
gripPoints.append(ptGeDown); //DOW
//增加2个命令夹点
AcGePoint3d ptGeT;
//按 10 个像素点
double dCmd = TSupportFunc::PixelToWcs(10);
ptGeT = ptGeS + vtDir * dCmd;
gripPoints.append(ptGeT); //cmd1
ptGeT = ptGeE - vtDir * dCmd;
gripPoints.append(ptGeT); //cmd2
ptGeT = ptGeTop - vtPreCross * dCmd;
gripPoints.append(ptGeT); //cmd3
ptGeT = ptGeDown + vtPreCross * dCmd;
gripPoints.append(ptGeT); //cmd4
}
}
return Acad::eOk;
}
Acad::ErrorStatus TEImpCabCross::moveStretchPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
return moveGripPointsAt(indices,offset);
}
Acad::ErrorStatus TEImpCabCross::moveGripPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
if (m_pXDataMap != NULL)
{
OnHorSameRCrossMoveGripPointsAt(indices,offset);
}
return Acad::eOk;
}
Acad::ErrorStatus TEImpCabCross::OnHorSameRCrossMoveGripPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset)
{
int nSize = indices.length();
if (nSize > 0)
{
AcGePoint3d ptGeM,ptGeS,ptGeE,ptGeTop,ptGeDown;
AcGeVector3d vtDir,vtNormal,vtPreCross,vtMinDir,vtMajNor,vtMinNor;
double dLen = 0.0,dH = 0.0;
int nStyle = 0;
if (!m_pXDataMap->GetAt(KEY_MID,ptGeM) ||
!m_pXDataMap->GetAt(KEY_L,dLen) ||
!m_pXDataMap->GetAt(KEY_NORMAL,vtNormal))
{
return Acad::eKeyNotFound;
}
m_pXDataMap->GetAt(KEY_CROSS,nStyle);
dLen /= 2.0;
switch(nStyle)
{
case TDb::eOldCbotHorEqualCross:
case TDb::eCbotHorEqualCross:
{
BOOL bIncline = FALSE;
m_pXDataMap->GetAt(KEY_INCLINE_FIT, bIncline);
if (bIncline)
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
m_pXDataMap->GetAt(KEY_MINBR,vtPreCross);
}
else
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtNormal = vtDir;
vtNormal.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
}
vtPreCross = vtDir;
vtPreCross.rotateBy(PI / 2.0,vtNormal);
}
vtDir.normalize();
vtPreCross.normalize();
ptGeS = ptGeM - vtDir * dLen;
ptGeE = ptGeM + vtDir * dLen;
ptGeTop = ptGeM + vtPreCross * dLen;
ptGeDown = ptGeM - vtPreCross * dLen;
break;
}
case TDb::eCrossForSpace:
{
m_pXDataMap->GetAt(KEY_MAJBR,vtDir);
m_pXDataMap->GetAt(KEY_MINBR,vtMinDir);
m_pXDataMap->GetAt(KEY_MAJNOR,vtMajNor);
m_pXDataMap->GetAt(KEY_MINNOR,vtMinNor);
m_pXDataMap->GetAt(KEY_H,dH);
vtDir.normalize();
vtMinDir.normalize();
vtMajNor.normalize();
vtMinNor.normalize();
vtPreCross = vtMinDir;
ptGeS = ptGeM - vtDir*dLen - vtMajNor*dH/2;
ptGeE = ptGeM + vtDir*dLen - vtMajNor*dH/2;
ptGeTop = ptGeM - vtMinDir*dLen - vtMinNor*dH/2;
ptGeDown = ptGeM + vtMinDir*dLen - vtMinNor*dH/2;
break;
}
default:
break;
}
AcGePoint3d ptGeMOld = ptGeM;
// 选择多个夹点,以first为准
int nIndex = indices.first();
TDb::Position ePos = ExplainGripIndex(nIndex);
switch(ePos)
{
case TDb::eBr1:
{
// 修改原因: 对于非正交的移动会使连接的桥架做错误图形变化
// 修改人 : tsj
// 修改时间:2009.11.24
//平行,或垂直按moveGrip 接口消息逻辑
//非平行,按transform 接口消息逻辑
// TDb::InterfaceOper eOper = TDb::eMoveGripPoint;
// if (vtDir.isParallelTo(offset))//平行
// {
// }
// else if (vtDir.isPerpendicularTo(offset))//垂直
// {
// }
// else
// {
// eOper = TDb::eTransformBy;
// }
ptGeM += offset;
m_pXDataMap->SetAt(KEY_MID,ptGeM);
if (m_pOwnerEnt != NULL && m_pOwnerEnt->objectId().isValid())
{
if (vtDir.isParallelTo(offset) || vtDir.isPerpendicularTo(offset))
{
// 写入接口更改消息
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeS);//new pos
iMsg.SetGripPosition(TDb::eBr1);
iMsg.SetMoveGripOffset(offset);
// if (eOper == TDb::eTransformBy)
// iMsg.SetTransform(offset);
iMsg.SetMsgValidate(TRUE);
/* iMsg.SetInterfaceOper(eOper);*/
iMsg.SetInterfaceOper(TDb::eMoveGripPoint);
iMsg.SetMsgOperateOn(m_pOwnerEnt->objectId());
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
}
//更新接口记录接口信息
AcGeMatrix3d xform;
xform.setToTranslation(offset);
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
}
}
break;
case TDb::eMid:
{
if (offset.isZeroLength())
return Acad::eOk;
ptGeM += offset;
m_pXDataMap->SetAt(KEY_MID,ptGeM);
if (m_pOwnerEnt != NULL && m_pOwnerEnt->objectId().isValid())
{
//modify by bsl 增加斜向四通支持
//if (vtDir.isParallelTo(offset) || vtDir.isPerpendicularTo(offset))
if (vtDir.isParallelTo(offset) || vtPreCross.isParallelTo(offset))
{
// 写入接口更改消息
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeMOld);//new pos
iMsg.SetGripPosition(TDb::eMid);
iMsg.SetMoveGripOffset(offset);
iMsg.SetMsgValidate(TRUE);
iMsg.SetInterfaceOper(TDb::eMoveGripPoint);
iMsg.SetMsgOperateOn(m_pOwnerEnt->objectId());
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
}
//更新接口记录接口信息
AcGeMatrix3d xform;
xform.setToTranslation(offset);
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
}
}
break;
case TDb::eBr2:
{
//平行,或垂直按moveGrip 接口消息逻辑
//非平行,按transform 接口消息逻辑
// TDb::InterfaceOper eOper = TDb::eMoveGripPoint;
// AcGeVector3d vtIntf = ptGeE - ptGeM;
// if (vtIntf.isParallelTo(offset))//平行
// {
// }
// else if (vtIntf.isPerpendicularTo(offset))//垂直
// {
// }
// else
// {
// eOper = TDb::eTransformBy;
// }
ptGeM += offset;
m_pXDataMap->SetAt(KEY_MID,ptGeM);
if (m_pOwnerEnt != NULL && m_pOwnerEnt->objectId().isValid())
{
if (vtDir.isParallelTo(offset) || vtDir.isPerpendicularTo(offset))
{
// 写入接口更改消息
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeE);//new pos
iMsg.SetGripPosition(TDb::eBr2);
iMsg.SetMoveGripOffset(offset);
// if (eOper == TDb::eTransformBy)
// iMsg.SetTransform(offset);
iMsg.SetMsgValidate(TRUE);
/* iMsg.SetInterfaceOper(eOper);*/
iMsg.SetInterfaceOper(TDb::eMoveGripPoint);
iMsg.SetMsgOperateOn(m_pOwnerEnt->objectId());
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
}
//更新接口记录接口信息
AcGeMatrix3d xform;
xform.setToTranslation(offset);
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
}
}
break;
case TDb::eBr3:
{
//平行,或垂直按moveGrip 接口消息逻辑
//非平行,按transform 接口消息逻辑
// TDb::InterfaceOper eOper = TDb::eMoveGripPoint;
// AcGeVector3d vtIntf = ptGeE - ptGeM;
// if (vtIntf.isParallelTo(offset))//平行
// {
// }
// else if (vtIntf.isPerpendicularTo(offset))//垂直
// {
// }
// else
// {
// eOper = TDb::eTransformBy;
// }
ptGeM += offset;
m_pXDataMap->SetAt(KEY_MID,ptGeM);
if (m_pOwnerEnt != NULL && m_pOwnerEnt->objectId().isValid())
{
if (vtDir.isParallelTo(offset) || vtDir.isPerpendicularTo(offset))
{
// 写入接口更改消息
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeTop);//new pos
iMsg.SetGripPosition(TDb::eBr3);
iMsg.SetMoveGripOffset(offset);
// if (eOper == TDb::eTransformBy)
// iMsg.SetTransform(offset);
iMsg.SetMsgValidate(TRUE);
/* iMsg.SetInterfaceOper(eOper);*/
iMsg.SetInterfaceOper(TDb::eMoveGripPoint);
iMsg.SetMsgOperateOn(m_pOwnerEnt->objectId());
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
}
//更新接口记录接口信息
AcGeMatrix3d xform;
xform.setToTranslation(offset);
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
}
}
break;
case TDb::eBr4:
{
//平行,或垂直按moveGrip 接口消息逻辑
//非平行,按transform 接口消息逻辑
// TDb::InterfaceOper eOper = TDb::eMoveGripPoint;
// AcGeVector3d vtIntf = ptGeE - ptGeM;
// if (vtIntf.isParallelTo(offset))//平行
// {
// }
// else if (vtIntf.isPerpendicularTo(offset))//垂直
// {
// }
// else
// {
// eOper = TDb::eTransformBy;
// }
ptGeM += offset;
m_pXDataMap->SetAt(KEY_MID,ptGeM);
if (m_pOwnerEnt != NULL && m_pOwnerEnt->objectId().isValid())
{
if (vtDir.isParallelTo(offset) || vtDir.isPerpendicularTo(offset))
{
// 写入接口更改消息
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeDown);//new pos
iMsg.SetGripPosition(TDb::eBr4);
iMsg.SetMoveGripOffset(offset);
// if (eOper == TDb::eTransformBy)
// iMsg.SetTransform(offset);
iMsg.SetMsgValidate(TRUE);
/* iMsg.SetInterfaceOper(eOper);*/
iMsg.SetInterfaceOper(TDb::eMoveGripPoint);
iMsg.SetMsgOperateOn(m_pOwnerEnt->objectId());
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
}
//更新接口记录接口信息
AcGeMatrix3d xform;
xform.setToTranslation(offset);
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
}
}
break;
case TDb::eCommand0:
{
AcGeVector3d vtLine = ptGeS - ptGeM;
if (nStyle == TDb::eCrossForSpace)
{
vtLine = -1*vtDir;
}
// 写入接口更改消息
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeS);//new pos
iMsg.SetGripPosition(TDb::eCommand0);
iMsg.SetMoveGripOffset(vtLine);
iMsg.SetMsgValidate(TRUE);
iMsg.SetInterfaceOper(TDb::eNewCommand);
AcDbSoftPointerId idOwner;
m_pXDataMap->GetAt(KEY_THISID,idOwner);
iMsg.SetMsgOperateOn(idOwner);
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
acedPostCommand(_T("\33"));
CString sCmd;
GetGlobalContext(KEY_CABGRIPCMD,sCmd);
if (!sCmd.IsEmpty())
{
sCmd += _T("\n");
acedPostCommand(sCmd);
}
}
break;
case TDb::eCommand1:
{
AcGeVector3d vtLine = ptGeE - ptGeM;
if (nStyle == TDb::eCrossForSpace)
{
vtLine = vtDir;
}
// 写入接口更改消息
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeE);//new pos
iMsg.SetGripPosition(TDb::eCommand1);
iMsg.SetMoveGripOffset(vtLine);
iMsg.SetMsgValidate(TRUE);
iMsg.SetInterfaceOper(TDb::eNewCommand);
AcDbSoftPointerId idOwner;
m_pXDataMap->GetAt(KEY_THISID,idOwner);
iMsg.SetMsgOperateOn(idOwner);
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
acedPostCommand(_T("\33"));
CString sCmd;
GetGlobalContext(KEY_CABGRIPCMD,sCmd);
if (!sCmd.IsEmpty())
{
sCmd += _T("\n");
acedPostCommand(sCmd);
}
}
break;
case TDb::eCommand2:
{
AcGeVector3d vtLine = ptGeTop - ptGeM;
if (nStyle == TDb::eCrossForSpace)
{
vtLine = -1*vtMinDir;
}
// 写入接口更改消息
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeTop);//new pos
iMsg.SetGripPosition(TDb::eCommand2);
iMsg.SetMoveGripOffset(vtLine);
iMsg.SetMsgValidate(TRUE);
iMsg.SetInterfaceOper(TDb::eNewCommand);
AcDbSoftPointerId idOwner;
m_pXDataMap->GetAt(KEY_THISID,idOwner);
iMsg.SetMsgOperateOn(idOwner);
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
acedPostCommand(_T("\33"));
CString sCmd;
GetGlobalContext(KEY_CABGRIPCMD,sCmd);
if (!sCmd.IsEmpty())
{
sCmd += _T("\n");
acedPostCommand(sCmd);
}
}
break;
case TDb::eCommand3:
{
AcGeVector3d vtLine = ptGeDown - ptGeM;
if (nStyle == TDb::eCrossForSpace)
{
vtLine = vtMinDir;
}
// 写入接口更改消息
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeDown);//new pos
iMsg.SetGripPosition(TDb::eCommand3);
iMsg.SetMoveGripOffset(vtLine);
iMsg.SetMsgValidate(TRUE);
iMsg.SetInterfaceOper(TDb::eNewCommand);
AcDbSoftPointerId idOwner;
m_pXDataMap->GetAt(KEY_THISID,idOwner);
iMsg.SetMsgOperateOn(idOwner);
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
acedPostCommand(_T("\33"));
CString sCmd;
GetGlobalContext(KEY_CABGRIPCMD,sCmd);
if (!sCmd.IsEmpty())
{
sCmd += _T("\n");
acedPostCommand(sCmd);
}
}
break;
default:
break;
}
}
return Acad::eOk;
}
Acad::ErrorStatus TEImpCabCross::transformBy(const AcGeMatrix3d& xform)
{
if (m_pXDataMap != NULL)
{
AcGePoint3d ptGeM;
AcGeVector3d vtDir,vtNormal;
if (m_pXDataMap->GetAt(KEY_MID,ptGeM) &&
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) )
{
ptGeM.transformBy(xform);
vtDir.transformBy(xform);
vtNormal.transformBy(xform);
m_pXDataMap->SetAt(KEY_MID,ptGeM);
m_pXDataMap->SetAt(KEY_MAINDIR,vtDir);
m_pXDataMap->SetAt(KEY_NORMAL,vtNormal);
if (m_pOwnerEnt->objectId().isValid())
{
// 写入接口更改消息
TInterfaceModifyMsg iMsg;
iMsg.SetInterfaceOper(TDb::eTransformBy);
iMsg.SetMsgValidate(TRUE);
iMsg.SetTransform(xform);
iMsg.SetMsgOperateOn(m_pOwnerEnt->objectId());
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
//更新接口记录接口信息
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
}
}
}
return Acad::eOk;
}
Acad::ErrorStatus TEImpCabCross::getOsnapPoints(AcDb::OsnapMode osnapMode,
INT_PTR gsSelectionMark,
const AcGePoint3d& pickPoint,
const AcGePoint3d& lastPoint,
const AcGeMatrix3d& viewXform,
AcGePoint3dArray& snapPoints,
AcDbIntArray& geomIds) const
{
if (m_pXDataMap != NULL)
{
switch(osnapMode)
{
case AcDb::kOsModeEnd:
{
TComplexCurve cplCurve;
int nNum = MakeCurvesBase(cplCurve);
for (int i = 0;i < nNum;i++)
{
snapPoints.append(cplCurve[i].ptGe[0]);
}
AcGePoint3d ptGeM;
AcGeVector3d vtDir,vtNormal;
double dLen = 0.0;
if (m_pXDataMap->GetAt(KEY_MID,ptGeM) &&
m_pXDataMap->GetAt(KEY_L,dLen) &&
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) )
{
dLen /= 2.0;
AcGeVector3d vtPreCross = vtDir;
vtPreCross.rotateBy(PI / 2.0,vtNormal);
vtDir.normalize();
vtPreCross.normalize();
AcGePoint3d ptGeS = ptGeM - vtDir * dLen;
AcGePoint3d ptGeE = ptGeM + vtDir * dLen;
AcGePoint3d ptGeTop = ptGeM + vtPreCross * dLen;
AcGePoint3d ptGeDown = ptGeM - vtPreCross * dLen;
snapPoints.append(ptGeS);
snapPoints.append(ptGeE);
snapPoints.append(ptGeTop);
snapPoints.append(ptGeDown);
}
}
break;
case AcDb::kOsModeMid:
{
AcGePoint3d ptGeM;
if (m_pXDataMap->GetAt(KEY_MID,ptGeM))
{
snapPoints.append(ptGeM);
}
}
break;
case AcDb::kOsModePerp:
{
AcGePoint3d ptVerFoot;
if (GetVerticalFootPoint(pickPoint, lastPoint, ptVerFoot))
{
snapPoints.append(ptVerFoot);
}
}
break;
case AcDb::kOsModeNear:
{
AcGePoint3d ptNear;
if (GetNearestPoint(pickPoint, ptNear))
{
snapPoints.append(ptNear);
}
}
break;
case AcDb::kOsModeNode:
break;
}
}
return Acad::eNotImplementedYet;
}
// 获取垂足点
BOOL TEImpCabCross::GetVerticalFootPoint(const AcGePoint3d& pickPoint,
const AcGePoint3d& lastPoint,
AcGePoint3d& ptVerFoot) const
{
BOOL bIsSuc = FALSE;
TComplexCurve cplCurve;
if (MakeCurves(cplCurve))
{
GetCrossMidLine(cplCurve);
TSupportFunc spFun;
bIsSuc = spFun.GetVerticalFootPoint(cplCurve, pickPoint, lastPoint, ptVerFoot);
}
return bIsSuc;
}
// 获取中心线
BOOL TEImpCabCross::GetCrossMidLine(TComplexCurve& compCurve) const
{
return GetCurvesInSide(compCurve);
}
// 获取最近点
BOOL TEImpCabCross::GetNearestPoint(const AcGePoint3d& pickPoint,
AcGePoint3d& ptNear) const
{
BOOL bIsFind = FALSE;
TComplexCurve cplCurve;
if (MakeCurves(cplCurve))
{
GetCrossMidLine(cplCurve);
TSupportFunc spFun;
bIsFind = spFun.GetNearestPoint(cplCurve, pickPoint, ptNear);
}
return bIsFind;
}
//
AcGePoint3d TEImpCabCross::GetPolyCurMidPoint(const AcGePoint3d& pt1,const AcGePoint3d& pt2,const AcGePoint3d& ptGeM,double dAngle) const
{
AcGePoint3d ptOr = GetPolyCurveCentre(pt1,pt2,ptGeM,dAngle);
AcGeVector3d vtT = ptOr - ptGeM;
vtT.normalize();
double dL = ptOr.distanceTo(pt1);
return ptOr - vtT * dL;
}
// 计算外切于两等距线的圆心 2012/11/16 add by wzh
AcGePoint3d TEImpCabCross::GetPolyCurveCentre(const AcGePoint3d& pt1,const AcGePoint3d& pt2,const AcGePoint3d& ptGeM,double dAngle) const
{
AcDbLine line(pt1, pt2); // 旋
AcGePoint3d ptOnLine;
line.getClosestPointTo(ptGeM, ptOnLine);
AcGeVector3d vtCircle = ptOnLine - ptGeM; // 指向圆心向量
vtCircle.normalize();
AcGePoint3d ptMid = TAuxTools::Mid(pt1, pt2); // 旋中点
double dLC = pt1.distanceTo(pt2) / 2; // 旋长一半
double dL = pt1.distanceTo(ptGeM); // 切线长
double dR = dL * tan(dAngle/2); // 圆半径
double dTmp = dR * dLC / dL; // 旋中点至圆心距离
return ptMid + vtCircle * dTmp;
}
// 判断当前视口是否为3d
BOOL TEImpCabCross::EnsureCurViewPortIs3D(const AcGeVector3d& vtNormal) const//暂时未用到
{
AcGeVector3d vtViewDir = AcGeVector3d::kZAxis;
struct resbuf rb;
memset (&rb, 0, sizeof (struct resbuf));
acedGetVar(_T("VIEWDIR"), &rb);
vtViewDir.set(rb.resval.rpoint[X], rb.resval.rpoint[Y], rb.resval.rpoint[Z]);
vtViewDir.normalize();
if (vtViewDir.isPerpendicularTo(vtNormal)) // 平行代表3d
{
return TRUE;
}
return FALSE;
}
Acad::ErrorStatus TEImpCabCross::getClassID(CLSID* pClsid) const
{
// #if (ADS < 16)
// CLSID CLSID_FittingBaseEntity = {0x1F6683C7, 0xD6BF, 0x4160, { 0x9D, 0xF1, 0xDB, 0xAA, 0x8F, 0x77, 0xC6, 0x7C }};
// *pClsid = CLSID_FittingBaseEntity;
// #endif
//
// #if (ADS == 16)
// CLSID CLSID_FittingBaseEntity = {0x1F6683C7, 0xD6BF, 0x4160, { 0x9D, 0xF1, 0xDB, 0xAA, 0x8F, 0x77, 0xC6, 0x7D }};
// *pClsid = CLSID_FittingBaseEntity;
// #endif
//
// #if (ADS == 17)
// CLSID CLSID_FittingBaseEntity = {0x1F6683C7, 0xD6BF, 0x4160, { 0x9D, 0xF1, 0xDB, 0xAA, 0x8F, 0x77, 0xC6, 0x7E }};
// *pClsid = CLSID_FittingBaseEntity;
// #endif
//
// #if (ADS == 18)
// CLSID CLSID_FittingBaseEntity = {0x1F6683C7, 0xD6BF, 0x4160, { 0x9D, 0xF1, 0xDB, 0xAA, 0x8F, 0x77, 0xC6, 0x7F }};
// *pClsid = CLSID_FittingBaseEntity;
// #endif
return Acad::eOk;
}
CString TEImpCabCross::GetCurrentTypeName() const
{
CString strName = _T("");
if (m_pXDataMap != NULL)
{
strName = (_T("槽式水平等径四通"));
int nStyle = 0;
m_pXDataMap->GetAt(KEY_STYLE,nStyle);
switch(nStyle)
{
case TDb::eP:
{
strName.Replace(_T("槽式"),_T("盘式"));
break;
}
case TDb::eT:
{
strName.Replace(_T("槽式"),_T("梯式"));
break;
}
default:
break;
}
}
return strName;
}
void TEImpCabCross::list() const
{
if (m_pXDataMap != NULL)
{
CString strType = _T("");
double dH = 0.0,dB = 0.0,dLen = 0.0;
m_pXDataMap->GetAt(KEY_L,dLen);
m_pXDataMap->GetAt(KEY_B,dB);
m_pXDataMap->GetAt(KEY_H,dH);
m_pXDataMap->GetAt(KEY_TYPE,strType);
acutPrintf(_T("\n\t\t\t\t\t\t\t\t%s\n"),GetCurrentTypeName());
acutPrintf(_T("\n\t\t\t\t\t型号: %s"),strType);
acutPrintf(_T("\n\t\t\t\t\t长度: %.0f"),dLen);
acutPrintf(_T("\n\t\t\t\t\t宽度: %.0f"),dB);
acutPrintf(_T("\n\t\t\t\t\t高度: %.0f\n"),dH);
}
}
void TEImpCabCross::GetTips(CMapStringToString& mapLable2Tip) const
{
if (m_pXDataMap != NULL)
{
double dH = 0.0,dB = 0.0;
AcGePoint3d ptM;
CString strTemp = _T("");
m_pXDataMap->GetAt(KEY_MID,ptM);
m_pXDataMap->GetAt(KEY_H,dH);
m_pXDataMap->GetAt(KEY_B,dB);
m_pXDataMap->GetAt(KEY_TYPE,strTemp);
mapLable2Tip.SetAt(_T("对象类型"), GetCurrentTypeName());
mapLable2Tip.SetAt(_T("型号"), strTemp);
strTemp.Format(_T("%d"),(int)ptM.z);
mapLable2Tip.SetAt(_T("中心标高"), strTemp);
strTemp.Format(_T("%d"),(int)dB);
mapLable2Tip.SetAt(_T("宽度"), strTemp);
strTemp.Format(_T("%d"),(int)dH);
mapLable2Tip.SetAt(_T("高度"), strTemp);
}
}
int TEImpCabCross::GetXBaseShellForPlane(TXShell& xShell)
{
int nRet = 0;
// 构建点
AcGePoint3d ptGeM;
AcGeVector3d vtNormal,vtDir;
double dHeight = 0.0,dB = 0.0,dLen = 0.0;
m_pXDataMap->GetAt(KEY_MID,ptGeM);
m_pXDataMap->GetAt(KEY_L,dLen);
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
m_pXDataMap->GetAt(KEY_B,dB);
m_pXDataMap->GetAt(KEY_H,dHeight);
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal);
dLen /= 2;
int nLinNum = 0;
const int nSize = 17;
AcGePoint3d* pBotVer = new AcGePoint3d[nSize];
AcGePoint3d* pTopVer = new AcGePoint3d[nSize];
if (pBotVer != NULL && pTopVer != NULL)
{
double dAngle = PI / 2.0;
AcGeVector3d vtPreCross = vtDir;
vtPreCross.rotateBy(dAngle,vtNormal);
vtDir.normalize();
vtPreCross.normalize();
AcGePoint3d ptGeS = ptGeM - vtDir * dLen;
AcGePoint3d ptGeE = ptGeM + vtDir * dLen;
AcGePoint3d ptGeTop = ptGeM + vtPreCross * dLen;
AcGePoint3d ptGeDown = ptGeM - vtPreCross * dLen;
// 底面
pBotVer[13] = ptGeS + vtPreCross * (dB / 2.0);
pBotVer[12] = ptGeS - vtPreCross * (dB / 2.0);
pBotVer[4] = ptGeE + vtPreCross * (dB / 2.0);
pBotVer[5] = ptGeE - vtPreCross * (dB / 2.0);
pBotVer[1] = ptGeTop + vtDir * (dB / 2.0);
pBotVer[0] = ptGeTop - vtDir * (dB / 2.0);
pBotVer[16] = pBotVer[0];
pBotVer[8] = ptGeDown + vtDir * (dB / 2.0);
pBotVer[9] = ptGeDown - vtDir * (dB / 2.0);
double dTemp = 0.5 * (dLen - 0.5 * dB);
pBotVer[15] = pBotVer[0] - vtPreCross * dTemp;
pBotVer[10] = pBotVer[9] + vtPreCross * dTemp;
dTemp = 0.5 * (dLen - 0.5 * dB);
pBotVer[2] = pBotVer[1] - vtPreCross * dTemp;
pBotVer[7] = pBotVer[8] + vtPreCross * dTemp;
dTemp = 0.5 * (dLen - 0.5 * dB);
pBotVer[3] = pBotVer[4] - vtDir * dTemp;
pBotVer[14] = pBotVer[13] + vtDir * dTemp;
dTemp = 0.5 * (dLen - 0.5 * dB);
pBotVer[6] = pBotVer[5] - vtDir * dTemp;
pBotVer[11] = pBotVer[12] + vtDir * dTemp;
// 顶面
for (int i = 0;i < nSize;i++)
{
pTopVer[i] = pBotVer[i] + vtNormal * dHeight;
}
// 创建面 -- 全封闭面
// 1.底面
xShell.AppendFace(CreateAcDbFace(pBotVer[0],pBotVer[1],pBotVer[8],pBotVer[9]));
xShell.AppendFace(CreateAcDbFace(pBotVer[10],pBotVer[11],pBotVer[14],pBotVer[15]));
xShell.AppendFace(CreateAcDbFace(pBotVer[11],pBotVer[12],pBotVer[13],pBotVer[14]));
xShell.AppendFace(CreateAcDbFace(pBotVer[2],pBotVer[3],pBotVer[6],pBotVer[7]));
xShell.AppendFace(CreateAcDbFace(pBotVer[3],pBotVer[4],pBotVer[5],pBotVer[6]));
// 2.顶面
xShell.AppendFace(CreateAcDbFace(pTopVer[0],pTopVer[1],pTopVer[8],pTopVer[9]));
xShell.AppendFace(CreateAcDbFace(pTopVer[10],pTopVer[11],pTopVer[14],pTopVer[15]));
xShell.AppendFace(CreateAcDbFace(pTopVer[11],pTopVer[12],pTopVer[13],pTopVer[14]));
xShell.AppendFace(CreateAcDbFace(pTopVer[2],pTopVer[3],pTopVer[6],pTopVer[7]));
xShell.AppendFace(CreateAcDbFace(pTopVer[3],pTopVer[4],pTopVer[5],pTopVer[6]));
// 3.封口
xShell.AppendFace(CreateAcDbFace(pBotVer[0],pBotVer[1],pTopVer[1],pTopVer[0]));
xShell.AppendFace(CreateAcDbFace(pBotVer[4],pBotVer[5],pTopVer[5],pTopVer[4]));
xShell.AppendFace(CreateAcDbFace(pBotVer[8],pBotVer[9],pTopVer[9],pTopVer[8]));
xShell.AppendFace(CreateAcDbFace(pBotVer[12],pBotVer[13],pTopVer[13],pTopVer[12]));
// 4.侧面
xShell.AppendFace(CreateAcDbFace(pBotVer[1],pBotVer[2],pTopVer[2],pTopVer[1]));
xShell.AppendFace(CreateAcDbFace(pBotVer[2],pBotVer[3],pTopVer[3],pTopVer[2]));
xShell.AppendFace(CreateAcDbFace(pBotVer[3],pBotVer[4],pTopVer[4],pTopVer[3]));
xShell.AppendFace(CreateAcDbFace(pBotVer[5],pBotVer[6],pTopVer[6],pTopVer[5]));
xShell.AppendFace(CreateAcDbFace(pBotVer[6],pBotVer[7],pTopVer[7],pTopVer[6]));
xShell.AppendFace(CreateAcDbFace(pBotVer[7],pBotVer[8],pTopVer[8],pTopVer[7]));
xShell.AppendFace(CreateAcDbFace(pBotVer[9],pBotVer[10],pTopVer[10],pTopVer[9]));
xShell.AppendFace(CreateAcDbFace(pBotVer[10],pBotVer[11],pTopVer[11],pTopVer[10]));
xShell.AppendFace(CreateAcDbFace(pBotVer[11],pBotVer[12],pTopVer[12],pTopVer[11]));
xShell.AppendFace(CreateAcDbFace(pBotVer[13],pBotVer[14],pTopVer[14],pTopVer[13]));
xShell.AppendFace(CreateAcDbFace(pBotVer[14],pBotVer[15],pTopVer[15],pTopVer[14]));
xShell.AppendFace(CreateAcDbFace(pBotVer[15],pBotVer[16],pTopVer[16],pTopVer[15]));
nRet = 1;
}
if (pBotVer != NULL)
delete []pBotVer;
if (pTopVer != NULL)
delete []pTopVer;
return nRet;
}
int TEImpCabCross::GetXBaseShellForSpace(TXShell& xShell)
{
int nRet = 0;
double dLen = 0.0,dB = 0.0,dH = 0.0,dTemp = 0.0;
AcGeVector3d vtMajNor,vtMinNor,vtMajDir,vtMinDir,vtTemp;
AcGePoint3d ptMid,ptUp,ptDown,ptL,ptR,ptTemp;
int nCover;
m_pXDataMap->GetAt(KEY_MID,ptMid);
m_pXDataMap->GetAt(KEY_L,dLen);
m_pXDataMap->GetAt(KEY_B,dB);
m_pXDataMap->GetAt(KEY_H,dH);
m_pXDataMap->GetAt(KEY_MAJNOR,vtMajNor);
m_pXDataMap->GetAt(KEY_MINNOR,vtMinNor);
//m_pXDataMap->GetAt(KEY_MAJBR,vtMajDir);
//m_pXDataMap->GetAt(KEY_MINBR,vtMinDir);
m_pXDataMap->GetAt(KEY_COVER,nCover);
vtMajDir = vtMinNor;
vtMinDir = vtMajNor;
vtMajNor.normalize();
vtMinNor.normalize();
vtMajDir.normalize();
vtMinDir.normalize();
dLen /= 2;
dTemp = (dLen - dH/2)/2;
vtTemp = vtMinDir;
vtTemp.rotateBy(PI/2,vtMinNor);
vtTemp.normalize();
ptTemp = ptMid + vtTemp*dB/2;
ptUp = ptTemp + vtMajDir*dLen;
ptDown = ptTemp - vtMajDir*dLen;
ptR = ptTemp + vtMinDir*dLen;
ptL = ptTemp - vtMinDir*dLen;
AcGePoint3d arPts[17];
arPts[0] = ptUp - vtMinDir*dH/2;
arPts[1] = ptUp + vtMinDir*dH/2;
arPts[2] = arPts[1] - vtMajDir*dTemp;
arPts[15] = arPts[0] - vtMajDir*dTemp;
arPts[4] = ptR + vtMajDir*dH/2;
arPts[5] = ptR - vtMajDir*dH/2;
arPts[3] = arPts[4] - vtMinDir*dTemp;
arPts[6] = arPts[5] - vtMinDir*dTemp;
arPts[8] = ptDown + vtMinDir*dH/2;
arPts[9] = ptDown - vtMinDir*dH/2;
arPts[7] = arPts[8] + vtMajDir*dTemp;
arPts[10] = arPts[9] + vtMajDir*dTemp;
arPts[12] = ptL - vtMajDir*dH/2;
arPts[13] = ptL + vtMajDir*dH/2;
arPts[11] = arPts[12] + vtMinDir*dTemp;
arPts[14] = arPts[13] + vtMinDir*dTemp;
arPts[16] = arPts[0];
AcGePoint3d arPts2[17];
int i = 0;
for (i = 0;i < 17;i++)
{
arPts2[i] = arPts[i] - vtTemp*dB;
}
AcGePoint3d arTemp[4];
//内外侧面
{
arTemp[0] = arPts[0];
arTemp[1] = arPts[1];
arTemp[2] = arPts[2];
arTemp[3] = arPts[15];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[15];
arTemp[1] = arPts[2];
arTemp[2] = arPts[3];
arTemp[3] = arPts[14];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[13];
arTemp[1] = arPts[4];
arTemp[2] = arPts[5];
arTemp[3] = arPts[12];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[11];
arTemp[1] = arPts[6];
arTemp[2] = arPts[7];
arTemp[3] = arPts[10];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[7];
arTemp[1] = arPts[8];
arTemp[2] = arPts[9];
arTemp[3] = arPts[10];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts2[0];
arTemp[1] = arPts2[1];
arTemp[2] = arPts2[2];
arTemp[3] = arPts2[15];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts2[15];
arTemp[1] = arPts2[2];
arTemp[2] = arPts2[3];
arTemp[3] = arPts2[14];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts2[13];
arTemp[1] = arPts2[4];
arTemp[2] = arPts2[5];
arTemp[3] = arPts2[12];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts2[11];
arTemp[1] = arPts2[6];
arTemp[2] = arPts2[7];
arTemp[3] = arPts2[10];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts2[7];
arTemp[1] = arPts2[8];
arTemp[2] = arPts2[9];
arTemp[3] = arPts2[10];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
}
//左上侧面
arTemp[0] = arPts[0];
arTemp[1] = arPts2[0];
arTemp[2] = arPts2[15];
arTemp[3] = arPts[15];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[15];
arTemp[1] = arPts2[15];
arTemp[2] = arPts2[14];
arTemp[3] = arPts[14];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
//左下侧面
arTemp[0] = arPts[12];
arTemp[1] = arPts2[12];
arTemp[2] = arPts2[11];
arTemp[3] = arPts[11];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[11];
arTemp[1] = arPts2[11];
arTemp[2] = arPts2[10];
arTemp[3] = arPts[10];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[10];
arTemp[1] = arPts2[10];
arTemp[2] = arPts2[9];
arTemp[3] = arPts[9];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
//右下侧面
arTemp[0] = arPts[7];
arTemp[1] = arPts2[7];
arTemp[2] = arPts2[6];
arTemp[3] = arPts[6];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[6];
arTemp[1] = arPts2[6];
arTemp[2] = arPts2[5];
arTemp[3] = arPts[5];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
//右上侧面
arTemp[0] = arPts[3];
arTemp[1] = arPts2[3];
arTemp[2] = arPts2[2];
arTemp[3] = arPts[2];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
{
//封盖
arTemp[0] = arPts[14];
arTemp[1] = arPts2[14];
arTemp[2] = arPts2[13];
arTemp[3] = arPts[13];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[4];
arTemp[1] = arPts2[4];
arTemp[2] = arPts2[3];
arTemp[3] = arPts[3];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[2];
arTemp[1] = arPts2[2];
arTemp[2] = arPts2[1];
arTemp[3] = arPts[1];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[8];
arTemp[1] = arPts2[8];
arTemp[2] = arPts2[7];
arTemp[3] = arPts[7];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
}
{
//封口
arTemp[0] = arPts[0];
arTemp[1] = arPts[1];
arTemp[2] = arPts2[1];
arTemp[3] = arPts2[0];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[4];
arTemp[1] = arPts[5];
arTemp[2] = arPts2[5];
arTemp[3] = arPts2[4];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[8];
arTemp[1] = arPts[9];
arTemp[2] = arPts2[9];
arTemp[3] = arPts2[8];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[12];
arTemp[1] = arPts[13];
arTemp[2] = arPts2[13];
arTemp[3] = arPts2[12];
xShell.AppendFace(CreateAcDbFace(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
}
nRet = 1;
return nRet;
}
//获取三维的壳对象
int TEImpCabCross::GetXBaseShell(TXShell& xShell)
{
/************************************************************************/
/* 0 1
16 +----+
| |
15 + + 2
14 / \ 3
13 +---+ 1 +---+ 4
| M |
12 +---+ +---+ 5
11 \ / 6
10 + + 7
| |
9 +----+ 8
/************************************************************************/
int nRet = 0;
if (m_pXDataMap != NULL)
{
int nCrossType = 0;
m_pXDataMap->GetAt(KEY_CROSS,nCrossType);
switch(nCrossType)
{
case TDb::eOldCbotHorEqualCross:
case TDb::eCbotHorEqualCross:
{
nRet = GetXBaseShellForPlane(xShell);
break;
}
case TDb::eCrossForSpace:
{
nRet = GetXBaseShellForSpace(xShell);
break;
}
}
}
return nRet;
}
//获取体的范围方块
int TEImpCabCross::GetBodyBox(AcDbExtents& ext)
{
if (m_pXDataMap == NULL)
{
return 0;
}
TXShell xShell;
GetXBaseShell(xShell);
int i = 0;
AcDbFace* pFace = NULL;
std::vector<AcGePoint3d> vctpt;
AcGePoint3d ptTemp;
int nPos = -1;
for (i = 0;i < xShell.GetCount();++i)
{
pFace = xShell.GetFace(i);
if (pFace != NULL)
{
for (int k = 0;k < 4;++k)
{
pFace->getVertexAt(k,ptTemp);
if (std::find(vctpt.begin(),vctpt.end(),ptTemp) == vctpt.end())
{
vctpt.push_back(ptTemp);
}
}
delete pFace;
}
}
AppendAcDbExtents(vctpt,ext);
/*
int nRet = 0;
if (m_pXDataMap != NULL)
{
double dH;
AcGeVector3d vtNormal;
m_pXDataMap->GetAt(KEY_H,dH);
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal);
vtNormal.normalize();
// 得到3D图形点
TComplexCurve cplCurve;
MakeCurvesBase(cplCurve);
AcGePoint3d ptTemp;
std::vector<AcGePoint3d> vctpt;
std::vector<AcGePoint3d>::iterator it;
for (int i = 0;i < cplCurve.length();i++)
{
if ((it = std::find(vctpt.begin(),vctpt.end(),cplCurve[i].ptGe[0])) == vctpt.end())
{
vctpt.push_back(cplCurve[i].ptGe[0]);
ptTemp = cplCurve[i].ptGe[0] + vtNormal * dH;
vctpt.push_back(ptTemp);
}
if ((it = std::find(vctpt.begin(),vctpt.end(),cplCurve[i].ptGe[1])) == vctpt.end())
{
vctpt.push_back(cplCurve[i].ptGe[1]);
ptTemp = cplCurve[i].ptGe[1] + vtNormal * dH;
vctpt.push_back(ptTemp);
}
if ((it = std::find(vctpt.begin(),vctpt.end(),cplCurve[i].ptGe[2])) == vctpt.end())
{
vctpt.push_back(cplCurve[i].ptGe[2]);
ptTemp = cplCurve[i].ptGe[2] + vtNormal * dH;
vctpt.push_back(ptTemp);
}
}
AppendAcDbExtents(vctpt,ext);
nRet = 1;
}*/
return 1;
}
void TEImpCabCross::AppendAcDbExtents(std::vector<AcGePoint3d>& vctpt,AcDbExtents& ext)
{
if (vctpt.size() > 0)
{
std::vector<AcGePoint3d>::iterator it;
std::vector<double> vctX,vctY,vctZ;
for (it = vctpt.begin();it != vctpt.end();it++)
{
vctX.push_back(it->x);
vctY.push_back(it->y);
vctZ.push_back(it->z);
}
if (vctX.size() > 0 && vctY.size() > 0 && vctZ.size() > 0)
{
AcGePoint3d ptMin,ptMax;
ptMin.x = *(std::min_element(vctX.begin(),vctX.end()));
ptMin.y = *(std::min_element(vctY.begin(),vctY.end()));
ptMin.z = *(std::min_element(vctZ.begin(),vctZ.end()));
ptMax.x = *(std::max_element(vctX.begin(),vctX.end()));
ptMax.y = *(std::max_element(vctY.begin(),vctY.end()));
ptMax.z = *(std::max_element(vctZ.begin(),vctZ.end()));
ext.set(ptMin,ptMax);
}
}
}
CString TEImpCabCross::GetXml() const
{
if (m_pXDataMap == NULL || m_pOwnerEnt == NULL)
{
return _T("");
}
int nValue(0);
double dValue(0.0);
int nSizePreci(3), nPtPreci(6); // 尺寸、位置精度
TXmlTree xmlTree;
CString csText;
AcGePoint3d pt;
AcGePoint3dArray arPts;
AcGeVector3d vtDir;
CString csX, csY, csZ;
POSITION posRoot = xmlTree.Insert(_T("ATS_EFITTING"), NULL, NULL);
{
CString sTemp = _T("");
sTemp.Format(_T("%d"),TDb::eCross);
xmlTree.SetAttribute(posRoot, _T("name"), sTemp);
xmlTree.SetAttribute(posRoot, _T("comment"), _T("四通"));
}
POSITION nowPos = xmlTree.Insert(KEY_STYLE,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("类型"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("0:槽式,1:盘式,2:梯式"));
m_pXDataMap->GetAt(KEY_STYLE,nValue);
csText.Format(_T("%d"),nValue);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_MID,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("中点"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("中间点"));
m_pXDataMap->GetAt(KEY_MID,pt);
TAuxTools::DoubleToString(pt.x,nPtPreci,csX);
TAuxTools::DoubleToString(pt.y,nPtPreci,csY);
TAuxTools::DoubleToString(pt.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_B,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("宽度"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("宽度"));
m_pXDataMap->GetAt(KEY_B,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_H,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("高度"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("高度"));
m_pXDataMap->GetAt(KEY_H,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_L,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("长度"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("主支长度"));
m_pXDataMap->GetAt(KEY_L,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_MAINDIR,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("主分支向量"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("主分支向量"));
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
TAuxTools::DoubleToString(vtDir.x,nPtPreci,csX);
TAuxTools::DoubleToString(vtDir.y,nPtPreci,csY);
TAuxTools::DoubleToString(vtDir.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_NORMAL,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("法相量"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("法相量"));
m_pXDataMap->GetAt(KEY_NORMAL,vtDir);
TAuxTools::DoubleToString(vtDir.x,nPtPreci,csX);
TAuxTools::DoubleToString(vtDir.y,nPtPreci,csY);
TAuxTools::DoubleToString(vtDir.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_COVER,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("盖板"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("0:不显示,1:显示"));
m_pXDataMap->GetAt(KEY_COVER,nValue);
csText.Format(_T("%d"),nValue);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(_T("Object_ID"),posRoot,NULL);
{
xmlTree.SetAttribute(nowPos,_T("name"),_T("ID"));
xmlTree.SetAttribute(nowPos,_T("comment"),_T("四通ID"));
LONG_PTR nid = m_pOwnerEnt->objectId().asOldId();
csText.Format(_T("%ld"),nid);
xmlTree.SetItemText(nowPos,csText);
}
CString csXml = xmlTree.GetXml();
return csXml;
}
CString TEImpCabCross::GetXml(const AcGeMatrix3d& mat) const
{
if (m_pXDataMap == NULL || m_pOwnerEnt == NULL)
{
return _T("");
}
int nValue(0);
double dValue(0.0);
int nSizePreci(3), nPtPreci(6); // 尺寸、位置精度
TXmlTree xmlTree;
CString csText;
AcGePoint3d pt;
AcGePoint3dArray arPts;
AcGeVector3d vtDir;
CString csX, csY, csZ;
POSITION posRoot = xmlTree.Insert(_T("ATS_EFITTING"), NULL, NULL);
{
CString sTemp = _T("");
sTemp.Format(_T("%d"),TDb::eCross);
xmlTree.SetAttribute(posRoot, _T("name"), sTemp);
xmlTree.SetAttribute(posRoot, _T("comment"), _T("四通"));
}
POSITION nowPos = xmlTree.Insert(KEY_STYLE,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("类型"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("0:槽式,1:盘式,2:梯式"));
m_pXDataMap->GetAt(KEY_STYLE,nValue);
csText.Format(_T("%d"),nValue);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_MID,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("中点"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("中间点"));
m_pXDataMap->GetAt(KEY_MID,pt);
pt.transformBy(mat);
TAuxTools::DoubleToString(pt.x,nPtPreci,csX);
TAuxTools::DoubleToString(pt.y,nPtPreci,csY);
TAuxTools::DoubleToString(pt.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(nowPos,csText);
}
//axc add 2013-11-27 增加读取四通连接点
POSITION ConnectPtPos = xmlTree.Insert(_T("ConnectData"),posRoot,NULL);
{
pt.set(0,0,0);
xmlTree.SetAttribute(ConnectPtPos, _T("name"), _T("接口点"));
xmlTree.SetAttribute(ConnectPtPos, _T("comment"), _T("接口点数据"));
POSITION PosPt1 = xmlTree.Insert(_T("ConnectPoint1"),ConnectPtPos,NULL);
{
xmlTree.SetAttribute(PosPt1, _T("name"), _T("接口点1"));
xmlTree.SetAttribute(PosPt1, _T("comment"), _T("Start"));
m_pXDataMap->GetAt(KEY_CONNECT_PT1,pt);
pt.transformBy(mat);
TAuxTools::DoubleToString(pt.x,nPtPreci,csX);
TAuxTools::DoubleToString(pt.y,nPtPreci,csY);
TAuxTools::DoubleToString(pt.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(PosPt1,csText);
}
pt.set(0,0,0);
POSITION PosPt2 = xmlTree.Insert(_T("ConnectPoint2"),ConnectPtPos,NULL);
{
xmlTree.SetAttribute(PosPt2, _T("name"), _T("接口点2"));
xmlTree.SetAttribute(PosPt2, _T("comment"), _T("End"));
m_pXDataMap->GetAt(KEY_CONNECT_PT2,pt);
pt.transformBy(mat);
TAuxTools::DoubleToString(pt.x,nPtPreci,csX);
TAuxTools::DoubleToString(pt.y,nPtPreci,csY);
TAuxTools::DoubleToString(pt.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(PosPt2,csText);
}
pt.set(0,0,0);
POSITION PosPt3 = xmlTree.Insert(_T("ConnectPoint3"),ConnectPtPos,NULL);
{
xmlTree.SetAttribute(PosPt3, _T("name"), _T("接口点3"));
xmlTree.SetAttribute(PosPt3, _T("comment"), _T("Top"));
m_pXDataMap->GetAt(KEY_CONNECT_PT3,pt);
pt.transformBy(mat);
TAuxTools::DoubleToString(pt.x,nPtPreci,csX);
TAuxTools::DoubleToString(pt.y,nPtPreci,csY);
TAuxTools::DoubleToString(pt.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(PosPt3,csText);
}
pt.set(0,0,0);
POSITION PosPt4 = xmlTree.Insert(_T("ConnectPoint4"),ConnectPtPos,NULL);
{
xmlTree.SetAttribute(PosPt4, _T("name"), _T("接口点4"));
xmlTree.SetAttribute(PosPt4, _T("comment"), _T("Down"));
m_pXDataMap->GetAt(KEY_CONNECT_PT4,pt);
pt.transformBy(mat);
TAuxTools::DoubleToString(pt.x,nPtPreci,csX);
TAuxTools::DoubleToString(pt.y,nPtPreci,csY);
TAuxTools::DoubleToString(pt.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(PosPt4,csText);
}
}
nowPos = xmlTree.Insert(KEY_B,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("宽度"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("宽度"));
m_pXDataMap->GetAt(KEY_B,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
//axc add 2013-10-23 增加解决四通变径情况下XML的导出
BOOL bTransFit = FALSE;
m_pXDataMap->GetAt(KEY_TRANS_FIT, bTransFit);
nowPos = xmlTree.Insert(KEY_TRANS_FIT,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("变径"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("0:不变径,1:变径"));
if (bTransFit)
nValue = 1;
else
nValue = 0;
csText.Format(_T("%d"),nValue);
xmlTree.SetItemText(nowPos,csText);
}
if (bTransFit)
{
nowPos = xmlTree.Insert(KEY_MAJBR_B,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("主宽度"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("主分支宽度"));
m_pXDataMap->GetAt(KEY_MAJBR_B,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_MINBR_B,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("次宽度"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("次分支宽度1"));
m_pXDataMap->GetAt(KEY_MINBR_B,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_DB3,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("次宽度"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("次分支宽度2"));
m_pXDataMap->GetAt(KEY_DB3,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_DB4,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("次宽度"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("次分支宽度3"));
m_pXDataMap->GetAt(KEY_DB4,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
}
nowPos = xmlTree.Insert(KEY_CORNER,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("四通拐角样式"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("拐角样式"));
m_pXDataMap->GetAt(KEY_CORNER,nValue);
csText.Format(_T("%d"),nValue);
xmlTree.SetItemText(nowPos,csText);
}
//end
nowPos = xmlTree.Insert(KEY_H,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("高度"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("高度"));
m_pXDataMap->GetAt(KEY_H,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_L,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("长度"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("主支长度"));
m_pXDataMap->GetAt(KEY_L,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_MAINDIR,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("主方向"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("主方向"));
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
vtDir.transformBy(mat);
TAuxTools::DoubleToString(vtDir.x,nPtPreci,csX);
TAuxTools::DoubleToString(vtDir.y,nPtPreci,csY);
TAuxTools::DoubleToString(vtDir.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(nowPos,csText);
}
//axc add
nowPos = xmlTree.Insert(KEY_MAJBR,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("主分支向量"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("主分支向量"));
m_pXDataMap->GetAt(KEY_MAJBR,vtDir);
vtDir.transformBy(mat);
TAuxTools::DoubleToString(vtDir.x,nPtPreci,csX);
TAuxTools::DoubleToString(vtDir.y,nPtPreci,csY);
TAuxTools::DoubleToString(vtDir.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_MINBR,posRoot,NULL);
{
vtDir.set(0,0,0);
xmlTree.SetAttribute(nowPos, _T("name"), _T("次分支向量"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("次分支向量"));
m_pXDataMap->GetAt(KEY_MINBR,vtDir);
vtDir.transformBy(mat);
TAuxTools::DoubleToString(vtDir.x,nPtPreci,csX);
TAuxTools::DoubleToString(vtDir.y,nPtPreci,csY);
TAuxTools::DoubleToString(vtDir.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(nowPos,csText);
}
//end
nowPos = xmlTree.Insert(KEY_NORMAL,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("法相量"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("法相量"));
m_pXDataMap->GetAt(KEY_NORMAL,vtDir);
vtDir.transformBy(mat);
TAuxTools::DoubleToString(vtDir.x,nPtPreci,csX);
TAuxTools::DoubleToString(vtDir.y,nPtPreci,csY);
TAuxTools::DoubleToString(vtDir.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_COVER,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("盖板"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("0:不显示,1:显示"));
m_pXDataMap->GetAt(KEY_COVER,nValue);
csText.Format(_T("%d"),nValue);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(_T("Object_ID"),posRoot,NULL);
{
xmlTree.SetAttribute(nowPos,_T("name"),_T("ID"));
xmlTree.SetAttribute(nowPos,_T("comment"),_T("四通ID"));
LONG_PTR nid = m_pOwnerEnt->objectId().asOldId();
csText.Format(_T("%ld"),nid);
xmlTree.SetItemText(nowPos,csText);
}
CString csXml = xmlTree.GetXml();
return csXml;
}
bool TEImpCabCross::GetSection(const AcDbFace &face, const AcGeVector3d &vtPlaneSecDir,
std::vector<TObjSectionRecord> &sectionRecord, AcDbVoidPtrArray& arFillPtrs) const
{
if (NULL == m_pOwnerEnt || NULL == m_pXDataMap)
return false;
// 基本参数
AcDbObjectId idObj = m_pOwnerEnt->objectId();
AcDbObjectId idLayer = m_pOwnerEnt->layerId();
TGGeSectionPlane section_pln(face, vtPlaneSecDir); // 构造一个辅助剖面
//AcDbVoidPtrArray arFaces;
//XExplodeStream dc(arFaces);
//ExplodeOrDraw3d(dc);
TXShell xShell;
GetXBaseShell2(xShell);
double dElevation = 0;
AcDbEntity* pEnt = NULL;
AcDbFace* pFace = NULL;
int i = 0;
for(i = 0; i < xShell.GetCount(); ++i)
{
pFace = xShell.GetFace(i);
if (pFace)
{
TGGeSectionPlane pln(*pFace, vtPlaneSecDir);
TGGePoly2D poly;
dElevation = SectionUtility::Projection_plane2plane(section_pln, pln, poly);
if (poly.Length())
sectionRecord.push_back(TObjSectionRecord(idObj, idLayer, TObjSectionRecord::eTCH_EFITTING, dElevation, poly));
}
}
return true;
}
// 剖切用,返回Z坐标最高、最低点
Acad::ErrorStatus TEImpCabCross::GetExtents(TADSGePoint3d &ptLow, TADSGePoint3d &ptUp) const
{
AcGePoint3d ptM;
double dHight = 0.0,dLen = 0.0;
AcGeVector3d vtNor;
int nCrossType = 0;
m_pXDataMap->GetAt(KEY_MID,ptM);
m_pXDataMap->GetAt(KEY_H,dHight);
m_pXDataMap->GetAt(KEY_L,dLen);
m_pXDataMap->GetAt(KEY_CROSS,nCrossType);
ptLow = ptM;
ptUp = ptM;
// if (nCrossType == TDb::eCrossForSpace)
// {
// ptUp.z += dLen/2;
// ptLow.z -= dLen/2;
// }
// else
ptUp.z += dHight;
return Acad::eOk;
}
Acad::ErrorStatus TEImpCabCross::Draw3dCrossForSpaceOfC(XExplodeDraw &mode) const
{
if (m_pXDataMap == NULL)
return Acad::eNotImplementedYet;
/************************************************************************/
/*空间侧面 |-H-|
/* 0 1
16 +---+ /|\
| | |vtMajDir
15 + + 2 |
14 / \ 3
13 +---+ +---+ 4 ------------>
| M | vtMinDir
12 +---+ +---+ 5
11 \ / 6
10 + + 7
| |
9 +---+ 8
/************************************************************************/
double dLen = 0.0,dB = 0.0,dH = 0.0,dTemp = 0.0;
AcGeVector3d vtMajNor,vtMinNor,vtMajDir,vtMinDir,vtTemp;
AcGePoint3d ptMid,ptUp,ptDown,ptL,ptR,ptTemp;
int nCover;
m_pXDataMap->GetAt(KEY_MID,ptMid);
m_pXDataMap->GetAt(KEY_L,dLen);
m_pXDataMap->GetAt(KEY_B,dB);
m_pXDataMap->GetAt(KEY_H,dH);
m_pXDataMap->GetAt(KEY_MAJNOR,vtMajNor);
m_pXDataMap->GetAt(KEY_MINNOR,vtMinNor);
//m_pXDataMap->GetAt(KEY_MAJBR,vtMajDir);
//m_pXDataMap->GetAt(KEY_MINBR,vtMinDir);
m_pXDataMap->GetAt(KEY_COVER,nCover);
vtMajDir = vtMinNor;
vtMinDir = vtMajNor;
vtMajNor.normalize();
vtMinNor.normalize();
vtMajDir.normalize();
vtMinDir.normalize();
dLen /= 2;
dTemp = (dLen - dH/2)/2;
vtTemp = vtMinDir;
vtTemp.rotateBy(PI/2,vtMinNor);
vtTemp.normalize();
ptTemp = ptMid + vtTemp*dB/2;
ptUp = ptTemp + vtMajDir*dLen;
ptDown = ptTemp - vtMajDir*dLen;
ptR = ptTemp + vtMinDir*dLen;
ptL = ptTemp - vtMinDir*dLen;
AcGePoint3d arPts[17];
arPts[0] = ptUp - vtMinDir*dH/2;
arPts[1] = ptUp + vtMinDir*dH/2;
arPts[2] = arPts[1] - vtMajDir*dTemp;
arPts[15] = arPts[0] - vtMajDir*dTemp;
arPts[4] = ptR + vtMajDir*dH/2;
arPts[5] = ptR - vtMajDir*dH/2;
arPts[3] = arPts[4] - vtMinDir*dTemp;
arPts[6] = arPts[5] - vtMinDir*dTemp;
arPts[8] = ptDown + vtMinDir*dH/2;
arPts[9] = ptDown - vtMinDir*dH/2;
arPts[7] = arPts[8] + vtMajDir*dTemp;
arPts[10] = arPts[9] + vtMajDir*dTemp;
arPts[12] = ptL - vtMajDir*dH/2;
arPts[13] = ptL + vtMajDir*dH/2;
arPts[11] = arPts[12] + vtMinDir*dTemp;
arPts[14] = arPts[13] + vtMinDir*dTemp;
arPts[16] = arPts[0];
AcGePoint3d arPts2[17];
for (int i = 0;i < 17;i++)
{
arPts2[i] = arPts[i] - vtTemp*dB;
}
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
mode.SetColor(curColor);
//内外侧面
static Adesk::Int32 faceList[] = {16,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
mode.DrawShell(16,arPts,17,faceList);
mode.DrawShell(16,arPts2,17,faceList);
//左上侧面
AcGePoint3d arTemp[4];
arTemp[0] = arPts[0];
arTemp[1] = arPts2[0];
arTemp[2] = arPts[15];
arTemp[3] = arPts2[15];
mode.DrawMesh(2,2,arTemp,NULL);
arTemp[0] = arPts[15];
arTemp[1] = arPts2[15];
arTemp[2] = arPts[14];
arTemp[3] = arPts2[14];
mode.DrawMesh(2,2,arTemp,NULL);
//左下侧面
arTemp[0] = arPts[12];
arTemp[1] = arPts2[12];
arTemp[2] = arPts[11];
arTemp[3] = arPts2[11];
mode.DrawMesh(2,2,arTemp,NULL);
arTemp[0] = arPts[11];
arTemp[1] = arPts2[11];
arTemp[2] = arPts[10];
arTemp[3] = arPts2[10];
mode.DrawMesh(2,2,arTemp,NULL);
arTemp[0] = arPts[10];
arTemp[1] = arPts2[10];
arTemp[2] = arPts[9];
arTemp[3] = arPts2[9];
mode.DrawMesh(2,2,arTemp,NULL);
//右下侧面
arTemp[0] = arPts[7];
arTemp[1] = arPts2[7];
arTemp[2] = arPts[6];
arTemp[3] = arPts2[6];
mode.DrawMesh(2,2,arTemp,NULL);
arTemp[0] = arPts[6];
arTemp[1] = arPts2[6];
arTemp[2] = arPts[5];
arTemp[3] = arPts2[5];
mode.DrawMesh(2,2,arTemp,NULL);
//右上侧面
arTemp[0] = arPts[3];
arTemp[1] = arPts2[3];
arTemp[2] = arPts[2];
arTemp[3] = arPts2[2];
mode.DrawMesh(2,2,arTemp,NULL);
if (nCover == TDb::eCover)
{
arTemp[0] = arPts[14];
arTemp[1] = arPts2[14];
arTemp[2] = arPts[13];
arTemp[3] = arPts2[13];
mode.DrawMesh(2,2,arTemp,NULL);
arTemp[0] = arPts[4];
arTemp[1] = arPts2[4];
arTemp[2] = arPts[3];
arTemp[3] = arPts2[3];
mode.DrawMesh(2,2,arTemp,NULL);
arTemp[0] = arPts[2];
arTemp[1] = arPts2[2];
arTemp[2] = arPts[1];
arTemp[3] = arPts2[1];
mode.DrawMesh(2,2,arTemp,NULL);
arTemp[0] = arPts[8];
arTemp[1] = arPts2[8];
arTemp[2] = arPts[7];
arTemp[3] = arPts2[7];
mode.DrawMesh(2,2,arTemp,NULL);
}
return Acad::eOk;
}
Acad::ErrorStatus TEImpCabCross::Draw3dCrossForSpaceOfT(XExplodeDraw &mode) const
{
return Draw3dCrossForSpaceOfC(mode);
//return Acad::eOk;
}
int TEImpCabCross::GetXBaseShellForSpace2(TXShell& xShell) const
{
int nRet = 0;
double dLen = 0.0,dB = 0.0,dH = 0.0,dTemp = 0.0;
AcGeVector3d vtMajNor,vtMinNor,vtMajDir,vtMinDir,vtTemp;
AcGePoint3d ptMid,ptUp,ptDown,ptL,ptR,ptTemp;
int nCover;
m_pXDataMap->GetAt(KEY_MID,ptMid);
m_pXDataMap->GetAt(KEY_L,dLen);
m_pXDataMap->GetAt(KEY_B,dB);
m_pXDataMap->GetAt(KEY_H,dH);
m_pXDataMap->GetAt(KEY_MAJNOR,vtMajNor);
m_pXDataMap->GetAt(KEY_MINNOR,vtMinNor);
//m_pXDataMap->GetAt(KEY_MAJBR,vtMajDir);
//m_pXDataMap->GetAt(KEY_MINBR,vtMinDir);
m_pXDataMap->GetAt(KEY_COVER,nCover);
vtMajDir = vtMinNor;
vtMinDir = vtMajNor;
vtMajNor.normalize();
vtMinNor.normalize();
vtMajDir.normalize();
vtMinDir.normalize();
dLen /= 2;
dTemp = (dLen - dH/2)/2;
vtTemp = vtMinDir;
vtTemp.rotateBy(PI/2,vtMinNor);
vtTemp.normalize();
ptTemp = ptMid + vtTemp*dB/2;
ptUp = ptTemp + vtMajDir*dLen;
ptDown = ptTemp - vtMajDir*dLen;
ptR = ptTemp + vtMinDir*dLen;
ptL = ptTemp - vtMinDir*dLen;
AcGePoint3d arPts[17];
arPts[0] = ptUp - vtMinDir*dH/2;
arPts[1] = ptUp + vtMinDir*dH/2;
arPts[2] = arPts[1] - vtMajDir*dTemp;
arPts[15] = arPts[0] - vtMajDir*dTemp;
arPts[4] = ptR + vtMajDir*dH/2;
arPts[5] = ptR - vtMajDir*dH/2;
arPts[3] = arPts[4] - vtMinDir*dTemp;
arPts[6] = arPts[5] - vtMinDir*dTemp;
arPts[8] = ptDown + vtMinDir*dH/2;
arPts[9] = ptDown - vtMinDir*dH/2;
arPts[7] = arPts[8] + vtMajDir*dTemp;
arPts[10] = arPts[9] + vtMajDir*dTemp;
arPts[12] = ptL - vtMajDir*dH/2;
arPts[13] = ptL + vtMajDir*dH/2;
arPts[11] = arPts[12] + vtMinDir*dTemp;
arPts[14] = arPts[13] + vtMinDir*dTemp;
arPts[16] = arPts[0];
AcGePoint3d arPts2[17];
int i = 0;
for (i = 0;i < 17;i++)
{
arPts2[i] = arPts[i] - vtTemp*dB;
}
AcGePoint3d arTemp[4];
//内外侧面
{
arTemp[0] = arPts[0];
arTemp[1] = arPts[1];
arTemp[2] = arPts[2];
arTemp[3] = arPts[15];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[15];
arTemp[1] = arPts[2];
arTemp[2] = arPts[3];
arTemp[3] = arPts[14];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[13];
arTemp[1] = arPts[4];
arTemp[2] = arPts[5];
arTemp[3] = arPts[12];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[11];
arTemp[1] = arPts[6];
arTemp[2] = arPts[7];
arTemp[3] = arPts[10];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[7];
arTemp[1] = arPts[8];
arTemp[2] = arPts[9];
arTemp[3] = arPts[10];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts2[0];
arTemp[1] = arPts2[1];
arTemp[2] = arPts2[2];
arTemp[3] = arPts2[15];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts2[15];
arTemp[1] = arPts2[2];
arTemp[2] = arPts2[3];
arTemp[3] = arPts2[14];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts2[13];
arTemp[1] = arPts2[4];
arTemp[2] = arPts2[5];
arTemp[3] = arPts2[12];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts2[11];
arTemp[1] = arPts2[6];
arTemp[2] = arPts2[7];
arTemp[3] = arPts2[10];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts2[7];
arTemp[1] = arPts2[8];
arTemp[2] = arPts2[9];
arTemp[3] = arPts2[10];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
}
//左上侧面
arTemp[0] = arPts[0];
arTemp[1] = arPts2[0];
arTemp[2] = arPts2[15];
arTemp[3] = arPts[15];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[15];
arTemp[1] = arPts2[15];
arTemp[2] = arPts2[14];
arTemp[3] = arPts[14];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
//左下侧面
arTemp[0] = arPts[12];
arTemp[1] = arPts2[12];
arTemp[2] = arPts2[11];
arTemp[3] = arPts[11];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[11];
arTemp[1] = arPts2[11];
arTemp[2] = arPts2[10];
arTemp[3] = arPts[10];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[10];
arTemp[1] = arPts2[10];
arTemp[2] = arPts2[9];
arTemp[3] = arPts[9];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
//右下侧面
arTemp[0] = arPts[7];
arTemp[1] = arPts2[7];
arTemp[2] = arPts2[6];
arTemp[3] = arPts[6];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[6];
arTemp[1] = arPts2[6];
arTemp[2] = arPts2[5];
arTemp[3] = arPts[5];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
//右上侧面
arTemp[0] = arPts[3];
arTemp[1] = arPts2[3];
arTemp[2] = arPts2[2];
arTemp[3] = arPts[2];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
{
//封盖
arTemp[0] = arPts[14];
arTemp[1] = arPts2[14];
arTemp[2] = arPts2[13];
arTemp[3] = arPts[13];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[4];
arTemp[1] = arPts2[4];
arTemp[2] = arPts2[3];
arTemp[3] = arPts[3];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[2];
arTemp[1] = arPts2[2];
arTemp[2] = arPts2[1];
arTemp[3] = arPts[1];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[8];
arTemp[1] = arPts2[8];
arTemp[2] = arPts2[7];
arTemp[3] = arPts[7];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
}
{
//封口
arTemp[0] = arPts[0];
arTemp[1] = arPts[1];
arTemp[2] = arPts2[1];
arTemp[3] = arPts2[0];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[4];
arTemp[1] = arPts[5];
arTemp[2] = arPts2[5];
arTemp[3] = arPts2[4];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[8];
arTemp[1] = arPts[9];
arTemp[2] = arPts2[9];
arTemp[3] = arPts2[8];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
arTemp[0] = arPts[12];
arTemp[1] = arPts[13];
arTemp[2] = arPts2[13];
arTemp[3] = arPts2[12];
xShell.AppendFace(CreateAcDbFace2(arTemp[0],arTemp[1],arTemp[2],arTemp[3]));
}
nRet = 1;
return nRet;
}
int TEImpCabCross::GetXBaseShellForPlane2(TXShell& xShell) const
{
int nRet = 0;
// 构建点
AcGePoint3d ptGeM;
AcGeVector3d vtNormal,vtDir;
double dHeight = 0.0,dB = 0.0,dLen = 0.0;
m_pXDataMap->GetAt(KEY_MID,ptGeM);
m_pXDataMap->GetAt(KEY_L,dLen);
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
m_pXDataMap->GetAt(KEY_B,dB);
m_pXDataMap->GetAt(KEY_H,dHeight);
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal);
dLen /= 2;
int nLinNum = 0;
const int nSize = 17;
AcGePoint3d* pBotVer = new AcGePoint3d[nSize];
AcGePoint3d* pTopVer = new AcGePoint3d[nSize];
if (pBotVer != NULL && pTopVer != NULL)
{
double dAngle = PI / 2.0;
AcGeVector3d vtPreCross = vtDir;
vtPreCross.rotateBy(dAngle,vtNormal);
vtDir.normalize();
vtPreCross.normalize();
AcGePoint3d ptGeS = ptGeM - vtDir * dLen;
AcGePoint3d ptGeE = ptGeM + vtDir * dLen;
AcGePoint3d ptGeTop = ptGeM + vtPreCross * dLen;
AcGePoint3d ptGeDown = ptGeM - vtPreCross * dLen;
// 底面
pBotVer[13] = ptGeS + vtPreCross * (dB / 2.0);
pBotVer[12] = ptGeS - vtPreCross * (dB / 2.0);
pBotVer[4] = ptGeE + vtPreCross * (dB / 2.0);
pBotVer[5] = ptGeE - vtPreCross * (dB / 2.0);
pBotVer[1] = ptGeTop + vtDir * (dB / 2.0);
pBotVer[0] = ptGeTop - vtDir * (dB / 2.0);
pBotVer[16] = pBotVer[0];
pBotVer[8] = ptGeDown + vtDir * (dB / 2.0);
pBotVer[9] = ptGeDown - vtDir * (dB / 2.0);
double dTemp = 0.5 * (dLen - 0.5 * dB);
pBotVer[15] = pBotVer[0] - vtPreCross * dTemp;
pBotVer[10] = pBotVer[9] + vtPreCross * dTemp;
dTemp = 0.5 * (dLen - 0.5 * dB);
pBotVer[2] = pBotVer[1] - vtPreCross * dTemp;
pBotVer[7] = pBotVer[8] + vtPreCross * dTemp;
dTemp = 0.5 * (dLen - 0.5 * dB);
pBotVer[3] = pBotVer[4] - vtDir * dTemp;
pBotVer[14] = pBotVer[13] + vtDir * dTemp;
dTemp = 0.5 * (dLen - 0.5 * dB);
pBotVer[6] = pBotVer[5] - vtDir * dTemp;
pBotVer[11] = pBotVer[12] + vtDir * dTemp;
// 顶面
for (int i = 0;i < nSize;i++)
{
pTopVer[i] = pBotVer[i] + vtNormal * dHeight;
}
// 创建面 -- 全封闭面
// 1.底面
xShell.AppendFace(CreateAcDbFace2(pBotVer[0],pBotVer[1],pBotVer[8],pBotVer[9]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[10],pBotVer[11],pBotVer[14],pBotVer[15]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[11],pBotVer[12],pBotVer[13],pBotVer[14]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[2],pBotVer[3],pBotVer[6],pBotVer[7]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[3],pBotVer[4],pBotVer[5],pBotVer[6]));
// 2.顶面
xShell.AppendFace(CreateAcDbFace2(pTopVer[0],pTopVer[1],pTopVer[8],pTopVer[9]));
xShell.AppendFace(CreateAcDbFace2(pTopVer[10],pTopVer[11],pTopVer[14],pTopVer[15]));
xShell.AppendFace(CreateAcDbFace2(pTopVer[11],pTopVer[12],pTopVer[13],pTopVer[14]));
xShell.AppendFace(CreateAcDbFace2(pTopVer[2],pTopVer[3],pTopVer[6],pTopVer[7]));
xShell.AppendFace(CreateAcDbFace2(pTopVer[3],pTopVer[4],pTopVer[5],pTopVer[6]));
// 3.封口
xShell.AppendFace(CreateAcDbFace2(pBotVer[0],pBotVer[1],pTopVer[1],pTopVer[0]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[4],pBotVer[5],pTopVer[5],pTopVer[4]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[8],pBotVer[9],pTopVer[9],pTopVer[8]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[12],pBotVer[13],pTopVer[13],pTopVer[12]));
// 4.侧面
xShell.AppendFace(CreateAcDbFace2(pBotVer[1],pBotVer[2],pTopVer[2],pTopVer[1]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[2],pBotVer[3],pTopVer[3],pTopVer[2]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[3],pBotVer[4],pTopVer[4],pTopVer[3]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[5],pBotVer[6],pTopVer[6],pTopVer[5]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[6],pBotVer[7],pTopVer[7],pTopVer[6]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[7],pBotVer[8],pTopVer[8],pTopVer[7]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[9],pBotVer[10],pTopVer[10],pTopVer[9]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[10],pBotVer[11],pTopVer[11],pTopVer[10]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[11],pBotVer[12],pTopVer[12],pTopVer[11]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[13],pBotVer[14],pTopVer[14],pTopVer[13]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[14],pBotVer[15],pTopVer[15],pTopVer[14]));
xShell.AppendFace(CreateAcDbFace2(pBotVer[15],pBotVer[16],pTopVer[16],pTopVer[15]));
nRet = 1;
}
if (pBotVer != NULL)
delete []pBotVer;
if (pTopVer != NULL)
delete []pTopVer;
return nRet;
}
int TEImpCabCross::GetXBaseShell2(TXShell& xShell) const
{
int nRet = 0;
if (m_pXDataMap != NULL)
{
int nCrossType = 0;
m_pXDataMap->GetAt(KEY_CROSS,nCrossType);
switch(nCrossType)
{
case TDb::eOldCbotHorEqualCross:
case TDb::eCbotHorEqualCross:
{
nRet = GetXBaseShellForPlane2(xShell);
break;
}
case TDb::eCrossForSpace:
{
nRet = GetXBaseShellForSpace2(xShell);
break;
}
}
}
return nRet;
}