2706 lines
92 KiB
C++
2706 lines
92 KiB
C++
// PDSMath.h
|
||
|
||
#if !defined(PDSMath_h)
|
||
#define PDSMath_h
|
||
|
||
#include <math.h>
|
||
#include <afxwin.h>
|
||
#include <afxtempl.h>
|
||
|
||
#define CONST_PI 3.14159265359
|
||
#define DBL_MIN 2.2250738585072014e-308
|
||
#define DBL_MAX 1.7976931348623158e+308
|
||
|
||
#define RPG_PT_GNCP 0 //端点(放码非弧线点)
|
||
#define RPG_PT_NGCP 1 //不放码弧线点
|
||
#define RPG_PT_NGNCP 2 //直线点(不放码非弧线点)
|
||
#define RPG_PT_GCP 3 //放码弧线点
|
||
#define RPG_PT_GP 64 //放码值
|
||
#define RPG_PT_INSPT 100 //插值点
|
||
#define RPG_PT_SEAM 128 //份缝点
|
||
#define RPG_PT_NODEF -1 //无定义点
|
||
|
||
#define CONST_MAXDISTANCE 0.05 //对于不在线上的点,默认在线上有对应点的最大距离,单位:mm. 考虑到旧系统中的分辨率为40,所以最小取值0.05mm
|
||
#define F_MAX_TANGENT_ERROR 0.1 //20131015 计算切线时的检索长度,单位:mm
|
||
|
||
#define CONST_SAME_POINT_ERROR 5 // 判断了两个点相等的最大误差值,系统内部单位,距离<=该值的点认为是同一个
|
||
// [20170830 syf]由于使用数据结构支持公式法,导致点链上的点可能相差1个或者2个内部单位,于是增加该宏定义判断相同的两个点
|
||
// 如果相邻点的非常靠近,这种情况经常发生在边线,将会导致计算后的角平分线出错,
|
||
// 所以在边线上获取某点处的前后点时,一定要跨过非常靠近的点
|
||
|
||
//带点类型的点,该类对点的类型没有指定其意义,使用者可根据自己的要求来使用
|
||
class CTypePoint : public CObject
|
||
{
|
||
public:
|
||
CPoint m_ptPoint;
|
||
int m_iType;
|
||
|
||
CTypePoint();
|
||
CTypePoint(CTypePoint &a);
|
||
CTypePoint(CPoint ptPoint,int iType);
|
||
~CTypePoint();
|
||
void operator=(const CTypePoint &a);
|
||
BOOL operator==(CTypePoint& a);
|
||
BOOL operator!=(CTypePoint& a);
|
||
};
|
||
|
||
class CTypePointListArray; // 声明
|
||
|
||
//带类型的点的链表
|
||
class CTypePointList : public CList<CTypePoint,CTypePoint>
|
||
{
|
||
public: //扩展的变量
|
||
public: //扩展的方法
|
||
|
||
CTypePointList& operator=(CTypePointList& rhs); //赋值
|
||
BOOL operator==(CTypePointList& rhs); //等号
|
||
BOOL operator!=(CTypePointList& rhs); //不等号
|
||
CTypePoint& operator[](int iIndex); //根据索引值检索,不可越界
|
||
|
||
//以下查找都是从Head->GetNext->Tail遍历,遇到第一个满足条件者即返回
|
||
|
||
//查找给定点在链表中的索引值
|
||
int FindIndexOfTypePoint(CTypePoint TypePoint);
|
||
|
||
//查找给定点在链表中位置
|
||
POSITION FindPositionOfPoint(CPoint ptPoint);
|
||
|
||
//查找给定点在链表中的索引值
|
||
int FindIndexOfPoint(CPoint ptPoint);
|
||
|
||
//查找给定类型在链表中的位置
|
||
POSITION FindPositionOfType(int iType);
|
||
|
||
//查找给定类型在链表中的索引值
|
||
int FindIndexOfType(int iType);
|
||
|
||
//根据给定的类型与点链设置this
|
||
//特别说明:
|
||
// 设置完成后,this的长度等于listPoint,每个点一一对应,并且this的每一项的类型等于iType
|
||
void SetTypePointList(int iType, CList<CPoint,CPoint>& listPoint);
|
||
|
||
//将this中的点链提取至listPoint
|
||
void ExtractPointList(CList<CPoint,CPoint>& listPoint);
|
||
|
||
//将listPoint设置到this的m_ptPoint中
|
||
void SetOnlyPointList(CList<CPoint,CPoint>& listPoint);
|
||
|
||
//根据指定的类型将this分段
|
||
//特别说明:
|
||
// (1)应用举例,该函数可应用于根据放码点将控制点分段,iType实际上表示bGrade
|
||
// (2)alTypePoint[]至少有两个点,本函数会保证这一点
|
||
// (3)bClose=true,那么至少要保证链表中有两个点等于iType,否则alTypePoint只有一条链表,并且等于this
|
||
//输入参数:
|
||
// bClose =true 闭合,头尾点不能相等,本函数不做判断,=false 开口
|
||
// iType 类型
|
||
//输出参数:
|
||
// alTypePoint 数组,遇到iType的点就要作为该段结束
|
||
void DivideTypePointListEqualType(BOOL bClose, int iType, CTypePointListArray& alTypePoint);
|
||
|
||
//只要类型不等于0就进行分段
|
||
//特别说明:
|
||
// (1)应用举例,该函数可应用于根据缝份数据将实际的分段,m_iType实际上表示缝份数据的指针
|
||
// (2)这样分段过后,每一段的头点与尾点带有缝份数据,而中间的点没有缝份数据,从而对整段计算缝份
|
||
// (3)alTypePoint[]至少有两个点,本函数会保证这一点
|
||
// (4)bClose=true,那么至少要保证链表中有两个点m_iType不为0,否则alTypePoint只有一条链表,并且等于this
|
||
//输入参数:
|
||
// bClose =true 闭合,头尾点不能相等,本函数不做判断,=false 开口
|
||
//输出参数:
|
||
// alTypePoint 数组,如果bClose=true,那么每段的头点与尾点的m_iType都不为0
|
||
void DivideTypePointListWhenTypeNoZero(BOOL bClose, CTypePointListArray& alTypePoint);
|
||
|
||
//根据m_iType的数值排序
|
||
//特别说明:
|
||
// (1)应用举例,m_ptPoint表示交点,m_iType表示该交点与曲线头点的距离(线上长度),那么,Sort之后的交点就是有序的
|
||
//输入参数:
|
||
// bSmallToLarge =true 从小到大,=false 从大到小
|
||
void SortByType(BOOL bSmallToLarge = TRUE);
|
||
|
||
void MakeReverse(); //将this反向
|
||
|
||
POSITION FindPositionOfSmallestType(void); //查找m_iType最小的那个元素的位置
|
||
int FindIndexOfSmallestType(void); // 查找m_iType最小的那个元素的索引值
|
||
|
||
POSITION FindPositionOfLargestType(void); //查找m_iType最大的那个元素的位置
|
||
int FindIndexOfLargestType(void); // 查找m_iType最大的那个元素的索引值
|
||
|
||
//在折线插入点
|
||
//输入参数:
|
||
// ptPoint 给定点
|
||
// dMaxError 判断点在线上的最大误差值
|
||
// iInsertType 插入点时的m_iType值
|
||
//返回值:
|
||
// =true 给定点在this中(输入时已经在this中,或者在this插入),=false 给定点不在this中
|
||
BOOL InsertPointAtPolyline(CPoint ptPoint, double dMaxError, int iInsertType = 0);
|
||
|
||
//在多边形插入点
|
||
//输入参数:
|
||
// ptPoint 给定点
|
||
// dMaxError 判断点在线上的最大误差值
|
||
// iInsertType 插入点时的m_iType值
|
||
//返回值:
|
||
// =true 给定点在this中(输入时已经在this中,或者在this插入),=false 给定点不在this中
|
||
BOOL InsertPointAtPolygon(CPoint ptPoint, double dMaxError, int iInsertType = 0);
|
||
|
||
//查找最近点
|
||
CPoint FindNearestPoint(CPoint ptPoint);
|
||
//查找最近点并输出最近距离
|
||
CPoint FindNearestPoint(CPoint ptPoint, int& nDistance);
|
||
//根据最大误差值查找最近点
|
||
BOOL FindNearestPoint(CPoint ptPoint, double dMaxError, CPoint& ptOutput);
|
||
};
|
||
|
||
//类型点链表的数组
|
||
class CTypePointListArray : public CArray<CTypePointList,CTypePointList&>
|
||
{
|
||
public: //扩展的变量
|
||
public: //扩展的方法
|
||
|
||
CTypePointListArray& operator=(CTypePointListArray& rhs); //赋值
|
||
};
|
||
|
||
class CRPGrade_Point : public CObject {
|
||
public:
|
||
CPoint m_ptPoint;
|
||
int m_nType;
|
||
long n_SerNo;
|
||
|
||
public:
|
||
|
||
CRPGrade_Point();
|
||
CRPGrade_Point(CRPGrade_Point &a);
|
||
CRPGrade_Point(CPoint ptPoint,int nType,long nSerNo);
|
||
CRPGrade_Point(CPoint ptPoint,int nType);
|
||
~CRPGrade_Point();
|
||
void operator=(CRPGrade_Point &a);
|
||
};
|
||
|
||
class CRotateMove : public CObject {
|
||
public:
|
||
double m_dAngle; //旋转的角度
|
||
double m_dSin,m_dCos; //旋转的角度正,余弦,引入此变量是为了不重复计算
|
||
CPoint m_ptPointO; //旋转原点
|
||
CPoint m_ptOffset; //偏移量
|
||
|
||
public:
|
||
CRotateMove();
|
||
CRotateMove(CRotateMove& rhs);
|
||
CRotateMove(double dAngle,CPoint ptPointO,CPoint ptOffset);
|
||
~CRotateMove();
|
||
void operator=(CRotateMove &a);
|
||
|
||
void Initial();
|
||
};
|
||
|
||
class CRotateMoveList : public CList<CRotateMove,CRotateMove>
|
||
{
|
||
public: //扩展的变量
|
||
public: //扩展的方法
|
||
|
||
CRotateMoveList& operator=(CRotateMoveList& rhs); //赋值
|
||
CRotateMove& operator[](int iIndex); //根据索引值检索,不可越界
|
||
};
|
||
|
||
class CDBLPoint : public CObject {
|
||
public:
|
||
double x,y;
|
||
|
||
public:
|
||
CDBLPoint();
|
||
CDBLPoint(double x1,double y1);
|
||
CDBLPoint(CDBLPoint &a);
|
||
~CDBLPoint();
|
||
void operator=(CDBLPoint &a);
|
||
BOOL operator==(CDBLPoint &a);
|
||
|
||
//使用ptPoint设置this
|
||
void SetPoint(CPoint ptPoint);
|
||
|
||
//返回CPoint点
|
||
CPoint GetPoint(void);
|
||
};
|
||
|
||
class CDBLPointList : public CList<CDBLPoint,CDBLPoint>
|
||
{
|
||
public: //扩展的变量
|
||
public: //扩展的方法
|
||
|
||
CDBLPointList& operator=(CDBLPointList& rhs); //赋值
|
||
CDBLPoint& operator[](int iIndex); //根据索引值检索,不可越界
|
||
|
||
//使用listPoint设置this
|
||
void SetPoint(CList<CPoint,CPoint>& listPoint);
|
||
|
||
//将this中的点输出到listPoint
|
||
void GetPoint(CList<CPoint,CPoint>& listPoint);
|
||
};
|
||
|
||
class CDBLPointListArray : public CArray<CDBLPointList,CDBLPointList&>
|
||
{
|
||
public: //扩展的变量
|
||
public: //扩展的方法
|
||
|
||
CDBLPointListArray& operator=(CDBLPointListArray& rhs); //赋值
|
||
};
|
||
|
||
class C4PRgn : public CObject {
|
||
public:
|
||
CPoint m_ptLU,m_ptLD,m_ptRU,m_ptRD; //字符串显示时占用的区域m_ptLU→m_ptRU→m_ptRD→m_ptLD→m_ptLU
|
||
|
||
public:
|
||
C4PRgn();
|
||
C4PRgn(C4PRgn &a);
|
||
C4PRgn(CPoint ptLU,CPoint ptLD,CPoint ptRU,CPoint ptRD);
|
||
void operator=(C4PRgn &a);
|
||
BOOL operator==(C4PRgn& a);
|
||
};
|
||
|
||
//线段
|
||
class CLineSegment : public CObject
|
||
{
|
||
public:
|
||
CPoint m_ptPointS; // 起点
|
||
CPoint m_ptPointE; // 终点
|
||
|
||
public:
|
||
CLineSegment();
|
||
CLineSegment(CPoint ptPointS, CPoint ptPointE);
|
||
CLineSegment(CLineSegment& rhs);
|
||
virtual ~CLineSegment();
|
||
CLineSegment& operator=(CLineSegment& rhs);
|
||
BOOL operator==(CLineSegment& rhs);
|
||
|
||
void Initial();
|
||
};
|
||
|
||
//线段的链表
|
||
class CLineSegmentList : public CList<CLineSegment,CLineSegment>
|
||
{
|
||
public: //扩展的变量
|
||
public: //扩展的方法
|
||
|
||
CLineSegmentList& operator=(CLineSegmentList& rhs); //赋值
|
||
CLineSegment& operator[](int iIndex); //根据索引值检索,不可越界
|
||
};
|
||
|
||
//线段链表的数组
|
||
class CLineSegmentListArray : public CArray<CLineSegmentList,CLineSegmentList&>
|
||
{
|
||
public: //扩展的变量
|
||
public: //扩展的方法
|
||
|
||
CLineSegmentListArray& operator=(CLineSegmentListArray& rhs); //赋值
|
||
};
|
||
|
||
//四舍五入取整
|
||
//输入参数:
|
||
// x
|
||
//返回值:
|
||
// 四舍五入后的整数
|
||
int IntRound(double x);
|
||
|
||
//样点旋转
|
||
//输入参数:
|
||
// (nPx,nPy)被旋转点,(x,y)旋转原点,dSinBeta,dCosBeta逆时针旋转角度的正余弦
|
||
//输出参数:
|
||
// (nPxNew,nPyNew)旋转后的值
|
||
void PointRotate(int nPx,int nPy,int x,int y,double dSinBeta,double dCosBeta,int& nPxNew,int& nPyNew);
|
||
void PointRotate(double dX,double dY,double dXO,double dYO,double dSinBeta,double dCosBeta,double& dXNew,double& dYNew);
|
||
//样点旋转
|
||
//输入参数:
|
||
// ptPoint被旋转点,ptPointO旋转原点,dSinBeta,dCosBeta逆时针旋转角度的正余弦
|
||
//输出参数:
|
||
// ptPoint旋转后的值
|
||
void PointRotate(CPoint &ptPoint,CPoint ptPointO,double dSinBeta,double dCosBeta);
|
||
|
||
//样点旋转
|
||
//输入参数:
|
||
// listPoint1被旋转的点链,ptPointO旋转原点,dSinBeta,dCosBeta逆时针旋转角度的正余弦
|
||
//输出参数:
|
||
// listPoint2旋转后的值
|
||
void PointRotate(CList<CPoint,CPoint> &listPoint1,CPoint ptPointO,double dSinBeta,double dCosBeta,CList<CPoint,CPoint> &listPoint2);
|
||
|
||
//样点平移
|
||
//输入参数:
|
||
// listPoint1被平移的点链
|
||
// nDx,nDy XY轴的平移量
|
||
//输出参数:
|
||
// listPoint2平移后的值
|
||
void PointMove(CList<CPoint,CPoint> &listPoint1,int nDx,int nDy,CList<CPoint,CPoint> &listPoint2);
|
||
|
||
//将ptPoint坐标缩放
|
||
//输入参数:
|
||
// ptPoint 给定点
|
||
// dScale >1放大,<1缩小
|
||
//返回值:
|
||
// 放大缩小后的点
|
||
CPoint PointScale(CPoint ptPoint,double dScale);
|
||
//以ptPointO为坐标原点,将ptPoint缩放dScale
|
||
CPoint PointScale(CPoint ptPoint,CPoint ptPointO,double dScale);
|
||
//以ptPointO为坐标原点,沿ptPointO,ptPoint1为方向,将ptPoint缩放dScale
|
||
CPoint PointScale(CPoint ptPoint,CPoint ptPointO,CPoint ptPoint1,double dScale);
|
||
|
||
//对给定点进行先平移后再缩放
|
||
//输入参数:
|
||
// ptPoint 给定点
|
||
// ptOffset 平移量
|
||
// dScale 缩放
|
||
//返回值:
|
||
// 平移缩放后的点
|
||
CPoint PointMoveScale(CPoint ptPoint,CPoint ptOffset,double dScale);
|
||
|
||
//20140603 对给定点平移旋转
|
||
//输入参数:
|
||
// ptPoint 给定点
|
||
// ptOrignalS 转圆心S
|
||
// ptOrignalE 旋转圆心E
|
||
// ptRotateS 旋转点S
|
||
// ptRotateE 旋转点E
|
||
//返回值:
|
||
// 平移旋转点
|
||
CPoint PointMoveRotate(CPoint ptPoint, CPoint ptOrignalS, CPoint ptOrignalE, CPoint ptRotateS, CPoint ptRotateE);
|
||
|
||
//20140603 对给定点平移旋转
|
||
//输入参数:
|
||
// listPoint 给定点链
|
||
// ptOrignalS 转圆心S
|
||
// ptOrignalE 旋转圆心E
|
||
// ptRotateS 旋转点S
|
||
// ptRotateE 旋转点E
|
||
//输出参数:
|
||
// listMoveRotatePoint平移旋转点链
|
||
void PointMoveRotate(CList<CPoint, CPoint> &listPoint, CPoint ptOrignalS, CPoint ptOrignalE, CPoint ptRotateS, CPoint ptRotateE, CList<CPoint, CPoint> &listMoveRotatePoint);
|
||
|
||
//解一元二次方程ax2+bx+c=0
|
||
//返回值:
|
||
// =0,无解
|
||
// =1,有一个解x1(x2=x1)
|
||
// =2,有两个解x1,x2
|
||
// =3,有无穷解或无实根
|
||
int Quadratic(double a,double b,double c,double& x1,double& x2);
|
||
|
||
//求直线方程ax+by+c=0的系数
|
||
//输入参数:
|
||
// (x1,y1),(x2_y2) 直线上两点的坐标
|
||
//输出参数:
|
||
// a,b,c 直线方程ax+by+c=0的系数
|
||
void LineEquationCoefficient(int x1,int y1,int x2,int y2,double& a,double& b,double& c);
|
||
void LineEquationCoefficient(double x1,double y1,double x2,double y2,double& a,double& b,double& c);
|
||
|
||
//求直线方程ax+by+c=0的系数
|
||
//输入参数:
|
||
// ptPoint1,ptPoint2 直线上两点的坐标
|
||
//输出参数:
|
||
// a,b,c 直线方程ax+by+c=0的系数
|
||
void LineEquationCoefficient(CPoint ptPoint1,CPoint ptPoint2,double& a,double& b,double& c);
|
||
|
||
//求两直线的交点
|
||
//输入参数
|
||
// a1,b1,c1 直线a1*x+b1*y+c1=0
|
||
// a2,b2,c2 直线a2*x+b2*y+c2=0
|
||
//输出参数
|
||
// (x,y) 交点坐标
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,有交点(x,y)
|
||
// =2,两直线重合
|
||
int IntOfTwoLine(double a1,double b1,double c1,double a2,double b2,double c2,double& x,double& y);
|
||
|
||
//求两直线的交点
|
||
//输入参数
|
||
// a1,b1,c1 直线a1*x+b1*y+c1=0
|
||
// a2,b2,c2 直线a2*x+b2*y+c2=0
|
||
//输出参数
|
||
// (nx,ny) 交点坐标
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,有交点(nx,ny)
|
||
// =2,两直线重合
|
||
int IntOfTwoLine(double a1,double b1,double c1,double a2,double b2,double c2,int& nx,int& ny);
|
||
|
||
//求两直线的交点
|
||
//输入参数
|
||
// (nXS1,nYS1),(nXE1,nYE1) 直线1的起点和终点坐标
|
||
// (nXS2,nYS2),(nXE2,nYE2) 直线2的起点和终点坐标
|
||
//输出参数
|
||
// (nx,ny) 交点坐标
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,有交点(nx,ny)
|
||
// =2,两直线重合
|
||
int IntOfTwoLine(int nXS1,int nYS1,int nXE1,int nYE1,int nXS2,int nYS2,int nXE2,int nYE2,int& nx,int& ny);
|
||
|
||
//求两直线的交点
|
||
//输入参数
|
||
// PointS1_PointE1 直线1的起点和终点
|
||
// PointS2_PointE2 直线2的起点和终点
|
||
//输出参数
|
||
// ptIntersection 交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,有交点ptIntersection
|
||
// =2,两直线重合
|
||
int IntOfTwoLine(POINT PointS1,POINT PointE1,POINT PointS2,POINT PointE2,POINT& ptIntersection);
|
||
|
||
//求两直线段的交点
|
||
//输入参数
|
||
// (nXS1,nYS1),(nXE1,nYE1) 直线段1的起点和终点坐标
|
||
// (nXS2,nYS2),(nXE2,nYE2) 直线段2的起点和终点坐标
|
||
//输出参数
|
||
// (nx,ny) 交点坐标
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,交点同时在两条线段内(包括两端点),交点(nx,ny)
|
||
// =2,交点不在线段内(包括两端点),交点(nx,ny)
|
||
// =3,没有共同端点的重叠线段,两线段在同一直线上(有一个以上的交点)且没有共同的端点
|
||
// =4,有共同端点的不重叠线段,两线段在同一直线上且只有一个端点重叠(nx,ny)
|
||
// =5,有共同端点的重叠线段,其中(nx,ny)是重叠部分中非共同的端点
|
||
int IntOfTwoLineSegment(int nXS1,int nYS1,int nXE1,int nYE1,int nXS2,int nYS2,int nXE2,int nYE2,int& nx,int& ny);
|
||
|
||
//求两直线段的交点
|
||
//输入参数
|
||
// PointS1_PointE1 直线段1的起点和终点
|
||
// PointS2_PointE2 直线段2的起点和终点
|
||
//输出参数
|
||
// ptIntersection 交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,交点同时在两条线段内(包括两端点),交点ptIntersection
|
||
// =2,交点不在线段内(包括两端点),交点ptIntersection
|
||
// =3,没有共同端点的重叠线段,两线段在同一直线上(有一个以上的交点)且没有共同的端点
|
||
// =4,有共同端点的不重叠线段,两线段在同一直线上且只有一个端点重叠ptIntersection
|
||
// =5,有共同端点的重叠线段,其中ptIntersection是重叠部分中非共同的端点
|
||
int IntOfTwoLineSegment(POINT PointS1,POINT PointE1,POINT PointS2,POINT PointE2,POINT& ptIntersection);
|
||
|
||
//求直线和直线段的交点!!!
|
||
//特别说明:
|
||
// 该函数是求一条直线和一条线段的交点,而不是求两条线段或两条直线的交点!!!
|
||
// 参见IntOfTwoLineSegment(...),IntOfTwoLine(...).
|
||
//输入参数
|
||
// a1,b1,c1 直线a1*x+b1*y+c1=0
|
||
// (nXS2,nYS2),(nXE2,nYE2) 线段的起点和终点坐标
|
||
//输出参数
|
||
// ptIntersection 交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,交点在线段内(包括两端点),交点(nx,ny)
|
||
// =2,交点不在线段内(包括两端点),交点(nx,ny)
|
||
// =3,直线和线段在同一直线上
|
||
int IntOfLineLineSegment(double a1,double b1,double c1,int nXS2,int nYS2,int nXE2,int nYE2,int& nx,int& ny);
|
||
|
||
//求直线和直线段的交点!!!
|
||
//特别说明:
|
||
// 该函数是求一条直线和一条线段的交点,而不是求两条线段或两条直线的交点!!!
|
||
// 参见IntOfTwoLineSegment(...),IntOfTwoLine(...).
|
||
//输入参数
|
||
// a1,b1,c1 直线a1*x+b1*y+c1=0
|
||
// PointS2,PointE2 线段的起点和终点坐标
|
||
//输出参数
|
||
// ptIntersection 交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,交点在线段内(包括两端点),交点ptIntersection
|
||
// =2,交点不在线段内(包括两端点),交点ptIntersection
|
||
// =3,直线和线段在同一直线上
|
||
int IntOfLineLineSegment(double a1,double b1,double c1,POINT PointS2,POINT PointE2,POINT& ptIntersection);
|
||
|
||
//求直线和直线段的交点!!!
|
||
//特别说明:
|
||
// 该函数是求一条直线和一条线段的交点,而不是求两条线段或两条直线的交点!!!
|
||
// 参见IntOfTwoLineSegment(...),IntOfTwoLine(...).
|
||
//输入参数
|
||
// (nXS1,nYS1),(nXE1,nYE1) 直线的起点和终点坐标
|
||
// (nXS2,nYS2),(nXE2,nYE2) 线段的起点和终点坐标
|
||
//输出参数
|
||
// (nx,ny) 交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,交点在线段内(包括两端点),交点(nx,ny)
|
||
// =2,交点不在线段内(包括两端点),交点(nx,ny)
|
||
// =3,直线和线段在同一直线上
|
||
int IntOfLineLineSegment(int nXS1,int nYS1,int nXE1,int nYE1,int nXS2,int nYS2,int nXE2,int nYE2,int& nx,int& ny);
|
||
|
||
//求直线和直线段的交点!!!
|
||
//特别说明:
|
||
// 该函数是求一条直线和一条线段的交点,而不是求两条线段或两条直线的交点!!!
|
||
// 参见IntOfTwoLineSegment(...),IntOfTwoLine(...).
|
||
//输入参数
|
||
// PointS1_PointE1 直线的起点和终点
|
||
// PointS2_PointE2 线段的起点和终点
|
||
//输出参数
|
||
// ptIntersection 交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,交点在线段内(包括两端点),交点ptIntersection
|
||
// =2,交点不在线段内(包括两端点),交点ptIntersection
|
||
// =3,直线和线段在同一直线上
|
||
int IntOfLineLineSegment(POINT PointS1,POINT PointE1,POINT PointS2,POINT PointE2,POINT& ptIntersection);
|
||
//求矢量ptPointS1→ptPointE1和矢量ptPointS2→ptPointE2的交点!!!
|
||
//输入参数
|
||
// PointS1,PointE1 矢量ptPointS1→ptPointE1
|
||
// PointS2,PointE2 矢量ptPointS2→ptPointE2
|
||
//输出参数
|
||
// ptIntersection 交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,有交点ptIntersection
|
||
// =2,两直线重合
|
||
int IntOfTwoVectorLine(POINT PointS1,POINT PointE1,POINT PointS2,POINT PointE2,POINT& ptIntersection);
|
||
|
||
//直线和圆的交点
|
||
//输入参数:
|
||
// a,b,c 直线:ax+by+c=0;
|
||
// (xc,yc) 圆心
|
||
// nR 半径
|
||
//输出参数:
|
||
// lpptIntersection1,lpptIntersection2 直线和圆的两个交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,一个交点
|
||
// =2,两个交点
|
||
int IntOfLineCircle(double a,double b,double c,int xc,int yc,int nR,LPPOINT lpptIntersection1,LPPOINT lpptIntersection2);
|
||
|
||
//直线和圆的交点
|
||
//输入参数:
|
||
// ptPointS,ptPointE 直线的起止点
|
||
// ptCenter 圆心
|
||
// nRadius 半径
|
||
//输出参数:
|
||
// lpptIntersection1,lpptIntersection2 直线和圆的两个交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,一个交点
|
||
// =2,两个交点
|
||
int IntOfLineCircle(POINT ptPointS,POINT ptPointE,POINT ptCenter,int nRadius,LPPOINT lpptIntersection1,LPPOINT lpptIntersection2);
|
||
|
||
//直线和圆的交点
|
||
//输入参数:
|
||
// ptPointS,ptPointE 直线的起止点
|
||
// ptCenter 圆心
|
||
// nRadius 半径
|
||
//输出参数:
|
||
// ptIntersection1,ptIntersection2 直线和圆的两个交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,一个交点
|
||
// =2,两个交点
|
||
int IntOfLineCircle(POINT ptPointS,POINT ptPointE,POINT ptCenter,int nRadius,CPoint& ptIntersection1,CPoint& ptIntersection2);
|
||
|
||
//直线段和圆的交点
|
||
//输入参数:
|
||
// ptPointS,ptPointE 直线段的起止点
|
||
// ptCenter 圆心
|
||
// nRadius 半径
|
||
//输出参数:
|
||
// lpptIntersection1,lpptIntersection2 直线和圆的两个交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,一个交点(包括两端点)
|
||
// =2,两个交点(包括两端点)
|
||
int IntOfLineSegmentCircle(POINT ptPointS,POINT ptPointE,POINT ptCenter,int nRadius,LPPOINT lpptIntersection1,LPPOINT lpptIntersection2);
|
||
|
||
//直线段和圆的交点
|
||
//输入参数:
|
||
// ptPointS,ptPointE 直线段的起止点
|
||
// ptCenter 圆心
|
||
// nRadius 半径
|
||
//输出参数:
|
||
// ptIntersection1,ptIntersection2 直线段和圆的两个交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,一个交点(包括两端点)
|
||
// =2,两个交点(包括两端点)
|
||
int IntOfLineSegmentCircle(POINT ptPointS,POINT ptPointE,POINT ptCenter,int nRadius,CPoint& ptIntersection1,CPoint& ptIntersection2);
|
||
|
||
//折线和圆的交点
|
||
//输入参数:
|
||
// listPolyline 折线
|
||
// ptCenter 圆心
|
||
// nRadius 半径
|
||
//输出参数:
|
||
// listIntPoint 折线和圆的交点
|
||
//返回值
|
||
// 交点个数(=0,没有交点)
|
||
int IntOfPolylineCircle(CList<CPoint,CPoint> &listPolyline,POINT ptCenter,int nRadius,CList<CPoint,CPoint> &listIntPoint);
|
||
|
||
//求两圆的交点
|
||
//输入参数
|
||
// x1,y1,r1 圆:(x-x1)*(x-x1) + (y-y1)*(y-y1) = r1*r1
|
||
// x2,y2,r2 圆:(x-x2)*(x-x2) + (y-y2)*(y-y2) = r2*r2
|
||
//输出参数
|
||
// (nIntX1,nIntY1),(nIntX2,nIntY2) 两交点坐标
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,有一个交点
|
||
// =2,有两个交点
|
||
int IntOfTwoCircle(int x1,int y1,int r1,int x2,int y2,int r2,int& nIntX1,int& nIntY1,int& nIntX2,int& nIntY2);
|
||
|
||
//求两圆的交点
|
||
//输入参数
|
||
// ptCenter1,nRadius1 圆心和半径
|
||
// ptCenter2,nRadius2 圆心和半径
|
||
//输出参数
|
||
// lpptIntersection1,lpptIntersection2 两交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,有一个交点
|
||
// =2,有两个交点
|
||
int IntOfTwoCircle(POINT ptCenter1,int nRadius1,POINT ptCenter2,int nRadius2,LPPOINT lpptIntersection1,LPPOINT lpptIntersection2);
|
||
|
||
//求两圆的交点
|
||
//输入参数
|
||
// ptCenter1,nRadius1 圆心和半径
|
||
// ptCenter2,nRadius2 圆心和半径
|
||
//输出参数
|
||
// ptIntersection1,ptIntersection2 两交点
|
||
//返回值
|
||
// =0,没有交点
|
||
// =1,有一个交点
|
||
// =2,有两个交点
|
||
int IntOfTwoCircle(POINT ptCenter1,int nRadius1,POINT ptCenter2,int nRadius2,CPoint& ptIntersection1,CPoint& ptIntersection2);
|
||
|
||
//求线段和折线的交点
|
||
//特别所明:
|
||
// 该函数是求线段和折线中的各线段的交点,而不是求直线和折线中的各线段的交点!!!
|
||
// 参见IntOfLinePolyline(...).
|
||
//输入参数
|
||
// ptPointS,ptPointE 直线的两点
|
||
// listPolyline 折线
|
||
//输出参数
|
||
// listIntPoint 交点链
|
||
//返回值
|
||
// 交点个数
|
||
int IntOfLineSegmentPolyline(CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint>& listPolyline,CList<CPoint,CPoint>& listIntPoint);
|
||
//与IntOfLineSegmentPolyline(...)相比,IntOfLineSegmentPolyline_Old(...)有个错误(包括了一句"case 2:")
|
||
int IntOfLineSegmentPolyline_Old(CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint>& listPolyline,CList<CPoint,CPoint>& listIntPoint);
|
||
|
||
//求矢量ptPointS→ptPointE和折线的交点!!!
|
||
//特别所明:
|
||
// 该函数是求矢量和折线中的各线段的交点,而不是求直线(或直线段)和折线中的各线段的交点!!!
|
||
// 要求交点在线段ptPointS_ptPointE上或在矢量ptPointS→ptPointE的延长线上
|
||
// 参见IntOfLineSegmentPolyline(...)和IntOfLinePolyline(...).
|
||
//输入参数
|
||
// ptPointS,ptPointE 矢量ptPointS→ptPointE
|
||
// listPolyline 折线
|
||
//输出参数
|
||
// listIntPoint 交点链
|
||
//返回值
|
||
// 交点个数
|
||
int IntOfVectorLinePolyline(CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint>& listPolyline,CList<CPoint,CPoint>& listIntPoint);
|
||
|
||
//求直线和折线的交点!!!
|
||
//特别所明:
|
||
// 该函数是求直线和折线中的各线段的交点,而不是求直线段和折线中的各线段的交点!!!
|
||
// 参见IntOfLineSegmentPolyline(...).
|
||
//输入参数
|
||
// ptPointS,ptPointE 直线的两点
|
||
// listPolyline 折线
|
||
//输出参数
|
||
// listIntPoint 交点链
|
||
//返回值
|
||
// 交点个数
|
||
int IntOfLinePolyline(CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint>& listPolyline,CList<CPoint,CPoint>& listIntPoint);
|
||
|
||
//求直线和折线的交点!!!
|
||
//特别所明:
|
||
// 该函数是求直线和折线中的各线段的交点,而不是求直线段和折线中的各线段的交点!!!
|
||
// 参见IntOfLineSegmentPolyline(...).
|
||
//输入参数
|
||
// a,b,c 直线方程ax+by+c=0
|
||
// listPolyline 折线
|
||
//输出参数
|
||
// listIntPoint 交点链
|
||
//返回值
|
||
// 交点个数
|
||
int IntOfLinePolyline(double a,double b,double c,CList<CPoint,CPoint>& listPolyline,CList<CPoint,CPoint>& listIntPoint);
|
||
|
||
//求直线和折线链头的延长线的交点
|
||
//输入参数
|
||
// ptPointS,ptPointE 直线的两点
|
||
// listPolyline 折线
|
||
// dLength 用于计算延长线时的搜索长度
|
||
//输出参数
|
||
// ptIntPoint 交点
|
||
//返回值
|
||
// 交点个数
|
||
int IntOfLinePolylineExtendHead(CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint>& listPolyline,double dLength,CPoint &ptIntPoint);
|
||
int IntOfLinePolylineExtendHead(double a,double b,double c,CList<CPoint,CPoint>& listPolyline,double dLength,CPoint &ptIntPoint);
|
||
|
||
//求直线和折线链尾的延长线的交点
|
||
//输入参数
|
||
// ptPointS,ptPointE 直线的两点
|
||
// listPolyline 折线
|
||
// dLength 用于计算延长线时的搜索长度
|
||
//输出参数
|
||
// ptIntPoint 交点
|
||
//返回值
|
||
// 交点个数
|
||
int IntOfLinePolylineExtendTail(CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint>& listPolyline,double dLength,CPoint &ptIntPoint);
|
||
int IntOfLinePolylineExtendTail(double a,double b,double c,CList<CPoint,CPoint>& listPolyline,double dLength,CPoint &ptIntPoint);
|
||
|
||
//求折线和折线的交点
|
||
//输入参数
|
||
// listPolyline1 折线
|
||
// listPolyline2 折线
|
||
//输出参数
|
||
// listIntPoint 交点链,交点以在listPolyline1的出现顺序从头到尾排列
|
||
//返回值
|
||
// 交点个数
|
||
int IntOfTwoPolyline(CList<CPoint,CPoint>& listPolyline1,CList<CPoint,CPoint>& listPolyline2,CList<CPoint,CPoint>& listIntPoint);
|
||
|
||
//[20161229 syf]求折线和折线的交点
|
||
//特别说明:
|
||
// (1)该函数拷贝IntOfTwoPolyline()代码,但是在判断IntOfTwoLineSegment()的返回值时,{1,4,5}都被采用,而IntOfTwoPolyline()仅仅采用=1的情况
|
||
//输入参数
|
||
// listPolyline1 折线
|
||
// listPolyline2 折线
|
||
//输出参数
|
||
// listIntPoint 交点链,交点以在listPolyline1的出现顺序从头到尾排列
|
||
//返回值
|
||
// 交点个数
|
||
int IntOfTwoPolyline_101(CList<CPoint,CPoint>& listPolyline1,CList<CPoint,CPoint>& listPolyline2,CList<CPoint,CPoint>& listIntPoint);
|
||
|
||
//匹配两直线段的交点
|
||
//输入参数
|
||
// ptPoint
|
||
// dMaxError 最大匹配距离
|
||
// ptPointS1_ptPointE1 直线段1的起点和终点
|
||
// ptPointS2_ptPointE2 直线段2的起点和终点
|
||
//输出参数
|
||
// ptIntersection 交点
|
||
// dDistance 实际距离
|
||
//返回值
|
||
// 若两直线段的交点ptIntersection与ptPoint的距离<=dMaxError,则返回true.否则false.
|
||
BOOL FixPointIntOfTwoLineSegment(POINT ptPoint,double dMaxError,POINT ptPointS1,POINT ptPointE1,
|
||
POINT ptPointS2,POINT ptPointE2,POINT& ptIntersection,double& dDistance);
|
||
|
||
//匹配线段和圆的交点
|
||
//输入参数:
|
||
// ptPoint
|
||
// dMaxError 最大匹配距离
|
||
// ptPointS,ptPointE 直线段的起止点
|
||
// ptCenter 圆心
|
||
// nRadius 半径
|
||
//输出参数
|
||
// ptIntersection 交点
|
||
// dDistance 实际距离
|
||
//返回值
|
||
// 若线段和圆的交点ptIntersection与ptPoint的距离<=dMaxError,则返回true.否则false.
|
||
BOOL FixPointIntOfLineSegmentCircle(POINT ptPoint,double dMaxError,POINT ptPointS,POINT ptPointE,
|
||
POINT ptCenter,int nRadius,POINT& ptIntersection,double& dDistance);
|
||
|
||
//匹配两圆的交点
|
||
//输入参数
|
||
// ptPoint
|
||
// dMaxError 最大匹配距离
|
||
// ptCenter1,nRadius1 圆心和半径
|
||
// ptCenter2,nRadius2 圆心和半径
|
||
//输出参数
|
||
// ptIntersection 交点
|
||
// dDistance 实际距离
|
||
//返回值
|
||
// 若两圆的交点ptIntersection与ptPoint的距离<=dMaxError,则返回true.否则false.
|
||
BOOL FixPointIntOfTwoCircle(POINT ptPoint,double dMaxError,POINT ptCenter1,int nRadius1,
|
||
POINT ptCenter2,int nRadius2,POINT& ptIntersection,double& dDistance);
|
||
|
||
//匹配线段和折线的交点
|
||
//输入参数
|
||
// ptPoint
|
||
// dMaxError 最大匹配距离
|
||
// ptPointS,ptPointE 线段
|
||
// listPolyline 折线
|
||
//输出参数
|
||
// ptIntersection 交点
|
||
// dDistance 实际距离
|
||
// nLocate 交点位置(第nLocate个交点)
|
||
//返回值
|
||
// 若线段和折线的交点ptIntersection与ptPoint的距离<=dMaxError,则返回true.否则false.
|
||
BOOL FixPointIntOfLineSegmentPolyline(POINT ptPoint,double dMaxError,POINT ptPointS,
|
||
POINT ptPointE,CList <CPoint,CPoint> &listPolyline,
|
||
POINT &ptIntersection,double &dDistance,int& nLocate);
|
||
|
||
//匹配两折线的交点
|
||
//输入参数
|
||
// ptPoint
|
||
// dMaxError 最大匹配距离
|
||
// listPolyline1 折线1
|
||
// listPolyline2 折线2
|
||
//输出参数
|
||
// ptIntersection 交点
|
||
// dDistance 实际距离
|
||
// nLocate 交点位置(第nLocate个交点)
|
||
//返回值
|
||
// 若折线的交点ptIntersection与ptPoint的距离<=dMaxError,则返回true.否则false.
|
||
BOOL FixPointIntOfTwoPolyline(POINT ptPoint,double dMaxError,CList <CPoint,CPoint> &listPolyline1,
|
||
CList <CPoint,CPoint> &listPolyline2,POINT &ptIntersection,double &dDistance,int& nLocate);
|
||
|
||
//滤点
|
||
//将完全在(ptPoint.x-nMaxError,ptPoint.y-nMaxError)__(ptPoint.x+nMaxError,ptPoint.y-nMaxError)
|
||
//之外的线段点删除
|
||
//输入参数:
|
||
// ptPoint 域的中心点
|
||
// nMaxError 域的半径
|
||
// listPoint1 滤点前的点链
|
||
//输出参数:
|
||
// listPoint2 滤点后的点链
|
||
void FilterPointOfListPoint(POINT ptPoint,int nMaxError,CList <CPoint,CPoint> &listPoint1,CList <CPoint,CPoint> &listPoint2);
|
||
|
||
//求过点(nPx,nPy)和直线ax+by+c=0垂直的直线与直线ax+by+c=0的交点(nFixX,nFixY)
|
||
//输入参数
|
||
// (nPx,nPy)给定点的坐标
|
||
// a,b,c 给定直线的系数
|
||
//输出参数
|
||
// (nFixX,nFixY)交点坐标
|
||
void IntOfLinePointVL(int nPx,int nPy,double a,double b,double c,int& nFixX,int& nFixY);
|
||
void IntOfLinePointVL(double dPx,double dPy,double a,double b,double c,double& dFixX,double& dFixY);
|
||
|
||
//求过点ptPoint1和直线ax+by+c=0垂直的直线与直线ax+by+c=0的交点ptPoint2
|
||
//输入参数
|
||
// ptPoint1给定点的坐标
|
||
// a,b,c 给定直线的系数
|
||
//输出参数
|
||
// ptPoint2交点坐标
|
||
void IntOfLinePointVL(CPoint ptPoint1,double a,double b,double c,CPoint& ptPoint2);
|
||
|
||
//求过点ptPoint1和直线ptPoint2_ptPoint3垂直的直线与直线ptPoint2_ptPoint3的交点ptPoint4
|
||
//输入参数
|
||
// ptPoint1给定点的坐标
|
||
// ptPoint2,ptPoint3 给定直线的两点
|
||
//输出参数
|
||
// ptPoint4交点坐标
|
||
void IntOfLinePointVL(CPoint ptPoint1,CPoint ptPoint2,CPoint ptPoint3,CPoint& ptPoint4);
|
||
|
||
//以(x2,y2)_(x3,y3)为对称轴的对称点
|
||
//输入参数;
|
||
// (x1,y1) 给定点
|
||
// (x2,y2)_(x3,y3) 给定对称轴
|
||
//输出参数:
|
||
// (nPx,nPy) 对称点
|
||
void SymmetryPoint(int x1,int y1,int x2,int y2,int x3,int y3,int& nPx,int& nPy);
|
||
//以ptPoint2_ptPoint3为对称轴的对称点
|
||
//输入参数;
|
||
// ptPoint1 给定点
|
||
// ptPoint2_ptPoint3 给定对称轴
|
||
//输出参数:
|
||
// ptPoint4 对称点
|
||
void SymmetryPoint(CPoint ptPoint1,CPoint ptPoint2,CPoint ptPoint3,CPoint &ptPoint4);
|
||
//以ptPoint1_ptPoint2为对称轴的对称点
|
||
//输入参数;
|
||
// listPoint1 给定点链
|
||
// ptPoint1_ptPoint2 给定对称轴
|
||
//输出参数:
|
||
// listPoint2 对称点链
|
||
void SymmetryPoint(CList<CPoint,CPoint> &listPoint1,CPoint ptPoint1,CPoint ptPoint2,CList<CPoint,CPoint> &listPoint2);
|
||
//以直线ax+by+c=0为对称轴的对称点
|
||
//输入参数;
|
||
// listPoint1 给定点链
|
||
// a,b,c 给定对称轴的直线方程
|
||
//输出参数:
|
||
// listPoint2 对称点链
|
||
void SymmetryPoint(CList<CPoint,CPoint> &listPoint1,double a,double b,double c,CList<CPoint,CPoint> &listPoint2);
|
||
void SymmetryPoint(CList<CDBLPoint,CDBLPoint> &listDBLPoint1,double a,double b,double c,CList<CDBLPoint,CDBLPoint> &listDBLPoint2);
|
||
//以直线ax+by+c=0为对称轴的对称点
|
||
//输入参数;
|
||
// (x1,y1) 给定点
|
||
// a,b,c 给定对称轴的直线方程
|
||
//输出参数:
|
||
// (nPx,nPy) 对称点
|
||
void SymmetryPoint(int x1,int y1,double a,double b,double c,int& nPx,int& nPy);
|
||
void SymmetryPoint(double x1,double y1,double a,double b,double c,double& dPx,double& dPy);
|
||
//以直线ax+by+c=0为对称轴的对称点
|
||
//输入参数;
|
||
// ptPoint1 给定点
|
||
// a,b,c 给定对称轴的直线方程
|
||
//输出参数:
|
||
// ptPoint2 对称点
|
||
void SymmetryPoint(CPoint ptPoint1,double a,double b,double c,CPoint& ptPoint2);
|
||
void SymmetryPoint(CDBLPoint ptDBLPoint1,double a,double b,double c,CDBLPoint& ptDBLPoint2);
|
||
|
||
//求两点确定的直线与X轴的夹角,在[0,2pi)之间
|
||
//输入参数:
|
||
// (startx,starty) 起点
|
||
// (endx,endy) 终点
|
||
//返回值:
|
||
// 夹角
|
||
double angle_2(int startx,int starty,int endx,int endy);
|
||
//[20170330 syf]
|
||
double angle_2(double startx,double starty,double endx,double endy);
|
||
|
||
//求两点确定的直线与X轴的夹角,在[0,2pi)之间
|
||
//输入参数:
|
||
// ptPointS 起点
|
||
// ptPointE 终点
|
||
//返回值:
|
||
// 夹角
|
||
double angle_2(POINT ptPointS,POINT ptPointE);
|
||
|
||
//[20170330 syf]
|
||
double angle_2(CDBLPoint ptPointS,CDBLPoint ptPointE);
|
||
|
||
//求矢量ptPointS1→ptPointE1逆时针方向旋转到矢量ptPointS2→ptPointE2的方向所经过的夹角,在[0,2pi)之间
|
||
//输入参数:
|
||
// ptPointS1,ptPointE1 矢量ptPointS1→ptPointE1
|
||
// ptPointS2,ptPointE2 矢量ptPointS2→ptPointE2
|
||
//返回值:
|
||
// 夹角
|
||
double angle_2(POINT ptPointS1,POINT ptPointE1,POINT ptPointS2,POINT ptPointE2);
|
||
|
||
//[20170330 syf]
|
||
double angle_2(CDBLPoint ptPointS1,CDBLPoint ptPointE1,CDBLPoint ptPointS2,CDBLPoint ptPointE2);
|
||
|
||
//给定弧线上三点(x1,y1),(x2,y2)和(x3,y3),以及圆心(cx,cy),
|
||
//其中(x2,y2)在(x1,y1)和(x3,y3)中间,按逆时针方向画弧时,
|
||
//当(x1,y1)是起点,(x3,y3)是终点时返回true,否则返回false
|
||
//特别说明:此处所说的逆时针是指显示器而言,对X向右为正,Y向上为正的坐标系来说此处是顺时针
|
||
BOOL IsAnticlockwise(long x1,long y1,long x2,long y2,long x3,long y3,long cx,long cy);
|
||
|
||
//[20170330 syf]
|
||
BOOL IsAnticlockwise_Double(double x1,double y1,double x2,double y2,double x3,double y3,double cx,double cy);
|
||
|
||
///////////////////////// 计算三点定圆时的圆心和半径 ///////////////////////////
|
||
// 输入参数:三个样点(x1,y1),(x2,y2),(x3,y3)
|
||
// 算法描述:
|
||
// 过(x1,y1),(x2,y2)的中点作垂线L1,
|
||
// 过(x2,y2),(x3,y3)的中点作垂线L2,
|
||
// 求L1,L2的交点.
|
||
// 输出参数:
|
||
// 如果不能形成圆返回false,
|
||
// 否则返回true其中圆心为(cx,cy),半径=cr.
|
||
// 按逆时针方向画弧时,如cr>0 则(x1,y1)是起点,(x3,y3)是终点,
|
||
// 如cr<0 则(x3,y3)是起点,(x1,y1)是终点.
|
||
// 特别说明:此处所说的逆时针是指显示器而言,如果对于对X向右为正,
|
||
// Y向上为正的坐标系来说此处是顺时针
|
||
////////////////////////////////////////////////////////////////////////////////
|
||
BOOL CircleCR(int x1,int y1,int x2,int y2,int x3,int y3,int& cx,int& cy,int& cr);
|
||
|
||
//[20170330 syf]
|
||
BOOL CircleCR(double x1,double y1,double x2,double y2,double x3,double y3,double& cx,double& cy,double& cr);
|
||
|
||
//求圆和一半径线(ptCenter和ptPoint的连线)的交点
|
||
//输入参数
|
||
// ptCenter 圆心
|
||
// nRadius 半径
|
||
// ptPoint 半径上的一点
|
||
//返回值
|
||
// 交点
|
||
CPoint IntOfCircleRadial(CPoint ptCenter,int nRadius,CPoint ptPoint);
|
||
|
||
//用追赶法求解三对角线方程组: AX=D
|
||
// ┌ ┐ ┌ ┐ ┌ ┐
|
||
// │ a00 a01 │ │x0 │ │d0 │
|
||
// │ a10 a11 a12 0 │ │x1 │ │d1 │
|
||
// │ a21 a22 a23 │ │x2 │ │d2 │
|
||
// │ . . . │ │. │ │. │
|
||
// A=│ . . . │, X=│. │, D=│. │
|
||
// │ . . . │ │. │ │. │
|
||
// │ 0 an-2,n-3 an-2,n-2 an-2,n-1 │ │xn-2│ │dn-2│
|
||
// │ an-1,n-2 an-1,n-1 │ │xn-1│ │dn-1│
|
||
// └ ┘ └ ┘ └ ┘
|
||
//输入参数:
|
||
// a[] 存放三对角线矩阵A的一维数组a00,a01,a10,a11,a12,a21,a22,a23,...,(an-1,n-2),(an-1,n-1)
|
||
// n 变量个数,方程组的阶数
|
||
// d[] 方程组右端的常数向量
|
||
//输出参数
|
||
// 有唯一解时返回TRUE,其中d[]是方程组的解.
|
||
// 否则返回FALSE.
|
||
BOOL Cetrd1(double *a,int n,double *d);
|
||
|
||
//求解带左下角右上角的三对角线方程组: AX=D
|
||
// ┌ ┐ ┌ ┐ ┌ ┐
|
||
// │ a00 a01 a0n │ │x0 │ │d0 │
|
||
// │ a10 a11 a12 0 │ │x1 │ │d1 │
|
||
// │ a21 a22 a23 │ │x2 │ │d2 │
|
||
// │ . . . │ │. │ │. │
|
||
// A=│ . . . │, X=│. │, D=│. │
|
||
// │ . . . │ │. │ │. │
|
||
// │ 0 an-2,n-3 an-2,n-2 an-2,n-1 │ │xn-2│ │dn-2│
|
||
// │ an-1,0 an-1,n-2 an-1,n-1 │ │xn-1│ │dn-1│
|
||
// └ ┘ └ ┘ └ ┘
|
||
//输入参数:
|
||
// a[] 存放矩阵A的一维数组a00,a01,a0n,a10,a11,a12,0,a21,a22,a23,0,...,(an-1,0),(an-1,n-2),(an-1,n-1)
|
||
// n 变量个数,方程组的阶数
|
||
// d[] 方程组右端的常数向量
|
||
//输出参数
|
||
// 有唯一解时返回TRUE,其中d[]是方程组的解.
|
||
// 否则返回FALSE.
|
||
BOOL Cetrd2(double *a,int n,double *d);
|
||
|
||
//对给定的型值点用二次Bezier曲线进行拟合,再用折线逼近.
|
||
// ┌ 1 -2 1 ┐┌P1 ┐
|
||
// P(t)=[t2 t 1]│-2 2 0 ││p2 │
|
||
// └ 1 0 0 ┘└p3 ┘
|
||
//输入参数:
|
||
// listSP是型值点链.
|
||
// dMaxError 最大拟合误差(>=0.5)
|
||
//输出参数:
|
||
// 拟合成功返回true,
|
||
// listFitP是根据拟合曲线得到的逼近折线样点链.
|
||
// 否则返回false,listFitP中的数据和listSP相同
|
||
BOOL BezierCurve(CList<CPoint,CPoint>& listSP,double dMaxError,CList<CPoint,CPoint>& listFitP);
|
||
|
||
//说明: 根据参数求2次Bezier上的一个点
|
||
//输入参数:
|
||
// (dX1,dY1),(dX2,dY2),(dX3,dY3) 2次Bezier的三个控制点
|
||
// dT 参数T
|
||
//返回值:
|
||
// point 与dT对应的点
|
||
CPoint BezierPoint(double dX1, double dY1, double dX2, double dY2, double dX3, double dY3, double dT);
|
||
//求与2次Bezier线上给定方向的切线的切点的参数值
|
||
//输入参数:
|
||
// (dX1,dY1),(dX2,dY2),(dX3,dY3) 2次Bezier的三个控制点
|
||
// pointS,pointE 切线方向(两点不能相同)
|
||
//返回值:
|
||
// 切点的参数
|
||
double BezierPointParam(double dX1, double dY1, double dX2, double dY2, double dX3, double dY3, CPoint pointS,CPoint pointE);
|
||
|
||
//对给定的型值点用参数(弦长)三次样条曲线进行拟合,再用折线逼近.
|
||
//输入参数:
|
||
// listSP是型值点链.
|
||
// bClose =fasle,开口曲线, =true 闭合周期曲线(此时要求型值点链的头和尾表示的是同一点).
|
||
// dMaxError 最大拟合误差(>=0.5)
|
||
// bNatural =true 自由端边界条件,=false 抛物线边界条件
|
||
//输出参数:
|
||
// 拟合成功返回true,
|
||
// listFitP是根据拟合曲线得到的逼近折线样点链.
|
||
// 特别说明:闭合周期曲线的逼近折线listFitP的头和尾两点坐标不相同!!!
|
||
// 否则返回false.
|
||
BOOL SplineCurve(CList<CPoint,CPoint>& listSP,BOOL bClose,double dMaxError,CList<CPoint,CPoint>& listFitP,BOOL bNatural=true);
|
||
|
||
//对给定的型值点用参数(弦长)三次样条曲线进行拟合,再用折线逼近.
|
||
//输入参数:
|
||
// listSP是型值点链.
|
||
// bClose =fasle,开口曲线, =true 闭合周期曲线(此时要求型值点链的头和尾表示的是同一点).
|
||
// dMaxError 最大拟合误差(>=0.5)
|
||
// bTangentH =true 起点有切线条件
|
||
// ptTangentH 起点有切线条件时切线上的点
|
||
// bTangentT =true 终点有切线条件
|
||
// ptTangentT 终点有切线条件时切线上的点
|
||
// bNatural =true 自由端边界条件,=false 抛物线边界条件
|
||
//输出参数:
|
||
// 拟合成功返回true,
|
||
// listFitP是根据拟合曲线得到的逼近折线样点链.
|
||
// 特别说明:闭合周期曲线的逼近折线listFitP的头和尾两点坐标不相同!!!
|
||
// 否则返回false.
|
||
BOOL SplineCurve(CList<CPoint,CPoint>& listSP,BOOL bClose,double dMaxError,CList<CPoint,CPoint>& listFitP,BOOL bTangentH,CPoint ptTangentH,BOOL bTangentT,CPoint ptTangentT,BOOL bNatural);
|
||
|
||
//对给定的型值点用Bezier曲线或参数(弦长)三次样条曲线进行拟合,再用折线逼近.
|
||
//特别说明:
|
||
// 当型值点的个数是3且是开口线时使用Bezier曲线,否则使用样条曲线
|
||
//输入参数:
|
||
// listSP是型值点链.
|
||
// bClose =fasle,开口曲线, =true 闭合周期曲线(此时要求型值点链的头和尾表示的是同一点).
|
||
// dMaxError 最大拟合误差(>=0.5)
|
||
// bNatural =true 自由端边界条件,=false 抛物线边界条件
|
||
//输出参数:
|
||
// 拟合成功返回true,
|
||
// listFitP是根据拟合曲线得到的逼近折线样点链.
|
||
// 特别说明:闭合周期曲线的逼近折线listFitP的头和尾两点坐标不相同!!!
|
||
// 否则返回false.
|
||
BOOL CurveFit(CList<CPoint,CPoint>& listSP,BOOL bClose,double dMaxError,CList<CPoint,CPoint>& listFitP,BOOL bNatural=true);
|
||
//对给定的型值点用Bezier曲线或参数(弦长)三次样条曲线进行拟合,再用折线逼近.
|
||
//特别说明:
|
||
// 当型值点的个数是3且起止点没有切线条件的开口线时使用Bezier曲线,否则使用样条曲线
|
||
//输入参数:
|
||
// listSP是型值点链.
|
||
// bClose =fasle,开口曲线, =true 闭合周期曲线(此时要求型值点链的头和尾表示的是同一点).
|
||
// dMaxError 最大拟合误差(>=0.5)
|
||
// bTangentH =true 起点有切线条件
|
||
// ptTangentH 起点有切线条件时切线上的点
|
||
// bTangentT =true 终点有切线条件
|
||
// ptTangentT 终点有切线条件时切线上的点
|
||
// bNatural =true 自由端边界条件,=false 抛物线边界条件
|
||
//输出参数:
|
||
// 拟合成功返回true,
|
||
// listFitP是根据拟合曲线得到的逼近折线样点链.
|
||
// 特别说明:闭合周期曲线的逼近折线listFitP的头和尾两点坐标不相同!!!
|
||
// 否则返回false.
|
||
BOOL CurveFit(CList<CPoint,CPoint>& listSP,BOOL bClose,double dMaxError,CList<CPoint,CPoint>& listFitP,BOOL bTangentH,CPoint ptTangentH,BOOL bTangentT,CPoint ptTangentT,BOOL bNatural);
|
||
|
||
//计算NURBS曲线的实际点链(非均匀有理B样条)
|
||
//特别说明:
|
||
// 本函数调用API计算,不需要传入拟合误差
|
||
//输入参数:
|
||
// listSP 型值点链,坐标系:既可以是纸样坐标系,又可以是设备坐标系
|
||
// bClose =true 闭合,=false 开口
|
||
//输出参数:
|
||
// listFitP 根据拟合曲线得到的逼近折线样点链,如果闭合,那么头尾点坐标不同!!!
|
||
//返回值:
|
||
// =true 计算成功,=false 计算失败
|
||
BOOL CurveFit_NURBS(CList<CPoint,CPoint>& listSP, CList<CPoint,CPoint>& listFitP, BOOL bClose = FALSE);
|
||
|
||
//反求开口曲线的控制点
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listFitPoint 原始点链
|
||
// dMaxError 最大误差
|
||
//输出参数:
|
||
// listCtrlPoint 控制点链
|
||
BOOL GetControlPointOfOpenCurve(int iDPMM,CList<CRPGrade_Point,CRPGrade_Point> &listFitPoint,double dMaxError,CList<CRPGrade_Point,CRPGrade_Point> &listCtrlPoint);
|
||
|
||
//反求开口曲线的控制点
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listFitPoint 原始点链
|
||
// dMaxError 最大误差
|
||
// listCtrlPoint 已有的控制点
|
||
//输出参数:
|
||
// listCtrlPoint 控制点链,listCtrlPoint的起点和终点的坐标不相同
|
||
BOOL GetControlPointOfOpenCurve(int iDPMM,CList<CPoint,CPoint> &listFitPoint,double dMaxError,CList<CPoint,CPoint> &listCtrlPoint);
|
||
|
||
//反求闭合曲线的控制点,listFitPoint的起点和终点的坐标不相同
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listFitPoint 原始点链
|
||
// dMaxError 最大误差
|
||
//输出参数:
|
||
// listCtrlPoint 控制点链,listCtrlPoint的起点和终点的坐标不相同
|
||
BOOL GetControlPointOfCloseCurve(int iDPMM,CList<CRPGrade_Point,CRPGrade_Point> &listFitPoint,
|
||
double dMaxError,CList<CRPGrade_Point,CRPGrade_Point> &listCtrlPoint);
|
||
|
||
//反求闭合曲线的控制点,listFitPoint的起点和终点的坐标不相同
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listFitPoint 原始点链
|
||
// dMaxError 最大误差
|
||
// listCtrlPoint 已有的控制点
|
||
//输出参数:
|
||
// listCtrlPoint 控制点链
|
||
BOOL GetControlPointOfCloseCurve(int iDPMM,CList<CPoint,CPoint> &listFitPoint,double dMaxError,CList<CPoint,CPoint> &listCtrlPoint);
|
||
|
||
//在点链listPointOld中的点与点链listPointNew的最小距离中的最大距离点
|
||
//输入参数:
|
||
// listPointOld 点链
|
||
// listPointNew 点链
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
//输出参数:
|
||
// dMaxDistance 最大距离
|
||
//返回值:
|
||
// 找到的最大距离点
|
||
CPoint MaxDistancePoint(int iDPMM,CList<CPoint,CPoint> &listPointOld,CList<CPoint,CPoint> &listPointNew,double &dMaxDistance);
|
||
|
||
//判断多边形点链从头到尾的方向
|
||
//输入参数:
|
||
// listPolygon 多边形的点链.
|
||
//返回值:
|
||
// =true 逆时针(显示器坐标系),=false 顺时针(显示器坐标系)
|
||
BOOL IsAnticlockwise(CList<CPoint,CPoint>& listPolygon);
|
||
|
||
//使点链的方向变反,链头不变.
|
||
//输入参数:
|
||
// listPoint1 点链.
|
||
//输出参数:
|
||
// listPoint2
|
||
void Reverse(CList<CPoint,CPoint>& listPoint1,CList<CPoint,CPoint>& listPoint2);
|
||
//使点链的方向变反,链尾变成链头.
|
||
//输入参数:
|
||
// listPoint1 点链.
|
||
//输出参数:
|
||
// listPoint2
|
||
void ReverseT2H(CList<CPoint,CPoint>& listPoint1,CList<CPoint,CPoint>& listPoint2);
|
||
|
||
//翻转
|
||
//输入参数:
|
||
// listPoint1 待翻转的点链
|
||
// x 水平翻转的对称轴
|
||
// bHorizontal =true 水平翻转
|
||
// y 垂直翻转的对称轴
|
||
// bVertical =true 垂直翻转
|
||
//输出参数:
|
||
// listPoint2 已翻转的点链
|
||
void Flip(CList<CPoint,CPoint> &listPoint1,int x,BOOL bHorizontal,int y,BOOL bVertical,CList<CPoint,CPoint> &listPoint2);
|
||
//翻转
|
||
//输入参数:
|
||
// ptPoint 待翻转的点链
|
||
// x 水平翻转的对称轴
|
||
// bHorizontal =true 水平翻转
|
||
// y 垂直翻转的对称轴
|
||
// bVertical =true 垂直翻转
|
||
//输出参数:
|
||
// ptPoint 已翻转的点
|
||
void Flip(CPoint &ptPoint,int x,BOOL bHorizontal,int y,BOOL bVertical);
|
||
|
||
//点ptPoint到直线ax+by+c=0的距离
|
||
double DistanceOfPL(CPoint ptPoint,double a,double b,double c);
|
||
//点ptPoint到直线ptPointL1_ptPointL2的距离
|
||
double DistanceOfPL(CPoint ptPoint,CPoint ptPointL1,CPoint ptPointL2);
|
||
//点ptPoint到线段ptPointL1_ptPointL2的距离
|
||
double DistanceOfPLineSegment(CPoint ptPoint,CPoint ptPointL1,CPoint ptPointL2);
|
||
//点ptPoint到折线listPolyline的最近距离
|
||
double DistanceOfPPloyline(CPoint ptPoint,CList<CPoint,CPoint> &listPolyline);
|
||
|
||
//去掉点链中相同的点,若点链中有相同的点则只保留一个
|
||
void RemoveSamePointOfPolygon(CList<CPoint,CPoint>& listPoint);
|
||
//[20170330 syf]
|
||
void RemoveSamePointOfPolygon(CDBLPointList& listPoint);
|
||
|
||
//去掉点链中相同的点,若点链中有相同的点则只保留一个
|
||
//与RemoveSamePointOfPolygon不同的是首尾点相同时不再去掉一点
|
||
void RemoveSamePointOfPolyline(CList<CPoint,CPoint>& listPoint);
|
||
|
||
//[20170330 syf]
|
||
void RemoveSamePointOfPolyline(CDBLPointList& listPoint);
|
||
|
||
//删除距离<=dMinLength的点
|
||
void Remove2NearPointOfPolygon(CList<CPoint,CPoint>& listPoint,double dMinLength);
|
||
//删除距离<=dMinLength的点
|
||
void Remove2NearPointOfPolyline(CList<CPoint,CPoint>& listPoint,double dMinLength);
|
||
|
||
//20160602 XQ 删除链中所有点距离<=dMinLength的点
|
||
void RemoveAll2NearPointOfPolyline(CList<CPoint,CPoint>& listPoint,double dMinLength);
|
||
|
||
//求多边形中的一段折线.
|
||
//将多边形从点ptPointS顺时针(显示器坐标系)方向移动到点ptPointE所经过的区域.
|
||
//若ptPointS==ptPointE,则是从ptPointS到ptPointE的整条点链
|
||
//特别说明:
|
||
// ptPointS,ptPointE不一定是多边形的顶点.
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPolygon 多边形的点链.
|
||
// ptPointS,ptPointE折线段的起止点.
|
||
//输出参数:
|
||
// listPolyline 折线的点链
|
||
//返回值:
|
||
// true 成功,否则false.
|
||
BOOL PolylineOfPolygon(int iDPMM,CList<CPoint,CPoint>& listPolygon,CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint>& listPolyline);
|
||
|
||
//求多边形中的一段折线.
|
||
//将多边形从点ptPointS先经过ptPointM再到点ptPointE所经过的区域.
|
||
//特别说明:
|
||
// ptPointS,ptPointM,ptPointE不一定是多边形的顶点.
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPolygon 多边形的点链.
|
||
// ptPointS,ptPointE折线段的端点.
|
||
// ptPointM 中间点
|
||
//输出参数:
|
||
// listPolyline 折线的点链
|
||
//返回值:
|
||
// true 成功,否则false.
|
||
BOOL PolylineOfPolygon(int iDPMM,CList<CPoint,CPoint>& listPolygon,CPoint ptPointS,CPoint ptPointM,CPoint ptPointE,CList<CPoint,CPoint>& listPolyline);
|
||
|
||
//求多边形中的一段折线.
|
||
//将多边形从点ptPointS前向移动到点ptPointE所经过的区域.若ptPointS==ptPointE则是从ptPointS开始
|
||
//到ptPointE结束的整条点链.
|
||
//特别说明:
|
||
// ptPointS,ptPointE不一定是多边形的顶点.
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPolygon 多边形的点链.
|
||
// ptPointS,ptPointE折线段的起止点.
|
||
//输出参数:
|
||
// listPolyline 折线的点链
|
||
//返回值:
|
||
// true 成功,否则false.
|
||
BOOL PrevPolylineOfPolygon(int iDPMM,CList<CPoint,CPoint>& listPolygon,CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint>& listPolyline);
|
||
|
||
//求多边形中的一段折线.
|
||
//将多边形从点ptPointS后向移动到点ptPointE所经过的区域.若ptPointS==ptPointE则是从ptPointS开始
|
||
//到ptPointE结束的整条点链.
|
||
//特别说明:
|
||
// ptPointS,ptPointE不一定是多边形的顶点.
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPolygon 多边形的点链.
|
||
// ptPointS,ptPointE折线段的起止点.
|
||
//输出参数:
|
||
// listPolyline 折线的点链
|
||
//返回值:
|
||
// true 成功,否则false.
|
||
BOOL NextPolylineOfPolygon(int iDPMM,CList<CPoint,CPoint>& listPolygon,CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint>& listPolyline);
|
||
|
||
//求折线的点ptPointS与点ptPointE之间的一段折线.
|
||
//特别说明:
|
||
// ptPointS,ptPointE不一定是折线的顶点.
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPolyline1 原折线的点链.
|
||
// ptPointS,ptPointE折线段的起止点.
|
||
//输出参数:
|
||
// listPolyline2 新折线的点链
|
||
//返回值:
|
||
// 成功true,否则false.
|
||
BOOL PolylineOfPolyline(int iDPMM,CList<CPoint,CPoint>& listPolyline1,CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint>& listPolyline2);
|
||
|
||
//求折线的起点与点ptPointE之间的一段折线.
|
||
//特别说明:
|
||
// ptPointE不一定是折线的顶点.
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPolyline1 原折线的点链.
|
||
// ptPointE折线段的终点.
|
||
//输出参数:
|
||
// listPolyline2 新折线的点链
|
||
//返回值:
|
||
// 成功true,否则false.
|
||
BOOL PolylineOfPolylineS(int iDPMM,CList<CPoint,CPoint>& listPolyline1,CPoint ptPointE,CList<CPoint,CPoint>& listPolyline2);
|
||
|
||
//求折线的点ptPointS与终点之间的一段折线.
|
||
//特别说明:
|
||
// ptPointS不一定是折线的顶点.
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPolyline1 原折线的点链.
|
||
// ptPointE折线段的终点.
|
||
//输出参数:
|
||
// listPolyline2 新折线的点链
|
||
//返回值:
|
||
// 成功true,否则false.
|
||
BOOL PolylineOfPolylineE(int iDPMM,CList<CPoint,CPoint>& listPolyline1,CPoint ptPointS,CList<CPoint,CPoint>& listPolyline2);
|
||
|
||
//求折线的从点ptPointS开始,经过点ptPointM到端点(起点或终点)之间的一段折线.
|
||
//特别说明:
|
||
// ptPointS,ptPointM不一定是多边形的顶点.
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPolyline1 原折线的点链.
|
||
// ptPointS,ptPointM折线段的起止点.
|
||
//输出参数:
|
||
// listPolyline2 新折线的点链
|
||
//返回值:
|
||
// 成功true,否则false.
|
||
BOOL PolylineOfPolylineSM(int iDPMM,CPoint ptPointS,CPoint ptPointM,CList<CPoint,CPoint>& listPolyline1,CList<CPoint,CPoint>& listPolyline2);
|
||
|
||
//求依次经过ptArcPointS,ptArcPointM,ptArcPointE的圆的多边形表示
|
||
//输入参数:
|
||
// ptCirclePointS,ptCirclePointM,ptCirclePointE 圆依次经过的点
|
||
// dMaxError 最大逼近误差
|
||
//输出参数:
|
||
// listPolygon 多边形点链
|
||
//返回值:
|
||
// 成功true,否则false.
|
||
BOOL PolygonOfCircle(CPoint ptCirclePointS,CPoint ptCirclePointM,CPoint ptCirclePointE,CList<CPoint,CPoint>& listPolygon,double dMaxError=0.5);
|
||
|
||
//[20170330 syf]
|
||
BOOL PolygonOfCircle(CDBLPoint ptCirclePointS,CDBLPoint ptCirclePointM,CDBLPoint ptCirclePointE,CDBLPointList& listPolygon,double dMaxError=0.5);
|
||
|
||
//求圆逆时针方向(显示器坐标)的多边形表示.
|
||
//输入参数:
|
||
// ptCenter 圆心
|
||
// ptCirclePointS 圆的起点
|
||
// dMaxError 最大逼近误差
|
||
//输出参数:
|
||
// listPolygon 多边形点链
|
||
//返回值:
|
||
// 成功true,否则false.
|
||
BOOL PolygonOfCircle(CPoint ptCenter,CPoint ptCirclePointS,CList<CPoint,CPoint>& listPolygon,double dMaxError=0.5);
|
||
|
||
//[20170330 syf]
|
||
BOOL PolygonOfCircle(CDBLPoint ptCenter,CDBLPoint ptCirclePointS,CDBLPointList& listPolygon,double dMaxError=0.5);
|
||
|
||
//求依次经过ptArcPointS,ptArcPointM,ptArcPointE的弧线的折线表示.
|
||
//输入参数:
|
||
// ptArcPointS,ptArcPointM,ptArcPointE 弧线依次经过的点
|
||
// dMaxError 最大逼近误差
|
||
//输出参数:
|
||
// listPolyline 折线点链
|
||
//返回值:
|
||
// 成功true,否则false.
|
||
BOOL PolylineOfArc(CPoint ptArcPointS,CPoint ptArcPointM,CPoint ptArcPointE,CList<CPoint,CPoint>& listPolyline,double dMaxError=0.5);
|
||
|
||
//[20170330 syf]
|
||
BOOL PolylineOfArc(CDBLPoint ptArcPointS,CDBLPoint ptArcPointM,CDBLPoint ptArcPointE,CDBLPointList& listPolyline,double dMaxError=0.5);
|
||
|
||
//求弧线的折线表示.
|
||
//输入参数:
|
||
// ptCenter 圆心
|
||
// ptArcPointS 弧线起点
|
||
// dAngle 扇形角度,>=0 逆时针(显示器坐标系),<0 顺时针(显示器坐标系),单位:弧度
|
||
// dMaxError 最大逼近误差
|
||
//输出参数:
|
||
// listPolyline 折线点链
|
||
//返回值:
|
||
// 成功true,否则false.
|
||
BOOL PolylineOfArc(CPoint ptCenter,CPoint ptArcPointS,double dAngle,CList<CPoint,CPoint>& listPolyline,double dMaxError=0.5);
|
||
|
||
//[20170330 syf]
|
||
BOOL PolylineOfArc(CDBLPoint ptCenter,CDBLPoint ptArcPointS,double dAngle,CDBLPointList& listPolyline,double dMaxError=0.5);
|
||
|
||
//判断一点是否在多边形内
|
||
//输入参数:
|
||
// point 给定点
|
||
// lpPoints[0]...lpPoints[nCount-1] 多边形的顶点
|
||
//返回值:
|
||
// =true 点在多边形内
|
||
// =false 点不在多边形内
|
||
BOOL PointInPolygon(POINT point,LPPOINT lpPoints,int nCount);
|
||
|
||
//判断一点是否在多边形内
|
||
//输入参数:
|
||
// point 给定点
|
||
// listPolygon 多边形的点链
|
||
//返回值:
|
||
// =true 点在多边形内
|
||
// =false 点不在多边形内
|
||
BOOL PointInPolygon(POINT point,CList<CPoint,CPoint>& listPolygon);
|
||
|
||
//求与直线P1P2相距nD的平行直线的方程,直线在矢量P1P2的左侧(显示器坐标系)
|
||
//重要说明:
|
||
// 在程序中是按X向右为正,Y向上为正的坐标系计算的,故所求直线是在矢量P1P2的右侧
|
||
//输入参数:
|
||
// (nX1,nY1),(nX2,nY2) 直线P1P2的两点
|
||
// nD 所求直线和给定直线P1P2的距离
|
||
//输出参数:
|
||
// 当(nX1,nY1),(nX2,nY2)不是同一点时返回true, a,b,c 所求得的直线:ax+b*y+c=0;
|
||
// 当(nX1,nY1),(nX2,nY2)是同一点时返回fasle.
|
||
BOOL LineParallel(int nX1,int nY1,int nX2,int nY2,int nD,double& a,double& b,double& c);
|
||
|
||
//求与直线P1P2相距nD的平行直线的方程,直线在矢量P1P2的左侧(显示器坐标系)
|
||
//重要说明:
|
||
// 在程序中是按X向右为正,Y向上为正的坐标系计算的,故所求直线是在矢量P1P2的右侧
|
||
//输入参数:
|
||
// ptPoint1,ptPoint2 直线P1P2的两点
|
||
// nD 所求直线和给定直线P1P2的距离
|
||
//输出参数:
|
||
// 当ptPoint1,ptPoint2不是同一点时返回true, a,b,c 所求得的直线:ax+b*y+c=0
|
||
// 当ptPoint1,ptPoint2是同一点时返回fasle.
|
||
BOOL LineParallel(CPoint ptPoint1,CPoint ptPoint2,int nD,double& a,double& b,double& c);
|
||
|
||
//求一条点链的边界矩形
|
||
CRect GetRectOfListPoint(CList<CPoint,CPoint>& listPoint);
|
||
|
||
//求两个整数的公约数
|
||
//输入参数
|
||
// nNum1,nNum2 两个需要求公约数的整数
|
||
//返回值:
|
||
// nNum1,nNum2的公约数(若nNum1,nNum2中有0时返回1)
|
||
int CommomDivisor(int nNum1,int nNum2);
|
||
|
||
//判断一点是否在两点之间
|
||
//输入参数:
|
||
// ptPoint
|
||
// ptPointS
|
||
// ptPointE
|
||
//返回值:
|
||
// 若ptPoint在ptPointS_ptPointE之间返回true,否则false.
|
||
BOOL BetweenTwoPoint(CPoint ptPoint,CPoint ptPointS,CPoint ptPointE);
|
||
|
||
//判断一点是否在折线的两点之间
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// ptPoint
|
||
// ptPointS
|
||
// ptPointE
|
||
// listPolyline1
|
||
//输出参数:
|
||
// listPolyline2 ptPointS_ptPointE之间的折线.
|
||
//返回值:
|
||
// 若ptPoint在折线的ptPointS_ptPointE之间返回true,否则false.
|
||
BOOL BetweenTwoPointAtPolyline(int iDPMM,CPoint ptPoint,CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint> &listPolyline1,CList<CPoint,CPoint> &listPolyline2);
|
||
|
||
//求折线上两点间的长度
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// ptPointS,ptPointE 折线上的两点
|
||
// listPolyline 折线
|
||
//返回值:
|
||
// 两点间的长度
|
||
int Get2PLengthOfPolyline(int iDPMM,CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint> &listPolyline);
|
||
|
||
//求折线的长度
|
||
//输入参数:
|
||
// listPolyline 折线
|
||
//返回值:
|
||
// 折线长度
|
||
int GetLengthOfPolyline(CList<CPoint,CPoint> &listPolyline);
|
||
|
||
//求折线的长度
|
||
//输入参数:
|
||
// listPolyline 折线
|
||
//输出参数:
|
||
// dLength 折线长度的双精度值
|
||
//返回值:
|
||
// 折线长度
|
||
int GetLengthOfPolyline(CList<CPoint,CPoint> &listPolyline,double &dLength);
|
||
|
||
//求多边形的长度
|
||
//输入参数:
|
||
// listPolygon 多边形
|
||
//返回值:
|
||
// 多边形长度
|
||
int GetLengthOfPolygon(CList<CPoint,CPoint> &listPolygon);
|
||
|
||
//求多边形的长度
|
||
//输入参数:
|
||
// listPolygon 多边形
|
||
//输出参数:
|
||
// dLength 多边形长度的双精度值
|
||
//返回值:
|
||
// 多边形长度
|
||
int GetLengthOfPolygon(CList<CPoint,CPoint> &listPolygon,double &dLength);
|
||
|
||
//求两点距离
|
||
//返回值:
|
||
// 两点间的距离
|
||
int TwoPointLength(CPoint ptPoint1,CPoint ptPoint2);
|
||
|
||
//求两点距离
|
||
//输出参数:
|
||
// dLength 两点间距离的双精度值
|
||
//返回值:
|
||
// 两点间的距离
|
||
int TwoPointLength(CPoint ptPoint1,CPoint ptPoint2,double &dLength);
|
||
|
||
//求两点距离
|
||
double TwoPointLength(CDBLPoint pDBLPoint1,CDBLPoint pDBLPoint2);
|
||
|
||
//判断某点所处的象限
|
||
//输入参数:
|
||
// ptPoint 给定点
|
||
//返回值:
|
||
// 1:1象限,2:2象限,3:3象限,4:4象限
|
||
int GetQuadrant(int x,int y);
|
||
|
||
//将多边形中被折线截断的部分去掉
|
||
//该函数用于计算衣片的填充轮廓线和切割轮廓线
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPolygon 多边形
|
||
// listPolyline 折线
|
||
//输出参数:
|
||
// listPolygon 多边形
|
||
//返回值:
|
||
// true 成功,否则false.
|
||
BOOL PolygonRemovePolyline(int iDPMM,CList<CPoint,CPoint> &listPolygon,CList<CPoint,CPoint> &listPolyline);
|
||
|
||
//求点链listPoint中与ptPointS_ptPointE同向(从ptPointS到ptPointE),且距离ptPointE最近的点ptPoint
|
||
BOOL GetEquidireectionalPoint(CPoint ptPointS,CPoint ptPointE,CList<CPoint,CPoint> &listPoint,CPoint &ptPoint);
|
||
|
||
//判断两点(ptPoint1,ptPoint2)是否在直线ptPointLS_ptPointLE的同侧
|
||
//输入参数:
|
||
// ptPoint1,ptPoint2 给定两点
|
||
// ptPointLS,ptPointLE 直线的两点
|
||
//返回值:
|
||
// true 同侧,false 异侧
|
||
BOOL IsSameSide(CPoint ptPoint1,CPoint ptPoint2,CPoint ptPointLS,CPoint ptPointLE);
|
||
|
||
//判断点链listPoint是否在直线ptPointLS_ptPointLE的同侧
|
||
//入口:
|
||
// listPoint 给定点链
|
||
// ptPointLS,ptPointLE 直线的两点
|
||
//返回值:
|
||
// true 同侧,false 异侧
|
||
BOOL IsSameSide(CList<CPoint,CPoint> &listPoint,CPoint ptPointLS,CPoint ptPointLE);
|
||
|
||
//判断平行的直线ptPoint1_ptPoint2和ptPoint3_ptPoint4,
|
||
//其矢量方向ptPoint1→ptPoint2和ptPoint3→ptPoint4是否相同.
|
||
//特别说明:在2009年11月11日前要求ptPoint1_ptPoint2和ptPoint3_ptPoint4必须是平行线.之后改成矢量ptPoint1→ptPoint2和ptPoint3→ptPoint4的夹角不大于一个指定角度
|
||
//输入参数:
|
||
// ptPoint1
|
||
// ptPoint2
|
||
// ptPoint3
|
||
// ptPoint4
|
||
// dCosMaxAngle 判断矢量ptPoint1→ptPoint2和ptPoint3→ptPoint4同向的最大允许夹角余弦,(原本默认值为1度的余弦,20130827之后要求传入余弦值)
|
||
//返回值:
|
||
// true 相同,false 相反.
|
||
BOOL IsSameDirection(CPoint ptPoint1,CPoint ptPoint2,CPoint ptPoint3,CPoint ptPoint4,double dCosMaxAngle);
|
||
|
||
//[20130827]恢复20091111之前的函数
|
||
// 因为在绝大多数情况下,输入变量已经是平行的,只需要判断它们的方向是否相同,无需使用角度判断
|
||
// 本次修改由杭州卓尚的<<S134211K00.dgs>>文件引起,其中计算101版本缝份时,两条矢量的交点明明存在,但是使用该函数判断时(默认用1度的余弦值)判断失败,因为角度=1.83度
|
||
BOOL IsSameDirection(CPoint ptPoint1,CPoint ptPoint2,CPoint ptPoint3,CPoint ptPoint4);
|
||
|
||
//判断点ptPoint是否在矩形(ptPoint1,ptPoint2)中
|
||
//输入参数:
|
||
// ptPoint 给定点
|
||
// ptPoint1,ptPoint2 矩形对角线
|
||
//返回值:
|
||
// true 在矩形内,false 不在矩形内
|
||
BOOL PointInRect(CPoint ptPoint,CPoint ptPoint1,CPoint ptPoint2);
|
||
|
||
//将数字字符串小数点后面无用的0或小数点去掉
|
||
void TrimAfterDot0(CString &strNum);
|
||
//将字符串第1个字符前的回车换行去掉
|
||
CString TrimHeadCRLF(CString string);
|
||
//将字符串最后1个字符后的回车换行去掉
|
||
CString TrimTailCRLF(CString string);
|
||
|
||
//判断ptPoint是否在矢量ptPointS→ptPointE的左边(显示器坐标)
|
||
//返回值:
|
||
// =true 在左边(显示器坐标)或在矢量ptPointS→ptPointE上,=false 在右边(显示器坐标)
|
||
BOOL IsLeftPoint(CPoint ptPoint,CPoint ptPointS,CPoint ptPointE);
|
||
//判断ptPoint是否在多边形(矢量方向是多边形的起点到终点)的左边(显示器坐标)
|
||
//返回值:
|
||
// =true 在左边(显示器坐标)或在多边形上,=false 在右边(显示器坐标)
|
||
BOOL IsLeftPoint(CPoint ptPoint,CList<CPoint,CPoint> &listPolyline);
|
||
|
||
//包括两点的矩形
|
||
//输入参数:
|
||
// ptPoint1
|
||
// ptPoint2
|
||
//返回值:
|
||
// 包括两点的矩形
|
||
CRect RectOfContainTowPoint(CPoint ptPoint1,CPoint ptPoint2);
|
||
|
||
//包括点链的矩形
|
||
//输入参数:
|
||
// listPolyline 点链
|
||
//返回值:
|
||
// 包括点链的矩形
|
||
CRect RectOfPolyline(CList<CPoint,CPoint> &listPolyline);
|
||
|
||
//包括圆弧的矩形,圆弧是指按逆时针方向(显示器坐标,若X向右为正,Y向上为正,则是顺时针方向)由起点到终点所经过的部分
|
||
//输入参数:
|
||
// ptLeftUp,ptRightDown 圆弧限定矩形的左上角和右下角(显示器坐标)
|
||
// ptPointS,ptPointE 圆弧的起点和终点
|
||
//返回值:
|
||
// 包括圆弧的矩形
|
||
CRect RectOfContainArc(CPoint ptLeftUp,CPoint ptRightDown,CPoint ptPointS,CPoint ptPointE);
|
||
|
||
//文字占用的区域大小
|
||
CSize StringSize(LOGFONT lfFont,CString string);
|
||
//文字占用的区域大小
|
||
CSize StringSize(CDC *pDC,CString string);
|
||
//文字占用的区域大小及行数
|
||
CSize StringSize(CDC *pDC,CString string,int &nLines);
|
||
//文字占用的区域
|
||
//输入参数:
|
||
// lfFont 显示的字体
|
||
// string 显示的文字
|
||
// ptLU 显示的左上角位置
|
||
// dScale 计算算时需要将字体的高度、宽度缩小的比例,主要是为了防止高度、宽度的值太大计算超界
|
||
//输出参数:
|
||
// ptLD 左下角位置
|
||
// ptRU 右上角位置
|
||
// ptRD 右下角位置
|
||
//返回值:
|
||
// 文字占用的区域大小
|
||
CSize StringRgnLU(LOGFONT lfFont,CString string,CPoint &ptLU,CPoint &ptLD,CPoint &ptRU,CPoint &ptRD,double dScale=1.0);
|
||
//文字占用的区域
|
||
//输入参数:
|
||
// lfFont 显示的字体
|
||
// string 显示的文字
|
||
// ptLD 显示的左下角位置
|
||
// dScale 计算算时需要将字体的高度、宽度缩小的比例,主要是为了防止高度、宽度的值太大计算超界
|
||
//输出参数:
|
||
// ptLU 左上角位置
|
||
// ptRU 右上角位置
|
||
// ptRD 右下角位置
|
||
//返回值:
|
||
// 文字占用的区域大小
|
||
CSize StringRgnLD(LOGFONT lfFont,CString string,CPoint &ptLU,CPoint &ptLD,CPoint &ptRU,CPoint &ptRD,double dScale=1.0);
|
||
//获取string的行数
|
||
int StringLines(CString string);
|
||
//获取string第nLineIndex行的字符(起始行的nLineIndex为0)
|
||
CString GetSubString(CString string,int nLineIndex);
|
||
|
||
//求多边形的面积
|
||
//输入参数:
|
||
// listPolygon 多边形点链
|
||
double AreaOfPloygon(CList<CPoint,CPoint> &listPolygon);
|
||
|
||
//判断线段和矩形是否相交
|
||
//输入参数:
|
||
// rect 给定矩形
|
||
// ptPointS_ptPointE 给定线段
|
||
//输出参数:
|
||
// ptPointS,ptPointE 截取的线段(ptPointS_ptPointE)
|
||
//返回值:
|
||
// true 线段和矩形相交, false 线段和矩形不相交.
|
||
BOOL IntersectLineRect(CRect rect,CPoint &ptPointS,CPoint &ptPointE);
|
||
|
||
//判断线段和矩形是否相交
|
||
//输入参数:
|
||
// rect 给定矩形
|
||
// ptPointS_ptPointE 给定线段
|
||
//输出参数:
|
||
// ptPointS,ptPointE 截取的线段(ptPointS_ptPointE)
|
||
//返回值:
|
||
// true 线段和矩形相交, false 线段和矩形不相交.
|
||
BOOL IntersectLineRect(CRect rect,int &nXS,int &nYS,int &nXE,int &nYE);
|
||
|
||
//判断折线和矩形是否相交
|
||
//输入参数:
|
||
// rect 给定矩形
|
||
// listPolyline 给定折线
|
||
//返回值:
|
||
// true 折线和矩形相交, false 折线和矩形不相交.
|
||
BOOL IntersectPolylineRect(CList<CPoint,CPoint> &listPolyline,CPoint ptPointS,CPoint ptPointE);
|
||
|
||
//判断矩形是否可以框选到折线
|
||
//输入参数:
|
||
// rect 框选的矩形
|
||
// listPolyline 折线
|
||
//返回值:
|
||
// true 可以框选到矩形
|
||
// false 矩形框选不到折线
|
||
BOOL IntersectPolylineRect(CRect rect,CList<CPoint,CPoint> &listPolyline);
|
||
|
||
//在点链listPoint中,从头到尾进行搜索,判断ptPoint1的最近点是否在ptPoint2的最近点前面(不一定是直接前趋)
|
||
//注意:如ptPoint1,ptPoint2不在点链中,则加入到点链中.
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPoint
|
||
// ptPoint1
|
||
// ptPoint2
|
||
//返回值:
|
||
// true ptPoint1的最近点在ptPoint2的最近点前面,
|
||
// false ptPoint1的最近点在ptPoint2的最近点前面.
|
||
BOOL IsPrevPoint(int iDPMM,CList<CPoint,CPoint> &listPoint,CPoint ptPoint1,CPoint ptPoint2);
|
||
|
||
//20140504 XQ 以ptPointO原点,将ptExtend拉到ptExtendToPoint时,与ptPointOld对应的拉伸ptPointNew
|
||
//该函数同时对弦高和弦长两个方向进行拉伸
|
||
void Extend(CPoint ptPointO,CPoint ptExtend,CPoint ptExtendToPoint,CPoint ptPointOld, CPoint &ptPointNew);
|
||
|
||
//以ptPointO原点,将ptExtend拉到ptExtendToPoint时,与listPointOld对应的拉伸listPointNew
|
||
//该函数同时对弦高和弦长两个方向进行拉伸
|
||
void Extend(CPoint ptPointO,CPoint ptExtend,CPoint ptExtendToPoint,CList<CPoint,CPoint> &listPointOld,CList<CPoint,CPoint> &listPointNew);
|
||
//以ptPointO原点,将ptExtend拉到ptExtendToPoint时,与listPointOld对应的拉伸listPointNew
|
||
//该函数仅对弦长方向进行拉伸
|
||
void ExtendInWidth(CPoint ptPointO,CPoint ptExtend,CPoint ptExtendToPoint,CList<CPoint,CPoint> &listPointOld,CList<CPoint,CPoint> &listPointNew);
|
||
|
||
//查找点链listPoint中与ptPoint距离最近的点
|
||
CPoint NearestPoint(CPoint ptPoint,CList<CPoint,CPoint> &listPoint,int &nDistance);
|
||
|
||
//查找点链listPoint1的点与listPoint2的点距离最近的两点
|
||
//输入参数:
|
||
// listPoint1
|
||
// listPoint2
|
||
//输出参数:
|
||
// ptPoint1 该点在listPoint1上
|
||
// ptPoint2 该点在listPoint2上
|
||
//返回值:
|
||
// ptPoint1与ptPoint2的距离
|
||
int NearestPoint(CList<CPoint,CPoint> &listPoint1,CList<CPoint,CPoint> &listPoint2,CPoint &ptPoint1,CPoint &ptPoint2);
|
||
|
||
//求折线中某一点的垂线ax+by+c=0
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPolyline
|
||
// ptPoint
|
||
// dMinLength 确定切线的最短距离
|
||
//输出参数:
|
||
// a,b,c 直线方程
|
||
BOOL VerticalLineOfPloyline(int iDPMM,CList<CPoint,CPoint> &listPolyline,CPoint ptPoint,double dMinLength,double &a,double &b,double &c);
|
||
BOOL VerticalLineOfPloygon(int iDPMM,CList<CPoint,CPoint> &listPolygon,CPoint ptPoint,double dMinLength,double &a,double &b,double &c);
|
||
|
||
//求折线中某一点的切线ax+by+c=0
|
||
//输入参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
BOOL TangentOfPloyline(int iDPMM,CList<CPoint,CPoint> &listPolyline,CPoint ptPoint,double dMinLength,double &a,double &b,double &c);
|
||
BOOL TangentOfPloygon(int iDPMM,CList<CPoint,CPoint> &listPolyline,CPoint ptPoint,double dMinLength,double &a,double &b,double &c);
|
||
|
||
//切割时对矩形排序
|
||
//输入参数:
|
||
// listRectOld 没有排序的矩形
|
||
// nDistance 排序的冗余大小
|
||
//输出参数:
|
||
// listRectNew 排好序的矩形
|
||
void CuttingSort(CList<CRect,CRect> &listRectOld,int nDistance,CList<CRect,CRect> &listRectNew);
|
||
|
||
//计算加入一个新点后形成的新矩形
|
||
//输入参数:
|
||
// ptPoint 给定的新点
|
||
// nLeft,nTop,nRight,nBottom 旧的矩形
|
||
//输出参数:
|
||
// nLeft,nTop,nRight,nBottom 新的矩形
|
||
void GetNewRect(CPoint ptPoint,int &nLeft,int &nTop,int &nRight,int &nBottom);
|
||
|
||
//判断点链是否在一直线上
|
||
//输入参数:
|
||
// listPoint 点链
|
||
// dMaxError 高度误差
|
||
//返回值:
|
||
// true 在一条直线上
|
||
BOOL AllPointAtLine(CList<CPoint,CPoint> &listPoint,double dMaxError);
|
||
|
||
//找水平垂直线
|
||
//如果直线ptPointS_ptPointE与水平垂直线的角度小于dMaxAngle,则计算ptPointE在水平垂直线上的最近距离点ptPointHV
|
||
//输入参数:
|
||
// ptPointS,ptPointE 直线点
|
||
// dMaxAngle 最大角度误差,单位:度
|
||
//输出参数:
|
||
// ptPointHV
|
||
//返回值:
|
||
// true 在给定的角度误差内有水平垂直线
|
||
BOOL HVLine(CPoint ptPointS,CPoint ptPointE,double dMaxAngle,CPoint &ptPointHV);
|
||
|
||
//反求样条曲线的控制点.
|
||
//参数:
|
||
// iDPMM [输入]长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPoint
|
||
// 点链
|
||
// listCtrl
|
||
// [输入][输出]控制点链,如果反求控制点成功,那么可以使用该参数有效否则无效
|
||
// dSplineError
|
||
// 计算样条曲线时的最大误差
|
||
// dMaxError
|
||
// 反求控制点链时的最大误差
|
||
// (bHeadTangent,ptHeadTangent)
|
||
// bHeadTangent=TRUE,有前切线点,此时ptHeadTangent有效;bHeadTangent=FALSE,没有前切线点,此时忽略ptHeadTangent的值
|
||
// (bTailTangent,ptTailTangent)
|
||
// bTailTangent=TRUE,有后切线点,此时ptTailTangent有效;bTailTangent=FALSE,没有后切线点,此时忽略ptTailTangent的值
|
||
// bNatrual
|
||
// =TRUE,自然样条;=FALSE,抛物线样条,20170406 syf,将默认值改为true
|
||
// bExactSolution
|
||
// =TRUE,求解精确解;=FALSE,如果不能求解精确解,那么尝试放大点阈值求解
|
||
BOOL CalculateSplineCtrlPoint(int iDPMM,CList<CPoint,CPoint>& listPoint, CList<CPoint,CPoint>& listCtrl, double dSplineError, double dMaxError,
|
||
BOOL bHeadTangent = FALSE,CPoint ptHeadTangent = CPoint(0,0),BOOL bTailTangent = FALSE,
|
||
CPoint ptTailTangent = CPoint(0,0),BOOL bNatrual = TRUE, BOOL bExactSolution = TRUE);
|
||
|
||
//对每一段等分反求样条曲线的控制点(segment divide)
|
||
//参数:
|
||
// listPoint
|
||
// 点链
|
||
// listCtrl
|
||
// [输入][输出]控制点链,如果反求控制点成功,那么可以使用该参数有效否则无效
|
||
// dSplineError
|
||
// 计算样条曲线时的最大误差
|
||
// dMaxError
|
||
// 反求控制点链时的最大误差
|
||
// (bHeadTangent,ptHeadTangent)
|
||
// bHeadTangent=TRUE,有前切线点,此时ptHeadTangent有效;bHeadTangent=FALSE,没有前切线点,此时忽略ptHeadTangent的值
|
||
// (bTailTangent,ptTailTangent)
|
||
// bTailTangent=TRUE,有后切线点,此时ptTailTangent有效;bTailTangent=FALSE,没有后切线点,此时忽略ptTailTangent的值
|
||
// bNatrual
|
||
// =TRUE,自然样条;=FALSE,抛物线样条,20170406 syf,将默认值改为true
|
||
// bExactSolution
|
||
// =TRUE,求解精确解;=FALSE,如果不能求解精确解,那么尝试放大点阈值求解
|
||
// dMaxCtrlPointDistance
|
||
// 两个控制点间的最大距离
|
||
BOOL CalculateSplineCtrlPoint_SD(CList<CPoint,CPoint>& listPoint, CList<CPoint,CPoint>& listCtrl, double dSplineError, double dMaxError, double dMaxCtrlPointDistance,
|
||
BOOL bHeadTangent = FALSE,CPoint ptHeadTangent = CPoint(0,0),BOOL bTailTangent = FALSE,
|
||
CPoint ptTailTangent = CPoint(0,0),BOOL bNatrual = TRUE, BOOL bExactSolution = TRUE);
|
||
|
||
//计算两条链表的距离
|
||
double DistanceOfTwoList(CList<CPoint,CPoint>& listPoint1, CList<CPoint,CPoint>& listPoint2);
|
||
|
||
//计算一条链表到另一条链表的距离.
|
||
double DistanceFromListToList(CList<CPoint,CPoint>& listPoint1, CList<CPoint,CPoint>& listPoint2);
|
||
|
||
//计算一个点到一条链表的距离.
|
||
double DistanceFromPointToList(CPoint point, CList<CPoint,CPoint>& listPoint);
|
||
double DistanceFromPointToList(CPoint point, CPoint* pt, int nArray);
|
||
|
||
//计算ptInt在线段ptS→ptE上的参数值
|
||
double PointToParam(CPoint& ptInt, CPoint& ptS, CPoint& ptE);
|
||
|
||
//求点到一条线段的垂足.
|
||
void GetVerticalPoint(CPoint& ptS, CPoint& ptE, CPoint& ptRes, CPoint& ptDes);
|
||
|
||
//求点到一条线段的垂足.
|
||
void GetVerticalPoint(CDBLPoint ptDBLPointS, CDBLPoint ptDBLPointE, CDBLPoint ptInput, CDBLPoint& ptOutput);
|
||
|
||
//判断两条线段是否平行
|
||
BOOL IsParallel(CPoint& ptS0, CPoint& ptE0, CPoint& ptS1, CPoint& ptE1);
|
||
|
||
//添加一个控制点.
|
||
BOOL AddOneCtrlPoint(CList<CPoint,CPoint>& listPoint, CList<CPoint,CPoint>& listCtrl);
|
||
|
||
//根据控制点分割点链.
|
||
void DivideListAccordingToCtrlList(CList<CPoint,CPoint>& listPoint, CList<CPoint,CPoint>& listCtrl, CArray<CList<CPoint,CPoint>,CList<CPoint,CPoint> >& arrayList);
|
||
|
||
//计算给定的元素在链表中的索引值
|
||
//参数:
|
||
// type
|
||
// 元素
|
||
// listType
|
||
// 链表
|
||
//返回值:
|
||
// >=0 该元素在链表中,该索引值从0开始
|
||
// =-1 该元素不在链表中
|
||
template<class TYPE,class ARG_TYPE>
|
||
int FindIndex(TYPE type, CList<TYPE,ARG_TYPE>& listType)
|
||
{
|
||
POSITION pos;
|
||
int iResult, i;
|
||
|
||
iResult = -1;
|
||
i = 0;
|
||
pos = listType.GetHeadPosition();
|
||
while (pos != NULL)
|
||
{
|
||
if (listType.GetAt(pos) == type)
|
||
{
|
||
iResult = i;
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
listType.GetNext(pos);
|
||
i++;
|
||
}
|
||
}
|
||
|
||
return iResult;
|
||
}
|
||
|
||
//计算给定元素在数组中的索引值
|
||
//参数:
|
||
// type
|
||
// 元素
|
||
// (p,nArray)
|
||
// 数组及长度
|
||
//返回值:
|
||
// >=0 该元素在数组中,该索引值从0开始
|
||
// =-1 该元素不在数组中
|
||
template<class TYPE>
|
||
int FindIndex(TYPE type, TYPE* p, int nArray)
|
||
{
|
||
int iResult, i;
|
||
|
||
ASSERT(p != NULL);
|
||
iResult = -1;
|
||
for (i = 0; i < nArray; i++)
|
||
{
|
||
if (p[i] == type)
|
||
{
|
||
iResult = i;
|
||
break;
|
||
}
|
||
}
|
||
|
||
return iResult;
|
||
}
|
||
|
||
//求一条链表的最大偏移距离.
|
||
double MaxDistanceOfList(CList<CPoint,CPoint>& listPoint, CPoint& point);
|
||
|
||
//判断点和多边形的关系
|
||
//输入:
|
||
// point 点.
|
||
// listPoint 点链.
|
||
//输出:
|
||
// 无.
|
||
//返回值:
|
||
// =1,点在多边形内部;=0,点在多边形上;=-1,点在多边形外部.
|
||
//说明:
|
||
// 此处应保证输入的点链是多边形,即:首尾点相同,面积大于0.
|
||
int PointInList(CPoint& point, CList<CPoint,CPoint>& listPoint);
|
||
//判断点和多边形的关系.
|
||
//输入:
|
||
// point 点.
|
||
// pt 多边形数组的首指针.
|
||
// nArray 多边形的元素个数.
|
||
//输出:
|
||
// 无.
|
||
//返回值:
|
||
// =1,点在多边形内部;=0,点在多边形上;=-1,点在多边形外部.
|
||
//说明:
|
||
// 数组元素应多于2个.
|
||
int PointInList(CPoint& point, CPoint* pt, int nArray);
|
||
|
||
//合并链表
|
||
//输入:
|
||
// listPoint 链表.
|
||
//输出:
|
||
// listPoint 链表.
|
||
//返回值:
|
||
// 无.
|
||
//说明:
|
||
// 如果连续的3个点共线,那么去掉中间的那一个点.
|
||
// 此函数应该保证相邻的点不相同,此函数不作判断.
|
||
void ComboSegment(CList<CPoint,CPoint>& listPoint);
|
||
|
||
//在一条线段上查找一个纵坐标为给定值的点的横坐标.
|
||
//输入:
|
||
// 线段(ptS,ptE)
|
||
// dY 给定的纵坐标值.
|
||
//输出:
|
||
// dX 横坐标.点(dX,dY)一定在线段(ptS,ptE)上.
|
||
//返回值:
|
||
// 无.
|
||
//说明:
|
||
// 该函数在判断一点是否在多边形内部(PointInList)时调用,在调用此函数之前已经能够保证
|
||
// 求出的结果点一定是落在线段上,而不是在线段的延长线.
|
||
void GetHorizonPoint(CPoint& ptS, CPoint& ptE, double& dY, double& dX);
|
||
|
||
//计算外积符号
|
||
//输入:
|
||
// 向量ptStart→ptEnd,ptStart→ptTemp
|
||
//输出:
|
||
// 无.
|
||
//返回值:
|
||
// = 1逆时针, = 0共线, = -1顺时针
|
||
//说明:
|
||
// 此函数返回向量ptStart→ptEnd旋转到ptStart→ptTemp是顺时针还是逆时针.
|
||
// 如果逆时针旋转是大于180度,那说明是顺时针的.
|
||
// 此结果是基于世界坐标系,在屏幕坐标系中结果要取相反的符号.
|
||
// 此结果只返回外积的符号,外积在数值上等于这三个点形成三角形的面积的2倍,此面积为有向面积.
|
||
int CrossProduct(CPoint& ptStart, CPoint& ptEnd, CPoint& ptTemp);
|
||
|
||
//由给定参数,计算线上的一个点.
|
||
//输入:
|
||
// 线段(ptS, ptE),有方向,原则上首尾点不相同.
|
||
// dParam 参数值.计算线上该参数值对应的点.
|
||
//输出: 无.
|
||
//返回值:
|
||
// CPoint点.
|
||
//说明:
|
||
// 此函数一定会有返回值,当输入的线段首位点相同的时候,直接返回头点坐标.
|
||
CPoint ParamToPoint(CPoint ptS, CPoint ptE, double dParam);
|
||
|
||
//两多边形是否重叠
|
||
BOOL IsOverlapOfTwoPolygon(CList<CPoint,CPoint> &listPolygon1,CList<CPoint,CPoint> &listPolygon2);
|
||
|
||
//将一条点链生成一个数组.
|
||
//输入:
|
||
// listPoint 点链.
|
||
//输出:
|
||
// pt 数组头指针.
|
||
// nListCount 数组元素数目.
|
||
//返回值:
|
||
// =TRUE,操作成功.=FALSE,操作失败.
|
||
//说明: 无.
|
||
BOOL MallocFromList(CList<CPoint,CPoint> &listPoint, CPoint *&pt, int &nListCount);
|
||
|
||
//获取两点的中点.
|
||
//输入:
|
||
// ptS,ptE 两个点.
|
||
//输出:
|
||
// ptMiddle 中点.
|
||
//返回值: 无.
|
||
//说明:
|
||
// 调用此函数时,输出变量可以与某个输入变量相同.
|
||
void GetMiddlePoint(CPoint ptS, CPoint ptE, CPoint &ptMiddle);
|
||
CPoint GetMiddlePoint(CPoint ptS, CPoint ptE);
|
||
//获取点链的中点
|
||
CPoint GetMiddlePoint(CList<CPoint,CPoint>& listPoint);
|
||
|
||
//计算点链的有向面积
|
||
//特别说明:
|
||
// 此面积为有向面积,>0 点链为逆时针(在屏幕上看为顺时针)
|
||
//输入参数:
|
||
// listPoint 点链
|
||
//返回值:
|
||
// 面积
|
||
double Area(CList<CPoint,CPoint>& listPoint);
|
||
|
||
//根据给定长度延长(缩短)一条线段.
|
||
//输入:
|
||
// (ptS,ptE) 有向线段.
|
||
// dLen 给定的线段长度.
|
||
//输出:
|
||
// ptExtend 延长(缩短)后的线段尾点.
|
||
//返回值: 无.
|
||
//说明:
|
||
// 调用此函数时ptE与ptExtend可以是同一个变量.
|
||
// 计算完成时(ptS,ptExtend)的长度为给定长度.
|
||
void ExtendSegment(CPoint &ptS, CPoint &ptE, double dLen, CPoint &ptExtend);
|
||
CPoint ExtendSegment(CPoint ptS, CPoint ptE, double dLen);
|
||
|
||
//计算两线段的交点.
|
||
//输入:
|
||
// 线段(ptS0,ptE0),(ptS1,ptE1)
|
||
//输出:
|
||
// ptInt 交点.
|
||
//返回值:
|
||
// 无.
|
||
//说明:
|
||
// 每条段的两端都都不应相同.
|
||
// 两条线段不应平行,此函数不作判断.
|
||
// 交点未必落在线段上.此为两线段所在直接的交点.
|
||
void IntPoint(CPoint& ptS0, CPoint& ptE0, CPoint& ptS1, CPoint& ptE1, CPoint& ptInt);
|
||
|
||
//计算两条向量夹角的余弦值和正弦值.
|
||
//输入:
|
||
// (ptS0,ptE0),(ptS1,ptE1) 两条向量.
|
||
//输出:
|
||
// dCos 夹角的余弦值.
|
||
// dSin 夹角的正弦值.
|
||
//返回值:
|
||
// =TRUE,成功计算.=FALSE,计算失败.
|
||
//说明:
|
||
// 只有当向量的两个端点退化成同一个点的时候才会计算失败.
|
||
// 此夹角是在世界坐标系下计算的.
|
||
BOOL RotateAngle(CPoint &ptS0, CPoint &ptE0, CPoint &ptS1, CPoint &ptE1, double &dCos, double &dSin);
|
||
|
||
//在给定的点链上找到距离给定点最近的点.
|
||
//输入:
|
||
// listPoint 点链.
|
||
// point 给定的点.
|
||
//输出:
|
||
// ptNearest 最近点.一定在折线上.
|
||
// dLen 最短的距离.
|
||
//返回值:
|
||
// TRUE,找到了这个最近点.FALSE,没有找到这个最近点.此时不可以使用输出变量.
|
||
//说明:
|
||
// 调用此函数时,输入变量和输出变量可以相同.
|
||
BOOL GetNearestPointOnList(CList<CPoint,CPoint> &listPoint, CPoint &point, CPoint &ptNearest, double &dMinLen);
|
||
|
||
//将源点链数组添加到目标点链数组的尾部.
|
||
//输入:
|
||
// alRsc 源点链数组.
|
||
//输出:
|
||
// alDes 目标点链数组.
|
||
//返回值: 无.
|
||
//说明: 无.
|
||
void AddArrayListTail(CArray<CList<CPoint,CPoint>,CList<CPoint,CPoint> >& alRsc, CArray<CList<CPoint,CPoint>,CList<CPoint,CPoint> >& alDes);
|
||
|
||
//计算平行的线段.
|
||
//参数:
|
||
// (ptS,ptE)
|
||
// 线段.一般来说这2个点不能相同.
|
||
// (dStartHeight,dEndHeight)
|
||
// 两个点各自的平行距离.本函数使用其绝对值,输入时每个长度都可以是0,这两个数值可以不同.
|
||
// bClockwise
|
||
// 旋转方向.=TRUE,顺时针;=FALSE,逆时针.注意:此处的顺时针是在"世界坐标系"下,与屏幕坐标系方向相反.
|
||
// (ptParallelS,ptParallelE)
|
||
// [输出]平行之后的两个端点.
|
||
//说明:
|
||
// 调用本函数时输入变量与输出变量一定要两两不同.
|
||
void ParallelSegment(CPoint ptS, CPoint ptE, double dStartHeight, double dEndHeight, BOOL bClockwise, CPoint& ptParallelS, CPoint& ptParallelE);
|
||
|
||
//计算平行曲线.
|
||
//参数:
|
||
// listPoint
|
||
// 点链.
|
||
// (dHeadHeight,dTailHeight)
|
||
// 头点和尾点处的距离.本函数使用其绝对值,并且这两个值可以不相同.
|
||
// bClockwise
|
||
// 方向.平行后的线在原线的哪一侧.=TRUE,顺时针(也就是屏幕上的左侧);=FALSE,逆时针(也就是屏幕上的右侧).注意:此处的顺时针是在"世界坐标系"下,与屏幕坐标系方向相反.
|
||
// listParallel
|
||
// [输出]平行之后的曲线.
|
||
// dMaxError
|
||
// 误差.判断输入的曲线是否为闭合的.如果判断出输入的曲线是闭合,那么将其按照多边形的情况来处理,
|
||
// 所以在处理多边形的时候要将其转化成点链传入.
|
||
// bRemoveIntersect
|
||
// =true 去自交,=false 不去自交
|
||
//说明:
|
||
// 在调用本函数的时候,输入变量与输出变量可以相同.
|
||
void ParalllelCurve(CList<CPoint,CPoint>& listPoint, double dHeadHeight, double dTailHeight, BOOL bClockwise, CList<CPoint,CPoint>& listParallel, double dMaxError = 0.0, BOOL bRemoveIntersect = TRUE);
|
||
|
||
//去除自交的折线.
|
||
//参数:
|
||
// listPoint
|
||
// [输入][输出]点链.
|
||
// bClose
|
||
// 标识点链是否为闭合的.
|
||
//说明:
|
||
// 如果是闭合的情形,那么按照多边形来求解,选择面积最大的那个.如果是折线的情形,那么则从头点到尾点的方向进行查找.
|
||
void RemoveIntersectPolyline(CList<CPoint,CPoint>& listPoint, BOOL bClose);
|
||
|
||
//获取边界内部的点链.
|
||
//参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listPoint
|
||
// 点链.
|
||
// listBorder
|
||
// 边界.头尾点相同也可以,不相同也可以.
|
||
// arrayList
|
||
// [输出]点链数组.可能有多条曲线,因为输入的点链可能被分割成了多条.
|
||
void GetListInBorder(int iDPMM,CList<CPoint,CPoint>& listPoint, CList<CPoint,CPoint>& listBorder, CArray<CList<CPoint,CPoint>,CList<CPoint,CPoint> >& arrayList);
|
||
|
||
//计算等比例的控制点链
|
||
//参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// (listPoint1,listCtrl1)
|
||
// 实际点链以及相对应的控制点链
|
||
// listPoint2
|
||
// 实际点链
|
||
// listCtrl2
|
||
// [输出]listPoint2对应的控制点链,其中的数目与listCtrl1相同,并且其中每个点的位置都是通过点在曲线上的比例来求得的
|
||
void GetProportionCtrlList(int iDPMM,CList<CPoint,CPoint>& listPoint1, CList<CPoint,CPoint>& listCtrl1, CList<CPoint,CPoint>& listPoint2, CList<CPoint,CPoint>& listCtrl2);
|
||
|
||
//从timeStart到timeFinish的时间差
|
||
//输入参数:
|
||
// iMillisecondsStart 开始的毫秒数
|
||
// iMillisecondsFinish 结束的毫秒数
|
||
//返回值:
|
||
// 持续时间,单位:秒
|
||
double Duration(int iMillisecondsStart,int iMillisecondsFinish);
|
||
|
||
//查找给定的点链距离数组中的哪条曲线最近
|
||
//参数:
|
||
// listPoint
|
||
// 点链,要保证该点链就是从数组中的某条曲线中提取出来的
|
||
// alCurve
|
||
// 点链数组
|
||
int FindListIndex(CList<CPoint,CPoint>& listPoint, CArray<CList<CPoint,CPoint>,CList<CPoint,CPoint> >& alCurve);
|
||
|
||
//计算垂足在线段上的参数值
|
||
//参数:
|
||
// (ptS,ptE)
|
||
// 线段,要求这两个点不相同,否则直接返回DBL_MAX
|
||
// point
|
||
// 点
|
||
//返回值:
|
||
// 参数值,若[0,1]则在线段内部
|
||
double GetVerticalParam(CPoint ptS, CPoint ptE, CPoint point);
|
||
|
||
//根据给定的虚线长度与间距,定制虚线
|
||
//参数:
|
||
// iDPMM
|
||
// 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listCurve
|
||
// 点链
|
||
// (iDashedLength,iSpaceLength)
|
||
// 虚线长度(每一段可见部分的长度),间隙长度(每一段不可见部分的长度),使用其绝对值
|
||
// alCurve
|
||
// [输出]点链数组,按照从头到尾的顺序,分段保存可见部分的点链
|
||
void CustomizeDashedLine(int iDPMM, CList<CPoint,CPoint>& listCurve, int iDashedLength, int iSpaceLength, CArray<CList<CPoint,CPoint>,CList<CPoint,CPoint> >& alCurve);
|
||
|
||
//计算渐变的自定义虚线
|
||
//参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// listCurve 点链
|
||
// iDashedLength 画线长度
|
||
// iSpaceLength 空白长度
|
||
// iDashGradualType 画线长度的渐变类型, =0 无, =1 长度渐变, =2比例渐变
|
||
// iDashGradualLength 画线长度的渐变长度,即:前一段的画线长度加上该值等于后一段的画线长度
|
||
// dDashGradualScale 画线长度的渐变比例,即:前一段的画线长度乘以该值等于后一段的画线长度
|
||
// iSpaceGradualType 空白长度的渐变类型, =0 无, =1 长度渐变, =2 比例渐变
|
||
// iSpaceGradualLength 空白长度的渐变长度,即:前一段的空白长度加上该值等于后一段的空白长度
|
||
// dSpaceGradualScale 空白长度的渐变比例,即:前一段的空白长度乘以该值等于后一段的空白长度
|
||
// bAdaptiveStretch =TRUE 自适应拉伸, =FALSE 不拉伸
|
||
// alCurve [输出]点链数组,按照从头到尾的顺序,分段保存可见部分的点链
|
||
void CustomizeGradualDashedLine(int iDPMM, CList<CPoint,CPoint>& listCurve, int iDashedLength, int iSpaceLength,
|
||
int iDashGradualType, int iDashGradualLength, double dDashGradualScale,
|
||
int iSpaceGradualType, int iSpaceGradualLength, double dSpaceGradualScale,
|
||
BOOL bAdaptiveStretch, CArray<CList<CPoint,CPoint>,CList<CPoint,CPoint> >& alCurve);
|
||
|
||
//根据给定的曲线,半径,间距计算圆形曲线
|
||
//参数:
|
||
// listCurve
|
||
// 点链
|
||
// (iRadius,iSpaceLength,dMaxError)
|
||
// 半径,圆心距(线上距离),计算圆形的最大逼近误差,若某一个值为0则输出变量为空
|
||
// alPolygon
|
||
// [输出]多边形数组,按照从头到尾的顺序,分段保存圆形实际位置
|
||
void CustomizeCircleCurve(CList<CPoint,CPoint>& listCurve, int iRadius, int iSpaceLength, double dMaxError, CArray<CList<CPoint,CPoint>,CList<CPoint,CPoint> >& alPolygon);
|
||
|
||
//计算自定义曲线(开口线或者闭合线)
|
||
//输入:
|
||
// listCurve 开口线
|
||
// alCustomCurveElement 自定义曲线元素
|
||
// bClose =TRUE 闭合线, =FALSE 开口线
|
||
// ptCustomBasePoint 基准点
|
||
// iCustomCurveHeight 高度,若<=0则使用alCustomCurveElement本身的高度
|
||
// iCustomCurveGap 相邻元素的间隔,若<0,则不能超过alCustomCurveElement本身的宽度
|
||
// bAdaptiveStretch =TRUE 自定义拉伸(等比例改变元素的宽度和高度,使得曲线的结束恰好是一个元素的结束), =FALSE 不拉伸(只保留整数部分的元素)
|
||
//输出:
|
||
// alCurve 计算出的点链
|
||
void CustomizeCurve(CList<CPoint,CPoint>& listCurve, BOOL bClose, CArray<CList<CPoint,CPoint>,CList<CPoint,CPoint> >& alCustomCurveElement, CPoint ptCustomBasePoint,
|
||
int iCustomCurveHeight, int iCustomCurveGap, BOOL bAdaptiveStretch, CArray<CList<CPoint,CPoint>,CList<CPoint,CPoint> >& alCurve);
|
||
|
||
//计算给定点链的最小矩形
|
||
//输入参数:
|
||
// listPoint 点链
|
||
//返回值:
|
||
// 点链的最小矩形
|
||
//说明:
|
||
// 将点链进行旋转求出面积最小矩形,箱包系统中计算纸样规格时即为此种方式
|
||
CRect GetBorderMinRect(CList<CPoint, CPoint> &listPoint);
|
||
|
||
//计算省山并修改边线形状
|
||
//参数:
|
||
// listPoint1E,listPoint3E
|
||
// [输入]对应于V形省的1E边和3E边,如果是计算锥形省,则对应于14边和35边,计算褶山时也是同样的道理
|
||
// 传入时要求这两条点链的头点是靠近边线的,否则需要将点链翻转,本函数不再判断
|
||
// 同时,还要保证在边线上1->3点长度小于3->1点长度,本函数不再判断
|
||
// [输出]如果计算成功,则根据它们的头点在边线上的最近点,将点链拉伸,并保证头点的坐标一定在边线中
|
||
// listPoint2E
|
||
// 两条省腰的中心线,将使用该线头点的切线将对称后的省山截断,若该链表为空,那么将会使用两条省腰中间的直线做截取
|
||
// listBorder
|
||
// [输入][输出]边线的实际点链,要求头尾点相同;输出时已经将省山的形状添加进去
|
||
// bClockwise
|
||
// =TRUE 顺时针倒向(视觉上的顺时针),即倒向GetNext
|
||
// dMaxError
|
||
// 判断1点和3点是否在边线上的误差值,如果省腰长度小于该值同样返回FALSE
|
||
// ptDartHill
|
||
// [输出]省山的尖点位置,计算完成后省山被插入到边线中,但是不知道省山尖点的坐标,将其输出后可以修改褶中心线的形状(因为刀褶也是调用此函数计算褶山的)
|
||
BOOL CalculateDartHill(int iDPMM, CList<CPoint,CPoint>& listPoint1E, CList<CPoint,CPoint>& listPoint3E, CList<CPoint,CPoint>& listPoint2E, CList<CPoint,CPoint>& listBorder, BOOL bClockwise, double dMaxError, CPoint& ptDartHill);
|
||
|
||
//计算工字褶褶山并修改边线形状
|
||
//特别说明:
|
||
// 刀褶褶山的计算与省相同,调用CalculateDartHill函数即可,本函数按照工字褶的规则计算
|
||
//参数:
|
||
// 详见CalculateDartHill函数的变量说明,注意:工字褶不涉及倒向
|
||
BOOL CalculatePleatHill(int iDPMM, CList<CPoint,CPoint>& listPoint12, CList<CPoint,CPoint>& listPoint34, CList<CPoint,CPoint>& listBorder, double dMaxError);
|
||
|
||
//获得沿直线 p0p1方向,到p0距离为 dDistance 的点
|
||
CPoint GetPointOnLine(CPoint p0,CPoint p1,double dDistance);
|
||
|
||
|
||
//20170222 获取两条曲线的交点
|
||
//[输入] listPoint1,listPoint2 两条点链
|
||
//[输出] ptInt交点
|
||
//[输入] iIntIndex 交点索引, -1返回 GetIntPointOfTwoCurve( int iDPMM, CList<CPoint,CPoint>& listPoint1, CList<CPoint,CPoint>& listPoint2, CPoint& ptInt, int iCount)结果
|
||
// 0, 1,2...求出listPoint1,listPoint2的所有交点(本身相交,延长相交),并且按照listPoint1的点连顺序排序, 按照排序顺序输出交点
|
||
//[输入]iCount 迭代的次数,当迭代一次之后就不能再进行迭代了
|
||
//返回值:
|
||
// =TRUE 成功求解出了交点
|
||
// =FALSE 求解交点失败,不能使用输出变量中的数据
|
||
//说明:
|
||
// 该函数是针对两个不同的平行交点,它们引用的两条曲线相同但是交点不同,新增加的函数
|
||
// iIntIndex为-1表示保持原有的结果;为0, 1,2...时表示需要求所有交点排序输出
|
||
BOOL GetIntPointOfTwoCurve( int iDPMM, CList<CPoint,CPoint>& listPoint1, CList<CPoint,CPoint>& listPoint2, CPoint& ptInt, int iIntIndex, int iCount);
|
||
|
||
//20170222 获取两条曲线的交点(相交的, 延长相交的),并按照listPoint1排序
|
||
//[20170911 syf]如果两条实际点链的交点>=2个,那么不再延长计算
|
||
//[输入] listPoint1,listPoint2 两条点链
|
||
//[输出] listInt 两条点链所有的交点,交点按照listPoint1排序
|
||
//返回值:
|
||
// =TRUE 成功求解出了交点
|
||
// =FALSE 求解交点失败,不能使用输出变量中的数据
|
||
//说明:
|
||
//该函数中分三种情况处理
|
||
//1. listPoint1/listPoint2都是非闭合曲线,如果两线有交点,先求出交点,再按两条曲线头尾点分别延长(20170911 syf如果实际点链的交点>=2个,那么不再延长计算)
|
||
//2. listPoint1/listPoint2一条非闭合,一条闭合; 先求两条线交点,再求非闭合线的延长线与闭合线交点
|
||
//3. listPoint1/listPoint2都是闭合曲线,直接求两线有交点返回
|
||
BOOL GetIntPointOfTwoCurve_All( int iDPMM, CList<CPoint,CPoint>& listPoint1, CList<CPoint,CPoint>& listPoint2, CList<CPoint,CPoint>& listInt);
|
||
|
||
//20130717 获取两条曲线的交点
|
||
//[输入] listPoint1,listPoint2 两条点链
|
||
//[输出] ptInt交点
|
||
//[输入]iCount 迭代的次数,当迭代一次之后就不能再进行迭代了
|
||
//返回值:
|
||
// =TRUE 成功求解出了交点
|
||
// =FALSE 求解交点失败,不能使用输出变量中的数据
|
||
//说明:
|
||
// 包含延长相交
|
||
BOOL GetIntPointOfTwoCurve(int iDPMM, CList<CPoint,CPoint>& listPoint1, CList<CPoint,CPoint>& listPoint2, CPoint& ptInt, int iCount);
|
||
|
||
|
||
//20130717 求解延长后的交点
|
||
//[输入] ptStart,ptEnd 向量,有方向
|
||
//[输入] listPoint 点链,在这条点链上求解交点,如果没有则尝试延长头尾点来进行
|
||
//[输出] ptInt 交点坐标,如果有多个交点那么只输入其中的任意一个
|
||
//返回值:
|
||
// =TRUE 求解成功,可以使用输出变量中的数据
|
||
// =FALSE 求解失败,不能使用输出变量中的数据
|
||
BOOL GetExtendInt(int iDPMM, CPoint ptStart, CPoint ptEnd, CList<CPoint,CPoint>& listPoint, CPoint& ptInt);
|
||
|
||
//20170223求解延长后的交点
|
||
//[输入] ptStart,ptEnd 向量,有方向
|
||
//[输入] listPoint 点链,在这条点链上求解交点,如果没有则尝试延长头尾点来进行
|
||
//[输出] listInt 交点坐标
|
||
//返回值:
|
||
// =TRUE 求解成功,可以使用输出变量中的数据
|
||
// =FALSE 求解失败,不能使用输出变量中的数据
|
||
BOOL GetExtendInt(int iDPMM, CPoint ptStart, CPoint ptEnd, CList<CPoint,CPoint>& listPoint, CList<CPoint,CPoint>& listInt);
|
||
|
||
//20130718 根据给定两点在给定的曲线上截取一段 20140427 增加一个输出值
|
||
//[输入]ptPointS, ptPointE 截取曲线的头尾点
|
||
//[输入][输出]listPoint 输入:原始曲线;输出:截取之后的曲线
|
||
//[输出] listPointMax 最长点链
|
||
//说明:
|
||
// ptPointS点可能为截取后的曲线的头点或者尾点
|
||
//如果ptPointS和ptPointE相等返回原曲线
|
||
//如果ptPointS或者ptPointE只有一个不在曲线上,根据在曲线上的将曲线分成两段,按另外一个点与曲线头尾点距离(按距离小的)得到需要段
|
||
//如果ptPointS和ptPointE都不在曲线上,按加入点链处理
|
||
//如果ptPointS和ptPointE都不在曲线上并且在曲线的同边,返回点链只有ptPointS和ptPointE两点
|
||
//最长点链的计算listPointMax
|
||
//如果ptPointS, ptPointE都在点链上,返回listPoint;
|
||
//如果有一个在点链上,返回:listPoint加上那个不在点链上的点
|
||
//如果两个都不在点链上, 两个在点链的异侧,返回:将两个点加到listPoint头尾,返回
|
||
// 两个在点链的异侧,将两个点同时加入头部或者尾部,返回
|
||
void GetCurveSegment(int iDPMM, CPoint ptPointS, CPoint ptPointE, CList<CPoint,CPoint>& listPoint, CList<CPoint,CPoint>& listPointMax);
|
||
|
||
//20130815 XQ 计算展开的终点
|
||
//参数:
|
||
// (ptUp,ptDown)
|
||
// 展开前的起止点
|
||
// (iUpWidth,iDownWidth)
|
||
// 上下展开量,使用其绝对值,任何一个宽度都可以为0
|
||
// bClockWise
|
||
// =TRUE,顺时针旋转;=FALSE,逆时针旋转.此旋转为世界坐标系下,与屏幕坐标系的方向相反
|
||
// 该方向表示,如果宽度为正数,那么展开的结果应该出现在ptUp->ptDown的bClockWise那一侧,如果宽度为负数,则要反向
|
||
// (ptSpreadUp,ptSpreadDown)
|
||
// [输出]展开后的起止点,调用本函数的时候这两个参数一定不能与输入的(ptUp,ptDown)使用相同的变量
|
||
// bAllowNegativeWidth
|
||
// =true 允许宽度为负数,=false 不允许,强制按照正数计算(数据结构中计算褶展开就是强制展开,所以该变量的默认值是false,20180123 syf添加此变量)
|
||
void CalculateSpreadEndPoint(CPoint ptUp, CPoint ptDown, int iUpWidth, int iDownWidth, BOOL bClockWise, CPoint& ptSpreadUp, CPoint& ptSpreadDown, BOOL bAllowNegativeWidth = FALSE);
|
||
|
||
//判断给定点是否在点链内(给定点是否在点链的某一线段上)
|
||
//参数:
|
||
// iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
// ptPoint 给定的点
|
||
// listPoint 给定点链
|
||
//返回值:
|
||
// =TRUE 点在点链内
|
||
BOOL PointInPolyline(int iDPMM, CPoint ptPoint, CList<CPoint,CPoint>& listPoint);
|
||
|
||
|
||
//20160718 XQ 根据listRefPoint对listSortPoint排序
|
||
//[输入] iDPMM 长度分辨率(一个内部单位即为1/iDPMM毫米)
|
||
//[输入] listRefPoint 参考点链
|
||
//[输入][输出] listSortPoint 需要排序的点链
|
||
//说明:
|
||
// 将listSortPoint中的点链按照listRefPoint的顺序排放,listSortPoint的点可能不在listRefPoint上
|
||
void SortIntPoint(int iDPMM, CList<CPoint, CPoint> &listRefPoint, CList<CPoint, CPoint> &listSortPoint);
|
||
|
||
//交换两个TYPE
|
||
template<class TYPE>
|
||
void Swap(TYPE& p1, TYPE& p2)
|
||
{
|
||
TYPE p3;
|
||
|
||
p3 = p1;
|
||
p1 = p2;
|
||
p2 = p3;
|
||
}
|
||
|
||
//交换两条链表
|
||
template<class TYPE>
|
||
void Swap(CList<TYPE,TYPE>& list1, CList<TYPE,TYPE>& list2)
|
||
{
|
||
CList<TYPE,TYPE> list3;
|
||
|
||
list3.RemoveAll();
|
||
list3.AddTail(&list1);
|
||
list1.RemoveAll();
|
||
list1.AddTail(&list2);
|
||
list2.RemoveAll();
|
||
list2.AddTail(&list3);
|
||
}
|
||
|
||
//设置数组值
|
||
// [输入] Value 设置值
|
||
// [输入][输出] arrayValue 数组
|
||
// [输入] iCount 数据大小
|
||
// 说明:
|
||
// 将数组中的每个值都设置位给定值
|
||
template<class TYPE>
|
||
void SetSameValue(TYPE Value, CArray<TYPE,TYPE> &arrayValue, int iCount)
|
||
{
|
||
int iIndex;
|
||
|
||
arrayValue.RemoveAll();
|
||
arrayValue.SetSize(iCount);
|
||
for (iIndex = 0; iIndex < iCount; iIndex++)
|
||
{
|
||
arrayValue[iIndex] = Value;
|
||
}
|
||
}
|
||
//判断数组中每个值是否都相等
|
||
// [输入] arryValue 数组
|
||
//返回值:
|
||
// =true 数组中每个值都相等;
|
||
// =false 至少存在一个值不相等
|
||
//说明:
|
||
// 数组为空时返回False, 数组只有一个值返回True
|
||
template<class TYPE>
|
||
BOOL IsSameValue(CArray<TYPE,TYPE> &arryValue)
|
||
{
|
||
BOOL bEqual;
|
||
int iIndex, iCount;
|
||
TYPE Value;
|
||
|
||
bEqual = TRUE;
|
||
iCount = arryValue.GetSize();
|
||
if (iCount == 0)
|
||
{
|
||
return FALSE;
|
||
}
|
||
if (iCount == 1)
|
||
{
|
||
return TRUE;
|
||
}
|
||
|
||
Value = arryValue[0];
|
||
for (iIndex = 1; (iIndex < iCount) && bEqual; iIndex++)
|
||
{
|
||
if (Value != arryValue[iIndex])
|
||
{
|
||
bEqual = FALSE;
|
||
}
|
||
}
|
||
|
||
return bEqual;
|
||
}
|
||
|
||
//判断两个数组是否完全相等
|
||
// [输入] arryValue1 数组
|
||
// [输入] arryValue2 数组
|
||
//返回值:
|
||
// =true 两个数组中对应的每个值都相等;
|
||
// =false 至少存在一个值不相等
|
||
template<class TYPE>
|
||
BOOL IsSameValue(CArray<TYPE,TYPE> &arryValue1, CArray<TYPE,TYPE> &arryValue2)
|
||
{
|
||
BOOL bEqual;
|
||
int iIndex, iCount;
|
||
|
||
bEqual = TRUE;
|
||
if (arryValue1.GetSize() != arryValue2.GetSize())
|
||
{
|
||
return FALSE;
|
||
}
|
||
iCount = arryValue1.GetSize();
|
||
if (iCount == 0)
|
||
{
|
||
return TRUE;
|
||
}
|
||
|
||
for (iIndex = 0; (iIndex < iCount) && bEqual; iIndex++)
|
||
{
|
||
if (arryValue1[iIndex] != arryValue2[iIndex])
|
||
{
|
||
bEqual = FALSE;
|
||
}
|
||
}
|
||
|
||
return bEqual;
|
||
}
|
||
//拷贝数据,将原数组中数据拷贝到目标数组中
|
||
// [输入] arryValueSrc 原数组
|
||
// [输入][输出] arryValueDes 目标数组
|
||
template<class TYPE>
|
||
void CopyData(CArray<TYPE,TYPE> &arryValueSrc, CArray<TYPE,TYPE> &arryValueDes)
|
||
{
|
||
int iIndex, iCount;
|
||
|
||
arryValueDes.RemoveAll();
|
||
iCount = arryValueSrc.GetSize();
|
||
for (iIndex = 0; iIndex < iCount; iIndex++)
|
||
{
|
||
arryValueDes.Add(arryValueSrc[iIndex]);
|
||
}
|
||
}
|
||
|
||
//在给定的数据中找一个最大值
|
||
// [输入] arryValue 数组
|
||
//返回值:
|
||
// 数组中最大值,如果数组中没有值返回0
|
||
template<class TYPE>
|
||
TYPE FindMaxCount(CArray<TYPE,TYPE> &arryValue)
|
||
{
|
||
int iIndex, iCount;
|
||
TYPE MaxValue;
|
||
|
||
iCount = arryValue.GetSize();
|
||
if (iCount == 0)
|
||
{
|
||
return 0;
|
||
}
|
||
MaxValue = arryValue[0];
|
||
for (iIndex = 1; iIndex < iCount; iIndex++)
|
||
{
|
||
if (MaxValue < arryValue[iIndex])
|
||
{
|
||
MaxValue = arryValue[iIndex];
|
||
}
|
||
}
|
||
|
||
return MaxValue;
|
||
}
|
||
|
||
//计算扣眼位置
|
||
//特别说明:
|
||
// 该函数也可以用来计算钻孔
|
||
//输入参数:
|
||
// ptPoint 给定点
|
||
// dAngle 扣眼与X轴的角度(显示器坐标,逆时针方向为正),单位:度
|
||
// ptButtonHoleS 旋转角度为0时的扣眼S点
|
||
// ptButtonHoleE 旋转角度为0时的扣眼E点,SE点构成了默认的扣眼方向(一般来说这是一条水平线)
|
||
//返回值:
|
||
// 线段,m_ptPointS表示扣眼的定位位置,m_ptPointE表示扣眼的方向
|
||
CLineSegment CalculateButtonHolePosition(CPoint ptPoint, double dAngle, CPoint ptButtonHoleS, CPoint ptButtonHoleE);
|
||
|
||
//计算扣眼位置
|
||
//输入参数:
|
||
// iDPMM 分辨率
|
||
// listCurve 曲线实际点链
|
||
// bClose =true 闭合线,=false 开口线
|
||
// iLocateType 定位类型,=0 等距,=1 不等距
|
||
// bNext =true 从ptPointH往GetNext的方向加扣眼,=false 从ptPointH往GetPrev的方向加扣眼
|
||
// iGroupCount 扣眼组数
|
||
// ptPointH 头点:等距时,从ptPointH~ptPointT加扣眼,不等距时,从ptPointH沿着bNext方向加扣眼
|
||
// iDistanceH 第一个扣眼与ptPointH的距离
|
||
// ptPointT 尾点:仅等距时有效
|
||
// iDistanceT 最后一个扣眼与ptPointT的距离,仅等距时有效
|
||
// bOnFirst =true 包括ptPointH往后iDistanceH处的扣眼,=false 不包括
|
||
// bOnLast =true 包括ptPointT往前iDistanceT处的扣眼,=false 不包括
|
||
// iSubCount 每小组的钻孔个数
|
||
// iSubGap 每个小组相邻两个间的间距
|
||
// listGap 各码扣眼间的间距,间距必须 > 0 !!!
|
||
// [i]是该码第i个与第i-1个间的距离,故各码扣眼间距个数比各码的扣眼数少1个 !!!
|
||
// 非等距,且个数>1时有效
|
||
// bFixAngle =true 与后向切线成固定角度
|
||
// dAngle 扣眼与X轴的角度(显示器坐标,逆时针方向为正),单位:度
|
||
// ptButtonHoleS 旋转角度为0时的扣眼S点
|
||
// ptButtonHoleE 旋转角度为0时的扣眼E点,SE点构成了默认的扣眼方向(一般来说这是一条水平线)
|
||
//输出参数:
|
||
// listLineSegment 线段链表,m_ptPointS表示扣眼的定位位置,m_ptPointE表示扣眼的方向
|
||
void CalculateButtonHolePosition(
|
||
int iDPMM, CList<CPoint,CPoint>& listCurve, BOOL bClose, int iLocateType, BOOL bNext, int iGroupCount,
|
||
CPoint ptPointH, int iDistanceH, CPoint ptPointT, int iDistanceT, BOOL bOnFirst, BOOL bOnLast,
|
||
int iSubCount, int iSubGap, CList<int,int>& listGap, BOOL bFixAngle, double dAngle,
|
||
CPoint ptButtonHoleS, CPoint ptButtonHoleE, CLineSegmentList& listLineSegment);
|
||
|
||
//计算扣眼位置(带有偏移量)
|
||
//输入参数:
|
||
// iDPMM 分辨率
|
||
// listCurve 曲线实际点链,这是主线
|
||
// bClose =true 闭合线,=false 开口线
|
||
// iOffsetCount 扣眼的排数,表示一共有几排扣眼
|
||
// bOffsetLeft =true 扣眼位于主线的左侧(显示器坐标系),=false 右侧
|
||
// iOffsetDistance 第一排扣眼与主线的间距,若<0则位于bOffsetLeft的反方向
|
||
// iOffsetGapS 第二排扣眼与第一排扣眼的间距,若<0则位于bOffsetLeft的反方向
|
||
// iOffsetGapE 最后一排扣眼与倒数第二排扣眼的间距,若不等于iOffsetGapS则成为渐变效果
|
||
// iLocateType 定位类型,=0 等距,=1 不等距
|
||
// bNext =true 从ptPointH往GetNext的方向加扣眼,=false 从ptPointH往GetPrev的方向加扣眼
|
||
// iGroupCount 扣眼组数
|
||
// ptPointH 头点:等距时,从ptPointH~ptPointT加扣眼,不等距时,从ptPointH沿着bNext方向加扣眼
|
||
// iDistanceH 第一个扣眼与ptPointH的距离
|
||
// ptPointT 尾点:仅等距时有效
|
||
// iDistanceT 最后一个扣眼与ptPointT的距离,仅等距时有效
|
||
// bOnFirst =true 包括ptPointH往后iDistanceH处的扣眼,=false 不包括
|
||
// bOnLast =true 包括ptPointT往前iDistanceT处的扣眼,=false 不包括
|
||
// iSubCount 每小组的钻孔个数
|
||
// iSubGap 每个小组相邻两个间的间距
|
||
// listGap 各码扣眼间的间距,间距必须 > 0 !!!
|
||
// [i]是该码第i个与第i-1个间的距离,故各码扣眼间距个数比各码的扣眼数少1个 !!!
|
||
// 非等距,且个数>1时有效
|
||
// bFixAngle =true 与后向切线成固定角度
|
||
// dAngle 扣眼与X轴的角度(显示器坐标,逆时针方向为正),单位:度
|
||
// ptButtonHoleS 旋转角度为0时的扣眼S点
|
||
// ptButtonHoleE 旋转角度为0时的扣眼E点,SE点构成了默认的扣眼方向(一般来说这是一条水平线)
|
||
//输出参数:
|
||
// alLineSegment 线段链表的数组,其长度等于iOffsetCount,m_ptPointS表示扣眼的定位位置,m_ptPointE表示扣眼的方向
|
||
void CalculateButtonHolePosition(
|
||
int iDPMM, CList<CPoint,CPoint>& listCurve, BOOL bClose, int iOffsetCount, BOOL bOffsetLeft, int iOffsetDistance, int iOffsetGapS, int iOffsetGapE,
|
||
int iLocateType, BOOL bNext, int iGroupCount, CPoint ptPointH, int iDistanceH, CPoint ptPointT, int iDistanceT, BOOL bOnFirst, BOOL bOnLast,
|
||
int iSubCount, int iSubGap, CList<int,int>& listGap, BOOL bFixAngle, double dAngle, CPoint ptButtonHoleS, CPoint ptButtonHoleE, CLineSegmentListArray& alLineSegment);
|
||
|
||
//计算平行线上的对应点
|
||
//输入参数:
|
||
// iDPMM 分辨率
|
||
// listCurve 曲线的实际点链
|
||
// bClose =true 闭合线,=false 开口线
|
||
// ptPoint 曲线listCurve上的一个点,未必在链表内
|
||
// 如果等于开口线listCurve的头点,那么直接返回listParallel的头点,同理返回尾点
|
||
// listParallel 曲线listCurve的平行线
|
||
//输出参数:
|
||
// ptParallel 与ptPoint对应的点,根据角平分线计算交点而得来
|
||
//返回值:
|
||
// =true 计算成功,=false 计算失败
|
||
BOOL CalculateParallelPoint(int iDPMM, CList<CPoint,CPoint>& listCurve, BOOL bClose, CPoint ptPoint, CList<CPoint,CPoint>& listParallel, CPoint& ptParallel);
|
||
|
||
//判断两个点是否为同一点
|
||
//特别说明:
|
||
// (1)由于舍入误差导致的两个点坐标不同,它们应该被视为同一个点,dxdy通常不会超过1
|
||
// (2)判断标准为CONST_SAME_POINT_ERROR,详见该宏定义的说明文字
|
||
// (3)本函数默认使用CONST_SAME_POINT_ERROR做判断,也可以传入误差值
|
||
//输入参数:
|
||
// ptPoint1 点1
|
||
// ptPoint2 点2
|
||
// dSamePointError 判断两个点相等的误差值,<=该值的点认为是同一个
|
||
// >0 直接使用该值做判断
|
||
// =0 坐标完全相等的点才是同一个,否则不是
|
||
// <0 本函数自动使用 CONST_SAME_POINT_ERROR 做判断
|
||
//返回值:
|
||
// =true 两个点视为同一个点,=false 不是
|
||
BOOL PDSIsSamePoint(CPoint ptPoint1, CPoint ptPoint2, double dSamePointError = -1.0);
|
||
|
||
//判断两个数组是否形状相同
|
||
//特别说明:
|
||
// (1)形状,指的是屏幕上的显示效果,与数组的长度或者链表的长度无关
|
||
// (2)本函数将会把每个数组都转换成线段CLineSegment,然后比较两个输入变量的线段是否完全重合
|
||
// (3)本函数可以判断自定义曲线/花稿元素/钻孔元素是否为同一个
|
||
//输入参数:
|
||
// alCurve1 链表数组1
|
||
// alCurve2 链表数组2
|
||
//返回值:
|
||
// =true 形状相同,=false 形状不同
|
||
BOOL PDSIsSameShape(CArray<CList<CPoint,CPoint>,CList<CPoint,CPoint> >& alCurve1, CArray<CList<CPoint,CPoint>,CList<CPoint,CPoint> >& alCurve2);
|
||
|
||
//生成全球唯一ID
|
||
//特别说明:
|
||
// https://blog.csdn.net/dpsying/article/details/21415811
|
||
//返回值:
|
||
// 唯一ID,字符串长度=38,例如{77046E66-C274-42CE-85AD-5DCFA5B4D2A5}
|
||
CString PDSCreateGUID(void);
|
||
|
||
#endif
|