0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / Geom2dLProp / Geom2dLProp_NumericCurInf2d.cxx
1 // Created on: 1994-09-05
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Geom2d_Curve.hxx>
19 #include <Geom2dLProp_Curve2dTool.hxx>
20 #include <Geom2dLProp_FuncCurExt.hxx>
21 #include <Geom2dLProp_FuncCurNul.hxx>
22 #include <Geom2dLProp_NumericCurInf2d.hxx>
23 #include <LProp_CurAndInf.hxx>
24 #include <math_BracketedRoot.hxx>
25 #include <math_FunctionRoots.hxx>
26 #include <Precision.hxx>
27
28 //=======================================================================
29 //function : 
30 //purpose  : 
31 //=======================================================================
32 Geom2dLProp_NumericCurInf2d::Geom2dLProp_NumericCurInf2d()
33 : isDone(Standard_False)
34 {
35 }
36 //=======================================================================
37 //function : PerformCurExt
38 //purpose  : 
39 //=======================================================================
40 void Geom2dLProp_NumericCurInf2d::PerformCurExt (const Handle(Geom2d_Curve)& C,LProp_CurAndInf& Result)
41 {
42   PerformCurExt(C,Geom2dLProp_Curve2dTool::FirstParameter(C),Geom2dLProp_Curve2dTool::LastParameter(C),Result);
43 }
44
45 //=======================================================================
46 //function : PerformCurExt
47 //purpose  : 
48 //=======================================================================
49 void Geom2dLProp_NumericCurInf2d::PerformCurExt (const Handle(Geom2d_Curve)& C,
50                                                  const Standard_Real UMin,
51                                                  const Standard_Real UMax,
52                                                  LProp_CurAndInf&    Result)
53 {
54   isDone = Standard_True;
55
56   Standard_Real    EpsH = 1.e-4*(UMax - UMin);
57   Standard_Real    Tol  = Precision::PConfusion();
58
59   // la premiere recherce se fait avec une tolerance assez grande
60   // car la derivee de la fonction est estimee assez grossierement.
61
62   Geom2dLProp_FuncCurExt    F(C,EpsH);
63   Standard_Integer NbSamples = 100;
64   Standard_Boolean SolType;
65
66   math_FunctionRoots SolRoot (F,UMin,UMax,NbSamples,EpsH,EpsH,EpsH);
67
68   if (SolRoot.IsDone()) {
69     for (Standard_Integer j = 1; j <= SolRoot.NbSolutions(); j++) {
70       Standard_Real Param = SolRoot.Value(j);
71       // la solution est affinee.
72       math_BracketedRoot BS (F,
73         Param - EpsH,
74         Param + EpsH,
75         Tol);
76       if (BS.IsDone()) {Param = BS.Root();}
77       SolType = F.IsMinKC(Param);
78       Result.AddExtCur(Param,SolType);
79     }
80   }
81   else {
82     isDone = Standard_False;
83   }
84 }
85
86 //=======================================================================
87 //function : PerformInf
88 //purpose  : 
89 //=======================================================================
90 void Geom2dLProp_NumericCurInf2d::PerformInf(const Handle(Geom2d_Curve)& C,LProp_CurAndInf& Result)
91 {  
92   PerformInf(C,Geom2dLProp_Curve2dTool::FirstParameter(C),Geom2dLProp_Curve2dTool::LastParameter(C),Result);
93 }
94
95 //=======================================================================
96 //function : PerformInf
97 //purpose  : 
98 //=======================================================================
99 void Geom2dLProp_NumericCurInf2d::PerformInf(const Handle(Geom2d_Curve)& C,                                      
100                                              const Standard_Real UMin,
101                                              const Standard_Real UMax,
102                                              LProp_CurAndInf& Result)
103 {
104   isDone = Standard_True;
105   Geom2dLProp_FuncCurNul    F(C);
106   Standard_Real    EpsX = 1.e-6;
107   Standard_Real    EpsF = 1.e-6;
108   Standard_Integer NbSamples = 30;
109
110   math_FunctionRoots SolRoot (F,UMin,UMax,NbSamples,EpsX,EpsF,EpsX);
111
112   if (SolRoot.IsDone()) {
113     for (Standard_Integer j = 1; j <= SolRoot.NbSolutions(); j++) {
114       Result.AddInflection(SolRoot.Value(j));
115     }
116   }
117   else {
118     isDone = Standard_False;
119   }  
120 }
121
122 //=======================================================================
123 //function : IsDone
124 //purpose  : 
125 //=======================================================================
126 Standard_Boolean Geom2dLProp_NumericCurInf2d::IsDone() const
127 {
128   return isDone;
129 }
130