#if !defined(__TAUXTOOLS_H__) #define __TAUXTOOLS_H__ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "dbpl.h" #include extern Adesk::Boolean acedPostCommand(LPCTSTR); class TAuxTools { public: // 求中点 static AcGePoint3d Mid(AcGePoint3d ptGe1, AcGePoint3d ptGe2); // 从圆得到投影到过ptCenter点的某个面的半个或整个椭圆多段线,两圆模拟法 // ptCenter:原圆心, dDia:原圆直径, vtOrigNormal:原圆法向 // vtNewNormal::投影面的法向,polyLine得到的多段线 // vtGet:指示返回哪半个部分, 默认返回整个 // 返回值:-1, 求椭圆时出错,0新旧法向平行,圆形 1:新旧法向垂直,直线 2;正常情况,椭圆 // Lixl 2011-11-24 10:53 重写了此函数,如果投影为椭圆,则返回polyline线是连续的线段,而不是之前的三个弧,投影为圆和直线保持不变 static int GetEllipseFromCircle(AcGePoint3d ptCenter, double dDia, AcGeVector3d vtOrigNormal, AcGeVector3d vtNewNormal, AcDbPolyline &polyLine, AcGeVector3d vtGet = AcGeVector3d::kIdentity); static void GetArcPoint(AcDbPolyline &polyLine, AcGePoint3dArray &ptArcArr); // 功能: 得到圆截面向平面投影后,投影曲线的焦点 // [OUT]: arPtsOnCurve椭圆返回7个点,直线3个点,圆5个点 static int GetEllipsePtsFromCircle(AcGePoint3dArray& arPtsOnCurve, AcGePoint3d ptCenter, double dDia, AcGeVector3d vtOrigNormal, AcGeVector3d vtNewNormal, AcDbPolyline &polyLine, AcGeVector3d vtGet = AcGeVector3d::kIdentity); // 函数功能: 从空间多个圆截面,向得到平行于z轴的平面投影,返回投影椭圆的焦点,用于确定边界构件 // [IN]: ptArr中连续三个点确定一个圆截面 // [IN]: arPtJudge中一个元素对应ptArr中连续三个元素,这个点用于确定投影后得到的投影椭圆或者直线的焦点,那个在外,那个在内 // [OUT]: 函数清空arPtJudge,并将每个圆截面的两个焦点,按距离近和远依次添加到arPtJudge中 static BOOL GetPrjPtsFromCircle(AcGePoint3dArray& ptArr, AcGePoint3dArray& arPtJudge); // pLine转换为TGGeCurveSegment,并添加到TDPtrList中 static void Poly2CurveSeg(AcDbPolyline* pLine, TDPtrList& segComs); // 判断向量是否是倾斜向量(不垂直Z轴,也不平行于Z轴) static BOOL IsIncline(AcGeVector3d& vt); //合并两条Pline线第一个参数为添加后的Pline。 static BOOL MergerPline(AcDbPolyline* pPl, AcDbPolyline* pSrc); //同线三点,判断ptBase在ptSta和ptEnd哪个位置。 static int PositionOnLine(AcGePoint3d ptSta, AcGePoint3d ptEnd, AcGePoint3d ptBase); static BOOL isCodirectionalPt(AcGePoint3d ptSta, AcGePoint3d ptEnd, AcGeVector3d vtBase); static AcGePlane GetHidePlane(AcGePoint3d pt1, AcGePoint3d pt2, AcGePoint3d pt3, AcGeVector3d vtNormal, double &dEle); static BOOL InsertBlock(AcDbVoidPtrArray& entitySet,AcDbObjectId idBlock, AcGePoint3d ptBase, AcGeScale3d ScaleFactor, double dAngle = 0.0); static BOOL GetIntersectWith(AcGePoint3d pt1, AcGePoint3d pt2, AcGePoint3d pt3, AcGePoint3d pt4, AcGePoint3d& ptIntersect); static int Getquadrant(AcGePoint3d ptCenter, AcGePoint3d pt, AcGeVector3d vtMain, AcGeVector3d vtNormal = AcGeVector3d::kZAxis); // 用户XYZ坐标向量 static AcGeVector3d GetUcsXvt(); static AcGeVector3d GetUcsYvt(); static AcGeVector3d GetUcsZvt(); // 圆管沿程阻力 static double CalFricLoss(double dTemp, double dRough, double dDia, double dLength, double dVelocity); // 矩形沿程阻力 static double CalFricLoss(double dTemp, double dRough, double dWidth, double dHeight, double dLength, double dVelocity); // 用于特性表修改某些参数后,更新遮挡关系 static void SetAndUpdateCover(TDbInterfacesObj* pObj, LPCTSTR pszName, TDb::OPMInfo* pInfo); // 获得当前数据库字体样式表 static void GetAllTextStyleNameArray(CStringArray& arTextStyle); // 获取最小分度角(曲面分化成小平面,相邻平面法向量间最小夹角) static double GetMinDiffAngle(); // 构造方截面管状碰撞实体 static void BuildRectDuct(const AcGePoint3d& ptStart, const AcGePoint3d& ptEnd, const AcGeVector3d& vtNormal, const double dSWidth, const double dSThick, const double dEWidth, const double dEThick, TXShell& xShell, const AcGeVector3d* pvtSSide = NULL, const AcGeVector3d* pvtESide = NULL); // 构造圆截面管状碰撞实体 static void BuildCirDuct(const AcGePoint3d& ptStart, const AcGePoint3d& ptEnd, const double dSDiameter, const double dEDismeter, TXShell& xShell, const AcGeVector3d* pvtSRot = NULL, const AcGeVector3d* pvtERot = NULL, const AcGeVector3d* pvtSRotAxis = NULL, const AcGeVector3d* pvtERotAxis = NULL); // 构造包含点集的最小长方体 static void BuildMinRectangle(const AcGePoint3dArray& arpt, AcDbExtents& ext); // 构造一头方一头圆的碰撞实体 static void BuildCir2RectDuct(const AcGePoint3d& ptCir, const AcGePoint3d& ptRec, const AcGeVector3d& vtNormal,const double dDiameter, const double dWidth, const double dThick, TXShell& xShell, const AcGeVector3d* pvtRot = NULL, const AcGeVector3d* pvtCirOut = NULL); // 构造一个矩形碰撞面 static void BuildRecFace(const AcGePoint3d& pt, const double dWidth, const double dThick, const AcGeVector3d& vtNormal, const AcGeVector3d& vtFaceNormal, TXShell& xShell); static void BuildRecFace(const AcGePoint3d& pt, const double dWidth, const double dThick, const AcGeVector3d& vtNormal, const AcGeVector3d& vtFaceNormal, AcDbVoidPtrArray& dbPtArr); // 构造一个圆形碰撞面 static void BuildCirFace(const AcGePoint3d& pt, const double dDiameter, const AcGeVector3d& vtNormal, const AcGeVector3d& vtFaceNormal, TXShell& xShell); static void BuildCirFace(const AcGePoint3d& pt, const double dDiameter, const AcGeVector3d& vtNormal, const AcGeVector3d& vtFaceNormal, AcDbVoidPtrArray& dbPtArr); // 是否联动取值,包括位移、连接、尺寸 static BOOL IsAutoWorkOffset(); static BOOL IsAutoWorkConnect(); static BOOL IsAutoWorkSize(); // 处理TDbInterfacesObj实体位移, // vtOff:作用于改实体偏移向量 idFrom:从何实体传来的指令,ptFrom:从何点传来的指令 static void DealWithConEnt(AcDbObjectId idToDeal, const AcGeVector3d& vtOff, AcDbObjectId idFrom, AcGePoint3d ptFrom); // 处理TDbInterfacesObj实体位移,可以处理多个 static void DealWithConEnt(AcDbObjectIdArray idArrToDeal, const AcGePoint3dArray& ptArrOrig, const AcGePoint3dArray& ptArrNew, AcDbObjectId idFrom); // 获取各接口位置 static BOOL GetInterfacePoint(const TImpSpecFitting* pFit, AcGePoint3dArray &ptArr); // 获取实体各接口连接其他id static BOOL GetInterfaceId(const TImpSpecFitting* pFit, AcDbObjectIdArray &idArr); // 获取面标高 static double GetPlaneEle( const AcGePlane &plan ); //写扩展数据 static BOOL WriteXdata(ads_name name, const TCHAR*szName, const TCHAR*szValue); static BOOL WriteXdata(AcDbObjectId idEnt, const TCHAR*szName, const TCHAR*szValue); //读扩展数据 static CString ReadXdata(ads_name name, const TCHAR*szName); static CString ReadXdata( AcDbObjectId idEnt, const TCHAR*szName); // 通过id获取文字样式名 static TCHAR* GetFontStyle(AcDbObjectId idTextStyle); // 检查偏移向量是否合适以支持联动(判断跟所有接口垂直或平行即可) static BOOL IsEquipAutoMove(TImpSpecEquipment* pImpEquip, AcGeVector3d vtOffset); // 暂拿水力计算中风管提风口找风口方法 static void GetAirLetByDuct(const TDbHvacDuct* pDuct, AcDbObjectIdArray &idArrAir); // 当前视图是不是二维的 static BOOL Is2DView(); // 按指定的精度转换double到字符串 static void DoubleToString(double dValue, int nPreci, CString &csValue); static void Matrix3D2String( const AcGeMatrix3d &mat, CString &str ); // 取得用于剖切的图块ID,比例和图块范围方块 add by hh 2011-02-14 // idSrc:原始图块ID vtNor:法向量 vtMain:主方向 vtPlaneSec:剖切方向 // scale:输入实体与原始图块的比例,输出新比例 pExt:新图块范围 返回新图块ID static AcDbObjectId GetProjBlockId(const AcDbObjectId& idSrc, AcGeVector3d vtNor, AcGeVector3d vtMain, AcGeVector3d vtPlaneSec, AcGeScale3d& scale, AcDbExtents* pExt = NULL); // 从数据库中取出接口记录指针 // 以Read模式打开;返回不为空时,使用后必须进行关闭,无须delete;写操作时需进行升级 static TDbInterfaceRecord* GetIntfPtrFromDB(); // 计算圆弧曲率 static double CalCurvature(const AcGePoint3d& pt1, const AcGePoint3d& pt2, const AcGePoint3d& pt3, const AcGeVector3d* pVtNor); //add by wc 13-12-16// // 通过id得到图块名称 static LPCTSTR GetBlkNameById (AcDbObjectId id); // 是否与Z轴垂直的直线 static BOOL IsVerticalLine(AcGePoint3d pt1, AcGePoint3d pt2); // 计算曲线遮挡 用于水管遮挡风管的情况 static void GetCurveGeomExtentsEdge(AcDbEntity* pEnt, TComplexCurve& crLoop); static void MakeCurvePolyFaces(AcDbEntity* pEnt, AcDbVoidPtrArray& arFaces); private: // 圆管沿程阻力 dFricCoef摩擦系数, dDia直径(mm), dLength:管长, dDensity密度 dVelocity流速(m/s) static double CalCircleFricLoss(double dFricCoef, double dDia, double dLength, double dDensity, double dVelocity); // 摩擦系数:根据粗糙度(mm)、流速当量直径(mm)和雷诺数计算 用柯列勃洛克-怀特公式计算 static double CalFricCoef(double dRough, double dCalDia, double dRe); // 根据管宽(mm)和管高(mm)计算流速当量直径(mm) static double CalVelDia(double dWidth, double dHeight); // 流速(m/s)、流速当量直径(mm)和黏度(m^2/s)计算雷诺数 static double CalRe(double dVelocity, double dVelDia, double dMoveVis) ; // 根据温度计算空气密度 static double CalDesity(double dTemperature); // 根据温度计算运动黏度 static double CalMoveVis(double dTemperature); // 用插值法从一维表格中取值 static double CalTable(double dAbscissa[], double *pTable, double dX, int m); // 暂拿水力计算中风管提风口找风口方法 static void GetAllAirFromModel(AcDbObjectIdArray& arAirId); static BOOL AirIsOnDuct(const AcDbObjectId& idAir, const TDbHvacDuct* pDuct, int& nPos, AcGeVector3d& vtFlux); static int CalPosBy3Point(const AcGePoint3d& pt1, const AcGePoint3d& pt2, const AcGePoint3d& pt3); public: // add by hh 2011-01-04 template static BOOL GetTHvacDataFromDwg(LPCTSTR pszKey, TYPE& value) // 从图纸中读取暖通专业数据 { if(NULL == pszKey) return FALSE; TDbConfig* pTHvacCfg = GetDwgGlobal(AcDb::kForRead); if(NULL == pTHvacCfg) return FALSE; CString csKey = pszKey; if(0 != csKey.Left(6).Compare(EXTENDDATAID)) { csKey.Format(_T("%s%s"), EXTENDDATAID, pszKey); } BOOL bRes = pTHvacCfg->GetFields().GFD(csKey, value); pTHvacCfg->close(); return bRes; } template static BOOL SetTHvacDataToDwg(LPCTSTR pszKey, const TYPE& value) // 写入暖通专业数据到图纸 { if(NULL == pszKey) return FALSE; TDbConfig* pTHvacCfg = GetDwgGlobal(AcDb::kForWrite); if(NULL == pTHvacCfg) return FALSE; CString csKey = pszKey; if(0 != csKey.Left(6).Compare(EXTENDDATAID)) { csKey.Format(_T("%s%s"), EXTENDDATAID, pszKey); } BOOL bRes = pTHvacCfg->Fields().SFD(csKey, value); pTHvacCfg->close(); return bRes; } // add by dyc on 2014-01-21 解决Y型三通在比较大坐标值情况下以后后变成T型问题,求两圆交点 static BOOL CircleInsertWith(const AcGeCircArc3d& circleS, const AcGeCircArc3d& circleE, AcGePoint3d& ptInter1, AcGePoint3d& ptInter2); // 字符串拆分 static int StrTokenize(LPCTSTR pszSrc, LPCTSTR pszDelimit, CStringArray& arSubs); }; #endif // !defined(__TAUXTOOLS_H__)