1 // File: BRepBlend_RstRstLineBuilder.cxx
2 // Created: Fri Jan 24 10:39:44 1997
3 // Author: Jacques GOUSSARD
4 // Author: Laurent BOURESCHE
5 // <lbo@pomalox.paris1.matra-dtv.fr>
9 #include <BRepBlend_RstRstLineBuilder.ixx>
10 #include <BRepBlend_BlendTool.hxx>
12 #include <IntSurf.hxx>
13 #include <math_FunctionSetRoot.hxx>
14 #include <gp_Pnt2d.hxx>
16 #include <gp_Vec2d.hxx>
20 #include <TColStd_Array1OfInteger.hxx>
21 #include <TColStd_Array1OfReal.hxx>
22 #include <TColgp_Array1OfPnt2d.hxx>
23 #include <TColgp_Array1OfVec.hxx>
24 #include <TColgp_Array1OfVec2d.hxx>
25 #include <TColgp_Array1OfPnt.hxx>
26 #include <Geom_BSplineCurve.hxx>
28 #include <DrawTrSurf.hxx>
30 static Standard_Integer IndexOfSection = 0;
31 extern Standard_Boolean Blend_GettraceDRAWSECT();
33 //-----------------------------------------------------
34 // Pour debug : visualisation de la section
35 static Standard_Boolean BBPP(const Standard_Real param,
36 Blend_RstRstFunction& Func,
37 const math_Vector& sol,
38 const Standard_Real tol,
41 if(!Func.IsSolution(sol,tol)) return 0;
42 gp_Pnt pntrst1 = Func.PointOnRst1();
43 gp_Pnt pntrst2 = Func.PointOnRst2();
44 gp_Pnt2d p2drst1 = Func.Pnt2dOnRst1();
45 gp_Pnt2d p2drst2 = Func.Pnt2dOnRst2();
46 Standard_Real w1 = Func.ParameterOnRst1();
47 Standard_Real w2 = Func.ParameterOnRst2();
48 BP = Blend_Point(pntrst1, pntrst2, param,
49 p2drst1.X(), p2drst1.Y(),
50 p2drst2.X(), p2drst2.Y(), w1, w2);
55 //-----------------------------------------------------
56 static void tracederiv(Blend_RstRstFunction& Func,
57 const Blend_Point& BP1,
58 const Blend_Point& BP2)
60 Standard_Integer hp,hk,hd,hp2d,i;
61 Func.GetShape(hp,hk,hd,hp2d);
62 TColgp_Array1OfPnt TP1(1,hp);
63 TColgp_Array1OfVec TDP1(1,hp);
64 TColgp_Array1OfPnt2d TP2d1(1,hp2d);
65 TColgp_Array1OfVec2d TDP2d1(1,hp2d);
66 TColStd_Array1OfReal TW1(1,hp);
67 TColStd_Array1OfReal TDW1(1,hp);
68 Func.Section(BP1, TP1,TDP1,TP2d1,TDP2d1,TW1,TDW1);
70 TColgp_Array1OfPnt TP2(1,hp);
71 TColgp_Array1OfVec TDP2(1,hp);
72 TColgp_Array1OfPnt2d TP2d2(1,hp2d);
73 TColgp_Array1OfVec2d TDP2d2(1,hp2d);
74 TColStd_Array1OfReal TW2(1,hp);
75 TColStd_Array1OfReal TDW2(1,hp);
76 Func.Section(BP2,TP2,TDP2,TP2d2,TDP2d2,TW2,TDW2);
78 Standard_Real param1 = BP1.Parameter();
79 Standard_Real param2 = BP2.Parameter();
80 Standard_Real scal = 1./ (param1 - param2);
83 cout<<"controle des derivees au point : "<<param1<<endl;
85 for(i = 1; i <= hp; i++){
87 cout<<"point : "<<i<<endl;
88 cout<<"dx calcule : "<<TDP1(i).X()<<endl;
89 cout<<"dx estime : "<<scal*(TP1(i).X()-TP2(i).X())<<endl;
90 cout<<"dy calcule : "<<TDP1(i).Y()<<endl;
91 cout<<"dy estime : "<<scal*(TP1(i).Y()-TP2(i).Y())<<endl;
92 cout<<"dz calcule : "<<TDP1(i).Z()<<endl;
93 cout<<"dz estime : "<<scal*(TP1(i).Z()-TP2(i).Z())<<endl;
94 cout<<"dw calcule : "<<TDW1(i)<<endl;
95 cout<<"dw estime : "<<scal*(TW1(i)-TW2(i))<<endl;
97 for(i = 1; i <= hp2d; i++){
99 cout<<"point 2d : "<<i<<endl;
100 cout<<"dx calcule : "<<TDP2d1(i).X()<<endl;
101 cout<<"dx estime : "<<scal*(TP2d1(i).X()-TP2d2(i).X())<<endl;
102 cout<<"dy calcule : "<<TDP2d1(i).Y()<<endl;
103 cout<<"dy estime : "<<scal*(TP2d1(i).Y()-TP2d2(i).Y())<<endl;
108 //-----------------------------------------------------
109 static void Drawsect(const Standard_Real param,
110 Blend_RstRstFunction& Func)
112 gp_Pnt pntrst1 = Func.PointOnRst1();
113 gp_Pnt pntrst2 = Func.PointOnRst2();
114 gp_Pnt2d p2drst1 = Func.Pnt2dOnRst1();
115 gp_Pnt2d p2drst2 = Func.Pnt2dOnRst2();
116 Standard_Real u = Func.ParameterOnRst1();
117 Standard_Real v = Func.ParameterOnRst2();
118 Blend_Point BP(pntrst1, pntrst2, param,
119 p2drst1.X(), p2drst1.Y(),
120 p2drst2.X(), p2drst2.Y(), u, v);
121 Standard_Integer hp,hk,hd,hp2d;
122 Func.GetShape(hp,hk,hd,hp2d);
123 TColStd_Array1OfReal TK(1,hk);
125 TColStd_Array1OfInteger TMul(1,hk);
127 TColgp_Array1OfPnt TP(1,hp);
128 TColgp_Array1OfPnt2d TP2d(1,hp2d);
129 TColStd_Array1OfReal TW(1,hp);
130 Func.Section(BP,TP,TP2d,TW);
131 Handle(Geom_BSplineCurve) sect = new Geom_BSplineCurve
136 Standard_CString name = tname ;
137 sprintf(name,"%s_%d","Section",IndexOfSection);
138 DrawTrSurf::Set(name,sect);
143 //=======================================================================
144 //function : BRepBlend_RstRstLineBuilder
146 //=======================================================================
148 BRepBlend_RstRstLineBuilder::BRepBlend_RstRstLineBuilder
149 (const Handle(Adaptor3d_HSurface)& Surf1,
150 const Handle(Adaptor2d_HCurve2d)& Rst1,
151 const Handle(Adaptor3d_TopolTool)& Domain1,
152 const Handle(Adaptor3d_HSurface)& Surf2,
153 const Handle(Adaptor2d_HCurve2d)& Rst2,
154 const Handle(Adaptor3d_TopolTool)& Domain2):
155 sol(1,2), surf1(Surf1), domain1(Domain1),
156 surf2(Surf2), domain2(Domain2), rst1(Rst1), rst2(Rst2)
160 //=======================================================================
162 //purpose : lance le processus de cheminement
163 //=======================================================================
165 void BRepBlend_RstRstLineBuilder::Perform(Blend_RstRstFunction& Func,
166 Blend_SurfCurvFuncInv& Finv1,
167 Blend_CurvPointFuncInv& FinvP1,
168 Blend_SurfCurvFuncInv& Finv2,
169 Blend_CurvPointFuncInv& FinvP2,
170 const Standard_Real Pdep,
171 const Standard_Real Pmax,
172 const Standard_Real MaxStep,
173 const Standard_Real TolGuide,
174 const math_Vector& ParDep,
175 const Standard_Real Tolesp,
176 const Standard_Real Fleche,
177 const Standard_Boolean Appro)
179 done = Standard_False;
180 iscomplete = Standard_False;
181 comptra = Standard_False;
182 line = new BRepBlend_Line();
183 tolesp = Abs(Tolesp);
184 tolgui = Abs(TolGuide);
185 fleche = Abs(Fleche);
186 rebrou = Standard_False;
187 pasmax = Abs(MaxStep);
189 if (Pmax - Pdep >= 0.) {
202 TopAbs_State siturst1, siturst2;
203 Blend_DecrochStatus decroch;
204 math_Vector tolerance(1, 2), infbound(1, 2), supbound(1, 2);
205 Func.GetTolerance(tolerance, tolesp);
206 Func.GetBounds(infbound, supbound);
207 math_FunctionSetRoot rsnld(Func, tolerance, 30);
209 rsnld.Perform(Func, ParDep, infbound, supbound);
211 if (!rsnld.IsDone()) {
215 if (!CheckInside(Func, siturst1, siturst2, decroch)) {
223 State = TestArret(Func, Standard_False, Blend_OK);
224 if (State != Blend_OK) {
228 if (Blend_GettraceDRAWSECT()){
229 Drawsect(param, Func);
232 // Mettre a jour la ligne.
233 line->Append(previousP);
235 U = previousP.ParameterOnC1();
236 V = previousP.ParameterOnC2();
237 BRepBlend_Extremity ptf1 (previousP.PointOnC1(),
238 U, previousP.Parameter(),tolesp);
239 BRepBlend_Extremity ptf2 (previousP.PointOnC2(),
240 V, previousP.Parameter(),tolesp);
241 if (!previousP.IsTangencyPoint()) {
242 ptf1.SetTangent(previousP.TangentOnC1());
243 ptf2.SetTangent(previousP.TangentOnC2());
247 line->SetStartPoints(ptf1, ptf2);
250 line->SetEndPoints(ptf1, ptf2);
253 InternalPerform(Func, Finv1, FinvP1, Finv2, FinvP2, Pmax);
254 done = Standard_True;
257 //=======================================================================
258 //function : PerformFirstSection
259 //purpose : Creation de la premiere section
260 //=======================================================================
262 Standard_Boolean BRepBlend_RstRstLineBuilder::PerformFirstSection
263 (Blend_RstRstFunction& Func,
264 Blend_SurfCurvFuncInv& Finv1,
265 Blend_CurvPointFuncInv& FinvP1,
266 Blend_SurfCurvFuncInv& Finv2,
267 Blend_CurvPointFuncInv& FinvP2,
268 const Standard_Real Pdep,
269 const Standard_Real Pmax,
270 const math_Vector& ParDep,
271 const Standard_Real Tolesp,
272 const Standard_Real TolGuide,
273 const Standard_Boolean RecRst1,
274 const Standard_Boolean RecP1,
275 const Standard_Boolean RecRst2,
276 const Standard_Boolean RecP2,
280 done = Standard_False;
281 iscomplete = Standard_False;
282 comptra = Standard_False;
283 line = new BRepBlend_Line();
284 tolesp = Abs(Tolesp);
285 tolgui = Abs(TolGuide);
286 rebrou = Standard_False;
288 if (Pmax - Pdep >= 0.) {
295 Standard_Boolean recadp1, recadp2, recadrst1, recadrst2;
296 Standard_Real wp1, wp2, wrst1, wrst2;
298 Blend_Status State = Blend_OnRst12;
299 Standard_Real trst11 = 0., trst12 = 0., trst21 = 0., trst22 = 0.;
302 Standard_Real trst11, trst12, trst21, trst22;
304 math_Vector infbound(1, 2), supbound(1, 2), tolerance(1, 2);
305 math_Vector solinvp1(1, 2), solinvp2(1, 2), solinvrst1(1, 3), solinvrst2(1, 3);
306 Handle(Adaptor3d_HVertex) Vtxp1, Vtxp2, Vtxrst1, Vtxrst2, Vtxc;
307 Standard_Boolean IsVtxp1 = 0, IsVtxp2 = 0, IsVtxrst1 = 0, IsVtxrst2 = 0;
308 Handle(Adaptor2d_HCurve2d) Arc;
309 wp1 = wp2 = wrst1 = wrst2 = Pmax;
312 Func.GetTolerance(tolerance, tolesp);
313 Func.GetBounds(infbound, supbound);
315 math_FunctionSetRoot rsnld(Func, tolerance, 30);
316 rsnld.Perform(Func, ParDep, infbound, supbound);
317 if (!rsnld.IsDone()) return Standard_False;
320 recadrst1 = RecRst1 && Recadre1(Func, Finv1, solinvrst1, IsVtxrst1, Vtxrst1);
322 wrst1 = solinvrst1(1);
325 recadp1 = RecP1 && Recadre1(FinvP1, solinvp1, IsVtxp1, Vtxp1);
330 recadrst2 = RecRst2 && Recadre2(Func, Finv2, solinvrst2, IsVtxrst2, Vtxrst2);
332 wrst2 = solinvrst2(1);
335 recadp2 = RecP2 && Recadre2(FinvP2, solinvp2, IsVtxp2, Vtxp2);
340 if (!recadrst1 && !recadp1 && !recadrst2 && !recadp2) return Standard_False;
343 // on regarde si on a decroche ou sorti du domaine 1
344 if (recadp1 && recadrst1) {
345 if (sens * (wrst1 - wp1) > tolgui){ //on sort du domaine d abord
347 trst12 = solinvp1(2);
348 trst11 = BRepBlend_BlendTool::Parameter(Vtxp1, rst1);
351 recadrst1 = Standard_False;
353 else { // on a decroche
354 trst11 = solinvrst1(3);
355 trst12 = solinvrst1(2);
356 recadp1 = Standard_False;
361 trst12 = solinvp1(2);
362 trst11 = BRepBlend_BlendTool::Parameter(Vtxp1, rst1);
366 else if (recadrst1) {
367 trst11 = solinvrst1(3);
368 trst12 = solinvrst1(2);
371 // on regarde si on a decrocher ou sortie du domaine 2
372 if (recadp2 && recadrst2) {
373 if (sens * (wrst2 - wp2) > tolgui) { //on sort du domaine d abord
375 trst21 = solinvp2(2);
376 trst22 = BRepBlend_BlendTool::Parameter(Vtxp2, rst2);
379 recadrst2 = Standard_False;
382 trst22 = solinvrst2(3);
383 trst21 = solinvrst2(2);
384 recadp2 = Standard_False;
389 trst21 = solinvp2(2);
390 trst22 = BRepBlend_BlendTool::Parameter(Vtxp2, rst2);
394 else if (recadrst2) {
395 trst22 = solinvrst2(3);
396 trst21 = solinvrst2(2);
399 // on regarde sur laquelle des courbes on decroche en premier
400 if (recadrst1 && recadrst2) {
401 if (Abs(wrst1 - wrst2) < tolgui) {
402 State = Blend_OnRst12;
403 param = 0.5 * (wrst1 + wrst2);
407 else if (sens * (wrst1 - wrst2) < 0) {
408 // on decroche sur Rst1
409 State = Blend_OnRst1;
415 // on decroche sur rst2
416 State = Blend_OnRst2;
423 else if (recadrst1) {
425 State = Blend_OnRst1;
431 else if (recadrst2) {
433 State = Blend_OnRst2;
439 // on regarde sur laquelle des courbes on sort en premier
440 else if (recadp1 && recadp2) {
441 if (Abs(wrst1 - wrst2) < tolgui) {
442 State = Blend_OnRst12;
443 param = 0.5 * (wrst1 + wrst2);
447 else if (sens * (wrst1 - wrst2) < 0) {
449 State = Blend_OnRst1;
456 State = Blend_OnRst2;
465 State = Blend_OnRst1;
473 State = Blend_OnRst2;
480 State = TestArret(Func, Standard_False, State);
483 return Standard_True;
486 //=======================================================================
487 //function : Complete
489 //=======================================================================
491 Standard_Boolean BRepBlend_RstRstLineBuilder::Complete(Blend_RstRstFunction& Func,
492 Blend_SurfCurvFuncInv& Finv1,
493 Blend_CurvPointFuncInv& FinvP1,
494 Blend_SurfCurvFuncInv& Finv2,
495 Blend_CurvPointFuncInv& FinvP2,
496 const Standard_Real Pmin)
498 if (!done) {StdFail_NotDone::Raise();}
499 if (iscomplete) {return Standard_True;}
501 previousP = line->Point(1);
504 previousP = line->Point(line->NbPoints());
507 param = previousP.Parameter();
508 sol(1) = previousP.ParameterOnC1();
509 sol(2) = previousP.ParameterOnC2();
511 InternalPerform(Func, Finv1, FinvP1, Finv2, FinvP2, Pmin);
512 iscomplete = Standard_True;
513 return Standard_True;
516 //=======================================================================
517 //function : InternalPerform
518 //purpose : algorithme de cheminement sauf aux extremites
519 //=======================================================================
521 void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction& Func,
522 Blend_SurfCurvFuncInv& Finv1,
523 Blend_CurvPointFuncInv& FinvP1,
524 Blend_SurfCurvFuncInv& Finv2,
525 Blend_CurvPointFuncInv& FinvP2,
526 const Standard_Real Bound)
528 Standard_Real stepw = pasmax;
529 Standard_Integer nbp = line->NbPoints();
530 if(nbp >= 2){ //On reprend le dernier step s il n est pas trop petit.
532 stepw = (line->Point(2).Parameter() - line->Point(1).Parameter());
535 stepw = (line->Point(nbp).Parameter() - line->Point(nbp - 1).Parameter());
537 stepw = Max(stepw, 100. * tolgui);
539 Standard_Real parprec = param;
540 if (sens* (parprec - Bound) >= -tolgui) {
544 Blend_Status State = Blend_OnRst12;
545 Standard_Real trst11 = 0., trst12 = 0., trst21 = 0., trst22 = 0.;
548 Standard_Real trst11, trst12, trst21, trst22;
550 TopAbs_State situonc1, situonc2;
551 Blend_DecrochStatus decroch;
552 Standard_Boolean Arrive, recadp1, recadp2, recadrst1, recadrst2, echecrecad;
553 Standard_Real wp1, wp2, wrst1, wrst2;
554 math_Vector infbound(1, 2), supbound(1, 2);
555 math_Vector parinit(1, 2), tolerance(1, 2);
556 math_Vector solinvp1(1, 2), solinvp2(1, 2), solinvrst1(1, 3), solinvrst2(1, 3);
557 Handle(Adaptor3d_HVertex) Vtxp1, Vtxp2, Vtxrst1, Vtxrst2;
558 Standard_Boolean IsVtxp1 = 0, IsVtxp2 = 0, IsVtxrst1 = 0, IsVtxrst2 = 0;
559 BRepBlend_Extremity Extrst1, Extrst2;
561 //IntSurf_Transition Tline, Tarc;
563 Func.GetTolerance(tolerance, tolesp);
564 Func.GetBounds(infbound, supbound);
566 math_FunctionSetRoot rsnld(Func, tolerance, 30);
569 Arrive = Standard_False;
570 param = parprec + sens * stepw;
571 if (sens * (param - Bound) > 0.) {
572 stepw = sens * (Bound - parprec) * 0.5;
573 param = parprec + sens * stepw;
577 Standard_Boolean bonpoint = 1;
581 rsnld.Perform(Func, parinit, infbound, supbound);
582 if (rsnld.IsDone()) {
585 if(BBPP(param, Func, sol, tolesp, bp1)){
586 Standard_Real dw = 1.e-10;
587 Func.Set(param + dw);
588 rsnld.Perform(Func, parinit, infbound, supbound);
589 if (rsnld.IsDone()) {
592 if(BBPP(param + dw, Func, sol, tolesp, bp2)){
593 tracederiv(Func, bp1, bp2);
601 rsnld.Perform(Func, parinit, infbound, supbound);
603 if (rsnld.IsDone()) {
605 if(!CheckInside(Func, situonc1, situonc2, decroch) && line->NbPoints() == 1){
606 State = Blend_StepTooLarge;
611 State = Blend_StepTooLarge;
615 wp1 = wp2 = wrst1 = wrst2 = Bound;
616 recadp1 = recadp2 = recadrst1 = recadrst2 = Standard_False;
617 echecrecad = Standard_False;
618 if (situonc1 != TopAbs_IN) {
619 // pb inverse rst/rst
620 recadp1 = Recadre1(FinvP1, solinvp1, IsVtxp1, Vtxp1);
625 echecrecad = Standard_True;
629 if (situonc2 != TopAbs_IN) {
630 // pb inverse point/surf
631 recadp2 = Recadre2(FinvP2, solinvp2, IsVtxp2, Vtxp2);
636 echecrecad = Standard_True;
640 if (decroch == Blend_DecrochRst1 || decroch == Blend_DecrochBoth) {
641 // pb inverse rst1/surf1
642 recadrst1 = Recadre1(Func, Finv1, solinvrst1, IsVtxrst1, Vtxrst1);
644 wrst1 = solinvrst1(1);
647 echecrecad = Standard_True;
651 if (decroch == Blend_DecrochRst2 || decroch == Blend_DecrochBoth) {
652 // pb inverse rst2/surf2
653 recadrst2 = Recadre2(Func, Finv2, solinvrst2, IsVtxrst2, Vtxrst2);
655 wrst2 = solinvrst2(1);
658 echecrecad = Standard_True;
662 decroch = Blend_NoDecroch;
663 if (recadp1 || recadp2 || recadrst1 || recadrst2) echecrecad = Standard_False;
666 // on regarde si on a decroche ou sorti du domaine 1
667 if (recadp1 && recadrst1) {
668 if (sens * (wrst1 - wp1) > tolgui){ //on sort du domaine d abord
670 trst12 = solinvp1(2);
671 trst11 = BRepBlend_BlendTool::Parameter(Vtxp1, rst1);
674 recadrst1 = Standard_False;
676 else { // on a decroche
677 trst11 = solinvrst1(3);
678 trst12 = solinvrst1(2);
679 recadp1 = Standard_False;
684 trst12 = solinvp1(2);
685 trst11 = BRepBlend_BlendTool::Parameter(Vtxp1, rst1);
689 else if (recadrst1) {
690 trst11 = solinvrst1(3);
691 trst12 = solinvrst1(2);
694 // on regarde si on a decrocher ou sortie du domaine 2
695 if (recadp2 && recadrst2) {
696 if (sens * (wrst2 - wp2) > tolgui) { //on sort du domaine d abord
698 trst21 = solinvp2(2);
699 trst22 = BRepBlend_BlendTool::Parameter(Vtxp2, rst2);
702 recadrst2 = Standard_False;
705 trst22 = solinvrst2(3);
706 trst21 = solinvrst2(2);
707 recadp2 = Standard_False;
712 trst21 = solinvp2(2);
713 trst22 = BRepBlend_BlendTool::Parameter(Vtxp2, rst2);
717 else if (recadrst2) {
718 trst22 = solinvrst2(3);
719 trst21 = solinvrst2(2);
722 // on regarde sur laquelle des courbes on decroche en premier
723 if (recadrst1 && recadrst2) {
724 if (Abs(wrst1 - wrst2) < tolgui) {
725 State = Blend_OnRst12;
726 decroch = Blend_DecrochBoth;
727 param = 0.5 * (wrst1 + wrst2);
731 else if (sens * (wrst1 - wrst2) < 0) {
732 // on decroche sur Rst1
733 State = Blend_OnRst1;
734 decroch = Blend_DecrochRst1;
740 // on decroche sur rst2
741 State = Blend_OnRst2;
742 decroch = Blend_DecrochRst2;
749 else if (recadrst1) {
751 State = Blend_OnRst1;
752 decroch = Blend_DecrochRst1;
758 else if (recadrst2) {
760 State = Blend_OnRst2;
761 decroch = Blend_DecrochRst2;
767 // on regarde sur laquelle des courbes on sort en premier
768 else if (recadp1 && recadp2) {
769 if (Abs(wrst1 - wrst2) < tolgui) {
770 State = Blend_OnRst12;
771 param = 0.5 * (wrst1 + wrst2);
775 else if (sens * (wrst1 - wrst2) < 0) {
777 State = Blend_OnRst1;
784 State = Blend_OnRst2;
793 State = Blend_OnRst1;
801 State = Blend_OnRst2;
811 State = TestArret(Func, Standard_True, State);
814 // echec recadrage. On sort avec PointsConfondus
815 cout<<"echec recadrage"<<endl;
816 State = Blend_SamePoints;
824 if (Blend_GettraceDRAWSECT()){
825 Drawsect(param, Func);
828 // Mettre a jour la ligne.
830 line->Append(previousP);
833 line->Prepend(previousP);
838 if (param == Bound) {
839 Arrive = Standard_True;
840 Extrst1.SetValue(previousP.PointOnC1(),
841 previousP.ParameterOnC1(),
842 previousP.Parameter(), tolesp);
843 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
844 // Indiquer que fin sur Bound.
847 param = param + sens * stepw;
848 if (sens * (param - Bound) > - tolgui) {
855 case Blend_StepTooLarge :
858 if (Abs(stepw) < tolgui) {
859 Extrst1.SetValue(previousP.PointOnC1(),
860 previousP.ParameterOnC1(),
861 previousP.Parameter(), tolesp);
862 Extrst2.SetValue(previousP.PointOnC2(),
863 previousP.ParameterOnC2(),
864 previousP.Parameter(), tolesp);
865 Arrive = Standard_True;
866 if (line->NbPoints()>=2) {
867 // Indiquer qu on s arrete en cours de cheminement
868 cout<<"On n avance plus dans le cheminement"<<endl;
872 param = parprec + sens * stepw; // on ne risque pas de depasser Bound.
877 case Blend_StepTooSmall :
880 if (Blend_GettraceDRAWSECT()){
881 Drawsect(param,Func);
884 // Mettre a jour la ligne.
886 line->Append(previousP);
889 line->Prepend(previousP);
894 stepw = Min(1.5 * stepw, pasmax);
895 if (param == Bound) {
896 Arrive = Standard_True;
897 Extrst1.SetValue(previousP.PointOnC1(),
898 previousP.ParameterOnC1(),
899 previousP.Parameter(), tolesp);
900 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
901 // Indiquer que fin sur Bound.
904 param = param + sens * stepw;
905 if (sens * (param - Bound) > - tolgui) {
915 if (Blend_GettraceDRAWSECT()){
916 Drawsect(param, Func);
920 line->Append(previousP);
923 line->Prepend(previousP);
925 MakeExtremity(Extrst1, Standard_True, rst1, sol(1), IsVtxrst1, Vtxrst1);
926 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
927 Arrive = Standard_True;
934 if (Blend_GettraceDRAWSECT()){
935 Drawsect(param, Func);
939 line->Append(previousP);
942 line->Prepend(previousP);
945 MakeExtremity(Extrst1, Standard_True, rst1, sol(1), IsVtxrst1, Vtxrst1);
946 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
947 Arrive = Standard_True;
954 if (Blend_GettraceDRAWSECT()){
955 Drawsect(param, Func);
959 line->Append(previousP);
962 line->Prepend(previousP);
965 MakeExtremity(Extrst1, Standard_True, rst1, sol(1), IsVtxrst1, Vtxrst1);
966 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
967 Arrive = Standard_True;
971 case Blend_SamePoints :
974 cout << " Points confondus dans le cheminement" << endl;
975 Extrst1.SetValue(previousP.PointOnC1(),
976 previousP.ParameterOnC1(),
977 previousP.Parameter(), tolesp);
978 Extrst2.SetValue(previousP.PointOnC2(),
979 previousP.ParameterOnC2(),
980 previousP.Parameter(), tolesp);
981 Arrive = Standard_True;
991 line->SetEndPoints(Extrst1, Extrst2);
992 decrochfin = decroch;
995 line->SetStartPoints(Extrst1, Extrst2);
996 decrochdeb = decroch;
1003 //=======================================================================
1004 //function : Recadre1
1005 //purpose : On a decroche en 1
1006 //=======================================================================
1008 Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre1(Blend_RstRstFunction& Func,
1009 Blend_SurfCurvFuncInv& Finv,
1010 math_Vector& Solinv,
1011 Standard_Boolean& IsVtx,
1012 Handle(Adaptor3d_HVertex)& Vtx)
1014 math_Vector toler(1, 3), infb(1, 3), supb(1, 3);
1015 Finv.GetTolerance(toler, tolesp);
1016 Finv.GetBounds(infb, supb);
1021 // On recherche le point de non decrochement
1022 math_FunctionSetRoot rsnld(Finv, toler, 30);
1023 rsnld.Perform(Finv, Solinv, infb, supb);
1024 if (!rsnld.IsDone()) {
1025 cout << "RSNLD not done "<< endl << endl;
1026 return Standard_False;
1031 // On doit verifier la valeur de la fonction est bien
1032 // sur la seconde restriction
1033 if (Finv.IsSolution(Solinv, tolesp)) {
1034 Standard_Real w = Solinv(2);
1035 if(w < rst2->FirstParameter() - toler(2)||
1036 w > rst2->LastParameter() + toler(2)){
1037 return Standard_False;
1040 // on regarde si on n est pas sur un Vertex
1041 domain1->Initialize(rst1);
1042 domain1->InitVertexIterator();
1043 IsVtx = !domain1->MoreVertex();
1045 Vtx = domain1->Vertex();
1046 if (Abs(BRepBlend_BlendTool::Parameter(Vtx, rst1)-Solinv(3)) <=
1047 BRepBlend_BlendTool::Tolerance(Vtx, rst1)) {
1048 IsVtx = Standard_True;
1051 domain1->NextVertex();
1052 IsVtx = !domain1->MoreVertex();
1055 if (!domain1->MoreVertex()) {
1056 IsVtx = Standard_False;
1058 // On recalcule la section par resolution directe, sinon, on se recupere
1059 // des incoherences entre le parametre et sol dues au baillement.
1061 math_Vector infbound(1, 2), supbound(1, 2);
1062 math_Vector parinit(1, 2), tolerance(1, 2);
1063 Func.GetTolerance(tolerance, tolesp);
1064 Func.GetBounds(infbound, supbound);
1066 math_FunctionSetRoot rsnld2(Func, tolerance, 30);
1067 parinit(1) = Solinv(3);
1068 parinit(2) = Solinv(2);
1069 Func.Set(Solinv(1));
1070 rsnld2.Perform(Func, parinit, infbound, supbound);
1071 if(!rsnld2.IsDone()) return Standard_False;
1072 rsnld2.Root(parinit);
1073 Solinv(2) = parinit(2);
1074 Solinv(3) = parinit(1);
1075 return Standard_True;
1077 return Standard_False;
1084 //=======================================================================
1085 //function : Recadre2
1086 //purpose : On a decroche sur Rst2
1087 //=======================================================================
1089 Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre2(Blend_RstRstFunction& Func,
1090 Blend_SurfCurvFuncInv& Finv,
1091 math_Vector& Solinv,
1092 Standard_Boolean& IsVtx,
1093 Handle(Adaptor3d_HVertex)& Vtx)
1095 math_Vector toler(1, 3), infb(1, 3), supb(1, 3);
1096 Finv.GetTolerance(toler, tolesp);
1097 Finv.GetBounds(infb, supb);
1102 math_FunctionSetRoot rsnld(Finv, toler, 30);
1103 rsnld.Perform(Finv, Solinv, infb, supb);
1104 if (!rsnld.IsDone()) {
1105 cout << "RSNLD not done "<< endl << endl;
1106 return Standard_False;
1111 // On doit verifier la valeur de la fonction
1112 if (Finv.IsSolution(Solinv, tolesp)) {
1113 Standard_Real w = Solinv(2);
1114 if(w < rst1->FirstParameter() - toler(2)||
1115 w > rst1->LastParameter() + toler(2)){
1116 return Standard_False;
1119 domain2->Initialize(rst2);
1120 domain2->InitVertexIterator();
1121 IsVtx = !domain2->MoreVertex();
1123 Vtx = domain2->Vertex();
1124 if (Abs(BRepBlend_BlendTool::Parameter(Vtx, rst2)-Solinv(3)) <=
1125 BRepBlend_BlendTool::Tolerance(Vtx, rst2)) {
1126 IsVtx = Standard_True;
1129 domain2->NextVertex();
1130 IsVtx = !domain2->MoreVertex();
1133 if (!domain2->MoreVertex()) {
1134 IsVtx = Standard_False;
1136 // On recalcule la section par resolution directe, sinon, on se recupere
1137 // des incoherences entre le parametre et sol dues au baillement.
1139 math_Vector infbound(1, 2), supbound(1, 2);
1140 math_Vector parinit(1,2), tolerance(1,2);
1141 Func.GetTolerance(tolerance, tolesp);
1142 Func.GetBounds(infbound, supbound);
1144 math_FunctionSetRoot rsnld2(Func, tolerance, 30);
1145 parinit(1) = Solinv(2);
1146 parinit(2) = Solinv(3);
1147 Func.Set(Solinv(1));
1148 rsnld2.Perform(Func, parinit, infbound, supbound);
1149 if(!rsnld2.IsDone()) return Standard_False;
1150 rsnld2.Root(parinit);
1151 Solinv(2) = parinit(1);
1152 Solinv(3) = parinit(2);
1153 return Standard_True;
1155 return Standard_False;
1158 //=======================================================================
1159 //function : Recadre
1160 //purpose : On est en fin de la courbe rst1
1161 //=======================================================================
1163 Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre1(Blend_CurvPointFuncInv& FinvP,
1164 math_Vector& Solinv,
1165 Standard_Boolean& IsVtx,
1166 Handle(Adaptor3d_HVertex)& Vtx)
1168 // On se place sur le dernier ou le premier point, suivant le
1169 // sens de cheminement.
1171 Standard_Real firstrst1 = rst1->FirstParameter();
1172 Standard_Real lastrst1 = rst1->LastParameter();
1173 Standard_Real upoint = firstrst1;
1175 if((sol(1) - firstrst1) > (lastrst1 - sol(1))) upoint = lastrst1;
1176 p2drst1 = rst1->Value(upoint);
1177 gp_Pnt thepoint = surf1->Value(p2drst1.X(), p2drst1.Y());
1179 FinvP.Set(thepoint);
1180 math_Vector toler(1,2), infb(1, 2), supb(1, 2);
1181 FinvP.GetTolerance(toler, tolesp);
1182 FinvP.GetBounds(infb, supb);
1186 math_FunctionSetRoot rsnld(FinvP, toler, 30);
1187 rsnld.Perform(FinvP, Solinv, infb, supb);
1188 if (!rsnld.IsDone()) {
1189 cout << "RSNLD not done "<< endl << endl;
1190 return Standard_False;
1194 if(FinvP.IsSolution(Solinv, tolesp)){
1195 gp_Pnt2d p2drst2 = rst2->Value(Solinv(2));
1196 TopAbs_State situ = domain2->Classify(p2drst2, toler(2), 0);
1197 if ((situ != TopAbs_IN) && (situ != TopAbs_ON)) {
1198 return Standard_False;
1200 domain1->Initialize(rst1);
1201 domain1->InitVertexIterator();
1202 IsVtx = !domain1->MoreVertex();
1204 Vtx = domain1->Vertex();
1205 if (Abs(BRepBlend_BlendTool::Parameter(Vtx, rst1) - upoint) <=
1206 BRepBlend_BlendTool::Tolerance(Vtx, rst1)) {
1207 IsVtx = Standard_True;
1210 domain1->NextVertex();
1211 IsVtx = !domain1->MoreVertex();
1214 if (!domain1->MoreVertex()) {
1215 IsVtx = Standard_False;
1217 return Standard_True;
1219 return Standard_False;
1224 //=======================================================================
1225 //function : Recadre2
1226 //purpose : On est en fin de la courbe rst2
1227 //=======================================================================
1229 Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre2(Blend_CurvPointFuncInv& FinvP,
1230 math_Vector& Solinv,
1231 Standard_Boolean& IsVtx,
1232 Handle(Adaptor3d_HVertex)& Vtx)
1234 // On se place sur le dernier ou le premier point, suivant le
1235 // sens de cheminement.
1237 Standard_Real firstrst2 = rst2->FirstParameter();
1238 Standard_Real lastrst2 = rst2->LastParameter();
1239 Standard_Real vpoint = firstrst2;
1241 if((sol(2) - firstrst2) > (lastrst2 - sol(2))) vpoint = lastrst2;
1242 p2drst2 = rst2->Value(vpoint);
1243 gp_Pnt thepoint = surf2->Value(p2drst2.X(), p2drst2.Y());
1245 FinvP.Set(thepoint);
1246 math_Vector toler(1,2), infb(1, 2), supb(1, 2);
1247 FinvP.GetTolerance(toler, tolesp);
1248 FinvP.GetBounds(infb, supb);
1252 math_FunctionSetRoot rsnld(FinvP, toler, 30);
1253 rsnld.Perform(FinvP, Solinv, infb, supb);
1254 if (!rsnld.IsDone()) {
1255 cout << "RSNLD not done "<< endl << endl;
1256 return Standard_False;
1260 if(FinvP.IsSolution(Solinv, tolesp)){
1261 gp_Pnt2d p2drst1 = rst1->Value(Solinv(2));
1262 TopAbs_State situ = domain1->Classify(p2drst1, toler(2), 0);
1263 if ((situ != TopAbs_IN) && (situ != TopAbs_ON)) {
1264 return Standard_False;
1266 domain2->Initialize(rst2);
1267 domain2->InitVertexIterator();
1268 IsVtx = !domain2->MoreVertex();
1270 Vtx = domain2->Vertex();
1271 if (Abs(BRepBlend_BlendTool::Parameter(Vtx, rst2) - vpoint) <=
1272 BRepBlend_BlendTool::Tolerance(Vtx, rst2)) {
1273 IsVtx = Standard_True;
1276 domain2->NextVertex();
1277 IsVtx = !domain2->MoreVertex();
1280 if (!domain2->MoreVertex()) {
1281 IsVtx = Standard_False;
1283 return Standard_True;
1285 return Standard_False;
1289 //=======================================================================
1290 //function : Transition
1292 //=======================================================================
1294 void BRepBlend_RstRstLineBuilder::Transition(const Standard_Boolean OnFirst,
1295 const Handle(Adaptor2d_HCurve2d)& Arc,
1296 const Standard_Real Param,
1297 IntSurf_Transition& TLine,
1298 IntSurf_Transition& TArc)
1300 Standard_Boolean computetranstionaveclacorde = 0;
1302 Blend_Point prevprev;
1304 if(previousP.IsTangencyPoint()){
1305 if(line->NbPoints() < 2) return;
1306 computetranstionaveclacorde = 1;
1308 prevprev = line->Point(2);
1311 prevprev = line->Point(line->NbPoints() - 1);
1318 gp_Vec d1u, d1v, normale, tgrst;
1320 Arc->D1(Param, p2d, dp2d);
1322 surf1->D1(p2d.X(), p2d.Y(), pbid, d1u, d1v);
1323 if(!computetranstionaveclacorde) tgline = previousP.TangentOnC1();
1324 else tgline = gp_Vec(prevprev.PointOnC1(), previousP.PointOnC1());
1327 surf2->D1(p2d.X(), p2d.Y(), pbid, d1u, d1v);
1328 if(!computetranstionaveclacorde) tgline = previousP.TangentOnC2();
1329 else tgline = gp_Vec(prevprev.PointOnC2(), previousP.PointOnC2());
1332 tgrst.SetLinearForm(dp2d.X(), d1u, dp2d.Y(), d1v);
1333 normale = d1u.Crossed(d1v);
1335 IntSurf::MakeTransition(tgline, tgrst, normale, TLine, TArc);
1338 //=======================================================================
1339 //function : MakeExtremity
1340 //purpose : fabrique l extremite d une courbe
1341 //=======================================================================
1343 void BRepBlend_RstRstLineBuilder::MakeExtremity(BRepBlend_Extremity& Extrem,
1344 const Standard_Boolean OnFirst,
1345 const Handle(Adaptor2d_HCurve2d)& Arc,
1346 const Standard_Real Param,
1347 const Standard_Boolean IsVtx,
1348 const Handle(Adaptor3d_HVertex)& Vtx)
1350 IntSurf_Transition Tline, Tarc;
1352 Handle(Adaptor3d_TopolTool) Iter;
1354 Extrem.SetValue(previousP.PointOnC1(),
1356 previousP.Parameter(), tolesp);
1357 if (!previousP.IsTangencyPoint())
1358 Extrem.SetTangent(previousP.TangentOnC1());
1362 Extrem.SetValue(previousP.PointOnC2(),
1364 previousP.Parameter(), tolesp);
1365 if (!previousP.IsTangencyPoint())
1366 Extrem.SetTangent(previousP.TangentOnC1());
1372 Transition(OnFirst, Arc, Param, Tline, Tarc);
1373 Extrem.AddArc(Arc, Param, Tline, Tarc);
1376 Extrem.SetVertex(Vtx);
1377 while (Iter->More()) {
1379 Handle(Adaptor2d_HCurve2d) arc = Iter->Value();
1381 // Handle(Adaptor2d_HCurve2d)& arc = Iter->Value();
1384 Iter->Initialize(arc);
1385 Iter->InitVertexIterator();
1386 while (Iter->MoreVertex()) {
1387 if (Iter->Identical(Vtx, Iter->Vertex())) {
1388 prm = BRepBlend_BlendTool::Parameter(Vtx, arc);
1389 Transition(OnFirst, arc, prm, Tline, Tarc);
1390 Extrem.AddArc(arc, prm, Tline, Tarc);
1396 Transition(OnFirst, arc, Param, Tline, Tarc);
1397 Extrem.AddArc(arc, Param, Tline, Tarc);
1404 //=======================================================================
1405 //function : CheckDeflectionOnRst1
1407 //=======================================================================
1409 Blend_Status BRepBlend_RstRstLineBuilder::CheckDeflectionOnRst1(const Blend_Point& CurPoint)
1411 //Controles 3d du Blend_CSWalking.
1413 // regle par tests dans U4 correspond a 11.478 d
1414 const Standard_Real CosRef3D = 0.98;
1415 Standard_Real Cosi, Cosi2;
1416 Standard_Boolean curpointistangent = CurPoint.IsTangencyPoint();
1417 Standard_Boolean prevpointistangent = previousP.IsTangencyPoint();
1419 gp_Pnt Psurf = CurPoint.PointOnC1();
1421 if(!curpointistangent){
1422 Tgsurf = CurPoint.TangentOnC1();
1424 gp_Pnt prevP = previousP.PointOnC1();
1426 if(!prevpointistangent){
1427 prevTg = previousP.TangentOnC1();
1429 Standard_Real Norme, curNorme;
1431 Standard_Real prevNorme = 0.;
1433 Standard_Real prevNorme;
1435 gp_Vec Corde(prevP, Psurf);
1436 Norme = Corde.SquareMagnitude();
1437 if (!curpointistangent) curNorme = Tgsurf.SquareMagnitude();
1438 if (!prevpointistangent) prevNorme = prevTg.SquareMagnitude();
1440 if (Norme <= tolesp * tolesp) {
1441 // il faudra peut etre forcer meme point
1442 return Blend_SamePoints;
1444 if(!prevpointistangent){
1445 if (prevNorme <= tolesp * tolesp) {
1446 return Blend_SamePoints;
1448 Cosi = sens * Corde * prevTg;
1449 if (Cosi < 0.) { // angle 3d>pi/2. --> retour arriere
1450 return Blend_Backward;
1453 Cosi2 = Cosi * Cosi / prevNorme / Norme;
1454 if (Cosi2 < CosRef3D) {
1455 return Blend_StepTooLarge;
1459 if(!curpointistangent){
1460 // Voir s il faut faire le controle sur le signe de prevtg*Tgsurf
1461 Cosi = sens * Corde * Tgsurf;
1462 Cosi2 = Cosi * Cosi / Tgsurf.SquareMagnitude() / Norme;
1463 if (Cosi2 < CosRef3D || Cosi < 0.) {
1464 return Blend_StepTooLarge;
1468 if (!curpointistangent && !prevpointistangent) {
1469 // Estimation de la fleche courante
1470 Standard_Real FlecheCourante =
1471 (prevTg.Normalized().XYZ() - Tgsurf.Normalized().XYZ()).SquareModulus() * Norme / 64.;
1473 if (FlecheCourante <= 0.25 * fleche * fleche) {
1474 return Blend_StepTooSmall;
1476 if (FlecheCourante > fleche * fleche) {
1477 // pas trop grand : commentaire interessant
1478 return Blend_StepTooLarge;
1485 //=======================================================================
1486 //function : CheckDeflectionOnRst2
1488 //=======================================================================
1490 Blend_Status BRepBlend_RstRstLineBuilder::CheckDeflectionOnRst2(const Blend_Point& CurPoint)
1492 //Controles 3d du Blend_CSWalking.
1494 // regle par tests dans U4 correspond a 11.478 d
1495 const Standard_Real CosRef3D = 0.98;
1496 Standard_Real Cosi, Cosi2;
1497 Standard_Boolean curpointistangent = CurPoint.IsTangencyPoint();
1498 Standard_Boolean prevpointistangent = previousP.IsTangencyPoint();
1500 gp_Pnt Psurf = CurPoint.PointOnC2();
1503 if (!curpointistangent) {
1504 Tgsurf = CurPoint.TangentOnC2();
1506 gp_Pnt prevP = previousP.PointOnC2();
1508 if (!prevpointistangent) {
1509 prevTg = previousP.TangentOnC2();
1511 Standard_Real Norme, curNorme;
1513 Standard_Real prevNorme = 0.;
1515 Standard_Real prevNorme;
1517 gp_Vec Corde(prevP, Psurf);
1518 Norme = Corde.SquareMagnitude();
1519 if (!curpointistangent) curNorme = Tgsurf.SquareMagnitude();
1520 if (!prevpointistangent) prevNorme = prevTg.SquareMagnitude();
1522 if (Norme <= tolesp * tolesp){
1523 // il faudra peut etre forcer meme point
1524 return Blend_SamePoints;
1526 if (!prevpointistangent) {
1527 if (prevNorme <= tolesp * tolesp) {
1528 return Blend_SamePoints;
1530 Cosi = sens * Corde * prevTg;
1531 if (Cosi < 0.) { // angle 3d>pi/2. --> retour arriere
1532 return Blend_Backward;
1535 Cosi2 = Cosi * Cosi / prevNorme / Norme;
1536 if (Cosi2 < CosRef3D) {
1537 return Blend_StepTooLarge;
1541 if (!curpointistangent) {
1542 // Voir s il faut faire le controle sur le signe de prevtg*Tgsurf
1543 Cosi = sens * Corde * Tgsurf;
1544 Cosi2 = Cosi * Cosi / Tgsurf.SquareMagnitude() / Norme;
1545 if (Cosi2 < CosRef3D || Cosi < 0.) {
1546 return Blend_StepTooLarge;
1550 if(!curpointistangent && !prevpointistangent){
1551 // Estimation de la fleche courante
1552 Standard_Real FlecheCourante =
1553 (prevTg.Normalized().XYZ() - Tgsurf.Normalized().XYZ()).SquareModulus() * Norme/64.;
1555 if (FlecheCourante <= 0.25 * fleche * fleche) {
1556 return Blend_StepTooSmall;
1558 if (FlecheCourante > fleche * fleche) {
1559 // pas trop grand : commentaire interessant
1560 return Blend_StepTooLarge;
1566 static IntSurf_TypeTrans ConvOrToTra(const TopAbs_Orientation O)
1568 if(O == TopAbs_FORWARD) return IntSurf_In;
1572 //=======================================================================
1573 //function : TestArret
1575 //=======================================================================
1577 Blend_Status BRepBlend_RstRstLineBuilder::TestArret(Blend_RstRstFunction& Func,
1578 const Standard_Boolean TestDeflection,
1579 const Blend_Status State)
1581 gp_Pnt ptrst1, ptrst2;
1582 gp_Pnt2d pt2drst1, pt2drst2;
1583 gp_Vec tgrst1, tgrst2;
1584 gp_Vec2d tg2drst1, tg2drst2;
1585 Blend_Status StateRst1, StateRst2;
1587 IntSurf_TypeTrans trarst1 = IntSurf_Undecided, trarst2 = IntSurf_Undecided;
1589 IntSurf_TypeTrans trarst1, trarst2;
1591 Blend_Point curpoint;
1593 if (Func.IsSolution(sol, tolesp)) {
1594 Standard_Boolean curpointistangent = Func.IsTangencyPoint();
1595 ptrst1 = Func.PointOnRst1();
1596 ptrst2 = Func.PointOnRst2();
1597 pt2drst1 = Func.Pnt2dOnRst1();
1598 pt2drst2 = Func.Pnt2dOnRst2();
1600 if(curpointistangent){
1601 curpoint.SetValue(ptrst1, ptrst2, param, pt2drst1.X(), pt2drst1.Y(),
1602 pt2drst2.X(), pt2drst2.Y(), sol(1), sol(2));
1605 tgrst1 = Func.TangentOnRst1();
1606 tgrst2 = Func.TangentOnRst2();
1607 tg2drst1 = Func.Tangent2dOnRst1();
1608 tg2drst2 = Func.Tangent2dOnRst2();
1609 curpoint.SetValue(ptrst1, ptrst2, param, pt2drst1.X(), pt2drst1.Y(),
1610 pt2drst2.X(), pt2drst2.Y(), sol(1), sol(2),
1611 tgrst1, tgrst2, tg2drst1, tg2drst2);
1613 if (TestDeflection) {
1614 StateRst1 = CheckDeflectionOnRst1(curpoint);
1615 StateRst2 = CheckDeflectionOnRst2(curpoint);
1618 StateRst1 = StateRst2 = Blend_OK;
1620 if (StateRst1 == Blend_Backward) {
1621 StateRst1 = Blend_StepTooLarge;
1622 rebrou = Standard_True;
1624 if (StateRst2 == Blend_Backward) {
1625 StateRst2 = Blend_StepTooLarge;
1626 rebrou = Standard_True;
1628 if (StateRst1 == Blend_StepTooLarge ||
1629 StateRst2 == Blend_StepTooLarge) {
1630 return Blend_StepTooLarge;
1633 if (!comptra && !curpointistangent) {
1635 gp_Vec2d tg2drstref;
1636 rst1->D1(sol(1), p2drstref, tg2drstref);
1637 Standard_Real testra = tg2drst1.Dot(tg2drstref);
1638 TopAbs_Orientation Or = domain1->Orientation(rst1);
1640 if (Abs(testra) > tolesp) {
1642 trarst1 = ConvOrToTra(TopAbs::Reverse(Or));
1644 else if (testra >0.) {
1645 trarst1 = ConvOrToTra(Or);
1648 rst2->D1(sol(2), p2drstref, tg2drstref);
1649 testra = tg2drst2.Dot(tg2drstref);
1651 Or = domain2->Orientation(rst2);
1652 if (Abs(testra) > tolesp) {
1654 trarst2 = ConvOrToTra(TopAbs::Reverse(Or));
1656 else if (testra >0.) {
1657 trarst2 = ConvOrToTra(Or);
1659 comptra = Standard_True;
1660 line->Set(trarst1, trarst2);
1664 if (StateRst1 == Blend_OK ||
1665 StateRst2 == Blend_OK ) {
1666 previousP = curpoint;
1669 if (StateRst1 == Blend_StepTooSmall &&
1670 StateRst2 == Blend_StepTooSmall) {
1671 previousP = curpoint;
1672 if (State == Blend_OK) {
1673 return Blend_StepTooSmall;
1679 if (State == Blend_OK) {
1680 return Blend_SamePoints;
1686 return Blend_StepTooLarge;
1689 //=======================================================================
1690 //function : CheckInside
1692 //=======================================================================
1694 Standard_Boolean BRepBlend_RstRstLineBuilder::CheckInside(Blend_RstRstFunction& Func,
1695 TopAbs_State& SituOnC1,
1696 TopAbs_State& SituOnC2,
1697 Blend_DecrochStatus & Decroch)
1699 // Standard_Boolean inside = Standard_True;
1700 math_Vector tolerance(1, 2);
1701 Func.GetTolerance(tolerance, tolesp);
1704 Standard_Real v = sol(1);
1705 if(v < rst1->FirstParameter() - tolerance(2)||
1706 v > rst1->LastParameter() + tolerance(2)){
1707 SituOnC1 = TopAbs_OUT;
1709 else if (v > rst1->FirstParameter() &&
1710 v < rst1->LastParameter()){
1711 SituOnC1 = TopAbs_IN;
1713 else SituOnC1 = TopAbs_ON;
1717 if(v < rst2->FirstParameter() - tolerance(2)||
1718 v > rst2->LastParameter() + tolerance(2)){
1719 SituOnC2 = TopAbs_OUT;
1721 else if (v > rst2->FirstParameter() &&
1722 v < rst2->LastParameter()){
1723 SituOnC2 = TopAbs_IN;
1725 else SituOnC2 = TopAbs_ON;
1729 gp_Vec tgrst1, norst1, tgrst2, norst2;
1730 Decroch = Func.Decroch(sol,tgrst1, norst1, tgrst2, norst2);
1732 return (SituOnC1 == TopAbs_IN && SituOnC2 == TopAbs_IN && Decroch == Blend_NoDecroch);