b311480e |
1 | // Created on: 1994-09-06 |
2 | // Created by: Yves FRICAUD |
3 | // Copyright (c) 1994-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. |
7fd59977 |
16 | |
17 | #include <gp.hxx> |
18 | #include <Precision.hxx> |
19 | |
20 | //============================================================================= |
21 | //function : |
22 | // purpose : |
23 | //============================================================================= |
24 | LProp_FuncCurExt::LProp_FuncCurExt(const Curve& C, |
25 | const Standard_Real Tol) |
26 | :theCurve(C) |
27 | { |
28 | epsX = Tol; |
29 | } |
30 | |
31 | //============================================================================= |
32 | //function : Value |
33 | // purpose : KC = (V1^V2.Z) / ||V1||^3 avec V1 tangente etV2 derivee seconde. |
34 | // F = d KC/ dU. |
35 | //============================================================================= |
36 | Standard_Boolean LProp_FuncCurExt::Value (const Standard_Real X, |
37 | Standard_Real& F) |
38 | { |
39 | Pnt P1; |
40 | Vec V1,V2,V3; |
41 | |
42 | Tool::D3(theCurve,X,P1,V1,V2,V3); |
43 | Standard_Real CPV1V2 = V1.Crossed(V2); |
44 | Standard_Real CPV1V3 = V1.Crossed(V3); |
45 | Standard_Real V1V2 = V1.Dot(V2); |
46 | Standard_Real V1V1 = V1.SquareMagnitude(); |
47 | Standard_Real NV1 = Sqrt(V1V1); |
48 | Standard_Real V13 = V1V1*NV1; |
49 | Standard_Real V15 = V13*V1V1; |
50 | |
51 | if (V15 < gp::Resolution()) { |
52 | return Standard_False; |
53 | } |
54 | F = CPV1V3/V13 - 3*CPV1V2*V1V2/V15; |
55 | |
56 | return Standard_True; |
57 | } |
58 | |
59 | //============================================================================= |
60 | //function : Derivative |
61 | // purpose : |
62 | //============================================================================= |
63 | Standard_Boolean LProp_FuncCurExt::Derivative(const Standard_Real X, |
64 | Standard_Real& D) |
65 | { |
66 | Standard_Real F; |
67 | return Values (X,F,D) ; |
68 | } |
69 | |
70 | //============================================================================= |
71 | //function : Values |
72 | // purpose : |
73 | //============================================================================= |
74 | Standard_Boolean LProp_FuncCurExt::Values (const Standard_Real X, |
75 | Standard_Real& F, |
76 | Standard_Real& D) |
77 | { |
78 | Standard_Real F2; |
79 | Standard_Real Dx= epsX/100.; |
80 | |
81 | if (X+Dx > Tool::LastParameter(theCurve)) {Dx = - Dx;} |
82 | |
83 | Value (X,F); |
84 | Value (X+Dx,F2); |
85 | D = (F2 - F)/Dx; |
86 | |
87 | return Standard_True; |
88 | } |
89 | |
90 | |
91 | //============================================================================= |
92 | //function : IsMinKC |
93 | // purpose : Teste si le parametere coorespond a un minimum du rayon de courbure |
94 | // par comparaison avec un point voisin. |
95 | //============================================================================= |
96 | Standard_Boolean LProp_FuncCurExt::IsMinKC (const Standard_Real X) const |
97 | { |
98 | Pnt P1; |
99 | Vec V1,V2,V3; |
100 | Standard_Real Dx= epsX; |
101 | Standard_Real KC,KP; |
102 | |
103 | Tool::D3(theCurve,X,P1,V1,V2,V3); |
104 | Standard_Real CPV1V2 = V1.Crossed(V2); |
105 | Standard_Real V1V1 = V1.SquareMagnitude(); |
106 | Standard_Real NV1 = Sqrt(V1V1); |
107 | Standard_Real V13 = V1V1*NV1; |
108 | |
109 | if (V13 < gp::Resolution()) {return Standard_False;} |
110 | |
111 | KC = CPV1V2/V13; |
112 | |
113 | if (X+Dx > Tool::LastParameter(theCurve)) {Dx = - Dx;} |
114 | |
115 | Tool::D3(theCurve,X+Dx,P1,V1,V2,V3); |
116 | CPV1V2 = V1.Crossed(V2); |
117 | V1V1 = V1.SquareMagnitude(); |
118 | NV1 = Sqrt(V1V1); |
119 | V13 = V1V1*NV1; |
120 | |
121 | if (V13 < gp::Resolution()) { return Standard_False;} |
122 | KP = CPV1V2/V13; |
123 | |
124 | if (Abs(KC) > Abs(KP)) {return Standard_True ;} |
125 | else {return Standard_False;} |
126 | |
127 | } |