5558 lines
136 KiB
C++
5558 lines
136 KiB
C++
#include "StdAfx.h"
|
||
#include "AcGiExplodeDraw.h"
|
||
#include "AecISODrawMake.h"
|
||
#include "KTModelLayoutXData.h"
|
||
#include "AecDbEwPipeDim.h"
|
||
#include "WPipeDimConfigDlg.h"
|
||
#include "AecDbEwPipe.h"
|
||
#include "AecDbEwfitting.h"
|
||
#include "AecDbHvacFitting.h"
|
||
#include "AecDbHvacDuct.h"
|
||
#include "AecDbEwequipment.h"
|
||
#include "AecDbPipeHanger.h"
|
||
#include "KTSetting.h"
|
||
#include "KTCadUtility.h"
|
||
#include "PipelineTools.h"
|
||
#include "AecDbECableTray.h"
|
||
#include "AecDbEcFitting.h"
|
||
#include "dbtable.h"
|
||
#include "coretools.h"
|
||
|
||
#pragma region brep-include
|
||
#include "acutads.h"
|
||
#include "acedads.h"
|
||
#include "string.h"
|
||
#include "adscodes.h"
|
||
#include "brent.h"
|
||
#include "brbrep.h"
|
||
#include "dbmain.h"
|
||
#include "geextc3d.h"
|
||
#include "brface.h"
|
||
#include "brvtx.h"
|
||
#include "dbents.h"
|
||
#include "geassign.h"
|
||
#include "geextc2d.h"
|
||
#include "gexbndsf.h"
|
||
#include "aced.h"
|
||
#include "acestext.h"
|
||
#include "actrans.h"
|
||
#include "adeskabb.h"
|
||
#include "brbctrav.h"
|
||
#include "brbvtrav.h"
|
||
#include "bredge.h"
|
||
#include "brfltrav.h"
|
||
#include "brgbl.h"
|
||
#include "brletrav.h"
|
||
#include "brlvtrav.h"
|
||
#include "dbsol3d.h"
|
||
#include "dbsymtb.h"
|
||
#include "gelnsg3d.h"
|
||
#include "gemat3d.h"
|
||
#include "genurb3d.h"
|
||
#include "genurbsf.h"
|
||
#include "geray3d.h"
|
||
#include "ol_errno.h"
|
||
#include "adesk.h"
|
||
#include "adslib.h"
|
||
#include "brbetrav.h"
|
||
#include "brbftrav.h"
|
||
#include "brbstrav.h"
|
||
#include "brcstrav.h"
|
||
#include "brelem2d.h"
|
||
#include "breltrav.h"
|
||
#include "brentrav.h"
|
||
#include "brhit.h"
|
||
#include "brloop.h"
|
||
#include "brmetrav.h"
|
||
#include "brprops.h"
|
||
#pragma endregion
|
||
|
||
|
||
extern AcGePoint3d MidPoint(const AcGePoint3d& pt1, const AcGePoint3d& pt2);
|
||
static const Adesk::UInt16 kColorByLayer = 256;
|
||
AecISODrawMake::AecISODrawMake(void)
|
||
{
|
||
m_dArrowL = 1.0;
|
||
m_dArrowW = 0.33;
|
||
m_dScale = 50.0;
|
||
m_dDimoffset = 10.0;
|
||
//西南默认
|
||
m_xform.Set(AcGePoint3d::kOrigin,PI / 6.0);
|
||
m_dISOAngle = PI / 6.0;
|
||
m_bDimTxtIso = TRUE;
|
||
m_bDimPipeEl = FALSE;
|
||
m_dRefEl = 0.0;
|
||
m_bWasDone = FALSE;
|
||
m_dTxtH = 2.0;
|
||
m_dGastGap = 5;
|
||
m_idDimSty = CKTCadUtility::InitTextStyle(PipelineTools::gTextStyle_Pipe_Dim);
|
||
m_idDimlay = KTSetting::InitLayer(PipelineTools::gLayer_Pipe_Dim);
|
||
m_nDimIndex = 0;
|
||
m_planeLookDir.set(AcGePoint3d::kOrigin, AcGeVector3d(-1,-1,1));
|
||
m_bODxtDim = FALSE;
|
||
m_bFitFGHide = FALSE;
|
||
m_bElStyle = FALSE;
|
||
KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, m_xInitDataMap);
|
||
|
||
CString sDocScale = "";
|
||
m_xInitDataMap.GetAt(_T("Scale"), sDocScale);
|
||
int nIndex = sDocScale.Find(':', 0);
|
||
if (nIndex != -1)
|
||
{
|
||
m_dScale = _ttof(sDocScale.Mid(nIndex + 1)) / _ttof(sDocScale.Mid(0, nIndex));
|
||
}
|
||
|
||
m_dWFact = 0.7;
|
||
m_xInitDataMap.GetAt(DOC_DIMTXTF, m_dWFact);
|
||
}
|
||
|
||
AecISODrawMake::AecISODrawMake(int nType,double dAngle, BOOL b45NoIso)
|
||
{
|
||
AcGeVector3d vtNorm;
|
||
m_nDimIndex = 0;
|
||
switch(nType)
|
||
{
|
||
case 0: //西南 30,120
|
||
{
|
||
m_dISOAngle = dAngle;//PI / 6.0;
|
||
m_xform.Set(AcGePoint3d::kOrigin,m_dISOAngle,nType,b45NoIso);
|
||
|
||
vtNorm.set(-1, -1, 1);
|
||
m_planeLookDir.set(AcGePoint3d::kOrigin, vtNorm);
|
||
break;
|
||
}
|
||
case 1://东南 -30,30
|
||
{
|
||
m_dISOAngle = dAngle;//PI / 6.0;
|
||
m_xform.Set(AcGePoint3d::kOrigin,-m_dISOAngle,nType,b45NoIso);
|
||
|
||
vtNorm.set(1, -1, 1);
|
||
m_planeLookDir.set(AcGePoint3d::kOrigin, vtNorm);
|
||
|
||
break;
|
||
}
|
||
case 2://东北 -150,-30
|
||
{
|
||
m_dISOAngle = dAngle - PI;//-5.0 * PI / 6.0;
|
||
m_xform.Set(AcGePoint3d::kOrigin,m_dISOAngle,nType,b45NoIso);
|
||
|
||
vtNorm.set(1, 1, 1);
|
||
m_planeLookDir.set(AcGePoint3d::kOrigin, vtNorm);
|
||
|
||
break;
|
||
}
|
||
case 3://西北 150,-150
|
||
{
|
||
m_dISOAngle = PI - dAngle;//5.0 * PI / 6.0;
|
||
m_xform.Set(AcGePoint3d::kOrigin,m_dISOAngle,nType,b45NoIso);
|
||
|
||
vtNorm.set(-1, 1, 1);
|
||
m_planeLookDir.set(AcGePoint3d::kOrigin, vtNorm);
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
|
||
m_dDimoffset = 10.0;
|
||
m_dArrowL = 1.0;
|
||
m_dArrowW = 0.33;
|
||
m_dScale = 50.0;
|
||
m_bDimTxtIso = TRUE;
|
||
m_bDimPipeEl = FALSE;
|
||
m_dRefEl = 0.0;
|
||
m_dTxtH = 2.0;
|
||
m_dGastGap = 5;
|
||
m_bFitFGHide = FALSE;
|
||
m_bWasDone = FALSE;
|
||
m_bElStyle = FALSE;
|
||
m_idDimSty = CKTCadUtility::InitTextStyle(PipelineTools::gTextStyle_Pipe_Dim);
|
||
m_idDimlay = KTSetting::InitLayer(PipelineTools::gLayer_Pipe_Dim);
|
||
KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, m_xInitDataMap);
|
||
|
||
CString sDocScale = "";
|
||
m_xInitDataMap.GetAt(_T("Scale"), sDocScale);
|
||
int nIndex = sDocScale.Find(':', 0);
|
||
if (nIndex != -1)
|
||
{
|
||
m_dScale = _ttof(sDocScale.Mid(nIndex + 1)) / _ttof(sDocScale.Mid(0, nIndex));
|
||
}
|
||
m_dWFact = 0.7;
|
||
m_xInitDataMap.GetAt(DOC_DIMTXTF, m_dWFact);
|
||
}
|
||
|
||
AecISODrawMake::AecISODrawMake(double dAngle)
|
||
{
|
||
m_xform.Set(AcGePoint3d::kOrigin,dAngle);
|
||
m_dISOAngle = dAngle;
|
||
m_dDimoffset = 10.0;
|
||
m_dArrowL = 1.0;
|
||
m_dArrowW = 0.33;
|
||
m_dScale = 50.0;
|
||
m_bDimTxtIso = TRUE;
|
||
m_bDimPipeEl = FALSE;
|
||
m_dRefEl = 0.0;
|
||
m_nDimIndex = 0;
|
||
m_dTxtH = 2.0;
|
||
m_dGastGap = 5;
|
||
m_bWasDone = FALSE;
|
||
m_bFitFGHide = FALSE;
|
||
m_bElStyle = FALSE;
|
||
m_idDimSty = CKTCadUtility::InitTextStyle(PipelineTools::gTextStyle_Pipe_Dim);
|
||
m_idDimlay = KTSetting::InitLayer(PipelineTools::gLayer_Pipe_Dim);
|
||
|
||
m_planeLookDir.set(AcGePoint3d::kOrigin, AcGeVector3d(-1, -1, 1));
|
||
KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, m_xInitDataMap);
|
||
|
||
CString sDocScale = "";
|
||
m_xInitDataMap.GetAt(_T("Scale"), sDocScale);
|
||
int nIndex = sDocScale.Find(':', 0);
|
||
if (nIndex != -1)
|
||
{
|
||
m_dScale = _ttof(sDocScale.Mid(nIndex + 1)) / _ttof(sDocScale.Mid(0, nIndex));
|
||
}
|
||
m_dWFact = 0.7;
|
||
m_xInitDataMap.GetAt(DOC_DIMTXTF, m_dWFact);
|
||
}
|
||
|
||
AecISODrawMake::~AecISODrawMake(void)
|
||
{
|
||
}
|
||
|
||
typedef struct PIPElDimEd
|
||
{
|
||
AcGePoint3d ptPos;
|
||
AcGeVector3d vtDir;
|
||
}PIPELDIMED;
|
||
|
||
static bool PipElDimed(std::vector<PIPElDimEd>& pipeldimed, AcGePoint3d& ptPos, AcGeVector3d& vtDir)
|
||
{
|
||
AcGeLine3d ln3d(ptPos,vtDir);
|
||
|
||
for (int i = 0;i < pipeldimed.size();i++)
|
||
{
|
||
PIPElDimEd &pipeldim = pipeldimed.at(i);
|
||
AcGeLine3d ln3d2(pipeldim.ptPos, pipeldim.vtDir);
|
||
if ( ln3d.isColinearTo(ln3d2) )
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
PIPElDimEd pipeldm;
|
||
pipeldm.ptPos = ptPos;
|
||
pipeldm.vtDir = vtDir;
|
||
pipeldimed.push_back(pipeldm);
|
||
return false;
|
||
}
|
||
|
||
void AecISODrawMake::MakeISOPipeline(AcDbObjectIdArray& arPipeIds,double dPlotPipeW,int nPipeDim,int nPipeDim2,int bDNDim,BOOL bDimTxtIso,BOOL bVlvISOV)
|
||
{
|
||
AcGePoint3d ptGe[6],ptPos;
|
||
AcDbObjectId idCen,id;
|
||
AcGeVector3d vtV;
|
||
AecInterface inf0,inf1;
|
||
AcDbEntity* pEnt = NULL;
|
||
TCHAR szHD[33];
|
||
double dGask = 0.0, dLen = 0;
|
||
AcDbPolyline *pPl = NULL;
|
||
AcDbVoidPtrArray arPipePls;
|
||
int nConnectType = 0;//焊接0 承插1 螺纹2 法兰管3
|
||
std::vector<PIPElDimEd> pipeldimed;
|
||
std::vector<PIPElDimEd> pipeodimed;
|
||
|
||
for (int i = 0;i < arPipeIds.length();i++)
|
||
{
|
||
id = arPipeIds.at(i);
|
||
id.handle().getIntoAsciiBuffer(szHD);
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id,AcDb::kForRead))
|
||
{
|
||
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
AecDbObjXDataMap* pXDataMap = pPipe->GetSpecialtyData(AcDb::kForRead);
|
||
|
||
int nColor = kColorByLayer;
|
||
if (pXDataMap != NULL && pXDataMap->GetAt(_T("COLOR"),nColor) )
|
||
{
|
||
//临时
|
||
pXDataMap->SetAt(_T("HD"), szHD);
|
||
}
|
||
|
||
dGask = pPipe->GetGasketThick();
|
||
pPipe->GetInterface(0, inf0);
|
||
pPipe->GetInterface(1, inf1);
|
||
inf0.vtDir.normalize(); inf1.vtDir.normalize();
|
||
|
||
if (dGask > 1.e-3)
|
||
{
|
||
inf0.ptPos -= inf0.vtDir * 0.5 * m_dGastGap * m_dScale;
|
||
inf1.ptPos -= inf1.vtDir * 0.5 * m_dGastGap * m_dScale;;
|
||
}
|
||
else
|
||
{
|
||
nConnectType = 0;//焊接0 承插1 螺纹2 法兰管3
|
||
pXDataMap->GetAt(PIPE_CONNECT, nConnectType);
|
||
if (nConnectType == 3 || nConnectType == 4)
|
||
{
|
||
inf0.ptPos -= inf0.vtDir * 0.5 * m_dGastGap * m_dScale;
|
||
inf1.ptPos -= inf1.vtDir * 0.5 * m_dGastGap * m_dScale;;
|
||
}
|
||
}
|
||
|
||
pPl = MakePoly(inf0.ptPos, inf1.ptPos,pPipe->layerId(),dPlotPipeW * m_dScale,nColor,pXDataMap);
|
||
arPipePls.append(pPl);
|
||
|
||
if (nPipeDim > 0)
|
||
{
|
||
//长度尺寸标注
|
||
dLen = pPipe->GetLength();
|
||
MakeDim(inf0.ptPos, inf1.ptPos,dLen);
|
||
}
|
||
|
||
if (nPipeDim2 > 0)
|
||
{
|
||
//市政标注方法
|
||
MakeDim2(pXDataMap, inf0.ptPos, inf1.ptPos,pPipe->layer(),dPlotPipeW * m_dScale);
|
||
}
|
||
|
||
if (bDNDim > 0 || m_bODxtDim > 0)
|
||
{
|
||
if (!PipElDimed(pipeodimed, inf0.ptPos, inf0.vtDir))
|
||
{
|
||
MakeDim3(pXDataMap, inf0.ptPos, inf1.ptPos,pPipe->layer(),dPlotPipeW * m_dScale,bDimTxtIso);
|
||
}
|
||
}
|
||
|
||
//水平管的标高标注
|
||
|
||
AcGeLine3d ln(inf0.ptPos, inf0.vtDir);
|
||
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
||
{
|
||
if (!PipElDimed(pipeldimed,inf0.ptPos, inf0.vtDir))
|
||
{
|
||
MakeDim4(inf0.ptPos, inf0.vtDir, m_dRefEl, pPipe->layerId());
|
||
}
|
||
}
|
||
|
||
int nConnectType = 0;//焊接0 承插1 螺纹2 法兰管3
|
||
pXDataMap->GetAt(PIPE_CONNECT, nConnectType);
|
||
|
||
if ( nConnectType == 3)
|
||
{
|
||
ptGe[0] = inf0.ptPos;
|
||
ptGe[1] = inf1.ptPos;
|
||
AcGeVector3d vtDir = ptGe[1] - ptGe[0];
|
||
|
||
vtV = vtDir;
|
||
if (vtDir.isParallelTo(AcGeVector3d::kZAxis))
|
||
{
|
||
if (fabs(m_dISOAngle - PI / 4.0) < 1.e-6)
|
||
vtV = AcGeVector3d::kYAxis;//45度为 y
|
||
else
|
||
vtV = AcGeVector3d::kXAxis;//45度为 y
|
||
}
|
||
else
|
||
{
|
||
AcGeLine3d ln(ptGe[0], vtDir);
|
||
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
||
{
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vtV = vtDir.perpVector();
|
||
}
|
||
}
|
||
vtV.normalize();
|
||
|
||
if (bVlvISOV && vtDir.isPerpendicularTo(AcGeVector3d::kZAxis))
|
||
{
|
||
vtV = AcGeVector3d::kZAxis;
|
||
}
|
||
|
||
double dWD = 0.0;
|
||
pXDataMap->GetAt(PIPE_INTERFACED, dWD);
|
||
|
||
//标注法兰
|
||
double dDN = 0.0, dPress = 0.0;
|
||
pXDataMap->GetAt(PIPE_DN, dDN);
|
||
pXDataMap->GetAt(PID_PIPE_DPRESS, dPress);
|
||
|
||
//三者其一
|
||
CString sStd, sEndF, sDimtext, sLevel, sMater, sRem, sSpec;
|
||
pXDataMap->GetAt(PIPE_STDNO, sStd);
|
||
pXDataMap->GetAt(PIPE_FLANGF, sEndF);
|
||
pXDataMap->GetAt(PIPE_FLANGF1, sEndF);
|
||
pXDataMap->GetAt(PIPE_FLANGF2, sEndF);
|
||
|
||
pXDataMap->GetAt(PIPE_LEVEL, sLevel);
|
||
pXDataMap->GetAt(PIPE_STDNO, sStd);
|
||
pXDataMap->GetAt(PIPE_MATERIALFT, sMater);
|
||
pXDataMap->GetAt(PID_PIPE_DPRESS, dPress);
|
||
pXDataMap->GetAt(PIPE_MATERIALFT, sMater);
|
||
pXDataMap->GetAt(PIPE_DESCR, sRem);
|
||
|
||
//法兰 DN100-PN1.6 RF GB/T9116.1-2000
|
||
sDimtext.Format(_T("法兰 DN%d-PN%.1f %s %s"), (int)(dDN + 0.5), dPress, sEndF, sStd);
|
||
sSpec.Format(_T("DN%d-PN%.1f"), (int)(dDN + 0.5), dPress);
|
||
|
||
int nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
|
||
ptGe[0] += vtV * 0.5 * dWD;
|
||
ptGe[2] = ptGe[0] - vtV * dWD;
|
||
|
||
ptPos = MidPoint(ptGe[0], ptGe[2]);
|
||
|
||
if (!m_bFitFGHide)
|
||
MakePoly(ptGe[0], ptGe[2], pPipe->layerId(), dPlotPipeW * m_dScale, nColor, pXDataMap);
|
||
|
||
DimIndex(nIndex, ptPos, vtV, id);
|
||
|
||
ptGe[1] += vtV * 0.5 * dWD;
|
||
ptGe[3] = ptGe[1] - vtV * dWD;
|
||
|
||
ptPos = MidPoint(ptGe[1], ptGe[3]);
|
||
|
||
if (!m_bFitFGHide)
|
||
MakePoly(ptGe[1], ptGe[3], pPipe->layerId(), dPlotPipeW * m_dScale, nColor, pXDataMap);
|
||
|
||
DimIndex(nIndex, ptPos, vtV, id);
|
||
}
|
||
}
|
||
|
||
AecDbHvacDuct* pDuct = AecDbHvacDuct::cast(pEnt);
|
||
if (pDuct != NULL)
|
||
{
|
||
AecDbObjXDataMap* pXDataMap = pDuct->GetSpecialtyData(AcDb::kForRead);
|
||
|
||
int nColor = kColorByLayer;
|
||
if (pXDataMap != NULL && pXDataMap->GetAt(_T("COLOR"),nColor) )
|
||
{
|
||
//临时
|
||
pXDataMap->SetAt(_T("HD"), szHD);
|
||
}
|
||
pPl = MakePoly(pDuct->StartPoint(),pDuct->EndPoint(),pDuct->GetSingleLayer(),dPlotPipeW * m_dScale,nColor,pXDataMap);
|
||
arPipePls.append(pPl);
|
||
|
||
if (nPipeDim > 0)
|
||
{
|
||
//尺寸标注
|
||
double dLen, dEndP;
|
||
pDuct->getEndParam(dEndP);
|
||
pDuct->getDistAtParam(dEndP, dLen);
|
||
MakeDim(pDuct->StartPoint(),pDuct->EndPoint(),dLen);
|
||
}
|
||
|
||
if (nPipeDim2 > 0)
|
||
{
|
||
//暖通wxh
|
||
MakeHDim2(pXDataMap,pDuct->StartPoint(),pDuct->EndPoint(),pDuct->layer(),dPlotPipeW * m_dScale);
|
||
}
|
||
|
||
if (bDNDim > 0 || m_bODxtDim > 0)
|
||
{
|
||
MakeHDim3(pXDataMap, pDuct->StartPoint(), pDuct->EndPoint(),pDuct->layer(), dPlotPipeW *m_dScale);
|
||
}
|
||
|
||
//水平管的标高标注
|
||
pDuct->GetInterface(0, inf0);
|
||
AcGeLine3d ln(inf0.ptPos, inf0.vtDir);
|
||
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
||
{
|
||
MakeDim4(inf0.ptPos, inf0.vtDir, m_dRefEl, pDuct->layerId());
|
||
}
|
||
}
|
||
|
||
AecDbECableTray *pTray = AecDbECableTray::cast(pEnt);
|
||
if (pTray != NULL)
|
||
{
|
||
AecDbObjXDataMap *pXDataMap = pTray->GetSpecialtyData(AcDb::kForRead);
|
||
|
||
int nColor = kColorByLayer;
|
||
if (pXDataMap != NULL && pXDataMap->GetAt(_T("COLOR"), nColor))
|
||
{
|
||
//临时
|
||
pXDataMap->SetAt(_T("HD"), szHD);
|
||
}
|
||
pPl = MakePoly(pTray->StartPoint(), pTray->EndPoint(), pTray->GetSingleLayer(), dPlotPipeW * m_dScale, nColor, pXDataMap);
|
||
arPipePls.append(pPl);
|
||
|
||
if (nPipeDim > 0)
|
||
{
|
||
//尺寸标注
|
||
double dLen, dEndP;
|
||
pTray->getEndParam(dEndP);
|
||
pTray->getDistAtParam(dEndP, dLen);
|
||
MakeDim(pTray->StartPoint(), pTray->EndPoint(), dLen);
|
||
}
|
||
|
||
if (nPipeDim2 > 0)
|
||
{
|
||
//桥架wxh
|
||
MakeEDim2(pXDataMap, pTray->StartPoint(), pTray->EndPoint(), pTray->layer(), dPlotPipeW * m_dScale);
|
||
}
|
||
|
||
if (bDNDim > 0 || m_bODxtDim > 0)
|
||
{
|
||
MakeEDim3(pXDataMap, pTray->StartPoint(), pTray->EndPoint(), pTray->layer(), dPlotPipeW * m_dScale);
|
||
}
|
||
|
||
//水平管的标高标注
|
||
pTray->GetInterface(0, inf0);
|
||
AcGeLine3d ln(inf0.ptPos, inf0.vtDir);
|
||
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
||
{
|
||
MakeDim4(inf0.ptPos, inf0.vtDir, m_dRefEl, pTray->layerId());
|
||
}
|
||
}
|
||
|
||
pEnt->close();
|
||
}
|
||
}
|
||
|
||
//遮挡
|
||
LookatandBreak();
|
||
}
|
||
|
||
void AecISODrawMake::MakeISOAxis(AcDbObjectIdArray& arAxis)
|
||
{
|
||
AcDbObjectId id;
|
||
AcDbEntity *pEnt = NULL;
|
||
|
||
for (int i = 0;i < arAxis.length();i++)
|
||
{
|
||
id = arAxis.at(i);
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
|
||
{
|
||
AcDbLine *pLn = AcDbLine::cast(pEnt);
|
||
if (pLn != NULL)
|
||
{
|
||
AcGePoint3d pt1(pLn->startPoint()), pt2(pLn->endPoint());
|
||
MakeLine(pt1, pt2, pLn->layerId());
|
||
}
|
||
|
||
AcDbBlockReference *pRef = AcDbBlockReference::cast(pEnt);
|
||
if (pRef != NULL)
|
||
{
|
||
MakeRef(pRef);
|
||
}
|
||
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::GetPtIsoTransform(AcGePoint3d &pt)
|
||
{
|
||
m_xform.GetTransformByThis(pt);
|
||
}
|
||
|
||
AcDbPolyline * AecISODrawMake::MakePoly(AcGePoint3d ptSta,AcGePoint3d ptEnd,const AcDbObjectId& idLay,double dPlotPipeW,int nCr/* = 256*/,AecDbObjXDataMap* pXDataMap)
|
||
{
|
||
double dEl = (ptSta.z + ptEnd.z) / 2.0 - m_dRefEl;
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
AcDbPolyline* pPoly = new AcDbPolyline;
|
||
pPoly->addVertexAt(0,ptSta.convert2d(AcGePlane::kXYPlane));
|
||
pPoly->addVertexAt(1,ptEnd.convert2d(AcGePlane::kXYPlane));
|
||
pPoly->setConstantWidth(dPlotPipeW);
|
||
pPoly->setLayer(idLay);
|
||
pPoly->setLinetype(KTSetting::InitLineStyle(_T("Continuous")));
|
||
pPoly->setColorIndex(nCr);
|
||
pPoly->setNormal(AcGeVector3d::kZAxis);
|
||
|
||
if (pXDataMap != NULL)
|
||
{
|
||
pXDataMap->SetAt(PIPE_EL,dEl);
|
||
pXDataMap->Write(pPoly,BIMDATA_APP);
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
|
||
ptSta.z = ptSta.z = 0.0;
|
||
AcGeLineSeg3d ln3d(ptSta,ptEnd);
|
||
AcGePoint3d ptS, ptE, ptInt;
|
||
AcDbEntity *pEnt = NULL;
|
||
IntsctWith intsct;
|
||
AcGeVector3d vtLn3d = ptEnd - ptSta;
|
||
AcGeVector3d vtThat;
|
||
|
||
for (int i = 0;i < m_arISOEntPtrs.length();i++)
|
||
{
|
||
pEnt = (AcDbEntity *)m_arISOEntPtrs.at(i);
|
||
|
||
AcDbPolyline *pPl = AcDbPolyline::cast(pEnt);
|
||
if (pPl != NULL)
|
||
{
|
||
if (xDataMap.Read(pPl, BIMDATA_APP))
|
||
{
|
||
pPl->getStartPoint(ptS);
|
||
pPl->getEndPoint(ptE);
|
||
vtThat = ptE - ptS;
|
||
if (vtLn3d.isParallelTo(vtThat))
|
||
continue;
|
||
|
||
ptS.z = ptE.z = 0.0;
|
||
AcGeLineSeg3d ln3d2(ptS,ptE);
|
||
|
||
if (ln3d.intersectWith(ln3d2, ptInt))
|
||
{
|
||
if (ptInt.distanceTo(ptS) > 5.0 &&
|
||
ptInt.distanceTo(ptE) > 5.0 &&
|
||
ptInt.distanceTo(ptSta) > 5.0 &&
|
||
ptInt.distanceTo(ptEnd) > 5.0)
|
||
{
|
||
//记录交点和 id1,id2
|
||
intsct.pPl1 = pPoly;
|
||
intsct.pPl2 = pPl;
|
||
intsct.ptInt = ptInt;
|
||
|
||
m_arIntsctWith.append(intsct);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
AddISOEnt(pPoly);
|
||
|
||
return pPoly;
|
||
}
|
||
|
||
AcDbLine *AecISODrawMake::MakeLine(AcGePoint3d &ptSta, AcGePoint3d &ptEnd, const AcDbObjectId &idLay)
|
||
{
|
||
double dEl = (ptSta.z + ptEnd.z) / 2.0 - m_dRefEl;
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
AcDbLine *pLn = new AcDbLine(ptSta, ptEnd);
|
||
pLn->setLayer(idLay);
|
||
|
||
AddISOEnt(pLn);
|
||
return pLn;
|
||
}
|
||
|
||
void AecISODrawMake::MakeRef(AcDbBlockReference* pRef)
|
||
{
|
||
AcGePoint3d pt2 = pRef->position();
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(pt2);
|
||
}
|
||
AcGeVector3d vt = pt2 - pRef->position();
|
||
AcGeMatrix3d xm;
|
||
xm.setToTranslation(vt);
|
||
|
||
AcDbBlockReference *pRefCln = (AcDbBlockReference *)pRef->clone();
|
||
pRefCln->transformBy(xm);
|
||
|
||
AddISOEnt(pRefCln);
|
||
}
|
||
|
||
bool AecISODrawMake::GetProjSrcPointAtParam(LPCTSTR sHd1, double dPa1, AcGePoint3d& pt1)
|
||
{
|
||
bool bGetOk = false;
|
||
AcDbHandle hd(sHd1);
|
||
|
||
AcDbObjectId id;
|
||
if (Acad::eOk == acdbCurDwg()->getAcDbObjectId(id, false, hd))
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
|
||
{
|
||
AecDbEwPipeBase *pPipe = AecDbEwPipeBase::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
AcDbLine ln(pPipe->StartPoint(), pPipe->EndPoint());
|
||
|
||
if (Acad::eOk == ln.getPointAtParam(dPa1, pt1))
|
||
bGetOk = true;
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
return bGetOk;
|
||
}
|
||
|
||
static void BreakPolyline(AcDbPolyline* pPly, const AcGePoint3d& pt2, double dBreak, AcDbPolyline*& pPly1, AcDbPolyline*& pPly2)
|
||
{
|
||
AcGePoint3d ptS, ptE,ptS1,ptE1;
|
||
pPly->getStartPoint(ptS);
|
||
pPly->getEndPoint(ptE);
|
||
|
||
AcGeVector3d vt = ptE - ptS;
|
||
vt.normalize();
|
||
vt *= 0.5 * dBreak;
|
||
|
||
ptE1 = pt2 - vt;
|
||
ptS1 = pt2 + vt;
|
||
|
||
double dPlotPipeW = 0.0;
|
||
pPly->getConstantWidth(dPlotPipeW);
|
||
|
||
pPly1 = new AcDbPolyline;
|
||
pPly1->addVertexAt(0, ptS.convert2d(AcGePlane::kXYPlane));
|
||
pPly1->addVertexAt(1, ptE1.convert2d(AcGePlane::kXYPlane));
|
||
pPly1->setConstantWidth(dPlotPipeW);
|
||
pPly1->setLayer(pPly->layerId());
|
||
pPly1->setLinetype(pPly->linetypeId());
|
||
pPly1->setColorIndex(pPly->colorIndex());
|
||
pPly1->setNormal(AcGeVector3d::kZAxis);
|
||
|
||
AecDbObjXDataMap xData1;
|
||
if (xData1.Read(pPly, BIMDATA_APP))
|
||
{
|
||
xData1.Write(pPly1, BIMDATA_APP);
|
||
}
|
||
|
||
pPly2 = new AcDbPolyline;
|
||
pPly2->addVertexAt(0, ptS1.convert2d(AcGePlane::kXYPlane));
|
||
pPly2->addVertexAt(1, ptE.convert2d(AcGePlane::kXYPlane));
|
||
pPly2->setConstantWidth(dPlotPipeW);
|
||
pPly2->setLayer(pPly->layerId());
|
||
pPly2->setLinetype(pPly->linetypeId());
|
||
pPly2->setColorIndex(pPly->colorIndex());
|
||
pPly2->setNormal(AcGeVector3d::kZAxis);
|
||
xData1.Write(pPly2, BIMDATA_APP);
|
||
}
|
||
|
||
static void AddPolyBreak(AcDbPolyline* pPoly,const AcGePoint3d& ptInt, AcArray< PolyBreaks > &arPolyBreaks)
|
||
{
|
||
bool bFind = false;
|
||
|
||
for (int i = 0; i < arPolyBreaks.length();i++)
|
||
{
|
||
PolyBreaks &plbks1 = arPolyBreaks.at(i);
|
||
|
||
if (plbks1.pPoly == pPoly)
|
||
{
|
||
plbks1.arBreaks.append(ptInt);
|
||
bFind = true;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (!bFind)
|
||
{
|
||
PolyBreaks plbrks;
|
||
plbrks.pPoly = pPoly;
|
||
plbrks.arBreaks.append(ptInt);
|
||
arPolyBreaks.append(plbrks);
|
||
}
|
||
}
|
||
|
||
extern void SortPoints(AcGePoint3dArray &points, AcDbCurve *pLine);
|
||
void AecISODrawMake::DoPolyBreak(PolyBreaks &plBrks, double dBreak)
|
||
{
|
||
AcGePoint3d ptS, ptE;
|
||
plBrks.pPoly->getStartPoint(ptS);
|
||
plBrks.pPoly->getEndPoint(ptE);
|
||
|
||
AecDbObjXDataMap xData;
|
||
xData.Read(plBrks.pPoly, BIMDATA_APP);
|
||
|
||
double dCnW = 0.0;
|
||
plBrks.pPoly->getConstantWidth(dCnW);
|
||
dBreak += dCnW;
|
||
|
||
AcDbLine ln(ptS, ptE);
|
||
SortPoints(plBrks.arBreaks, &ln);
|
||
|
||
plBrks.arBreaks.insertAt(0, ptS);
|
||
plBrks.arBreaks.append(ptE);
|
||
|
||
AcDbPolyline *pPly2 = NULL;
|
||
|
||
AcGeVector3d vt;
|
||
for (int i = 0;i < plBrks.arBreaks.length() - 1;i++)
|
||
{
|
||
ptS = plBrks.arBreaks.at(i);
|
||
ptE = plBrks.arBreaks.at(i + 1);
|
||
|
||
vt = ptE - ptS;
|
||
vt.normalize();
|
||
|
||
if (i == 0)
|
||
{
|
||
ptE -= vt * 0.5 * dBreak;
|
||
|
||
pPly2 = new AcDbPolyline;
|
||
pPly2->addVertexAt(0, ptS.convert2d(AcGePlane::kXYPlane));
|
||
pPly2->addVertexAt(1, ptE.convert2d(AcGePlane::kXYPlane));
|
||
pPly2->setConstantWidth(dCnW);
|
||
pPly2->setLayer(plBrks.pPoly->layerId());
|
||
pPly2->setLinetype(plBrks.pPoly->linetypeId());
|
||
pPly2->setColorIndex(plBrks.pPoly->colorIndex());
|
||
pPly2->setNormal(AcGeVector3d::kZAxis);
|
||
xData.Write(pPly2, BIMDATA_APP);
|
||
|
||
AddISOEnt(pPly2);
|
||
}
|
||
else if (i == plBrks.arBreaks.length() - 2)
|
||
{
|
||
ptS += vt * 0.5 * dBreak;
|
||
|
||
pPly2 = new AcDbPolyline;
|
||
pPly2->addVertexAt(0, ptS.convert2d(AcGePlane::kXYPlane));
|
||
pPly2->addVertexAt(1, ptE.convert2d(AcGePlane::kXYPlane));
|
||
pPly2->setConstantWidth(dCnW);
|
||
pPly2->setLayer(plBrks.pPoly->layerId());
|
||
pPly2->setLinetype(plBrks.pPoly->linetypeId());
|
||
pPly2->setColorIndex(plBrks.pPoly->colorIndex());
|
||
pPly2->setNormal(AcGeVector3d::kZAxis);
|
||
xData.Write(pPly2, BIMDATA_APP);
|
||
|
||
AddISOEnt(pPly2);
|
||
}
|
||
else
|
||
{
|
||
ptS += vt * 0.5 * dBreak;
|
||
|
||
pPly2 = new AcDbPolyline;
|
||
pPly2->addVertexAt(0, ptS.convert2d(AcGePlane::kXYPlane));
|
||
pPly2->addVertexAt(1, ptE.convert2d(AcGePlane::kXYPlane));
|
||
pPly2->setConstantWidth(dCnW);
|
||
pPly2->setLayer(plBrks.pPoly->layerId());
|
||
pPly2->setLinetype(plBrks.pPoly->linetypeId());
|
||
pPly2->setColorIndex(plBrks.pPoly->colorIndex());
|
||
pPly2->setNormal(AcGeVector3d::kZAxis);
|
||
xData.Write(pPly2, BIMDATA_APP);
|
||
|
||
AddISOEnt(pPly2);
|
||
}
|
||
}
|
||
}
|
||
|
||
bool AecISODrawMake::LookatandBreak()
|
||
{
|
||
#ifdef _DEBUG
|
||
acutPrintf(_T("\nIntsctWith count=%d"), m_arIntsctWith.length());
|
||
#endif
|
||
|
||
AcArray< PolyBreaks > arPolyBreaks;
|
||
|
||
double dBreak = 2.0;
|
||
m_xInitDataMap.GetAt(DOC_BREAKSPACE, dBreak);
|
||
dBreak *= m_dScale;
|
||
|
||
AecDbObjXDataMap xData1;
|
||
AecDbObjXDataMap xData2;
|
||
|
||
AcGeVector3d vtDir;
|
||
AcGeVector3d vtLook = m_planeLookDir.normal();
|
||
|
||
CString sHd1, sHd2;
|
||
AcDbLine ln1, ln2;
|
||
AcGePoint3d ptS, ptE,pt1,pt2;
|
||
double dPa1 = 0, dPa2 = 0;
|
||
|
||
for (int i = 0; i < m_arIntsctWith.length(); i++)
|
||
{
|
||
IntsctWith &ints = m_arIntsctWith.at(i);
|
||
|
||
xData1.Read(ints.pPl1, BIMDATA_APP);
|
||
xData2.Read(ints.pPl2, BIMDATA_APP);
|
||
|
||
xData1.GetAt(_T("HD"), sHd1);
|
||
xData2.GetAt(_T("HD"), sHd2);
|
||
|
||
ints.pPl1->getStartPoint(ptS);
|
||
ints.pPl1->getEndPoint(ptE);
|
||
ln1.setStartPoint(ptS);
|
||
ln1.setEndPoint(ptE);
|
||
|
||
ints.pPl2->getStartPoint(ptS);
|
||
ints.pPl2->getEndPoint(ptE);
|
||
ln2.setStartPoint(ptS);
|
||
ln2.setEndPoint(ptE);
|
||
|
||
ln1.getParamAtPoint(ints.ptInt, dPa1);
|
||
ln2.getParamAtPoint(ints.ptInt, dPa2);
|
||
|
||
//获取交点 来自 三维方向的管道位置点 pt1,pt2 投影
|
||
if (GetProjSrcPointAtParam(sHd1, dPa1, pt1) &&
|
||
GetProjSrcPointAtParam(sHd2, dPa2, pt2))
|
||
{
|
||
vtDir = pt1 - pt2;
|
||
if (vtDir.dotProduct(vtLook) > 1.e-10)
|
||
{
|
||
//ints.pPl1 打断 ints.pPl2
|
||
AddPolyBreak(ints.pPl2, ints.ptInt, arPolyBreaks);
|
||
}
|
||
else
|
||
{
|
||
//ints.pPl2 打断 ints.pPl1
|
||
AddPolyBreak(ints.pPl1, ints.ptInt, arPolyBreaks);
|
||
}
|
||
}
|
||
}
|
||
|
||
for (int i = 0;i < arPolyBreaks.length();i++)
|
||
{
|
||
PolyBreaks &plBrks = arPolyBreaks.at(i);
|
||
|
||
for (int k = 0;k < m_arISOEntPtrs.length();k++)
|
||
{
|
||
if (plBrks.pPoly == m_arISOEntPtrs.at(k))
|
||
{
|
||
m_arISOEntPtrs.removeAt(k);
|
||
break;
|
||
}
|
||
}
|
||
DoPolyBreak(plBrks, dBreak);
|
||
|
||
if (!plBrks.arNewPolys.isEmpty())
|
||
{
|
||
m_arISOEntPtrs.append(plBrks.arNewPolys);
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
void AecISODrawMake::MakeDim(AcGePoint3d ptSta,AcGePoint3d ptEnd,double dLen)
|
||
{
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
AcGePoint3d ptTemp;
|
||
AcGeVector3d vt = ptEnd - ptSta;
|
||
vt.normalize();
|
||
|
||
//Z向的变换不标注尺寸
|
||
if (vt.isParallelTo(AcGeVector3d::kYAxis))
|
||
return;
|
||
|
||
if ( fabs(m_dISOAngle - PI / 4.0) < 1.e-6)
|
||
{
|
||
vt.rotateBy(m_dISOAngle,AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vt.rotateBy(PI - 2 * m_dISOAngle,AcGeVector3d::kZAxis);
|
||
}
|
||
vt *= m_dDimoffset * m_dScale;
|
||
|
||
AcGePoint3d ptSta1 = ptSta;
|
||
AcGePoint3d ptEnd1 = ptEnd;
|
||
|
||
ptSta += vt;
|
||
ptEnd += vt;
|
||
|
||
vt = ptEnd - ptSta;
|
||
vt.normalize();
|
||
|
||
CPoint pt;
|
||
pt.x = m_arISOEntPtrs.length();
|
||
|
||
//标注线<----->
|
||
AcDbPolyline* pPl = new AcDbPolyline;
|
||
pPl->addVertexAt(0,ptSta.convert2d(AcGePlane::kXYPlane),0,0,m_dArrowW * m_dScale);
|
||
ptTemp = ptSta + m_dArrowL * m_dScale * vt;
|
||
pPl->addVertexAt(1,ptTemp.convert2d(AcGePlane::kXYPlane),0,0,0);
|
||
ptTemp = ptEnd - m_dArrowL * m_dScale * vt;
|
||
pPl->addVertexAt(2,ptTemp.convert2d(AcGePlane::kXYPlane),0,m_dArrowW * m_dScale,0);
|
||
pPl->addVertexAt(3,ptEnd.convert2d(AcGePlane::kXYPlane),0,0,0);
|
||
pPl->setLayer(m_idDimlay);
|
||
|
||
int nFr = AddISOEnt(pPl);
|
||
|
||
AcGePoint3d ptTemp2;
|
||
//标注端线
|
||
if ( fabs(m_dISOAngle - PI / 4.0) < 1.e-6)
|
||
{
|
||
if (vt.isParallelTo(AcGeVector3d::kYAxis))
|
||
{
|
||
vt.rotateBy(-m_dISOAngle,AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vt.rotateBy(m_dISOAngle,AcGeVector3d::kZAxis);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
vt.rotateBy(PI - 2 * m_dISOAngle,AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
vt.normalize();
|
||
vt *= m_dArrowL * m_dScale; //端线的一半=箭头长
|
||
|
||
ptTemp = ptSta + vt;
|
||
ptTemp2 = ptSta1;// ptSta - vt;
|
||
|
||
AcDbLine* pLine = new AcDbLine(ptTemp,ptTemp2);
|
||
pLine->setLayer(m_idDimlay);
|
||
AddISOEnt(pLine);
|
||
|
||
ptTemp = ptEnd + vt;
|
||
ptTemp2 = ptEnd1;// ptEnd - vt;
|
||
pLine = new AcDbLine(ptTemp,ptTemp2);
|
||
pLine->setLayer(m_idDimlay);
|
||
AddISOEnt(pLine);
|
||
|
||
CString sText;
|
||
sText.Format(_T("%d"),(int)(dLen + 0.5)); //四舍五入
|
||
|
||
AcDbText* pText = MakeDimText(ptSta,ptEnd,m_dTxtH,m_idDimSty,sText);
|
||
AddISOEnt(pText);
|
||
|
||
pt.y = m_arISOEntPtrs.length() - 1;
|
||
if (pt.y > pt.x)
|
||
{
|
||
m_arGrpIdx.Add(pt);
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeDim(AcGePoint3d ptSta, AcGePoint3d ptEnd, AcGePoint3d ptTxt, CString &sDimTxt, bool bDimTxtIso)
|
||
{
|
||
AcGePoint3d ptTemp;
|
||
AcGeVector3d vt = ptEnd - ptSta;
|
||
vt.normalize();
|
||
|
||
if (fabs(m_dISOAngle - PI / 4.0) < 1.e-6)
|
||
{
|
||
vt.rotateBy(m_dISOAngle, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vt.rotateBy(PI - 2 * m_dISOAngle, AcGeVector3d::kZAxis);
|
||
}
|
||
vt *= m_dDimoffset * m_dScale;
|
||
|
||
AcDbLine ln(ptSta, ptEnd);
|
||
AcGePoint3d ptTxt1;
|
||
ln.getClosestPointTo(ptTxt, vt, ptTxt1,Adesk::kTrue);
|
||
|
||
vt = ptTxt - ptTxt1;
|
||
ptSta += vt;
|
||
ptEnd += vt;
|
||
|
||
vt = ptEnd - ptSta;
|
||
vt.normalize();
|
||
|
||
CPoint pt;
|
||
pt.x = m_arISOEntPtrs.length();
|
||
|
||
//标注线<----->
|
||
AcDbPolyline *pPl = new AcDbPolyline;
|
||
pPl->addVertexAt(0, ptSta.convert2d(AcGePlane::kXYPlane), 0, 0, m_dArrowW * m_dScale);
|
||
ptTemp = ptSta + m_dArrowL * m_dScale * vt;
|
||
pPl->addVertexAt(1, ptTemp.convert2d(AcGePlane::kXYPlane), 0, 0, 0);
|
||
ptTemp = ptEnd - m_dArrowL * m_dScale * vt;
|
||
pPl->addVertexAt(2, ptTemp.convert2d(AcGePlane::kXYPlane), 0, m_dArrowW * m_dScale, 0);
|
||
pPl->addVertexAt(3, ptEnd.convert2d(AcGePlane::kXYPlane), 0, 0, 0);
|
||
pPl->setLayer(m_idDimlay);
|
||
|
||
int nFr = AddISOEnt(pPl);
|
||
|
||
AcGePoint3d ptTemp2;
|
||
//标注端线
|
||
if (fabs(m_dISOAngle - PI / 4.0) < 1.e-6)
|
||
{
|
||
if (vt.isParallelTo(AcGeVector3d::kYAxis))
|
||
{
|
||
vt.rotateBy(-m_dISOAngle, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vt.rotateBy(m_dISOAngle, AcGeVector3d::kZAxis);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
vt.rotateBy(PI - 2 * m_dISOAngle, AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
vt.normalize();
|
||
vt *= m_dArrowL * m_dScale; //端线的一半=箭头长
|
||
|
||
ptTemp = ptSta + vt;
|
||
ptTemp2 = ptSta - vt;
|
||
|
||
AcDbLine *pLine = new AcDbLine(ptTemp, ptTemp2);
|
||
pLine->setLayer(m_idDimlay);
|
||
AddISOEnt(pLine);
|
||
|
||
ptTemp = ptEnd + vt;
|
||
ptTemp2 = ptEnd - vt;
|
||
pLine = new AcDbLine(ptTemp, ptTemp2);
|
||
pLine->setLayer(m_idDimlay);
|
||
AddISOEnt(pLine);
|
||
|
||
ptTemp = ptSta;
|
||
ptTemp2 = ptEnd;
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetInvrtTransformByThis(ptTemp);
|
||
m_xform.GetInvrtTransformByThis(ptTemp2);
|
||
}
|
||
|
||
double dH = m_dTxtH;
|
||
AcGeVector3d vt1 = ptTemp2 - ptTemp;
|
||
if (vt1.isParallelTo(AcGeVector3d::kXAxis))//X
|
||
{
|
||
ptTxt.y += (dH * m_dScale);//半个字高间隙
|
||
}
|
||
else if (vt1.isParallelTo(AcGeVector3d::kYAxis))//Y
|
||
{
|
||
ptTxt.x -= (dH * m_dScale);//半个字高间隙
|
||
}
|
||
else
|
||
{
|
||
if (vt1.x > 1.e-10 && vt1.y > 1.e-10) //I
|
||
{
|
||
vt1.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
vt1.normalize();
|
||
ptTxt += (dH * m_dScale * vt1);
|
||
}
|
||
|
||
if (vt1.x < 1.e-10 && vt1.y > 1.e-10) //II
|
||
{
|
||
vt1.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
vt1.normalize();
|
||
ptTxt += (dH * m_dScale * vt1);
|
||
}
|
||
|
||
if (vt1.x < 1.e-10 && vt1.y < 1.e-10) //III==I
|
||
{
|
||
vt1.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
vt1.normalize();
|
||
ptTxt += (dH * m_dScale * vt1);
|
||
}
|
||
|
||
if (vt1.x > 1.e-10 && vt1.y < 1.e-10) //IV==II
|
||
{
|
||
vt1.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
vt1.normalize();
|
||
ptTxt += (dH * m_dScale * vt1);
|
||
}
|
||
}
|
||
|
||
CString sText = sDimTxt;
|
||
AcDbText *pText = MakeDimText(ptSta, ptEnd, ptTxt,m_idDimSty,m_dTxtH,sText);
|
||
AddISOEnt(pText);
|
||
|
||
pt.y = m_arISOEntPtrs.length() - 1;
|
||
if (pt.y > pt.x)
|
||
{
|
||
m_arGrpIdx.Add(pt);
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeDim2(AecDbObjXDataMap* pXDataMap,AcGePoint3d ptSta,AcGePoint3d ptEnd,TCHAR* pszLay,double dPipeWD)
|
||
{
|
||
int nUnit = 1;
|
||
bool bDimPipeEl = false;
|
||
double dEl = 0.0;
|
||
dEl = (ptSta.z - 0.0) / nUnit - m_dRefEl / nUnit;
|
||
AcGeVector3d vtDir = ptEnd - ptSta;
|
||
AcGeLine3d ln3d;
|
||
ln3d.set(ptSta, ptEnd);
|
||
if (AcGePlane::kXYPlane.isParallelTo(ln3d) && m_bDimPipeEl)
|
||
{
|
||
bDimPipeEl = true;
|
||
}
|
||
|
||
int nUnitDrw = 1;//默认毫米
|
||
struct resbuf rb;
|
||
acedGetVar(_T("INSUNITS"), &rb);
|
||
if (rb.resval.rint == AcDb::kUnitsMeters)
|
||
{
|
||
nUnitDrw = 1000;
|
||
}
|
||
|
||
int nApp = 0;
|
||
pXDataMap->GetAt(PIPE_EAPP, nApp);
|
||
WPipe::EApp eApp = (WPipe::EApp)nApp;
|
||
|
||
if ( (eApp >= WPipe::eButtweld && eApp <= WPipe::eFlange) || eApp == WPipe::eGroove )
|
||
{
|
||
if (!CoreTools::hasCSSZ(true)) return;
|
||
|
||
CUIISQLiteServer Db;
|
||
if (!PipelineTools::getSqliteDB(_T("Plumbing.db"), Db))
|
||
{
|
||
AfxMessageBox(_T("未找到数据库文件Plumbing.db,请重新安装!"));
|
||
return;
|
||
}
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap)) return;
|
||
|
||
CString sDimUp, sDimDwn;
|
||
if (PipelineTools::FormatDimText(&Db, xDataMap, pXDataMap, sDimUp, sDimDwn, dEl, pszLay, nUnit))
|
||
{
|
||
int nTrade = 0;
|
||
xDataMap.GetAt(DOC_TRADE, nTrade);
|
||
if (nTrade == WPipe::eCivial)
|
||
{
|
||
sDimDwn = _T("");//市政只要上标
|
||
}
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
AcGePoint3d ptGeOn = ptSta;
|
||
Midpoint(ptSta, ptEnd, ptGeOn);
|
||
|
||
double dDn = 0.0;
|
||
pXDataMap->GetAt(PIPE_DN, dDn);
|
||
|
||
vtDir.normalize();
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kYAxis))
|
||
{
|
||
vtDir = AcGeVector3d::kYAxis;
|
||
}
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kXAxis))
|
||
{
|
||
vtDir = AcGeVector3d::kXAxis;
|
||
}
|
||
|
||
AcGeVector3d vtV = vtDir;
|
||
if (vtDir.x < -1.e-10 && vtDir.y > 1.e-10)//第2象限
|
||
{
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
vtDir *= -1.0;//转到第4象限
|
||
}
|
||
else if (vtDir.x < -1.e-10 && vtDir.y < -1.e-10)//第3象限
|
||
{
|
||
vtDir.negate();//转道第1象限
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
ptGeOn += vtV * dPipeWD * 2.0; //
|
||
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(PipelineTools::gLayer_Pipe_Dim);
|
||
AcDbObjectId idTSty = CKTCadUtility::InitTextStyle(PipelineTools::gTextStyle_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim *pDim = new AecDbEwPipeDim;
|
||
//pDim->AddAecDbWEntity(id1);
|
||
pDim->SetDimStyle(1);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(1);
|
||
pDim->SetTextStyleId(idTSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->setLayer(idDimLay);
|
||
sDimUp.TrimLeft();
|
||
sDimDwn.TrimLeft();
|
||
if (sDimUp.IsEmpty() && sDimDwn.IsEmpty())
|
||
{
|
||
delete pDim;
|
||
return;
|
||
}
|
||
|
||
pDim->AddDimText(sDimUp, sDimDwn);
|
||
|
||
double dTxtH = m_dTxtH, dTxWS = 1.0;
|
||
//xDataMap.GetAt(DOC_DIMTXTH, dTxtH);
|
||
xDataMap.GetAt(DOC_DIMTXTF, dTxWS);
|
||
|
||
CString sDimupScr, sDimupScrTrue;
|
||
xDataMap.GetAt(DOC_SCRIPTT, sDimupScr);
|
||
CWPipeDimConfigDlg::PipeScript2Detail(sDimupScr, sDimupScrTrue);
|
||
pDim->SetDimupScript(sDimupScrTrue);
|
||
|
||
CString sDimdwScr, sDimdwScrTrue;
|
||
xDataMap.GetAt(DOC_SCRIPTB, sDimdwScr);
|
||
CWPipeDimConfigDlg::PipeScript2Detail(sDimdwScr, sDimdwScrTrue);
|
||
pDim->SetDimdownScript(sDimdwScrTrue);
|
||
|
||
pDim->SetPScale(m_dScale);
|
||
pDim->SetTextHeight(dTxtH);
|
||
pDim->SetTextWidthScale(dTxWS);
|
||
|
||
vtDir = ptEnd - ptSta;
|
||
vtDir /= 10.0;
|
||
ptSta += vtDir;
|
||
|
||
pDim->AppendPoint(ptSta);
|
||
pDim->AppendPoint(ptEnd);
|
||
|
||
pDim->SetDimupdownSpace(dDn);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
|
||
AcDbVoidPtrArray arSubPtrs;
|
||
pDim->explode(arSubPtrs);
|
||
delete pDim;
|
||
|
||
if (arSubPtrs.length() == 1)
|
||
{
|
||
AcDbText *pText = (AcDbText *)arSubPtrs.first();
|
||
double dOb = m_xform.GetISOOblique(vtDir);
|
||
pText->setLayer(m_idDimlay);
|
||
pText->setTextStyle(m_idDimSty);
|
||
|
||
if (m_bDimTxtIso)
|
||
{
|
||
pText->setOblique(dOb);
|
||
}
|
||
|
||
AddISOEnt(pText);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeEDim2(AecDbObjXDataMap *pXDataMap, AcGePoint3d ptSta, AcGePoint3d ptEnd, TCHAR *pszLay, double dPipeWD)
|
||
{
|
||
int nUnit = 1;
|
||
bool bDimPipeEl = false;
|
||
double dEl = 0.0;
|
||
dEl = (ptSta.z - 0.0) / nUnit - m_dRefEl / nUnit;
|
||
AcGeVector3d vtDir = ptEnd - ptSta;
|
||
AcGeLine3d ln3d;
|
||
ln3d.set(ptSta, ptEnd);
|
||
if (AcGePlane::kXYPlane.isParallelTo(ln3d) && m_bDimPipeEl)
|
||
{
|
||
bDimPipeEl = true;
|
||
}
|
||
|
||
int nUnitDrw = 1;//默认毫米
|
||
struct resbuf rb;
|
||
acedGetVar(_T("INSUNITS"), &rb);
|
||
if (rb.resval.rint == AcDb::kUnitsMeters)
|
||
{
|
||
nUnitDrw = 1000;
|
||
}
|
||
|
||
int nApp = 0;
|
||
pXDataMap->GetAt(KEY_APP, nApp);
|
||
WPipe::EApp eApp = (WPipe::EApp)nApp;
|
||
if (eApp == WPipe::eBridge)
|
||
{
|
||
CString sDimUp, sDimDwn, sNo, sType;
|
||
|
||
int nType = 0;
|
||
pXDataMap->GetAt(KEY_SECSHAPE, nType);
|
||
ESection eType = (ESection)nType;
|
||
|
||
AecHvac::DuctParam data;
|
||
memset(&data, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
switch (eType)
|
||
{
|
||
case eRect:
|
||
{
|
||
sType = _T("");
|
||
pXDataMap->GetAt(KEY_TYPE, sType);
|
||
|
||
sNo = _T("");
|
||
pXDataMap->GetAt(KEY_TYPE, sNo);
|
||
|
||
pXDataMap->GetAt(KEY_SIZE1, data.dSize[0]); //L
|
||
pXDataMap->GetAt(KEY_SIZE2, data.dSize[1]); //w
|
||
|
||
if (bDimPipeEl)
|
||
{
|
||
double dBomEl = ptSta.z;
|
||
dBomEl -= 0.5 * data.dSize[1];
|
||
dBomEl /= nUnitDrw;//米单位
|
||
|
||
sDimUp.Format(_T("%s-%s %dx%d底%.3fm"), sType, sNo, (int)(data.dSize[0] + 0.5), (int)(data.dSize[1] + 0.5), dBomEl);
|
||
}
|
||
else
|
||
{
|
||
sDimUp.Format(_T("%s-%s %dx%d"), sType, sNo, (int)(data.dSize[0] + 0.5), (int)(data.dSize[1] + 0.5));
|
||
}
|
||
}
|
||
case eCircle:
|
||
{
|
||
double dBomEl = ptSta.z;
|
||
dBomEl /= nUnitDrw;
|
||
|
||
pXDataMap->GetAt(KEY_SIZE1, data.dSize[0]); //D
|
||
|
||
if (bDimPipeEl)
|
||
{
|
||
sDimUp.Format(_T("%s-%s D%d中%.3fm"), sType, sNo, (int)(data.dSize[0] + 0.5), dBomEl);
|
||
}
|
||
else
|
||
{
|
||
sDimUp.Format(_T("%s-%s D%d"), sType, sNo, (int)(data.dSize[0] + 0.5));
|
||
}
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap)) return;
|
||
|
||
AcGePoint3d ptGeOn = ptSta;
|
||
Midpoint(ptSta, ptEnd, ptGeOn);
|
||
|
||
double dDn = 0.0;
|
||
pXDataMap->GetAt(PIPE_DN, dDn);
|
||
|
||
vtDir.normalize();
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kYAxis))
|
||
{
|
||
vtDir = AcGeVector3d::kYAxis;
|
||
}
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kXAxis))
|
||
{
|
||
vtDir = AcGeVector3d::kXAxis;
|
||
}
|
||
|
||
AcGeVector3d vtV = vtDir;
|
||
if (vtDir.x < -1.e-10 && vtDir.y > 1.e-10)//第2象限
|
||
{
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
vtDir *= -1.0;//转到第4象限
|
||
}
|
||
else if (vtDir.x < -1.e-10 && vtDir.y < -1.e-10)//第3象限
|
||
{
|
||
vtDir.negate();//转道第1象限
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
ptGeOn += vtV * dPipeWD * 2.0; //
|
||
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(PipelineTools::gLayer_Pipe_Dim);
|
||
AcDbObjectId idTSty = CKTCadUtility::InitTextStyle(PipelineTools::gTextStyle_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim *pDim = new AecDbEwPipeDim;
|
||
pDim->SetDimStyle(1);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(1);
|
||
pDim->SetTextStyleId(idTSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->setLayer(idDimLay);
|
||
sDimUp.TrimLeft();
|
||
sDimDwn.TrimLeft();
|
||
if (sDimUp.IsEmpty() && sDimDwn.IsEmpty())
|
||
{
|
||
delete pDim;
|
||
return;
|
||
}
|
||
|
||
pDim->AddDimText(sDimUp, sDimDwn);
|
||
|
||
double dTxtH = m_dTxtH, dTxWS = 1.0;
|
||
//xDataMap.GetAt(DOC_DIMTXTH, dTxtH);
|
||
xDataMap.GetAt(DOC_DIMTXTF, dTxWS);
|
||
|
||
pDim->SetPScale(m_dScale);
|
||
pDim->SetTextHeight(dTxtH);
|
||
pDim->SetTextWidthScale(dTxWS);
|
||
|
||
vtDir = ptEnd - ptSta;
|
||
vtDir /= 10.0;
|
||
ptSta += vtDir;
|
||
|
||
pDim->AppendPoint(ptSta);
|
||
pDim->AppendPoint(ptEnd);
|
||
|
||
pDim->SetDimupdownSpace(dDn);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
|
||
AcDbVoidPtrArray arSubPtrs;
|
||
pDim->explode(arSubPtrs);
|
||
delete pDim;
|
||
|
||
if (arSubPtrs.length() == 1)
|
||
{
|
||
AcDbText *pText = (AcDbText *)arSubPtrs.first();
|
||
double dOb = m_xform.GetISOOblique(vtDir);
|
||
pText->setLayer(m_idDimlay);
|
||
pText->setTextStyle(m_idDimSty);
|
||
if (m_bDimTxtIso)
|
||
{
|
||
pText->setOblique(dOb);
|
||
}
|
||
AddISOEnt(pText);
|
||
}
|
||
}
|
||
else if (eApp == WPipe::eTrench)
|
||
{
|
||
CString sDimUp, sDimDwn, sNo, sType, sKey;
|
||
|
||
AecHvac::DuctParam data;
|
||
memset(&data, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
pXDataMap->GetAt(KEY_WELLW, data.dSize[4]);
|
||
|
||
sKey.Format(_T("%s_%d"), KEY_SIZE, 5);
|
||
pXDataMap->GetAt(sKey, data.dSize[5]);
|
||
|
||
sType = _T("");
|
||
pXDataMap->GetAt(KEY_TYPE, sType);
|
||
|
||
sNo = _T("");
|
||
pXDataMap->GetAt(KEY_TYPE, sNo);
|
||
|
||
if (bDimPipeEl)
|
||
{
|
||
double dTopEl = ptSta.z;
|
||
dTopEl += 0.5 * data.dSize[1];
|
||
dTopEl /= nUnitDrw;
|
||
|
||
sDimUp.Format(_T("%s-%s %dx%d顶%.3fm"), sType, sNo, (int)(data.dSize[4] + 0.5), (int)(data.dSize[5] + 0.5), dTopEl);
|
||
}
|
||
else
|
||
{
|
||
sDimUp.Format(_T("%s-%s %dx%d"), sType, sNo, (int)(data.dSize[4] + 0.5), (int)(data.dSize[5] + 0.5));
|
||
}
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap)) return;
|
||
|
||
AcGePoint3d ptGeOn = ptSta;
|
||
Midpoint(ptSta, ptEnd, ptGeOn);
|
||
|
||
double dDn = 0.0;
|
||
pXDataMap->GetAt(PIPE_DN, dDn);
|
||
|
||
vtDir.normalize();
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kYAxis))
|
||
{
|
||
vtDir = AcGeVector3d::kYAxis;
|
||
}
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kXAxis))
|
||
{
|
||
vtDir = AcGeVector3d::kXAxis;
|
||
}
|
||
|
||
AcGeVector3d vtV = vtDir;
|
||
if (vtDir.x < -1.e-10 && vtDir.y > 1.e-10)//第2象限
|
||
{
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
vtDir *= -1.0;//转到第4象限
|
||
}
|
||
else if (vtDir.x < -1.e-10 && vtDir.y < -1.e-10)//第3象限
|
||
{
|
||
vtDir.negate();//转道第1象限
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
ptGeOn += vtV * dPipeWD * 2.0; //
|
||
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(PipelineTools::gLayer_Pipe_Dim);
|
||
AcDbObjectId idTSty = CKTCadUtility::InitTextStyle(PipelineTools::gTextStyle_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim *pDim = new AecDbEwPipeDim;
|
||
pDim->SetDimStyle(1);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(1);
|
||
pDim->SetTextStyleId(idTSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->setLayer(idDimLay);
|
||
sDimUp.TrimLeft();
|
||
sDimDwn.TrimLeft();
|
||
if (sDimUp.IsEmpty() && sDimDwn.IsEmpty())
|
||
{
|
||
delete pDim;
|
||
return;
|
||
}
|
||
|
||
pDim->AddDimText(sDimUp, sDimDwn);
|
||
|
||
double dTxtH = m_dTxtH, dTxWS = 1.0;
|
||
//xDataMap.GetAt(DOC_DIMTXTH, dTxtH);
|
||
xDataMap.GetAt(DOC_DIMTXTF, dTxWS);
|
||
|
||
pDim->SetPScale(m_dScale);
|
||
pDim->SetTextHeight(dTxtH);
|
||
pDim->SetTextWidthScale(dTxWS);
|
||
|
||
vtDir = ptEnd - ptSta;
|
||
vtDir /= 10.0;
|
||
ptSta += vtDir;
|
||
|
||
pDim->AppendPoint(ptSta);
|
||
pDim->AppendPoint(ptEnd);
|
||
|
||
pDim->SetDimupdownSpace(dDn);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
|
||
AcDbVoidPtrArray arSubPtrs;
|
||
pDim->explode(arSubPtrs);
|
||
delete pDim;
|
||
|
||
if (arSubPtrs.length() == 1)
|
||
{
|
||
AcDbText *pText = (AcDbText *)arSubPtrs.first();
|
||
double dOb = m_xform.GetISOOblique(vtDir);
|
||
pText->setLayer(m_idDimlay);
|
||
pText->setTextStyle(m_idDimSty);
|
||
if (m_bDimTxtIso)
|
||
{
|
||
pText->setOblique(dOb);
|
||
}
|
||
AddISOEnt(pText);
|
||
}
|
||
}
|
||
}
|
||
void AecISODrawMake::MakeEDim3(AecDbObjXDataMap *pXDataMap, AcGePoint3d ptSta, AcGePoint3d ptEnd, TCHAR *pszLay, double dPipeWD)
|
||
{
|
||
int nUnit = 1;
|
||
bool bDimPipeEl = false;
|
||
double dEl = 0.0;
|
||
dEl = (ptSta.z - 0.0) / nUnit - m_dRefEl / nUnit;
|
||
AcGeVector3d vtDir = ptEnd - ptSta;
|
||
AcGeLine3d ln3d;
|
||
ln3d.set(ptSta, ptEnd);
|
||
if (AcGePlane::kXYPlane.isParallelTo(ln3d) && m_bDimPipeEl)
|
||
{
|
||
bDimPipeEl = true;
|
||
}
|
||
|
||
int nUnitDrw = 1;//默认毫米
|
||
struct resbuf rb;
|
||
acedGetVar(_T("INSUNITS"), &rb);
|
||
if (rb.resval.rint == AcDb::kUnitsMeters)
|
||
{
|
||
nUnitDrw = 1000;
|
||
}
|
||
|
||
int nApp = 0;
|
||
pXDataMap->GetAt(KEY_APP, nApp);
|
||
WPipe::EApp eApp = (WPipe::EApp)nApp;
|
||
if (eApp == WPipe::eBridge)
|
||
{
|
||
CString sDimUp, sDimDwn, sNo, sType;
|
||
|
||
int nType = 0;
|
||
pXDataMap->GetAt(KEY_SECSHAPE, nType);
|
||
ESection eType = (ESection)nType;
|
||
|
||
AecHvac::DuctParam data;
|
||
memset(&data, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
switch (eType)
|
||
{
|
||
case eRect:
|
||
{
|
||
sType = _T("");
|
||
pXDataMap->GetAt(KEY_TYPE, sType);
|
||
|
||
sNo = _T("");
|
||
pXDataMap->GetAt(KEY_TYPE, sNo);
|
||
|
||
pXDataMap->GetAt(KEY_SIZE1, data.dSize[0]); //L
|
||
pXDataMap->GetAt(KEY_SIZE2, data.dSize[1]); //w
|
||
|
||
if (bDimPipeEl)
|
||
{
|
||
double dBomEl = ptSta.z;
|
||
dBomEl -= 0.5 * data.dSize[1];
|
||
dBomEl /= nUnitDrw;//米单位
|
||
|
||
sDimUp.Format(_T("%dx%d"), (int)(data.dSize[0] + 0.5), (int)(data.dSize[1] + 0.5));
|
||
}
|
||
else
|
||
{
|
||
sDimUp.Format(_T("%%dx%d"),(int)(data.dSize[0] + 0.5), (int)(data.dSize[1] + 0.5));
|
||
}
|
||
}
|
||
case eCircle:
|
||
{
|
||
double dBomEl = ptSta.z;
|
||
dBomEl /= nUnitDrw;
|
||
|
||
pXDataMap->GetAt(KEY_SIZE1, data.dSize[0]); //D
|
||
|
||
if (bDimPipeEl)
|
||
{
|
||
sDimUp.Format(_T("D%d"), (int)(data.dSize[0] + 0.5));
|
||
}
|
||
else
|
||
{
|
||
sDimUp.Format(_T("D%d"),(int)(data.dSize[0] + 0.5));
|
||
}
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap)) return;
|
||
|
||
AcGePoint3d ptGeOn = ptSta;
|
||
Midpoint(ptSta, ptEnd, ptGeOn);
|
||
|
||
double dDn = 0.0;
|
||
pXDataMap->GetAt(PIPE_DN, dDn);
|
||
|
||
vtDir.normalize();
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kYAxis))
|
||
{
|
||
vtDir = AcGeVector3d::kYAxis;
|
||
}
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kXAxis))
|
||
{
|
||
vtDir = AcGeVector3d::kXAxis;
|
||
}
|
||
|
||
AcGeVector3d vtV = vtDir;
|
||
if (vtDir.x < -1.e-10 && vtDir.y > 1.e-10)//第2象限
|
||
{
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
vtDir *= -1.0;//转到第4象限
|
||
}
|
||
else if (vtDir.x < -1.e-10 && vtDir.y < -1.e-10)//第3象限
|
||
{
|
||
vtDir.negate();//转道第1象限
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
ptGeOn += vtV * dPipeWD * 2.0; //
|
||
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(PipelineTools::gLayer_Pipe_Dim);
|
||
AcDbObjectId idTSty = CKTCadUtility::InitTextStyle(PipelineTools::gTextStyle_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim *pDim = new AecDbEwPipeDim;
|
||
pDim->SetDimStyle(1);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(1);
|
||
pDim->SetTextStyleId(idTSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->setLayer(idDimLay);
|
||
sDimUp.TrimLeft();
|
||
sDimDwn.TrimLeft();
|
||
if (sDimUp.IsEmpty() && sDimDwn.IsEmpty())
|
||
{
|
||
delete pDim;
|
||
return;
|
||
}
|
||
|
||
pDim->AddDimText(sDimUp, sDimDwn);
|
||
|
||
double dTxtH = m_dTxtH, dTxWS = 1.0;
|
||
//xDataMap.GetAt(DOC_DIMTXTH, dTxtH);
|
||
xDataMap.GetAt(DOC_DIMTXTF, dTxWS);
|
||
|
||
pDim->SetPScale(m_dScale);
|
||
pDim->SetTextHeight(dTxtH);
|
||
pDim->SetTextWidthScale(dTxWS);
|
||
|
||
vtDir = ptEnd - ptSta;
|
||
vtDir /= 10.0;
|
||
ptSta += vtDir;
|
||
|
||
pDim->AppendPoint(ptSta);
|
||
pDim->AppendPoint(ptEnd);
|
||
|
||
pDim->SetDimupdownSpace(dDn);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
|
||
AcDbVoidPtrArray arSubPtrs;
|
||
pDim->explode(arSubPtrs);
|
||
delete pDim;
|
||
|
||
if (arSubPtrs.length() == 1)
|
||
{
|
||
AcDbText *pText = (AcDbText *)arSubPtrs.first();
|
||
double dOb = m_xform.GetISOOblique(vtDir);
|
||
pText->setLayer(m_idDimlay);
|
||
pText->setTextStyle(m_idDimSty);
|
||
|
||
if (m_bDimTxtIso)
|
||
{
|
||
pText->setOblique(dOb);
|
||
}
|
||
AddISOEnt(pText);
|
||
}
|
||
}
|
||
else if (eApp == WPipe::eTrench)
|
||
{
|
||
CString sDimUp, sDimDwn, sNo, sType, sKey;
|
||
|
||
AecHvac::DuctParam data;
|
||
memset(&data, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
pXDataMap->GetAt(KEY_WELLW, data.dSize[4]);
|
||
|
||
sKey.Format(_T("%s_%d"), KEY_SIZE, 5);
|
||
pXDataMap->GetAt(sKey, data.dSize[5]);
|
||
|
||
sType = _T("");
|
||
pXDataMap->GetAt(KEY_TYPE, sType);
|
||
|
||
sNo = _T("");
|
||
pXDataMap->GetAt(KEY_TYPE, sNo);
|
||
|
||
if (bDimPipeEl)
|
||
{
|
||
double dTopEl = ptSta.z;
|
||
dTopEl += 0.5 * data.dSize[1];
|
||
dTopEl /= nUnitDrw;
|
||
|
||
sDimUp.Format(_T("%s-%s %dx%d顶%.3fm"), sType, sNo, (int)(data.dSize[4] + 0.5), (int)(data.dSize[5] + 0.5), dTopEl);
|
||
}
|
||
else
|
||
{
|
||
sDimUp.Format(_T("%s-%s %dx%d"), sType, sNo, (int)(data.dSize[4] + 0.5), (int)(data.dSize[5] + 0.5));
|
||
}
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap)) return;
|
||
|
||
AcGePoint3d ptGeOn = ptSta;
|
||
Midpoint(ptSta, ptEnd, ptGeOn);
|
||
|
||
double dDn = 0.0;
|
||
pXDataMap->GetAt(PIPE_DN, dDn);
|
||
|
||
vtDir.normalize();
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kYAxis))
|
||
{
|
||
vtDir = AcGeVector3d::kYAxis;
|
||
}
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kXAxis))
|
||
{
|
||
vtDir = AcGeVector3d::kXAxis;
|
||
}
|
||
|
||
AcGeVector3d vtV = vtDir;
|
||
if (vtDir.x < -1.e-10 && vtDir.y > 1.e-10)//第2象限
|
||
{
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
vtDir *= -1.0;//转到第4象限
|
||
}
|
||
else if (vtDir.x < -1.e-10 && vtDir.y < -1.e-10)//第3象限
|
||
{
|
||
vtDir.negate();//转道第1象限
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
ptGeOn += vtV * dPipeWD * 2.0; //
|
||
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(PipelineTools::gLayer_Pipe_Dim);
|
||
AcDbObjectId idTSty = CKTCadUtility::InitTextStyle(PipelineTools::gTextStyle_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim *pDim = new AecDbEwPipeDim;
|
||
pDim->SetDimStyle(1);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(1);
|
||
pDim->SetTextStyleId(idTSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->setLayer(idDimLay);
|
||
sDimUp.TrimLeft();
|
||
sDimDwn.TrimLeft();
|
||
if (sDimUp.IsEmpty() && sDimDwn.IsEmpty())
|
||
{
|
||
delete pDim;
|
||
return;
|
||
}
|
||
|
||
pDim->AddDimText(sDimUp, sDimDwn);
|
||
|
||
double dTxtH = m_dTxtH, dTxWS = 1.0;
|
||
//xDataMap.GetAt(DOC_DIMTXTH, dTxtH);
|
||
xDataMap.GetAt(DOC_DIMTXTF, dTxWS);
|
||
|
||
pDim->SetPScale(m_dScale);
|
||
pDim->SetTextHeight(dTxtH);
|
||
pDim->SetTextWidthScale(dTxWS);
|
||
|
||
vtDir = ptEnd - ptSta;
|
||
vtDir /= 10.0;
|
||
ptSta += vtDir;
|
||
|
||
pDim->AppendPoint(ptSta);
|
||
pDim->AppendPoint(ptEnd);
|
||
|
||
pDim->SetDimupdownSpace(dDn);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
|
||
AcDbVoidPtrArray arSubPtrs;
|
||
pDim->explode(arSubPtrs);
|
||
delete pDim;
|
||
|
||
if (arSubPtrs.length() == 1)
|
||
{
|
||
AcDbText *pText = (AcDbText *)arSubPtrs.first();
|
||
double dOb = m_xform.GetISOOblique(vtDir);
|
||
pText->setLayer(m_idDimlay);
|
||
pText->setTextStyle(m_idDimSty);
|
||
|
||
if (m_bDimTxtIso)
|
||
{
|
||
pText->setOblique(dOb);
|
||
}
|
||
AddISOEnt(pText);
|
||
}
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeHDim2(AecDbObjXDataMap* pXDataMap,AcGePoint3d ptSta,AcGePoint3d ptEnd,TCHAR* pszLay,double dPipeWD)
|
||
{
|
||
int nUnit = 1;
|
||
bool bDimPipeEl = false;
|
||
double dEl = 0.0;
|
||
dEl = (ptSta.z - 0.0) / nUnit - m_dRefEl / nUnit;
|
||
AcGeVector3d vtDir = ptEnd - ptSta;
|
||
AcGeLine3d ln3d;
|
||
ln3d.set(ptSta, ptEnd);
|
||
if (AcGePlane::kXYPlane.isParallelTo(ln3d) && m_bDimPipeEl)
|
||
{
|
||
bDimPipeEl = true;
|
||
}
|
||
|
||
int nUnitDrw = 1;//默认毫米
|
||
struct resbuf rb;
|
||
acedGetVar(_T("INSUNITS"), &rb);
|
||
if (rb.resval.rint == AcDb::kUnitsMeters)
|
||
{
|
||
nUnitDrw = 1000;
|
||
}
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT,xDataMap)) return;
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
AcGePoint3d ptGeOn;
|
||
Midpoint(ptSta, ptEnd, ptGeOn);
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kYAxis))
|
||
vtDir = AcGeVector3d::kYAxis;
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kXAxis))
|
||
vtDir = AcGeVector3d::kXAxis;
|
||
|
||
AcGeVector3d vtV = vtDir;
|
||
if (vtDir.x < -1.e-10 && vtDir.y > 1.e-10)//第2象限
|
||
{
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
vtDir *= -1.0;//转到第4象限
|
||
}
|
||
else if (vtDir.x < -1.e-10 && vtDir.y < -1.e-10)//第3象限
|
||
{
|
||
vtDir.negate();//转道第1象限
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
ptGeOn += vtV * dPipeWD * 2.0; //
|
||
|
||
int nType = 0;
|
||
pXDataMap->GetAt(KEY_SECSHAPE,nType);
|
||
|
||
AecHvac::DuctParam data;
|
||
memset(&data,0,sizeof(AecHvac::DuctParam));
|
||
|
||
CString sDimUp,sDimDwn, sType,sNo;
|
||
|
||
sType = _T("");
|
||
pXDataMap->GetAt(KEY_TYPE, sType);
|
||
|
||
sNo = _T("");
|
||
pXDataMap->GetAt(KEY_TYPE, sNo);
|
||
|
||
ESection eType = (ESection)nType;
|
||
switch(eType)
|
||
{
|
||
case eRect:
|
||
{
|
||
pXDataMap->GetAt(KEY_SIZE1,data.dSize[0]); //L
|
||
pXDataMap->GetAt(KEY_SIZE2,data.dSize[1]); //w
|
||
pXDataMap->GetAt(PIPE_THICK,data.dSize[2]);//t
|
||
|
||
if (bDimPipeEl)
|
||
{
|
||
double dBomEl = ptSta.z;
|
||
dBomEl -= 0.5 * data.dSize[1];
|
||
dBomEl /= nUnitDrw;//米单位
|
||
|
||
sDimUp.Format(_T("风管%s-%s %dx%dt=%.1f底%.3fm"), sType, sNo, (int)(data.dSize[0] + 0.5), (int)(data.dSize[1] + 0.5), data.dSize[2], dBomEl);
|
||
}
|
||
else
|
||
{
|
||
sDimUp.Format(_T("风管%s-%s %dx%dt=%.1f"), sType, sNo, (int)(data.dSize[0] + 0.5), (int)(data.dSize[1] + 0.5), data.dSize[2]);
|
||
}
|
||
break;
|
||
}
|
||
case eCircle:
|
||
{
|
||
pXDataMap->GetAt(KEY_SIZE1,data.dSize[0]); //D
|
||
data.dSize[1] = 0.0;
|
||
pXDataMap->GetAt(PIPE_THICK,data.dSize[2]);//t
|
||
|
||
double dBomEl = ptSta.z;
|
||
dBomEl /= nUnitDrw;
|
||
|
||
if (bDimPipeEl)
|
||
{
|
||
sDimUp.Format(_T("风管%s-%s D%dt=%.1f中%.3fm"), sType, sNo, (int)(data.dSize[0] + 0.5), data.dSize[2], dBomEl);
|
||
}
|
||
else
|
||
{
|
||
sDimUp.Format(_T("风管%s-%s D%dt=%.1f"), sType, sNo, (int)(data.dSize[0] + 0.5), data.dSize[2]);
|
||
}
|
||
|
||
break;
|
||
}
|
||
case eOblate:
|
||
{
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(PipelineTools::gLayer_Pipe_Dim);
|
||
AcDbObjectId idTSty = CKTCadUtility::InitTextStyle(PipelineTools::gTextStyle_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim* pDim = new AecDbEwPipeDim;
|
||
pDim->SetDimStyle(1);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(0);
|
||
pDim->SetTextStyleId(idTSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->setLayer(idDimLay);
|
||
sDimUp.TrimLeft();
|
||
sDimDwn.TrimLeft();
|
||
pDim->AddDimText(sDimUp, sDimDwn);
|
||
|
||
double dTxtH = m_dTxtH, dTxWS = 1.0;
|
||
//xDataMap.GetAt(DOC_DIMTXTH, dTxtH);
|
||
xDataMap.GetAt(DOC_DIMTXTF, dTxWS);
|
||
|
||
pDim->SetPScale(m_dScale);
|
||
pDim->SetTextHeight(dTxtH);
|
||
pDim->SetTextWidthScale(dTxWS);
|
||
|
||
vtDir = ptEnd - ptSta;
|
||
vtDir /= 10.0;
|
||
ptSta += vtDir;
|
||
|
||
pDim->AppendPoint(ptSta);
|
||
pDim->AppendPoint(ptEnd);
|
||
|
||
pDim->SetDimupdownSpace(data.dSize[0]);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
|
||
AcDbVoidPtrArray arSubPtrs;
|
||
pDim->explode(arSubPtrs);
|
||
delete pDim;
|
||
|
||
if (arSubPtrs.length() == 1)
|
||
{
|
||
AcDbText* pText = (AcDbText*)arSubPtrs.first();
|
||
double dOb = m_xform.GetISOOblique(vtDir);
|
||
pText->setTextStyle(m_idDimSty);
|
||
pText->setLayer(m_idDimlay);
|
||
|
||
if (m_bDimTxtIso)
|
||
pText->setOblique(dOb);
|
||
|
||
AddISOEnt(pText);
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeHDim3(AecDbObjXDataMap *pXDataMap, AcGePoint3d ptSta, AcGePoint3d ptEnd, TCHAR *pszLay, double dPipeWD)
|
||
{
|
||
int nUnit = 1;
|
||
bool bDimPipeEl = false;
|
||
double dEl = 0.0;
|
||
dEl = (ptSta.z - 0.0) / nUnit - m_dRefEl / nUnit;
|
||
AcGeVector3d vtDir = ptEnd - ptSta;
|
||
AcGeLine3d ln3d;
|
||
ln3d.set(ptSta, ptEnd);
|
||
if (AcGePlane::kXYPlane.isParallelTo(ln3d) && m_bDimPipeEl)
|
||
{
|
||
bDimPipeEl = true;
|
||
}
|
||
|
||
int nUnitDrw = 1;//默认毫米
|
||
struct resbuf rb;
|
||
acedGetVar(_T("INSUNITS"), &rb);
|
||
if (rb.resval.rint == AcDb::kUnitsMeters)
|
||
{
|
||
nUnitDrw = 1000;
|
||
}
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap)) return;
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
AcGePoint3d ptGeOn;
|
||
Midpoint(ptSta, ptEnd, ptGeOn);
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kYAxis))
|
||
vtDir = AcGeVector3d::kYAxis;
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kXAxis))
|
||
vtDir = AcGeVector3d::kXAxis;
|
||
|
||
AcGeVector3d vtV = vtDir;
|
||
if (vtDir.x < -1.e-10 && vtDir.y > 1.e-10)//第2象限
|
||
{
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
vtDir *= -1.0;//转到第4象限
|
||
}
|
||
else if (vtDir.x < -1.e-10 && vtDir.y < -1.e-10)//第3象限
|
||
{
|
||
vtDir.negate();//转道第1象限
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
ptGeOn += vtV * dPipeWD * 2.0; //
|
||
|
||
int nType = 0;
|
||
pXDataMap->GetAt(KEY_SECSHAPE, nType);
|
||
|
||
AecHvac::DuctParam data;
|
||
memset(&data, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
CString sDimUp, sDimDwn, sType, sNo;
|
||
|
||
sType = _T("");
|
||
pXDataMap->GetAt(KEY_TYPE, sType);
|
||
|
||
sNo = _T("");
|
||
pXDataMap->GetAt(KEY_TYPE, sNo);
|
||
|
||
ESection eType = (ESection)nType;
|
||
switch (eType)
|
||
{
|
||
case eRect:
|
||
{
|
||
pXDataMap->GetAt(KEY_SIZE1, data.dSize[0]); //L
|
||
pXDataMap->GetAt(KEY_SIZE2, data.dSize[1]); //w
|
||
pXDataMap->GetAt(PIPE_THICK, data.dSize[2]);//t
|
||
|
||
if (bDimPipeEl)
|
||
{
|
||
double dBomEl = ptSta.z;
|
||
dBomEl -= 0.5 * data.dSize[1];
|
||
dBomEl /= nUnitDrw;//米单位
|
||
|
||
sDimUp.Format(_T("风管%dx%d"), (int)(data.dSize[0] + 0.5), (int)(data.dSize[1] + 0.5));
|
||
}
|
||
else
|
||
{
|
||
sDimUp.Format(_T("风管%dx%d"),(int)(data.dSize[0] + 0.5), (int)(data.dSize[1] + 0.5));
|
||
}
|
||
break;
|
||
}
|
||
case eCircle:
|
||
{
|
||
pXDataMap->GetAt(KEY_SIZE1, data.dSize[0]); //D
|
||
data.dSize[1] = 0.0;
|
||
pXDataMap->GetAt(PIPE_THICK, data.dSize[2]);//t
|
||
|
||
double dBomEl = ptSta.z;
|
||
dBomEl /= nUnitDrw;
|
||
|
||
if (bDimPipeEl)
|
||
{
|
||
sDimUp.Format(_T("风管D%d"), (int)(data.dSize[0] + 0.5));
|
||
}
|
||
else
|
||
{
|
||
sDimUp.Format(_T("风管D%d"), (int)(data.dSize[0] + 0.5));
|
||
}
|
||
|
||
break;
|
||
}
|
||
case eOblate:
|
||
{
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(PipelineTools::gLayer_Pipe_Dim);
|
||
AcDbObjectId idTSty = CKTCadUtility::InitTextStyle(PipelineTools::gTextStyle_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim *pDim = new AecDbEwPipeDim;
|
||
pDim->SetDimStyle(1);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(0);
|
||
pDim->SetTextStyleId(idTSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->setLayer(idDimLay);
|
||
sDimUp.TrimLeft();
|
||
sDimDwn.TrimLeft();
|
||
pDim->AddDimText(sDimUp, sDimDwn);
|
||
|
||
double dTxtH = m_dTxtH, dTxWS = 1.0;
|
||
//xDataMap.GetAt(DOC_DIMTXTH, dTxtH);
|
||
xDataMap.GetAt(DOC_DIMTXTF, dTxWS);
|
||
|
||
pDim->SetPScale(m_dScale);
|
||
pDim->SetTextHeight(dTxtH);
|
||
pDim->SetTextWidthScale(dTxWS);
|
||
|
||
vtDir = ptEnd - ptSta;
|
||
vtDir /= 10.0;
|
||
ptSta += vtDir;
|
||
|
||
pDim->AppendPoint(ptSta);
|
||
pDim->AppendPoint(ptEnd);
|
||
|
||
pDim->SetDimupdownSpace(data.dSize[0]);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
|
||
AcDbVoidPtrArray arSubPtrs;
|
||
pDim->explode(arSubPtrs);
|
||
delete pDim;
|
||
|
||
if (arSubPtrs.length() == 1)
|
||
{
|
||
AcDbText *pText = (AcDbText *)arSubPtrs.first();
|
||
double dOb = m_xform.GetISOOblique(vtDir);
|
||
pText->setTextStyle(m_idDimSty);
|
||
pText->setLayer(m_idDimlay);
|
||
if (m_bDimTxtIso)
|
||
pText->setOblique(dOb);
|
||
|
||
AddISOEnt(pText);
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeDim3(AecDbObjXDataMap* pXDataMap,AcGePoint3d ptSta,AcGePoint3d ptEnd,TCHAR* pszLay,double dPipeWD,BOOL bTextISO)
|
||
{
|
||
if (!CoreTools::hasCSSZ(true)) return;
|
||
CUIISQLiteServer Db;
|
||
if (!PipelineTools::getSqliteDB(_T("Plumbing.db"), Db))
|
||
{
|
||
AfxMessageBox(_T("未找到数据库文件Plumbing.db,请重新安装!"));
|
||
return;
|
||
}
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT,xDataMap))
|
||
return;
|
||
|
||
double dDn = 0.0,dOD = 0.0, dt = 0.0;
|
||
CString sDimUp,sDimDwn = _T("");
|
||
if (!pXDataMap->GetAt(PIPE_DN, dDn))
|
||
{
|
||
pXDataMap->GetAt(KEY_NAME, sDimUp);
|
||
}
|
||
else
|
||
{
|
||
sDimUp.Format(_T("DN%d"),(int)(dDn + 0.5));
|
||
}
|
||
|
||
//OD
|
||
if (this->m_bODxtDim)
|
||
{
|
||
if (!pXDataMap->GetAt(PIPE_OD, dDn))
|
||
{
|
||
pXDataMap->GetAt(KEY_NAME, sDimUp);
|
||
}
|
||
else
|
||
{
|
||
pXDataMap->GetAt(PIPE_THICK, dt);
|
||
sDimUp.Format(_T("%dx%.1f"), (int)(dDn + 0.5), dt);
|
||
}
|
||
}
|
||
|
||
sDimDwn = _T("");//上
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
AcGePoint3d ptGeOn = ptEnd;
|
||
//Midpoint(ptSta, ptEnd, ptGeOn);
|
||
|
||
AcGeVector3d vtDir = ptEnd - ptSta;
|
||
vtDir.normalize();
|
||
|
||
double dLen = ptEnd.distanceTo(ptSta);
|
||
//ptGeOn -= vtDir * dLen * 0.25;//1/4
|
||
ptGeOn = MidPoint(ptSta, ptEnd);
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kYAxis))
|
||
vtDir = AcGeVector3d::kYAxis;
|
||
|
||
if (vtDir.isParallelTo(AcGeVector3d::kXAxis))
|
||
vtDir = AcGeVector3d::kXAxis;
|
||
|
||
bool bNegate = false;
|
||
AcGeVector3d vtV = vtDir;
|
||
if (vtDir.x < -1.e-10 && vtDir.y > 1.e-10)//第2象限
|
||
{
|
||
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
||
vtDir *= -1.0;//转到第4象限
|
||
}
|
||
else if (vtDir.x < -1.e-10 && vtDir.y < -1.e-10)//第3象限
|
||
{
|
||
vtDir.negate();//转道第1象限
|
||
vtV = vtDir;
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
bNegate = true;
|
||
}
|
||
else//I IV 第1,4象限
|
||
{
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
ptGeOn += vtV * dPipeWD * 2.0; //
|
||
|
||
AecDbEwPipeDim* pDim = new AecDbEwPipeDim;
|
||
//pDim->AddAecDbWEntity(id1);
|
||
pDim->SetDimStyle(1);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(1);
|
||
pDim->SetTextStyleId(m_idDimSty);
|
||
pDim->setLayer(m_idDimlay);
|
||
|
||
sDimUp.TrimLeft();
|
||
sDimDwn.TrimLeft();
|
||
if (sDimUp.IsEmpty() && sDimDwn.IsEmpty())
|
||
{
|
||
delete pDim;
|
||
return;
|
||
}
|
||
|
||
pDim->AddDimText(sDimUp, sDimDwn);
|
||
|
||
double dTxtH = m_dTxtH, dTxWS = 1.0;
|
||
//xDataMap.GetAt(DOC_DIMTXTH, dTxtH);
|
||
xDataMap.GetAt(DOC_DIMTXTF, dTxWS);
|
||
|
||
CString sDimupScr, sDimupScrTrue;
|
||
xDataMap.GetAt(DOC_SCRIPTT, sDimupScr);
|
||
CWPipeDimConfigDlg::PipeScript2Detail(sDimupScr, sDimupScrTrue);
|
||
pDim->SetDimupScript(sDimupScrTrue);
|
||
|
||
CString sDimdwScr, sDimdwScrTrue;
|
||
xDataMap.GetAt(DOC_SCRIPTB, sDimdwScr);
|
||
CWPipeDimConfigDlg::PipeScript2Detail(sDimdwScr, sDimdwScrTrue);
|
||
pDim->SetDimdownScript(sDimdwScrTrue);
|
||
|
||
pDim->SetPScale(m_dScale);
|
||
pDim->SetTextHeight(dTxtH);
|
||
pDim->SetTextWidthScale(dTxWS);
|
||
|
||
AcGePoint3d ptTmp;
|
||
if (bNegate)
|
||
{
|
||
ptTmp = ptEnd;
|
||
ptEnd = ptSta;
|
||
ptSta = ptTmp;
|
||
}
|
||
|
||
vtDir = ptEnd - ptSta;
|
||
if (vtDir.isParallelTo(AcGeVector3d::kXAxis))
|
||
{
|
||
if (!vtDir.isCodirectionalTo(AcGeVector3d::kXAxis))
|
||
{
|
||
ptTmp = ptEnd;
|
||
ptEnd = ptSta;
|
||
ptSta = ptTmp;
|
||
vtDir.negate();
|
||
}
|
||
}
|
||
|
||
if (vtDir.x < -1.e-10 && vtDir.y > 1.e-10)
|
||
{
|
||
ptTmp = ptEnd;
|
||
ptEnd = ptSta;
|
||
ptSta = ptTmp;
|
||
vtDir.negate();
|
||
}
|
||
|
||
vtDir /= 3.0;
|
||
ptSta += vtDir;
|
||
|
||
pDim->AppendPoint(ptSta);
|
||
pDim->AppendPoint(ptEnd);
|
||
|
||
pDim->SetDimupdownSpace(dDn);
|
||
pDim->SetTextLayerId(m_idDimSty);
|
||
|
||
AcDbVoidPtrArray arSubPtrs;
|
||
pDim->explode(arSubPtrs);
|
||
delete pDim;
|
||
|
||
if (arSubPtrs.length() == 1)
|
||
{
|
||
AcDbText* pText = (AcDbText*)arSubPtrs.first();
|
||
if (bTextISO)
|
||
{
|
||
double dOb = m_xform.GetISOOblique(vtDir);
|
||
pText->setOblique(dOb);
|
||
}
|
||
pText->setTextStyle(m_idDimSty);
|
||
pText->setLayer(m_idDimlay);
|
||
AddISOEnt(pText);
|
||
}
|
||
}
|
||
|
||
double AecISODrawMake::UnderLineLength(LPCTSTR pszDimup ) const
|
||
{
|
||
AcGiTextStyle giTxtStyle;
|
||
fromAcDbTextStyle(giTxtStyle, m_idDimSty);
|
||
|
||
giTxtStyle.setTextSize(m_dTxtH * m_dScale);
|
||
giTxtStyle.setXScale(m_dWFact);
|
||
|
||
CString sDimup = pszDimup;
|
||
int nLen = sDimup.GetLength();
|
||
AcGePoint2d pt2d = giTxtStyle.extents(sDimup, Adesk::kFalse, nLen, Adesk::kTrue);
|
||
|
||
return pt2d.x;
|
||
}
|
||
|
||
void AecISODrawMake::MakeDim4(AcGePoint3d ptPos, AcGeVector3d vtDir, double dRefEl,const AcDbObjectId& idLay)
|
||
{
|
||
AcGeVector3d vtOff = vtDir;
|
||
vtOff.normalize();
|
||
vtOff *= m_dDimoffset * m_dScale;
|
||
|
||
double dEl = ptPos.z - dRefEl;
|
||
//标高按米单位
|
||
dEl /= 1000.0;
|
||
|
||
CString sDimTxt;
|
||
sDimTxt.Format(_T("%.3f"), dEl);
|
||
double dTxtLen = UnderLineLength(sDimTxt);
|
||
|
||
AcGeVector3d vtOffEl = 1.1 * vtOff;
|
||
if (m_bElStyle > 0)
|
||
{
|
||
vtOffEl.normalize();
|
||
vtOffEl *= (dTxtLen + 1.1 * vtOff.length());
|
||
}
|
||
|
||
AcGePoint3d ptGe[5];
|
||
ptGe[4] = ptPos + vtOffEl;
|
||
|
||
//标高标注
|
||
vtOff.normalize();
|
||
vtOff *= 2.0 * m_dDimoffset * m_dScale;
|
||
|
||
ptGe[0] = ptPos + vtOff;
|
||
ptGe[1] = ptGe[0] + vtOff;
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap);
|
||
|
||
double dTxtH = m_dTxtH, dTxWS = 1.0;
|
||
//xDataMap.GetAt(DOC_DIMTXTH, dTxtH);
|
||
xDataMap.GetAt(DOC_DIMTXTF, dTxWS);
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptGe[0]);
|
||
m_xform.GetTransformByThis(ptGe[1]);
|
||
}
|
||
|
||
ptGe[2] = MidPoint(ptGe[0], ptGe[1]);
|
||
AcGeVector3d vtIso = ptGe[1] - ptGe[0];
|
||
vtIso.normalize();
|
||
|
||
AcGeVector3d vtIsoV = vtIso;
|
||
vtIsoV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
vtIsoV.normalize();
|
||
|
||
if (vtIsoV.y < -1.e-10)
|
||
vtIsoV.negate();
|
||
|
||
double dL = 1.732 * m_dTxtH * m_dScale;
|
||
|
||
ptGe[1] = ptGe[2] + vtIsoV * m_dTxtH * m_dScale;
|
||
ptGe[1] -= vtIso * 0.5 * dL;
|
||
ptGe[3] = ptGe[1] + vtIso * dL;
|
||
|
||
ptGe[0] = ptGe[1] + vtIso * (dTxtLen + dL);
|
||
ptGe[0] = ptGe[3];
|
||
ptGe[3] += vtIsoV * 0.2 * m_dTxtH * m_dScale;
|
||
|
||
double dRo = m_xform.GetISORotation(vtIso);
|
||
AcDbText *pText = NULL;
|
||
|
||
if (m_bElStyle == 0)
|
||
{
|
||
pText = new AcDbText;
|
||
pText->setPosition(ptGe[3]);
|
||
|
||
pText->setRotation(dRo);
|
||
|
||
pText->setHeight(m_dTxtH * m_dScale);
|
||
pText->setWidthFactor(m_dWFact);
|
||
pText->setNormal(AcGeVector3d::kZAxis);
|
||
pText->setHorizontalMode(AcDb::kTextLeft);
|
||
pText->setVerticalMode(AcDb::kTextBottom);
|
||
pText->setAlignmentPoint(ptGe[3]);
|
||
sDimTxt.TrimRight(_T('0'));
|
||
if (sDimTxt.CompareNoCase(_T("0.")) == 0)
|
||
sDimTxt = _T("0");
|
||
pText->setTextString(sDimTxt);
|
||
pText->setTextStyle(m_idDimSty);
|
||
pText->setLayer(m_idDimlay);
|
||
|
||
AddISOEnt(pText);
|
||
}
|
||
|
||
//有尾标高符号线
|
||
vtIso = AcGeVector3d::kXAxis;
|
||
vtIso.rotateBy(dRo, AcGeVector3d::kZAxis);
|
||
|
||
ptGe[1] = ptGe[0] + vtIso * (dTxtLen + dL);
|
||
ptGe[2] = ptGe[1] - vtIso * 0.5 * dL;
|
||
ptGe[2] -= vtIsoV * m_dTxtH * m_dScale;
|
||
ptGe[3] = ptGe[1] - vtIso *dL;
|
||
|
||
if (m_bElStyle)
|
||
ptGe[0] = ptGe[3];
|
||
|
||
AcDbPolyline *pPoly = NULL;
|
||
if (m_bElStyle == 0)
|
||
{
|
||
pPoly = new AcDbPolyline;
|
||
for (int i = 0; i < 4; i++)
|
||
{
|
||
pPoly->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
||
}
|
||
|
||
pPoly->setConstantWidth(0);
|
||
pPoly->setLayer(m_idDimlay);
|
||
pPoly->setLinetype(KTSetting::InitLineStyle(_T("Continuous")));
|
||
pPoly->setNormal(AcGeVector3d::kZAxis);
|
||
|
||
AddISOEnt(pPoly);
|
||
}
|
||
|
||
//底线
|
||
AcGePoint3dArray arLn;
|
||
ptGe[2] -= vtIso * dL;
|
||
arLn.append(ptGe[2]);
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptGe[4]);
|
||
arLn.append(ptGe[4]);
|
||
}
|
||
|
||
AcGeVector3d vt = ptGe[2] - ptGe[4];
|
||
if (vt.isCodirectionalTo(vtIso))
|
||
{
|
||
ptGe[2] = ptGe[1] - vtIsoV * m_dTxtH * m_dScale;
|
||
arLn.append(ptGe[2]);
|
||
}
|
||
AcDbLine lnUnder(ptGe[2],ptGe[4]);
|
||
|
||
if (m_bElStyle == 1)
|
||
{
|
||
ptGe[2] += vtIsoV * 0.2 * m_dTxtH * m_dScale;
|
||
pText = new AcDbText;
|
||
pText->setPosition(ptGe[2]);
|
||
|
||
pText->setRotation(dRo);
|
||
|
||
pText->setHeight(m_dTxtH * m_dScale);
|
||
pText->setWidthFactor(m_dWFact);
|
||
pText->setNormal(AcGeVector3d::kZAxis);
|
||
pText->setHorizontalMode(AcDb::kTextLeft);
|
||
pText->setVerticalMode(AcDb::kTextBottom);
|
||
pText->setAlignmentPoint(ptGe[2]);
|
||
sDimTxt.TrimRight(_T('0'));
|
||
if (sDimTxt.CompareNoCase(_T("0.")) == 0)
|
||
sDimTxt = _T("0");
|
||
pText->setTextString(sDimTxt);
|
||
pText->setTextStyle(m_idDimSty);
|
||
pText->setLayer(m_idDimlay);
|
||
|
||
AddISOEnt(pText);
|
||
|
||
ptGe[0] = ptGe[2] - 0.2 * m_dTxtH * m_dScale * vtIso;
|
||
ptGe[0] -= 0.5 * dL * vtIso;
|
||
|
||
ptGe[1] = ptGe[0] + vtIsoV * m_dTxtH * m_dScale;
|
||
ptGe[1] -= 0.5 * dL * vtIso;
|
||
|
||
ptGe[2] = ptGe[1] + dL * vtIso;
|
||
ptGe[3] = ptGe[0];
|
||
|
||
pPoly = new AcDbPolyline;
|
||
for (int i = 0; i < 4; i++)
|
||
{
|
||
pPoly->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
||
}
|
||
|
||
pPoly->setConstantWidth(0);
|
||
pPoly->setLayer(m_idDimlay);
|
||
pPoly->setLinetype(KTSetting::InitLineStyle(_T("Continuous")));
|
||
pPoly->setNormal(AcGeVector3d::kZAxis);
|
||
|
||
AddISOEnt(pPoly);
|
||
|
||
ptGe[1] -= vtIsoV * 1.2 * m_dTxtH * m_dScale;
|
||
arLn.append(ptGe[1]);
|
||
|
||
ptGe[2] -= vtIsoV * 1.2 * m_dTxtH * m_dScale;
|
||
arLn.append(ptGe[2]);
|
||
}
|
||
|
||
//底线
|
||
SortPoints(arLn, &lnUnder);
|
||
|
||
pPoly = new AcDbPolyline;
|
||
pPoly->addVertexAt(0, arLn.first().convert2d(AcGePlane::kXYPlane));
|
||
pPoly->addVertexAt(1, arLn.last().convert2d(AcGePlane::kXYPlane));
|
||
pPoly->setConstantWidth(0);
|
||
pPoly->setLayer(m_idDimlay);
|
||
pPoly->setLinetype(KTSetting::InitLineStyle(_T("Continuous")));
|
||
pPoly->setNormal(AcGeVector3d::kZAxis);
|
||
AddISOEnt(pPoly);
|
||
}
|
||
|
||
int AecISODrawMake::AddISOEnt(AcDbEntity* pEnt)
|
||
{
|
||
int nIndex = m_arISOEntPtrs.append(pEnt);
|
||
return nIndex;
|
||
}
|
||
|
||
AcDbText *AecISODrawMake::MakeDimText(AcGePoint3d ptSta, AcGePoint3d ptEnd, AcGePoint3d ptMid, AcDbObjectId &idSty, double dH,CString &sText)
|
||
{
|
||
AcGeVector3d vt1 = ptEnd - ptSta;
|
||
double dRo = m_xform.GetISORotation(vt1);
|
||
double dOb = m_xform.GetISOOblique(vt1);
|
||
|
||
if (sText.IsEmpty())
|
||
{
|
||
sText.Format(_T("%d"), (int)ptSta.distanceTo(ptEnd));
|
||
}
|
||
|
||
AcDbText *pText = new AcDbText;
|
||
pText->setPosition(ptMid);
|
||
pText->setRotation(dRo);
|
||
|
||
if (m_bDimTxtIso)
|
||
pText->setOblique(dOb);
|
||
|
||
pText->setHeight(dH * m_dScale);
|
||
pText->setWidthFactor(m_dWFact);
|
||
pText->setNormal(AcGeVector3d::kZAxis);
|
||
pText->setHorizontalMode(AcDb::kTextMid);
|
||
pText->setVerticalMode(AcDb::kTextVertMid);
|
||
pText->setTextString(sText);
|
||
pText->setAlignmentPoint(ptMid);
|
||
pText->setTextStyle(m_idDimSty);
|
||
pText->setLayer(m_idDimlay);
|
||
return pText;
|
||
}
|
||
|
||
AcDbText* AecISODrawMake::MakeDimText(AcGePoint3d ptSta,AcGePoint3d ptEnd,double dH,AcDbObjectId& idSty,CString& sText)
|
||
{
|
||
AcGeVector3d vt1 = ptEnd - ptSta;
|
||
double dRo = m_xform.GetISORotation(vt1);
|
||
double dOb = m_xform.GetISOOblique(vt1);
|
||
|
||
if (sText.IsEmpty())
|
||
{
|
||
sText.Format(_T("%d"),(int)ptSta.distanceTo(ptEnd));
|
||
}
|
||
|
||
AcGePoint3d ptMid;
|
||
Midpoint(ptSta,ptEnd,ptMid);
|
||
|
||
if (vt1.isParallelTo(AcGeVector3d::kXAxis))//X
|
||
{
|
||
ptMid.y += (dH * m_dScale);//半个字高间隙
|
||
}
|
||
else if (vt1.isParallelTo(AcGeVector3d::kYAxis))//Y
|
||
{
|
||
ptMid.x -= (dH * m_dScale);//半个字高间隙
|
||
}
|
||
else
|
||
{
|
||
if (vt1.x > 1.e-10 && vt1.y > 1.e-10) //I
|
||
{
|
||
vt1.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
||
vt1.normalize();
|
||
ptMid += (dH * m_dScale * vt1);
|
||
}
|
||
|
||
if (vt1.x < 1.e-10 && vt1.y > 1.e-10) //II
|
||
{
|
||
vt1.rotateBy(-PI / 2.0,AcGeVector3d::kZAxis);
|
||
vt1.normalize();
|
||
ptMid += (dH * m_dScale * vt1);
|
||
}
|
||
|
||
if (vt1.x < 1.e-10 && vt1.y < 1.e-10) //III==I
|
||
{
|
||
vt1.rotateBy(-PI / 2.0,AcGeVector3d::kZAxis);
|
||
vt1.normalize();
|
||
ptMid += (dH * m_dScale * vt1);
|
||
}
|
||
|
||
if (vt1.x > 1.e-10 && vt1.y < 1.e-10) //IV==II
|
||
{
|
||
vt1.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
||
vt1.normalize();
|
||
ptMid += (dH * m_dScale * vt1);
|
||
}
|
||
}
|
||
|
||
|
||
AcDbText* pText = new AcDbText;
|
||
pText->setPosition(ptMid);
|
||
pText->setRotation(dRo);
|
||
|
||
if (m_bDimTxtIso)
|
||
pText->setOblique(dOb);
|
||
|
||
pText->setHeight(dH * m_dScale);
|
||
pText->setWidthFactor(m_dWFact);
|
||
pText->setNormal(AcGeVector3d::kZAxis);
|
||
pText->setHorizontalMode(AcDb::kTextMid);
|
||
pText->setVerticalMode(AcDb::kTextVertMid);
|
||
pText->setTextString(sText);
|
||
pText->setAlignmentPoint(ptMid);
|
||
pText->setTextStyle(m_idDimSty);
|
||
pText->setLayer(m_idDimlay);
|
||
return pText;
|
||
}
|
||
|
||
void AecISODrawMake::MakeISOFittingFlange(AecDbEwFitting* pFitting, double dPlotPipeW, double dPlotDotD, int nPipeDim, int nFitDim, BOOL bElbowLine, BOOL bWelDot, BOOL bVlvISOV)
|
||
{
|
||
if (pFitting == NULL)
|
||
return;
|
||
|
||
if (m_bFitFGHide)
|
||
return;
|
||
|
||
AecDbObjXDataMap *pXDataMap = pFitting->GetSpecialtyData(AcDb::kForRead);
|
||
|
||
int nConnectType = 0;//焊接0 承插1 螺纹2 法兰管3
|
||
pXDataMap->GetAt(PIPE_CONNECT, nConnectType);
|
||
|
||
AcGeVector3d vtV;
|
||
AcGePoint3d ptGe[6];
|
||
CString sKey, sGasketInf, sDimtext, sSpec, sMat, sRem,sLevel, sBoltInfs;
|
||
CStringArray arVals;
|
||
int nIndex = -1, nCountAdd = 1;
|
||
|
||
AcArray<AecInterface> arInfs;
|
||
pFitting->GetInterface(arInfs);
|
||
|
||
for (int i = 0; i < arInfs.length(); i++)
|
||
{
|
||
AecInterface &inf = arInfs.at(i);
|
||
ptGe[0] = inf.ptPos;
|
||
|
||
|
||
//如果是衬塑管,放大间隙
|
||
|
||
|
||
|
||
AcGeVector3d vtDir = inf.vtDir;
|
||
|
||
vtV = vtDir;
|
||
if (vtDir.isParallelTo(AcGeVector3d::kZAxis))
|
||
{
|
||
if (fabs(m_dISOAngle - PI / 4.0) < 1.e-6)
|
||
vtV = AcGeVector3d::kYAxis;//45度为 y
|
||
else
|
||
vtV = AcGeVector3d::kXAxis;//45度为 y
|
||
}
|
||
else
|
||
{
|
||
AcGeLine3d ln(ptGe[0], vtDir);
|
||
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
||
{
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vtV = vtDir.perpVector();
|
||
}
|
||
}
|
||
vtV.normalize();
|
||
|
||
if (bVlvISOV && vtDir.isPerpendicularTo(AcGeVector3d::kZAxis))
|
||
{
|
||
vtV = AcGeVector3d::kZAxis;
|
||
}
|
||
|
||
double dWD = 0.0;
|
||
pXDataMap->GetAt(PIPE_INTERFACED, dWD);
|
||
pXDataMap->GetAt(PIPE_LEVEL, sLevel);
|
||
|
||
ptGe[0] += vtV * 0.5 * dWD;
|
||
ptGe[2] = ptGe[0] - vtV * dWD;
|
||
|
||
//螺纹2 法兰管3 只画竖线
|
||
MakePoly(ptGe[0], ptGe[2], pFitting->layerId(), ( nConnectType == 3 ) ? dPlotPipeW * m_dScale : 0, kColorByLayer, pXDataMap);
|
||
|
||
//承插1
|
||
//绘制U口
|
||
if (nConnectType == 1)
|
||
{
|
||
double dL = 0.0;
|
||
pXDataMap->GetAt(PIPE_INTERFACEL, dL);
|
||
|
||
ptGe[1] = ptGe[0] + vtDir * dL;
|
||
MakePoly(ptGe[0], ptGe[1], pFitting->layerId(), 0.0, kColorByLayer, pXDataMap);
|
||
|
||
ptGe[3] = ptGe[2] + vtDir * dL;
|
||
MakePoly(ptGe[2], ptGe[3], pFitting->layerId(), 0.0, kColorByLayer, pXDataMap);
|
||
}
|
||
|
||
|
||
//统计螺栓 螺母 信息
|
||
//BOLT - 0:专用级双头螺柱#35CrMoA#HG / T 20613 - 2009#螺栓, 专用级双头螺柱, 35CrMoA, HG / T 20613 - 2009, RF, 1.6#M20#105#8#M20#105#8 type : String
|
||
//BOLT - 1:专用级双头螺柱#35CrMoA#HG / T 20613 - 2009#螺栓, 专用级双头螺柱, 35CrMoA, HG / T 20613 - 2009, RF, 1.6#M20#105#8#M20#105#8 type : String
|
||
//GSKT - 0 : 150.0#石棉橡胶板#1.600#1.5#透镜垫, 石棉橡胶板, HG / T 20609 - 2009, RF, 1.6, 1.5 type : String
|
||
//GSKT - 1 : 125.0#石棉橡胶板#1.600#1.5#透镜垫, 石棉橡胶板, HG / T 20609 - 2009, RF, 1.6, 1.5 type : String
|
||
|
||
if (nConnectType == 3 || nConnectType == 5)//无法兰结构 承插 或焊接 无垫片 无法兰
|
||
{
|
||
sKey.Format(_T("%s%d"), PIPE_GASKETINF, i);
|
||
if (pXDataMap->GetAt(sKey, sGasketInf))
|
||
{
|
||
//公称直径#材质#压力]#垫片厚度#描述
|
||
arVals.RemoveAll();
|
||
CoreTools::SplitStrintToArray(sGasketInf, arVals, _T('#'));
|
||
|
||
if (arVals.GetCount() >= 5)
|
||
{
|
||
sSpec = arVals.GetAt(4);
|
||
sMat = arVals.GetAt(1);
|
||
sRem = arVals.GetAt(4);
|
||
|
||
//公称直径#材质#压力#垫片厚度
|
||
sDimtext.Format(_T("垫片 %s %s %s %s"), arVals.GetAt(0), arVals.GetAt(1), arVals.GetAt(2), arVals.GetAt(3));
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMat, sRem, sLevel);
|
||
|
||
AcGeVector3d _v(inf.vtDir.perpVector());
|
||
DimIndex(nIndex, inf.ptPos, _v, pFitting->objectId());
|
||
}
|
||
}
|
||
|
||
sKey.Format(_T("%s%d"), PIPE_BOLTINF, i);
|
||
if (pXDataMap->GetAt(sKey, sBoltInfs))
|
||
{
|
||
//[类型],[材质],[标准号],[描述],螺栓规格,螺栓长度,数量
|
||
arVals.RemoveAll();
|
||
CoreTools::SplitStrintToArray(sBoltInfs, arVals, _T('#'));
|
||
|
||
if (arVals.GetSize() >= 7)
|
||
{
|
||
//专用级双头螺柱 35CrMoA M20x105
|
||
sDimtext.Format(_T("%s %s %sx%s"), arVals.GetAt(0), arVals.GetAt(1), arVals.GetAt(4), arVals.GetAt(5));
|
||
|
||
sSpec = arVals.GetAt(3);
|
||
sMat = arVals.GetAt(1);
|
||
sRem = arVals.GetAt(3);
|
||
nCountAdd = _ttoi(arVals.GetAt(6));
|
||
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMat, sRem, sLevel, nCountAdd);
|
||
//不需要标注
|
||
|
||
//螺母 5CrMoA M20
|
||
sDimtext.Format(_T("%s螺母 %s %s"), arVals.GetAt(0), arVals.GetAt(1), arVals.GetAt(4));
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMat, sRem, sLevel, nCountAdd);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
int AecISODrawMake::AddFitDimtName(CString& sDimtext,CString& sSpec,CString& sFitMat,CString& sRem,CString& sLevel,int nCountAdd)
|
||
{
|
||
sDimtext.TrimRight();
|
||
|
||
int nIndexNo = -1;
|
||
CString sTxt;
|
||
for (int i = 0;i < m_arFitSumRecs.GetSize();i++)
|
||
{
|
||
FitSumRec& fsr = m_arFitSumRecs.GetAt(i);
|
||
if (sDimtext.CompareNoCase(fsr.szDimtext) == 0)
|
||
{
|
||
fsr.nCount += nCountAdd;
|
||
nIndexNo = i + 1;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (nIndexNo == -1)
|
||
{
|
||
FitSumRec fsrt;
|
||
memset(&fsrt, 0, sizeof(FitSumRec));
|
||
|
||
_tcscpy(fsrt.szDimtext, (LPCTSTR)sDimtext);
|
||
_tcscpy(fsrt.szSpec, (LPCTSTR)sSpec);
|
||
_tcscpy(fsrt.szMat, (LPCTSTR)sFitMat);
|
||
_tcscpy(fsrt.szLevel, (LPCTSTR)sLevel);
|
||
|
||
if (sRem.IsEmpty())
|
||
sRem = _T("-");
|
||
_tcscpy(fsrt.szRem, (LPCTSTR)sRem);
|
||
|
||
fsrt.nCount = nCountAdd;
|
||
nIndexNo = m_arFitSumRecs.Add(fsrt);
|
||
nIndexNo += 1;
|
||
}
|
||
|
||
return nIndexNo;
|
||
}
|
||
|
||
void AecISODrawMake::DimIndex(int nIndex, AcGePoint3d& ptPos,AcGeVector3d& vtV,const AcDbObjectId& id)
|
||
{
|
||
if (!m_nDimIndex) return;
|
||
|
||
AcGeVector3d vtDir = vtV;
|
||
AecDbObjXDataMap xDataMap;
|
||
KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap);
|
||
|
||
double dTxtH = m_dTxtH, dTxWS = 1.0;
|
||
//xDataMap.GetAt(DOC_DIMTXTH, dTxtH);
|
||
xDataMap.GetAt(DOC_DIMTXTF, dTxWS);
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptPos);
|
||
m_xform.GetTransformByThis(vtDir);
|
||
}
|
||
|
||
//引出标注
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(PipelineTools::gLayer_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim* pDim = new AecDbEwPipeDim;
|
||
pDim->AddAecDbWEntity(id);
|
||
pDim->SetDimStyle(0);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(1);
|
||
pDim->setLayer(idDimLay);
|
||
pDim->SetTextStyleId(m_idDimSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->setLayer(idDimLay);
|
||
pDim->SetPScale(PipelineTools::getPScale());
|
||
pDim->SetTextHeight(dTxtH);
|
||
pDim->SetTextWidthScale(m_dWFact);
|
||
|
||
CString sNo;
|
||
sNo.Format(_T("%d"),nIndex);
|
||
pDim->AddDimText(sNo, NULL);
|
||
|
||
AcGeVector3d vt[4];
|
||
vt[0].set(1, 1, 0); vt[1].set(-1, 1, 0);
|
||
vt[2].set(-1, -1, 0); vt[3].set(1, -1, 0);
|
||
|
||
vtDir.z = 0;
|
||
|
||
if (vtDir.x > 1.e-10 && vtDir.y > 1.e-10) //I
|
||
{
|
||
vtDir = vt[0];
|
||
}
|
||
else if (vtDir.x < 1.e-10 && vtDir.y > 1.e-10) //II
|
||
{
|
||
vtDir = vt[1];
|
||
}
|
||
else if (vtDir.x < 1.e-10 && vtDir.y < 1.e-10) //III
|
||
{
|
||
vtDir = vt[2];
|
||
}
|
||
else if (vtDir.x > 1.e-10 && vtDir.y < 1.e-10) //IV
|
||
{
|
||
vtDir = vt[3];
|
||
}
|
||
|
||
vtDir.normalize();
|
||
AcGePoint3d ptGe1 = ptPos, ptGe2;
|
||
ptGe2 = ptGe1 + vtDir * 5.0 * dTxtH * PipelineTools::getPScale();
|
||
|
||
pDim->AppendPoint(ptGe1);
|
||
pDim->AppendPoint(ptGe2);
|
||
|
||
AddISOEnt(pDim);
|
||
}
|
||
|
||
void AecISODrawMake::DimIndex(CString& sIndex, AcGePoint3d &ptPos, AcGeVector3d &vtDir,const AcDbObjectId &id)
|
||
{
|
||
if (!m_nDimIndex) return;
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap);
|
||
|
||
double dTxtH = m_dTxtH, dTxWS = 1.0;
|
||
//xDataMap.GetAt(DOC_DIMTXTH, dTxtH);
|
||
xDataMap.GetAt(DOC_DIMTXTF, dTxWS);
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptPos);
|
||
//m_xform.GetTransformByThis(vtDir);
|
||
}
|
||
|
||
//引出标注
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(PipelineTools::gLayer_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim *pDim = new AecDbEwPipeDim;
|
||
pDim->AddAecDbWEntity(id);
|
||
pDim->SetDimStyle(0);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(1);
|
||
pDim->setLayer(idDimLay);
|
||
pDim->SetTextStyleId(m_idDimSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->setLayer(idDimLay);
|
||
pDim->SetPScale(PipelineTools::getPScale());
|
||
pDim->SetTextHeight(dTxtH);
|
||
pDim->SetTextWidthScale(m_dWFact);
|
||
|
||
CString sNo = sIndex;
|
||
pDim->AddDimText(sNo, NULL);
|
||
|
||
AcGeVector3d vt[4];
|
||
vt[0].set(1, 1, 0); vt[1].set(-1, 1, 0);
|
||
vt[2].set(-1, -1, 0); vt[3].set(1, -1, 0);
|
||
|
||
vtDir.z = 0;
|
||
/*if (vtDir.x > 1.e-10 && vtDir.y > 1.e-10) //I
|
||
{
|
||
vtDir = vt[0];
|
||
}
|
||
else if (vtDir.x < 1.e-10 && vtDir.y > 1.e-10) //II
|
||
{
|
||
vtDir = vt[1];
|
||
}
|
||
else if (vtDir.x < 1.e-10 && vtDir.y < 1.e-10) //III
|
||
{
|
||
vtDir = vt[2];
|
||
}
|
||
else if (vtDir.x > 1.e-10 && vtDir.y < 1.e-10) //IV
|
||
{
|
||
vtDir = vt[3];
|
||
}*/
|
||
|
||
vtDir.normalize();
|
||
AcGePoint3d ptGe1 = ptPos, ptGe2;
|
||
ptGe2 = ptGe1 + vtDir * 5.0 * dTxtH * PipelineTools::getPScale();
|
||
|
||
pDim->AppendPoint(ptGe1);
|
||
pDim->AppendPoint(ptGe2);
|
||
|
||
AddISOEnt(pDim);
|
||
}
|
||
|
||
void AecISODrawMake::MakeISOFitting(AcDbObjectIdArray& arFitingIds,double dPlotPipeW,double dPlotDotD,int nPipeDim,int nFitDim,BOOL bElbowLine,BOOL bWelDot, BOOL bVlvISOV)
|
||
{
|
||
AcDbObjectId id;
|
||
AcDbEntity* pEnt = NULL;
|
||
AecDbEwFitting* pFitting = NULL;
|
||
AecDbObjXDataMap* pXDataMap = NULL;
|
||
|
||
AcGePoint3d ptGe[10];
|
||
AcGeVector3d vtDir[6];
|
||
AecInterface intf[4];
|
||
double dL = 0.0,dThk = 0.0,dFD = 0.0,dWD = 0.0,dTemp = 0.0, dTDN = 0;
|
||
double dSW = 0.0,dEW = 0.0,dST = 0.0,dET = 0.0,dBW1 = 0.0,dBW2 = 0.0;
|
||
double dPlus(0.0),dThick = 0, dPress = 1.6,dDN = 0.0,dLen = 0;
|
||
|
||
int nType = 0,nIndex = 0;
|
||
|
||
//iSO 标注内容
|
||
AcGeVector3d vtDirT,vtV, vtOff;
|
||
AcGePoint3d ptPos, ptMid;
|
||
double dGask = 0;
|
||
CString sDimtext,sGaskets = _T(""), sStd = _T(""),sEndF = _T("RF"), sMater, sLevel, sSpec, sRem;
|
||
|
||
for (int i = 0;i < arFitingIds.length();i++)
|
||
{
|
||
id = arFitingIds.at(i);
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead))
|
||
{
|
||
pFitting = AecDbEwFitting::cast(pEnt);
|
||
if (pFitting != NULL)
|
||
{
|
||
sDimtext = _T("");
|
||
pXDataMap = pFitting->GetSpecialtyData(AcDb::kForRead);
|
||
pXDataMap->GetAt(KEY_RUNTIME,nType);
|
||
int nColor = kColorByLayer;
|
||
|
||
pXDataMap->GetAt(_T("COLOR"),nColor);
|
||
pXDataMap->GetAt(PIPE_LEVEL, sLevel);
|
||
pXDataMap->GetAt(PIPE_STDNO, sStd);
|
||
pXDataMap->GetAt(PIPE_MATERIALFT, sMater);
|
||
//pXDataMap->GetAt(PIPE_PRESSURE, dPress);
|
||
pXDataMap->GetAt(PID_PIPE_DPRESS, dPress);
|
||
pXDataMap->GetAt(PIPE_MATERIALFT, sMater);
|
||
pXDataMap->GetAt(PIPE_DESCR, sRem);
|
||
|
||
EFittingType eKind = (EFittingType)nType;
|
||
switch (eKind)
|
||
{
|
||
case eElbow:
|
||
case eReduceElbow:
|
||
{
|
||
pXDataMap->GetAt(KEY_MID,ptGe[1]);
|
||
|
||
pFitting->GetInterface(0,intf[0]);
|
||
pFitting->GetInterface(1,intf[1]);
|
||
|
||
dGask = pFitting->GetGasketThick();
|
||
for(int kk = 0;kk < 2;kk++)
|
||
{
|
||
intf[kk].vtDir.normalize();
|
||
intf[kk].ptPos -= intf[kk].vtDir * 0.5 * dGask;
|
||
}
|
||
|
||
ptGe[0] = intf[0].ptPos;
|
||
ptGe[2] = intf[1].ptPos;
|
||
|
||
vtDir[0] = intf[0].vtDir;
|
||
vtDir[1] = intf[1].vtDir;
|
||
|
||
if (nFitDim > 0)
|
||
{
|
||
for (int k = 0; k < pFitting->GetInterfaceCount(); k++)
|
||
{
|
||
dLen = intf[k].ptPos.distanceTo(ptGe[1]);
|
||
MakeDim(intf[k].ptPos, ptGe[1], dLen);
|
||
}
|
||
}
|
||
|
||
MakeElbowISO(ptGe[0],vtDir[0],ptGe[1],ptGe[2],vtDir[1],dPlotPipeW,dPlotDotD, nFitDim,pFitting->layerId(),bElbowLine,bWelDot,nColor,pXDataMap);
|
||
|
||
//Dxt rat
|
||
pXDataMap->GetAt(PIPE_DN, dDN);
|
||
pXDataMap->GetAt(PIPE_TDN, dTDN);
|
||
pXDataMap->GetAt(PIPE_THICK,dThk);
|
||
pXDataMap->GetAt(PIPE_ELBOWANG, dTemp);
|
||
dTemp *= 180 / PI;
|
||
|
||
if (eReduceElbow)
|
||
{
|
||
sDimtext.Format(_T("变径弯头 DN%d-DN%d %d度 %s %s %s"), (int)(dDN + 0.5), (int)(dTDN + 0.5), (int)(dTemp + 0.5), sLevel, sStd, sMater);
|
||
sSpec.Format(_T("DN%d PN%.1f"), (int)(dDN + 0.5), dPress);
|
||
}
|
||
else
|
||
{
|
||
sDimtext.Format(_T("弯头 DN%d %d度 %s %s %s"), (int)(dDN + 0.5),(int)(dTemp + 0.5), sLevel, sStd, sMater);
|
||
sSpec.Format(_T("DN%d PN%.1f"), (int)(dDN + 0.5), dPress);
|
||
}
|
||
|
||
ptGe[0] = intf[0].ptPos;
|
||
ptGe[2] = intf[1].ptPos;
|
||
pXDataMap->GetAt(KEY_MID, ptGe[1]);
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptGe[0]);
|
||
m_xform.GetTransformByThis(ptGe[1]);
|
||
m_xform.GetTransformByThis(ptGe[2]);
|
||
|
||
vtDir[0] = ptGe[0] - ptGe[1];
|
||
vtDir[1] = ptGe[2] - ptGe[1];
|
||
}
|
||
|
||
vtDir[0].normalize();
|
||
vtDir[1].normalize();
|
||
|
||
vtDirT = vtDir[0] + vtDir[1];
|
||
vtDirT.normalize();
|
||
vtDirT.negate();
|
||
|
||
pXDataMap->GetAt(KEY_MID,ptPos);
|
||
|
||
nIndex = AddFitDimtName(sDimtext,sSpec, sMater,sRem, sLevel);
|
||
DimIndex(nIndex, ptPos, vtDirT,id);
|
||
|
||
MakeISOFittingFlange(pFitting, dPlotPipeW, dPlotDotD, nPipeDim, nFitDim, bElbowLine, bWelDot,bVlvISOV);
|
||
|
||
break;
|
||
}
|
||
case eReduce:
|
||
{
|
||
pFitting->GetInterface(0,intf[0]);
|
||
pFitting->GetInterface(1,intf[1]);
|
||
|
||
for (int kk = 0; kk < 2; kk++)
|
||
{
|
||
intf[kk].vtDir.normalize();
|
||
intf[kk].ptPos -= intf[kk].vtDir * 0.5 * dGask;
|
||
}
|
||
|
||
ptGe[0] = intf[0].ptPos;
|
||
ptGe[2] = intf[1].ptPos;
|
||
vtDir[0] = intf[0].vtDir;
|
||
vtDir[1] = intf[1].vtDir;
|
||
|
||
AcGeLine3d ln3d(intf[0].ptPos, intf[0].vtDir);
|
||
if (ln3d.isParallelTo(AcGePlane::kXYPlane))
|
||
{
|
||
vtV = intf[1].ptPos - intf[0].ptPos;
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vtV = intf[0].vtDir.perpVector();
|
||
}
|
||
vtV.normalize();
|
||
|
||
if (bVlvISOV && vtDir->isPerpendicularTo(AcGeVector3d::kZAxis))
|
||
{
|
||
vtV = AcGeVector3d::kZAxis;
|
||
}
|
||
|
||
MakeReducer(ptGe[0],ptGe[2],dPlotPipeW,dPlotDotD, nFitDim,pFitting->layerId(),bWelDot,nColor,pXDataMap);
|
||
|
||
//外边线
|
||
ptGe[3] = ptGe[0] + vtV * 0.5 * intf[0].dSize1;
|
||
ptGe[4] = ptGe[0] - vtV * 0.5 * intf[0].dSize1;
|
||
|
||
MakeReducer(ptGe[3], ptGe[4], dPlotPipeW, dPlotDotD, 0, pFitting->layerId(), bWelDot, nColor, pXDataMap);
|
||
|
||
ptGe[5] = ptGe[2] + vtV * 0.5 * intf[1].dSize2;
|
||
ptGe[6] = ptGe[2] - vtV * 0.5 * intf[1].dSize2;
|
||
MakeReducer(ptGe[5], ptGe[6], dPlotPipeW, dPlotDotD, 0, pFitting->layerId(), bWelDot, nColor, pXDataMap);
|
||
|
||
MakeReducer(ptGe[3], ptGe[5], dPlotPipeW, dPlotDotD, 0, pFitting->layerId(), bWelDot, nColor, pXDataMap);
|
||
MakeReducer(ptGe[4], ptGe[6], dPlotPipeW, dPlotDotD, 0, pFitting->layerId(), bWelDot, nColor, pXDataMap);
|
||
|
||
pXDataMap->GetAt(PIPE_DN, dDN);
|
||
pXDataMap->GetAt(PIPE_TDN, dTDN);
|
||
|
||
vtOff.set(0, 0, 0);
|
||
pXDataMap->GetAt(KEY_OFFSET, vtOff);
|
||
|
||
//500×400-Sch80 GB/T 13401
|
||
if (vtOff.isZeroLength())
|
||
sDimtext.Format(_T("变径 DN%d-%d %s %s %s"), (int)(dDN + 0.5), (int)(dTDN + 0.5), sLevel,sStd,sMater);
|
||
else
|
||
sDimtext.Format(_T("偏心变径 DN%d-%d %s %s %s"), (int)(dDN + 0.5), (int)(dTDN + 0.5), sLevel, sStd, sMater);
|
||
|
||
sSpec.Format(_T("DN%d-%d PN%.1f"), (int)(dDN + 0.5), (int)(dTDN + 0.5), dPress);
|
||
|
||
Midpoint(ptGe[2],ptGe[0],ptPos);
|
||
|
||
vtDirT = ptGe[2] - ptGe[0];
|
||
vtV = vtDirT;
|
||
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
||
vtV.normalize();
|
||
ptPos += vtV * dPlotPipeW;
|
||
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
DimIndex(nIndex, ptPos, vtV, id);
|
||
|
||
MakeISOFittingFlange(pFitting, dPlotPipeW, dPlotDotD, nPipeDim, nFitDim, bElbowLine, bWelDot, bVlvISOV);
|
||
|
||
break;
|
||
}
|
||
case eTee:
|
||
case eLateral:
|
||
case eWye:
|
||
{
|
||
pXDataMap->GetAt(KEY_MID,ptGe[1]);
|
||
|
||
pFitting->GetInterface(0,intf[0]);
|
||
pFitting->GetInterface(1,intf[1]);
|
||
pFitting->GetInterface(2,intf[2]);
|
||
|
||
for (int kk = 0; kk < 3; kk++)
|
||
{
|
||
intf[kk].vtDir.normalize();
|
||
intf[kk].ptPos -= intf[kk].vtDir * 0.5 * dGask;
|
||
}
|
||
|
||
ptGe[0] = intf[0].ptPos;
|
||
ptGe[2] = intf[1].ptPos;
|
||
ptGe[3] = intf[2].ptPos;
|
||
|
||
MakeTeeISO(ptGe[0],ptGe[2],ptGe[3],ptGe[1],dPlotPipeW,dPlotDotD, nFitDim,pFitting->layerId(),bWelDot,nColor,pXDataMap);
|
||
|
||
if (nFitDim > 0)
|
||
{
|
||
for (int k = 0;k < pFitting->GetInterfaceCount();k++)
|
||
{
|
||
dLen = intf[k].ptPos.distanceTo(ptGe[1]);
|
||
MakeDim(intf[k].ptPos, ptGe[1], dLen);
|
||
}
|
||
}
|
||
|
||
pXDataMap->GetAt(PIPE_DN,dDN);
|
||
pXDataMap->GetAt(PIPE_TDN, dTDN);
|
||
|
||
if (eKind == eTee)
|
||
sDimtext.Format(_T("三通 DN%dx%d %s %s %s"),(int)(dDN + 0.5), (int)(dTDN + 0.5), sLevel, sStd, sMater);
|
||
else if(eKind == eLateral)
|
||
sDimtext.Format(_T("L三通 DN%dx%d %s %s %s"), (int)(dDN + 0.5),(int)(dTDN + 0.5), sLevel, sStd, sMater);
|
||
else if(eKind == eWye)
|
||
sDimtext.Format(_T("Y三通 DN%dx%d %s %s %s"), (int)(dDN + 0.5), (int)(dTDN + 0.5), sLevel, sStd, sMater);
|
||
|
||
sSpec.Format(_T("DN%dx%d PN%.1f"), (int)(dDN + 0.5), (int)(dTDN + 0.5),dPress);
|
||
|
||
vtDirT = ptGe[2] - ptGe[0];
|
||
|
||
vtV = vtDirT;
|
||
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
||
vtV.normalize();
|
||
|
||
ptPos = ptGe[1] + vtV * dPlotPipeW;
|
||
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
DimIndex(nIndex, ptPos, vtV, id);
|
||
|
||
MakeISOFittingFlange(pFitting, dPlotPipeW, dPlotDotD, nPipeDim, nFitDim, bElbowLine, bWelDot,bVlvISOV);
|
||
|
||
break;
|
||
}
|
||
case eCross:
|
||
{
|
||
pXDataMap->GetAt(KEY_MID,ptGe[1]);
|
||
|
||
pFitting->GetInterface(0,intf[0]);
|
||
pFitting->GetInterface(1,intf[1]);
|
||
pFitting->GetInterface(2,intf[2]);
|
||
pFitting->GetInterface(3,intf[3]);
|
||
|
||
for (int kk = 0; kk < 4; kk++)
|
||
{
|
||
intf[kk].vtDir.normalize();
|
||
intf[kk].ptPos -= intf[kk].vtDir * 0.5 * dGask;
|
||
}
|
||
|
||
ptGe[0] = intf[0].ptPos;
|
||
ptGe[2] = intf[1].ptPos;
|
||
ptGe[3] = intf[2].ptPos;
|
||
ptGe[4] = intf[3].ptPos;
|
||
|
||
MakeCrossISO(ptGe,dPlotPipeW,dPlotDotD, nFitDim,pFitting->layerId(),bWelDot,nColor,pXDataMap);
|
||
|
||
if (nFitDim > 0)
|
||
{
|
||
for (int k = 0; k < pFitting->GetInterfaceCount(); k++)
|
||
{
|
||
dLen = intf[k].ptPos.distanceTo(ptGe[1]);
|
||
MakeDim(intf[k].ptPos, ptGe[1], dLen);
|
||
}
|
||
}
|
||
|
||
pXDataMap->GetAt(PIPE_DN, dDN);
|
||
pXDataMap->GetAt(PIPE_TDN, dTDN);
|
||
|
||
sDimtext.Format(_T("四通 DN%dx%d %s %s %s"), (int)(dDN + 0.5), (int)(dTDN + 0.5), sLevel, sStd, sMater);
|
||
sSpec.Format(_T("DN%dx%d PN%.1f"), (int)(dDN + 0.5), (int)(dTDN + 0.5), dPress);
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptGe[0]);
|
||
m_xform.GetTransformByThis(ptGe[3]);
|
||
}
|
||
|
||
vtDirT = ptGe[3] - ptGe[0];
|
||
vtV = vtDirT;
|
||
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
||
vtV.normalize();
|
||
|
||
pXDataMap->GetAt(KEY_MID, ptGe[1]);
|
||
ptPos = ptGe[1] + vtV * dPlotPipeW;
|
||
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
DimIndex(nIndex, ptPos, vtV, id);
|
||
|
||
MakeISOFittingFlange(pFitting, dPlotPipeW, dPlotDotD, nPipeDim, nFitDim, bElbowLine, bWelDot, bVlvISOV);
|
||
|
||
break;
|
||
}
|
||
case eWcap:
|
||
{
|
||
pXDataMap->GetAt(KEY_START,ptGe[0]);
|
||
pXDataMap->GetAt(KEY_MAJBR,vtDir[0]);
|
||
pXDataMap->GetAt(KEY_L,dL);
|
||
|
||
vtDir[0].normalize();
|
||
ptGe[1] = ptGe[0] + vtDir[0] * dL;
|
||
MakePoly(ptGe[0],ptGe[1],pFitting->layerId(),dPlotPipeW * m_dScale,nColor,pXDataMap);
|
||
if (bWelDot)
|
||
{
|
||
MakeWDot(ptGe[0],pFitting->layerId(),dPlotDotD * m_dScale);
|
||
}
|
||
|
||
if (nFitDim)
|
||
MakeDim(ptGe[0],ptGe[1],ptGe[0].distanceTo(ptGe[1]));
|
||
|
||
pXDataMap->GetAt(PIPE_DN, dDN);
|
||
|
||
sDimtext.Format(_T("堵头 DN%d sLevel, sStd, sMater"),(int)(dDN + 0.5), sLevel, sStd, sMater);
|
||
sSpec.Format(_T("DN%dx%d PN%.1f"), (int)(dDN + 0.5), (int)(dTDN + 0.5), dPress);
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptGe[0]);
|
||
m_xform.GetTransformByThis(ptGe[1]);
|
||
}
|
||
|
||
vtDirT = ptGe[1] - ptGe[0];
|
||
vtV = vtDirT;
|
||
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
||
vtV.normalize();
|
||
ptPos = ptGe[0] + vtV * dPlotPipeW;
|
||
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
DimIndex(nIndex, ptPos, vtV, id);
|
||
|
||
break;
|
||
}
|
||
case eFlange:
|
||
{
|
||
pXDataMap->GetAt(KEY_START,ptGe[0]);//
|
||
pXDataMap->GetAt(PIPE_THICK,dThk); //总厚
|
||
pXDataMap->GetAt(PIPE_WD,dWD); //发兰盘外径
|
||
pXDataMap->GetAt(KEY_MAJBR,vtDir[0]);//
|
||
|
||
pFitting->GetInterface(0, intf[0]);
|
||
pFitting->GetInterface(1, intf[1]);
|
||
|
||
vtV = vtDir[0];
|
||
if (vtDir[0].isParallelTo(AcGeVector3d::kZAxis))
|
||
{
|
||
if (fabs(m_dISOAngle - PI / 4.0) < 1.e-6)
|
||
vtV = AcGeVector3d::kYAxis;//45度为 y
|
||
else
|
||
vtV = AcGeVector3d::kXAxis;//45度为 y
|
||
}
|
||
else
|
||
{
|
||
AcGeLine3d ln(ptGe[0],vtDir[0]);
|
||
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
||
{
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vtV = vtDir[0].perpVector();
|
||
}
|
||
}
|
||
vtV.normalize();
|
||
if (bVlvISOV && vtDir[0].isPerpendicularTo(AcGeVector3d::kZAxis))
|
||
{
|
||
vtV = AcGeVector3d::kZAxis;
|
||
}
|
||
|
||
//取中点绘制法兰
|
||
ptGe[0] = MidPoint(intf[0].ptPos, intf[1].ptPos);
|
||
ptGe[0] += vtV * 0.5 * dWD;
|
||
ptGe[1] = ptGe[0] - vtV * dWD;
|
||
|
||
MakePoly(ptGe[0], ptGe[1], pFitting->layerId(), dPlotPipeW *m_dScale, nColor, pXDataMap);
|
||
|
||
if (bWelDot)
|
||
{
|
||
MakeWDot(MidPoint(intf[0].ptPos, intf[1].ptPos),pFitting->layerId(),dPlotDotD * m_dScale);
|
||
}
|
||
|
||
//三者其一
|
||
pXDataMap->GetAt(PIPE_FLANGF,sEndF);
|
||
pXDataMap->GetAt(PIPE_FLANGF1,sEndF);
|
||
pXDataMap->GetAt(PIPE_FLANGF2,sEndF);
|
||
|
||
//法兰 DN100-PN1.6 RF GB/T9116.1-2000
|
||
sDimtext.Format(_T("法兰 DN%d-PN%.1f %s %s"), (int)(dDN + 0.5), dPress, sEndF, sStd);
|
||
sSpec.Format(_T("DN%d-PN%.1f"), (int)(dDN + 0.5), dPress);
|
||
|
||
vtDirT = intf[0].vtDir;
|
||
ptPos = MidPoint(intf[0].ptPos, intf[1].ptPos);
|
||
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
DimIndex(nIndex, ptPos, vtDirT, id);
|
||
|
||
break;
|
||
}
|
||
case eFlxJoin:
|
||
{
|
||
pXDataMap->GetAt(KEY_MAJBR, vtDir[0]);
|
||
pXDataMap->GetAt(KEY_MID, ptGe[0]);
|
||
|
||
pXDataMap->GetAt(KEY_A, dWD);
|
||
|
||
pXDataMap->GetAt(KEY_TYPE, sRem);
|
||
pXDataMap->GetAt(PIPE_STDNO, sStd);
|
||
|
||
vtV = vtDir[0];
|
||
if (vtDir[0].isParallelTo(AcGeVector3d::kZAxis))
|
||
{
|
||
if (fabs(m_dISOAngle - PI / 4.0) < 1.e-6)
|
||
vtV = AcGeVector3d::kYAxis;//45度为 y
|
||
else
|
||
vtV = AcGeVector3d::kXAxis;//45度为 y
|
||
}
|
||
else
|
||
{
|
||
AcGeLine3d ln(ptGe[0], vtDir[0]);
|
||
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
||
{
|
||
vtV.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
vtV = vtDir[0].perpVector();
|
||
}
|
||
}
|
||
vtV.normalize();
|
||
|
||
//取中点绘制
|
||
ptGe[0] += vtV * 0.5 * dWD;
|
||
ptGe[1] = ptGe[0] - vtV * dWD;
|
||
|
||
MakePoly(ptGe[0], ptGe[1], pFitting->layerId(), dPlotPipeW *m_dScale, nColor, pXDataMap);
|
||
|
||
if (bWelDot)
|
||
{
|
||
MakeWDot(MidPoint(intf[0].ptPos, intf[1].ptPos), pFitting->layerId(), dPlotDotD * m_dScale);
|
||
}
|
||
|
||
//卡箍 DN100-PN1.6 RF GB/T9116.1-2000
|
||
sDimtext.Format(_T("卡箍 DN%d-PN%.1f %s %s"), (int)(dDN + 0.5), dPress, sRem, sStd);
|
||
sSpec.Format(_T("DN%d-PN%.1f"), (int)(dDN + 0.5), dPress);
|
||
|
||
vtDirT = vtDir[0];
|
||
ptPos = MidPoint(ptGe[0], ptGe[1]);
|
||
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
DimIndex(nIndex, ptPos, vtDirT, id);
|
||
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
AecDbHvacFitting* pHFit = AecDbHvacFitting::cast(pEnt);
|
||
if (pHFit != NULL)
|
||
{
|
||
AecHvac::DuctParam data;
|
||
memset(&data,0,sizeof(AecHvac::DuctParam));
|
||
pHFit->GetDuctParam(data);
|
||
|
||
pXDataMap = pHFit->GetSpecialtyData(AcDb::kForRead);
|
||
|
||
sLevel = _T(""); sStd = _T("");
|
||
sMater = _T("");
|
||
dPress = 0.0; sMater = _T("");
|
||
sRem = _T("");
|
||
|
||
sMater = data.szMat;
|
||
sRem = data.szRem;
|
||
|
||
pXDataMap->GetAt(PIPE_LEVEL, sLevel);
|
||
pXDataMap->GetAt(PIPE_STDNO, sStd);
|
||
pXDataMap->GetAt(PID_PIPE_DPRESS, dPress);
|
||
|
||
pXDataMap->GetAt(KEY_RUNTIME,nType);
|
||
|
||
int nColor = kColorByLayer;
|
||
pXDataMap->GetAt(_T("COLOR"),nColor);
|
||
|
||
switch(nType)
|
||
{
|
||
case eElbow:
|
||
{
|
||
pXDataMap->GetAt(HELB_CornerPoint,ptGe[1]);
|
||
pHFit->GetInterface(0,intf[0]);
|
||
pHFit->GetInterface(1,intf[1]);
|
||
|
||
ptGe[0] = intf[0].ptPos;
|
||
ptGe[2] = intf[1].ptPos;
|
||
vtDir[0] = intf[0].vtDir;
|
||
vtDir[1] = intf[1].vtDir;
|
||
|
||
MakeHElbowISO(ptGe[0],vtDir[0],ptGe[1],ptGe[2],vtDir[1],dPlotPipeW,dPlotDotD, nFitDim,pHFit->layerId(),bElbowLine,bWelDot,nColor,pXDataMap);
|
||
|
||
if (nPipeDim > 0)
|
||
{
|
||
for (int k = 0; k < pHFit->GetInterfaceCount(); k++)
|
||
{
|
||
dLen = intf[k].ptPos.distanceTo(ptGe[1]);
|
||
MakeDim(intf[k].ptPos, ptGe[1], dLen);
|
||
}
|
||
}
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptGe[0]);
|
||
m_xform.GetTransformByThis(ptGe[2]);
|
||
}
|
||
|
||
if (data.eType == eCircle)
|
||
{
|
||
//Dxt rat
|
||
sDimtext.Format(_T("D%dx%.1f %.1f"),(int)(data.dSize[0]+0.5),data.dSize[2],data.m_dRatio);
|
||
vtDirT = ptGe[2] - ptGe[0];
|
||
pXDataMap->GetAt(HELB_CornerPoint,ptPos);
|
||
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(ptPos);
|
||
}
|
||
else
|
||
{
|
||
sDimtext.Format(_T("%dx%d t=%.1f %.1f"),(int)(data.dSize[0]+0.5),(int)(data.dSize[1] + 0.5),data.dSize[2],data.m_dRatio);
|
||
vtDirT = ptGe[2] - ptGe[0];
|
||
pXDataMap->GetAt(HELB_CornerPoint,ptPos);
|
||
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(ptPos);
|
||
}
|
||
|
||
vtDirT = vtDir[0] + vtDir[1];
|
||
vtDirT.normalize();
|
||
vtDirT.negate();
|
||
|
||
pXDataMap->GetAt(HELB_CornerPoint, ptPos);
|
||
|
||
sSpec = sDimtext;
|
||
sDimtext.Insert(0, _T("风管弯头"));
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
DimIndex(nIndex, ptPos, vtDirT, id);
|
||
|
||
break;
|
||
}
|
||
case eReduce:
|
||
{
|
||
pHFit->GetInterface(0,intf[0]);
|
||
pHFit->GetInterface(1,intf[1]);
|
||
|
||
ptGe[0] = intf[0].ptPos;
|
||
ptGe[2] = intf[2].ptPos;
|
||
vtDir[0] = intf[0].vtDir;
|
||
vtDir[1] = intf[1].vtDir;
|
||
|
||
MakeHReducer(ptGe[0],ptGe[2],dPlotPipeW,dPlotDotD, nFitDim,pHFit->layerId(),bWelDot,nColor,pXDataMap);
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptGe[0]);
|
||
m_xform.GetTransformByThis(ptGe[2]);
|
||
}
|
||
|
||
vtDirT = ptGe[2] - ptGe[0];
|
||
Midpoint(ptGe[2],ptGe[0],ptPos);
|
||
vtV = vtDirT;
|
||
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
||
vtV.normalize();
|
||
ptPos += vtV * dPlotPipeW;
|
||
|
||
if (data.eType == eCircle)
|
||
{
|
||
//Dxt rat
|
||
pXDataMap->GetAt(HRED_StartWidth,dSW);
|
||
pXDataMap->GetAt(HRED_EndWidth,dEW);
|
||
|
||
sDimtext.Format(_T("D%d-D%d"),(int)(dSW+0.5),(int)(dEW+0.5));
|
||
|
||
vtDirT = ptGe[2] - ptGe[0];
|
||
pXDataMap->GetAt(HELB_CornerPoint,ptPos);
|
||
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(ptPos);
|
||
}
|
||
else
|
||
{
|
||
pXDataMap->GetAt(HRED_StartWidth,dSW);
|
||
pXDataMap->GetAt(HRED_EndWidth,dEW);
|
||
|
||
pXDataMap->GetAt(HRED_StartThick,dST);
|
||
pXDataMap->GetAt(HRED_EndThick,dET);
|
||
|
||
sDimtext.Format(_T("%dx%.1f-%dx%.1f"),(int)(dSW+0.5),(int)(dST+0.5),(int)(dEW+0.5),(int)(dET+0.5));
|
||
|
||
vtDirT = ptGe[2] - ptGe[0];
|
||
pXDataMap->GetAt(HELB_CornerPoint,ptPos);
|
||
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(ptPos);
|
||
}
|
||
|
||
vtDirT = vtDir[0] + vtDir[1];
|
||
vtDirT.normalize();
|
||
vtDirT.negate();
|
||
|
||
sSpec = sDimtext;
|
||
sDimtext.Insert(0, _T("风管变径"));
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
DimIndex(nIndex, intf[0].ptPos, vtDirT, id);
|
||
|
||
break;
|
||
}
|
||
break;
|
||
case eTee:
|
||
{
|
||
pHFit->GetInterface(0,intf[0]);
|
||
pHFit->GetInterface(1,intf[1]);
|
||
pHFit->GetInterface(2,intf[2]);
|
||
|
||
ptGe[0] = intf[0].ptPos;
|
||
ptGe[2] = intf[1].ptPos;
|
||
ptGe[3] = intf[2].ptPos;
|
||
ptGe[1] = MidPoint(ptGe[0],ptGe[2]);
|
||
|
||
vtDir[0] = intf[0].vtDir;
|
||
vtDir[1] = intf[2].vtDir;
|
||
|
||
MakeHTeeISO(ptGe[0],ptGe[2],ptGe[3],ptGe[1],dPlotPipeW,dPlotDotD, nFitDim,pHFit->layerId(),bWelDot,nColor,pXDataMap);
|
||
|
||
if (nPipeDim > 0)
|
||
{
|
||
for (int k = 0; k < pHFit->GetInterfaceCount(); k++)
|
||
{
|
||
dLen = intf[k].ptPos.distanceTo(ptGe[1]);
|
||
MakeDim(intf[k].ptPos, ptGe[1], dLen);
|
||
}
|
||
}
|
||
|
||
pXDataMap->GetAt(HCRS_StartWidth, dSW);
|
||
pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
pXDataMap->GetAt(HCRS_EndWidth, dEW);
|
||
pXDataMap->GetAt(HCRS_Branch1Width, dBW1);
|
||
pXDataMap->GetAt(HCRS_Branch2Width, dBW2);
|
||
|
||
if (data.eType == eCircle)
|
||
{
|
||
sDimtext.Format(_T("%dx%.1f-%dx%.1f"),(int)(dSW+0.5),(int)(dThick+0.5),(int)(dBW1+0.5),(int)(dBW2+0.5));
|
||
}
|
||
else
|
||
{
|
||
sDimtext.Format(_T("D%d-D%dx"),(int)(dSW+0.5),(int)(dEW+0.5));
|
||
}
|
||
|
||
vtDirT = ptGe[2] - ptGe[0];
|
||
pXDataMap->GetAt(HCRS_StartPoint,ptPos);
|
||
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(ptPos);
|
||
|
||
vtDirT = vtDir[0] + vtDir[1];
|
||
vtDirT.normalize();
|
||
vtDirT.negate();
|
||
|
||
sSpec = sDimtext;
|
||
sDimtext.Insert(0, _T("风管三通"));
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
DimIndex(nIndex, ptGe[1], vtDirT, id);
|
||
|
||
break;
|
||
}
|
||
case eCross:
|
||
{
|
||
pHFit->GetInterface(0,intf[0]);
|
||
pHFit->GetInterface(1,intf[1]);
|
||
pHFit->GetInterface(2,intf[2]);
|
||
pHFit->GetInterface(3,intf[3]);
|
||
|
||
ptGe[0] = intf[0].ptPos;
|
||
ptGe[2] = intf[1].ptPos;
|
||
|
||
ptGe[3] = intf[2].ptPos;
|
||
ptGe[4] = intf[3].ptPos;
|
||
|
||
vtDir[0] = intf[0].vtDir;
|
||
vtDir[1] = intf[2].vtDir;
|
||
|
||
ptGe[1] = MidPoint(ptGe[0],ptGe[2]);
|
||
|
||
MakeHCrossISO(ptGe,dPlotPipeW,dPlotDotD, nFitDim,pHFit->layerId(),bWelDot,nColor,pXDataMap);
|
||
|
||
if (nPipeDim > 0)
|
||
{
|
||
for (int k = 0; k < pHFit->GetInterfaceCount(); k++)
|
||
{
|
||
dLen = intf[k].ptPos.distanceTo(ptGe[1]);
|
||
MakeDim(intf[k].ptPos, ptGe[1], dLen);
|
||
}
|
||
}
|
||
|
||
pXDataMap->GetAt(HCRS_StartWidth, dSW);
|
||
pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
pXDataMap->GetAt(HCRS_EndWidth, dEW);
|
||
pXDataMap->GetAt(HCRS_Branch1Width, dBW1);
|
||
pXDataMap->GetAt(HCRS_Branch2Width, dBW2);
|
||
|
||
if (data.eType == eCircle)
|
||
{
|
||
sDimtext.Format(_T("%dx%.1f-%dx%.1f"),(int)(dSW+0.5),(int)(dThick+0.5),(int)(dBW1+0.5),(int)(dBW2+0.5));
|
||
}
|
||
else
|
||
{
|
||
sDimtext.Format(_T("D%d-D%dx"),(int)(dSW+0.5),(int)(dEW+0.5));
|
||
}
|
||
|
||
vtDirT = ptGe[2] - ptGe[0];
|
||
pXDataMap->GetAt(HCRS_StartPoint,ptPos);
|
||
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(ptPos);
|
||
|
||
|
||
vtDirT = vtDir[0] + vtDir[1];
|
||
vtDirT.normalize();
|
||
vtDirT.negate();
|
||
|
||
sSpec = sDimtext;
|
||
sDimtext.Insert(0, _T("风管四通"));
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
DimIndex(nIndex, ptGe[1], vtDirT, id);
|
||
|
||
break;
|
||
}
|
||
case eOffset:
|
||
{
|
||
pHFit->GetInterface(0,intf[0]);
|
||
pHFit->GetInterface(1,intf[1]);
|
||
|
||
ptGe[0] = intf[0].ptPos;
|
||
ptGe[3] = intf[1].ptPos;
|
||
|
||
vtDir[0] = intf[0].vtDir;
|
||
vtDir[1] = intf[1].vtDir;
|
||
|
||
pXDataMap->GetAt(HVAC_PlusEdge, dPlus);
|
||
ptGe[1] = ptGe[0] - dPlus * intf[0].vtDir;
|
||
ptGe[2] = ptGe[3] - dPlus * intf[1].vtDir;
|
||
|
||
MakePoly(ptGe[0],ptGe[1],pHFit->layerId(),dPlotPipeW * m_dScale,nColor,pXDataMap);
|
||
MakePoly(ptGe[1],ptGe[2],pHFit->layerId(),dPlotPipeW * m_dScale,nColor,pXDataMap);
|
||
MakePoly(ptGe[2],ptGe[3],pHFit->layerId(),dPlotPipeW * m_dScale,nColor,pXDataMap);
|
||
|
||
pXDataMap->GetAt(HCRS_StartWidth, dSW);
|
||
pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
pXDataMap->GetAt(HCRS_EndWidth, dEW);
|
||
|
||
if (data.eType == eCircle)
|
||
{
|
||
sDimtext.Format(_T("%dx%.1f-%dx%.1f"),(int)(dSW+0.5),(int)(dThick+0.5),(int)(dEW+0.5),(int)(dThick+0.5));
|
||
}
|
||
else
|
||
{
|
||
sDimtext.Format(_T("D%d-D%dx"),(int)(dSW+0.5),(int)(dEW+0.5));
|
||
}
|
||
|
||
vtDirT = ptGe[2] - ptGe[0];
|
||
pXDataMap->GetAt(HCRS_StartPoint,ptPos);
|
||
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(ptPos);
|
||
|
||
vtDirT = vtDir[0] + vtDir[1];
|
||
vtDirT.normalize();
|
||
vtDirT.negate();
|
||
|
||
sSpec = sDimtext;
|
||
sDimtext.Insert(0, _T("风管乙字弯"));
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
DimIndex(nIndex, intf[0].ptPos, vtDirT, id);
|
||
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
AecDbEcFitting *pEFit = AecDbEcFitting::cast(pEnt);
|
||
if (pEFit != NULL)
|
||
{
|
||
AcArray<AecInterface> arInfs;
|
||
pEFit->GetInterface(arInfs);
|
||
|
||
AecHvac::DuctParam dp;
|
||
memset(&dp,0, sizeof(AecHvac::DuctParam));
|
||
pEFit->GetDuctParam(dp);
|
||
|
||
sDimtext = _T("");
|
||
pXDataMap = pEFit->GetSpecialtyData(AcDb::kForRead);
|
||
|
||
pXDataMap->GetAt(KEY_MID, ptMid);
|
||
|
||
ptPos = ptMid;
|
||
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(ptPos);
|
||
|
||
int nColor = kColorByLayer;
|
||
pXDataMap->GetAt(_T("COLOR"), nColor);
|
||
|
||
sLevel = _T(""); sStd = _T("");
|
||
sMater = _T("");
|
||
dPress = 0.0; sMater = _T("");
|
||
sRem = _T("");
|
||
|
||
pXDataMap->GetAt(PIPE_LEVEL, sLevel);
|
||
pXDataMap->GetAt(PIPE_STDNO, sStd);
|
||
sMater = dp.szMat;
|
||
pXDataMap->GetAt(PID_PIPE_DPRESS, dPress);
|
||
sRem = dp.szRem;
|
||
pXDataMap->GetAt(KEY_RUNTIME, nType);
|
||
|
||
for (int ii = 0;ii < arInfs.length();ii++)
|
||
{
|
||
AecInterface &inf = arInfs.at(ii);
|
||
|
||
MakePoly(inf.ptPos, ptMid, pEFit->layerId(), dPlotPipeW *m_dScale, nColor, pXDataMap);
|
||
}
|
||
|
||
if (nPipeDim > 0)
|
||
{
|
||
for (int k = 0; k < pEFit->GetInterfaceCount(); k++)
|
||
{
|
||
dLen = arInfs.at(k).ptPos.distanceTo(ptMid);
|
||
MakeDim(arInfs.at(k).ptPos, ptMid, dLen);
|
||
}
|
||
}
|
||
|
||
ptGe[0] = arInfs.first().ptPos;
|
||
ptGe[2] = arInfs.last().ptPos;
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptGe[0]);
|
||
m_xform.GetTransformByThis(ptGe[2]);
|
||
}
|
||
|
||
vtDirT = ptGe[2] - ptGe[0];
|
||
|
||
int nTeeStyle = 0;
|
||
switch (nType)
|
||
{
|
||
case eElbow:
|
||
{
|
||
sDimtext = _T("桥架弯通");
|
||
break;
|
||
}
|
||
case eTee:
|
||
{
|
||
pXDataMap->GetAt(KEY_TEESTYLE, nTeeStyle);
|
||
|
||
if (nTeeStyle == 0)
|
||
sDimtext = _T("桥架三通");
|
||
else if (nTeeStyle > 0 && nTeeStyle < 4)
|
||
sDimtext = _T("桥架垂直三通");
|
||
else if(nTeeStyle >= 4 && nTeeStyle <= 5)
|
||
sDimtext = _T("桥架垂直三通");
|
||
break;
|
||
}
|
||
case eCross:
|
||
{
|
||
sDimtext = _T("桥架四通");
|
||
break;
|
||
}
|
||
case eReduce:
|
||
{
|
||
sDimtext = _T("桥架异径接头");
|
||
break;
|
||
}
|
||
case eOffset:
|
||
{
|
||
sDimtext = _T("桥架乙字弯通");
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
|
||
|
||
sRem.Format(_T("%s %dx%d %s %s %s"), dp.szType, (int)(dp.dSize[0] + 0.5), (int)(dp.dSize[1] + 0.5), dp.szSys, dp.szNo, dp.szMat);
|
||
sSpec.Format(_T("%dx%d"), (int)(dp.dSize[0] + 0.5), (int)(dp.dSize[1] + 0.5));
|
||
|
||
//标注索引
|
||
nIndex = AddFitDimtName(sDimtext, sSpec, sMater, sRem, sLevel);
|
||
DimIndex(nIndex, ptMid, vtDirT, id);
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeElbowISO(AcGePoint3d& ptSta,AcGeVector3d& vtSta,AcGePoint3d& ptMid,
|
||
AcGePoint3d& ptEnd,AcGeVector3d& vtEnd,double dPlotPipeW,
|
||
double dPlotDotD,int nPipeDim,const AcDbObjectId& idLay,
|
||
BOOL bElbowLine,BOOL bWelDot,int nCr,AecDbObjXDataMap* pXDataMap)
|
||
{
|
||
if (bElbowLine)
|
||
{
|
||
MakePoly(ptSta,ptMid,idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
MakePoly(ptMid,ptEnd,idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
}
|
||
else
|
||
{
|
||
AcGeVector3d vtNorm = vtEnd.crossProduct(vtSta);
|
||
AcGeVector3d vtStaV = vtSta;
|
||
vtStaV.rotateBy(PI / 2.0,vtNorm);
|
||
|
||
AcGeVector3d vtEndV = vtEnd;
|
||
vtEndV.rotateBy(PI / 2.0,vtNorm);
|
||
|
||
AcGeLine3d ln1(ptSta,vtStaV);
|
||
AcGeLine3d ln2(ptEnd,vtEndV);
|
||
|
||
AcGePoint3d ptCen;
|
||
if ( ln1.intersectWith(ln2,ptCen) )
|
||
{
|
||
AcDbCircle cir;
|
||
cir.setCenter(ptCen);
|
||
cir.setRadius(ptSta.distanceTo(ptCen));
|
||
cir.setNormal(vtNorm);
|
||
|
||
AcGePoint3dArray pts;
|
||
pts.append(ptSta);
|
||
pts.append(ptEnd);
|
||
|
||
AcDbVoidPtrArray arCrvptrs;
|
||
cir.getSplitCurves(pts,arCrvptrs);
|
||
|
||
AcDbLine ln;
|
||
ln.setStartPoint(ptMid);
|
||
ln.setEndPoint(ptCen);
|
||
ln.setNormal(vtNorm);
|
||
|
||
AcDbCurve* pArc = NULL;
|
||
AcDbCurve* pCrv = NULL;
|
||
|
||
for (int i = 0;i < arCrvptrs.length();i++)
|
||
{
|
||
pCrv = (AcDbCurve*)arCrvptrs.at(i);
|
||
|
||
pts.setLogicalLength(0);
|
||
ln.intersectWith(pCrv,AcDb::kOnBothOperands,pts);
|
||
|
||
if (pts.length() > 0)
|
||
{
|
||
pArc = pCrv;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
delete pCrv;
|
||
}
|
||
}
|
||
|
||
if (pArc != NULL)
|
||
{
|
||
double dSta = 0.0,dEnd = 0.0;
|
||
pArc->getStartParam(dSta);
|
||
pArc->getEndParam(dEnd);
|
||
|
||
double dStep = (dEnd - dSta) / 5;
|
||
AcGePoint3d ptGe;
|
||
|
||
AcDbPolyline* pPoly = new AcDbPolyline;
|
||
for (int i = 0;i <= 5;i++)
|
||
{
|
||
pArc->getPointAtParam(dSta + i * dStep,ptGe);
|
||
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(ptGe);
|
||
pPoly->addVertexAt(i,ptGe.convert2d(AcGePlane::kXYPlane));
|
||
}
|
||
pPoly->setConstantWidth(dPlotPipeW * m_dScale);
|
||
pPoly->setLayer(idLay);
|
||
pPoly->setColorIndex(nCr);
|
||
pPoly->setNormal(AcGeVector3d::kZAxis);
|
||
|
||
if (pXDataMap != NULL)
|
||
{
|
||
pXDataMap->Write(pPoly,BIMDATA_APP);
|
||
}
|
||
AddISOEnt(pPoly);
|
||
|
||
if (nPipeDim) //标注
|
||
{
|
||
AcGePoint3d ptSta1 = ptSta;
|
||
AcGePoint3d ptEnd1 = ptEnd;
|
||
AcGePoint3d ptMid1 = ptMid;
|
||
|
||
MakeDim(ptSta1,ptMid1,ptSta1.distanceTo(ptMid));
|
||
MakeDim(ptMid1,ptEnd1,ptEnd1.distanceTo(ptMid));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//焊接点
|
||
if (bWelDot)
|
||
{
|
||
MakeWDot(ptSta,idLay,dPlotDotD * m_dScale);
|
||
MakeWDot(ptEnd,idLay,dPlotDotD * m_dScale);
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeHElbowISO(AcGePoint3d& ptSta,AcGeVector3d& vtSta,AcGePoint3d& ptMid,
|
||
AcGePoint3d& ptEnd,AcGeVector3d& vtEnd,double dPlotPipeW,
|
||
double dPlotDotD,int nPipeDim,const AcDbObjectId& idLay,
|
||
BOOL bElbowLine,BOOL bWelDot,int nCr,AecDbObjXDataMap* pXDataMap)
|
||
{
|
||
if (bElbowLine)
|
||
{
|
||
MakePoly(ptSta,ptMid,idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
MakePoly(ptMid,ptEnd,idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
}
|
||
else
|
||
{
|
||
AcGeVector3d vtNorm = vtEnd.crossProduct(vtSta);
|
||
AcGeVector3d vtStaV = vtSta;
|
||
vtStaV.rotateBy(PI / 2.0,vtNorm);
|
||
|
||
AcGeVector3d vtEndV = vtEnd;
|
||
vtEndV.rotateBy(PI / 2.0,vtNorm);
|
||
|
||
AcGeLine3d ln1(ptSta,vtStaV);
|
||
AcGeLine3d ln2(ptEnd,vtEndV);
|
||
|
||
AcGePoint3d ptCen;
|
||
if ( ln1.intersectWith(ln2,ptCen) )
|
||
{
|
||
AcDbCircle cir;
|
||
cir.setCenter(ptCen);
|
||
cir.setRadius(ptSta.distanceTo(ptCen));
|
||
cir.setNormal(vtNorm);
|
||
|
||
AcGePoint3dArray pts;
|
||
pts.append(ptSta);
|
||
pts.append(ptEnd);
|
||
|
||
AcDbVoidPtrArray arCrvptrs;
|
||
cir.getSplitCurves(pts,arCrvptrs);
|
||
|
||
AcDbLine ln;
|
||
ln.setStartPoint(ptMid);
|
||
ln.setEndPoint(ptCen);
|
||
ln.setNormal(vtNorm);
|
||
|
||
AcDbCurve* pArc = NULL;
|
||
AcDbCurve* pCrv = NULL;
|
||
|
||
for (int i = 0;i < arCrvptrs.length();i++)
|
||
{
|
||
pCrv = (AcDbCurve*)arCrvptrs.at(i);
|
||
|
||
pts.setLogicalLength(0);
|
||
ln.intersectWith(pCrv,AcDb::kOnBothOperands,pts);
|
||
|
||
if (pts.length() > 0)
|
||
{
|
||
pArc = pCrv;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
delete pCrv;
|
||
}
|
||
}
|
||
|
||
if (pArc != NULL)
|
||
{
|
||
double dSta = 0.0,dEnd = 0.0;
|
||
pArc->getStartParam(dSta);
|
||
pArc->getEndParam(dEnd);
|
||
|
||
double dStep = (dEnd - dSta) / 5;
|
||
AcGePoint3d ptGe;
|
||
|
||
AcDbPolyline* pPoly = new AcDbPolyline;
|
||
for (int i = 0;i <= 5;i++)
|
||
{
|
||
pArc->getPointAtParam(dSta + i * dStep,ptGe);
|
||
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(ptGe);
|
||
|
||
pPoly->addVertexAt(i,ptGe.convert2d(AcGePlane::kXYPlane));
|
||
}
|
||
pPoly->setConstantWidth(dPlotPipeW * m_dScale);
|
||
pPoly->setLayer(idLay);
|
||
pPoly->setColorIndex(nCr);
|
||
pPoly->setNormal(AcGeVector3d::kZAxis);
|
||
|
||
if (pXDataMap != NULL)
|
||
{
|
||
pXDataMap->Write(pPoly,BIMDATA_APP);
|
||
}
|
||
AddISOEnt(pPoly);
|
||
|
||
if (nPipeDim) //标注
|
||
{
|
||
AcGePoint3d ptSta1 = ptSta;
|
||
AcGePoint3d ptEnd1 = ptEnd;
|
||
AcGePoint3d ptMid1 = ptMid;
|
||
|
||
MakeDim(ptSta1,ptMid1,ptSta1.distanceTo(ptMid));
|
||
MakeDim(ptMid1,ptEnd1,ptEnd1.distanceTo(ptMid));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//焊接点
|
||
if (bWelDot)
|
||
{
|
||
//绘制法兰线
|
||
AcGePoint3d ptSta1 = ptSta;
|
||
AcGePoint3d ptEnd1 = ptEnd;
|
||
AcGePoint3d ptMid1 = ptMid;
|
||
|
||
AcGeVector3d vtS = ptEnd1 - ptMid1;
|
||
vtS.normalize();
|
||
|
||
AcGeVector3d vtE = ptSta1 - ptMid1;
|
||
vtE.normalize();
|
||
|
||
AcGePoint3d ptGe[2];
|
||
ptGe[0] = ptSta1 + vtS * dPlotDotD * m_dScale;
|
||
ptGe[1] = ptSta1 - vtS * dPlotDotD * m_dScale;
|
||
MakePoly(ptGe[0],ptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
|
||
ptGe[0] = ptEnd1 + vtE * dPlotDotD * m_dScale;
|
||
ptGe[1] = ptEnd1 - vtE * dPlotDotD * m_dScale;
|
||
MakePoly(ptGe[0],ptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeReducer(AcGePoint3d ptGe0,AcGePoint3d ptGe1,double dPlotPipeW,double dPlotDotD,int nPipeDim,const AcDbObjectId& idLay,BOOL bWelDot,int nCr/* = 256*/,AecDbObjXDataMap* pXDataMap)
|
||
{
|
||
MakePoly(ptGe0,ptGe1,idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
|
||
//焊接点
|
||
if (bWelDot)
|
||
{
|
||
MakeWDot(ptGe0,idLay,dPlotDotD * m_dScale);
|
||
MakeWDot(ptGe1,idLay,dPlotDotD * m_dScale);
|
||
}
|
||
|
||
if (nPipeDim) //标注
|
||
MakeDim(ptGe0,ptGe1,ptGe0.distanceTo(ptGe1));
|
||
}
|
||
|
||
void AecISODrawMake::MakeHReducer(AcGePoint3d ptGe0,AcGePoint3d ptGe1,double dPlotPipeW,double dPlotDotD,int nPipeDim,const AcDbObjectId& idLay,BOOL bWelDot,int nCr/* = 256*/,AecDbObjXDataMap* pXDataMap)
|
||
{
|
||
MakePoly(ptGe0,ptGe1,idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
|
||
//焊接点
|
||
if (bWelDot)
|
||
{
|
||
AcGeVector3d vt = ptGe1 - ptGe0;
|
||
vt.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
||
vt.normalize();
|
||
|
||
AcGePoint3d ptGe[2];
|
||
ptGe[0] = ptGe0 + vt * dPlotDotD * m_dScale;
|
||
ptGe[1] = ptGe0 - vt * dPlotDotD * m_dScale;
|
||
MakePoly(ptGe[0],ptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
|
||
ptGe[0] = ptGe1 + vt * dPlotDotD * m_dScale;
|
||
ptGe[1] = ptGe1 - vt * dPlotDotD * m_dScale;
|
||
MakePoly(ptGe[0],ptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
}
|
||
|
||
if (nPipeDim) //标注
|
||
MakeDim(ptGe0,ptGe1,ptGe0.distanceTo(ptGe1));
|
||
}
|
||
|
||
void AecISODrawMake::MakeTeeISO(AcGePoint3d ptGe0,AcGePoint3d ptGe1,AcGePoint3d ptGe2,AcGePoint3d ptMid,
|
||
double dPlotPipeW,double dPlotDotD,int nPipeDim,const AcDbObjectId& idLay,BOOL bWelDot,int nCr/* = 256*/,AecDbObjXDataMap* pXDataMap)
|
||
{
|
||
MakePoly(ptGe0,ptMid,idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
MakePoly(ptGe1,ptMid,idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
MakePoly(ptGe2,ptMid,idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
|
||
//焊接点
|
||
if (bWelDot)
|
||
{
|
||
MakeWDot(ptGe0,idLay,dPlotDotD * m_dScale);
|
||
MakeWDot(ptGe1,idLay,dPlotDotD * m_dScale);
|
||
MakeWDot(ptGe2,idLay,dPlotDotD * m_dScale);
|
||
}
|
||
|
||
if (nPipeDim > 0)
|
||
{
|
||
MakeDim(ptGe0,ptMid,ptGe0.distanceTo(ptMid));
|
||
MakeDim(ptGe1,ptMid,ptGe1.distanceTo(ptMid));
|
||
MakeDim(ptGe2,ptMid,ptGe2.distanceTo(ptMid));
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeHTeeISO( AcGePoint3d ptGe0,AcGePoint3d ptGe1,AcGePoint3d ptGe2,AcGePoint3d ptMid,
|
||
double dPlotPipeW,double dPlotDotD,int nPipeDim,const AcDbObjectId& idLay,BOOL bWelDot,int nCr/* = 256*/,AecDbObjXDataMap* pXDataMap)
|
||
|
||
{
|
||
MakePoly(ptGe0,ptMid,idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
MakePoly(ptGe1,ptMid,idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
MakePoly(ptGe2,ptMid,idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
|
||
//焊接点
|
||
if (bWelDot)
|
||
{
|
||
AcGeVector3d vtS = ptGe2 - ptMid;
|
||
vtS.normalize();
|
||
|
||
AcGeVector3d vtB = ptGe1 - ptGe0;
|
||
vtB.normalize();
|
||
|
||
AcGePoint3d ptGe[2];
|
||
ptGe[0] = ptGe0 + vtS * dPlotDotD * m_dScale;
|
||
ptGe[1] = ptGe0 - vtS * dPlotDotD * m_dScale;
|
||
MakePoly(ptGe[0],ptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
|
||
ptGe[0] = ptGe1 + vtS * dPlotDotD * m_dScale;
|
||
ptGe[1] = ptGe1 - vtS * dPlotDotD * m_dScale;
|
||
MakePoly(ptGe[0],ptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
|
||
ptGe[0] = ptGe2 + vtB * dPlotDotD * m_dScale;
|
||
ptGe[1] = ptGe2 - vtB * dPlotDotD * m_dScale;
|
||
MakePoly(ptGe[0],ptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
}
|
||
|
||
if (nPipeDim > 0)
|
||
{
|
||
MakeDim(ptGe0,ptMid,ptGe0.distanceTo(ptMid));
|
||
MakeDim(ptGe1,ptMid,ptGe1.distanceTo(ptMid));
|
||
MakeDim(ptGe2,ptMid,ptGe2.distanceTo(ptMid));
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeHCrossISO( AcGePoint3d* pptGe,double dPlotPipeW,double dPlotDotD,int nPipeDim,const AcDbObjectId& idLay,BOOL bWelDot,int nCr/* = 256*/,AecDbObjXDataMap* pXDataMap)
|
||
{
|
||
MakePoly(pptGe[0],pptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
MakePoly(pptGe[2],pptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
MakePoly(pptGe[3],pptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
MakePoly(pptGe[4],pptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
|
||
//焊接点
|
||
if (bWelDot)
|
||
{
|
||
AcGeVector3d vtS;
|
||
AcGePoint3d ptGe[2];
|
||
|
||
for(int i = 0;i < 5;i++)
|
||
{
|
||
if (i == 1)
|
||
continue;
|
||
|
||
vtS = pptGe[i] - pptGe[1];
|
||
vtS.normalize();
|
||
vtS.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
||
|
||
ptGe[0] = pptGe[1] + vtS * dPlotDotD * m_dScale;
|
||
ptGe[1] = pptGe[1] - vtS * dPlotDotD * m_dScale;
|
||
MakePoly(ptGe[0],ptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
}
|
||
}
|
||
|
||
if (nPipeDim > 0)
|
||
{
|
||
MakeDim(pptGe[0],pptGe[2],pptGe[0].distanceTo(pptGe[2]));
|
||
MakeDim(pptGe[4],pptGe[3],pptGe[4].distanceTo(pptGe[3]));
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeCrossISO( AcGePoint3d* pptGe,double dPlotPipeW,double dPlotDotD,int nPipeDim,const AcDbObjectId& idLay,BOOL bWelDot,int nCr/* = 256*/,AecDbObjXDataMap* pXDataMap)
|
||
{
|
||
MakePoly(pptGe[0],pptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
MakePoly(pptGe[2],pptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
MakePoly(pptGe[3],pptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
MakePoly(pptGe[4],pptGe[1],idLay,dPlotPipeW * m_dScale,nCr,pXDataMap);
|
||
|
||
//焊接点
|
||
if (bWelDot)
|
||
{
|
||
MakeWDot(pptGe[0],idLay,dPlotDotD * m_dScale);
|
||
MakeWDot(pptGe[2],idLay,dPlotDotD * m_dScale);
|
||
MakeWDot(pptGe[3],idLay,dPlotDotD * m_dScale);
|
||
MakeWDot(pptGe[4],idLay,dPlotDotD * m_dScale);
|
||
}
|
||
|
||
if (nPipeDim > 0)
|
||
{
|
||
MakeDim(pptGe[0],pptGe[2],pptGe[0].distanceTo(pptGe[2]));
|
||
MakeDim(pptGe[4],pptGe[3],pptGe[4].distanceTo(pptGe[3]));
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeWDot(AcGePoint3d ptGeCen,const AcDbObjectId& idLay,double dPlotDotD)
|
||
{
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(ptGeCen);
|
||
|
||
double dDotRadius = dPlotDotD * 0.5;
|
||
AcGePoint2d ptGeCenDot = ptGeCen.convert2d(AcGePlane::kXYPlane);
|
||
AcGePoint2d ptGe[4];
|
||
double dBulge = tan(PI / 8.0);
|
||
|
||
ptGe[0] = ptGeCenDot + dDotRadius * AcGeVector2d::kYAxis;
|
||
ptGe[1] = ptGeCenDot + dDotRadius * AcGeVector2d::kXAxis;
|
||
ptGe[2] = ptGeCenDot - dDotRadius * AcGeVector2d::kYAxis;
|
||
ptGe[3] = ptGeCenDot - dDotRadius * AcGeVector2d::kXAxis;
|
||
|
||
AcDbPolyline* pDot = new AcDbPolyline;
|
||
pDot->addVertexAt(0,ptGe[0],-dBulge);
|
||
pDot->addVertexAt(1,ptGe[1],-dBulge);
|
||
pDot->addVertexAt(2,ptGe[2],-dBulge);
|
||
pDot->addVertexAt(3,ptGe[3],-dBulge);
|
||
pDot->addVertexAt(4,ptGe[0],0.0);
|
||
pDot->setConstantWidth(dPlotDotD);
|
||
pDot->setClosed(Adesk::kTrue);
|
||
pDot->setNormal(AcGeVector3d::kZAxis);
|
||
pDot->setLayer(idLay);
|
||
|
||
AddISOEnt(pDot);
|
||
}
|
||
|
||
int Extract3dSolidOrderEdages(AcDb3dSolid* pSolid,AcDbVoidPtrArray& arLinePtrs)
|
||
{
|
||
//临时加入db
|
||
AcDbObjectId id;
|
||
id = CoreTools::AddToModelSpace(pSolid);
|
||
|
||
if ( Acad::eOk != acdbOpenAcDbEntity((AcDbEntity*&)pSolid,id,AcDb::kForRead))
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
AcBrBrep pBrep;
|
||
AcDbFullSubentPath _PP (id, kNullSubentId);
|
||
pBrep.setSubentPath(_PP);
|
||
|
||
AcBr::ErrorStatus returnValue = AcBr::eOk;
|
||
AcBrBrepFaceTraverser brepFaceTrav;
|
||
if (brepFaceTrav.setBrep(pBrep) != AcBr::eOk)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
AcDbLine* pLn = NULL;
|
||
int faceCount = 0;
|
||
while (!brepFaceTrav.done() && (returnValue == AcBr::eOk))
|
||
{
|
||
faceCount++;
|
||
|
||
AcBrFace face;
|
||
if ( brepFaceTrav.getFace(face)
|
||
!= AcBr::eOk)
|
||
{
|
||
continue ;
|
||
}
|
||
|
||
AcGeSurface *pGeSurface = NULL;
|
||
face.getSurface(pGeSurface);
|
||
|
||
AcGeInterval intervalU, intervalV;
|
||
pGeSurface->getEnvelope(intervalU, intervalV);
|
||
|
||
AcBrFaceLoopTraverser faLoTrav;
|
||
for ( faLoTrav.setFace(face); !faLoTrav.done(); faLoTrav.next() )
|
||
{
|
||
AcBrLoop lp;
|
||
faLoTrav.getLoop(lp);
|
||
|
||
AcBrLoopEdgeTraverser loEdTrav;
|
||
if ( loEdTrav.setLoop(faLoTrav) == AcBr::eOk)
|
||
{
|
||
int edgeCount = 0;
|
||
AcGePoint2dArray verts;
|
||
AcGeVoidPointerArray edgeArray;
|
||
for (;! loEdTrav.done(); loEdTrav.next())
|
||
{
|
||
edgeCount++;
|
||
|
||
AcBrEdge edge;
|
||
loEdTrav.getEdge(edge);
|
||
|
||
AcBrVertex start;
|
||
edge.getVertex1( start );
|
||
AcGePoint3d stPt3d;
|
||
start.getPoint( stPt3d );
|
||
|
||
AcBrVertex end;
|
||
edge.getVertex2( end );
|
||
AcGePoint3d endPt3d;
|
||
end.getPoint( endPt3d );
|
||
|
||
Adesk::Boolean orient = Adesk::kFalse;
|
||
loEdTrav.getEdgeOrientToLoop(orient);
|
||
if (orient)
|
||
{
|
||
pLn = new AcDbLine(stPt3d,endPt3d);
|
||
arLinePtrs.append(pLn);
|
||
}
|
||
else
|
||
{
|
||
pLn = new AcDbLine(endPt3d,stPt3d);
|
||
arLinePtrs.append(pLn);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
returnValue = brepFaceTrav.next();
|
||
}
|
||
|
||
pSolid->upgradeOpen();
|
||
pSolid->erase();
|
||
pSolid->downgradeOpen();
|
||
pSolid->close();
|
||
|
||
return arLinePtrs.length();
|
||
}
|
||
|
||
static void Rotate90(AecComplexCurve& cplCurve, AcGePoint3d& ptIns, AcGeVector3d& vtDir2)
|
||
{
|
||
AcGeMatrix3d xm;
|
||
xm.setToRotation(PI / 2.0, vtDir2, ptIns);
|
||
cplCurve.transformBy(xm);
|
||
}
|
||
|
||
void AecISODrawMake::MakeISOVal(AcDbObjectIdArray& arValIds,int nVal2D,double dPlotDotD,BOOL bDNDim,BOOL bDimTxtIso,BOOL bVlvISOV)
|
||
{
|
||
AcDbObjectId id;
|
||
AcDbEntity* pEnt = NULL;
|
||
AecDbObjXDataMap* pXDataMap = NULL;
|
||
|
||
AcGeVector3d vtDir,vtV,vtDir2;
|
||
AcGePoint3d ptSta,ptEnd,ptIns;
|
||
AcGePoint3d ptGe1,ptGe2,ptGeIns;
|
||
AcDbEntity* pSubEnt = NULL,*pSubEnt2 = NULL;
|
||
CString sName, sSpec, sMater, sRem, sLevel;
|
||
|
||
//子实体类型绘制
|
||
int nType = 0,nIndex = 0;
|
||
|
||
for (int i = 0;i < arValIds.length();i++)
|
||
{
|
||
id = arValIds.at(i);
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead))
|
||
{
|
||
AecDbEwEquipment* pEqu = AecDbEwEquipment::cast(pEnt);
|
||
if (pEqu != NULL)
|
||
{
|
||
pXDataMap = pEqu->GetSpecialtyData(AcDb::kForRead);
|
||
|
||
nType = 0;
|
||
pXDataMap->GetAt(KEY_SUBRUNTIME,nType);
|
||
EFittingType eSubType = (EFittingType)nType;
|
||
|
||
pEqu->GetInsert(ptGeIns,vtDir);
|
||
|
||
AcDbExtents ext;
|
||
pEqu->getGeomExtents(ext);
|
||
|
||
vtV = ext.maxPoint() - ext.minPoint();
|
||
vtV = vtV.orthoProject(vtDir);
|
||
vtV.normalize();
|
||
|
||
if ( eSubType == eValve )
|
||
{
|
||
//三维炸碎
|
||
if (nVal2D)
|
||
{
|
||
CPoint pt;
|
||
pt.x = m_arISOEntPtrs.length();
|
||
|
||
//提取ISO阀门
|
||
AcDbCurve* pCurve = NULL;
|
||
AecComplexCurve cplCurve;
|
||
|
||
bool bIs45 = false;
|
||
if ( fabs(m_dISOAngle - PI / 4.0) < 1.e-6)
|
||
bIs45 = true;
|
||
|
||
pEqu->DrawValveForISO(cplCurve,true,bIs45);
|
||
|
||
AcDbVoidPtrArray arHdFlg;
|
||
AcGiExplodeDraw dc(arHdFlg);
|
||
pEqu->DrawHandFlg(dc);
|
||
|
||
//如果水平阀门需求竖直放置
|
||
pEqu->GetInsert(ptIns, vtDir2);
|
||
|
||
if (vtDir2.isPerpendicularTo(AcGeVector3d::kZAxis) &&
|
||
bVlvISOV)
|
||
{
|
||
Rotate90(cplCurve, ptIns, vtDir2);
|
||
}
|
||
|
||
int nColor = kColorByLayer;
|
||
if (pXDataMap != NULL && pXDataMap->GetAt(_T("COLOR"), nColor))
|
||
{
|
||
}
|
||
|
||
for (int j = 0;j < cplCurve.length();j++)
|
||
{
|
||
pCurve = cplCurve.segat(j);
|
||
if (pCurve != NULL)
|
||
{
|
||
pCurve->setLayer(pEqu->layerId());
|
||
pCurve->setColorIndex(kColorByLayer);
|
||
CovertToISO(pCurve,pXDataMap);
|
||
}
|
||
if (pCurve != NULL) delete pCurve;
|
||
}
|
||
|
||
|
||
for (int j = 0;j < arHdFlg.length();j++)
|
||
{
|
||
pSubEnt2 = (AcDbEntity*)arHdFlg.at(j);
|
||
pSubEnt2->setLayer(pEqu->layerId());
|
||
pSubEnt2->setColorIndex(kColorByLayer);
|
||
CovertToISO(pSubEnt2, pXDataMap);
|
||
}
|
||
|
||
pt.y = m_arISOEntPtrs.length() - 1;
|
||
if (pt.y > pt.x)
|
||
{
|
||
m_arGrpIdx.Add(pt);
|
||
}
|
||
}
|
||
else //有问题,产生乱线2025-11-3!! 上游注释掉
|
||
{
|
||
AcDbVoidPtrArray arEntPtrs;
|
||
AcGiExplodeDraw dc(arEntPtrs);
|
||
pEqu->Draw2d(dc);
|
||
|
||
CPoint pt;
|
||
pt.x = m_arISOEntPtrs.length();
|
||
|
||
for (int j = 0;j < arEntPtrs.length();j++)
|
||
{
|
||
pSubEnt = (AcDbEntity*)arEntPtrs.at(j);
|
||
|
||
AcDbArc *pArc = AcDbArc::cast(pSubEnt);
|
||
AcDbEllipse* pEArc = AcDbEllipse::cast(pSubEnt);
|
||
AcDbSpline* pSPL = AcDbSpline::cast(pSubEnt);
|
||
AcDb3dSolid* pSolid = AcDb3dSolid::cast(pSubEnt);
|
||
|
||
if (pArc != NULL ||
|
||
pEArc != NULL ||
|
||
pSPL != NULL )
|
||
{
|
||
AcGePoint3dArray arpts;
|
||
PipelineTools::GetSamplePoints(pArc, arpts);
|
||
for (int i = 0; i < arpts.length() - 1; ++i)
|
||
{
|
||
AcDbLine *pLine = new AcDbLine(arpts[i], arpts[i + 1]);
|
||
|
||
AcGePoint3d ptSta = pLine->startPoint();
|
||
AcGePoint3d ptEnd = pLine->endPoint();
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptSta);
|
||
}
|
||
|
||
pLine->setStartPoint(ptSta);
|
||
pLine->setEndPoint(ptEnd);
|
||
pXDataMap->Write(pLine,BIMDATA_APP);
|
||
AddISOEnt(pLine);
|
||
}
|
||
}
|
||
else if (pSolid != NULL)
|
||
{
|
||
AcDbVoidPtrArray arLnPtrs;
|
||
Extract3dSolidOrderEdages(pSolid,arLnPtrs);
|
||
|
||
AcDbEntity* pEntT = NULL;
|
||
for (int ii = 0;ii < arLnPtrs.length();ii++)
|
||
{
|
||
pEntT = (AcDbEntity*)arLnPtrs.at(ii);
|
||
AcDbLine* pLnT = AcDbLine::cast(pEntT);
|
||
if (pLnT != NULL)
|
||
{
|
||
AcGePoint3d ptSta = pLnT->startPoint();
|
||
AcGePoint3d ptEnd = pLnT->endPoint();
|
||
|
||
double dDis = ptSta.distanceTo(ptEnd);
|
||
if (dDis < 1.e-1)
|
||
{
|
||
arLnPtrs.removeAt(ii);
|
||
ii -= 1;
|
||
continue;
|
||
}
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
pLnT->setStartPoint(ptSta);
|
||
pLnT->setEndPoint(ptEnd);
|
||
pXDataMap->Write(pLnT,BIMDATA_APP);
|
||
AddISOEnt(pLnT);
|
||
}
|
||
}
|
||
arEntPtrs.removeAt(j);
|
||
j -= 1;
|
||
}
|
||
else
|
||
{
|
||
AcDbCurve *pCurve = (AcDbCurve*)pSubEnt->clone();
|
||
if (pCurve)
|
||
{
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(pCurve);
|
||
|
||
pXDataMap->Write(pCurve,BIMDATA_APP);
|
||
AddISOEnt(pCurve);
|
||
}
|
||
}
|
||
}
|
||
|
||
pt.y = m_arISOEntPtrs.length() - 1;
|
||
if (pt.y > pt.x)
|
||
{
|
||
m_arGrpIdx.Add(pt);
|
||
}
|
||
}
|
||
|
||
/*if (bDNDim)
|
||
{
|
||
double dDn = 0.0;
|
||
pXDataMap->GetAt(PIPE_DN,dDn);
|
||
ptGeIns += vtV * 2.0 * dDn;
|
||
ptSta = ptGeIns - vtDir * 10.0;
|
||
ptEnd = ptGeIns + vtDir * 10.0;
|
||
MakeDim3(pXDataMap,ptSta,ptEnd,pEqu->layer(),dPlotDotD * m_dScale,bDimTxtIso);
|
||
}*/
|
||
|
||
sName = _T("阀门");
|
||
pXDataMap->GetAt(KEY_NAME, sName);
|
||
pXDataMap->GetAt(PIPE_LEVEL, sLevel);
|
||
pXDataMap->GetAt(PIPE_DESCR, sRem);
|
||
|
||
if (!sName.IsEmpty())
|
||
{
|
||
sSpec = sName;
|
||
int nIndex = AddFitDimtName(sName, sSpec, sMater, sRem, sLevel);
|
||
|
||
vtV.set(-1, -1, 0);
|
||
DimIndex(nIndex, ptGeIns, vtV, id);
|
||
}
|
||
}
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeISOHanger(AcDbObjectIdArray& arHangIds, double dPlotDotD,int nPipeDim, int nFitDim)
|
||
{
|
||
CMapStringToString mapNameToRomaIndex;
|
||
int nRomIndex = 0;
|
||
AcGeVector3d vtDirT;
|
||
AcGePoint3d ptPos;
|
||
AcDbLine lnDir;
|
||
AcDbObjectId id;
|
||
AcDbEntity *pEnt = NULL,*pSubEnt = NULL;
|
||
for (int i = 0;i < arHangIds.length();i++)
|
||
{
|
||
id = arHangIds.at(i);
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
|
||
{
|
||
AecDbEntityBase *pAecEnt = AecDbEntityBase::cast(pEnt);
|
||
if (pAecEnt != NULL)
|
||
{
|
||
AecDbPipeHanger *pPHg = AecDbPipeHanger::cast(pAecEnt);
|
||
if (pPHg == NULL)
|
||
{
|
||
pEnt->close();
|
||
continue;
|
||
}
|
||
|
||
pPHg->GetDirLine(lnDir);
|
||
|
||
AecDbObjXDataMap *pXData = pAecEnt->GetSpecialtyData(AcDb::kForRead);
|
||
int n2dStyle = 0;
|
||
pXData->GetAt(_T("2dStl"), n2dStyle);
|
||
|
||
AcDbVoidPtrArray arEntPtrs;
|
||
pAecEnt->GetDraw2dables(n2dStyle, arEntPtrs);
|
||
|
||
for (int n = 0;n < arEntPtrs.length();n++)
|
||
{
|
||
pSubEnt = (AcDbEntity *)arEntPtrs.at(n);
|
||
AcDbLine *pSubLine = AcDbLine::cast(pSubEnt);
|
||
if (pSubLine != NULL)
|
||
{
|
||
MakePoly(pSubLine->startPoint(), pSubLine->endPoint(), pAecEnt->layerId(),0,kColorByLayer, pXData);
|
||
}
|
||
}
|
||
|
||
//标标注
|
||
if (m_nDimIndex)
|
||
{
|
||
CString sName, sName2,sSubTxt, sPNo, sTmp, sKey, sIndex, sRem;
|
||
double dVal = 0.0;
|
||
|
||
pXData->GetAt(KEY_NAME, sName);
|
||
|
||
//钢筋混凝土墙、柱预埋件式单管托架图(一)(DN15-150) --->
|
||
//钢筋混凝土墙、柱预埋件式单管托架图(一)
|
||
sName2 = sName;
|
||
int nPos = sName.Find(_T('('));
|
||
if (nPos != -1)
|
||
{
|
||
sName2 = sName.Mid(0, nPos);
|
||
sName2.TrimRight(_T("图"));
|
||
}
|
||
sName2.Insert(0, _T(" "));
|
||
sName = sName2;
|
||
//acutPrintf(_T("\n%s"),sName);
|
||
|
||
double dDN = 0.0;
|
||
pXData->GetAt(_T("DN"), dDN);
|
||
sTmp.Format(_T("(DN%d)"), (int)(dDN + 0.5));
|
||
sName += sTmp;
|
||
|
||
pPHg->GetAt(_T("DN"), dDN);
|
||
sTmp.Format(_T("DN%d "), (int)(dDN + 0.5));
|
||
sSubTxt += sTmp;
|
||
|
||
dVal = 0;
|
||
if (pPHg->GetAt(_T("L1"), dVal))
|
||
{
|
||
sTmp.Format(_T("L1=%d "), (int)(dVal + 0.5));
|
||
sSubTxt += sTmp;
|
||
}
|
||
dVal = 0;
|
||
if (pPHg->GetAt(_T("L2"), dVal))
|
||
{
|
||
sTmp.Format(_T("L2=%d "), (int)(dVal + 0.5));
|
||
sSubTxt += sTmp;
|
||
}
|
||
dVal = 0;
|
||
if (pPHg->GetAt(_T("L3"), dVal))
|
||
{
|
||
sTmp.Format(_T("L3=%d "), (int)(dVal + 0.5));
|
||
sSubTxt += sTmp;
|
||
}
|
||
dVal = 0;
|
||
if (pPHg->GetAt(_T("H"), dVal))
|
||
{
|
||
sTmp.Format(_T("H=%d "), (int)(dVal + 0.5));
|
||
sSubTxt += sTmp;
|
||
}
|
||
dVal = 0;
|
||
if (pPHg->GetAt(_T("H1"), dVal))
|
||
{
|
||
sTmp.Format(_T("H1=%d "), (int)(dVal + 0.5));
|
||
sSubTxt += sTmp;
|
||
}
|
||
dVal = 0;
|
||
if (pPHg->GetAt(_T("H2"), dVal))
|
||
{
|
||
sTmp.Format(_T("H2=%d "), (int)(dVal + 0.5));
|
||
sSubTxt += sTmp;
|
||
}
|
||
|
||
sPNo = _T("");
|
||
pPHg->GetAt(_T("PAGENO"), sPNo);
|
||
sRem.Format(_T(" 03S402室内管道支架及吊架 第%s页"), sPNo);
|
||
|
||
PipeHangerRec pgr;
|
||
memset(&pgr, 0, sizeof(PipeHangerRec));
|
||
_tcscpy(pgr.szName, (LPCTSTR)sName);
|
||
_tcscpy(pgr.szSubTxt, (LPCTSTR)sSubTxt);
|
||
_tcscpy(pgr.szRem, (LPCTSTR)sRem);
|
||
|
||
AppendPipeHgr(mapNameToRomaIndex, nRomIndex,pgr, sIndex);
|
||
|
||
ptPos = MidPoint(lnDir.startPoint(), lnDir.endPoint());
|
||
vtDirT = lnDir.endPoint() - lnDir.startPoint();
|
||
vtDirT.rotateBy(PI / 3.0, AcGeVector3d::kZAxis);
|
||
|
||
//标注
|
||
DimIndex(sIndex, ptPos, vtDirT, id);
|
||
}
|
||
|
||
//定位尺寸标注
|
||
if (nPipeDim)
|
||
{
|
||
|
||
}
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
bool AecISODrawMake::AppendPipeHgr(CMapStringToString& mapNameToRomaIndex, int& nRomIndex, PipeHangerRec &pgr, CString &sIndex)
|
||
{
|
||
//默认20种支吊架
|
||
const LPCTSTR pszRomaIndex[] = { _T("Ⅰ"),_T("Ⅱ"),_T("Ⅲ"),_T("Ⅳ"),_T("Ⅴ"),_T("Ⅵ"),_T("Ⅶ"),_T("Ⅷ"),_T("Ⅸ"),_T("Ⅹ"),
|
||
_T("Ⅺ"),_T("Ⅻ"),_T("XIII"),_T("XIV"),_T("XV"),_T("XVI"),_T("XVII"),_T("XVIII"),_T("XIX"),_T("XX"),NULL };
|
||
const int nRomaMaxIndex = 20;
|
||
|
||
CString sName = pgr.szName;
|
||
if (mapNameToRomaIndex.Lookup(sName, sIndex))
|
||
{
|
||
}
|
||
else
|
||
{
|
||
if (nRomIndex < nRomaMaxIndex)
|
||
{
|
||
sIndex = pszRomaIndex[nRomIndex];
|
||
|
||
nRomIndex += 1;
|
||
mapNameToRomaIndex.SetAt(sName, sIndex);
|
||
}
|
||
else
|
||
{
|
||
//索引不够
|
||
sIndex.Format(_T("支%d"), nRomIndex);
|
||
mapNameToRomaIndex.SetAt(sName, sIndex);
|
||
nRomIndex += 1;
|
||
}
|
||
}
|
||
|
||
CString sKey;
|
||
sKey.Format(_T("%s%s"), pgr.szName, pgr.szSubTxt);
|
||
sKey.TrimLeft(); sKey.TrimRight();
|
||
|
||
bool bFind = false;
|
||
for (int i = 0; i < m_arHngrRess.GetSize(); i++)
|
||
{
|
||
PipeHangerRec &pgrt = m_arHngrRess.GetAt(i);
|
||
if (_tcscmp(pgrt.szKey, (LPCTSTR)sKey) == 0)
|
||
{
|
||
pgrt.nCount += 1;
|
||
bFind = true;
|
||
break;
|
||
}
|
||
}
|
||
if (!bFind)
|
||
{
|
||
_tcscpy(pgr.szKey, sKey);
|
||
pgr.nCount = 1;
|
||
_tcscpy(pgr.szIndex, (LPCTSTR)sIndex);
|
||
m_arHngrRess.Add(pgr);
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
static void FreeBuffer(int n, AcDbVoidPtrArray& arEntPtrs)
|
||
{
|
||
AcDbEntity* pEnt = NULL;
|
||
while (arEntPtrs.length() > n)
|
||
{
|
||
pEnt = (AcDbEntity*)arEntPtrs.last();
|
||
DELETE_PTR(pEnt);
|
||
|
||
//TEST
|
||
//pEnt->setColorIndex(1);
|
||
//CoreTools::AddToModelSpace(pEnt);
|
||
|
||
arEntPtrs.removeLast();
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::MakeISOEquipment(AcDbObjectIdArray& arEquIds,double dPlotDotD)
|
||
{
|
||
AcDbObjectId id;
|
||
AcDbEntity* pEnt = NULL;
|
||
AecDbObjXDataMap* pXDataMap = NULL;
|
||
|
||
AcGePoint3d ptGe1,ptGe2;
|
||
AcDbEntity* pSubEnt = NULL;
|
||
|
||
//子实体类型绘制
|
||
int nType = 0,nIndex = 0;
|
||
|
||
for (int i = 0;i < arEquIds.length();i++)
|
||
{
|
||
id = arEquIds.at(i);
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead))
|
||
{
|
||
AecDbEwEquipment* pEqu = AecDbEwEquipment::cast(pEnt);
|
||
if (pEqu != NULL)
|
||
{
|
||
pXDataMap = pEqu->GetSpecialtyData(AcDb::kForRead);
|
||
|
||
nType = 0;
|
||
pXDataMap->GetAt(KEY_SUBRUNTIME,nType);
|
||
EFittingType eSubType = (EFittingType)nType;
|
||
|
||
if ( eSubType != eValve )
|
||
{
|
||
//三维炸碎, 需要真实3D位置
|
||
AcDbVoidPtrArray arEntPtrs;
|
||
AcGiExplodeDraw dc(arEntPtrs);
|
||
pEqu->Draw2d(dc);
|
||
|
||
CPoint pt;
|
||
pt.x = m_arISOEntPtrs.length();
|
||
|
||
for (int j = 0;j < arEntPtrs.length();j++)
|
||
{
|
||
pSubEnt = (AcDbEntity*)arEntPtrs.at(j);
|
||
AcDbArc *pArc = AcDbArc::cast(pSubEnt);
|
||
AcDbEllipse* pEArc = AcDbEllipse::cast(pSubEnt);
|
||
AcDbSpline* pSPL = AcDbSpline::cast(pSubEnt);
|
||
AcDb3dSolid* pSolid = AcDb3dSolid::cast(pSubEnt);
|
||
|
||
if (pArc != NULL ||
|
||
pEArc != NULL ||
|
||
pSPL != NULL)
|
||
{
|
||
AcDbCurve* pCrT = AcDbCurve::cast(pSubEnt);
|
||
AcGePoint3dArray arpts;
|
||
PipelineTools::GetSamplePoints(pCrT, arpts);
|
||
for (int i = 0; i < arpts.length() - 1; ++i)
|
||
{
|
||
AcDbLine *pLine = new AcDbLine(arpts[i], arpts[i + 1]);
|
||
|
||
AcGePoint3d ptSta = pLine->startPoint();
|
||
AcGePoint3d ptEnd = pLine->endPoint();
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
pLine->setStartPoint(ptSta);
|
||
pLine->setEndPoint(ptEnd);
|
||
pXDataMap->Write(pLine,BIMDATA_APP);
|
||
AddISOEnt(pLine);
|
||
}
|
||
}
|
||
else if (pSolid != NULL)
|
||
{
|
||
AcDbVoidPtrArray arLnPtrs;
|
||
Extract3dSolidOrderEdages(pSolid,arLnPtrs);
|
||
|
||
AcDbEntity* pEntT = NULL;
|
||
for (int ii = 0;ii < arLnPtrs.length();ii++)
|
||
{
|
||
pEntT = (AcDbEntity*)arLnPtrs.at(ii);
|
||
AcDbLine* pLnT = AcDbLine::cast(pEntT);
|
||
if (pLnT != NULL)
|
||
{
|
||
AcGePoint3d ptSta = pLnT->startPoint();
|
||
AcGePoint3d ptEnd = pLnT->endPoint();
|
||
|
||
double dDis = ptSta.distanceTo(ptEnd);
|
||
if (dDis < 1.e-1)
|
||
{
|
||
arLnPtrs.removeAt(ii);
|
||
ii -= 1;
|
||
continue;
|
||
}
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
pLnT->setStartPoint(ptSta);
|
||
pLnT->setEndPoint(ptEnd);
|
||
pXDataMap->Write(pLnT,BIMDATA_APP);
|
||
AddISOEnt(pLnT);
|
||
}
|
||
}
|
||
arEntPtrs.removeAt(j);
|
||
j -= 1;
|
||
}
|
||
else
|
||
{
|
||
AcDbCurve *pCurve = (AcDbCurve*)pSubEnt->clone();
|
||
if (pCurve)
|
||
{
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(pCurve);
|
||
|
||
pXDataMap->Write(pCurve,BIMDATA_APP);
|
||
AddISOEnt(pCurve);
|
||
}
|
||
}
|
||
}
|
||
|
||
FreeBuffer(0,arEntPtrs);
|
||
|
||
pt.y = m_arISOEntPtrs.length() - 1;
|
||
if (pt.y > pt.x)
|
||
{
|
||
m_arGrpIdx.Add(pt);
|
||
}
|
||
}
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::GetISOEntities(AcDbVoidPtrArray& arISOEntPtrs,AcDbExtents& ext)
|
||
{
|
||
arISOEntPtrs.append(m_arISOEntPtrs);
|
||
|
||
AcDbEntity* pEnt = NULL;
|
||
AcDbExtents ext1;
|
||
for (int i = 0;i < arISOEntPtrs.length();i++)
|
||
{
|
||
pEnt = (AcDbEntity*)arISOEntPtrs.at(i);
|
||
if (i == 0)
|
||
{
|
||
pEnt->getGeomExtents(ext);
|
||
}
|
||
else
|
||
{
|
||
pEnt->getGeomExtents(ext1);
|
||
ext.addExt(ext1);
|
||
}
|
||
}
|
||
}
|
||
|
||
void AecISODrawMake::GetMaterialSheet(AcDbVoidPtrArray &arISOEntPtrs, AcDbExtents &ext)
|
||
{
|
||
double dTxtMaxLen = 0;
|
||
double dH = 2.5 * m_dScale;
|
||
|
||
//需要同类排序
|
||
AcDbExtents extT;
|
||
for (int i = 0; i < m_arFitSumRecs.GetSize(); i++)
|
||
{
|
||
FitSumRec &fsmr = m_arFitSumRecs.GetAt(i);
|
||
CKTCadUtility::GetTextBox(extT, fsmr.szDimtext, PipelineTools::gTextStyle_Pipe_Dim, dH, 1.0, 0.0);
|
||
|
||
dTxtMaxLen = __max(dTxtMaxLen, extT.maxPoint().x - extT.minPoint().x);
|
||
ext.addExt(extT);
|
||
}
|
||
|
||
//1. 材料表格
|
||
AcDbTable *pTbl = new AcDbTable;
|
||
pTbl->setLayer(m_idDimlay);
|
||
pTbl->setTextStyle(m_idDimSty);
|
||
|
||
pTbl->setNumRows(m_arFitSumRecs.GetSize() + 1);
|
||
pTbl->setNumColumns(8);
|
||
|
||
pTbl->setWidth(32207 + dTxtMaxLen);
|
||
pTbl->setRowHeight(950);
|
||
|
||
pTbl->setColumnWidth(0, 1732);
|
||
pTbl->setColumnWidth(1, dTxtMaxLen);
|
||
pTbl->setColumnWidth(2, 4895);
|
||
pTbl->setColumnWidth(3, 4895);
|
||
pTbl->setColumnWidth(4, 4895);
|
||
pTbl->setColumnWidth(5, 4895);
|
||
pTbl->setColumnWidth(6, 4895);
|
||
pTbl->setColumnWidth(7, 6000);
|
||
|
||
pTbl->setDirection(AcGeVector3d::kXAxis);
|
||
pTbl->setPosition(AcGePoint3d::kOrigin);
|
||
pTbl->setNormal(AcGeVector3d::kZAxis);
|
||
|
||
//pTbl->setTableStyle();
|
||
|
||
pTbl->setTextHeight(0, 0, 300);
|
||
pTbl->setTextString(0, 0, _T("序号"));
|
||
pTbl->setAlignment(0, 0, kMiddleCenter);
|
||
|
||
pTbl->setTextHeight(0, 1, 300);
|
||
pTbl->setTextString(0, 1, _T("名称"));
|
||
pTbl->setAlignment(0, 1, kMiddleCenter);
|
||
|
||
pTbl->setTextHeight(0, 2, 300);
|
||
pTbl->setTextString(0, 2, _T("规格及型号"));
|
||
pTbl->setAlignment(0, 2, kMiddleCenter);
|
||
|
||
pTbl->setTextHeight(0, 3, 300);
|
||
pTbl->setTextString(0, 3, _T("数量"));
|
||
pTbl->setAlignment(0, 3, kMiddleCenter);
|
||
|
||
pTbl->setTextHeight(0, 4, 300);
|
||
pTbl->setTextString(0, 4, _T("材料"));
|
||
pTbl->setAlignment(0, 4, kMiddleCenter);
|
||
|
||
pTbl->setTextHeight(0, 5, 300);
|
||
pTbl->setTextString(0, 5, _T("单重"));
|
||
pTbl->setAlignment(0, 5, kMiddleCenter);
|
||
|
||
pTbl->setTextHeight(0, 6, 300);
|
||
pTbl->setTextString(0, 6, _T("总计"));
|
||
pTbl->setAlignment(0, 6, kMiddleCenter);
|
||
|
||
pTbl->setTextHeight(0, 7, 300);
|
||
pTbl->setTextString(0, 7, _T("备注"));
|
||
pTbl->setAlignment(0, 7, kMiddleCenter);
|
||
|
||
int j = 0;
|
||
CString sText, sTmp;
|
||
for (int i = 0; i < m_arFitSumRecs.GetSize(); i++)
|
||
{
|
||
FitSumRec &fsmr = m_arFitSumRecs.GetAt(i);
|
||
|
||
//No
|
||
sText.Format(_T("%d"), i + 1);
|
||
|
||
pTbl->setTextHeight(i + 1, 0, 300);
|
||
pTbl->setTextString(i + 1, 0, sText);
|
||
pTbl->setAlignment(i + 1, 0, kMiddleCenter);
|
||
pTbl->setTextStyle(i + 1, 0, m_idDimSty);
|
||
|
||
//名称
|
||
pTbl->setTextHeight(i + 1, 1, 300);
|
||
pTbl->setTextString(i + 1, 1, fsmr.szDimtext);
|
||
pTbl->setAlignment(i + 1, 1, kMiddleLeft);
|
||
pTbl->setTextStyle(i + 1, 1, m_idDimSty);
|
||
|
||
//规格及型号
|
||
pTbl->setTextHeight(i + 1, 2, 300);
|
||
pTbl->setTextString(i + 1, 2, fsmr.szSpec);
|
||
pTbl->setAlignment(i + 1, 2, kMiddleCenter);
|
||
pTbl->setTextStyle(i + 1, 2, m_idDimSty);
|
||
|
||
//数量
|
||
sText.Format(_T("%d"), fsmr.nCount);
|
||
pTbl->setTextHeight(i + 1, 3, 300);
|
||
pTbl->setTextString(i + 1, 3, sText);
|
||
pTbl->setAlignment(i + 1, 3, kMiddleCenter);
|
||
pTbl->setTextStyle(i + 1, 3, m_idDimSty);
|
||
|
||
//材料
|
||
pTbl->setTextHeight(i + 1, 4, 300);
|
||
pTbl->setTextString(i + 1, 4, fsmr.szMat);
|
||
pTbl->setAlignment(i + 1, 4, kMiddleCenter);
|
||
pTbl->setTextStyle(i + 1, 4, m_idDimSty);
|
||
|
||
//单重
|
||
pTbl->setTextHeight(i + 1, 5, 300);
|
||
pTbl->setTextString(i + 1, 5, _T("-"));
|
||
pTbl->setAlignment(i + 1, 5, kMiddleCenter);
|
||
pTbl->setTextStyle(i + 1, 5, m_idDimSty);
|
||
|
||
//总计
|
||
pTbl->setTextHeight(i + 1, 6, 300);
|
||
pTbl->setTextString(i + 1, 6, _T("-"));
|
||
pTbl->setAlignment(i + 1, 6, kMiddleCenter);
|
||
pTbl->setTextStyle(i + 1, 6, m_idDimSty);
|
||
|
||
//备注
|
||
pTbl->setTextHeight(i + 1, 7, 300);
|
||
pTbl->setTextString(i + 1, 7, fsmr.szRem);
|
||
pTbl->setAlignment(i + 1, 7, kMiddleCenter);
|
||
pTbl->setTextStyle(i + 1, 7, m_idDimSty);
|
||
}
|
||
arISOEntPtrs.append(pTbl);
|
||
|
||
//2. 吊架表
|
||
AcDbExtents extTbl;
|
||
pTbl->getGeomExtents(extTbl);
|
||
|
||
AcGePoint3d ptHgr = extTbl.minPoint();
|
||
ptHgr.y -= (m_arFitSumRecs.GetSize() + 2) * 950.0;
|
||
|
||
//需要同类排序
|
||
for (int i = 0; i < m_arHngrRess.GetSize(); i++)
|
||
{
|
||
PipeHangerRec &phg = m_arHngrRess.GetAt(i);
|
||
CKTCadUtility::GetTextBox(extT, phg.szName, PipelineTools::gTextStyle_Pipe_Dim, dH, 1.0, 0.0);
|
||
|
||
dTxtMaxLen = __max(dTxtMaxLen, extT.maxPoint().x - extT.minPoint().x);
|
||
ext.addExt(extT);
|
||
}
|
||
|
||
pTbl = new AcDbTable;
|
||
pTbl->setLayer(m_idDimlay);
|
||
pTbl->setTextStyle(m_idDimSty);
|
||
|
||
pTbl->setNumRows(m_arHngrRess.GetSize() + 1);
|
||
pTbl->setNumColumns(5);
|
||
|
||
pTbl->setWidth(19500);
|
||
pTbl->setRowHeight(950);
|
||
|
||
pTbl->setColumnWidth(0, 1200);
|
||
pTbl->setColumnWidth(1, 6900);
|
||
pTbl->setColumnWidth(2, 5900);
|
||
pTbl->setColumnWidth(3, 1200);
|
||
pTbl->setColumnWidth(4, 4300);
|
||
|
||
pTbl->setDirection(AcGeVector3d::kXAxis);
|
||
pTbl->setPosition(ptHgr);
|
||
pTbl->setNormal(AcGeVector3d::kZAxis);
|
||
|
||
pTbl->setTextHeight(0, 0, 300);
|
||
pTbl->setTextString(0, 0, _T("序号"));
|
||
pTbl->setAlignment(0, 0, kMiddleCenter);
|
||
|
||
pTbl->setTextHeight(0, 1, 300);
|
||
pTbl->setTextString(0, 1, _T("名称"));
|
||
pTbl->setAlignment(0, 1, kMiddleCenter);
|
||
|
||
pTbl->setTextHeight(0, 2, 300);
|
||
pTbl->setTextString(0, 2, _T("尺寸规格"));
|
||
pTbl->setAlignment(0, 2, kMiddleCenter);
|
||
|
||
pTbl->setTextHeight(0, 3, 300);
|
||
pTbl->setTextString(0, 3, _T("数量"));
|
||
pTbl->setAlignment(0, 3, kMiddleCenter);
|
||
|
||
pTbl->setTextHeight(0, 4, 300);
|
||
pTbl->setTextString(0, 4, _T("备注"));
|
||
pTbl->setAlignment(0, 4, kMiddleCenter);
|
||
|
||
for (int i = 0; i < m_arHngrRess.GetSize(); i++)
|
||
{
|
||
PipeHangerRec &pipegr = m_arHngrRess.GetAt(i);
|
||
|
||
//No
|
||
pTbl->setTextHeight(i + 1, 0, 300);
|
||
//sText.Format(_T("%d"), i + 1);
|
||
sText = pipegr.szIndex;
|
||
pTbl->setTextString(i + 1, 0, sText);
|
||
pTbl->setAlignment(i + 1, 0, kMiddleCenter);
|
||
pTbl->setTextStyle(i + 1, 0, m_idDimSty);
|
||
|
||
//名称
|
||
pTbl->setTextHeight(i + 1, 1, 300);
|
||
pTbl->setTextString(i + 1, 1, pipegr.szName);
|
||
pTbl->setAlignment(i + 1, 1, kMiddleLeft);
|
||
pTbl->setTextStyle(i + 1, 1, m_idDimSty);
|
||
|
||
//尺寸
|
||
pTbl->setTextHeight(i + 1, 2, 300);
|
||
pTbl->setTextString(i + 1, 2, pipegr.szSubTxt);
|
||
pTbl->setAlignment(i + 1, 2, kMiddleLeft);
|
||
pTbl->setTextStyle(i + 1, 2, m_idDimSty);
|
||
|
||
//页码
|
||
sTmp.Format(_T("%d"), pipegr.nCount);
|
||
pTbl->setTextHeight(i + 1, 3, 300);
|
||
pTbl->setTextString(i + 1, 3, sTmp);
|
||
pTbl->setAlignment(i + 1, 3, kMiddleCenter);
|
||
pTbl->setTextStyle(i + 1, 3, m_idDimSty);
|
||
|
||
//备注
|
||
pTbl->setTextHeight(i + 1, 4, 300);
|
||
pTbl->setTextString(i + 1, 4, pipegr.szRem);
|
||
pTbl->setAlignment(i + 1, 4, kMiddleLeft);
|
||
pTbl->setTextStyle(i + 1, 4, m_idDimSty);
|
||
}
|
||
arISOEntPtrs.append(pTbl);
|
||
}
|
||
|
||
int AecISODrawMake::IsEntityInGroup(int nIndex)
|
||
{
|
||
CPoint pt;
|
||
for (int i = 0;i < m_arGrpIdx.GetSize();i++)
|
||
{
|
||
pt = m_arGrpIdx.GetAt(i);
|
||
|
||
if (nIndex >= pt.x && nIndex <= pt.y)
|
||
{
|
||
if (pt.y == nIndex)
|
||
return 2;
|
||
return 1;
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
void AecISODrawMake::CovertToISO(AcDbEntity* pEnt,AecDbObjXDataMap* pXDataMap/* = NULL*/)
|
||
{
|
||
AcDbLine* pLine = AcDbLine::cast(pEnt);
|
||
if (pLine != NULL)
|
||
{
|
||
AcGePoint3d ptSta = pLine->startPoint();
|
||
AcGePoint3d ptEnd = pLine->endPoint();
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptSta);
|
||
m_xform.GetTransformByThis(ptEnd);
|
||
}
|
||
|
||
AcDbLine* pLine2 = new AcDbLine;
|
||
pLine2->setStartPoint(ptSta);
|
||
pLine2->setEndPoint(ptEnd);
|
||
pLine2->setLayer(pEnt->layerId());
|
||
pLine2->setLinetype(KTSetting::InitLineStyle(_T("Continuous")));
|
||
pLine2->setNormal(AcGeVector3d::kZAxis);
|
||
if (pXDataMap != NULL)
|
||
{
|
||
pXDataMap->Write(pLine2,BIMDATA_APP);
|
||
}
|
||
AddISOEnt(pLine2);
|
||
return;
|
||
}
|
||
|
||
AcDbArc* pArc = AcDbArc::cast(pEnt);
|
||
if (pArc != NULL)
|
||
{
|
||
//取6个点
|
||
double dSta = 0.0,dEnd = 0.0;
|
||
pArc->getStartParam(dSta);
|
||
pArc->getEndParam(dEnd);
|
||
AcGeVector3d vtNom = pArc->normal();
|
||
|
||
double dStep = (dEnd - dSta) / 6.0;//6等分
|
||
AcGePoint3d ptGe;
|
||
AcDbPolyline* pPl = new AcDbPolyline;
|
||
|
||
for (int i = 0;i <= 6;i++)
|
||
{
|
||
pArc->getPointAtParam(dSta + i * dStep,ptGe);
|
||
|
||
if (!m_bWasDone)
|
||
m_xform.GetTransformByThis(ptGe);
|
||
|
||
pPl->addVertexAt(i,ptGe.convert2d(AcGePlane::kXYPlane));
|
||
}
|
||
pPl->setNormal(AcGeVector3d::kZAxis);
|
||
pPl->setLayer(pEnt->layerId());
|
||
if (pXDataMap != NULL)
|
||
{
|
||
pXDataMap->Write(pPl,BIMDATA_APP);
|
||
}
|
||
AddISOEnt(pPl);
|
||
return;
|
||
}
|
||
|
||
AcDbCircle *pCir = AcDbCircle::cast(pEnt);
|
||
if (pCir != NULL)
|
||
{
|
||
AcGePoint3d ptCen = pCir->center();
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptCen);
|
||
}
|
||
|
||
AcDbCircle *pCir2 = new AcDbCircle;
|
||
pCir2->setCenter(ptCen);
|
||
pCir2->setRadius(pCir->radius());
|
||
pCir2->setLayer(pEnt->layerId());
|
||
pCir2->setLinetype(KTSetting::InitLineStyle(_T("Continuous")));
|
||
pCir2->setNormal(AcGeVector3d::kZAxis);
|
||
if (pXDataMap != NULL)
|
||
{
|
||
pXDataMap->Write(pCir2, BIMDATA_APP);
|
||
}
|
||
AddISOEnt(pCir2);
|
||
return;
|
||
}
|
||
|
||
AcDbText *pTxt = AcDbText::cast(pEnt);
|
||
if (pTxt != NULL)
|
||
{
|
||
AcGePoint3d ptGe = pTxt->position();
|
||
AcGePoint3d ptAg = pTxt->alignmentPoint();
|
||
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(ptGe);
|
||
m_xform.GetTransformByThis(ptAg);
|
||
}
|
||
|
||
double dRot = pTxt->rotation();
|
||
AcGeVector3d vt = AcGeVector3d::kXAxis;
|
||
vt.rotateBy(dRot, AcGeVector3d::kZAxis);
|
||
if (!m_bWasDone)
|
||
{
|
||
m_xform.GetTransformByThis(vt);
|
||
dRot = AcGeVector3d::kXAxis.angleTo(vt, AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
AcDbText *pTxt2 = new AcDbText;
|
||
pTxt2->setPosition(ptGe);
|
||
pTxt2->setHorizontalMode(pTxt->horizontalMode());
|
||
pTxt2->setVerticalMode(pTxt->verticalMode());
|
||
pTxt2->setAlignmentPoint(ptAg);
|
||
pTxt2->setRotation(dRot);
|
||
pTxt2->setTextString(pTxt->textStringConst());
|
||
pTxt2->setTextStyle(pTxt->textStyle());
|
||
pTxt2->setHeight(pTxt->height());
|
||
pTxt2->setWidthFactor(pTxt->widthFactor());
|
||
pTxt2->setLayer(pTxt->layerId());
|
||
pTxt2->setLinetype(KTSetting::InitLineStyle(_T("Continuous")));
|
||
pTxt2->setNormal(AcGeVector3d::kZAxis);
|
||
if (pXDataMap != NULL)
|
||
{
|
||
pXDataMap->Write(pTxt2, BIMDATA_APP);
|
||
}
|
||
AddISOEnt(pTxt2);
|
||
return;
|
||
}
|
||
}
|