372 lines
12 KiB
C++
372 lines
12 KiB
C++
#ifndef __DBSLOPEROOF_H
|
|
#define __DBSLOPEROOF_H
|
|
|
|
#include "aecroof.h"
|
|
#include "XAcGiViewDraw.h"
|
|
|
|
class TRoofBase
|
|
{
|
|
public:
|
|
enum RidgeStyle{kNull,kRect,kArc};
|
|
protected:
|
|
static Adesk::UInt8 g_nVersion;
|
|
protected:
|
|
AcDbHardPointerId m_idTopFaceLayer;//顶面图层
|
|
AcDbHardPointerId m_idBotFaceLayer;//底面图层
|
|
AcDbHardPointerId m_idSlabLayer; //侧面图层
|
|
AcDbHardPointerId m_idRidgeLayer; //屋脊图层
|
|
double m_nSlabThick;//板厚
|
|
RidgeStyle m_nRidgeStyle;//屋脊样式
|
|
double m_nRidgeWidth,m_nRidgeHeight;//屋脊大小
|
|
|
|
//Aec8
|
|
DList<XPoly2D> m_lstHole;//洞数据
|
|
DList<AcDbObjectId> m_lstIdOpening;//天`窗或老虎窗
|
|
public:
|
|
TRoofBase();
|
|
Acad::ErrorStatus Read(AcDbDwgFiler*);
|
|
Acad::ErrorStatus Write(AcDbDwgFiler*) const;
|
|
double GetSlabThick()const{return m_nSlabThick;}
|
|
void SetSlabThick(double d){m_nSlabThick=d;}
|
|
};
|
|
|
|
class TSlopeRoof {
|
|
protected:
|
|
XPoly2D m_polyOutline; //轮廓
|
|
DList<double> m_slope; //倾角
|
|
|
|
//Aec7
|
|
double m_fMaxHeight;
|
|
public:
|
|
TSlopeRoof():m_polyOutline(1){}
|
|
TSlopeRoof(const TSlopeRoof &src);
|
|
TSlopeRoof & operator = (const TSlopeRoof &src);
|
|
|
|
int GetEdgeNum() const {
|
|
return m_slope.Length();
|
|
}
|
|
void Reset();
|
|
void AppendEdge(const XPoint &ptFrom, double nSlope);
|
|
void InitEqualSlope(const XPoly2D &poly, double nSlope);
|
|
double GetAngleToPrev(int idx) const;
|
|
XLine GetSlopeEdge(int idx) const;
|
|
BOOL OffsetIn(double *pDistArray, TSlopeRoof &result) const;
|
|
BOOL IsInOtherEdge(int idx) const;
|
|
void Compress();
|
|
BOOL GetGeometry(XExplodeDraw &dc, BOOL bBotVis) const;
|
|
BOOL GetGeometry1(XExplodeDraw &dc, BOOL bBotVis) const;
|
|
BOOL GetGeometry2d(XExplodeDraw &dc, BOOL bBotVis) const;
|
|
BOOL GetGeometry2d1(XExplodeDraw &dc, BOOL bBotVis) const;
|
|
|
|
//////////////////////////////////////////////////
|
|
// OPM属性, 修改属性需要先asswertWriteEnabled();
|
|
double GetSlopeAngle(int idx) const;
|
|
void SetSlopeAngle(int idx, double nAngle);
|
|
void SetElevation(double h) {
|
|
m_polyOutline.SetElevation(h);
|
|
}
|
|
double GetElevation() const {
|
|
ASSERT(!!m_polyOutline);
|
|
return m_polyOutline[0].z;
|
|
}
|
|
// 底面积
|
|
double GetBottomArea() const {
|
|
return m_polyOutline.Area();
|
|
}
|
|
// 表面积
|
|
double GetSurfArea() const;
|
|
///////////////////////////////////////////////
|
|
|
|
const XPoly2D & GetOutlinePoly() const {
|
|
return m_polyOutline;
|
|
}
|
|
|
|
|
|
// 某一边消失时的HMin
|
|
double GetHMin() const;
|
|
|
|
//////////////////////////////////////////////////////
|
|
double C(int n1) const {
|
|
int nEdgeNum=GetEdgeNum();
|
|
int n=DePeriod(nEdgeNum, n1);
|
|
const XPoly2D &poly=m_polyOutline;
|
|
return (poly[n].y*poly[DePeriod(nEdgeNum, n+1)].x - poly[n].x*poly[DePeriod(nEdgeNum, n+1)].y);
|
|
}
|
|
double A(int n1) const {
|
|
int nEdgeNum=GetEdgeNum();
|
|
int n=DePeriod(nEdgeNum, n1);
|
|
const XPoly2D &poly=m_polyOutline;
|
|
return (poly[DePeriod(nEdgeNum, n+1)].y - poly[n].y);
|
|
}
|
|
double B(int n1) const {
|
|
int nEdgeNum=GetEdgeNum();
|
|
int n=DePeriod(nEdgeNum, n1);
|
|
const XPoly2D &poly=m_polyOutline;
|
|
return (poly[n].x - poly[DePeriod(nEdgeNum, n+1)].x);
|
|
}
|
|
double E(int n) const { //必须不为0
|
|
double val=(A(n-1)*B(n) - A(n)*B(n-1));
|
|
ASSERT(fabs(val)>1.0E-6);
|
|
return val;
|
|
}
|
|
|
|
double a(int n1) const {
|
|
int nEdgeNum=GetEdgeNum();
|
|
int n=DePeriod(nEdgeNum, n1);
|
|
// return GetSlopeEdge(n).Length();
|
|
return GetSlopeEdge(n).GetLength();
|
|
}
|
|
double Ctan(int n1) const {
|
|
int nEdgeNum=GetEdgeNum();
|
|
int n=DePeriod(nEdgeNum, n1);
|
|
double nAng=GetSlopeAngle(n);
|
|
ASSERT(nAng>0);
|
|
return (fabs(PI/2-nAng)<1.0E-5? 0.0 : 1.0/tan(nAng));
|
|
}
|
|
double r(int n) const {
|
|
return (1.0/E(n)*(B(n-1)*a(n)*Ctan(n) - B(n)*a(n-1)*Ctan(n-1)));
|
|
}
|
|
double s(int n) const {
|
|
return (1.0/E(n)*(B(n-1)*C(n)-B(n)*C(n-1)));
|
|
}
|
|
double u(int n) const {
|
|
return (1.0/E(n)*(A(n)*a(n-1)*Ctan(n-1) - A(n-1)*a(n)*Ctan(n)));
|
|
}
|
|
double v(int n) const {
|
|
return (1.0/E(n)*(A(n)*C(n-1) - A(n-1)*C(n)));
|
|
}
|
|
|
|
|
|
double GetHMin(int i, int n) const;
|
|
double GetHMin(int i, int *n) const;
|
|
double GetHMin(int *i, int *n) const;
|
|
BOOL SplitRoof(int iVert, int nEdge, TSlopeRoof &roof1, TSlopeRoof &roof2) const;
|
|
};
|
|
|
|
class TDbSlopeRoof: public TDbPolyPathEnt, public TRoofBase,public TSlopeRoof {
|
|
DECLARE_TENTBASE();
|
|
ACRX_DECLARE_MEMBERS(TDbSlopeRoof);
|
|
private:
|
|
const static Adesk::UInt8 g_nVersion;
|
|
public:
|
|
TDbSlopeRoof();
|
|
~TDbSlopeRoof();
|
|
|
|
virtual void UnionScale(double nScale);
|
|
|
|
virtual Acad::ErrorStatus SetPathPoly(const XPoly2D &polyPath,const AcGeVector3d&normal);
|
|
virtual Acad::ErrorStatus GetPathPoly(XPoly2D &polyPath,AcGeVector3d&normal) const;
|
|
|
|
virtual Acad::ErrorStatus ExplodeOrDraw3d(XExplodeDraw &dc) const;
|
|
virtual Acad::ErrorStatus ExplodeOrDraw2d(XExplodeDraw &dc) const;
|
|
|
|
virtual bool UnifyElevation(double dElevation = 0.0);
|
|
|
|
virtual void SetPolyPath(const XPoly2D &polyPath)
|
|
{
|
|
assertWriteEnabled();
|
|
XPoly2D polyDest(1);
|
|
polyPath.Disperse(polyDest);
|
|
m_polyOutline=polyDest;
|
|
}
|
|
|
|
virtual void GetPolyPath(XPoly2D &polyPath) const
|
|
{
|
|
polyPath=m_polyOutline;
|
|
}
|
|
};
|
|
|
|
class TDbDualSlopeRoof: public TDbPolyPathEnt, public TRoofBase
|
|
{
|
|
DECLARE_TENTBASE();
|
|
ACRX_DECLARE_MEMBERS(TDbDualSlopeRoof);
|
|
private:
|
|
const static Adesk::UInt8 g_nVersion;
|
|
protected:
|
|
XPoly2D m_polyOutline; //标高为顶标高
|
|
XPoint m_ptRidge1,m_ptRidge2; //脊线起点、终点
|
|
double m_nAngleLeft,m_nAngleRight; //脊线两侧坡度
|
|
Adesk::Boolean m_bEqualAngle; //两侧是否等坡度(使用左坡度)
|
|
|
|
Adesk::Boolean m_bHeightLim; //是否限高
|
|
double m_dHeight; //限高时的屋顶高
|
|
|
|
public:
|
|
|
|
TDbDualSlopeRoof()
|
|
{
|
|
m_nAngleLeft=m_nAngleRight=0;
|
|
m_bEqualAngle=Adesk::kFalse;
|
|
m_dHeight=_AS_SYS_UNIT(3000);
|
|
}
|
|
|
|
virtual void UnionScale(double nScale);
|
|
|
|
virtual Acad::ErrorStatus SetPathPoly(const XPoly2D &polyPath,const AcGeVector3d&normal);
|
|
virtual Acad::ErrorStatus GetPathPoly(XPoly2D &polyPath,AcGeVector3d&normal) const;
|
|
|
|
virtual Acad::ErrorStatus ExplodeOrDraw3d(XExplodeDraw &dc) const;
|
|
virtual Acad::ErrorStatus ExplodeOrDraw2d(XExplodeDraw &dc) const;
|
|
|
|
// SetMethod
|
|
virtual void SetPolyPath(const XPoly2D &polyPath)
|
|
{
|
|
assertWriteEnabled();
|
|
XPoly2D polyDest(1);
|
|
polyPath.Disperse(polyDest);
|
|
m_polyOutline=polyDest;
|
|
}
|
|
|
|
virtual void GetPolyPath(XPoly2D &polyPath) const
|
|
{
|
|
polyPath=m_polyOutline;
|
|
}
|
|
|
|
void Split(DList<XPoly2D>&lstLeft,DList<XPoly2D>&lstRight)const;
|
|
void GetPlane(XPlane&planeLeft,XPlane&planeRight)const;
|
|
|
|
double GetElevation()const{return m_polyOutline[0].z;}
|
|
void SetElevation(double e){assertWriteEnabled();m_polyOutline.SetElevation(e);}
|
|
|
|
void SetEqualAngle(Adesk::Boolean bEqual){assertWriteEnabled();m_bEqualAngle=bEqual;}
|
|
Adesk::Boolean IsEqualAngle()const{return m_bEqualAngle;}
|
|
|
|
double GetAngleLeft()const{return m_nAngleLeft;}
|
|
double GetAngleRight()const{return m_nAngleRight;}
|
|
|
|
void SetAngle(double a1,double a2){assertWriteEnabled();m_nAngleLeft=a1;m_nAngleRight=a2;}
|
|
|
|
XPoint GetRidgeStart()const{return m_ptRidge1;}
|
|
XPoint GetRidgeEnd()const{return m_ptRidge2;}
|
|
|
|
void SetRidge(XPoint pt1,XPoint pt2){assertWriteEnabled();m_ptRidge1=pt1;m_ptRidge2=pt2;}
|
|
|
|
void SetHeightLim(Adesk::Boolean bTrue);
|
|
Adesk::Boolean IsHeightLim()const;
|
|
|
|
void SetRoofHeight(double h);
|
|
double GetRoofHeight()const;
|
|
|
|
BOOL CalAngle(double &angLeft,double &angRight);
|
|
};
|
|
|
|
//矩形屋顶
|
|
class TDbMountRoof: public TDbPolyPathEnt, public TRoofBase
|
|
{
|
|
DECLARE_TENTBASE();
|
|
ACRX_DECLARE_MEMBERS(TDbMountRoof);
|
|
private:
|
|
const static Adesk::UInt8 g_nVersion;
|
|
protected:
|
|
XPoint m_ptLocation; //左下角,标高为底标高
|
|
double m_nRotation; //转角
|
|
double m_nLength,m_nWidth; //长,宽(出檐长和出山长不计在内)
|
|
double m_dEavesLen; //出檐长
|
|
double m_dMountLen; //出山长,人字坡有效
|
|
double m_nSlopeAngle1,m_nSlopeAngle2;//主坡角,副坡角
|
|
double m_dMountHeight; //歇山高
|
|
double m_dRoofHeight; //屋顶高
|
|
Adesk::Boolean m_bShowSide; //四坡屋顶,侧坡为90度时是否显示侧坡
|
|
public:
|
|
|
|
virtual void UnionScale(double nScale);
|
|
|
|
#if ADS>15
|
|
|
|
virtual Acad::ErrorStatus EntityToDim(long iGrip, long iDim,const AcDbEntity *pEnt);
|
|
virtual Acad::ErrorStatus DimToEntity(long iGrip, long iDim,double newValue, const AcGeVector3d& offset);
|
|
#endif
|
|
|
|
virtual Acad::ErrorStatus ExplodeOrDraw3d(XExplodeDraw &dc) const;
|
|
virtual Acad::ErrorStatus ExplodeOrDraw2d(XExplodeDraw &dc) const;
|
|
|
|
virtual int GetCtrlToggleIndex()const{return 5;}//ok
|
|
|
|
virtual bool UnifyElevation(double dElevation = 0.0);
|
|
|
|
virtual Acad::ErrorStatus GetPathPoly(XPoly2D &polyPath,AcGeVector3d&normal) const;
|
|
void GetPolyPath(XPoly2D& poly)const;
|
|
void GetMountLine(XLine &leftLine,XLine &rightLine,XLine &midLine)const;
|
|
|
|
void SetElevation(double e){assertWriteEnabled();m_ptLocation.z=e;}
|
|
double GetElevation()const{return m_ptLocation.z;}
|
|
XPoint GetLocation()const;
|
|
void SetLocation(const XPoint &pt);
|
|
double GetRotation()const;
|
|
void SetRotation(double d);
|
|
double GetEavesLen()const;
|
|
void SetEavesLen(double d);
|
|
double GetMountLen()const;//出山长
|
|
void SetMountLen(double d);//出山长
|
|
double GetLength()const;
|
|
void SetLength(double d);
|
|
double GetWidth()const;
|
|
void SetWidth(double d);
|
|
double GetSlopeAngle1()const;
|
|
void SetSlopeAngle1(double d);
|
|
double GetSlopeAngle2()const;
|
|
void SetSlopeAngle2(double d);
|
|
double GetMountHeight()const;
|
|
void SetMountHeight(double d);
|
|
double GetRoofHeight()const;
|
|
void SetRoofHeight(double d);
|
|
Adesk::Boolean IsShowSide()const;
|
|
void SetShowSide(Adesk::Boolean bEqual);
|
|
double GetTopLength()const;
|
|
};
|
|
|
|
//攒尖屋顶
|
|
class TDbCuspRoof: public TDbPolyPathEnt, public TRoofBase
|
|
{
|
|
DECLARE_TENTBASE();
|
|
ACRX_DECLARE_MEMBERS(TDbCuspRoof);
|
|
private:
|
|
const static Adesk::UInt8 g_nVersion;
|
|
protected:
|
|
XPoint m_ptCenter;//标高为底标高
|
|
double m_nRotation;//转角
|
|
double m_nHeight;//高度
|
|
double m_nRadius;//半径
|
|
Adesk::UInt8 m_nSideNum;//边数
|
|
|
|
//add by aec on 081223
|
|
//Aec8 member
|
|
double m_dEavesLen;
|
|
public:
|
|
virtual void UnionScale(double nScale);
|
|
virtual Acad::ErrorStatus GetPathPoly(XPoly2D &polyPath,AcGeVector3d&normal) const;
|
|
|
|
// drived from AecEntity
|
|
virtual Acad::ErrorStatus ExplodeOrDraw3d(XExplodeDraw &dc) const;
|
|
virtual Acad::ErrorStatus ExplodeOrDraw2d(XExplodeDraw &dc) const;
|
|
|
|
virtual bool UnifyElevation(double dElevation = 0.0);
|
|
|
|
virtual void GetPolyPath(XPoly2D &polyPath) const;
|
|
|
|
XPoint GetCenter()const{return m_ptCenter;}//ok
|
|
void SetCenter(XPoint pt){assertWriteEnabled();m_ptCenter=pt;}//ok
|
|
void SetElevation(double e){assertWriteEnabled();m_ptCenter.z=e;}//ok
|
|
double GetElevation()const{return m_ptCenter.z;}//ok
|
|
double GetRotation()const{return m_nRotation;}//ok
|
|
void SetRotation(double nRot){assertWriteEnabled();m_nRotation=nRot;}//ok
|
|
void SetHeight(double h){assertWriteEnabled();m_nHeight=h;}//ok
|
|
double GetHeight()const{return m_nHeight;}//ok
|
|
double GetRadius()const{return m_nRadius;}//ok
|
|
void SetRadius(double r){assertWriteEnabled();m_nRadius=r;}//ok
|
|
void SetSideNum(Adesk::UInt8 num){assertWriteEnabled();m_nSideNum=num;}//ok
|
|
long GetSideNum()const{return m_nSideNum;}//ok
|
|
|
|
//add by aec on 081223
|
|
double GetEavesLen()const;
|
|
void SetEavesLen(double d);
|
|
|
|
#if ADS>15
|
|
virtual Acad::ErrorStatus EntityToDim(long iGrip, long iDim,const AcDbEntity *pEnt);
|
|
virtual Acad::ErrorStatus DimToEntity(long iGrip, long iDim,double newValue, const AcGeVector3d& offset);
|
|
#endif
|
|
};
|
|
|
|
#endif
|
|
|