0029915: Porting to VC 2017 : Regressions in Modeling Algorithms on VC 2017
[occt.git] / src / Extrema / Extrema_ExtPC2d.hxx
1 // Created on: 1991-02-26
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 _Extrema_ExtPC2d_HeaderFile
18 #define _Extrema_ExtPC2d_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Address.hxx>
25 #include <gp_Pnt2d.hxx>
26 #include <Extrema_ExtPElC2d.hxx>
27 #include <Extrema_SequenceOfPOnCurv2d.hxx>
28 #include <Standard_Boolean.hxx>
29 #include <Standard_Real.hxx>
30 #include <Extrema_EPCOfExtPC2d.hxx>
31 #include <Standard_Integer.hxx>
32 #include <GeomAbs_CurveType.hxx>
33 #include <TColStd_SequenceOfBoolean.hxx>
34 #include <TColStd_SequenceOfReal.hxx>
35 class StdFail_NotDone;
36 class Standard_OutOfRange;
37 class Standard_TypeMismatch;
38 class Adaptor2d_Curve2d;
39 class Extrema_Curve2dTool;
40 class Extrema_ExtPElC2d;
41 class gp_Pnt2d;
42 class gp_Vec2d;
43 class Extrema_POnCurv2d;
44 class Extrema_EPCOfExtPC2d;
45 class Extrema_PCFOfEPCOfExtPC2d;
46
47
48
49 class Extrema_ExtPC2d 
50 {
51 public:
52
53   DEFINE_STANDARD_ALLOC
54
55   
56   Standard_EXPORT Extrema_ExtPC2d();
57   
58   //! It calculates all the distances.
59   //! The function F(u)=distance(P,C(u)) has an extremum
60   //! when g(u)=dF/du=0. The algorithm searchs all the
61   //! zeros inside the definition range of the curve.
62   //! Zeros are searched between uinf and usup.
63   //! Tol  is used to decide to stop the
64   //! iterations according to the following condition:
65   //! if n is the number of iterations,
66   //! the algorithm stops when abs(F(Un)-F(Un-1)) < Tol.
67   Standard_EXPORT Extrema_ExtPC2d(const gp_Pnt2d& P, const Adaptor2d_Curve2d& C, const Standard_Real Uinf, const Standard_Real Usup, const Standard_Real TolF = 1.0e-10);
68   
69   //! It calculates all the distances.
70   //! The function F(u)=distance(P,C(u)) has an extremum
71   //! when g(u)=dF/du=0. The algorithm searchs all the
72   //! zeros inside the definition range of the curve.
73   //! Tol is used to decide to stop the
74   //! iterations according to the following condition:
75   //! if n is the number of iterations,
76   //! the algorithm stops when abs(F(Un)-F(Un-1)) < Tol.
77   Standard_EXPORT Extrema_ExtPC2d(const gp_Pnt2d& P, const Adaptor2d_Curve2d& C, const Standard_Real TolF = 1.0e-10);
78   
79   //! initializes the fields of the algorithm.
80   Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real Uinf, const Standard_Real Usup, const Standard_Real TolF = 1.0e-10);
81   
82   //! An exception is raised if the fields have not been
83   //! initialized.
84   Standard_EXPORT void Perform (const gp_Pnt2d& P);
85   
86   //! True if the distances are found.
87   Standard_EXPORT Standard_Boolean IsDone() const;
88   
89   //! Returns the value of the <N>th extremum square distance.
90   Standard_EXPORT Standard_Real SquareDistance (const Standard_Integer N) const;
91   
92   //! Returns the number of extremum distances.
93   Standard_EXPORT Standard_Integer NbExt() const;
94   
95   //! Returns True if the <N>th extremum distance is a
96   //! minimum.
97   Standard_EXPORT Standard_Boolean IsMin (const Standard_Integer N) const;
98   
99   //! Returns the point of the <N>th extremum distance.
100   Standard_EXPORT const Extrema_POnCurv2d& Point (const Standard_Integer N) const;
101   
102   //! if the curve is a trimmed curve,
103   //! dist1 is a square distance between <P> and the point
104   //! of parameter FirstParameter <P1> and
105   //! dist2 is a square distance between <P> and the point
106   //! of parameter LastParameter <P2>.
107   Standard_EXPORT void TrimmedSquareDistances (Standard_Real& dist1, Standard_Real& dist2, gp_Pnt2d& P1, gp_Pnt2d& P2) const;
108
109
110
111
112 protected:
113
114   
115   Standard_EXPORT void IntervalPerform (const gp_Pnt2d& P);
116
117   Standard_EXPORT void AddSol(const Standard_Real theU,
118                               const gp_Pnt2d& theP,
119                               const Standard_Real theSqDist,
120                               const Standard_Boolean isMin);
121
122
123
124 private:
125
126
127
128   Standard_Address myC;
129   gp_Pnt2d Pf;
130   gp_Pnt2d Pl;
131   Extrema_ExtPElC2d myExtPElC;
132   Extrema_SequenceOfPOnCurv2d mypoint;
133   Standard_Boolean mydone;
134   Standard_Real mydist1;
135   Standard_Real mydist2;
136   Extrema_EPCOfExtPC2d myExtPC;
137   Standard_Real mytolu;
138   Standard_Real mytolf;
139   Standard_Integer mysample;
140   Standard_Real myintuinf;
141   Standard_Real myintusup;
142   Standard_Real myuinf;
143   Standard_Real myusup;
144   GeomAbs_CurveType type;
145   TColStd_SequenceOfBoolean myismin;
146   TColStd_SequenceOfReal mySqDist;
147
148
149 };
150
151
152
153
154
155
156
157 #endif // _Extrema_ExtPC2d_HeaderFile