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 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
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 | |
a104bb8f |
17 | |
42cf5bc1 |
18 | #include <Geom2d_Curve.hxx> |
a104bb8f |
19 | #include <Geom2dLProp_Curve2dTool.hxx> |
42cf5bc1 |
20 | #include <Geom2dLProp_FuncCurExt.hxx> |
7fd59977 |
21 | #include <gp.hxx> |
42cf5bc1 |
22 | #include <gp_Pnt2d.hxx> |
7fd59977 |
23 | #include <Precision.hxx> |
24 | |
25 | //============================================================================= |
26 | //function : |
27 | // purpose : |
28 | //============================================================================= |
a104bb8f |
29 | Geom2dLProp_FuncCurExt::Geom2dLProp_FuncCurExt(const Handle(Geom2d_Curve)& C, |
30 | const Standard_Real Tol) |
31 | :theCurve(C) |
7fd59977 |
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 | //============================================================================= |
a104bb8f |
41 | Standard_Boolean Geom2dLProp_FuncCurExt::Value (const Standard_Real X, |
42 | Standard_Real& F) |
7fd59977 |
43 | { |
a104bb8f |
44 | gp_Pnt2d P1; |
45 | gp_Vec2d V1,V2,V3; |
7fd59977 |
46 | |
a104bb8f |
47 | Geom2dLProp_Curve2dTool::D3(theCurve,X,P1,V1,V2,V3); |
7fd59977 |
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 | //============================================================================= |
a104bb8f |
68 | Standard_Boolean Geom2dLProp_FuncCurExt::Derivative(const Standard_Real X, |
69 | Standard_Real& D) |
7fd59977 |
70 | { |
71 | Standard_Real F; |
72 | return Values (X,F,D) ; |
73 | } |
74 | |
75 | //============================================================================= |
76 | //function : Values |
77 | // purpose : |
78 | //============================================================================= |
a104bb8f |
79 | Standard_Boolean Geom2dLProp_FuncCurExt::Values (const Standard_Real X, |
80 | Standard_Real& F, |
81 | Standard_Real& D) |
7fd59977 |
82 | { |
83 | Standard_Real F2; |
84 | Standard_Real Dx= epsX/100.; |
85 | |
a104bb8f |
86 | if (X+Dx > Geom2dLProp_Curve2dTool::LastParameter(theCurve)) {Dx = - Dx;} |
7fd59977 |
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 | //============================================================================= |
a104bb8f |
101 | Standard_Boolean Geom2dLProp_FuncCurExt::IsMinKC (const Standard_Real X) const |
7fd59977 |
102 | { |
a104bb8f |
103 | gp_Pnt2d P1; |
104 | gp_Vec2d V1,V2,V3; |
7fd59977 |
105 | Standard_Real Dx= epsX; |
106 | Standard_Real KC,KP; |
107 | |
a104bb8f |
108 | Geom2dLProp_Curve2dTool::D3(theCurve,X,P1,V1,V2,V3); |
7fd59977 |
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 | |
a104bb8f |
118 | if (X+Dx > Geom2dLProp_Curve2dTool::LastParameter(theCurve)) {Dx = - Dx;} |
7fd59977 |
119 | |
a104bb8f |
120 | Geom2dLProp_Curve2dTool::D3(theCurve,X+Dx,P1,V1,V2,V3); |
7fd59977 |
121 | CPV1V2 = V1.Crossed(V2); |
122 | V1V1 = V1.SquareMagnitude(); |
123 | NV1 = Sqrt(V1V1); |
124 | V13 = V1V1*NV1; |
a104bb8f |
125 | |
7fd59977 |
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 | } |