1 // Created on: 1992-01-20
2 // Created by: Remi GILET
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 #include <Geom2dAdaptor_Curve.hxx>
20 #include <Geom2dGcc_CurveTool.hxx>
21 #include <Geom2dGcc_FunctionTanCuCuOnCu.hxx>
22 #include <gp_Circ2d.hxx>
23 #include <gp_Lin2d.hxx>
24 #include <gp_Pnt2d.hxx>
25 #include <gp_Vec2d.hxx>
26 #include <math_Matrix.hxx>
27 #include <Standard_ConstructionError.hxx>
29 void Geom2dGcc_FunctionTanCuCuOnCu::
30 InitDerivative(const math_Vector& X,
41 case Geom2dGcc_CuCuOnCu:
43 Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21);
44 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
45 Geom2dGcc_CurveTool::D2(Curvon,X(3),Point3,Tan3,D23);
48 case Geom2dGcc_CiCuOnCu:
50 ElCLib::D2(X(1),Circ1,Point1,Tan1,D21);
51 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
52 Geom2dGcc_CurveTool::D2(Curvon,X(3),Point3,Tan3,D23);
55 case Geom2dGcc_LiCuOnCu:
57 ElCLib::D1(X(1),Lin1,Point1,Tan1);
58 D21 = gp_Vec2d(0.,0.);
59 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
60 Geom2dGcc_CurveTool::D2(Curvon,X(3),Point3,Tan3,D23);
63 case Geom2dGcc_CuPtOnCu:
65 Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21);
66 Geom2dGcc_CurveTool::D2(Curvon,X(3),Point3,Tan3,D23);
68 Tan2 = gp_Vec2d(0.,0.);
69 D22 = gp_Vec2d(0.,0.);
72 case Geom2dGcc_CuCuOnCi:
74 Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21);
75 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
76 ElCLib::D2(X(3),Circon,Point3,Tan3,D23);
79 case Geom2dGcc_CiCuOnCi:
81 ElCLib::D2(X(1),Circ1,Point1,Tan1,D21);
82 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
83 ElCLib::D2(X(3),Circon,Point3,Tan3,D23);
86 case Geom2dGcc_LiCuOnCi:
88 ElCLib::D1(X(1),Lin1,Point1,Tan1);
89 D21 = gp_Vec2d(0.,0.);
90 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
91 ElCLib::D2(X(3),Circon,Point3,Tan3,D23);
94 case Geom2dGcc_CuPtOnCi:
96 Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21);
98 Tan2 = gp_Vec2d(0.,0.);
99 D22 = gp_Vec2d(0.,0.);
100 ElCLib::D2(X(3),Circon,Point3,Tan3,D23);
103 case Geom2dGcc_CuCuOnLi:
105 Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21);
106 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
107 ElCLib::D1(X(3),Linon,Point3,Tan3);
108 D23 = gp_Vec2d(0.,0.);
111 case Geom2dGcc_CiCuOnLi:
113 ElCLib::D2(X(1),Circ1,Point1,Tan1,D21);
114 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
115 ElCLib::D1(X(3),Linon,Point3,Tan3);
116 D23 = gp_Vec2d(0.,0.);
119 case Geom2dGcc_LiCuOnLi:
121 ElCLib::D1(X(1),Lin1,Point1,Tan1);
122 Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22);
123 D21 = gp_Vec2d(0.,0.);
124 ElCLib::D1(X(3),Linon,Point3,Tan3);
125 D23 = gp_Vec2d(0.,0.);
128 case Geom2dGcc_CuPtOnLi:
130 Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21);
132 Tan2 = gp_Vec2d(0.,0.);
133 D22 = gp_Vec2d(0.,0.);
134 ElCLib::D1(X(3),Linon,Point3,Tan3);
135 D23 = gp_Vec2d(0.,0.);
140 throw Standard_ConstructionError();
145 Geom2dGcc_FunctionTanCuCuOnCu::
146 Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 ,
147 const Geom2dAdaptor_Curve& C2 ,
148 const Geom2dAdaptor_Curve& C3 ,
149 const Standard_Real Rad ) {
154 TheType = Geom2dGcc_CuCuOnCu;
157 Geom2dGcc_FunctionTanCuCuOnCu::
158 Geom2dGcc_FunctionTanCuCuOnCu(const gp_Circ2d& C1 ,
159 const Geom2dAdaptor_Curve& C2 ,
160 const Geom2dAdaptor_Curve& C3 ,
161 const Standard_Real Rad ) {
166 TheType = Geom2dGcc_CiCuOnCu;
169 Geom2dGcc_FunctionTanCuCuOnCu::
170 Geom2dGcc_FunctionTanCuCuOnCu(const gp_Lin2d& L1 ,
171 const Geom2dAdaptor_Curve& C2 ,
172 const Geom2dAdaptor_Curve& C3 ,
173 const Standard_Real Rad ) {
178 TheType = Geom2dGcc_LiCuOnCu;
181 Geom2dGcc_FunctionTanCuCuOnCu::
182 Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 ,
184 const Geom2dAdaptor_Curve& C3 ,
185 const Standard_Real Rad ) {
190 TheType = Geom2dGcc_CuPtOnCu;
193 Geom2dGcc_FunctionTanCuCuOnCu::
194 Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 ,
195 const Geom2dAdaptor_Curve& C2 ,
196 const gp_Lin2d& OnLi ,
197 const Standard_Real Rad ) {
202 TheType = Geom2dGcc_CuCuOnLi;
205 Geom2dGcc_FunctionTanCuCuOnCu::
206 Geom2dGcc_FunctionTanCuCuOnCu(const gp_Circ2d& C1 ,
207 const Geom2dAdaptor_Curve& C2 ,
208 const gp_Lin2d& OnLi ,
209 const Standard_Real Rad ) {
214 TheType = Geom2dGcc_CiCuOnLi;
217 Geom2dGcc_FunctionTanCuCuOnCu::
218 Geom2dGcc_FunctionTanCuCuOnCu(const gp_Lin2d& L1 ,
219 const Geom2dAdaptor_Curve& C2 ,
220 const gp_Lin2d& OnLi ,
221 const Standard_Real Rad ) {
226 TheType = Geom2dGcc_LiCuOnLi;
229 Geom2dGcc_FunctionTanCuCuOnCu::
230 Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 ,
232 const gp_Lin2d& OnLi ,
233 const Standard_Real Rad ) {
238 TheType = Geom2dGcc_CuPtOnLi;
241 Geom2dGcc_FunctionTanCuCuOnCu::
242 Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 ,
243 const Geom2dAdaptor_Curve& C2 ,
244 const gp_Circ2d& OnCi ,
245 const Standard_Real Rad ) {
250 TheType = Geom2dGcc_CuCuOnCi;
253 Geom2dGcc_FunctionTanCuCuOnCu::
254 Geom2dGcc_FunctionTanCuCuOnCu(const gp_Circ2d& C1 ,
255 const Geom2dAdaptor_Curve& C2 ,
256 const gp_Circ2d& OnCi ,
257 const Standard_Real Rad ) {
262 TheType = Geom2dGcc_CuCuOnCi;
265 Geom2dGcc_FunctionTanCuCuOnCu::
266 Geom2dGcc_FunctionTanCuCuOnCu(const gp_Lin2d& L1 ,
267 const Geom2dAdaptor_Curve& C2 ,
268 const gp_Circ2d& OnCi ,
269 const Standard_Real Rad ) {
274 TheType = Geom2dGcc_LiCuOnCi;
277 Geom2dGcc_FunctionTanCuCuOnCu::
278 Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 ,
280 const gp_Circ2d& OnCi ,
281 const Standard_Real Rad ) {
286 TheType = Geom2dGcc_CuPtOnCi;
289 Standard_Integer Geom2dGcc_FunctionTanCuCuOnCu::
290 NbVariables () const { return 4; }
292 Standard_Integer Geom2dGcc_FunctionTanCuCuOnCu::
293 NbEquations () const { return 4; }
295 Standard_Boolean Geom2dGcc_FunctionTanCuCuOnCu::
296 Value (const math_Vector& X ,
297 math_Vector& Fval ) {
298 gp_Pnt2d Point1,Point2,Point3;
299 gp_Vec2d Tan1,Tan2,Tan3,D21,D22,D23;
300 InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23);
301 //pipj (normes) et PiPj (non Normes).
302 gp_Vec2d P1P2(Point1,Point2);
303 gp_Vec2d P2P3(Point2,Point3);
304 gp_Vec2d P3P1(Point3,Point1);
305 gp_Vec2d p1p2,p2p3,p3p1;
306 // if (FirstRad < 1.) {FirstRad = 1.; }
307 p1p2 = P1P2/FirstRad;
308 p2p3 = P2P3/FirstRad;
309 p3p1 = P3P1/FirstRad;
311 Standard_Real nnor1 = Tan1.Magnitude();
312 Standard_Real nnor2 = Tan2.Magnitude();
315 Fval(1) = (P3P1.Dot(P3P1)-X(4)*X(4))/(FirstRad*FirstRad);
316 Fval(2) = (P2P3.Dot(P2P3)-X(4)*X(4))/(FirstRad*FirstRad);
317 Fval(3) = P3P1.Dot(Tan1)/(nnor1*FirstRad);
318 Fval(4) = P2P3.Dot(Tan2)/(nnor2*FirstRad);
319 return Standard_True;
322 Standard_Boolean Geom2dGcc_FunctionTanCuCuOnCu::
323 Derivatives (const math_Vector& X ,
324 math_Matrix& Deriv ) {
325 gp_Pnt2d Point1,Point2,Point3;
326 gp_Vec2d Tan1,Tan2,Tan3;
327 gp_Vec2d D21,D22,D23;
328 InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23);
329 //pipj (normes) et PiPj (non Normes).
330 gp_Vec2d P1P2(Point1,Point2);
331 gp_Vec2d P2P3(Point2,Point3);
332 gp_Vec2d P3P1(Point3,Point1);
333 gp_Vec2d p1p2,p2p3,p3p1;
334 // if (FirstRad < 1.) {FirstRad = 1.; }
335 p1p2 = P1P2/FirstRad;
336 p2p3 = P2P3/FirstRad;
337 p3p1 = P3P1/FirstRad;
338 //normales au courbes normees Nori et non nromees nori et norme des nori.
339 Standard_Real nnor1 = Tan1.Magnitude();
340 Standard_Real nnor2 = Tan2.Magnitude();
341 // Derivees dFui/uj 1 <= ui <= 3 , 1 <= uj <= 3
342 // =============================================
343 Deriv(1,1) = 2.*Tan1.Dot(P3P1)/(FirstRad*FirstRad);
345 Deriv(1,3) = -2.*Tan3.Dot(P3P1)/(FirstRad*FirstRad);
346 Deriv(1,4) = -2.*X(4)/(FirstRad*FirstRad);
349 Deriv(2,2) = -2.*Tan2.Dot(P2P3)/(FirstRad*FirstRad);
350 Deriv(2,3) = 2.*Tan3.Dot(P2P3)/(FirstRad*FirstRad);
351 Deriv(2,4) = -2.*X(4)/(FirstRad*FirstRad);
353 Deriv(3,1) = (P3P1.Dot(D21)+Tan1.Dot(Tan1))/(FirstRad*nnor1)-
354 (P3P1.Dot(Tan1)*D21.Dot(Tan1))/(FirstRad*nnor1*nnor1*nnor1);
356 Deriv(3,3) = -(Tan3.Dot(Tan1))/(FirstRad*nnor1);
360 Deriv(4,2) = (P2P3.Dot(D22)-Tan2.Dot(Tan2))/(FirstRad*nnor2)-
361 P2P3.Dot(Tan2)*Tan2.Dot(D22)/(FirstRad*nnor2*nnor2*nnor2);
362 Deriv(4,3) = Tan3.Dot(Tan2)/(FirstRad*nnor1);
364 return Standard_True;
367 Standard_Boolean Geom2dGcc_FunctionTanCuCuOnCu::
368 Values (const math_Vector& X ,
370 math_Matrix& Deriv ) {
371 gp_Pnt2d Point1,Point2,Point3;
372 gp_Vec2d Tan1,Tan2,Tan3;
373 gp_Vec2d D21,D22,D23;
374 InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23);
375 //pipj (normes) et PiPj (non Normes).
376 gp_Vec2d P1P2(Point1,Point2);
377 gp_Vec2d P2P3(Point2,Point3);
378 gp_Vec2d P3P1(Point3,Point1);
379 gp_Vec2d p1p2,p2p3,p3p1;
380 // if (FirstRad < 1.) {FirstRad = 1.; }
381 p1p2 = P1P2/FirstRad;
382 p2p3 = P2P3/FirstRad;
383 p3p1 = P3P1/FirstRad;
384 //normales au courbes normees Nori et non nromees nori et norme des nori.
385 Standard_Real nnor1 = Tan1.Magnitude();
386 Standard_Real nnor2 = Tan2.Magnitude();
389 Fval(1) = (P3P1.Dot(P3P1)-X(4)*X(4))/(FirstRad*FirstRad);
390 Fval(2) = (P2P3.Dot(P2P3)-X(4)*X(4))/(FirstRad*FirstRad);
391 Fval(3) = P3P1.Dot(Tan1)/(nnor1*FirstRad);
392 Fval(4) = P2P3.Dot(Tan2)/(nnor2*FirstRad);
393 // Derivees dFui/uj 1 <= ui <= 3 , 1 <= uj <= 3
394 // =============================================
395 Deriv(1,1) = 2.*Tan1.Dot(P3P1)/(FirstRad*FirstRad);
397 Deriv(1,3) = -2.*Tan3.Dot(P3P1)/(FirstRad*FirstRad);
398 Deriv(1,4) = -2.*X(4)/(FirstRad*FirstRad);
401 Deriv(2,2) = -2.*Tan2.Dot(P2P3)/(FirstRad*FirstRad);
402 Deriv(2,3) = 2.*Tan3.Dot(P2P3)/(FirstRad*FirstRad);
403 Deriv(2,4) = -2.*X(4)/(FirstRad*FirstRad);
405 Deriv(3,1) = (P3P1.Dot(D21)+Tan1.Dot(Tan1))/(FirstRad*nnor1)-
406 (P3P1.Dot(Tan1)*D21.Dot(Tan1))/(FirstRad*nnor1*nnor1*nnor1);
408 Deriv(3,3) = -(Tan3.Dot(Tan1))/(FirstRad*nnor1);
412 Deriv(4,2) = (P2P3.Dot(D22)-Tan2.Dot(Tan2))/(FirstRad*nnor2)-
413 P2P3.Dot(Tan2)*Tan2.Dot(D22)/(FirstRad*nnor2*nnor2*nnor2);
414 Deriv(4,3) = Tan3.Dot(Tan2)/(FirstRad*nnor1);
416 return Standard_True;