#ifndef __TGFOLDDEF_H__ #define __TGFOLDDEF_H__ #if _MSC_VER > 1000 #pragma once #endif //折线法避雷数据定义 typedef struct XFoldThunder { int m_nGroup; //组号 int m_nNo; //编号 double m_dHeight; //避雷针高度 AcGePoint3d m_ptPos; //插入点 AcGeDoubleArray m_arProHeight; //保护高度 AcDbObjectId m_Id; //避雷针ID }XFoldThunder; //弧线 typedef struct XFoldProArc { AcGePoint3d m_ptCenter; //圆心 AcGePoint3d m_ptS; //绑定的起点,用于圆弧求交时确定结果取值 double m_dR; //半径 double m_dAngleS; //起始角度 double m_dAngleE; //终止角度 BOOL ConverToArc(XArc& pArc) { if (m_dR > 1e-3) { pArc.SetRadius(m_dR); pArc.SetStarAngle(m_dAngleS); pArc.SetEndAngle(m_dAngleE); pArc.SetCenterPt(m_ptCenter); return TRUE; } return FALSE; } }XFoldProArc; //半边折线 typedef struct XHalfFoldLine { int m_nNo; //关联避雷针编号 AcGePoint3d m_ptS; //切点 XFoldProArc m_ArcS; //起点关联弧线 BOOL m_bValid; //半边是否有效 BOOL GetCntArc(XArc& pArc) { return m_ArcS.ConverToArc(pArc); } }XHalfFoldLine; //折线 typedef struct TGFoldProLine { XHalfFoldLine m_LinePart1; XHalfFoldLine m_LinePart2; AcGePoint3d m_ptTurn; //折点 BOOL m_bValid; XHalfFoldLine& GetHalfFoldLine(int nIndex) { if (nIndex == 1) { return m_LinePart1; } return m_LinePart2; } void GetProLineNo(int& nNo1,int& nNo2) { nNo1 = m_LinePart1.m_nNo; nNo2 = m_LinePart2.m_nNo; } void GetStartPtByNo(int nNo,AcGePoint3d& ptS) { if (m_LinePart1.m_nNo == nNo) { ptS = m_LinePart1.m_ptS; } if (m_LinePart2.m_nNo == nNo) { ptS = m_LinePart2.m_ptS; } } void SetStartPtByNo(int nNo,const AcGePoint3d& ptS) { if (m_LinePart1.m_nNo == nNo) { m_LinePart1.m_ptS = ptS; } if (m_LinePart2.m_nNo == nNo) { m_LinePart2.m_ptS = ptS; } } void SetAnotherPt(int nNo,const AcGePoint3d& ptS) { if (m_LinePart1.m_nNo != nNo) { m_LinePart1.m_ptS = ptS; } if (m_LinePart2.m_nNo != nNo) { m_LinePart2.m_ptS = ptS; } } AcGePoint3d GetTangentPoint(int nThunderNo) { if (m_LinePart1.m_nNo == nThunderNo) { return m_LinePart1.m_ptS; } if (m_LinePart2.m_nNo == nThunderNo) { return m_LinePart2.m_ptS; } return AcGePoint3d::kOrigin; } void InvalidArcByNo(int nNo) { if (m_LinePart1.m_nNo == nNo) { m_LinePart1.m_ArcS.m_dR = 0.0; } if (m_LinePart2.m_nNo == nNo) { m_LinePart2.m_ArcS.m_dR = 0.0; } } void InvalidHalfByNo(int nNo) { if (m_LinePart1.m_nNo == nNo) { m_LinePart1.m_bValid = FALSE; } if (m_LinePart2.m_nNo == nNo) { m_LinePart2.m_bValid = FALSE; } } void InvalidAnothHalf(int nNo) { if (m_LinePart1.m_nNo != nNo) { m_LinePart1.m_bValid = FALSE; } if (m_LinePart2.m_nNo != nNo) { m_LinePart2.m_bValid = FALSE; } } void GetArcByNo(int nNo,XFoldProArc& arc) { if (m_LinePart1.m_nNo == nNo) { arc = m_LinePart1.m_ArcS; } if (m_LinePart2.m_nNo == nNo) { arc = m_LinePart2.m_ArcS; } } void SetArcByNo(int nNo,const XFoldProArc& arc) { if (m_LinePart1.m_nNo == nNo) { m_LinePart1.m_ArcS = arc; } if (m_LinePart2.m_nNo == nNo) { m_LinePart2.m_ArcS = arc; } } void ConverToPL(AcDbPolyline* pLine) { if (pLine == NULL) { return; } XPoint ptS1,ptS2,ptTurn; int nPos = 0; if (m_LinePart1.m_bValid) { ptS1 = m_LinePart1.m_ptS; pLine->addVertexAt(nPos,ptS1.AsAcGePoint2d()); ++nPos; } ptTurn = m_ptTurn; pLine->addVertexAt(nPos,ptTurn.AsAcGePoint2d()); ++nPos; if (m_LinePart2.m_bValid) { ptS2 = m_LinePart2.m_ptS; pLine->addVertexAt(nPos,ptS2.AsAcGePoint2d()); } } }TGFoldProLine,*PFoldProLine; typedef struct TGFOLDNO { int m_nNo1; int m_nNo2; bool operator == (const TGFOLDNO& FoldNo) const { if ((m_nNo1 == FoldNo.m_nNo1 && m_nNo2 == FoldNo.m_nNo2) || (m_nNo1 == FoldNo.m_nNo2 && m_nNo2 == FoldNo.m_nNo1)) { return true; } return false; } bool operator != (const TGFOLDNO& FoldNo) const { if ((m_nNo1 == FoldNo.m_nNo1 && m_nNo2 == FoldNo.m_nNo2) || (m_nNo1 == FoldNo.m_nNo2 && m_nNo2 == FoldNo.m_nNo1)) { return false; } return true; } bool operator < (const TGFOLDNO& FoldNo) const { if (m_nNo1 + m_nNo2 < FoldNo.m_nNo1 + FoldNo.m_nNo2) { return true; } else if (m_nNo1 + m_nNo2 == FoldNo.m_nNo1 + FoldNo.m_nNo2) { if ((*this) != FoldNo) { if (m_nNo1 < FoldNo.m_nNo1) { return true; } } } return false; } }TGFOLDNO; typedef struct PairProLine { PFoldProLine m_pProline1; PFoldProLine m_pProline2; }PAIRPROLINE; typedef struct FoldCalcResult { double m_dEffectD; //有效距离 double m_dBx; //BX double m_dY; //Y double m_dH0; //h0 }FoldCalcResult; typedef std::vector FOLDPINLST; typedef std::map FOLDPINGROUP; inline BOOL IsExist(const XFoldThunder& thunder,const FOLDPINLST& arLst,int& nPos) { for (int i = 0;i < arLst.size();i++) { if (thunder.m_Id == arLst[i].m_Id) { nPos = i; return TRUE; } } nPos = -1; return FALSE; } inline BOOL IsExist(const XFoldThunder& thunder,const FOLDPINLST& arLst) { for (int i = 0;i < arLst.size();i++) { if (thunder.m_Id == arLst[i].m_Id) { return TRUE; } } return FALSE; } inline BOOL IsExist(std::map >& arPre,const TGFOLDNO& FoldNo) { std::map >::iterator itor; for (itor = arPre.begin();itor != arPre.end();++itor) { if (itor->first == FoldNo) { return TRUE; } } return FALSE; } inline BOOL IsEqual(const AcDbObjectIdArray& arIds1,const AcDbObjectIdArray& arIds2) { if (arIds1.length() != arIds2.length()) { return FALSE; } int nPos = 0; int i = 0; for (i = 0;i < arIds1.length();++i) { if (!arIds2.find(arIds1[i],nPos)) { return FALSE; } } for (i = 0;i < arIds2.length();++i) { if (!arIds1.find(arIds2[i],nPos)) { return FALSE; } } return TRUE; } inline BOOL IsExist(const std::vector& arSrc,const AcDbObjectIdArray& arIds) { if (arIds.length() == 0) { return TRUE; } for (int i = 0;i < arSrc.size();++i) { if (IsEqual(arSrc[i],arIds)) { return TRUE; } } return FALSE; } #define FOLD_BLOCK_SIGN _T("00000112") inline AcGePoint3d Mid(AcGePoint3d ptGe1, AcGePoint3d ptGe2) { return AcGePoint3d((ptGe1.x + ptGe2.x) / 2.0,(ptGe1.y + ptGe2.y) / 2.0,(ptGe1.z + ptGe2.z) / 2.0); } inline void SortDoubleArray(AcGeDoubleArray& arEls) { std::list arDtmp; int i = 0; for (i = 0;i < arEls.length();++i) { arDtmp.push_back(arEls[i]); } arDtmp.sort(); arEls.setLogicalLength(0); std::list::iterator itor; for (itor = arDtmp.begin();itor != arDtmp.end();++itor) { arEls.append(*itor); } } #endif