#ifndef __GLOBALFUNCTION_H_2006_12_19_ #define __GLOBALFUNCTION_H_2006_12_19_ #include "TDbDuctNode.h" /*============================================================================* * Copyright(c), 1994-2007, Beijing Tangent Engineering Software Co.Ltd. * 文 件 名: GlobalFunction.h * 描 述: 全局函数,目前只有暖通在使用 * 归属项目: 给排水、暖通 * 历史记录: =============================================================================*/ //********************************************************************** // 暖通管线用全局函数 //********************************************************************** //////////节点已经存在,或可以构成节点为前提,获取一组风管的信息////////// // 获取某风管是否是立管 PS_IMPEXP BOOL IsVerDuct(AcDbObjectId idNode, AcDbObjectId id, int nType); // 判断某风管是否是圆风管 PS_IMPEXP BOOL IsCircleDuct(AcDbObjectId idNode, AcDbObjectId id, int nType); PS_IMPEXP AcGeDoubleArray GetWidths(AcDbObjectId id, const DList &ids, const AcDbIntArray &aryTypes); // 管径 PS_IMPEXP AcGeDoubleArray GetHeights(AcDbObjectId id, const DList &ids, const AcDbIntArray &aryTypes); // 高度 // 离指定点较近的端点的位置(是起点,还是终点) PS_IMPEXP void GetPtLocations(AcDbObjectId id, XPoint ptLoc, const DList &ids, const AcDbIntArray &aryTypes, DList &lstLoc); PS_IMPEXP void GetSegs(AcDbObjectId id, XPoint ptLoc, const DList &ids, const AcDbIntArray &aryTypes, // 中心线 DList &lstSeg); PS_IMPEXP void GetVectors(AcDbObjectId id, XPoint ptLoc, // 法向 const DList &ids, const AcDbIntArray &aryTypes, DList &lstVt); PS_IMPEXP AcGeDoubleArray GetAngles(AcDbObjectId id, XPoint ptLoc, // 角度 const DList &ids, const AcDbIntArray &aryTypes); // 获取矩形风管的截面 extern void GetSquare(const XPoint &ptCen, const double &dAngle, const double &dWide, const double &dHigh, XPoly2D* poly, XPoly2D* vDuctPoly = NULL); // 根据中线点ptMid,获取边线的四个角点 PS_IMPEXP extern void GetDuctSidePts(XPoint ptMid, double dWidth, double dHigh, XVector3D vtDraw, XPointList &lstPt); PS_IMPEXP TDbDuctNode::DuctNodeType GetNodeType(const AcDbObjectId id, const XPoint &ptLoc, const AcDbIntArray &types, const DList &ids); // 判断并返回节点类型 // 找出另外管线的标号 PS_IMPEXP void GetAnotherPipe(const int &nNum1, int &nNum2, int &nNum3, int &nNum4); // 将连接件的位置点ptLoc,向各管线的中线做投影,获取投影点 PS_IMPEXP extern void GetDuctTrueMidPts(AcDbObjectId id, XPoint ptLoc, const DList &ids, const AcDbIntArray &types, XPointList &lstPts); // 找出三、四通的支风管标号 PS_IMPEXP AcDbIntArray GetCornerBranchNums(const AcDbObjectId id, const XPoint &ptLoc, const DList &ids, const AcDbIntArray &types, const int &nMain); // 找出三通连接的立管标号 extern void Get3TVDuctNums(AcDbObjectId id, const DList &ids, const AcDbIntArray &types, int &nVDuct1, int &nVDuct2); // 获取风管法兰图层名 extern CString GetDuctFLLayerName(const TPipeSys::SysType st); // 获取指定节点类型的注册表参数 extern int GetDNodeConfig(const TDbDuctNode::DuctNodeType nType, Adesk::UInt8 &nMode, double &dParam1, double &dParam2); //********************************************************************** // 给排水管线用全局函数 //********************************************************************** // 判断两直线是否平行 extern BOOL IsParallelLine(const XLine &l1, const XLine &l2); // 获取通过夹点启动绘制命令返回的数据 PS_IMPEXP bool GetGripCmdData( AcGePoint3d &ptGirp, AcDbObjectId &id ); //********************************************************************** // 管线全局通用函数 //********************************************************************** PS_IMPEXP void AT_cal_fillet(const XPoint pt1, const XPoint ptLoc, const XPoint pt2, const double dDist, XPoint &ptReal1, XPoint &ptCen, XPoint &ptReal2, const BOOL bIsSin = TRUE); // 计算点ptReal1、ptReal2的位置 extern void DrawWeight(XExplodeDraw &dc, double dWeight, XCurveSegment &seg, int nColorIndex, double nScale); extern void DrawWeight(XExplodeDraw &dc, double dWeight, XPoly2D &poly, int nColorIndex, double nScale); // 通过层名,来获取系统类型 PS_IMPEXP TPipeSys::SysType GetTypeByLayer(const TCHAR *csLayer); // 以下两函数用于与“图层管理”交互 // 通过系统类型,获取层名及颜色。例:chLayerKey为“送风管” BOOL GetLayerNameAndColor(const TCHAR *chLayerKey, CString &csLayer, int &nColorIndex); // 通过层名,获取系统类型名称。例:返回的csLayerKey为“送风管” BOOL GetLayerKey(const TCHAR *chLayer, CString &csLayerKey); //********************************************************************** // 补充函数 //********************************************************************** // 获取pt1、pt2中,离ptBase点较近的点 PS_IMPEXP XPoint GetNearPt(XPoint ptBase, XPoint pt1, XPoint pt2); // 获取pt1、pt2中,离ptBase点较远的点 PS_IMPEXP XPoint GetFarPt(XPoint ptBase, XPoint pt1, XPoint pt2); // 获取pt点投影到seg上的投影点,考虑了三维投影,不支持seg与Z轴平行 PS_IMPEXP XPoint PtProjectToSeg(const XCurveSegment &seg, XPoint pt, const AcDb::Intersect &nType = AcDb::kExtendBoth); extern BOOL Get2LineIntPts(AcGePoint3d pt1, AcGePoint3d pt3, AcGePoint3d pt2, AcGePoint3d pt4, AcGePoint3d &ptInt); // 判断两向量是否平行;若不平行,返回0;若平行且方向一致,返回1;方向相反,返回-1, PS_IMPEXP int IsParallel(const XVector3D vt1, const XVector3D vt2); // 判断两个seg是否共线或共圆 PS_IMPEXP BOOL Is2SegOnSeg(const XCurveSegment &seg1, const XCurveSegment &seg2); // 获取直线srcLine关于直线mirrorLine镜像后的直线 PS_IMPEXP XLine GetMirrorLine(const XLine &srcLine, const XLine &mirrorLine); // 获取以ptCen为圆心,过ptStart、ptEnd点的优弧 PS_IMPEXP XArc GetRightArc(XPoint ptStart, XPoint ptCen, XPoint ptEnd, BOOL &bSwitch); // 过圆外一点向圆引切线,获取一个离ptRef点较近的切点 PS_IMPEXP XPoint GetTangentPt2(const XCircle &circle, XPoint pt, XPoint ptRef); // 过弧外一点向弧引切线,获取一个离ptRef点较近的切点 PS_IMPEXP XPoint GetTangentPt1(const XArc &arc, XPoint pt, XPoint ptRef); // 将以ptStart、ptEnd为起止点的线段XLine,分割成nNum份,获取分割点 PS_IMPEXP void GetSplitPts(XPoint ptStart, XPoint ptEnd, int nNum, XPointList &pts); // 获取X3DFace extern X3DFace GetFace1(XPoint pt1, XPoint pt2, XPoint pt3, XPoint pt4, // 四点 BOOL bShow0 = TRUE, BOOL bShow1 = TRUE, BOOL bShow2 = TRUE, BOOL bShow3 = TRUE); extern X3DFace GetFace2(XPoint pt1, XPoint pt2, XPoint pt3, // 三点 BOOL bShow0 = FALSE, BOOL bShow1 = FALSE, BOOL bShow2 = FALSE, BOOL bShow3 = FALSE); // 将一个完整的圆分割成指定份数,获取分割点 extern void GetSplitCirclePts(XPoint ptCen, double dRadius, XVector3D vtNormal, int nSplitNum, XPointList &pts); // 将一个圆柱、圆台,切割成多个3DFace extern BOOL GetColumn3DFaces(XPoint ptCen1, double dRadius1, XVector3D vtNormal1, XPoint ptCen2, double dRadius2, XVector3D vtNormal2, DList &lstFaces, int nSplitNum, int nShowSideNum, BOOL bGetCircle1 = TRUE, BOOL bGetCircle2 = TRUE, BOOL bShow1 = TRUE, BOOL bShow2 = TRUE); // 将DuctNode中的边线,分隔成指定的份数 extern void GetTHSplitPts(XPoint point1, XPoint point2, XVector3D vt1, XVector3D vt2, int nSplitNum, XPointList &lstPts, int nMod = 1, XPoint pointMid = XPoint()); /*============================================================================* * 类 名: TCalCornerPts * 功能描述: 三通、四通点的计算类 * 备 注: ==============================================================================*/ class PS_IMPEXP TCalCornerPts { public: TCalCornerPts(const XPoint &ptLoc, const AcDbObjectId &idNode, int nLen): pt(ptLoc), id(idNode), nNum(nLen) {}; protected: int nNum; // 三通、四通 XPoint pt; // 位置点 AcDbObjectId id; // ID DList ids; // 连接的管线 AcDbIntArray types; AcGeDoubleArray ws; // 宽度 AcGeDoubleArray hs; // 高度 AcGeDoubleArray as; // 角度 DList vs; // 方向 DList ss; // segs XPointList ps; // 中心点投影点 AcGeDoubleArray flcs; // 法兰出头 AcGeDoubleArray flhs; // 法兰厚度 double dRate; // 曲率半径 int nMod; // 绘制样式 public: void ClearSS(); BOOL SetIdAndType(const DList &ducts, const AcDbIntArray &aryTypes); // 初始化其他链表 void SetFlange(); // 初始化法兰链表 void SetParam(double dNum, int nNum) { // 样式、曲率 dRate = dNum; nMod = nNum; } public: int GetBigNum(int nNum1, int nNum2); // 获取较大管径的角标 // 获取numArray中,最大数的索引号 AcDbIntArray GetMaxNumIndexs(const AcGeDoubleArray &numArray); int GetMainNum(); // 主风管 double GetDistFl(int nNum1, int nNum2, double dAngle); // 法兰不相交的距离 XPoint GetFlLocPt(int nNum, double dDist, XPoint pt); // 缩进点 XPoint GetIntPt(int nNum1, int nNum2); // 中心线交点 public: // 三通 XPoint Cal3TMainDuctPt(int nMain, int nB1, int nB2); // 主管 XPoint Cal3TPoint(int nSelf, int nMain, int nOther); // 其他支管 XPoint Cal3TPoint11(int nSelf); // 叉型支管 void Cal3TPoint9(int nMain, int nB1, double dAng, XPoint &ptM, XPoint &ptB1, XPoint &ptB2); // 斜插主、支管 public: // 四通 XPoint Cal4TPoint(int nSelf, int nNum1, int nNum2, BOOL bMain = TRUE); // 方 void Cal4TPoint7(int nMain, int nB1, int nB2, double dAng, XPoint &ptM, XPoint &pt1, XPoint &pt2, XPoint &pt3); // 圆 }; #endif