b311480e |
1 | // Created on: 1994-09-06 |
2 | // Created by: Yves FRICAUD |
3 | // Copyright (c) 1994-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | #include <gp.hxx> |
23 | #include <Precision.hxx> |
24 | |
25 | //============================================================================= |
26 | //function : |
27 | // purpose : |
28 | //============================================================================= |
29 | LProp_FuncCurExt::LProp_FuncCurExt(const Curve& C, |
30 | const Standard_Real Tol) |
31 | :theCurve(C) |
32 | { |
33 | epsX = Tol; |
34 | } |
35 | |
36 | //============================================================================= |
37 | //function : Value |
38 | // purpose : KC = (V1^V2.Z) / ||V1||^3 avec V1 tangente etV2 derivee seconde. |
39 | // F = d KC/ dU. |
40 | //============================================================================= |
41 | Standard_Boolean LProp_FuncCurExt::Value (const Standard_Real X, |
42 | Standard_Real& F) |
43 | { |
44 | Pnt P1; |
45 | Vec V1,V2,V3; |
46 | |
47 | Tool::D3(theCurve,X,P1,V1,V2,V3); |
48 | Standard_Real CPV1V2 = V1.Crossed(V2); |
49 | Standard_Real CPV1V3 = V1.Crossed(V3); |
50 | Standard_Real V1V2 = V1.Dot(V2); |
51 | Standard_Real V1V1 = V1.SquareMagnitude(); |
52 | Standard_Real NV1 = Sqrt(V1V1); |
53 | Standard_Real V13 = V1V1*NV1; |
54 | Standard_Real V15 = V13*V1V1; |
55 | |
56 | if (V15 < gp::Resolution()) { |
57 | return Standard_False; |
58 | } |
59 | F = CPV1V3/V13 - 3*CPV1V2*V1V2/V15; |
60 | |
61 | return Standard_True; |
62 | } |
63 | |
64 | //============================================================================= |
65 | //function : Derivative |
66 | // purpose : |
67 | //============================================================================= |
68 | Standard_Boolean LProp_FuncCurExt::Derivative(const Standard_Real X, |
69 | Standard_Real& D) |
70 | { |
71 | Standard_Real F; |
72 | return Values (X,F,D) ; |
73 | } |
74 | |
75 | //============================================================================= |
76 | //function : Values |
77 | // purpose : |
78 | //============================================================================= |
79 | Standard_Boolean LProp_FuncCurExt::Values (const Standard_Real X, |
80 | Standard_Real& F, |
81 | Standard_Real& D) |
82 | { |
83 | Standard_Real F2; |
84 | Standard_Real Dx= epsX/100.; |
85 | |
86 | if (X+Dx > Tool::LastParameter(theCurve)) {Dx = - Dx;} |
87 | |
88 | Value (X,F); |
89 | Value (X+Dx,F2); |
90 | D = (F2 - F)/Dx; |
91 | |
92 | return Standard_True; |
93 | } |
94 | |
95 | |
96 | //============================================================================= |
97 | //function : IsMinKC |
98 | // purpose : Teste si le parametere coorespond a un minimum du rayon de courbure |
99 | // par comparaison avec un point voisin. |
100 | //============================================================================= |
101 | Standard_Boolean LProp_FuncCurExt::IsMinKC (const Standard_Real X) const |
102 | { |
103 | Pnt P1; |
104 | Vec V1,V2,V3; |
105 | Standard_Real Dx= epsX; |
106 | Standard_Real KC,KP; |
107 | |
108 | Tool::D3(theCurve,X,P1,V1,V2,V3); |
109 | Standard_Real CPV1V2 = V1.Crossed(V2); |
110 | Standard_Real V1V1 = V1.SquareMagnitude(); |
111 | Standard_Real NV1 = Sqrt(V1V1); |
112 | Standard_Real V13 = V1V1*NV1; |
113 | |
114 | if (V13 < gp::Resolution()) {return Standard_False;} |
115 | |
116 | KC = CPV1V2/V13; |
117 | |
118 | if (X+Dx > Tool::LastParameter(theCurve)) {Dx = - Dx;} |
119 | |
120 | Tool::D3(theCurve,X+Dx,P1,V1,V2,V3); |
121 | CPV1V2 = V1.Crossed(V2); |
122 | V1V1 = V1.SquareMagnitude(); |
123 | NV1 = Sqrt(V1V1); |
124 | V13 = V1V1*NV1; |
125 | |
126 | if (V13 < gp::Resolution()) { return Standard_False;} |
127 | KP = CPV1V2/V13; |
128 | |
129 | if (Abs(KC) > Abs(KP)) {return Standard_True ;} |
130 | else {return Standard_False;} |
131 | |
132 | } |