📄 cadbase.h
字号:
//-- {CycleCode: 242} file [0..9632]
//-- {StartSubRegion: 279} module.ifndef [0..20]
#ifndef _CAD_DEF_H_
//-- {StartSubRegion: 280} module.define [21..41]
#define _CAD_DEF_H_
//-- {AddDecl: 243} module.includes preserve=yes [42..85]
//## begin module.includes preserve=yes
#include <math.h>
#include <afxtempl.h>
//## end module.includes preserve=yes
//-- {InsertRegion: 282} module.vulnerableDeclarations [86..1006]
//## begin module.additionalDeclarations preserve=yes
#define CAD_ZERO 1.0E-6
#define NC_ZERO 1.0E-3
#define IS_ZERO(x) (fabs(x)<=CAD_ZERO)
#define IS_NCZERO(x) (fabs(x)<=NC_ZERO)
#define IS_BETWEEN(x,min,max) (x<=max && x>=min)
#define PI 3.1415926535
typedef struct tagRect{
double left;
double right;
double top;
double bottom;
} RECT2D, *PRECT2D;
typedef struct tagPoint2D{
double x;
double y;
} POINT2D, *PPOINT2D;
typedef struct tagVector2D{
double dx;
double dy;
} VECTOR2D,*PVECTOR2D;
typedef struct tagPoint3D{
double x;
double y;
double z;
} POINT3D, *PPOINT3D;
typedef struct tagVector3D{
double dx;
double dy;
double dz;
} VECTOR3D,*PVECTOR3D;
typedef struct tagMatrix2D{
double A[3][3];
} MATRIX2D, *PMATRIX2D;
typedef struct tagMatrix3D{
double A[4][4];
} MATRIX3D, *PMATRIX3D;
class CPoint2D;
class CPoint3D;
class CVector2D;
class CVector3D;
class CMatrix2D;
class CMatrix3D;
//## end module.additionalDeclarations
//-- {AddDecl: 244} region.inlineAnnotation [1007..1006]
//-- {AddDecl: 245} class [1007..1281]
class __declspec(dllexport) CRect2D :public RECT2D
{
//-- {AddDecl: 246} region.generated [1060..1279]
public:
void Scale(double scale);
CRect2D(CPoint2D p1,CPoint2D p2);
CRect2D(double l, double b, double r, double t);
CPoint2D GetConter();
double GetHeight();
double GetWidth();
CRect2D();
~CRect2D();
CRect2D operator+(CRect2D v) const;
void operator+=(CRect2D v);
};
//-- {AddDecl: 247} region.inlineAnnotation [1282..1285]
//-- {AddDecl: 248} class [1286..1937]
class __declspec(dllexport) CPoint2D :public POINT2D
{
//-- {AddDecl: 249} region.generated [1341..1934]
public:
CPoint2D();
CPoint2D(double ix,double iy);
CPoint2D(const double*);
CPoint2D(POINT2D p);
~CPoint2D();
public:
//operators
CPoint2D operator*(const MATRIX2D& matrix) const;
void operator*=(const MATRIX2D& matrix);
BOOL operator==(const CPoint2D Po2D);
//offsetting with vector
CPoint2D operator+(VECTOR2D v) const;
void operator+=(VECTOR2D v);
CPoint2D operator-(VECTOR2D v) const;
void operator-=(VECTOR2D v);
//derived vector = this point - sp
CPoint2D operator /(const MATRIX2D &matrix);
CVector2D operator-(POINT2D sp) const;
//
} ;
//-- {AddDecl: 250} module.vulnerableDeclarations [1938..2089]
//## begin CPoint2D.postscript preserve=yes
// Intersection Point structure
typedef struct tagInterPOINT2D{
CPoint2D interPt;
double t0;
double t1;
} INTERPOINT2D,*PINTERPOINT2D;
//## end CPoint2D.postscript
//-- {AddDecl: 251} region.inlineAnnotation [2090..2089]
//-- {AddDecl: 252} class [2090..2998]
class __declspec(dllexport) CVector2D : public VECTOR2D
{
//-- {AddDecl: 253} region.generated [2150..2996]
public:
CVector2D();
CVector2D(double ix,double iy=0.0);
CVector2D(const double* pv);
CVector2D(VECTOR2D v);
virtual ~CVector2D();
public:
//operators declaration
CVector2D operator+(VECTOR2D v) const;
CVector2D operator-(VECTOR2D v) const;
void operator+=(VECTOR2D v);
void operator-=(VECTOR2D v);
CVector2D operator*(double d) const;
void operator*=(double d);
CVector2D operator/(double d) const;
void operator/=(double d);
// cross product
CVector3D operator*(VECTOR2D v) const;
// dot product
double operator|(VECTOR2D v) const;
//matrix transformation
CVector2D operator*(const MATRIX2D& matrix ) const;
void operator*=(const MATRIX2D& matrix );
//methods declaration
double GetLength()const;
CVector2D GetNormal()const;
void Normalize();
BOOL IsZeroLength() const;
};
//-- {AddDecl: 254} region.inlineAnnotation [2999..3002]
//-- {AddDecl: 255} class [3003..3684]
class __declspec(dllexport) CPoint3D :public POINT3D
{
//-- {AddDecl: 256} region.generated [3058..3681]
public:
CPoint3D();
CPoint3D(double ix,double iy,double iz=0.0);
CPoint3D(const double*);
CPoint3D(POINT3D p);
~CPoint3D();
public:
//operators
CPoint3D operator*(const MATRIX3D& matrix) const;
void operator*=(const MATRIX3D& matrix);
void operator=(CPoint2D Po2D);
//offsetting with vector
CPoint3D operator+(VECTOR3D v) const;
void operator+=(VECTOR3D v);
CPoint3D operator-(VECTOR3D v) const;
void operator-=(VECTOR3D v);
BOOL operator==(POINT3D pos) const;
BOOL operator!=(POINT3D pos) const;
//derived vector = this point - sp
CVector3D operator-(POINT3D sp) const;
} ;
//-- {AddDecl: 257} region.inlineAnnotation [3685..3688]
//-- {AddDecl: 258} class [3689..4626]
class __declspec(dllexport) CVector3D: public VECTOR3D
{
//-- {AddDecl: 259} region.generated [3746..4624]
public:
CVector3D();
CVector3D(double dx,double dy,double dz=0);
CVector3D(const double*);
CVector3D(VECTOR3D v);
virtual ~CVector3D();
//operator
CVector3D operator+(VECTOR3D v) const;
void operator+=(VECTOR3D v);
CVector3D operator-(VECTOR3D v) const;
void operator-=(VECTOR3D v);
CVector3D operator*(double d) const;
void operator*=(double d);
CVector3D operator/(double d) const;
void operator/=(double d);
//cross product
CVector3D operator*(VECTOR3D v) const;
//dot product
double operator|(VECTOR3D v) const;
CVector3D operator*(const MATRIX3D& matrix) const;
void operator*=(const MATRIX3D& matrix);
//length
double GetLength() const;
double GetLengthXY() const;
double GetLengthYZ() const;
double GetLengthZX() const;
CVector3D GetNormal() const;
void Normalize();
BOOL IsZeroLength() const;
};
//-- {AddDecl: 260} region.inlineAnnotation [4627..4632]
//-- {AddDecl: 261} class [4633..5436]
class __declspec(dllexport) CMatrix2D : public MATRIX2D
{
//-- {AddDecl: 262} region.generated [4691..5433]
public:
CMatrix2D();
CMatrix2D(const MATRIX2D&);
CMatrix2D(const double *);
virtual ~CMatrix2D();
//operators
CMatrix2D operator*(const MATRIX2D&) const;
void operator*=(const MATRIX2D&);
//methods
void IdenticalMatrix();
double GetValue() const;
CMatrix2D GetAccompany()const;
CMatrix2D operator ~();
CMatrix2D T()const;
public:
void IdenticalOffset();
CVector2D GetOffset();
// static member functions
static double GetValue(double a00, double a01,
double a10, double a11);
static CMatrix2D CreateMirrorMatrix(VECTOR2D vect);
static CMatrix2D CreateRotateMatrix(double angle);
static CMatrix2D CreateScaleMatrix(double);
static CMatrix2D CreateTransfMatrix(VECTOR2D vect);
} ;
//-- {AddDecl: 263} region.inlineAnnotation [5437..5441]
//-- {AddDecl: 264} class [5442..6210]
class __declspec(dllexport) CMatrix3D : public MATRIX3D
{
//-- {AddDecl: 265} region.generated [5500..6207]
public:
CMatrix3D();
CMatrix3D(const MATRIX3D&);
CMatrix3D(const double *);
virtual ~CMatrix3D();
public:
//operators
CMatrix3D operator*(const MATRIX3D& matrix)const;
void operator*=(const MATRIX3D& matrix);
//methods
void IdenticalMatrix();
double GetValue() const;
public:
// static member functions
static double GetValue(double a00, double a01, double a02,
double a10, double a11, double a12,
double a20, double a21, double a22);
static CMatrix3D CreateMirrorMatrix(VECTOR3D plnNorm);
static CMatrix3D CreateRotateMatrix(double da,VECTOR3D bv);
static CMatrix3D CreateScaleMatrix(double);
static CMatrix3D CreateTransfMatrix(VECTOR3D vec);
} ;
//-- {AddDecl: 266} module.vulnerableDeclarations [6211..6547]
//## begin CMatrix3D.postscript preserve=yes
//////////////////////////////////////////////////////////////////////////
// (x0,y0): the left and bottom corner
// (x1,y1): the right and top corner
//////////////////////////////////////////////////////////////////////////
typedef struct tagBox2D{
double x0;
double y0;
double x1;
double y1;
} BOX2D , *PBOX2D;
//## end CMatrix3D.postscript
//-- {AddDecl: 267} region.inlineAnnotation [6548..6547]
//-- {AddDecl: 268} class [6548..7359]
class __declspec(dllexport) CBox2D : public BOX2D
{
//-- {AddDecl: 269} region.generated [6600..7244]
//constructor && destructor
public:
CBox2D();
CBox2D(double ix0,double iy0,double ix1,double iy1);
CBox2D(POINT2D pt0,POINT2D pt1);
CBox2D(BOX2D b);
CBox2D(POINT2D p,VECTOR2D v);
virtual ~CBox2D();
// operator
public:
//// get the union box of this and box b.
CBox2D operator+(BOX2D b) const;
void operator+=(BOX2D b);
//// get the intersect box of this and box b.
CBox2D operator&(BOX2D b) const;
void operator&=(BOX2D b);
// get attribs
public:
BOOL IsZero() const;
double Width() const; // Length of X direction
double Height()const; // Length of Y direction
// relationship culation
public:
//-- {AddDecl: 270} module.vulnerableDeclarations [7245..7284]
//## begin CBox2D.initialDeclarations preserve=yes
public:
enum {enumSeparated,enumIntersected};
//## end CBox2D.initialDeclarations
//-- {AddDecl: 271} region.generated [7285..7357]
UINT GetRelationWith(BOX2D b) const;
protected:
void normalize();
};
//-- {AddDecl: 272} module.vulnerableDeclarations [7360..7721]
//## begin CBox2D.postscript preserve=yes
//////////////////////////////////////////////////////////////////////////
// (x0,y0): the left and bottom corner
// (x1,y1): the right and top corner
//////////////////////////////////////////////////////////////////////////
typedef struct tagBox3D{
double x0;
double y0;
double z0;
double x1;
double y1;
double z1;
} BOX3D , *PBOX3D;
//## end CBox2D.postscript
//-- {AddDecl: 273} region.inlineAnnotation [7722..7721]
//-- {AddDecl: 274} class [7722..9067]
class __declspec(dllexport) CBox3D : public BOX3D
{
//-- {AddDecl: 275} region.generated [7774..8921]
//constructor && destructor
public:
CBox3D();
CBox3D(double ix0,double iy0,double iz0, double ix1,double iy1, double iz1);
CBox3D(POINT3D pt0,POINT3D pt1);
CBox3D(BOX3D b);
CBox3D(POINT3D p,VECTOR3D v);
virtual ~CBox3D();
// operator
public:
//// get the union box of this and box b.
CBox3D operator+(BOX3D b) const;
void operator+=(BOX3D b);
//// get the intersect box of this and box b.
CBox3D operator&(BOX3D b) const;
void operator&=(BOX3D b);
CBox3D operator*( double sc ) const;
void operator*= ( double sc );
CBox3D operator*( const MATRIX3D& matrix ) const;
void operator*= ( const MATRIX3D& matrix );
BOOL operator<< ( BOX3D b )const ;
BOOL operator>> ( BOX3D b ) const;
BOOL operator>> ( POINT3D p ) const;
CBox3D operator|(BOX3D b) const;
void operator|=(BOX3D b);
CBox3D operator+(VECTOR3D vect) const;
void operator+=(VECTOR3D vect);
CBox3D operator-(VECTOR3D vect)const;
void operator-=(VECTOR3D vect);
// get attribs
BOOL IsEmpty() const;
double Width() const; //// Length of X direction
double Height() const; //// Length of Z direction
double Length( )const;
//-- {AddDecl: 276} module.vulnerableDeclarations [8922..8990]
//## begin CBox3D.initialDeclarations preserve=yes
public:
//// Length of Y direction
enum {enumSeparated,enumIntersected};
//## end CBox3D.initialDeclarations
//-- {AddDecl: 277} region.generated [8991..9065]
UINT GetRelationWith(BOX3D b) const;
protected:
void normalize();
};
//-- {AddDecl: 278} module.vulnerableDeclarations [9068..9624]
//## begin module.epilog preserve=yes
typedef struct tagIndexSerise
{
UINT * pPointIndexS;
UINT PointNumber;
} IndexSerise , *LPIndexSerise;
// exported API functions
//double AFX_EXT_API AngleBetween(VECTOR2D v1,VECTOR2D v2);
//double AFX_EXT_API AngleBetween(VECTOR3D v1,VECTOR3D v2);
//double AFX_EXT_API DistOf(POINT2D pt0, POINT2D pt1);
//double AFX_EXT_API DistOf(POINT3D pt0, POINT3D pt1);
//BOOL AFX_EXT_API IsParallel(VECTOR2D v0,VECTOR2D v1);
//BOOL AFX_EXT_API IsParallel(VECTOR3D v0,VECTOR3D v1);
//BOOL AFX_EXT_API IsOrthogonal(VECTOR3D v0,VECTOR3D v1);
//## end module.epilog
//-- {StartSubRegion: 281} module.endif [9625..9632]
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -