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

4156 lines
108 KiB
C++

#include "stdafx.h"
#include "StdArx.h"
#include "TEImpCabReducer.h"
#include "TDbInterfaceRecord.h"
#include "TDbXDataMap.h"
#include "TDbInterfaceMsgWrite.h"
#include "math.h"
#include "dbray.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
TEImpCabReducer::TEImpCabReducer()
{
}
TEImpCabReducer::~TEImpCabReducer()
{
}
Adesk::Boolean acedPostCommand( const TCHAR * );
// 接口描述对象
BOOL TEImpCabReducer::GetInterface(int nIndex,TInterface& pipeInterface) const
{
if (m_pXDataMap != NULL)
{
AcGePoint3d ptSta,ptEnd,ptGeM;
AcDbObjectId id1,id2;
int nType = 0;
m_pXDataMap->GetAt(KEY_START,ptSta);
m_pXDataMap->GetAt(KEY_END,ptEnd);
m_pXDataMap->GetAt(KEY_REDUCER,nType);
ptGeM = TSupportFunc::Mid(ptSta,ptEnd);
AcGeVector3d vtDir = ptSta - ptGeM;
AcGeVector3d vtDir2 = ptEnd - ptGeM;
if (nType == TDb::eRbotHorOffsetDifR ||
nType == TDb::eRbotHorOffsetDifR2)
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
vtDir *= -1; // 2012/6/14 wzh 支持非桥架中心线偏移变径联动
vtDir2 = -vtDir;
}
switch(nIndex)
{
case 0:
{
if (m_pXDataMap->GetAt(KEY_IDCNT1,id1))
{
if (MakesureInterfaceValidate(id1,ptSta,vtDir,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT2,id2))
{
if (MakesureInterfaceValidate(id2,ptSta,vtDir,pipeInterface))
{
return TRUE;
}
}
pipeInterface.SetOutDir(vtDir);
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
pipeInterface.SetPosition(ptSta);
return TRUE;
break;
}
case 1:
{
if (m_pXDataMap->GetAt(KEY_IDCNT1,id1))
{
if (MakesureInterfaceValidate(id1,ptEnd,vtDir2,pipeInterface))
{
return TRUE;
}
}
if (m_pXDataMap->GetAt(KEY_IDCNT2,id2))
{
if (MakesureInterfaceValidate(id2,ptEnd,vtDir2,pipeInterface))
{
return TRUE;
}
}
pipeInterface.SetOutDir(vtDir2);
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
pipeInterface.SetPosition(ptEnd);
return TRUE;
break;
}
default:
break;
}
}
return FALSE;
}
BOOL TEImpCabReducer::GetInterface(const AcGePoint3d& ptCon,TInterface& pipeInterface) const
{
AcGePoint3d ptSta,ptEnd,ptGeM;
AcGeVector3d vtDir;
if (m_pXDataMap != NULL)
{
int nType = 0;
m_pXDataMap->GetAt(KEY_REDUCER,nType);
m_pXDataMap->GetAt(KEY_START,ptSta);
m_pXDataMap->GetAt(KEY_END,ptEnd);
ptGeM = TSupportFunc::Mid(ptSta,ptEnd);
double dDis1 = ptCon.distanceTo(ptSta);
double dDis2 = ptCon.distanceTo(ptEnd);
if (dDis1 < 1.e-3 || dDis2 < 1.e-3)
{
//判断点是否在接口对象上
AcGeVector3d vtDir = ptCon - ptGeM;
if (nType == TDb::eRbotHorOffsetDifR ||
nType == TDb::eRbotHorOffsetDifR2)
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
}
AcDbObjectId id1,id2;
BOOL bSuc = FALSE;
if (m_pXDataMap->GetAt(KEY_IDCNT1,id1))
{
bSuc = MakesureInterfaceValidate(id1,ptCon,vtDir,pipeInterface);
if (!bSuc)
{
if (m_pXDataMap->GetAt(KEY_IDCNT2,id2))
{
bSuc = MakesureInterfaceValidate(id2,ptCon,vtDir,pipeInterface);
}
}
return bSuc;
}
if (m_pXDataMap->GetAt(KEY_IDCNT2,id2))
{
bSuc = MakesureInterfaceValidate(id2,ptCon,vtDir,pipeInterface);
if (!bSuc)
{
if (m_pXDataMap->GetAt(KEY_IDCNT1,id1))
{
bSuc = MakesureInterfaceValidate(id1,ptCon,vtDir,pipeInterface);
}
}
return bSuc;
}
if (dDis1 < 1.e-3)
{
vtDir = ptSta - ptGeM;
pipeInterface.SetOutDir(vtDir);
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
pipeInterface.SetPosition(ptSta);
}
if (dDis2 < 1.e-3)
{
vtDir = ptEnd - ptGeM;
pipeInterface.SetOutDir(vtDir);
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
pipeInterface.SetPosition(ptEnd);
}
return TRUE;
}
}
return FALSE;
}
BOOL TEImpCabReducer::HasInterface(const AcGePoint3d& ptCon,const AcGeVector3d& vtDir)
{
AcGePoint3d ptSta,ptEnd,ptGeM;
if (m_pXDataMap != NULL)
{
m_pXDataMap->GetAt(KEY_START,ptSta);
m_pXDataMap->GetAt(KEY_END,ptEnd);
double dDis1 = ptCon.distanceTo(ptSta);
double dDis2 = ptCon.distanceTo(ptEnd);
ptGeM = TSupportFunc::Mid(ptSta,ptEnd);
if (dDis1 < 1.e-3 || dDis2 < 1.e-3)
{
AcGeVector3d vtT = ptCon - ptGeM;
int nReducerStyle = 0;
m_pXDataMap->GetAt(KEY_REDUCER,nReducerStyle);
if (nReducerStyle == TDb::eRbotHorOffsetDifR ||
nReducerStyle == TDb::eRbotHorOffsetDifR2)
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtT);
}
if (vtT.isParallelTo(vtDir))
{
return TRUE;
}
}
}
return FALSE;
}
int TEImpCabReducer::GetInterfaceCount() const
{
return 2;
}
BOOL TEImpCabReducer::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
{
if ( !idConnect.isValid())
return FALSE;
BOOL bSuccess = FALSE;
if (m_pXDataMap != NULL)
{
AcGePoint3d ptSta,ptEnd,ptGeM;
int nStyle = 0;
m_pXDataMap->GetAt(KEY_START,ptSta);
m_pXDataMap->GetAt(KEY_END,ptEnd);
m_pXDataMap->GetAt(KEY_REDUCER,nStyle);
ptGeM = TSupportFunc::Mid(ptSta,ptEnd);
double dDis1 = ptConnect.distanceTo(ptSta);
double dDis2 = ptConnect.distanceTo(ptEnd);
if (dDis1 < 1.e-3 || dDis2 < 1.e-3)
{
AcGeVector3d vtT = ptConnect - ptGeM;
if (nStyle == TDb::eRbotHorOffsetDifR ||
nStyle == TDb::eRbotHorOffsetDifR2)
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtT);
}
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 TEImpCabReducer::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;
}
if (id2 == idConnect)
{
m_pXDataMap->SetAt(KEY_IDCNT2,idNull);
bRemoved = TRUE;
}
return bRemoved;
}
return FALSE;
}
BOOL TEImpCabReducer::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;
}
Acad::ErrorStatus TEImpCabReducer::moveGripPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
if (m_pXDataMap != NULL)
{
int nType = 0;
m_pXDataMap->GetAt(KEY_REDUCER,nType);
switch(nType)
{
case TDb::eRbotHorDifR: // 槽式下平异径接头
case TDb::eRbotHorOffsetDifR2:
case TDb::eRbotHorOffsetDifR:
case TDb::eRbotHorNormalDifR: // 槽式下平普通异径接头
{
OnBottomHorDifRMoveGripPointsAt(indices,offset);
}
break;
default:
break;
}
}
return Acad::eOk;
}
Acad::ErrorStatus TEImpCabReducer::OnBottomHorDifRMoveGripPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset)
{
int nSize = indices.length();
if (nSize > 0)
{
AcGePoint3d ptGeS,ptGeM,ptGeE;
int nStyle = 0;
m_pXDataMap->GetAt(KEY_REDUCER,nStyle);
m_pXDataMap->GetAt(KEY_START,ptGeS);
m_pXDataMap->GetAt(KEY_END,ptGeE);
ptGeM = TSupportFunc::Mid(ptGeS, ptGeE);
AcGePoint3d ptGeSOld = ptGeS;
AcGePoint3d ptGeMOld = ptGeM;
AcGePoint3d ptGeEOld = ptGeE;
AcGeVector3d vtDir = ptGeS - ptGeE;
if (nStyle == TDb::eRbotHorOffsetDifR ||
nStyle == TDb::eRbotHorOffsetDifR2)
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
}
// 选择多个夹点,以first为准
int nIndex = indices.first();
TDb::Position ePos = ExplainGripIndex(nIndex);
switch(ePos)
{
case TDb::eBr1:
{
// 修改原因: 对于非正交的移动会使连接的桥架做错误图形变化
// 修改人 : tsj
// 修改时间:2009.11.24
//平行,或垂直按moveGrip 接口消息逻辑
//非平行,按transform 接口消息逻辑
// TDb::InterfaceOper eOper = TDb::eMoveGripPoint;
// AcGeVector3d vtIntf = ptGeS - ptGeM;
// int nStyle = 0;
// m_pXDataMap->GetAt(KEY_REDUCER,nStyle);
// if (nStyle == TDb::eRbotHorOffsetDifR ||
// nStyle == TDb::eRbotHorOffsetDifR2)
// {
// m_pXDataMap->GetAt(KEY_MAINDIR,vtIntf);
// }
// AcGeVector3d vtMove = offset;
// if (vtIntf.isParallelTo(offset))//平行
// {
// }
// else if (vtIntf.isPerpendicularTo(offset))//垂直
// {
// }
// else
// {
// eOper = TDb::eTransformBy;
// }
ptGeE += offset;
ptGeS += offset;
m_pXDataMap->SetAt(KEY_END,ptGeE);
m_pXDataMap->SetAt(KEY_START,ptGeS);
if (m_pOwnerEnt != NULL && m_pOwnerEnt->objectId().isValid())
{
// 写入接口更改消息
if (vtDir.isParallelTo(offset) || vtDir.isPerpendicularTo(offset))
{
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeEOld);//new pos
iMsg.SetGripPosition(TDb::eBr1);
iMsg.SetMoveGripOffset(offset);
iMsg.SetMsgValidate(TRUE);
iMsg.SetInterfaceOper(TDb::eMoveGripPoint);
iMsg.SetMsgOperateOn(m_pOwnerEnt->objectId());
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
}
//更新接口记录接口信息
AcGeMatrix3d xform;
xform.setToTranslation(offset);
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
}
}
break;
case TDb::eMid:
{
// 修改原因: 对于非正交的移动会使连接的桥架做错误图形变化
// 修改人 : tsj
// 修改时间:2009.11.24
if (offset.isZeroLength())
return Acad::eOk;
ptGeE += offset;
ptGeS += offset;
m_pXDataMap->SetAt(KEY_END,ptGeE);
m_pXDataMap->SetAt(KEY_START,ptGeS);
if (m_pOwnerEnt != NULL && m_pOwnerEnt->objectId().isValid())
{
if (vtDir.isParallelTo(offset) || vtDir.isPerpendicularTo(offset))
{
// 写入接口更改消息
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeMOld);//new pos
iMsg.SetGripPosition(TDb::eMid);
iMsg.SetMoveGripOffset(offset);
iMsg.SetMsgValidate(TRUE);
iMsg.SetInterfaceOper(TDb::eMoveGripPoint);
iMsg.SetMsgOperateOn(m_pOwnerEnt->objectId());
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
}
//更新接口记录接口信息
AcGeMatrix3d xform;
xform.setToTranslation(offset);
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
}
}
break;
case TDb::eBr2:
{
// 修改原因: 对于非正交的移动会使连接的桥架做错误图形变化
// 修改人 : tsj
// 修改时间:2009.11.24
//平行,或垂直按moveGrip 接口消息逻辑
//非平行,按transform 接口消息逻辑
// TDb::InterfaceOper eOper = TDb::eMoveGripPoint;
// AcGeVector3d vtIntf = ptGeE - ptGeM;
// int nStyle = 0;
// m_pXDataMap->GetAt(KEY_REDUCER,nStyle);
// if (nStyle == TDb::eRbotHorOffsetDifR ||
// nStyle == TDb::eRbotHorOffsetDifR2)
// {
// m_pXDataMap->GetAt(KEY_MAINDIR,vtIntf);
// }
// AcGeVector3d vtMove = offset;
// if (vtIntf.isParallelTo(offset))//平行
// {
// }
// else if (vtIntf.isPerpendicularTo(offset))//垂直
// {
// }
// else
// {
// eOper = TDb::eTransformBy;
// }
ptGeE += offset;
ptGeS += offset;
m_pXDataMap->SetAt(KEY_END,ptGeE);
m_pXDataMap->SetAt(KEY_START,ptGeS);
if (m_pOwnerEnt != NULL && m_pOwnerEnt->objectId().isValid())
{
if (vtDir.isParallelTo(offset) || vtDir.isPerpendicularTo(offset))
{
// 写入接口更改消息
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeEOld);//new pos
iMsg.SetGripPosition(TDb::eBr2);
iMsg.SetMoveGripOffset(offset);
iMsg.SetMsgValidate(TRUE);
iMsg.SetInterfaceOper(TDb::eMoveGripPoint);
iMsg.SetMsgOperateOn(m_pOwnerEnt->objectId());
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
}
//更新接口记录接口信息
AcGeMatrix3d xform;
xform.setToTranslation(offset);
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
}
}
break;
case TDb::eCommand0:
{
// 写入接口更改消息
double dH = 0.0,dB = 0.0;
if (m_pXDataMap != NULL)
{
m_pXDataMap->GetAt(KEY_H1,dH);
m_pXDataMap->GetAt(KEY_B1,dB);
}
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeS);//new pos
iMsg.SetGripPosition(TDb::eCommand0);
iMsg.SetMoveGripOffset(vtDir);
iMsg.SetMsgValidate(TRUE);
iMsg.SetSize(dB,dH);
iMsg.SetInterfaceOper(TDb::eNewCommand);
iMsg.SetPreviewObjToCreate(TDb::eReduce,TDb::eRbotHorOffsetDifR);
AcDbSoftPointerId idOwner;
m_pXDataMap->GetAt(KEY_THISID,idOwner);
iMsg.SetMsgOperateOn(idOwner);
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
acedPostCommand(_T("\33"));
CString sCmd;
GetGlobalContext(KEY_CABGRIPCMD,sCmd);
if (!sCmd.IsEmpty())
{
sCmd += _T("\n");
acedPostCommand(sCmd);
}
}
break;
case TDb::eCommand1:
{
// 写入接口更改消息
double dH = 0.0,dB = 0.0;
if (m_pXDataMap != NULL)
{
m_pXDataMap->GetAt(KEY_H2,dH);
m_pXDataMap->GetAt(KEY_B2,dB);
}
TInterfaceModifyMsg iMsg;
iMsg.SetMsgPoint(ptGeE);//new pos
iMsg.SetGripPosition(TDb::eCommand0);
iMsg.SetMoveGripOffset(vtDir);
iMsg.SetMsgValidate(TRUE);
iMsg.SetSize(dB,dH);
iMsg.SetInterfaceOper(TDb::eNewCommand);
iMsg.SetPreviewObjToCreate(TDb::eReduce,TDb::eRbotHorOffsetDifR);
AcDbSoftPointerId idOwner;
m_pXDataMap->GetAt(KEY_THISID,idOwner);
iMsg.SetMsgOperateOn(idOwner);
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
acedPostCommand(_T("\33"));
CString sCmd;
GetGlobalContext(KEY_CABGRIPCMD,sCmd);
if (!sCmd.IsEmpty())
{
sCmd += _T("\n");
acedPostCommand(sCmd);
}
}
break;
default:
break;
}
}
return Acad::eOk;
}
TDb::Position TEImpCabReducer::ExplainGripIndex(int nIndex) const
{
TDb::Position ePos = TDb::eBr1;
switch(nIndex)
{
case 0:
{
ePos = TDb::eBr1;
break;
}
case 1:
{
ePos = TDb::eMid;
break;
}
case 2:
{
ePos = TDb::eBr2;
break;
}
case 3:
{
ePos = TDb::eCommand0;
break;
}
case 4:
{
ePos = TDb::eCommand1;
break;
}
default:
break;
}
return ePos;
}
void TEImpCabReducer::GetKindName(CString& sName)
{
sName = _T("TCH_EREDUCER");
}
Acad::ErrorStatus TEImpCabReducer::transformBy(const AcGeMatrix3d& xform)
{
AcGePoint3d ptSta,ptEnd;
AcGeVector3d vtOffSet, vtReducer,vtClap;
if (m_pXDataMap != NULL)
{
m_pXDataMap->GetAt(KEY_START,ptSta);
m_pXDataMap->GetAt(KEY_END,ptEnd);
m_pXDataMap->GetAt(KEY_BRDIR,vtOffSet);
m_pXDataMap->GetAt(KEY_MAINDIR,vtReducer);
m_pXDataMap->GetAt(KEY_CLAPBOARD_MAINBR,vtClap);
ptSta.transformBy(xform);
ptEnd.transformBy(xform);
vtOffSet.transformBy(xform);
vtReducer.transformBy(xform);
vtClap.transformBy(xform);
m_pXDataMap->SetAt(KEY_START,ptSta);
m_pXDataMap->SetAt(KEY_END,ptEnd);
m_pXDataMap->SetAt(KEY_BRDIR,vtOffSet);
m_pXDataMap->SetAt(KEY_MAINDIR,vtReducer);
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 TEImpCabReducer::getGripPoints(AcGePoint3dArray& gripPoints,
AcDbIntArray& osnapModes,
AcDbIntArray& geomIds) const
{
if (m_pXDataMap != NULL)
{
AcGePoint3d ptGeS,ptGeE,ptGeM;
int nType = 0;
AcGeVector3d vtNormal;
if ( m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_REDUCER,nType) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) )
{
AcGeVector3d vtTemp = ptGeE - ptGeS;
switch(nType)
{
case TDb::eRbotHorDifR: // 槽式下平异径接头
{
/************************************************************************/
/* 0
6 +
| \ 1 2
| +------+
ptGeS | |ptGeE
| |
| +------+3
| / 4
5 +
/************************************************************************/
ptGeM = TSupportFunc::Mid(ptGeS, ptGeE);
}
break;
case TDb::eRbotHorNormalDifR:
{
/************************************************************************/
/* 0 ptGeS
4 +
| \
| \1
dWidthL | | dWidthS
ptGeS | /2 ptGeE
| /
3 +
/************************************************************************/
ptGeM = TSupportFunc::Mid(ptGeS, ptGeE);
}
break;
case TDb::eRbotHorOffsetDifR2:
case TDb::eRbotHorOffsetDifR:
{
// 槽式下平右偏异径接头
/************************************************************************/
/* 0 ptGeS 1 ptGeE
6 +-----------------+
| | dWidthS
| |
dWidthL | +-----+2
| /3 dLen2
| /
5 +--------+4
dLen1
/************************************************************************/
m_pXDataMap->GetAt(KEY_MAINDIR,vtTemp);
ptGeM = TSupportFunc::Mid(ptGeS, ptGeE);
// 槽式下平左偏异径接头
/************************************************************************/
/* 0 dLen1 1
6 +-----------+
| \
dWidthL | \ 2 dLen2 3
| +---------+
| | dWidthS
ptGeS | |
5 +------------------------+4 ptGeE
/************************************************************************/
}
break;
default:
break;
}
//传统夹点
gripPoints.append(ptGeS); //STA
gripPoints.append(ptGeM); //MID
gripPoints.append(ptGeE); //END
//增加2个命令夹点
AcGePoint3d ptGeT;
vtTemp.normalize();
//按 10 个像素点
double dCmd = TSupportFunc::PixelToWcs(10);
ptGeT = ptGeS + vtTemp * dCmd;
gripPoints.append(ptGeT); //cmd1
ptGeT = ptGeE - vtTemp * dCmd;
gripPoints.append(ptGeT); //cmd2
}
}
return Acad::eOk;
}
BOOL TEImpCabReducer::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;
int nType = 0;
AcGePoint3d ptGeS,ptGeE,ptGeM;
m_pXDataMap->GetAt(KEY_START,ptGeS);
m_pXDataMap->GetAt(KEY_END,ptGeE);
m_pXDataMap->GetAt(KEY_REDUCER,nType);
ptGeM = TSupportFunc::Mid(ptGeS,ptGeE);
AcGeVector3d vtSta = ptGeS - ptGeM;
AcGeVector3d vtEnd = ptGeE - ptGeM;
if (nType == TDb::eRbotHorOffsetDifR ||
nType == TDb::eRbotHorOffsetDifR2)
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtSta);
vtEnd = -vtSta;
}
AcGePoint3d ptGeSOld = ptGeS;
AcGePoint3d ptGeEOld = ptGeE;
int nPos = iModiMsg.GetGripPosition();
switch (nPos)
{
case TDb::eStart:
case TDb::eEnd:
case TDb::eBr1:
case TDb::eBr2:
case TDb::eBr3:
case TDb::eBr4:
case TDb::eMid:
{
if ( vtOffset.isParallelTo(vtSta) ||
vtOffset.isPerpendicularTo(vtSta)) //平行或者垂直
{
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(ptGeSOld,vtSta,m_pOwnerEnt->objectId(),idT)) // sta 点的接口
{
if ((idT == id1 || idT == id2) && !idT.isNull())
{
TInterfaceModifyMsg msg;
msg.SetMsgPoint(ptGeSOld);
msg.SetTransform(vtOffset);
msg.SetMsgOperateOn(idT);
iModiMsgs.append(msg);
bMsgTranslate = TRUE;
}
}
// 构造接口消息传递 末端检查
if (FindConnect(ptGeEOld,vtEnd,m_pOwnerEnt->objectId(),idT)) // end 点的接口
{
if ((idT == id1 || idT == id2) && !idT.isNull())
{
TInterfaceModifyMsg msg;
msg.SetMsgPoint(ptGeEOld);
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 TEImpCabReducer::OnTransformByMsgNotify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
{
// 不考虑其所属的接口的关系,变化后相当于断开关系
// 新位置的关系建立,由外部管理对象处理;
AcGePoint3d ptSta,ptEnd,ptGeM;
BOOL bMsgTranslate = FALSE;
if (m_pXDataMap != NULL)
{
AcGeMatrix3d xform = iModiMsg.GetTransform();
m_pXDataMap->GetAt(KEY_START,ptSta);
m_pXDataMap->GetAt(KEY_END,ptEnd);
AcGePoint3d ptGeSOld = ptSta;
AcGePoint3d ptGeEOld = ptEnd;
ptGeM = TSupportFunc::Mid(ptSta,ptEnd);
AcGeVector3d vtSta = ptSta - ptGeM;
AcGeVector3d vtEnd = ptEnd - ptGeM;
int nReducerStyle = 0;
m_pXDataMap->GetAt(KEY_REDUCER,nReducerStyle);
if (nReducerStyle == TDb::eRbotHorOffsetDifR ||
nReducerStyle == TDb::eRbotHorOffsetDifR2)
{
m_pXDataMap->GetAt(KEY_MAINDIR,vtSta);
vtEnd = -vtSta;
}
ptSta.transformBy(xform);
ptEnd.transformBy(xform);
m_pXDataMap->SetAt(KEY_START,ptSta);
m_pXDataMap->SetAt(KEY_END,ptEnd);
//产生新的接口消息
AcDbObjectId id1,id2;
m_pXDataMap->GetAt(KEY_IDCNT1,id1);
m_pXDataMap->GetAt(KEY_IDCNT2,id2);
// 构造接口消息传递 开始端检查
AcDbObjectId idT;
if (FindConnect(ptGeSOld,vtSta,m_pOwnerEnt->objectId(),idT)) // sta 点的接口
{
if (idT == id1 || idT == id2)
{
TInterfaceModifyMsg msg;
msg.SetMsgPoint(ptGeSOld);
msg.SetTransform(xform);
msg.SetMsgOperateOn(idT);
iModiMsgs.append(msg);
bMsgTranslate = TRUE;
}
}
// 构造接口消息传递 末端检查
if (FindConnect(ptGeEOld,vtEnd,m_pOwnerEnt->objectId(),idT)) // end 点的接口
{
if (idT == id1 || idT == id2)
{
TInterfaceModifyMsg msg;
msg.SetMsgPoint(ptGeEOld);
msg.SetTransform(xform);
msg.SetMsgOperateOn(idT);
iModiMsgs.append(msg);
bMsgTranslate = TRUE;
}
}
if (m_pOwnerEnt->objectId().isValid())
{
//更新接口记录接口信息
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
}
}
return bMsgTranslate;
}
BOOL TEImpCabReducer::OnSizeMsgNotify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
{
//尺寸更改涉及到相关接口的更改
return FALSE;
}
Acad::ErrorStatus TEImpCabReducer::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 TEImpCabReducer::ExplodeOrDraw3dOfC(XExplodeDraw &mode) const
{
if (m_pXDataMap != NULL)
{
int nType = 0;
if (m_pXDataMap->GetAt(KEY_REDUCER,nType))
{
switch(nType)
{
case TDb::eRbotHorDifR:
{
ExplodeOrDraw3dDifR(mode);
}
break;
case TDb::eRbotHorNormalDifR:
{
ExplodeOrDraw3dNorDifR(mode);
}
break;
case TDb::eRbotHorOffsetDifR2:
case TDb::eRbotHorOffsetDifR:
{
ExplodeOrDraw3dOffDifR(mode);
}
break;
default:
break;
}
}
}
return Acad::eOk;
}
Acad::ErrorStatus TEImpCabReducer::ExplodeOrDraw3dOfT(XExplodeDraw &mode) const
{
if (m_pXDataMap != NULL)
{
int nType = 0;
if (m_pXDataMap->GetAt(KEY_REDUCER,nType))
{
switch(nType)
{
case TDb::eRbotHorDifR:
{
//ExplodeOrDraw3dDifROfT(mode);
}
break;
case TDb::eRbotHorNormalDifR:
{
ExplodeOrDraw3dNorDifROfT(mode);
}
break;
case TDb::eRbotHorOffsetDifR2:
case TDb::eRbotHorOffsetDifR:
{
ExplodeOrDraw3dOffDifROfT(mode);
}
break;
default:
break;
}
}
}
return Acad::eOk;
}
BOOL TEImpCabReducer::ExplodeOrDraw3dOffDifROfT(XExplodeDraw &mode) const
{
if (m_pXDataMap == NULL)
return FALSE;
double dLadderWidth = 50; //梯宽
double dSideWidth = 30; //侧面宽
double dThick = 10; //梯厚度
AcGePoint3d ptGeS,ptGeE;
AcGeVector3d vtNormal;
double dLen = 0.0;
double dWidth = 0.0,dWidth2 = 0.0;
double dHeight = 0.0,dHeight2 = 0.0;// 长高度
if (m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_L,dLen) &&
m_pXDataMap->GetAt(KEY_B1,dWidth) &&
m_pXDataMap->GetAt(KEY_B2,dWidth2) &&
m_pXDataMap->GetAt(KEY_H1,dHeight) &&
m_pXDataMap->GetAt(KEY_H2,dHeight2) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal))
{
double dLen1 = dLen / 3.0;
double dLen2 = dLen1;
double dAngle = PI / 2.0;
Adesk::UInt32 nRows = 0;
Adesk::UInt32 nColums = 0;
AcGePoint3d* lstVertex = NULL;
AcGeVector3d vtRed,vtOff;
if (m_pXDataMap->GetAt(KEY_MAINDIR,vtRed) &&
m_pXDataMap->GetAt(KEY_BRDIR,vtOff) )
{
nRows = 4;
vtRed.normalize();
vtOff.normalize();
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtNormal = vtOff;
vtNormal.rotateBy(dAngle,vtRed);
vtNormal.normalize();
}
nColums = 4;
lstVertex = new AcGePoint3d[nRows * nColums];
if (lstVertex == NULL)
return FALSE;
AcGePoint3d ptTemp;
ptTemp = ptGeS - vtOff * (dWidth / 2.0);
lstVertex[4] = ptTemp;
lstVertex[0] = ptTemp + vtNormal * dHeight;
lstVertex[5] = ptTemp + vtRed * dLen1;
lstVertex[1] = lstVertex[5] + vtNormal * dHeight;
ptTemp = ptGeS + vtOff * (dWidth / 2.0);
lstVertex[8] = ptTemp;
lstVertex[12] = ptTemp + vtNormal * dHeight;
lstVertex[9] = ptTemp + vtRed * dLen1;
lstVertex[13] = lstVertex[9] + vtNormal * dHeight;
ptTemp = ptGeE - vtOff * (dWidth2 / 2.0);
lstVertex[7] = ptTemp;
lstVertex[3] = ptTemp + vtNormal * dHeight2;
lstVertex[6] = ptTemp - vtRed * dLen2;
lstVertex[10] = lstVertex[6] + vtOff * dWidth2;
lstVertex[2] = lstVertex[3] - vtRed * dLen2;
ptTemp = ptGeE + vtOff * (dWidth2 / 2.0);
lstVertex[11] = ptTemp;
lstVertex[15] = ptTemp + vtNormal * dHeight2;
lstVertex[14] = lstVertex[15] - vtRed * dLen2;
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
mode.SetColor(curColor);
AcGePoint3dArray arPt;
arPt.append(lstVertex[0]);
arPt.append(lstVertex[1]);
arPt.append(lstVertex[4]);
arPt.append(lstVertex[5]);
DrawCube(mode, -vtOff, arPt, dSideWidth);
arPt.setLogicalLength(0);
arPt.append(lstVertex[1]);
arPt.append(lstVertex[2]);
arPt.append(lstVertex[5]);
arPt.append(lstVertex[6]);
DrawCube(mode, -vtOff, arPt, dSideWidth);
arPt.setLogicalLength(0);
arPt.append(lstVertex[2]);
arPt.append(lstVertex[3]);
arPt.append(lstVertex[6]);
arPt.append(lstVertex[7]);
DrawCube(mode, -vtOff, arPt, dSideWidth);
arPt.setLogicalLength(0);
arPt.append(lstVertex[12]);
arPt.append(lstVertex[13]);
arPt.append(lstVertex[8]);
arPt.append(lstVertex[9]);
DrawCube(mode, vtOff, arPt, dSideWidth);
arPt.setLogicalLength(0);
arPt.append(lstVertex[13]);
arPt.append(lstVertex[14]);
arPt.append(lstVertex[9]);
arPt.append(lstVertex[10]);
DrawCube(mode, vtOff, arPt, dSideWidth);
arPt.setLogicalLength(0);
arPt.append(lstVertex[14]);
arPt.append(lstVertex[15]);
arPt.append(lstVertex[10]);
arPt.append(lstVertex[11]);
DrawCube(mode, vtOff, arPt, dSideWidth);
arPt.setLogicalLength(0);
arPt.append(lstVertex[6]);
arPt.append(lstVertex[10]);
arPt.append(lstVertex[6] + vtRed * dLadderWidth);
arPt.append(lstVertex[10] + vtRed * dLadderWidth);
DrawCube(mode, vtNormal, arPt, dThick);
arPt.setLogicalLength(0);
arPt.append(lstVertex[5]);
arPt.append(lstVertex[9]);
arPt.append(lstVertex[5] - vtRed * dLadderWidth);
arPt.append(lstVertex[9] - vtRed * dLadderWidth);
DrawCube(mode, vtNormal, arPt, dThick);
delete []lstVertex;
lstVertex = NULL;
}
}
return TRUE;
}
void TEImpCabReducer::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 TEImpCabReducer::ExplodeOrDraw3dOfP(XExplodeDraw &mode) const
{
return ExplodeOrDraw3dOfC(mode);
}
// 槽式下平异径3d
BOOL TEImpCabReducer::ExplodeOrDraw3dDifR(XExplodeDraw &mode) const
{
if (m_pXDataMap == NULL)
return FALSE;
AcGePoint3d ptGeS,ptGeE;
AcGeVector3d vtNormal,vtDir;
double dHeight2 = 0.0;// 长高度
int nCover = 0;
double dHeight = 0.0,dWidth = 0.0,dWidth2 = 0.0,dLen = 0.0;
if (m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_L,dLen) && // 确定变径点
m_pXDataMap->GetAt(KEY_B1,dWidth) &&
m_pXDataMap->GetAt(KEY_B2,dWidth2) &&
m_pXDataMap->GetAt(KEY_H1,dHeight) &&
m_pXDataMap->GetAt(KEY_H2,dHeight2) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) &&
m_pXDataMap->GetAt(KEY_COVER,nCover) &&
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) )
{
dLen /= 2.0;
double dAngle = PI / 2.0;
Adesk::UInt32 nRows = 0;
Adesk::UInt32 nColums = 0;
AcGePoint3d* lstVertex = NULL;
if (nCover)
{
nRows = 5;
}
else
{
nRows = 4;
}
nColums = 3;
AcGeVector3d vtH = vtDir;
AcGeVector3d vtV = vtH;
vtV.rotateBy(dAngle,vtNormal);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtH = ptGeE - ptGeS;
vtV = vtDir;
vtNormal = vtDir;
vtNormal.rotateBy(dAngle, vtH);
vtNormal.normalize();
}
vtV.normalize();
vtH.normalize();
lstVertex = new AcGePoint3d[nRows * nColums];
if (lstVertex == NULL) return FALSE;
AcGePoint3d ptTemp;
ptTemp = ptGeS + vtV * (dWidth / 2.0);
lstVertex[3] = ptTemp;
lstVertex[0] = ptTemp + vtNormal * dHeight;
lstVertex[4] = ptTemp + vtH * dLen;
ptTemp = ptGeS - vtV * (dWidth / 2.0);
lstVertex[6] = ptTemp;
lstVertex[9] = ptTemp + vtNormal * dHeight;
lstVertex[7] = ptTemp + vtH * dLen;
ptTemp = ptGeE + vtV * (dWidth2 / 2.0);
lstVertex[5] = ptTemp;
lstVertex[2] = ptTemp + vtNormal * dHeight2;
ptTemp = ptGeE - vtV * (dWidth2 / 2.0);
lstVertex[8] = ptTemp;
lstVertex[11] = ptTemp + vtNormal * dHeight2;
if (dWidth > dWidth2)
{
lstVertex[4] = lstVertex[5] - vtH * dLen;
lstVertex[7] = lstVertex[8] - vtH * dLen;
}
lstVertex[1] = lstVertex[4] + vtNormal * dHeight;
lstVertex[10] = lstVertex[7] + vtNormal * dHeight;
if (nCover)
{
lstVertex[12] = lstVertex[0];
lstVertex[13] = lstVertex[1];
lstVertex[14] = lstVertex[2];
}
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
mode.SetColor(curColor);
mode.DrawMesh(nRows, nColums, lstVertex);
delete []lstVertex;
int nCalBoradShow = 0,nHaveClap = -1;
m_pXDataMap->GetAt(KEY_HAVE_CLAPBOARD,nHaveClap);
m_pXDataMap->GetAt(KEY_SHOW_CLAPBOARD,nCalBoradShow);
if (nCalBoradShow == TDb::eShowBoard &&
nHaveClap == TDb::eBoard)
{
double dSubWidth1,dSubWidth2;
m_pXDataMap->GetAt(KEY_B1,dSubWidth1);
m_pXDataMap->GetAt(KEY_B2,dSubWidth2);
AcGeVector3d vtNor;
m_pXDataMap->GetAt(KEY_CLAPBOARD_MAINBR,vtNor);
vtNor.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 dOffset1 = 0.0,dOffset2 = 0.0;
m_pXDataMap->GetAt(KEY_NORMAL, vtNormal);
vtNormal.normalize();
for (int i = 0;i < arDimeS.length();++i)
{
dOffset1 = arDimeS[i];
dOffset2 = arDimeE[i];
AcGePoint3d ptVer[4];
ptVer[0] = ptGeS - vtNor * (dSubWidth1/2-dOffset1);
ptVer[1] = ptGeE - vtNor * (dSubWidth2/2-dOffset2);
ptVer[2] = ptVer[0] + vtNormal * dHeight;
ptVer[3] = ptVer[1] + vtNormal * dHeight2;
mode.DrawMesh(2,2,ptVer);
}
}
}
return TRUE;
}
// 槽式下平普通异径3d
BOOL TEImpCabReducer::ExplodeOrDraw3dNorDifR(XExplodeDraw &mode) const
{
if (m_pXDataMap == NULL)
return FALSE;
int nCover = 0;
AcGeVector3d vtNormal,vtDir;
AcGePoint3d ptGeS,ptGeE;
double dHeight = 0.0,dHeight2 = 0.0;// dHeight2 长高度
double dWidth = 0.0,dWidth2 = 0.0;
if (m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_B1,dWidth) &&
m_pXDataMap->GetAt(KEY_B2,dWidth2) &&
m_pXDataMap->GetAt(KEY_H1,dHeight) &&
m_pXDataMap->GetAt(KEY_H2,dHeight2) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) &&
m_pXDataMap->GetAt(KEY_COVER,nCover) &&
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) )
{
double dAngle = PI / 2.0;
Adesk::UInt32 nRows = 0;
Adesk::UInt32 nColums = 0;
AcGePoint3d* lstVertex = NULL;
if (nCover)
{
nRows = 5;
}
else
{
nRows = 4;
}
nColums = 2;
AcGeVector3d vtH = vtDir;
AcGeVector3d vtV = vtH;
vtV.rotateBy(dAngle,vtNormal);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtH = ptGeE - ptGeS;
vtV = vtDir;
vtNormal = vtDir;
vtNormal.rotateBy(dAngle, vtH);
vtNormal.normalize();
}
vtV.normalize();
vtH.normalize();
lstVertex = new AcGePoint3d[nRows * nColums];
if (lstVertex == NULL) return FALSE;
AcGePoint3d ptTemp;
ptTemp = ptGeS + vtV * (dWidth / 2.0);
lstVertex[2] = ptTemp;
lstVertex[0] = ptTemp + vtNormal * dHeight;
ptTemp = ptGeS - vtV * (dWidth / 2.0);
lstVertex[4] = ptTemp;
lstVertex[6] = ptTemp + vtNormal * dHeight;
ptTemp = ptGeE + vtV * (dWidth2 / 2.0);
lstVertex[3] = ptTemp;
lstVertex[1] = ptTemp + vtNormal * dHeight2;
ptTemp = ptGeE - vtV * (dWidth2 / 2.0);
lstVertex[5] = ptTemp;
lstVertex[7] = ptTemp + vtNormal * dHeight2;
if (nCover == 1)
{
lstVertex[8] = lstVertex[0];
lstVertex[9] = lstVertex[1];
}
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
mode.SetColor(curColor);
mode.DrawMesh(nRows, nColums, lstVertex);
delete []lstVertex;
int nCalBoradShow = 0,nHaveClap = -1;
m_pXDataMap->GetAt(KEY_HAVE_CLAPBOARD,nHaveClap);
m_pXDataMap->GetAt(KEY_HAVE_CLAPBOARD,nCalBoradShow);
if (nCalBoradShow == TDb::eShowBoard &&
nHaveClap == TDb::eBoard)
{
double dSubWidth1,dSubWidth2;
m_pXDataMap->GetAt(KEY_B1,dSubWidth1);
m_pXDataMap->GetAt(KEY_B2,dSubWidth2);
AcGeVector3d vtNor;
m_pXDataMap->GetAt(KEY_CLAPBOARD_MAINBR,vtNor);
vtNor.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 dOffset1 = 0.0,dOffset2 = 0.0;
m_pXDataMap->GetAt(KEY_NORMAL, vtNormal);
vtNormal.normalize();
for (int i = 0;i < arDimeS.length();++i)
{
dOffset1 = arDimeS[i];
dOffset2 = arDimeE[i];
AcGePoint3d ptVer[4];
ptVer[0] = ptGeS - vtNor * (dSubWidth1/2-dOffset1);
ptVer[1] = ptGeE - vtNor * (dSubWidth2/2-dOffset2);
ptVer[2] = ptVer[0] + vtNormal * dHeight;
ptVer[3] = ptVer[1] + vtNormal * dHeight2;
mode.DrawMesh(2,2,ptVer);
}
}
}
return TRUE;
}
BOOL TEImpCabReducer::ExplodeOrDraw3dNorDifROfT(XExplodeDraw &mode) const
{
if (m_pXDataMap == NULL)
return FALSE;
double dLadderWidth = 50; //梯宽
double dSideWidth = 30; //侧面宽
double dThick = 10; //梯厚度
AcGeVector3d vtNormal,vtDir;
AcGePoint3d ptGeS,ptGeE;
double dHeight = 0.0,dHeight2 = 0.0;// dHeight2 长高度
double dWidth = 0.0,dWidth2 = 0.0;
if (m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_B1,dWidth) &&
m_pXDataMap->GetAt(KEY_B2,dWidth2) &&
m_pXDataMap->GetAt(KEY_H1,dHeight) &&
m_pXDataMap->GetAt(KEY_H2,dHeight2) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) &&
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) )
{
double dAngle = PI / 2.0;
Adesk::UInt32 nRows = 0;
Adesk::UInt32 nColums = 0;
AcGePoint3d* lstVertex = NULL;
nRows = 4;
nColums = 2;
AcGeVector3d vtH = vtDir;
AcGeVector3d vtV = vtH;
vtV.rotateBy(dAngle,vtNormal);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtH = ptGeE - ptGeS;
vtV = vtDir;
vtNormal = vtDir;
vtNormal.rotateBy(dAngle, vtH);
vtNormal.normalize();
}
vtV.normalize();
vtH.normalize();
lstVertex = new AcGePoint3d[nRows * nColums];
if (lstVertex == NULL)
return FALSE;
AcGePoint3d ptTemp;
ptTemp = ptGeS + vtV * (dWidth / 2.0);
lstVertex[2] = ptTemp;
lstVertex[0] = ptTemp + vtNormal * dHeight;
ptTemp = ptGeS - vtV * (dWidth / 2.0);
lstVertex[4] = ptTemp;
lstVertex[6] = ptTemp + vtNormal * dHeight;
ptTemp = ptGeE + vtV * (dWidth2 / 2.0);
lstVertex[3] = ptTemp;
lstVertex[1] = ptTemp + vtNormal * dHeight2;
ptTemp = ptGeE - vtV * (dWidth2 / 2.0);
lstVertex[5] = ptTemp;
lstVertex[7] = ptTemp + vtNormal * dHeight2;
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
mode.SetColor(curColor);
AcGePoint3dArray arPt;
arPt.append(lstVertex[0]);
arPt.append(lstVertex[1]);
arPt.append(lstVertex[2]);
arPt.append(lstVertex[3]);
AcGeVector3d vtr = lstVertex[4] - lstVertex[2];
vtr.normalize();
DrawCube(mode ,-vtr, arPt, dSideWidth);
arPt.setLogicalLength(0);
arPt.append(lstVertex[6]);
arPt.append(lstVertex[7]);
arPt.append(lstVertex[4]);
arPt.append(lstVertex[5]);
DrawCube(mode ,vtr, arPt, dSideWidth);
AcGePoint3dArray arPt2;
double dDist = lstVertex[2].distanceTo(lstVertex[3]) / 3;
vtr = lstVertex[3] - lstVertex[2];
vtr.normalize();
arPt.setLogicalLength(0);
arPt.append(lstVertex[2] + vtr * (dDist + dLadderWidth / 2));
arPt.append(lstVertex[2] + vtr * (dDist + dLadderWidth / 2) - vtr * dLadderWidth);
arPt2.append(lstVertex[2] + vtr * 2 * (dDist + dLadderWidth / 2));
arPt2.append(lstVertex[2] + vtr * 2 * (dDist + dLadderWidth / 2) - vtr * dLadderWidth);
vtr = lstVertex[5] - lstVertex[4];
vtr.normalize();
arPt.append(lstVertex[4] + vtr * (dDist + dLadderWidth / 2));
arPt.append(lstVertex[4] + vtr * (dDist + dLadderWidth / 2) - vtr * dLadderWidth);
arPt2.append(lstVertex[4] + vtr * 2 * (dDist + dLadderWidth / 2));
arPt2.append(lstVertex[4] + vtr * 2 * (dDist + dLadderWidth / 2) - vtr * dLadderWidth);
DrawCube(mode, vtNormal, arPt, dThick);
DrawCube(mode, vtNormal, arPt2, dThick);
delete []lstVertex;
lstVertex = NULL;
}
return TRUE;
}
// 槽式下平偏移异径3d
BOOL TEImpCabReducer::ExplodeOrDraw3dOffDifR(XExplodeDraw &mode) const
{
if (m_pXDataMap == NULL)
return FALSE;
int nCover = 0;
AcGePoint3d ptGeS,ptGeE;
AcGeVector3d vtNormal;
double dLen = 0.0;
double dWidth = 0.0,dWidth2 = 0.0;
double dHeight = 0.0,dHeight2 = 0.0;// 长高度
if (m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_L,dLen) &&
m_pXDataMap->GetAt(KEY_B1,dWidth) &&
m_pXDataMap->GetAt(KEY_B2,dWidth2) &&
m_pXDataMap->GetAt(KEY_H1,dHeight) &&
m_pXDataMap->GetAt(KEY_H2,dHeight2) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) &&
m_pXDataMap->GetAt(KEY_COVER,nCover))
{
double dLen1 = dLen / 3.0;
double dLen2 = dLen1;
double dAngle = PI / 2.0;
Adesk::UInt32 nRows = 0;
Adesk::UInt32 nColums = 0;
AcGePoint3d* lstVertex = NULL;
AcGeVector3d vtRed,vtOff;
if (m_pXDataMap->GetAt(KEY_MAINDIR,vtRed) &&
m_pXDataMap->GetAt(KEY_BRDIR,vtOff) )
{
if (nCover)
{
nRows = 5;
}
else
{
nRows = 4;
}
vtRed.normalize();
vtOff.normalize();
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtNormal = vtOff;
vtNormal.rotateBy(dAngle,vtRed);
vtNormal.normalize();
}
nColums = 4;
lstVertex = new AcGePoint3d[nRows * nColums];
if (lstVertex == NULL) return FALSE;
AcGePoint3d ptTemp;
ptTemp = ptGeS - vtOff * (dWidth / 2.0);
lstVertex[4] = ptTemp;
lstVertex[0] = ptTemp + vtNormal * dHeight;
lstVertex[5] = ptTemp + vtRed * dLen1;
lstVertex[1] = lstVertex[5] + vtNormal * dHeight;
ptTemp = ptGeS + vtOff * (dWidth / 2.0);
lstVertex[8] = ptTemp;
lstVertex[12] = ptTemp + vtNormal * dHeight;
lstVertex[9] = ptTemp + vtRed * dLen1;
lstVertex[13] = lstVertex[9] + vtNormal * dHeight;
ptTemp = ptGeE - vtOff * (dWidth2 / 2.0);
lstVertex[7] = ptTemp;
lstVertex[3] = ptTemp + vtNormal * dHeight2;
lstVertex[6] = ptTemp - vtRed * dLen2;
lstVertex[10] = lstVertex[6] + vtOff * dWidth2;
lstVertex[2] = lstVertex[3] - vtRed * dLen2;
ptTemp = ptGeE + vtOff * (dWidth2 / 2.0);
lstVertex[11] = ptTemp;
lstVertex[15] = ptTemp + vtNormal * dHeight2;
lstVertex[14] = lstVertex[15] - vtRed * dLen2;
if (nCover)
{
lstVertex[16] = lstVertex[0];
lstVertex[17] = lstVertex[1];
lstVertex[18] = lstVertex[2];
lstVertex[19] = lstVertex[3];
}
Adesk::UInt16 curColor = m_pOwnerEnt->colorIndex();
mode.SetColor(curColor);
mode.DrawMesh(nRows, nColums, lstVertex);
delete []lstVertex;
int nCalBoradShow = 0,nHaveClap = -1;
m_pXDataMap->GetAt(KEY_HAVE_CLAPBOARD,nHaveClap);
m_pXDataMap->GetAt(KEY_SHOW_CLAPBOARD,nCalBoradShow);
if (nCalBoradShow = TDb::eShowBoard &&
nHaveClap == TDb::eBoard)
{
double dSubWidth1,dSubWidth2;
m_pXDataMap->GetAt(KEY_B1,dSubWidth1);
m_pXDataMap->GetAt(KEY_B2,dSubWidth2);
AcGeVector3d vtNor;
m_pXDataMap->GetAt(KEY_CLAPBOARD_MAINBR,vtNor);
vtNor.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 dOffset1 = 0.0,dOffset2 = 0.0;
m_pXDataMap->GetAt(KEY_NORMAL, vtNormal);
vtNormal.normalize();
for (int i = 0;i < arDimeS.length();++i)
{
dOffset1 = arDimeS[i];
dOffset2 = arDimeE[i];
AcGePoint3d ptVer[4];
ptVer[0] = ptGeS - vtNor * (dSubWidth1/2-dOffset1);
ptVer[1] = ptGeE - vtNor * (dSubWidth2/2-dOffset2);
ptVer[2] = ptVer[0] + vtNormal * dHeight;
ptVer[3] = ptVer[1] + vtNormal * dHeight;
mode.DrawMesh(2,2,ptVer);
}
}
}
}
return TRUE;
}
Acad::ErrorStatus TEImpCabReducer::ExplodeOrDraw2d(XExplodeDraw &mode) const
{
if (m_pXDataMap == NULL)
{
return Acad::eNotImplementedYet;
}
TComplexCurve cplCurve;
MakeCurves(cplCurve);
TDbExtentsEdge edage;
edage.SetEdage(cplCurve);
BOOL bWeight = FALSE;
m_pXDataMap->GetAt(KEY_EDAGEWEIGHT,bWeight);
AcDbObjectId idReal = ((TDbInterfacesObj*)m_pOwnerEnt)->layerId();
AcDbObjectId idDash = ((TDbInterfacesObj*)m_pOwnerEnt)->DashLayer();
AcDbObjectId idCent = ((TDbInterfacesObj*)m_pOwnerEnt)->CenterLayer();
edage.ExplodeOrDraw2d(mode,idReal,idDash,idCent,NULL,bWeight,FALSE);
/* TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int i = 0;i < cplCurve.length();i++)
{
el = cplCurve.at(i);
if (el.ptGe[1].distanceTo(el.ptGe[2]) < 1.e-10)
{
mode->geometry().polyline(2,el.ptGe);
}
else
{
if (el.ptGe[0].distanceTo(el.ptGe[1]) > 1.e-10 &&
el.ptGe[1].distanceTo(el.ptGe[2]) > 1.e-10)
{
mode->geometry().circularArc(el.ptGe[0],el.ptGe[1],el.ptGe[2]);
}
}
}*/
return Acad::eOk;
}
void TEImpCabReducer::FreeBuffer(AcDbVoidPtrArray& arCurves)
{
for (int i = 0;i < arCurves.length();i++)
{
AcDbEntity* pEnt = (AcDbEntity*)arCurves.at(i);
if (pEnt != NULL)
{
delete pEnt;
}
}
arCurves.setLogicalLength(0);
}
BOOL TEImpCabReducer::MakeCurves(TComplexCurve& cplCurve) const
{
if (m_pXDataMap == NULL)
return FALSE;
int nType = 0;
m_pXDataMap->GetAt(KEY_REDUCER,nType);
int nVetexNum = 0;
switch(nType)
{
case TDb::eRbotHorDifR: // 槽式下平异径接头
{
MakeCurvesOfHorDifR2D(cplCurve,nVetexNum);
}
break;
case TDb::eRbotHorNormalDifR: // 槽式下平普通异径接头
{
MakeCurvesOfHorNorDifR2D(cplCurve,nVetexNum);
}
break;
case TDb::eRbotHorOffsetDifR2:
case TDb::eRbotHorOffsetDifR: // 槽式下平偏移异径接头
{
MakeCurvesOfHorOffDifR2D(cplCurve,nVetexNum);
}
break;
default:
break;
}
if (cplCurve.length() > 0)
{
// 是否显示连接线
int nCnt = -1;
m_pXDataMap->GetAt(KEY_SHOWCNTLINE,nCnt);
if (nCnt == 0)
{
int nSize = cplCurve.length();
NoneConectLineIfNeed(cplCurve);
nSize -= cplCurve.length();
nVetexNum -= nSize;
}
// 设置边线宽
double dWidth = 0.0;
m_pXDataMap->GetAt(KEY_EDAGEWIDTH,dWidth);
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int j = 0;j < nVetexNum;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 < nVetexNum;j++)
{
el = cplCurve[j];
el.nColorIndex = nColor;
cplCurve.setAt(j,el);
}
}
return TRUE;
}
return FALSE;
}
BOOL TEImpCabReducer::NoneConectLineIfNeed(TComplexCurve& cplCurve) const
{
TInterface inf;
int nIndex = -1;
int nInfCount = GetInterfaceCount();
for (int i = 0;i < nInfCount;i++)
{
// 获取接口
if (GetInterface(i,inf))
{
// 判断是否有连接物
if (GetInterface(inf.GetPosition(),inf))
{
// 获取连接点所在的线段索引号
if (GetIndexOfPointIsOn(cplCurve,inf.GetPosition(),nIndex))
{
cplCurve.removeAt(nIndex);
}
}
}
}
return TRUE;
}
BOOL TEImpCabReducer::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;
}
// 槽式下平异径2d
void TEImpCabReducer::MakeCurvesOfHorDifR2D(TComplexCurve& cplCurve,int& nNum) const
{
AcGePoint3d* pVetex = NULL;
if (m_pXDataMap == NULL)
return;
int nCover = 0;
double dLen = 0.0;
AcGePoint3d ptGeS,ptGeE;
AcGeVector3d vtNormal,vtDir;
double dHeight = 0.0,dHeight2 = 0.0;
double dWidthL = 0.0, dWidthS = 0.0;
if ( m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_L,dLen) &&
m_pXDataMap->GetAt(KEY_B1,dWidthL) &&
m_pXDataMap->GetAt(KEY_B2,dWidthS) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) &&
m_pXDataMap->GetAt(KEY_H1,dHeight) &&
m_pXDataMap->GetAt(KEY_H2,dHeight2) &&
m_pXDataMap->GetAt(KEY_COVER,nCover) &&
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) )
{
// ptGeS 长宽度的中点,ptGee短宽度的中点
dLen /= 2.0;
int nPtNum = 0;
double dAngle = PI / 2.0;
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
/************************************************************************/
/* 0 3
|\ /|
| \ 4 5 / |
| | | |
| | | |
| |6 7 | |
1 +--+--+--+--+2
ptGeS
ptGeE
/************************************************************************/
AcGeVector3d vtPerRe = vtDir;
AcGeVector3d vtT = ptGeE - ptGeS; //z
vtPerRe.rotateBy(dAngle,vtT); // 87方向
vtPerRe.normalize();
vtDir.normalize();
AcGePoint3d* pVetex = new AcGePoint3d[8];
if (pVetex == NULL) return;
pVetex[6] = ptGeS - vtDir * (dWidthL / 2);
pVetex[7] = ptGeS + vtDir * (dWidthL / 2);
pVetex[1] = ptGeS - vtDir * (dWidthS / 2);
pVetex[2] = ptGeS + vtDir * (dWidthS / 2);
pVetex[0] = pVetex[1] + vtPerRe * dHeight2;
pVetex[3] = pVetex[2] + vtPerRe * dHeight2;
pVetex[4] = pVetex[6] + vtPerRe * dHeight;
pVetex[5] = pVetex[7] + vtPerRe * dHeight;
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int i = 0;i < 3;i++)
{
el.ptGe[0] = pVetex[i];
el.ptGe[1] = pVetex[i + 1];
el.ptGe[2] = pVetex[i + 1];
cplCurve.append(el);
}
el.ptGe[0] = pVetex[0];
el.ptGe[1] = pVetex[4];
el.ptGe[2] = pVetex[4];
cplCurve.append(el);
el.ptGe[0] = pVetex[4];
el.ptGe[1] = pVetex[6];
el.ptGe[2] = pVetex[6];
cplCurve.append(el);
el.ptGe[0] = pVetex[3];
el.ptGe[1] = pVetex[5];
el.ptGe[2] = pVetex[5];
cplCurve.append(el);
el.ptGe[0] = pVetex[5];
el.ptGe[1] = pVetex[7];
el.ptGe[2] = pVetex[7];
cplCurve.append(el);
if (nCover) //conver
{
/************************************************************************/
/* 0 5
8 +-----------+
| \ 1 4 / |
| 9|-----|10|
| | | |
| |2 3| |
7 +--+--+--+--+6
ptGeS
ptGeE
/************************************************************************/
el.ptGe[0] = pVetex[0];
el.ptGe[1] = pVetex[3];
el.ptGe[2] = pVetex[3];
cplCurve.append(el);
el.ptGe[0] = pVetex[4];
el.ptGe[1] = pVetex[5];
el.ptGe[2] = pVetex[5];
cplCurve.append(el);
}
nNum = 3;
}
else //Normal:Z
{
/************************************************************************/
/* 0
6 +
| \ 1 2
| +------+
ptGeS | |ptGeE
| |
| +------+3
| / 4
5 +
/************************************************************************/
AcGeVector3d vt = vtDir;
vt.rotateBy(dAngle,vtNormal);
vt.normalize();
vtDir.normalize();
pVetex = new AcGePoint3d[7];
if (pVetex == NULL) return;
pVetex[0] = ptGeS + vt * (dWidthL / 2.0);
pVetex[6] = pVetex[0];
pVetex[5] = ptGeS - vt * (dWidthL / 2.0);
pVetex[2] = ptGeE + vt * (dWidthS / 2.0);
pVetex[3] = ptGeE - vt * (dWidthS / 2.0);
if (dWidthL < dWidthS)
{
pVetex[1] = pVetex[0] + vtDir * dLen;
pVetex[4] = pVetex[5] + vtDir * dLen;
}
else
{
pVetex[1] = pVetex[2] - vtDir * dLen;
pVetex[4] = pVetex[3] - vtDir * dLen;
}
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int i = 0;i < 6;i++)
{
el.ptGe[0] = pVetex[i];
el.ptGe[1] = pVetex[i + 1];
el.ptGe[2] = pVetex[i + 1];
cplCurve.append(el);
}
nNum = 6;
}
}
if (pVetex != NULL)
{
delete []pVetex;
pVetex = NULL;
}
}
// 槽式下平普通异径2d
void TEImpCabReducer::MakeCurvesOfHorNorDifR2D(TComplexCurve& cplCuve,int& nNum) const
{
AcGePoint3d* pVetex = NULL;
if (m_pXDataMap == NULL)
return;
int nType = 0;
int nCover = 0;
AcGeVector3d vtNormal,vtDir;
AcGePoint3d ptGeS,ptGeE;
double dHeight = 0.0,dHeight2 = 0.0;
double dWidthL = 0.0, dWidthS = 0.0;
if ( m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_B1,dWidthL) &&
m_pXDataMap->GetAt(KEY_B2,dWidthS) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) &&
m_pXDataMap->GetAt(KEY_H1,dHeight) &&
m_pXDataMap->GetAt(KEY_H2,dHeight2) &&
m_pXDataMap->GetAt(KEY_COVER,nCover) &&
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) )
{
// ptGeS 长宽度的中点,ptGee短宽度的中点
double dAngle = PI / 2.0;
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
/************************************************************************/
/* 0 3
|\ /|
| \ 4 5 / |
| | | |
| | | |
| |6 7 | |
1 +--+--+--+--+2
ptGeS
ptGeE
/************************************************************************/
AcGeVector3d vtPerRe = vtDir;
AcGeVector3d vtT = ptGeE - ptGeS; //z
vtPerRe.rotateBy(dAngle,vtT); // 87方向
vtPerRe.normalize();
vtDir.normalize();
AcGePoint3d* pVetex = new AcGePoint3d[8];
if (pVetex == NULL) return;
pVetex[6] = ptGeS - vtDir * (dWidthS / 2);
pVetex[7] = ptGeS + vtDir * (dWidthS / 2);
pVetex[1] = ptGeS - vtDir * (dWidthL / 2);
pVetex[2] = ptGeS + vtDir * (dWidthL / 2);
pVetex[0] = pVetex[1] + vtPerRe * dHeight;
pVetex[3] = pVetex[2] + vtPerRe * dHeight;
pVetex[4] = pVetex[6] + vtPerRe * dHeight2;
pVetex[5] = pVetex[7] + vtPerRe * dHeight2;
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int i = 0;i < 3;i++)
{
el.ptGe[0] = pVetex[i];
el.ptGe[1] = pVetex[i + 1];
el.ptGe[2] = pVetex[i + 1];
cplCuve.append(el);
}
if (nCover) //conver
{
/************************************************************************/
/* 0 5
8 +-----------+
| \ 1 4 / |
| 9|-----|10|
| | | |
| |2 3| |
7 +--+--+--+--+6
ptGeS
ptGeE
/************************************************************************/
el.ptGe[0] = pVetex[0];
el.ptGe[1] = pVetex[3];
el.ptGe[2] = pVetex[3];
cplCuve.append(el);
el.ptGe[0] = pVetex[4];
el.ptGe[1] = pVetex[5];
el.ptGe[2] = pVetex[5];
cplCuve.append(el);
}
el.ptGe[0] = pVetex[0];
el.ptGe[1] = pVetex[4];
el.ptGe[2] = pVetex[4];
cplCuve.append(el);
el.ptGe[0] = pVetex[4];
el.ptGe[1] = pVetex[6];
el.ptGe[2] = pVetex[6];
cplCuve.append(el);
el.ptGe[0] = pVetex[3];
el.ptGe[1] = pVetex[5];
el.ptGe[2] = pVetex[5];
cplCuve.append(el);
el.ptGe[0] = pVetex[5];
el.ptGe[1] = pVetex[7];
el.ptGe[2] = pVetex[7];
cplCuve.append(el);
nNum = 3;
}
else //Normal:z
{
/************************************************************************/
/* 0 ptGeS
4 +
| \
| \1
dWidthL | | dWidthS
ptGeS | /2 ptGeE
| /
3 +
/************************************************************************/
AcGeVector3d vt = vtDir;
vt.rotateBy(dAngle,vtNormal);
vt.normalize();
vtDir.normalize();
pVetex = new AcGePoint3d[5];
if (pVetex == NULL) return;
pVetex[0] = ptGeS + vt * (dWidthL / 2.0);
pVetex[4] = pVetex[0];
pVetex[3] = ptGeS - vt * (dWidthL / 2.0);
pVetex[1] = ptGeE + vt * (dWidthS / 2.0);
pVetex[2] = ptGeE - vt * (dWidthS / 2.0);
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int i = 0;i < 4;i++)
{
el.ptGe[0] = pVetex[i];
el.ptGe[1] = pVetex[i + 1];
el.ptGe[2] = pVetex[i + 1];
cplCuve.append(el);
}
nNum = 4;
}
}
if (pVetex != NULL)
{
delete []pVetex;
pVetex = NULL;
}
}
// 槽式下平偏移异径2d
void TEImpCabReducer::MakeCurvesOfHorOffDifR2D(TComplexCurve& cplCurve,int& nNum) const
{
AcGePoint3d* pVetex = NULL;
if (m_pXDataMap == NULL)
return;
int nType = 0;
int nCover = 0;
AcGePoint3d ptGeS,ptGeE;
AcGeVector3d vtNormal;
double dHeight = 0.0,dHeight2 = 0.0;
double dWidthL = 0.0, dWidthS = 0.0,dLen = 0.0;
if ( m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_L,dLen) &&
m_pXDataMap->GetAt(KEY_B1,dWidthL) &&
m_pXDataMap->GetAt(KEY_B2,dWidthS) &&
m_pXDataMap->GetAt(KEY_REDUCER,nType) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) &&
m_pXDataMap->GetAt(KEY_H1,dHeight) &&
m_pXDataMap->GetAt(KEY_H2,dHeight2) &&
m_pXDataMap->GetAt(KEY_COVER,nCover) )
{
// ptGeS 长宽度的中点,ptGee短宽度的中点
double dLen1 = dLen / 3.0;
double dLen2 = dLen1;
AcGeVector3d vtReduc;
double dAngle = PI / 2.0;
AcGeVector3d vtOffDir;
if (m_pXDataMap->GetAt(KEY_BRDIR,vtOffDir) &&
m_pXDataMap->GetAt(KEY_MAINDIR,vtReduc) )
{
/************************************************************************
0 1 2 3
8 +--------+--+-----+
| | | | dWidthS
| | | | ptGeE
dWidthL | | +-----+4
ptGeS | | /5
| |/
7 +--------+6
************************************************************************/
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line)) // Normal:x
{
/************************************************************************/
/* 0 3
| /|
6 | 4 / |
| | |
| | |
| 5 | |
1 +-----+--+--+ 2
ptGeS
ptGeE
/************************************************************************/
AcGeVector3d vtPerRe = vtOffDir; //z
vtPerRe.rotateBy(dAngle,vtReduc);
vtPerRe.normalize();
vtReduc.normalize();
vtOffDir.normalize();
pVetex = new AcGePoint3d[7];
if (pVetex == NULL) return;
pVetex[1] = ptGeS - vtOffDir * (dWidthL / 2.0);
pVetex[0] = pVetex[1] + vtPerRe * dHeight;
pVetex[2] = ptGeS + vtOffDir * (dWidthL / 2.0);
pVetex[3] = pVetex[2] + vtPerRe * dHeight;
pVetex[5] = ptGeS + vtOffDir * (dWidthS - dWidthL / 2.0);
pVetex[4] = pVetex[5] + vtPerRe * dHeight2;
pVetex[6] = pVetex[0] - vtPerRe * fabs((dHeight - dHeight2));
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int i = 0;i < 3;i++)
{
el.ptGe[0] = pVetex[i];
el.ptGe[1] = pVetex[i + 1];
el.ptGe[2] = pVetex[i + 1];
cplCurve.append(el);
}
if (nCover) // cover
{
/************************************************************************/
/* 8 9
0 +-----------+ 3
| 4 / |
7 |--------|6 |
| | |
| 5| |
1 +--+--+--+--+ 2
ptGeS
ptGeE
/************************************************************************/
el.ptGe[0] = pVetex[3];
el.ptGe[1] = pVetex[0];
el.ptGe[2] = pVetex[0];
cplCurve.append(el);
el.ptGe[0] = pVetex[4];
el.ptGe[1] = pVetex[6];
el.ptGe[2] = pVetex[6];
cplCurve.append(el);
}
el.ptGe[0] = pVetex[3];
el.ptGe[1] = pVetex[4];
el.ptGe[2] = pVetex[4];
cplCurve.append(el);
el.ptGe[0] = pVetex[4];
el.ptGe[1] = pVetex[5];
el.ptGe[2] = pVetex[5];
cplCurve.append(el);
nNum = 3;
}
else // Normal:z
{
vtOffDir.normalize();
pVetex = new AcGePoint3d[9];
if (pVetex == NULL) return;
pVetex[0] = ptGeS - vtOffDir * (dWidthL / 2.0);
pVetex[8] = pVetex[0];
pVetex[7] = ptGeS + vtOffDir * (dWidthL / 2.0);
vtReduc.normalize();
pVetex[3] = ptGeE - vtOffDir * (dWidthS / 2.0);
pVetex[4] = ptGeE + vtOffDir * (dWidthS / 2.0);
pVetex[5] = pVetex[4] - vtReduc * dLen2;
pVetex[6] = pVetex[7] + vtReduc * dLen1;
pVetex[1] = pVetex[6] - vtOffDir * dWidthL;
pVetex[2] = pVetex[5] - vtOffDir * dWidthS;
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int i = 0;i < 8;i++)
{
el.ptGe[0] = pVetex[i];
el.ptGe[1] = pVetex[i + 1];
el.ptGe[2] = pVetex[i + 1];
cplCurve.append(el);
}
nNum = 8;
}
}
}
if (pVetex != NULL)
{
delete []pVetex;
pVetex = NULL;
}
}
Acad::ErrorStatus TEImpCabReducer::getOsnapPoints(AcDb::OsnapMode osnapMode,
INT_PTR gsSelectionMark,
const AcGePoint3d& pickPoint,
const AcGePoint3d& lastPoint,
const AcGeMatrix3d& viewXform,
AcGePoint3dArray& snapPoints,
AcDbIntArray& geomIds) const
{
if (m_pXDataMap != NULL)
{
switch(osnapMode)
{
case AcDb::kOsModeEnd:
{
TComplexCurve cpl;
MakeCurves(cpl);
for (int i = 0;i < cpl.length();i++)
{
snapPoints.append(cpl[i].ptGe[0]);
}
AcGePoint3d ptGeS,ptGeE,ptGeM;
if (m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) )
{
snapPoints.append(ptGeS);
snapPoints.append(ptGeE);
}
}
break;
case AcDb::kOsModeMid:
{
AcGePoint3d ptGeS,ptGeE,ptGeM;
if (m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) )
{
ptGeM = TSupportFunc::Mid(ptGeS,ptGeE);
snapPoints.append(ptGeM);
}
}
break;
case AcDb::kOsModePerp:
{
AcGePoint3d ptVerFoot;
if (GetVerticalFootPoint(pickPoint, lastPoint, ptVerFoot))
{
snapPoints.append(ptVerFoot);
}
}
break;
case AcDb::kOsModeNear:
{
AcGePoint3d ptNear;
if (GetNearestPoint(pickPoint, ptNear))
{
snapPoints.append(ptNear);
}
}
break;
case AcDb::kOsModeNode: // 三维用到,暂时不实现
break;
}
}
return Acad::eNotImplementedYet;
}
// 获取垂足点
BOOL TEImpCabReducer::GetVerticalFootPoint(const AcGePoint3d& pickPoint,
const AcGePoint3d& lastPoint,
AcGePoint3d& ptVerFoot) const
{
BOOL bIsSuc = FALSE;
TComplexCurve cplCurve;
if (MakeCurves(cplCurve))
{
GetReducerMidLine(cplCurve);
TSupportFunc spFun;
bIsSuc = spFun.GetVerticalFootPoint(cplCurve, pickPoint, lastPoint, ptVerFoot);
}
return bIsSuc;
}
// 获取中心线
BOOL TEImpCabReducer::GetReducerMidLine(TComplexCurve& compCurve) const
{
return GetCurvesInSide(compCurve);
}
// 获取最近点
BOOL TEImpCabReducer::GetNearestPoint(const AcGePoint3d& pickPoint,
AcGePoint3d& ptNear) const
{
BOOL bIsFind = FALSE;
TComplexCurve cplCurve;
if (MakeCurves(cplCurve))
{
GetReducerMidLine(cplCurve);
TSupportFunc spFun;
bIsFind = spFun.GetNearestPoint(cplCurve, pickPoint, ptNear);
}
return bIsFind;
}
AcDbPolyline* TEImpCabReducer::MakePolyCurve() const
{
AcDbPolyline* pPl = new AcDbPolyline;
if (m_pXDataMap != NULL)
{
int nType = 0;
if (m_pXDataMap->GetAt(KEY_REDUCER,nType))
{
switch(nType)
{
case TDb::eRbotHorDifR: // 槽式下平异径接头
{
MakePolyCurveOfBHDifR(pPl);
break;
}
case TDb::eRbotHorNormalDifR: // 槽式下平普通异径接头
{
MakePolyCurveOfNorDifR(pPl);
break;
}
case TDb::eRbotHorOffsetDifR2:
case TDb::eRbotHorOffsetDifR: // 槽式下平偏移异径接头
{
MakePolyCurveOfOffDifR(pPl);
break;
}
default:
break;
}
}
}
if (pPl != NULL && pPl->numVerts() == 0)
{
delete pPl;
pPl = NULL;
}
return pPl;
}
void TEImpCabReducer::MakePolyCurveOfBHDifR(AcDbPolyline*& pPl) const
{
TComplexCurve cplCurve;
int nNum = 0;
MakeCurvesOfHorDifR2D(cplCurve,nNum);
FormatPolyline(pPl,cplCurve,nNum);
}
void TEImpCabReducer::MakePolyCurveOfNorDifR(AcDbPolyline*& pPl) const
{
TComplexCurve cplCurve;
int nNum = 0;
MakeCurvesOfHorNorDifR2D(cplCurve,nNum);
FormatPolyline(pPl,cplCurve,nNum);
}
void TEImpCabReducer::MakePolyCurveOfOffDifR(AcDbPolyline*& pPl) const
{
TComplexCurve cplCurve;
int nNum = 0;
MakeCurvesOfHorOffDifR2D(cplCurve,nNum);
if (cplCurve.length() < 3)
{
return;
}
AcGePlane plan(cplCurve.at(0).ptGe[0],cplCurve.at(3).ptGe[0],cplCurve.at(3).ptGe[1]);
AcGePoint3d ptOrth = AcGePoint3d::kOrigin.orthoProject(plan);
plan.set(ptOrth,plan.normal());
double dEl = ptOrth.asVector().length();
if (!ptOrth.asVector().isCodirectionalTo(plan.normal()))
{
dEl *= -1.0;
}
for (int i = 0;i < nNum;i++)
{
pPl->addVertexAt(i,cplCurve.at(i).ptGe[0].convert2d(plan));
}
pPl->setClosed(Adesk::kTrue);
pPl->setElevation(dEl);
pPl->setNormal(plan.normal());
}
void TEImpCabReducer::FormatPolyline(AcDbPolyline*& pPl,TComplexCurve& cplCurve,int nNum) const
{
if (cplCurve.length() < 3)
{
return;
}
AcGePlane plan(cplCurve.at(0).ptGe[0],cplCurve.at(1).ptGe[0],cplCurve.at(2).ptGe[0]);
AcGePoint3d ptOrth = AcGePoint3d::kOrigin.orthoProject(plan);
plan.set(ptOrth,plan.normal());
double dEl = ptOrth.asVector().length();
if (!ptOrth.asVector().isCodirectionalTo(plan.normal()))
{
dEl *= -1.0;
}
for (int i = 0;i < nNum;i++)
{
pPl->addVertexAt(i,cplCurve.at(i).ptGe[0].convert2d(plan));
}
pPl->setClosed(Adesk::kTrue);
pPl->setElevation(dEl);
pPl->setNormal(plan.normal());
}
BOOL TEImpCabReducer::GetCurvesInSide(TComplexCurve& compCurve) const
{
if (m_pXDataMap == NULL)
{
return FALSE;
}
AcGePoint3d ptGeS,ptGeE;
m_pXDataMap->GetAt(KEY_START,ptGeS);
m_pXDataMap->GetAt(KEY_END,ptGeE);
AcGeVector3d vtNorm;
m_pXDataMap->GetAt(KEY_NORMAL,vtNorm);
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
int nShowCenLine = 0;
m_pXDataMap->GetAt(KEY_HASCENLINE,nShowCenLine);
if (nShowCenLine)
{
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNorm);
if (line.isPerpendicularTo(AcGePlane::kXYPlane))
{
el.ptGe[0] = ptGeS;
el.ptGe[1] = ptGeE;
el.ptGe[2] = ptGeE;
el.gsMark = -1;
compCurve.append(el);
}
if (compCurve.length() > 0)
{
// 设置中心线宽
double dWidth = 0.0;
m_pXDataMap->GetAt(KEY_CENLWIDTH,dWidth);
if (dWidth > 0)
{
TDb::TCurveElement el;
memset(&el,0,sizeof(TDb::TCurveElement));
for (int j = 0;j < compCurve.length();j++)
{
el = compCurve[j];
el.dWidth = dWidth;
compCurve.setAt(j,el);
}
}
}
}
//显示隔板线
double dWith2 = 0.0;
m_pXDataMap->GetAt(KEY_EDAGEWIDTH, dWith2);
int bShowBorad = 0,bHaveClap = -1;
m_pXDataMap->GetAt(KEY_HAVE_CLAPBOARD,bHaveClap);
m_pXDataMap->GetAt(KEY_SHOW_CLAPBOARD,bShowBorad);
if(bShowBorad == TDb::eShowBoard &&
bHaveClap == TDb::eBoard)
{
double dSubWidth1,dSubWidth2;
m_pXDataMap->GetAt(KEY_B1,dSubWidth1);
m_pXDataMap->GetAt(KEY_B2,dSubWidth2);
AcGeVector3d vtNor;
m_pXDataMap->GetAt(KEY_CLAPBOARD_MAINBR,vtNor);
vtNor.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 dOffset1 = 0.0,dOffset2 = 0.0;
for (int i = 0;i < arDimeS.length();++i)
{
dOffset1 = arDimeS[i];
dOffset2 = arDimeE[i];
el.ptGe[0] = ptGeS - vtNor * (dSubWidth1/2-dOffset1);
el.ptGe[1] = ptGeE - vtNor * (dSubWidth2/2-dOffset2);
el.ptGe[2] = el.ptGe[1];
el.dWidth = dWith2;
el.gsMark = -2;
el.nColorIndex = KEY_CLP_COLORINDEX;
compCurve.append(el);
}
}
return TRUE;
}
BOOL TEImpCabReducer::MakePolyCurveFaces(AcDbVoidPtrArray& arFaces)
{
if (m_pXDataMap != NULL)
{
int nType = 0;
m_pXDataMap->GetAt(KEY_REDUCER,nType);
switch(nType)
{
case TDb::eRbotHorDifR: // 槽式下平异径接头
{
MakePolyCurveFacesOfBHDifR(arFaces);
break;
}
case TDb::eRbotHorNormalDifR: // 槽式下平普通异径接头
{
MakePolyCurveFacesOfNorDifR(arFaces);
break;
}
case TDb::eRbotHorOffsetDifR2:
case TDb::eRbotHorOffsetDifR: // 槽式下平偏移异径接头
{
MakePolyCurveFacesOfOffDifR(arFaces);
break;
}
default:
break;
}
}
return arFaces.length() > 0;
}
void TEImpCabReducer::MakePolyCurveFacesOfBHDifR(AcDbVoidPtrArray& arFaces)
{
if (m_pXDataMap != NULL)
{
AcGeVector3d vtNor;
m_pXDataMap->GetAt(KEY_NORMAL,vtNor);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNor);
if (line.isPerpendicularTo(AcGePlane::kXYPlane)) // Z
{
MakePolyCurveFacesOfBHDifRZNor(arFaces);
}
else
{
MakePolyCurveFacesOfBHDifRNoZNor(arFaces);
}
}
}
void TEImpCabReducer::MakePolyCurveFacesOfBHDifRZNor(AcDbVoidPtrArray& arFaces)
{
/***********************************************************************
0
+
| \ 1 2
| +------+
ptGeS | |ptGeE
| |
| +------+3
| / 4
5 +
***********************************************************************/
TComplexCurve cplCurve;
int nNum = 0;
MakeCurvesOfHorDifR2D(cplCurve,nNum);
if (cplCurve.length() > 0)
{
arFaces.append(CreateAcDbFace(cplCurve.at(0).ptGe[0],cplCurve.at(0).ptGe[1],
cplCurve.at(4).ptGe[0],cplCurve.at(4).ptGe[1]));
arFaces.append(CreateAcDbFace(cplCurve.at(1).ptGe[0],cplCurve.at(1).ptGe[1],
cplCurve.at(3).ptGe[0],cplCurve.at(3).ptGe[1]));
}
}
void TEImpCabReducer::MakePolyCurveFacesOfBHDifRNoZNor(AcDbVoidPtrArray& arFaces)
{
/************************************************************************
0 3
|\ /|
| \ 4 5 / |
| | | |
| | | |
| |6 7 | |
1 +--+--+--+--+2
ptGeS
ptGeE
************************************************************************/
TComplexCurve cplCurve;
int nNum = 0;
MakeCurvesOfHorDifR2D(cplCurve,nNum);
if (cplCurve.length() > 0)
{
arFaces.append(CreateAcDbFace(cplCurve.at(0).ptGe[0],cplCurve.at(0).ptGe[1],
cplCurve.at(4).ptGe[0],cplCurve.at(4).ptGe[1]));
arFaces.append(CreateAcDbFace(cplCurve.at(2).ptGe[0],cplCurve.at(2).ptGe[1],
cplCurve.at(6).ptGe[0],cplCurve.at(6).ptGe[1]));
}
}
void TEImpCabReducer::MakePolyCurveFacesOfNorDifR(AcDbVoidPtrArray& arFaces)
{
if (m_pXDataMap != NULL)
{
AcGeVector3d vtNor;
m_pXDataMap->GetAt(KEY_NORMAL,vtNor);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNor);
if (line.isPerpendicularTo(AcGePlane::kXYPlane)) // Z
{
MakePolyCurveFacesOfNorDifRZNor(arFaces);
}
else
{
MakePolyCurveFacesOfNorDifRNoZNor(arFaces);
}
}
}
void TEImpCabReducer::MakePolyCurveFacesOfNorDifRZNor(AcDbVoidPtrArray& arFaces)
{
/***********************************************************************
0 ptGeS
+
| \
| \1
dWidthL | | dWidthS
ptGeS | /2 ptGeE
| /
3 +
************************************************************************/
TComplexCurve cplCurve;
int nNum = 0;
MakeCurvesOfHorNorDifR2D(cplCurve,nNum);
if (cplCurve.length() > 0)
{
arFaces.append(CreateAcDbFace(cplCurve.at(0).ptGe[0],cplCurve.at(0).ptGe[1],
cplCurve.at(2).ptGe[0],cplCurve.at(2).ptGe[1]));
}
}
void TEImpCabReducer::MakePolyCurveFacesOfNorDifRNoZNor(AcDbVoidPtrArray& arFaces)
{
/************************************************************************
0 3
|\ /|
| \ 4 5 / |
| | | |
| | | |
| |6 7 | |
1 +--+--+--+--+2
ptGeS
ptGeE
************************************************************************/
TComplexCurve cplCurve;
int nNum = 0;
MakeCurvesOfHorNorDifR2D(cplCurve,nNum);
if (cplCurve.length() > 0)
{
arFaces.append(CreateAcDbFace(cplCurve.at(0).ptGe[0],cplCurve.at(0).ptGe[1],
cplCurve.at(4).ptGe[0],cplCurve.at(4).ptGe[1]));
arFaces.append(CreateAcDbFace(cplCurve.at(2).ptGe[0],cplCurve.at(2).ptGe[1],
cplCurve.at(6).ptGe[0],cplCurve.at(6).ptGe[1]));
}
}
void TEImpCabReducer::MakePolyCurveFacesOfOffDifR(AcDbVoidPtrArray& arFaces)
{
if (m_pXDataMap != NULL)
{
AcGeVector3d vtNor;
m_pXDataMap->GetAt(KEY_NORMAL,vtNor);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNor);
if (line.isPerpendicularTo(AcGePlane::kXYPlane)) // Z
{
MakePolyCurveFacesOfOffDifRZNor(arFaces);
}
else
{
MakePolyCurveFacesOfOffDifRNoZNor(arFaces);
}
}
}
void TEImpCabReducer::MakePolyCurveFacesOfOffDifRZNor(AcDbVoidPtrArray& arFaces)
{
/***********************************************************************
0 1 2 3
+--------+--+-----+
| | | | dWidthS
| | | | ptGeE
dWidthL | | +-----+4
ptGeS | | /5
| |/
7 +--------+6
************************************************************************/
TComplexCurve cplCurve;
int nNum = 0;
MakeCurvesOfHorOffDifR2D(cplCurve,nNum);
if (cplCurve.length() > 0)
{
arFaces.append(CreateAcDbFace(cplCurve.at(0).ptGe[0],cplCurve.at(0).ptGe[1],
cplCurve.at(6).ptGe[0],cplCurve.at(6).ptGe[1]));
arFaces.append(CreateAcDbFace(cplCurve.at(1).ptGe[0],cplCurve.at(1).ptGe[1],
cplCurve.at(5).ptGe[0],cplCurve.at(5).ptGe[1]));
arFaces.append(CreateAcDbFace(cplCurve.at(2).ptGe[0],cplCurve.at(2).ptGe[1],
cplCurve.at(4).ptGe[0],cplCurve.at(4).ptGe[1]));
}
}
void TEImpCabReducer::MakePolyCurveFacesOfOffDifRNoZNor(AcDbVoidPtrArray& arFaces)
{
/************************************************************************
0 3
| /|
6 | 4 / |
| | |
| | |
| 5 | |
1 +-----+--+--+ 2
ptGeS
ptGeE
/************************************************************************/
TComplexCurve cplCurve;
int nNum = 0;
MakeCurvesOfHorOffDifR2D(cplCurve,nNum);
if (cplCurve.length() > 0)
{
arFaces.append(CreateAcDbFace(cplCurve.at(2).ptGe[0],cplCurve.at(2).ptGe[1],
cplCurve.at(4).ptGe[0],cplCurve.at(4).ptGe[1]));
}
}
BOOL TEImpCabReducer::EnsureCurViewPortIs3D(const AcGeVector3d& vtNormal) const
{
AcGeVector3d vtViewDir = AcGeVector3d::kZAxis;
struct resbuf rb;
memset (&rb, 0, sizeof (struct resbuf));
acedGetVar(_T("VIEWDIR"), &rb);
vtViewDir.set(rb.resval.rpoint[X], rb.resval.rpoint[Y], rb.resval.rpoint[Z]);
vtViewDir.normalize();
if (vtViewDir.isPerpendicularTo(vtNormal)) // 平行代表3d
{
return TRUE;
}
return FALSE;
}
AcDbFace* TEImpCabReducer::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;
}
Acad::ErrorStatus TEImpCabReducer::getClassID(CLSID* pClsid) const
{
// #if (ADS < 16)
// CLSID CLSID_FittingBaseEntity = {0x1F6683C6,0xD6BF,0x415f,{0x9D,0xF1,0xDB,0xAA,0x8F,0x77,0xC6,0x7C}};
// #endif
//
// #if (ADS == 16)
// CLSID CLSID_FittingBaseEntity = {0x1F6683C6,0xD6BF,0x415f,{0x9D,0xF1,0xDB,0xAA,0x8F,0x77,0xC6,0x7D}};
// #endif
//
// #if (ADS == 17)
// CLSID CLSID_FittingBaseEntity = {0x1F6683C6,0xD6BF,0x415f,{0x9D,0xF1,0xDB,0xAA,0x8F,0x77,0xC6,0x7E}};
// #endif
//
// #if (ADS == 18)
// CLSID CLSID_FittingBaseEntity = {0x1F6683C6,0xD6BF,0x415f,{0x9D,0xF1,0xDB,0xAA,0x8F,0x77,0xC6,0x7F}};
// #endif
//
// #if (ADS == 19)
// CLSID CLSID_FittingBaseEntity = {0x1F6683C6,0xD6BF,0x415f,{0x9D,0xF1,0xDB,0xAA,0x8F,0x77,0xC6,0x7F}};
// #endif
return Acad::eOk;
}
CString TEImpCabReducer::GetCurrentTypeName() const
{
CString strName = _T("");
if (m_pXDataMap != NULL)
{
int nType = -1;
int nStyle = 0;
m_pXDataMap->GetAt(KEY_STYLE,nStyle);
m_pXDataMap->GetAt(KEY_REDUCER,nType);
switch(nType)
{
case TDb::eRbotHorDifR: // 槽式下平异径接头
{
strName = (_T("槽式下平异径接头"));
break;
}
case TDb::eRbotHorNormalDifR: // 槽式下平普通异径接头
{
strName = (_T("槽式下平普通异径接头"));
break;
}
case TDb::eRbotHorOffsetDifR2: // 槽式下平偏移(右)异径接头
{
strName = (_T("槽式下平右偏移异径接头"));
break;
}
case TDb::eRbotHorOffsetDifR: // 槽式下平偏移(左)异径接头
{
strName = (_T("槽式下平左偏移异径接头"));
break;
}
default:
break;
}
switch(nStyle)
{
case TDb::eP:
{
strName.Replace(_T("槽式"),_T("盘式"));
break;
}
case TDb::eT:
{
strName.Replace(_T("槽式"),_T("梯式"));
break;
}
default:
break;
}
}
return strName;
}
void TEImpCabReducer::list() const
{
if (m_pXDataMap != NULL)
{
int nType = -1;
double dL = 0.0,dB1 = 0.0,dB2 = 0.0;
double dH1 = 0.0,dH2 = 0.0;
CString strType = _T("");
m_pXDataMap->GetAt(KEY_TYPE,strType);
m_pXDataMap->GetAt(KEY_B1,dB1);
m_pXDataMap->GetAt(KEY_B2,dB2);
m_pXDataMap->GetAt(KEY_H1,dH1);
m_pXDataMap->GetAt(KEY_H2,dH2);
m_pXDataMap->GetAt(KEY_L,dL);
acutPrintf(_T("\n\t\t\t\t\t\t\t\t%s\n"),GetCurrentTypeName());
acutPrintf(_T("\n\t\t\t\t\t型号: %s"),strType);
acutPrintf(_T("\n\t\t\t\t\t长度: %.0f"),dL);
acutPrintf(_T("\n\t\t\t\t\t宽度1: %.0f"),dB1);
acutPrintf(_T("\n\t\t\t\t\t宽度2: %.0f"),dH2);
acutPrintf(_T("\n\t\t\t\t\t高度1: %.0f"),dH1);
acutPrintf(_T("\n\t\t\t\t\t高度2: %.0f\n"),dH2);
}
}
void TEImpCabReducer::GetTips(CMapStringToString& mapLable2Tip) const
{
if (m_pXDataMap != NULL)
{
double dH1 = 0.0,dH2 = 0.0,dB1 = 0.0,dB2 = 0.0;
AcGePoint3d ptS;
CString strTemp = _T("");
m_pXDataMap->GetAt(KEY_START,ptS);
m_pXDataMap->GetAt(KEY_H1,dH1);
m_pXDataMap->GetAt(KEY_H2,dH2);
m_pXDataMap->GetAt(KEY_B1,dB1);
m_pXDataMap->GetAt(KEY_B2,dB2);
m_pXDataMap->GetAt(KEY_TYPE,strTemp);
mapLable2Tip.SetAt(_T("对象类型"), GetCurrentTypeName());
mapLable2Tip.SetAt(_T("型号"), strTemp);
strTemp.Format(_T("%d"),(int)ptS.z);
mapLable2Tip.SetAt(_T("中心标高"), strTemp);
strTemp.Format(_T("%d"),(int)dB1);
mapLable2Tip.SetAt(_T("宽度1"), strTemp);
strTemp.Format(_T("%d"),(int)dB2);
mapLable2Tip.SetAt(_T("宽度2"), strTemp);
strTemp.Format(_T("%d"),(int)dH1);
mapLable2Tip.SetAt(_T("高度1"), strTemp);
strTemp.Format(_T("%d"),(int)dH2);
mapLable2Tip.SetAt(_T("高度2"), strTemp);
}
}
//获取三维的壳对象
int TEImpCabReducer::GetXBaseShell(TXShell& xShell)
{
int nRet = 0;
if (m_pXDataMap != NULL)
{
int nType = 0;
if (m_pXDataMap->GetAt(KEY_REDUCER,nType))
{
switch(nType)
{
case TDb::eRbotHorDifR:
{
}
break;
case TDb::eRbotHorNormalDifR:
{
nRet = GetXBaseShellNorDifR(xShell);
}
break;
case TDb::eRbotHorOffsetDifR2:
case TDb::eRbotHorOffsetDifR:
{
nRet = GetXBaseShellOffDifR(xShell);
}
break;
default:
break;
}
}
}
return nRet;
}
//获取体的范围方块
int TEImpCabReducer::GetBodyBox(AcDbExtents& ext)
{
int nRet = 0;
if (m_pXDataMap != NULL)
{
int nType = 0;
if (m_pXDataMap->GetAt(KEY_REDUCER,nType))
{
switch(nType)
{
case TDb::eRbotHorDifR:
{
}
break;
case TDb::eRbotHorNormalDifR:
{
nRet = GetBodyBoxNorDifR(ext);
}
break;
case TDb::eRbotHorOffsetDifR2:
case TDb::eRbotHorOffsetDifR:
{
nRet = GetBodyBoxOffDifR(ext);
}
break;
default:
break;
}
}
}
return nRet;
}
//通过点得到最大范围
int TEImpCabReducer::GetBoxExtendByPts(const AcGePoint3dArray &arPts,AcDbExtents& ext)
{
if (arPts.length() > 0)
{
std::vector<double> vecX;
std::vector<double> vecY;
std::vector<double> vecZ;
for (int i = 0; i < arPts.length(); ++i)
{
vecX.push_back(arPts[i].x);
vecY.push_back(arPts[i].y);
vecZ.push_back(arPts[i].z);
}
AcGePoint3d ptLow,ptUp;
ptLow.x = *(std::min_element(vecX.begin(),vecX.end()));
ptLow.y = *(std::min_element(vecY.begin(),vecY.end()));
ptLow.z = *(std::min_element(vecZ.begin(),vecZ.end()));
ptUp.x = *(std::max_element(vecX.begin(),vecX.end()));
ptUp.y = *(std::max_element(vecY.begin(),vecY.end()));
ptUp.z = *(std::max_element(vecZ.begin(),vecZ.end()));
ext.set(ptLow,ptUp);
}
return 0;
}
//获取外壳
int TEImpCabReducer::GetXBaseShellNorDifR(TXShell& xShell)
{
int nRet = 0;
if (m_pXDataMap == NULL) return 0;
int nCover = 0;
AcGeVector3d vtNormal,vtDir;
AcGePoint3d ptGeS,ptGeE;
double dHeight = 0.0,dHeight2 = 0.0;// dHeight2 长高度
double dWidth = 0.0,dWidth2 = 0.0;
if (m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_B1,dWidth) &&
m_pXDataMap->GetAt(KEY_B2,dWidth2) &&
m_pXDataMap->GetAt(KEY_H1,dHeight) &&
m_pXDataMap->GetAt(KEY_H2,dHeight2) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) &&
m_pXDataMap->GetAt(KEY_COVER,nCover) &&
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) )
{
double dAngle = PI / 2.0;
Adesk::UInt32 nRows = 0;
Adesk::UInt32 nColums = 0;
AcGePoint3d* lstVertex = NULL;
nRows = 5;
nColums = 2;
AcGeVector3d vtH = vtDir;
AcGeVector3d vtV = vtH;
vtV.rotateBy(dAngle,vtNormal);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtH = ptGeE - ptGeS;
vtV = vtDir;
vtNormal = vtDir;
vtNormal.rotateBy(dAngle, vtH);
vtNormal.normalize();
}
vtV.normalize();
vtH.normalize();
lstVertex = new AcGePoint3d[nRows * nColums];
if (lstVertex == NULL) return 0;
AcGePoint3d ptTemp;
ptTemp = ptGeS + vtV * (dWidth / 2.0);
lstVertex[2] = ptTemp;
lstVertex[0] = ptTemp + vtNormal * dHeight;
ptTemp = ptGeS - vtV * (dWidth / 2.0);
lstVertex[4] = ptTemp;
lstVertex[6] = ptTemp + vtNormal * dHeight;
ptTemp = ptGeE + vtV * (dWidth2 / 2.0);
lstVertex[3] = ptTemp;
lstVertex[1] = ptTemp + vtNormal * dHeight2;
ptTemp = ptGeE - vtV * (dWidth2 / 2.0);
lstVertex[5] = ptTemp;
lstVertex[7] = ptTemp + vtNormal * dHeight2;
xShell.AppendFace(new AcDbFace(lstVertex[2],lstVertex[0],lstVertex[6],lstVertex[4]));
xShell.AppendFace(new AcDbFace(lstVertex[2],lstVertex[0],lstVertex[1],lstVertex[3]));
xShell.AppendFace(new AcDbFace(lstVertex[3],lstVertex[1],lstVertex[7],lstVertex[5]));
xShell.AppendFace(new AcDbFace(lstVertex[4],lstVertex[6],lstVertex[7],lstVertex[5]));
xShell.AppendFace(new AcDbFace(lstVertex[2],lstVertex[4],lstVertex[5],lstVertex[3]));
xShell.AppendFace(new AcDbFace(lstVertex[0],lstVertex[6],lstVertex[7],lstVertex[1]));
delete []lstVertex;
nRet = 1;
}
return nRet;
}
int TEImpCabReducer::GetXBaseShellOffDifR(TXShell& xShell)
{
int nRet = 0;
if (m_pXDataMap == NULL) return 0;
int nCover = 0;
AcGePoint3d ptGeS,ptGeE;
AcGeVector3d vtNormal;
double dLen = 0.0;
double dWidth = 0.0,dWidth2 = 0.0;
double dHeight = 0.0,dHeight2 = 0.0;// 长高度
if (m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_L,dLen) &&
m_pXDataMap->GetAt(KEY_B1,dWidth) &&
m_pXDataMap->GetAt(KEY_B2,dWidth2) &&
m_pXDataMap->GetAt(KEY_H1,dHeight) &&
m_pXDataMap->GetAt(KEY_H2,dHeight2) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) &&
m_pXDataMap->GetAt(KEY_COVER,nCover) )
{
double dLen1 = dLen / 3.0;
double dLen2 = dLen1;
double dAngle = PI / 2.0;
Adesk::UInt32 nRows = 0;
Adesk::UInt32 nColums = 0;
AcGePoint3d* lstVertex = NULL;
AcGeVector3d vtRed,vtOff;
if (m_pXDataMap->GetAt(KEY_MAINDIR,vtRed) &&
m_pXDataMap->GetAt(KEY_BRDIR,vtOff) )
{
nRows = 5;
vtRed.normalize();
vtOff.normalize();
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtNormal = vtOff;
vtNormal.rotateBy(dAngle,vtRed);
vtNormal.normalize();
}
nColums = 4;
lstVertex = new AcGePoint3d[nRows * nColums];
if (lstVertex == NULL) return FALSE;
AcGePoint3d ptTemp;
ptTemp = ptGeS - vtOff * (dWidth / 2.0);
lstVertex[4] = ptTemp;
lstVertex[0] = ptTemp + vtNormal * dHeight;
lstVertex[5] = ptTemp + vtRed * dLen1;
lstVertex[1] = lstVertex[5] + vtNormal * dHeight;
ptTemp = ptGeS + vtOff * (dWidth / 2.0);
lstVertex[8] = ptTemp;
lstVertex[12] = ptTemp + vtNormal * dHeight;
lstVertex[9] = ptTemp + vtRed * dLen1;
lstVertex[13] = lstVertex[9] + vtNormal * dHeight;
ptTemp = ptGeE - vtOff * (dWidth2 / 2.0);
lstVertex[7] = ptTemp;
lstVertex[3] = ptTemp + vtNormal * dHeight2;
lstVertex[6] = ptTemp - vtRed * dLen2;
lstVertex[10] = lstVertex[6] + vtOff * dWidth2;
lstVertex[2] = lstVertex[3] - vtRed * dLen2;
ptTemp = ptGeE + vtOff * (dWidth2 / 2.0);
lstVertex[11] = ptTemp;
lstVertex[15] = ptTemp + vtNormal * dHeight2;
lstVertex[14] = lstVertex[15] - vtRed * dLen2;
lstVertex[16] = lstVertex[0];
lstVertex[17] = lstVertex[1];
lstVertex[18] = lstVertex[2];
lstVertex[19] = lstVertex[3];
xShell.AppendFace(new AcDbFace(lstVertex[0],lstVertex[1],lstVertex[5],lstVertex[4]));
xShell.AppendFace(new AcDbFace(lstVertex[1],lstVertex[2],lstVertex[6],lstVertex[5]));
xShell.AppendFace(new AcDbFace(lstVertex[2],lstVertex[3],lstVertex[7],lstVertex[6]));
xShell.AppendFace(new AcDbFace(lstVertex[4],lstVertex[5],lstVertex[9],lstVertex[8]));
xShell.AppendFace(new AcDbFace(lstVertex[5],lstVertex[6],lstVertex[10],lstVertex[9]));
xShell.AppendFace(new AcDbFace(lstVertex[6],lstVertex[7],lstVertex[11],lstVertex[10]));
xShell.AppendFace(new AcDbFace(lstVertex[8],lstVertex[9],lstVertex[13],lstVertex[12]));
xShell.AppendFace(new AcDbFace(lstVertex[9],lstVertex[10],lstVertex[14],lstVertex[13]));
xShell.AppendFace(new AcDbFace(lstVertex[10],lstVertex[11],lstVertex[15],lstVertex[14]));
xShell.AppendFace(new AcDbFace(lstVertex[12],lstVertex[13],lstVertex[17],lstVertex[16]));
xShell.AppendFace(new AcDbFace(lstVertex[13],lstVertex[14],lstVertex[18],lstVertex[17]));
xShell.AppendFace(new AcDbFace(lstVertex[14],lstVertex[15],lstVertex[19],lstVertex[18]));
xShell.AppendFace(new AcDbFace(lstVertex[0],lstVertex[4],lstVertex[8],lstVertex[12]));
xShell.AppendFace(new AcDbFace(lstVertex[3],lstVertex[7],lstVertex[11],lstVertex[15]));
delete []lstVertex;
nRet = 1;
}
}
return nRet;
}
//获取体的范围方块
int TEImpCabReducer::GetBodyBoxNorDifR(AcDbExtents& ext)
{
int nRet = 0;
if (m_pXDataMap == NULL) return 0;
int nCover = 0;
AcGeVector3d vtNormal,vtDir;
AcGePoint3d ptGeS,ptGeE;
double dHeight = 0.0,dHeight2 = 0.0;// dHeight2 长高度
double dWidth = 0.0,dWidth2 = 0.0;
if (m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_B1,dWidth) &&
m_pXDataMap->GetAt(KEY_B2,dWidth2) &&
m_pXDataMap->GetAt(KEY_H1,dHeight) &&
m_pXDataMap->GetAt(KEY_H2,dHeight2) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) &&
m_pXDataMap->GetAt(KEY_COVER,nCover) &&
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir) )
{
double dAngle = PI / 2.0;
Adesk::UInt32 nRows = 0;
Adesk::UInt32 nColums = 0;
AcGePoint3d* lstVertex = NULL;
nRows = 5;
nColums = 2;
AcGeVector3d vtH = vtDir;
AcGeVector3d vtV = vtH;
vtV.rotateBy(dAngle,vtNormal);
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtH = ptGeE - ptGeS;
vtV = vtDir;
vtNormal = vtDir;
vtNormal.rotateBy(dAngle, vtH);
vtNormal.normalize();
}
vtV.normalize();
vtH.normalize();
lstVertex = new AcGePoint3d[nRows * nColums];
if (lstVertex == NULL) return 0;
AcGePoint3d ptTemp;
ptTemp = ptGeS + vtV * (dWidth / 2.0);
lstVertex[2] = ptTemp;
lstVertex[0] = ptTemp + vtNormal * dHeight;
ptTemp = ptGeS - vtV * (dWidth / 2.0);
lstVertex[4] = ptTemp;
lstVertex[6] = ptTemp + vtNormal * dHeight;
ptTemp = ptGeE + vtV * (dWidth2 / 2.0);
lstVertex[3] = ptTemp;
lstVertex[1] = ptTemp + vtNormal * dHeight2;
ptTemp = ptGeE - vtV * (dWidth2 / 2.0);
lstVertex[5] = ptTemp;
lstVertex[7] = ptTemp + vtNormal * dHeight2;
AcGePoint3dArray arPts;
for (int i = 0; i < 8; ++i)
{
arPts.append(lstVertex[i]);
}
GetBoxExtendByPts(arPts,ext);
delete []lstVertex;
nRet = 1;
}
return nRet;
}
int TEImpCabReducer::GetBodyBoxOffDifR(AcDbExtents& ext)
{
int nRet = 0;
if (m_pXDataMap == NULL)return 0;
int nCover = 0;
AcGePoint3d ptGeS,ptGeE;
AcGeVector3d vtNormal;
double dLen = 0.0;
double dWidth = 0.0,dWidth2 = 0.0;
double dHeight = 0.0,dHeight2 = 0.0;// 长高度
if (m_pXDataMap->GetAt(KEY_START,ptGeS) &&
m_pXDataMap->GetAt(KEY_END,ptGeE) &&
m_pXDataMap->GetAt(KEY_L,dLen) &&
m_pXDataMap->GetAt(KEY_B1,dWidth) &&
m_pXDataMap->GetAt(KEY_B2,dWidth2) &&
m_pXDataMap->GetAt(KEY_H1,dHeight) &&
m_pXDataMap->GetAt(KEY_H2,dHeight2) &&
m_pXDataMap->GetAt(KEY_NORMAL,vtNormal) &&
m_pXDataMap->GetAt(KEY_COVER,nCover) )
{
double dLen1 = dLen / 3.0;
double dLen2 = dLen1;
double dAngle = PI / 2.0;
Adesk::UInt32 nRows = 0;
Adesk::UInt32 nColums = 0;
AcGePoint3d* lstVertex = NULL;
AcGeVector3d vtRed,vtOff;
if (m_pXDataMap->GetAt(KEY_MAINDIR,vtRed) &&
m_pXDataMap->GetAt(KEY_BRDIR,vtOff) )
{
nRows = 5;
vtRed.normalize();
vtOff.normalize();
AcGeLine3d line;
line.set(AcGePoint3d::kOrigin,vtNormal);
if (AcGePlane::kXYPlane.isParallelTo(line))
{
vtNormal = vtOff;
vtNormal.rotateBy(dAngle,vtRed);
vtNormal.normalize();
}
nColums = 4;
lstVertex = new AcGePoint3d[nRows * nColums];
if (lstVertex == NULL) return FALSE;
AcGePoint3d ptTemp;
ptTemp = ptGeS - vtOff * (dWidth / 2.0);
lstVertex[4] = ptTemp;
lstVertex[0] = ptTemp + vtNormal * dHeight;
lstVertex[5] = ptTemp + vtRed * dLen1;
lstVertex[1] = lstVertex[5] + vtNormal * dHeight;
ptTemp = ptGeS + vtOff * (dWidth / 2.0);
lstVertex[8] = ptTemp;
lstVertex[12] = ptTemp + vtNormal * dHeight;
lstVertex[9] = ptTemp + vtRed * dLen1;
lstVertex[13] = lstVertex[9] + vtNormal * dHeight;
ptTemp = ptGeE - vtOff * (dWidth2 / 2.0);
lstVertex[7] = ptTemp;
lstVertex[3] = ptTemp + vtNormal * dHeight2;
lstVertex[6] = ptTemp - vtRed * dLen2;
lstVertex[10] = lstVertex[6] + vtOff * dWidth2;
lstVertex[2] = lstVertex[3] - vtRed * dLen2;
ptTemp = ptGeE + vtOff * (dWidth2 / 2.0);
lstVertex[11] = ptTemp;
lstVertex[15] = ptTemp + vtNormal * dHeight2;
lstVertex[14] = lstVertex[15] - vtRed * dLen2;
AcGePoint3dArray arPts;
for (int i = 0; i < 16; ++i)
{
arPts.append(lstVertex[i]);
}
GetBoxExtendByPts(arPts,ext);
delete []lstVertex;
nRet = 1;
}
}
return nRet;
}
CString TEImpCabReducer::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::eReduce);
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_REDUCER,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("变径样式"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("1:槽式下平异径接头.."));
m_pXDataMap->GetAt(KEY_REDUCER,nValue);
csText.Format(_T("%d"),nValue);
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_L,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("长度"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("长度"));
m_pXDataMap->GetAt(KEY_L,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_B1,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("宽度1"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("宽度1"));
m_pXDataMap->GetAt(KEY_B1,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_H1,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("高度1"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("高度1"));
m_pXDataMap->GetAt(KEY_H1,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_B2,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("宽度2"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("宽度2"));
m_pXDataMap->GetAt(KEY_B2,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_H2,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("高度2"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("高度2"));
m_pXDataMap->GetAt(KEY_H2,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_MAINDIR,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("主分支向量"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("主分支向量"));
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
TAuxTools::DoubleToString(vtDir.x,nPtPreci,csX);
TAuxTools::DoubleToString(vtDir.y,nPtPreci,csY);
TAuxTools::DoubleToString(vtDir.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_BRDIR,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("分向量"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("分支向量"));
m_pXDataMap->GetAt(KEY_BRDIR,vtDir);
TAuxTools::DoubleToString(vtDir.x,nPtPreci,csX);
TAuxTools::DoubleToString(vtDir.y,nPtPreci,csY);
TAuxTools::DoubleToString(vtDir.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_NORMAL,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("法相量"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("法相量"));
m_pXDataMap->GetAt(KEY_NORMAL,vtDir);
TAuxTools::DoubleToString(vtDir.x,nPtPreci,csX);
TAuxTools::DoubleToString(vtDir.y,nPtPreci,csY);
TAuxTools::DoubleToString(vtDir.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_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_MAJBR,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板向量"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("隔板偏移向量"));
m_pXDataMap->GetAt(KEY_MAJBR,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(KEY_COVER,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("盖板"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("0:不显示,1:显示"));
m_pXDataMap->GetAt(KEY_COVER,nValue);
csText.Format(_T("%d"),nValue);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(_T("Object_ID"),posRoot,NULL);
{
xmlTree.SetAttribute(nowPos,_T("name"),_T("ID"));
xmlTree.SetAttribute(nowPos,_T("comment"),_T("桥架ID"));
LONG_PTR nid = m_pOwnerEnt->objectId().asOldId();
csText.Format(_T("%ld"),nid);
xmlTree.SetItemText(nowPos,csText);
}
CString csXml = xmlTree.GetXml();
return csXml;
}
CString TEImpCabReducer::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::eReduce);
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_REDUCER,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("变径样式"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("1:槽式下平异径接头.."));
m_pXDataMap->GetAt(KEY_REDUCER,nValue);
csText.Format(_T("%d"),nValue);
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_L,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("长度"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("长度"));
m_pXDataMap->GetAt(KEY_L,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_B1,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("宽度1"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("宽度1"));
m_pXDataMap->GetAt(KEY_B1,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_H1,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("高度1"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("高度1"));
m_pXDataMap->GetAt(KEY_H1,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_B2,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("宽度2"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("宽度2"));
m_pXDataMap->GetAt(KEY_B2,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_H2,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("高度2"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("高度2"));
m_pXDataMap->GetAt(KEY_H2,dValue);
TAuxTools::DoubleToString(dValue,nSizePreci,csText);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_MAINDIR,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("主分支向量"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("主分支向量"));
m_pXDataMap->GetAt(KEY_MAINDIR,vtDir);
vtDir.transformBy(mat);
TAuxTools::DoubleToString(vtDir.x,nPtPreci,csX);
TAuxTools::DoubleToString(vtDir.y,nPtPreci,csY);
TAuxTools::DoubleToString(vtDir.z,nPtPreci,csZ);
csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(KEY_BRDIR,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("分向量"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("分支向量"));
m_pXDataMap->GetAt(KEY_BRDIR,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_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);
}
int nHaveClapBoard = -1;
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,nHaveClapBoard);
csText.Format(_T("%d"),nHaveClapBoard);
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);
}
//axc add 2013-11-28
if (TDb::eShowBoard == nValue && TDb::eBoard == nHaveClapBoard)
{
vtDir.set(0,0,0);
nowPos = xmlTree.Insert(KEY_CLAPBOARD_MAINBR,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板向量1"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("隔板偏移向量1"));
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_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(KEY_MAJBR,posRoot,NULL);
//{
// vtDir.set(0,0,0);
// xmlTree.SetAttribute(nowPos, _T("name"), _T("隔板向量"));
// xmlTree.SetAttribute(nowPos, _T("comment"), _T("隔板偏移向量"));
// m_pXDataMap->GetAt(KEY_MAJBR,vtDir);
// vtDir.transformBy(mat);
// TAuxTools::DoubleToString(vtDir.x,nPtPreci,csX);
// TAuxTools::DoubleToString(vtDir.y,nPtPreci,csY);
// TAuxTools::DoubleToString(vtDir.z,nPtPreci,csZ);
// csText.Format(_T("%s,%s,%s"),csX,csY,csZ);
// xmlTree.SetItemText(nowPos,csText);
//}
nowPos = xmlTree.Insert(KEY_COVER,posRoot,NULL);
{
xmlTree.SetAttribute(nowPos, _T("name"), _T("盖板"));
xmlTree.SetAttribute(nowPos, _T("comment"), _T("0:不显示,1:显示"));
m_pXDataMap->GetAt(KEY_COVER,nValue);
csText.Format(_T("%d"),nValue);
xmlTree.SetItemText(nowPos,csText);
}
nowPos = xmlTree.Insert(_T("Object_ID"),posRoot,NULL);
{
xmlTree.SetAttribute(nowPos,_T("name"),_T("ID"));
xmlTree.SetAttribute(nowPos,_T("comment"),_T("桥架ID"));
LONG_PTR nid = m_pOwnerEnt->objectId().asOldId();
csText.Format(_T("%ld"),nid);
xmlTree.SetItemText(nowPos,csText);
}
CString csXml = xmlTree.GetXml();
return csXml;
}
bool TEImpCabReducer::GetSection(const AcDbFace &face, const AcGeVector3d &vtPlaneSecDir,
std::vector<TObjSectionRecord> &sectionRecord, AcDbVoidPtrArray& arFillPtrs) const
{
if (NULL == m_pOwnerEnt || NULL == m_pXDataMap)
return false;
// 基本参数
AcDbObjectId idObj = m_pOwnerEnt->objectId();
AcDbObjectId idLayer = m_pOwnerEnt->layerId();
TGGeSectionPlane section_pln(face, vtPlaneSecDir); // 构造一个辅助剖面
AcDbVoidPtrArray arFaces;
XExplodeStream dc(arFaces);
ExplodeOrDraw3d(dc);
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 TEImpCabReducer::GetExtents(TADSGePoint3d &ptLow, TADSGePoint3d &ptUp) const
{
AcGePoint3d ptS,ptE;
double dHight = 0.0;
AcGeVector3d vtNor;
m_pXDataMap->GetAt(KEY_START,ptS);
m_pXDataMap->GetAt(KEY_END,ptE);
m_pXDataMap->GetAt(KEY_H,dHight);
ptLow = ptS;
ptUp = ptE;
ptUp.z += dHight;
return Acad::eOk;
}