1 // Created on: 1997-02-10
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1997-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
9 // under the terms of the GNU Lesser General Public 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.
17 #include <BRepBlend_RstRstEvolRad.ixx>
18 #include <math_Gauss.hxx>
19 #include <math_SVD.hxx>
23 #include <BlendFunc.hxx>
24 #include <GeomFill.hxx>
25 #include <TColStd_SequenceOfReal.hxx>
26 #include <Standard_DomainError.hxx>
27 #include <Standard_NotImplemented.hxx>
28 #include <Precision.hxx>
32 static void t3dto2d(Standard_Real& a,
38 Standard_Real AB = A.Dot(B);
39 Standard_Real AC = A.Dot(C);
40 Standard_Real BC = B.Dot(C);
41 Standard_Real BB = B.Dot(B);
42 Standard_Real CC = C.Dot(C);
43 Standard_Real deno = (BB*CC-BC*BC);
44 a = (AB*CC-AC*BC)/deno;
45 b = (AC*BB-AB*BC)/deno;
49 static void FusionneIntervalles(const TColStd_Array1OfReal& I1,
50 const TColStd_Array1OfReal& I2,
51 TColStd_SequenceOfReal& Seq)
53 Standard_Integer ind1=1, ind2=1;
54 Standard_Real Epspar = Precision::PConfusion()*0.99;
55 // supposed that the positioning works with PConfusion()/2
57 // Initialisations : IND1 and IND2 point the 1st element
58 // of each of 2 tables to be processed. INDS points at the last
59 // created element of TABSOR
62 //--- TABSOR is filled by parsing TABLE1 and TABLE2 simultaneously ---
63 //------------------ and removing multiple occurrencies ------------
65 while ((ind1<=I1.Upper()) && (ind2<=I2.Upper())) {
68 if (Abs(v1-v2)<= Epspar) {
69 // elements of I1 and I2 fit here
70 Seq.Append((v1+v2)/2);
75 // element of I1 fits here.
80 // element of TABLE2 fits here.
86 if (ind1>I1.Upper()) {
87 //----- Here I1 is exhausted, completed using the end of TABLE2 -------
89 for (; ind2<=I2.Upper(); ind2++) {
94 if (ind2>I2.Upper()) {
95 //----- Here I2 is exhausted, completed using the end of I1 -------
97 for (; ind1<=I1.Upper(); ind1++) {
105 //=======================================================================
106 //function : BRepBlend_RstRstEvolRad
108 //=======================================================================
110 BRepBlend_RstRstEvolRad::BRepBlend_RstRstEvolRad
111 (const Handle(Adaptor3d_HSurface)& Surf1,
112 const Handle(Adaptor2d_HCurve2d)& Rst1,
113 const Handle(Adaptor3d_HSurface)& Surf2,
114 const Handle(Adaptor2d_HCurve2d)& Rst2,
115 const Handle(Adaptor3d_HCurve)& CGuide,
116 const Handle(Law_Function)& Evol):
117 surf1(Surf1), surf2(Surf2), rst1(Rst1), rst2(Rst2),
118 cons1(Rst1, Surf1), cons2(Rst2, Surf2),
119 guide(CGuide), tguide(CGuide),
120 istangent(Standard_True), maxang(RealFirst()), minang(RealLast()),
122 mySShape(BlendFunc_Rational)
128 //=======================================================================
129 //function : NbVariables
131 //=======================================================================
133 Standard_Integer BRepBlend_RstRstEvolRad::NbVariables() const
138 //=======================================================================
139 //function : NbEquations
141 //=======================================================================
143 Standard_Integer BRepBlend_RstRstEvolRad::NbEquations() const
148 //=======================================================================
151 //=======================================================================
153 Standard_Boolean BRepBlend_RstRstEvolRad::Value(const math_Vector& X,
156 ptrst1 = cons1.Value(X(1));
157 ptrst2 = cons2.Value(X(2));
159 F(1) = nplan.XYZ().Dot(ptrst1.XYZ()) + theD;
160 F(2) = nplan.XYZ().Dot(ptrst2.XYZ()) + theD;
162 return Standard_True;
165 //=======================================================================
166 //function : Derivatives
168 //=======================================================================
170 Standard_Boolean BRepBlend_RstRstEvolRad::Derivatives(const math_Vector& X,
175 cons1.D1(X(1), ptrst1, d11);
176 cons2.D1(X(2), ptrst2, d21);
178 D(1,1) = nplan.Dot(d11);
182 D(2,2) = nplan.Dot(d21);
184 return Standard_True;
187 //=======================================================================
190 //=======================================================================
192 Standard_Boolean BRepBlend_RstRstEvolRad::Values(const math_Vector& X,
196 Standard_Boolean Error;
199 Error = Derivatives(X, D);
201 return Standard_True;
204 //=======================================================================
207 //=======================================================================
209 void BRepBlend_RstRstEvolRad::Set(const Handle(Adaptor3d_HSurface)& SurfRef1,
210 const Handle(Adaptor2d_HCurve2d)& RstRef1,
211 const Handle(Adaptor3d_HSurface)& SurfRef2,
212 const Handle(Adaptor2d_HCurve2d)& RstRef2)
220 //=======================================================================
223 //=======================================================================
225 void BRepBlend_RstRstEvolRad::Set(const Standard_Real Param)
227 d1gui = gp_Vec(0.,0.,0.);
228 nplan = gp_Vec(0.,0.,0.);
229 tguide->D2(Param, ptgui, d1gui, d2gui);
230 normtg = d1gui.Magnitude();
231 nplan.SetXYZ(d1gui.Normalized().XYZ());
232 gp_XYZ nplanXYZ(nplan.XYZ());
233 gp_XYZ ptguiXYZ(ptgui.XYZ());
234 theD = nplanXYZ.Dot(ptguiXYZ) ;
235 theD = theD * (-1.) ;
236 // theD = - (nplan.XYZ().Dot(ptgui.XYZ()));
237 tevol->D1(Param,ray,dray);
241 //=======================================================================
244 //=======================================================================
246 void BRepBlend_RstRstEvolRad::Set(const Standard_Real First,
247 const Standard_Real Last)
249 tguide = guide->Trim(First, Last, 1.e-12);
250 tevol = fevol->Trim(First,Last,1.e-12);
253 //=======================================================================
254 //function : GetTolerance
256 //=======================================================================
258 void BRepBlend_RstRstEvolRad::GetTolerance(math_Vector& Tolerance,
259 const Standard_Real Tol) const
261 Tolerance(1) = cons1.Resolution(Tol);
262 Tolerance(2) = cons2.Resolution(Tol);
265 //=======================================================================
266 //function : GetBounds
268 //=======================================================================
270 void BRepBlend_RstRstEvolRad::GetBounds(math_Vector& InfBound,
271 math_Vector& SupBound) const
273 InfBound(1) = cons1.FirstParameter();
274 InfBound(2) = cons2.FirstParameter();
275 SupBound(1) = cons1.LastParameter();
276 SupBound(2) = cons2.LastParameter();
280 //=======================================================================
281 //function : IsSolution
283 //=======================================================================
285 Standard_Boolean BRepBlend_RstRstEvolRad::IsSolution(const math_Vector& Sol,
286 const Standard_Real Tol)
290 math_Vector valsol(1, 2), secmember(1, 2);
291 math_Matrix gradsol(1, 2, 1, 2);
293 gp_Vec dnplan, d1urst1, d1vrst1, d1urst2, d1vrst2, d11, d21, temp;
296 Standard_Real Cosa, Sina, Angle;
298 Values(Sol, valsol, gradsol);
300 if (Abs(valsol(1)) <= Tol &&
301 Abs(valsol(2)) <= Tol ) {
303 // Calculation of tangents
305 pt2drst1 = rst1->Value(prmrst1);
307 pt2drst2 = rst2->Value(prmrst2);
309 cons1.D1(Sol(1), ptrst1, d11);
310 cons2.D1(Sol(2), ptrst2, d21);
312 dnplan.SetLinearForm(1./normtg, d2gui,
313 -1./normtg * (nplan.Dot(d2gui)), nplan);
315 temp.SetXYZ(ptrst1.XYZ() - ptgui.XYZ());
316 secmember(1) = normtg - dnplan.Dot(temp);
318 temp.SetXYZ(ptrst2.XYZ() - ptgui.XYZ());
319 secmember(2) = normtg - dnplan.Dot(temp);
321 math_Gauss Resol(gradsol);
323 if (Resol.IsDone()) {
324 Resol.Solve(secmember);
325 istangent = Standard_False;
328 math_SVD SingRS (gradsol);
329 if (SingRS.IsDone()) {
330 math_Vector DEDT(1,3);
332 SingRS.Solve(DEDT, secmember, 1.e-6);
333 istangent = Standard_False;
335 else istangent = Standard_True;
340 tgrst1 = secmember(1) * d11;
341 tgrst2 = secmember(2) * d21;
344 surf1->D1(pt2drst1.X(), pt2drst1.Y(), bid, d1urst1, d1vrst1);
345 t3dto2d(a, b, tgrst1, d1urst1, d1vrst1);
346 tg2drst1.SetCoord(a, b);
347 surf2->D1(pt2drst2.X(), pt2drst2.Y(), bid, d1urst2, d1vrst2);
348 t3dto2d(a, b, tgrst1, d1urst2, d1vrst2);
349 tg2drst2.SetCoord(a, b);
354 Standard_Boolean IsCenter;
356 IsCenter = CenterCircleRst1Rst2(ptrst1, ptrst2, nplan, Center, NotUsed);
358 if (!IsCenter) return Standard_False;
360 gp_Vec n1(Center, ptrst1) , n2(Center, ptrst2);
366 Sina = nplan.Dot(n1.Crossed(n2));
369 Sina = -Sina; //nplan is changed into -nplan
374 Angle = 2.*M_PI - Angle;
377 if (Angle > maxang) {maxang = Angle;}
378 if (Angle < minang) {minang = Angle;}
379 distmin = Min( distmin, ptrst1.Distance(ptrst2));
381 return Standard_True;
383 istangent = Standard_True;
384 return Standard_False;
387 //=======================================================================
388 //function : GetMinimalDistance
390 //=======================================================================
392 Standard_Real BRepBlend_RstRstEvolRad::GetMinimalDistance() const
397 //=======================================================================
398 //function : PointOnRst1
400 //=======================================================================
402 const gp_Pnt& BRepBlend_RstRstEvolRad::PointOnRst1() const
407 //=======================================================================
408 //function : PointOnRst2
410 //=======================================================================
412 const gp_Pnt& BRepBlend_RstRstEvolRad::PointOnRst2() const
417 //=======================================================================
418 //function : Pnt2dOnRst1
420 //=======================================================================
422 const gp_Pnt2d& BRepBlend_RstRstEvolRad::Pnt2dOnRst1() const
427 //=======================================================================
428 //function : Pnt2dOnRst2
430 //=======================================================================
432 const gp_Pnt2d& BRepBlend_RstRstEvolRad::Pnt2dOnRst2() const
437 //=======================================================================
438 //function : ParameterOnRst1
440 //=======================================================================
442 Standard_Real BRepBlend_RstRstEvolRad::ParameterOnRst1() const
447 //=======================================================================
448 //function : ParameterOnRst2
450 //=======================================================================
452 Standard_Real BRepBlend_RstRstEvolRad::ParameterOnRst2() const
456 //=======================================================================
457 //function : IsTangencyPoint
459 //=======================================================================
461 Standard_Boolean BRepBlend_RstRstEvolRad::IsTangencyPoint() const
466 //=======================================================================
467 //function : TangentOnRst1
469 //=======================================================================
471 const gp_Vec& BRepBlend_RstRstEvolRad::TangentOnRst1() const
473 if (istangent) {Standard_DomainError::Raise();}
477 //=======================================================================
478 //function : Tangent2dOnRst1
480 //=======================================================================
482 const gp_Vec2d& BRepBlend_RstRstEvolRad::Tangent2dOnRst1() const
484 if (istangent) {Standard_DomainError::Raise();}
488 //=======================================================================
489 //function : TangentOnRst2
491 //=======================================================================
493 const gp_Vec& BRepBlend_RstRstEvolRad::TangentOnRst2() const
495 if (istangent) {Standard_DomainError::Raise();}
499 //=======================================================================
500 //function : Tangent2dOnRst2
502 //=======================================================================
504 const gp_Vec2d& BRepBlend_RstRstEvolRad::Tangent2dOnRst2() const
506 if (istangent) {Standard_DomainError::Raise();}
510 //=======================================================================
513 //=======================================================================
515 Blend_DecrochStatus BRepBlend_RstRstEvolRad::Decroch(const math_Vector& Sol,
521 gp_Vec NRst1InPlane, NRst2InPlane;
522 gp_Pnt PtTmp1, PtTmp2, Center;
523 gp_Vec d1u, d1v, centptrst, NotUsed;
524 Standard_Real norm, unsurnorm;
527 rstref1->Value(Sol(1)).Coord(u, v);
528 surfref1->D1(u, v,PtTmp1,d1u,d1v);
529 // Normal to the reference surface 1
530 NRst1 = d1u.Crossed(d1v);
531 rstref2->Value(Sol(2)).Coord(u, v);
532 surfref2->D1(u, v, PtTmp2, d1u, d1v);
533 // Normal to the reference surface 2
534 NRst2 = d1u.Crossed(d1v);
536 Standard_Boolean IsCenter;
538 IsCenter = CenterCircleRst1Rst2(PtTmp1, PtTmp2, nplan, Center, NotUsed);
540 norm = nplan.Crossed(NRst1).Magnitude();
541 unsurnorm = 1. / norm;
543 NRst1InPlane.SetLinearForm(nplan.Dot(NRst1) * unsurnorm, nplan, -unsurnorm, NRst1);
545 centptrst.SetXYZ(PtTmp1.XYZ() - Center.XYZ());
547 if (centptrst.Dot(NRst1InPlane) < 0.) NRst1InPlane.Reverse();
549 TgRst1 = nplan.Crossed(centptrst);
551 norm = nplan.Crossed(NRst2).Magnitude();
552 unsurnorm = 1./ norm;
553 NRst2InPlane.SetLinearForm(nplan.Dot(NRst2) * unsurnorm, nplan, -unsurnorm, NRst2);
554 centptrst.SetXYZ(PtTmp2.XYZ() - Center.XYZ());
557 if (centptrst.Dot(NRst2InPlane) < 0.) NRst2InPlane.Reverse();
559 TgRst2 = nplan.Crossed(centptrst);
566 // Vectors are returned
567 if (NRst1InPlane.Dot(TgRst1) > -1.e-10) {
568 if (NRst2InPlane.Dot(TgRst2) < 1.e-10) {
569 return Blend_DecrochBoth;
572 return Blend_DecrochRst1;
576 if (NRst2InPlane.Dot(TgRst2) < 1.e-10) {
577 return Blend_DecrochRst2;
580 return Blend_NoDecroch;
586 //=======================================================================
589 //=======================================================================
591 void BRepBlend_RstRstEvolRad::Set(const Standard_Integer Choix)
596 //=======================================================================
599 //=======================================================================
601 void BRepBlend_RstRstEvolRad::Set(const BlendFunc_SectionShape TypeSection)
603 mySShape = TypeSection;
608 //=======================================================================
609 //function : CenterCircleRst1Rst2
610 //purpose : Calculate the center of circle passing by two points of restrictions
611 //=======================================================================
612 Standard_Boolean BRepBlend_RstRstEvolRad::CenterCircleRst1Rst2(const gp_Pnt& PtRst1,
613 const gp_Pnt& PtRst2,
619 gp_Vec rst1rst2(PtRst1, PtRst2);
620 gp_Vec vdmedNor; //,NRst1; vdmedNor vector director of the perpendicular bisector
622 Standard_Real Dist;// distance between the middle of PtRst1,PtRst2 and Center
624 // Calculate the center of the circle
625 VdMed = rst1rst2.Crossed(np);
626 norm2 = rst1rst2.SquareMagnitude();
627 Dist = ray * ray - 0.25 * norm2;
633 if (Dist < - 1.E-07) return Standard_False;
637 vdmedNor = VdMed.Normalized();
638 Center.SetXYZ(0.5 * rst1rst2.XYZ() + PtRst1.XYZ() + Dist * vdmedNor.XYZ());
642 Center.SetXYZ(0.5 * rst1rst2.XYZ() + PtRst1.XYZ());
645 return Standard_True;
654 //=======================================================================
657 //=======================================================================
659 void BRepBlend_RstRstEvolRad::Section(const Standard_Real Param,
660 const Standard_Real U,
661 const Standard_Real V,
666 gp_Vec ns, np, NotUsed;
669 tguide->D1(Param, ptgui, d1gui);
670 ray = tevol->Value(Param);
671 np = d1gui.Normalized();
672 ptrst1 = cons1.Value(U);
673 ptrst2 = cons2.Value(V);
675 Standard_Boolean IsCenter;
677 IsCenter = CenterCircleRst1Rst2(ptrst1, ptrst2, np, Center, NotUsed);
679 C.SetRadius(Abs(ray));
680 ns = gp_Vec(Center, ptrst1).Normalized();
686 C.SetPosition(gp_Ax2(Center, np, ns));
687 Pdeb = 0; //ElCLib::Parameter(C, pts);
688 Pfin = ElCLib::Parameter(C, ptrst2);
690 // Test negative and quasi null angles: Special case
691 if (Pfin > 1.5 * M_PI) {
693 C.SetPosition(gp_Ax2(Center, np, ns));
694 Pfin = ElCLib::Parameter(C, ptrst2);
696 if (Pfin < Precision::PConfusion()) Pfin += Precision::PConfusion();
699 //=======================================================================
700 //function : IsRational
702 //=======================================================================
704 Standard_Boolean BRepBlend_RstRstEvolRad::IsRational () const
706 return (mySShape==BlendFunc_Rational || mySShape==BlendFunc_QuasiAngular);
709 //=======================================================================
710 //function : GetSectionSize
712 //=======================================================================
714 Standard_Real BRepBlend_RstRstEvolRad::GetSectionSize() const
716 return maxang * Abs(ray);
719 //=======================================================================
720 //function : GetMinimalWeight
722 //=======================================================================
724 void BRepBlend_RstRstEvolRad::GetMinimalWeight(TColStd_Array1OfReal& Weights) const
726 BlendFunc::GetMinimalWeights(mySShape, myTConv, minang, maxang, Weights );
727 // It is supposed that it does not depend on the Radius!
730 //=======================================================================
731 //function : NbIntervals
733 //=======================================================================
735 Standard_Integer BRepBlend_RstRstEvolRad::NbIntervals (const GeomAbs_Shape S) const
737 Standard_Integer Nb_Int_Courbe, Nb_Int_Loi;
738 Nb_Int_Courbe = guide->NbIntervals(BlendFunc::NextShape(S));
739 Nb_Int_Loi = fevol->NbIntervals(S);
742 return Nb_Int_Courbe;
745 TColStd_Array1OfReal IntC(1, Nb_Int_Courbe+1);
746 TColStd_Array1OfReal IntL(1, Nb_Int_Loi+1);
747 TColStd_SequenceOfReal Inter;
748 guide->Intervals(IntC, BlendFunc::NextShape(S));
749 fevol->Intervals(IntL, S);
751 FusionneIntervalles( IntC, IntL, Inter);
752 return Inter.Length()-1;
755 //=======================================================================
756 //function : Intervals
758 //=======================================================================
760 void BRepBlend_RstRstEvolRad::Intervals (TColStd_Array1OfReal& T,
761 const GeomAbs_Shape S) const
763 Standard_Integer Nb_Int_Courbe, Nb_Int_Loi;
764 Nb_Int_Courbe = guide->NbIntervals(BlendFunc::NextShape(S));
765 Nb_Int_Loi = fevol->NbIntervals(S);
768 guide->Intervals(T, BlendFunc::NextShape(S));
771 TColStd_Array1OfReal IntC(1, Nb_Int_Courbe+1);
772 TColStd_Array1OfReal IntL(1, Nb_Int_Loi+1);
773 TColStd_SequenceOfReal Inter;
774 guide->Intervals(IntC, BlendFunc::NextShape(S));
775 fevol->Intervals(IntL, S);
777 FusionneIntervalles( IntC, IntL, Inter);
778 for (Standard_Integer ii=1; ii<=Inter.Length(); ii++) {
784 //=======================================================================
785 //function : GetShape
787 //=======================================================================
789 void BRepBlend_RstRstEvolRad::GetShape (Standard_Integer& NbPoles,
790 Standard_Integer& NbKnots,
791 Standard_Integer& Degree,
792 Standard_Integer& NbPoles2d)
795 BlendFunc::GetShape(mySShape, maxang, NbPoles, NbKnots, Degree, myTConv);
798 //=======================================================================
799 //function : GetTolerance
800 //purpose : Determine the Tolerance to be used in approximations.
801 //=======================================================================
803 void BRepBlend_RstRstEvolRad::GetTolerance(const Standard_Real BoundTol,
804 const Standard_Real SurfTol,
805 const Standard_Real AngleTol,
807 math_Vector& Tol1d) const
809 Standard_Integer low = Tol3d.Lower(), up = Tol3d.Upper();
811 Tol= GeomFill::GetTolerance(myTConv, minang, Abs(ray),
815 Tol3d(low+1) = Tol3d(up-1) = Min(Tol, SurfTol);
816 Tol3d(low) = Tol3d(up) = Min(Tol, BoundTol);
819 //=======================================================================
822 //=======================================================================
824 void BRepBlend_RstRstEvolRad::Knots(TColStd_Array1OfReal& TKnots)
826 GeomFill::Knots(myTConv, TKnots);
829 //=======================================================================
832 //=======================================================================
834 void BRepBlend_RstRstEvolRad::Mults(TColStd_Array1OfInteger& TMults)
836 GeomFill::Mults(myTConv, TMults);
839 //=======================================================================
842 //=======================================================================
844 void BRepBlend_RstRstEvolRad::Section(const Blend_Point& P,
845 TColgp_Array1OfPnt& Poles,
846 TColgp_Array1OfPnt2d& Poles2d,
847 TColStd_Array1OfReal& Weights)
849 gp_Vec n1, n2, NotUsed;
853 Standard_Real prm = P.Parameter();
854 Standard_Integer low = Poles.Lower();
855 Standard_Integer upp = Poles.Upper();
857 tguide->D1(prm,ptgui, d1gui);
858 ray = tevol->Value(prm);
859 nplan = d1gui.Normalized();
861 u = P.ParameterOnC1();
862 v = P.ParameterOnC2();
864 gp_Pnt2d pt2d1 = rst1->Value(u);
865 gp_Pnt2d pt2d2 = rst2->Value(v);
867 ptrst1 = cons1.Value(u);
868 ptrst2 = cons2.Value(v);
869 distmin = Min (distmin, ptrst1.Distance(ptrst2));
871 Poles2d(Poles2d.Lower()).SetCoord(pt2d1.X(),pt2d1.Y());
872 Poles2d(Poles2d.Upper()).SetCoord(pt2d2.X(),pt2d2.Y());
875 if (mySShape == BlendFunc_Linear) {
883 // Calculate the center of the circle
884 Standard_Boolean IsCenter;
885 IsCenter = CenterCircleRst1Rst2(ptrst1, ptrst2, nplan, Center, NotUsed);
887 // normals to the section with points
888 n1 = gp_Vec(Center, ptrst1).Normalized();
889 n2 = gp_Vec(Center, ptrst2).Normalized();
895 GeomFill::GetCircle(myTConv,
897 nplan, ptrst1, ptrst2,
902 //=======================================================================
905 //=======================================================================
907 Standard_Boolean BRepBlend_RstRstEvolRad::Section(const Blend_Point& P,
908 TColgp_Array1OfPnt& Poles,
909 TColgp_Array1OfVec& DPoles,
910 TColgp_Array1OfPnt2d& Poles2d,
911 TColgp_Array1OfVec2d& DPoles2d,
912 TColStd_Array1OfReal& Weights,
913 TColStd_Array1OfReal& DWeights)
917 gp_Vec dnplan, d1n1, d1n2;//,np2, dnp2;
919 gp_Vec d1urst, d1vrst;
920 gp_Pnt Center, NotUsed;
922 Standard_Real norm2, normmed, Dist;
924 math_Vector sol(1, 2), valsol(1, 2), secmember(1, 2);
925 math_Matrix gradsol(1, 2, 1, 2);
927 Standard_Real prm = P.Parameter();
928 Standard_Integer low = Poles.Lower();
929 Standard_Integer upp = Poles.Upper();
930 Standard_Boolean istgt;
932 tguide->D2(prm, ptgui, d1gui, d2gui);
933 tevol->D1(prm,ray,dray);
934 normtg = d1gui.Magnitude();
935 nplan = d1gui.Normalized();
936 dnplan.SetLinearForm(1./normtg, d2gui,
937 -1./normtg * (nplan.Dot(d2gui)), nplan);
939 sol(1) = prmrst1 = P.ParameterOnC1();
940 sol(2) = prmrst2 = P.ParameterOnC2();
941 pt2drst1 = rst1->Value(prmrst1);
942 pt2drst2 = rst2->Value(prmrst2);
944 Values(sol, valsol, gradsol);
946 cons1.D1(sol(1), ptrst1, d11);
947 cons2.D1(sol(2), ptrst2, d21);
949 temp.SetXYZ(ptrst1.XYZ() - ptgui.XYZ());
950 secmember(1) = normtg - dnplan.Dot(temp);
952 temp.SetXYZ(ptrst2.XYZ() - ptgui.XYZ());
953 secmember(2) = normtg - dnplan.Dot(temp);
955 math_Gauss Resol(gradsol, 1.e-9);
957 if (Resol.IsDone()) {
958 istgt = Standard_False;
959 Resol.Solve(secmember);
962 math_SVD SingRS (gradsol);
963 if (SingRS.IsDone()) {
964 math_Vector DEDT(1,2);
966 SingRS.Solve(DEDT, secmember, 1.e-6);
967 istgt = Standard_False;
969 else istgt = Standard_True;
973 gp_Vec rst1rst2(ptrst1, ptrst2);
974 Standard_Boolean IsCenter;
976 IsCenter = CenterCircleRst1Rst2(ptrst1, ptrst2, nplan, Center, med);
977 if (!IsCenter) return Standard_False;
979 normmed = med.Magnitude();
981 gp_Vec n1(Center, ptrst1), n2(Center, ptrst2);
984 // secmember contains derivatives of parameters on curves
985 // corresponding to t
986 tgrst1 = secmember(1) * d11;
987 tgrst2 = secmember(2) * d21;
991 norm2 = rst1rst2.SquareMagnitude();
992 d1rst1rst2 = tgrst2 - tgrst1;
993 Dist = ray * ray - 0.25 * norm2;
994 Standard_Real Invdray = dray / ray;
997 gp_Vec d1P1P2CrosNp, dmed;
998 d1P1P2CrosNp = d1rst1rst2.Crossed(nplan) + rst1rst2.Crossed(dnplan);
999 // derivative of the bisector
1000 dmed = d1P1P2CrosNp - med.Dot(d1P1P2CrosNp) * med;
1003 Standard_Real d1Dist;
1005 d1Dist = (ray * dray - 0.25 * rst1rst2.Dot(d1rst1rst2) ) / Dist;
1011 // derivative of the coefficient Dist is located in dmed
1012 dmed.SetLinearForm(Dist, dmed, d1Dist, med);
1014 // derivative of the Normal to the curve in P1
1015 d1n1 = - (d1rst1rst2 + dmed + Invdray * n1) / ray;
1017 // derivative of the Normal to the curve in P2
1018 d1n2 = (d1rst1rst2 - dmed - Invdray * n2) / ray;
1022 // Normal to the curve in P1
1023 d1n1 = - (d1rst1rst2 + Invdray * n1) / ray;
1025 // Normal to the curve in P2
1026 d1n2 = (d1rst1rst2 - Invdray * n2) / ray;
1035 Poles2d(Poles2d.Lower()).SetCoord(pt2drst1.X(), pt2drst1.Y());
1036 Poles2d(Poles2d.Upper()).SetCoord(pt2drst2.X(), pt2drst2.Y());
1039 surf1->D1(pt2drst1.X(), pt2drst1.Y(), NotUsed, d1urst, d1vrst);
1040 t3dto2d(a,b,tgrst1, d1urst, d1vrst);
1041 DPoles2d(Poles2d.Lower()).SetCoord(a, b);
1043 surf2->D1(pt2drst2.X(), pt2drst2.Y(), NotUsed, d1urst, d1vrst);
1044 t3dto2d(a, b, tgrst2, d1urst, d1vrst);
1045 DPoles2d(Poles2d.Upper()).SetCoord(a, b);
1049 if (mySShape == BlendFunc_Linear) {
1050 Poles(low) = ptrst1;
1051 Poles(upp) = ptrst2;
1055 DPoles(low) = tgrst1;
1056 DPoles(upp) = tgrst2;
1057 DWeights(low) = 0.0;
1058 DWeights(upp) = 0.0;
1063 // Case of the circle
1064 // tangent to the center of the circle
1066 tgct.SetLinearForm(-ray, d1n1, -dray, n1, tgrst1);
1076 return GeomFill::GetCircle(myTConv,
1090 GeomFill::GetCircle(myTConv,
1092 nplan, ptrst1, ptrst2,
1095 return Standard_False;
1099 //=======================================================================
1100 //function : Section
1102 //=======================================================================
1104 Standard_Boolean BRepBlend_RstRstEvolRad::Section
1105 (const Blend_Point&,
1106 TColgp_Array1OfPnt&,
1107 TColgp_Array1OfVec&,
1108 TColgp_Array1OfVec&,
1109 TColgp_Array1OfPnt2d&,
1110 TColgp_Array1OfVec2d&,
1111 TColgp_Array1OfVec2d&,
1112 TColStd_Array1OfReal&,
1113 TColStd_Array1OfReal&,
1114 TColStd_Array1OfReal&)
1116 return Standard_False;
1120 void BRepBlend_RstRstEvolRad::Resolution(const Standard_Integer IC2d,
1121 const Standard_Real Tol,
1122 Standard_Real& TolU,
1123 Standard_Real& TolV) const
1126 TolU = surf1->UResolution(Tol);
1127 TolV = surf1->VResolution(Tol);
1130 TolU = surf2->UResolution(Tol);
1131 TolV = surf2->VResolution(Tol);