3817 lines
99 KiB
C++
3817 lines
99 KiB
C++
#include "stdafx.h"
|
|
#include "TEImpCabOffset.h"
|
|
#include "TDbInterfaceMsgWrite.h"
|
|
#include "dbray.h"
|
|
|
|
|
|
TEImpCabOffset::TEImpCabOffset()
|
|
{
|
|
|
|
}
|
|
|
|
TEImpCabOffset::~TEImpCabOffset()
|
|
{
|
|
|
|
}
|
|
|
|
// 接口描述对象
|
|
BOOL TEImpCabOffset::GetInterface(int nIndex,TInterface& pipeInterface) const
|
|
{
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
AcDbObjectId id1,id2;
|
|
|
|
AcGePoint3d ptGeM,ptGeS,ptGeE;
|
|
AcGeVector3d vtDir;
|
|
AcGeVector3d vtNormal;
|
|
|
|
if (!m_pXDataMap->GetAt(KEY_START,ptGeS) ||
|
|
!m_pXDataMap->GetAt(KEY_END,ptGeE) ||
|
|
!m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) ||
|
|
!m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) )
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
switch(nIndex)
|
|
{
|
|
case 0:
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
|
|
pipeInterface.SetOutDir(vtDir);
|
|
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
|
|
pipeInterface.SetPosition(ptGeS);
|
|
return TRUE;
|
|
}
|
|
break;
|
|
case 1:
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
|
|
pipeInterface.SetOutDir(vtDir);
|
|
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
|
|
pipeInterface.SetPosition(ptGeE);
|
|
return TRUE;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TEImpCabOffset::GetInterface(const AcGePoint3d& ptCon,TInterface& pipeInterface) const
|
|
{
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
AcGePoint3d ptGeM,ptGeE,ptGeS;
|
|
AcGeVector3d vtDir;
|
|
AcGeVector3d vtNormal;
|
|
|
|
if (!m_pXDataMap->GetAt(KEY_START,ptGeS) ||
|
|
!m_pXDataMap->GetAt(KEY_END,ptGeE) ||
|
|
!m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) ||
|
|
!m_pXDataMap->GetAt(KEY_NORMAL,vtNormal))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AcDbObjectId id1,id2;
|
|
|
|
double dDis1 = ptCon.distanceTo(ptGeS);
|
|
double dDis2 = ptCon.distanceTo(ptGeE);
|
|
|
|
if (dDis1 < 1.e-3 ||
|
|
dDis2 < 1.e-3)
|
|
{
|
|
//判断点是否在接口对象上
|
|
|
|
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 (bSign)
|
|
{
|
|
return bSuc;
|
|
}
|
|
|
|
if (dDis1 < 1.e-3)
|
|
{
|
|
pipeInterface.SetOutDir(vtDir);
|
|
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
|
|
pipeInterface.SetPosition(ptGeS);
|
|
}
|
|
|
|
if (dDis2 < 1.e-3)
|
|
{
|
|
pipeInterface.SetOutDir(vtDir);
|
|
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
|
|
pipeInterface.SetPosition(ptGeE);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TEImpCabOffset::HasInterface(const AcGePoint3d& ptCon,const AcGeVector3d& vtDir)
|
|
{
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
AcGePoint3d ptGeS,ptGeE;
|
|
AcGeVector3d vtDirT,vtNormal;
|
|
if (!m_pXDataMap->GetAt(KEY_START,ptGeS) ||
|
|
!m_pXDataMap->GetAt(KEY_END,ptGeE) ||
|
|
!m_pXDataMap->GetAt(KEY_MAINDIR,vtDirT) ||
|
|
!m_pXDataMap->GetAt(KEY_NORMAL,vtNormal))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
double dDis1 = ptCon.distanceTo(ptGeS);
|
|
double dDis2 = ptCon.distanceTo(ptGeE);
|
|
|
|
if (dDis1 < 1.e-3 || dDis2 < 1.e-3)
|
|
{
|
|
if (vtDirT.isParallelTo(vtDir))
|
|
{
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
int TEImpCabOffset::GetInterfaceCount() const
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
// 建立接口关联关系
|
|
BOOL TEImpCabOffset::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
|
|
{
|
|
if ( !idConnect.isValid() )
|
|
return FALSE;
|
|
|
|
BOOL bSuccess = FALSE;
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
AcGePoint3d ptGeS,ptGeE;
|
|
AcGeVector3d vtDir,vtNormal;
|
|
if (!m_pXDataMap->GetAt(KEY_START,ptGeS) ||
|
|
!m_pXDataMap->GetAt(KEY_END,ptGeE) ||
|
|
!m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) ||
|
|
!m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) )
|
|
{
|
|
return Acad::eKeyNotFound;
|
|
}
|
|
|
|
double dDis1 = ptConnect.distanceTo(ptGeS);
|
|
double dDis2 = ptConnect.distanceTo(ptGeE);
|
|
|
|
if (dDis1 < 1.e-3 || dDis2 < 1.e-3)
|
|
{
|
|
AcGeVector3d vtT = vtDir;
|
|
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);
|
|
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);
|
|
bSuccess = TRUE;
|
|
}
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
}
|
|
return bSuccess;
|
|
}
|
|
|
|
// 移除接口关联关系
|
|
BOOL TEImpCabOffset::RemoveInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
|
|
{
|
|
//浅层次删除; 命名字典中的关系,需要外面移除关系,只移除内部关系
|
|
AcDbObjectId id1,id2;
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
m_pXDataMap->GetAt(KEY_IDCNT1,id1);
|
|
m_pXDataMap->GetAt(KEY_IDCNT2,id2);
|
|
|
|
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;
|
|
}
|
|
return bRemoved;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
// 接口更改通知
|
|
BOOL TEImpCabOffset::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;
|
|
}
|
|
|
|
TDb::Position TEImpCabOffset::ExplainGripIndex(int nIndex) const
|
|
{
|
|
AcGeVector3d vtNormal;
|
|
TDb::Position ePos = TDb::eBr1;
|
|
switch(nIndex)
|
|
{
|
|
case 1:
|
|
{
|
|
ePos = TDb::eMid;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
ePos = TDb::eBr1;
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
ePos = TDb::eBr2;
|
|
break;
|
|
}
|
|
case 4:
|
|
{
|
|
ePos = TDb::eCommand0;
|
|
break;
|
|
}
|
|
case 5:
|
|
{
|
|
ePos = TDb::eCommand1;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return ePos;
|
|
}
|
|
|
|
void TEImpCabOffset::GetKindName(CString& sName)
|
|
{
|
|
sName = _T("TCH_EOFFSET");
|
|
}
|
|
|
|
BOOL TEImpCabOffset::GetCurvesInSide(TComplexCurve& compCurve) const
|
|
{
|
|
ASSERT(m_pXDataMap != NULL);
|
|
|
|
//中线
|
|
AcGePoint3d ptSta,ptEnd,ptM,ptOn;
|
|
AcGePoint3d ptM1,ptM2;
|
|
int nType = 0;
|
|
AcGeVector3d vtDir,vtDirT1,vtDirT2,vtNorm;
|
|
m_pXDataMap->GetAt(KEY_START,ptSta);
|
|
m_pXDataMap->GetAt(KEY_END,ptEnd);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
m_pXDataMap->GetAt(KEY_OFFSET,nType);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
vtDirT1 = vtDir;
|
|
vtDirT1.rotateBy(PI/2,AcGeVector3d::kZAxis);
|
|
vtDirT2 = vtDir;
|
|
if (nType == TDb::eHorLeftOffset)
|
|
vtDirT2.rotateBy(3*PI/4,AcGeVector3d::kZAxis);
|
|
else if (nType == TDb::eHorRightOffset)
|
|
vtDirT2.rotateBy(PI/4,AcGeVector3d::kZAxis);
|
|
|
|
Midpoint(ptSta,ptEnd,ptM);
|
|
|
|
//求中间连接的两点
|
|
if (nType != TDb::eVerOffset)
|
|
{
|
|
AcDbLine line(ptSta,ptSta+vtDirT1);
|
|
line.getClosestPointTo(ptEnd,ptOn,Adesk::kTrue);
|
|
double dLen = ptOn.distanceTo(ptSta);
|
|
if (nType == TDb::eHorLeftOffset)
|
|
{
|
|
ptM1 = ptM + vtDirT2*pow(2,0.5)*dLen/2;
|
|
ptM2 = ptM - vtDirT2*pow(2,0.5)*dLen/2;
|
|
}
|
|
else
|
|
{
|
|
ptM1 = ptM - vtDirT2*pow(2,0.5)*dLen/2;
|
|
ptM2 = ptM + vtDirT2*pow(2,0.5)*dLen/2;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePlane planNorm(ptSta,vtNorm);
|
|
dLenT = ptEnd.distanceTo(ptEnd.orthoProject(planNorm));
|
|
AcGePlane plan(ptEnd,vtDir);
|
|
dLen = ptSta.distanceTo(ptSta.orthoProject(plan));
|
|
ptM1 = ptSta + vtDir*(dLen - dLenT)/2;
|
|
ptM2 = ptEnd - vtDir*(dLen - dLenT)/2;
|
|
}
|
|
|
|
double dW = 0.0;
|
|
m_pXDataMap->GetAt(KEY_B,dW);
|
|
|
|
TDb::TCurveElement el;
|
|
memset(&el,0,sizeof(TDb::TCurveElement));
|
|
|
|
int nShowCenLine = 0;
|
|
m_pXDataMap->GetAt(KEY_HASCENLINE,nShowCenLine);
|
|
if (nShowCenLine)
|
|
{
|
|
double dWidth = 0.0;
|
|
m_pXDataMap->GetAt(KEY_CENLWIDTH,dWidth);
|
|
|
|
el.ptGe[0] = ptSta;
|
|
el.ptGe[1] = ptM1;
|
|
el.ptGe[2] = ptM1;
|
|
el.gsMark = -1;
|
|
el.dWidth = dWidth;
|
|
compCurve.append(el);
|
|
|
|
el.ptGe[0] = ptM1;
|
|
el.ptGe[1] = ptM2;
|
|
el.ptGe[2] = ptM2;
|
|
el.gsMark = -1;
|
|
el.dWidth = dWidth;
|
|
compCurve.append(el);
|
|
|
|
el.ptGe[0] = ptM2;
|
|
el.ptGe[1] = ptEnd;
|
|
el.ptGe[2] = ptEnd;
|
|
el.gsMark = -1;
|
|
el.dWidth = dWidth;
|
|
compCurve.append(el);
|
|
}
|
|
|
|
//显示隔板线
|
|
double dWith2 = 0.0;
|
|
m_pXDataMap->GetAt(KEY_EDAGEWIDTH, dWith2);
|
|
int bShowBorad = -1,bHaveClap = -1;
|
|
m_pXDataMap->GetAt(KEY_HAVE_CLAPBOARD,bHaveClap);
|
|
m_pXDataMap->GetAt(KEY_SHOW_CLAPBOARD,bShowBorad);
|
|
if(bShowBorad == TDb::eShowBoard &&
|
|
bHaveClap == TDb::eBoard)
|
|
{
|
|
AcGeVector3d vtBoardMain;
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_MAINBR,vtBoardMain);
|
|
vtBoardMain.normalize();
|
|
|
|
TSupportFunc spFun;
|
|
AcGeDoubleArray arDimeS,arDimeE;
|
|
spFun.GetClapboardDimension(m_pXDataMap, arDimeS);
|
|
spFun.GetClapboardDimension(m_pXDataMap,arDimeE,KEY_CLAPBOARD_DATA2);
|
|
|
|
if (arDimeE.length() != arDimeS.length())
|
|
{
|
|
return FALSE;
|
|
}
|
|
//计算 拐点
|
|
double dDistH = 0.0,dDistV = 0.0,dDistLong = 0.0,dDistShort = 0.0;
|
|
AcGeVector3d vtTmp1;
|
|
vtTmp1 = vtDir;
|
|
AcDbLine line(ptSta,ptSta+vtTmp1);
|
|
line.getClosestPointTo(ptEnd,ptOn,Adesk::kTrue);
|
|
dDistH = ptOn.distanceTo(ptSta);
|
|
vtTmp1.rotateBy(PI/2,vtNorm);
|
|
line.setEndPoint(ptSta+vtTmp1);
|
|
line.getClosestPointTo(ptEnd,ptOn,Adesk::kTrue);
|
|
dDistV = ptOn.distanceTo(ptSta);
|
|
dDistShort = (dDistH - dDistV - dW*tan(PI/8))/2;
|
|
dDistLong = dDistShort + dW*tan(PI/8);
|
|
|
|
AcGePoint3d ptT1,ptT2;
|
|
AcDbLine tl1,tl2;
|
|
if (nType == TDb::eHorLeftOffset)
|
|
{
|
|
XPoint ptl1,ptl2;
|
|
ptl1 = ptSta + vtTmp1*dW/2 + vtDir*dDistLong;
|
|
ptl2 = ptSta - vtTmp1*dW/2 + vtDir*dDistShort;
|
|
tl1.setStartPoint(ptl1);
|
|
tl1.setEndPoint(ptl2);
|
|
ptl1 = ptEnd + vtTmp1*dW/2 - vtDir*dDistShort;
|
|
ptl2 = ptEnd - vtTmp1*dW/2 - vtDir*dDistLong;
|
|
tl2.setStartPoint(ptl1);
|
|
tl2.setEndPoint(ptl2);
|
|
}
|
|
else
|
|
{
|
|
XPoint ptl1,ptl2;
|
|
ptl1 = ptSta + vtTmp1*dW/2 + vtDir*dDistShort;
|
|
ptl2 = ptSta - vtTmp1*dW/2 + vtDir*dDistLong;
|
|
tl1.setStartPoint(ptl1);
|
|
tl1.setEndPoint(ptl2);
|
|
ptl1 = ptEnd + vtTmp1*dW/2 - vtDir*dDistLong;
|
|
ptl2 = ptEnd - vtTmp1*dW/2 - vtDir*dDistShort;
|
|
tl2.setStartPoint(ptl1);
|
|
tl2.setEndPoint(ptl2);
|
|
}
|
|
|
|
double dOffset1 = 0.0,dOffset2 = 0.0;
|
|
for (int i = 0;i < arDimeS.length();++i)
|
|
{
|
|
dOffset1 = arDimeS[i];
|
|
dOffset2 = arDimeE[i];
|
|
|
|
AcGePoint3d ptClap1,ptClap2,ptClap3,ptClap4;
|
|
ptClap1 = ptSta - vtBoardMain*(dW/2 - dOffset1);
|
|
ptClap4 = ptEnd - vtBoardMain*(dW/2 - dOffset2);
|
|
|
|
AcGePoint3dArray arInt;
|
|
AcDbLine midline(ptClap1,ptClap1+vtDir);
|
|
midline.intersectWith(&tl1,AcDb::kExtendBoth,arInt);
|
|
if (arInt.length() > 0)
|
|
{
|
|
ptClap2 = arInt.first();
|
|
arInt.setLogicalLength(0);
|
|
}
|
|
midline.setStartPoint(ptClap4);
|
|
midline.setEndPoint(ptClap4+vtDir);
|
|
midline.intersectWith(&tl2,AcDb::kExtendBoth,arInt);
|
|
if (arInt.length() > 0)
|
|
{
|
|
ptClap3 = arInt.first();
|
|
}
|
|
|
|
el.ptGe[0] = ptClap1;
|
|
el.ptGe[1] = ptClap2;
|
|
el.ptGe[2] = ptClap2;
|
|
el.dWidth = dWith2;
|
|
el.gsMark = -2;
|
|
el.nColorIndex = KEY_CLP_COLORINDEX;
|
|
compCurve.append(el);
|
|
|
|
el.ptGe[0] = ptClap2;
|
|
el.ptGe[1] = ptClap3;
|
|
el.ptGe[2] = ptClap3;
|
|
el.dWidth = dWith2;
|
|
el.gsMark = -2;
|
|
el.nColorIndex = KEY_CLP_COLORINDEX;
|
|
compCurve.append(el);
|
|
|
|
el.ptGe[0] = ptClap3;
|
|
el.ptGe[1] = ptClap4;
|
|
el.ptGe[2] = ptClap4;
|
|
el.dWidth = dWith2;
|
|
el.gsMark = -2;
|
|
el.nColorIndex = KEY_CLP_COLORINDEX;
|
|
compCurve.append(el);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
AcDbFace* TEImpCabOffset::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;
|
|
}
|
|
|
|
BOOL TEImpCabOffset::MakePolyCurveFaces(AcDbVoidPtrArray& arFaces)
|
|
{
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
TComplexCurve cplCurve;
|
|
MakeBaseCurves(cplCurve);
|
|
if (cplCurve.length() > 0)
|
|
{
|
|
if (cplCurve.length() < 7)
|
|
return FALSE;
|
|
arFaces.append(CreateAcDbFace(cplCurve.at(1).ptGe[0],cplCurve.at(1).ptGe[2],
|
|
cplCurve.at(7).ptGe[0],cplCurve.at(7).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]));
|
|
arFaces.append(CreateAcDbFace(cplCurve.at(3).ptGe[0],cplCurve.at(3).ptGe[2],
|
|
cplCurve.at(5).ptGe[0],cplCurve.at(5).ptGe[2]));
|
|
}
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// 判断实体是否为桥架
|
|
BOOL TEImpCabOffset::MakesureIsPipe(const AcDbObjectId& id) const
|
|
{
|
|
BOOL bSuc = FALSE;
|
|
AcDbEntity* pEnt = NULL;
|
|
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead) == Acad::eOk)
|
|
{
|
|
TDbECabletry* pPipe = TDbECabletry::cast(pEnt);
|
|
if (pPipe)
|
|
{
|
|
bSuc = TRUE;
|
|
}
|
|
pEnt->close();
|
|
}
|
|
return bSuc;
|
|
}
|
|
|
|
BOOL TEImpCabOffset::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;
|
|
}
|
|
|
|
//连接线根据需要去掉
|
|
BOOL TEImpCabOffset::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 (!MakesureIsPipe(inf.GetConnectObject()))
|
|
{
|
|
continue;
|
|
}
|
|
// 获取连接点所在的线段索引号
|
|
if (GetIndexOfPointIsOn(cplCurve,inf.GetPosition(),nIndex))
|
|
{
|
|
cplCurve.removeAt(nIndex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
//生成完整的CURVE
|
|
BOOL TEImpCabOffset::MakeBaseCurves(TComplexCurve& cplCurve) const
|
|
{
|
|
int nType = 0;
|
|
m_pXDataMap->GetAt(KEY_OFFSET,nType);
|
|
|
|
switch(nType)
|
|
{
|
|
case TDb::eHorLeftOffset:
|
|
MakeHorLeftOffsetCurves(cplCurve);
|
|
break;
|
|
case TDb::eHorRightOffset:
|
|
MakeHorRightOffsetCurves(cplCurve);
|
|
break;
|
|
case TDb::eVerOffset:
|
|
MakeVerOffsetCurves(cplCurve);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL TEImpCabOffset::MakeCurves(TComplexCurve& cplCurve) const
|
|
{
|
|
ASSERT(m_pXDataMap != NULL);
|
|
|
|
MakeBaseCurves(cplCurve);
|
|
|
|
// 是否显示连接线
|
|
int nCnt = -1;
|
|
m_pXDataMap->GetAt(KEY_SHOWCNTLINE,nCnt);
|
|
if (nCnt == 0)
|
|
{
|
|
NoneConectLineIfNeed(cplCurve);
|
|
}
|
|
|
|
// 设置边线宽
|
|
double dWidth = 0.0;
|
|
m_pXDataMap->GetAt(KEY_EDAGEWIDTH,dWidth);
|
|
TDb::TCurveElement el;
|
|
memset(&el,0,sizeof(TDb::TCurveElement));
|
|
|
|
for (int j = 0;j < cplCurve.length();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 < cplCurve.length();j++)
|
|
{
|
|
el = cplCurve[j];
|
|
el.nColorIndex = nColor;
|
|
el.bHided = FALSE;
|
|
cplCurve.setAt(j,el);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
AcDbPolyline* TEImpCabOffset::MakePolyCurve() const
|
|
{
|
|
ASSERT(m_pXDataMap != NULL);
|
|
|
|
AcGePoint3d ptS,ptE,ptM;
|
|
AcGeVector3d vtNorm;
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
|
|
AcGePlane plan(ptS,vtNorm);
|
|
AcGePoint3d ptOrth = AcGePoint3d::kOrigin.orthoProject(plan);
|
|
plan.set(ptOrth,normal());
|
|
|
|
double dEl = ptOrth.asVector().length();
|
|
if (!ptOrth.asVector().isCodirectionalTo(normal()))
|
|
{
|
|
dEl *= -1.0;
|
|
}
|
|
|
|
TComplexCurve cplCurve;
|
|
MakeCurves(cplCurve);
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
for (int i = 0;i < cplCurve.length();i++)
|
|
{
|
|
pPl->addVertexAt(i,cplCurve.at(i).ptGe[0].convert2d(plan));
|
|
}
|
|
|
|
pPl->setElevation(dEl);
|
|
pPl->setNormal(plan.normal());
|
|
pPl->setClosed(Adesk::kTrue);
|
|
|
|
return pPl;
|
|
}
|
|
|
|
void TEImpCabOffset::GetTips(CMapStringToString& mapLable2Tip) const
|
|
{
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
double dH = 0.0,dB = 0.0;
|
|
AcGePoint3d ptM,ptS,ptE;
|
|
CString strTemp = _T("");
|
|
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_TYPE,strTemp);
|
|
|
|
Midpoint(ptS,ptE,ptM);
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::ExplodeOrDraw2d(XExplodeDraw &mode) const
|
|
{
|
|
ASSERT(m_pXDataMap != NULL);
|
|
|
|
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);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::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 TEImpCabOffset::ExplodeOrDraw3dOfT(XExplodeDraw &mode) const
|
|
{
|
|
Acad::ErrorStatus es = Acad::eNotImplementedYet;
|
|
if (m_pXDataMap == NULL)
|
|
return es;
|
|
|
|
int nType = 0;
|
|
m_pXDataMap->GetAt(KEY_OFFSET,nType);
|
|
|
|
switch(nType)
|
|
{
|
|
case TDb::eHorLeftOffset:
|
|
es = ExplodeOrHorLeftDraw3dOfT(mode);
|
|
break;
|
|
case TDb::eHorRightOffset:
|
|
es = ExplodeOrHorRightDraw3dOfT(mode);
|
|
break;
|
|
case TDb::eVerOffset:
|
|
es = ExplodeOrVerDraw3dOfT(mode);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::ExplodeOrDraw3dOfP(XExplodeDraw &mode) const
|
|
{
|
|
return ExplodeOrDraw3dOfC(mode);
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::ExplodeOrDraw3dOfC(XExplodeDraw &mode) const
|
|
{
|
|
Acad::ErrorStatus es = Acad::eNotImplementedYet;
|
|
if (m_pXDataMap == NULL) return es;
|
|
|
|
int nType = 0;
|
|
m_pXDataMap->GetAt(KEY_OFFSET,nType);
|
|
|
|
switch(nType)
|
|
{
|
|
case TDb::eHorLeftOffset:
|
|
es = ExplodeOrHorLeftDraw3d(mode);
|
|
break;
|
|
case TDb::eHorRightOffset:
|
|
es = ExplodeOrHorRightDraw3d(mode);
|
|
break;
|
|
case TDb::eVerOffset:
|
|
es = ExplodeOrVerDraw3d(mode);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::transformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
AcGePoint3d ptGeS,ptGeE;
|
|
AcGeVector3d vtDir,vtNormal,vtClap;
|
|
if (m_pXDataMap->GetAt(KEY_START,ptGeS) &&
|
|
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) &&
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) )
|
|
{
|
|
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_MAINBR,vtClap);
|
|
ptGeS.transformBy(xform);
|
|
ptGeE.transformBy(xform);
|
|
vtDir.transformBy(xform);
|
|
vtNormal.transformBy(xform);
|
|
vtClap.transformBy(xform);
|
|
|
|
m_pXDataMap->SetAt(KEY_START,ptGeS);
|
|
m_pXDataMap->SetAt(KEY_END,ptGeE);
|
|
m_pXDataMap->SetAt(KEY_MAINDIR,vtDir);
|
|
m_pXDataMap->SetAt(KEY_NORMAL,vtNormal);
|
|
m_pXDataMap->SetAt(KEY_CLAPBOARD_MAINBR,vtClap);
|
|
|
|
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 TEImpCabOffset::moveStretchPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::moveGripPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
int nSize = indices.length();
|
|
if (nSize > 0)
|
|
{
|
|
AcGePoint3d ptGeS,ptGeE,ptGeM;
|
|
AcGeVector3d vtDir,vtNormal;
|
|
if (!m_pXDataMap->GetAt(KEY_START,ptGeS) ||
|
|
!m_pXDataMap->GetAt(KEY_END,ptGeE) ||
|
|
!m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) ||
|
|
!m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) )
|
|
{
|
|
return Acad::eKeyNotFound;
|
|
}
|
|
|
|
Midpoint(ptGeS,ptGeE,ptGeM);
|
|
AcGePoint3d ptGeMOld = ptGeM;
|
|
|
|
// 选择多个夹点,以first为准
|
|
int nIndex = indices.first();
|
|
TDb::Position ePos = ExplainGripIndex(nIndex);
|
|
switch(ePos)
|
|
{
|
|
case TDb::eBr1:
|
|
case TDb::eBr2:
|
|
case TDb::eMid:
|
|
{
|
|
// 修改原因: 对于非正交的移动会使连接的桥架做错误图形变化
|
|
// 修改人 : tsj
|
|
// 修改时间:2009.11.24
|
|
//平行,或垂直按moveGrip 接口消息逻辑
|
|
//非平行,按transform 接口消息逻辑
|
|
// TDb::InterfaceOper eOper = TDb::eMoveGripPoint;
|
|
// if (vtDir.isParallelTo(offset))//平行
|
|
// {
|
|
// }
|
|
// else if (vtDir.isPerpendicularTo(offset))//垂直
|
|
// {
|
|
// }
|
|
// else
|
|
// {
|
|
// // eOper = TDb::eTransformBy;
|
|
// }
|
|
|
|
ptGeS += offset;
|
|
ptGeE += offset;
|
|
|
|
m_pXDataMap->SetAt(KEY_START,ptGeS);
|
|
m_pXDataMap->SetAt(KEY_END,ptGeE);
|
|
|
|
if (m_pOwnerEnt != NULL && m_pOwnerEnt->objectId().isValid())
|
|
{
|
|
if (vtDir.isParallelTo(offset) || vtDir.isPerpendicularTo(offset))// add
|
|
{
|
|
// 写入接口更改消息
|
|
TInterfaceModifyMsg iMsg;
|
|
iMsg.SetMsgPoint(ptGeS);//new pos
|
|
iMsg.SetGripPosition(ePos);
|
|
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:
|
|
break;
|
|
case TDb::eCommand1:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::getStretchPoints(AcGePoint3dArray& stretchPoints) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::getGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
ASSERT(m_pXDataMap != NULL);
|
|
|
|
AcGePoint3d ptS,ptE,ptM,ptGeT;
|
|
AcGeVector3d vtDir;
|
|
if (m_pXDataMap->GetAt(KEY_START,ptS)
|
|
&& m_pXDataMap->GetAt(KEY_END,ptE)
|
|
&& m_pXDataMap->GetAt(KEY_MAINDIR,vtDir))
|
|
{
|
|
Midpoint(ptS,ptE,ptM);
|
|
|
|
gripPoints.append(ptM);
|
|
gripPoints.append(ptS);
|
|
gripPoints.append(ptE);
|
|
|
|
//增加2个命令夹点
|
|
AcGePoint3d ptGeT;
|
|
//按 10 个像素点
|
|
double dCmd = TSupportFunc::PixelToWcs(10);
|
|
ptGeT = ptS + vtDir * dCmd;
|
|
gripPoints.append(ptGeT); //cmd1
|
|
|
|
ptGeT = ptE - vtDir * dCmd;
|
|
gripPoints.append(ptGeT); //cmd2
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::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) return Acad::eOk;
|
|
|
|
double dW = 0.0;
|
|
double dEl = 0.0;
|
|
double dH = 0.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptSta,ptEnd;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dW);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_EL,dEl);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptSta);
|
|
m_pXDataMap->GetAt(KEY_END,ptEnd);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
AcGePoint3d ptMid = TSupportFunc::Mid(ptSta,ptEnd);
|
|
|
|
AcGePoint3d ptGe[4];
|
|
AcGeVector3d vtVer = vtDir;
|
|
vtVer.rotateBy(PI / 2.0,vtNorm);
|
|
vtVer.normalize();
|
|
|
|
ptGe[0] = ptEnd + dW / 2.0 * vtVer;
|
|
ptGe[2] = ptEnd - dW / 2.0 * vtVer;
|
|
ptGe[1] = ptSta + dW / 2.0 * vtVer;
|
|
ptGe[3] = ptSta - dW / 2.0 * vtVer;
|
|
|
|
switch (osnapMode)
|
|
{
|
|
case AcDb::kOsModeEnd:
|
|
{
|
|
snapPoints.append(ptGe[0]);
|
|
snapPoints.append(ptGe[1]);
|
|
snapPoints.append(ptGe[2]);
|
|
snapPoints.append(ptGe[3]);
|
|
snapPoints.append(ptSta);
|
|
snapPoints.append(ptEnd);
|
|
break;
|
|
}
|
|
case AcDb::kOsModeMid:
|
|
{
|
|
snapPoints.append(ptMid);
|
|
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;
|
|
}
|
|
default:
|
|
{
|
|
AcGePlane plan(ptGe[0],ptGe[1],ptGe[2]);
|
|
AcGePoint3d ptOrth = AcGePoint3d::kOrigin.orthoProject(plan);
|
|
plan.set(ptOrth,normal());
|
|
|
|
dEl = ptOrth.asVector().length();
|
|
if (!ptOrth.asVector().isCodirectionalTo(normal()))
|
|
{
|
|
dEl *= -1.0;
|
|
}
|
|
|
|
AcDbPolyline pLine;
|
|
pLine.addVertexAt(0,ptGe[0].convert2d(plan));
|
|
pLine.addVertexAt(1,ptGe[1].convert2d(plan));
|
|
pLine.addVertexAt(2,ptGe[3].convert2d(plan));
|
|
pLine.addVertexAt(3,ptGe[2].convert2d(plan));
|
|
pLine.setClosed(Adesk::kTrue);
|
|
|
|
pLine.setElevation(dEl);
|
|
pLine.setNormal(plan.normal());
|
|
|
|
return pLine.getOsnapPoints(osnapMode,gsSelectionMark,pickPoint,lastPoint,viewXform,snapPoints,geomIds);
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
// 获取垂足点
|
|
BOOL TEImpCabOffset::GetVerticalFootPoint(const AcGePoint3d& pickPoint,
|
|
const AcGePoint3d& lastPoint,
|
|
AcGePoint3d& ptVerFoot) const
|
|
{
|
|
BOOL bIsSuc = FALSE;
|
|
|
|
TComplexCurve cplCurve;
|
|
if (MakeCurves(cplCurve))
|
|
{
|
|
GetOffsetMidLine(cplCurve);
|
|
|
|
TSupportFunc spFun;
|
|
bIsSuc = spFun.GetVerticalFootPoint(cplCurve, pickPoint, lastPoint, ptVerFoot);
|
|
}
|
|
|
|
return bIsSuc;
|
|
}
|
|
|
|
void TEImpCabOffset::list() const
|
|
{
|
|
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::getClassID(CLSID* pClsid) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//左偏乙字弯
|
|
BOOL TEImpCabOffset::MakeHorLeftOffsetCurves(TComplexCurve& cplCurve) const
|
|
{
|
|
/*
|
|
左偏乙字弯
|
|
0________1
|
|
8| |
|
|
| |
|
|
7 | | 2
|
|
/ /
|
|
/ /
|
|
6| | 3
|
|
| |
|
|
5|_________|4
|
|
|
|
方向属性 从起点到终点
|
|
*/
|
|
|
|
ASSERT(m_pXDataMap != NULL);
|
|
|
|
//1 得到乙字弯参数属性
|
|
AcGeVector3d vtNormal,vtDir,vtDirT;
|
|
AcGePoint3d ptS,ptE;
|
|
int nCover = 0;
|
|
double dB = 0.0,dH = 0.0;
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal);
|
|
m_pXDataMap->GetAt(KEY_COVER,nCover);
|
|
|
|
vtDir.normalize();
|
|
vtDirT = vtDir;
|
|
vtDirT.rotateBy(PI/2,AcGeVector3d::kZAxis);
|
|
|
|
//2存储各个点
|
|
int nNum = 8;
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePoint3d arPt[9];
|
|
AcGePoint3d ptOn;
|
|
AcDbLine line(ptS,ptS+vtDirT);
|
|
line.getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
|
dLen = ptOn.distanceTo(ptE);
|
|
dLenT = ptOn.distanceTo(ptS);
|
|
|
|
arPt[0] = ptS - vtDirT*dB/2;
|
|
arPt[1] = ptS + vtDirT*dB/2;
|
|
arPt[2] = arPt[1] + vtDir*((dLen - dLenT + dB*tan(PI/8))/2);
|
|
arPt[5] = ptE - vtDirT*dB/2;
|
|
arPt[4] = ptE + vtDirT*dB/2;
|
|
arPt[3] = arPt[4] - vtDir*((dLen - dLenT - dB*tan(PI/8))/2);
|
|
arPt[6] = arPt[5] - vtDir*((dLen - dLenT + dB*tan(PI/8))/2);
|
|
arPt[7] = arPt[0] + vtDir*((dLen - dLenT - dB*tan(PI/8))/2);
|
|
arPt[8] = arPt[0];
|
|
|
|
TCurveElement ele;
|
|
for (int i = 0; i < nNum; ++i)
|
|
{
|
|
ele.ptGe[0] = arPt[i];
|
|
ele.ptGe[1] = arPt[i+1];
|
|
ele.ptGe[2] = arPt[i+1];
|
|
cplCurve.append(ele);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
//右偏乙字弯
|
|
BOOL TEImpCabOffset::MakeHorRightOffsetCurves(TComplexCurve& cplCurve) const
|
|
{
|
|
ASSERT(m_pXDataMap != NULL);
|
|
|
|
//1 得到乙字弯参数属性
|
|
AcGeVector3d vtNormal,vtDir,vtDirT;
|
|
AcGePoint3d ptS,ptE;
|
|
int nCover = 0;
|
|
double dB = 0.0,dH = 0.0;
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal);
|
|
m_pXDataMap->GetAt(KEY_COVER,nCover);
|
|
|
|
vtDir.normalize();
|
|
vtDirT = vtDir;
|
|
vtDirT.rotateBy(PI/2,AcGeVector3d::kZAxis);
|
|
|
|
//2存储各个点
|
|
int nNum = 8;
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePoint3d arPt[9];
|
|
AcGePoint3d ptOn;
|
|
AcDbLine line(ptS,ptS+vtDirT);
|
|
line.getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
|
dLen = ptOn.distanceTo(ptE);
|
|
dLenT = ptOn.distanceTo(ptS);
|
|
|
|
arPt[0] = ptS - vtDirT*dB/2;
|
|
arPt[1] = ptS + vtDirT*dB/2;
|
|
arPt[2] = arPt[1] + vtDir*((dLen - dLenT - dB*tan(PI/8))/2);
|
|
arPt[5] = ptE - vtDirT*dB/2;
|
|
arPt[4] = ptE + vtDirT*dB/2;
|
|
arPt[3] = arPt[4] - vtDir*((dLen - dLenT + dB*tan(PI/8))/2);
|
|
arPt[6] = arPt[5] - vtDir*((dLen - dLenT - dB*tan(PI/8))/2);
|
|
arPt[7] = arPt[0] + vtDir*((dLen - dLenT + dB*tan(PI/8))/2);
|
|
arPt[8] = arPt[0];
|
|
|
|
TCurveElement ele;
|
|
for (int i = 0; i < nNum; ++i)
|
|
{
|
|
ele.ptGe[0] = arPt[i];
|
|
ele.ptGe[1] = arPt[i+1];
|
|
ele.ptGe[2] = arPt[i+1];
|
|
cplCurve.append(ele);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
//垂直乙字弯
|
|
BOOL TEImpCabOffset::MakeVerOffsetCurves(TComplexCurve& cplCurve) const
|
|
{
|
|
ASSERT(m_pXDataMap != NULL);
|
|
//起点为Z坐标较低的点,终点为Z坐标较高的点
|
|
//1 得到乙字弯参数属性
|
|
AcGeVector3d vtNormal,vtDir,vtDirT,vtVer;
|
|
AcGePoint3d ptS,ptE,ptMid;
|
|
int nCover = 0;
|
|
double dB = 0.0,dH = 0.0;
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal);
|
|
m_pXDataMap->GetAt(KEY_COVER,nCover);
|
|
|
|
vtDir.normalize();
|
|
vtVer = vtDir;
|
|
vtDirT = vtDir;
|
|
vtDirT.rotateBy(PI/2,AcGeVector3d::kZAxis);
|
|
|
|
//2存储各个点
|
|
int nNum = 8;
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePoint3d arPt[9];
|
|
AcGePlane planNorm(ptS,vtNormal);
|
|
dLenT = ptE.distanceTo(ptE.orthoProject(planNorm));
|
|
|
|
AcGePlane plan(ptE,vtDir);
|
|
dLen = ptS.distanceTo(ptS.orthoProject(plan));
|
|
|
|
arPt[0] = ptS - vtDirT*dB/2;
|
|
arPt[1] = ptS + vtDirT*dB/2;
|
|
arPt[2] = arPt[1] + vtDir*((dLen - dLenT)/2);
|
|
arPt[5] = ptE - vtDirT*dB/2;
|
|
arPt[4] = ptE + vtDirT*dB/2;
|
|
arPt[3] = arPt[4] - vtDir*((dLen - dLenT)/2);
|
|
arPt[6] = arPt[5] - vtDir*((dLen - dLenT)/2);
|
|
arPt[7] = arPt[0] + vtDir*((dLen - dLenT)/2);
|
|
arPt[8] = arPt[0];
|
|
|
|
TCurveElement ele;
|
|
for (int i = 0; i < nNum; ++i)
|
|
{
|
|
ele.ptGe[0] = arPt[i];
|
|
ele.ptGe[1] = arPt[i+1];
|
|
ele.ptGe[2] = arPt[i+1];
|
|
cplCurve.append(ele);
|
|
}
|
|
|
|
//显示>指示符
|
|
vtVer.rotateBy(PI/2,vtNormal);
|
|
ptMid = TSupportFunc::Mid(ptS,ptE);
|
|
if (ptS.z > ptE.z)
|
|
{
|
|
AcGePoint3d ptTemp;
|
|
ptTemp = ptE;
|
|
ptE = ptS;
|
|
ptS = ptTemp;
|
|
}
|
|
if (ptS.z != ptE.z)
|
|
{
|
|
vtDir = ptS - ptE;
|
|
vtDir.normalize();
|
|
AcGePoint3d pt1,pt2;
|
|
dB /= 8;
|
|
pt1 = ptMid - 50*vtDir;
|
|
pt1 += vtVer*3*dB;
|
|
pt2 = pt1 - vtVer * 6 * dB;
|
|
|
|
ele.ptGe[0] = ptMid;
|
|
ele.ptGe[1] = pt1;
|
|
ele.ptGe[2] = pt1;
|
|
cplCurve.append(ele);
|
|
|
|
ele.ptGe[0] = ptMid;
|
|
ele.ptGe[1] = pt2;
|
|
ele.ptGe[2] = pt2;
|
|
cplCurve.append(ele);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL TEImpCabOffset::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 ptGeS,ptGeE;
|
|
AcGePoint3d ptOldGeS,ptOldGeE;
|
|
AcGeVector3d vtDir,vtNormal;
|
|
double dLen = 0.0;
|
|
if ( m_pXDataMap->GetAt(KEY_START,ptGeS) &&
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) &&
|
|
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) )
|
|
{
|
|
|
|
int nPos = iModiMsg.GetGripPosition();
|
|
switch (nPos)
|
|
{
|
|
case TDb::eBr1:
|
|
case TDb::eBr2:
|
|
case TDb::eMid:
|
|
{
|
|
if ( vtOffset.isParallelTo(vtDir) ||
|
|
vtOffset.isPerpendicularTo(vtDir)) //平行或者垂直
|
|
{
|
|
ptOldGeS = ptGeS;
|
|
ptOldGeE = ptGeE;
|
|
|
|
ptGeS += vtOffset;
|
|
ptGeE += vtOffset;
|
|
|
|
m_pXDataMap->SetAt(KEY_START,ptGeS);
|
|
m_pXDataMap->SetAt(KEY_END,ptGeE);
|
|
|
|
AcDbObjectId id1,id2;
|
|
m_pXDataMap->GetAt(KEY_IDCNT1,id1);
|
|
m_pXDataMap->GetAt(KEY_IDCNT2,id2);
|
|
|
|
// 构造接口消息传递 开始端检查
|
|
AcDbObjectId idT;
|
|
if (FindConnect(ptOldGeS,vtDir,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(ptOldGeE,vtDir,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;
|
|
}
|
|
}
|
|
|
|
// 更新模型空间的扩展字典的注册的接口数据
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(vtOffset);
|
|
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
|
|
return bMsgTranslate;
|
|
}
|
|
else // 倾斜,不传递消息,只改变自身
|
|
{
|
|
ptGeS += vtOffset;
|
|
ptGeE += vtOffset;
|
|
|
|
m_pXDataMap->SetAt(KEY_START,ptGeS);
|
|
m_pXDataMap->SetAt(KEY_END,ptGeE);
|
|
|
|
// 更新模型空间的扩展字典的注册的接口数据
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(vtOffset);
|
|
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
|
|
return FALSE;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return bMsgTranslate;
|
|
}
|
|
|
|
BOOL TEImpCabOffset::OnTransformByMsgNotify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
|
|
{
|
|
// 不考虑其所属的接口的关系,变化后相当于断开关系
|
|
// 新位置的关系建立,由外部管理对象处理;
|
|
AcGePoint3d ptSta,ptEnd,ptGeM;
|
|
BOOL bMsgTranslate = FALSE;
|
|
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
AcGeMatrix3d xform = iModiMsg.GetTransform();
|
|
|
|
AcGePoint3d ptGeM,ptGeS,ptGeE;
|
|
AcGePoint3d ptOldGeS,ptOldGeE;
|
|
AcGeVector3d vtDir,vtNormal;
|
|
if (!m_pXDataMap->GetAt(KEY_START,ptGeS) ||
|
|
!m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) ||
|
|
!m_pXDataMap->GetAt(KEY_END,ptGeE) ||
|
|
!m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) )
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
ptOldGeS = ptGeS;
|
|
ptOldGeE = ptGeE;
|
|
|
|
ptGeS.transformBy(xform);
|
|
ptGeE.transformBy(xform);
|
|
|
|
m_pXDataMap->SetAt(KEY_START,ptGeS);
|
|
m_pXDataMap->SetAt(KEY_END,ptGeE);
|
|
|
|
//产生新的接口消息
|
|
AcDbObjectId id1,id2;
|
|
m_pXDataMap->GetAt(KEY_IDCNT1,id1);
|
|
m_pXDataMap->GetAt(KEY_IDCNT2,id2);
|
|
|
|
// 构造接口消息传递 开始端检查
|
|
AcDbObjectId idT;
|
|
if (FindConnect(ptOldGeS,vtDir,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(ptOldGeE,vtDir,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 (m_pOwnerEnt->objectId().isValid())
|
|
{
|
|
//更新接口记录接口信息
|
|
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
|
|
}
|
|
}
|
|
return bMsgTranslate;
|
|
}
|
|
|
|
BOOL TEImpCabOffset::OnSizeMsgNotify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
CString TEImpCabOffset::GetCurrentTypeName() const
|
|
{
|
|
CString strName = _T("");
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
int nType = 0;
|
|
m_pXDataMap->GetAt(KEY_OFFSET,nType);
|
|
switch(nType)
|
|
{
|
|
case TDb::eHorLeftOffset:
|
|
strName = (_T("槽式水平Z字左偏等径弯通"));
|
|
break;
|
|
case TDb::eHorRightOffset:
|
|
strName = (_T("槽式水平Z字右偏等径弯通"));
|
|
break;
|
|
case TDb::eVerOffset:
|
|
strName = (_T("槽式垂直高低等径弯通"));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
//获取中心线
|
|
BOOL TEImpCabOffset::GetOffsetMidLine(TComplexCurve& compCurve) const
|
|
{
|
|
return GetCurvesInSide(compCurve);
|
|
}
|
|
|
|
// 获取最近点
|
|
BOOL TEImpCabOffset::GetNearestPoint(const AcGePoint3d& pickPoint, AcGePoint3d& ptNear) const
|
|
{
|
|
BOOL bIsFind = FALSE;
|
|
|
|
TComplexCurve cplCurve;
|
|
if (MakeBaseCurves(cplCurve))
|
|
{
|
|
GetOffsetMidLine(cplCurve);
|
|
|
|
TSupportFunc spFun;
|
|
bIsFind = spFun.GetNearestPoint(cplCurve, pickPoint, ptNear);
|
|
}
|
|
|
|
return bIsFind;
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::ExplodeOrHorLeftDraw3d(XExplodeDraw &mode) const
|
|
{
|
|
double dB = 0.0;
|
|
double dH = 0.0;
|
|
double dEl = 0.0;
|
|
double dHeight = 100.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptS,ptE;
|
|
int nCover = 1;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_COVER,nCover);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
AcGePoint3d *pVerList = NULL;
|
|
AcGeVector3d vtDirT = vtDir;
|
|
vtDirT.rotateBy(PI / 2.0,vtNorm);
|
|
vtDirT.normalize();
|
|
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePoint3d ptOn;
|
|
AcDbLine line(ptS,ptS+vtDirT);
|
|
line.getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
|
dLen = ptOn.distanceTo(ptE);
|
|
dLenT = ptOn.distanceTo(ptS);
|
|
|
|
int nRow = 4;
|
|
int nCol = 4;
|
|
if (nCover)
|
|
nRow = 5;
|
|
|
|
pVerList = new AcGePoint3d[nRow*nCol];
|
|
|
|
pVerList[7] = ptS - vtDirT*dB/2;
|
|
pVerList[11] = ptS + vtDirT*dB/2;
|
|
pVerList[10] = pVerList[11] + vtDir*((dLen - dLenT + dB*tan(PI/8))/2);
|
|
pVerList[4] = ptE - vtDirT*dB/2;
|
|
pVerList[8] = ptE + vtDirT*dB/2;
|
|
pVerList[9] = pVerList[8] - vtDir*((dLen - dLenT - dB*tan(PI/8))/2);
|
|
pVerList[5] = pVerList[4] - vtDir*((dLen - dLenT + dB*tan(PI/8))/2);
|
|
pVerList[6] = pVerList[7] + vtDir*((dLen - dLenT - dB*tan(PI/8))/2);
|
|
pVerList[0] = pVerList[4] + vtNorm*dH;
|
|
pVerList[1] = pVerList[5] + vtNorm*dH;
|
|
pVerList[2] = pVerList[6] + vtNorm*dH;
|
|
pVerList[3] = pVerList[7] + vtNorm*dH;
|
|
pVerList[12] = pVerList[8] + vtNorm*dH;
|
|
pVerList[13] = pVerList[9] + vtNorm*dH;
|
|
pVerList[14] = pVerList[10] + vtNorm*dH;
|
|
pVerList[15] = pVerList[11] + vtNorm*dH;
|
|
|
|
if (nCover)
|
|
{
|
|
//有盖子
|
|
nRow = 5;
|
|
pVerList[16] = pVerList[0];
|
|
pVerList[17] = pVerList[1];
|
|
pVerList[18] = pVerList[2];
|
|
pVerList[19] = pVerList[3];
|
|
}
|
|
|
|
if (pVerList != NULL)
|
|
{
|
|
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
|
|
mode.SetColor(curColor);
|
|
|
|
mode.DrawMesh(nRow, nCol, pVerList,NULL);
|
|
|
|
delete []pVerList;
|
|
}
|
|
|
|
////////////////////
|
|
//中线
|
|
AcGePoint3d ptSta,ptEnd,ptM;
|
|
AcGePoint3d ptM1,ptM2;
|
|
int nType = 0;
|
|
AcGeVector3d vtDirT1,vtDirT2;
|
|
m_pXDataMap->GetAt(KEY_START,ptSta);
|
|
m_pXDataMap->GetAt(KEY_END,ptEnd);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
m_pXDataMap->GetAt(KEY_OFFSET,nType);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
vtDirT1 = vtDir;
|
|
vtDirT1.rotateBy(PI/2,AcGeVector3d::kZAxis);
|
|
vtDirT2 = vtDir;
|
|
if (nType == TDb::eHorLeftOffset)
|
|
vtDirT2.rotateBy(3*PI/4,AcGeVector3d::kZAxis);
|
|
else if (nType == TDb::eHorRightOffset)
|
|
vtDirT2.rotateBy(PI/4,AcGeVector3d::kZAxis);
|
|
|
|
Midpoint(ptSta,ptEnd,ptM);
|
|
|
|
//求中间连接的两点
|
|
if (nType != TDb::eVerOffset)
|
|
{
|
|
AcDbLine line(ptSta,ptSta+vtDirT1);
|
|
line.getClosestPointTo(ptEnd,ptOn,Adesk::kTrue);
|
|
double dLen = ptOn.distanceTo(ptSta);
|
|
if (nType == TDb::eHorLeftOffset)
|
|
{
|
|
ptM1 = ptM + vtDirT2*pow(2,0.5)*dLen/2;
|
|
ptM2 = ptM - vtDirT2*pow(2,0.5)*dLen/2;
|
|
}
|
|
else
|
|
{
|
|
ptM1 = ptM - vtDirT2*pow(2,0.5)*dLen/2;
|
|
ptM2 = ptM + vtDirT2*pow(2,0.5)*dLen/2;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePlane planNorm(ptSta,vtNorm);
|
|
dLenT = ptEnd.distanceTo(ptEnd.orthoProject(planNorm));
|
|
AcGePlane plan(ptEnd,vtDir);
|
|
dLen = ptSta.distanceTo(ptSta.orthoProject(plan));
|
|
ptM1 = ptSta + vtDir*(dLen - dLenT)/2;
|
|
ptM2 = ptEnd - vtDir*(dLen - dLenT)/2;
|
|
}
|
|
|
|
double dW = 0.0;
|
|
m_pXDataMap->GetAt(KEY_B,dW);
|
|
|
|
TDb::TCurveElement el;
|
|
memset(&el,0,sizeof(TDb::TCurveElement));
|
|
|
|
int nShowCenLine = 0;
|
|
m_pXDataMap->GetAt(KEY_HASCENLINE,nShowCenLine);
|
|
if (nShowCenLine)
|
|
{
|
|
double dWidth = 0.0;
|
|
m_pXDataMap->GetAt(KEY_CENLWIDTH,dWidth);
|
|
|
|
AcGePoint3d ptVer[4];
|
|
|
|
ptVer[0] = ptSta;
|
|
ptVer[1] = ptM1;
|
|
ptVer[2] = ptVer[0] + vtNorm * dH;
|
|
ptVer[3] = ptVer[1] + vtNorm * dH;
|
|
mode.DrawMesh(2,2,ptVer);
|
|
|
|
ptVer[0] = ptM1;
|
|
ptVer[1] = ptM2;
|
|
ptVer[2] = ptVer[0] + vtNorm * dH;
|
|
ptVer[3] = ptVer[1] + vtNorm * dH;
|
|
mode.DrawMesh(2,2,ptVer);
|
|
|
|
ptVer[0] = ptM2;
|
|
ptVer[1] = ptEnd;
|
|
ptVer[2] = ptVer[0] + vtNorm * dH;
|
|
ptVer[3] = ptVer[1] + vtNorm * dH;
|
|
mode.DrawMesh(2,2,ptVer);
|
|
}
|
|
|
|
//显示隔板
|
|
int bShowBorad = -1,bHaveClap = -1;
|
|
m_pXDataMap->GetAt(KEY_HAVE_CLAPBOARD,bHaveClap);
|
|
m_pXDataMap->GetAt(KEY_SHOW_CLAPBOARD,bShowBorad);
|
|
if(bShowBorad == TDb::eShowBoard &&
|
|
bHaveClap == TDb::eBoard)
|
|
{
|
|
AcGeVector3d vtBoardMain;
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_MAINBR,vtBoardMain);
|
|
vtBoardMain.normalize();
|
|
|
|
TSupportFunc spFun;
|
|
AcGeDoubleArray arDimeS,arDimeE;
|
|
spFun.GetClapboardDimension(m_pXDataMap, arDimeS);
|
|
spFun.GetClapboardDimension(m_pXDataMap,arDimeE,KEY_CLAPBOARD_DATA2);
|
|
|
|
if (arDimeE.length() != arDimeS.length())
|
|
{
|
|
return Acad::eKeyNotFound;
|
|
}
|
|
//计算 拐点
|
|
double dDistH = 0.0,dDistV = 0.0,dDistLong = 0.0,dDistShort = 0.0;
|
|
AcGeVector3d vtTmp1;
|
|
vtTmp1 = vtDir;
|
|
AcDbLine line(ptSta,ptSta+vtTmp1);
|
|
line.getClosestPointTo(ptEnd,ptOn,Adesk::kTrue);
|
|
dDistH = ptOn.distanceTo(ptSta);
|
|
vtTmp1.rotateBy(PI/2,vtNorm);
|
|
line.setEndPoint(ptSta+vtTmp1);
|
|
line.getClosestPointTo(ptEnd,ptOn,Adesk::kTrue);
|
|
dDistV = ptOn.distanceTo(ptSta);
|
|
dDistShort = (dDistH - dDistV - dW*tan(PI/8))/2;
|
|
dDistLong = dDistShort + dW*tan(PI/8);
|
|
|
|
AcGePoint3d ptT1,ptT2;
|
|
AcDbLine tl1,tl2;
|
|
|
|
XPoint ptl1,ptl2;
|
|
ptl1 = ptSta + vtTmp1*dW/2 + vtDir*dDistLong;
|
|
ptl2 = ptSta - vtTmp1*dW/2 + vtDir*dDistShort;
|
|
tl1.setStartPoint(ptl1);
|
|
tl1.setEndPoint(ptl2);
|
|
ptl1 = ptEnd + vtTmp1*dW/2 - vtDir*dDistShort;
|
|
ptl2 = ptEnd - vtTmp1*dW/2 - vtDir*dDistLong;
|
|
tl2.setStartPoint(ptl1);
|
|
tl2.setEndPoint(ptl2);
|
|
|
|
double dOffset1 = 0.0,dOffset2 = 0.0;
|
|
for (int i = 0;i < arDimeS.length();++i)
|
|
{
|
|
dOffset1 = arDimeS[i];
|
|
dOffset2 = arDimeE[i];
|
|
|
|
AcGePoint3d ptClap1,ptClap2,ptClap3,ptClap4;
|
|
ptClap1 = ptSta - vtBoardMain*(dW/2 - dOffset1);
|
|
ptClap4 = ptEnd - vtBoardMain*(dW/2 - dOffset2);
|
|
|
|
AcGePoint3dArray arInt;
|
|
AcDbLine midline(ptClap1,ptClap1+vtDir);
|
|
midline.intersectWith(&tl1,AcDb::kExtendBoth,arInt);
|
|
if (arInt.length() > 0)
|
|
{
|
|
ptClap2 = arInt.first();
|
|
arInt.setLogicalLength(0);
|
|
}
|
|
midline.setStartPoint(ptClap4);
|
|
midline.setEndPoint(ptClap4+vtDir);
|
|
midline.intersectWith(&tl2,AcDb::kExtendBoth,arInt);
|
|
if (arInt.length() > 0)
|
|
{
|
|
ptClap3 = arInt.first();
|
|
}
|
|
|
|
AcGePoint3d ptVer[4];
|
|
ptVer[0] = ptClap1;
|
|
ptVer[1] = ptClap2;
|
|
ptVer[2] = ptClap1 + vtNorm*dH;
|
|
ptVer[3] = ptClap2 + vtNorm*dH;
|
|
mode.DrawMesh(2,2,ptVer);
|
|
|
|
ptVer[0] = ptClap2;
|
|
ptVer[1] = ptClap3;
|
|
ptVer[2] = ptClap2 + vtNorm*dH;
|
|
ptVer[3] = ptClap3 + vtNorm*dH;
|
|
mode.DrawMesh(2,2,ptVer);
|
|
|
|
ptVer[0] = ptClap3;
|
|
ptVer[1] = ptClap4;
|
|
ptVer[2] = ptClap3 + vtNorm*dH;
|
|
ptVer[3] = ptClap4 + vtNorm*dH;
|
|
mode.DrawMesh(2,2,ptVer);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::ExplodeOrHorLeftDraw3dOfT(XExplodeDraw &mode) const
|
|
{
|
|
if (m_pXDataMap == NULL)
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
double dLadderWidth = 50; //梯宽
|
|
double dSideWidth = 30; //侧面宽
|
|
double dThick = 10; //梯厚度
|
|
double dOffSetDist = 300; //乙字弯间距
|
|
|
|
double dB = 0.0;
|
|
double dH = 0.0;
|
|
double dEl = 0.0;
|
|
double dHeight = 100.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptS,ptE;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
AcGePoint3d *pVerList = NULL;
|
|
AcGeVector3d vtDirT = vtDir;
|
|
vtDirT.rotateBy(PI / 2.0,vtNorm);
|
|
vtDirT.normalize();
|
|
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePoint3d ptOn;
|
|
AcDbLine line(ptS,ptS+vtDirT);
|
|
line.getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
|
dLen = ptOn.distanceTo(ptE);
|
|
dLenT = ptOn.distanceTo(ptS);
|
|
|
|
int nRow = 4;
|
|
int nCol = 4;
|
|
|
|
pVerList = new AcGePoint3d[nRow*nCol];
|
|
|
|
pVerList[7] = ptS - vtDirT*dB/2;
|
|
pVerList[11] = ptS + vtDirT*dB/2;
|
|
pVerList[10] = pVerList[11] + vtDir*((dLen - dLenT + dB*tan(PI/8))/2);
|
|
pVerList[4] = ptE - vtDirT*dB/2;
|
|
pVerList[8] = ptE + vtDirT*dB/2;
|
|
pVerList[9] = pVerList[8] - vtDir*((dLen - dLenT - dB*tan(PI/8))/2);
|
|
pVerList[5] = pVerList[4] - vtDir*((dLen - dLenT + dB*tan(PI/8))/2);
|
|
pVerList[6] = pVerList[7] + vtDir*((dLen - dLenT - dB*tan(PI/8))/2);
|
|
pVerList[0] = pVerList[4] + vtNorm*dH;
|
|
pVerList[1] = pVerList[5] + vtNorm*dH;
|
|
pVerList[2] = pVerList[6] + vtNorm*dH;
|
|
pVerList[3] = pVerList[7] + vtNorm*dH;
|
|
pVerList[12] = pVerList[8] + vtNorm*dH;
|
|
pVerList[13] = pVerList[9] + vtNorm*dH;
|
|
pVerList[14] = pVerList[10] + vtNorm*dH;
|
|
pVerList[15] = pVerList[11] + vtNorm*dH;
|
|
|
|
if (pVerList != NULL)
|
|
{
|
|
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
|
|
mode.SetColor(curColor);
|
|
|
|
AcGePoint3dArray arPt;
|
|
AcDbLine line1(pVerList[11] + vtDirT * dSideWidth, pVerList[10] + vtDirT * dSideWidth);
|
|
|
|
AcGeVector3d vtr = pVerList[9] - pVerList[10];
|
|
vtr.rotateBy(PI / 2, vtNorm);
|
|
vtr.normalize();
|
|
AcDbLine line2(pVerList[9] + vtr * dSideWidth, pVerList[10] + vtr * dSideWidth);
|
|
|
|
line1.intersectWith(&line2, AcDb::kExtendBoth, arPt);
|
|
|
|
if (arPt.length() == 1)
|
|
{
|
|
AcGePoint3d ptIns1 = arPt[0];
|
|
|
|
line1.setStartPoint(pVerList[9] + vtDirT * dSideWidth);
|
|
line1.setEndPoint(pVerList[8] + vtDirT * dSideWidth);
|
|
|
|
arPt.setLogicalLength(0);
|
|
line1.intersectWith(&line2, AcDb::kExtendBoth, arPt);
|
|
|
|
if (arPt.length() == 1)
|
|
{
|
|
AcGePoint3d ptIns2 = arPt[0];
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[11]);
|
|
arPt.append(pVerList[10]);
|
|
arPt.append(pVerList[11] + vtDirT * dSideWidth);
|
|
arPt.append(ptIns1);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[9]);
|
|
arPt.append(pVerList[10]);
|
|
arPt.append(ptIns2);
|
|
arPt.append(ptIns1);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[9]);
|
|
arPt.append(pVerList[8]);
|
|
arPt.append(ptIns2);
|
|
arPt.append(pVerList[8] + vtDirT * dSideWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
}
|
|
}
|
|
|
|
vtr = pVerList[6] - pVerList[5];
|
|
vtr.rotateBy(PI / 2, vtNorm);
|
|
vtr.normalize();
|
|
line1.setStartPoint(pVerList[7] - vtDirT * dSideWidth);
|
|
line1.setEndPoint(pVerList[6] - vtDirT * dSideWidth);
|
|
line2.setStartPoint(pVerList[5] + vtr * dSideWidth);
|
|
line2.setEndPoint(pVerList[6] + vtr * dSideWidth);
|
|
|
|
arPt.setLogicalLength(0);
|
|
line1.intersectWith(&line2, AcDb::kExtendBoth, arPt);
|
|
|
|
if (arPt.length() == 1)
|
|
{
|
|
AcGePoint3d ptIns1 = arPt[0];
|
|
|
|
line1.setStartPoint(pVerList[5] - vtDirT * dSideWidth);
|
|
line1.setEndPoint(pVerList[4] - vtDirT * dSideWidth);
|
|
|
|
arPt.setLogicalLength(0);
|
|
line1.intersectWith(&line2, AcDb::kExtendBoth, arPt);
|
|
|
|
if (arPt.length() == 1)
|
|
{
|
|
AcGePoint3d ptIns2 = arPt[0];
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[7]);
|
|
arPt.append(pVerList[6]);
|
|
arPt.append(pVerList[7] - vtDirT * dSideWidth);
|
|
arPt.append(ptIns1);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[5]);
|
|
arPt.append(pVerList[6]);
|
|
arPt.append(ptIns2);
|
|
arPt.append(ptIns1);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[5]);
|
|
arPt.append(pVerList[4]);
|
|
arPt.append(ptIns2);
|
|
arPt.append(pVerList[4] - vtDirT * dSideWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
}
|
|
}
|
|
|
|
double dLen = (pVerList[6].distanceTo(pVerList[5]));
|
|
int num = (int)(dLen / dOffSetDist);
|
|
vtr = pVerList[9] - pVerList[10];
|
|
vtr.normalize();
|
|
|
|
int i = 0;
|
|
for (i = 0; i < num; i++)
|
|
{
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[10] + vtr * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[6] + vtr * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[10] + vtr * (i + 1) * dOffSetDist - vtr * dLadderWidth);
|
|
arPt.append(pVerList[6] + vtr * (i + 1) * dOffSetDist - vtr * dLadderWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dThick);
|
|
}
|
|
|
|
double dLength = pVerList[7].distanceTo(pVerList[6]);
|
|
num = (int)(dLength / dOffSetDist);
|
|
for (i = 0; i < num; i++)
|
|
{
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[11] + vtDir * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[7] + vtDir * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[11] + vtDir * (i + 1) * dOffSetDist - vtDir * dLadderWidth);
|
|
arPt.append(pVerList[7] + vtDir * (i + 1) * dOffSetDist - vtDir * dLadderWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dThick);
|
|
}
|
|
|
|
for (i = 0; i < num; i++)
|
|
{
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[8] - vtDir * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[4] - vtDir * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[8] - vtDir * (i + 1) * dOffSetDist + vtDir * dLadderWidth);
|
|
arPt.append(pVerList[4] - vtDir * (i + 1) * dOffSetDist + vtDir * dLadderWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dThick);
|
|
}
|
|
delete []pVerList;
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void TEImpCabOffset::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 TEImpCabOffset::ExplodeOrHorRightDraw3d(XExplodeDraw &mode) const
|
|
{
|
|
double dB = 0.0;
|
|
double dH = 0.0;
|
|
double dEl = 0.0;
|
|
double dHeight = 100.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptS,ptE;
|
|
int nCover = 1;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_COVER,nCover);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
AcGePoint3d *pVerList = NULL;
|
|
AcGeVector3d vtDirT = vtDir;
|
|
vtDirT.rotateBy(PI / 2.0,vtNorm);
|
|
vtDirT.normalize();
|
|
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePoint3d ptOn;
|
|
AcDbLine line(ptS,ptS+vtDirT);
|
|
line.getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
|
dLen = ptOn.distanceTo(ptE);
|
|
dLenT = ptOn.distanceTo(ptS);
|
|
|
|
int nRow = 4;
|
|
int nCol = 4;
|
|
if (nCover)
|
|
nRow = 5;
|
|
|
|
pVerList = new AcGePoint3d[nRow*nCol];
|
|
|
|
pVerList[7] = ptS - vtDirT*dB/2;
|
|
pVerList[11] = ptS + vtDirT*dB/2;
|
|
pVerList[10] = pVerList[11] + vtDir*((dLen - dLenT - dB*tan(PI/8))/2);
|
|
pVerList[4] = ptE - vtDirT*dB/2;
|
|
pVerList[8] = ptE + vtDirT*dB/2;
|
|
pVerList[9] = pVerList[8] - vtDir*((dLen - dLenT + dB*tan(PI/8))/2);
|
|
pVerList[5] = pVerList[4] - vtDir*((dLen - dLenT - dB*tan(PI/8))/2);
|
|
pVerList[6] = pVerList[7] + vtDir*((dLen - dLenT + dB*tan(PI/8))/2);
|
|
pVerList[0] = pVerList[4] + vtNorm*dH;
|
|
pVerList[1] = pVerList[5] + vtNorm*dH;
|
|
pVerList[2] = pVerList[6] + vtNorm*dH;
|
|
pVerList[3] = pVerList[7] + vtNorm*dH;
|
|
pVerList[12] = pVerList[8] + vtNorm*dH;
|
|
pVerList[13] = pVerList[9] + vtNorm*dH;
|
|
pVerList[14] = pVerList[10] + vtNorm*dH;
|
|
pVerList[15] = pVerList[11] + vtNorm*dH;
|
|
|
|
if (nCover)
|
|
{
|
|
//有盖子
|
|
nRow = 5;
|
|
pVerList[16] = pVerList[0];
|
|
pVerList[17] = pVerList[1];
|
|
pVerList[18] = pVerList[2];
|
|
pVerList[19] = pVerList[3];
|
|
}
|
|
|
|
if (pVerList != NULL)
|
|
{
|
|
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
|
|
mode.SetColor(curColor);
|
|
|
|
mode.DrawMesh(nRow, nCol, pVerList,NULL);
|
|
|
|
delete []pVerList;
|
|
}
|
|
//显示隔板
|
|
int bShowBorad = -1,bHaveClap = -1;
|
|
m_pXDataMap->GetAt(KEY_HAVE_CLAPBOARD,bHaveClap);
|
|
m_pXDataMap->GetAt(KEY_SHOW_CLAPBOARD,bShowBorad);
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
if(bShowBorad == TDb::eBoard &&
|
|
bHaveClap == TDb::eBoard)
|
|
{
|
|
AcGeVector3d vtBoardMain;
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_MAINBR,vtBoardMain);
|
|
vtBoardMain.normalize();
|
|
|
|
TSupportFunc spFun;
|
|
AcGeDoubleArray arDimeS,arDimeE;
|
|
spFun.GetClapboardDimension(m_pXDataMap, arDimeS);
|
|
spFun.GetClapboardDimension(m_pXDataMap,arDimeE,KEY_CLAPBOARD_DATA2);
|
|
|
|
if (arDimeE.length() != arDimeS.length())
|
|
{
|
|
return Acad::eKeyNotFound;
|
|
}
|
|
//计算 拐点
|
|
double dDistH = 0.0,dDistV = 0.0,dDistLong = 0.0,dDistShort = 0.0;
|
|
AcGeVector3d vtTmp1;
|
|
vtTmp1 = vtDir;
|
|
AcDbLine line(ptS,ptS+vtTmp1);
|
|
line.getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
|
dDistH = ptOn.distanceTo(ptS);
|
|
vtTmp1.rotateBy(PI/2,vtNorm);
|
|
line.setEndPoint(ptS+vtTmp1);
|
|
line.getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
|
dDistV = ptOn.distanceTo(ptS);
|
|
dDistShort = (dDistH - dDistV - dB*tan(PI/8))/2;
|
|
dDistLong = dDistShort + dB*tan(PI/8);
|
|
|
|
AcGePoint3d ptT1,ptT2;
|
|
AcDbLine tl1,tl2;
|
|
int nType;
|
|
m_pXDataMap->GetAt(KEY_OFFSET,nType);
|
|
|
|
XPoint ptl1,ptl2;
|
|
ptl1 = ptS + vtTmp1*dB/2 + vtDir*dDistShort;
|
|
ptl2 = ptS - vtTmp1*dB/2 + vtDir*dDistLong;
|
|
tl1.setStartPoint(ptl1);
|
|
tl1.setEndPoint(ptl2);
|
|
ptl1 = ptE + vtTmp1*dB/2 - vtDir*dDistLong;
|
|
ptl2 = ptE - vtTmp1*dB/2 - vtDir*dDistShort;
|
|
tl2.setStartPoint(ptl1);
|
|
tl2.setEndPoint(ptl2);
|
|
|
|
double dOffset1 = 0.0,dOffset2 = 0.0;
|
|
for (int i = 0;i < arDimeS.length();++i)
|
|
{
|
|
dOffset1 = arDimeS[i];
|
|
dOffset2 = arDimeE[i];
|
|
|
|
AcGePoint3d ptClap1,ptClap2,ptClap3,ptClap4;
|
|
ptClap1 = ptS - vtBoardMain*(dB/2 - dOffset1);
|
|
ptClap4 = ptE - vtBoardMain*(dB/2 - dOffset2);
|
|
|
|
AcGePoint3dArray arInt;
|
|
AcDbLine midline(ptClap1,ptClap1+vtDir);
|
|
midline.intersectWith(&tl1,AcDb::kExtendBoth,arInt);
|
|
if (arInt.length() > 0)
|
|
{
|
|
ptClap2 = arInt.first();
|
|
arInt.setLogicalLength(0);
|
|
}
|
|
midline.setStartPoint(ptClap4);
|
|
midline.setEndPoint(ptClap4+vtDir);
|
|
midline.intersectWith(&tl2,AcDb::kExtendBoth,arInt);
|
|
if (arInt.length() > 0)
|
|
{
|
|
ptClap3 = arInt.first();
|
|
}
|
|
|
|
AcGePoint3d ptVer[4];
|
|
ptVer[0] = ptClap1;
|
|
ptVer[1] = ptClap2;
|
|
ptVer[2] = ptClap1 + vtNorm*dH;
|
|
ptVer[3] = ptClap2 + vtNorm*dH;
|
|
mode.DrawMesh(2,2,ptVer);
|
|
|
|
ptVer[0] = ptClap2;
|
|
ptVer[1] = ptClap3;
|
|
ptVer[2] = ptClap2 + vtNorm*dH;
|
|
ptVer[3] = ptClap3 + vtNorm*dH;
|
|
mode.DrawMesh(2,2,ptVer);
|
|
|
|
ptVer[0] = ptClap3;
|
|
ptVer[1] = ptClap4;
|
|
ptVer[2] = ptClap3 + vtNorm*dH;
|
|
ptVer[3] = ptClap4 + vtNorm*dH;
|
|
mode.DrawMesh(2,2,ptVer);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::ExplodeOrHorRightDraw3dOfT(XExplodeDraw &mode) const
|
|
{
|
|
if (m_pXDataMap == NULL)
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
double dLadderWidth = 50; //梯宽
|
|
double dSideWidth = 30; //侧面宽
|
|
double dThick = 10; //梯厚度
|
|
double dOffSetDist = 300; //乙字弯间距
|
|
|
|
double dB = 0.0;
|
|
double dH = 0.0;
|
|
double dEl = 0.0;
|
|
double dHeight = 100.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptS,ptE;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
AcGePoint3d *pVerList = NULL;
|
|
AcGeVector3d vtDirT = vtDir;
|
|
vtDirT.rotateBy(PI / 2.0,vtNorm);
|
|
vtDirT.normalize();
|
|
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePoint3d ptOn;
|
|
AcDbLine line(ptS,ptS+vtDirT);
|
|
line.getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
|
dLen = ptOn.distanceTo(ptE);
|
|
dLenT = ptOn.distanceTo(ptS);
|
|
|
|
int nRow = 4;
|
|
int nCol = 4;
|
|
|
|
pVerList = new AcGePoint3d[nRow*nCol];
|
|
|
|
pVerList[7] = ptS - vtDirT*dB/2;
|
|
pVerList[11] = ptS + vtDirT*dB/2;
|
|
pVerList[10] = pVerList[11] + vtDir*((dLen - dLenT - dB*tan(PI/8))/2);
|
|
pVerList[4] = ptE - vtDirT*dB/2;
|
|
pVerList[8] = ptE + vtDirT*dB/2;
|
|
pVerList[9] = pVerList[8] - vtDir*((dLen - dLenT + dB*tan(PI/8))/2);
|
|
pVerList[5] = pVerList[4] - vtDir*((dLen - dLenT - dB*tan(PI/8))/2);
|
|
pVerList[6] = pVerList[7] + vtDir*((dLen - dLenT + dB*tan(PI/8))/2);
|
|
pVerList[0] = pVerList[4] + vtNorm*dH;
|
|
pVerList[1] = pVerList[5] + vtNorm*dH;
|
|
pVerList[2] = pVerList[6] + vtNorm*dH;
|
|
pVerList[3] = pVerList[7] + vtNorm*dH;
|
|
pVerList[12] = pVerList[8] + vtNorm*dH;
|
|
pVerList[13] = pVerList[9] + vtNorm*dH;
|
|
pVerList[14] = pVerList[10] + vtNorm*dH;
|
|
pVerList[15] = pVerList[11] + vtNorm*dH;
|
|
|
|
if (pVerList != NULL)
|
|
{
|
|
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
|
|
mode.SetColor(curColor);
|
|
|
|
AcGePoint3dArray arPt;
|
|
AcDbLine line1(pVerList[11] + vtDirT * dSideWidth, pVerList[10] + vtDirT * dSideWidth);
|
|
|
|
AcGeVector3d vtr = pVerList[9] - pVerList[10];
|
|
vtr.rotateBy(PI / 2, vtNorm);
|
|
vtr.normalize();
|
|
AcDbLine line2(pVerList[9] + vtr * dSideWidth, pVerList[10] + vtr * dSideWidth);
|
|
|
|
line1.intersectWith(&line2, AcDb::kExtendBoth, arPt);
|
|
|
|
if (arPt.length() == 1)
|
|
{
|
|
AcGePoint3d ptIns1 = arPt[0];
|
|
|
|
line1.setStartPoint(pVerList[9] + vtDirT * dSideWidth);
|
|
line1.setEndPoint(pVerList[8] + vtDirT * dSideWidth);
|
|
|
|
arPt.setLogicalLength(0);
|
|
line1.intersectWith(&line2, AcDb::kExtendBoth, arPt);
|
|
|
|
if (arPt.length() == 1)
|
|
{
|
|
AcGePoint3d ptIns2 = arPt[0];
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[11]);
|
|
arPt.append(pVerList[10]);
|
|
arPt.append(pVerList[11] + vtDirT * dSideWidth);
|
|
arPt.append(ptIns1);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[9]);
|
|
arPt.append(pVerList[10]);
|
|
arPt.append(ptIns2);
|
|
arPt.append(ptIns1);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[9]);
|
|
arPt.append(pVerList[8]);
|
|
arPt.append(ptIns2);
|
|
arPt.append(pVerList[8] + vtDirT * dSideWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
}
|
|
}
|
|
|
|
vtr = pVerList[6] - pVerList[5];
|
|
vtr.rotateBy(PI / 2, vtNorm);
|
|
vtr.normalize();
|
|
line1.setStartPoint(pVerList[7] - vtDirT * dSideWidth);
|
|
line1.setEndPoint(pVerList[6] - vtDirT * dSideWidth);
|
|
line2.setStartPoint(pVerList[5] + vtr * dSideWidth);
|
|
line2.setEndPoint(pVerList[6] + vtr * dSideWidth);
|
|
|
|
arPt.setLogicalLength(0);
|
|
line1.intersectWith(&line2, AcDb::kExtendBoth, arPt);
|
|
|
|
if (arPt.length() == 1)
|
|
{
|
|
AcGePoint3d ptIns1 = arPt[0];
|
|
|
|
line1.setStartPoint(pVerList[5] - vtDirT * dSideWidth);
|
|
line1.setEndPoint(pVerList[4] - vtDirT * dSideWidth);
|
|
|
|
arPt.setLogicalLength(0);
|
|
line1.intersectWith(&line2, AcDb::kExtendBoth, arPt);
|
|
|
|
if (arPt.length() == 1)
|
|
{
|
|
AcGePoint3d ptIns2 = arPt[0];
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[7]);
|
|
arPt.append(pVerList[6]);
|
|
arPt.append(pVerList[7] - vtDirT * dSideWidth);
|
|
arPt.append(ptIns1);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[5]);
|
|
arPt.append(pVerList[6]);
|
|
arPt.append(ptIns2);
|
|
arPt.append(ptIns1);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[5]);
|
|
arPt.append(pVerList[4]);
|
|
arPt.append(ptIns2);
|
|
arPt.append(pVerList[4] - vtDirT * dSideWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
}
|
|
}
|
|
|
|
double dLen = pVerList[6].distanceTo(pVerList[5]);
|
|
int num = (int)(dLen / dOffSetDist);
|
|
vtr = pVerList[9] - pVerList[10];
|
|
vtr.normalize();
|
|
|
|
//支架
|
|
int i = 0;
|
|
for (i = 0; i < num; i++)
|
|
{
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[10] + vtr * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[6] + vtr * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[10] + vtr * (i + 1) * dOffSetDist - vtr * dLadderWidth);
|
|
arPt.append(pVerList[6] + vtr * (i + 1) * dOffSetDist - vtr * dLadderWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dThick);
|
|
}
|
|
|
|
//支架
|
|
double dLength = pVerList[11].distanceTo(pVerList[10]);
|
|
num = (int)(dLength / dOffSetDist);
|
|
for (i = 0; i < num; i++)
|
|
{
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[11] + vtDir * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[7] + vtDir * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[11] + vtDir * (i + 1) * dOffSetDist - vtDir * dLadderWidth);
|
|
arPt.append(pVerList[7] + vtDir * (i + 1) * dOffSetDist - vtDir * dLadderWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dThick);
|
|
}
|
|
|
|
//支架
|
|
for (i = 0; i < num; i++)
|
|
{
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[8] - vtDir * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[4] - vtDir * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[8] - vtDir * (i + 1) * dOffSetDist + vtDir * dLadderWidth);
|
|
arPt.append(pVerList[4] - vtDir * (i + 1) * dOffSetDist + vtDir * dLadderWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dThick);
|
|
}
|
|
|
|
delete []pVerList;
|
|
pVerList = NULL;
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::ExplodeOrVerDraw3d(XExplodeDraw &mode) const
|
|
{
|
|
double dB = 0.0;
|
|
double dH = 0.0;
|
|
double dEl = 0.0;
|
|
double dHeight = 100.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptS,ptE;
|
|
int nCover = 1;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_COVER,nCover);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
AcGePoint3d *pVerList = NULL;
|
|
AcGeVector3d vtDirT = vtDir;
|
|
vtDirT.rotateBy(PI / 2.0,vtNorm);
|
|
vtDirT.normalize();
|
|
|
|
int nRow = 4;
|
|
int nCol = 4;
|
|
if (nCover)
|
|
nRow = 5;
|
|
|
|
pVerList = new AcGePoint3d[nRow*nCol];
|
|
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePlane planNorm(ptS,vtNorm);
|
|
dLenT = ptE.distanceTo(ptE.orthoProject(planNorm));
|
|
|
|
AcGePlane plan(ptE,vtDir);
|
|
dLen = ptS.distanceTo(ptS.orthoProject(plan));
|
|
|
|
pVerList[8] = ptS - vtDirT*dB/2;
|
|
pVerList[4] = ptS + vtDirT*dB/2;
|
|
pVerList[5] = pVerList[4] + vtDir*((dLen - dLenT)/2);
|
|
pVerList[11] = ptE - vtDirT*dB/2;
|
|
pVerList[7] = ptE + vtDirT*dB/2;
|
|
pVerList[6] = pVerList[7] - vtDir*((dLen - dLenT)/2);
|
|
pVerList[10] = pVerList[11] - vtDir*((dLen - dLenT)/2);
|
|
pVerList[9] = pVerList[8] + vtDir*((dLen - dLenT)/2);
|
|
pVerList[0] = pVerList[4] + dH*vtNorm;
|
|
pVerList[1] = pVerList[5] + dH*vtNorm;
|
|
pVerList[2] = pVerList[6] + dH*vtNorm;
|
|
pVerList[3] = pVerList[7] + dH*vtNorm;
|
|
pVerList[12] = pVerList[8] + dH*vtNorm;
|
|
pVerList[13] = pVerList[9] + dH*vtNorm;
|
|
pVerList[14] = pVerList[10] + dH*vtNorm;
|
|
pVerList[15] = pVerList[11] + dH*vtNorm;
|
|
|
|
if (nCover)
|
|
{
|
|
//有盖子
|
|
nRow = 5;
|
|
pVerList[16] = pVerList[0];
|
|
pVerList[17] = pVerList[1];
|
|
pVerList[18] = pVerList[2];
|
|
pVerList[19] = pVerList[3];
|
|
}
|
|
|
|
if (pVerList != NULL)
|
|
{
|
|
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
|
|
mode.SetColor(curColor);
|
|
|
|
mode.DrawMesh(nRow, nCol, pVerList,NULL);
|
|
|
|
delete []pVerList;
|
|
}
|
|
|
|
//显示隔板
|
|
int bShowBorad = -1,bHaveClap = -1;
|
|
m_pXDataMap->GetAt(KEY_HAVE_CLAPBOARD,bHaveClap);
|
|
m_pXDataMap->GetAt(KEY_SHOW_CLAPBOARD,bShowBorad);
|
|
if(bShowBorad == TDb::eShowBoard &&
|
|
bHaveClap == TDb::eBoard)
|
|
{
|
|
AcGeVector3d vtBoardMain;
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_MAINBR,vtBoardMain);
|
|
vtBoardMain.normalize();
|
|
|
|
TSupportFunc spFun;
|
|
AcGeDoubleArray arDimeS,arDimeE;
|
|
spFun.GetClapboardDimension(m_pXDataMap, arDimeS);
|
|
spFun.GetClapboardDimension(m_pXDataMap,arDimeE,KEY_CLAPBOARD_DATA2);
|
|
|
|
if (arDimeE.length() != arDimeS.length())
|
|
{
|
|
return Acad::eKeyNotFound;
|
|
}
|
|
for (int t = 0;t < arDimeS.length();++t)
|
|
{
|
|
AcGePoint3d ptFace[8];
|
|
ptFace[0] = ptS - vtBoardMain * (dB/2 - arDimeS[t]);
|
|
ptFace[1] = ptFace[0] + vtNorm * dH;
|
|
ptFace[2] = ptFace[0] + vtDir * ((dLen - dLenT)/2);
|
|
ptFace[3] = ptFace[2] + vtNorm * dH;
|
|
|
|
ptFace[6] = ptE - vtBoardMain * (dB/2 - arDimeS[t]);
|
|
ptFace[7] = ptFace[6] + vtNorm * dH;
|
|
ptFace[4] = ptFace[6] - vtDir * ((dLen - dLenT)/2);
|
|
ptFace[5] = ptFace[4] + vtNorm * dH;
|
|
|
|
mode.DrawMesh(4,2,ptFace);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TEImpCabOffset::ExplodeOrVerDraw3dOfT(XExplodeDraw &mode) const
|
|
{
|
|
if (m_pXDataMap == NULL)
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
double dLadderWidth = 50; //梯宽
|
|
double dSideWidth = 30; //侧面宽
|
|
double dThick = 10; //梯厚度
|
|
double dOffSetDist = 300; //乙字弯间距
|
|
|
|
double dB = 0.0;
|
|
double dH = 0.0;
|
|
double dEl = 0.0;
|
|
double dHeight = 100.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptS,ptE;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
AcGePoint3d *pVerList = NULL;
|
|
AcGeVector3d vtDirT = vtDir;
|
|
vtDirT.rotateBy(PI / 2.0,vtNorm);
|
|
vtDirT.normalize();
|
|
|
|
int nRow = 4;
|
|
int nCol = 4;
|
|
|
|
pVerList = new AcGePoint3d[nRow*nCol];
|
|
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePlane planNorm(ptS,vtNorm);
|
|
dLenT = ptE.distanceTo(ptE.orthoProject(planNorm));
|
|
|
|
AcGePlane plan(ptE,vtDir);
|
|
dLen = ptS.distanceTo(ptS.orthoProject(plan));
|
|
|
|
pVerList[8] = ptS - vtDirT*dB/2;
|
|
pVerList[4] = ptS + vtDirT*dB/2;
|
|
pVerList[5] = pVerList[4] + vtDir*((dLen - dLenT)/2);
|
|
pVerList[11] = ptE - vtDirT*dB/2;
|
|
pVerList[7] = ptE + vtDirT*dB/2;
|
|
pVerList[6] = pVerList[7] - vtDir*((dLen - dLenT)/2);
|
|
pVerList[10] = pVerList[11] - vtDir*((dLen - dLenT)/2);
|
|
pVerList[9] = pVerList[8] + vtDir*((dLen - dLenT)/2);
|
|
pVerList[0] = pVerList[4] + dH*vtNorm;
|
|
pVerList[1] = pVerList[5] + dH*vtNorm;
|
|
pVerList[2] = pVerList[6] + dH*vtNorm;
|
|
pVerList[3] = pVerList[7] + dH*vtNorm;
|
|
pVerList[12] = pVerList[8] + dH*vtNorm;
|
|
pVerList[13] = pVerList[9] + dH*vtNorm;
|
|
pVerList[14] = pVerList[10] + dH*vtNorm;
|
|
pVerList[15] = pVerList[11] + dH*vtNorm;
|
|
|
|
if (pVerList != NULL)
|
|
{
|
|
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
|
|
mode.SetColor(curColor);
|
|
|
|
AcGePoint3dArray arPt;
|
|
arPt.append(pVerList[11]);
|
|
arPt.append(pVerList[10]);
|
|
arPt.append(pVerList[11] - vtDirT * dSideWidth);
|
|
arPt.append(pVerList[10] - vtDirT * dSideWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
AcGeVector3d vtr = pVerList[9] - pVerList[10];
|
|
vtr.rotateBy(PI / 2, vtNorm);
|
|
vtr.normalize();
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[9]);
|
|
arPt.append(pVerList[10]);
|
|
arPt.append(pVerList[9] - vtDirT * dSideWidth);
|
|
arPt.append(pVerList[10] - vtDirT * dSideWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[9]);
|
|
arPt.append(pVerList[8]);
|
|
arPt.append(pVerList[9] - vtDirT * dSideWidth);
|
|
arPt.append(pVerList[8] - vtDirT * dSideWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[7]);
|
|
arPt.append(pVerList[6]);
|
|
arPt.append(pVerList[7] + vtDirT * dSideWidth);
|
|
arPt.append(pVerList[6] + vtDirT * dSideWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[5]);
|
|
arPt.append(pVerList[6]);
|
|
arPt.append(pVerList[5] + vtDirT * dSideWidth);
|
|
arPt.append(pVerList[6] + vtDirT * dSideWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[5]);
|
|
arPt.append(pVerList[4]);
|
|
arPt.append(pVerList[5] + vtDirT * dSideWidth);
|
|
arPt.append(pVerList[4] + vtDirT * dSideWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dH);
|
|
|
|
double dLen = pVerList[6].distanceTo(pVerList[5]);
|
|
int num = (int)(dLen / dOffSetDist);
|
|
vtr = pVerList[9] - pVerList[10];
|
|
vtr.normalize();
|
|
|
|
int i = 0;
|
|
for (i = 0; i < num; i++)
|
|
{
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[10] + vtr * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[6] + vtr * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[10] + vtr * (i + 1) * dOffSetDist - vtr * dLadderWidth);
|
|
arPt.append(pVerList[6] + vtr * (i + 1) * dOffSetDist - vtr * dLadderWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dThick);
|
|
}
|
|
|
|
double dLength = pVerList[7].distanceTo(pVerList[6]);
|
|
num = (int)(dLength / dOffSetDist);
|
|
for (i = 0; i < num; i++)
|
|
{
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[11] - vtDir * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[7] - vtDir * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[11] - vtDir * (i + 1) * dOffSetDist + vtDir * dLadderWidth);
|
|
arPt.append(pVerList[7] - vtDir * (i + 1) * dOffSetDist + vtDir * dLadderWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dThick);
|
|
}
|
|
|
|
for (i = 0; i < num; i++)
|
|
{
|
|
arPt.setLogicalLength(0);
|
|
arPt.append(pVerList[8] + vtDir * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[4] + vtDir * (i + 1) * dOffSetDist);
|
|
arPt.append(pVerList[8] + vtDir * (i + 1) * dOffSetDist - vtDir * dLadderWidth);
|
|
arPt.append(pVerList[4] + vtDir * (i + 1) * dOffSetDist - vtDir * dLadderWidth);
|
|
|
|
DrawCube(mode, vtNorm, arPt, dThick);
|
|
}
|
|
|
|
delete []pVerList;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int TEImpCabOffset::GetXBaseShell(TXShell& xShell)
|
|
{
|
|
int nRet = 0;
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
int nType = 0, nNum = 0;
|
|
m_pXDataMap->GetAt(KEY_OFFSET,nType);
|
|
switch(nType)
|
|
{
|
|
case TDb::eHorLeftOffset: // 槽式水平左偏移乙字弯通
|
|
{
|
|
MakeHorLeftOffsetShell(xShell);
|
|
break;
|
|
}
|
|
case TDb::eHorRightOffset: // 槽式水平右偏移乙字弯通
|
|
{
|
|
MakeHorRightOffsetShell(xShell);
|
|
break;
|
|
}
|
|
case TDb::eVerOffset: // 槽式垂直偏移乙字弯通
|
|
{
|
|
MakeVerOffsetShell(xShell);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
return nRet;
|
|
}
|
|
|
|
int TEImpCabOffset::GetBodyBox(AcDbExtents& ext)
|
|
{
|
|
int nRet = 0;
|
|
if (NULL != m_pXDataMap)
|
|
{
|
|
int nType = 0;
|
|
m_pXDataMap->GetAt(KEY_OFFSET,nType);
|
|
|
|
if (eHorLeftOffset == nType)
|
|
{
|
|
nRet = GetBodyBoxHorLeftOffsetShell(ext);
|
|
}
|
|
else if (eHorRightOffset == nType)
|
|
{
|
|
nRet = GetBodyBoxHorRightOffsetShell(ext);
|
|
}
|
|
else if (eVerOffset == nType)
|
|
{
|
|
nRet = GetBodyBoxVerOffsetShell(ext);
|
|
}
|
|
}
|
|
|
|
return nRet;
|
|
}
|
|
|
|
//左偏乙字弯
|
|
int TEImpCabOffset::MakeHorLeftOffsetShell(TXShell& xShell) const
|
|
{
|
|
if (NULL != m_pXDataMap)
|
|
{
|
|
double dB = 0.0;
|
|
double dH = 0.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptS,ptE;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
AcGeVector3d vtDirT = vtDir;
|
|
vtDirT.rotateBy(-PI / 2.0,vtNorm);
|
|
vtDirT.normalize();
|
|
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePoint3d ptOn;
|
|
AcDbLine line(ptS,ptS+vtDirT);
|
|
line.getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
|
dLen = ptOn.distanceTo(ptE);
|
|
dLenT = ptOn.distanceTo(ptS);
|
|
|
|
const int nSize = 8;
|
|
AcGePoint3d ptArrBottom[nSize];
|
|
|
|
ptArrBottom[0] = ptS + vtDirT * (dB / 2);
|
|
ptArrBottom[1] = ptArrBottom[0] + vtDir*((dLen - dLenT - dB*tan(PI / 8)) / 2);
|
|
ptArrBottom[7] = ptS - vtDirT * (dB / 2);
|
|
ptArrBottom[6] = ptArrBottom[7] + vtDir*((dLen - dLenT + dB*tan(PI / 8)) / 2);
|
|
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[0],ptArrBottom[1],ptArrBottom[6],ptArrBottom[7]));
|
|
|
|
ptArrBottom[3] = ptE + vtDirT * (dB / 2);
|
|
ptArrBottom[2] = ptArrBottom[3] - vtDir*((dLen - dLenT + dB*tan(PI / 8)) / 2);
|
|
ptArrBottom[4] = ptE - vtDirT * (dB / 2);
|
|
ptArrBottom[5] = ptArrBottom[4] - vtDir*((dLen - dLenT - dB*tan(PI / 8)) / 2);
|
|
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[2], ptArrBottom[3], ptArrBottom[4], ptArrBottom[5]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[1], ptArrBottom[2], ptArrBottom[5], ptArrBottom[6]));
|
|
|
|
AcGePoint3d ptArrTop[nSize];
|
|
for (int i = 0; i < nSize; i++)
|
|
{
|
|
ptArrTop[i] = ptArrBottom[i] + vtNorm * dH;
|
|
}
|
|
|
|
xShell.AppendFace(CreateAcDbFace(ptArrTop[0], ptArrTop[1], ptArrTop[6], ptArrTop[7]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrTop[2], ptArrTop[3], ptArrTop[4], ptArrTop[5]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrTop[1], ptArrTop[2], ptArrTop[5], ptArrTop[6]));
|
|
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[3], ptArrBottom[4], ptArrTop[4], ptArrTop[3]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[4], ptArrBottom[5], ptArrTop[5], ptArrTop[4]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[5], ptArrBottom[6], ptArrTop[6], ptArrTop[5]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[6], ptArrBottom[7], ptArrTop[7], ptArrTop[6]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[7], ptArrBottom[0], ptArrTop[0], ptArrTop[7]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[0], ptArrBottom[1], ptArrTop[1], ptArrTop[0]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[1], ptArrBottom[2], ptArrTop[2], ptArrTop[1]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[2], ptArrBottom[3], ptArrTop[3], ptArrTop[2]));
|
|
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
//右偏乙字弯
|
|
int TEImpCabOffset::MakeHorRightOffsetShell(TXShell& xShell) const
|
|
{
|
|
if (NULL != m_pXDataMap)
|
|
{
|
|
double dB = 0.0;
|
|
double dH = 0.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptS,ptE;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
AcGeVector3d vtDirT = vtDir;
|
|
vtDirT.rotateBy(-PI / 2.0,vtNorm);
|
|
vtDirT.normalize();
|
|
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePoint3d ptOn;
|
|
AcDbLine line(ptS,ptS+vtDirT);
|
|
line.getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
|
dLen = ptOn.distanceTo(ptE);
|
|
dLenT = ptOn.distanceTo(ptS);
|
|
|
|
const int nSize = 8;
|
|
AcGePoint3d ptArrBottom[nSize];
|
|
|
|
ptArrBottom[0] = ptS + vtDirT * (dB / 2);
|
|
ptArrBottom[1] = ptArrBottom[0] + vtDir*((dLen - dLenT + dB*tan(PI / 8)) / 2);
|
|
ptArrBottom[7] = ptS - vtDirT * (dB / 2);
|
|
ptArrBottom[6] = ptArrBottom[7] + vtDir*(dB / 2);
|
|
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[0],ptArrBottom[1],ptArrBottom[6],ptArrBottom[7]));
|
|
|
|
ptArrBottom[3] = ptE + vtDirT * (dB / 2);
|
|
ptArrBottom[2] = ptArrBottom[3] - vtDir*(dB / 2);
|
|
ptArrBottom[4] = ptE - vtDirT * (dB / 2);
|
|
ptArrBottom[5] = ptArrBottom[4] - vtDir*((dLen - dLenT + dB*tan(PI / 8)) / 2);
|
|
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[2], ptArrBottom[3], ptArrBottom[4], ptArrBottom[5]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[1], ptArrBottom[2], ptArrBottom[5], ptArrBottom[6]));
|
|
|
|
AcGePoint3d ptArrTop[nSize];
|
|
for (int i = 0; i < nSize; i++)
|
|
{
|
|
ptArrTop[i] = ptArrBottom[i] + vtNorm * dH;
|
|
}
|
|
|
|
xShell.AppendFace(CreateAcDbFace(ptArrTop[0], ptArrTop[1], ptArrTop[6], ptArrTop[7]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrTop[2], ptArrTop[3], ptArrTop[4], ptArrTop[5]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrTop[1], ptArrTop[2], ptArrTop[5], ptArrTop[6]));
|
|
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[3], ptArrBottom[4], ptArrTop[4], ptArrTop[3]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[4], ptArrBottom[5], ptArrTop[5], ptArrTop[4]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[5], ptArrBottom[6], ptArrTop[6], ptArrTop[5]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[6], ptArrBottom[7], ptArrTop[7], ptArrTop[6]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[7], ptArrBottom[0], ptArrTop[0], ptArrTop[7]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[0], ptArrBottom[1], ptArrTop[1], ptArrTop[0]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[1], ptArrBottom[2], ptArrTop[2], ptArrTop[1]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[2], ptArrBottom[3], ptArrTop[3], ptArrTop[2]));
|
|
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
//垂直乙字弯
|
|
int TEImpCabOffset::MakeVerOffsetShell(TXShell& xShell) const
|
|
{
|
|
if (NULL != m_pXDataMap)
|
|
{
|
|
double dB = 0.0;
|
|
double dH = 0.0;
|
|
double dEl = 0.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptS,ptE;
|
|
int nCover = 1;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
AcGeVector3d vtDirT = vtDir;
|
|
vtDirT.rotateBy(PI / 2.0,vtNorm);
|
|
vtDirT.normalize();
|
|
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePlane planNorm(ptS,vtNorm);
|
|
dLenT = ptE.distanceTo(ptE.orthoProject(planNorm));
|
|
|
|
AcGePlane plan(ptE,vtDir);
|
|
dLen = ptS.distanceTo(ptS.orthoProject(plan));
|
|
|
|
const int nSize = 8;
|
|
|
|
AcGePoint3d ptArrBottom[nSize];
|
|
|
|
ptArrBottom[0] = ptS + vtDirT * (dB / 2);
|
|
ptArrBottom[1] = ptArrBottom[0] + vtDir*((dLen - dLenT)/2);
|
|
ptArrBottom[7] = ptS - vtDirT * (dB / 2);
|
|
ptArrBottom[6] = ptArrBottom[7] + vtDir*((dLen - dLenT)/2);
|
|
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[0], ptArrBottom[1], ptArrBottom[6], ptArrBottom[7]));
|
|
|
|
ptArrBottom[4] = ptE -vtDirT * (dB / 2);
|
|
ptArrBottom[5] = ptArrBottom[4] - vtDir*((dLen - dLenT)/2);
|
|
ptArrBottom[3] = ptE + vtDirT * (dB / 2);
|
|
ptArrBottom[2] = ptArrBottom[3] - vtDir*((dLen - dLenT)/2);
|
|
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[2], ptArrBottom[3], ptArrBottom[4], ptArrBottom[5]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[1], ptArrBottom[2], ptArrBottom[5], ptArrBottom[6]));
|
|
|
|
AcGePoint3d ptArrTop[nSize];
|
|
for (int i = 0; i < nSize; i++)
|
|
{
|
|
ptArrTop[i] = ptArrBottom[i] + vtNorm * dH;
|
|
}
|
|
|
|
xShell.AppendFace(CreateAcDbFace(ptArrTop[0], ptArrTop[1], ptArrTop[6], ptArrTop[7]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrTop[2], ptArrTop[3], ptArrTop[4], ptArrTop[5]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrTop[1], ptArrTop[2], ptArrTop[5], ptArrTop[6]));
|
|
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[3], ptArrBottom[4], ptArrTop[4], ptArrTop[3]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[4], ptArrBottom[5], ptArrTop[5], ptArrTop[4]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[5], ptArrBottom[6], ptArrTop[6], ptArrTop[5]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[6], ptArrBottom[7], ptArrTop[7], ptArrTop[6]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[7], ptArrBottom[0], ptArrTop[0], ptArrTop[7]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[0], ptArrBottom[1], ptArrTop[1], ptArrTop[0]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[1], ptArrBottom[2], ptArrTop[2], ptArrTop[1]));
|
|
xShell.AppendFace(CreateAcDbFace(ptArrBottom[2], ptArrBottom[3], ptArrTop[3], ptArrTop[2]));
|
|
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
AcDbFace* TEImpCabOffset::CreateAcDbFace(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;
|
|
}
|
|
|
|
|
|
int TEImpCabOffset::GetBodyBoxHorLeftOffsetShell(AcDbExtents& ext)
|
|
{
|
|
if (NULL != m_pXDataMap)
|
|
{
|
|
double dB = 0.0;
|
|
double dH = 0.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptS,ptE;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
AcGeVector3d vtDirT = vtDir;
|
|
vtDirT.rotateBy(-PI / 2.0,vtNorm);
|
|
vtDirT.normalize();
|
|
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePoint3d ptOn;
|
|
AcDbLine line(ptS,ptS+vtDirT);
|
|
line.getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
|
dLen = ptOn.distanceTo(ptE);
|
|
dLenT = ptOn.distanceTo(ptS);
|
|
|
|
const int nSize = 8;
|
|
AcGePoint3d ptArrBottom[nSize];
|
|
|
|
ptArrBottom[0] = ptS + vtDirT * (dB / 2);
|
|
ptArrBottom[1] = ptArrBottom[0] + vtDir*((dLen - dLenT - dB*tan(PI / 8)) / 2);
|
|
ptArrBottom[7] = ptS - vtDirT * (dB / 2);
|
|
ptArrBottom[6] = ptArrBottom[7] + vtDir*((dLen - dLenT + dB*tan(PI / 8)) / 2);
|
|
|
|
ptArrBottom[3] = ptE + vtDirT * (dB / 2);
|
|
ptArrBottom[2] = ptArrBottom[3] - vtDir*((dLen - dLenT + dB*tan(PI / 8)) / 2);
|
|
ptArrBottom[4] = ptE - vtDirT * (dB / 2);
|
|
ptArrBottom[5] = ptArrBottom[4] - vtDir*((dLen - dLenT - dB*tan(PI / 8)) / 2);
|
|
|
|
std::vector<AcGePoint3d> vctVer;
|
|
for (int i = 0; i < nSize; i++)
|
|
{
|
|
vctVer.push_back(ptArrBottom[i]);
|
|
vctVer.push_back(ptArrBottom[i] + vtNorm * dH);
|
|
}
|
|
|
|
AppendAcDbExtents(vctVer,ext);
|
|
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int TEImpCabOffset::GetBodyBoxHorRightOffsetShell(AcDbExtents& ext)
|
|
{
|
|
if (NULL != m_pXDataMap)
|
|
{
|
|
double dB = 0.0;
|
|
double dH = 0.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptS,ptE;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
AcGeVector3d vtDirT = vtDir;
|
|
vtDirT.rotateBy(-PI / 2.0,vtNorm);
|
|
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePoint3d ptOn;
|
|
AcDbLine line(ptS,ptS+vtDirT);
|
|
line.getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
|
dLen = ptOn.distanceTo(ptE);
|
|
dLenT = ptOn.distanceTo(ptS);
|
|
|
|
const int nSize = 8;
|
|
AcGePoint3d ptArrBottom[nSize];
|
|
|
|
ptArrBottom[0] = ptS + vtDirT * (dB / 2);
|
|
ptArrBottom[1] = ptArrBottom[0] + vtDir*((dLen - dLenT + dB*tan(PI / 8)) / 2);
|
|
ptArrBottom[7] = ptS - vtDirT * (dB / 2);
|
|
ptArrBottom[6] = ptArrBottom[7] + vtDir*(dB / 2);
|
|
|
|
ptArrBottom[3] = ptE + vtDirT * (dB / 2);
|
|
ptArrBottom[2] = ptArrBottom[3] - vtDir*(dB / 2);
|
|
ptArrBottom[4] = ptE - vtDirT * (dB / 2);
|
|
ptArrBottom[5] = ptArrBottom[4] - vtDir*((dLen - dLenT + dB*tan(PI / 8)) / 2);
|
|
|
|
std::vector<AcGePoint3d> vctVer;
|
|
for (int i = 0; i < nSize; i++)
|
|
{
|
|
vctVer.push_back(ptArrBottom[i]);
|
|
vctVer.push_back(ptArrBottom[i] + vtNorm * dH);
|
|
}
|
|
|
|
AppendAcDbExtents(vctVer,ext);
|
|
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
int TEImpCabOffset::GetBodyBoxVerOffsetShell(AcDbExtents& ext)
|
|
{
|
|
if (NULL != m_pXDataMap)
|
|
{
|
|
double dB = 0.0;
|
|
double dH = 0.0;
|
|
double dEl = 0.0;
|
|
AcGeVector3d vtNorm,vtDir;
|
|
AcGePoint3d ptS,ptE;
|
|
int nCover = 1;
|
|
|
|
m_pXDataMap->GetAt(KEY_B,dB);
|
|
m_pXDataMap->GetAt(KEY_H,dH);
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
|
|
vtDir.normalize();
|
|
vtNorm.normalize();
|
|
|
|
AcGeVector3d vtDirT = vtDir;
|
|
vtDirT.rotateBy(PI / 2.0,vtNorm);
|
|
vtDirT.normalize();
|
|
|
|
double dLenT = 0.0,dLen = 0.0;
|
|
AcGePlane planNorm(ptS,vtNorm);
|
|
dLenT = ptE.distanceTo(ptE.orthoProject(planNorm));
|
|
|
|
AcGePlane plan(ptE,vtDir);
|
|
dLen = ptS.distanceTo(ptS.orthoProject(plan));
|
|
|
|
const int nSize = 8;
|
|
|
|
AcGePoint3d ptArrBottom[nSize];
|
|
|
|
ptArrBottom[0] = ptS + vtDirT * (dB / 2);
|
|
ptArrBottom[1] = ptArrBottom[0] + vtDir*((dLen - dLenT)/2);
|
|
ptArrBottom[7] = ptS - vtDirT * (dB / 2);
|
|
ptArrBottom[6] = ptArrBottom[7] + vtDir*((dLen - dLenT)/2);
|
|
|
|
ptArrBottom[4] = ptE -vtDirT * (dB / 2);
|
|
ptArrBottom[5] = ptArrBottom[4] - vtDir*((dLen - dLenT)/2);
|
|
ptArrBottom[3] = ptE + vtDirT * (dB / 2);
|
|
ptArrBottom[2] = ptArrBottom[3] - vtDir*((dLen - dLenT)/2);
|
|
|
|
std::vector<AcGePoint3d> vctVer;
|
|
for (int i = 0; i < nSize; i++)
|
|
{
|
|
vctVer.push_back(ptArrBottom[i]);
|
|
vctVer.push_back(ptArrBottom[i] + vtNorm * dH);
|
|
}
|
|
|
|
AppendAcDbExtents(vctVer,ext);
|
|
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
void TEImpCabOffset::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);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool TEImpCabOffset::GetSection(const AcDbFace &face, const AcGeVector3d &vtPlaneSecDir,
|
|
std::vector<TObjSectionRecord> §ionRecord, 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);
|
|
|
|
double dElevation = 0;
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbFace* pFace = NULL;
|
|
int i = 0;
|
|
for(i = 0; i < arFaces.length(); ++i)
|
|
{
|
|
pEnt = (AcDbEntity*)arFaces[i];
|
|
if (NULL == pEnt)
|
|
continue;
|
|
pFace = AcDbFace::cast(pEnt);
|
|
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));
|
|
}
|
|
delete pEnt;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// 剖切用,返回Z坐标最高、最低点
|
|
Acad::ErrorStatus TEImpCabOffset::GetExtents(TADSGePoint3d &ptLow, TADSGePoint3d &ptUp) const
|
|
{
|
|
AcGePoint3d ptS,ptE;
|
|
double dHight = 0.0;
|
|
m_pXDataMap->GetAt(KEY_H,dHight);
|
|
m_pXDataMap->GetAt(KEY_START,ptS);
|
|
m_pXDataMap->GetAt(KEY_END,ptE);
|
|
|
|
if (ptS.z > ptE.z)
|
|
{
|
|
ptLow = ptE;
|
|
ptUp = ptS;
|
|
}
|
|
else
|
|
{
|
|
ptLow = ptS;
|
|
ptUp = ptE;
|
|
}
|
|
ptUp.z += dHight;
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
CString TEImpCabOffset::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::eOffset);
|
|
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_OFFSET,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("乙字弯型号"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("乙字弯型号"));
|
|
m_pXDataMap->GetAt(KEY_OFFSET,nValue);
|
|
csText.Format(_T("%d"),nValue);
|
|
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_START,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("起点"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("起点"));
|
|
m_pXDataMap->GetAt(KEY_START,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_END,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("终点"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("终点"));
|
|
m_pXDataMap->GetAt(KEY_END,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_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_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(KEY_HAVE_CLAPBOARD,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("有无隔板"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("0:无,1:有"));
|
|
m_pXDataMap->GetAt(KEY_HAVE_CLAPBOARD,nValue);
|
|
csText.Format(_T("%d"),nValue);
|
|
xmlTree.SetItemText(nowPos,csText);
|
|
}
|
|
nowPos = xmlTree.Insert(KEY_SHOW_CLAPBOARD,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("0:不显示,1:显示"));
|
|
m_pXDataMap->GetAt(KEY_SHOW_CLAPBOARD,nValue);
|
|
csText.Format(_T("%d"),nValue);
|
|
xmlTree.SetItemText(nowPos,csText);
|
|
}
|
|
nowPos = xmlTree.Insert(KEY_CLAPBOARD_MAINBR,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板主向量"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("隔板主向量"));
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_MAINBR,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_CLAPBOARD_SUBBR,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板主向量"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("隔板主向量"));
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_SUBBR,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_CLAPBOARD_DATA,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板数据"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("隔板尺寸*通道码;隔板尺寸*通道码;"));
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_DATA,csText);
|
|
xmlTree.SetItemText(nowPos,csText);
|
|
}
|
|
nowPos = xmlTree.Insert(KEY_CLAPBOARD_DATA2,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板数据2"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("隔板尺寸*通道码;隔板尺寸*通道码;"));
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_DATA2,csText);
|
|
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);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
CString csXml = xmlTree.GetXml();
|
|
|
|
return csXml;
|
|
}
|
|
|
|
CString TEImpCabOffset::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::eOffset);
|
|
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_OFFSET,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("乙字弯型号"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("乙字弯型号"));
|
|
m_pXDataMap->GetAt(KEY_OFFSET,nValue);
|
|
csText.Format(_T("%d"),nValue);
|
|
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_START,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("起点"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("起点"));
|
|
m_pXDataMap->GetAt(KEY_START,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);
|
|
}
|
|
nowPos = xmlTree.Insert(KEY_END,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("终点"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("终点"));
|
|
m_pXDataMap->GetAt(KEY_END,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);
|
|
}
|
|
|
|
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_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(KEY_HAVE_CLAPBOARD,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("有无隔板"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("0:无,1:有"));
|
|
m_pXDataMap->GetAt(KEY_HAVE_CLAPBOARD,nValue);
|
|
csText.Format(_T("%d"),nValue);
|
|
xmlTree.SetItemText(nowPos,csText);
|
|
}
|
|
nowPos = xmlTree.Insert(KEY_SHOW_CLAPBOARD,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("0:不显示,1:显示"));
|
|
m_pXDataMap->GetAt(KEY_SHOW_CLAPBOARD,nValue);
|
|
csText.Format(_T("%d"),nValue);
|
|
xmlTree.SetItemText(nowPos,csText);
|
|
}
|
|
nowPos = xmlTree.Insert(KEY_CLAPBOARD_MAINBR,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板主向量"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("隔板主向量"));
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_MAINBR,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_CLAPBOARD_SUBBR,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板主向量"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("隔板主向量"));
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_SUBBR,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_CLAPBOARD_DATA,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板数据"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("隔板尺寸*通道码;隔板尺寸*通道码;"));
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_DATA,csText);
|
|
xmlTree.SetItemText(nowPos,csText);
|
|
}
|
|
nowPos = xmlTree.Insert(KEY_CLAPBOARD_DATA2,posRoot,NULL);
|
|
{
|
|
xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板数据2"));
|
|
xmlTree.SetAttribute(nowPos, _T("comment"), _T("隔板尺寸*通道码;隔板尺寸*通道码;"));
|
|
m_pXDataMap->GetAt(KEY_CLAPBOARD_DATA2,csText);
|
|
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);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
CString csXml = xmlTree.GetXml();
|
|
|
|
return csXml;
|
|
} |