#ifndef __DBSLOPEROOF_H #define __DBSLOPEROOF_H #include "aecroof.h" //extern GEOAPI int DePeriod(int, int); class TARCH_EXP 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;//屋脊大小 //TArch8 DList m_lstHole;//洞数据 DList 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 TARCH_EXP TSlopeRoof { protected: XPoly2D m_polyOutline; //轮廓 DList m_slope; //倾角 //TArch7 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; }; // TDbColumn class TARCH_EXP 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 BOOL IsValid() const; virtual bool IsModelEntity() const{return true;} virtual bool IsClipMe(const TEntityBase* pEnt=NULL)const;//ok virtual void CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag); virtual Acad::ErrorStatus SetPathPoly(const XPoly2D &polyPath,const AcGeVector3d&normal); virtual Acad::ErrorStatus GetPathPoly(XPoly2D &polyPath,AcGeVector3d&normal) const; virtual CString GetXml(const AcGeMatrix3d& mat) const; // Overriden function from AcDbEntity virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const; virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler*); virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler*) const; virtual Acad::ErrorStatus dxfInFields (AcDbDxfFiler*); virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler*) const; virtual Acad::ErrorStatus subTransformBy(const AcGeMatrix3d& xform); // drived from TDbEntity virtual Acad::ErrorStatus ExplodeOrDraw3d(XExplodeDraw &dc) const; virtual Acad::ErrorStatus ExplodeOrDraw2d(XExplodeDraw &dc) const; virtual void GetTips(DList &) const; //取动态属性显示数据 //virtual Acad::ErrorStatus GetGripText(int i, CString &cs) const; virtual const TCHAR *GetDefaultLayer() const; // sg add 101115,支持统一标高 virtual bool UnifyElevation(double dElevation = 0.0); // 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; } private: // 获取三维实体面 void GetFaceFrom3d(DList& listFace) const; }; //人字双坡屋顶 #ifdef I_AM_TCH_KERNAL class TARCH_EXP TDbDualSlopeRoof: public TDbPolyPathEnt, public TRoofBase #else class TARCH_IMPEXP TDbDualSlopeRoof: public TDbPolyPathEnt, public TRoofBase #endif { 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;//两侧是否等坡度(使用左坡度) //add by xlc on 081223 //TArch8 member Adesk::Boolean m_bHeightLim;//是否限高 double m_dHeight; //限高时的屋顶高 public: TDbDualSlopeRoof() { m_nAngleLeft=m_nAngleRight=0; m_bEqualAngle=Adesk::kFalse; //add by xlc on 090223 //Tarch8 m_dHeight=_AS_SYS_UNIT(3000); }//ok virtual void UnionScale(double nScale); virtual BOOL IsValid() const; virtual bool IsModelEntity() const{return true;} virtual bool IsClipMe(const TEntityBase* pEnt=NULL)const;//ok virtual void CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag); virtual Acad::ErrorStatus SetPathPoly(const XPoly2D &polyPath,const AcGeVector3d&normal); virtual Acad::ErrorStatus GetPathPoly(XPoly2D &polyPath,AcGeVector3d&normal) const; // Overriden function from AcDbEntity virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const; virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler*); virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler*) const; virtual Acad::ErrorStatus dxfInFields (AcDbDxfFiler*); virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler*) const; virtual Acad::ErrorStatus subTransformBy(const AcGeMatrix3d& xform); virtual Acad::ErrorStatus subGetGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const; virtual Acad::ErrorStatus subMoveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset); // drived from TDbEntity virtual Acad::ErrorStatus ExplodeOrDraw3d(XExplodeDraw &dc) const; virtual Acad::ErrorStatus ExplodeOrDraw2d(XExplodeDraw &dc) const; virtual void GetTips(DList &) const; //取动态属性显示数据 virtual Acad::ErrorStatus GetGripText(int i, CString &cs) const; virtual const TCHAR *GetDefaultLayer() const; virtual int GetFirstVersion()const{return 7;}//ok // 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; } // sg add 101119,支持导出XML virtual CString GetXml(const AcGeMatrix3d& mat) const; void Split(DList&lstLeft,DList&lstRight)const; void GetPlane(XPlane&planeLeft,XPlane&planeRight)const; double GetElevation()const{return m_polyOutline[0].z;}//ok void SetElevation(double e){assertWriteEnabled();m_polyOutline.SetElevation(e);}//ok void SetEqualAngle(Adesk::Boolean bEqual){assertWriteEnabled();m_bEqualAngle=bEqual;}//ok Adesk::Boolean IsEqualAngle()const{return m_bEqualAngle;}//ok double GetAngleLeft()const{return m_nAngleLeft;}//ok double GetAngleRight()const{return m_nAngleRight;}//ok void SetAngle(double a1,double a2){assertWriteEnabled();m_nAngleLeft=a1;m_nAngleRight=a2;}//ok XPoint GetRidgeStart()const{return m_ptRidge1;}//ok XPoint GetRidgeEnd()const{return m_ptRidge2;}//ok void SetRidge(XPoint pt1,XPoint pt2){assertWriteEnabled();m_ptRidge1=pt1;m_ptRidge2=pt2;}//ok //add by xlc on 081223 //TArch8 member void SetHeightLim(Adesk::Boolean bTrue); Adesk::Boolean IsHeightLim()const; //add by xlc on 090223 void SetRoofHeight(double h); double GetRoofHeight()const; //add by xlc on 090310 BOOL CalAngle(double &angLeft,double &angRight); }; //矩形屋顶 #ifdef I_AM_TCH_KERNAL class TARCH_EXP TDbMountRoof: public TDbPolyPathEnt, public TRoofBase #else class TARCH_IMPEXP TDbMountRoof: public TDbPolyPathEnt, public TRoofBase #endif { 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 Acad::ErrorStatus dwgInFields (AcDbDwgFiler*); virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler*) const; virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const; virtual Acad::ErrorStatus subTransformBy(const AcGeMatrix3d& xform); virtual Acad::ErrorStatus subGetGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const; virtual Acad::ErrorStatus subMoveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset); virtual Acad::ErrorStatus subGetStretchPoints(AcGePoint3dArray& stretchPoints) const; virtual Acad::ErrorStatus subMoveStretchPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset); virtual void UnionScale(double nScale); #if ADS>15 virtual void CreateGrip(); 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 BOOL IsValid() const; virtual bool IsClipMe(const TEntityBase* pEnt=NULL)const;//ok virtual void CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag); // drived from TDbEntity virtual int GetFirstVersion()const{return 8;}//ok virtual bool IsModelEntity() const{return true;} virtual Acad::ErrorStatus ExplodeOrDraw3d(XExplodeDraw &dc) const; virtual Acad::ErrorStatus ExplodeOrDraw2d(XExplodeDraw &dc) const; virtual void GetTips(DList &) const; //取动态属性显示数据 virtual Acad::ErrorStatus GetGripText(int i, CString &cs) const; virtual const TCHAR *GetDefaultLayer() const; virtual int GetCtrlToggleIndex()const{return 5;}//ok // sg add 100722,支持统一标高 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; }; //攒尖屋顶 #ifdef I_AM_TCH_KERNAL class TARCH_EXP TDbCuspRoof: public TDbPolyPathEnt, public TRoofBase #else class TARCH_IMPEXP TDbCuspRoof: public TDbPolyPathEnt, public TRoofBase #endif { 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 xlc on 081223 //TArch8 member double m_dEavesLen; public: virtual void UnionScale(double nScale); virtual BOOL IsValid() const; virtual bool IsModelEntity() const{return true;} virtual bool IsClipMe(const TEntityBase* pEnt=NULL)const;//ok virtual void CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag); virtual Acad::ErrorStatus GetPathPoly(XPoly2D &polyPath,AcGeVector3d&normal) const; // Overriden function from AcDbEntity virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const; virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler*); virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler*) const; virtual Acad::ErrorStatus dxfInFields (AcDbDxfFiler*); virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler*) const; virtual Acad::ErrorStatus subTransformBy(const AcGeMatrix3d& xform); virtual Acad::ErrorStatus subGetGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const; virtual Acad::ErrorStatus subMoveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset); // drived from TDbEntity virtual Acad::ErrorStatus ExplodeOrDraw3d(XExplodeDraw &dc) const; virtual Acad::ErrorStatus ExplodeOrDraw2d(XExplodeDraw &dc) const; virtual void GetTips(DList &) const; //取动态属性显示数据 virtual Acad::ErrorStatus GetGripText(int i, CString &cs) const; virtual const TCHAR *GetDefaultLayer() const; virtual int GetFirstVersion()const{return 7;}//ok // sg add 101115,支持统一标高 virtual bool UnifyElevation(double dElevation = 0.0); // SetMethod 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 xlc on 081223 double GetEavesLen()const; void SetEavesLen(double d); #if ADS>15 virtual void CreateGrip(); 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