0032402: Coding Rules - eliminate msvc warning C4668 (symbol is not defined as a...
[occt.git] / src / math / math_FunctionAllRoots.hxx
1 // Created on: 1991-07-17
2 // Created by: Isabelle GRIGNON
3 // Copyright (c) 1991-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 #ifndef _math_FunctionAllRoots_HeaderFile
18 #define _math_FunctionAllRoots_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Boolean.hxx>
25 #include <TColStd_SequenceOfReal.hxx>
26 #include <TColStd_SequenceOfInteger.hxx>
27 #include <Standard_Real.hxx>
28 #include <Standard_Integer.hxx>
29 #include <Standard_OStream.hxx>
30 class Standard_OutOfRange;
31 class StdFail_NotDone;
32 class Standard_NumericError;
33 class math_FunctionWithDerivative;
34 class math_FunctionSample;
35
36
37 //! This algorithm uses a sample of the function to find
38 //! all intervals on which the function is null, and afterwards
39 //! uses the FunctionRoots algorithm to find the points
40 //! where the function is null outside the "null intervals".
41 //! Knowledge of the derivative is required.
42 class math_FunctionAllRoots 
43 {
44 public:
45
46   DEFINE_STANDARD_ALLOC
47
48   
49   //! The algorithm uses the sample to find intervals on which
50   //! the function is null. An interval is found if, for at least
51   //! two consecutive points of the sample, Ui and Ui+1, we get
52   //! |F(Ui)|<=EpsNul and |F(Ui+1)|<=EpsNul. The real bounds of
53   //! an interval are computed with the FunctionRoots.
54   //! algorithm.
55   //! Between two intervals, the roots of the function F are
56   //! calculated using the FunctionRoots algorithm.
57   Standard_EXPORT math_FunctionAllRoots(math_FunctionWithDerivative& F, const math_FunctionSample& S, const Standard_Real EpsX, const Standard_Real EpsF, const Standard_Real EpsNul);
58   
59   //! Returns True if the computation has been done successfully.
60     Standard_Boolean IsDone() const;
61   
62   //! Returns the number of intervals on which the function
63   //! is Null.
64   //! An exception is raised if IsDone returns False.
65     Standard_Integer NbIntervals() const;
66   
67   //! Returns the interval of parameter of range Index.
68   //! An exception is raised if IsDone returns False;
69   //! An exception is raised if Index<=0 or Index >Nbintervals.
70     void GetInterval (const Standard_Integer Index, Standard_Real& A, Standard_Real& B) const;
71   
72   //! returns the State Number associated to the interval Index.
73   //! An exception is raised if IsDone returns False;
74   //! An exception is raised if Index<=0 or Index >Nbintervals.
75     void GetIntervalState (const Standard_Integer Index, Standard_Integer& IFirst, Standard_Integer& ILast) const;
76   
77   //! returns the number of points where the function is Null.
78   //! An exception is raised if IsDone returns False.
79     Standard_Integer NbPoints() const;
80   
81   //! Returns the parameter of the point of range Index.
82   //! An exception is raised if IsDone returns False;
83   //! An exception is raised if Index<=0 or Index >NbPoints.
84     Standard_Real GetPoint (const Standard_Integer Index) const;
85   
86   //! returns the State Number associated to the point Index.
87   //! An exception is raised if IsDone returns False;
88   //! An exception is raised if Index<=0 or Index >Nbintervals.
89     Standard_Integer GetPointState (const Standard_Integer Index) const;
90   
91   //! Prints on the stream o information on the current state
92   //! of the object.
93   Standard_EXPORT void Dump (Standard_OStream& o) const;
94
95
96
97
98 protected:
99
100
101
102
103
104 private:
105
106
107
108   Standard_Boolean done;
109   TColStd_SequenceOfReal pdeb;
110   TColStd_SequenceOfReal pfin;
111   TColStd_SequenceOfReal piso;
112   TColStd_SequenceOfInteger ideb;
113   TColStd_SequenceOfInteger ifin;
114   TColStd_SequenceOfInteger iiso;
115
116
117 };
118
119
120 #include <math_FunctionAllRoots.lxx>
121
122
123
124
125
126 #endif // _math_FunctionAllRoots_HeaderFile