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