84 lines
3.4 KiB
C++
84 lines
3.4 KiB
C++
#ifndef DATAOPERAT_H
|
|
#define DATAOPERAT_H
|
|
|
|
#include "machine/comm/datadef.h"
|
|
#include <iostream>
|
|
#include<iomanip>
|
|
#include<cmath>
|
|
#include <QList>
|
|
#include <QListIterator>
|
|
#include <QDebug>
|
|
|
|
#define QUI_TYPE_LINE 1 //直线
|
|
#define QUI_TYPE_STEP 4 //跨步
|
|
#define QUI_TYPE_HSTEP 5 //翻头跨步
|
|
#define QUI_TYPE_ARC 2 //三点圆弧
|
|
#define QUI_TYPE_BES 6 //贝塞尔曲线
|
|
#define QUI_TYPE_SPLINE 7 //样条曲线
|
|
|
|
#define ERROR_NOTHING 0 //成功
|
|
#define ZERO 1e-6
|
|
|
|
#define LINEDUAN_NUM_LIMIT 5 // 计算分段数固定:不进行特殊计算
|
|
#define LINEDUAN_STITCHLEN_LIMIT 6 // 针迹步长固定
|
|
#define LINEDUAN_STITCHLEN_LIMIT_END 7 // 针迹步长固定(最后线段)
|
|
|
|
#define OBJECT_STITCHLEN_NEW_BIG 8 // 固定针迹长度(大等分)
|
|
#define OBJECT_STITCHLEN_NEW_SAME 9 // 固定针迹长度(等距分)
|
|
#define OBJECT_STITCHLEN_NEW_SAMALL 10 // 固定针迹长度(小等分)
|
|
#define ADJUSTLINE_ADD_DUAN_LIMIT 11 // 自动单针指定分段添加
|
|
|
|
typedef struct
|
|
{
|
|
double x;
|
|
double y;
|
|
} Point2D;
|
|
|
|
typedef struct
|
|
{
|
|
double x;
|
|
double y;
|
|
int ctrl;
|
|
} QuiPoint;
|
|
|
|
int isThreePointOnALine(const double threex[],const double threey[]);
|
|
int getArcCenter(const double x[], const double y[], double * pxc, double * pyc, double * pr);
|
|
int getArcMinMax(const double x[], const double y[], double * pminx, double * pmaxx, double * pminy, double * pmaxy);
|
|
void rotatec(double xin, double yin, double * px, double * py, double angle);
|
|
int arcDir(const double x[], const double y[]);
|
|
|
|
Point2D pointOnCubicBezier(Point2D* cp, double t);
|
|
void computeBezier(Point2D* cp, long numberOfPoints, Point2D* curve);
|
|
int getBezierMinMax(const double x[], const double y[], double * pminx, double * pmaxx, double * pminy, double * pmaxy);
|
|
int getSplineMinMax(QList<QPointF> &ptList, double * pminx, double * pmaxx, double * pminy, double * pmaxy);
|
|
|
|
int calcLine(double x0, double y0, double x1, double y1, s16 step, QByteArray &absAry, WORD datatype);
|
|
int calcCurve(double threex[], double threey[], s16 step, QByteArray &absAry);
|
|
int calcBezier(double threex[], double threey[], s16 step, QByteArray &absAry);
|
|
void getBezierPointList(double threex[], double threey[], s16 step, QList<QPointF> &outList);
|
|
|
|
//样条拟合
|
|
void getSplineNew(QList<QPointF> &ptList, QList<QPointF> &splineList);
|
|
void getShap(int nCtrlPntNum, QPointF *pPoint, QList<QPointF> &splineList, double dfMinX, double dfMinY);
|
|
//线段拟合
|
|
void getCurvePointFillLine(QList<QPointF> &inList, double indRunLen,
|
|
QList<QPointF> &outList, int iSumParm, BYTE biLenLimit);
|
|
int getTotalDistanceFillLine(QList<QPointF> *pPointList, double &dTotal);
|
|
void pointToPoint(const QPointF &inPoint, QPointF &outPoint);
|
|
long doubleToLong(double indValue);//浮点数转整形
|
|
double round(double indValue);//四舍五入
|
|
void distPointToPoint(const QPointF &p1, const QPointF &p2, double &outd);
|
|
bool getPointInSectFillLine(const QPointF &p1, const QPointF &p2, const double &d, QPointF &outp);
|
|
|
|
//距p1点距离为d的点
|
|
// d > s : out_p在p2延长线上
|
|
// s >= d >= 0 : out_p在p1、p2线段上
|
|
// d < 0 : out_p在p1延长线上
|
|
bool getPointAtSect(const QPointF &p1, const QPointF &p2, const double &d, QPointF &outp);
|
|
|
|
// 两点间距离
|
|
double disPointToPoint(double x1, double y1, double x2, double y2);
|
|
|
|
|
|
#endif // DATAOPERAT_H
|