File indexing completed on 2026-09-28 09:19:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef _Extrema_GenLocateExtCC_HeaderFile
0018 #define _Extrema_GenLocateExtCC_HeaderFile
0019
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022
0023 #include <math_FunctionSetRoot.hxx>
0024 #include <math_Vector.hxx>
0025 #include <StdFail_NotDone.hxx>
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 template <typename TheCurve, typename TheTool, typename ThePOnC, typename TheCCLocF>
0036 class Extrema_GenLocateExtCC
0037 {
0038 public:
0039 DEFINE_STANDARD_ALLOC
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 Extrema_GenLocateExtCC(const TheCurve& theC1,
0050 const TheCurve& theC2,
0051 const double theU0,
0052 const double theV0,
0053 const double theTolU,
0054 const double theTolV)
0055 {
0056 myDone = false;
0057 mySqDist = RealLast();
0058
0059 double Uinf = TheTool::FirstParameter(theC1);
0060 double Usup = TheTool::LastParameter(theC1);
0061 double Uu;
0062 if (Uinf > Usup)
0063 {
0064 Uu = Uinf;
0065 Uinf = Usup;
0066 Usup = Uu;
0067 }
0068
0069 double Vinf = TheTool::FirstParameter(theC2);
0070 double Vsup = TheTool::LastParameter(theC2);
0071 if (Vinf > Vsup)
0072 {
0073 Uu = Vinf;
0074 Vinf = Vsup;
0075 Vsup = Uu;
0076 }
0077
0078 TheCCLocF F(theC1, theC2);
0079 math_Vector Tol(1, 2);
0080 Tol(1) = theTolU;
0081 Tol(2) = theTolV;
0082 double Tolf = 1.e-10;
0083
0084 math_Vector Start(1, 2);
0085 math_Vector Uuinf(1, 2);
0086 math_Vector Uusup(1, 2);
0087
0088 Start(1) = theU0;
0089 Start(2) = theV0;
0090
0091 Uuinf(1) = Uinf;
0092 Uuinf(2) = Vinf;
0093 Uusup(1) = Usup;
0094 Uusup(2) = Vsup;
0095
0096 math_FunctionSetRoot S(F, Tol);
0097 S.Perform(F, Start, Uuinf, Uusup);
0098
0099 if (S.IsDone() && F.NbExt() > 0)
0100 {
0101 mySqDist = F.SquareDistance(1);
0102 F.Points(1, myPoint1, myPoint2);
0103 Start(1) = myPoint1.Parameter();
0104 Start(2) = myPoint2.Parameter();
0105 math_Vector Ff(1, 2);
0106 F.Value(Start, Ff);
0107 if ((Ff(1) < Tolf) && (Ff(2) < Tolf))
0108 myDone = true;
0109 }
0110 }
0111
0112
0113 bool IsDone() const { return myDone; }
0114
0115
0116 double SquareDistance() const
0117 {
0118 if (!IsDone())
0119 {
0120 throw StdFail_NotDone();
0121 }
0122 return mySqDist;
0123 }
0124
0125
0126
0127
0128 void Point(ThePOnC& theP1, ThePOnC& theP2) const
0129 {
0130 if (!IsDone())
0131 {
0132 throw StdFail_NotDone();
0133 }
0134 theP1 = myPoint1;
0135 theP2 = myPoint2;
0136 }
0137
0138 private:
0139 bool myDone;
0140 double mySqDist;
0141 ThePOnC myPoint1;
0142 ThePOnC myPoint2;
0143 };
0144
0145 #endif