0023022: This is desirable to access OpenGl extensions and core API (1.2+) in one...
[occt.git] / src / Extrema / Extrema_GenLocateExtCS.cxx
1 // File:        Extrema_GenLocateExtCS.cxx
2 // Created:     Thu Jan 25 15:29:48 1996
3 // Author:      Laurent PAINNOT
4 //              <lpa@nonox>
5
6
7 #include <Extrema_GenLocateExtCS.ixx>
8
9 #include <Extrema_FuncExtCS.hxx>
10 #include <math_Vector.hxx>
11 #include <math_FunctionSetRoot.hxx>
12 #include <math_NewtonFunctionSetRoot.hxx>
13
14 //=======================================================================
15 //function : Extrema_GenLocateExtCS
16 //purpose  : 
17 //=======================================================================
18
19  Extrema_GenLocateExtCS::Extrema_GenLocateExtCS()
20 {
21 }
22
23 //=======================================================================
24 //function : Extrema_GenLocateExtCS
25 //purpose  : 
26 //=======================================================================
27
28  Extrema_GenLocateExtCS::Extrema_GenLocateExtCS(const Adaptor3d_Curve& C, 
29                                                 const Adaptor3d_Surface& S, 
30                                                 const Standard_Real T, 
31                                                 const Standard_Real U, 
32                                                 const Standard_Real V, 
33                                                 const Standard_Real Tol1, 
34                                                 const Standard_Real Tol2)
35 {
36   Perform(C,S,T,U,V,Tol1,Tol2);
37 }
38
39 //=======================================================================
40 //function : Perform
41 //purpose  : 
42 //=======================================================================
43
44 void Extrema_GenLocateExtCS::Perform(const Adaptor3d_Curve& C, 
45                                      const Adaptor3d_Surface& S, 
46                                      const Standard_Real T, 
47                                      const Standard_Real U, 
48                                      const Standard_Real V, 
49                                      const Standard_Real Tol1, 
50                                      const Standard_Real Tol2)
51 {
52   myDone = Standard_False;
53
54   Standard_Real Tinf, Tsup;
55   Tinf = C.FirstParameter();
56   Tsup = C.LastParameter();
57
58   Standard_Real Uinf, Usup, Vinf, Vsup;
59   Uinf = S.FirstUParameter();
60   Usup = S.LastUParameter();
61   Vinf = S.FirstVParameter();
62   Vsup = S.LastVParameter();
63
64   Extrema_FuncExtCS F (C,S);
65   math_Vector Tol(1, 3), Start(1, 3), BInf(1, 3), BSup(1, 3);
66   Tol(1) = Tol1;
67   Tol(2) = Tol2;
68   Tol(3) = Tol2;
69
70   Start(1) = T;
71   Start(2) = U;
72   Start(3) = V;
73
74   BInf(1) = Tinf;
75   BInf(2) = Uinf;
76   BInf(3) = Vinf;
77
78   BSup(1) = Tsup;
79   BSup(2) = Usup;
80   BSup(3) = Vsup;
81
82   math_FunctionSetRoot SR (F, Start,Tol, BInf, BSup);
83   if (!SR.IsDone()) 
84     return;
85
86   mySqDist = F.SquareDistance(1);
87   myPoint1 = F.PointOnCurve(1);
88   myPoint2 = F.PointOnSurface(1);
89   myDone = Standard_True;
90
91 }
92
93 //=======================================================================
94 //function : IsDone
95 //purpose  : 
96 //=======================================================================
97
98 Standard_Boolean Extrema_GenLocateExtCS::IsDone() const 
99 {
100   return myDone;
101 }
102
103 //=======================================================================
104 //function : Value
105 //purpose  : 
106 //=======================================================================
107
108 Standard_Real Extrema_GenLocateExtCS::SquareDistance() const 
109 {
110   if (!IsDone()) { StdFail_NotDone::Raise(); }
111   return mySqDist;
112 }
113
114 //=======================================================================
115 //function : PointOnCurve
116 //purpose  : 
117 //=======================================================================
118
119 const Extrema_POnCurv& Extrema_GenLocateExtCS::PointOnCurve() const 
120 {
121   if (!IsDone()) { StdFail_NotDone::Raise(); }
122   return myPoint1;
123 }
124
125 //=======================================================================
126 //function : PointOnSurface
127 //purpose  : 
128 //=======================================================================
129
130 const Extrema_POnSurf& Extrema_GenLocateExtCS::PointOnSurface() const 
131 {
132   if (!IsDone()) { StdFail_NotDone::Raise(); }
133   return myPoint2;
134 }
135