460 lines
8.0 KiB
C++
460 lines
8.0 KiB
C++
|
|
#pragma once
|
|
#ifndef __NEWDATASRUCT_H
|
|
#define __NEWDATASRUCT_H
|
|
#include<vector>
|
|
#include <math.h>
|
|
#define ROW 12 //所能输入的最多点数
|
|
#define COL ROW
|
|
using namespace std;
|
|
struct Mat
|
|
{
|
|
Mat()
|
|
{
|
|
m_pArr=NULL;
|
|
m_nRow=0;
|
|
m_nCol=0;
|
|
}
|
|
Mat(int row,int col)
|
|
{
|
|
if(row>0&&col>0)
|
|
{
|
|
m_nRow=row;
|
|
m_nCol=col;
|
|
m_pArr=new double[row*col]; //自动选取 automatism 自动化 automatization 边沿 edge fringe 边缘
|
|
}
|
|
else
|
|
{
|
|
m_nRow=0;
|
|
m_nCol=0;
|
|
m_pArr=NULL;
|
|
}
|
|
}
|
|
Mat(Mat& mat)
|
|
{
|
|
m_nRow=mat.m_nRow;
|
|
m_nCol=mat.m_nCol;
|
|
int length=m_nRow*m_nCol;
|
|
m_pArr=new double[length];
|
|
for(int i=0;i<length;i++)
|
|
m_pArr[i]=mat.m_pArr[i];
|
|
}
|
|
|
|
Mat& operator=(Mat& mat)
|
|
{
|
|
m_nRow=mat.m_nRow;
|
|
m_nCol=mat.m_nCol;
|
|
int length=m_nRow*m_nCol;
|
|
if(m_pArr)
|
|
delete []m_pArr;
|
|
m_pArr=new double[length];
|
|
for(int i=0;i<length;i++)
|
|
m_pArr[i]=mat.m_pArr[i];
|
|
return (*this);
|
|
}
|
|
|
|
void ReSet(int row,int col)
|
|
{
|
|
if(m_pArr)
|
|
delete []m_pArr;
|
|
m_nRow=row;
|
|
m_nCol=col;
|
|
m_pArr=new double[row*col];
|
|
}
|
|
|
|
void SetRow(int row)
|
|
{
|
|
if(m_pArr)
|
|
delete []m_pArr;
|
|
m_nRow=row;
|
|
if(m_nRow>0&&m_nCol>0)
|
|
m_pArr=new double[m_nRow*m_nCol];
|
|
}
|
|
|
|
void SetCol(int col)
|
|
{
|
|
if(m_pArr)
|
|
delete []m_pArr;
|
|
m_nCol=col;
|
|
if(m_nRow>0&&m_nCol>0)
|
|
m_pArr=new double[m_nRow*m_nCol];
|
|
}
|
|
|
|
BOOL SetData(int row,int col,double data)
|
|
{
|
|
if(row<0||row>=m_nRow||col<0||col>=m_nCol)
|
|
return FALSE;
|
|
m_pArr[row*m_nCol+col]=data;
|
|
return TRUE;
|
|
}
|
|
|
|
double GetData(int row,int col)
|
|
{
|
|
return m_pArr[row*m_nCol+col];
|
|
}
|
|
|
|
Mat TurnSet()
|
|
{
|
|
Mat temp(m_nCol,m_nRow);
|
|
|
|
for(int i=0;i<temp.m_nRow;i++)
|
|
for(int j=0;j<temp.m_nCol;j++)
|
|
temp.SetData(i,j,GetData(j,i));
|
|
|
|
return temp;
|
|
}
|
|
|
|
Mat operator *(Mat& mat)
|
|
{
|
|
Mat temp;
|
|
|
|
if(m_nCol!=mat.m_nRow)
|
|
return temp;
|
|
temp.ReSet(m_nRow,mat.m_nCol);
|
|
for(int i=0;i<m_nRow;i++)
|
|
{
|
|
for(int j=0;j<mat.m_nCol;j++)
|
|
{
|
|
temp.SetData(i,j,0.0);
|
|
|
|
for(int k=0;k<m_nCol;k++)
|
|
temp.SetData(i,j,temp.GetData(i,j)+GetData(i,k)*mat.GetData(k,j));
|
|
}
|
|
}
|
|
return temp;
|
|
}
|
|
|
|
BOOL IsEmpty()
|
|
{
|
|
return m_pArr==NULL;
|
|
}
|
|
|
|
~Mat()
|
|
{
|
|
if(m_pArr)
|
|
{
|
|
delete []m_pArr;
|
|
m_pArr=NULL;
|
|
}
|
|
}
|
|
|
|
double* m_pArr;
|
|
int m_nRow;
|
|
int m_nCol;
|
|
};
|
|
|
|
struct PointDB
|
|
{
|
|
double _x;
|
|
double _y;
|
|
PointDB()
|
|
{
|
|
_x=0.0;
|
|
_y=0.0;
|
|
}
|
|
|
|
PointDB(double x,double y)
|
|
{
|
|
_x=x;
|
|
_y=y;
|
|
}
|
|
|
|
PointDB operator-(PointDB& pot)
|
|
{
|
|
PointDB temp;
|
|
temp._x=_x-pot._x;
|
|
temp._y=_y-pot._y;
|
|
return temp;
|
|
}
|
|
|
|
PointDB operator+(PointDB& pot)
|
|
{
|
|
PointDB temp;
|
|
temp._x=_x+pot._x;
|
|
temp._y=_y+pot._y;
|
|
return temp;
|
|
}
|
|
|
|
PointDB operator/(double div)
|
|
{
|
|
PointDB temp;
|
|
temp._x=_x/div;
|
|
temp._y=_y/div;
|
|
return temp;
|
|
}
|
|
|
|
PointDB operator*(double mul)
|
|
{
|
|
PointDB temp;
|
|
temp._x=_x*mul;
|
|
temp._y=_y*mul;
|
|
return temp;
|
|
}
|
|
double length()
|
|
{
|
|
return sqrt(_x*_x+_y*_y);
|
|
}
|
|
BOOL operator ==(PointDB& pot)
|
|
{
|
|
return fabs(_x-pot._x)<0.0001&&fabs(_y-pot._y)<0.0001;
|
|
}
|
|
//PointDB& operator =(PointDB& pot)
|
|
//{
|
|
// _x=(double)pot._x;
|
|
// _y=(double)pot._y;
|
|
// return *this;
|
|
//}
|
|
PointDB operator=(PointDB pot) { _x=pot._x; _y=pot._y; return (*this); }
|
|
|
|
};
|
|
|
|
|
|
struct Point
|
|
{
|
|
int _x;
|
|
int _y;
|
|
|
|
Point() { _x=0; _y=0; }
|
|
Point(int x,int y) { _x=x; _y=y; }
|
|
Point(PointDB pot) { _x=(int)(pot._x+0.5); _y=(int)(pot._y+0.5); }
|
|
Point(CPoint pot) { _x=pot.x; _y=pot.y; }
|
|
|
|
void Empty() { _x=0; _y=0; }
|
|
BOOL IsEmpty() { return (_x==0&&_y==0); }
|
|
|
|
void Left(int i=1) { _x-=i; }
|
|
void Right(int i=1) { _x+=i; }
|
|
void Top(int i=1) { _y-=i; }
|
|
void Bottom(int i=1) { _y+=i; }
|
|
|
|
operator CPoint() { return CPoint(_x,_y); }
|
|
operator PointDB() { return PointDB(_x,_y); };
|
|
Point operator=(CPoint pot) { _x=pot.x; _y=pot.y; return (*this); }
|
|
Point operator=(Point pot) { _x=pot._x; _y=pot._y; return (*this); }
|
|
Point operator=(PointDB pot) { _x=(int)(pot._x+0.5); _y=(int)(pot._y+0.5); return (*this); }
|
|
BOOL operator==(Point& pot) { return _x==pot._x&&_y==pot._y; }
|
|
Point operator+(CPoint pot) { int x=_x+pot.x; int y=_y+pot.y; return Point(x,y); }
|
|
Point operator-(CPoint pot) { int x=_x-pot.x; int y=_y-pot.y; return Point(x,y); }
|
|
Point operator+(Point pot) { int x=_x+pot._x; int y=_y+pot._y; return Point(x,y); }
|
|
Point operator-(Point pot) { int x=_x-pot._x; int y=_y-pot._y; return Point(x,y); }
|
|
Point operator*(int mul) { int x=_x*mul; int y=_y*mul; return Point(x,y); }
|
|
Point operator*(double mul) { int x=(int)(_x*mul+0.5); int y=(int)(_y*mul+0.5); return Point(x,y); }
|
|
Point operator/(double mul) { int x=(int)(_x/mul+0.5); int y=(int)(_y/mul+0.5); return Point(x,y); }
|
|
Point operator/(int mul) { int x=_x/mul; int y=_y/mul; return Point(x,y); }
|
|
Point& operator +=(int add) { _x+=add; _y+=add; return *this; }
|
|
Point& operator /=(int mul) { _x/=mul; _y/=mul; return *this; }
|
|
|
|
double length() { return sqrt((double)(_x*_x+_y*_y)); }
|
|
};
|
|
|
|
|
|
struct PointEx:public PointDB
|
|
{
|
|
double _length;
|
|
PointEx& operator =(PointEx& pot) { _x=pot._x;_y=pot._y;_length=pot._length;return *this; }
|
|
PointEx& operator =(PointDB& pot) { _x=pot._x;_y=pot._y;_length=0.0;return *this; }
|
|
operator CRect() { return CRect((int)_x-2,(int)_y-2,(int)_x+2,(int)_y+2); }
|
|
};
|
|
|
|
struct SimpleLine
|
|
{
|
|
double k;
|
|
double m;
|
|
};
|
|
|
|
struct MYPIXEL
|
|
{
|
|
BYTE R;
|
|
BYTE G;
|
|
BYTE B;
|
|
};
|
|
|
|
struct Rect
|
|
{
|
|
int left;
|
|
int top;
|
|
int right;
|
|
int bottom;
|
|
void SetRect(int l,int t,int r,int b)
|
|
{
|
|
left=l;
|
|
top=t;
|
|
right=r;
|
|
bottom=b;
|
|
}
|
|
void SetRectEmpty()
|
|
{
|
|
left=0;
|
|
top=0;
|
|
right=0;
|
|
bottom=0;
|
|
}
|
|
Rect& operator=(CRect& rc)
|
|
{
|
|
left=rc.left;
|
|
top=rc.top;
|
|
right=rc.right;
|
|
bottom=rc.bottom;
|
|
return *this;
|
|
}
|
|
};
|
|
struct PointInt
|
|
{
|
|
INT x;
|
|
INT y;
|
|
PointInt()
|
|
{
|
|
x=0;
|
|
y=0;
|
|
}
|
|
|
|
PointInt(INT xPara,INT yPara)
|
|
{
|
|
this->x=xPara;
|
|
this->y=yPara;
|
|
}
|
|
|
|
PointInt operator+(PointInt& pot)
|
|
{
|
|
PointInt temp;
|
|
temp.x=x+pot.x;
|
|
temp.y=y+pot.y;
|
|
return temp;
|
|
}
|
|
|
|
PointInt operator*(INT mul)
|
|
{
|
|
PointInt temp;
|
|
temp.x=x*mul;
|
|
temp.y=y*mul;
|
|
return temp;
|
|
}
|
|
};
|
|
|
|
struct PointDB_New
|
|
{
|
|
double x;
|
|
double y;
|
|
PointDB_New()
|
|
{
|
|
x=0.0;
|
|
y=0.0;
|
|
}
|
|
|
|
PointDB_New(double xPara,double yPara)
|
|
{
|
|
this->x=xPara;
|
|
this->y=yPara;
|
|
}
|
|
|
|
PointDB_New operator+(PointDB_New& pot)
|
|
{
|
|
PointDB_New temp;
|
|
temp.x=x+pot.x;
|
|
temp.y=y+pot.y;
|
|
return temp;
|
|
}
|
|
|
|
PointDB_New operator-(PointDB_New& pot)
|
|
{
|
|
PointDB_New temp;
|
|
temp.x=x-pot.x;
|
|
temp.y=y-pot.y;
|
|
return temp;
|
|
}
|
|
|
|
PointDB_New operator+(CPoint& pot)
|
|
{
|
|
PointDB_New temp;
|
|
temp.x=x+(double)pot.x;
|
|
temp.y=y+(double)pot.y;
|
|
return temp;
|
|
}
|
|
|
|
PointDB_New operator-(CPoint& pot)
|
|
{
|
|
PointDB_New temp;
|
|
temp.x=x-(double)pot.x;
|
|
temp.y=y-(double)pot.y;
|
|
return temp;
|
|
}
|
|
|
|
PointDB_New operator*(double mul)
|
|
{
|
|
PointDB_New temp;
|
|
temp.x=x*mul;
|
|
temp.y=y*mul;
|
|
return temp;
|
|
}
|
|
|
|
PointDB_New& operator=(CPoint& pot)
|
|
{
|
|
x=(double)pot.x;
|
|
y=(double)pot.y;
|
|
return *this;
|
|
}
|
|
|
|
PointDB_New& operator=(PointDB_New& pot)
|
|
{
|
|
x=pot.x;
|
|
y=pot.y;
|
|
return *this;
|
|
}
|
|
double Length()
|
|
{
|
|
return sqrt(x*x+y*y);
|
|
}
|
|
};
|
|
|
|
typedef struct tagdrawpoint
|
|
{
|
|
double X_COOR;
|
|
double Y_COOR;
|
|
}DRAWPoint;
|
|
|
|
typedef struct{
|
|
double x;
|
|
double y;
|
|
double z;
|
|
}MY3DPoint/*点*//*,MY3DVector向量*/;
|
|
|
|
typedef struct Squ
|
|
{
|
|
double ppA[ROW][COL];
|
|
int row;
|
|
int col;
|
|
}Squ;
|
|
|
|
typedef struct tagpoint
|
|
{
|
|
double X;
|
|
double Y;
|
|
double R;
|
|
tagpoint operator=(tagpoint pot) { X=pot.X; Y=pot.Y; R=pot.R; return (*this); }
|
|
}READPOINT;
|
|
|
|
|
|
struct SetCtrl{
|
|
short THREAD_WIDTH; //线宽
|
|
short AVER_NUMS; //做一个平均值的个数
|
|
short RETURN_NUM_POINTS; //返回点数
|
|
short MIN_POINTS; //认为是曲线的最少点数
|
|
SetCtrl(void) {THREAD_WIDTH=5; AVER_NUMS=5; RETURN_NUM_POINTS=200; MIN_POINTS=100;}
|
|
};
|
|
|
|
struct LinkVec{
|
|
vector <Point> vec;
|
|
};
|
|
|
|
struct LinkVecDB{
|
|
vector <PointDB> vec;
|
|
};
|
|
|
|
typedef struct{
|
|
int x;
|
|
int y;
|
|
int value;
|
|
double r;
|
|
}PointDBV;
|
|
|
|
#endif |