1 // Created on: 1997-01-24
2 // Created by: Laurent BOURESCHE
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.
19 #include <BRepBlend_RstRstLineBuilder.ixx>
20 #include <BRepBlend_BlendTool.hxx>
22 #include <IntSurf.hxx>
23 #include <math_FunctionSetRoot.hxx>
24 #include <gp_Pnt2d.hxx>
26 #include <gp_Vec2d.hxx>
30 #include <TColStd_Array1OfInteger.hxx>
31 #include <TColStd_Array1OfReal.hxx>
32 #include <TColgp_Array1OfPnt2d.hxx>
33 #include <TColgp_Array1OfVec.hxx>
34 #include <TColgp_Array1OfVec2d.hxx>
35 #include <TColgp_Array1OfPnt.hxx>
36 #include <Geom_BSplineCurve.hxx>
38 #include <DrawTrSurf.hxx>
40 static Standard_Integer IndexOfSection = 0;
41 extern Standard_Boolean Blend_GettraceDRAWSECT();
43 #ifdef DEB_BBPP_N_TRDERIV
44 //-----------------------------------------------------
45 // For debug : visualisation of the section
46 static Standard_Boolean BBPP(const Standard_Real param,
47 Blend_RstRstFunction& Func,
48 const math_Vector& sol,
49 const Standard_Real tol,
52 if(!Func.IsSolution(sol,tol)) return 0;
53 gp_Pnt pntrst1 = Func.PointOnRst1();
54 gp_Pnt pntrst2 = Func.PointOnRst2();
55 gp_Pnt2d p2drst1 = Func.Pnt2dOnRst1();
56 gp_Pnt2d p2drst2 = Func.Pnt2dOnRst2();
57 Standard_Real w1 = Func.ParameterOnRst1();
58 Standard_Real w2 = Func.ParameterOnRst2();
59 BP = Blend_Point(pntrst1, pntrst2, param,
60 p2drst1.X(), p2drst1.Y(),
61 p2drst2.X(), p2drst2.Y(), w1, w2);
66 //-----------------------------------------------------
67 static void tracederiv(Blend_RstRstFunction& Func,
68 const Blend_Point& BP1,
69 const Blend_Point& BP2)
71 Standard_Integer hp,hk,hd,hp2d,i;
72 Func.GetShape(hp,hk,hd,hp2d);
73 TColgp_Array1OfPnt TP1(1,hp);
74 TColgp_Array1OfVec TDP1(1,hp);
75 TColgp_Array1OfPnt2d TP2d1(1,hp2d);
76 TColgp_Array1OfVec2d TDP2d1(1,hp2d);
77 TColStd_Array1OfReal TW1(1,hp);
78 TColStd_Array1OfReal TDW1(1,hp);
79 Func.Section(BP1, TP1,TDP1,TP2d1,TDP2d1,TW1,TDW1);
81 TColgp_Array1OfPnt TP2(1,hp);
82 TColgp_Array1OfVec TDP2(1,hp);
83 TColgp_Array1OfPnt2d TP2d2(1,hp2d);
84 TColgp_Array1OfVec2d TDP2d2(1,hp2d);
85 TColStd_Array1OfReal TW2(1,hp);
86 TColStd_Array1OfReal TDW2(1,hp);
87 Func.Section(BP2,TP2,TDP2,TP2d2,TDP2d2,TW2,TDW2);
89 Standard_Real param1 = BP1.Parameter();
90 Standard_Real param2 = BP2.Parameter();
91 Standard_Real scal = 1./ (param1 - param2);
94 cout<<"control of derivatives at point : "<<param1<<endl;
96 for(i = 1; i <= hp; i++){
98 cout<<"point : "<<i<<endl;
99 cout<<"dx calculated : "<<TDP1(i).X()<<endl;
100 cout<<"dx estimated : "<<scal*(TP1(i).X()-TP2(i).X())<<endl;
101 cout<<"dy calculated : "<<TDP1(i).Y()<<endl;
102 cout<<"dy estimated : "<<scal*(TP1(i).Y()-TP2(i).Y())<<endl;
103 cout<<"dz calculated : "<<TDP1(i).Z()<<endl;
104 cout<<"dz estimated : "<<scal*(TP1(i).Z()-TP2(i).Z())<<endl;
105 cout<<"dw calculated : "<<TDW1(i)<<endl;
106 cout<<"dw estimated : "<<scal*(TW1(i)-TW2(i))<<endl;
108 for(i = 1; i <= hp2d; i++){
110 cout<<"point 2d : "<<i<<endl;
111 cout<<"dx calculated : "<<TDP2d1(i).X()<<endl;
112 cout<<"dx estimated : "<<scal*(TP2d1(i).X()-TP2d2(i).X())<<endl;
113 cout<<"dy calculated : "<<TDP2d1(i).Y()<<endl;
114 cout<<"dy estimated : "<<scal*(TP2d1(i).Y()-TP2d2(i).Y())<<endl;
119 //-----------------------------------------------------
120 static void Drawsect(const Standard_Real param,
121 Blend_RstRstFunction& Func)
123 gp_Pnt pntrst1 = Func.PointOnRst1();
124 gp_Pnt pntrst2 = Func.PointOnRst2();
125 gp_Pnt2d p2drst1 = Func.Pnt2dOnRst1();
126 gp_Pnt2d p2drst2 = Func.Pnt2dOnRst2();
127 Standard_Real u = Func.ParameterOnRst1();
128 Standard_Real v = Func.ParameterOnRst2();
129 Blend_Point BP(pntrst1, pntrst2, param,
130 p2drst1.X(), p2drst1.Y(),
131 p2drst2.X(), p2drst2.Y(), u, v);
132 Standard_Integer hp,hk,hd,hp2d;
133 Func.GetShape(hp,hk,hd,hp2d);
134 TColStd_Array1OfReal TK(1,hk);
136 TColStd_Array1OfInteger TMul(1,hk);
138 TColgp_Array1OfPnt TP(1,hp);
139 TColgp_Array1OfPnt2d TP2d(1,hp2d);
140 TColStd_Array1OfReal TW(1,hp);
141 Func.Section(BP,TP,TP2d,TW);
142 Handle(Geom_BSplineCurve) sect = new Geom_BSplineCurve
147 Standard_CString name = tname ;
148 sprintf(name,"%s_%d","Section",IndexOfSection);
149 DrawTrSurf::Set(name,sect);
154 //=======================================================================
155 //function : BRepBlend_RstRstLineBuilder
157 //=======================================================================
159 BRepBlend_RstRstLineBuilder::BRepBlend_RstRstLineBuilder
160 (const Handle(Adaptor3d_HSurface)& Surf1,
161 const Handle(Adaptor2d_HCurve2d)& Rst1,
162 const Handle(Adaptor3d_TopolTool)& Domain1,
163 const Handle(Adaptor3d_HSurface)& Surf2,
164 const Handle(Adaptor2d_HCurve2d)& Rst2,
165 const Handle(Adaptor3d_TopolTool)& Domain2):
166 sol(1,2), surf1(Surf1), domain1(Domain1),
167 surf2(Surf2), domain2(Domain2), rst1(Rst1), rst2(Rst2)
171 //=======================================================================
173 //purpose : launch the processing
174 //=======================================================================
176 void BRepBlend_RstRstLineBuilder::Perform(Blend_RstRstFunction& Func,
177 Blend_SurfCurvFuncInv& Finv1,
178 Blend_CurvPointFuncInv& FinvP1,
179 Blend_SurfCurvFuncInv& Finv2,
180 Blend_CurvPointFuncInv& FinvP2,
181 const Standard_Real Pdep,
182 const Standard_Real Pmax,
183 const Standard_Real MaxStep,
184 const Standard_Real TolGuide,
185 const math_Vector& ParDep,
186 const Standard_Real Tolesp,
187 const Standard_Real Fleche,
188 const Standard_Boolean Appro)
190 done = Standard_False;
191 iscomplete = Standard_False;
192 comptra = Standard_False;
193 line = new BRepBlend_Line();
194 tolesp = Abs(Tolesp);
195 tolgui = Abs(TolGuide);
196 fleche = Abs(Fleche);
197 rebrou = Standard_False;
198 pasmax = Abs(MaxStep);
200 if (Pmax - Pdep >= 0.) {
213 TopAbs_State siturst1, siturst2;
214 Blend_DecrochStatus decroch;
215 math_Vector tolerance(1, 2), infbound(1, 2), supbound(1, 2);
216 Func.GetTolerance(tolerance, tolesp);
217 Func.GetBounds(infbound, supbound);
218 math_FunctionSetRoot rsnld(Func, tolerance, 30);
220 rsnld.Perform(Func, ParDep, infbound, supbound);
222 if (!rsnld.IsDone()) {
226 if (!CheckInside(Func, siturst1, siturst2, decroch)) {
234 State = TestArret(Func, Standard_False, Blend_OK);
235 if (State != Blend_OK) {
239 if (Blend_GettraceDRAWSECT()){
240 Drawsect(param, Func);
244 line->Append(previousP);
246 U = previousP.ParameterOnC1();
247 V = previousP.ParameterOnC2();
248 BRepBlend_Extremity ptf1 (previousP.PointOnC1(),
249 U, previousP.Parameter(),tolesp);
250 BRepBlend_Extremity ptf2 (previousP.PointOnC2(),
251 V, previousP.Parameter(),tolesp);
252 if (!previousP.IsTangencyPoint()) {
253 ptf1.SetTangent(previousP.TangentOnC1());
254 ptf2.SetTangent(previousP.TangentOnC2());
258 line->SetStartPoints(ptf1, ptf2);
261 line->SetEndPoints(ptf1, ptf2);
264 InternalPerform(Func, Finv1, FinvP1, Finv2, FinvP2, Pmax);
265 done = Standard_True;
268 //=======================================================================
269 //function : PerformFirstSection
270 //purpose : Creation of the first section
271 //=======================================================================
273 Standard_Boolean BRepBlend_RstRstLineBuilder::PerformFirstSection
274 (Blend_RstRstFunction& Func,
275 Blend_SurfCurvFuncInv& Finv1,
276 Blend_CurvPointFuncInv& FinvP1,
277 Blend_SurfCurvFuncInv& Finv2,
278 Blend_CurvPointFuncInv& FinvP2,
279 const Standard_Real Pdep,
280 const Standard_Real Pmax,
281 const math_Vector& ParDep,
282 const Standard_Real Tolesp,
283 const Standard_Real TolGuide,
284 const Standard_Boolean RecRst1,
285 const Standard_Boolean RecP1,
286 const Standard_Boolean RecRst2,
287 const Standard_Boolean RecP2,
291 done = Standard_False;
292 iscomplete = Standard_False;
293 comptra = Standard_False;
294 line = new BRepBlend_Line();
295 tolesp = Abs(Tolesp);
296 tolgui = Abs(TolGuide);
297 rebrou = Standard_False;
299 if (Pmax - Pdep >= 0.) {
306 Standard_Boolean recadp1, recadp2, recadrst1, recadrst2;
307 Standard_Real wp1, wp2, wrst1, wrst2;
308 Blend_Status State = Blend_OnRst12;
309 Standard_Real trst11 = 0., trst12 = 0., trst21 = 0., trst22 = 0.;
310 math_Vector infbound(1, 2), supbound(1, 2), tolerance(1, 2);
311 math_Vector solinvp1(1, 2), solinvp2(1, 2), solinvrst1(1, 3), solinvrst2(1, 3);
312 Handle(Adaptor3d_HVertex) Vtxp1, Vtxp2, Vtxrst1, Vtxrst2, Vtxc;
313 Standard_Boolean IsVtxp1 = 0, IsVtxp2 = 0, IsVtxrst1 = 0, IsVtxrst2 = 0;
314 Handle(Adaptor2d_HCurve2d) Arc;
315 wp1 = wp2 = wrst1 = wrst2 = Pmax;
318 Func.GetTolerance(tolerance, tolesp);
319 Func.GetBounds(infbound, supbound);
321 math_FunctionSetRoot rsnld(Func, tolerance, 30);
322 rsnld.Perform(Func, ParDep, infbound, supbound);
323 if (!rsnld.IsDone()) return Standard_False;
326 recadrst1 = RecRst1 && Recadre1(Func, Finv1, solinvrst1, IsVtxrst1, Vtxrst1);
328 wrst1 = solinvrst1(1);
331 recadp1 = RecP1 && Recadre1(FinvP1, solinvp1, IsVtxp1, Vtxp1);
336 recadrst2 = RecRst2 && Recadre2(Func, Finv2, solinvrst2, IsVtxrst2, Vtxrst2);
338 wrst2 = solinvrst2(1);
341 recadp2 = RecP2 && Recadre2(FinvP2, solinvp2, IsVtxp2, Vtxp2);
346 if (!recadrst1 && !recadp1 && !recadrst2 && !recadp2) return Standard_False;
349 // it is checked if the contact was lost or domain 1 was left
350 if (recadp1 && recadrst1) {
351 if (sens * (wrst1 - wp1) > tolgui){ //at first one leaves the domain
353 trst12 = solinvp1(2);
354 trst11 = BRepBlend_BlendTool::Parameter(Vtxp1, rst1);
357 recadrst1 = Standard_False;
359 else { // the contact is lost
360 trst11 = solinvrst1(3);
361 trst12 = solinvrst1(2);
362 recadp1 = Standard_False;
367 trst12 = solinvp1(2);
368 trst11 = BRepBlend_BlendTool::Parameter(Vtxp1, rst1);
372 else if (recadrst1) {
373 trst11 = solinvrst1(3);
374 trst12 = solinvrst1(2);
377 // it is checked if the contact was lost or domain 2 was left
378 if (recadp2 && recadrst2) {
379 if (sens * (wrst2 - wp2) > tolgui) { //at first one leaves the domain
381 trst21 = solinvp2(2);
382 trst22 = BRepBlend_BlendTool::Parameter(Vtxp2, rst2);
385 recadrst2 = Standard_False;
388 trst22 = solinvrst2(3);
389 trst21 = solinvrst2(2);
390 recadp2 = Standard_False;
395 trst21 = solinvp2(2);
396 trst22 = BRepBlend_BlendTool::Parameter(Vtxp2, rst2);
400 else if (recadrst2) {
401 trst22 = solinvrst2(3);
402 trst21 = solinvrst2(2);
405 // it is checked on which curve the contact is lost earlier
406 if (recadrst1 && recadrst2) {
407 if (Abs(wrst1 - wrst2) < tolgui) {
408 State = Blend_OnRst12;
409 param = 0.5 * (wrst1 + wrst2);
413 else if (sens * (wrst1 - wrst2) < 0) {
414 // contact lost on Rst1
415 State = Blend_OnRst1;
421 // contact lost on rst2
422 State = Blend_OnRst2;
429 else if (recadrst1) {
431 State = Blend_OnRst1;
437 else if (recadrst2) {
439 State = Blend_OnRst2;
445 // it is checked on which curves one leaves first
446 else if (recadp1 && recadp2) {
447 if (Abs(wrst1 - wrst2) < tolgui) {
448 State = Blend_OnRst12;
449 param = 0.5 * (wrst1 + wrst2);
453 else if (sens * (wrst1 - wrst2) < 0) {
455 State = Blend_OnRst1;
462 State = Blend_OnRst2;
471 State = Blend_OnRst1;
479 State = Blend_OnRst2;
486 State = TestArret(Func, Standard_False, State);
489 return Standard_True;
492 //=======================================================================
493 //function : Complete
495 //=======================================================================
497 Standard_Boolean BRepBlend_RstRstLineBuilder::Complete(Blend_RstRstFunction& Func,
498 Blend_SurfCurvFuncInv& Finv1,
499 Blend_CurvPointFuncInv& FinvP1,
500 Blend_SurfCurvFuncInv& Finv2,
501 Blend_CurvPointFuncInv& FinvP2,
502 const Standard_Real Pmin)
504 if (!done) {StdFail_NotDone::Raise();}
505 if (iscomplete) {return Standard_True;}
507 previousP = line->Point(1);
510 previousP = line->Point(line->NbPoints());
513 param = previousP.Parameter();
514 sol(1) = previousP.ParameterOnC1();
515 sol(2) = previousP.ParameterOnC2();
517 InternalPerform(Func, Finv1, FinvP1, Finv2, FinvP2, Pmin);
518 iscomplete = Standard_True;
519 return Standard_True;
522 //=======================================================================
523 //function : InternalPerform
524 //purpose : algorithm of processing without extremities
525 //=======================================================================
527 void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction& Func,
528 Blend_SurfCurvFuncInv& Finv1,
529 Blend_CurvPointFuncInv& FinvP1,
530 Blend_SurfCurvFuncInv& Finv2,
531 Blend_CurvPointFuncInv& FinvP2,
532 const Standard_Real Bound)
534 Standard_Real stepw = pasmax;
535 Standard_Integer nbp = line->NbPoints();
536 if(nbp >= 2){ //The last step is redone if it is not too small.
538 stepw = (line->Point(2).Parameter() - line->Point(1).Parameter());
541 stepw = (line->Point(nbp).Parameter() - line->Point(nbp - 1).Parameter());
543 stepw = Max(stepw, 100. * tolgui);
545 Standard_Real parprec = param;
546 if (sens* (parprec - Bound) >= -tolgui) {
549 Blend_Status State = Blend_OnRst12;
550 Standard_Real trst11 = 0., trst12 = 0., trst21 = 0., trst22 = 0.;
551 TopAbs_State situonc1 = TopAbs_UNKNOWN, situonc2 = TopAbs_UNKNOWN;
552 Blend_DecrochStatus decroch = Blend_NoDecroch;
553 Standard_Boolean Arrive, recadp1, recadp2, recadrst1, recadrst2, echecrecad;
554 Standard_Real wp1, wp2, wrst1, wrst2;
555 math_Vector infbound(1, 2), supbound(1, 2);
556 math_Vector parinit(1, 2), tolerance(1, 2);
557 math_Vector solinvp1(1, 2), solinvp2(1, 2), solinvrst1(1, 3), solinvrst2(1, 3);
558 Handle(Adaptor3d_HVertex) Vtxp1, Vtxp2, Vtxrst1, Vtxrst2;
559 Standard_Boolean IsVtxp1 = 0, IsVtxp2 = 0, IsVtxrst1 = 0, IsVtxrst2 = 0;
560 BRepBlend_Extremity Extrst1, Extrst2;
562 //IntSurf_Transition Tline, Tarc;
564 Func.GetTolerance(tolerance, tolesp);
565 Func.GetBounds(infbound, supbound);
567 math_FunctionSetRoot rsnld(Func, tolerance, 30);
570 Arrive = Standard_False;
571 param = parprec + sens * stepw;
572 if (sens * (param - Bound) > 0.) {
573 stepw = sens * (Bound - parprec) * 0.5;
574 param = parprec + sens * stepw;
578 Standard_Boolean bonpoint = 1;
579 #ifdef DEB_BBPP_N_TRDERIV
582 rsnld.Perform(Func, parinit, infbound, supbound);
583 if (rsnld.IsDone()) {
586 if(BBPP(param, Func, sol, tolesp, bp1)){
587 Standard_Real dw = 1.e-10;
588 Func.Set(param + dw);
589 rsnld.Perform(Func, parinit, infbound, supbound);
590 if (rsnld.IsDone()) {
593 if(BBPP(param + dw, Func, sol, tolesp, bp2)){
594 tracederiv(Func, bp1, bp2);
602 rsnld.Perform(Func, parinit, infbound, supbound);
604 if (rsnld.IsDone()) {
606 if(!CheckInside(Func, situonc1, situonc2, decroch) && line->NbPoints() == 1){
607 State = Blend_StepTooLarge;
612 State = Blend_StepTooLarge;
616 wp1 = wp2 = wrst1 = wrst2 = Bound;
617 recadp1 = recadp2 = recadrst1 = recadrst2 = Standard_False;
618 echecrecad = Standard_False;
619 if (situonc1 != TopAbs_IN) {
620 // pb inversion rst/rst
621 recadp1 = Recadre1(FinvP1, solinvp1, IsVtxp1, Vtxp1);
626 echecrecad = Standard_True;
630 if (situonc2 != TopAbs_IN) {
631 // pb inversion point/surf
632 recadp2 = Recadre2(FinvP2, solinvp2, IsVtxp2, Vtxp2);
637 echecrecad = Standard_True;
641 if (decroch == Blend_DecrochRst1 || decroch == Blend_DecrochBoth) {
642 // pb inversion rst1/surf1
643 recadrst1 = Recadre1(Func, Finv1, solinvrst1, IsVtxrst1, Vtxrst1);
645 wrst1 = solinvrst1(1);
648 echecrecad = Standard_True;
652 if (decroch == Blend_DecrochRst2 || decroch == Blend_DecrochBoth) {
653 // pb inverse rst2/surf2
654 recadrst2 = Recadre2(Func, Finv2, solinvrst2, IsVtxrst2, Vtxrst2);
656 wrst2 = solinvrst2(1);
659 echecrecad = Standard_True;
663 decroch = Blend_NoDecroch;
664 if (recadp1 || recadp2 || recadrst1 || recadrst2) echecrecad = Standard_False;
667 // it is checked if the contact was lost or domain 1 was left
668 if (recadp1 && recadrst1) {
669 if (sens * (wrst1 - wp1) > tolgui){ //first one leaves the domain
671 trst12 = solinvp1(2);
672 trst11 = BRepBlend_BlendTool::Parameter(Vtxp1, rst1);
675 recadrst1 = Standard_False;
677 else { // contact is lost
678 trst11 = solinvrst1(3);
679 trst12 = solinvrst1(2);
680 recadp1 = Standard_False;
685 trst12 = solinvp1(2);
686 trst11 = BRepBlend_BlendTool::Parameter(Vtxp1, rst1);
690 else if (recadrst1) {
691 trst11 = solinvrst1(3);
692 trst12 = solinvrst1(2);
695 // it is checked if the contact was lost or domain 2 was left
696 if (recadp2 && recadrst2) {
697 if (sens * (wrst2 - wp2) > tolgui) { //first one leaves the domain
699 trst21 = solinvp2(2);
700 trst22 = BRepBlend_BlendTool::Parameter(Vtxp2, rst2);
703 recadrst2 = Standard_False;
706 trst22 = solinvrst2(3);
707 trst21 = solinvrst2(2);
708 recadp2 = Standard_False;
713 trst21 = solinvp2(2);
714 trst22 = BRepBlend_BlendTool::Parameter(Vtxp2, rst2);
718 else if (recadrst2) {
719 trst22 = solinvrst2(3);
720 trst21 = solinvrst2(2);
723 // it is checked on which curve the contact is lost earlier
724 if (recadrst1 && recadrst2) {
725 if (Abs(wrst1 - wrst2) < tolgui) {
726 State = Blend_OnRst12;
727 decroch = Blend_DecrochBoth;
728 param = 0.5 * (wrst1 + wrst2);
732 else if (sens * (wrst1 - wrst2) < 0) {
733 // contact is lost on Rst1
734 State = Blend_OnRst1;
735 decroch = Blend_DecrochRst1;
741 // contact is lost on rst2
742 State = Blend_OnRst2;
743 decroch = Blend_DecrochRst2;
750 else if (recadrst1) {
752 State = Blend_OnRst1;
753 decroch = Blend_DecrochRst1;
759 else if (recadrst2) {
761 State = Blend_OnRst2;
762 decroch = Blend_DecrochRst2;
768 // it is checked on which curve the contact is lost earlier
769 else if (recadp1 && recadp2) {
770 if (Abs(wrst1 - wrst2) < tolgui) {
771 State = Blend_OnRst12;
772 param = 0.5 * (wrst1 + wrst2);
776 else if (sens * (wrst1 - wrst2) < 0) {
778 State = Blend_OnRst1;
785 State = Blend_OnRst2;
794 State = Blend_OnRst1;
802 State = Blend_OnRst2;
812 State = TestArret(Func, Standard_True, State);
815 // reframing failed. Leave with PointsConfondus
816 cout<<"reframing failed"<<endl;
817 State = Blend_SamePoints;
825 if (Blend_GettraceDRAWSECT()){
826 Drawsect(param, Func);
831 line->Append(previousP);
834 line->Prepend(previousP);
839 if (param == Bound) {
840 Arrive = Standard_True;
841 Extrst1.SetValue(previousP.PointOnC1(),
842 previousP.ParameterOnC1(),
843 previousP.Parameter(), tolesp);
844 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
845 // Show that end is on Bound.
848 param = param + sens * stepw;
849 if (sens * (param - Bound) > - tolgui) {
856 case Blend_StepTooLarge :
859 if (Abs(stepw) < tolgui) {
860 Extrst1.SetValue(previousP.PointOnC1(),
861 previousP.ParameterOnC1(),
862 previousP.Parameter(), tolesp);
863 Extrst2.SetValue(previousP.PointOnC2(),
864 previousP.ParameterOnC2(),
865 previousP.Parameter(), tolesp);
866 Arrive = Standard_True;
867 if (line->NbPoints()>=2) {
868 // Show that there is a stop during processing
869 cout<<"No more advancement in the processing"<<endl;
873 param = parprec + sens * stepw; // there is no risk to exceed Bound.
878 case Blend_StepTooSmall :
881 if (Blend_GettraceDRAWSECT()){
882 Drawsect(param,Func);
887 line->Append(previousP);
890 line->Prepend(previousP);
895 stepw = Min(1.5 * stepw, pasmax);
896 if (param == Bound) {
897 Arrive = Standard_True;
898 Extrst1.SetValue(previousP.PointOnC1(),
899 previousP.ParameterOnC1(),
900 previousP.Parameter(), tolesp);
901 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
902 // Indicate that end is on Bound.
905 param = param + sens * stepw;
906 if (sens * (param - Bound) > - tolgui) {
916 if (Blend_GettraceDRAWSECT()){
917 Drawsect(param, Func);
921 line->Append(previousP);
924 line->Prepend(previousP);
926 MakeExtremity(Extrst1, Standard_True, rst1, sol(1), IsVtxrst1, Vtxrst1);
927 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
928 Arrive = Standard_True;
935 if (Blend_GettraceDRAWSECT()){
936 Drawsect(param, Func);
940 line->Append(previousP);
943 line->Prepend(previousP);
946 MakeExtremity(Extrst1, Standard_True, rst1, sol(1), IsVtxrst1, Vtxrst1);
947 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
948 Arrive = Standard_True;
955 if (Blend_GettraceDRAWSECT()){
956 Drawsect(param, Func);
960 line->Append(previousP);
963 line->Prepend(previousP);
966 MakeExtremity(Extrst1, Standard_True, rst1, sol(1), IsVtxrst1, Vtxrst1);
967 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
968 Arrive = Standard_True;
972 case Blend_SamePoints :
975 cout << " Mixed points in the processing" << endl;
976 Extrst1.SetValue(previousP.PointOnC1(),
977 previousP.ParameterOnC1(),
978 previousP.Parameter(), tolesp);
979 Extrst2.SetValue(previousP.PointOnC2(),
980 previousP.ParameterOnC2(),
981 previousP.Parameter(), tolesp);
982 Arrive = Standard_True;
990 line->SetEndPoints(Extrst1, Extrst2);
991 decrochfin = decroch;
994 line->SetStartPoints(Extrst1, Extrst2);
995 decrochdeb = decroch;
1002 //=======================================================================
1003 //function : Recadre1
1004 //purpose : Contact lost on 1
1005 //=======================================================================
1007 Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre1(Blend_RstRstFunction& Func,
1008 Blend_SurfCurvFuncInv& Finv,
1009 math_Vector& Solinv,
1010 Standard_Boolean& IsVtx,
1011 Handle(Adaptor3d_HVertex)& Vtx)
1013 math_Vector toler(1, 3), infb(1, 3), supb(1, 3);
1014 Finv.GetTolerance(toler, tolesp);
1015 Finv.GetBounds(infb, supb);
1020 // The point where contact is not lost is found
1021 math_FunctionSetRoot rsnld(Finv, toler, 30);
1022 rsnld.Perform(Finv, Solinv, infb, supb);
1023 if (!rsnld.IsDone()) {
1024 cout << "RSNLD not done "<< endl << endl;
1025 return Standard_False;
1030 // It is necessary to check if the function value meets the
1031 // second restriction
1032 if (Finv.IsSolution(Solinv, tolesp)) {
1033 Standard_Real w = Solinv(2);
1034 if(w < rst2->FirstParameter() - toler(2)||
1035 w > rst2->LastParameter() + toler(2)){
1036 return Standard_False;
1039 // it is checked if it is on a Vertex
1040 domain1->Initialize(rst1);
1041 domain1->InitVertexIterator();
1042 IsVtx = !domain1->MoreVertex();
1044 Vtx = domain1->Vertex();
1045 if (Abs(BRepBlend_BlendTool::Parameter(Vtx, rst1)-Solinv(3)) <=
1046 BRepBlend_BlendTool::Tolerance(Vtx, rst1)) {
1047 IsVtx = Standard_True;
1050 domain1->NextVertex();
1051 IsVtx = !domain1->MoreVertex();
1054 if (!domain1->MoreVertex()) {
1055 IsVtx = Standard_False;
1057 // The section is recalculated by direct solution, otherwise return
1058 // incoherences between the parameter and the ground caused by yawn.
1060 math_Vector infbound(1, 2), supbound(1, 2);
1061 math_Vector parinit(1, 2), tolerance(1, 2);
1062 Func.GetTolerance(tolerance, tolesp);
1063 Func.GetBounds(infbound, supbound);
1065 math_FunctionSetRoot rsnld2(Func, tolerance, 30);
1066 parinit(1) = Solinv(3);
1067 parinit(2) = Solinv(2);
1068 Func.Set(Solinv(1));
1069 rsnld2.Perform(Func, parinit, infbound, supbound);
1070 if(!rsnld2.IsDone()) return Standard_False;
1071 rsnld2.Root(parinit);
1072 Solinv(2) = parinit(2);
1073 Solinv(3) = parinit(1);
1074 return Standard_True;
1076 return Standard_False;
1083 //=======================================================================
1084 //function : Recadre2
1085 //purpose : Contact lost on Rst2
1086 //=======================================================================
1088 Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre2(Blend_RstRstFunction& Func,
1089 Blend_SurfCurvFuncInv& Finv,
1090 math_Vector& Solinv,
1091 Standard_Boolean& IsVtx,
1092 Handle(Adaptor3d_HVertex)& Vtx)
1094 math_Vector toler(1, 3), infb(1, 3), supb(1, 3);
1095 Finv.GetTolerance(toler, tolesp);
1096 Finv.GetBounds(infb, supb);
1101 math_FunctionSetRoot rsnld(Finv, toler, 30);
1102 rsnld.Perform(Finv, Solinv, infb, supb);
1103 if (!rsnld.IsDone()) {
1104 cout << "RSNLD not done "<< endl << endl;
1105 return Standard_False;
1110 // It is necessary to check the value of the function
1111 if (Finv.IsSolution(Solinv, tolesp)) {
1112 Standard_Real w = Solinv(2);
1113 if(w < rst1->FirstParameter() - toler(2)||
1114 w > rst1->LastParameter() + toler(2)){
1115 return Standard_False;
1118 domain2->Initialize(rst2);
1119 domain2->InitVertexIterator();
1120 IsVtx = !domain2->MoreVertex();
1122 Vtx = domain2->Vertex();
1123 if (Abs(BRepBlend_BlendTool::Parameter(Vtx, rst2)-Solinv(3)) <=
1124 BRepBlend_BlendTool::Tolerance(Vtx, rst2)) {
1125 IsVtx = Standard_True;
1128 domain2->NextVertex();
1129 IsVtx = !domain2->MoreVertex();
1132 if (!domain2->MoreVertex()) {
1133 IsVtx = Standard_False;
1135 // The section is recalculated by direct solution, otherwise return
1136 // incoherences between the parameter and the ground caused by yawn.
1138 math_Vector infbound(1, 2), supbound(1, 2);
1139 math_Vector parinit(1,2), tolerance(1,2);
1140 Func.GetTolerance(tolerance, tolesp);
1141 Func.GetBounds(infbound, supbound);
1143 math_FunctionSetRoot rsnld2(Func, tolerance, 30);
1144 parinit(1) = Solinv(2);
1145 parinit(2) = Solinv(3);
1146 Func.Set(Solinv(1));
1147 rsnld2.Perform(Func, parinit, infbound, supbound);
1148 if(!rsnld2.IsDone()) return Standard_False;
1149 rsnld2.Root(parinit);
1150 Solinv(2) = parinit(1);
1151 Solinv(3) = parinit(2);
1152 return Standard_True;
1154 return Standard_False;
1157 //=======================================================================
1158 //function : Recadre
1159 //purpose : This is the end of curve rst1
1160 //=======================================================================
1162 Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre1(Blend_CurvPointFuncInv& FinvP,
1163 math_Vector& Solinv,
1164 Standard_Boolean& IsVtx,
1165 Handle(Adaptor3d_HVertex)& Vtx)
1167 // One is located on the last or the first point, following the
1168 // direction of processing.
1170 Standard_Real firstrst1 = rst1->FirstParameter();
1171 Standard_Real lastrst1 = rst1->LastParameter();
1172 Standard_Real upoint = firstrst1;
1174 if((sol(1) - firstrst1) > (lastrst1 - sol(1))) upoint = lastrst1;
1175 p2drst1 = rst1->Value(upoint);
1176 gp_Pnt thepoint = surf1->Value(p2drst1.X(), p2drst1.Y());
1178 FinvP.Set(thepoint);
1179 math_Vector toler(1,2), infb(1, 2), supb(1, 2);
1180 FinvP.GetTolerance(toler, tolesp);
1181 FinvP.GetBounds(infb, supb);
1185 math_FunctionSetRoot rsnld(FinvP, toler, 30);
1186 rsnld.Perform(FinvP, Solinv, infb, supb);
1187 if (!rsnld.IsDone()) {
1188 cout << "RSNLD not done "<< endl << endl;
1189 return Standard_False;
1193 if(FinvP.IsSolution(Solinv, tolesp)){
1194 gp_Pnt2d p2drst2 = rst2->Value(Solinv(2));
1195 TopAbs_State situ = domain2->Classify(p2drst2, toler(2), 0);
1196 if ((situ != TopAbs_IN) && (situ != TopAbs_ON)) {
1197 return Standard_False;
1199 domain1->Initialize(rst1);
1200 domain1->InitVertexIterator();
1201 IsVtx = !domain1->MoreVertex();
1203 Vtx = domain1->Vertex();
1204 if (Abs(BRepBlend_BlendTool::Parameter(Vtx, rst1) - upoint) <=
1205 BRepBlend_BlendTool::Tolerance(Vtx, rst1)) {
1206 IsVtx = Standard_True;
1209 domain1->NextVertex();
1210 IsVtx = !domain1->MoreVertex();
1213 if (!domain1->MoreVertex()) {
1214 IsVtx = Standard_False;
1216 return Standard_True;
1218 return Standard_False;
1223 //=======================================================================
1224 //function : Recadre2
1225 //purpose : This is the end of curve rst2
1226 //=======================================================================
1228 Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre2(Blend_CurvPointFuncInv& FinvP,
1229 math_Vector& Solinv,
1230 Standard_Boolean& IsVtx,
1231 Handle(Adaptor3d_HVertex)& Vtx)
1233 // One is located on the last or the first point, following the
1234 // direction of processing.
1236 Standard_Real firstrst2 = rst2->FirstParameter();
1237 Standard_Real lastrst2 = rst2->LastParameter();
1238 Standard_Real vpoint = firstrst2;
1240 if((sol(2) - firstrst2) > (lastrst2 - sol(2))) vpoint = lastrst2;
1241 p2drst2 = rst2->Value(vpoint);
1242 gp_Pnt thepoint = surf2->Value(p2drst2.X(), p2drst2.Y());
1244 FinvP.Set(thepoint);
1245 math_Vector toler(1,2), infb(1, 2), supb(1, 2);
1246 FinvP.GetTolerance(toler, tolesp);
1247 FinvP.GetBounds(infb, supb);
1251 math_FunctionSetRoot rsnld(FinvP, toler, 30);
1252 rsnld.Perform(FinvP, Solinv, infb, supb);
1253 if (!rsnld.IsDone()) {
1254 cout << "RSNLD not done "<< endl << endl;
1255 return Standard_False;
1259 if(FinvP.IsSolution(Solinv, tolesp)){
1260 gp_Pnt2d p2drst1 = rst1->Value(Solinv(2));
1261 TopAbs_State situ = domain1->Classify(p2drst1, toler(2), 0);
1262 if ((situ != TopAbs_IN) && (situ != TopAbs_ON)) {
1263 return Standard_False;
1265 domain2->Initialize(rst2);
1266 domain2->InitVertexIterator();
1267 IsVtx = !domain2->MoreVertex();
1269 Vtx = domain2->Vertex();
1270 if (Abs(BRepBlend_BlendTool::Parameter(Vtx, rst2) - vpoint) <=
1271 BRepBlend_BlendTool::Tolerance(Vtx, rst2)) {
1272 IsVtx = Standard_True;
1275 domain2->NextVertex();
1276 IsVtx = !domain2->MoreVertex();
1279 if (!domain2->MoreVertex()) {
1280 IsVtx = Standard_False;
1282 return Standard_True;
1284 return Standard_False;
1288 //=======================================================================
1289 //function : Transition
1291 //=======================================================================
1293 void BRepBlend_RstRstLineBuilder::Transition(const Standard_Boolean OnFirst,
1294 const Handle(Adaptor2d_HCurve2d)& Arc,
1295 const Standard_Real Param,
1296 IntSurf_Transition& TLine,
1297 IntSurf_Transition& TArc)
1299 Standard_Boolean computetranstionaveclacorde = 0;
1301 Blend_Point prevprev;
1303 if(previousP.IsTangencyPoint()){
1304 if(line->NbPoints() < 2) return;
1305 computetranstionaveclacorde = 1;
1307 prevprev = line->Point(2);
1310 prevprev = line->Point(line->NbPoints() - 1);
1317 gp_Vec d1u, d1v, normale, tgrst;
1319 Arc->D1(Param, p2d, dp2d);
1321 surf1->D1(p2d.X(), p2d.Y(), pbid, d1u, d1v);
1322 if(!computetranstionaveclacorde) tgline = previousP.TangentOnC1();
1323 else tgline = gp_Vec(prevprev.PointOnC1(), previousP.PointOnC1());
1326 surf2->D1(p2d.X(), p2d.Y(), pbid, d1u, d1v);
1327 if(!computetranstionaveclacorde) tgline = previousP.TangentOnC2();
1328 else tgline = gp_Vec(prevprev.PointOnC2(), previousP.PointOnC2());
1331 tgrst.SetLinearForm(dp2d.X(), d1u, dp2d.Y(), d1v);
1332 normale = d1u.Crossed(d1v);
1334 IntSurf::MakeTransition(tgline, tgrst, normale, TLine, TArc);
1337 //=======================================================================
1338 //function : MakeExtremity
1339 //purpose : produce the extremity of a curve
1340 //=======================================================================
1342 void BRepBlend_RstRstLineBuilder::MakeExtremity(BRepBlend_Extremity& Extrem,
1343 const Standard_Boolean OnFirst,
1344 const Handle(Adaptor2d_HCurve2d)& Arc,
1345 const Standard_Real Param,
1346 const Standard_Boolean IsVtx,
1347 const Handle(Adaptor3d_HVertex)& Vtx)
1349 IntSurf_Transition Tline, Tarc;
1351 Handle(Adaptor3d_TopolTool) Iter;
1353 Extrem.SetValue(previousP.PointOnC1(),
1355 previousP.Parameter(), tolesp);
1356 if (!previousP.IsTangencyPoint())
1357 Extrem.SetTangent(previousP.TangentOnC1());
1361 Extrem.SetValue(previousP.PointOnC2(),
1363 previousP.Parameter(), tolesp);
1364 if (!previousP.IsTangencyPoint())
1365 Extrem.SetTangent(previousP.TangentOnC1());
1371 Transition(OnFirst, Arc, Param, Tline, Tarc);
1372 Extrem.AddArc(Arc, Param, Tline, Tarc);
1375 Extrem.SetVertex(Vtx);
1376 while (Iter->More()) {
1377 Handle(Adaptor2d_HCurve2d) arc = Iter->Value();
1379 Iter->Initialize(arc);
1380 Iter->InitVertexIterator();
1381 while (Iter->MoreVertex()) {
1382 if (Iter->Identical(Vtx, Iter->Vertex())) {
1383 prm = BRepBlend_BlendTool::Parameter(Vtx, arc);
1384 Transition(OnFirst, arc, prm, Tline, Tarc);
1385 Extrem.AddArc(arc, prm, Tline, Tarc);
1391 Transition(OnFirst, arc, Param, Tline, Tarc);
1392 Extrem.AddArc(arc, Param, Tline, Tarc);
1399 //=======================================================================
1400 //function : CheckDeflectionOnRst1
1402 //=======================================================================
1404 Blend_Status BRepBlend_RstRstLineBuilder::CheckDeflectionOnRst1(const Blend_Point& CurPoint)
1406 //Controls 3d of Blend_CSWalking.
1408 // rule by tests in U4 corresponds to 11.478
1409 const Standard_Real CosRef3D = 0.98;
1410 Standard_Real Cosi, Cosi2;
1411 Standard_Boolean curpointistangent = CurPoint.IsTangencyPoint();
1412 Standard_Boolean prevpointistangent = previousP.IsTangencyPoint();
1414 gp_Pnt Psurf = CurPoint.PointOnC1();
1416 if(!curpointistangent){
1417 Tgsurf = CurPoint.TangentOnC1();
1419 gp_Pnt prevP = previousP.PointOnC1();
1421 if(!prevpointistangent){
1422 prevTg = previousP.TangentOnC1();
1424 Standard_Real Norme;
1425 Standard_Real prevNorme = 0.;
1426 gp_Vec Corde(prevP, Psurf);
1427 Norme = Corde.SquareMagnitude();
1428 if (!prevpointistangent) prevNorme = prevTg.SquareMagnitude();
1430 if (Norme <= tolesp * tolesp) {
1431 // it can be necessary to force the same point
1432 return Blend_SamePoints;
1434 if(!prevpointistangent){
1435 if (prevNorme <= tolesp * tolesp) {
1436 return Blend_SamePoints;
1438 Cosi = sens * Corde * prevTg;
1439 if (Cosi < 0.) { // angle 3d>pi/2. --> return back
1440 return Blend_Backward;
1443 Cosi2 = Cosi * Cosi / prevNorme / Norme;
1444 if (Cosi2 < CosRef3D) {
1445 return Blend_StepTooLarge;
1449 if(!curpointistangent){
1450 // Check if it is necessary to control the sign of prevtg*Tgsurf
1451 Cosi = sens * Corde * Tgsurf;
1452 Cosi2 = Cosi * Cosi / Tgsurf.SquareMagnitude() / Norme;
1453 if (Cosi2 < CosRef3D || Cosi < 0.) {
1454 return Blend_StepTooLarge;
1458 if (!curpointistangent && !prevpointistangent) {
1459 // Estimation of the current arrow
1460 Standard_Real FlecheCourante =
1461 (prevTg.Normalized().XYZ() - Tgsurf.Normalized().XYZ()).SquareModulus() * Norme / 64.;
1463 if (FlecheCourante <= 0.25 * fleche * fleche) {
1464 return Blend_StepTooSmall;
1466 if (FlecheCourante > fleche * fleche) {
1468 return Blend_StepTooLarge;
1475 //=======================================================================
1476 //function : CheckDeflectionOnRst2
1478 //=======================================================================
1480 Blend_Status BRepBlend_RstRstLineBuilder::CheckDeflectionOnRst2(const Blend_Point& CurPoint)
1482 //3D Controls of Blend_CSWalking.
1484 // rule by tests in U4 corresponding to 11.478 d
1485 const Standard_Real CosRef3D = 0.98;
1486 Standard_Real Cosi, Cosi2;
1487 Standard_Boolean curpointistangent = CurPoint.IsTangencyPoint();
1488 Standard_Boolean prevpointistangent = previousP.IsTangencyPoint();
1490 gp_Pnt Psurf = CurPoint.PointOnC2();
1493 if (!curpointistangent) {
1494 Tgsurf = CurPoint.TangentOnC2();
1496 gp_Pnt prevP = previousP.PointOnC2();
1498 if (!prevpointistangent) {
1499 prevTg = previousP.TangentOnC2();
1501 Standard_Real Norme;
1502 Standard_Real prevNorme = 0.;
1503 gp_Vec Corde(prevP, Psurf);
1504 Norme = Corde.SquareMagnitude();
1505 if (!prevpointistangent) prevNorme = prevTg.SquareMagnitude();
1507 if (Norme <= tolesp * tolesp){
1508 // it can be necessary to force the same point
1509 return Blend_SamePoints;
1511 if (!prevpointistangent) {
1512 if (prevNorme <= tolesp * tolesp) {
1513 return Blend_SamePoints;
1515 Cosi = sens * Corde * prevTg;
1516 if (Cosi < 0.) { // angle 3d>pi/2. --> return back
1517 return Blend_Backward;
1520 Cosi2 = Cosi * Cosi / prevNorme / Norme;
1521 if (Cosi2 < CosRef3D) {
1522 return Blend_StepTooLarge;
1526 if (!curpointistangent) {
1527 // Check if it is necessary to control the sign of prevtg*Tgsurf
1528 Cosi = sens * Corde * Tgsurf;
1529 Cosi2 = Cosi * Cosi / Tgsurf.SquareMagnitude() / Norme;
1530 if (Cosi2 < CosRef3D || Cosi < 0.) {
1531 return Blend_StepTooLarge;
1535 if(!curpointistangent && !prevpointistangent){
1536 // Estimation of the current arrow
1537 Standard_Real FlecheCourante =
1538 (prevTg.Normalized().XYZ() - Tgsurf.Normalized().XYZ()).SquareModulus() * Norme/64.;
1540 if (FlecheCourante <= 0.25 * fleche * fleche) {
1541 return Blend_StepTooSmall;
1543 if (FlecheCourante > fleche * fleche) {
1545 return Blend_StepTooLarge;
1551 static IntSurf_TypeTrans ConvOrToTra(const TopAbs_Orientation O)
1553 if(O == TopAbs_FORWARD) return IntSurf_In;
1557 //=======================================================================
1558 //function : TestArret
1560 //=======================================================================
1562 Blend_Status BRepBlend_RstRstLineBuilder::TestArret(Blend_RstRstFunction& Func,
1563 const Standard_Boolean TestDeflection,
1564 const Blend_Status State)
1566 gp_Pnt ptrst1, ptrst2;
1567 gp_Pnt2d pt2drst1, pt2drst2;
1568 gp_Vec tgrst1, tgrst2;
1569 gp_Vec2d tg2drst1, tg2drst2;
1570 Blend_Status StateRst1, StateRst2;
1571 IntSurf_TypeTrans trarst1 = IntSurf_Undecided, trarst2 = IntSurf_Undecided;
1572 Blend_Point curpoint;
1574 if (Func.IsSolution(sol, tolesp)) {
1575 Standard_Boolean curpointistangent = Func.IsTangencyPoint();
1576 ptrst1 = Func.PointOnRst1();
1577 ptrst2 = Func.PointOnRst2();
1578 pt2drst1 = Func.Pnt2dOnRst1();
1579 pt2drst2 = Func.Pnt2dOnRst2();
1581 if(curpointistangent){
1582 curpoint.SetValue(ptrst1, ptrst2, param, pt2drst1.X(), pt2drst1.Y(),
1583 pt2drst2.X(), pt2drst2.Y(), sol(1), sol(2));
1586 tgrst1 = Func.TangentOnRst1();
1587 tgrst2 = Func.TangentOnRst2();
1588 tg2drst1 = Func.Tangent2dOnRst1();
1589 tg2drst2 = Func.Tangent2dOnRst2();
1590 curpoint.SetValue(ptrst1, ptrst2, param, pt2drst1.X(), pt2drst1.Y(),
1591 pt2drst2.X(), pt2drst2.Y(), sol(1), sol(2),
1592 tgrst1, tgrst2, tg2drst1, tg2drst2);
1594 if (TestDeflection) {
1595 StateRst1 = CheckDeflectionOnRst1(curpoint);
1596 StateRst2 = CheckDeflectionOnRst2(curpoint);
1599 StateRst1 = StateRst2 = Blend_OK;
1601 if (StateRst1 == Blend_Backward) {
1602 StateRst1 = Blend_StepTooLarge;
1603 rebrou = Standard_True;
1605 if (StateRst2 == Blend_Backward) {
1606 StateRst2 = Blend_StepTooLarge;
1607 rebrou = Standard_True;
1609 if (StateRst1 == Blend_StepTooLarge ||
1610 StateRst2 == Blend_StepTooLarge) {
1611 return Blend_StepTooLarge;
1614 if (!comptra && !curpointistangent) {
1616 gp_Vec2d tg2drstref;
1617 rst1->D1(sol(1), p2drstref, tg2drstref);
1618 Standard_Real testra = tg2drst1.Dot(tg2drstref);
1619 TopAbs_Orientation Or = domain1->Orientation(rst1);
1621 if (Abs(testra) > tolesp) {
1623 trarst1 = ConvOrToTra(TopAbs::Reverse(Or));
1625 else if (testra >0.) {
1626 trarst1 = ConvOrToTra(Or);
1629 rst2->D1(sol(2), p2drstref, tg2drstref);
1630 testra = tg2drst2.Dot(tg2drstref);
1632 Or = domain2->Orientation(rst2);
1633 if (Abs(testra) > tolesp) {
1635 trarst2 = ConvOrToTra(TopAbs::Reverse(Or));
1637 else if (testra >0.) {
1638 trarst2 = ConvOrToTra(Or);
1640 comptra = Standard_True;
1641 line->Set(trarst1, trarst2);
1645 if (StateRst1 == Blend_OK ||
1646 StateRst2 == Blend_OK ) {
1647 previousP = curpoint;
1650 if (StateRst1 == Blend_StepTooSmall &&
1651 StateRst2 == Blend_StepTooSmall) {
1652 previousP = curpoint;
1653 if (State == Blend_OK) {
1654 return Blend_StepTooSmall;
1660 if (State == Blend_OK) {
1661 return Blend_SamePoints;
1667 return Blend_StepTooLarge;
1670 //=======================================================================
1671 //function : CheckInside
1673 //=======================================================================
1675 Standard_Boolean BRepBlend_RstRstLineBuilder::CheckInside(Blend_RstRstFunction& Func,
1676 TopAbs_State& SituOnC1,
1677 TopAbs_State& SituOnC2,
1678 Blend_DecrochStatus & Decroch)
1680 // Standard_Boolean inside = Standard_True;
1681 math_Vector tolerance(1, 2);
1682 Func.GetTolerance(tolerance, tolesp);
1685 Standard_Real v = sol(1);
1686 if(v < rst1->FirstParameter() - tolerance(2)||
1687 v > rst1->LastParameter() + tolerance(2)){
1688 SituOnC1 = TopAbs_OUT;
1690 else if (v > rst1->FirstParameter() &&
1691 v < rst1->LastParameter()){
1692 SituOnC1 = TopAbs_IN;
1694 else SituOnC1 = TopAbs_ON;
1698 if(v < rst2->FirstParameter() - tolerance(2)||
1699 v > rst2->LastParameter() + tolerance(2)){
1700 SituOnC2 = TopAbs_OUT;
1702 else if (v > rst2->FirstParameter() &&
1703 v < rst2->LastParameter()){
1704 SituOnC2 = TopAbs_IN;
1706 else SituOnC2 = TopAbs_ON;
1710 gp_Vec tgrst1, norst1, tgrst2, norst2;
1711 Decroch = Func.Decroch(sol,tgrst1, norst1, tgrst2, norst2);
1713 return (SituOnC1 == TopAbs_IN && SituOnC2 == TopAbs_IN && Decroch == Blend_NoDecroch);