1397 lines
33 KiB
C++
1397 lines
33 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbZLineStair.h"
|
|
#include "KTSetting.h"
|
|
#include "AcDbX3dSolid.h"
|
|
#include "AcGiExplodeDraw.h"
|
|
#include "AcGiViewDraw.h"
|
|
#include "impmd5.h"
|
|
|
|
|
|
static const Adesk::UInt16 kColorByBlock = 0;
|
|
static const Adesk::UInt16 kRed = 1;
|
|
static const Adesk::UInt16 kYellow = 2;
|
|
static const Adesk::UInt16 kGreen = 3;
|
|
static const Adesk::UInt16 kCyan = 4;
|
|
static const Adesk::UInt16 kBlue = 5;
|
|
static const Adesk::UInt16 kMagenta = 6;
|
|
static const Adesk::UInt16 kWhite = 7;
|
|
static const Adesk::UInt16 kColorByLayer = 256;
|
|
|
|
extern AcDbPolyline* FormatPolyline(AcGePoint3d* ppPts,int nCount);
|
|
extern BOOL GetDocScale(double& dPScale);
|
|
extern void SortPoints(AcGePoint3dArray& points,AcDbCurve* pLine);
|
|
extern AcDbRegion* CreatePolygonRegionOnly(AcGePoint3d* pPoints,int nSize);
|
|
extern Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEnt,AcDbDatabase* pDb = NULL,bool bClose = true);
|
|
extern AcGePoint3d MidPoint(const AcGePoint3d& pt1,const AcGePoint3d& pt2);
|
|
extern void DLLIMPEXP OrthoProjected3DSolid(AcDb3dSolid* pSolidClone,const AcGePlane& plan,AcGeMatrix3d& xformPlanToWorld,AcDbVoidPtrArray& arEntPtrs);
|
|
|
|
Adesk::UInt32 AecDbZLineStair::kCurrentVersionNumber = 1;
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbZLineStair, AecDbEwPipeBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_DBZSTAIR,
|
|
"AecDbZLineStair"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
AecDbZLineStair::AecDbZLineStair(void)
|
|
{
|
|
m_mapSpecXData.SetAt(KEY_NAME,_T("双跑楼梯"));
|
|
}
|
|
|
|
AecDbZLineStair::~AecDbZLineStair(void)
|
|
{
|
|
deleteContainerOfStd(m_solids);
|
|
deleteContainerOfStd(m_pipes);
|
|
}
|
|
|
|
|
|
void AecDbZLineStair::SetZLineStairData(const ZLineStair& data)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//set section; 底层设置section,用于绘制管子
|
|
//路径单独设置
|
|
//bar数据key方式保存,只是占位用
|
|
if (data.nGShape == 0)
|
|
{
|
|
//Circle
|
|
SetSection(data.dGarSize[0],5.0);//5mm厚
|
|
}
|
|
else
|
|
{
|
|
//Rect
|
|
SetSection(data.dGarSize[0],data.dGarSize[1],5.0);//5mm厚
|
|
}
|
|
|
|
m_mapSpecXData.SetAt(KEY_ZS,data.nZs);
|
|
m_mapSpecXData.SetAt(KEY_KIND,data.nKind);
|
|
m_mapSpecXData.SetAt(KEY_STEEPH,data.dSteepH);
|
|
m_mapSpecXData.SetAt(KEY_STEEPW,data.dSteepW);
|
|
|
|
m_mapSpecXData.SetAt(KEY_STEEPS1,data.nSteeps1);
|
|
m_mapSpecXData.SetAt(KEY_STEEPS2,data.nSteeps2);
|
|
|
|
m_mapSpecXData.SetAt(KEY_STAIRTW,data.dStairTW);
|
|
m_mapSpecXData.SetAt(KEY_STAIRSW,data.dStairSW);
|
|
|
|
m_mapSpecXData.SetAt(KEY_UPSIDE,data.nUpSide);
|
|
m_mapSpecXData.SetAt(KEY_BOMEL,data.dBomEl);
|
|
|
|
m_mapSpecXData.SetAt(KEY_RESTPTW,data.dRestPtW);
|
|
m_mapSpecXData.SetAt(KEY_STIFFNH,data.dStiffnH);
|
|
m_mapSpecXData.SetAt(KEY_STIFFNW,data.dStiffnW);
|
|
m_mapSpecXData.SetAt(KEY_WELLW,data.dWellW);
|
|
m_mapSpecXData.SetAt(KEY_SLABT,data.dSbThick);
|
|
|
|
m_mapSpecXData.SetAt(KEY_BARH,data.dBarH);
|
|
m_mapSpecXData.SetAt(KEY_GARSIZE0,data.dGarSize[0]);
|
|
m_mapSpecXData.SetAt(KEY_GARSIZE1,data.dGarSize[1]);
|
|
|
|
m_mapSpecXData.SetAt(KEY_GSHAPE,data.nGShape);
|
|
m_mapSpecXData.SetAt(KEY_GAREXT,data.dGarExt);
|
|
m_mapSpecXData.SetAt(KEY_ZGAREXT,data.dZGarExt);
|
|
m_mapSpecXData.SetAt(KEY_GARMAT,data.szGarMat);
|
|
|
|
m_mapSpecXData.SetAt(KEY_BARSP,data.dBarSp);
|
|
m_mapSpecXData.SetAt(KEY_BARSIZE0,data.dBarSize[0]);
|
|
m_mapSpecXData.SetAt(KEY_BARSIZE1,data.dBarSize[1]);
|
|
m_mapSpecXData.SetAt(KEY_BSHAPE,data.nBShape);
|
|
m_mapSpecXData.SetAt(KEY_BARMAT,data.szBarMat);
|
|
}
|
|
|
|
void AecDbZLineStair::GetZLineStairData(ZLineStair& data) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
m_mapSpecXData.GetAt(KEY_ZS,data.nZs);
|
|
m_mapSpecXData.GetAt(KEY_KIND,data.nKind);
|
|
m_mapSpecXData.GetAt(KEY_STEEPH,data.dSteepH);
|
|
m_mapSpecXData.GetAt(KEY_STEEPW,data.dSteepW);
|
|
|
|
m_mapSpecXData.GetAt(KEY_STEEPS1,data.nSteeps1);
|
|
m_mapSpecXData.GetAt(KEY_STEEPS2,data.nSteeps2);
|
|
|
|
m_mapSpecXData.GetAt(KEY_STAIRTW,data.dStairTW);
|
|
m_mapSpecXData.GetAt(KEY_STAIRSW,data.dStairSW);
|
|
|
|
m_mapSpecXData.GetAt(KEY_UPSIDE,data.nUpSide);
|
|
m_mapSpecXData.GetAt(KEY_BOMEL,data.dBomEl);
|
|
|
|
m_mapSpecXData.GetAt(KEY_RESTPTW,data.dRestPtW);
|
|
m_mapSpecXData.GetAt(KEY_STIFFNH,data.dStiffnH);
|
|
m_mapSpecXData.GetAt(KEY_STIFFNW,data.dStiffnW);
|
|
m_mapSpecXData.GetAt(KEY_WELLW,data.dWellW);
|
|
m_mapSpecXData.GetAt(KEY_SLABT,data.dSbThick);
|
|
|
|
m_mapSpecXData.GetAt(KEY_BARH,data.dBarH);
|
|
m_mapSpecXData.GetAt(KEY_GARSIZE0,data.dGarSize[0]);
|
|
m_mapSpecXData.GetAt(KEY_GARSIZE1,data.dGarSize[1]);
|
|
|
|
m_mapSpecXData.GetAt(KEY_GSHAPE,data.nGShape);
|
|
m_mapSpecXData.GetAt(KEY_GAREXT,data.dGarExt);
|
|
m_mapSpecXData.GetAt(KEY_ZGAREXT,data.dZGarExt);
|
|
|
|
CString sTemp;
|
|
m_mapSpecXData.GetAt(KEY_GARMAT,sTemp);
|
|
_tcscpy(data.szGarMat,(LPCTSTR)sTemp);
|
|
|
|
m_mapSpecXData.GetAt(KEY_BARSP,data.dBarSp);
|
|
m_mapSpecXData.GetAt(KEY_BARSIZE0,data.dBarSize[0]);
|
|
m_mapSpecXData.GetAt(KEY_BARSIZE1,data.dBarSize[1]);
|
|
m_mapSpecXData.GetAt(KEY_BSHAPE,data.nBShape);
|
|
m_mapSpecXData.GetAt(KEY_BARMAT,sTemp);
|
|
_tcscpy(data.szBarMat,(LPCTSTR)sTemp);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbZLineStair::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = AecDbEwPipeBase::dwgInFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
|
|
//----- Object version number needs to be read first
|
|
Adesk::UInt32 version =0 ;
|
|
if ( (es = pFiler->readUInt32 (&version)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
if ( version > AecDbZLineStair::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbZLineStair::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//----- Save parent class information first.
|
|
Acad::ErrorStatus es = AecDbEwPipeBase::dwgOutFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
|
|
//----- Object version number needs to be saved first
|
|
if ( (es =pFiler->writeUInt32 (AecDbZLineStair::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbZLineStair::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbZLineStair::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbZLineStair::subList() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
acutPrintf(_T("\n多跑楼梯"));
|
|
AecDbEwPipeBase::subList();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbZLineStair::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
AecDbEwPipeBase::subTransformBy(xform);
|
|
|
|
double dBomEl = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_BOMEL,dBomEl);
|
|
|
|
AcGePoint3d pt(0,0,dBomEl);
|
|
pt.transformBy(xform);
|
|
|
|
m_mapSpecXData.SetAt(KEY_BOMEL,pt.z);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbZLineStair::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbObjectId idCurLay = dc.GetLayerId();
|
|
Adesk::UInt16 nCrBk = colorIndex();
|
|
|
|
dc.SetLayer(layerId());
|
|
|
|
//二维缓存,未知出错!
|
|
if (Has2DBuffer())
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(i);
|
|
|
|
dc.SetColor(colorIndex());
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
dc.SetColor(nCrBk);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDbCurve* pBaseCrv = GetBaseCurve(true);
|
|
if (pBaseCrv != NULL)
|
|
{
|
|
ZLineStair data;
|
|
memset(&data,0,sizeof(ZLineStair));
|
|
|
|
GetZLineStairData(data);
|
|
|
|
AcDbObjectId idLayOld = dc.GetLayerId();
|
|
AcDbObjectId idLay = layerId();
|
|
dc.SetLayer(idLay);
|
|
|
|
AcDbVoidPtrArray arEntDrawPtrs;
|
|
|
|
//跑步方向
|
|
AcDbLine* pLn = AcDbLine::cast(pBaseCrv);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGeVector3d vtDir = pLn->endPoint() - pLn->startPoint();
|
|
vtDir.normalize();
|
|
|
|
AcGeVector3d vtLR;
|
|
if (data.nUpSide == 0)//左侧上梯
|
|
{
|
|
vtLR = vtDir;
|
|
vtLR.rotateBy(-PI / 2.0,AcGeVector3d::kZAxis);
|
|
}
|
|
else//右侧
|
|
{
|
|
vtLR = vtDir;
|
|
vtLR.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
}
|
|
|
|
//一跑步数
|
|
AcGePoint3d ptBase = pLn->startPoint();
|
|
|
|
AcGePoint3d ptFr = ptBase;
|
|
AcGePoint3d ptS[5],ptSlab[4],ptZCen;
|
|
|
|
//2D 侧进一个扶手宽度
|
|
ptFr += data.dGarSize[0] * vtLR;
|
|
|
|
//踏步线宽度
|
|
double dLen = data.dStairSW;
|
|
dLen -= 2.0 * data.dGarSize[0];
|
|
|
|
//绘制踏步线 踏步数+1
|
|
AcGePoint3d ptTo;
|
|
for (int i = 0;i <= data.nSteeps1;i++)
|
|
{
|
|
ptTo = ptFr;
|
|
ptTo += vtLR * dLen;
|
|
|
|
AcDbLine* pLnX = new AcDbLine;
|
|
pLnX->setStartPoint(ptFr);
|
|
pLnX->setEndPoint(ptTo);
|
|
pLnX->setLayer(idLay);
|
|
|
|
//dc.DrawEntity(pLnX);
|
|
//Add2DBuffer(pLnX);
|
|
arEntDrawPtrs.append(pLnX);
|
|
|
|
//步进一个台阶
|
|
if (i == data.nSteeps1)
|
|
break;
|
|
ptFr += vtDir * data.dSteepW;
|
|
}
|
|
|
|
ptSlab[0] = ptFr;
|
|
ptSlab[0] -= data.dGarSize[0] * vtLR;
|
|
|
|
//绘制扶手投影
|
|
ptS[0] = ptBase;
|
|
ptS[0] -= data.dGarExt * vtDir;//转角扶手伸出
|
|
|
|
ptS[1] = ptS[0];
|
|
ptS[1] += data.dGarSize[0] * vtLR;
|
|
|
|
ptS[2] = ptFr;
|
|
ptS[2] += data.dGarExt * vtDir;//转角扶手伸出
|
|
|
|
ptS[3] = ptS[2];
|
|
ptS[3] -= data.dGarSize[0] * vtLR;
|
|
ptS[4] = ptS[0];
|
|
|
|
AcDbPolyline* pL = FormatPolyline(ptS,5);
|
|
//dc.DrawEntity(pL);
|
|
//Add2DBuffer(pL);
|
|
arEntDrawPtrs.append(pL);
|
|
|
|
//绘制中间井宽
|
|
if (data.dWellW > 1.e-3)
|
|
{
|
|
ptS[0] = ptBase;
|
|
ptS[0] += data.dStairSW * vtLR;
|
|
|
|
ptS[1] = ptS[0] + data.dWellW * vtLR;
|
|
|
|
ptS[3] = ptTo;
|
|
ptS[3] += data.dGarSize[0] * vtLR;
|
|
|
|
ptS[2] = ptS[3];
|
|
ptS[2] += data.dWellW * vtLR;
|
|
|
|
ptS[4] = ptS[0];
|
|
|
|
pL = FormatPolyline(ptS,5);
|
|
//dc.DrawEntity(pL);
|
|
//Add2DBuffer(pL);
|
|
arEntDrawPtrs.append(pL);
|
|
}
|
|
else
|
|
{
|
|
//绘制一直线
|
|
ptS[0] = ptBase;
|
|
ptS[0] += data.dStairSW * vtLR;
|
|
|
|
ptS[1] = ptTo + data.dWellW * vtLR;
|
|
ptS[1] += data.dGarSize[0] * vtLR;
|
|
|
|
pL = FormatPolyline(ptS,2);
|
|
//dc.DrawEntity(pL);
|
|
//Add2DBuffer(pL);
|
|
arEntDrawPtrs.append(pL);
|
|
}
|
|
|
|
//绘制中间扶手投影,记录ptTo位置
|
|
AcGePoint3d ptLTo;
|
|
|
|
ptS[0] = ptBase;
|
|
ptS[0] += (data.dStairSW - data.dGarSize[0]) * vtLR;
|
|
ptS[0] -= data.dZGarExt * vtDir;
|
|
|
|
ptLTo = ptS[0];
|
|
ptLTo += data.dZGarExt * vtDir;
|
|
ptLTo += (2.0 * data.dGarSize[0] + data.dWellW) * vtLR;
|
|
|
|
ptS[1] = ptS[0] + (2.0 * data.dGarSize[0] + data.dWellW) * vtLR;
|
|
|
|
ptS[3] = ptTo;
|
|
ptS[3] += data.dZGarExt * vtDir;
|
|
|
|
ptS[2] = ptS[3] + (2.0 * data.dGarSize[0] + data.dWellW) * vtLR;
|
|
ptS[4] = ptS[0];
|
|
|
|
pL = FormatPolyline(ptS,5);
|
|
//dc.DrawEntity(pL);
|
|
//Add2DBuffer(pL);
|
|
arEntDrawPtrs.append(pL);
|
|
|
|
//二跑
|
|
ptTo += (2.0 * data.dGarSize[0] + data.dWellW) * vtLR;
|
|
ptFr = ptTo;
|
|
|
|
ptSlab[3] = ptTo;
|
|
ptSlab[3] += vtLR * dLen;
|
|
ptSlab[3] += data.dGarSize[0] * vtLR;
|
|
|
|
ptS[0] = ptFr;
|
|
ptS[0] += vtLR * dLen;
|
|
ptS[0] += data.dGarExt * vtDir;
|
|
ptS[1] = ptS[0] + data.dGarSize[0] * vtLR;
|
|
|
|
for (int i = 0;i <= data.nSteeps2;i++)
|
|
{
|
|
ptTo = ptFr;
|
|
ptTo += vtLR * dLen;
|
|
|
|
AcDbLine* pLnX = new AcDbLine;
|
|
pLnX->setStartPoint(ptFr);
|
|
pLnX->setEndPoint(ptTo);
|
|
pLnX->setLayer(idLay);
|
|
|
|
//dc.DrawEntity(pLnX);
|
|
//Add2DBuffer(pLnX);
|
|
arEntDrawPtrs.append(pLnX);
|
|
|
|
//步进一个台阶 回走
|
|
if (i == data.nSteeps2)
|
|
break;
|
|
|
|
ptFr -= vtDir * data.dSteepW;
|
|
}
|
|
|
|
//二跑外侧扶手投影
|
|
ptS[3] = ptTo;
|
|
ptS[3] -= vtDir * data.dGarExt;
|
|
ptS[2] = ptS[3] + data.dGarSize[0] * vtLR;
|
|
ptS[4] = ptS[0];
|
|
|
|
pL = FormatPolyline(ptS,5);
|
|
//dc.DrawEntity(pL);
|
|
//Add2DBuffer(pL);
|
|
arEntDrawPtrs.append(pL);
|
|
|
|
//绘制平台
|
|
ptSlab[1] = ptSlab[0] + vtDir * data.dRestPtW;
|
|
ptSlab[2] = ptSlab[3] + vtDir * data.dRestPtW;
|
|
|
|
pL = FormatPolyline(ptSlab,4);
|
|
if (pL != NULL)
|
|
{
|
|
arEntDrawPtrs.append(pL);
|
|
}
|
|
|
|
double dDis = 0.0;
|
|
if ( (dDis = ptLTo.distanceTo(ptFr)) > 1.0)
|
|
{
|
|
//
|
|
AcGePoint3d ptS2[5];
|
|
ptS2[0] = ptLTo;
|
|
ptS2[0] -= data.dGarSize[0] * vtLR;
|
|
ptS2[0] -= data.dZGarExt * vtDir;
|
|
|
|
ptS2[1] = ptS2[0];
|
|
ptS2[1] += data.dGarSize[0] * vtLR;
|
|
|
|
ptS2[2] = ptFr;
|
|
ptS2[2] -= data.dGarExt * vtDir;
|
|
ptS2[3] = ptS2[2] - data.dGarSize[0] * vtLR;
|
|
ptS2[4] = ptS2[0];
|
|
|
|
pL = FormatPolyline(ptS2,5);
|
|
if (pL != NULL)
|
|
{
|
|
arEntDrawPtrs.append(pL);
|
|
}
|
|
}
|
|
|
|
//绘制省略线,省略线和以上求交裁剪
|
|
ptZCen = ptBase;
|
|
ptZCen += 0.5 * data.dStairSW * vtLR;
|
|
ptZCen += 4.5 * data.dSteepW * vtDir;//4.5 步
|
|
DrawZLine(ptZCen,vtDir,data.dSteepW,data.dStairSW,arEntDrawPtrs);
|
|
|
|
//绘制UP折线 绿色
|
|
if (data.nUpSide == 0)//左侧上梯
|
|
{
|
|
ptS[0] = ptBase;
|
|
ptS[0] += 0.5 * data.dStairSW * vtLR;
|
|
ptS[0] -= 0.5 * data.dSteepW * vtDir;//一半步宽
|
|
ptS[1] = ptS[0] + 4.5 * data.dSteepW * vtDir;//4.5 步
|
|
|
|
ptTo = ptS[0];
|
|
DrawLeader(dc,ptS[0],ptS[1],kGreen);
|
|
|
|
DrawUporDown(dc,ptS[0],-vtDir,1);
|
|
|
|
ptS[0] += data.nSteeps1 * data.dSteepW * vtDir;
|
|
ptS[0] += 0.5 * data.dRestPtW * vtDir;
|
|
ptS[1] += data.dSteepW * vtDir;
|
|
|
|
DrawLeader(dc,ptS[0],ptS[1],kGreen);
|
|
|
|
//
|
|
ptS[1] = ptS[0] + (data.dStairSW + data.dWellW) * vtLR;
|
|
ptS[2] = ptFr + (0.5 * data.dStairSW - data.dGarSize[0]) * vtLR;
|
|
ptS[2] -= 0.5 * data.dSteepW * vtDir;//一半步宽
|
|
|
|
pL = FormatPolyline(ptS,3);
|
|
if (pL != NULL)
|
|
{
|
|
pL->setColorIndex(kGreen);
|
|
arEntDrawPtrs.append(pL);
|
|
|
|
DrawUporDown(dc,ptS[2],-vtDir,-1);
|
|
}
|
|
}
|
|
else//右侧上梯
|
|
{
|
|
ptS[0] = ptBase;
|
|
ptS[0] += data.dWellW * vtLR;
|
|
ptS[0] += 0.5 * data.dStairSW * vtLR;
|
|
ptS[0] -= 0.5 * data.dSteepW * vtDir;//一半步宽
|
|
ptS[1] = ptS[0] + 4.5 * data.dSteepW * vtDir;//4.5 步
|
|
|
|
ptTo = ptS[0];
|
|
DrawLeader(dc,ptS[0],ptS[1],kGreen);
|
|
|
|
DrawUporDown(dc,ptS[0],-vtDir,1);
|
|
|
|
ptS[0] += data.nSteeps1 * data.dSteepW * vtDir;
|
|
ptS[0] += 0.5 * data.dRestPtW * vtDir;
|
|
ptS[1] += data.dSteepW * vtDir;
|
|
|
|
DrawLeader(dc,ptS[0],ptS[1],kGreen);
|
|
|
|
//
|
|
ptS[1] = ptS[0] + (data.dStairSW + data.dWellW) * vtLR;
|
|
ptS[2] = ptFr + (0.5 * data.dStairSW - data.dGarSize[0]) * vtLR;
|
|
ptS[2] -= 0.5 * data.dSteepW * vtDir;//一半步宽
|
|
|
|
pL = FormatPolyline(ptS,3);
|
|
if (pL != NULL)
|
|
{
|
|
pL->setColorIndex(kGreen);
|
|
arEntDrawPtrs.append(pL);
|
|
|
|
DrawUporDown(dc,ptS[0],-vtDir,-1);
|
|
}
|
|
}
|
|
}
|
|
|
|
//统一绘制
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int j = 0;j < arEntDrawPtrs.length();j++)
|
|
{
|
|
pEnt = (AcDbEntity*)arEntDrawPtrs.at(j);
|
|
dc.DrawEntity(pEnt);
|
|
Add2DBuffer(pEnt);
|
|
}
|
|
|
|
delete pBaseCrv;
|
|
dc.SetLayer(idLayOld);
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbZLineStair::DrawZLine(const AcGePoint3d& ptZCen,const AcGeVector3d& vtDir,
|
|
double dSteepW,double dStairSW,
|
|
AcDbVoidPtrArray& arEntDrawPtrs) const
|
|
{
|
|
double dLx = 178.0,dOff = 100.0;
|
|
|
|
|
|
//30度斜 70度折
|
|
AcGeVector3d vtZ = vtDir;
|
|
vtZ.rotateBy(-PI / 3.0,AcGeVector3d::kZAxis);//60
|
|
vtZ.normalize();
|
|
|
|
//70度斜 Z 中线斜
|
|
AcGeVector3d vtL = vtZ;
|
|
vtL.rotateBy(-1.222,AcGeVector3d::kZAxis);//70
|
|
vtL.normalize();
|
|
|
|
//Z 左右斜
|
|
AcGeVector3d vtLx = vtL;
|
|
vtLx.rotateBy(-0.61087,AcGeVector3d::kZAxis);//35
|
|
vtLx.normalize();
|
|
|
|
//
|
|
AcGePoint3d ptZ[6];
|
|
ptZ[2] = ptZCen - vtL * 0.5 * dSteepW;
|
|
ptZ[1] = ptZ[2] + dLx * vtLx;
|
|
|
|
double dLf = 0.5 * dStairSW / cos(PI / 6.0);
|
|
ptZ[0] = ptZCen - vtZ * dLf;
|
|
ptZ[0] -= vtDir * 0.5 * dOff / cos(PI / 6.0);
|
|
|
|
ptZ[3] = ptZCen + vtL * 0.5 * dSteepW;
|
|
ptZ[4] = ptZ[3] - dLx * vtLx;
|
|
|
|
ptZ[5] = ptZCen + vtZ * dLf;
|
|
ptZ[5] += vtDir * 0.5 * dOff / cos(PI / 6.0);
|
|
|
|
AcDbPolyline* pPl = FormatPolyline(ptZ,6);
|
|
if (pPl != NULL)
|
|
{
|
|
AcGePoint3d ptL[2];
|
|
|
|
ptL[0] = ptZ[0] + vtDir * dOff / cos(PI / 6.0);
|
|
ptL[1] = ptZ[1] - dOff / cos(0.416667) * vtLx;//15
|
|
AcDbLine* pLn0 = new AcDbLine(ptL[0],ptL[1]);
|
|
|
|
ptL[0] = ptZ[5] - vtDir * dOff / cos(PI / 6.0);
|
|
ptL[1] = ptZ[4] + dOff / cos(0.416667) * vtLx;
|
|
AcDbLine* pLn1 = new AcDbLine(ptL[0],ptL[1]);
|
|
|
|
AcDbVoidPtrArray arSplitPtrs;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arEntDrawPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arEntDrawPtrs.at(i);
|
|
|
|
//首先和pl相交
|
|
AcGePoint3dArray arPts;
|
|
pEnt->intersectWith(pPl,AcDb::kOnBothOperands,arPts);
|
|
if (!arPts.isEmpty())
|
|
{
|
|
pEnt->intersectWith(pLn0,AcDb::kOnBothOperands,arPts);
|
|
pEnt->intersectWith(pLn1,AcDb::kOnBothOperands,arPts);
|
|
|
|
if (arPts.length() > 2)//如果多于2点,去除端点压线
|
|
{
|
|
arPts.remove(pLn0->startPoint());
|
|
arPts.remove(pLn0->endPoint());
|
|
arPts.remove(pLn1->startPoint());
|
|
arPts.remove(pLn1->endPoint());
|
|
|
|
arPts.remove(ptZ[0]);
|
|
arPts.remove(ptZ[5]);
|
|
}
|
|
|
|
if (arPts.length() == 2)
|
|
{
|
|
AcDbCurve* pCurve = AcDbCurve::cast(pEnt);
|
|
if (pCurve != NULL)
|
|
{
|
|
SortPoints(arPts,pCurve);
|
|
|
|
//裁剪
|
|
AcDbVoidPtrArray arSubCurPtrs;
|
|
pCurve->getSplitCurves(arPts,arSubCurPtrs);
|
|
|
|
//三条,取两头
|
|
if (arSubCurPtrs.length() == 3)
|
|
{
|
|
arSplitPtrs.append(arSubCurPtrs.first());
|
|
arSplitPtrs.append(arSubCurPtrs.last());
|
|
|
|
AcDbEntity* pEntT = (AcDbEntity*)arSubCurPtrs.at(1);
|
|
delete pEntT;
|
|
|
|
delete pEnt;
|
|
arEntDrawPtrs.removeAt(i);
|
|
i -= 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
arEntDrawPtrs.append(pPl);
|
|
arEntDrawPtrs.append(pLn0);
|
|
arEntDrawPtrs.append(pLn1);
|
|
arEntDrawPtrs.append(arSplitPtrs);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbZLineStair::DrawUporDown(AcGiDraw &dc,const AcGePoint3d& ptFr,const AcGeVector3d& vtOff,int nUporDown) const
|
|
{
|
|
double dDocScale = 100.0;
|
|
GetDocScale(dDocScale);
|
|
|
|
AcGePoint3d ptOff = ptFr + vtOff * 1.5 * dDocScale;
|
|
ptOff += vtOff * 3.5 * dDocScale;
|
|
|
|
LPCTSTR pszText = nUporDown < 0 ? _T("下") : _T("上");
|
|
|
|
AcGeVector3d vtT = vtOff;
|
|
vtT.negate();
|
|
vtT.rotateBy(-PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtT.normalize();
|
|
|
|
double dRot = AcGeVector3d::kXAxis.angleTo(vtT);
|
|
ptOff -= 1.75 * dDocScale * vtT;
|
|
|
|
AcDbText* pText = new AcDbText;
|
|
pText->setPosition(ptOff);
|
|
pText->setHeight(3.5 * dDocScale);
|
|
pText->setWidthFactor(0.75);
|
|
pText->setNormal(AcGeVector3d::kZAxis);
|
|
pText->setTextString(pszText);
|
|
pText->setRotation(dRot);
|
|
|
|
AcDbObjectId idSt = KTSetting::InitTextStyle(_T("Pipe_Dim"));
|
|
pText->setTextStyle(idSt);
|
|
pText->setLayer(layerId());
|
|
pText->setColorIndex(kWhite);
|
|
|
|
dc.DrawEntity(pText);
|
|
Add2DBuffer(pText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbZLineStair::DrawLeader(AcGiDraw &dc,AcGePoint3d& pt0,AcGePoint3d& pt1,int nColor) const
|
|
{
|
|
double dAL = 3.0;
|
|
double dAW = 0.8;
|
|
double dDocScale = 100.0;
|
|
GetDocScale(dDocScale);
|
|
|
|
AcGeVector3d vt = pt1 - pt0;
|
|
vt.normalize();
|
|
|
|
AcGePoint3d ptA = pt1 - vt * dAL * dDocScale;
|
|
|
|
AcDbPolyline* pPl = new AcDbPolyline;
|
|
pPl->addVertexAt(0,pt0.convert2d(AcGePlane::kXYPlane));
|
|
pPl->addVertexAt(1,ptA.convert2d(AcGePlane::kXYPlane),0,dAW*dDocScale);
|
|
pPl->addVertexAt(2,pt1.convert2d(AcGePlane::kXYPlane),0,0);
|
|
pPl->setColorIndex(nColor);
|
|
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbZLineStair::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
//样子参照 PDMS 的样子
|
|
assertReadEnabled();
|
|
|
|
//管线系统屏蔽掉
|
|
if ( dc.IsDragging() )
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
if (m_pBaseCurve == NULL)
|
|
return Acad::eInvalidInput;
|
|
|
|
//图层
|
|
AcDbObjectId idLay = dc.GetLayerId();
|
|
dc.SetLayer(layerId());
|
|
|
|
int nCrBk = dc.GetColor();
|
|
|
|
if (Has3DBuffer())
|
|
{
|
|
//Clean3DBuffer();
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar3D = Get3DBuffer();
|
|
for (int i = 0;i < ar3D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar3D.at(i);
|
|
dc.SetColor(colorIndex());
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
|
|
dc.SetLayer(idLay);
|
|
dc.SetColor(nCrBk);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
dc.SetColor(colorIndex());
|
|
|
|
ZLineStair data;
|
|
memset(&data,0,sizeof(ZLineStair));
|
|
GetZLineStairData(data);
|
|
|
|
if (m_pBaseCurve != NULL)//路径
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptSta,ptEnd;
|
|
ptSta = pLn->startPoint();
|
|
ptEnd = pLn->endPoint();
|
|
|
|
deleteContainerOfStd(m_solids);
|
|
deleteContainerOfStd(m_pipes);
|
|
DrawSteep3d(dc,ptSta,ptEnd,data);
|
|
}
|
|
}
|
|
dc.SetLayer(idLay);
|
|
dc.SetColor(nCrBk);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbZLineStair::DrawSteep3d(AcGiDraw &dc,const AcGePoint3d& ptFr,const AcGePoint3d& ptTo,ZLineStair& data) const
|
|
{
|
|
//1跑
|
|
AcGePoint3d ptBase = ptFr;
|
|
ptBase.z = data.dBomEl;
|
|
|
|
AcGeVector3d vtDir = ptTo - ptFr;
|
|
vtDir.z = 0.0;
|
|
vtDir.normalize();
|
|
|
|
AcGeVector3d vtLR;
|
|
if (data.nUpSide == 0)//左侧上梯
|
|
{
|
|
vtLR = vtDir;
|
|
vtLR.rotateBy(-PI / 2.0,AcGeVector3d::kZAxis);
|
|
}
|
|
else//右侧
|
|
{
|
|
vtLR = vtDir;
|
|
vtLR.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
}
|
|
|
|
AcGeVector3d vtStep;//精确计算楼梯的上下跑向向量
|
|
AcGePoint3d ptVet = ptBase;
|
|
AcGePoint3d ptBar;
|
|
|
|
AcGePoint3dArray arZPts,arGuarPts;
|
|
|
|
for (int i = 0;i <= data.nSteeps1;i++)
|
|
{
|
|
arZPts.append(ptVet);
|
|
|
|
ptVet.z += data.dSteepH;
|
|
arZPts.append( ptVet);
|
|
|
|
if (i == data.nSteeps1)
|
|
break;
|
|
|
|
ptVet += vtDir * data.dSteepW;
|
|
|
|
//中点
|
|
ptBar = MidPoint(arZPts.last(),ptVet);
|
|
arGuarPts.append(ptBar);
|
|
|
|
if (arZPts.length() == 4)
|
|
{
|
|
vtStep = arZPts.last() - arZPts.at(1);
|
|
vtStep.normalize();
|
|
}
|
|
}
|
|
|
|
//二跑开始处
|
|
AcGePoint3d pt2Fr = ptVet;
|
|
|
|
//倒数第2点,二跑底支撑点
|
|
AcGePoint3d pt2Bom = arZPts.at(arZPts.length() - 2);
|
|
|
|
arZPts.removeLast();
|
|
|
|
//休息平台
|
|
AcGePoint3dArray arRestPts;
|
|
arRestPts.append(ptVet);
|
|
|
|
ptVet += vtDir * (data.dRestPtW - data.dSideBeamW);
|
|
arRestPts.append(ptVet);
|
|
|
|
ptVet.z += data.dSideBeamH;
|
|
arRestPts.append(ptVet);
|
|
|
|
ptVet += vtDir * data.dSideBeamW;
|
|
arRestPts.append(ptVet);
|
|
|
|
ptVet.z -= (data.dSideBeamH + data.dStiffnH + data.dSbThick);
|
|
arRestPts.append(ptVet);
|
|
|
|
ptVet -= vtDir * data.dStiffnW;
|
|
arRestPts.append(ptVet);
|
|
|
|
ptVet.z += data.dStiffnH;
|
|
arRestPts.append(ptVet);
|
|
|
|
ptVet -= vtDir * (data.dRestPtW - 2.0 * data.dStiffnW);
|
|
arRestPts.append(ptVet);
|
|
|
|
ptVet.z -= data.dStiffnH;
|
|
arRestPts.append(ptVet);
|
|
|
|
ptVet -= vtDir * data.dStiffnW;
|
|
arRestPts.append(ptVet);
|
|
arRestPts.append(arRestPts.first());
|
|
|
|
arZPts.append(ptVet);
|
|
|
|
AcDbRay rayL;
|
|
rayL.setUnitDir(vtStep.negate());
|
|
rayL.setBasePoint(ptVet);
|
|
|
|
AcDbRay rayX;
|
|
rayX.setUnitDir(vtDir);
|
|
rayX.setBasePoint(arZPts.first());
|
|
|
|
AcGePoint3dArray arPts;
|
|
rayX.intersectWith(&rayL,AcDb::kOnBothOperands,arPts);
|
|
|
|
if (!arPts.isEmpty())
|
|
{
|
|
arZPts.append(arPts.first());
|
|
arZPts.append(arZPts.first());
|
|
|
|
AcDbLine ln;
|
|
ln.setStartPoint(arZPts.first());
|
|
|
|
AcGePoint3d ptEnd = arZPts.first() + vtLR * data.dStairSW;
|
|
ln.setEndPoint(ptEnd);
|
|
|
|
//楼梯1
|
|
AcDbRegion* pReg = CreatePolygonRegionOnly(arZPts.asArrayPtr(),arZPts.length());
|
|
if (pReg != NULL)
|
|
{
|
|
AcDbX3dSolid x3dSolid;
|
|
if ( x3dSolid.CreateExtrude(pReg,ln) )
|
|
{
|
|
m_solids.push_back(x3dSolid.Clone());
|
|
AcDb3dSolid* pSolid = (AcDb3dSolid*)x3dSolid.GetNative3dSolid()->clone();
|
|
if (pSolid != NULL)
|
|
{
|
|
pSolid->setTransparency(transparency());
|
|
dc.DrawEntity(pSolid);
|
|
Add3DBuffer(pSolid);
|
|
}
|
|
}
|
|
delete pReg;
|
|
}
|
|
|
|
//休息平台
|
|
pReg = CreatePolygonRegionOnly(arRestPts.asArrayPtr(),arRestPts.length());
|
|
if (pReg != NULL)
|
|
{
|
|
ln.setStartPoint(arRestPts.first());
|
|
|
|
ptEnd = arRestPts.first() + vtLR * data.dStairTW;
|
|
ln.setEndPoint(ptEnd);
|
|
|
|
AcDbX3dSolid x3dSolid;
|
|
if ( x3dSolid.CreateExtrude(pReg,ln) )
|
|
{
|
|
m_solids.push_back(x3dSolid.Clone());
|
|
AcDb3dSolid* pSolid = (AcDb3dSolid*)x3dSolid.GetNative3dSolid()->clone();
|
|
if (pSolid != NULL)
|
|
{
|
|
pSolid->setTransparency(transparency());
|
|
dc.DrawEntity(pSolid);
|
|
Add3DBuffer(pSolid);
|
|
}
|
|
}
|
|
delete pReg;
|
|
}
|
|
|
|
//两侧护栏
|
|
DrawGuarBar3d(dc,arGuarPts,vtLR,data);
|
|
}
|
|
|
|
//2跑
|
|
arZPts.removeAll();
|
|
arGuarPts.removeAll();
|
|
|
|
pt2Fr += (data.dStairSW + data.dWellW) * vtLR;
|
|
pt2Bom += (data.dStairSW + data.dWellW) * vtLR;
|
|
|
|
//从底部支撑开始
|
|
arZPts.append(pt2Bom);
|
|
|
|
ptVet = pt2Fr;
|
|
for (int i = 0;i < data.nSteeps2;i++)
|
|
{
|
|
arZPts.append(ptVet);
|
|
|
|
ptVet.z += data.dSteepH;
|
|
arZPts.append( ptVet);
|
|
|
|
ptVet -= vtDir * data.dSteepW;//回跑
|
|
|
|
//中点
|
|
ptBar = MidPoint(arZPts.last(),ptVet);
|
|
arGuarPts.append(ptBar);
|
|
|
|
if (arZPts.length() == 5)
|
|
{
|
|
vtStep = arZPts.last() - arZPts.at(2);
|
|
vtStep.normalize();
|
|
}
|
|
}
|
|
|
|
//最后踏步
|
|
arZPts.append(ptVet);
|
|
|
|
rayL.setBasePoint(pt2Bom);
|
|
rayL.setUnitDir(vtStep);
|
|
|
|
rayX.setBasePoint(ptVet);
|
|
rayX.setUnitDir(-AcGeVector3d::kZAxis);
|
|
|
|
arPts.removeAll();
|
|
rayX.intersectWith(&rayL,AcDb::kOnBothOperands,arPts);
|
|
|
|
if (!arPts.isEmpty())
|
|
{
|
|
arZPts.append(arPts.first());
|
|
arZPts.append(arZPts.first());
|
|
|
|
AcDbLine ln;
|
|
ln.setStartPoint(arZPts.first());
|
|
|
|
AcGePoint3d ptEnd = arZPts.first() + vtLR * data.dStairSW;
|
|
ln.setEndPoint(ptEnd);
|
|
|
|
//楼梯2
|
|
AcDbRegion* pReg = CreatePolygonRegionOnly(arZPts.asArrayPtr(),arZPts.length());
|
|
if (pReg != NULL)
|
|
{
|
|
AcDbX3dSolid x3dSolid;
|
|
if ( x3dSolid.CreateExtrude(pReg,ln) )
|
|
{
|
|
m_solids.push_back(x3dSolid.Clone());
|
|
AcDb3dSolid* pSolid = (AcDb3dSolid*)x3dSolid.GetNative3dSolid()->clone();
|
|
if (pSolid != NULL)
|
|
{
|
|
pSolid->setTransparency(transparency());
|
|
dc.DrawEntity(pSolid);
|
|
Add3DBuffer(pSolid);
|
|
}
|
|
}
|
|
delete pReg;
|
|
}
|
|
|
|
//两侧护栏
|
|
DrawGuarBar3d(dc,arGuarPts,vtLR,data);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbZLineStair::DrawGuarBar3d(AcGiDraw &dc,AcGePoint3dArray& arGBarPts,const AcGeVector3d& vtLR,ZLineStair& data) const
|
|
{
|
|
AcGePoint3d pt,pt2,ptT;
|
|
AcGePoint3d ptGar[2];
|
|
|
|
AcDbLine ln;
|
|
AecDbEwPipeBase pipe;
|
|
AcDbVoidPtrArray ar3DSoldPtrs;
|
|
AcGiExplodeDraw dc2(ar3DSoldPtrs);
|
|
|
|
for (int i = 0;i < arGBarPts.length();i++)
|
|
{
|
|
pt = arGBarPts.at(i);
|
|
|
|
//上扶手侧和楼梯侧平齐,该位置为护栏插入位置
|
|
pt += 0.5 * data.dGarSize[0] * vtLR;
|
|
pt2 = pt;
|
|
pt2.z += data.dBarH;
|
|
|
|
if (i == 0)
|
|
{
|
|
ptGar[0] = pt2;
|
|
}
|
|
else if(i == arGBarPts.length() - 1)
|
|
{
|
|
ptGar[1] = pt2;
|
|
}
|
|
|
|
if (data.nGShape == 0)
|
|
pipe.SetSection(data.dBarSize[0],data.dBarSize[1],0.0);
|
|
else
|
|
pipe.SetSection(data.dBarSize[0],0.0);
|
|
|
|
ln.setStartPoint(pt);
|
|
ln.setEndPoint(pt2);
|
|
pipe.SetBaseCurve(&ln);
|
|
|
|
pipe.Draw3d(dc2);
|
|
m_pipes.push_back((AecDbEwPipeBase*)pipe.clone());
|
|
pipe.Clean3DBufferNoDel();
|
|
|
|
|
|
//对称位置
|
|
pt += (data.dStairSW - data.dBarSize[0]) * vtLR;
|
|
pt2 += (data.dStairSW - data.dBarSize[0]) * vtLR;
|
|
|
|
ln.setStartPoint(pt);
|
|
ln.setEndPoint(pt2);
|
|
pipe.SetBaseCurve(&ln);
|
|
|
|
pipe.Draw3d(dc2);
|
|
m_pipes.push_back((AecDbEwPipeBase*)pipe.clone());
|
|
pipe.Clean3DBufferNoDel();
|
|
}
|
|
|
|
//扶手
|
|
ln.setStartPoint(ptGar[0]);
|
|
ln.setEndPoint(ptGar[1]);
|
|
|
|
if (data.nBShape == 0)
|
|
pipe.SetSection(data.dBarSize[0],data.dBarSize[1],0);
|
|
else
|
|
pipe.SetSection(data.dBarSize[0],0);
|
|
|
|
pipe.SetBaseCurve(&ln);
|
|
|
|
pipe.Draw3d(dc2);
|
|
m_pipes.push_back((AecDbEwPipeBase*)pipe.clone());
|
|
pipe.Clean3DBufferNoDel();
|
|
|
|
//扶手伸出
|
|
AcGeVector3d vtE = ptGar[0] - ptGar[1];
|
|
vtE.z = 0.0;
|
|
vtE.normalize();
|
|
|
|
ln.setStartPoint(ptGar[0]);
|
|
ptT = ptGar[0] + vtE * data.dGarExt;
|
|
ln.setEndPoint(ptT);
|
|
pipe.SetBaseCurve(&ln);
|
|
|
|
pipe.Draw3d(dc2);
|
|
m_pipes.push_back((AecDbEwPipeBase*)pipe.clone());
|
|
pipe.Clean3DBufferNoDel();
|
|
|
|
//对称位置
|
|
ptGar[0] += (data.dStairSW - data.dBarSize[0]) * vtLR;
|
|
ptGar[1] += (data.dStairSW - data.dBarSize[0]) * vtLR;
|
|
ln.setStartPoint(ptGar[0]);
|
|
ln.setEndPoint(ptGar[1]);
|
|
pipe.SetBaseCurve(&ln);
|
|
|
|
pipe.Draw3d(dc2);
|
|
m_pipes.push_back((AecDbEwPipeBase*)pipe.clone());
|
|
pipe.Clean3DBufferNoDel();
|
|
|
|
//扶手伸出
|
|
ln.setStartPoint(ptGar[0]);
|
|
ptT = ptGar[0] + vtE * data.dGarExt;
|
|
ln.setEndPoint(ptT);
|
|
pipe.SetBaseCurve(&ln);
|
|
|
|
pipe.Draw3d(dc2);
|
|
m_pipes.push_back((AecDbEwPipeBase*)pipe.clone());
|
|
pipe.Clean3DBufferNoDel();
|
|
|
|
int nCrbk = dc.GetColor();
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < ar3DSoldPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar3DSoldPtrs.at(i);
|
|
pEnt->setColorIndex(kCyan);
|
|
pEnt->setTransparency(transparency());
|
|
dc.SetColor(kCyan);
|
|
dc.DrawEntity(pEnt);
|
|
Add3DBuffer(pEnt);
|
|
}
|
|
|
|
dc.SetColor(nCrbk);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int AecDbZLineStair::GetSectionDraw(const AcGePoint3d& ptFr,const AcGePoint3d& ptTo,const AcGeVector3d& vtViewDir,const AcGeVector3d& vtTo, AcDbVoidPtrArray& arRegPtrs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGeVector3d vtLn = ptTo - ptFr;
|
|
AcGeVector3d vtNorm = vtLn.crossProduct(vtViewDir);
|
|
|
|
AcGePlane plan;
|
|
plan.set(ptFr,vtNorm);
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToPlaneToWorld(plan);
|
|
xform.invert();
|
|
|
|
if (Get3DBuffer().length() == 0)
|
|
{
|
|
AcGiViewDraw dc(NULL,NULL);
|
|
Draw3d(dc);
|
|
}
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDb3dSolid* pSolid = NULL;
|
|
|
|
AcDbVoidPtrArray arRegPtrsT;
|
|
|
|
const AcDbVoidPtrArray &ar3D = Get3DBuffer();
|
|
for (int i = 0;i < ar3D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar3D.at(i);
|
|
|
|
pSolid = AcDb3dSolid::cast(pEnt);
|
|
if (pSolid != NULL)
|
|
{
|
|
//投影法
|
|
OrthoProjected3DSolid(pSolid,plan,xform,arRegPtrsT);
|
|
}
|
|
}
|
|
|
|
for (int i = 0;i < arRegPtrsT.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arRegPtrsT.at(i);
|
|
pEnt->setLayer(layerId());
|
|
pEnt->setColorIndex(kColorByLayer);
|
|
arRegPtrs.append(pEnt);
|
|
}
|
|
|
|
return arRegPtrs.length();
|
|
}
|
|
|
|
CString AecDbZLineStair::getUniqueName() const
|
|
{
|
|
assertReadEnabled();
|
|
CString str(_T(""));
|
|
ZLineStair data;
|
|
::memset(&data, 0, sizeof(ZLineStair));
|
|
GetZLineStairData(data);
|
|
|
|
::memset(data.szGarMat, 0, 256 * sizeof(TCHAR));
|
|
::memset(data.szBarMat, 0, 256 * sizeof(TCHAR));
|
|
::memset(&data.dBomEl, 0, sizeof(double));
|
|
|
|
return ImpMD5(&data, sizeof(ZLineStair)).toString16W().c_str();
|
|
}
|
|
|
|
SHJson::WValue & AecDbZLineStair::ToJson(bool bExprotGeo) const
|
|
{
|
|
assertReadEnabled();
|
|
using namespace SHJson;
|
|
WValue &v = AecDbEwPipeBase::ToJson(bExprotGeo);
|
|
|
|
if (bExprotGeo)
|
|
{
|
|
AecDbZLineStair *pNew = (AecDbZLineStair*)clone();
|
|
AcDbCurve *pCurve = pNew->GetNativeCurve();
|
|
if (pCurve)
|
|
{
|
|
AcGePoint3d ptS(AcGePoint3d::kOrigin);
|
|
AcGePoint3d ptE(ptS);
|
|
pCurve->getStartPoint(ptS);
|
|
pCurve->getEndPoint(ptE);
|
|
AcGeMatrix3d mat;
|
|
|
|
mat.setToTranslation(-ptS.asVector());
|
|
pCurve->transformBy(mat);
|
|
|
|
pCurve->getStartPoint(ptS);
|
|
pCurve->getEndPoint(ptE);
|
|
AcGeVector3d vt(ptE - ptS);
|
|
if (!vt.isCodirectionalTo(AcGeVector3d::kXAxis))
|
|
{
|
|
double dAngle = AcGeVector3d::kXAxis.angleTo(vt, AcGeVector3d::kZAxis);
|
|
mat.setToRotation(-dAngle, AcGeVector3d::kZAxis, ptS);
|
|
pCurve->transformBy(mat);
|
|
}
|
|
}
|
|
pNew->Clean3DBuffer();
|
|
AcGiViewDraw dc;
|
|
pNew->Draw3d(dc);
|
|
|
|
WValue ar;
|
|
ar.SetArray();
|
|
|
|
for (size_t i(0); i < pNew->m_solids.size(); ++i)
|
|
{
|
|
AcDbX3dSolid *pSolid(pNew->m_solids[i]);
|
|
if (!pSolid) continue;
|
|
WValue &x = pSolid->ToJson();
|
|
pushBack(ar, x);
|
|
}
|
|
if (!pNew->m_solids.empty())
|
|
addMember(v, _T("__solids__"), ar);
|
|
|
|
ar.SetArray();
|
|
for (size_t i(0); i < pNew->m_pipes.size(); ++i)
|
|
{
|
|
AecDbEwPipeBase *pPipe(pNew->m_pipes[i]);
|
|
if (!pPipe) continue;
|
|
WValue &x = pPipe->ToJson();
|
|
pushBack(ar, x);
|
|
}
|
|
if (!pNew->m_pipes.empty())
|
|
addMember(v, _T("__pipes__"), ar);
|
|
DELETE_PTR(pNew);
|
|
}
|
|
|
|
|
|
/*
|
|
int nZs; //折数
|
|
int nKind; //0 钢筋混凝土 1 钢梯
|
|
double dSteepH; //踏步高度
|
|
double dSteepW; //踏步宽度
|
|
|
|
int nSteeps1; //一跑步数
|
|
int nSteeps2; //二跑步数
|
|
|
|
double dStairTW; //梯间宽度 总宽
|
|
double dStairSW; //梯段宽度 单宽
|
|
double dWellW; //井宽
|
|
|
|
int nUpSide; //上梯位置 0 L 1 R
|
|
double dBomEl; //底部标高
|
|
|
|
//平台参数
|
|
double dRestPtW; //休息平台宽
|
|
double dStiffnW; //加强筋宽 钢梯无效
|
|
double dStiffnH; //加强筋高 钢梯无效
|
|
double dSbThick; //平台板厚
|
|
|
|
//边梁
|
|
double dSideBeamW; //边梁宽 60
|
|
double dSideBeamH; //边梁高 60
|
|
|
|
//扶手护栏
|
|
double dBarH; //扶手高度
|
|
double dGarSize[2]; //扶手截面尺寸
|
|
double dGarExt; //转角扶手伸出 60 默认
|
|
double dZGarExt; //层间扶手伸出 60 默认
|
|
int nGShape; //截面类型0 Rect 1 C
|
|
TCHAR szGarMat[256];//材质
|
|
|
|
double dBarSp; //护栏间距
|
|
double dBarSize[2]; //护栏截面尺寸
|
|
int nBShape; //护栏截面类型0 Rect 1 C
|
|
TCHAR szBarMat[256];//材质
|
|
*/
|
|
|
|
ZLineStair data;
|
|
memset(&data, 0, sizeof(ZLineStair));
|
|
GetZLineStairData(data);
|
|
WValue vData;
|
|
|
|
addMember(vData, _T("__nZs__"), data.nZs);
|
|
addMember(vData, _T("__nKind__"), data.nKind);
|
|
addMember(vData, _T("__dSteepH__"), data.dSteepH);
|
|
addMember(vData, _T("__dSteepW__"), data.dSteepW);
|
|
|
|
addMember(vData, _T("__nSteeps1__"), data.nSteeps1);
|
|
addMember(vData, _T("__nSteeps2__"), data.nSteeps2);
|
|
|
|
addMember(vData, _T("__dStairTW__"), data.dStairTW);
|
|
addMember(vData, _T("__dStairSW__"), data.dStairSW);
|
|
addMember(vData, _T("__dWellW__"), data.dWellW);
|
|
|
|
addMember(vData, _T("__nUpSide__"), data.nUpSide);
|
|
addMember(vData, _T("__dBomEl__"), data.dBomEl);
|
|
|
|
//平台参数
|
|
addMember(vData, _T("__dRestPtW__"), data.dRestPtW);
|
|
addMember(vData, _T("__dStiffnW__"), data.dStiffnW);
|
|
addMember(vData, _T("__dStiffnH__"), data.dStiffnH);
|
|
addMember(vData, _T("__dSbThick__"), data.dSbThick);
|
|
|
|
//边梁
|
|
addMember(vData, _T("__dSideBeamW__"), data.dSideBeamW);
|
|
addMember(vData, _T("__dSideBeamH__"), data.dSideBeamH);
|
|
|
|
//扶手护栏
|
|
addMember(vData, _T("__dBarH__"), data.dBarH);
|
|
|
|
WValue ar;
|
|
ar.SetArray();
|
|
for (int i(0); i < sizeof(data.dGarSize) / sizeof(data.dGarSize[0]); ++i)
|
|
pushBack(ar, data.dGarSize[i]);
|
|
addMember(vData, _T("__dGarSize__"), ar);
|
|
|
|
addMember(vData, _T("__dGarExt__"), data.dGarExt);
|
|
addMember(vData, _T("__dZGarExt__"), data.dZGarExt);
|
|
addMember(vData, _T("__nGShape__"), data.nGShape);
|
|
addMember(vData, _T("__szGarMat__"), data.szGarMat);
|
|
|
|
addMember(vData, _T("__dBarSp__"), data.dBarSp);
|
|
|
|
ar.SetArray();
|
|
for (int i(0); i < sizeof(data.dBarSize) / sizeof(data.dBarSize[0]); ++i)
|
|
pushBack(ar, data.dBarSize[i]);
|
|
addMember(vData, _T("__dBarSize__"), ar);
|
|
|
|
addMember(vData, _T("__nBShape__"), data.nBShape);
|
|
addMember(vData, _T("__szBarMat__"), data.szBarMat);
|
|
|
|
addMember(v, _T("_ZLineStair_data_"), vData);
|
|
|
|
return v;
|
|
}
|
|
|
|
#include "HlrCutOption.h"
|
|
void AecDbZLineStair::ProcessHlrResult(const AcArray<AcDbEntity *> &ar
|
|
, const std::map<AcDbEntity *, AcArray<AcDbEntity *>> &preAr
|
|
, AcArray<AcDbEntity *> &output) const
|
|
{
|
|
HlrCutOption::ProcessHlrResult(this
|
|
, FALSE
|
|
, .0
|
|
, HlrCutOption::getHlrBLK_STAIR()
|
|
, ar
|
|
, preAr
|
|
, output);
|
|
}
|