b311480e |
1 | // Created on: 1999-02-19 |
2 | // Created by: Sergey KHROMOV |
3 | // Copyright (c) 1999-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
973c2be1 |
8 | // This library is free software; you can redistribute it and / or modify it |
9 | // under the terms of the GNU Lesser General Public version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
17 | static Standard_Boolean NotParallel(gp_Vec& T, gp_Vec& V) |
7fd59977 |
18 | { |
19 | V = T; |
20 | V.SetX(V.X() + 1.); |
21 | if (V.CrossMagnitude(T) > 1.e-12) |
22 | return Standard_True; |
23 | V.SetY(V.Y() + 1.); |
24 | if (V.CrossMagnitude(T) > 1.e-12) |
25 | return Standard_True; |
26 | V.SetZ(V.Z() + 1.); |
27 | if (V.CrossMagnitude(T) > 1.e-12) |
28 | return Standard_True; |
29 | return Standard_False; |
30 | } |
31 | |
32 | Standard_Boolean AppParCurves_Variational::InitTthetaF(const Standard_Integer ndimen, |
33 | const AppParCurves_Constraint typcon, |
34 | const Standard_Integer begin, |
35 | const Standard_Integer jndex) |
36 | { |
37 | if ((ndimen < 2)||(ndimen >3)) |
38 | return Standard_False; |
39 | gp_Vec T, V; |
40 | gp_Vec theta1, theta2; |
41 | gp_Vec F; |
42 | Standard_Real XX, XY, YY, XZ, YZ, ZZ; |
43 | |
44 | if ((typcon == AppParCurves_TangencyPoint)||(typcon == AppParCurves_CurvaturePoint)) |
45 | { |
46 | T.SetX(myTabConstraints->Value(jndex)); |
47 | T.SetY(myTabConstraints->Value(jndex + 1)); |
48 | if (ndimen == 3) |
49 | T.SetZ(myTabConstraints->Value(jndex + 2)); |
50 | else |
51 | T.SetZ(0.); |
52 | if (ndimen == 2) |
53 | { |
54 | V.SetX(0.); |
55 | V.SetY(0.); |
56 | V.SetZ(1.); |
57 | } |
58 | if (ndimen == 3) |
59 | if (!NotParallel(T, V)) |
60 | return Standard_False; |
61 | theta1 = V ^ T; |
62 | theta1.Normalize(); |
63 | myTtheta->SetValue(begin, theta1.X()); |
64 | myTtheta->SetValue(begin + 1, theta1.Y()); |
65 | if (ndimen == 3) |
66 | { |
67 | theta2 = T ^ theta1; |
68 | theta2.Normalize(); |
69 | myTtheta->SetValue(begin + 2, theta1.Z()); |
70 | myTtheta->SetValue(begin + 3, theta2.X()); |
71 | myTtheta->SetValue(begin + 4, theta2.Y()); |
72 | myTtheta->SetValue(begin + 5, theta2.Z()); |
73 | } |
74 | |
75 | // Calculation of myTfthet |
76 | if (typcon == AppParCurves_CurvaturePoint) |
77 | { |
78 | XX = Pow(T.X(), 2); |
79 | XY = T.X() * T.Y(); |
80 | YY = Pow(T.Y(), 2); |
81 | if (ndimen == 2) |
82 | { |
83 | F.SetX(YY * theta1.X() - XY * theta1.Y()); |
84 | F.SetY(XX * theta1.Y() - XY * theta1.X()); |
85 | myTfthet->SetValue(begin, F.X()); |
86 | myTfthet->SetValue(begin + 1, F.Y()); |
87 | } |
88 | if (ndimen == 3) |
89 | { |
90 | XZ = T.X() * T.Z(); |
91 | YZ = T.Y() * T.Z(); |
92 | ZZ = Pow(T.Z(), 2); |
93 | |
94 | F.SetX((ZZ + YY) * theta1.X() - XY * theta1.Y() - XZ * theta1.Z()); |
95 | F.SetY((XX + ZZ) * theta1.Y() - XY * theta1.X() - YZ * theta1.Z()); |
96 | F.SetZ((XX + YY) * theta1.Z() - XZ * theta1.X() - YZ * theta1.Y()); |
97 | myTfthet->SetValue(begin, F.X()); |
98 | myTfthet->SetValue(begin + 1, F.Y()); |
99 | myTfthet->SetValue(begin + 2, F.Z()); |
100 | F.SetX((ZZ + YY) * theta2.X() - XY * theta2.Y() - XZ * theta2.Z()); |
101 | F.SetY((XX + ZZ) * theta2.Y() - XY * theta2.X() - YZ * theta2.Z()); |
102 | F.SetZ((XX + YY) * theta2.Z() - XZ * theta2.X() - YZ * theta2.Y()); |
103 | myTfthet->SetValue(begin + 3, F.X()); |
104 | myTfthet->SetValue(begin + 4, F.Y()); |
105 | myTfthet->SetValue(begin + 5, F.Z()); |
106 | } |
107 | } |
108 | } |
109 | return Standard_True; |
110 | } |