b311480e |
1 | // Created on: 1995-07-18 |
2 | // Created by: Modelistation |
3 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <Adaptor3d_Surface.hxx> |
7fd59977 |
19 | #include <Extrema_FuncExtSS.hxx> |
42cf5bc1 |
20 | #include <Extrema_GenLocateExtSS.hxx> |
21 | #include <Extrema_POnSurf.hxx> |
7fd59977 |
22 | #include <math_FunctionSetRoot.hxx> |
23 | #include <math_NewtonFunctionSetRoot.hxx> |
42cf5bc1 |
24 | #include <math_Vector.hxx> |
25 | #include <Standard_DomainError.hxx> |
26 | #include <StdFail_NotDone.hxx> |
7fd59977 |
27 | |
28 | //======================================================================= |
29 | //function : Extrema_GenLocateExtSS |
30 | //purpose : |
31 | //======================================================================= |
b311480e |
32 | Extrema_GenLocateExtSS::Extrema_GenLocateExtSS() |
7fd59977 |
33 | { |
34 | } |
35 | |
36 | //======================================================================= |
37 | //function : Extrema_GenLocateExtSS |
38 | //purpose : |
39 | //======================================================================= |
40 | |
41 | Extrema_GenLocateExtSS::Extrema_GenLocateExtSS(const Adaptor3d_Surface& S1, |
42 | const Adaptor3d_Surface& S2, |
43 | const Standard_Real U1, |
44 | const Standard_Real V1, |
45 | const Standard_Real U2, |
46 | const Standard_Real V2, |
47 | const Standard_Real Tol1, |
48 | const Standard_Real Tol2) |
49 | { |
50 | Perform(S1,S2,U1,V1,U2,V2,Tol1,Tol2); |
51 | } |
52 | |
53 | //======================================================================= |
54 | //function : Perform |
55 | //purpose : |
56 | //======================================================================= |
57 | |
58 | void Extrema_GenLocateExtSS::Perform(const Adaptor3d_Surface& S1, |
59 | const Adaptor3d_Surface& S2, |
60 | const Standard_Real U1, |
61 | const Standard_Real V1, |
62 | const Standard_Real U2, |
63 | const Standard_Real V2, |
64 | const Standard_Real Tol1, |
65 | const Standard_Real Tol2) |
66 | { |
67 | myDone = Standard_False; |
68 | |
69 | Standard_Real Uinf1, Usup1, Vinf1, Vsup1; |
70 | Uinf1 = S1.FirstUParameter(); |
71 | Usup1 = S1.LastUParameter(); |
72 | Vinf1 = S1.FirstVParameter(); |
73 | Vsup1 = S1.LastVParameter(); |
74 | |
75 | Standard_Real Uinf2, Usup2, Vinf2, Vsup2; |
76 | Uinf2 = S2.FirstUParameter(); |
77 | Usup2 = S2.LastUParameter(); |
78 | Vinf2 = S2.FirstVParameter(); |
79 | Vsup2 = S2.LastVParameter(); |
80 | |
81 | Extrema_FuncExtSS F (S1,S2); |
82 | math_Vector Tol(1, 4), Start(1, 4), BInf(1, 4), BSup(1, 4); |
83 | |
84 | Tol(1) = Tol1; |
85 | Tol(2) = Tol1; |
86 | Tol(3) = Tol2; |
87 | Tol(4) = Tol2; |
88 | |
89 | Start(1) = U1; |
90 | Start(2) = V1; |
91 | Start(3) = U2; |
92 | Start(4) = V2; |
93 | |
94 | BInf(1) = Uinf1; |
95 | BInf(2) = Vinf1; |
96 | BInf(3) = Uinf2; |
97 | BInf(4) = Vinf2; |
98 | BSup(1) = Usup1; |
99 | BSup(2) = Vsup1; |
100 | BSup(3) = Usup2; |
101 | BSup(4) = Vsup2; |
102 | |
859a47c3 |
103 | math_FunctionSetRoot SR (F, Tol); |
104 | SR.Perform(F, Start, BInf, BSup); |
7fd59977 |
105 | if (!SR.IsDone()) |
106 | return; |
107 | |
108 | mySqDist = F.SquareDistance(1); |
109 | myPoint1 = F.PointOnS1(1); |
110 | myPoint2 = F.PointOnS2(1); |
111 | myDone = Standard_True; |
112 | |
113 | } |
114 | |
115 | //======================================================================= |
116 | //function : IsDone |
117 | //purpose : |
118 | //======================================================================= |
119 | |
120 | Standard_Boolean Extrema_GenLocateExtSS::IsDone() const |
121 | { |
122 | return myDone; |
123 | } |
124 | |
125 | //======================================================================= |
126 | //function : Value |
127 | //purpose : |
128 | //======================================================================= |
129 | |
130 | Standard_Real Extrema_GenLocateExtSS::SquareDistance() const |
131 | { |
9775fa61 |
132 | if (!IsDone()) { throw StdFail_NotDone(); } |
7fd59977 |
133 | return mySqDist; |
134 | } |
135 | |
136 | //======================================================================= |
137 | //function : PointOnS1 |
138 | //purpose : |
139 | //======================================================================= |
140 | |
141 | const Extrema_POnSurf& Extrema_GenLocateExtSS::PointOnS1() const |
142 | { |
9775fa61 |
143 | if (!IsDone()) { throw StdFail_NotDone(); } |
7fd59977 |
144 | return myPoint1; |
145 | } |
146 | |
147 | //======================================================================= |
148 | //function : PointOnS2 |
149 | //purpose : |
150 | //======================================================================= |
151 | |
152 | const Extrema_POnSurf& Extrema_GenLocateExtSS::PointOnS2() const |
153 | { |
9775fa61 |
154 | if (!IsDone()) { throw StdFail_NotDone(); } |
7fd59977 |
155 | return myPoint2; |
156 | } |
157 | |