0024138: Exception during projection of the point on the face
[occt.git] / src / Extrema / Extrema_GenLocateExtSS.cxx
1 // Created on: 1995-07-18
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 #include <Extrema_GenLocateExtSS.ixx>
23
24 #include <Extrema_FuncExtSS.hxx>
25 #include <math_Vector.hxx>
26 #include <math_FunctionSetRoot.hxx>
27 #include <math_NewtonFunctionSetRoot.hxx>
28
29 //=======================================================================
30 //function : Extrema_GenLocateExtSS
31 //purpose  : 
32 //=======================================================================
33
34 Extrema_GenLocateExtSS::Extrema_GenLocateExtSS()
35 {
36 }
37
38 //=======================================================================
39 //function : Extrema_GenLocateExtSS
40 //purpose  : 
41 //=======================================================================
42
43  Extrema_GenLocateExtSS::Extrema_GenLocateExtSS(const Adaptor3d_Surface& S1, 
44                                                 const Adaptor3d_Surface& S2, 
45                                                 const Standard_Real U1, 
46                                                 const Standard_Real V1, 
47                                                 const Standard_Real U2, 
48                                                 const Standard_Real V2, 
49                                                 const Standard_Real Tol1, 
50                                                 const Standard_Real Tol2)
51 {
52   Perform(S1,S2,U1,V1,U2,V2,Tol1,Tol2);
53 }
54
55 //=======================================================================
56 //function : Perform
57 //purpose  : 
58 //=======================================================================
59
60 void Extrema_GenLocateExtSS::Perform(const Adaptor3d_Surface& S1, 
61                                      const Adaptor3d_Surface& S2, 
62                                      const Standard_Real U1, 
63                                      const Standard_Real V1, 
64                                      const Standard_Real U2, 
65                                      const Standard_Real V2, 
66                                      const Standard_Real Tol1, 
67                                      const Standard_Real Tol2)
68 {
69   myDone = Standard_False;
70
71   Standard_Real Uinf1, Usup1, Vinf1, Vsup1;
72   Uinf1 = S1.FirstUParameter();
73   Usup1 = S1.LastUParameter();
74   Vinf1 = S1.FirstVParameter();
75   Vsup1 = S1.LastVParameter();
76
77   Standard_Real Uinf2, Usup2, Vinf2, Vsup2;
78   Uinf2 = S2.FirstUParameter();
79   Usup2 = S2.LastUParameter();
80   Vinf2 = S2.FirstVParameter();
81   Vsup2 = S2.LastVParameter();
82
83   Extrema_FuncExtSS F (S1,S2);
84   math_Vector Tol(1, 4), Start(1, 4), BInf(1, 4), BSup(1, 4);
85
86   Tol(1) = Tol1;
87   Tol(2) = Tol1;
88   Tol(3) = Tol2;
89   Tol(4) = Tol2;
90
91   Start(1) = U1;
92   Start(2) = V1;
93   Start(3) = U2;
94   Start(4) = V2;
95
96   BInf(1) = Uinf1;
97   BInf(2) = Vinf1;
98   BInf(3) = Uinf2;
99   BInf(4) = Vinf2;
100   BSup(1) = Usup1;
101   BSup(2) = Vsup1;
102   BSup(3) = Usup2;
103   BSup(4) = Vsup2;
104
105   math_FunctionSetRoot SR (F, Start,Tol, BInf, BSup);
106   if (!SR.IsDone()) 
107     return;
108
109   mySqDist = F.SquareDistance(1);
110   myPoint1 = F.PointOnS1(1);
111   myPoint2 = F.PointOnS2(1);
112   myDone = Standard_True;
113
114 }
115
116 //=======================================================================
117 //function : IsDone
118 //purpose  : 
119 //=======================================================================
120
121 Standard_Boolean Extrema_GenLocateExtSS::IsDone() const 
122 {
123   return myDone;
124 }
125
126 //=======================================================================
127 //function : Value
128 //purpose  : 
129 //=======================================================================
130
131 Standard_Real Extrema_GenLocateExtSS::SquareDistance() const 
132 {
133   if (!IsDone()) { StdFail_NotDone::Raise(); }
134   return mySqDist;
135 }
136
137 //=======================================================================
138 //function : PointOnS1
139 //purpose  : 
140 //=======================================================================
141
142 const Extrema_POnSurf& Extrema_GenLocateExtSS::PointOnS1() const 
143 {
144   if (!IsDone()) { StdFail_NotDone::Raise(); }
145   return myPoint1;
146 }
147
148 //=======================================================================
149 //function : PointOnS2
150 //purpose  : 
151 //=======================================================================
152
153 const Extrema_POnSurf& Extrema_GenLocateExtSS::PointOnS2() const 
154 {
155   if (!IsDone()) { StdFail_NotDone::Raise(); }
156   return myPoint2;
157 }
158