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