Files
envi-code/SourceCode/Code2026/tg_shs/shs_siteplan/RoadArith.h
T

89 lines
4.4 KiB
C++
Raw Normal View History

2026-10-04 00:04:20 +08:00
// Copyright (C), 1998-2007, Beijing Tangent Engineering Software Co. Ltd.
2026-09-28 15:28:50 +08:00
// = FileName: RoadArith.h
// = Version: 8.5
// = Author: lgh
// = Date: 2010-9-7 14:44:54
2026-10-04 00:04:20 +08:00
// = Description: 道路相关密切的一些处理算法
2026-09-28 15:28:50 +08:00
// = Maintainers:
#ifndef __TCH_SITIPLAN_ROADADAPTERFORLINK_H__
#define __TCH_SITIPLAN_ROADADAPTERFORLINK_H__
#include <geray2d.h>
class CRoadArith
{
private:
CRoadArith() {};
~CRoadArith(){};
public:
2026-10-04 00:04:20 +08:00
// 处理道路的倒角
// 按照正常情况考虑问题,排除异常情况
// 返回值:是否正确的执行倒角
// InterCircle:生成的倒角
// 线段跟线段的倒角
2026-09-28 15:28:50 +08:00
static bool InterCircleLineAndLine(AcGeCurve2d *pEnt1, bool bDir1, AcGeCurve2d *pEnt2, bool bDir2,
double dRadius, AcGeCircArc2d &interCircle);
2026-10-04 00:04:20 +08:00
// 线段跟弧线的倒角,参数同上
2026-09-28 15:28:50 +08:00
static bool InterCircleLineAndArc(AcGeCurve2d *pEnt1, bool bDir1, AcGeCurve2d *pEnt2, bool bDir2,
double dRadius, AcGeCircArc2d &interCircle);
static bool InterCircleArcAndLine(AcGeCurve2d *pEnt1, bool bDir1, AcGeCurve2d *pEnt2, bool bDir2,
double dRadius, AcGeCircArc2d &interCircle);
2026-10-04 00:04:20 +08:00
// 弧线跟弧线的倒角,参数同上
2026-09-28 15:28:50 +08:00
static bool InterCircleArcAndArc(AcGeCurve2d *pEnt1, bool bDir1, AcGeCurve2d *pEnt2, bool bDir2,
double dRadius, AcGeCircArc2d &interCircle);
2026-10-04 00:04:20 +08:00
// 倒角线在延长线附近存在两个交点, 应该从中选取一个合适的交点。
2026-09-28 15:28:50 +08:00
static bool TestProperPoint(const AcGeLineSeg2d &line1, bool bStart1, const AcGeCircArc2d &arc2, bool bStart2,
const AcGePoint2d &pt1, const AcGePoint2d &pt2, AcGePoint2d &ptDest);
static bool TestProperPoint(const AcGeCircArc2d &arc1, bool bStart1, const AcGeCircArc2d &arc2, bool bStart2,
const AcGePoint2d &pt1, const AcGePoint2d &pt2, AcGePoint2d &ptDest);
private:
2026-10-04 00:04:20 +08:00
// 交点是否在bDir的方向上。验证点在线上,或者在对应段的延伸线上。
2026-09-28 15:28:50 +08:00
static bool PointInLineDir(const AcGeLineSeg2d &line, bool bDir, const AcGePoint2d &ptInter);
static bool PointInArcDir(const AcGeCircArc2d &arc, bool bDir, const AcGePoint2d &ptInter);
2026-10-04 00:04:20 +08:00
// 计算距离bStart端的距离。
2026-09-28 15:28:50 +08:00
static void NearPtInLine(const AcGeLineSeg2d &line, bool bStart, const AcGePoint2d &pt1, const AcGePoint2d &pt2,
double &dLen1, double &dLen2);
static void NearPtInArc(const AcGeCircArc2d &arc, bool bStart, const AcGePoint2d &pt1, const AcGePoint2d &pt2,
double &dLen1, double &dLen2);
2026-10-04 00:04:20 +08:00
// 判断两线段(圆弧)是否可以执行倒角,如果可以倒角则计算交点
2026-09-28 15:28:50 +08:00
static bool ForCenterLineAndLine(AcGeCurve2d *pEnt1, bool bDir1, AcGeCurve2d *pEnt2, bool bDir2, double dRadius, AcGePoint2d &ptCenter);
static bool ForCenterLineAndArc(AcGeCurve2d *pEnt1, bool bDir1, AcGeCurve2d *pEnt2, bool bDir2, double dRadius, AcGePoint2d &ptCenter);
static bool ForCenterArcAndLine(AcGeCurve2d *pEnt1, bool bDir1, AcGeCurve2d *pEnt2, bool bDir2, double dRadius, AcGePoint2d &ptCenter);
static bool ForCenterArcAndArc(AcGeCurve2d *pEnt1, bool bDir1, AcGeCurve2d *pEnt2, bool bDir2, double dRadius, AcGePoint2d &ptCenter);
2026-10-04 00:04:20 +08:00
// 构造线段所对应的弧线
2026-09-28 15:28:50 +08:00
static AcGeRay2d LineSegToRay(const AcGeLineSeg2d &line, bool bDir);
2026-10-04 00:04:20 +08:00
// 算法:以两个起点相连的线段为例,讲解该偏移算法。
// line1 的两个向量:左向量vecL1,右向量vecR1
// line2 的两个向量:左向量vecL2,右向量vecR2
// line1,line2分别有两个方向向量:dri1, dir2;
// line1、line2的左向量和右向量分别跟对方的方向向量比较。点积为正的即偏移方向。
// 以统一的向量形式来描述两条相交边线的关系。判断他们应该的偏移方向
2026-09-28 15:28:50 +08:00
static bool Off(const AcGeVector2d &vecL1, const AcGeVector2d &vecR1, const AcGeVector2d &vecL2, const AcGeVector2d &vecR2,
const AcGeVector2d &dir1, const AcGeVector2d &dir2, bool &bLeft1, bool &bLeft2);
2026-10-04 00:04:20 +08:00
// 计算两个倒角线的偏向,
// ret:bLeft1, bLeft2;
2026-09-28 15:28:50 +08:00
static bool FindUnitVec(const AcGeLineSeg2d &line1, bool bDir1, const AcGeLineSeg2d &line2, bool bDir2,
bool &bLeft1, bool &bLeft2);
static bool FindUnitVec(const AcGeLineSeg2d &line1, bool bDir1, const AcGeCircArc2d &arc2, bool bDir2,
bool &bLeft1, bool &bIn2);
static bool FindUnitVec(const AcGeCircArc2d &arc1, bool bDir1, const AcGeCircArc2d &arc2, bool bDir2,
bool &bIn1, bool &bIn2);
2026-10-04 00:04:20 +08:00
// 构造圆弧,
2026-09-28 15:28:50 +08:00
static void ConInterCircle(const AcGePoint2d &ptCenter, const AcGePoint2d &pt1, const AcGePoint2d &pt2, AcGeCircArc2d &interArc);
};
#endif