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