1 // File: BRepBlend_SurfRstConstRad.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_SurfRstConstRad.ixx>
8 #include <math_Gauss.hxx>
9 #include <math_SVD.hxx>
13 #include <BlendFunc.hxx>
14 #include <GeomFill.hxx>
15 #include <Standard_DomainError.hxx>
16 #include <Standard_NotImplemented.hxx>
17 #include <Precision.hxx>
21 static void t3dto2d(Standard_Real& a,
27 Standard_Real AB = A.Dot(B);
28 Standard_Real AC = A.Dot(C);
29 Standard_Real BC = B.Dot(C);
30 Standard_Real BB = B.Dot(B);
31 Standard_Real CC = C.Dot(C);
32 Standard_Real deno = (BB*CC-BC*BC);
33 a = (AB*CC-AC*BC)/deno;
34 b = (AC*BB-AB*BC)/deno;
37 //=======================================================================
38 //function : BRepBlend_SurfRstConstRad
40 //=======================================================================
42 BRepBlend_SurfRstConstRad::BRepBlend_SurfRstConstRad
43 (const Handle(Adaptor3d_HSurface)& Surf,
44 const Handle(Adaptor3d_HSurface)& SurfRst,
45 const Handle(Adaptor2d_HCurve2d)& Rst,
46 const Handle(Adaptor3d_HCurve)& CGuide):
47 surf(Surf), surfrst(SurfRst), rst(Rst), cons(Rst,SurfRst),
48 guide(CGuide), tguide(CGuide),
49 istangent(Standard_True), theD(0.), maxang(RealFirst()), minang(RealLast()),
51 mySShape(BlendFunc_Rational)
54 //=======================================================================
55 //function : NbVariables
57 //=======================================================================
59 Standard_Integer BRepBlend_SurfRstConstRad::NbVariables() const
64 //=======================================================================
65 //function : NbEquations
67 //=======================================================================
69 Standard_Integer BRepBlend_SurfRstConstRad::NbEquations() const
74 //=======================================================================
77 //=======================================================================
79 Standard_Boolean BRepBlend_SurfRstConstRad::Value(const math_Vector& X,
82 gp_Vec d1u1,d1v1,ns,vref;
85 surf->D1(X(1),X(2),pts,d1u1,d1v1);
86 ptrst = cons.Value(X(3));
88 F(1) = nplan.XYZ().Dot(pts.XYZ()) + theD;
89 F(2) = nplan.XYZ().Dot(ptrst.XYZ()) + theD;
91 ns = d1u1.Crossed(d1v1);
92 norm = nplan.Crossed(ns).Magnitude();
93 ns.SetLinearForm(nplan.Dot(ns)/norm,nplan, -1./norm,ns);
94 vref.SetLinearForm(ray,ns,gp_Vec(ptrst,pts));
96 F(3) = (vref.SquareMagnitude() - 1)*ray*ray;
100 //=======================================================================
101 //function : Derivatives
103 //=======================================================================
105 Standard_Boolean BRepBlend_SurfRstConstRad::Derivatives(const math_Vector& X,
108 gp_Vec d1u1,d1v1,d2u1,d2v1,d2uv1,d1;
109 gp_Vec ns,ncrossns,resul,temp, vref;
111 Standard_Real norm,ndotns,grosterme;
113 surf->D2(X(1),X(2),pts,d1u1,d1v1,d2u1,d2v1,d2uv1);
114 cons.D1(X(3),ptrst,d1);
116 D(1,1) = nplan.Dot(d1u1);
117 D(1,2) = nplan.Dot(d1v1);
122 D(2,3) = nplan.Dot(d1);
125 ns = d1u1.Crossed(d1v1);
126 ncrossns = nplan.Crossed(ns);
127 norm = ncrossns.Magnitude();
128 ndotns = nplan.Dot(ns);
130 vref.SetLinearForm(ndotns,nplan,-1.,ns);
132 vref.SetLinearForm(ray,vref,gp_Vec(ptrst,pts));
135 temp = d2u1.Crossed(d1v1).Added(d1u1.Crossed(d2uv1));
136 grosterme = ncrossns.Dot(nplan.Crossed(temp))/norm/norm;
137 resul.SetLinearForm(-ray/norm*(grosterme*ndotns-nplan.Dot(temp)),nplan,
138 ray*grosterme/norm,ns,
142 D(3,1) = resul.Dot(vref);
143 D(3,1) = D(3,1) * 2.;
147 temp = d2uv1.Crossed(d1v1).Added(d1u1.Crossed(d2v1));
148 grosterme = ncrossns.Dot(nplan.Crossed(temp))/norm/norm;
149 resul.SetLinearForm(-ray/norm*(grosterme*ndotns-nplan.Dot(temp)),nplan,
150 ray*grosterme/norm,ns,
154 D(3,2) = resul.Dot(vref);
155 D(3,2) = D(3,2) * 2.;
157 D(3,3) = d1.Dot(vref);
158 D(3,3) = D(3,3) * (-2.);
160 return Standard_True;
163 //=======================================================================
166 //=======================================================================
168 Standard_Boolean BRepBlend_SurfRstConstRad::Values(const math_Vector& X,
173 gp_Vec d2u1,d2v1,d2uv1;
174 gp_Vec ns,ncrossns,resul,temp,vref;
176 Standard_Real norm,ndotns,grosterme;
178 surf->D2(X(1),X(2),pts,d1u1,d1v1,d2u1,d2v1,d2uv1);
179 cons.D1(X(3),ptrst,d1);
181 F(1) = nplan.XYZ().Dot(pts.XYZ()) + theD;
182 F(2) = nplan.XYZ().Dot(ptrst.XYZ()) + theD;
184 D(1,1) = nplan.Dot(d1u1);
185 D(1,2) = nplan.Dot(d1v1);
190 D(2,3) = nplan.Dot(d1);
192 ns = d1u1.Crossed(d1v1);
193 ncrossns = nplan.Crossed(ns);
194 norm = ncrossns.Magnitude();
195 ndotns = nplan.Dot(ns);
197 vref.SetLinearForm(ndotns,nplan,-1.,ns);
199 vref.SetLinearForm(ray,vref,gp_Vec(ptrst,pts));
202 // F(3) = vref.SquareMagnitude() - ray*ray;
203 F(3) = (temp.SquareMagnitude() - 1)*ray*ray; // more stable numerically
206 temp = d2u1.Crossed(d1v1).Added(d1u1.Crossed(d2uv1));
207 grosterme = ncrossns.Dot(nplan.Crossed(temp))/norm/norm;
208 resul.SetLinearForm(-ray/norm*(grosterme*ndotns-nplan.Dot(temp)),nplan,
209 ray*grosterme/norm,ns,
213 D(3,1) = resul.Dot(vref);
219 temp = d2uv1.Crossed(d1v1).Added(d1u1.Crossed(d2v1));
220 grosterme = ncrossns.Dot(nplan.Crossed(temp))/norm/norm;
221 resul.SetLinearForm(-ray/norm*(grosterme*ndotns-nplan.Dot(temp)),nplan,
222 ray*grosterme/norm,ns,
226 D(3,2) = resul.Dot(vref);
229 D(3,3) = d1.Dot(vref);
230 D(3,3) = D(3,3)*(-2.);
232 return Standard_True;
235 //=======================================================================
238 //=======================================================================
240 void BRepBlend_SurfRstConstRad::Set(const Handle(Adaptor3d_HSurface)& SurfRef,
241 const Handle(Adaptor2d_HCurve2d)& RstRef)
247 //=======================================================================
250 //=======================================================================
252 void BRepBlend_SurfRstConstRad::Set(const Standard_Real Param)
254 d1gui = gp_Vec(0.,0.,0.);
255 nplan = gp_Vec(0.,0.,0.);
256 tguide->D2(Param,ptgui,d1gui,d2gui);
257 normtg = d1gui.Magnitude();
258 nplan.SetXYZ(d1gui.Normalized().XYZ());
259 gp_XYZ nplanXYZ(nplan.XYZ());
260 gp_XYZ ptguiXYZ(ptgui.XYZ());
261 theD = nplanXYZ.Dot(ptguiXYZ) ;
262 theD = theD * (-1.) ;
265 //=======================================================================
268 //=======================================================================
270 void BRepBlend_SurfRstConstRad::Set(const Standard_Real First,
271 const Standard_Real Last)
273 tguide = guide->Trim(First, Last, 1.e-12);
276 //=======================================================================
277 //function : GetTolerance
279 //=======================================================================
281 void BRepBlend_SurfRstConstRad::GetTolerance(math_Vector& Tolerance,
282 const Standard_Real Tol) const
284 Tolerance(1) = surf->UResolution(Tol);
285 Tolerance(2) = surf->VResolution(Tol);
286 Tolerance(3) = cons.Resolution(Tol);
289 //=======================================================================
290 //function : GetBounds
292 //=======================================================================
294 void BRepBlend_SurfRstConstRad::GetBounds(math_Vector& InfBound,
295 math_Vector& SupBound) const
297 InfBound(1) = surf->FirstUParameter();
298 InfBound(2) = surf->FirstVParameter();
299 InfBound(3) = cons.FirstParameter();
300 SupBound(1) = surf->LastUParameter();
301 SupBound(2) = surf->LastVParameter();
302 SupBound(3) = cons.LastParameter();
304 if(!Precision::IsInfinite(InfBound(1)) &&
305 !Precision::IsInfinite(SupBound(1))) {
306 Standard_Real range = (SupBound(1) - InfBound(1));
307 InfBound(1) -= range;
308 SupBound(1) += range;
310 if(!Precision::IsInfinite(InfBound(2)) &&
311 !Precision::IsInfinite(SupBound(2))) {
312 Standard_Real range = (SupBound(2) - InfBound(2));
313 InfBound(2) -= range;
314 SupBound(2) += range;
318 //=======================================================================
319 //function : IsSolution
321 //=======================================================================
323 Standard_Boolean BRepBlend_SurfRstConstRad::IsSolution(const math_Vector& Sol,
324 const Standard_Real Tol)
328 math_Vector valsol(1,3),secmember(1,3);
329 math_Matrix gradsol(1,3,1,3);
331 gp_Vec dnplan,d1u1,d1v1,d1urst,d1vrst,d1,temp,ns,ns2,ncrossns,resul;
333 Standard_Real norm,ndotns,grosterme;
334 Standard_Real Cosa,Sina,Angle;
336 Values(Sol,valsol,gradsol);
337 if (Abs(valsol(1)) <= Tol &&
338 Abs(valsol(2)) <= Tol &&
339 Abs(valsol(3)) <= 2*Tol*Abs(ray) ) {
341 // Calculation of tangents
343 pt2ds = gp_Pnt2d(Sol(1),Sol(2));
345 pt2drst = rst->Value(prmrst);
346 surf->D1(Sol(1),Sol(2),pts,d1u1,d1v1);
347 cons.D1(Sol(3),ptrst,d1);
348 dnplan.SetLinearForm(1./normtg,d2gui,
349 -1./normtg*(nplan.Dot(d2gui)),nplan);
351 temp.SetXYZ(pts.XYZ() - ptgui.XYZ());
352 secmember(1) = normtg - dnplan.Dot(temp);
354 temp.SetXYZ(ptrst.XYZ() - ptgui.XYZ());
355 secmember(2) = normtg - dnplan.Dot(temp);
357 ns = d1u1.Crossed(d1v1);
358 ncrossns = nplan.Crossed(ns);
359 ndotns = nplan.Dot(ns);
360 norm = ncrossns.Magnitude();
362 grosterme = ncrossns.Dot(dnplan.Crossed(ns))/norm/norm;
363 temp.SetLinearForm(ray/norm*(dnplan.Dot(ns)-grosterme*ndotns),nplan,
364 ray*ndotns/norm,dnplan,
365 ray*grosterme/norm,ns);
367 ns.SetLinearForm(ndotns/norm,nplan, -1./norm,ns);
368 resul.SetLinearForm(ray,ns,gp_Vec(ptrst,pts));
369 secmember(3) = -2.*(temp.Dot(resul));
371 math_Gauss Resol(gradsol);
372 if (Resol.IsDone()) {
373 Resol.Solve(secmember);
374 istangent = Standard_False;
377 math_SVD SingRS (gradsol);
378 if (SingRS.IsDone()) {
379 math_Vector DEDT(1,3);
381 SingRS.Solve(DEDT, secmember, 1.e-6);
382 istangent = Standard_False;
384 else istangent = Standard_True;
388 tgs.SetLinearForm(secmember(1),d1u1,secmember(2),d1v1);
389 tgrst = secmember(3)*d1;
390 tg2ds.SetCoord(secmember(1),secmember(2));
391 surfrst->D1(pt2drst.X(),pt2drst.Y(),bid,d1urst,d1vrst);
393 t3dto2d(a,b,tgrst,d1urst,d1vrst);
394 tg2drst.SetCoord(a,b);
398 if(ray>0.) ns.Reverse();
399 ns2 = -resul.Normalized();
402 Sina = nplan.Dot(ns.Crossed(ns2));
404 Sina = -Sina; //nplan is changed to -nplan
409 Angle = 2.*PI - Angle;
412 if (Angle>maxang) {maxang = Angle;}
413 if (Angle<minang) {minang = Angle;}
414 distmin = Min( distmin, pts.Distance(ptrst));
416 return Standard_True;
418 istangent = Standard_True;
419 return Standard_False;
422 //=======================================================================
423 //function : GetMinimalDistance
425 //=======================================================================
427 Standard_Real BRepBlend_SurfRstConstRad::GetMinimalDistance() const
432 //=======================================================================
433 //function : PointOnS
435 //=======================================================================
437 const gp_Pnt& BRepBlend_SurfRstConstRad::PointOnS() const
442 //=======================================================================
443 //function : PointOnRst
445 //=======================================================================
447 const gp_Pnt& BRepBlend_SurfRstConstRad::PointOnRst() const
452 //=======================================================================
453 //function : Pnt2dOnS
455 //=======================================================================
457 const gp_Pnt2d& BRepBlend_SurfRstConstRad::Pnt2dOnS() const
462 //=======================================================================
463 //function : Pnt2dOnRst
465 //=======================================================================
467 const gp_Pnt2d& BRepBlend_SurfRstConstRad::Pnt2dOnRst() const
472 //=======================================================================
473 //function : ParameterOnRst
475 //=======================================================================
477 Standard_Real BRepBlend_SurfRstConstRad::ParameterOnRst() const
482 //=======================================================================
483 //function : IsTangencyPoint
485 //=======================================================================
487 Standard_Boolean BRepBlend_SurfRstConstRad::IsTangencyPoint() const
492 //=======================================================================
493 //function : TangentOnS
495 //=======================================================================
497 const gp_Vec& BRepBlend_SurfRstConstRad::TangentOnS() const
499 if (istangent) {Standard_DomainError::Raise();}
503 //=======================================================================
504 //function : Tangent2dOnS
506 //=======================================================================
508 const gp_Vec2d& BRepBlend_SurfRstConstRad::Tangent2dOnS() const
510 if (istangent) {Standard_DomainError::Raise();}
514 //=======================================================================
515 //function : TangentOnRst
517 //=======================================================================
519 const gp_Vec& BRepBlend_SurfRstConstRad::TangentOnRst() const
521 if (istangent) {Standard_DomainError::Raise();}
525 //=======================================================================
526 //function : Tangent2dOnRst
528 //=======================================================================
530 const gp_Vec2d& BRepBlend_SurfRstConstRad::Tangent2dOnRst() const
532 if (istangent) {Standard_DomainError::Raise();}
536 //=======================================================================
539 //=======================================================================
541 Standard_Boolean BRepBlend_SurfRstConstRad::Decroch(const math_Vector& Sol,
545 gp_Vec TgRst, NRst, NRstInPlane, NSInPlane;
548 Standard_Real norm,unsurnorm;
550 surf->D1(Sol(1),Sol(2),bid,d1u,d1v);
551 NS = NSInPlane = d1u.Crossed(d1v);
553 norm = nplan.Crossed(NS).Magnitude();
555 NSInPlane.SetLinearForm(nplan.Dot(NS)*unsurnorm,nplan,-unsurnorm,NS);
557 Center.SetXYZ(bid.XYZ()+ray*NSInPlane.XYZ());
558 if(choix>2) NSInPlane.Reverse();
559 TgS = nplan.Crossed(gp_Vec(Center,bid));
564 rstref->Value(Sol(3)).Coord(u,v);
565 surfref->D1(u,v,bid,d1u,d1v);
566 NRst = d1u.Crossed(d1v);
567 norm = nplan.Crossed(NRst).Magnitude();
569 NRstInPlane.SetLinearForm(nplan.Dot(NRst)*unsurnorm,nplan,-unsurnorm,NRst);
570 gp_Vec centptrst(Center,bid);
571 if(centptrst.Dot(NRstInPlane) < 0.) NRstInPlane.Reverse();
572 TgRst = nplan.Crossed(centptrst);
577 Standard_Real dot, NT = NRstInPlane.Magnitude();
578 NT *= TgRst.Magnitude();
579 if (Abs(NT) < 1.e-7) {
580 return Standard_False; // Singularity or Incoherence.
582 dot = NRstInPlane.Dot(TgRst);
585 return (dot < 1.e-10);
588 //=======================================================================
591 //=======================================================================
593 void BRepBlend_SurfRstConstRad::Set(const Standard_Real Radius,
594 const Standard_Integer Choix)
612 //=======================================================================
615 //=======================================================================
617 void BRepBlend_SurfRstConstRad::Set(const BlendFunc_SectionShape TypeSection)
619 mySShape = TypeSection;
622 //=======================================================================
625 //=======================================================================
627 void BRepBlend_SurfRstConstRad::Section(const Standard_Real Param,
628 const Standard_Real U,
629 const Standard_Real V,
630 const Standard_Real W,
640 tguide->D1(Param,ptgui,d1gui);
641 np = d1gui.Normalized();
643 surf->D1(U,V,pts,d1u1,d1v1);
644 ptrst = cons.Value(W);
646 ns = d1u1.Crossed(d1v1);
648 norm = nplan.Crossed(ns).Magnitude();
649 ns.SetLinearForm(nplan.Dot(ns)/norm,nplan, -1./norm,ns);
650 Center.SetXYZ(pts.XYZ()+ray*ns.XYZ());
651 C.SetRadius(Abs(ray));
661 C.SetPosition(gp_Ax2(Center,np,ns));
662 Pdeb = 0; //ElCLib::Parameter(C,pts);
663 Pfin = ElCLib::Parameter(C,ptrst);
665 // Test negative and almost null angles : Special case
668 C.SetPosition(gp_Ax2(Center,np,ns));
669 Pfin = ElCLib::Parameter(C,ptrst);
671 if (Pfin < Precision::PConfusion()) Pfin += Precision::PConfusion();
674 //=======================================================================
675 //function : IsRational
677 //=======================================================================
679 Standard_Boolean BRepBlend_SurfRstConstRad::IsRational () const
681 return (mySShape==BlendFunc_Rational || mySShape==BlendFunc_QuasiAngular);
684 //=======================================================================
685 //function : GetSectionSize
687 //=======================================================================
689 Standard_Real BRepBlend_SurfRstConstRad::GetSectionSize() const
691 return maxang*Abs(ray);
694 //=======================================================================
695 //function : GetMinimalWeight
697 //=======================================================================
699 void BRepBlend_SurfRstConstRad::GetMinimalWeight(TColStd_Array1OfReal& Weights) const
701 BlendFunc::GetMinimalWeights(mySShape, myTConv, minang, maxang, Weights );
702 // It is supposed that it does not depend on the Radius!
705 //=======================================================================
706 //function : NbIntervals
708 //=======================================================================
710 Standard_Integer BRepBlend_SurfRstConstRad::NbIntervals (const GeomAbs_Shape S) const
712 return guide->NbIntervals(BlendFunc::NextShape(S));
715 //=======================================================================
716 //function : Intervals
718 //=======================================================================
720 void BRepBlend_SurfRstConstRad::Intervals (TColStd_Array1OfReal& T,
721 const GeomAbs_Shape S) const
723 guide->Intervals(T, BlendFunc::NextShape(S));
726 //=======================================================================
727 //function : GetShape
729 //=======================================================================
731 void BRepBlend_SurfRstConstRad::GetShape (Standard_Integer& NbPoles,
732 Standard_Integer& NbKnots,
733 Standard_Integer& Degree,
734 Standard_Integer& NbPoles2d)
737 BlendFunc::GetShape(mySShape,maxang,NbPoles,NbKnots,Degree,myTConv);
740 //=======================================================================
741 //function : GetTolerance
742 //purpose : Find Tolerance to be used in approximations.
743 //=======================================================================
745 void BRepBlend_SurfRstConstRad::GetTolerance(const Standard_Real BoundTol,
746 const Standard_Real SurfTol,
747 const Standard_Real AngleTol,
749 math_Vector& Tol1d) const
751 Standard_Integer low = Tol3d.Lower() , up=Tol3d.Upper();
753 Tol= GeomFill::GetTolerance(myTConv, minang, Abs(ray),
757 Tol3d(low+1) = Tol3d(up-1) = Min( Tol, SurfTol);
758 Tol3d(low) = Tol3d(up) = Min( Tol, BoundTol);
761 //=======================================================================
764 //=======================================================================
766 void BRepBlend_SurfRstConstRad::Knots(TColStd_Array1OfReal& TKnots)
768 GeomFill::Knots(myTConv,TKnots);
771 //=======================================================================
774 //=======================================================================
776 void BRepBlend_SurfRstConstRad::Mults(TColStd_Array1OfInteger& TMults)
778 GeomFill::Mults(myTConv, TMults);
781 //=======================================================================
784 //=======================================================================
786 void BRepBlend_SurfRstConstRad::Section(const Blend_Point& P,
787 TColgp_Array1OfPnt& Poles,
788 TColgp_Array1OfPnt2d& Poles2d,
789 TColStd_Array1OfReal& Weights)
791 gp_Vec d1u1,d1v1;//,,d1;
792 gp_Vec ns,ns2;//,temp,np2;
795 Standard_Real norm,u1,v1,w;
797 Standard_Real prm = P.Parameter();
798 Standard_Integer low = Poles.Lower();
799 Standard_Integer upp = Poles.Upper();
801 tguide->D1(prm,ptgui,d1gui);
802 nplan = d1gui.Normalized();
804 P.ParametersOnS(u1,v1);
805 w = P.ParameterOnC(); //jlr : point on curve not on surface
806 gp_Pnt2d pt2d = rst->Value(w);
808 surf->D1(u1,v1,pts,d1u1,d1v1);
809 ptrst = cons.Value(w);
810 distmin = Min (distmin, pts.Distance(ptrst));
812 Poles2d(Poles2d.Lower()).SetCoord(u1,v1);
813 Poles2d(Poles2d.Upper()).SetCoord(pt2d.X(),pt2d.Y());
816 if (mySShape == BlendFunc_Linear) {
824 ns = d1u1.Crossed(d1v1);
825 norm = nplan.Crossed(ns).Magnitude();
827 ns.SetLinearForm(nplan.Dot(ns)/norm,nplan, -1./norm,ns);
829 Center.SetXYZ(pts.XYZ()+ray*ns.XYZ());
831 ns2 = gp_Vec(Center,ptrst).Normalized();
832 if(ray>0) ns.Reverse();
837 GeomFill::GetCircle(myTConv,
844 //=======================================================================
847 //=======================================================================
849 Standard_Boolean BRepBlend_SurfRstConstRad::Section
850 (const Blend_Point& P,
851 TColgp_Array1OfPnt& Poles,
852 TColgp_Array1OfVec& DPoles,
853 TColgp_Array1OfPnt2d& Poles2d,
854 TColgp_Array1OfVec2d& DPoles2d,
855 TColStd_Array1OfReal& Weights,
856 TColStd_Array1OfReal& DWeights)
859 gp_Vec d1u1,d1v1,d2u1,d2v1,d2uv1,d1;
860 gp_Vec ns,ns2,dnplan,dnw,dn2w; //,np2,dnp2;
862 gp_Vec resulu,resulv,temp,tgct,resul;
863 gp_Vec d1urst,d1vrst;
866 Standard_Real norm,ndotns,grosterme;
868 math_Vector sol(1,3),valsol(1,3),secmember(1,3);
869 math_Matrix gradsol(1,3,1,3);
871 Standard_Real prm = P.Parameter();
873 Standard_Integer NbSpan=(Poles.Length()-1)/2;
875 Standard_Integer low = Poles.Lower();
876 Standard_Integer upp = Poles.Upper();
877 Standard_Boolean istgt;
879 tguide->D2(prm,ptgui,d1gui,d2gui);
880 normtg = d1gui.Magnitude();
881 nplan = d1gui.Normalized();
882 dnplan.SetLinearForm(1./normtg,d2gui,
883 -1./normtg*(nplan.Dot(d2gui)),nplan);
885 P.ParametersOnS(sol(1),sol(2));
886 sol(3) = prmrst = P.ParameterOnC();
887 pt2drst = rst->Value(prmrst);
889 Values(sol,valsol,gradsol);
891 surf->D2(sol(1),sol(2),pts,d1u1,d1v1,d2u1,d2v1,d2uv1);
892 cons.D1(sol(3),ptrst,d1);
894 temp.SetXYZ(pts.XYZ()- ptgui.XYZ());
895 secmember(1) = normtg - dnplan.Dot(temp);
897 temp.SetXYZ(ptrst.XYZ()- ptgui.XYZ());
898 secmember(2) = normtg - dnplan.Dot(temp);
900 ns = d1u1.Crossed(d1v1);
901 ncrossns = nplan.Crossed(ns);
902 ndotns = nplan.Dot(ns);
903 norm = ncrossns.Magnitude();
905 norm = 1; // Not enough, but it is not necessary to stop
907 cout << " SurfRstConstRad : Singular Surface " << endl;
911 // Derivative of n1 corresponding to w
913 grosterme = ncrossns.Dot(dnplan.Crossed(ns))/norm/norm;
914 dnw.SetLinearForm((dnplan.Dot(ns)-grosterme*ndotns)/norm,nplan,
918 temp.SetLinearForm(ndotns/norm,nplan, -1./norm,ns);
919 resul.SetLinearForm(ray,temp,gp_Vec(ptrst,pts));
920 secmember(3) = dnw.Dot(resul);
921 secmember(3) = -2.*ray*secmember(3);
923 math_Gauss Resol(gradsol, 1.e-9);
926 if (Resol.IsDone()) {
927 istgt = Standard_False;
928 Resol.Solve(secmember);
931 math_SVD SingRS (gradsol);
932 if (SingRS.IsDone()) {
933 math_Vector DEDT(1,3);
935 SingRS.Solve(DEDT, secmember, 1.e-6);
936 istgt = Standard_False;
938 else istgt = Standard_True;
942 tgs.SetLinearForm(secmember(1),d1u1,secmember(2),d1v1);
943 tgrst = secmember(3)*d1;
945 // Derivative of n1 corresponding to u1
946 temp = d2u1.Crossed(d1v1).Added(d1u1.Crossed(d2uv1));
947 grosterme = ncrossns.Dot(nplan.Crossed(temp))/norm/norm;
948 resulu.SetLinearForm(-(grosterme*ndotns-nplan.Dot(temp))/norm,nplan,
952 // Derivative of n1 corresponding to v1
953 temp = d2uv1.Crossed(d1v1).Added(d1u1.Crossed(d2v1));
954 grosterme = ncrossns.Dot(nplan.Crossed(temp))/norm/norm;
955 resulv.SetLinearForm(-(grosterme*ndotns-nplan.Dot(temp))/norm,nplan,
960 dnw.SetLinearForm(secmember(1),resulu,secmember(2),resulv,dnw);
961 ns.SetLinearForm(ndotns/norm,nplan, -1./norm,ns);
963 dn2w.SetLinearForm(ray, dnw, -1., tgrst, tgs);
964 norm = resul.Magnitude();
966 ns2 = -resul.Normalized();
967 dn2w.SetLinearForm(ns2.Dot(dn2w),ns2,-1.,dn2w);
970 ns.SetLinearForm(ndotns/norm,nplan, -1./norm,ns);
971 ns2 = -resul.Normalized();
976 Poles2d(Poles2d.Lower()).SetCoord(sol(1),sol(2));
977 Poles2d(Poles2d.Upper()).SetCoord(pt2drst.X(),pt2drst.Y());
979 DPoles2d(Poles2d.Lower()).SetCoord(secmember(1),secmember(2));
980 surfrst->D1(pt2drst.X(),pt2drst.Y(),bid,d1urst,d1vrst);
982 t3dto2d(a,b,tgrst,d1urst,d1vrst);
983 DPoles2d(Poles2d.Upper()).SetCoord(a,b);
987 if (mySShape == BlendFunc_Linear) {
1001 // Case of the circle
1002 Center.SetXYZ(pts.XYZ()+ray*ns.XYZ());
1004 tgct = tgs.Added(ray*dnw);
1018 return GeomFill::GetCircle(myTConv,
1032 GeomFill::GetCircle(myTConv,
1037 return Standard_False;
1041 //=======================================================================
1042 //function : Section
1044 //=======================================================================
1046 Standard_Boolean BRepBlend_SurfRstConstRad::Section
1047 (const Blend_Point&,
1048 TColgp_Array1OfPnt&,
1049 TColgp_Array1OfVec&,
1050 TColgp_Array1OfVec&,
1051 TColgp_Array1OfPnt2d&,
1052 TColgp_Array1OfVec2d&,
1053 TColgp_Array1OfVec2d&,
1054 TColStd_Array1OfReal&,
1055 TColStd_Array1OfReal&,
1056 TColStd_Array1OfReal&)
1058 return Standard_False;
1061 void BRepBlend_SurfRstConstRad::Resolution(const Standard_Integer IC2d,
1062 const Standard_Real Tol,
1063 Standard_Real& TolU,
1064 Standard_Real& TolV) const
1067 TolU = surf->UResolution(Tol);
1068 TolV = surf->VResolution(Tol);
1071 TolU = surfrst->UResolution(Tol);
1072 TolV = surfrst->VResolution(Tol);