0024023: Revamp the OCCT Handle -- ambiguity
[occt.git] / src / Geom2dGcc / Geom2dGcc_FunctionTanCuCuOnCu.cxx
CommitLineData
b311480e 1// Created on: 1992-01-20
2// Created by: Remi GILET
3// Copyright (c) 1992-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
54e37688 17#include <Geom2dGcc_FunctionTanCuCuOnCu.ixx>
18
7fd59977 19#include <Standard_ConstructionError.hxx>
20#include <ElCLib.hxx>
21
54e37688 22#include <Geom2dGcc_CurveTool.hxx>
23
24void Geom2dGcc_FunctionTanCuCuOnCu::
7fd59977 25 InitDerivative(const math_Vector& X,
26 gp_Pnt2d& Point1,
27 gp_Pnt2d& Point2,
28 gp_Pnt2d& Point3,
29 gp_Vec2d& Tan1,
30 gp_Vec2d& Tan2,
31 gp_Vec2d& Tan3,
32 gp_Vec2d& D21,
33 gp_Vec2d& D22,
34 gp_Vec2d& D23) {
35 switch (TheType) {
54e37688 36 case Geom2dGcc_CuCuOnCu:
7fd59977 37 {
54e37688 38 Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21);
39 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
40 Geom2dGcc_CurveTool::D2(Curvon,X(3),Point3,Tan3,D23);
7fd59977 41 }
42 break;
54e37688 43 case Geom2dGcc_CiCuOnCu:
7fd59977 44 {
45 ElCLib::D2(X(1),Circ1,Point1,Tan1,D21);
54e37688 46 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
47 Geom2dGcc_CurveTool::D2(Curvon,X(3),Point3,Tan3,D23);
7fd59977 48 }
49 break;
54e37688 50 case Geom2dGcc_LiCuOnCu:
7fd59977 51 {
52 ElCLib::D1(X(1),Lin1,Point1,Tan1);
53 D21 = gp_Vec2d(0.,0.);
54e37688 54 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
55 Geom2dGcc_CurveTool::D2(Curvon,X(3),Point3,Tan3,D23);
7fd59977 56 }
57 break;
54e37688 58 case Geom2dGcc_CuPtOnCu:
7fd59977 59 {
54e37688 60 Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21);
61 Geom2dGcc_CurveTool::D2(Curvon,X(3),Point3,Tan3,D23);
7fd59977 62 Point2 = Pnt2;
63 Tan2 = gp_Vec2d(0.,0.);
64 D22 = gp_Vec2d(0.,0.);
65 }
66 break;
54e37688 67 case Geom2dGcc_CuCuOnCi:
7fd59977 68 {
54e37688 69 Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21);
70 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
7fd59977 71 ElCLib::D2(X(3),Circon,Point3,Tan3,D23);
72 }
73 break;
54e37688 74 case Geom2dGcc_CiCuOnCi:
7fd59977 75 {
76 ElCLib::D2(X(1),Circ1,Point1,Tan1,D21);
54e37688 77 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
7fd59977 78 ElCLib::D2(X(3),Circon,Point3,Tan3,D23);
79 }
80 break;
54e37688 81 case Geom2dGcc_LiCuOnCi:
7fd59977 82 {
83 ElCLib::D1(X(1),Lin1,Point1,Tan1);
84 D21 = gp_Vec2d(0.,0.);
54e37688 85 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
7fd59977 86 ElCLib::D2(X(3),Circon,Point3,Tan3,D23);
87 }
88 break;
54e37688 89 case Geom2dGcc_CuPtOnCi:
7fd59977 90 {
54e37688 91 Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21);
7fd59977 92 Point2 = Pnt2;
93 Tan2 = gp_Vec2d(0.,0.);
94 D22 = gp_Vec2d(0.,0.);
95 ElCLib::D2(X(3),Circon,Point3,Tan3,D23);
96 }
97 break;
54e37688 98 case Geom2dGcc_CuCuOnLi:
7fd59977 99 {
54e37688 100 Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21);
101 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
7fd59977 102 ElCLib::D1(X(3),Linon,Point3,Tan3);
103 D23 = gp_Vec2d(0.,0.);
104 }
105 break;
54e37688 106 case Geom2dGcc_CiCuOnLi:
7fd59977 107 {
108 ElCLib::D2(X(1),Circ1,Point1,Tan1,D21);
54e37688 109 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
7fd59977 110 ElCLib::D1(X(3),Linon,Point3,Tan3);
111 D23 = gp_Vec2d(0.,0.);
112 }
113 break;
54e37688 114 case Geom2dGcc_LiCuOnLi:
7fd59977 115 {
116 ElCLib::D1(X(1),Lin1,Point1,Tan1);
54e37688 117 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
7fd59977 118 D21 = gp_Vec2d(0.,0.);
119 ElCLib::D1(X(3),Linon,Point3,Tan3);
120 D23 = gp_Vec2d(0.,0.);
121 }
122 break;
54e37688 123 case Geom2dGcc_CuPtOnLi:
7fd59977 124 {
54e37688 125 Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21);
7fd59977 126 Point2 = Pnt2;
127 Tan2 = gp_Vec2d(0.,0.);
128 D22 = gp_Vec2d(0.,0.);
129 ElCLib::D1(X(3),Linon,Point3,Tan3);
130 D23 = gp_Vec2d(0.,0.);
131 }
132 break;
133 default:
134 {
135 Standard_ConstructionError::Raise();
136 }
137 }
138}
139
54e37688 140Geom2dGcc_FunctionTanCuCuOnCu::
141 Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 ,
142 const Geom2dAdaptor_Curve& C2 ,
143 const Geom2dAdaptor_Curve& C3 ,
7fd59977 144 const Standard_Real Rad ) {
145 Curv1 = C1;
146 Curv2 = C2;
147 Curvon = C3;
148 FirstRad = Rad;
54e37688 149 TheType = Geom2dGcc_CuCuOnCu;
7fd59977 150}
151
54e37688 152Geom2dGcc_FunctionTanCuCuOnCu::
153 Geom2dGcc_FunctionTanCuCuOnCu(const gp_Circ2d& C1 ,
154 const Geom2dAdaptor_Curve& C2 ,
155 const Geom2dAdaptor_Curve& C3 ,
7fd59977 156 const Standard_Real Rad ) {
157 Circ1 = C1;
158 Curv2 = C2;
159 Curvon = C3;
160 FirstRad = Rad;
54e37688 161 TheType = Geom2dGcc_CiCuOnCu;
7fd59977 162}
163
54e37688 164Geom2dGcc_FunctionTanCuCuOnCu::
165 Geom2dGcc_FunctionTanCuCuOnCu(const gp_Lin2d& L1 ,
166 const Geom2dAdaptor_Curve& C2 ,
167 const Geom2dAdaptor_Curve& C3 ,
7fd59977 168 const Standard_Real Rad ) {
169 Lin1 = L1;
170 Curv2 = C2;
171 Curvon = C3;
172 FirstRad = Rad;
54e37688 173 TheType = Geom2dGcc_LiCuOnCu;
7fd59977 174}
175
54e37688 176Geom2dGcc_FunctionTanCuCuOnCu::
177 Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 ,
7fd59977 178 const gp_Pnt2d& P2 ,
54e37688 179 const Geom2dAdaptor_Curve& C3 ,
7fd59977 180 const Standard_Real Rad ) {
181 Curv1 = C1;
182 Pnt2 = P2;
183 Curvon = C3;
184 FirstRad = Rad;
54e37688 185 TheType = Geom2dGcc_CuPtOnCu;
7fd59977 186}
187
54e37688 188Geom2dGcc_FunctionTanCuCuOnCu::
189 Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 ,
190 const Geom2dAdaptor_Curve& C2 ,
7fd59977 191 const gp_Lin2d& OnLi ,
192 const Standard_Real Rad ) {
193 Curv1 = C1;
194 Curv2 = C2;
195 Linon = OnLi;
196 FirstRad = Rad;
54e37688 197 TheType = Geom2dGcc_CuCuOnLi;
7fd59977 198}
199
54e37688 200Geom2dGcc_FunctionTanCuCuOnCu::
201 Geom2dGcc_FunctionTanCuCuOnCu(const gp_Circ2d& C1 ,
202 const Geom2dAdaptor_Curve& C2 ,
7fd59977 203 const gp_Lin2d& OnLi ,
204 const Standard_Real Rad ) {
205 Circ1 = C1;
206 Curv2 = C2;
207 Linon = OnLi;
208 FirstRad = Rad;
54e37688 209 TheType = Geom2dGcc_CiCuOnLi;
7fd59977 210}
211
54e37688 212Geom2dGcc_FunctionTanCuCuOnCu::
213 Geom2dGcc_FunctionTanCuCuOnCu(const gp_Lin2d& L1 ,
214 const Geom2dAdaptor_Curve& C2 ,
7fd59977 215 const gp_Lin2d& OnLi ,
216 const Standard_Real Rad ) {
217 Lin1 = L1;
218 Curv2 = C2;
219 Linon = OnLi;
220 FirstRad = Rad;
54e37688 221 TheType = Geom2dGcc_LiCuOnLi;
7fd59977 222}
223
54e37688 224Geom2dGcc_FunctionTanCuCuOnCu::
225 Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 ,
7fd59977 226 const gp_Pnt2d& P2 ,
227 const gp_Lin2d& OnLi ,
228 const Standard_Real Rad ) {
229 Curv1 = C1;
230 Pnt2 = P2;
231 Linon = OnLi;
232 FirstRad = Rad;
54e37688 233 TheType = Geom2dGcc_CuPtOnLi;
7fd59977 234}
235
54e37688 236Geom2dGcc_FunctionTanCuCuOnCu::
237 Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 ,
238 const Geom2dAdaptor_Curve& C2 ,
7fd59977 239 const gp_Circ2d& OnCi ,
240 const Standard_Real Rad ) {
241 Curv1 = C1;
242 Curv2 = C2;
243 Circon = OnCi;
244 FirstRad = Rad;
54e37688 245 TheType = Geom2dGcc_CuCuOnCi;
7fd59977 246}
247
54e37688 248Geom2dGcc_FunctionTanCuCuOnCu::
249 Geom2dGcc_FunctionTanCuCuOnCu(const gp_Circ2d& C1 ,
250 const Geom2dAdaptor_Curve& C2 ,
7fd59977 251 const gp_Circ2d& OnCi ,
252 const Standard_Real Rad ) {
253 Circ1 = C1;
254 Curv2 = C2;
255 Circon = OnCi;
256 FirstRad = Rad;
54e37688 257 TheType = Geom2dGcc_CuCuOnCi;
7fd59977 258}
259
54e37688 260Geom2dGcc_FunctionTanCuCuOnCu::
261 Geom2dGcc_FunctionTanCuCuOnCu(const gp_Lin2d& L1 ,
262 const Geom2dAdaptor_Curve& C2 ,
7fd59977 263 const gp_Circ2d& OnCi ,
264 const Standard_Real Rad ) {
265 Lin1 = L1;
266 Curv2 = C2;
267 Circon = OnCi;
268 FirstRad = Rad;
54e37688 269 TheType = Geom2dGcc_LiCuOnCi;
7fd59977 270}
271
54e37688 272Geom2dGcc_FunctionTanCuCuOnCu::
273 Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 ,
7fd59977 274 const gp_Pnt2d& P2 ,
275 const gp_Circ2d& OnCi ,
276 const Standard_Real Rad ) {
277 Curv1 = C1;
278 Pnt2 = P2;
279 Circon = OnCi;
280 FirstRad = Rad;
54e37688 281 TheType = Geom2dGcc_CuPtOnCi;
7fd59977 282}
283
54e37688 284Standard_Integer Geom2dGcc_FunctionTanCuCuOnCu::
7fd59977 285 NbVariables () const { return 4; }
286
54e37688 287Standard_Integer Geom2dGcc_FunctionTanCuCuOnCu::
7fd59977 288 NbEquations () const { return 4; }
289
54e37688 290Standard_Boolean Geom2dGcc_FunctionTanCuCuOnCu::
7fd59977 291 Value (const math_Vector& X ,
292 math_Vector& Fval ) {
293 gp_Pnt2d Point1,Point2,Point3;
294 gp_Vec2d Tan1,Tan2,Tan3,D21,D22,D23;
295 InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23);
296//pipj (normes) et PiPj (non Normes).
297 gp_Vec2d P1P2(Point1,Point2);
298 gp_Vec2d P2P3(Point2,Point3);
299 gp_Vec2d P3P1(Point3,Point1);
300 gp_Vec2d p1p2,p2p3,p3p1;
301// if (FirstRad < 1.) {FirstRad = 1.; }
302 p1p2 = P1P2/FirstRad;
303 p2p3 = P2P3/FirstRad;
304 p3p1 = P3P1/FirstRad;
305//norme des Tani.
306 Standard_Real nnor1 = Tan1.Magnitude();
307 Standard_Real nnor2 = Tan2.Magnitude();
7fd59977 308// Fonctions Fui.
309// ==============
310 Fval(1) = (P3P1.Dot(P3P1)-X(4)*X(4))/(FirstRad*FirstRad);
311 Fval(2) = (P2P3.Dot(P2P3)-X(4)*X(4))/(FirstRad*FirstRad);
312 Fval(3) = P3P1.Dot(Tan1)/(nnor1*FirstRad);
313 Fval(4) = P2P3.Dot(Tan2)/(nnor2*FirstRad);
314 return Standard_True;
315}
316
54e37688 317Standard_Boolean Geom2dGcc_FunctionTanCuCuOnCu::
7fd59977 318 Derivatives (const math_Vector& X ,
319 math_Matrix& Deriv ) {
320 gp_Pnt2d Point1,Point2,Point3;
321 gp_Vec2d Tan1,Tan2,Tan3;
322 gp_Vec2d D21,D22,D23;
323 InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23);
324//pipj (normes) et PiPj (non Normes).
325 gp_Vec2d P1P2(Point1,Point2);
326 gp_Vec2d P2P3(Point2,Point3);
327 gp_Vec2d P3P1(Point3,Point1);
328 gp_Vec2d p1p2,p2p3,p3p1;
329// if (FirstRad < 1.) {FirstRad = 1.; }
330 p1p2 = P1P2/FirstRad;
331 p2p3 = P2P3/FirstRad;
332 p3p1 = P3P1/FirstRad;
333//normales au courbes normees Nori et non nromees nori et norme des nori.
334 Standard_Real nnor1 = Tan1.Magnitude();
335 Standard_Real nnor2 = Tan2.Magnitude();
7fd59977 336// Derivees dFui/uj 1 <= ui <= 3 , 1 <= uj <= 3
337// =============================================
338 Deriv(1,1) = 2.*Tan1.Dot(P3P1)/(FirstRad*FirstRad);
339 Deriv(1,2) = 0.;
340 Deriv(1,3) = -2.*Tan3.Dot(P3P1)/(FirstRad*FirstRad);
341 Deriv(1,4) = -2.*X(4)/(FirstRad*FirstRad);
342
343 Deriv(2,1) = 0.;
344 Deriv(2,2) = -2.*Tan2.Dot(P2P3)/(FirstRad*FirstRad);
345 Deriv(2,3) = 2.*Tan3.Dot(P2P3)/(FirstRad*FirstRad);
346 Deriv(2,4) = -2.*X(4)/(FirstRad*FirstRad);
347
348 Deriv(3,1) = (P3P1.Dot(D21)+Tan1.Dot(Tan1))/(FirstRad*nnor1)-
349 (P3P1.Dot(Tan1)*D21.Dot(Tan1))/(FirstRad*nnor1*nnor1*nnor1);
350 Deriv(3,2) = 0.;
351 Deriv(3,3) = -(Tan3.Dot(Tan1))/(FirstRad*nnor1);
352 Deriv(3,4) = 0.;
353
354 Deriv(4,1) = 0.;
355 Deriv(4,2) = (P2P3.Dot(D22)-Tan2.Dot(Tan2))/(FirstRad*nnor2)-
356 P2P3.Dot(Tan2)*Tan2.Dot(D22)/(FirstRad*nnor2*nnor2*nnor2);
357 Deriv(4,3) = Tan3.Dot(Tan2)/(FirstRad*nnor1);
358 Deriv(4,4) = 0.;
359 return Standard_True;
360}
361
54e37688 362Standard_Boolean Geom2dGcc_FunctionTanCuCuOnCu::
7fd59977 363 Values (const math_Vector& X ,
364 math_Vector& Fval ,
365 math_Matrix& Deriv ) {
366 gp_Pnt2d Point1,Point2,Point3;
367 gp_Vec2d Tan1,Tan2,Tan3;
368 gp_Vec2d D21,D22,D23;
369 InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23);
370//pipj (normes) et PiPj (non Normes).
371 gp_Vec2d P1P2(Point1,Point2);
372 gp_Vec2d P2P3(Point2,Point3);
373 gp_Vec2d P3P1(Point3,Point1);
374 gp_Vec2d p1p2,p2p3,p3p1;
375// if (FirstRad < 1.) {FirstRad = 1.; }
376 p1p2 = P1P2/FirstRad;
377 p2p3 = P2P3/FirstRad;
378 p3p1 = P3P1/FirstRad;
379//normales au courbes normees Nori et non nromees nori et norme des nori.
380 Standard_Real nnor1 = Tan1.Magnitude();
381 Standard_Real nnor2 = Tan2.Magnitude();
7fd59977 382// Fonctions Fui.
383// ==============
384 Fval(1) = (P3P1.Dot(P3P1)-X(4)*X(4))/(FirstRad*FirstRad);
385 Fval(2) = (P2P3.Dot(P2P3)-X(4)*X(4))/(FirstRad*FirstRad);
386 Fval(3) = P3P1.Dot(Tan1)/(nnor1*FirstRad);
387 Fval(4) = P2P3.Dot(Tan2)/(nnor2*FirstRad);
388// Derivees dFui/uj 1 <= ui <= 3 , 1 <= uj <= 3
389// =============================================
390 Deriv(1,1) = 2.*Tan1.Dot(P3P1)/(FirstRad*FirstRad);
391 Deriv(1,2) = 0.;
392 Deriv(1,3) = -2.*Tan3.Dot(P3P1)/(FirstRad*FirstRad);
393 Deriv(1,4) = -2.*X(4)/(FirstRad*FirstRad);
394
395 Deriv(2,1) = 0.;
396 Deriv(2,2) = -2.*Tan2.Dot(P2P3)/(FirstRad*FirstRad);
397 Deriv(2,3) = 2.*Tan3.Dot(P2P3)/(FirstRad*FirstRad);
398 Deriv(2,4) = -2.*X(4)/(FirstRad*FirstRad);
399
400 Deriv(3,1) = (P3P1.Dot(D21)+Tan1.Dot(Tan1))/(FirstRad*nnor1)-
401 (P3P1.Dot(Tan1)*D21.Dot(Tan1))/(FirstRad*nnor1*nnor1*nnor1);
402 Deriv(3,2) = 0.;
403 Deriv(3,3) = -(Tan3.Dot(Tan1))/(FirstRad*nnor1);
404 Deriv(3,4) = 0.;
405
406 Deriv(4,1) = 0.;
407 Deriv(4,2) = (P2P3.Dot(D22)-Tan2.Dot(Tan2))/(FirstRad*nnor2)-
408 P2P3.Dot(Tan2)*Tan2.Dot(D22)/(FirstRad*nnor2*nnor2*nnor2);
409 Deriv(4,3) = Tan3.Dot(Tan2)/(FirstRad*nnor1);
410 Deriv(4,4) = 0.;
411 return Standard_True;
412}
413