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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#include <math.hxx>
#include <math_Vector.hxx>
#include <gp.hxx>
#include <gp_Vec.hxx>
#include <Standard_NotImplemented.hxx>
#include <TColStd_Array1OfReal.hxx>
GProp_CGProps::GProp_CGProps(){}
void GProp_CGProps::SetLocation(const gp_Pnt& CLocation)
{
loc = CLocation;
}
void GProp_CGProps::Perform (const Curve& C)
{
Standard_Real Ix, Iy, Iz, Ixx, Iyy, Izz, Ixy, Ixz, Iyz;
dim = Ix = Iy = Iz = Ixx = Iyy = Izz = Ixy = Ixz = Iyz = 0.0;
Standard_Real Lower = Tool::FirstParameter (C);
Standard_Real Upper = Tool::LastParameter (C);
Standard_Integer Order = Min(Tool::IntegrationOrder (C),
math::GaussPointsMax());
gp_Pnt P; //value on the curve
gp_Vec V1; //first derivative on the curve
Standard_Real ds; //curvilign abscissae
Standard_Real ur, um, u;
Standard_Real x, y, z;
Standard_Real xloc, yloc, zloc;
math_Vector GaussP (1, Order);
math_Vector GaussW (1, Order);
//Recuperation des points de Gauss dans le fichier GaussPoints.
math::GaussPoints (Order,GaussP);
math::GaussWeights (Order,GaussW);
// modified by NIZHNY-MKK Thu Jun 9 12:13:21 2005.BEGIN
Standard_Integer nbIntervals = Tool::NbIntervals(C, GeomAbs_CN);
Standard_Boolean bHasIntervals = (nbIntervals > 1);
TColStd_Array1OfReal TI(1, nbIntervals + 1);
if(bHasIntervals) {
Tool::Intervals(C, TI, GeomAbs_CN);
}
else {
nbIntervals = 1;
}
Standard_Integer nIndex = 0;
Standard_Real UU1 = Min(Lower, Upper);
Standard_Real UU2 = Max(Lower, Upper);
for(nIndex = 1; nIndex <= nbIntervals; nIndex++) {
if(bHasIntervals) {
Lower = Max(TI(nIndex), UU1);
Upper = Min(TI(nIndex+1), UU2);
}
else {
Lower = UU1;
Upper = UU2;
}
Standard_Real dimLocal, IxLocal, IyLocal, IzLocal, IxxLocal, IyyLocal, IzzLocal, IxyLocal, IxzLocal, IyzLocal;
dimLocal = IxLocal = IyLocal = IzLocal = IxxLocal = IyyLocal = IzzLocal = IxyLocal = IxzLocal = IyzLocal = 0.0;
// modified by NIZHNY-MKK Thu Jun 9 12:13:32 2005.END
loc.Coord (xloc, yloc, zloc);
Standard_Integer i;
// Calcul des integrales aux points de gauss :
um = 0.5 * (Upper + Lower);
ur = 0.5 * (Upper - Lower);
for (i = 1; i <= Order; i++) {
u = um + ur * GaussP (i);
Tool::D1 (C,u, P, V1);
ds = V1.Magnitude();
P.Coord (x, y, z);
x -= xloc;
y -= yloc;
z -= zloc;
ds *= GaussW (i);
dimLocal += ds;
IxLocal += x * ds;
IyLocal += y * ds;
IzLocal += z * ds;
IxyLocal += x * y * ds;
IyzLocal += y * z * ds;
IxzLocal += x * z * ds;
x *= x;
y *= y;
z *= z;
IxxLocal += (y + z) * ds;
IyyLocal += (x + z) * ds;
IzzLocal += (x + y) * ds;
}
// modified by NIZHNY-MKK Thu Jun 9 12:13:47 2005.BEGIN
dimLocal *= ur;
IxLocal *= ur;
IyLocal *= ur;
IzLocal *= ur;
IxxLocal *= ur;
IyyLocal *= ur;
IzzLocal *= ur;
IxyLocal *= ur;
IxzLocal *= ur;
IyzLocal *= ur;
dim += dimLocal;
Ix += IxLocal;
Iy += IyLocal;
Iz += IzLocal;
Ixx += IxxLocal;
Iyy += IyyLocal;
Izz += IzzLocal;
Ixy += IxyLocal;
Ixz += IxzLocal;
Iyz += IyzLocal;
}
// modified by NIZHNY-MKK Thu Jun 9 12:13:55 2005.END
inertia = gp_Mat (gp_XYZ (Ixx, -Ixy, -Ixz),
gp_XYZ (-Ixy, Iyy, -Iyz),
gp_XYZ (-Ixz, -Iyz, Izz));
if (Abs(dim) < gp::Resolution())
g = P;
else
g.SetCoord (Ix/dim, Iy/dim, Iz/dim);
}
GProp_CGProps::GProp_CGProps (const Curve& C,
const gp_Pnt& CLocation)
{
SetLocation(CLocation);
Perform(C);
}
|