1 // File: BRepBlend_RstRstEvolRad.cxx
2 // Created: Mon Feb 10 10:32:10 1997
3 // Author: Laurent BOURESCHE
4 // Author: Jacques GOUSSARD
5 // <lbo@pomalox.paris1.matra-dtv.fr>
7 #include <BRepBlend_RstRstEvolRad.ixx>
8 #include <math_Gauss.hxx>
9 #include <math_SVD.hxx>
13 #include <BlendFunc.hxx>
14 #include <GeomFill.hxx>
15 #include <TColStd_SequenceOfReal.hxx>
16 #include <Standard_DomainError.hxx>
17 #include <Standard_NotImplemented.hxx>
18 #include <Precision.hxx>
22 static void t3dto2d(Standard_Real& a,
28 Standard_Real AB = A.Dot(B);
29 Standard_Real AC = A.Dot(C);
30 Standard_Real BC = B.Dot(C);
31 Standard_Real BB = B.Dot(B);
32 Standard_Real CC = C.Dot(C);
33 Standard_Real deno = (BB*CC-BC*BC);
34 a = (AB*CC-AC*BC)/deno;
35 b = (AC*BB-AB*BC)/deno;
39 static void FusionneIntervalles(const TColStd_Array1OfReal& I1,
40 const TColStd_Array1OfReal& I2,
41 TColStd_SequenceOfReal& Seq)
43 Standard_Integer ind1=1, ind2=1;
44 Standard_Real Epspar = Precision::PConfusion()*0.99;
45 // supposed that the positioning works with PConfusion()/2
47 // Initialisations : IND1 and IND2 point the 1st element
48 // of each of 2 tables to be processed. INDS points at the last
49 // created element of TABSOR
52 //--- TABSOR is filled by parsing TABLE1 and TABLE2 simultaneously ---
53 //------------------ and removing multiple occurrencies ------------
55 while ((ind1<=I1.Upper()) && (ind2<=I2.Upper())) {
58 if (Abs(v1-v2)<= Epspar) {
59 // elements of I1 and I2 fit here
60 Seq.Append((v1+v2)/2);
65 // element of I1 fits here.
70 // element of TABLE2 fits here.
76 if (ind1>I1.Upper()) {
77 //----- Here I1 is exhausted, completed using the end of TABLE2 -------
79 for (; ind2<=I2.Upper(); ind2++) {
84 if (ind2>I2.Upper()) {
85 //----- Here I2 is exhausted, completed using the end of I1 -------
87 for (; ind1<=I1.Upper(); ind1++) {
95 //=======================================================================
96 //function : BRepBlend_RstRstEvolRad
98 //=======================================================================
100 BRepBlend_RstRstEvolRad::BRepBlend_RstRstEvolRad
101 (const Handle(Adaptor3d_HSurface)& Surf1,
102 const Handle(Adaptor2d_HCurve2d)& Rst1,
103 const Handle(Adaptor3d_HSurface)& Surf2,
104 const Handle(Adaptor2d_HCurve2d)& Rst2,
105 const Handle(Adaptor3d_HCurve)& CGuide,
106 const Handle(Law_Function)& Evol):
107 surf1(Surf1), surf2(Surf2), rst1(Rst1), rst2(Rst2),
108 cons1(Rst1, Surf1), cons2(Rst2, Surf2),
109 guide(CGuide), tguide(CGuide),
110 istangent(Standard_True), maxang(RealFirst()), minang(RealLast()),
112 mySShape(BlendFunc_Rational)
118 //=======================================================================
119 //function : NbVariables
121 //=======================================================================
123 Standard_Integer BRepBlend_RstRstEvolRad::NbVariables() const
128 //=======================================================================
129 //function : NbEquations
131 //=======================================================================
133 Standard_Integer BRepBlend_RstRstEvolRad::NbEquations() const
138 //=======================================================================
141 //=======================================================================
143 Standard_Boolean BRepBlend_RstRstEvolRad::Value(const math_Vector& X,
146 ptrst1 = cons1.Value(X(1));
147 ptrst2 = cons2.Value(X(2));
149 F(1) = nplan.XYZ().Dot(ptrst1.XYZ()) + theD;
150 F(2) = nplan.XYZ().Dot(ptrst2.XYZ()) + theD;
152 return Standard_True;
155 //=======================================================================
156 //function : Derivatives
158 //=======================================================================
160 Standard_Boolean BRepBlend_RstRstEvolRad::Derivatives(const math_Vector& X,
165 cons1.D1(X(1), ptrst1, d11);
166 cons2.D1(X(2), ptrst2, d21);
168 D(1,1) = nplan.Dot(d11);
172 D(2,2) = nplan.Dot(d21);
174 return Standard_True;
177 //=======================================================================
180 //=======================================================================
182 Standard_Boolean BRepBlend_RstRstEvolRad::Values(const math_Vector& X,
186 Standard_Boolean Error;
189 Error = Derivatives(X, D);
191 return Standard_True;
194 //=======================================================================
197 //=======================================================================
199 void BRepBlend_RstRstEvolRad::Set(const Handle(Adaptor3d_HSurface)& SurfRef1,
200 const Handle(Adaptor2d_HCurve2d)& RstRef1,
201 const Handle(Adaptor3d_HSurface)& SurfRef2,
202 const Handle(Adaptor2d_HCurve2d)& RstRef2)
210 //=======================================================================
213 //=======================================================================
215 void BRepBlend_RstRstEvolRad::Set(const Standard_Real Param)
217 d1gui = gp_Vec(0.,0.,0.);
218 nplan = gp_Vec(0.,0.,0.);
219 tguide->D2(Param, ptgui, d1gui, d2gui);
220 normtg = d1gui.Magnitude();
221 nplan.SetXYZ(d1gui.Normalized().XYZ());
222 gp_XYZ nplanXYZ(nplan.XYZ());
223 gp_XYZ ptguiXYZ(ptgui.XYZ());
224 theD = nplanXYZ.Dot(ptguiXYZ) ;
225 theD = theD * (-1.) ;
226 // theD = - (nplan.XYZ().Dot(ptgui.XYZ()));
227 tevol->D1(Param,ray,dray);
231 //=======================================================================
234 //=======================================================================
236 void BRepBlend_RstRstEvolRad::Set(const Standard_Real First,
237 const Standard_Real Last)
239 tguide = guide->Trim(First, Last, 1.e-12);
240 tevol = fevol->Trim(First,Last,1.e-12);
243 //=======================================================================
244 //function : GetTolerance
246 //=======================================================================
248 void BRepBlend_RstRstEvolRad::GetTolerance(math_Vector& Tolerance,
249 const Standard_Real Tol) const
251 Tolerance(1) = cons1.Resolution(Tol);
252 Tolerance(2) = cons2.Resolution(Tol);
255 //=======================================================================
256 //function : GetBounds
258 //=======================================================================
260 void BRepBlend_RstRstEvolRad::GetBounds(math_Vector& InfBound,
261 math_Vector& SupBound) const
263 InfBound(1) = cons1.FirstParameter();
264 InfBound(2) = cons2.FirstParameter();
265 SupBound(1) = cons1.LastParameter();
266 SupBound(2) = cons2.LastParameter();
270 //=======================================================================
271 //function : IsSolution
273 //=======================================================================
275 Standard_Boolean BRepBlend_RstRstEvolRad::IsSolution(const math_Vector& Sol,
276 const Standard_Real Tol)
280 math_Vector valsol(1, 2), secmember(1, 2);
281 math_Matrix gradsol(1, 2, 1, 2);
283 gp_Vec dnplan, d1urst1, d1vrst1, d1urst2, d1vrst2, d11, d21, temp;
286 Standard_Real Cosa, Sina, Angle;
288 Values(Sol, valsol, gradsol);
290 if (Abs(valsol(1)) <= Tol &&
291 Abs(valsol(2)) <= Tol ) {
293 // Calculation of tangents
295 pt2drst1 = rst1->Value(prmrst1);
297 pt2drst2 = rst2->Value(prmrst2);
299 cons1.D1(Sol(1), ptrst1, d11);
300 cons2.D1(Sol(2), ptrst2, d21);
302 dnplan.SetLinearForm(1./normtg, d2gui,
303 -1./normtg * (nplan.Dot(d2gui)), nplan);
305 temp.SetXYZ(ptrst1.XYZ() - ptgui.XYZ());
306 secmember(1) = normtg - dnplan.Dot(temp);
308 temp.SetXYZ(ptrst2.XYZ() - ptgui.XYZ());
309 secmember(2) = normtg - dnplan.Dot(temp);
311 math_Gauss Resol(gradsol);
313 if (Resol.IsDone()) {
314 Resol.Solve(secmember);
315 istangent = Standard_False;
318 math_SVD SingRS (gradsol);
319 if (SingRS.IsDone()) {
320 math_Vector DEDT(1,3);
322 SingRS.Solve(DEDT, secmember, 1.e-6);
323 istangent = Standard_False;
325 else istangent = Standard_True;
330 tgrst1 = secmember(1) * d11;
331 tgrst2 = secmember(2) * d21;
334 surf1->D1(pt2drst1.X(), pt2drst1.Y(), bid, d1urst1, d1vrst1);
335 t3dto2d(a, b, tgrst1, d1urst1, d1vrst1);
336 tg2drst1.SetCoord(a, b);
337 surf2->D1(pt2drst2.X(), pt2drst2.Y(), bid, d1urst2, d1vrst2);
338 t3dto2d(a, b, tgrst1, d1urst2, d1vrst2);
339 tg2drst2.SetCoord(a, b);
344 Standard_Boolean IsCenter;
346 IsCenter = CenterCircleRst1Rst2(ptrst1, ptrst2, nplan, Center, NotUsed);
348 if (!IsCenter) return Standard_False;
350 gp_Vec n1(Center, ptrst1) , n2(Center, ptrst2);
356 Sina = nplan.Dot(n1.Crossed(n2));
359 Sina = -Sina; //nplan is changed into -nplan
364 Angle = 2.*M_PI - Angle;
367 if (Angle > maxang) {maxang = Angle;}
368 if (Angle < minang) {minang = Angle;}
369 distmin = Min( distmin, ptrst1.Distance(ptrst2));
371 return Standard_True;
373 istangent = Standard_True;
374 return Standard_False;
377 //=======================================================================
378 //function : GetMinimalDistance
380 //=======================================================================
382 Standard_Real BRepBlend_RstRstEvolRad::GetMinimalDistance() const
387 //=======================================================================
388 //function : PointOnRst1
390 //=======================================================================
392 const gp_Pnt& BRepBlend_RstRstEvolRad::PointOnRst1() const
397 //=======================================================================
398 //function : PointOnRst2
400 //=======================================================================
402 const gp_Pnt& BRepBlend_RstRstEvolRad::PointOnRst2() const
407 //=======================================================================
408 //function : Pnt2dOnRst1
410 //=======================================================================
412 const gp_Pnt2d& BRepBlend_RstRstEvolRad::Pnt2dOnRst1() const
417 //=======================================================================
418 //function : Pnt2dOnRst2
420 //=======================================================================
422 const gp_Pnt2d& BRepBlend_RstRstEvolRad::Pnt2dOnRst2() const
427 //=======================================================================
428 //function : ParameterOnRst1
430 //=======================================================================
432 Standard_Real BRepBlend_RstRstEvolRad::ParameterOnRst1() const
437 //=======================================================================
438 //function : ParameterOnRst2
440 //=======================================================================
442 Standard_Real BRepBlend_RstRstEvolRad::ParameterOnRst2() const
446 //=======================================================================
447 //function : IsTangencyPoint
449 //=======================================================================
451 Standard_Boolean BRepBlend_RstRstEvolRad::IsTangencyPoint() const
456 //=======================================================================
457 //function : TangentOnRst1
459 //=======================================================================
461 const gp_Vec& BRepBlend_RstRstEvolRad::TangentOnRst1() const
463 if (istangent) {Standard_DomainError::Raise();}
467 //=======================================================================
468 //function : Tangent2dOnRst1
470 //=======================================================================
472 const gp_Vec2d& BRepBlend_RstRstEvolRad::Tangent2dOnRst1() const
474 if (istangent) {Standard_DomainError::Raise();}
478 //=======================================================================
479 //function : TangentOnRst2
481 //=======================================================================
483 const gp_Vec& BRepBlend_RstRstEvolRad::TangentOnRst2() const
485 if (istangent) {Standard_DomainError::Raise();}
489 //=======================================================================
490 //function : Tangent2dOnRst2
492 //=======================================================================
494 const gp_Vec2d& BRepBlend_RstRstEvolRad::Tangent2dOnRst2() const
496 if (istangent) {Standard_DomainError::Raise();}
500 //=======================================================================
503 //=======================================================================
505 Blend_DecrochStatus BRepBlend_RstRstEvolRad::Decroch(const math_Vector& Sol,
511 gp_Vec NRst1InPlane, NRst2InPlane;
512 gp_Pnt PtTmp1, PtTmp2, Center;
513 gp_Vec d1u, d1v, centptrst, NotUsed;
514 Standard_Real norm, unsurnorm;
517 rstref1->Value(Sol(1)).Coord(u, v);
518 surfref1->D1(u, v,PtTmp1,d1u,d1v);
519 // Normal to the reference surface 1
520 NRst1 = d1u.Crossed(d1v);
521 rstref2->Value(Sol(2)).Coord(u, v);
522 surfref2->D1(u, v, PtTmp2, d1u, d1v);
523 // Normal to the reference surface 2
524 NRst2 = d1u.Crossed(d1v);
526 Standard_Boolean IsCenter;
528 IsCenter = CenterCircleRst1Rst2(PtTmp1, PtTmp2, nplan, Center, NotUsed);
530 norm = nplan.Crossed(NRst1).Magnitude();
531 unsurnorm = 1. / norm;
533 NRst1InPlane.SetLinearForm(nplan.Dot(NRst1) * unsurnorm, nplan, -unsurnorm, NRst1);
535 centptrst.SetXYZ(PtTmp1.XYZ() - Center.XYZ());
537 if (centptrst.Dot(NRst1InPlane) < 0.) NRst1InPlane.Reverse();
539 TgRst1 = nplan.Crossed(centptrst);
541 norm = nplan.Crossed(NRst2).Magnitude();
542 unsurnorm = 1./ norm;
543 NRst2InPlane.SetLinearForm(nplan.Dot(NRst2) * unsurnorm, nplan, -unsurnorm, NRst2);
544 centptrst.SetXYZ(PtTmp2.XYZ() - Center.XYZ());
547 if (centptrst.Dot(NRst2InPlane) < 0.) NRst2InPlane.Reverse();
549 TgRst2 = nplan.Crossed(centptrst);
556 // Vectors are returned
557 if (NRst1InPlane.Dot(TgRst1) > -1.e-10) {
558 if (NRst2InPlane.Dot(TgRst2) < 1.e-10) {
559 return Blend_DecrochBoth;
562 return Blend_DecrochRst1;
566 if (NRst2InPlane.Dot(TgRst2) < 1.e-10) {
567 return Blend_DecrochRst2;
570 return Blend_NoDecroch;
576 //=======================================================================
579 //=======================================================================
581 void BRepBlend_RstRstEvolRad::Set(const Standard_Integer Choix)
586 //=======================================================================
589 //=======================================================================
591 void BRepBlend_RstRstEvolRad::Set(const BlendFunc_SectionShape TypeSection)
593 mySShape = TypeSection;
598 //=======================================================================
599 //function : CenterCircleRst1Rst2
600 //purpose : Calculate the center of circle passing by two points of restrictions
601 //=======================================================================
602 Standard_Boolean BRepBlend_RstRstEvolRad::CenterCircleRst1Rst2(const gp_Pnt& PtRst1,
603 const gp_Pnt& PtRst2,
609 gp_Vec rst1rst2(PtRst1, PtRst2);
610 gp_Vec vdmedNor; //,NRst1; vdmedNor vector director of the perpendicular bisector
612 Standard_Real Dist;// distance between the middle of PtRst1,PtRst2 and Center
614 // Calculate the center of the circle
615 VdMed = rst1rst2.Crossed(np);
616 norm2 = rst1rst2.SquareMagnitude();
617 Dist = ray * ray - 0.25 * norm2;
623 if (Dist < - 1.E-07) return Standard_False;
627 vdmedNor = VdMed.Normalized();
628 Center.SetXYZ(0.5 * rst1rst2.XYZ() + PtRst1.XYZ() + Dist * vdmedNor.XYZ());
632 Center.SetXYZ(0.5 * rst1rst2.XYZ() + PtRst1.XYZ());
635 return Standard_True;
644 //=======================================================================
647 //=======================================================================
649 void BRepBlend_RstRstEvolRad::Section(const Standard_Real Param,
650 const Standard_Real U,
651 const Standard_Real V,
656 gp_Vec ns, np, NotUsed;
659 tguide->D1(Param, ptgui, d1gui);
660 ray = tevol->Value(Param);
661 np = d1gui.Normalized();
662 ptrst1 = cons1.Value(U);
663 ptrst2 = cons2.Value(V);
665 Standard_Boolean IsCenter;
667 IsCenter = CenterCircleRst1Rst2(ptrst1, ptrst2, np, Center, NotUsed);
669 C.SetRadius(Abs(ray));
670 ns = gp_Vec(Center, ptrst1).Normalized();
676 C.SetPosition(gp_Ax2(Center, np, ns));
677 Pdeb = 0; //ElCLib::Parameter(C, pts);
678 Pfin = ElCLib::Parameter(C, ptrst2);
680 // Test negative and quasi null angles: Special case
681 if (Pfin > 1.5 * M_PI) {
683 C.SetPosition(gp_Ax2(Center, np, ns));
684 Pfin = ElCLib::Parameter(C, ptrst2);
686 if (Pfin < Precision::PConfusion()) Pfin += Precision::PConfusion();
689 //=======================================================================
690 //function : IsRational
692 //=======================================================================
694 Standard_Boolean BRepBlend_RstRstEvolRad::IsRational () const
696 return (mySShape==BlendFunc_Rational || mySShape==BlendFunc_QuasiAngular);
699 //=======================================================================
700 //function : GetSectionSize
702 //=======================================================================
704 Standard_Real BRepBlend_RstRstEvolRad::GetSectionSize() const
706 return maxang * Abs(ray);
709 //=======================================================================
710 //function : GetMinimalWeight
712 //=======================================================================
714 void BRepBlend_RstRstEvolRad::GetMinimalWeight(TColStd_Array1OfReal& Weights) const
716 BlendFunc::GetMinimalWeights(mySShape, myTConv, minang, maxang, Weights );
717 // It is supposed that it does not depend on the Radius!
720 //=======================================================================
721 //function : NbIntervals
723 //=======================================================================
725 Standard_Integer BRepBlend_RstRstEvolRad::NbIntervals (const GeomAbs_Shape S) const
727 Standard_Integer Nb_Int_Courbe, Nb_Int_Loi;
728 Nb_Int_Courbe = guide->NbIntervals(BlendFunc::NextShape(S));
729 Nb_Int_Loi = fevol->NbIntervals(S);
732 return Nb_Int_Courbe;
735 TColStd_Array1OfReal IntC(1, Nb_Int_Courbe+1);
736 TColStd_Array1OfReal IntL(1, Nb_Int_Loi+1);
737 TColStd_SequenceOfReal Inter;
738 guide->Intervals(IntC, BlendFunc::NextShape(S));
739 fevol->Intervals(IntL, S);
741 FusionneIntervalles( IntC, IntL, Inter);
742 return Inter.Length()-1;
745 //=======================================================================
746 //function : Intervals
748 //=======================================================================
750 void BRepBlend_RstRstEvolRad::Intervals (TColStd_Array1OfReal& T,
751 const GeomAbs_Shape S) const
753 Standard_Integer Nb_Int_Courbe, Nb_Int_Loi;
754 Nb_Int_Courbe = guide->NbIntervals(BlendFunc::NextShape(S));
755 Nb_Int_Loi = fevol->NbIntervals(S);
758 guide->Intervals(T, BlendFunc::NextShape(S));
761 TColStd_Array1OfReal IntC(1, Nb_Int_Courbe+1);
762 TColStd_Array1OfReal IntL(1, Nb_Int_Loi+1);
763 TColStd_SequenceOfReal Inter;
764 guide->Intervals(IntC, BlendFunc::NextShape(S));
765 fevol->Intervals(IntL, S);
767 FusionneIntervalles( IntC, IntL, Inter);
768 for (Standard_Integer ii=1; ii<=Inter.Length(); ii++) {
774 //=======================================================================
775 //function : GetShape
777 //=======================================================================
779 void BRepBlend_RstRstEvolRad::GetShape (Standard_Integer& NbPoles,
780 Standard_Integer& NbKnots,
781 Standard_Integer& Degree,
782 Standard_Integer& NbPoles2d)
785 BlendFunc::GetShape(mySShape, maxang, NbPoles, NbKnots, Degree, myTConv);
788 //=======================================================================
789 //function : GetTolerance
790 //purpose : Determine the Tolerance to be used in approximations.
791 //=======================================================================
793 void BRepBlend_RstRstEvolRad::GetTolerance(const Standard_Real BoundTol,
794 const Standard_Real SurfTol,
795 const Standard_Real AngleTol,
797 math_Vector& Tol1d) const
799 Standard_Integer low = Tol3d.Lower(), up = Tol3d.Upper();
801 Tol= GeomFill::GetTolerance(myTConv, minang, Abs(ray),
805 Tol3d(low+1) = Tol3d(up-1) = Min(Tol, SurfTol);
806 Tol3d(low) = Tol3d(up) = Min(Tol, BoundTol);
809 //=======================================================================
812 //=======================================================================
814 void BRepBlend_RstRstEvolRad::Knots(TColStd_Array1OfReal& TKnots)
816 GeomFill::Knots(myTConv, TKnots);
819 //=======================================================================
822 //=======================================================================
824 void BRepBlend_RstRstEvolRad::Mults(TColStd_Array1OfInteger& TMults)
826 GeomFill::Mults(myTConv, TMults);
829 //=======================================================================
832 //=======================================================================
834 void BRepBlend_RstRstEvolRad::Section(const Blend_Point& P,
835 TColgp_Array1OfPnt& Poles,
836 TColgp_Array1OfPnt2d& Poles2d,
837 TColStd_Array1OfReal& Weights)
839 gp_Vec n1, n2, NotUsed;
843 Standard_Real prm = P.Parameter();
844 Standard_Integer low = Poles.Lower();
845 Standard_Integer upp = Poles.Upper();
847 tguide->D1(prm,ptgui, d1gui);
848 ray = tevol->Value(prm);
849 nplan = d1gui.Normalized();
851 u = P.ParameterOnC1();
852 v = P.ParameterOnC2();
854 gp_Pnt2d pt2d1 = rst1->Value(u);
855 gp_Pnt2d pt2d2 = rst2->Value(v);
857 ptrst1 = cons1.Value(u);
858 ptrst2 = cons2.Value(v);
859 distmin = Min (distmin, ptrst1.Distance(ptrst2));
861 Poles2d(Poles2d.Lower()).SetCoord(pt2d1.X(),pt2d1.Y());
862 Poles2d(Poles2d.Upper()).SetCoord(pt2d2.X(),pt2d2.Y());
865 if (mySShape == BlendFunc_Linear) {
873 // Calculate the center of the circle
874 Standard_Boolean IsCenter;
875 IsCenter = CenterCircleRst1Rst2(ptrst1, ptrst2, nplan, Center, NotUsed);
877 // normals to the section with points
878 n1 = gp_Vec(Center, ptrst1).Normalized();
879 n2 = gp_Vec(Center, ptrst2).Normalized();
885 GeomFill::GetCircle(myTConv,
887 nplan, ptrst1, ptrst2,
892 //=======================================================================
895 //=======================================================================
897 Standard_Boolean BRepBlend_RstRstEvolRad::Section(const Blend_Point& P,
898 TColgp_Array1OfPnt& Poles,
899 TColgp_Array1OfVec& DPoles,
900 TColgp_Array1OfPnt2d& Poles2d,
901 TColgp_Array1OfVec2d& DPoles2d,
902 TColStd_Array1OfReal& Weights,
903 TColStd_Array1OfReal& DWeights)
907 gp_Vec dnplan, d1n1, d1n2;//,np2, dnp2;
909 gp_Vec d1urst, d1vrst;
910 gp_Pnt Center, NotUsed;
912 Standard_Real norm2, normmed, Dist;
914 math_Vector sol(1, 2), valsol(1, 2), secmember(1, 2);
915 math_Matrix gradsol(1, 2, 1, 2);
917 Standard_Real prm = P.Parameter();
919 Standard_Integer NbSpan = (Poles.Length() - 1) / 2;
921 Standard_Integer low = Poles.Lower();
922 Standard_Integer upp = Poles.Upper();
923 Standard_Boolean istgt;
925 tguide->D2(prm, ptgui, d1gui, d2gui);
926 tevol->D1(prm,ray,dray);
927 normtg = d1gui.Magnitude();
928 nplan = d1gui.Normalized();
929 dnplan.SetLinearForm(1./normtg, d2gui,
930 -1./normtg * (nplan.Dot(d2gui)), nplan);
932 sol(1) = prmrst1 = P.ParameterOnC1();
933 sol(2) = prmrst2 = P.ParameterOnC2();
934 pt2drst1 = rst1->Value(prmrst1);
935 pt2drst2 = rst2->Value(prmrst2);
937 Values(sol, valsol, gradsol);
939 cons1.D1(sol(1), ptrst1, d11);
940 cons2.D1(sol(2), ptrst2, d21);
942 temp.SetXYZ(ptrst1.XYZ() - ptgui.XYZ());
943 secmember(1) = normtg - dnplan.Dot(temp);
945 temp.SetXYZ(ptrst2.XYZ() - ptgui.XYZ());
946 secmember(2) = normtg - dnplan.Dot(temp);
948 math_Gauss Resol(gradsol, 1.e-9);
950 if (Resol.IsDone()) {
951 istgt = Standard_False;
952 Resol.Solve(secmember);
955 math_SVD SingRS (gradsol);
956 if (SingRS.IsDone()) {
957 math_Vector DEDT(1,2);
959 SingRS.Solve(DEDT, secmember, 1.e-6);
960 istgt = Standard_False;
962 else istgt = Standard_True;
966 gp_Vec rst1rst2(ptrst1, ptrst2);
967 Standard_Boolean IsCenter;
969 IsCenter = CenterCircleRst1Rst2(ptrst1, ptrst2, nplan, Center, med);
970 if (!IsCenter) return Standard_False;
972 normmed = med.Magnitude();
974 gp_Vec n1(Center, ptrst1), n2(Center, ptrst2);
977 // secmember contains derivatives of parameters on curves
978 // corresponding to t
979 tgrst1 = secmember(1) * d11;
980 tgrst2 = secmember(2) * d21;
984 norm2 = rst1rst2.SquareMagnitude();
985 d1rst1rst2 = tgrst2 - tgrst1;
986 Dist = ray * ray - 0.25 * norm2;
987 Standard_Real Invdray = dray / ray;
990 gp_Vec d1P1P2CrosNp, dmed;
991 d1P1P2CrosNp = d1rst1rst2.Crossed(nplan) + rst1rst2.Crossed(dnplan);
992 // derivative of the bisector
993 dmed = d1P1P2CrosNp - med.Dot(d1P1P2CrosNp) * med;
996 Standard_Real d1Dist;
998 d1Dist = (ray * dray - 0.25 * rst1rst2.Dot(d1rst1rst2) ) / Dist;
1004 // derivative of the coefficient Dist is located in dmed
1005 dmed.SetLinearForm(Dist, dmed, d1Dist, med);
1007 // derivative of the Normal to the curve in P1
1008 d1n1 = - (d1rst1rst2 + dmed + Invdray * n1) / ray;
1010 // derivative of the Normal to the curve in P2
1011 d1n2 = (d1rst1rst2 - dmed - Invdray * n2) / ray;
1015 // Normal to the curve in P1
1016 d1n1 = - (d1rst1rst2 + Invdray * n1) / ray;
1018 // Normal to the curve in P2
1019 d1n2 = (d1rst1rst2 - Invdray * n2) / ray;
1028 Poles2d(Poles2d.Lower()).SetCoord(pt2drst1.X(), pt2drst1.Y());
1029 Poles2d(Poles2d.Upper()).SetCoord(pt2drst2.X(), pt2drst2.Y());
1032 surf1->D1(pt2drst1.X(), pt2drst1.Y(), NotUsed, d1urst, d1vrst);
1033 t3dto2d(a,b,tgrst1, d1urst, d1vrst);
1034 DPoles2d(Poles2d.Lower()).SetCoord(a, b);
1036 surf2->D1(pt2drst2.X(), pt2drst2.Y(), NotUsed, d1urst, d1vrst);
1037 t3dto2d(a, b, tgrst2, d1urst, d1vrst);
1038 DPoles2d(Poles2d.Upper()).SetCoord(a, b);
1042 if (mySShape == BlendFunc_Linear) {
1043 Poles(low) = ptrst1;
1044 Poles(upp) = ptrst2;
1048 DPoles(low) = tgrst1;
1049 DPoles(upp) = tgrst2;
1050 DWeights(low) = 0.0;
1051 DWeights(upp) = 0.0;
1056 // Case of the circle
1057 // tangent to the center of the circle
1059 tgct.SetLinearForm(-ray, d1n1, -dray, n1, tgrst1);
1069 return GeomFill::GetCircle(myTConv,
1083 GeomFill::GetCircle(myTConv,
1085 nplan, ptrst1, ptrst2,
1088 return Standard_False;
1092 //=======================================================================
1093 //function : Section
1095 //=======================================================================
1097 Standard_Boolean BRepBlend_RstRstEvolRad::Section
1098 (const Blend_Point&,
1099 TColgp_Array1OfPnt&,
1100 TColgp_Array1OfVec&,
1101 TColgp_Array1OfVec&,
1102 TColgp_Array1OfPnt2d&,
1103 TColgp_Array1OfVec2d&,
1104 TColgp_Array1OfVec2d&,
1105 TColStd_Array1OfReal&,
1106 TColStd_Array1OfReal&,
1107 TColStd_Array1OfReal&)
1109 return Standard_False;
1113 void BRepBlend_RstRstEvolRad::Resolution(const Standard_Integer IC2d,
1114 const Standard_Real Tol,
1115 Standard_Real& TolU,
1116 Standard_Real& TolV) const
1119 TolU = surf1->UResolution(Tol);
1120 TolV = surf1->VResolution(Tol);
1123 TolU = surf2->UResolution(Tol);
1124 TolV = surf2->VResolution(Tol);