b311480e |
1 | // Created on: 1994-09-05 |
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 <math_FunctionRoots.hxx> |
23 | #include <math_BracketedRoot.hxx> |
24 | #include <Precision.hxx> |
25 | |
26 | //======================================================================= |
27 | //function : |
28 | //purpose : |
29 | //======================================================================= |
30 | LProp_NumericCurInf::LProp_NumericCurInf() |
31 | { |
32 | } |
33 | //======================================================================= |
34 | //function : PerformCurExt |
35 | //purpose : |
36 | //======================================================================= |
37 | void LProp_NumericCurInf::PerformCurExt (const Curve& C,LProp_CurAndInf& Result) |
38 | { |
39 | PerformCurExt(C,Tool::FirstParameter(C),Tool::LastParameter(C),Result); |
40 | } |
41 | |
42 | //======================================================================= |
43 | //function : PerformCurExt |
44 | //purpose : |
45 | //======================================================================= |
46 | void LProp_NumericCurInf::PerformCurExt (const Curve& C, |
47 | const Standard_Real UMin, |
48 | const Standard_Real UMax, |
49 | LProp_CurAndInf& Result) |
50 | { |
51 | isDone = Standard_True; |
52 | |
53 | Standard_Real EpsH = 1.e-4*(UMax - UMin); |
54 | Standard_Real Tol = Precision::PConfusion(); |
55 | |
56 | // la premiere recherce se fait avec une tolerance assez grande |
57 | // car la derivee de la fonction est estimee assez grossierement. |
58 | |
59 | LProp_FCurExt F(C,EpsH); |
60 | Standard_Integer NbSamples = 100; |
61 | Standard_Boolean SolType; |
62 | |
63 | math_FunctionRoots SolRoot (F,UMin,UMax,NbSamples,EpsH,EpsH,EpsH); |
64 | |
65 | if (SolRoot.IsDone()) { |
66 | for (Standard_Integer j = 1; j <= SolRoot.NbSolutions(); j++) { |
67 | Standard_Real Param = SolRoot.Value(j); |
68 | // la solution est affinee. |
69 | math_BracketedRoot BS (F, |
70 | Param - EpsH, |
71 | Param + EpsH, |
72 | Tol); |
73 | if (BS.IsDone()) {Param = BS.Root();} |
74 | SolType = F.IsMinKC(Param); |
75 | Result.AddExtCur(Param,SolType); |
76 | } |
77 | } |
78 | else { |
79 | isDone = Standard_False; |
80 | } |
81 | } |
82 | |
83 | //======================================================================= |
84 | //function : PerformInf |
85 | //purpose : |
86 | //======================================================================= |
87 | void LProp_NumericCurInf::PerformInf(const Curve& C,LProp_CurAndInf& Result) |
88 | { |
89 | PerformInf(C,Tool::FirstParameter(C),Tool::LastParameter(C),Result); |
90 | } |
91 | |
92 | //======================================================================= |
93 | //function : PerformInf |
94 | //purpose : |
95 | //======================================================================= |
96 | void LProp_NumericCurInf::PerformInf(const Curve& C, |
97 | const Standard_Real UMin, |
98 | const Standard_Real UMax, |
99 | LProp_CurAndInf& Result) |
100 | { |
101 | isDone = Standard_True; |
102 | LProp_FCurNul F(C); |
103 | Standard_Real EpsX = 1.e-6; |
104 | Standard_Real EpsF = 1.e-6; |
105 | Standard_Integer NbSamples = 30; |
106 | |
107 | math_FunctionRoots SolRoot (F,UMin,UMax,NbSamples,EpsX,EpsF,EpsX); |
108 | |
109 | if (SolRoot.IsDone()) { |
110 | for (Standard_Integer j = 1; j <= SolRoot.NbSolutions(); j++) { |
111 | Result.AddInflection(SolRoot.Value(j)); |
112 | } |
113 | } |
114 | else { |
115 | isDone = Standard_False; |
116 | } |
117 | } |
118 | |
119 | //======================================================================= |
120 | //function : IsDone |
121 | //purpose : |
122 | //======================================================================= |
123 | Standard_Boolean LProp_NumericCurInf::IsDone() const |
124 | { |
125 | return isDone; |
126 | } |
127 | |