-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nurbs-DS.h
111 lines (94 loc) · 1.96 KB
/
Nurbs-DS.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <iostream>
using namespace std;
/*定义通用数据类型 */
typedef int INDEX;
typedef short FLAG;
typedef int INTEGER;
typedef float REAL;
typedef char * STRING;
typedef short DEGRSE;
typedef double PARAMETER;
/*通用数据结构*/
struct point //普通点
{
REAL x,
y,
z;
void init() { this->x = 0.0; this->y = 0.0; this->z = 0.0; }
template<typename T>
inline point & operator * (const T &p)
{ //重载*运算,进行point和其他的乘法运算,使用形式如 point*p point类型在前;
point *q;
q = new point;
q->x = this->x * p;
q->y = this->y * p;
q->z = this->z * p; //*this->w
return *q;
}
template<typename C>
inline point & operator / (const C &p)
{ //重载*运算,进行point和其他的乘法运算,使用形式如 point*p point类型在前;
point *q;
q = new point;
q->x = this->x / p;
q->y = this->y / p;
q->z = this->z / p; //*this->w
return *q;
}
inline point & operator + (const point &p)
{
//重载+运算,进行两个point相加
point *q;
q = new point;
q->x = this->x + p.x;
q->y = this->y + p.y;
q->z = this->z + p.z; //*this->w
return *q;
}
};
struct cpoint //带权点
{
REAL x,
y,
z,
w;
void init() { this->x = 0.0; this->y = 0.0; this->z = 0.0; this->w = 0.0; }
template<typename T>
inline cpoint & operator * (const T &p)
{ //重载*运算,进行cpoint和其他的乘法运算,使用形式如 cpoint*p cpoint类型在前;
cpoint *q;
q = new cpoint;
q->x = this->x * p;
q->y = this->y * p;
q->z = this->z * p;
q->w = this->w * p; //*this->w
return *q;
}
inline cpoint & operator + (const cpoint &p)
{
//重载+运算,进行两个cpoint相加
cpoint *q;
q = new cpoint;
q->x = this->x + p.x;
q->y = this->y + p.y;
q->z = this->z + p.z;
q->w = this->w + p.w; //*this->w
return *q;
}
};
struct cpolygon //面
{
INDEX n;
cpoint *Pw;
};
struct knotvector //节点矢量
{
INDEX m;
REAL * U;
};
struct curve //曲线
{
cpolygon *pol;
DEGRSE p;
knotvector * knt;
};