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 under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepBlend_SurfRstConstRad.ixx>
18 #include <math_Gauss.hxx>
19 #include <math_SVD.hxx>
23 #include <BlendFunc.hxx>
24 #include <GeomFill.hxx>
25 #include <Standard_DomainError.hxx>
26 #include <Standard_NotImplemented.hxx>
27 #include <Precision.hxx>
31 static void t3dto2d(Standard_Real& a,
37 Standard_Real AB = A.Dot(B);
38 Standard_Real AC = A.Dot(C);
39 Standard_Real BC = B.Dot(C);
40 Standard_Real BB = B.Dot(B);
41 Standard_Real CC = C.Dot(C);
42 Standard_Real deno = (BB*CC-BC*BC);
43 a = (AB*CC-AC*BC)/deno;
44 b = (AC*BB-AB*BC)/deno;
47 //=======================================================================
48 //function : BRepBlend_SurfRstConstRad
50 //=======================================================================
52 BRepBlend_SurfRstConstRad::BRepBlend_SurfRstConstRad
53 (const Handle(Adaptor3d_HSurface)& Surf,
54 const Handle(Adaptor3d_HSurface)& SurfRst,
55 const Handle(Adaptor2d_HCurve2d)& Rst,
56 const Handle(Adaptor3d_HCurve)& CGuide):
57 surf(Surf), surfrst(SurfRst), rst(Rst), cons(Rst,SurfRst),
58 guide(CGuide), tguide(CGuide),
59 istangent(Standard_True), theD(0.), maxang(RealFirst()), minang(RealLast()),
61 mySShape(BlendFunc_Rational)
64 //=======================================================================
65 //function : NbVariables
67 //=======================================================================
69 Standard_Integer BRepBlend_SurfRstConstRad::NbVariables() const
74 //=======================================================================
75 //function : NbEquations
77 //=======================================================================
79 Standard_Integer BRepBlend_SurfRstConstRad::NbEquations() const
84 //=======================================================================
87 //=======================================================================
89 Standard_Boolean BRepBlend_SurfRstConstRad::Value(const math_Vector& X,
92 gp_Vec d1u1,d1v1,ns,vref;
95 surf->D1(X(1),X(2),pts,d1u1,d1v1);
96 ptrst = cons.Value(X(3));
98 F(1) = nplan.XYZ().Dot(pts.XYZ()) + theD;
99 F(2) = nplan.XYZ().Dot(ptrst.XYZ()) + theD;
101 ns = d1u1.Crossed(d1v1);
102 norm = nplan.Crossed(ns).Magnitude();
103 ns.SetLinearForm(nplan.Dot(ns)/norm,nplan, -1./norm,ns);
104 vref.SetLinearForm(ray,ns,gp_Vec(ptrst,pts));
106 F(3) = (vref.SquareMagnitude() - 1)*ray*ray;
107 return Standard_True;
110 //=======================================================================
111 //function : Derivatives
113 //=======================================================================
115 Standard_Boolean BRepBlend_SurfRstConstRad::Derivatives(const math_Vector& X,
118 gp_Vec d1u1,d1v1,d2u1,d2v1,d2uv1,d1;
119 gp_Vec ns,ncrossns,resul,temp, vref;
121 Standard_Real norm,ndotns,grosterme;
123 surf->D2(X(1),X(2),pts,d1u1,d1v1,d2u1,d2v1,d2uv1);
124 cons.D1(X(3),ptrst,d1);
126 D(1,1) = nplan.Dot(d1u1);
127 D(1,2) = nplan.Dot(d1v1);
132 D(2,3) = nplan.Dot(d1);
135 ns = d1u1.Crossed(d1v1);
136 ncrossns = nplan.Crossed(ns);
137 norm = ncrossns.Magnitude();
138 ndotns = nplan.Dot(ns);
140 vref.SetLinearForm(ndotns,nplan,-1.,ns);
142 vref.SetLinearForm(ray,vref,gp_Vec(ptrst,pts));
145 temp = d2u1.Crossed(d1v1).Added(d1u1.Crossed(d2uv1));
146 grosterme = ncrossns.Dot(nplan.Crossed(temp))/norm/norm;
147 resul.SetLinearForm(-ray/norm*(grosterme*ndotns-nplan.Dot(temp)),nplan,
148 ray*grosterme/norm,ns,
152 D(3,1) = resul.Dot(vref);
153 D(3,1) = D(3,1) * 2.;
157 temp = d2uv1.Crossed(d1v1).Added(d1u1.Crossed(d2v1));
158 grosterme = ncrossns.Dot(nplan.Crossed(temp))/norm/norm;
159 resul.SetLinearForm(-ray/norm*(grosterme*ndotns-nplan.Dot(temp)),nplan,
160 ray*grosterme/norm,ns,
164 D(3,2) = resul.Dot(vref);
165 D(3,2) = D(3,2) * 2.;
167 D(3,3) = d1.Dot(vref);
168 D(3,3) = D(3,3) * (-2.);
170 return Standard_True;
173 //=======================================================================
176 //=======================================================================
178 Standard_Boolean BRepBlend_SurfRstConstRad::Values(const math_Vector& X,
183 gp_Vec d2u1,d2v1,d2uv1;
184 gp_Vec ns,ncrossns,resul,temp,vref;
186 Standard_Real norm,ndotns,grosterme;
188 surf->D2(X(1),X(2),pts,d1u1,d1v1,d2u1,d2v1,d2uv1);
189 cons.D1(X(3),ptrst,d1);
191 F(1) = nplan.XYZ().Dot(pts.XYZ()) + theD;
192 F(2) = nplan.XYZ().Dot(ptrst.XYZ()) + theD;
194 D(1,1) = nplan.Dot(d1u1);
195 D(1,2) = nplan.Dot(d1v1);
200 D(2,3) = nplan.Dot(d1);
202 ns = d1u1.Crossed(d1v1);
203 ncrossns = nplan.Crossed(ns);
204 norm = ncrossns.Magnitude();
205 ndotns = nplan.Dot(ns);
207 vref.SetLinearForm(ndotns,nplan,-1.,ns);
209 vref.SetLinearForm(ray,vref,gp_Vec(ptrst,pts));
212 // F(3) = vref.SquareMagnitude() - ray*ray;
213 F(3) = (temp.SquareMagnitude() - 1)*ray*ray; // more stable numerically
216 temp = d2u1.Crossed(d1v1).Added(d1u1.Crossed(d2uv1));
217 grosterme = ncrossns.Dot(nplan.Crossed(temp))/norm/norm;
218 resul.SetLinearForm(-ray/norm*(grosterme*ndotns-nplan.Dot(temp)),nplan,
219 ray*grosterme/norm,ns,
223 D(3,1) = resul.Dot(vref);
229 temp = d2uv1.Crossed(d1v1).Added(d1u1.Crossed(d2v1));
230 grosterme = ncrossns.Dot(nplan.Crossed(temp))/norm/norm;
231 resul.SetLinearForm(-ray/norm*(grosterme*ndotns-nplan.Dot(temp)),nplan,
232 ray*grosterme/norm,ns,
236 D(3,2) = resul.Dot(vref);
239 D(3,3) = d1.Dot(vref);
240 D(3,3) = D(3,3)*(-2.);
242 return Standard_True;
245 //=======================================================================
248 //=======================================================================
250 void BRepBlend_SurfRstConstRad::Set(const Handle(Adaptor3d_HSurface)& SurfRef,
251 const Handle(Adaptor2d_HCurve2d)& RstRef)
257 //=======================================================================
260 //=======================================================================
262 void BRepBlend_SurfRstConstRad::Set(const Standard_Real Param)
264 d1gui = gp_Vec(0.,0.,0.);
265 nplan = gp_Vec(0.,0.,0.);
266 tguide->D2(Param,ptgui,d1gui,d2gui);
267 normtg = d1gui.Magnitude();
268 nplan.SetXYZ(d1gui.Normalized().XYZ());
269 gp_XYZ nplanXYZ(nplan.XYZ());
270 gp_XYZ ptguiXYZ(ptgui.XYZ());
271 theD = nplanXYZ.Dot(ptguiXYZ) ;
272 theD = theD * (-1.) ;
275 //=======================================================================
278 //=======================================================================
280 void BRepBlend_SurfRstConstRad::Set(const Standard_Real First,
281 const Standard_Real Last)
283 tguide = guide->Trim(First, Last, 1.e-12);
286 //=======================================================================
287 //function : GetTolerance
289 //=======================================================================
291 void BRepBlend_SurfRstConstRad::GetTolerance(math_Vector& Tolerance,
292 const Standard_Real Tol) const
294 Tolerance(1) = surf->UResolution(Tol);
295 Tolerance(2) = surf->VResolution(Tol);
296 Tolerance(3) = cons.Resolution(Tol);
299 //=======================================================================
300 //function : GetBounds
302 //=======================================================================
304 void BRepBlend_SurfRstConstRad::GetBounds(math_Vector& InfBound,
305 math_Vector& SupBound) const
307 InfBound(1) = surf->FirstUParameter();
308 InfBound(2) = surf->FirstVParameter();
309 InfBound(3) = cons.FirstParameter();
310 SupBound(1) = surf->LastUParameter();
311 SupBound(2) = surf->LastVParameter();
312 SupBound(3) = cons.LastParameter();
314 if(!Precision::IsInfinite(InfBound(1)) &&
315 !Precision::IsInfinite(SupBound(1))) {
316 Standard_Real range = (SupBound(1) - InfBound(1));
317 InfBound(1) -= range;
318 SupBound(1) += range;
320 if(!Precision::IsInfinite(InfBound(2)) &&
321 !Precision::IsInfinite(SupBound(2))) {
322 Standard_Real range = (SupBound(2) - InfBound(2));
323 InfBound(2) -= range;
324 SupBound(2) += range;
328 //=======================================================================
329 //function : IsSolution
331 //=======================================================================
333 Standard_Boolean BRepBlend_SurfRstConstRad::IsSolution(const math_Vector& Sol,
334 const Standard_Real Tol)
338 math_Vector valsol(1,3),secmember(1,3);
339 math_Matrix gradsol(1,3,1,3);
341 gp_Vec dnplan,d1u1,d1v1,d1urst,d1vrst,d1,temp,ns,ns2,ncrossns,resul;
343 Standard_Real norm,ndotns,grosterme;
344 Standard_Real Cosa,Sina,Angle;
346 Values(Sol,valsol,gradsol);
347 if (Abs(valsol(1)) <= Tol &&
348 Abs(valsol(2)) <= Tol &&
349 Abs(valsol(3)) <= 2*Tol*Abs(ray) ) {
351 // Calculation of tangents
353 pt2ds = gp_Pnt2d(Sol(1),Sol(2));
355 pt2drst = rst->Value(prmrst);
356 surf->D1(Sol(1),Sol(2),pts,d1u1,d1v1);
357 cons.D1(Sol(3),ptrst,d1);
358 dnplan.SetLinearForm(1./normtg,d2gui,
359 -1./normtg*(nplan.Dot(d2gui)),nplan);
361 temp.SetXYZ(pts.XYZ() - ptgui.XYZ());
362 secmember(1) = normtg - dnplan.Dot(temp);
364 temp.SetXYZ(ptrst.XYZ() - ptgui.XYZ());
365 secmember(2) = normtg - dnplan.Dot(temp);
367 ns = d1u1.Crossed(d1v1);
368 ncrossns = nplan.Crossed(ns);
369 ndotns = nplan.Dot(ns);
370 norm = ncrossns.Magnitude();
372 grosterme = ncrossns.Dot(dnplan.Crossed(ns))/norm/norm;
373 temp.SetLinearForm(ray/norm*(dnplan.Dot(ns)-grosterme*ndotns),nplan,
374 ray*ndotns/norm,dnplan,
375 ray*grosterme/norm,ns);
377 ns.SetLinearForm(ndotns/norm,nplan, -1./norm,ns);
378 resul.SetLinearForm(ray,ns,gp_Vec(ptrst,pts));
379 secmember(3) = -2.*(temp.Dot(resul));
381 math_Gauss Resol(gradsol);
382 if (Resol.IsDone()) {
383 Resol.Solve(secmember);
384 istangent = Standard_False;
387 math_SVD SingRS (gradsol);
388 if (SingRS.IsDone()) {
389 math_Vector DEDT(1,3);
391 SingRS.Solve(DEDT, secmember, 1.e-6);
392 istangent = Standard_False;
394 else istangent = Standard_True;
398 tgs.SetLinearForm(secmember(1),d1u1,secmember(2),d1v1);
399 tgrst = secmember(3)*d1;
400 tg2ds.SetCoord(secmember(1),secmember(2));
401 surfrst->D1(pt2drst.X(),pt2drst.Y(),bid,d1urst,d1vrst);
403 t3dto2d(a,b,tgrst,d1urst,d1vrst);
404 tg2drst.SetCoord(a,b);
408 if(ray>0.) ns.Reverse();
409 ns2 = -resul.Normalized();
412 Sina = nplan.Dot(ns.Crossed(ns2));
414 Sina = -Sina; //nplan is changed to -nplan
419 Angle = 2.*M_PI - Angle;
422 if (Angle>maxang) {maxang = Angle;}
423 if (Angle<minang) {minang = Angle;}
424 distmin = Min( distmin, pts.Distance(ptrst));
426 return Standard_True;
428 istangent = Standard_True;
429 return Standard_False;
432 //=======================================================================
433 //function : GetMinimalDistance
435 //=======================================================================
437 Standard_Real BRepBlend_SurfRstConstRad::GetMinimalDistance() const
442 //=======================================================================
443 //function : PointOnS
445 //=======================================================================
447 const gp_Pnt& BRepBlend_SurfRstConstRad::PointOnS() const
452 //=======================================================================
453 //function : PointOnRst
455 //=======================================================================
457 const gp_Pnt& BRepBlend_SurfRstConstRad::PointOnRst() const
462 //=======================================================================
463 //function : Pnt2dOnS
465 //=======================================================================
467 const gp_Pnt2d& BRepBlend_SurfRstConstRad::Pnt2dOnS() const
472 //=======================================================================
473 //function : Pnt2dOnRst
475 //=======================================================================
477 const gp_Pnt2d& BRepBlend_SurfRstConstRad::Pnt2dOnRst() const
482 //=======================================================================
483 //function : ParameterOnRst
485 //=======================================================================
487 Standard_Real BRepBlend_SurfRstConstRad::ParameterOnRst() const
492 //=======================================================================
493 //function : IsTangencyPoint
495 //=======================================================================
497 Standard_Boolean BRepBlend_SurfRstConstRad::IsTangencyPoint() const
502 //=======================================================================
503 //function : TangentOnS
505 //=======================================================================
507 const gp_Vec& BRepBlend_SurfRstConstRad::TangentOnS() const
509 if (istangent) {Standard_DomainError::Raise();}
513 //=======================================================================
514 //function : Tangent2dOnS
516 //=======================================================================
518 const gp_Vec2d& BRepBlend_SurfRstConstRad::Tangent2dOnS() const
520 if (istangent) {Standard_DomainError::Raise();}
524 //=======================================================================
525 //function : TangentOnRst
527 //=======================================================================
529 const gp_Vec& BRepBlend_SurfRstConstRad::TangentOnRst() const
531 if (istangent) {Standard_DomainError::Raise();}
535 //=======================================================================
536 //function : Tangent2dOnRst
538 //=======================================================================
540 const gp_Vec2d& BRepBlend_SurfRstConstRad::Tangent2dOnRst() const
542 if (istangent) {Standard_DomainError::Raise();}
546 //=======================================================================
549 //=======================================================================
551 Standard_Boolean BRepBlend_SurfRstConstRad::Decroch(const math_Vector& Sol,
555 gp_Vec TgRst, NRst, NRstInPlane, NSInPlane;
558 Standard_Real norm,unsurnorm;
560 surf->D1(Sol(1),Sol(2),bid,d1u,d1v);
561 NS = NSInPlane = d1u.Crossed(d1v);
563 norm = nplan.Crossed(NS).Magnitude();
565 NSInPlane.SetLinearForm(nplan.Dot(NS)*unsurnorm,nplan,-unsurnorm,NS);
567 Center.SetXYZ(bid.XYZ()+ray*NSInPlane.XYZ());
568 if(choix>2) NSInPlane.Reverse();
569 TgS = nplan.Crossed(gp_Vec(Center,bid));
574 rstref->Value(Sol(3)).Coord(u,v);
575 surfref->D1(u,v,bid,d1u,d1v);
576 NRst = d1u.Crossed(d1v);
577 norm = nplan.Crossed(NRst).Magnitude();
579 NRstInPlane.SetLinearForm(nplan.Dot(NRst)*unsurnorm,nplan,-unsurnorm,NRst);
580 gp_Vec centptrst(Center,bid);
581 if(centptrst.Dot(NRstInPlane) < 0.) NRstInPlane.Reverse();
582 TgRst = nplan.Crossed(centptrst);
587 Standard_Real dot, NT = NRstInPlane.Magnitude();
588 NT *= TgRst.Magnitude();
589 if (Abs(NT) < 1.e-7) {
590 return Standard_False; // Singularity or Incoherence.
592 dot = NRstInPlane.Dot(TgRst);
595 return (dot < 1.e-10);
598 //=======================================================================
601 //=======================================================================
603 void BRepBlend_SurfRstConstRad::Set(const Standard_Real Radius,
604 const Standard_Integer Choix)
622 //=======================================================================
625 //=======================================================================
627 void BRepBlend_SurfRstConstRad::Set(const BlendFunc_SectionShape TypeSection)
629 mySShape = TypeSection;
632 //=======================================================================
635 //=======================================================================
637 void BRepBlend_SurfRstConstRad::Section(const Standard_Real Param,
638 const Standard_Real U,
639 const Standard_Real V,
640 const Standard_Real W,
650 tguide->D1(Param,ptgui,d1gui);
651 np = d1gui.Normalized();
653 surf->D1(U,V,pts,d1u1,d1v1);
654 ptrst = cons.Value(W);
656 ns = d1u1.Crossed(d1v1);
658 norm = nplan.Crossed(ns).Magnitude();
659 ns.SetLinearForm(nplan.Dot(ns)/norm,nplan, -1./norm,ns);
660 Center.SetXYZ(pts.XYZ()+ray*ns.XYZ());
661 C.SetRadius(Abs(ray));
671 C.SetPosition(gp_Ax2(Center,np,ns));
672 Pdeb = 0; //ElCLib::Parameter(C,pts);
673 Pfin = ElCLib::Parameter(C,ptrst);
675 // Test negative and almost null angles : Special case
678 C.SetPosition(gp_Ax2(Center,np,ns));
679 Pfin = ElCLib::Parameter(C,ptrst);
681 if (Pfin < Precision::PConfusion()) Pfin += Precision::PConfusion();
684 //=======================================================================
685 //function : IsRational
687 //=======================================================================
689 Standard_Boolean BRepBlend_SurfRstConstRad::IsRational () const
691 return (mySShape==BlendFunc_Rational || mySShape==BlendFunc_QuasiAngular);
694 //=======================================================================
695 //function : GetSectionSize
697 //=======================================================================
699 Standard_Real BRepBlend_SurfRstConstRad::GetSectionSize() const
701 return maxang*Abs(ray);
704 //=======================================================================
705 //function : GetMinimalWeight
707 //=======================================================================
709 void BRepBlend_SurfRstConstRad::GetMinimalWeight(TColStd_Array1OfReal& Weights) const
711 BlendFunc::GetMinimalWeights(mySShape, myTConv, minang, maxang, Weights );
712 // It is supposed that it does not depend on the Radius!
715 //=======================================================================
716 //function : NbIntervals
718 //=======================================================================
720 Standard_Integer BRepBlend_SurfRstConstRad::NbIntervals (const GeomAbs_Shape S) const
722 return guide->NbIntervals(BlendFunc::NextShape(S));
725 //=======================================================================
726 //function : Intervals
728 //=======================================================================
730 void BRepBlend_SurfRstConstRad::Intervals (TColStd_Array1OfReal& T,
731 const GeomAbs_Shape S) const
733 guide->Intervals(T, BlendFunc::NextShape(S));
736 //=======================================================================
737 //function : GetShape
739 //=======================================================================
741 void BRepBlend_SurfRstConstRad::GetShape (Standard_Integer& NbPoles,
742 Standard_Integer& NbKnots,
743 Standard_Integer& Degree,
744 Standard_Integer& NbPoles2d)
747 BlendFunc::GetShape(mySShape,maxang,NbPoles,NbKnots,Degree,myTConv);
750 //=======================================================================
751 //function : GetTolerance
752 //purpose : Find Tolerance to be used in approximations.
753 //=======================================================================
755 void BRepBlend_SurfRstConstRad::GetTolerance(const Standard_Real BoundTol,
756 const Standard_Real SurfTol,
757 const Standard_Real AngleTol,
759 math_Vector& Tol1d) const
761 Standard_Integer low = Tol3d.Lower() , up=Tol3d.Upper();
763 Tol= GeomFill::GetTolerance(myTConv, minang, Abs(ray),
767 Tol3d(low+1) = Tol3d(up-1) = Min( Tol, SurfTol);
768 Tol3d(low) = Tol3d(up) = Min( Tol, BoundTol);
771 //=======================================================================
774 //=======================================================================
776 void BRepBlend_SurfRstConstRad::Knots(TColStd_Array1OfReal& TKnots)
778 GeomFill::Knots(myTConv,TKnots);
781 //=======================================================================
784 //=======================================================================
786 void BRepBlend_SurfRstConstRad::Mults(TColStd_Array1OfInteger& TMults)
788 GeomFill::Mults(myTConv, TMults);
791 //=======================================================================
794 //=======================================================================
796 void BRepBlend_SurfRstConstRad::Section(const Blend_Point& P,
797 TColgp_Array1OfPnt& Poles,
798 TColgp_Array1OfPnt2d& Poles2d,
799 TColStd_Array1OfReal& Weights)
801 gp_Vec d1u1,d1v1;//,,d1;
802 gp_Vec ns,ns2;//,temp,np2;
805 Standard_Real norm,u1,v1,w;
807 Standard_Real prm = P.Parameter();
808 Standard_Integer low = Poles.Lower();
809 Standard_Integer upp = Poles.Upper();
811 tguide->D1(prm,ptgui,d1gui);
812 nplan = d1gui.Normalized();
814 P.ParametersOnS(u1,v1);
815 w = P.ParameterOnC(); //jlr : point on curve not on surface
816 gp_Pnt2d pt2d = rst->Value(w);
818 surf->D1(u1,v1,pts,d1u1,d1v1);
819 ptrst = cons.Value(w);
820 distmin = Min (distmin, pts.Distance(ptrst));
822 Poles2d(Poles2d.Lower()).SetCoord(u1,v1);
823 Poles2d(Poles2d.Upper()).SetCoord(pt2d.X(),pt2d.Y());
826 if (mySShape == BlendFunc_Linear) {
834 ns = d1u1.Crossed(d1v1);
835 norm = nplan.Crossed(ns).Magnitude();
837 ns.SetLinearForm(nplan.Dot(ns)/norm,nplan, -1./norm,ns);
839 Center.SetXYZ(pts.XYZ()+ray*ns.XYZ());
841 ns2 = gp_Vec(Center,ptrst).Normalized();
842 if(ray>0) ns.Reverse();
847 GeomFill::GetCircle(myTConv,
854 //=======================================================================
857 //=======================================================================
859 Standard_Boolean BRepBlend_SurfRstConstRad::Section
860 (const Blend_Point& P,
861 TColgp_Array1OfPnt& Poles,
862 TColgp_Array1OfVec& DPoles,
863 TColgp_Array1OfPnt2d& Poles2d,
864 TColgp_Array1OfVec2d& DPoles2d,
865 TColStd_Array1OfReal& Weights,
866 TColStd_Array1OfReal& DWeights)
869 gp_Vec d1u1,d1v1,d2u1,d2v1,d2uv1,d1;
870 gp_Vec ns,ns2,dnplan,dnw,dn2w; //,np2,dnp2;
872 gp_Vec resulu,resulv,temp,tgct,resul;
873 gp_Vec d1urst,d1vrst;
876 Standard_Real norm,ndotns,grosterme;
878 math_Vector sol(1,3),valsol(1,3),secmember(1,3);
879 math_Matrix gradsol(1,3,1,3);
881 Standard_Real prm = P.Parameter();
882 Standard_Integer low = Poles.Lower();
883 Standard_Integer upp = Poles.Upper();
884 Standard_Boolean istgt;
886 tguide->D2(prm,ptgui,d1gui,d2gui);
887 normtg = d1gui.Magnitude();
888 nplan = d1gui.Normalized();
889 dnplan.SetLinearForm(1./normtg,d2gui,
890 -1./normtg*(nplan.Dot(d2gui)),nplan);
892 P.ParametersOnS(sol(1),sol(2));
893 sol(3) = prmrst = P.ParameterOnC();
894 pt2drst = rst->Value(prmrst);
896 Values(sol,valsol,gradsol);
898 surf->D2(sol(1),sol(2),pts,d1u1,d1v1,d2u1,d2v1,d2uv1);
899 cons.D1(sol(3),ptrst,d1);
901 temp.SetXYZ(pts.XYZ()- ptgui.XYZ());
902 secmember(1) = normtg - dnplan.Dot(temp);
904 temp.SetXYZ(ptrst.XYZ()- ptgui.XYZ());
905 secmember(2) = normtg - dnplan.Dot(temp);
907 ns = d1u1.Crossed(d1v1);
908 ncrossns = nplan.Crossed(ns);
909 ndotns = nplan.Dot(ns);
910 norm = ncrossns.Magnitude();
912 norm = 1; // Not enough, but it is not necessary to stop
914 cout << " SurfRstConstRad : Singular Surface " << endl;
918 // Derivative of n1 corresponding to w
920 grosterme = ncrossns.Dot(dnplan.Crossed(ns))/norm/norm;
921 dnw.SetLinearForm((dnplan.Dot(ns)-grosterme*ndotns)/norm,nplan,
925 temp.SetLinearForm(ndotns/norm,nplan, -1./norm,ns);
926 resul.SetLinearForm(ray,temp,gp_Vec(ptrst,pts));
927 secmember(3) = dnw.Dot(resul);
928 secmember(3) = -2.*ray*secmember(3);
930 math_Gauss Resol(gradsol, 1.e-9);
933 if (Resol.IsDone()) {
934 istgt = Standard_False;
935 Resol.Solve(secmember);
938 math_SVD SingRS (gradsol);
939 if (SingRS.IsDone()) {
940 math_Vector DEDT(1,3);
942 SingRS.Solve(DEDT, secmember, 1.e-6);
943 istgt = Standard_False;
945 else istgt = Standard_True;
949 tgs.SetLinearForm(secmember(1),d1u1,secmember(2),d1v1);
950 tgrst = secmember(3)*d1;
952 // Derivative of n1 corresponding to u1
953 temp = d2u1.Crossed(d1v1).Added(d1u1.Crossed(d2uv1));
954 grosterme = ncrossns.Dot(nplan.Crossed(temp))/norm/norm;
955 resulu.SetLinearForm(-(grosterme*ndotns-nplan.Dot(temp))/norm,nplan,
959 // Derivative of n1 corresponding to v1
960 temp = d2uv1.Crossed(d1v1).Added(d1u1.Crossed(d2v1));
961 grosterme = ncrossns.Dot(nplan.Crossed(temp))/norm/norm;
962 resulv.SetLinearForm(-(grosterme*ndotns-nplan.Dot(temp))/norm,nplan,
967 dnw.SetLinearForm(secmember(1),resulu,secmember(2),resulv,dnw);
968 ns.SetLinearForm(ndotns/norm,nplan, -1./norm,ns);
970 dn2w.SetLinearForm(ray, dnw, -1., tgrst, tgs);
971 norm = resul.Magnitude();
973 ns2 = -resul.Normalized();
974 dn2w.SetLinearForm(ns2.Dot(dn2w),ns2,-1.,dn2w);
977 ns.SetLinearForm(ndotns/norm,nplan, -1./norm,ns);
978 ns2 = -resul.Normalized();
983 Poles2d(Poles2d.Lower()).SetCoord(sol(1),sol(2));
984 Poles2d(Poles2d.Upper()).SetCoord(pt2drst.X(),pt2drst.Y());
986 DPoles2d(Poles2d.Lower()).SetCoord(secmember(1),secmember(2));
987 surfrst->D1(pt2drst.X(),pt2drst.Y(),bid,d1urst,d1vrst);
989 t3dto2d(a,b,tgrst,d1urst,d1vrst);
990 DPoles2d(Poles2d.Upper()).SetCoord(a,b);
994 if (mySShape == BlendFunc_Linear) {
1001 DPoles(upp) = tgrst;
1002 DWeights(low) = 0.0;
1003 DWeights(upp) = 0.0;
1008 // Case of the circle
1009 Center.SetXYZ(pts.XYZ()+ray*ns.XYZ());
1011 tgct = tgs.Added(ray*dnw);
1025 return GeomFill::GetCircle(myTConv,
1039 GeomFill::GetCircle(myTConv,
1044 return Standard_False;
1048 //=======================================================================
1049 //function : Section
1051 //=======================================================================
1053 Standard_Boolean BRepBlend_SurfRstConstRad::Section
1054 (const Blend_Point&,
1055 TColgp_Array1OfPnt&,
1056 TColgp_Array1OfVec&,
1057 TColgp_Array1OfVec&,
1058 TColgp_Array1OfPnt2d&,
1059 TColgp_Array1OfVec2d&,
1060 TColgp_Array1OfVec2d&,
1061 TColStd_Array1OfReal&,
1062 TColStd_Array1OfReal&,
1063 TColStd_Array1OfReal&)
1065 return Standard_False;
1068 void BRepBlend_SurfRstConstRad::Resolution(const Standard_Integer IC2d,
1069 const Standard_Real Tol,
1070 Standard_Real& TolU,
1071 Standard_Real& TolV) const
1074 TolU = surf->UResolution(Tol);
1075 TolV = surf->VResolution(Tol);
1078 TolU = surfrst->UResolution(Tol);
1079 TolV = surfrst->VResolution(Tol);