3332 lines
76 KiB
C++
3332 lines
76 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbRoof.h"
|
|
#include "MFCDbDwgFiler.h"
|
|
#include "CoreTools.h"
|
|
#include "Geom.h"
|
|
#include "AcGiViewDraw.h"
|
|
|
|
//系统单位相对于毫米的数值比例
|
|
#define _UNIT_SCALE (IsMeterfUnitDraw() ? 0.001 : 1.0)
|
|
|
|
//把MM单位换算为系统单位
|
|
#define _AS_SYS_UNIT(nMM) (nMM * _UNIT_SCALE)
|
|
|
|
BOOL g_bCtrlToggle1[] =
|
|
{0,0,0,0,0,0,0,0,0,0,
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
0,0,0,0,0,0,0,0,0,0};
|
|
|
|
//=============================================================================================
|
|
Adesk::UInt32 AecDbXRoof::kCurrentVersionNumber = 1;
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbXRoof, AecDbEntityBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_DBXROOF,
|
|
"AecDbXRoof"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
AecDbXRoof::AecDbXRoof(void)
|
|
{
|
|
m_dSlabThick = 200;//mm
|
|
m_mapSpecXData.SetAt(KEY_NAME,_T("屋顶"));
|
|
m_SlopeRoofImpl = new TSlopeRoof;
|
|
m_nRoofType = 0;
|
|
}
|
|
|
|
AecDbXRoof::~AecDbXRoof(void)
|
|
{
|
|
if (m_SlopeRoofImpl != NULL)
|
|
delete m_SlopeRoofImpl;
|
|
deleteContainerOfStd(m_solids);
|
|
deleteContainerOfStd(m_pipes);
|
|
}
|
|
|
|
void AecDbXRoof::SetRidgeStyle(AecDbXRoof::RidgeStyle rStyle)
|
|
{
|
|
assertWriteEnabled();
|
|
m_nRidgeStyle = rStyle;
|
|
}
|
|
|
|
AecDbXRoof::RidgeStyle AecDbXRoof::GetRidgeStyle() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nRidgeStyle;
|
|
}
|
|
|
|
void AecDbXRoof::SetRoofStyle(AecDbXRoof::RoofStyle rStyle)
|
|
{
|
|
assertWriteEnabled();
|
|
m_nRoofStyle = rStyle;
|
|
}
|
|
|
|
AecDbXRoof::RoofStyle AecDbXRoof::GetRoofStyle() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nRoofStyle;
|
|
}
|
|
|
|
void AecDbXRoof::subList() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDbEntityBase::subList();
|
|
|
|
switch(m_nRoofStyle)
|
|
{
|
|
case kSlopeRoof:
|
|
{
|
|
acutPrintf(_T("\n任意坡顶:"));
|
|
break;
|
|
}
|
|
case kDualRoof:
|
|
{
|
|
acutPrintf(_T("\n人字屋顶:"));
|
|
break;
|
|
}
|
|
case kMountRoof:
|
|
{
|
|
acutPrintf(_T("\n山脊屋顶:"));
|
|
break;
|
|
}
|
|
case kCuspRoof:
|
|
{
|
|
acutPrintf(_T("\n攒尖屋顶:"));
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::copyFrom(const AcRxObject* pSrc)
|
|
{
|
|
assertWriteEnabled();
|
|
if (pSrc != NULL)
|
|
{
|
|
AecDbXRoof* pXRoof = AecDbXRoof::cast(pSrc);
|
|
if (pXRoof != NULL)
|
|
{
|
|
m_nRidgeStyle = pXRoof->m_nRidgeStyle;
|
|
m_nRoofStyle = pXRoof->m_nRoofStyle;
|
|
m_arAssocPartEntIds = pXRoof->m_arAssocPartEntIds;
|
|
|
|
if (m_SlopeRoofImpl != NULL)
|
|
{
|
|
*((TSlopeRoof*)m_SlopeRoofImpl) = *((TSlopeRoof*)pXRoof->m_SlopeRoofImpl);
|
|
}
|
|
|
|
m_dSlabThick = pXRoof->m_dSlabThick;
|
|
m_dRidgeWidth = pXRoof->m_dRidgeWidth;
|
|
m_dRidgeHeight = pXRoof->m_dRidgeHeight;
|
|
m_idTopFaceLayer = pXRoof->m_idTopFaceLayer;
|
|
m_idBotFaceLayer = pXRoof->m_idBotFaceLayer;
|
|
m_idSlabLayer = pXRoof->m_idSlabLayer;
|
|
m_idRidgeLayer = pXRoof->m_idRidgeLayer;
|
|
|
|
m_ptRidge1 = pXRoof->m_ptRidge1;
|
|
m_ptRidge2 = pXRoof->m_ptRidge2;
|
|
|
|
m_dAngleLeft = pXRoof->m_dAngleLeft;
|
|
m_dAngleRight = pXRoof->m_dAngleRight;
|
|
m_bEqualAngle = pXRoof->m_bEqualAngle;
|
|
m_bHeightLim = pXRoof->m_bHeightLim;
|
|
m_dRoofHeight = pXRoof->m_dRoofHeight;
|
|
|
|
m_ptLocation = pXRoof->m_ptLocation;
|
|
m_dRotation = pXRoof->m_dRotation;
|
|
m_dLength = pXRoof->m_dLength;
|
|
m_dWidth = pXRoof->m_dWidth;
|
|
m_dEavesLen = pXRoof->m_dEavesLen;
|
|
m_dMountLen = pXRoof->m_dMountLen;
|
|
m_dSlopeAngle1 = pXRoof->m_dSlopeAngle1;
|
|
m_dSlopeAngle2 = pXRoof->m_dSlopeAngle2;
|
|
m_dMountHeight = pXRoof->m_dMountHeight;
|
|
m_bShowSide = pXRoof->m_bShowSide;
|
|
|
|
m_ptCenter = pXRoof->m_ptCenter;
|
|
m_dRadius = pXRoof->m_dRadius;
|
|
m_nSideNum = pXRoof->m_nSideNum;
|
|
|
|
m_mapSpecXData.CopyFrom(&pXRoof->m_mapSpecXData);
|
|
|
|
//发送提资需要相同的ID
|
|
extern CString IDCreate();
|
|
Adesk::Int16 nVal = acdbCurDwg()->useri4();
|
|
if (nVal != KEY_NOPROTECT)
|
|
{
|
|
int nVt = 0;
|
|
CString sID = IDCreate();
|
|
if (m_mapSpecXData.HasKey(KEY_NO, nVt))
|
|
m_mapSpecXData.SetAt(KEY_NO, sID);
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
const AecDbObjXDataMap* AecDbXRoof::GetSpecialtyData() const
|
|
{
|
|
assertReadEnabled();
|
|
return &m_mapSpecXData;
|
|
}
|
|
|
|
AecDbObjXDataMap* AecDbXRoof::GetSpecialtyData(AcDb::OpenMode bMode/* = AcDb::kForWrite*/)
|
|
{
|
|
switch(bMode)
|
|
{
|
|
case AcDb::kForRead:
|
|
{
|
|
assertReadEnabled();
|
|
break;
|
|
}
|
|
case AcDb::kForWrite:
|
|
{
|
|
if (!isWriteEnabled())
|
|
{
|
|
upgradeOpen();
|
|
}
|
|
assertWriteEnabled();
|
|
break;
|
|
}
|
|
case AcDb::kForNotify:
|
|
{
|
|
if (!isWriteEnabled())
|
|
{
|
|
upgradeOpen();
|
|
}
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return &m_mapSpecXData;
|
|
}
|
|
|
|
void AecDbXRoof::UnionScale(double nScale)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
m_dSlabThick *= nScale;//板厚
|
|
m_dRidgeWidth *= nScale;
|
|
m_dRidgeHeight *= nScale;//屋脊大小
|
|
m_dRoofHeight*=nScale;
|
|
if (m_SlopeRoofImpl != NULL)
|
|
{
|
|
double nOldElev = ((TSlopeRoof*)m_SlopeRoofImpl)->GetElevation();
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->SetElevation(nOldElev*nScale);
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->m_fMaxHeight *= nScale;
|
|
}
|
|
|
|
if (m_nRoofStyle == AecDbXRoof::kMountRoof)
|
|
{
|
|
double nOldElev=GetElevation();
|
|
|
|
AcGeMatrix3d mat;
|
|
mat.setToScaling(nScale);
|
|
subTransformBy(mat);
|
|
|
|
SetElevation(nOldElev*nScale);
|
|
|
|
m_dWidth*=nScale; //屋顶宽
|
|
m_dLength*=nScale; //屋顶长
|
|
m_dRoofHeight*=nScale; //高度
|
|
m_dEavesLen*=nScale; //出檐长
|
|
m_dMountLen*=nScale; //出山长
|
|
m_dMountHeight*=nScale; //歇山高
|
|
}
|
|
else if (m_nRoofStyle == kCuspRoof)
|
|
{
|
|
double nOldElev=GetElevation();
|
|
AcGeMatrix3d mat;
|
|
mat.setToScaling(nScale);
|
|
subTransformBy(mat);
|
|
|
|
SetElevation(nOldElev*nScale);
|
|
m_dSlabThick*=nScale;//板厚
|
|
m_dRidgeWidth*=nScale;
|
|
m_dRidgeHeight*=nScale;//屋脊大小
|
|
m_dRoofHeight*=nScale;//高度
|
|
m_dRadius*=nScale;//半径
|
|
m_dEavesLen*=nScale;
|
|
}
|
|
}
|
|
|
|
bool AecDbXRoof::UnifyElevation(double dElevation/* = 0.0*/)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
m_mapSpecXData.SetAt(KEY_EL,dElevation);
|
|
if (m_SlopeRoofImpl != NULL)
|
|
{
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline.SetElevation(dElevation);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbXRoof::InitEqualSlope(AcDbPolyline* pPl,double dEl,double dAng)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
XPoly2D poly;
|
|
poly.SetAcDbCurve(pPl);
|
|
|
|
//确保逆时针
|
|
if (poly.PathArea() >0 )
|
|
{
|
|
poly.Reverse();
|
|
}
|
|
poly.Compress();
|
|
|
|
XPoly2D polyDest(1);
|
|
poly.Disperse(polyDest);
|
|
polyDest.SetElevation(dEl);
|
|
|
|
if (m_SlopeRoofImpl != NULL)
|
|
{
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->InitEqualSlope(polyDest,dAng);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
//设置轮廓Init方式
|
|
Acad::ErrorStatus AecDbXRoof::SetPathPoly(AcDbPolyline* pPl,const AcGeVector3d&normal)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (pPl == NULL)
|
|
return Acad::eOk;
|
|
|
|
if (m_SlopeRoofImpl != NULL)
|
|
{
|
|
XPoly2D polyPath1;
|
|
polyPath1.SetAcDbCurve(pPl);
|
|
|
|
if(polyPath1.PathArea()>0)
|
|
polyPath1.Reverse();
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->InitEqualSlope(polyPath1,PI/6);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::GetPathPoly(AcDbPolyline*& pPl,AcGeVector3d&normal) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
assertReadEnabled();
|
|
if (m_SlopeRoofImpl != NULL)
|
|
{
|
|
if (((TSlopeRoof *)m_SlopeRoofImpl)->m_polyOutline.Length() > 0)
|
|
pPl = (AcDbPolyline *)((TSlopeRoof *)m_SlopeRoofImpl)->m_polyOutline.AsAcDbCurve();
|
|
normal = AcGeVector3d::kZAxis;
|
|
}
|
|
|
|
if (m_nRoofStyle == kMountRoof)
|
|
{
|
|
normal=AcGeVector3d::kZAxis;
|
|
GetPolyPath(pPl);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbXRoof::SetPolyPath(AcDbPolyline* pPl)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (pPl == NULL)
|
|
return;
|
|
|
|
if (m_SlopeRoofImpl != NULL)
|
|
{
|
|
if (m_nRoofStyle == AecDbXRoof::kDualRoof)
|
|
{
|
|
XPoly2D poly;
|
|
poly.SetAcDbCurve(pPl);
|
|
|
|
if (poly.PathArea()>0)
|
|
{
|
|
poly.Reverse();
|
|
}
|
|
poly.Compress();
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline = poly;
|
|
}
|
|
else
|
|
{
|
|
XPoly2D polyPath;
|
|
polyPath.SetAcDbCurve(pPl);
|
|
|
|
XPoly2D polyDest(1);
|
|
polyPath.Disperse(polyDest);
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline = polyDest;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool AecDbXRoof::GetPolyPath(AcDbPolyline*& pPl) const
|
|
{
|
|
assertReadEnabled();
|
|
if (m_SlopeRoofImpl != NULL)
|
|
{
|
|
if (((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline.Length() > 0)
|
|
pPl = (AcDbPolyline*)((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline.AsAcDbCurve();
|
|
}
|
|
|
|
if (m_nRoofStyle == kMountRoof)
|
|
{
|
|
XPoly2D poly;
|
|
|
|
poly.SetFlag(1);
|
|
poly.Reset();
|
|
|
|
double dHeight=0;//屋檐产生的高差
|
|
dHeight=GetEavesLen()*tan(GetSlopeAngle1());
|
|
|
|
XPoint pt=GetLocation();
|
|
pt.z -= (dHeight+m_dSlabThick);
|
|
|
|
ads_polar(pt,m_dRotation+PI,GetMountLen(),pt);
|
|
ads_polar(pt,m_dRotation-PI*0.5,GetEavesLen(),pt);
|
|
poly.AppendNode(pt); //屋顶左下角点
|
|
|
|
ads_polar(pt,m_dRotation,GetMountLen()*2+GetLength(),pt);
|
|
poly.AppendNode(pt); //屋顶右下角点
|
|
|
|
ads_polar(pt,m_dRotation+PI*0.5,GetEavesLen()*2+GetWidth(),pt);
|
|
poly.AppendNode(pt); //屋顶右上角点
|
|
|
|
ads_polar(pt,m_dRotation+PI,GetMountLen()*2+GetLength(),pt);
|
|
poly.AppendNode(pt); //屋顶左上角点
|
|
pPl = (AcDbPolyline*)poly.AsAcDbCurve();
|
|
}
|
|
else if (m_nRoofStyle == kCuspRoof)
|
|
{
|
|
XPoly2D poly;
|
|
poly.SetFlag(1);
|
|
poly.Reset();
|
|
double nAngle=PI*2.0/m_nSideNum;
|
|
|
|
if(GetRadius()<_DIST_SNAP || m_nSideNum < 2)
|
|
return false;
|
|
|
|
double dEaves=GetEavesLen()/cos(PI/GetSideNum());
|
|
XPoint ptCenter=m_ptCenter;
|
|
ptCenter.z-=((GetRoofHeight()-m_dSlabThick)*GetEavesLen()/(GetRadius()*cos(PI/GetSideNum()))+m_dSlabThick);
|
|
|
|
for(long i=0;i<m_nSideNum;i++)
|
|
{
|
|
XPoint pt;
|
|
ads_polar(ptCenter,m_dRotation+i*nAngle,m_dRadius+dEaves,pt);
|
|
poly.AppendNode(pt);
|
|
}
|
|
pPl = (AcDbPolyline*)poly.AsAcDbCurve();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void AecDbXRoof::SetSlabThick(double dThick)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_dSlabThick = dThick;
|
|
}
|
|
|
|
double AecDbXRoof::GetSlabThick() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dSlabThick;
|
|
}
|
|
|
|
void AecDbXRoof::SetRidgeWidth(double dWidth)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_dRidgeWidth = dWidth;
|
|
}
|
|
|
|
double AecDbXRoof::GetRidgeWidth() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dRidgeWidth;
|
|
}
|
|
|
|
void AecDbXRoof::SetRidgeHeight(double dHeight)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_dRidgeHeight = dHeight;
|
|
}
|
|
|
|
double AecDbXRoof::GetRidgeHeight() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dRidgeHeight;
|
|
}
|
|
|
|
void AecDbXRoof::SetRidge(AcGePoint3d pt1,AcGePoint3d pt2)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_ptRidge1=pt1;m_ptRidge2=pt2;
|
|
}
|
|
|
|
AcGePoint3d AecDbXRoof::GetRidgeStart()const
|
|
{
|
|
assertReadEnabled();
|
|
return m_ptRidge1;
|
|
}
|
|
|
|
AcGePoint3d AecDbXRoof::GetRidgeEnd()const
|
|
{
|
|
assertReadEnabled();
|
|
return m_ptRidge2;
|
|
}
|
|
|
|
void AecDbXRoof::SetHeightLim(Adesk::Boolean bTrue)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_bHeightLim=bTrue;
|
|
}
|
|
Adesk::Boolean AecDbXRoof::IsHeightLim()const
|
|
{
|
|
return m_bHeightLim;
|
|
}
|
|
|
|
void AecDbXRoof::SetRoofHeight(double h)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_dRoofHeight=h;
|
|
}
|
|
|
|
double AecDbXRoof::GetRoofHeight()const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dRoofHeight;
|
|
}
|
|
|
|
double AecDbXRoof::GetElevation()const
|
|
{
|
|
assertReadEnabled();
|
|
const XPoly2D& pl = ((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline;
|
|
if (pl.Length() > 0)
|
|
{
|
|
return pl[0].z;
|
|
}
|
|
|
|
if (m_nRoofStyle == kMountRoof)
|
|
return m_ptLocation.z;
|
|
|
|
if (m_nRoofStyle == kCuspRoof)
|
|
return m_ptCenter.z;
|
|
|
|
return 0.0;
|
|
}
|
|
|
|
void AecDbXRoof::SetElevation(double dE)
|
|
{
|
|
AssertWriteEnabled();
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->SetElevation(dE);
|
|
m_ptLocation.z = dE;
|
|
m_ptCenter.z = dE;
|
|
}
|
|
|
|
void AecDbXRoof::SetEqualAngle(Adesk::Boolean bEqual)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_bEqualAngle=bEqual;
|
|
}
|
|
|
|
Adesk::Boolean AecDbXRoof::IsEqualAngle() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_bEqualAngle;
|
|
}
|
|
|
|
double AecDbXRoof::GetAngleLeft() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dAngleLeft;
|
|
}
|
|
|
|
double AecDbXRoof::GetAngleRight() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dAngleRight;
|
|
}
|
|
|
|
void AecDbXRoof::SetAngle(double a1,double a2)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_dAngleLeft=a1;m_dAngleRight=a2;
|
|
}
|
|
|
|
AcGePoint3d AecDbXRoof::GetLocation() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_ptLocation;
|
|
}
|
|
|
|
void AecDbXRoof::SetLocation(const AcGePoint3d &pt)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_ptLocation = pt;
|
|
}
|
|
|
|
double AecDbXRoof::GetRotation() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dRotation;
|
|
}
|
|
|
|
void AecDbXRoof::SetRotation(double dRot)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_dRotation = dRot;
|
|
}
|
|
|
|
double AecDbXRoof::GetEavesLen()const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dEavesLen;
|
|
}
|
|
void AecDbXRoof::SetEavesLen(double dE)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_dEavesLen=dE;
|
|
}
|
|
|
|
void AecDbXRoof::SetRoofType(Adesk::UInt16 nRoofType)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_nRoofType = nRoofType;
|
|
}
|
|
|
|
Adesk::UInt16 AecDbXRoof::GetRoofType() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nRoofType;
|
|
}
|
|
|
|
double AecDbXRoof::GetMountLen() const
|
|
{
|
|
assertReadEnabled();
|
|
double dMountLen=0;
|
|
if (GetRoofHeight() - GetMountHeight() < _DIST_SNAP || fabs(cos(GetSlopeAngle2()))< 1E-3 )//人字坡
|
|
{
|
|
return m_dMountLen;
|
|
}
|
|
else
|
|
{
|
|
dMountLen = GetEavesLen()*tan(GetSlopeAngle1()) / tan(GetSlopeAngle2());
|
|
}
|
|
return dMountLen;
|
|
}
|
|
|
|
void AecDbXRoof::SetMountLen(double dL)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_dMountLen = dL;
|
|
}
|
|
|
|
double AecDbXRoof::GetLength()const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dLength;
|
|
}
|
|
void AecDbXRoof::SetLength(double dL)
|
|
{
|
|
AssertWriteEnabled();
|
|
if(dL>_DIST_SNAP)
|
|
m_dLength=dL;
|
|
}
|
|
|
|
double AecDbXRoof::GetWidth()const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dWidth;
|
|
}
|
|
void AecDbXRoof::SetWidth(double dW)
|
|
{
|
|
AssertWriteEnabled();
|
|
if(dW>_DIST_SNAP)
|
|
m_dWidth=dW;
|
|
}
|
|
|
|
double AecDbXRoof::GetRadius() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dRadius;
|
|
}
|
|
|
|
void AecDbXRoof::SetRadius(double r)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_dRadius=r;
|
|
}
|
|
|
|
void AecDbXRoof::SetSideNum(Adesk::UInt8 num)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_nSideNum = num;
|
|
}
|
|
|
|
long AecDbXRoof::GetSideNum()const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nSideNum;
|
|
}
|
|
|
|
double AecDbXRoof::GetSlopeAngle(int idx) const
|
|
{
|
|
assertReadEnabled();
|
|
return ((TSlopeRoof*)m_SlopeRoofImpl)->GetSlopeAngle(idx);
|
|
}
|
|
|
|
void AecDbXRoof::SetSlopeAngle(int idx, double nAngle)
|
|
{
|
|
AssertWriteEnabled();
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->SetSlopeAngle(idx,nAngle);
|
|
}
|
|
|
|
double AecDbXRoof::GetSlopeAngle1()const
|
|
{
|
|
assertReadEnabled();
|
|
double nSlopeAngle1=PI/6.0;
|
|
if(GetWidth()>_DIST_SNAP)
|
|
{
|
|
nSlopeAngle1=atan(GetRoofHeight()*2/GetWidth());
|
|
}
|
|
return nSlopeAngle1;
|
|
}
|
|
void AecDbXRoof::SetSlopeAngle1(double dA)
|
|
{
|
|
AssertWriteEnabled();
|
|
if(dA>0)
|
|
m_dSlopeAngle1=dA;
|
|
}
|
|
double AecDbXRoof::GetSlopeAngle2()const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dSlopeAngle2;
|
|
}
|
|
void AecDbXRoof::SetSlopeAngle2(double dA)
|
|
{
|
|
AssertWriteEnabled();
|
|
if(dA>0)
|
|
m_dSlopeAngle2=dA;
|
|
}
|
|
|
|
double AecDbXRoof::GetMountHeight() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dMountHeight;
|
|
}
|
|
void AecDbXRoof::SetMountHeight(double dH)
|
|
{
|
|
assertWriteEnabled();
|
|
m_dMountHeight=dH;
|
|
}
|
|
|
|
double AecDbXRoof::GetTopLength() const
|
|
{
|
|
assertReadEnabled();
|
|
double dTopLength=0;
|
|
if (GetRoofHeight()-GetMountHeight()<_DIST_SNAP||fabs(cos(GetSlopeAngle2()))<1E-3)
|
|
{
|
|
dTopLength=GetMountLen()*2+GetLength();
|
|
}
|
|
else
|
|
{
|
|
double dDist=(GetRoofHeight()-GetMountHeight())/tan(GetSlopeAngle2());
|
|
if (GetLength()-dDist*2>_DIST_SNAP)
|
|
{
|
|
dTopLength=GetLength()-dDist*2;
|
|
}
|
|
}
|
|
return dTopLength;
|
|
}
|
|
|
|
void AecDbXRoof::SetShowSide(Adesk::Boolean bTrue)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_bShowSide=bTrue;
|
|
}
|
|
Adesk::Boolean AecDbXRoof::IsShowSide()const
|
|
{
|
|
assertReadEnabled();
|
|
return m_bShowSide;
|
|
}
|
|
|
|
AcGePoint3d AecDbXRoof::GetCenter() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_ptCenter;
|
|
}
|
|
|
|
void AecDbXRoof::SetCenter(AcGePoint3d pt)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_ptCenter=pt;
|
|
}
|
|
|
|
void AecDbXRoof::CallFromJigUpdate(int nRoofType,int nPromptCounter,const AcGePoint3d& ptLoc,const AcGePoint3d& ptRightDown,const AcGePoint3d& ptRightUp)
|
|
{
|
|
switch (nPromptCounter)
|
|
{
|
|
case 0:
|
|
{
|
|
AcGePoint3d pt1,pt2;
|
|
pt1=ptRightDown;
|
|
pt2=ptLoc;
|
|
pt1.z=pt2.z=0;
|
|
XVector3D vtRot=pt1-pt2;
|
|
vtRot.z=0;
|
|
double rot=CT_std_angle(ads_angle(XPoint(),vtRot)-ads_angle(XPoint(),XVector3D(1,0,0)));
|
|
this->SetRotation(rot);
|
|
double length=pt1.distanceTo(pt2);
|
|
this->SetLength(length);
|
|
this->SetWidth(length*0.5);
|
|
|
|
if (nRoofType == 3 && length > 0 )
|
|
{
|
|
this->SetSlopeAngle2(atan(this->GetRoofHeight()*2.0/length));
|
|
}
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
AcGeVector3d offset=ptRightUp-ptRightDown;
|
|
XVector3D vtOffset=ptRightUp-ptRightDown;
|
|
vtOffset.z = 0;
|
|
double nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-this->GetRotation());
|
|
double nIncLen=ads_distance(XPoint(), vtOffset) * sin(nVtRot);
|
|
|
|
if (nIncLen>_DIST_SNAP)
|
|
{
|
|
this->SetWidth(nIncLen);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
bool AecDbXRoof::ExploreToFaces(AcDbVoidPtrArray& arFacePtrs) const
|
|
{
|
|
switch(m_nRoofStyle)
|
|
{
|
|
case kSlopeRoof:
|
|
{
|
|
DrawSlopeRoof3d(NULL,&arFacePtrs);
|
|
break;
|
|
}
|
|
case kDualRoof:
|
|
{
|
|
DrawDualRoof3d(NULL,&arFacePtrs);
|
|
break;
|
|
}
|
|
case kMountRoof:
|
|
{
|
|
DrawMountRoof3d(NULL,&arFacePtrs);
|
|
break;
|
|
}
|
|
case kCuspRoof:
|
|
{
|
|
DrawCuspRoof3d(NULL,&arFacePtrs);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbXRoof::HitGetPlane(AcGePoint3d& ptHit,AcDbVoidPtrArray& entSet,AcGePlane& plane)
|
|
{
|
|
return TSlopeRoof::HitGetPlane(ptHit,entSet,plane);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//管线系统屏蔽掉
|
|
if ( dc.IsDragging() )
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
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(pEnt->colorIndex());
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
dc.SetColor(nCrBk);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
switch(m_nRoofStyle)
|
|
{
|
|
case kSlopeRoof:
|
|
{
|
|
DrawSlopeRoof2d(dc);
|
|
break;
|
|
}
|
|
case kDualRoof:
|
|
{
|
|
DrawDualRoof2d(dc);
|
|
break;
|
|
}
|
|
case kMountRoof:
|
|
{
|
|
DrawMountRoof2d(dc);
|
|
break;
|
|
}
|
|
case kCuspRoof:
|
|
{
|
|
DrawCuspRoof2d(dc);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//管线系统屏蔽掉
|
|
if ( dc.IsDragging() )
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
//图层
|
|
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(pEnt->colorIndex());
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
dc.SetLayer(idLay);
|
|
dc.SetColor(nCrBk);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
deleteContainerOfStd(m_solids);
|
|
deleteContainerOfStd(m_pipes);
|
|
|
|
switch(m_nRoofStyle)
|
|
{
|
|
case kSlopeRoof:
|
|
{
|
|
DrawSlopeRoof3d(&dc);
|
|
break;
|
|
}
|
|
case kDualRoof:
|
|
{
|
|
DrawDualRoof3d(&dc);
|
|
break;
|
|
}
|
|
case kMountRoof:
|
|
{
|
|
DrawMountRoof3d(&dc);
|
|
break;
|
|
}
|
|
case kCuspRoof:
|
|
{
|
|
DrawCuspRoof3d(&dc);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus AecDbXRoof::dwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if ( !pFiler->isKindOf(CMFCDbDwgFiler::desc()))
|
|
{
|
|
es = AecDbEntityBase::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 > AecDbXRoof::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy);
|
|
|
|
Adesk::UInt8 nStyle = 0;
|
|
pFiler->readItem(&nStyle);
|
|
m_nRoofStyle=(RoofStyle)nStyle;
|
|
|
|
RoofBaseDwgin(pFiler);
|
|
|
|
switch(m_nRoofStyle)
|
|
{
|
|
case kSlopeRoof:
|
|
{
|
|
SlopeRoofDwgIn(pFiler);
|
|
break;
|
|
}
|
|
case kDualRoof:
|
|
{
|
|
DualRoofDwgIn(pFiler);
|
|
break;
|
|
}
|
|
case kMountRoof:
|
|
{
|
|
MountRoofDwgIn(pFiler);
|
|
break;
|
|
}
|
|
case kCuspRoof:
|
|
{
|
|
CuspRoofDwgIn(pFiler);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
m_mapSpecXData.dwgInFields(pFiler);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::RoofBaseDwgin(AcDbDwgFiler* pFiler)
|
|
{
|
|
pFiler->readItem(&m_idTopFaceLayer);
|
|
pFiler->readItem(&m_idBotFaceLayer);
|
|
pFiler->readItem(&m_idSlabLayer);
|
|
pFiler->readItem(&m_idRidgeLayer);
|
|
pFiler->readItem(&m_dSlabThick);
|
|
pFiler->readItem(&m_dRidgeWidth);
|
|
pFiler->readItem(&m_dRidgeHeight);
|
|
|
|
Adesk::UInt8 nStyle;
|
|
pFiler->readItem(&nStyle);
|
|
m_nRidgeStyle=(RidgeStyle)nStyle;
|
|
|
|
Adesk::Int32 nLen = 0;
|
|
pFiler->readItem(&nLen);
|
|
|
|
m_arAssocPartEntIds.removeAll();
|
|
for(int i=0;i<nLen;i++)
|
|
{
|
|
AcDbSoftPointerId id;
|
|
pFiler->readItem(&id);
|
|
m_arAssocPartEntIds.append(id);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::SlopeRoofDwgIn(AcDbDwgFiler* pFiler)
|
|
{
|
|
double nElev=0.0;
|
|
pFiler->readItem(&nElev);
|
|
|
|
Adesk::UInt16 nEdgeNum=0;
|
|
pFiler->readItem(&nEdgeNum);
|
|
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->Reset();
|
|
for(Adesk::UInt16 i=0; i<nEdgeNum; i++)
|
|
{
|
|
AcGePoint3d ptVertex;
|
|
double nSlope;
|
|
pFiler->readItem(&ptVertex);
|
|
pFiler->readItem(&nSlope);
|
|
ptVertex[2]=nElev;
|
|
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->AppendEdge(XPoint(ptVertex), nSlope);
|
|
}
|
|
|
|
double fMaxHeight = 0.0;
|
|
pFiler->readItem(&fMaxHeight);
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->m_fMaxHeight = fMaxHeight;
|
|
|
|
//出檐长
|
|
pFiler->readItem(&m_dEavesLen);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::DualRoofDwgIn(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
XPoly2D& pl = ((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline;
|
|
|
|
double nElev;
|
|
pFiler->readItem(&nElev);
|
|
ReadPoly2D(pFiler,pl);
|
|
pl.SetElevation(nElev);
|
|
|
|
pFiler->readItem(&m_ptRidge1);
|
|
pFiler->readItem(&m_ptRidge2);
|
|
|
|
pFiler->readItem(&m_dAngleLeft);
|
|
pFiler->readItem(&m_dAngleRight);
|
|
pFiler->readItem(&m_bEqualAngle);
|
|
|
|
pFiler->readItem(&m_bHeightLim);
|
|
pFiler->readItem(&m_dRoofHeight);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::MountRoofDwgIn(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
pFiler->readItem(&m_ptLocation);
|
|
pFiler->readItem(&m_dRotation);
|
|
pFiler->readItem(&m_dLength);
|
|
pFiler->readItem(&m_dWidth);
|
|
pFiler->readItem(&m_dSlopeAngle2);
|
|
|
|
pFiler->readItem(&m_dEavesLen);
|
|
pFiler->readItem(&m_dMountLen);
|
|
pFiler->readItem(&m_dRoofHeight);
|
|
pFiler->readItem(&m_dMountHeight);
|
|
pFiler->readItem(&m_bShowSide);
|
|
pFiler->readUInt16(&m_nRoofType);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::CuspRoofDwgIn(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertReadEnabled();
|
|
|
|
pFiler->readItem(&m_ptCenter);
|
|
pFiler->readItem(&m_dRotation);
|
|
pFiler->readItem(&m_dRoofHeight);
|
|
pFiler->readItem(&m_dRadius);
|
|
pFiler->readItem(&m_nSideNum);
|
|
pFiler->readItem(&m_dEavesLen);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//----- Save parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if ( !pFiler->isKindOf(CMFCDbDwgFiler::desc()))
|
|
{
|
|
es = AecDbEntityBase::dwgOutFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
}
|
|
|
|
//----- Object version number needs to be saved first
|
|
if ( (es =pFiler->writeUInt32 (AecDbXRoof::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
Adesk::UInt8 nStyle = (Adesk::UInt8)m_nRoofStyle;
|
|
pFiler->writeItem(nStyle);
|
|
|
|
RoofBaseDwgOut(pFiler);
|
|
|
|
switch(m_nRoofStyle)
|
|
{
|
|
case kSlopeRoof:
|
|
{
|
|
SlopeRoofDwgOut(pFiler);
|
|
break;
|
|
}
|
|
case kDualRoof:
|
|
{
|
|
DualRoofDwgOut(pFiler);
|
|
break;
|
|
}
|
|
case kMountRoof:
|
|
{
|
|
MountRoofDwgOut(pFiler);
|
|
break;
|
|
}
|
|
case kCuspRoof:
|
|
{
|
|
CuspRoofDwgOut(pFiler);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
m_mapSpecXData.dwgOutFields(pFiler);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::RoofBaseDwgOut(AcDbDwgFiler* pFiler) const
|
|
{
|
|
pFiler->writeItem(m_idTopFaceLayer);
|
|
pFiler->writeItem(m_idBotFaceLayer);
|
|
pFiler->writeItem(m_idSlabLayer);
|
|
pFiler->writeItem(m_idRidgeLayer);
|
|
pFiler->writeItem(m_dSlabThick);
|
|
pFiler->writeItem(m_dRidgeWidth);
|
|
pFiler->writeItem(m_dRidgeHeight);
|
|
pFiler->writeItem((Adesk::UInt8)m_nRidgeStyle);
|
|
|
|
Adesk::Int32 nLen = m_arAssocPartEntIds.length();
|
|
pFiler->writeInt32(nLen);
|
|
|
|
AcDbSoftPointerId id;
|
|
for(int i=0;i < nLen;i++)
|
|
{
|
|
id = m_arAssocPartEntIds.at(i);
|
|
pFiler->writeItem(id);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::SlopeRoofDwgOut(AcDbDwgFiler* pFiler) const
|
|
{
|
|
double nElev=0.0;
|
|
if(!!((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline)
|
|
{
|
|
const XPoly2D& pl = ((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline;
|
|
nElev = pl[0].z;
|
|
}
|
|
|
|
pFiler->writeItem(nElev);
|
|
|
|
Adesk::UInt16 nTotalEdge = ((TSlopeRoof*)m_SlopeRoofImpl)->GetEdgeNum();
|
|
pFiler->writeItem(nTotalEdge);
|
|
|
|
const XPoly2D& pl = ((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline;
|
|
int nLen = pl.Length();
|
|
|
|
const DList<double>& slope = ((TSlopeRoof*)m_SlopeRoofImpl)->m_slope;
|
|
|
|
double dSlope = 0.0;
|
|
for(int i =0; i< nTotalEdge; i++)
|
|
{
|
|
pFiler->writeItem( pl[i].AsAcGePoint3d());
|
|
|
|
dSlope = slope[i];
|
|
pFiler->writeItem( dSlope );
|
|
}
|
|
|
|
pFiler->writeItem(((TSlopeRoof*)m_SlopeRoofImpl)->m_fMaxHeight);
|
|
|
|
//出檐长
|
|
pFiler->writeItem(m_dEavesLen);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
extern BOOL IsMirrorMatrix(ads_matrix mat);
|
|
Acad::ErrorStatus AecDbXRoof::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
AssertWriteEnabled();
|
|
if (m_nRoofStyle == kSlopeRoof)
|
|
{
|
|
ads_matrix mat;
|
|
memcpy(mat, &xform, sizeof(ads_matrix));
|
|
double nElev=0.0;
|
|
for(int i=0; i<((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline.Length(); i++) {
|
|
XPoint *pt=((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline[i];
|
|
pt->TransformBy(mat);
|
|
|
|
//以第一个顶点的z坐标为基准
|
|
if(i==0) {
|
|
nElev = pt->z;
|
|
} else {
|
|
pt->z = nElev;
|
|
}
|
|
}
|
|
if( IsMirrorMatrix(mat) && ((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline.PathArea()>0) {
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline.Reverse();
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->m_slope.Reverse();
|
|
}
|
|
}
|
|
else if (m_nRoofStyle == kDualRoof)
|
|
{
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline.TransformBy(xform);
|
|
m_ptRidge1.transformBy(xform);
|
|
m_ptRidge2.transformBy(xform);
|
|
}
|
|
else if (m_nRoofStyle == kMountRoof)
|
|
{
|
|
ads_point ptX,ptY;
|
|
ads_polar(asDblArray(m_ptLocation), m_dRotation, GetLength(), ptX);
|
|
ads_polar(asDblArray(m_ptLocation), m_dRotation+PI/2.0, GetWidth(), ptY);
|
|
|
|
asPnt3d(ptX).transformBy(xform);
|
|
asPnt3d(ptY).transformBy(xform);
|
|
m_ptLocation.transformBy(xform);
|
|
|
|
double dAng = CT_std_angle(ads_angle(asDblArray(m_ptLocation), ptY) - ads_angle(asDblArray(m_ptLocation), ptX));
|
|
if(fabs(dAng-PI*1.5)<_angSnap)
|
|
{
|
|
Exchange(m_ptLocation, asPnt3d(ptX));
|
|
}
|
|
m_dRotation = ads_angle(asDblArray(m_ptLocation), ptX);
|
|
}
|
|
else if (m_nRoofStyle == kCuspRoof)
|
|
{
|
|
m_ptCenter.transformBy(xform);
|
|
AcGeVector3d vt(cos(m_dRotation),sin(m_dRotation),0);
|
|
vt.transformBy(xform);
|
|
AcGeVector2d vt2d(vt.x,vt.y);
|
|
m_dRotation=vt2d.angle();
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::DualRoofDwgOut(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
const XPoly2D& pl = ((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline;
|
|
int nLen = pl.Length();
|
|
|
|
double nElev=0;
|
|
if(nLen > 0 )
|
|
nElev = pl[0].z;
|
|
pFiler->writeItem(nElev);
|
|
WritePoly2D(pFiler,pl);
|
|
|
|
pFiler->writeItem(m_ptRidge1);
|
|
pFiler->writeItem(m_ptRidge2);
|
|
pFiler->writeItem(m_dAngleLeft);
|
|
pFiler->writeItem(m_dAngleRight);
|
|
pFiler->writeItem(m_bEqualAngle);
|
|
|
|
pFiler->writeItem(m_bHeightLim);
|
|
pFiler->writeItem(m_dRoofHeight);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::MountRoofDwgOut(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
pFiler->writeItem(m_ptLocation);
|
|
pFiler->writeItem(m_dRotation);
|
|
pFiler->writeItem(m_dLength);
|
|
pFiler->writeItem(m_dWidth);
|
|
pFiler->writeItem(m_dSlopeAngle2);
|
|
pFiler->writeItem(m_dEavesLen);
|
|
pFiler->writeItem(m_dMountLen);
|
|
pFiler->writeItem(m_dRoofHeight);
|
|
pFiler->writeItem(m_dMountHeight);
|
|
pFiler->writeItem(m_bShowSide);
|
|
pFiler->writeUInt16(m_nRoofType);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::CuspRoofDwgOut(AcDbDwgFiler* pFiler) const
|
|
{
|
|
pFiler->writeItem(m_ptCenter);
|
|
pFiler->writeItem(m_dRotation);
|
|
pFiler->writeItem(m_dRoofHeight);
|
|
pFiler->writeItem(m_dRadius);
|
|
pFiler->writeItem(m_nSideNum);
|
|
pFiler->writeItem(m_dEavesLen);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::dxfInFields (AcDbDxfFiler* pFiler)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbXRoof::GetMountLine(AcGeLineSeg3d &leftLine,AcGeLineSeg3d &rightLine,AcGeLineSeg3d &midLine) const
|
|
{
|
|
XPoint pt = m_ptLocation;
|
|
pt.z+=(GetRoofHeight()-m_dSlabThick);
|
|
|
|
if (GetRoofHeight()-GetMountHeight()<_DIST_SNAP||fabs(cos(GetSlopeAngle2()))<1E-3)//人字屋顶
|
|
{
|
|
ads_polar(pt,m_dRotation+PI*0.5,GetWidth()*0.5,pt);
|
|
ads_polar(pt,m_dRotation+PI,GetMountLen(),pt);
|
|
XPoint ptS = pt;
|
|
ads_polar(pt,m_dRotation,GetTopLength(),pt);
|
|
midLine.set(ptS.AsAcGePoint3d(),pt.AsAcGePoint3d()); //屋脊线终点
|
|
}
|
|
else if (GetMountHeight()<_DIST_SNAP) //四坡屋顶或攒尖屋顶
|
|
{
|
|
double dDist=GetRoofHeight()/tan(GetSlopeAngle2());//侧坡在平面上的间距
|
|
ads_polar(pt,m_dRotation+PI*0.5,GetWidth()*0.5,pt);
|
|
ads_polar(pt,m_dRotation,dDist,pt);
|
|
XPoint ptS = pt;
|
|
ads_polar(pt,m_dRotation,GetTopLength(),pt);
|
|
midLine.set(ptS.AsAcGePoint3d(),pt.AsAcGePoint3d()); //屋脊线终点
|
|
}
|
|
else //歇山屋顶
|
|
{
|
|
double dWidth=GetMountHeight()/tan(GetSlopeAngle1());//歇山半宽
|
|
double dDist=(GetRoofHeight()-GetMountHeight())/tan(GetSlopeAngle2());//侧坡在平面上的间距
|
|
|
|
pt.z-=GetMountHeight();
|
|
|
|
ads_polar(pt,m_dRotation,dDist,pt);
|
|
ads_polar(pt,m_dRotation+PI*0.5,GetWidth()*0.5-dWidth,pt);
|
|
|
|
XPoint ptS = pt;
|
|
ads_polar(pt,m_dRotation+PI*0.5,dWidth*2,pt);
|
|
leftLine.set(ptS.AsAcGePoint3d(),pt.AsAcGePoint3d()); //歇山左上角点
|
|
|
|
ads_polar(asDblArray(leftLine.startPoint()),m_dRotation,GetLength()-dDist*2,pt);
|
|
ptS = pt;
|
|
|
|
ads_polar(asDblArray(leftLine.endPoint()),m_dRotation,GetLength()-dDist*2,pt);
|
|
rightLine.set(ptS.AsAcGePoint3d(),pt.AsAcGePoint3d()); //歇山右上角点
|
|
|
|
Midpoint(asDblArray(leftLine.startPoint()),asDblArray(leftLine.endPoint()),pt);
|
|
pt.z=GetLocation().z+GetRoofHeight()-m_dSlabThick;
|
|
ptS = pt;
|
|
|
|
ads_polar(pt,m_dRotation,GetLength()-dDist*2,pt);
|
|
midLine.set(ptS.AsAcGePoint3d(),pt.AsAcGePoint3d()); //屋脊线终点
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::subGetGripPoints(AcGePoint3dArray& gripPoints,AcDbIntArray& osnapModes,AcDbIntArray& geomIds) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGeVector3d vtNormal;
|
|
XPoly2D polyPath;
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->GetPathPoly(polyPath,vtNormal);
|
|
|
|
int nVertexCount = polyPath.Length();
|
|
for(int i=0; i<nVertexCount; i++)
|
|
{
|
|
XPoint ptWcs = Ecs2Wcs(*polyPath[i], XVector3D(vtNormal));
|
|
gripPoints.append(ptWcs);
|
|
}
|
|
|
|
//边上的夹点
|
|
int nEdgeNum=polyPath.TotalSegments();
|
|
for(int i=0; i<nEdgeNum; i++) {
|
|
XCurveSegment seg;
|
|
polyPath.Nth(i, seg);
|
|
XPoint ptMid=Ecs2Wcs(seg.MidPoint(), vtNormal);
|
|
gripPoints.append(ptMid);
|
|
}
|
|
|
|
if (m_nRoofStyle == kDualRoof)
|
|
{
|
|
gripPoints.append(m_ptRidge1);
|
|
gripPoints.append(m_ptRidge2);
|
|
gripPoints.append(XCurveSegment(m_ptRidge1,m_ptRidge2,0).MidPoint().AsAcGePoint3d());
|
|
}
|
|
else if (m_nRoofStyle == kMountRoof)
|
|
{
|
|
XPoint ptLoc = m_ptLocation;
|
|
XPoint ptCenter;
|
|
ads_polar(ptLoc,m_dRotation,0.5*GetLength(),ptCenter);
|
|
ads_polar(ptCenter,m_dRotation+PI*0.5,0.5*GetWidth(),ptCenter);
|
|
gripPoints.append(ptCenter);
|
|
|
|
gripPoints.append(ptLoc);
|
|
|
|
XPoint ptFirst;
|
|
ads_polar(ptLoc,m_dRotation,GetLength(),ptFirst);
|
|
gripPoints.append(ptFirst);
|
|
ads_polar(ptFirst,m_dRotation+PI*0.5,GetWidth(),ptFirst);
|
|
gripPoints.append(ptFirst);
|
|
ads_polar(ptLoc,m_dRotation+PI*0.5,GetWidth(),ptFirst);
|
|
gripPoints.append(ptFirst);
|
|
|
|
ads_polar(ptLoc,m_dRotation,GetLength()*0.5,ptFirst);
|
|
ads_polar(ptFirst,m_dRotation-PI*0.5,GetEavesLen(),ptFirst);
|
|
gripPoints.append(ptFirst); //出檐长
|
|
ads_polar(ptFirst,m_dRotation+PI*0.5,GetWidth()+GetEavesLen()*2,ptFirst);
|
|
gripPoints.append(ptFirst); //出檐长
|
|
|
|
ads_polar(ptLoc,m_dRotation+PI*0.5,GetWidth()*0.5,ptFirst);
|
|
ads_polar(ptFirst,m_dRotation+PI,GetMountLen(),ptFirst);
|
|
gripPoints.append(ptFirst); //出山长
|
|
ads_polar(ptFirst,m_dRotation,GetLength()+GetMountLen()*2,ptFirst);
|
|
gripPoints.append(ptFirst); //出山长
|
|
|
|
XLine leftLine, rightLine, midLine;
|
|
|
|
AcGeLineSeg3d lLn,rLn,mLn;
|
|
GetMountLine(lLn,rLn,mLn);
|
|
leftLine.SetPoints(lLn.startPoint(),lLn.endPoint());
|
|
rightLine.SetPoints(rLn.startPoint(),rLn.endPoint());
|
|
midLine.SetPoints(mLn.startPoint(),mLn.endPoint());
|
|
|
|
midLine.SetElevation(ptLoc.z);
|
|
if (!(GetRoofHeight()-GetMountHeight()<_DIST_SNAP
|
|
||fabs(cos(GetSlopeAngle2()))<1E-3)) //四坡,歇山,攒尖
|
|
{
|
|
if (midLine.GetLength()>_DIST_SNAP) //四坡,歇山
|
|
{
|
|
gripPoints.append(midLine.StartPoint()); //脊线长
|
|
gripPoints.append(midLine.EndPoint()); //脊线长
|
|
}
|
|
}
|
|
}
|
|
else if (m_nRoofStyle == kCuspRoof)
|
|
{
|
|
gripPoints.append(m_ptCenter);
|
|
ads_point ptFirst;
|
|
ads_polar(asDblArray(m_ptCenter),m_dRotation,m_dRadius,ptFirst);
|
|
gripPoints.append(asPnt3d(ptFirst));
|
|
|
|
ads_polar(asDblArray(m_ptCenter),m_dRotation+PI/m_nSideNum,m_dRadius*cos(PI/m_nSideNum)+m_dEavesLen,ptFirst);
|
|
gripPoints.append(asPnt3d(ptFirst));
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::subMoveGripPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (m_nRoofStyle == kDualRoof)
|
|
{
|
|
AcDbIntArray indices2;
|
|
for(long i=0;i<indices.length();i++)
|
|
{
|
|
int iGrip=indices[i]-((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline.Length()*2;
|
|
if(iGrip>=0)
|
|
{
|
|
if(iGrip==0)
|
|
m_ptRidge1+=offset;
|
|
else if(iGrip==1)
|
|
m_ptRidge2+=offset;
|
|
else
|
|
{
|
|
m_ptRidge1+=offset;
|
|
m_ptRidge2+=offset;
|
|
}
|
|
}
|
|
else
|
|
indices2.append(indices[i]);
|
|
}
|
|
|
|
AcGeVector3d offset1=offset;
|
|
offset1.z=0;
|
|
}
|
|
|
|
//RoofBase
|
|
XVector3D vtNormal;
|
|
XPoly2D polyPath;
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->GetPathPoly(polyPath,vtNormal);
|
|
|
|
int nVertexCount = polyPath.Length();
|
|
if (nVertexCount > 0)
|
|
{
|
|
XPoint vtOffset=Wcs2Ecs(*(XPoint *)&offset, vtNormal);
|
|
for (int i = 0; i < indices.length(); i++) {
|
|
int idx = indices[i];
|
|
if(idx<nVertexCount) { // Move vertex
|
|
*polyPath[idx] += vtOffset;
|
|
} else { // Move Edge or Shape
|
|
XPoly2D poly2d(polyPath);
|
|
poly2d.SetElevation(0.0);
|
|
|
|
int nEdgeIndex=idx-nVertexCount;
|
|
int nTotalEdge=poly2d.TotalSegments();
|
|
if(nEdgeIndex<nTotalEdge) { //移动边
|
|
XDirectionCurve cv;
|
|
poly2d.Nth(nEdgeIndex, cv);
|
|
ASSERT(!!cv);
|
|
if(cv.Is(CURVE_LINE)) { // Move
|
|
XLine ln=cv.GetLine();
|
|
ln.StartPoint() += vtOffset;
|
|
ln.EndPoint() += vtOffset;
|
|
ln.SetLineFlag(LS_INFINITE);
|
|
XDirectionCurve prevSeg, nextSeg;
|
|
int nPrev=nEdgeIndex-1, nNext=nEdgeIndex+1;
|
|
if(poly2d.IsClosed()) {
|
|
nPrev=DePeriod(nTotalEdge, nPrev);
|
|
nNext=DePeriod(nTotalEdge, nNext);
|
|
}
|
|
|
|
XPoint ptStart, ptEnd;
|
|
BOOL bUpdateIt=TRUE;
|
|
//更新起点
|
|
if(nPrev>=0 && nPrev<nTotalEdge) {
|
|
poly2d.Nth(nPrev, prevSeg);
|
|
prevSeg.SetLineFlag(LS_INFINITE);
|
|
XPoint ptInt[2];
|
|
int nIntNum=prevSeg.Intersection(ln, ptInt[0], ptInt[1]);
|
|
if(nIntNum==1) ptStart=ptInt[0];
|
|
else if(nIntNum==2) {
|
|
ptStart=XLine(ptInt[0], ptInt[1]).NearPoint(ln.StartPoint());
|
|
} else bUpdateIt=FALSE;
|
|
} else {
|
|
ptStart = *poly2d[nEdgeIndex] + vtOffset;
|
|
}
|
|
|
|
// 更新下一点
|
|
if(nNext>=0 && nNext<nTotalEdge) {
|
|
poly2d.Nth(nNext, nextSeg);
|
|
nextSeg.SetLineFlag(LS_INFINITE);
|
|
XPoint ptInt[2];
|
|
int nIntNum=nextSeg.Intersection(ln, ptInt[0], ptInt[1]);
|
|
if(nIntNum==1) ptEnd=ptInt[0];
|
|
else if(nIntNum==2) {
|
|
ptEnd=XLine(ptInt[0], ptInt[1]).NearPoint(ln.EndPoint());
|
|
} else bUpdateIt=FALSE;
|
|
} else {
|
|
ptEnd = *poly2d[nEdgeIndex+1] + vtOffset;
|
|
}
|
|
|
|
if(bUpdateIt) {
|
|
double nPrevBulge=0.0, nNextBulge=0.0;
|
|
if(fabs(prevSeg.GetBulge())>1.0E-5) {
|
|
XArc prevArc=prevSeg.GetArc();
|
|
double nAngBeg=ads_angle(prevArc.GetCenterPt(), prevSeg.StartPoint());
|
|
double nAngEnd=ads_angle(prevArc.GetCenterPt(), ptStart);
|
|
if(prevSeg.IsMinusArc()) {
|
|
nPrevBulge=-CT_std_angle(nAngBeg-nAngEnd);
|
|
} else {
|
|
nPrevBulge=CT_std_angle(nAngEnd-nAngBeg);
|
|
}
|
|
}
|
|
if(fabs(nextSeg.GetBulge())>1.0E-5) {
|
|
XArc nextArc=nextSeg.GetArc();
|
|
double nAngBeg=ads_angle(nextArc.GetCenterPt(), ptEnd);
|
|
double nAngEnd=ads_angle(nextArc.GetCenterPt(), nextSeg.EndPoint());
|
|
if(nextSeg.IsMinusArc()) {
|
|
nNextBulge=-CT_std_angle(nAngBeg-nAngEnd);
|
|
} else {
|
|
nNextBulge=CT_std_angle(nAngEnd-nAngBeg);
|
|
}
|
|
}
|
|
|
|
*poly2d[nEdgeIndex] = ptStart;
|
|
if(nNext>=0 && nNext<poly2d.Length())
|
|
{
|
|
*poly2d[nNext] = ptEnd;
|
|
poly2d.SetBulge(nNext, nNextBulge);
|
|
}
|
|
if(nPrev>=0 && nPrev<poly2d.Length())
|
|
{
|
|
poly2d.SetBulge(nPrev, nPrevBulge);
|
|
}
|
|
|
|
}
|
|
|
|
} else { // Change Arc Segment--bulge
|
|
XPoint ptMid=cv.MidPoint();
|
|
XPoint ptMidNew= ptMid + vtOffset;
|
|
XArc arNew(cv.StartPoint(), ptMidNew, cv.EndPoint());
|
|
if(!!arNew) { //新的弧有效
|
|
XCurveSegment cvLine(cv.StartPoint(), cv.EndPoint(), 0.0);
|
|
int nSideOld=cvLine.OnWhichSide(ptMid);
|
|
int nSideNew=cvLine.OnWhichSide(ptMidNew);
|
|
double nSignal=cv.GetBulge()/fabs(cv.GetBulge());
|
|
if(nSideOld==nSideNew)
|
|
{
|
|
poly2d.SetBulge(nEdgeIndex, nSignal*arNew.Bulge());
|
|
}
|
|
else
|
|
{
|
|
poly2d.SetBulge(nEdgeIndex, -nSignal*arNew.Bulge());
|
|
}
|
|
}
|
|
}
|
|
|
|
for(int n=0; n<poly2d.Length(); n++) {
|
|
poly2d[n]->z = polyPath[n]->z;
|
|
}
|
|
polyPath = poly2d;
|
|
}
|
|
}
|
|
}
|
|
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->SetPathPoly(polyPath,vtNormal);
|
|
}
|
|
|
|
if( m_bHeightLim && m_dRoofHeight >_DIST_SNAP)
|
|
{
|
|
double angLeft(0),angRight(0);
|
|
if(CalAngle(angLeft,angRight))
|
|
{
|
|
m_dAngleLeft=angLeft;
|
|
m_dAngleRight=angRight;
|
|
}
|
|
}
|
|
|
|
if (m_nRoofStyle == kMountRoof)
|
|
{
|
|
XPoint vtOffset=*(XPoint *)&offset;
|
|
vtOffset.z = 0;
|
|
|
|
double nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-m_dRotation);
|
|
double nIncWidth=ads_distance(XPoint(), vtOffset) * cos(nVtRot);
|
|
double nIncLen=ads_distance(XPoint(), vtOffset) * sin(nVtRot);
|
|
int nLen=indices.length();
|
|
for (int i = 0; i < nLen; i++)
|
|
{
|
|
int idx = indices[i];
|
|
switch(idx) {
|
|
case 0:
|
|
if( g_bCtrlToggle1[5] ) //移动
|
|
{
|
|
m_ptLocation += vtOffset;
|
|
}
|
|
else //旋转
|
|
{
|
|
XPoint ptCenter=GetLocation();
|
|
ptCenter.z=0;
|
|
ads_polar(ptCenter,m_dRotation,0.5*GetLength(),ptCenter);
|
|
ads_polar(ptCenter,m_dRotation+PI*0.5,0.5*GetWidth(),ptCenter);
|
|
|
|
ads_matrix mat;
|
|
ptCenter.GetRotationMatrix(AcGeVector2d(offset.x,offset.y).angle(),mat);
|
|
subTransformBy(AsAcGeMatrix3d(mat));
|
|
}
|
|
break;
|
|
case 1: //拉伸
|
|
{
|
|
if (GetRoofHeight()-GetMountHeight()<_DIST_SNAP
|
|
||fabs(cos(GetSlopeAngle2()))<1E-3) //人字坡
|
|
{
|
|
if(((m_dLength-nIncWidth)>_DIST_SNAP) //脊线长度>0
|
|
&&(m_dWidth-nIncLen)>_DIST_SNAP)
|
|
{
|
|
m_ptLocation += vtOffset;
|
|
m_dLength -= nIncWidth;
|
|
m_dWidth -= nIncLen;
|
|
}
|
|
}
|
|
else //四坡,歇山,攒尖
|
|
{
|
|
if (GetTopLength()<_DIST_SNAP //攒尖
|
|
&&m_dLength-nIncWidth>_DIST_SNAP
|
|
&&m_dWidth-nIncLen>_DIST_SNAP
|
|
)
|
|
{
|
|
m_ptLocation += vtOffset;
|
|
m_dLength -= nIncWidth;
|
|
m_dWidth -= nIncLen;
|
|
m_dSlopeAngle2=atan(GetRoofHeight()*2/GetLength());
|
|
}
|
|
else if((((m_dLength-nIncWidth)*0.5)>(m_dRoofHeight-m_dMountHeight)/tan(GetSlopeAngle2())) //脊线长度>0
|
|
&&(m_dWidth-nIncLen)>_DIST_SNAP)
|
|
{
|
|
m_ptLocation += vtOffset;
|
|
m_dLength -= nIncWidth;
|
|
m_dWidth -= nIncLen;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 2: //拉伸
|
|
{
|
|
if (GetRoofHeight()-GetMountHeight()<_DIST_SNAP
|
|
||fabs(cos(GetSlopeAngle2()))<1E-3) //人字坡
|
|
{
|
|
if(((m_dLength+nIncWidth)>_DIST_SNAP) //脊线长度>0
|
|
&&(m_dWidth-nIncLen)>_DIST_SNAP)
|
|
{
|
|
ads_polar(asDblArray(m_ptLocation),m_dRotation+PI*0.5,nIncLen,asDblArray(m_ptLocation));
|
|
m_dLength += nIncWidth;
|
|
m_dWidth -= nIncLen;
|
|
}
|
|
}
|
|
else //四坡,歇山,攒尖
|
|
{
|
|
if (GetTopLength()<_DIST_SNAP //攒尖
|
|
&&m_dLength+nIncWidth>_DIST_SNAP
|
|
&&m_dWidth-nIncLen>_DIST_SNAP)
|
|
{
|
|
ads_polar(asDblArray(m_ptLocation),m_dRotation+PI*0.5,nIncLen,asDblArray(m_ptLocation));
|
|
m_dLength += nIncWidth;
|
|
m_dWidth -= nIncLen;
|
|
m_dSlopeAngle2=atan(GetRoofHeight()*2/GetLength());
|
|
}
|
|
else if((((m_dLength+nIncWidth)*0.5)>(m_dRoofHeight-m_dMountHeight)/tan(GetSlopeAngle2())) //脊线长度>0
|
|
&&(m_dWidth-nIncLen)>_DIST_SNAP)
|
|
{
|
|
ads_polar(asDblArray(m_ptLocation),m_dRotation+PI*0.5,nIncLen,asDblArray(m_ptLocation));
|
|
m_dLength += nIncWidth;
|
|
m_dWidth -= nIncLen;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 3: //拉伸
|
|
{
|
|
if (GetRoofHeight()-GetMountHeight()<_DIST_SNAP
|
|
||fabs(cos(GetSlopeAngle2()))<1E-3) //人字坡
|
|
{
|
|
if(((m_dLength+nIncWidth)>_DIST_SNAP) //脊线长度>0
|
|
&&(m_dWidth+nIncLen)>_DIST_SNAP)
|
|
{
|
|
m_dLength += nIncWidth;
|
|
m_dWidth += nIncLen;
|
|
}
|
|
}
|
|
else //四坡,歇山,攒尖
|
|
{
|
|
if (GetTopLength()<_DIST_SNAP //攒尖
|
|
&&m_dLength+nIncWidth>_DIST_SNAP
|
|
&&m_dWidth+nIncLen>_DIST_SNAP
|
|
)
|
|
{
|
|
m_dLength += nIncWidth;
|
|
m_dWidth += nIncLen;
|
|
m_dSlopeAngle2=atan(GetRoofHeight()*2/GetLength());
|
|
}
|
|
else if((((m_dLength+nIncWidth)*0.5)>(m_dRoofHeight-m_dMountHeight)/tan(GetSlopeAngle2())) //脊线长度>0
|
|
&&(m_dWidth+nIncLen)>_DIST_SNAP)
|
|
{
|
|
m_dLength += nIncWidth;
|
|
m_dWidth += nIncLen;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 4: //拉伸
|
|
{
|
|
if (GetRoofHeight()-GetMountHeight()<_DIST_SNAP
|
|
||fabs(cos(GetSlopeAngle2()))<1E-3) //人字坡
|
|
{
|
|
if(((m_dLength-nIncWidth)>_DIST_SNAP) //脊线长度>0
|
|
&&(m_dWidth+nIncLen)>_DIST_SNAP)
|
|
{
|
|
ads_polar(asDblArray(m_ptLocation),m_dRotation,nIncWidth,asDblArray(m_ptLocation));
|
|
m_dLength -= nIncWidth;
|
|
m_dWidth += nIncLen;
|
|
}
|
|
}
|
|
else //四坡,歇山,攒尖
|
|
{
|
|
if (GetTopLength()<_DIST_SNAP //攒尖
|
|
&&m_dLength-nIncWidth>_DIST_SNAP
|
|
&&m_dWidth+nIncLen>_DIST_SNAP
|
|
)
|
|
{
|
|
ads_polar(asDblArray(m_ptLocation),m_dRotation,nIncWidth,asDblArray(m_ptLocation));
|
|
m_dLength -= nIncWidth;
|
|
m_dWidth += nIncLen;
|
|
m_dSlopeAngle2=atan(GetRoofHeight()*2/GetLength());
|
|
}
|
|
else if((((m_dLength-nIncWidth)*0.5)>(m_dRoofHeight-m_dMountHeight)/tan(GetSlopeAngle2())) //脊线长度>0
|
|
&&(m_dWidth+nIncLen)>_DIST_SNAP)
|
|
{
|
|
ads_polar(asDblArray(m_ptLocation),m_dRotation,nIncWidth,asDblArray(m_ptLocation));
|
|
m_dLength -= nIncWidth;
|
|
m_dWidth += nIncLen;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 5: //调整出檐长
|
|
case 6:
|
|
{
|
|
double dIncLen=nIncLen;
|
|
if(idx==6)
|
|
dIncLen=-nIncLen;
|
|
|
|
if(m_dEavesLen-dIncLen>_DIST_SNAP)
|
|
{
|
|
m_dEavesLen -= dIncLen;
|
|
}
|
|
else
|
|
{
|
|
m_dEavesLen = 0;
|
|
}
|
|
}
|
|
break;
|
|
case 7: //调整出山长
|
|
case 8:
|
|
{
|
|
double dIncWidth=nIncWidth;
|
|
if(idx==8)
|
|
dIncWidth=-nIncWidth;
|
|
if (GetRoofHeight()-GetMountHeight()<_DIST_SNAP
|
|
||fabs(cos(GetSlopeAngle2()))<1E-3) //人字坡
|
|
{
|
|
if(m_dMountLen-dIncWidth>_DIST_SNAP)
|
|
{
|
|
m_dMountLen -= dIncWidth;
|
|
}
|
|
else if(m_dMountLen-dIncWidth<-_DIST_SNAP&&m_dMountLen-dIncWidth>-GetLength()*0.5-_DIST_SNAP)//可能改变为歇山或四坡或攒尖屋顶
|
|
{
|
|
if (GetRoofHeight()-GetMountHeight()<_DIST_SNAP)//仍为人字坡
|
|
{
|
|
m_dMountLen = 0;
|
|
}
|
|
else if (fabs(cos(GetSlopeAngle2()))<1E-3)
|
|
{
|
|
if ( (fabs(m_dMountLen-dIncWidth)<_DIST_SNAP&&GetMountHeight()<_DIST_SNAP) //变为攒尖屋顶
|
|
||(fabs(m_dMountLen-dIncWidth)>_DIST_SNAP ) ) //变为四坡或歇山屋顶)
|
|
{
|
|
m_dSlopeAngle2=atan((GetRoofHeight()-GetMountHeight())*2/fabs(m_dMountLen-dIncWidth));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_dMountLen = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
double dLen=dIncWidth*tan(GetSlopeAngle2())/tan(GetSlopeAngle1());
|
|
|
|
if(m_dEavesLen-dLen>_DIST_SNAP)
|
|
{
|
|
m_dEavesLen -= dLen;
|
|
}
|
|
else
|
|
{
|
|
m_dEavesLen = 0;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 9:
|
|
case 10:
|
|
{
|
|
double dIncWidth=nIncWidth;
|
|
if (idx==10)
|
|
{
|
|
dIncWidth=-nIncWidth;
|
|
}
|
|
if (!(GetRoofHeight()-GetMountHeight()<_DIST_SNAP
|
|
||fabs(cos(GetSlopeAngle2()))<1E-3)) //四坡,歇山,攒尖
|
|
{
|
|
XLine leftLine, rightLine, midLine;
|
|
AcGeLineSeg3d lLn,rLn,mLn;
|
|
GetMountLine(lLn,rLn,mLn);
|
|
leftLine.SetPoints(lLn.startPoint(),lLn.endPoint());
|
|
rightLine.SetPoints(rLn.startPoint(),rLn.endPoint());
|
|
midLine.SetPoints(mLn.startPoint(),mLn.endPoint());
|
|
|
|
midLine.SetElevation(0);
|
|
if (GetMountHeight()<_DIST_SNAP) //四坡
|
|
{
|
|
if (midLine.GetLength()-dIncWidth*2<_DIST_SNAP)//变为攒尖屋顶
|
|
{
|
|
m_dSlopeAngle2=atan(GetRoofHeight()*2/GetLength());
|
|
}
|
|
else if(midLine.GetLength()-dIncWidth*2>GetLength()-_DIST_SNAP)//变为人字屋顶
|
|
{
|
|
m_dSlopeAngle2=PI*0.5;
|
|
m_dMountLen=0;
|
|
}
|
|
else
|
|
{
|
|
m_dSlopeAngle2=atan(GetRoofHeight()/(0.5*GetLength()-midLine.GetLength()*0.5+dIncWidth));
|
|
}
|
|
}
|
|
else //歇山
|
|
{
|
|
if (midLine.GetLength()-dIncWidth*2<_DIST_SNAP)//歇山屋顶脊线长为0时不能直接变为攒尖屋顶
|
|
{
|
|
//m_nSlopeAngle2=atan(GetRoofHeight()*2/GetLength());
|
|
}
|
|
else if(midLine.GetLength()-dIncWidth*2>GetLength()-_DIST_SNAP)//变为人字屋顶
|
|
{
|
|
m_dSlopeAngle2=PI*0.5;
|
|
m_dMountLen=0;
|
|
}
|
|
else
|
|
{
|
|
m_dSlopeAngle2=atan((GetRoofHeight()-GetMountHeight())/(0.5*GetLength()-midLine.GetLength()*0.5+dIncWidth));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else if (m_nRoofStyle == kCuspRoof)
|
|
{
|
|
for(long i=0;i<indices.length();i++)
|
|
{
|
|
int iGrip=indices[i];
|
|
if(iGrip==0)
|
|
m_ptCenter+=offset;
|
|
else if(iGrip==1)
|
|
{
|
|
AcGeVector2d vt0(m_dRadius*cos(m_dRotation),m_dRadius*sin(m_dRotation));
|
|
AcGeVector2d vt=vt0+AcGeVector2d(offset.x,offset.y);
|
|
m_dRadius=vt.length();
|
|
m_dRotation=vt.angle();
|
|
}
|
|
else
|
|
{
|
|
XPoint vtOffset=*(XPoint *)&offset;
|
|
vtOffset.z = 0;
|
|
double nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-(m_dRotation+PI/m_nSideNum));
|
|
double nIncWidth=ads_distance(XPoint(), vtOffset) * cos(nVtRot);
|
|
|
|
if(m_dEavesLen+nIncWidth>_DIST_SNAP)
|
|
{
|
|
m_dEavesLen+=nIncWidth;
|
|
}
|
|
else if(fabs(m_dEavesLen+nIncWidth)<_DIST_SNAP)
|
|
{
|
|
m_dEavesLen = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGeVector3d vtNormal;
|
|
XPoly2D polyPath;
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->GetPathPoly(polyPath,vtNormal);
|
|
|
|
int nVertexCount=polyPath.Length();
|
|
if (nVertexCount > 0)
|
|
{
|
|
for(int i=0; i<nVertexCount; i++) {
|
|
XPoint ptWcs=Ecs2Wcs(*polyPath[i], vtNormal);
|
|
stretchPoints.append(ptWcs);
|
|
}
|
|
}
|
|
|
|
if (m_nRoofStyle == kMountRoof)
|
|
{
|
|
XPoint ptLoc = GetLocation();
|
|
ptLoc.z=0;
|
|
|
|
XPoint ptCenter;
|
|
ads_polar(ptLoc,m_dRotation,0.5*GetLength(),ptCenter);
|
|
ads_polar(ptCenter,m_dRotation+PI*0.5,0.5*GetWidth(),ptCenter);
|
|
stretchPoints.append(ptCenter);
|
|
|
|
XPoint ptFirst;
|
|
ads_polar(ptLoc,m_dRotation,GetLength()*0.5,ptFirst);
|
|
ads_polar(ptFirst,m_dRotation-PI*0.5,GetEavesLen(),ptFirst);
|
|
stretchPoints.append(ptFirst); //出檐长
|
|
ads_polar(ptFirst,m_dRotation+PI*0.5,GetWidth()+GetEavesLen()*2,ptFirst);
|
|
stretchPoints.append(ptFirst); //出檐长
|
|
|
|
ads_polar(ptLoc,m_dRotation+PI*0.5,GetWidth()*0.5,ptFirst);
|
|
ads_polar(ptFirst,m_dRotation+PI,GetMountLen(),ptFirst);
|
|
stretchPoints.append(ptFirst); //出山长
|
|
ads_polar(ptFirst,m_dRotation,GetLength()+GetMountLen()*2,ptFirst);
|
|
stretchPoints.append(ptFirst); //出山长
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::subMoveStretchPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcGeVector3d vtNormal;
|
|
XPoly2D polyPath;
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->GetPathPoly(polyPath,vtNormal);
|
|
|
|
int nVertexCount = polyPath.Length();
|
|
if (nVertexCount > 0)
|
|
{
|
|
XPoint vtOffset=Wcs2Ecs(*(XPoint *)&offset, vtNormal);
|
|
for (int i = 0; i < indices.length(); i++) {
|
|
int idx = indices[i];
|
|
if(idx<nVertexCount) // Move vertex
|
|
*polyPath[idx] += vtOffset;
|
|
}
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->SetPathPoly(polyPath,vtNormal);
|
|
}
|
|
|
|
if (m_nRoofStyle == kMountRoof)
|
|
{
|
|
XPoint vtOffset=*(XPoint *)&offset;
|
|
vtOffset.z = 0;
|
|
|
|
double nVtRot=CT_std_angle(ads_angle(XPoint(), vtOffset)-m_dRotation);
|
|
double nIncWidth=ads_distance(XPoint(), vtOffset) * cos(nVtRot);
|
|
double nIncLen=ads_distance(XPoint(), vtOffset) * sin(nVtRot);
|
|
|
|
int nLen=indices.length();
|
|
if(nLen>1)
|
|
{
|
|
m_ptLocation += vtOffset;
|
|
}
|
|
else if(nLen==1)
|
|
{
|
|
int idx=indices[0];
|
|
switch(idx)
|
|
{
|
|
case 1:
|
|
{
|
|
if(m_dWidth-nIncLen>_DIST_SNAP)
|
|
{
|
|
m_dWidth -= nIncLen;
|
|
ads_polar(asDblArray(m_ptLocation),m_dRotation+PI*0.5,nIncLen,asDblArray(m_ptLocation));
|
|
}
|
|
}
|
|
break;
|
|
case 2:
|
|
{
|
|
if(m_dWidth+nIncLen>_DIST_SNAP)
|
|
{
|
|
m_dWidth += nIncLen;
|
|
}
|
|
}
|
|
break;
|
|
case 3:
|
|
{
|
|
if(m_dLength-nIncWidth>_DIST_SNAP)
|
|
{
|
|
if ( GetRoofHeight()-GetMountHeight()<_DIST_SNAP
|
|
||fabs(cos(GetSlopeAngle2()))<1E-3) //人字坡
|
|
{
|
|
m_dLength -= nIncWidth;
|
|
ads_polar(asDblArray(m_ptLocation),m_dRotation,nIncWidth,asDblArray(m_ptLocation));
|
|
}
|
|
else //四坡,歇山,攒尖
|
|
{
|
|
if (GetTopLength()<_DIST_SNAP) //攒尖
|
|
{
|
|
m_dLength -= nIncWidth;
|
|
m_dSlopeAngle2=atan(GetRoofHeight()*2/GetLength());
|
|
ads_polar(asDblArray(m_ptLocation),m_dRotation,nIncWidth,asDblArray(m_ptLocation));
|
|
}
|
|
else if((((m_dLength-nIncWidth)*0.5)>(m_dRoofHeight-m_dMountHeight)/tan(GetSlopeAngle2())) //脊线长度>0
|
|
)
|
|
{
|
|
m_dLength -= nIncWidth;
|
|
ads_polar(asDblArray(m_ptLocation),m_dRotation,nIncWidth,asDblArray(m_ptLocation));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 4:
|
|
if(m_dLength+nIncWidth>_DIST_SNAP)
|
|
{
|
|
if (GetRoofHeight()-GetMountHeight()<_DIST_SNAP
|
|
||fabs(cos(GetSlopeAngle2()))<1E-3) //人字坡
|
|
{
|
|
m_dLength += nIncWidth;
|
|
}
|
|
else //四坡,歇山,攒尖
|
|
{
|
|
if (GetTopLength()<_DIST_SNAP) //攒尖
|
|
{
|
|
m_dLength += nIncWidth;
|
|
m_dSlopeAngle2=atan(GetRoofHeight()*2/GetLength());
|
|
}
|
|
else if((((m_dLength+nIncWidth)*0.5)>(m_dRoofHeight-m_dMountHeight)/tan(GetSlopeAngle2()))) //脊线长度>0
|
|
{
|
|
m_dLength += nIncWidth;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
m_ptLocation += vtOffset;
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::subGetOsnapPoints(AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& ptPick,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
assertReadEnabled();
|
|
if(osnapMode==AcDb::kOsModeNode) {
|
|
XPoly2D polyPath;
|
|
AcGeVector3d normal;
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->GetPathPoly(polyPath,normal);
|
|
for(int i=0; i<polyPath.Length(); i++) {
|
|
snapPoints.append(Ecs2Wcs(*polyPath[i], normal));
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//[out]左坡角(弧度) 右坡角(弧度)
|
|
BOOL AecDbXRoof::CalAngle(double &angLeft,double &angRight)
|
|
{
|
|
BOOL bRet=FALSE;
|
|
XLine xLine( asDblArray(GetRidgeStart()), asDblArray(GetRidgeEnd()));
|
|
xLine.SetElevation(0);
|
|
|
|
XPoly2D poly;
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->GetPolyPath(poly);
|
|
poly.SetElevation(0);
|
|
|
|
XPoint pt;
|
|
double dLowLeft = 0.0,dLowRight = 0.0; //到屋脊线的水平距离
|
|
for (long i = 0;i < poly.Length();i++) //距脊线的最远点
|
|
{
|
|
pt = *poly[i];
|
|
int nSide=xLine.OnWhichSide(pt);
|
|
double dTemp;
|
|
if (nSide==0) //左侧
|
|
{
|
|
dTemp = pt.Distance(&xLine);
|
|
if (dLowLeft < dTemp)
|
|
{
|
|
dLowLeft = dTemp;
|
|
}
|
|
}
|
|
else if(nSide==1) //右侧
|
|
{
|
|
dTemp = pt.Distance(&xLine);
|
|
if (dLowRight < dTemp)
|
|
{
|
|
dLowRight = dTemp;
|
|
}
|
|
}
|
|
}
|
|
if (fabs(dLowLeft-0.0) <= 1E-6
|
|
&&fabs(dLowRight-0.0) <= 1E-6) //没有左右坡
|
|
{
|
|
return bRet;
|
|
}
|
|
if (fabs(dLowLeft-0.0) <= 1E-6) //没有左坡
|
|
{
|
|
double dTempLow = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp = pt.Distance(&xLine);
|
|
if (fabs(dTempLow-0.0) <= 1E-6)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
else if (dTempLow > dTemp)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
}
|
|
dLowRight = dLowRight - dTempLow;
|
|
if(dLowRight>_DIST_SNAP)
|
|
{
|
|
angLeft=angRight=atan(GetRoofHeight() / dLowRight);
|
|
bRet = TRUE;
|
|
}
|
|
}
|
|
else if(fabs(dLowRight-0.0) <= 1E-6) //没有右坡
|
|
{
|
|
double dTempLow = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp = pt.Distance(&xLine);
|
|
if (fabs(dTempLow-0.0) <= 1E-6)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
else if (dTempLow > dTemp)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
}
|
|
dLowLeft = dLowLeft - dTempLow;
|
|
if(dLowLeft>_DIST_SNAP)
|
|
{
|
|
angLeft=angRight=atan(GetRoofHeight() / dLowLeft);
|
|
bRet = TRUE;
|
|
}
|
|
}
|
|
else //左右坡都有
|
|
{
|
|
angLeft=atan(GetRoofHeight() / dLowLeft);
|
|
angRight=atan(GetRoofHeight() / dLowRight);
|
|
bRet = TRUE;
|
|
}
|
|
return bRet;
|
|
}
|
|
|
|
void AecDbXRoof::CalAngle(ads_name entPl,ads_point ptFirst,ads_point ptSecond,double &dLeftAng,double &dRightAng,double dHeight)
|
|
{
|
|
XPoly2D poly(entPl);
|
|
XLine xLine(ptFirst,ptSecond);
|
|
xLine.SetElevation(0);
|
|
poly.SetElevation(0);
|
|
|
|
XPoint pt;
|
|
double dLowLeft = 0.0,dLowRight = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
if (!xLine.OnWhichSide(pt))
|
|
{
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dLowLeft-0.0) <= 1E-6)
|
|
{
|
|
dLowLeft = dTemp;
|
|
}
|
|
else if (dLowLeft < dTemp)
|
|
{
|
|
dLowLeft = dTemp;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dLowRight-0.0) <= 1E-6)
|
|
{
|
|
dLowRight = dTemp;
|
|
}
|
|
else if (dLowRight < dTemp)
|
|
{
|
|
dLowRight = dTemp;
|
|
}
|
|
}
|
|
}
|
|
if (fabs(dLowLeft-0.0) <= 1E-6)
|
|
{
|
|
double dTempLow = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dTempLow-0.0) <= 1E-6)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
else if (dTempLow > dTemp)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
}
|
|
dLowRight = dLowRight - dTempLow;
|
|
{
|
|
double dTemp = dHeight / dLowRight;
|
|
dTemp = atan(dTemp);
|
|
dLeftAng = dRightAng = (dTemp * 180.0) / PI;
|
|
}
|
|
}
|
|
else if (fabs(dLowRight-0.0) <= 1E-6)
|
|
{
|
|
double dTempLow = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dTempLow-0.0) <= 1E-6)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
else if (dTempLow > dTemp)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
}
|
|
dLowLeft = dLowLeft - dTempLow;
|
|
{
|
|
double dTemp = dHeight/ dLowLeft;
|
|
dTemp = atan(dTemp);
|
|
dRightAng = dLeftAng = (dTemp * 180.0) / PI;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
double dTemp;
|
|
{
|
|
dTemp = dHeight / dLowLeft;
|
|
dTemp = atan(dTemp);
|
|
dLeftAng = (dTemp * 180.0) / PI;
|
|
}
|
|
{
|
|
dTemp = dHeight / dLowRight;
|
|
dTemp = atan(dTemp);
|
|
dRightAng = (dTemp * 180.0) / PI;
|
|
}
|
|
}
|
|
}
|
|
|
|
//2D
|
|
Acad::ErrorStatus AecDbXRoof::DrawSlopeRoof2d(AcGiDraw &dc) const
|
|
{
|
|
const XPoly2D& pl = ((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline;
|
|
if (pl.Length() == 0)
|
|
{
|
|
acutPrintf(_T("屋顶多义线没有设置!"));
|
|
return Acad::eOk;
|
|
}
|
|
|
|
XDraw xDc;
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->GetGeometry2d(xDc, TRUE);
|
|
|
|
AcDbVoidPtrArray arEntPtrs;
|
|
xDc.GetDraw(arEntPtrs);
|
|
|
|
AcDbObjectId idLayOld = dc.GetLayerId();
|
|
AcDbObjectId idLay = layerId();
|
|
dc.SetLayer(idLay);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arEntPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arEntPtrs.at(i);
|
|
pEnt->setLayer(idLay);
|
|
dc.DrawEntity(pEnt);
|
|
Add2DBuffer(pEnt);
|
|
}
|
|
dc.SetLayer(idLayOld);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::DrawDualRoof2d(AcGiDraw &dc) const
|
|
{
|
|
AcDbObjectId idLayOld = dc.GetLayerId();
|
|
AcDbObjectId idLay = layerId();
|
|
dc.SetLayer(idLay);
|
|
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
XPoly2D poly= ((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline;
|
|
|
|
const XPoly2D& pl = ((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline;
|
|
if (pl.Length() == 0)
|
|
{
|
|
acutPrintf(_T("屋顶多义线没有设置!"));
|
|
return Acad::eOk;
|
|
}
|
|
poly.SetElevation(0);
|
|
|
|
DList<XCurveSegment> lstLnDraw,lstIn,lstOut;
|
|
|
|
XLine line( asDblArray(m_ptRidge1),asDblArray(m_ptRidge2));
|
|
line.SetElevation(0);
|
|
AcDbLine acLine(line.StartPoint(),line.EndPoint());
|
|
AcDbCurve* pCurveOutline=poly.AsAcDbCurve();
|
|
AcGePoint3dArray pts;
|
|
pCurveOutline->intersectWith(&acLine,AcDb::kExtendArg,pts);
|
|
delete pCurveOutline;
|
|
if(pts.length()>1)
|
|
{
|
|
XPoint ptR1=m_ptRidge1;
|
|
XPoint ptR2=m_ptRidge2;
|
|
ptR1.z=ptR2.z=0;
|
|
XPoint vt=ptR2-ptR1;
|
|
vt.Normalize();
|
|
vt.Scale(_AS_SYS_UNIT(1E7));
|
|
PointList ptList(ptR1-vt,ptR2+vt);
|
|
for(long i=0;i<pts.length();i++)
|
|
ptList.Insert(pts[i]);
|
|
|
|
if(ptList.Length()>3)
|
|
{
|
|
line.StartPoint()=*ptList[1];
|
|
line.EndPoint()=*ptList[ptList.Length()-2];
|
|
line.SetElevation(0);
|
|
|
|
XCurveSegment* pXCurSeg = new XCurveSegment;
|
|
*pXCurSeg = line;
|
|
lstLnDraw.Append(pXCurSeg);
|
|
}
|
|
}
|
|
|
|
PolyClip(lstLnDraw,poly,lstIn,lstOut);
|
|
|
|
AcDbCurve* pPl = poly.AsAcDbCurve();
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setLayer(idLay);
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
|
|
for (int i = 0;i < lstIn.Length();i++)
|
|
{
|
|
XCurveSegment* pLn = lstIn.GetAt(i);
|
|
AcDbCurve* pCrv = pLn->AsAcDbCurve();
|
|
if (pCrv != NULL)
|
|
{
|
|
pCrv->setLayer(idLay);
|
|
dc.DrawEntity(pCrv);
|
|
Add2DBuffer(pCrv);
|
|
}
|
|
}
|
|
dc.SetLayer(idLayOld);
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::DrawMountRoof2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if(GetLength()<_DIST_SNAP ||
|
|
GetWidth()<_DIST_SNAP)
|
|
return Acad::eOk;
|
|
|
|
AcDbObjectId idLayOld = dc.GetLayerId();
|
|
AcDbObjectId idLay = layerId();
|
|
dc.SetLayer(idLay);
|
|
|
|
XDraw xDc;
|
|
XPoly2D poly;
|
|
|
|
AcDbPolyline* pPl = NULL;
|
|
GetPolyPath(pPl);
|
|
if (pPl != NULL)
|
|
{
|
|
poly.SetAcDbCurve(pPl);
|
|
}
|
|
poly.SetElevation(0);
|
|
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setLayer(idLay);
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
|
|
XLine leftLine, rightLine, midLine;
|
|
|
|
AcGeLineSeg3d lLn,rLn,mLn;
|
|
GetMountLine(lLn,rLn,mLn);
|
|
leftLine.SetPoints(lLn.startPoint(),lLn.endPoint());
|
|
rightLine.SetPoints(rLn.startPoint(),rLn.endPoint());
|
|
midLine.SetPoints(mLn.startPoint(),mLn.endPoint());
|
|
|
|
midLine.SetElevation(0);
|
|
if(midLine.GetLength()>_DIST_SNAP)
|
|
xDc.DrawLine(midLine);
|
|
|
|
if (GetRoofHeight()-GetMountHeight()<_DIST_SNAP
|
|
||fabs(cos(GetSlopeAngle2()))<1E-3) //人字屋顶
|
|
{
|
|
|
|
}
|
|
else if (GetMountHeight()<_DIST_SNAP) //四坡屋顶或攒尖屋顶
|
|
{
|
|
if(poly.Length()==4)
|
|
{
|
|
xDc.DrawLine(XLine(midLine.StartPoint(),*poly[0]));
|
|
xDc.DrawLine(XLine(midLine.EndPoint(),*poly[1]));
|
|
xDc.DrawLine(XLine(midLine.EndPoint(),*poly[2]));
|
|
xDc.DrawLine(XLine(midLine.StartPoint(),*poly[3]));
|
|
}
|
|
}
|
|
else //歇山屋顶
|
|
{
|
|
leftLine.SetElevation(0);
|
|
if(leftLine.GetLength()>_DIST_SNAP)
|
|
xDc.DrawLine(XLine(leftLine.StartPoint(),leftLine.EndPoint()));
|
|
rightLine.SetElevation(0);
|
|
if(rightLine.GetLength()>_DIST_SNAP)
|
|
xDc.DrawLine(rightLine);
|
|
if(poly.Length()==4)
|
|
{
|
|
xDc.DrawLine(XLine(leftLine.StartPoint(),*poly[0]));
|
|
xDc.DrawLine(XLine(leftLine.EndPoint(),*poly[3]));
|
|
xDc.DrawLine(XLine(rightLine.StartPoint(),*poly[1]));
|
|
xDc.DrawLine(XLine(rightLine.EndPoint(),*poly[2]));
|
|
}
|
|
}
|
|
|
|
AcDbVoidPtrArray arEntPtrs;
|
|
xDc.GetDraw(arEntPtrs);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arEntPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arEntPtrs.at(i);
|
|
pEnt->setLayer(idLay);
|
|
dc.DrawEntity(pEnt);
|
|
Add2DBuffer(pEnt);
|
|
}
|
|
dc.SetLayer(idLayOld);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::DrawCuspRoof2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbObjectId idLayOld = dc.GetLayerId();
|
|
AcDbObjectId idLay = layerId();
|
|
dc.SetLayer(idLay);
|
|
|
|
XDraw xDc;
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
XPoly2D poly;
|
|
AcDbPolyline* pPl = NULL;
|
|
GetPolyPath(pPl);
|
|
if (pPl != NULL)
|
|
{
|
|
poly.SetAcDbCurve(pPl);
|
|
}
|
|
poly.SetElevation(0);
|
|
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setLayer(idLay);
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
|
|
for(long i=0;i<poly.Length();i++)
|
|
{
|
|
XPoint ptCenter=m_ptCenter;
|
|
ptCenter.z=0;
|
|
xDc.DrawLine(XLine(ptCenter,*poly[i]));
|
|
}
|
|
|
|
AcDbVoidPtrArray arEntPtrs;
|
|
xDc.GetDraw(arEntPtrs);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arEntPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arEntPtrs.at(i);
|
|
pEnt->setLayer(idLay);
|
|
dc.DrawEntity(pEnt);
|
|
Add2DBuffer(pEnt);
|
|
}
|
|
dc.SetLayer(idLayOld);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//此两个函数待定有AcDbX3dSolid转换
|
|
extern AcDb3dSolid* FaceToSolid(AcDbFace* pFace, std::vector<AcDbX3dSolid*> *pSos = NULL);
|
|
AcDb3dSolid* SubDMeshToSolid(AcDbSubDMesh* pSDMesh
|
|
, std::vector<AcDbX3dSolid*> *pSos = NULL)
|
|
{
|
|
double dthick(5.0);
|
|
AcDb3dSolid* pSolid = NULL;
|
|
if (pSDMesh != NULL)
|
|
{
|
|
AcDbSurface* pSurface = NULL;
|
|
pSDMesh->convertToSurface(false,false,pSurface);
|
|
if (pSurface != NULL)
|
|
{
|
|
pSurface->thicken(dthick, false, pSolid);
|
|
|
|
if (pSos)
|
|
{
|
|
AcArray<AcDbEntity*> regs;
|
|
pSurface->convertToRegion(regs);
|
|
if (!regs.isEmpty())
|
|
{
|
|
// 只取第一个
|
|
for (int i(0); i < regs.length(); ++i)
|
|
{
|
|
AcDbRegion *pReg = AcDbRegion::cast(regs[i]->clone());
|
|
if (pReg)
|
|
{
|
|
double d;
|
|
AcGePlane pln;
|
|
AcGePoint3d pt;
|
|
AcGeVector3d vt;
|
|
pReg->getNormal(vt);
|
|
CoreTools::getRegionInfo(pReg, pt, d, pln);
|
|
vt.normalize();
|
|
vt *= dthick;
|
|
AcDbX3dSolid *pSo = new AcDbX3dSolid();
|
|
pSo->CreateExtrude(pReg, AcDbLine(pt, pt + vt));
|
|
pSos->push_back(pSo);
|
|
DELETE_PTR(pReg);
|
|
}
|
|
}
|
|
deleteContainerOfArx<AcDbEntity>(regs);
|
|
}
|
|
}
|
|
|
|
delete pSurface;
|
|
}
|
|
}
|
|
return pSolid;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::DrawEntsToSolid(AcGiDraw* pDC,AcDbVoidPtrArray* pGetFaces,AcDbVoidPtrArray& arEntPtrs) const
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDb3dSolid* pSolid = NULL;
|
|
for (int i = 0;i < arEntPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arEntPtrs.at(i);
|
|
|
|
//Face,SubMesh To Solid !!!
|
|
AcDbFace* pFace = AcDbFace::cast(pEnt);
|
|
if (pFace != NULL)
|
|
{
|
|
pSolid = FaceToSolid(pFace, &m_solids);
|
|
if (pSolid != NULL && pDC != NULL)
|
|
{
|
|
pSolid->setTransparency(transparency());
|
|
pDC->DrawEntity(pSolid);
|
|
Add3DBuffer(pSolid);
|
|
}
|
|
|
|
//ASSERT(pDC != NULL && pGetFaces != NULL);
|
|
if (pGetFaces != NULL)
|
|
{
|
|
pGetFaces->append(pFace);
|
|
pEnt = NULL;
|
|
}
|
|
}
|
|
|
|
AcDbSubDMesh* pSDMesh = AcDbSubDMesh::cast(pEnt);
|
|
if (pSDMesh != NULL)
|
|
{
|
|
pSolid = SubDMeshToSolid(pSDMesh, &m_solids);
|
|
if (pSolid != NULL && pDC != NULL)
|
|
{
|
|
pSolid->setTransparency(transparency());
|
|
pDC->DrawEntity(pSolid);
|
|
Add3DBuffer(pSolid);
|
|
}
|
|
else
|
|
{
|
|
if (pSolid) delete pSolid;
|
|
pSolid = NULL;
|
|
}
|
|
|
|
if (pGetFaces != NULL)
|
|
{
|
|
pSDMesh->explode(*pGetFaces);
|
|
pEnt = NULL;
|
|
}
|
|
}
|
|
if (pEnt != NULL) delete pEnt;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//3D
|
|
Acad::ErrorStatus AecDbXRoof::DrawSlopeRoof3d(AcGiDraw* pDC,AcDbVoidPtrArray* pGetFaces) const
|
|
{
|
|
const XPoly2D& pl = ((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline;
|
|
if (pl.Length() == 0)
|
|
{
|
|
acutPrintf(_T("屋顶多义线没有设置!"));
|
|
return Acad::eOk;
|
|
}
|
|
|
|
XDraw xDc;
|
|
((TSlopeRoof*)m_SlopeRoofImpl)->GetGeometry(xDc, TRUE);
|
|
|
|
AcDbVoidPtrArray arEntPtrs;
|
|
xDc.GetDraw(arEntPtrs);
|
|
|
|
AcDbObjectId idLayOld;
|
|
AcDbObjectId idLay = layerId();
|
|
if (pDC != NULL)
|
|
{
|
|
idLayOld = pDC->GetLayerId();
|
|
pDC->SetLayer(idLay);
|
|
}
|
|
|
|
//
|
|
DrawEntsToSolid(pDC,pGetFaces,arEntPtrs);
|
|
|
|
if (pDC != NULL) pDC->SetLayer(idLayOld);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::DrawDualRoof3d(AcGiDraw* pDC,AcDbVoidPtrArray* pGetFaces) const
|
|
{
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
|
|
XDraw xdc;
|
|
XPoint vt=m_ptRidge2-m_ptRidge1;
|
|
vt.Normalize();
|
|
vt.Scale(_AS_SYS_UNIT(5E6));
|
|
|
|
XPoint ptT1 = m_ptRidge1-vt.AsAcGeVector3d();
|
|
XPoint ptT2 = m_ptRidge2+vt.AsAcGeVector3d();
|
|
XCurveSegment line(ptT1,ptT2,0);
|
|
line.SetElevation(0);
|
|
|
|
const XPoly2D& pl = ((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline;
|
|
if (pl.Length() == 0)
|
|
{
|
|
acutPrintf(_T("屋顶多义线没有设置!"));
|
|
return Acad::eOk;
|
|
}
|
|
double dEl = pl[0].z;
|
|
|
|
DList<XPoly2D> lstLeft,lstRight;
|
|
Split(lstLeft,lstRight,m_ptRidge1,m_ptRidge2,((TSlopeRoof*)m_SlopeRoofImpl)->m_polyOutline);
|
|
AcGeVector3d vtAxis=(m_ptRidge2-m_ptRidge1);
|
|
{
|
|
AcGeVector3d vt(AcGeVector3d::kZAxis);
|
|
vt.rotateBy(-m_dAngleLeft,vtAxis);
|
|
|
|
XPlane planeLeft(XPoint(m_ptRidge1.x,m_ptRidge1.y,dEl),vt);
|
|
for(long i=0;i<lstLeft.Length();i++)
|
|
{
|
|
XPoly2D* pPoly=lstLeft[i];
|
|
XPoly2D poly1=*pPoly;
|
|
for(long j=0;j<pPoly->Length();j++)
|
|
{
|
|
XPoint *pPt=(*pPoly)[j];
|
|
pPt->z=-1*(planeLeft.GetParaA()*pPt->x+planeLeft.GetParaB()*pPt->y+planeLeft.GetParaD())/planeLeft.GetParaC();
|
|
poly1[j]->z=pPt->z-m_dSlabThick;
|
|
}
|
|
xdc.DrawShell(*pPoly);
|
|
|
|
for(long k=0;k<poly1.TotalSegments();k++)
|
|
{
|
|
XCurveSegment e0,e1;
|
|
pPoly->Nth(k,e0);
|
|
poly1.Nth(k,e1);
|
|
X3DFace face;
|
|
face.SetFlag(0);
|
|
face.GetVertex(0)=e1.StartPoint();
|
|
face.GetVertex(1)=e1.EndPoint();
|
|
face.GetVertex(2)=e0.EndPoint();
|
|
face.GetVertex(3)=e0.StartPoint();
|
|
|
|
e0.SetElevation(0);
|
|
int nRet0=line.HitTest2d(e0.StartPoint());
|
|
int nRet1=line.HitTest2d(e0.EndPoint());
|
|
if(nRet0==1||nRet0==2||nRet1==1||nRet1==2||lstRight.Length()==0)
|
|
xdc.DrawFace(face);
|
|
}
|
|
poly1.Reverse();
|
|
xdc.DrawShell(poly1);
|
|
}
|
|
}
|
|
|
|
{
|
|
AcGeVector3d vt(AcGeVector3d::kZAxis);
|
|
vt.rotateBy(m_dAngleRight,vtAxis);
|
|
XPlane planeRight(XPoint(m_ptRidge1.x,m_ptRidge1.y,dEl),vt);
|
|
for(long i=0;i<lstRight.Length();i++)
|
|
{
|
|
XPoly2D* pPoly=lstRight[i];
|
|
XPoly2D poly1=*pPoly;
|
|
for(long j=0;j<pPoly->Length();j++)
|
|
{
|
|
XPoint *pPt=(*pPoly)[j];
|
|
pPt->z=-1*(planeRight.GetParaA()*pPt->x+planeRight.GetParaB()*pPt->y+planeRight.GetParaD())/planeRight.GetParaC();
|
|
poly1[j]->z=pPt->z-m_dSlabThick;
|
|
}
|
|
xdc.DrawShell(*pPoly);
|
|
|
|
for(long k=0;k<poly1.TotalSegments();k++)
|
|
{
|
|
XCurveSegment e0,e1;
|
|
pPoly->Nth(k,e0);
|
|
poly1.Nth(k,e1);
|
|
X3DFace face;
|
|
face.SetFlag(0);
|
|
face.GetVertex(0)=e1.StartPoint();
|
|
face.GetVertex(1)=e1.EndPoint();
|
|
face.GetVertex(2)=e0.EndPoint();
|
|
face.GetVertex(3)=e0.StartPoint();
|
|
|
|
e0.SetElevation(0);
|
|
int nRet0=line.HitTest2d(e0.StartPoint());
|
|
int nRet1=line.HitTest2d(e0.EndPoint());
|
|
if(nRet0==1||nRet0==2||nRet1==1||nRet1==2||lstLeft.Length()==0)
|
|
xdc.DrawFace(face);
|
|
}
|
|
|
|
poly1.Reverse();
|
|
xdc.DrawShell(poly1);
|
|
}
|
|
}
|
|
|
|
AcDbVoidPtrArray arEntPtrs;
|
|
xdc.GetDraw(arEntPtrs);
|
|
|
|
AcDbObjectId idLay = layerId();
|
|
AcDbObjectId idLayOld = layerId();
|
|
|
|
if (pDC != NULL)
|
|
{
|
|
idLayOld = pDC->GetLayerId();
|
|
pDC->SetLayer(idLay);
|
|
}
|
|
|
|
DrawEntsToSolid(pDC,pGetFaces,arEntPtrs);
|
|
|
|
if (pDC != NULL) pDC->SetLayer(idLayOld);
|
|
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::DrawMountRoof3d(AcGiDraw* pDC,AcDbVoidPtrArray* pGetFaces) const
|
|
{
|
|
if(GetLength()<_DIST_SNAP || GetWidth()<_DIST_SNAP)
|
|
return Acad::eOk;
|
|
|
|
XDraw xDc;
|
|
|
|
XPoly2D poly;
|
|
AcDbPolyline* pPl = NULL;
|
|
GetPolyPath(pPl);
|
|
if (pPl != NULL)
|
|
{
|
|
poly.SetAcDbCurve(pPl);
|
|
delete pPl;
|
|
}
|
|
|
|
XLine leftLine, rightLine, midLine;
|
|
AcGeLineSeg3d lLn,rLn,mLn;
|
|
GetMountLine(lLn,rLn,mLn);
|
|
leftLine.SetPoints(lLn.startPoint(),lLn.endPoint());
|
|
rightLine.SetPoints(rLn.startPoint(),rLn.endPoint());
|
|
midLine.SetPoints(mLn.startPoint(),mLn.endPoint());
|
|
|
|
XLine midLine0;
|
|
midLine0=midLine;
|
|
midLine0.StartPoint().z+=m_dSlabThick;
|
|
midLine0.EndPoint().z+=m_dSlabThick;
|
|
|
|
if (GetRoofHeight()-GetMountHeight()<_DIST_SNAP
|
|
||fabs(cos(GetSlopeAngle2()))<1E-3
|
|
||GetMountHeight()<_DIST_SNAP) //人字屋顶,四坡屋顶,攒尖屋顶
|
|
{
|
|
if (poly.Length()!=4)
|
|
return Acad::eOk;
|
|
|
|
XCurveSegment e0,e1;
|
|
poly.Nth(0,e0);
|
|
e1=e0;
|
|
e1.StartPoint().z+=m_dSlabThick;
|
|
e1.EndPoint().z+=m_dSlabThick;
|
|
|
|
//前后檐屋顶面
|
|
X3DFace face;
|
|
face.SetFlag(0);
|
|
face.GetVertex(0)=midLine.EndPoint();
|
|
face.GetVertex(1)=e0.EndPoint();
|
|
face.GetVertex(2)=e0.StartPoint();
|
|
face.GetVertex(3)=midLine.StartPoint();
|
|
xDc.DrawFace(face); //主坡内面
|
|
|
|
face.GetVertex(0)=midLine0.StartPoint();
|
|
face.GetVertex(1)=e1.StartPoint();
|
|
face.GetVertex(2)=e1.EndPoint();
|
|
face.GetVertex(3)=midLine0.EndPoint();
|
|
xDc.DrawFace(face); //主坡外面
|
|
|
|
face.GetVertex(0)=e0.StartPoint();
|
|
face.GetVertex(1)=e0.EndPoint();
|
|
face.GetVertex(2)=e1.EndPoint();
|
|
face.GetVertex(3)=e1.StartPoint();
|
|
xDc.DrawFace(face); //主坡立面
|
|
|
|
poly.Nth(2,e0);
|
|
e1=e0;
|
|
e1.StartPoint().z+=m_dSlabThick;
|
|
e1.EndPoint().z+=m_dSlabThick;
|
|
|
|
face.GetVertex(0)=midLine.StartPoint();
|
|
face.GetVertex(1)=e0.EndPoint();
|
|
face.GetVertex(2)=e0.StartPoint();
|
|
face.GetVertex(3)=midLine.EndPoint();
|
|
xDc.DrawFace(face); //主坡内面
|
|
|
|
face.GetVertex(0)=midLine0.EndPoint();
|
|
face.GetVertex(1)=e1.StartPoint();
|
|
face.GetVertex(2)=e1.EndPoint();
|
|
face.GetVertex(3)=midLine0.StartPoint();
|
|
xDc.DrawFace(face); //主坡外面
|
|
|
|
face.GetVertex(0)=e0.StartPoint();
|
|
face.GetVertex(1)=e0.EndPoint();
|
|
face.GetVertex(2)=e1.EndPoint();
|
|
face.GetVertex(3)=e1.StartPoint();
|
|
xDc.DrawFace(face); //主坡立面
|
|
|
|
//山墙屋顶面
|
|
if (GetRoofHeight()-GetMountHeight()<_DIST_SNAP
|
|
||fabs(cos(GetSlopeAngle2()))<1E-3) //人字屋顶
|
|
{
|
|
if (IsShowSide()) //显示侧坡
|
|
{
|
|
poly.Nth(1,e0);
|
|
e1=e0;
|
|
e1.StartPoint().z+=m_dSlabThick;
|
|
e1.EndPoint().z+=m_dSlabThick;
|
|
|
|
X3DFace face1;
|
|
face1.SetFlag(0);
|
|
face1.GetVertex(0)=midLine0.EndPoint();
|
|
face1.GetVertex(1)=e1.StartPoint();
|
|
face1.GetVertex(2)=e1.EndPoint();
|
|
face1.GetVertex(3)=midLine0.EndPoint();
|
|
xDc.DrawFace(face1); //侧坡面
|
|
|
|
face1.GetVertex(0)=e1.StartPoint();
|
|
face1.GetVertex(1)=e0.StartPoint();
|
|
face1.GetVertex(2)=e0.EndPoint();
|
|
face1.GetVertex(3)=e1.EndPoint();
|
|
xDc.DrawFace(face1); //侧坡立面
|
|
|
|
poly.Nth(3,e0);
|
|
e1=e0;
|
|
e1.StartPoint().z+=m_dSlabThick;
|
|
e1.EndPoint().z+=m_dSlabThick;
|
|
|
|
face1.GetVertex(0)=midLine0.StartPoint();
|
|
face1.GetVertex(1)=e1.StartPoint();
|
|
face1.GetVertex(2)=e1.EndPoint();
|
|
face1.GetVertex(3)=midLine0.StartPoint();
|
|
xDc.DrawFace(face1); //侧坡面
|
|
|
|
face1.GetVertex(0)=e1.StartPoint();
|
|
face1.GetVertex(1)=e0.StartPoint();
|
|
face1.GetVertex(2)=e0.EndPoint();
|
|
face1.GetVertex(3)=e1.EndPoint();
|
|
xDc.DrawFace(face1); //侧坡立面
|
|
}
|
|
}
|
|
else //四坡屋顶,攒尖屋顶
|
|
{
|
|
poly.Nth(1,e0);
|
|
e1=e0;
|
|
e1.StartPoint().z+=m_dSlabThick;
|
|
e1.EndPoint().z+=m_dSlabThick;
|
|
|
|
X3DFace face1;
|
|
face1.SetFlag(0);
|
|
face1.GetVertex(0)=midLine0.EndPoint();
|
|
face1.GetVertex(1)=e1.StartPoint();
|
|
face1.GetVertex(2)=e1.EndPoint();
|
|
face1.GetVertex(3)=midLine0.EndPoint();
|
|
xDc.DrawFace(face1); //侧坡外面
|
|
|
|
face1.GetVertex(0)=midLine.EndPoint();
|
|
face1.GetVertex(1)=e0.EndPoint();
|
|
face1.GetVertex(2)=e0.StartPoint();
|
|
face1.GetVertex(3)=midLine.EndPoint();
|
|
xDc.DrawFace(face1); //侧坡内面
|
|
|
|
face1.GetVertex(0)=e1.StartPoint();
|
|
face1.GetVertex(1)=e0.StartPoint();
|
|
face1.GetVertex(2)=e0.EndPoint();
|
|
face1.GetVertex(3)=e1.EndPoint();
|
|
xDc.DrawFace(face1); //侧坡立面
|
|
|
|
poly.Nth(3,e0);
|
|
e1=e0;
|
|
e1.StartPoint().z+=m_dSlabThick;
|
|
e1.EndPoint().z+=m_dSlabThick;
|
|
|
|
face1.GetVertex(0)=midLine0.StartPoint();
|
|
face1.GetVertex(1)=e1.StartPoint();
|
|
face1.GetVertex(2)=e1.EndPoint();
|
|
face1.GetVertex(3)=midLine0.StartPoint();
|
|
xDc.DrawFace(face1); //侧坡外面
|
|
|
|
face1.GetVertex(0)=midLine.StartPoint();
|
|
face1.GetVertex(1)=e0.EndPoint();
|
|
face1.GetVertex(2)=e0.StartPoint();
|
|
face1.GetVertex(3)=midLine.StartPoint();
|
|
xDc.DrawFace(face1); //侧坡内面
|
|
|
|
face1.GetVertex(0)=e1.StartPoint();
|
|
face1.GetVertex(1)=e0.StartPoint();
|
|
face1.GetVertex(2)=e0.EndPoint();
|
|
face1.GetVertex(3)=e1.EndPoint();
|
|
xDc.DrawFace(face1); //侧坡立面
|
|
}
|
|
}
|
|
else //歇山屋顶
|
|
{
|
|
XPoly2D poly0(1);
|
|
poly0.AppendNode(leftLine.StartPoint());
|
|
poly0.AppendNode(rightLine.StartPoint());
|
|
poly0.AppendNode(rightLine.EndPoint());
|
|
poly0.AppendNode(leftLine.EndPoint());
|
|
|
|
for(int i=0;i<poly.TotalSegments();i++)
|
|
{
|
|
XCurveSegment e0,e1,e2,e3;
|
|
poly.Nth(i,e0);
|
|
e1=e0;
|
|
e1.StartPoint().z+=m_dSlabThick;
|
|
e1.EndPoint().z+=m_dSlabThick;
|
|
poly0.Nth(i,e2);
|
|
e3=e2;
|
|
e3.StartPoint().z+=m_dSlabThick;
|
|
e3.EndPoint().z+=m_dSlabThick;
|
|
|
|
X3DFace face;
|
|
face.SetFlag(0);
|
|
face.GetVertex(0)=e0.StartPoint();
|
|
face.GetVertex(1)=e0.EndPoint();
|
|
face.GetVertex(2)=e1.EndPoint();
|
|
face.GetVertex(3)=e1.StartPoint();
|
|
xDc.DrawFace(face); //立面
|
|
|
|
face.GetVertex(0)=e2.EndPoint();
|
|
face.GetVertex(1)=e0.EndPoint();
|
|
face.GetVertex(2)=e0.StartPoint();
|
|
face.GetVertex(3)=e2.StartPoint();
|
|
if(i%2==0)
|
|
face.SetVisible(3,FALSE);
|
|
xDc.DrawFace(face); //坡内面
|
|
|
|
face.GetVertex(0)=e3.StartPoint();
|
|
face.GetVertex(1)=e1.StartPoint();
|
|
face.GetVertex(2)=e1.EndPoint();
|
|
face.GetVertex(3)=e3.EndPoint();
|
|
if(i%2==0)
|
|
face.SetVisible(3,FALSE);
|
|
xDc.DrawFace(face); //坡外面
|
|
}
|
|
|
|
if(midLine.GetLength()>_DIST_SNAP&&poly0.TotalSegments()==4)
|
|
{
|
|
XCurveSegment e0,e1;
|
|
poly0.Nth(0,e0);
|
|
e1=e0;
|
|
e1.StartPoint().z+=m_dSlabThick;
|
|
e1.EndPoint().z+=m_dSlabThick;
|
|
|
|
X3DFace face;
|
|
face.SetFlag(0);
|
|
face.GetVertex(0)=e0.StartPoint();
|
|
face.GetVertex(1)=midLine.StartPoint();
|
|
face.GetVertex(2)=midLine.EndPoint();
|
|
face.GetVertex(3)=e0.EndPoint();
|
|
face.SetVisible(3,FALSE);
|
|
xDc.DrawFace(face); //坡内面
|
|
|
|
X3DFace face1;
|
|
face1.SetFlag(0);
|
|
face1.GetVertex(0)=e1.StartPoint();
|
|
face1.GetVertex(1)=e1.EndPoint();
|
|
face1.GetVertex(2)=midLine0.EndPoint();
|
|
face1.GetVertex(3)=midLine0.StartPoint();
|
|
face1.SetVisible(0,FALSE);
|
|
xDc.DrawFace(face1); //坡外面
|
|
|
|
poly0.Nth(2,e0);
|
|
e1=e0;
|
|
e1.StartPoint().z+=m_dSlabThick;
|
|
e1.EndPoint().z+=m_dSlabThick;
|
|
|
|
X3DFace face2;
|
|
face2.SetFlag(0);
|
|
face2.GetVertex(0)=e0.StartPoint();
|
|
face2.GetVertex(1)=midLine.EndPoint();
|
|
face2.GetVertex(2)=midLine.StartPoint();
|
|
face2.GetVertex(3)=e0.EndPoint();
|
|
face2.SetVisible(3,FALSE);
|
|
xDc.DrawFace(face2); //坡内面
|
|
|
|
X3DFace face3;
|
|
face3.SetFlag(0);
|
|
face3.GetVertex(0)=e1.StartPoint();
|
|
face3.GetVertex(1)=e1.EndPoint();
|
|
face3.GetVertex(2)=midLine0.StartPoint();
|
|
face3.GetVertex(3)=midLine0.EndPoint();
|
|
face3.SetVisible(0,FALSE);
|
|
xDc.DrawFace(face3); //坡外面
|
|
|
|
poly0.Nth(1,e0);
|
|
e1=e0;
|
|
e1.StartPoint().z+=m_dSlabThick;
|
|
e1.EndPoint().z+=m_dSlabThick;
|
|
|
|
X3DFace face4;
|
|
face4.SetFlag(0);
|
|
face4.GetVertex(0)=midLine0.EndPoint();
|
|
face4.GetVertex(1)=e1.StartPoint();
|
|
face4.GetVertex(2)=e1.EndPoint();
|
|
face4.GetVertex(3)=midLine0.EndPoint();
|
|
xDc.DrawFace(face4); //山头面
|
|
|
|
poly0.Nth(3,e0);
|
|
e1=e0;
|
|
e1.StartPoint().z+=m_dSlabThick;
|
|
e1.EndPoint().z+=m_dSlabThick;
|
|
|
|
face4.GetVertex(0)=midLine0.StartPoint();
|
|
face4.GetVertex(1)=e1.StartPoint();
|
|
face4.GetVertex(2)=e1.EndPoint();
|
|
face4.GetVertex(3)=midLine0.StartPoint();
|
|
xDc.DrawFace(face4); //山头面
|
|
}
|
|
}
|
|
|
|
AcDbVoidPtrArray arEntPtrs;
|
|
xDc.GetDraw(arEntPtrs);
|
|
|
|
AcDbObjectId idLayOld = layerId();
|
|
AcDbObjectId idLay = layerId();
|
|
|
|
if (pDC != NULL)
|
|
{
|
|
idLayOld = pDC->GetLayerId();
|
|
pDC->SetLayer(idLay);
|
|
}
|
|
|
|
DrawEntsToSolid(pDC,pGetFaces,arEntPtrs);
|
|
|
|
if (pDC != NULL) pDC->SetLayer(idLayOld);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbXRoof::DrawCuspRoof3d(AcGiDraw* pDC,AcDbVoidPtrArray* pGetFaces) const
|
|
{
|
|
XDraw xDc;
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
|
|
XPoly2D poly;
|
|
AcDbPolyline* pPl = NULL;
|
|
GetPolyPath(pPl);
|
|
if (pPl != NULL)
|
|
{
|
|
poly.SetAcDbCurve(pPl);
|
|
delete pPl;
|
|
}
|
|
|
|
XPoint ptTop=m_ptCenter,ptTop1=m_ptCenter;
|
|
ptTop.z += m_dRoofHeight-m_dSlabThick;
|
|
ptTop1.z += m_dRoofHeight;
|
|
for(long i=0;i<poly.TotalSegments();i++)
|
|
{
|
|
XCurveSegment e0,e1;
|
|
poly.Nth(i,e0);
|
|
e1=e0;
|
|
e1.StartPoint().z += m_dSlabThick;
|
|
e1.EndPoint().z += m_dSlabThick;
|
|
X3DFace face;
|
|
face.SetFlag(0);
|
|
face.GetVertex(0)=e0.StartPoint();
|
|
face.GetVertex(1)=e0.EndPoint();
|
|
face.GetVertex(2)=e1.EndPoint();
|
|
face.GetVertex(3)=e1.StartPoint();
|
|
xDc.DrawFace(face);
|
|
|
|
face.GetVertex(0)=ptTop;
|
|
face.GetVertex(1)=e0.EndPoint();
|
|
face.GetVertex(2)=e0.StartPoint();
|
|
face.GetVertex(3)=ptTop;
|
|
xDc.DrawFace(face);
|
|
|
|
face.GetVertex(0)=ptTop1;
|
|
face.GetVertex(1)=e1.StartPoint();
|
|
face.GetVertex(2)=e1.EndPoint();
|
|
face.GetVertex(3)=ptTop1;
|
|
xDc.DrawFace(face);
|
|
}
|
|
|
|
AcDbVoidPtrArray arEntPtrs;
|
|
xDc.GetDraw(arEntPtrs);
|
|
|
|
AcDbObjectId idLayOld = layerId();
|
|
AcDbObjectId idLay = layerId();
|
|
|
|
if (pDC != NULL)
|
|
{
|
|
idLayOld = pDC->GetLayerId();
|
|
pDC->SetLayer(idLay);
|
|
}
|
|
|
|
DrawEntsToSolid(pDC,pGetFaces,arEntPtrs);
|
|
|
|
if (pDC != NULL) pDC->SetLayer(idLayOld);
|
|
|
|
return es;
|
|
}
|
|
|
|
void AecDbXRoof::subList()
|
|
{
|
|
return AecDbEntityBase::subList();
|
|
}
|
|
|
|
SHJson::WValue &AecDbXRoof::ToJson(bool bExprotGeo) const
|
|
{
|
|
using namespace SHJson;
|
|
assertReadEnabled();
|
|
|
|
// 如果没有3D缓存,则绘制
|
|
if (!Has3DBuffer())
|
|
{
|
|
AcGiViewDraw dc;
|
|
Draw3d(dc);
|
|
}
|
|
|
|
using namespace SHJson;
|
|
WValue &v = AecDbEntityBase::ToJson(bExprotGeo);
|
|
|
|
WValue ar;
|
|
ar.SetArray();
|
|
|
|
for (size_t i(0); i < m_solids.size(); ++i)
|
|
{
|
|
AcDbX3dSolid *pSolid(m_solids[i]);
|
|
if (!pSolid) continue;
|
|
WValue &x = pSolid->ToJson();
|
|
pushBack(ar, x);
|
|
}
|
|
addMember(v, _T("__solids__"), ar);
|
|
|
|
ar.SetArray();
|
|
for (size_t i(0); i < m_pipes.size(); ++i)
|
|
{
|
|
AecDbEwPipeBase *pPipe(m_pipes[i]);
|
|
if (!pPipe) continue;
|
|
WValue &x = pPipe->ToJson();
|
|
pushBack(ar, x);
|
|
}
|
|
addMember(v, _T("__pipes__"), ar);
|
|
|
|
return v;
|
|
} |