Files
envi-code/SourceCode/Code2026/tg_shs/inc/pipewire/GlobalFunction.h
T

236 lines
10 KiB
C++
Raw Normal View History

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