0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / BlendFunc / BlendFunc_ChAsym.cxx
CommitLineData
b311480e 1// Created on: 1998-06-02
2// Created by: Philippe NOUAILLE
3// Copyright (c) 1998-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_HCurve.hxx>
19#include <Adaptor3d_HSurface.hxx>
20#include <Blend_Point.hxx>
7fd59977 21#include <BlendFunc.hxx>
42cf5bc1 22#include <BlendFunc_ChAsym.hxx>
7fd59977 23#include <ElCLib.hxx>
42cf5bc1 24#include <gp_Lin.hxx>
25#include <gp_Pnt.hxx>
26#include <gp_Vec.hxx>
27#include <gp_Vec2d.hxx>
28#include <math_Gauss.hxx>
29#include <math_Matrix.hxx>
30#include <math_SVD.hxx>
7fd59977 31#include <Precision.hxx>
32#include <Standard_NotImplemented.hxx>
33
34//=======================================================================
35//function : BlendFunc_ChAsym
36//purpose :
37//=======================================================================
7fd59977 38BlendFunc_ChAsym::BlendFunc_ChAsym(const Handle(Adaptor3d_HSurface)& S1,
39 const Handle(Adaptor3d_HSurface)& S2,
40 const Handle(Adaptor3d_HCurve)& C) :
41 surf1(S1),surf2(S2),
42 curv(C), tcurv(C),
43 FX(1, 4),
44 DX(1, 4, 1, 4),
45 istangent(Standard_True),
46 distmin(RealLast())
47{
48}
49
50
51//=======================================================================
52//function : NbEquations
53//purpose :
54//=======================================================================
55
56Standard_Integer BlendFunc_ChAsym::NbEquations () const
57{
58 return 4;
59}
60
61
62
63//=======================================================================
64//function : Set
65//purpose :
66//=======================================================================
67
68void BlendFunc_ChAsym::Set(const Standard_Real Param)
69{
70 param = Param;
71}
72
73//=======================================================================
74//function : Set
75//purpose : Segmente la courbe a sa partie utile.
76// La precision est prise arbitrairement petite !?
77//=======================================================================
78
79void BlendFunc_ChAsym::Set(const Standard_Real First, const Standard_Real Last)
80{
81 tcurv = curv->Trim(First, Last, 1.e-12);
82}
83
84//=======================================================================
85//function : GetTolerance
86//purpose :
87//=======================================================================
88
89void BlendFunc_ChAsym::GetTolerance(math_Vector& Tolerance, const Standard_Real Tol) const
90{
91 Tolerance(1) = surf1->UResolution(Tol);
92 Tolerance(2) = surf1->VResolution(Tol);
93 Tolerance(3) = surf2->UResolution(Tol);
94 Tolerance(4) = surf2->VResolution(Tol);
95}
96
97
98//=======================================================================
99//function : GetBounds
100//purpose :
101//=======================================================================
102
103void BlendFunc_ChAsym::GetBounds(math_Vector& InfBound, math_Vector& SupBound) const
104{
105 InfBound(1) = surf1->FirstUParameter();
106 InfBound(2) = surf1->FirstVParameter();
107 InfBound(3) = surf2->FirstUParameter();
108 InfBound(4) = surf2->FirstVParameter();
109 SupBound(1) = surf1->LastUParameter();
110 SupBound(2) = surf1->LastVParameter();
111 SupBound(3) = surf2->LastUParameter();
112 SupBound(4) = surf2->LastVParameter();
113
114 for(Standard_Integer i = 1; i <= 4; i++){
115 if(!Precision::IsInfinite(InfBound(i)) &&
116 !Precision::IsInfinite(SupBound(i))) {
117 const Standard_Real range = (SupBound(i) - InfBound(i));
118 InfBound(i) -= range;
119 SupBound(i) += range;
120 }
121 }
122}
123
124
125//=======================================================================
126//function : IsSolution
127//purpose :
128//=======================================================================
129
130Standard_Boolean BlendFunc_ChAsym::IsSolution(const math_Vector& Sol, const Standard_Real Tol)
131{
132 math_Vector valsol(1, 4), secmember(1, 4);
133 math_Matrix gradsol(1, 4, 1, 4);
134
135 gp_Pnt ptgui;
136 gp_Vec np, dnp, d1gui, d2gui, Nsurf1, dwtsurf1;
137 gp_Vec d1u1, d1v1, d1u2, d1v2;
138 Standard_Real Normg;
139
140 tcurv->D2(param, ptgui, d1gui, d2gui);
141 Normg = d1gui.Magnitude();
142 np = d1gui.Normalized();
143 dnp = (d2gui - np.Dot(d2gui) * np) / Normg;
144
145 if (choix%2 != 0) {
146 np.Reverse();
147 dnp.Reverse();
148 Normg = -Normg;
149 }
150
151 surf1->D1(Sol(1), Sol(2), pt1, d1u1, d1v1);
152 Nsurf1 = d1u1.Crossed(d1v1);
153 tsurf1 = Nsurf1.Crossed(np);
154 dwtsurf1 = Nsurf1.Crossed(dnp);
155
156 surf2->D1(Sol(3), Sol(4), pt2, d1u2, d1v2);
157
158 gp_Vec pguis1(ptgui, pt1), pguis2(ptgui, pt2);
159 gp_Vec CrossVec, s1s2(pt1, pt2);
160 Standard_Real PScaInv = 1. / tsurf1.Dot(s1s2), F4, temp;
161 Standard_Real maxpiv = 1.e-9;
162 Standard_Real Nordu1 = d1u1.Magnitude(),
163 Nordv1 = d1v1.Magnitude();
164
165 temp = 2. * (Nordu1 + Nordv1) * s1s2.Magnitude() + 2. * Nordu1 * Nordv1;
166
167 Values(Sol, valsol, gradsol);
168
169 if (Abs(valsol(1)) < Tol &&
170 Abs(valsol(2)) < Tol &&
171 Abs(valsol(3)) < 2. * dist1 * Tol &&
172 Abs(valsol(4)) < Tol * (1. + tgang) * Abs(PScaInv) * temp) {
173
174 secmember(1) = Normg - dnp.Dot(pguis1);
175 secmember(2) = Normg - dnp.Dot(pguis2);
176 secmember(3) = - 2. * d1gui.Dot(pguis1);
177
178 CrossVec = tsurf1.Crossed(s1s2);
179 F4 = np.Dot(CrossVec) * PScaInv;
180 temp = dnp.Dot(CrossVec) + np.Dot(dwtsurf1.Crossed(s1s2));
181
182 temp -= F4 * dwtsurf1.Dot(s1s2);
183 secmember(4) = PScaInv * temp;
184
185 math_Gauss Resol(gradsol, maxpiv);
186
187 if (Resol.IsDone()) {
188 Resol.Solve(secmember);
189 istangent = Standard_False;
190 }
191 else {
192 math_SVD SingRS (gradsol);
193 if (SingRS.IsDone()) {
194 math_Vector DEDT(1,4);
195 DEDT = secmember;
196 SingRS.Solve(DEDT, secmember, 1.e-6);
197 istangent = Standard_False;
198 }
199 else istangent = Standard_True;
200 }
201
202 if (!istangent) {
203 tg1.SetLinearForm(secmember(1), d1u1, secmember(2), d1v1);
204 tg2.SetLinearForm(secmember(3), d1u2, secmember(4), d1v2);
205 tg12d.SetCoord(secmember(1),secmember(2));
206 tg22d.SetCoord(secmember(3),secmember(4));
207 }
208
209 distmin = Min( distmin, pt1.Distance(pt2));
210
211 return Standard_True;
212 }
213
214 istangent = Standard_True;
215 return Standard_False;
216}
217
218
219//=======================================================================
220//function : GetMinimalDistance
221//purpose :
222//=======================================================================
223
224Standard_Real BlendFunc_ChAsym::GetMinimalDistance() const
225{
226 return distmin;
227}
228
229//=======================================================================
230//function : ComputeValues
231//purpose :
232//=======================================================================
233Standard_Boolean BlendFunc_ChAsym::ComputeValues(const math_Vector& X,
234 const Standard_Integer DegF,
235 const Standard_Integer DegL)
236{
237 if (DegF > DegL) return Standard_False;
238
239 gp_Vec np, d1gui, d1u1, d1v1, d2u1, d2v1, d2uv1, d1u2, d1v2, Nsurf1;
240 gp_Pnt ptgui;
241 Standard_Real PScaInv, F4;
242
243 tcurv->D1(param, ptgui, d1gui);
244 nplan = d1gui.Normalized();
245 np = nplan;
246
247 if (choix%2 != 0) np.Reverse();
248
249 if ( (DegF == 0) && (DegL == 0) ) {
250 surf1->D1(X(1), X(2), pt1, d1u1, d1v1);
251 pt2 = surf2->Value(X(3), X(4));
252 }
253 else {
254 surf1->D2(X(1), X(2), pt1, d1u1, d1v1, d2u1, d2v1, d2uv1);
255 surf2->D1(X(3), X(4), pt2, d1u2, d1v2);
256 }
257
258 Nsurf1 = d1u1.Crossed(d1v1);
259 tsurf1 = Nsurf1.Crossed(np);
260
261 gp_Vec nps1(ptgui, pt1), s1s2(pt1, pt2);//, tempVec;
262 PScaInv = 1. / tsurf1.Dot(s1s2);
263 F4 = np.Dot(tsurf1.Crossed(s1s2)) * PScaInv;
264
265 if (DegF == 0) {
266 Standard_Real Dist;
267 Dist = ptgui.XYZ().Dot(np.XYZ());
268
269 FX(1) = pt1.XYZ().Dot(np.XYZ()) - Dist;
270 FX(2) = pt2.XYZ().Dot(np.XYZ()) - Dist;
271 FX(3) = dist1 * dist1 - nps1.SquareMagnitude();
272 FX(4) = tgang - F4;
273 }
274
275 if (DegL == 1) {
276 Standard_Real temp;
277 gp_Vec tempVec;
278 gp_Vec d1utsurf1, d1vtsurf1;
279 d1utsurf1 = (d2u1.Crossed(d1v1) + d1u1.Crossed(d2uv1)).Crossed(np);
280 d1vtsurf1 = (d2uv1.Crossed(d1v1) + d1u1.Crossed(d2v1)).Crossed(np);
281
282 DX(1, 1) = np.Dot(d1u1);
283 DX(1, 2) = np.Dot(d1v1);
284 DX(1, 3) = 0.;
285 DX(1, 4) = 0.;
286
287 DX(2, 1) = 0.;
288 DX(2, 2) = 0.;
289 DX(2, 3) = np.Dot(d1u2);
290 DX(2, 4) = np.Dot(d1v2);
291
292 tempVec = -2. * nps1;
293 DX(3, 1) = d1u1.Dot(tempVec);
294 DX(3, 2) = d1v1.Dot(tempVec);
295 DX(3, 3) = 0.;
296 DX(3, 4) = 0.;
297
298 temp = F4 * (d1utsurf1.Dot(s1s2) - tsurf1.Dot(d1u1));
299 temp += np.Dot(tsurf1.Crossed(d1u1) - d1utsurf1.Crossed(s1s2));
300 DX(4, 1) = temp * PScaInv;
301
302 temp = F4 * (d1vtsurf1.Dot(s1s2) - tsurf1.Dot(d1v1));
303 temp += np.Dot(tsurf1.Crossed(d1v1) - d1vtsurf1.Crossed(s1s2));
304 DX(4, 2) = temp * PScaInv;
305
306 temp = F4 * tsurf1.Dot(d1u2) - np.Dot(tsurf1.Crossed(d1u2));
307 DX(4, 3) = temp * PScaInv;
308
309 temp = F4 * tsurf1.Dot(d1v2) - np.Dot(tsurf1.Crossed(d1v2));
310 DX(4, 4) = temp * PScaInv;
311 }
312
313 return Standard_True;
314
315}
316
317
318//=======================================================================
319//function : Value
320//purpose :
321//=======================================================================
322
323Standard_Boolean BlendFunc_ChAsym::Value(const math_Vector& X, math_Vector& F)
324{
325 const Standard_Boolean Error = ComputeValues(X, 0, 0);
326 F = FX;
327 return Error;
328}
329
330
331//=======================================================================
332//function : Derivatives
333//purpose :
334//=======================================================================
335
336Standard_Boolean BlendFunc_ChAsym::Derivatives(const math_Vector& X, math_Matrix& D)
337{
338 const Standard_Boolean Error = ComputeValues(X, 1, 1);
339 D = DX;
340 return Error;
341}
342
343
344//=======================================================================
345//function : Values
346//purpose :
347//=======================================================================
348
349Standard_Boolean BlendFunc_ChAsym::Values(const math_Vector& X, math_Vector& F, math_Matrix& D)
350{
351 const Standard_Boolean Error = ComputeValues(X, 0, 1);
352 F = FX;
353 D = DX;
354 return Error;
355}
356
357
358//=======================================================================
359//function : PointOnS1
360//purpose :
361//=======================================================================
362
363const gp_Pnt& BlendFunc_ChAsym::PointOnS1 () const
364{
365 return pt1;
366}
367
368
369//=======================================================================
370//function : PointOnS2
371//purpose :
372//=======================================================================
373
374const gp_Pnt& BlendFunc_ChAsym::PointOnS2 () const
375{
376 return pt2;
377}
378
379
380//=======================================================================
381//function : IsTangencyPoint
382//purpose :
383//=======================================================================
384
385Standard_Boolean BlendFunc_ChAsym::IsTangencyPoint () const
386{
387 return istangent;
388}
389
390
391//=======================================================================
392//function : TangentOnS1
393//purpose :
394//=======================================================================
395
396const gp_Vec& BlendFunc_ChAsym::TangentOnS1 () const
397{
398 if (istangent)
9775fa61 399 throw Standard_DomainError("BlendFunc_ChAsym::TangentOnS1");
7fd59977 400 return tg1;
401}
402
403
404//=======================================================================
405//function : Tangent2dOnS1
406//purpose :
407//=======================================================================
408
409const gp_Vec2d& BlendFunc_ChAsym::Tangent2dOnS1 () const
410{
411 if (istangent)
9775fa61 412 throw Standard_DomainError("BlendFunc_ChAsym::Tangent2dOnS1");
7fd59977 413 return tg12d;
414}
415
416//=======================================================================
417//function : TangentOnS2
418//purpose :
419//=======================================================================
420
421const gp_Vec& BlendFunc_ChAsym::TangentOnS2 () const
422{
423 if (istangent)
9775fa61 424 throw Standard_DomainError("BlendFunc_ChAsym::TangentOnS2");
7fd59977 425 return tg2;
426}
427
428
429//=======================================================================
430//function : Tangent2dOnS2
431//purpose :
432//=======================================================================
433
434const gp_Vec2d& BlendFunc_ChAsym::Tangent2dOnS2 () const
435{
436 if (istangent)
9775fa61 437 throw Standard_DomainError("BlendFunc_ChAsym::Tangent2dOnS2");
7fd59977 438 return tg22d;
439}
440
441
442//=======================================================================
443//function : TwistOnS1
444//purpose :
445//=======================================================================
446
447Standard_Boolean BlendFunc_ChAsym::TwistOnS1() const
448{
449 if (istangent)
9775fa61 450 throw Standard_DomainError("BlendFunc_ChAsym::TwistOnS1");
7fd59977 451 return tg1.Dot(nplan) < 0.;
452}
453
454//=======================================================================
455//function : TwistOnS2
456//purpose :
457//=======================================================================
458
459Standard_Boolean BlendFunc_ChAsym::TwistOnS2() const
460{
461 if (istangent)
9775fa61 462 throw Standard_DomainError("BlendFunc_ChAsym::TwistOnS2");
7fd59977 463 return tg2.Dot(nplan) < 0.;
464}
465
466//=======================================================================
467//function : Tangent
468//purpose : TgF,NmF et TgL,NmL les tangentes et normales respectives
469// aux surfaces S1 et S2
470//=======================================================================
471
472void BlendFunc_ChAsym::Tangent(const Standard_Real U1,
473 const Standard_Real V1,
474 const Standard_Real U2,
475 const Standard_Real V2,
476 gp_Vec& TgF,
477 gp_Vec& TgL,
478 gp_Vec& NmF,
479 gp_Vec& NmL) const
480{
481 gp_Pnt Pt1,Pt2,ptgui;
482 gp_Vec d1u1,d1v1,d1u2,d1v2;
483 gp_Vec np, d1gui;
484 Standard_Boolean revF = Standard_False;
485 Standard_Boolean revL = Standard_False;
486
487 tcurv->D1(param, ptgui, d1gui);
488 np = d1gui.Normalized();
489
490 surf1->D1(U1,V1,Pt1,d1u1,d1v1);
491 NmF = d1u1.Crossed(d1v1);
492
493 surf2->D1(U2,V2,Pt2,d1u2,d1v2);
494 NmL = d1u2.Crossed(d1v2);
495
496 TgF = (np.Crossed(NmF)).Normalized();
497 TgL = (np.Crossed(NmL)).Normalized();
498
499 if ( (choix == 2)||(choix == 5) ){
500 revF = Standard_True;
501 revL = Standard_True;
502 }
503
504 if ( (choix == 4)||(choix == 7) )
505 revL = Standard_True;
506
507 if ( (choix == 3)||(choix == 8) )
508 revF = Standard_True;
509
510 if ( revF )
511 TgF.Reverse();
512 if ( revL )
513 TgL.Reverse();
514}
515
516
517
518//=======================================================================
519//function : Section
520//purpose :
521//=======================================================================
522
35e08fe8 523void BlendFunc_ChAsym::Section(const Standard_Real /*Param*/,
7fd59977 524 const Standard_Real U1,
525 const Standard_Real V1,
526 const Standard_Real U2,
527 const Standard_Real V2,
528 Standard_Real& Pdeb,
529 Standard_Real& Pfin,
530 gp_Lin& C)
531{
532 const gp_Pnt Pt1 = surf1->Value(U1,V1);
533 const gp_Pnt Pt2 = surf2->Value(U2,V2);
534 const gp_Dir dir( gp_Vec(Pt1,Pt2) );
535
536 C.SetLocation(Pt1);
537 C.SetDirection(dir);
538
539 Pdeb = 0.;
540 Pfin = ElCLib::Parameter(C, Pt2);
541}
542
543
544//=======================================================================
545//function : IsRational
546//purpose :
547//=======================================================================
548
549Standard_Boolean BlendFunc_ChAsym::IsRational () const
550{
551 return Standard_False;
552}
553
554//=======================================================================
555//function : GetSectionSize
556//purpose :
557//=======================================================================
558Standard_Real BlendFunc_ChAsym::GetSectionSize() const
559{
9775fa61 560 throw Standard_NotImplemented("BlendFunc_ChAsym::GetSectionSize()");
7fd59977 561}
562
563//=======================================================================
564//function : GetMinimalWeight
565//purpose :
566//=======================================================================
567void BlendFunc_ChAsym::GetMinimalWeight(TColStd_Array1OfReal& Weights) const
568{
569 Weights.Init(1);
570}
571
572//=======================================================================
573//function : NbIntervals
574//purpose :
575//=======================================================================
576
577Standard_Integer BlendFunc_ChAsym::NbIntervals (const GeomAbs_Shape S) const
578{
579 return curv->NbIntervals(BlendFunc::NextShape(S));
580}
581
582
583//=======================================================================
584//function : Intervals
585//purpose :
586//=======================================================================
587
588void BlendFunc_ChAsym::Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const
589{
590 curv->Intervals(T, BlendFunc::NextShape(S));
591}
592
593//=======================================================================
594//function : GetShape
595//purpose :
596//=======================================================================
597
598void BlendFunc_ChAsym::GetShape (Standard_Integer& NbPoles,
599 Standard_Integer& NbKnots,
600 Standard_Integer& Degree,
601 Standard_Integer& NbPoles2d)
602{
603 NbPoles = 2;
604 NbPoles2d = 2;
605 NbKnots = 2;
606 Degree = 1;
607}
608
609//=======================================================================
610//function : GetTolerance
611//purpose : Determine les Tolerances a utiliser dans les approximations.
612//=======================================================================
613void BlendFunc_ChAsym::GetTolerance(const Standard_Real BoundTol,
35e08fe8 614 const Standard_Real,
615 const Standard_Real,
7fd59977 616 math_Vector& Tol3d,
35e08fe8 617 math_Vector&) const
7fd59977 618{
619 Tol3d.Init(BoundTol);
620}
621
622//=======================================================================
623//function : Knots
624//purpose :
625//=======================================================================
626
627void BlendFunc_ChAsym::Knots(TColStd_Array1OfReal& TKnots)
628{
629 TKnots(1) = 0.;
630 TKnots(2) = 1.;
631}
632
633
634//=======================================================================
635//function : Mults
636//purpose :
637//=======================================================================
638
639void BlendFunc_ChAsym::Mults(TColStd_Array1OfInteger& TMults)
640{
641 TMults(1) = 2;
642 TMults(2) = 2;
643}
644
645
646//=======================================================================
647//function : Section
648//purpose :
649//=======================================================================
650
651void BlendFunc_ChAsym::Section(const Blend_Point& P,
652 TColgp_Array1OfPnt& Poles,
653 TColgp_Array1OfPnt2d& Poles2d,
654 TColStd_Array1OfReal& Weights)
655{
656 Standard_Real u1, v1, u2, v2, prm = P.Parameter();
657 Standard_Integer low = Poles.Lower();
658 Standard_Integer upp = Poles.Upper();
659 math_Vector X(1,4), F(1,4);
660
661 P.ParametersOnS1(u1, v1);
662 P.ParametersOnS2(u2, v2);
663 X(1) = u1;
664 X(2) = v1;
665 X(3) = u2;
666 X(4) = v2;
667 Poles2d(Poles2d.Lower()).SetCoord(u1,v1);
668 Poles2d(Poles2d.Upper()).SetCoord(u2,v2);
669
670 Set(prm);
671 Value(X,F);
672 Poles(low) = PointOnS1();
673 Poles(upp) = PointOnS2();
674 Weights(low) = 1.0;
675 Weights(upp) = 1.0;
676}
677
678
679//=======================================================================
680//function : Section
681//purpose :
682//=======================================================================
683
684Standard_Boolean BlendFunc_ChAsym::Section
685 (const Blend_Point& P,
686 TColgp_Array1OfPnt& Poles,
687 TColgp_Array1OfVec& DPoles,
688 TColgp_Array1OfPnt2d& Poles2d,
689 TColgp_Array1OfVec2d& DPoles2d,
690 TColStd_Array1OfReal& Weights,
691 TColStd_Array1OfReal& DWeights)
692{
693 math_Vector Sol(1, 4), valsol(1, 4), secmember(1, 4);
694 math_Matrix gradsol(1, 4, 1, 4);
695 Standard_Real prm = P.Parameter();
696 Standard_Integer low = Poles.Lower();
697 Standard_Integer upp = Poles.Upper();
698
699 P.ParametersOnS1(Sol(1),Sol(2));
700 P.ParametersOnS2(Sol(3),Sol(4));
701 Set(prm);
702
703 Poles2d(Poles2d.Lower()).SetCoord(Sol(1),Sol(2));
704 Poles2d(Poles2d.Upper()).SetCoord(Sol(3),Sol(4));
705 Poles(low) = PointOnS1();
706 Poles(upp) = PointOnS2();
707 Weights(low) = 1.0;
708 Weights(upp) = 1.0;
709
710 gp_Pnt ptgui;
711 gp_Vec np, dnp, d1gui, d2gui, Nsurf1, dwtsurf1;
712 gp_Vec d1u1, d1v1, d1u2, d1v2;
713 Standard_Real Normg;
714
715 tcurv->D2(param, ptgui, d1gui, d2gui);
716 Normg = d1gui.Magnitude();
717 np = d1gui.Normalized();
718 dnp = (d2gui - np.Dot(d2gui) * np) / Normg;
719
720 if (choix%2 != 0) {
721 np.Reverse();
722 dnp.Reverse();
723 Normg = -Normg;
724 }
725
726 surf1->D1(Sol(1), Sol(2), pt1, d1u1, d1v1);
727 Nsurf1 = d1u1.Crossed(d1v1);
728 tsurf1 = Nsurf1.Crossed(np);
729 dwtsurf1 = Nsurf1.Crossed(dnp);
730
731 surf2->D1(Sol(3), Sol(4), pt2, d1u2, d1v2);
732
733 gp_Vec pguis1(ptgui, pt1), pguis2(ptgui, pt2);
734 gp_Vec CrossVec, s1s2(pt1, pt2);
735 Standard_Real PScaInv = 1. / tsurf1.Dot(s1s2), F4, temp;
736 Standard_Real maxpiv = 1.e-9;
737 Standard_Real Nordu1 = d1u1.Magnitude(),
738 Nordv1 = d1v1.Magnitude();
739
740 temp = 2. * (Nordu1 + Nordv1) * s1s2.Magnitude() + 2. * Nordu1 * Nordv1;
741
742 Values(Sol, valsol, gradsol);
743
744 secmember(1) = Normg - dnp.Dot(pguis1);
745 secmember(2) = Normg - dnp.Dot(pguis2);
746 secmember(3) = - 2. * d1gui.Dot(pguis1);
747
748 CrossVec = tsurf1.Crossed(s1s2);
749 F4 = np.Dot(CrossVec) * PScaInv;
750 temp = dnp.Dot(CrossVec) + np.Dot(dwtsurf1.Crossed(s1s2));
751 temp -= F4 * dwtsurf1.Dot(s1s2);
752 secmember(4) = PScaInv * temp;
753
754 math_Gauss Resol(gradsol, maxpiv);
755
756 if (Resol.IsDone()) {
757 Resol.Solve(secmember);
758 istangent = Standard_False;
759 }
760 else {
761 math_SVD SingRS (gradsol);
762 if (SingRS.IsDone()) {
763 math_Vector DEDT(1,4);
764 DEDT = secmember;
765 SingRS.Solve(DEDT, secmember, 1.e-6);
766 istangent = Standard_False;
767 }
768 else istangent = Standard_True;
769 }
770
771 if (!istangent) {
772 tg1.SetLinearForm(secmember(1), d1u1, secmember(2), d1v1);
773 tg2.SetLinearForm(secmember(3), d1u2, secmember(4), d1v2);
774 tg12d.SetCoord(secmember(1),secmember(2));
775 tg22d.SetCoord(secmember(3),secmember(4));
776 }
777
778 distmin = Min( distmin, pt1.Distance(pt2));
779
780 if (!istangent) {
781 DPoles2d(Poles2d.Lower()).SetCoord(Tangent2dOnS1().X(),
782 Tangent2dOnS1().Y());
783 DPoles2d(Poles2d.Upper()).SetCoord(Tangent2dOnS2().X(),
784 Tangent2dOnS2().Y());
785
786 DPoles(low) = TangentOnS1();
787 DPoles(upp) = TangentOnS2();
788 DWeights(low) = 0.0;
789 DWeights(upp) = 0.0;
790 }
791
792 return (!istangent);
793
794}
795
796
797//=======================================================================
798//function : Section
799//purpose :
800//=======================================================================
801
802Standard_Boolean BlendFunc_ChAsym::Section
35e08fe8 803 (const Blend_Point& /*P*/,
804 TColgp_Array1OfPnt& /*Poles*/,
805 TColgp_Array1OfVec& /*DPoles*/,
806 TColgp_Array1OfVec& /*D2Poles*/,
807 TColgp_Array1OfPnt2d& /*Poles2d*/,
808 TColgp_Array1OfVec2d& /*DPoles2d*/,
809 TColgp_Array1OfVec2d& /*D2Poles2d*/,
810 TColStd_Array1OfReal& /*Weights*/,
811 TColStd_Array1OfReal& /*DWeights*/,
812 TColStd_Array1OfReal& /*D2Weights*/)
7fd59977 813{
814 return Standard_False;
815}
816
817
818//=======================================================================
819//function : Resolution
820//purpose :
821//=======================================================================
822void BlendFunc_ChAsym::Resolution(const Standard_Integer IC2d, const Standard_Real Tol,
823 Standard_Real& TolU, Standard_Real& TolV) const
824{
825 if(IC2d == 1){
826 TolU = surf1->UResolution(Tol);
827 TolV = surf1->VResolution(Tol);
828 }
829 else {
830 TolU = surf2->UResolution(Tol);
831 TolV = surf2->VResolution(Tol);
832 }
833}
834
835
836//=======================================================================
837//function : Set
838//purpose :
839//=======================================================================
840void BlendFunc_ChAsym::Set(const Standard_Real Dist1,
841 const Standard_Real Angle,
842 const Standard_Integer Choix)
843{
844 dist1 = Abs(Dist1);
845 angle = Angle;
846 tgang = Tan(Angle);
847 choix = Choix;
848}