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

3539 lines
87 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "stdafx.h"
#include "TDbColumn.h"
////////////////////////////////////////////////////////////////////////////
// ver: 0-TArch8
const Adesk::UInt8 TDbTriangleStair::g_nVersion = 0;
ACRX_DXF_DEFINE_MEMBERS(ATSTriangleStair, ATSPolyPathEnt, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
1, ATS_TRIANGLESTAIR, "ATS_TRIANGLESTAIR图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
IMPLEMENT_TENTBASE(TDbTriangleStair);
TDbTriangleStair::TDbTriangleStair()
{
m_nStepHeight=_AS_SYS_UNIT(220.0); //踏步高
m_nStepWidth=_AS_SYS_UNIT(300); //踏步宽
m_nStairWidth=_AS_SYS_UNIT(1200); //梯段宽
m_nRotation=0.0; //旋转角度
m_nStepNum=0; //梯段步数
m_nSpaceWidth=_AS_SYS_UNIT(3600.0); //梯段间距
m_nRailHeight=_AS_SYS_UNIT(900); //扶手高
m_nStairFlag=1; //楼层标记
m_nStartSide=OFFSET_LEFT; //顺时针上楼
m_nRailWidth=_AS_SYS_UNIT(60.0); //扶手宽度
m_nRailDist=m_nStepWidth*0.5; //扶手伸出距离
m_dSectRotation=PI/6.0; //剖断线旋转角度
m_nSlabSize=_AS_SYS_UNIT(1200); //休息平台尺寸
m_nFlagEx=0;
m_nBeamHeight=_AS_SYS_UNIT(200); //边梁高,坡道专用
m_nBeamThick=_AS_SYS_UNIT(120); //边梁厚度
m_nSlabThick=_AS_SYS_UNIT(120); //板厚或梁厚
m_nViewCtrl=0; //自动确定
m_nFlagEx |= SFEX_SECTPOS;
m_dTextHeight=3.5;
}
TDbTriangleStair::~TDbTriangleStair()
{
}
BOOL TDbTriangleStair::IsValid() const
{
BOOL bRet=TDbEntity::IsValid();
if(!bRet)
return bRet;
bRet=(m_nStepHeight>_DIST_SNAP && //踏步高
m_nStepWidth>_DIST_SNAP && //踏步宽
m_nStairWidth>_DIST_SNAP && //梯段宽
m_nStepNum>1 && //梯段步数
m_dTextHeight>0&& //字高
m_nRailHeight>_DIST_SNAP && //扶手高
m_nRailWidth>_DIST_SNAP && //扶手宽
m_nRailDistToSide>-_DIST_SNAP &&//扶手距边
GreatEqual(m_nBeamHeight, 0.0) &&//边梁高
GreatEqual(m_nBeamThick, 0.0) &&//边梁厚
GreatEqual(m_nSlabThick, 0.0) &&//休息台厚
m_nStairWidth>m_nRailWidth+m_nRailDistToSide); //扶手边距
return bRet;
}
// 提供对格式刷的支持
void TDbTriangleStair::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag)
{
assertWriteEnabled();
TDbPolyPathEnt::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
TDbTriangleStair *pSrc=TDbTriangleStair::cast(pSrcEntity);
if(pSrc) {
m_nStepHeight=pSrc->m_nStepHeight;
m_nStepWidth=pSrc->m_nStepWidth;
m_nStairWidth=pSrc->m_nStairWidth;
m_nStepNum=pSrc->m_nStepNum;
m_dTextHeight=pSrc->m_dTextHeight;
m_nSpaceWidth=pSrc->m_nSpaceWidth;
m_nRailHeight=pSrc->m_nRailHeight;
m_nRailWidth=pSrc->m_nRailWidth;
m_nRailDistToSide=pSrc->m_nRailDistToSide;
m_nStairFlag=pSrc->m_nStairFlag;
m_nRailDist=pSrc->m_nRailDist;
m_dSectRotation=pSrc->m_dSectRotation;
m_nSectStepNum=pSrc->m_nSectStepNum;
m_nStartSide=pSrc->m_nStartSide;
m_nSlabSize=pSrc->m_nSlabSize;
m_nFlagEx=pSrc->m_nFlagEx;
m_nBeamHeight=pSrc->m_nBeamHeight; //边梁高,坡道专用
m_nBeamThick=pSrc->m_nBeamThick; //边梁厚度
m_nSlabThick=pSrc->m_nSlabThick; //板厚或梁厚
//add by xlc on 090426箭头文字
SetTextUp(pSrc->GetTextUp());
SetTextDown(pSrc->GetTextDown());
if(database()==NULL||
pSrcEntity->database()==NULL||
database()==pSrcEntity->database())
{
m_idLayerHand3d=pSrc->m_idLayerHand3d;
m_idLayerStep3d=pSrc->m_idLayerStep3d;
m_idLayerBeam3d=pSrc->m_idLayerBeam3d;
m_idLayerRail3d=pSrc->m_idLayerRail3d;
m_idLayerArrow=pSrc->m_idLayerArrow;
m_idLayerText=pSrc->m_idLayerText;
m_idTextStyle=pSrc->m_idTextStyle;
}
m_nViewCtrl=pSrc->m_nViewCtrl;
}
}
Acad::ErrorStatus
TDbTriangleStair::subGetClassID(CLSID* pClsid) const
{
return Acad::eOk;
}
// 从DWG读入数据:
Acad::ErrorStatus
TDbTriangleStair::dwgInFields (AcDbDwgFiler* pFiler)
{
assertWriteEnabled();
Acad::ErrorStatus es = TDbPolyPathEnt::dwgInFields(pFiler);
if(es != Acad::eOk) return es;
Adesk::UInt8 nVer;
pFiler->readItem(&nVer);
if(nVer>g_nVersion) {// Version is too new
return Acad::eMakeMeProxy;
}
pFiler->readItem((AcGePoint3d *)&m_ptLocation);
pFiler->readItem(&m_nRotation); //旋转角度
pFiler->readItem(&m_nStepHeight); //踏步高
pFiler->readItem(&m_nStepWidth); //踏步宽
pFiler->readItem(&m_nStairWidth); //梯段宽
pFiler->readItem(&m_nSlabSize); //休息平台尺寸
pFiler->readItem(&m_nStepNum); //梯段步数
pFiler->readItem(&m_nSpaceWidth); //梯段间距
pFiler->readItem(&m_nRailHeight); //扶手高
pFiler->readItem(&m_nStairFlag); //楼层标记
pFiler->readItem(&m_nStartSide); //起步的一侧
pFiler->readItem(&m_nRailWidth); //扶手宽
pFiler->readItem(&m_nRailDistToSide); //扶手距离边
pFiler->readItem(&m_nRailDist); //扶手伸出距离
pFiler->readItem(&m_nSectStepNum); //剖断步数
pFiler->readItem(&m_dSectRotation); //剖断转角
pFiler->readItem(&m_dTextHeight); //字高
pFiler->readItem(&m_nFlagEx);
pFiler->readItem(&m_nBeamHeight);
pFiler->readItem(&m_nBeamThick);
pFiler->readItem(&m_nSlabThick);
pFiler->readItem(&m_idLayerHand3d);
pFiler->readItem(&m_idLayerStep3d);
pFiler->readItem(&m_idLayerBeam3d);
pFiler->readItem(&m_idLayerRail3d);
pFiler->readItem(&m_idLayerText);
pFiler->readItem(&m_idTextStyle);
pFiler->readItem(&m_idLayerArrow);
pFiler->readItem(&m_nViewCtrl);
return pFiler->filerStatus();
}
Acad::ErrorStatus
TDbTriangleStair::dwgOutFields(AcDbDwgFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es = TDbPolyPathEnt::dwgOutFields(pFiler);
if(es != Acad::eOk) return es;
pFiler->writeItem(g_nVersion);
pFiler->writeItem((AcGePoint3d &)m_ptLocation);
pFiler->writeItem(m_nRotation); //旋转角度
pFiler->writeItem(m_nStepHeight); //踏步高
pFiler->writeItem(m_nStepWidth); //踏步宽
pFiler->writeItem(m_nStairWidth); //梯段宽
pFiler->writeItem(m_nSlabSize); //休息平台尺寸
pFiler->writeItem(m_nStepNum); //梯段步数
pFiler->writeItem(m_nSpaceWidth); //梯段间距
pFiler->writeItem(m_nRailHeight); //扶手高度
pFiler->writeItem(m_nStairFlag); //楼层标记
pFiler->writeItem(m_nStartSide); //起步的一侧
pFiler->writeItem(m_nRailWidth); //扶手宽
pFiler->writeItem(m_nRailDistToSide); //扶手距离边
pFiler->writeItem(m_nRailDist); //扶手伸出距离
pFiler->writeItem(m_nSectStepNum); //剖断步数
pFiler->writeItem(m_dSectRotation); //剖断转角
pFiler->writeItem(m_dTextHeight); //字高
pFiler->writeItem(m_nFlagEx);
pFiler->writeItem(m_nBeamHeight);
pFiler->writeItem(m_nBeamThick);
pFiler->writeItem(m_nSlabThick);
pFiler->writeItem(m_idLayerHand3d);
pFiler->writeItem(m_idLayerStep3d);
pFiler->writeItem(m_idLayerBeam3d);
pFiler->writeItem(m_idLayerRail3d);
pFiler->writeItem(m_idLayerText);
pFiler->writeItem(m_idTextStyle);
pFiler->writeItem(m_idLayerArrow);
pFiler->writeItem(m_nViewCtrl);
return pFiler->filerStatus();
}
Acad::ErrorStatus
TDbTriangleStair::dxfInFields (AcDbDxfFiler* pFiler)
{
assertWriteEnabled();
Acad::ErrorStatus es = TDbPolyPathEnt::dxfInFields(pFiler);
if(es!=Acad::eOk)
return es;
if (!pFiler->atSubclassData(_T("TDbTriangleStair"))) {
return Acad::eBadDxfSequence;
}
Adesk::Int32 fieldsFlags=0;
resbuf rb;
double r1, r2, r3, r4, r5, r6, r7, r8, r9;
int i1, i2, i4;
XPoint pt;
while ((es == Acad::eOk)
&& ((es = pFiler->readResBuf(&rb)) == Acad::eOk)) {
switch (rb.restype) {
case AcDb::kDxfXCoord:
pt=rb.resval.rpoint;
fieldsFlags |= 0x01;
break;
case AcDb::kDxfReal:
r1=rb.resval.rreal;
fieldsFlags |= 0x02;
break;
case AcDb::kDxfReal+1:
r2=rb.resval.rreal;
fieldsFlags |= 0x04;
break;
case AcDb::kDxfReal+2:
r3=rb.resval.rreal;
fieldsFlags |= 0x08;
break;
case AcDb::kDxfReal+3:
r4=rb.resval.rreal;
fieldsFlags |= 0x10;
break;
case AcDb::kDxfReal+4:
r5=rb.resval.rreal;
fieldsFlags |= 0x20;
break;
case AcDb::kDxfReal+5:
r6=rb.resval.rreal;
fieldsFlags |= 0x40;
break;
case AcDb::kDxfReal+6:
r7=rb.resval.rreal;
fieldsFlags |= 0x80;
break;
case AcDb::kDxfReal+7:
r8=rb.resval.rreal;
fieldsFlags |= 0x100;
break;
case AcDb::kDxfReal+8:
m_dSectRotation=rb.resval.rreal;
break;
case AcDb::kDxfReal+9:
m_nRailDist=rb.resval.rreal;
break;
case AcDb::kDxfReal+11:
m_dTextHeight=rb.resval.rreal;
break;
case AcDb::kDxfAngle:
r9 = rb.resval.rreal;
fieldsFlags |= 0x200;
break;
case AcDb::kDxfInt16:
i1=rb.resval.rint;
fieldsFlags |= 0x400;
break;
case AcDb::kDxfInt16+1:
i2=rb.resval.rint;
fieldsFlags |= 0x800;
break;
case AcDb::kDxfInt16+3:
i4=rb.resval.rint;
fieldsFlags |= 0x400;
break;
case 75:
m_nViewCtrl=(Adesk::UInt8)rb.resval.rint;
break;
case 76:
m_nSectStepNum=(Adesk::Int16)rb.resval.rint;
break;
case 90:
m_nFlagEx=rb.resval.rlong;
break;
case 145:
m_nBeamHeight=rb.resval.rreal;
break;
case 146:
m_nBeamThick=rb.resval.rreal;
break;
case 147:
m_nSlabThick=rb.resval.rreal;
break;
case 412:
m_idLayerStep3d=GetLayerIdFromString(rb.resval.rstring, database());
free(rb.resval.rstring);
break;
case 413:
m_idLayerBeam3d=GetLayerIdFromString(rb.resval.rstring, database());
free(rb.resval.rstring);
break;
case 414:
m_idLayerHand3d=GetLayerIdFromString(rb.resval.rstring, database());
free(rb.resval.rstring);
break;
case 415:
m_idLayerRail3d=GetLayerIdFromString(rb.resval.rstring, database());
free(rb.resval.rstring);
break;
case 416:
m_idLayerText=GetLayerIdFromString(rb.resval.rstring, database());
free(rb.resval.rstring);
break;
case 417:
m_idTextStyle=GetLayerIdFromString(rb.resval.rstring, database());
free(rb.resval.rstring);
break;
case 418:
m_idLayerArrow=GetLayerIdFromString(rb.resval.rstring, database());
free(rb.resval.rstring);
break;
//fall through intentional
default:
// An unrecognized group. Push it back so that
// the subclass can read it again.
pFiler->pushBackItem();
es = Acad::eEndOfFile;
break;
}
}
// At this point the es variable must contain eEndOfFile
// - either from readResBuf() or from pushback. If not,
// it indicates that an error happened and we should
// return immediately.
//
if (es != Acad::eEndOfFile)
return Acad::eInvalidResBuf;
if (!(fieldsFlags&0x01)) {
pFiler->setError(Acad::eMissingDxfField, _T("\nMissing DXF group code: 10"));
return Acad::eMissingDxfField;
}
if (!(fieldsFlags&0x02)) {
pFiler->setError(Acad::eMissingDxfField, _T("\nMissing DXF group code: 40"));
return Acad::eMissingDxfField;
}
if (!(fieldsFlags&0x04)) {
pFiler->setError(Acad::eMissingDxfField, _T("\nMissing DXF group code: 41"));
return Acad::eMissingDxfField;
}
if (!(fieldsFlags&0x08)) {
pFiler->setError(Acad::eMissingDxfField, _T("\nMissing DXF group code: 42"));
return Acad::eMissingDxfField;
}
if (!(fieldsFlags&0x10)) {
pFiler->setError(Acad::eMissingDxfField, _T("\nMissing DXF group code: 43"));
return Acad::eMissingDxfField;
}
if (!(fieldsFlags&0x20)) {
pFiler->setError(Acad::eMissingDxfField, _T("\nMissing DXF group code: 44"));
return Acad::eMissingDxfField;
}
if (!(fieldsFlags&0x10000)) {
pFiler->setError(Acad::eMissingDxfField, _T("\nMissing DXF group code: 49"));
return Acad::eMissingDxfField;
}
if (!(fieldsFlags&0x800)) {
pFiler->setError(Acad::eMissingDxfField, _T("\nMissing DXF group code: 71"));
return Acad::eMissingDxfField;
}
m_ptLocation=pt;
SetStepHeight(r1);
SetSpaceWidth(r2);
SetSlabSize(r3);
SetStepWidth(r4);
SetStairWidth(r5);
if(fieldsFlags&0x40)
SetRailHeight(r6);
if(fieldsFlags&0x80)
SetRailWidth(r7);
if(fieldsFlags&0x100)
SetRailDistToSide(r8);
if(fieldsFlags&0x200)
SetRotation(r9);
if(fieldsFlags&0x400)
SetStairFlag(i1);
SetStepNum(i2);
m_nStartSide=i4;
return pFiler->filerStatus();
}
Acad::ErrorStatus
TDbTriangleStair::dxfOutFields(AcDbDxfFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es;
es = TDbPolyPathEnt::dxfOutFields(pFiler);
assert(es == Acad::eOk);
es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbTriangleStair"));
assert(es == Acad::eOk);
pFiler->writePoint3d(AcDb::kDxfXCoord, m_ptLocation);
pFiler->writeDouble(AcDb::kDxfReal, GetStepHeight());
pFiler->writeDouble(AcDb::kDxfReal+1, GetSpaceWidth());
pFiler->writeDouble(AcDb::kDxfReal+2, GetSlabSize());
pFiler->writeDouble(AcDb::kDxfReal+3, GetStepWidth());
pFiler->writeDouble(AcDb::kDxfReal+4, GetStairWidth());
pFiler->writeDouble(AcDb::kDxfReal+5, GetRailHeight());
pFiler->writeDouble(AcDb::kDxfReal+6, GetRailWidth());
pFiler->writeDouble(AcDb::kDxfReal+7, GetRailDistToSide());
pFiler->writeDouble(AcDb::kDxfReal+8, GetSectRotation());
pFiler->writeDouble(AcDb::kDxfReal+9, GetRailDist());
pFiler->writeDouble(AcDb::kDxfReal+11, GetTextHeight());
pFiler->writeDouble(AcDb::kDxfAngle, GetRotation());
pFiler->writeInt16(AcDb::kDxfInt16, GetStairFlag());
pFiler->writeInt16(AcDb::kDxfInt16+1, GetStepNum());
pFiler->writeInt16(AcDb::kDxfInt16+3, m_nStartSide);
pFiler->writeInt16(AcDb::kDxfInt16+5, m_nViewCtrl);
pFiler->writeInt16(AcDb::kDxfInt16+6, m_nSectStepNum);
pFiler->writeInt32(90, m_nFlagEx);
pFiler->writeDouble(145, m_nBeamHeight);
pFiler->writeDouble(146, m_nBeamThick);
pFiler->writeDouble(147, m_nSlabThick);
pFiler->writeString(412, (const TCHAR *)LayerId2String(m_idLayerStep3d));
pFiler->writeString(413, (const TCHAR *)LayerId2String(m_idLayerBeam3d));
pFiler->writeString(414, (const TCHAR *)LayerId2String(m_idLayerHand3d));
pFiler->writeString(415, (const TCHAR *)LayerId2String(m_idLayerRail3d));
pFiler->writeString(416, (const TCHAR *)LayerId2String(m_idLayerText));
pFiler->writeString(417, (const TCHAR *)LayerId2String(m_idTextStyle));
pFiler->writeString(418, (const TCHAR *)LayerId2String(m_idLayerArrow));
return pFiler->filerStatus();
}
Acad::ErrorStatus
TDbTriangleStair::subGetGripPoints(AcGePoint3dArray& gripPoints,
AcDbIntArray& osnapModes,
AcDbIntArray& geomIds) const
{
assertReadEnabled();
//add by xlc on 090222
if(m_nStepNum<2)
return Acad::eOk;
TDbLineStair stair1, stair2,stair3;
TDbSlab slab1,slab2,slab3;
TDbHandRail rail,rail2,rail3;
ExplodeTo(stair1, stair2, stair3, slab1,slab2,slab3, rail,rail2, rail3);
XPoint ptLowLeft1=stair1.GetLowLeft2d(),
ptLowRight1=stair1.GetLowRight2d(),
ptLowLeft2=stair2.GetLowLeft2d(),
ptLowRight2=stair2.GetLowRight2d(),
ptLowLeft3=stair3.GetLowLeft2d(),
ptLowRight3=stair3.GetLowRight2d(),
ptUpLeft1=stair1.GetUpLeft2d(),
ptUpRight1=stair1.GetUpRight2d(),
ptUpLeft2=stair2.GetUpLeft2d(),
ptUpRight2=stair2.GetUpRight2d(),
ptUpLeft3=stair3.GetUpLeft2d(),
ptUpRight3=stair3.GetUpRight2d();
XPoint ptMid;
// 0,1,2--移动
Midpoint(ptLowLeft1,ptLowRight1,ptMid);
gripPoints.append(ptMid);
Midpoint(ptLowLeft2,ptLowRight2,ptMid);
gripPoints.append(ptMid);
Midpoint(ptLowLeft3,ptLowRight3,ptMid);
gripPoints.append(ptMid);
//3,4,5--楼梯宽度
if(m_nStartSide == OFFSET_LEFT)//顺时针上楼梯段左侧设置夹点
{
Midpoint(ptLowLeft1,ptUpLeft1,ptMid);
gripPoints.append(ptMid);
Midpoint(ptLowLeft2,ptUpLeft2,ptMid);
gripPoints.append(ptMid);
Midpoint(ptLowLeft3,ptUpLeft3,ptMid);
gripPoints.append(ptMid);
}
else
{
Midpoint(ptLowRight1,ptUpRight1,ptMid);
gripPoints.append(ptMid);
Midpoint(ptLowRight2,ptUpRight2,ptMid);
gripPoints.append(ptMid);
Midpoint(ptLowRight3,ptUpRight3,ptMid);
gripPoints.append(ptMid);
}
// 6,7,8--楼梯井宽
if(m_nStartSide == OFFSET_LEFT)//顺时针上楼梯段右侧设置夹点
{
gripPoints.append(ptLowRight1);
gripPoints.append(ptLowRight2);
gripPoints.append(ptLowRight3);
}
else
{
gripPoints.append(ptLowLeft1);
gripPoints.append(ptLowLeft2);
gripPoints.append(ptLowLeft3);
}
// 9,10,11--楼梯井宽和梯段宽度
if(m_nStartSide == OFFSET_LEFT)//顺时针上楼梯段右侧设置夹点
{
Midpoint(ptLowRight1,ptUpRight1,ptMid);
gripPoints.append(ptMid);
Midpoint(ptLowRight2,ptUpRight2,ptMid);
gripPoints.append(ptMid);
Midpoint(ptLowRight3,ptUpRight3,ptMid);
gripPoints.append(ptMid);
}
else
{
Midpoint(ptLowLeft1,ptUpLeft1,ptMid);
gripPoints.append(ptMid);
Midpoint(ptLowLeft2,ptUpLeft2,ptMid);
gripPoints.append(ptMid);
Midpoint(ptLowLeft3,ptUpLeft3,ptMid);
gripPoints.append(ptMid);
}
//12,13,14,15,16,17--扶手伸出距离
if(m_nStartSide == OFFSET_LEFT)//顺时针上楼梯段右侧设置夹点
{
ads_polar(ptLowLeft1, stair1.GetRotation()-PI/2, m_nRailDist, ptMid);
gripPoints.append(ptMid);
ads_polar(ptUpLeft1, stair1.GetRotation()+PI/2, m_nRailDist, ptMid);
gripPoints.append(ptMid);
ads_polar(ptLowLeft2, stair2.GetRotation()-PI/2, m_nRailDist, ptMid);
gripPoints.append(ptMid);
ads_polar(ptUpLeft2, stair2.GetRotation()+PI/2, m_nRailDist, ptMid);
gripPoints.append(ptMid);
ads_polar(ptLowLeft3, stair3.GetRotation()-PI/2, m_nRailDist, ptMid);
gripPoints.append(ptMid);
ads_polar(ptUpLeft3, stair3.GetRotation()+PI/2, m_nRailDist, ptMid);
gripPoints.append(ptMid);
}
else
{
ads_polar(ptLowRight1, stair1.GetRotation()-PI/2, m_nRailDist, ptMid);
gripPoints.append(ptMid);
ads_polar(ptUpRight1, stair1.GetRotation()+PI/2, m_nRailDist, ptMid);
gripPoints.append(ptMid);
ads_polar(ptLowRight2, stair2.GetRotation()-PI/2, m_nRailDist, ptMid);
gripPoints.append(ptMid);
ads_polar(ptUpRight2, stair2.GetRotation()+PI/2, m_nRailDist, ptMid);
gripPoints.append(ptMid);
ads_polar(ptLowRight3, stair3.GetRotation()-PI/2, m_nRailDist, ptMid);
gripPoints.append(ptMid);
ads_polar(ptUpRight3, stair3.GetRotation()+PI/2, m_nRailDist, ptMid);
gripPoints.append(ptMid);
}
// 休息平台
if(IsShowSlab())
{
if(m_nStartSide == OFFSET_LEFT)//顺时针方向上楼
{
ads_polar(ptUpLeft1, stair1.GetRotation()+PI/2, m_nSlabSize, ptMid);
gripPoints.append(ptMid);
ads_polar(ptUpLeft2, stair2.GetRotation()+PI/2, m_nSlabSize, ptMid);
gripPoints.append(ptMid);
ads_polar(ptUpLeft3, stair3.GetRotation()+PI/2, m_nSlabSize, ptMid);
gripPoints.append(ptMid);
}
else //逆时针上楼
{
ads_polar(ptUpRight1, stair1.GetRotation()+PI/2, m_nSlabSize, ptMid);
gripPoints.append(ptMid);
ads_polar(ptUpRight2, stair2.GetRotation()+PI/2, m_nSlabSize, ptMid);
gripPoints.append(ptMid);
ads_polar(ptUpRight3, stair3.GetRotation()+PI/2, m_nSlabSize, ptMid);
gripPoints.append(ptMid);
}
}
{ // 剖切线
XPoint ptLeft, ptRight;
double lSectPos,rSectPos;
if(CalSectPos(lSectPos,rSectPos,ptLeft,ptRight))
{
gripPoints.append(ptLeft);
gripPoints.append(ptRight);
XPoint ptMid;
Midpoint(ptLeft,ptRight,ptMid);
gripPoints.append(ptMid);
}
}
return Acad::eOk;
}
Acad::ErrorStatus
TDbTriangleStair::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
{
assertReadEnabled();
XPoint ptUpLeft=GetLocation();
stretchPoints.append(ptUpLeft);
return Acad::eOk;
}
Acad::ErrorStatus
TDbTriangleStair::GetGripText(int i, CString &cs) const
{
switch(i) {
case 0:
case 1:
case 2:
cs=_T("移动楼梯");
break;
case 3:
case 4:
case 5:
cs=_T("改梯段宽度");
break;
case 6:
case 7:
case 8:
cs=_T("改楼梯井宽");
break;
case 9:
case 10:
case 11:
cs=_T("改楼梯井宽和梯段宽度");
break;
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
cs=_T("改扶手伸出距离");
break;
case 18:
case 19:
if(IsShowSlab())
{
cs=_T("改平台宽");
}
else
{
cs=_T("移动剖切角度");
}
break;
case 20:
if(IsShowSlab())
{
cs=_T("改平台宽");
}
else
{
cs=_T("移动剖切位置");
}
break;
case 21:
case 22:
if(IsShowSlab())
{
cs=_T("移动剖切角度");
}
break;
case 23:
if(IsShowSlab())
{
cs=_T("移动剖切位置");
}
break;
default:
break;
}
return Acad::eOk;
}
Acad::ErrorStatus
TDbTriangleStair::subTransformBy(const AcGeMatrix3d& xform)
{
assertWriteEnabled();
TDbEntity::subTransformBy(xform);
XPoint ptX, ptY;
ads_polar(m_ptLocation,m_nRotation, GetStairWidth()*0.5, ptX);
ads_polar(m_ptLocation, m_nRotation+PI/2.0, 1000.0, ptY);
((AcGePoint3d &)ptX).transformBy(xform);
((AcGePoint3d &)ptY).transformBy(xform);
XPoint ptLoc;
ads_polar(m_ptLocation,m_nRotation, GetStairWidth(), ptLoc);
ads_polar(ptLoc,m_nRotation-PI/6, GetSpaceWidth(), ptLoc);
ads_polar(ptLoc,m_nRotation-PI/3, GetStairWidth(), ptLoc);
((AcGePoint3d &)ptLoc).transformBy(xform);
((AcGePoint3d &)m_ptLocation).transformBy(xform);
double nAng = CT_std_angle(ads_angle(m_ptLocation, ptY)-
ads_angle(m_ptLocation, ptX));
if(fabs(nAng-PI*1.5)<_angSnap)
{
m_dSectRotation = -m_dSectRotation;
m_nRotation = ads_angle(ptX,m_ptLocation);
m_nRotation += PI/3;
//::Exchange(m_ptLocation,ptLoc);
m_ptLocation=ptLoc;
m_nStartSide = !m_nStartSide;
}
else
m_nRotation = ads_angle(m_ptLocation,ptX);
return Acad::eOk;
}
Acad::ErrorStatus
TDbTriangleStair::subMoveGripPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
assertWriteEnabled();
XPoint vtOffset=*(XPoint *)&offset;
vtOffset.z = 0;
//add by xlc on 090222
if(m_nStepNum<2)
return Acad::eOk;
TDbLineStair stair1, stair2,stair3;
TDbSlab slab1,slab2,slab3;
TDbHandRail rail,rail2,rail3;
ExplodeTo(stair1, stair2, stair3, slab1,slab2,slab3, rail,rail2, rail3);
double nVtRot=0;
double nIncWidth=0;
double nIncLen=0;
int nLen=indices.length();
for (int i = 0; i < nLen; i++) {
int idx = indices[i];
switch(idx) {
case 0:
case 1:
case 2: //移动楼梯
if(nLen==1) {
m_ptLocation += vtOffset;
}
break;
case 3: //改楼梯段宽度
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair1.GetRotation());
}
case 4: //改楼梯段宽度
if(idx==4)
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair2.GetRotation());
}
case 5: //改楼梯段宽度
if(idx==5)
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair3.GetRotation());
}
nIncWidth=ads_distance(XPoint(), vtOffset) * cos(nVtRot);
if(m_nStartSide==OFFSET_LEFT) //顺时针上楼
{
if(m_nStairWidth-nIncWidth > _DIST_SNAP)
{
m_nStairWidth -= nIncWidth;
ads_polar(m_ptLocation, m_nRotation, nIncWidth, m_ptLocation);
}
}
else
{
if(m_nStairWidth+nIncWidth > _DIST_SNAP)
{
m_nStairWidth += nIncWidth;
ads_polar(m_ptLocation, m_nRotation+PI, nIncWidth, m_ptLocation);
}
}
break;
case 6: //改楼梯井宽
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair1.GetRotation());
case 7: //改楼梯井宽
if(idx==7)
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair2.GetRotation());
}
case 8: //改楼梯井宽
if(idx==8)
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair3.GetRotation());
}
nIncWidth=ads_distance(XPoint(), vtOffset) * cos(nVtRot);
if(m_nStartSide==OFFSET_LEFT) //顺时针上楼
{
if(m_nSpaceWidth-nIncWidth*sin(PI/3)*2 > _DIST_SNAP)
{
m_nSpaceWidth -= (nIncWidth*sin(PI/3)*2);
ads_polar(m_ptLocation, m_nRotation, nIncWidth, m_ptLocation);
}
else
{
ads_polar(m_ptLocation, m_nRotation, m_nSpaceWidth*0.5/cos(PI/6), m_ptLocation);
m_nSpaceWidth = 0;
}
}
else
{
if(m_nSpaceWidth+nIncWidth*sin(PI/3)*2 > _DIST_SNAP)
{
m_nSpaceWidth += nIncWidth*sin(PI/3)*2;
ads_polar(m_ptLocation, m_nRotation+PI, nIncWidth, m_ptLocation);
}
else
{
ads_polar(m_ptLocation, m_nRotation, m_nSpaceWidth*0.5/cos(PI/6), m_ptLocation);
m_nSpaceWidth = 0;
}
}
break;
case 9: //改楼梯井宽和梯段宽度
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair1.GetRotation());
case 10: //改楼梯井宽和梯段宽度
if(idx==10)
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair2.GetRotation());
}
case 11: //改楼梯井宽和梯段宽度
if(idx==11)
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair3.GetRotation());
}
nIncWidth=ads_distance(XPoint(), vtOffset) * cos(nVtRot);
if(m_nStartSide==OFFSET_LEFT) //顺时针上楼
{
if(m_nStairWidth+nIncWidth > _DIST_SNAP && m_nSpaceWidth-nIncWidth*sin(PI/3)*2 > _DIST_SNAP)
{
m_nStairWidth += nIncWidth;
m_nSpaceWidth -= nIncWidth*sin(PI/3)*2;
//ads_polar(m_ptLocation, m_nRotation, nIncWidth, m_ptLocation);
}
else if(m_nSpaceWidth-nIncWidth*sin(PI/3)*2 < _DIST_SNAP)
{
double width=m_nSpaceWidth*0.5/cos(PI/6);
m_nStairWidth += width;
//ads_polar(m_ptLocation, m_nRotation, width, m_ptLocation);
m_nSpaceWidth = 0;
}
}
else
{
if(m_nStairWidth-nIncWidth > _DIST_SNAP && m_nSpaceWidth+nIncWidth*sin(PI/3)*2 > _DIST_SNAP)
{
m_nStairWidth -= nIncWidth;
m_nSpaceWidth += nIncWidth*sin(PI/3)*2;
//ads_polar(m_ptLocation, m_nRotation, nIncWidth, m_ptLocation);
}
else if(m_nSpaceWidth+nIncWidth*sin(PI/3)*2 < _DIST_SNAP)
{
double width=m_nSpaceWidth*0.5/cos(PI/6);
m_nStairWidth += width;
m_nSpaceWidth = 0;
}
}
break;
case 12: //扶手伸出距离
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair1.GetRotation());
case 14: //扶手伸出距离
if(idx==14)
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair2.GetRotation());
}
case 16: //扶手伸出距离
if(idx==16)
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair3.GetRotation());
}
nIncLen=ads_distance(XPoint(), vtOffset) * sin(nVtRot);
if(m_nRailDist - nIncLen > -m_nStepWidth*(m_nStepNum-1)*0.5-_DIST_SNAP)
{
m_nRailDist -= nIncLen;
}
break;
case 13: //扶手伸出距离
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair1.GetRotation());
case 15: //扶手伸出距离
if(idx==15)
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair2.GetRotation());
}
case 17: //扶手伸出距离
if(idx==17)
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair3.GetRotation());
}
nIncLen=ads_distance(XPoint(), vtOffset) * sin(nVtRot);
if(m_nRailDist + nIncLen > -m_nStepWidth*(m_nStepNum-1)*0.5-_DIST_SNAP)
{
m_nRailDist += nIncLen;
}
break;
default:
if(IsShowSlab()) //平台伸出距离
{
if(idx==18||idx==19||idx==20)
{
if(idx==18)
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair1.GetRotation());
}
else if(idx==19)
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair2.GetRotation());
}
else
{
nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-stair3.GetRotation());
}
nIncLen=ads_distance(XPoint(), vtOffset) * sin(nVtRot);
if(m_nSlabSize + nIncLen > _DIST_SNAP)
{
m_nSlabSize += nIncLen;
}
}
}
if((IsShowSlab()&& (idx==21||idx==22||idx==23))
||(!IsShowSlab()&& (idx==18||idx==19||idx==20))) //剖切位置
{
double lSectPos,rSectPos;
XPoint ptLeft2d,ptRight2d;
double angle=m_dSectRotation;
if(CalSectPos(lSectPos,rSectPos,ptLeft2d,ptRight2d))
{
XPoint ptMid;
Midpoint(ptLeft2d,ptRight2d,ptMid);
if(idx==20||idx==23)
{
XPoint ptHit2d;
ptHit2d=ptMid;
ptHit2d += vtOffset;
int nPosHit=HitSectPosByPoint2d(ptHit2d);
if(nPosHit!=-1)
{
m_nSectStepNum = nPosHit;
}
}
else
{
int nSectStair=GetSectStairPos();
XPoint ptTmp;
if(nSectStair==1)
{
ads_polar(ptMid, stair2.GetRotation(), m_nStairWidth, ptTmp);
}
else if(nSectStair==2)
{
ads_polar(ptMid, stair3.GetRotation(), m_nStairWidth, ptTmp);
}
else
{
ads_polar(ptMid, stair1.GetRotation(), m_nStairWidth, ptTmp);
}
AcGeVector3d vectFrom,vectTo;
vectFrom=ptMid-ptTmp;
int num=18;
if(IsShowSlab()&& (idx==21||idx==22))
{
num+=1;
}
if((idx-num)%2==0)
{
ptTmp=ptLeft2d+vtOffset;
vectTo=ptTmp-ptMid;
}
else
{
ptTmp=ptRight2d+vtOffset;
vectTo=ptMid-ptTmp;
}
angle=vectFrom.angleTo(vectTo,AcGeVector3d::kZAxis);
SetSectRotation(angle);
}
}
}
break;
}
}
return Acad::eOk;
//return TDbEntity::moveGripPointsAt(indices, offset);
}
Acad::ErrorStatus
TDbTriangleStair::subMoveStretchPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
assertWriteEnabled();
if(indices.length()) {
AcGeMatrix3d mat;
mat.setToTranslation(offset);
subTransformBy(mat);
}
return Acad::eOk;
}
const TCHAR *
TDbTriangleStair::GetDefaultLayer() const
{
return LAY_STAIR;
}
void
TDbTriangleStair::GetTips(DList<TObjInfoUnit> &lstInfo) const
{
lstInfo.Append(new TObjInfoUnit(_T("对象类型"), _T("三角楼梯")));
lstInfo.Append(new TObjInfoUnit(_T("梯段步数"), XString(_T("%d"), int(GetStepNum()))));
lstInfo.Append(new TObjInfoUnit(_T("踏步高"), Dist2Str(GetStepHeight())));
lstInfo.Append(new TObjInfoUnit(_T("踏步宽"), Dist2Str(GetStepWidth())));
lstInfo.Append(new TObjInfoUnit(_T("楼梯高"), Dist2Str(GetStepHeight()*GetStepNum()*3)));
lstInfo.Append(new TObjInfoUnit(_T("梯段宽"), Dist2Str(GetStairWidth())));
lstInfo.Append(new TObjInfoUnit(_T("楼梯间宽"), Dist2Str(GetSpaceWidth())));
lstInfo.Append(new TObjInfoUnit(_T("扶手宽"), Dist2Str(GetRailWidth())));
lstInfo.Append(new TObjInfoUnit(_T("扶手边距"), Dist2Str(GetRailDistToSide())));
lstInfo.Append(new TObjInfoUnit(_T("底标高"), Dist2Str(GetElevation())));
const TCHAR *pszFloor=_T("首层");
if(m_nStairFlag==1)
pszFloor=_T("中间层");
else if(m_nStairFlag==2)
pszFloor=_T("顶层");
lstInfo.Append(new TObjInfoUnit(_T("楼层标记"), pszFloor));
lstInfo.Append(new TObjInfoUnit(_T("上楼方向"), m_nStartSide? _T("逆时针") : _T("顺时针")));
}
void TDbTriangleStair::GetRail(TDbLineStair &stair, //[in/out]梯段
XPoly2D &polyRail, //[in/out]扶手
int nStairNo, //[in]梯段序号,1,2,3
BOOL bIn, //[in]是否内侧扶手
BOOL bLeft, //[in]是否梯段左侧
BOOL bTop //[in]是否顶层起步梯段
)const
{
double nDistToSide=m_nRailDistToSide;
nDistToSide += m_nRailWidth/2;
//梯段位置
XPoint ptLoc = stair.GetLocation();
double distLimit=m_nSpaceWidth+(m_nRailDistToSide+m_nRailWidth*0.5)*tan(PI/6)*3;//扶手相交时的伸出距离
double nRailDist=m_nRailDist; //实际扶手伸出距离
if(bIn)
{
if(m_nRailDist > distLimit)
{
nRailDist = distLimit;
}
}
XPoint ptStart;
double elev=(nRailDist/stair.GetStairLength())*(stair.GetStairHeight()-m_nStepHeight); //扶手伸出产生的高差
XLine line=stair.GetSideCurve2d(bLeft==TRUE?0:1).Offset(bLeft==TRUE?nDistToSide:-nDistToSide,0);
if(IsConnectRail())
{
if(nRailDist>m_nStepWidth*0.5+_DIST_SNAP)
{
//扶手下端点
if(bTop&&nRailDist>0) //顶层起步段扶手不伸出梯段
{
ptStart=line.StartPoint();
ptStart.z = ptLoc.z+m_nStepHeight*0.5;
}
else
{
ads_polar(line.StartPoint(), stair.GetRotation()-PI*0.5, nRailDist, ptStart);
ptStart.z = ptLoc.z;
polyRail.AppendNode(ptStart);
ads_polar(ptStart, stair.GetRotation()+PI*0.5, nRailDist-m_nStepWidth*0.5, ptStart);
}
polyRail.AppendNode(ptStart);
//扶手上端点
ads_polar(line.EndPoint(), stair.GetRotation()+PI*0.5, m_nStepWidth*0.5, ptStart);
ptStart.z=ptLoc.z+stair.GetStairHeight();
polyRail.AppendNode(ptStart);
ads_polar(ptStart, stair.GetRotation()+PI*0.5, nRailDist-m_nStepWidth*0.5, ptStart);
polyRail.AppendNode(ptStart);
}
else
{
//扶手下端点
if(bTop&&nRailDist>0) //顶层起步段扶手不伸出梯段
{
ptStart=line.StartPoint();
ptStart.z = ptLoc.z+m_nStepHeight*0.5;
}
else
{
ads_polar(line.StartPoint(), stair.GetRotation()-PI*0.5, nRailDist, ptStart);
ptStart.z = ptLoc.z+m_nStepHeight*0.5-elev;
}
polyRail.AppendNode(ptStart);
//扶手上端点
ads_polar(line.EndPoint(), stair.GetRotation()+PI*0.5, nRailDist, ptStart);
ptStart.z=ptLoc.z+stair.GetStairHeight()-m_nStepHeight*0.5+elev;
polyRail.AppendNode(ptStart);
}
}
else
{
if(nStairNo==1) //一跑
{
//扶手下端点
if(nRailDist>m_nStepWidth*0.5+_DIST_SNAP)
{
if(bTop&&nRailDist>0) //顶层起步段扶手不伸出梯段
{
ptStart=line.StartPoint();
ptStart.z = ptLoc.z+m_nStepHeight*0.5;
}
else
{
ads_polar(line.StartPoint(), stair.GetRotation()-PI*0.5, nRailDist, ptStart);
ptStart.z = ptLoc.z;
polyRail.AppendNode(ptStart);
ads_polar(ptStart, stair.GetRotation()+PI*0.5, nRailDist-m_nStepWidth*0.5, ptStart);
}
}
else
{
if(bTop&&nRailDist>0) //顶层起步段扶手不伸出梯段
{
ptStart=line.StartPoint();
ptStart.z = ptLoc.z+m_nStepHeight*0.5;
}
else
{
ads_polar(line.StartPoint(), stair.GetRotation()-PI*0.5, nRailDist, ptStart);
ptStart.z = ptLoc.z+m_nStepHeight*0.5-elev;
}
}
polyRail.AppendNode(ptStart);
//扶手上端点
ptStart = line.EndPoint();
ptStart.z=ptLoc.z+stair.GetStairHeight()-m_nStepHeight*0.5;
polyRail.AppendNode(ptStart);
}
else if(nStairNo == 2)//二跑
{
//扶手下端点
ptStart=line.StartPoint();
ptStart.z = ptLoc.z+m_nStepHeight*0.5;
polyRail.AppendNode(ptStart);
//扶手上端点
ptStart = line.EndPoint();
ptStart.z=ptLoc.z+stair.GetStairHeight()-m_nStepHeight*0.5;
polyRail.AppendNode(ptStart);
}
else
{
//扶手下端点
ptStart=line.StartPoint();
ptStart.z = ptLoc.z+m_nStepHeight*0.5;
polyRail.AppendNode(ptStart);
//扶手上端点
if(nRailDist>m_nStepWidth*0.5+_DIST_SNAP)
{
ads_polar(line.EndPoint(), stair.GetRotation()+PI*0.5, m_nStepWidth*0.5, ptStart);
ptStart.z=ptLoc.z+stair.GetStairHeight();
polyRail.AppendNode(ptStart);
ads_polar(ptStart, stair.GetRotation()+PI*0.5, nRailDist-m_nStepWidth*0.5, ptStart);
}
else
{
ads_polar(line.EndPoint(), stair.GetRotation()+PI*0.5, nRailDist, ptStart);
ptStart.z=ptLoc.z+stair.GetStairHeight()-m_nStepHeight*0.5+elev;
}
polyRail.AppendNode(ptStart);
}
}
}
Acad::ErrorStatus
TDbTriangleStair::ExplodeTo(TDbLineStair &stair1, //[in/out]一跑梯段
TDbLineStair &stair2, //[in/out]二跑梯段
TDbLineStair &stair3, //[in/out]三跑梯段
TDbSlab &slab1, //[in/out]一跑平台
TDbSlab &slab2, //[in/out]二跑平台
TDbSlab &slab3, //[in/out]三跑平台
TDbHandRail &rail, //[in/out]一跑内扶手
TDbHandRail &rail2, //[in/out]二跑内扶手
TDbHandRail &rail3, //[in/out]三跑内扶手
TDbHandRail *pRailTop, //[out]顶层扶手
TDbHandRail *pRailOut1, //[out]一跑外侧扶手
TDbHandRail*pRailOut2, //[out]二跑外侧扶手
TDbHandRail*pRailOut3 //[out]三跑外侧扶手
) const
{
assertReadEnabled();
int nSectStair=GetSectStairPos();
double nLen1=(m_nStepNum-1)*m_nStepWidth;
//设置梯段宽度
stair1.SetStairWidth(m_nStairWidth);
stair2.SetStairWidth(m_nStairWidth);
stair3.SetStairWidth(m_nStairWidth);
//设置踏步高度
stair1.SetStepHeight(m_nStepHeight);
stair2.SetStepHeight(m_nStepHeight);
stair3.SetStepHeight(m_nStepHeight);
//设置踏步宽度
stair1.SetStepWidth(m_nStepWidth);
stair2.SetStepWidth(m_nStepWidth);
stair3.SetStepWidth(m_nStepWidth);
//设置踏步数
stair1.SetStepNum(m_nStepNum);
stair2.SetStepNum(m_nStepNum);
stair3.SetStepNum(m_nStepNum);
//设置踏步旋转角度
stair1.SetRotation(m_nRotation);
//if(m_nStartSide == OFFSET_LEFT) //顺时针上楼
{
stair2.SetRotation(CT_std_angle(m_nRotation-PI*2/3));
stair3.SetRotation(CT_std_angle(m_nRotation-PI*4/3));
}
/*else
{
stair2.SetRotation(CT_std_angle(m_nRotation+PI*2/3));
stair3.SetRotation(CT_std_angle(m_nRotation-PI*2/3));
}*/
//计算梯段位置
XPoint ptLoc1, ptLoc2, ptLoc3;
//顺时针上楼
{
ptLoc1=GetLocation();
XPoint ptTmp;
ads_polar(ptLoc1, stair1.GetRotation(), m_nStairWidth, ptTmp);
ads_polar(ptTmp, stair1.GetRotation()+PI*0.5, nLen1, ptTmp);
ads_polar(ptTmp, stair1.GetRotation()+PI/6, m_nSpaceWidth, ptTmp);
ads_polar(ptTmp, stair2.GetRotation()+PI, m_nStairWidth, ptLoc2);
ptLoc2.z = ptLoc1.z + m_nStepNum*m_nStepHeight;
ads_polar(ptTmp, stair2.GetRotation()+PI*0.5, nLen1, ptTmp);
ads_polar(ptTmp, stair2.GetRotation()+PI/6, m_nSpaceWidth, ptTmp);
ads_polar(ptTmp, stair3.GetRotation()+PI, m_nStairWidth, ptLoc3);
ptLoc3.z = ptLoc2.z + m_nStepNum*m_nStepHeight;
}
//设置梯段位置
stair1.SetLocation(ptLoc1);
stair2.SetLocation(ptLoc2);
stair3.SetLocation(ptLoc3);
if(m_nStartSide!=OFFSET_LEFT) //逆时针上楼
{
ptLoc1=stair3.GetUpRight2d();
ptLoc2=stair2.GetUpRight2d();
ptLoc3=stair1.GetUpRight2d();
ptLoc1.z=m_ptLocation.z;
ptLoc2.z = ptLoc1.z + m_nStepNum*m_nStepHeight;
ptLoc3.z = ptLoc2.z + m_nStepNum*m_nStepHeight;
stair1.SetRotation(CT_std_angle(m_nRotation-PI/3));
stair2.SetRotation(CT_std_angle(m_nRotation+PI/3));
stair3.SetRotation(m_nRotation+PI);
stair1.SetLocation(ptLoc1);
stair2.SetLocation(ptLoc2);
stair3.SetLocation(ptLoc3);
}
//设置梯段标记
stair1.Set3DFlag(m_nStairFlag==SF_TOP? 0 : SF_HAS3D);
stair2.Set3DFlag(m_nStairFlag==SF_TOP? 0 : SF_HAS3D);
stair3.Set3DFlag(m_nStairFlag==SF_TOP? 0 : SF_HAS3D);
stair1.Set2DFlag(SF_NOSECT);
stair2.Set2DFlag(SF_NOSECT);
stair3.Set2DFlag(SF_NOSECT);
if(m_nStairFlag==SF_FIRST) //首层
{
if(nSectStair==0) //一跑剖断
{
stair1.Set2DFlag(SF_1SECT);
}
else if(nSectStair==1) //二跑剖断
{
stair2.Set2DFlag(SF_1SECT);
}
else if(nSectStair==2) //三跑剖断
{
stair3.Set2DFlag(SF_1SECT);
}
}
else if(m_nStairFlag==SF_MIDDLE) //中间层
{
if(nSectStair==0) //一跑剖断
{
stair1.Set2DFlag(SF_2SECT);
}
else if(nSectStair==1) //二跑剖断
{
stair2.Set2DFlag(SF_2SECT);
}
else if(nSectStair ==2) //三跑剖断
{
stair3.Set2DFlag(SF_2SECT);
}
}
// 设置边梁属性
/*for(int nSide=0; nSide<2; nSide++)
{
stair1.SetSideBeam(nSide, HasSideBeam(nSide));
stair2.SetSideBeam(nSide, HasSideBeam(nSide));
stair3.SetSideBeam(nSide, HasSideBeam(nSide));
}*/
if(m_nStartSide==OFFSET_LEFT)
{
stair1.SetSideBeam(0, IsOutSideBeam());
stair2.SetSideBeam(0, IsOutSideBeam());
stair3.SetSideBeam(0, IsOutSideBeam());
stair1.SetSideBeam(1, IsInSideBeam());
stair2.SetSideBeam(1, IsInSideBeam());
stair3.SetSideBeam(1, IsInSideBeam());
}
else
{
stair1.SetSideBeam(1, IsOutSideBeam());
stair2.SetSideBeam(1, IsOutSideBeam());
stair3.SetSideBeam(1, IsOutSideBeam());
stair1.SetSideBeam(0, IsInSideBeam());
stair2.SetSideBeam(0, IsInSideBeam());
stair3.SetSideBeam(0, IsInSideBeam());
}
/////////////////////////////////////////////////////////////////
//扶手
XPoly2D polyRail,polyRail2,polyRail3;//内侧扶手线
XPoint ptStart,ptStart2;
if(m_nStartSide==OFFSET_LEFT) //顺时针上楼
{
GetRail(stair1,polyRail,1,TRUE,FALSE,m_nStairFlag==SF_TOP);
GetRail(stair2,polyRail2,2,TRUE,FALSE);
GetRail(stair3,polyRail3,3,TRUE,FALSE);
}
else //逆时针上楼
{
GetRail(stair1,polyRail,1,TRUE,TRUE,m_nStairFlag==SF_TOP);
GetRail(stair2,polyRail2,2,TRUE,TRUE);
GetRail(stair3,polyRail3,3,TRUE,TRUE);
}
if(IsConnectRail())
{
double distLimit=m_nSpaceWidth+(m_nRailDistToSide+m_nRailWidth*0.5)*tan(PI/6)*3;//扶手相交时的伸出距离
if(m_nRailDist > distLimit)
{
if(polyRail2.Length()==4)
{
polyRail.AppendNode(*polyRail2[1]);
polyRail.AppendNode(*polyRail2[2]);
}
for(int i=0;i<polyRail3.Length();i++)
{
polyRail.AppendNode(*polyRail3[i]);
}
}
else
{
for(int i=0;i<polyRail2.Length();i++)
{
polyRail.AppendNode(*polyRail2[i]);
}
for(i=0;i<polyRail3.Length();i++)
{
polyRail.AppendNode(*polyRail3[i]);
}
if(m_nStairFlag==SF_MIDDLE)
{
XPoint pt=*polyRail3[polyRail3.Length()-1];
pt.z -= GetStairHeight();
polyRail.InsertNodeAt(0,pt);
}
}
}
if(m_nStairFlag == SF_TOP) //顶层扶手
{
XPoint pt;
if(IsConnectRail())
{
pt=*polyRail[polyRail.Length()-1];
}
else
{
pt=*polyRail3[polyRail3.Length()-1];
}
double elev=pt.z;
pt.z = 0;
XLine line=stair1.GetSideCurve2d(m_nStartSide == OFFSET_LEFT?0:1).Offset(0,0);
XLine line2(pt,stair1.GetRotation());
XPoint ptInt;
line.Intersection(&line2,ptInt);
XPoly2D polyTopRail(0);
polyTopRail.AppendNode(XPoint(pt.x,pt.y,GetElevation()));
pt=ptInt;
pt.z=elev;
if(IsConnectRail())
{
polyRail.AppendNode(pt);
}
else
{
polyRail3.AppendNode(pt);
}
polyTopRail.AppendNode(XPoint(pt.x,pt.y,GetElevation()));
if(pRailTop)
{
pRailTop->SetPathPoly(polyTopRail,GetNormal().AsAcGeVector3d());
pRailTop->SetWidth(m_nRailWidth);
pRailTop->SetHeight(m_nRailHeight);
pRailTop->SetStyle(TDbHandRail::RS_RAIL1);
}
}
polyRail.SetFlag(0);
polyRail2.SetFlag(0);
polyRail3.SetFlag(0);
{
rail.SetHas2D(TRUE);
rail.SetHas3D(TRUE);
rail2.SetHas2D(TRUE);
rail2.SetHas3D(TRUE);
rail3.SetHas2D(TRUE);
rail3.SetHas3D(TRUE);
}
rail.SetPathPoly(polyRail,GetNormal().AsAcGeVector3d());
rail.SetWidth(m_nRailWidth);
rail.SetHeight(m_nRailHeight);
rail.SetStyle(TDbHandRail::RS_RAIL1);
if(!IsConnectRail())
{
rail2.SetPathPoly(polyRail2,GetNormal().AsAcGeVector3d());
rail2.SetWidth(m_nRailWidth);
rail2.SetHeight(m_nRailHeight);
rail2.SetStyle(TDbHandRail::RS_RAIL1);
rail3.SetPathPoly(polyRail3,GetNormal().AsAcGeVector3d());
rail3.SetWidth(m_nRailWidth);
rail3.SetHeight(m_nRailHeight);
rail3.SetStyle(TDbHandRail::RS_RAIL1);
}
//外侧扶手
if(pRailOut1!=0&&pRailOut2!=0&&pRailOut3!=0) //外侧扶手
{
XPoly2D poly,poly2,poly3;
if(m_nStartSide==OFFSET_LEFT)
{
GetRail(stair1,poly,1,FALSE,TRUE,m_nStairFlag==SF_TOP);
GetRail(stair2,poly2,2,FALSE,TRUE);
GetRail(stair3,poly3,3,FALSE,TRUE);
}
else
{
GetRail(stair1,poly,1,FALSE,FALSE,m_nStairFlag==SF_TOP);
GetRail(stair2,poly2,2,FALSE,FALSE);
GetRail(stair3,poly3,3,FALSE,FALSE);
}
pRailOut1->SetPathPoly(poly,GetNormal().AsAcGeVector3d());
pRailOut1->SetWidth(m_nRailWidth);
pRailOut1->SetHeight(m_nRailHeight);
pRailOut1->SetStyle(TDbHandRail::RS_RAIL1);
pRailOut2->SetPathPoly(poly2,GetNormal().AsAcGeVector3d());
pRailOut2->SetWidth(m_nRailWidth);
pRailOut2->SetHeight(m_nRailHeight);
pRailOut2->SetStyle(TDbHandRail::RS_RAIL1);
pRailOut3->SetPathPoly(poly3,GetNormal().AsAcGeVector3d());
pRailOut3->SetWidth(m_nRailWidth);
pRailOut3->SetHeight(m_nRailHeight);
pRailOut3->SetStyle(TDbHandRail::RS_RAIL1);
}
//休息平台
//if(IsShowSlab())
{
double dLengthLimit=(m_nSpaceWidth*0.5/sin(PI/3)+m_nStairWidth)*tan(PI/3);
XPoint ptLowLeft1=stair1.GetLowLeft2d(),
ptLowRight1=stair1.GetLowRight2d(),
ptLowLeft2=stair2.GetLowLeft2d(),
ptLowRight2=stair2.GetLowRight2d(),
ptLowLeft3=stair3.GetLowLeft2d(),
ptLowRight3=stair3.GetLowRight2d(),
ptUpLeft1=stair1.GetUpLeft2d(),
ptUpRight1=stair1.GetUpRight2d(),
ptUpLeft2=stair2.GetUpLeft2d(),
ptUpRight2=stair2.GetUpRight2d(),
ptUpLeft3=stair3.GetUpLeft2d(),
ptUpRight3=stair3.GetUpRight2d(),pt;
XPoly2D polySlab1(1),polySlab2(1),polySlab3(1);
if(m_nStartSide == OFFSET_LEFT)
{
polySlab1.AppendNode(ptLowLeft2);
polySlab1.AppendNode(ptLowRight2);
polySlab1.AppendNode(ptUpRight1);
polySlab1.AppendNode(ptUpLeft1);
polySlab2.AppendNode(ptLowLeft3);
polySlab2.AppendNode(ptLowRight3);
polySlab2.AppendNode(ptUpRight2);
polySlab2.AppendNode(ptUpLeft2);
polySlab3.AppendNode(ptLowLeft1);
polySlab3.AppendNode(ptLowRight1);
polySlab3.AppendNode(ptUpRight3);
polySlab3.AppendNode(ptUpLeft3);
if(m_nSlabSize>dLengthLimit-_DIST_SNAP)
{
ads_polar(ptUpLeft1, stair1.GetRotation()+PI*0.5, dLengthLimit, pt);
polySlab1.AppendNode(pt);
ads_polar(ptUpLeft2, stair2.GetRotation()+PI*0.5, dLengthLimit, pt);
polySlab2.AppendNode(pt);
ads_polar(ptUpLeft3, stair3.GetRotation()+PI*0.5, dLengthLimit, pt);
polySlab3.AppendNode(pt);
}
else
{
ads_polar(ptUpLeft1, stair1.GetRotation()+PI*0.5, m_nSlabSize, pt);
polySlab1.AppendNode(pt);
ads_polar(ptLowLeft2, stair2.GetRotation()-PI*0.5, m_nSlabSize, pt);
polySlab1.AppendNode(pt);
ads_polar(ptUpLeft2, stair2.GetRotation()+PI*0.5, m_nSlabSize, pt);
polySlab2.AppendNode(pt);
ads_polar(ptLowLeft3, stair3.GetRotation()-PI*0.5, m_nSlabSize, pt);
polySlab2.AppendNode(pt);
ads_polar(ptUpLeft3, stair3.GetRotation()+PI*0.5, m_nSlabSize, pt);
polySlab3.AppendNode(pt);
ads_polar(ptLowLeft1, stair1.GetRotation()-PI*0.5, m_nSlabSize, pt);
polySlab3.AppendNode(pt);
}
}
else
{
polySlab1.AppendNode(ptLowRight2);
polySlab1.AppendNode(ptLowLeft2);
polySlab1.AppendNode(ptUpLeft1);
polySlab1.AppendNode(ptUpRight1);
polySlab2.AppendNode(ptLowRight3);
polySlab2.AppendNode(ptLowLeft3);
polySlab2.AppendNode(ptUpLeft2);
polySlab2.AppendNode(ptUpRight2);
polySlab3.AppendNode(ptLowRight1);
polySlab3.AppendNode(ptLowLeft1);
polySlab3.AppendNode(ptUpLeft3);
polySlab3.AppendNode(ptUpRight3);
if(m_nSlabSize>dLengthLimit-_DIST_SNAP)
{
ads_polar(ptUpRight1, stair1.GetRotation()+PI*0.5, dLengthLimit, pt);
polySlab1.AppendNode(pt);
ads_polar(ptUpRight2, stair2.GetRotation()+PI*0.5, dLengthLimit, pt);
polySlab2.AppendNode(pt);
ads_polar(ptUpRight3, stair3.GetRotation()+PI*0.5, dLengthLimit, pt);
polySlab3.AppendNode(pt);
}
else
{
ads_polar(ptUpRight1, stair1.GetRotation()+PI*0.5, m_nSlabSize, pt);
polySlab1.AppendNode(pt);
ads_polar(ptLowRight2, stair2.GetRotation()-PI*0.5, m_nSlabSize, pt);
polySlab1.AppendNode(pt);
ads_polar(ptUpRight2, stair2.GetRotation()+PI*0.5, m_nSlabSize, pt);
polySlab2.AppendNode(pt);
ads_polar(ptLowRight3, stair3.GetRotation()-PI*0.5, m_nSlabSize, pt);
polySlab2.AppendNode(pt);
ads_polar(ptUpRight3, stair3.GetRotation()+PI*0.5, m_nSlabSize, pt);
polySlab3.AppendNode(pt);
ads_polar(ptLowRight1, stair1.GetRotation()-PI*0.5, m_nSlabSize, pt);
polySlab3.AppendNode(pt);
}
}
if(polySlab1.PathArea()>0)
polySlab1.Reverse();
slab1.SetOutline(polySlab1);
slab1.SetThickness(-m_nSlabThick);
slab1.SetElevation(ptLoc2.z);
if(polySlab2.PathArea()>0)
polySlab2.Reverse();
slab2.SetOutline(polySlab2);
slab2.SetThickness(-m_nSlabThick);
slab2.SetElevation(ptLoc3.z);
if(polySlab3.PathArea()>0)
polySlab3.Reverse();
slab3.SetOutline(polySlab3);
slab3.SetThickness(-m_nSlabThick);
slab3.SetElevation(ptLoc3.z+stair3.GetStairHeight());
}
stair1.setPropertiesFrom(this);
stair2.setPropertiesFrom(this);
stair3.setPropertiesFrom(this);
stair1.SetBeamHeight(GetBeamHeight());
stair2.SetBeamHeight(GetBeamHeight());
stair3.SetBeamHeight(GetBeamHeight());
stair1.SetBeamThick(GetBeamThick());
stair2.SetBeamThick(GetBeamThick());
stair3.SetBeamThick(GetBeamThick());
slab1.setPropertiesFrom(this);
slab2.setPropertiesFrom(this);
slab3.setPropertiesFrom(this);
rail.setPropertiesFrom(this);
rail2.setPropertiesFrom(this);
rail3.setPropertiesFrom(this);
if(pRailTop!=NULL)
pRailTop->setPropertiesFrom(this);
if(pRailOut1!=NULL)
pRailOut1->setPropertiesFrom(this);
if(pRailOut2!=NULL)
pRailOut2->setPropertiesFrom(this);
if(pRailOut3!=NULL)
pRailOut3->setPropertiesFrom(this);
if(m_idLayerStep3d.isValid())
{
slab1.setLayer(m_idLayerStep3d);
slab2.setLayer(m_idLayerStep3d);
slab3.setLayer(m_idLayerStep3d);
stair1.SetLayerStep3d(m_idLayerStep3d);
stair2.SetLayerStep3d(m_idLayerStep3d);
stair3.SetLayerStep3d(m_idLayerStep3d);
}
if(m_idLayerBeam3d.isValid())
{
stair1.SetLayerBeam3d(m_idLayerBeam3d);
stair2.SetLayerBeam3d(m_idLayerBeam3d);
stair3.SetLayerBeam3d(m_idLayerBeam3d);
}
if(m_idLayerHand3d.isValid())
{
rail.setLayer(m_idLayerHand3d);
rail2.setLayer(m_idLayerHand3d);
rail3.setLayer(m_idLayerHand3d);
if(pRailTop!=NULL)
pRailTop->setLayer(m_idLayerHand3d);
if(pRailOut1!=NULL)
pRailOut1->setLayer(m_idLayerHand3d);
if(pRailOut2!=NULL)
pRailOut2->setLayer(m_idLayerHand3d);
if(pRailOut3!=NULL)
pRailOut3->setLayer(m_idLayerHand3d);
}
return Acad::eOk;
}
void TDbTriangleStair::GetDefaultArrow(TDbLineStair &stair1,TDbLineStair &stair2,TDbLineStair &stair3,
TDbSymbArrow*pArrowUp,TDbSymbArrow*pArrowDown)const
{
assertReadEnabled();
int nSectStair=GetSectStairPos();
if(m_nStairFlag != SF_TOP && nSectStair == -1) //剖断位置不正确
return;
int nSectStepNum=m_nSectStepNum; //剖断步数
if(nSectStepNum < 0) //负数调整为正的
{
nSectStepNum=m_nSectStepNum+m_nStepNum*3+1;
}
if(nSectStepNum%m_nStepNum==0)
{
nSectStepNum--;
}
XPoint pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8,pt9,pt10,pt11,pt12,pt;
/*----------点相对位置示意----------------------
_________________________________________________
*pt4*pt5
/ \
/ \
*pt3 *pt6
*pt2 *pt7
/ \
/ \
*pt1 *pt8
*pt12 *pt11*pt10 *pt9
------------------------------------------------*/
ads_polar(stair1.GetLocation(),stair1.GetRotation(),stair1.GetStairWidth()/2,pt);
{
ads_polar(pt,stair1.GetRotation()-PI/2,m_nStepWidth*0.5,pt1);
ads_polar(pt,stair1.GetRotation()+PI/2,m_nStepWidth*(nSectStepNum-1),pt2);
ads_polar(pt,stair1.GetRotation()+PI/2,m_nStepWidth*nSectStepNum,pt3);
ads_polar(pt,stair1.GetRotation()+PI/2,m_nStepWidth*m_nStepNum,pt4);
ads_polar(stair2.GetLocation(),stair2.GetRotation(),stair2.GetStairWidth()*0.5,pt5);
ads_polar(pt5,stair2.GetRotation()-PI/2,m_nStepWidth,pt5);
ads_polar(pt5,stair2.GetRotation()+PI/2,m_nStepWidth*(nSectStepNum-m_nStepNum),pt6);
ads_polar(pt5,stair2.GetRotation()+PI/2,m_nStepWidth*(nSectStepNum-m_nStepNum+1),pt7);
ads_polar(pt5,stair2.GetRotation()+PI/2,m_nStepWidth*(m_nStepNum+1),pt8);
ads_polar(stair3.GetLocation(),stair3.GetRotation(),stair3.GetStairWidth()*0.5,pt9);
ads_polar(pt9,stair3.GetRotation()-PI/2,m_nStepWidth,pt9);
ads_polar(pt9,stair3.GetRotation()+PI/2,(m_nStepWidth*(nSectStepNum-m_nStepNum*2)),pt10);
ads_polar(pt9,stair3.GetRotation()+PI/2,(m_nStepWidth*(nSectStepNum-m_nStepNum*2+1)),pt11);
ads_polar(pt9,stair3.GetRotation()+PI/2,m_nStepWidth*(m_nStepNum+0.5),pt12);
}
XPoly2D poly;
if(nSectStair==0) //中梯剖断
{
poly.AppendNode(pt1);
poly.AppendNode(pt2);
poly.SetElevation(GetElevation());
pArrowUp->SetPoly2D(poly);
if(m_nStairFlag==SF_MIDDLE)
{
XPoly2D poly2;
poly2.AppendNode(pt12);
poly2.AppendNode(pt9);
poly2.AppendNode(pt8);
poly2.AppendNode(pt5);
poly2.AppendNode(pt4);
poly2.AppendNode(pt3);
poly2.SetElevation(GetElevation());
pArrowDown->SetPoly2D(poly2);
}
}
else if(nSectStair==1) //边梯剖断
{
poly.AppendNode(pt1);
poly.AppendNode(pt4);
poly.AppendNode(pt5);
poly.AppendNode(pt6);
poly.SetElevation(GetElevation());
pArrowUp->SetPoly2D(poly);
if(m_nStairFlag==SF_MIDDLE)
{
XPoly2D poly2;
poly2.AppendNode(pt12);
poly2.AppendNode(pt9);
poly2.AppendNode(pt8);
poly2.AppendNode(pt7);
poly2.SetElevation(GetElevation());
pArrowDown->SetPoly2D(poly2);
}
}
else if(nSectStair==2)
{
poly.AppendNode(pt1);
poly.AppendNode(pt4);
poly.AppendNode(pt5);
poly.AppendNode(pt8);
poly.AppendNode(pt9);
poly.AppendNode(pt10);
poly.SetElevation(GetElevation());
pArrowUp->SetPoly2D(poly);
if(m_nStairFlag==SF_MIDDLE)
{
XPoly2D poly2;
poly2.AppendNode(pt12);
poly2.AppendNode(pt11);
pArrowDown->SetPoly2D(poly2);
}
}
else
{
if(m_nStairFlag==SF_TOP)
{
poly.AppendNode(pt12);
poly.AppendNode(pt9);
poly.AppendNode(pt8);
poly.AppendNode(pt5);
poly.AppendNode(pt4);
ads_polar(pt1,stair1.GetRotation()+PI/2,m_nStepWidth,pt);
poly.AppendNode(pt);
poly.SetElevation(GetElevation());
pArrowDown->SetPoly2D(poly);
}
}
{
pArrowUp->setPropertiesFrom(this);
//add by xlc on 090212
pArrowUp->SetTextHeight(m_dTextHeight);
//modify by xlc on 090205
pArrowUp->SetLayoutRotation(GetLayoutRotation());
//modify by xlc on 090426
//pArrowUp->SetText(_T("上"));
pArrowUp->SetText(GetTextUp());
pArrowUp->SetTextAlign(TDbSymbArrow::kAtSide);
pArrowUp->SetTextLocation(pArrowUp->GetDefaultTextLocation());
pArrowUp->SetTextLayerId(m_idLayerText);
pArrowUp->SetTextStyleId(m_idTextStyle);
pArrowDown->setPropertiesFrom(this);
//add by xlc on 090212
pArrowDown->SetTextHeight(m_dTextHeight);
pArrowDown->SetLayoutRotation(GetLayoutRotation());
//modify by xlc on 090426
//pArrowDown->SetText(_T("下"));
pArrowDown->SetText(GetTextDown());
pArrowDown->SetTextAlign(TDbSymbArrow::kAtSide);
pArrowDown->SetTextLocation(pArrowDown->GetDefaultTextLocation());
pArrowDown->SetTextLayerId(m_idLayerText);
pArrowDown->SetTextStyleId(m_idTextStyle);
if(m_idLayerArrow.isValid())
{
pArrowUp->setLayer(m_idLayerArrow);
pArrowDown->setLayer(m_idLayerArrow);
}
}
}
//add by xlc on 090123 获得梯段扶手线的位置
void TDbTriangleStair::GetRailPolyFromStair(TDbLineStair &stair, //[in]操作梯段
double dOffset, //[in]偏移距离
double dDistS, //[in]起始端伸出距离
double dDistE, //[in]终端伸出距离
BOOL bRight, //[in]扶手侧
XPoly2D &poly //[out]扶手线
)const
{
poly.Reset();
XLine line=stair.GetSideCurve2d(bRight).Offset(dOffset,0);
XPoint pt=line.StartPoint();
pt.z=stair.GetElevation()+0.5*m_nStepHeight;
if(dDistS<-0.5*m_nStepWidth+_DIST_SNAP)
{
int num=(int)fabs((dDistS-0.5*m_nStepWidth)/m_nStepWidth);
ads_polar(pt, stair.GetRotation()+PI/2,m_nStepWidth*num, pt);
pt.z+=m_nStepHeight*num;
}
poly.AppendNode(pt);
pt=line.EndPoint();
pt.z=stair.GetElevation()+stair.GetStairHeight()-0.5*m_nStepHeight;
if(dDistE<-0.5*m_nStepWidth+_DIST_SNAP)
{
int num=(int)fabs((dDistE-0.5*m_nStepWidth)/m_nStepWidth);
ads_polar(pt, stair.GetRotation()-PI/2,m_nStepWidth*num, pt);
pt.z-=m_nStepHeight*num;
}
poly.AppendNode(pt);
}
//画栏杆
void TDbTriangleStair::DrawRail(XPoly2D polyPath,double nStepWidth,XExplodeDraw &dc) const
{
double nTotalDist=polyPath.Distance2d();
int nRailNum=AS_INT(nTotalDist/nStepWidth);
if(nRailNum<1)
nRailNum=1;
double nStepW=nTotalDist/nRailNum;
double nRailHeight=m_nRailHeight-_AS_SYS_UNIT(20);
if(m_nRailDistToSide < -_DIST_SNAP)//扶手偏移距离为负时栏杆增加一个踏步高
nRailHeight += m_nStepHeight;
for(int iRail=0; iRail<nRailNum; iRail++)
{
double nDist=nStepW/2.0 + iRail*nStepW;
XPoint pt;
double nDir=0.0;
polyPath.Polar2d(nDist, pt, &nDir);
XRectAngle box(pt, _AS_SYS_UNIT(40), _AS_SYS_UNIT(40));
XPoly2D poly2d;
box.AsPoly2D(poly2d);
if(m_nRailDistToSide < -_DIST_SNAP)//扶手偏移距离为负时栏杆增加一个踏步高
{
for(int i = 0; i < poly2d.Length(); i++)
{
poly2d[i]->z -= m_nStepHeight;
}
}
dc.DrawMesh(poly2d, XVector3D(0,0,nRailHeight));
}
}
Acad::ErrorStatus
TDbTriangleStair::ExplodeOrDraw3d(XExplodeDraw &dc) const
{
if(m_nViewCtrl==1)
return Acad::eOk; //三维被禁止
assertReadEnabled();
//add by xlc on 090222
if(m_nStepNum<2)
return Acad::eOk;
TDbLineStair stair1, stair2, stair3;
TDbSlab slab1,slab2,slab3;
TDbHandRail rail, rail2, rail3, railTop,railOut1,railOut2, railOut3;
ExplodeTo(stair1, stair2, stair3,slab1,slab2,slab3, rail, rail2, rail3, &railTop, &railOut1,&railOut2,&railOut3);
if(m_nStairFlag==SF_TOP)
{
{
TPushProperty vProp(&railTop, dc);
if(dc.IsFullExplode())
railTop.ExplodeOrDraw3d(dc);
else
dc.DrawEntity(railTop);
}
// 内侧栏杆
if(IsAutoRail())
{
dc.SetColorLayer(colorIndex(), m_idLayerRail3d);
XPoly2D polyPath=railTop.GetOutline();
DrawRail(polyPath,m_nStepWidth,dc);
}
}
else
{
//一跑梯段
{
TPushProperty vProp(&stair1, dc);
if(dc.IsFullExplode())
stair1.ExplodeOrDraw3d(dc);
else
dc.DrawEntity(stair1);
}
//二跑梯段
{
TPushProperty vProp(&stair2, dc);
if(dc.IsFullExplode())
stair2.ExplodeOrDraw3d(dc);
else
dc.DrawEntity(stair2);
}
//三跑梯段
{
TPushProperty vProp(&stair3, dc);
if(dc.IsFullExplode())
stair3.ExplodeOrDraw3d(dc);
else
dc.DrawEntity(stair3);
}
//休息平台
if(m_nSlabSize>_DIST_SNAP)
{
TPushProperty vProp(&slab1, dc);
if(dc.IsFullExplode())
{
slab1.ExplodeOrDraw3d(dc);
slab2.ExplodeOrDraw3d(dc);
slab3.ExplodeOrDraw3d(dc);
}
else
{
dc.DrawEntity(slab1);
dc.DrawEntity(slab2);
dc.DrawEntity(slab3);
}
}
{
//外侧扶手
if(IsOutRail())
{
if(dc.IsFullExplode())
{
railOut1.ExplodeOrDraw3d(dc);
railOut2.ExplodeOrDraw3d(dc);
railOut3.ExplodeOrDraw3d(dc);
}
else
{
dc.DrawEntity(railOut1);
dc.DrawEntity(railOut2);
dc.DrawEntity(railOut3);
}
// 外侧栏杆
if(IsAutoOutRail())
{
dc.SetColorLayer(colorIndex(), m_idLayerRail3d);
XPoly2D polyPath=railOut1.GetOutline();
// DrawRail(polyPath,m_nStepWidth,dc);
//
// polyPath=railOut2.GetOutline();
// DrawRail(polyPath,m_nStepWidth,dc);
//
// polyPath=railOut3.GetOutline();
// DrawRail(polyPath,m_nStepWidth,dc);
//add by xlc on 090123 修改栏杆画法,只在踏步中间画
double nDistToSide=m_nRailDistToSide + m_nRailWidth/2; //扶手偏移距离
GetRailPolyFromStair(stair1,m_nStartSide==OFFSET_LEFT?nDistToSide:-nDistToSide,m_nRailDist,IsConnectRail()?m_nRailDist:0,m_nStartSide,polyPath);
DrawRail(polyPath,m_nStepWidth,dc);
GetRailPolyFromStair(stair2,m_nStartSide==OFFSET_LEFT?nDistToSide:-nDistToSide,IsConnectRail()?m_nRailDist:0,IsConnectRail()?m_nRailDist:0,m_nStartSide,polyPath);
DrawRail(polyPath,m_nStepWidth,dc);
GetRailPolyFromStair(stair3,m_nStartSide==OFFSET_LEFT?nDistToSide:-nDistToSide,IsConnectRail()?m_nRailDist:0,m_nRailDist,m_nStartSide,polyPath);
DrawRail(polyPath,m_nStepWidth,dc);
}
}
//内侧扶手
extern BOOL g_bInElevProcess;
TPushProperty vProp(&rail, dc);
if(g_bInElevProcess)
{
XPoly2D polyPath;
AcGeVector3d normal;
rail.GetPathPoly(polyPath,normal);
for(int mm=0; mm<polyPath.TotalSegments(); mm++) {
XDirectionCurve cv;
polyPath.Nth(mm, cv);
if(fabs(cv.StartPoint().z-cv.EndPoint().z)>_DIST_SNAP) {
XPoly2D poly3d(0);
poly3d.AppendNode(cv.StartPoint(), cv.GetBulge());
poly3d.AppendNode(cv.EndPoint());
rail.SetPathPoly(poly3d,normal);
if(dc.IsFullExplode())
rail.ExplodeOrDraw3d(dc);
else
dc.DrawEntity(rail);
}
}
rail.SetPathPoly(polyPath,normal);
}
else
{
if(dc.IsFullExplode())
rail.ExplodeOrDraw3d(dc);
else
dc.DrawEntity(rail);
}
if(!IsConnectRail()) //扶手不连接
{
TPushProperty vProp2(&rail2, dc);
if(g_bInElevProcess)
{
XPoly2D polyPath;
AcGeVector3d normal;
rail2.GetPathPoly(polyPath,normal);
for(int mm=0; mm<polyPath.TotalSegments(); mm++)
{
XDirectionCurve cv;
polyPath.Nth(mm, cv);
if(fabs(cv.StartPoint().z-cv.EndPoint().z)>_DIST_SNAP)
{
XPoly2D poly3d(0);
poly3d.AppendNode(cv.StartPoint(), cv.GetBulge());
poly3d.AppendNode(cv.EndPoint());
rail2.SetPathPoly(poly3d,normal);
if(dc.IsFullExplode())
rail2.ExplodeOrDraw3d(dc);
else
dc.DrawEntity(rail2);
}
}
rail2.SetPathPoly(polyPath,normal);
}
else
{
if(dc.IsFullExplode())
rail2.ExplodeOrDraw3d(dc);
else
dc.DrawEntity(rail2);
}
TPushProperty vProp3(&rail3, dc);
if(g_bInElevProcess)
{
XPoly2D polyPath;
AcGeVector3d normal;
rail3.GetPathPoly(polyPath,normal);
for(int mm=0; mm<polyPath.TotalSegments(); mm++)
{
XDirectionCurve cv;
polyPath.Nth(mm, cv);
if(fabs(cv.StartPoint().z-cv.EndPoint().z)>_DIST_SNAP)
{
XPoly2D poly3d(0);
poly3d.AppendNode(cv.StartPoint(), cv.GetBulge());
poly3d.AppendNode(cv.EndPoint());
rail3.SetPathPoly(poly3d,normal);
if(dc.IsFullExplode())
rail3.ExplodeOrDraw3d(dc);
else
dc.DrawEntity(rail3);
}
}
rail3.SetPathPoly(polyPath,normal);
}
else
{
if(dc.IsFullExplode())
rail3.ExplodeOrDraw3d(dc);
else
dc.DrawEntity(rail3);
}
}
}
// 内侧栏杆
if(IsAutoRail())
{
dc.SetColorLayer(colorIndex(), m_idLayerRail3d);
XPoly2D polyPath=rail.GetOutline();
//mnodify by xlc on 090123 修改栏杆画法,只在踏步中间画
// DrawRail(polyPath,m_nStepWidth,dc);
// if(!IsConnectRail())
// {
// polyPath=rail2.GetOutline();
// DrawRail(polyPath,m_nStepWidth,dc);
//
// polyPath=rail3.GetOutline();
// DrawRail(polyPath,m_nStepWidth,dc);
// }
double nDistToSide=m_nRailDistToSide + m_nRailWidth/2; //扶手偏移距离
GetRailPolyFromStair(stair1,m_nStartSide==OFFSET_LEFT?-nDistToSide:nDistToSide,m_nRailDist,IsConnectRail()?m_nRailDist:0,!m_nStartSide,polyPath);
DrawRail(polyPath,m_nStepWidth,dc);
GetRailPolyFromStair(stair2,m_nStartSide==OFFSET_LEFT?-nDistToSide:nDistToSide,IsConnectRail()?m_nRailDist:0,IsConnectRail()?m_nRailDist:0,!m_nStartSide,polyPath);
DrawRail(polyPath,m_nStepWidth,dc);
GetRailPolyFromStair(stair3,m_nStartSide==OFFSET_LEFT?-nDistToSide:nDistToSide,IsConnectRail()?m_nRailDist:0,m_nRailDist,!m_nStartSide,polyPath);
DrawRail(polyPath,m_nStepWidth,dc);
}
}
return Acad::eOk;
}
bool TDbTriangleStair::IsClipMe(const TEntityBase* pEnt)const
{
if(TDbEntity::IsClipMe(pEnt))
return true;
if(pEnt->GetMe()->isKindOf(TDbColumn::desc()))
return true;
return false;
}
//计算扶手开口的poly线
void TDbTriangleStair::CalPolyFromPoint(XPoint ptS,XPoint ptE,double dAngle,XPoly2D &poly) const
{
XPoint pt;
double scale=3.0;
ads_polar(ptS, dAngle,_DIST_SNAP*scale, pt);
poly.AppendNode(pt);
ads_polar(ptE, dAngle, _DIST_SNAP*scale, pt);
poly.AppendNode(pt);
ads_polar(ptE, dAngle, -_DIST_SNAP*scale, pt);
poly.AppendNode(pt);
ads_polar(ptS, dAngle, -_DIST_SNAP*scale, pt);
poly.AppendNode(pt);
}
Acad::ErrorStatus
TDbTriangleStair::ExplodeOrDraw2d(XExplodeDraw &dc) const
{
if(m_nViewCtrl==2)
return Acad::eOk; //二维被禁止
assertReadEnabled();
CString s1=dc.Desc(),s2=XAcGiViewDraw::Descriptor();
if(_tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor())==0 ||
g_bOsnapExpl)
{
XPushMemVar<BOOL> bExpl(g_bOsnapExpl, FALSE);
XPushMemVar<BOOL> bFull(XExplodeStream::m_bFullExplode, TRUE);
AcDbVoidPtrArray entSet;
XExplodeStream dcExp(entSet);
dcExp.SetPropertiesFrom(this);
ExplodeOrDraw2d(dcExp);
INT_PTR nQuickMarker=GetQuickMarker();
int nGsMarker=1;
int nCount=entSet.length();
for(int i=0; i<nCount; i++) {
AcDbEntity *pEnt=(AcDbEntity *)entSet[i];
dc.SetSelectionMarker(nGsMarker);
nGsMarker++;
if(nQuickMarker && (nGsMarker-1)!=nQuickMarker) //用于捕捉时加速
continue;
dc.DrawEntity(*pEnt);
if(nQuickMarker && (nGsMarker-1)==nQuickMarker)
break;
}
ReleaseEntSet(entSet);
}
else
{
//add by xlc on 090222
if(m_nStepNum<2)
return Acad::eOk;
TDbLineStair stair1, stair2,stair3;
TDbSlab slab1,slab2,slab3;
TDbHandRail rail,rail2,rail3,railOut1,railOut2,railOut3;
ExplodeTo(stair1, stair2, stair3, slab1,slab2,slab3, rail,rail2, rail3, NULL,&railOut1,&railOut2,&railOut3);
TDbSymbArrow pArrowUp,pArrowDown;
if(IsArrow()) //画箭头
{
GetDefaultArrow(stair1,stair2,stair3,&pArrowUp,&pArrowDown);
if(dc.IsFullExplode())
{
TPushProperty vProp(&pArrowUp, dc);
pArrowUp.ExplodeOrDraw2d(dc);
pArrowDown.ExplodeOrDraw2d(dc);
}
else
{
dc.DrawEntity(pArrowUp);
dc.DrawEntity(pArrowDown);
}
}
stair1.AddTempRail(&rail);
if(IsConnectRail())
{
stair2.AddTempRail(&rail);
stair3.AddTempRail(&rail);
}
else
{
stair2.AddTempRail(&rail2);
stair3.AddTempRail(&rail3);
}
int nSectStair=GetSectStairPos();
if(IsOutRail()) //外侧扶手
{
stair1.AddTempRail(&railOut1);
railOut1.SetTempStair(&stair1);
if(!(m_nStairFlag == SF_FIRST && nSectStair == 0))
{
stair2.AddTempRail(&railOut2);
railOut2.SetTempStair(&stair2);
}
if(!(m_nStairFlag == SF_FIRST && nSectStair != 2))
{
stair3.AddTempRail(&railOut3);
railOut3.SetTempStair(&stair3);
}
}
double lSectPos,rSectPos;
XPoint ptLeft2d,ptRight2d;
if(CalSectPos(lSectPos,rSectPos,ptLeft2d,ptRight2d))
{
if(nSectStair==0) //剖切一跑
{
stair1.SetSectionPos(0, lSectPos);
stair1.SetSectionPos(1, rSectPos);
stair2.Set2DFlag(SF_NOSECT);
stair3.Set2DFlag(SF_NOSECT);
}
else if(nSectStair==1) //剖切二跑
{
stair2.SetSectionPos(0, lSectPos);
stair2.SetSectionPos(1, rSectPos);
stair1.Set2DFlag(SF_NOSECT);
stair3.Set2DFlag(SF_NOSECT);
}
else if(nSectStair==2) //剖切三跑
{
stair3.SetSectionPos(0, lSectPos);
stair3.SetSectionPos(1, rSectPos);
stair1.Set2DFlag(SF_NOSECT);
stair2.Set2DFlag(SF_NOSECT);
}
}
else
{
stair1.Set2DFlag(SF_NOSECT);
stair2.Set2DFlag(SF_NOSECT);
stair3.Set2DFlag(SF_NOSECT);
}
//显示梯段
if(dc.IsFullExplode())
{
if(m_nStairFlag!=SF_FIRST)
{
stair1.ExplodeOrDraw2d(dc);
stair2.ExplodeOrDraw2d(dc);
stair3.ExplodeOrDraw2d(dc);
}
else
{
stair1.ExplodeOrDraw2d(dc);
if(!(m_nStairFlag == SF_FIRST && nSectStair == 0))
{
stair2.ExplodeOrDraw2d(dc);
}
if(!(m_nStairFlag == SF_FIRST && nSectStair != 2))
{
stair3.ExplodeOrDraw2d(dc);
}
}
}
else
{
if(m_nStairFlag!=SF_FIRST)
{
dc.DrawEntity(stair1);
dc.DrawEntity(stair2);
dc.DrawEntity(stair3);
}
else
{
dc.DrawEntity(stair1);
if(!(m_nStairFlag == SF_FIRST && nSectStair == 0))
{
dc.DrawEntity(stair2);
}
if(!(m_nStairFlag == SF_FIRST && nSectStair != 2))
{
dc.DrawEntity(stair3);
}
}
}
// 设置内侧扶手
if(IsConnectRail())
{
if(nSectStair==0)
{
rail.SetTempStair(&stair1);
rail.setPropertiesFrom(this);
}
else if(nSectStair==1)
{
rail.SetTempStair(&stair2);
rail.setPropertiesFrom(this);
}
else if(nSectStair==2)
{
rail.SetTempStair(&stair3);
rail.setPropertiesFrom(this);
}
}
else
{
rail.SetTempStair(&stair1);
rail.setPropertiesFrom(this);
rail2.SetTempStair(&stair2);
rail2.setPropertiesFrom(this);
rail3.SetTempStair(&stair3);
rail3.setPropertiesFrom(this);
}
// 内侧扶手
{
long clipCount=0;
XPoly2D spoly(1),epoly(1),lpoly,rpoly;
if(IsOpenRail()&&!IsConnectRail())//开放内侧扶手端口
{
rail.GetSidePoly2d(lpoly,rpoly);
CalPolyFromPoint(*lpoly[0],*rpoly[0],stair1.GetRotation()-PI*0.5,spoly);
if(spoly.Length()>0)
{
dc.PushClip(spoly);
clipCount++;
}
CalPolyFromPoint(*lpoly[lpoly.Length()-1],*rpoly[rpoly.Length()-1],stair1.GetRotation()-PI*0.5,epoly);
if(epoly.Length()>0)
{
dc.PushClip(epoly);
clipCount++;
}
rail2.GetSidePoly2d(lpoly,rpoly);
spoly.Reset();
CalPolyFromPoint(*lpoly[0],*rpoly[0],stair2.GetRotation()-PI*0.5,spoly);
if(spoly.Length()>0)
{
dc.PushClip(spoly);
clipCount++;
}
epoly.Reset();
CalPolyFromPoint(*lpoly[lpoly.Length()-1],*rpoly[rpoly.Length()-1],stair2.GetRotation()-PI*0.5,epoly);
if(epoly.Length()>0)
{
dc.PushClip(epoly);
clipCount++;
}
rail3.GetSidePoly2d(lpoly,rpoly);
spoly.Reset();
CalPolyFromPoint(*lpoly[0],*rpoly[0],stair3.GetRotation()-PI*0.5,spoly);
if(spoly.Length()>0)
{
dc.PushClip(spoly);
clipCount++;
}
epoly.Reset();
CalPolyFromPoint(*lpoly[lpoly.Length()-1],*rpoly[rpoly.Length()-1],stair3.GetRotation()-PI*0.5,epoly);
if(epoly.Length()>0)
{
dc.PushClip(epoly);
clipCount++;
}
}
rail.setPropertiesFrom(this);
rail2.setPropertiesFrom(this);
rail3.setPropertiesFrom(this);
if(dc.IsFullExplode())
{
rail.ExplodeOrDraw2d(dc);
if((!IsConnectRail())
&&(m_nStairFlag!=SF_FIRST
|| (m_nStairFlag==SF_FIRST && nSectStair > 0))
)
{
rail2.ExplodeOrDraw2d(dc);
}
if((!IsConnectRail())
&&(m_nStairFlag!=SF_FIRST
|| (m_nStairFlag==SF_FIRST && nSectStair > 1))
)
{
rail3.ExplodeOrDraw2d(dc);
}
}
else
{
dc.DrawEntity(rail);
if((!IsConnectRail())
&&(m_nStairFlag!=SF_FIRST
|| (m_nStairFlag==SF_FIRST && nSectStair > 0))
)
{
dc.DrawEntity(rail2);
}
if((!IsConnectRail())
&&(m_nStairFlag!=SF_FIRST
|| (m_nStairFlag==SF_FIRST && nSectStair > 1))
)
{
dc.DrawEntity(rail3);
}
}
for(long i=0;i<clipCount;i++)
dc.PopClip();
}
//外侧扶手
if(IsOutRail())
{
long clipCount=0;
XPoly2D spoly(1),epoly(1),lpoly,rpoly;
if(IsOpenRail())//开放外侧扶手端口
{
railOut1.GetSidePoly2d(lpoly,rpoly);
CalPolyFromPoint(*lpoly[0],*rpoly[0],stair1.GetRotation()-PI*0.5,spoly);
if(spoly.Length()>0)
{
dc.PushClip(spoly);
clipCount++;
}
CalPolyFromPoint(*lpoly[lpoly.Length()-1],*rpoly[rpoly.Length()-1],stair1.GetRotation()-PI*0.5,epoly);
if(epoly.Length()>0)
{
dc.PushClip(epoly);
clipCount++;
}
railOut2.GetSidePoly2d(lpoly,rpoly);
spoly.Reset();
CalPolyFromPoint(*lpoly[0],*rpoly[0],stair2.GetRotation()-PI*0.5,spoly);
if(spoly.Length()>0)
{
dc.PushClip(spoly);
clipCount++;
}
epoly.Reset();
CalPolyFromPoint(*lpoly[lpoly.Length()-1],*rpoly[rpoly.Length()-1],stair2.GetRotation()-PI*0.5,epoly);
if(epoly.Length()>0)
{
dc.PushClip(epoly);
clipCount++;
}
railOut3.GetSidePoly2d(lpoly,rpoly);
spoly.Reset();
CalPolyFromPoint(*lpoly[0],*rpoly[0],stair3.GetRotation()-PI*0.5,spoly);
if(spoly.Length()>0)
{
dc.PushClip(spoly);
clipCount++;
}
epoly.Reset();
CalPolyFromPoint(*lpoly[lpoly.Length()-1],*rpoly[rpoly.Length()-1],stair3.GetRotation()-PI*0.5,epoly);
if(epoly.Length()>0)
{
dc.PushClip(epoly);
clipCount++;
}
}
railOut1.setPropertiesFrom(this);
railOut2.setPropertiesFrom(this);
railOut3.setPropertiesFrom(this);
if(dc.IsFullExplode())
{
railOut1.ExplodeOrDraw2d(dc);
//首层一跑剖断时不画外侧扶手
if(!(m_nStairFlag==SF_FIRST && nSectStair == 0))
{
railOut2.ExplodeOrDraw2d(dc);
}
//首层一跑或二跑剖断时不画外侧扶手
if(!(m_nStairFlag==SF_FIRST
&& (nSectStair == 0 || nSectStair == 1))
)
{
railOut3.ExplodeOrDraw2d(dc);
}
}
else
{
dc.DrawEntity(railOut1);
//首层一跑剖断时不画外侧扶手
if(!(m_nStairFlag==SF_FIRST && nSectStair == 0))
{
dc.DrawEntity(railOut2);
}
//首层一跑或二跑剖断时不画外侧扶手
if(!(m_nStairFlag==SF_FIRST
&& (nSectStair == 0 || nSectStair == 1))
)
{
dc.DrawEntity(railOut3);
}
}
for(long i=0;i<clipCount;i++)
dc.PopClip();
}
if(IsShowSlab())
{
if(m_nStairFlag != SF_FIRST ||
(m_nStairFlag == SF_FIRST && nSectStair != 0))
{
if(m_nSlabSize>_DIST_SNAP)
{
slab1.AddTempRail(&rail);
if(!IsConnectRail())
{
slab1.AddTempRail(&rail2);
}
if(IsOutRail())
{
slab1.AddTempRail(&railOut1);
slab1.AddTempRail(&railOut2);
}
if(dc.IsFullExplode())
slab1.ExplodeOrDraw2d(dc);
else
dc.DrawEntity(slab1);
}
}
if(m_nStairFlag != SF_FIRST ||
(m_nStairFlag == SF_FIRST && nSectStair == 2))
{
if(m_nSlabSize>_DIST_SNAP)
{
if(IsConnectRail())
{
slab2.AddTempRail(&rail);
}
else
{
slab2.AddTempRail(&rail2);
slab2.AddTempRail(&rail3);
}
if(IsOutRail())
{
slab2.AddTempRail(&railOut3);
slab2.AddTempRail(&railOut2);
}
if(dc.IsFullExplode())
slab2.ExplodeOrDraw2d(dc);
else
dc.DrawEntity(slab2);
}
}
if(m_nStairFlag != SF_FIRST)
{
if(m_nSlabSize>_DIST_SNAP)
{
if(IsConnectRail())
{
slab3.AddTempRail(&rail);
}
else
{
slab3.AddTempRail(&rail);
slab3.AddTempRail(&rail3);
}
if(IsOutRail())
{
slab3.AddTempRail(&railOut3);
slab3.AddTempRail(&railOut1);
}
if(dc.IsFullExplode())
slab3.ExplodeOrDraw2d(dc);
else
dc.DrawEntity(slab3);
}
}
}
}
return Acad::eOk;
}
// From TDbPolyPathEnt
Acad::ErrorStatus
TDbTriangleStair::GetPathPoly(XPoly2D &polyPath,AcGeVector3d&normal) const
{
assertReadEnabled();
//add by xlc on 090222
if(m_nStepNum<2)
return Acad::eOk;
TDbLineStair stair1, stair2,stair3;
TDbSlab slab1,slab2,slab3;
TDbHandRail rail, rail2, rail3, railTop;
ExplodeTo(stair1, stair2, stair3, slab1,slab2,slab3, rail, rail2, rail3,&railTop);
if(m_nStairFlag==SF_TOP)
railTop.GetBindPath(polyPath,normal);
else
rail.GetBindPath(polyPath,normal);
return Acad::eOk;
}
Acad::ErrorStatus
TDbTriangleStair::SetPathPoly(const XPoly2D &polyPath,const AcGeVector3d&normal)
{
return Acad::eNotApplicable;
}
BOOL TDbTriangleStair::CalSectPos(double &lSectPos,double &rSectPos,XPoint &ptLeft2d,XPoint &ptRight2d)const
{
if(m_nStairFlag == SF_TOP)
return FALSE;
int nSectStair=GetSectStairPos();
if(nSectStair == -1)
return FALSE;
TDbLineStair stair1, stair2, stair3;
TDbSlab slab1,slab2,slab3;
TDbHandRail rail, rail2, rail3,railTop;
ExplodeTo(stair1, stair2, stair3, slab1,slab2,slab3, rail, rail2, rail3, &railTop);
XDirectionCurve cvLeft1,cvRight1;
double width=0; //剖断楼梯宽
double len=0; //剖断位置距楼梯起始点的距离
double length=0; //剖切梯段楼梯总长
int nSectStepNum=m_nSectStepNum; //剖断步数
if(nSectStepNum < 0) //负数调整为正的
{
nSectStepNum=m_nSectStepNum+m_nStepNum*3+1;
}
if(nSectStepNum%m_nStepNum==0)
{
nSectStepNum--;
}
len=(nSectStepNum-0.5)*m_nStepWidth;
if(nSectStair==0)
{
cvLeft1=stair1.GetSideCurve2d(0);
cvRight1=stair1.GetSideCurve2d(1);
width=stair1.GetStairWidth()*0.5;
length=stair1.GetStairLength();
}
else if(nSectStair==1)
{
cvLeft1=stair2.GetSideCurve2d(0);
cvRight1=stair2.GetSideCurve2d(1);
width=stair2.GetStairWidth()*0.5;
length=stair2.GetStairLength();
len-=m_nStepWidth*m_nStepNum;
}
else if(nSectStair==2)
{
cvLeft1=stair3.GetSideCurve2d(0);
cvRight1=stair3.GetSideCurve2d(1);
width=stair3.GetStairWidth()*0.5;
length=stair3.GetStairLength();
len-=m_nStepWidth*m_nStepNum*2;
}
else
{
return FALSE;
}
double dLen=0; //投影长
if(fabs(cos(m_dSectRotation))>_DIST_SNAP)
{
dLen=width*tan(m_dSectRotation);
}
else
{
return FALSE;
}
if((len+fabs(dLen)+m_nStepWidth/3.0 )>length
||(len-fabs(dLen)-m_nStepWidth/3.0 )<_DIST_SNAP) //剖断线转角过大,不能与梯段两边都相交
{
double dist=(len<length-len)?len:length-len;
dist -= m_nStepWidth/2;
if(tan(m_dSectRotation)>_DIST_SNAP)
{
dLen=dist;
}
else
{
dLen=-dist;
}
}
lSectPos=(len-dLen)/length;
rSectPos=(len+dLen)/length;
XPointDir2d pt;
cvLeft1.Polar(len-dLen, pt);
ptLeft2d=pt;
cvRight1.Polar(len+dLen, pt);
ptRight2d=pt;
return TRUE;
}
//获得剖断线所在梯段:0,一跑;1,二跑;2,三跑;-1,没有剖断
int TDbTriangleStair::GetSectStairPos()const
{
if(m_nStairFlag==SF_TOP)
return -1;
if(abs(m_nSectStepNum)<1|| abs(m_nSectStepNum)>m_nStepNum*3)
{
return -1;
}
int nSectStepNum=m_nSectStepNum; //剖断步数
if(nSectStepNum < 0) //负数调整为正的
{
nSectStepNum=m_nSectStepNum+m_nStepNum*3+1;
}
int nSectStair;
if(nSectStepNum<=m_nStepNum)
{
nSectStair=0; //剖断在一跑
}
else if(nSectStepNum <= m_nStepNum*2)
{
nSectStair=1; //剖断在二跑
}
else
{
nSectStair=2; //剖断在三跑
}
return nSectStair;
}
// 由平面二维点推算剖切步数
int TDbTriangleStair::HitSectPosByPoint2d(XPoint ptHit2d) const
{
TDbLineStair stair1, stair2,stair3;
TDbSlab slab,slab2,slab3;
TDbHandRail rail, rail2, rail3;
ExplodeTo(stair1, stair2, stair3, slab,slab2,slab3, rail, rail2,rail3);
XDirectionCurve cvLeft1=stair1.GetSideCurve2d(0);
XDirectionCurve cvRight1=stair1.GetSideCurve2d(1);
XPoly2D poly1(1);
poly1.AppendNode(cvLeft1.StartPoint());
poly1.AppendNode(cvRight1.StartPoint());
poly1.AppendNode(cvRight1.EndPoint());
poly1.AppendNode(cvLeft1.EndPoint());
ptHit2d.z=0;
int nPosHit=-1;
if((ptHit2d&poly1)!=PR_OUTSIDE)
{
XPoint ptPrj;
cvLeft1.ProjectToMe(ptHit2d, ptPrj);
nPosHit=(int)(ptPrj.Distance2d(cvLeft1.StartPoint())/m_nStepWidth);
nPosHit += 1;
}
else
{
XDirectionCurve cvLeft2=stair2.GetSideCurve2d(0);
XDirectionCurve cvRight2=stair2.GetSideCurve2d(1);
XPoly2D poly2(1);
poly2.AppendNode(cvLeft2.StartPoint());
poly2.AppendNode(cvRight2.StartPoint());
poly2.AppendNode(cvRight2.EndPoint());
poly2.AppendNode(cvLeft2.EndPoint());
if((ptHit2d&poly2)!=PR_OUTSIDE)
{
XPoint ptPrj;
cvLeft2.ProjectToMe(ptHit2d, ptPrj);
nPosHit=(int)(ptPrj.Distance2d(cvLeft2.StartPoint())/m_nStepWidth);
nPosHit += m_nStepNum+1;
}
else
{
XDirectionCurve cvLeft3=stair3.GetSideCurve2d(0);
XDirectionCurve cvRight3=stair3.GetSideCurve2d(1);
XPoly2D poly3(1);
poly3.AppendNode(cvLeft3.StartPoint());
poly3.AppendNode(cvRight3.StartPoint());
poly3.AppendNode(cvRight3.EndPoint());
poly3.AppendNode(cvLeft3.EndPoint());
if((ptHit2d&poly3)!=PR_OUTSIDE)
{
XPoint ptPrj;
cvLeft3.ProjectToMe(ptHit2d, ptPrj);
nPosHit=(int)(ptPrj.Distance2d(cvLeft3.StartPoint())/m_nStepWidth);
nPosHit += m_nStepNum*2+1;
}
}
}
return nPosHit;
}
// Attribute Access method
double
TDbTriangleStair::GetTextHeight()const
{
assertReadEnabled();
return m_dTextHeight;
}
void
TDbTriangleStair::SetTextHeight(double h)
{
assertWriteEnabled();
m_dTextHeight=h;
}
Adesk::UInt8
TDbTriangleStair::GetStepNum() const
{
assertReadEnabled();
return m_nStepNum;
}
double
TDbTriangleStair::GetStepHeight() const
{
assertReadEnabled();
return m_nStepHeight;
}
void
TDbTriangleStair::SetStepNum(Adesk::UInt8 n)
{
assertWriteEnabled();
m_nStepNum=n;
}
double
TDbTriangleStair::GetRailHeight() const
{
assertReadEnabled();
return m_nRailHeight;
}
double
TDbTriangleStair::GetRailWidth() const
{
assertReadEnabled();
return m_nRailWidth;
}
double
TDbTriangleStair::GetRailDistToSide() const
{
assertReadEnabled();
return m_nRailDistToSide;
}
double
TDbTriangleStair::GetRailDist() const
{
assertReadEnabled();
return m_nRailDist;
}
double
TDbTriangleStair::GetSpaceWidth() const
{
assertReadEnabled();
return m_nSpaceWidth;
}
double
TDbTriangleStair::GetStairWidth() const
{
assertReadEnabled();
return m_nStairWidth;
}
double
TDbTriangleStair::GetStepWidth() const
{
assertReadEnabled();
return m_nStepWidth;
}
Adesk::UInt8
TDbTriangleStair::GetStairFlag() const
{
assertReadEnabled();
return m_nStairFlag;
}
int
TDbTriangleStair::GetSectStepNum() const
{
assertReadEnabled();
return m_nSectStepNum;
}
double
TDbTriangleStair::GetElevation() const
{
assertReadEnabled();
return m_ptLocation.z;
}
XPoint
TDbTriangleStair::GetLocation() const
{
assertReadEnabled();
return m_ptLocation;
}
double
TDbTriangleStair::GetRotation() const
{
assertReadEnabled();
return m_nRotation;
}
int
TDbTriangleStair::GetStartSide() const
{
assertReadEnabled();
return m_nStartSide;
}
double
TDbTriangleStair::GetSlabSize() const
{
assertReadEnabled();
return m_nSlabSize;
}
void
TDbTriangleStair::SetSlabSize(double s)
{
assertWriteEnabled();
m_nSlabSize=s;
}
void
TDbTriangleStair::SetConnectRail(BOOL bTrue)
{
assertWriteEnabled();
if(bTrue)
m_nFlagEx|=SFEX_CONNECTRAIL;
else
m_nFlagEx&=~SFEX_CONNECTRAIL;
}
void
TDbTriangleStair::SetRailHeight(double l)
{
assertWriteEnabled();
m_nRailHeight=l;
}
void
TDbTriangleStair::SetRailWidth(double w)
{
assertWriteEnabled();
m_nRailWidth=w;
}
void
TDbTriangleStair::SetRailDistToSide(double l)
{
assertWriteEnabled();
m_nRailDistToSide=l;
}
void
TDbTriangleStair::SetRailDist(double l)
{
assertWriteEnabled();
m_nRailDist=l;
}
void
TDbTriangleStair::SetStairFlag(Adesk::UInt8 flag)
{
assertWriteEnabled();
m_nStairFlag=flag;
}
void
TDbTriangleStair::SetSpaceWidth(double w)
{
assertWriteEnabled();
m_nSpaceWidth=w;
}
void
TDbTriangleStair::SetStepWidth(double w)
{
assertWriteEnabled();
m_nStepWidth=w;
}
void
TDbTriangleStair::SetStairWidth(double w)
{
assertWriteEnabled();
m_nStairWidth=w;
}
void
TDbTriangleStair::SetElevation(double elev)
{
assertWriteEnabled();
m_ptLocation.z = elev;
}
void
TDbTriangleStair::SetLocation(const XPoint &pt)
{
assertWriteEnabled();
m_ptLocation = pt;
}
void
TDbTriangleStair::SetRotation(double rot)
{
assertWriteEnabled();
m_nRotation=rot;
}
void
TDbTriangleStair::SetStartSide(int nSide)
{
assertWriteEnabled();
m_nStartSide=nSide;
}
void
TDbTriangleStair::SetStepHeight(double h)
{
assertWriteEnabled();
m_nStepHeight=h;
}
void
TDbTriangleStair::SetShowSlab(BOOL bTrue)
{
assertWriteEnabled();
if(bTrue)
m_nFlagEx|=SFEX_SHOWSLAB;
else
m_nFlagEx&=~SFEX_SHOWSLAB;
}
void TDbTriangleStair::SetOpenRail(BOOL bTrue)
{
assertWriteEnabled();
if(bTrue)
m_nFlagEx|=SFEX_OPENRAIL;
else
m_nFlagEx&=~SFEX_OPENRAIL;
}
void TDbTriangleStair::SetArrow(BOOL bTrue)
{
assertWriteEnabled();
if(bTrue)
m_nFlagEx|=SFEX_ARROW;
else
m_nFlagEx&=~SFEX_ARROW;
}
BOOL TDbTriangleStair::IsArrow() const
{
return ((m_nFlagEx&SFEX_ARROW)!=0);
}
BOOL TDbTriangleStair::IsAutoOutRail() const
{
return ((m_nFlagEx&SFEX_AUTOOUTRAIL)!=0);
}
// TArch6 memeber
BOOL TDbTriangleStair::IsAutoRail() const
{
return ((m_nFlagEx&SFEX_AUTORAIL)!=0);
}
BOOL TDbTriangleStair::IsOutRail()const
{
return (m_nFlagEx&SFEX_OUTRAIL)!=0;
}
void TDbTriangleStair::SetOutRail(BOOL bTrue)
{
assertWriteEnabled();
if(bTrue)
m_nFlagEx|=SFEX_OUTRAIL;
else
m_nFlagEx&=~SFEX_OUTRAIL;
}
BOOL TDbTriangleStair::IsArcPlatform() const
{
return ((m_nFlagEx&SFEX_ARCPLAT)!=0);
}
BOOL TDbTriangleStair::HasSideBeam(int nSide) const
{
int nBitFlag=nSide? SFEX_RBEAM : SFEX_LBEAM;
return ((m_nFlagEx&nBitFlag)!=0);
}
BOOL TDbTriangleStair::IsAscent() const
{
return ((m_nFlagEx&SFEX_ASCENT)!=0);
}
BOOL TDbTriangleStair::IsOnGround() const
{
return ((m_nFlagEx&SFEX_GROUND)!=0);
}
BOOL TDbTriangleStair::HasSlant() const
{
return ((m_nFlagEx&SFEX_SLANT)!=0);
}
void TDbTriangleStair::SetAutoOutRail(BOOL bTrue)
{
assertWriteEnabled();
if(bTrue)
m_nFlagEx |= SFEX_AUTOOUTRAIL;
else
m_nFlagEx &= ~SFEX_AUTOOUTRAIL;
}
void TDbTriangleStair::SetAutoRail(BOOL bTrue)
{
assertWriteEnabled();
if(bTrue)
m_nFlagEx |= SFEX_AUTORAIL;
else
m_nFlagEx &= ~SFEX_AUTORAIL;
}
void TDbTriangleStair::SetAscent(BOOL bTrue)
{
assertWriteEnabled();
if(bTrue)
m_nFlagEx |= SFEX_ASCENT;
else
m_nFlagEx &= ~SFEX_ASCENT;
}
void TDbTriangleStair::SetOnGround(BOOL bTrue)
{
assertWriteEnabled();
if(bTrue)
m_nFlagEx |= SFEX_GROUND;
else
m_nFlagEx &= ~SFEX_GROUND;
}
void TDbTriangleStair::SetSlant(BOOL bTrue)
{
assertWriteEnabled();
if(bTrue)
m_nFlagEx |= SFEX_SLANT;
else
m_nFlagEx &= ~SFEX_SLANT;
}
void TDbTriangleStair::SetArcPlatform(BOOL bTrue)
{
assertWriteEnabled();
if(bTrue)
m_nFlagEx |= SFEX_ARCPLAT;
else
m_nFlagEx &= ~SFEX_ARCPLAT;
}
void TDbTriangleStair::SetSideBeam(int nSide, BOOL bTrue)
{
assertWriteEnabled();
int nBitFlag=nSide? SFEX_RBEAM : SFEX_LBEAM;
if(bTrue)
m_nFlagEx |= nBitFlag;
else
m_nFlagEx &= ~nBitFlag;
}
double TDbTriangleStair::GetBeamHeight() const
{
return m_nBeamHeight;
}
double TDbTriangleStair::GetBeamThick() const
{
return m_nBeamThick;
}
double TDbTriangleStair::GetSlabThick() const
{
return m_nSlabThick;
}
AcDbObjectId TDbTriangleStair::GetLayerBeam3d() const
{
return m_idLayerBeam3d;
}
AcDbObjectId TDbTriangleStair::GetLayerStep3d() const
{
return m_idLayerStep3d;
}
AcDbObjectId TDbTriangleStair::GetLayerHand3d() const
{
return m_idLayerHand3d;
}
AcDbObjectId TDbTriangleStair::GetLayerRail3d() const
{
return m_idLayerRail3d;
}
AcDbObjectId TDbTriangleStair::GetLayerText() const
{
return m_idLayerText;
}
AcDbObjectId TDbTriangleStair::GetTextStyle() const
{
return m_idTextStyle;
}
AcDbObjectId TDbTriangleStair::GetLayerArrow() const
{
return m_idLayerArrow;
}
void TDbTriangleStair::SetBeamHeight(double val)
{
assertWriteEnabled();
m_nBeamHeight = val;
}
void TDbTriangleStair::SetSlabThick(double val)
{
assertWriteEnabled();
m_nSlabThick=val;
}
void TDbTriangleStair::SetBeamThick(double val)
{
assertWriteEnabled();
m_nBeamThick=val;
}
void TDbTriangleStair::SetLayerBeam3d(AcDbObjectId idLayer)
{
assertWriteEnabled();
m_idLayerBeam3d=idLayer;
}
void TDbTriangleStair::SetLayerStep3d(AcDbObjectId idLayer)
{
assertWriteEnabled();
m_idLayerStep3d=idLayer;
}
void TDbTriangleStair::SetLayerHand3d(AcDbObjectId idLayer)
{
assertWriteEnabled();
m_idLayerHand3d=idLayer;
}
void TDbTriangleStair::SetLayerRail3d(AcDbObjectId idLayer)
{
assertWriteEnabled();
m_idLayerRail3d=idLayer;
}
void TDbTriangleStair::SetLayerText(AcDbObjectId idLayer)
{
assertWriteEnabled();
m_idLayerText=idLayer;
}
void TDbTriangleStair::SetTextStyle(AcDbObjectId idStyle)
{
assertWriteEnabled();
m_idTextStyle=idStyle;
}
void TDbTriangleStair::SetLayerArrow(AcDbObjectId idLayer)
{
assertWriteEnabled();
m_idLayerArrow=idLayer;
}
void TDbTriangleStair::SetSectStepNum(int n)
{
assertWriteEnabled();
m_nSectStepNum=n;
}
double TDbTriangleStair::GetSectRotation()const
{
return m_dSectRotation;
}
void TDbTriangleStair::SetSectRotation(double r)
{
assertWriteEnabled();
m_dSectRotation=r;
}
//add by xlc 090426,箭头文字,动态数据
CString TDbTriangleStair::GetTextUp() const
{
assertReadEnabled();
CString sVal(_T("上"));
const TEntityFields &fd = GetFields();
fd.GFD(_T("上楼箭头文字"), sVal);
return sVal;
}
void TDbTriangleStair::SetTextUp(const TCHAR *sVal)
{
assertWriteEnabled();
TEntityFields &fd = Fields();
fd.SFD(_T("上楼箭头文字"), sVal);
}
CString TDbTriangleStair::GetTextDown() const
{
assertReadEnabled();
CString sVal(_T("下"));
const TEntityFields &fd = GetFields();
fd.GFD(_T("下楼箭头文字"), sVal);
return sVal;
}
void TDbTriangleStair::SetTextDown(const TCHAR *sVal)
{
assertWriteEnabled();
TEntityFields &fd = Fields();
fd.SFD(_T("下楼箭头文字"), sVal);
}
// sg add 101115,支持统一标高
bool TDbTriangleStair::UnifyElevation(double dElevation)
{
assertWriteEnabled();
SetElevation(dElevation);
return true;
}
// cet 2013.9.5 add
CString TDbTriangleStair::GetXml(const AcGeMatrix3d& mat) const
{
CString sXml;
AcDbVoidPtrArray arrEnts;
explode(arrEnts);
int nSize = arrEnts.length();
for (int i = 0; i < nSize; ++i)
{
AcDbEntity *pEnt = (AcDbEntity*)arrEnts[i];
if (pEnt == NULL)
{
continue;
}
TDbLineStair *pLineStair = TDbLineStair::cast(pEnt);
if (pLineStair != NULL)
{
sXml += pLineStair->GetXml(mat);
continue;
}
TDbSlab *pSlab = TDbSlab::cast(pEnt);
if (pSlab != NULL)
{
sXml += pSlab->GetXml(mat);
}
}
ReleaseEntSet(arrEnts);
return sXml;
}
/////////////////////////////////////////////////////////////////////////////
void InitDbTriangleStair(BOOL bTrue)
{
if(bTrue)
{
TDbTriangleStair::rxInit();
acrxBuildClassHierarchy();
TDbTriangleStair::InitMatchProtocol(TRUE);
}
else
{
TDbTriangleStair::InitMatchProtocol(FALSE);
deleteAcRxClass(TDbTriangleStair::desc());
}
}