File indexing completed on 2026-09-20 09:17:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef _Extrema_GenLocateExtPC_HeaderFile
0018 #define _Extrema_GenLocateExtPC_HeaderFile
0019
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022
0023 #include <math_FunctionRoot.hxx>
0024 #include <StdFail_NotDone.hxx>
0025
0026 #include <cmath>
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 template <typename TheCurve,
0038 typename TheTool,
0039 typename ThePOnC,
0040 typename ThePnt,
0041 typename ThePCLocF>
0042 class Extrema_GenLocateExtPC
0043 {
0044 public:
0045 DEFINE_STANDARD_ALLOC
0046
0047
0048 Extrema_GenLocateExtPC()
0049 : myDone(false),
0050 mytolU(0.0),
0051 myumin(0.0),
0052 myusup(0.0)
0053 {
0054 }
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 Extrema_GenLocateExtPC(const ThePnt& theP,
0065 const TheCurve& theC,
0066 const double theU0,
0067 const double theTolU)
0068 {
0069 Initialize(theC, TheTool::FirstParameter(theC), TheTool::LastParameter(theC), theTolU);
0070 Perform(theP, theU0);
0071 }
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082 Extrema_GenLocateExtPC(const ThePnt& theP,
0083 const TheCurve& theC,
0084 const double theU0,
0085 const double theUmin,
0086 const double theUsup,
0087 const double theTolU)
0088 {
0089 Initialize(theC, theUmin, theUsup, theTolU);
0090 Perform(theP, theU0);
0091 }
0092
0093
0094 void Initialize(const TheCurve& theC,
0095 const double theUmin,
0096 const double theUsup,
0097 const double theTolU)
0098 {
0099 myDone = false;
0100 myF.Initialize(theC);
0101 myumin = theUmin;
0102 myusup = theUsup;
0103 mytolU = theTolU;
0104 }
0105
0106
0107
0108 void Perform(const ThePnt& theP, const double theU0)
0109 {
0110 myF.SetPoint(theP);
0111 math_FunctionRoot S(myF, theU0, mytolU, myumin, myusup);
0112 myDone = S.IsDone();
0113 if (myDone)
0114 {
0115 double uu, ff;
0116 const ThePOnC& PP = Point();
0117 uu = PP.Parameter();
0118 if (myF.Value(uu, ff))
0119 {
0120 if (std::abs(ff) >= 1.e-07)
0121 myDone = false;
0122 }
0123 else
0124 myDone = false;
0125 }
0126 }
0127
0128
0129 bool IsDone() const { return myDone; }
0130
0131
0132 double SquareDistance() const
0133 {
0134 if (!IsDone())
0135 {
0136 throw StdFail_NotDone();
0137 }
0138 return myF.SquareDistance(1);
0139 }
0140
0141
0142 bool IsMin() const
0143 {
0144 if (!IsDone())
0145 {
0146 throw StdFail_NotDone();
0147 }
0148 return myF.IsMin(1);
0149 }
0150
0151
0152 const ThePOnC& Point() const
0153 {
0154 if (!IsDone())
0155 {
0156 throw StdFail_NotDone();
0157 }
0158 return myF.Point(1);
0159 }
0160
0161 private:
0162 bool myDone;
0163 double mytolU;
0164 double myumin;
0165 double myusup;
0166 ThePCLocF myF;
0167 };
0168
0169 #endif