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.
18 #include <Adaptor2d_HCurve2d.hxx>
19 #include <Adaptor3d_HSurface.hxx>
20 #include <Adaptor3d_HVertex.hxx>
21 #include <Adaptor3d_TopolTool.hxx>
22 #include <Blend_CurvPointFuncInv.hxx>
23 #include <Blend_Point.hxx>
24 #include <Blend_RstRstFunction.hxx>
25 #include <Blend_SurfCurvFuncInv.hxx>
26 #include <BRepBlend_BlendTool.hxx>
27 #include <BRepBlend_Extremity.hxx>
28 #include <BRepBlend_Line.hxx>
29 #include <BRepBlend_RstRstLineBuilder.hxx>
31 #include <gp_Pnt2d.hxx>
33 #include <gp_Vec2d.hxx>
34 #include <IntSurf.hxx>
35 #include <IntSurf_Transition.hxx>
36 #include <math_FunctionSetRoot.hxx>
41 #include <TColStd_Array1OfInteger.hxx>
42 #include <TColStd_Array1OfReal.hxx>
43 #include <TColgp_Array1OfPnt2d.hxx>
44 #include <TColgp_Array1OfVec.hxx>
45 #include <TColgp_Array1OfVec2d.hxx>
46 #include <TColgp_Array1OfPnt.hxx>
47 #include <Geom_BSplineCurve.hxx>
49 #include <DrawTrSurf.hxx>
51 static Standard_Integer IndexOfSection = 0;
52 extern Standard_Boolean Blend_GettraceDRAWSECT();
54 #ifdef OCCT_DEBUG_BBPP_N_TRDERIV
55 //-----------------------------------------------------
56 // For debug : visualisation of the section
57 static Standard_Boolean BBPP(const Standard_Real param,
58 Blend_RstRstFunction& Func,
59 const math_Vector& sol,
60 const Standard_Real tol,
63 if(!Func.IsSolution(sol,tol)) return 0;
64 gp_Pnt pntrst1 = Func.PointOnRst1();
65 gp_Pnt pntrst2 = Func.PointOnRst2();
66 gp_Pnt2d p2drst1 = Func.Pnt2dOnRst1();
67 gp_Pnt2d p2drst2 = Func.Pnt2dOnRst2();
68 Standard_Real w1 = Func.ParameterOnRst1();
69 Standard_Real w2 = Func.ParameterOnRst2();
70 BP = Blend_Point(pntrst1, pntrst2, param,
71 p2drst1.X(), p2drst1.Y(),
72 p2drst2.X(), p2drst2.Y(), w1, w2);
77 //-----------------------------------------------------
78 static void tracederiv(Blend_RstRstFunction& Func,
79 const Blend_Point& BP1,
80 const Blend_Point& BP2)
82 Standard_Integer hp,hk,hd,hp2d,i;
83 Func.GetShape(hp,hk,hd,hp2d);
84 TColgp_Array1OfPnt TP1(1,hp);
85 TColgp_Array1OfVec TDP1(1,hp);
86 TColgp_Array1OfPnt2d TP2d1(1,hp2d);
87 TColgp_Array1OfVec2d TDP2d1(1,hp2d);
88 TColStd_Array1OfReal TW1(1,hp);
89 TColStd_Array1OfReal TDW1(1,hp);
90 Func.Section(BP1, TP1,TDP1,TP2d1,TDP2d1,TW1,TDW1);
92 TColgp_Array1OfPnt TP2(1,hp);
93 TColgp_Array1OfVec TDP2(1,hp);
94 TColgp_Array1OfPnt2d TP2d2(1,hp2d);
95 TColgp_Array1OfVec2d TDP2d2(1,hp2d);
96 TColStd_Array1OfReal TW2(1,hp);
97 TColStd_Array1OfReal TDW2(1,hp);
98 Func.Section(BP2,TP2,TDP2,TP2d2,TDP2d2,TW2,TDW2);
100 Standard_Real param1 = BP1.Parameter();
101 Standard_Real param2 = BP2.Parameter();
102 Standard_Real scal = 1./ (param1 - param2);
104 std::cout<<std::endl;
105 std::cout<<"control of derivatives at point : "<<param1<<std::endl;
107 for(i = 1; i <= hp; i++){
108 std::cout<<std::endl;
109 std::cout<<"point : "<<i<<std::endl;
110 std::cout<<"dx calculated : "<<TDP1(i).X()<<std::endl;
111 std::cout<<"dx estimated : "<<scal*(TP1(i).X()-TP2(i).X())<<std::endl;
112 std::cout<<"dy calculated : "<<TDP1(i).Y()<<std::endl;
113 std::cout<<"dy estimated : "<<scal*(TP1(i).Y()-TP2(i).Y())<<std::endl;
114 std::cout<<"dz calculated : "<<TDP1(i).Z()<<std::endl;
115 std::cout<<"dz estimated : "<<scal*(TP1(i).Z()-TP2(i).Z())<<std::endl;
116 std::cout<<"dw calculated : "<<TDW1(i)<<std::endl;
117 std::cout<<"dw estimated : "<<scal*(TW1(i)-TW2(i))<<std::endl;
119 for(i = 1; i <= hp2d; i++){
120 std::cout<<std::endl;
121 std::cout<<"point 2d : "<<i<<std::endl;
122 std::cout<<"dx calculated : "<<TDP2d1(i).X()<<std::endl;
123 std::cout<<"dx estimated : "<<scal*(TP2d1(i).X()-TP2d2(i).X())<<std::endl;
124 std::cout<<"dy calculated : "<<TDP2d1(i).Y()<<std::endl;
125 std::cout<<"dy estimated : "<<scal*(TP2d1(i).Y()-TP2d2(i).Y())<<std::endl;
130 //-----------------------------------------------------
131 static void Drawsect(const Standard_Real param,
132 Blend_RstRstFunction& Func)
134 gp_Pnt pntrst1 = Func.PointOnRst1();
135 gp_Pnt pntrst2 = Func.PointOnRst2();
136 gp_Pnt2d p2drst1 = Func.Pnt2dOnRst1();
137 gp_Pnt2d p2drst2 = Func.Pnt2dOnRst2();
138 Standard_Real u = Func.ParameterOnRst1();
139 Standard_Real v = Func.ParameterOnRst2();
140 Blend_Point BP(pntrst1, pntrst2, param,
141 p2drst1.X(), p2drst1.Y(),
142 p2drst2.X(), p2drst2.Y(), u, v);
143 Standard_Integer hp,hk,hd,hp2d;
144 Func.GetShape(hp,hk,hd,hp2d);
145 TColStd_Array1OfReal TK(1,hk);
147 TColStd_Array1OfInteger TMul(1,hk);
149 TColgp_Array1OfPnt TP(1,hp);
150 TColgp_Array1OfPnt2d TP2d(1,hp2d);
151 TColStd_Array1OfReal TW(1,hp);
152 Func.Section(BP,TP,TP2d,TW);
153 Handle(Geom_BSplineCurve) sect = new Geom_BSplineCurve
158 Standard_CString name = tname ;
159 sprintf(name,"%s_%d","Section",IndexOfSection);
160 DrawTrSurf::Set(name,sect);
165 //=======================================================================
166 //function : BRepBlend_RstRstLineBuilder
168 //=======================================================================
170 BRepBlend_RstRstLineBuilder::BRepBlend_RstRstLineBuilder
171 (const Handle(Adaptor3d_HSurface)& Surf1,
172 const Handle(Adaptor2d_HCurve2d)& Rst1,
173 const Handle(Adaptor3d_TopolTool)& Domain1,
174 const Handle(Adaptor3d_HSurface)& Surf2,
175 const Handle(Adaptor2d_HCurve2d)& Rst2,
176 const Handle(Adaptor3d_TopolTool)& Domain2):
177 sol(1,2), surf1(Surf1), domain1(Domain1),
178 surf2(Surf2), domain2(Domain2), rst1(Rst1), rst2(Rst2)
182 //=======================================================================
184 //purpose : launch the processing
185 //=======================================================================
187 void BRepBlend_RstRstLineBuilder::Perform(Blend_RstRstFunction& Func,
188 Blend_SurfCurvFuncInv& Finv1,
189 Blend_CurvPointFuncInv& FinvP1,
190 Blend_SurfCurvFuncInv& Finv2,
191 Blend_CurvPointFuncInv& FinvP2,
192 const Standard_Real Pdep,
193 const Standard_Real Pmax,
194 const Standard_Real MaxStep,
195 const Standard_Real TolGuide,
196 const math_Vector& ParDep,
197 const Standard_Real Tolesp,
198 const Standard_Real Fleche,
199 const Standard_Boolean Appro)
201 done = Standard_False;
202 iscomplete = Standard_False;
203 comptra = Standard_False;
204 line = new BRepBlend_Line();
205 tolesp = Abs(Tolesp);
206 tolgui = Abs(TolGuide);
207 fleche = Abs(Fleche);
208 rebrou = Standard_False;
209 pasmax = Abs(MaxStep);
211 if (Pmax - Pdep >= 0.) {
224 TopAbs_State siturst1, siturst2;
225 Blend_DecrochStatus decroch;
226 math_Vector tolerance(1, 2), infbound(1, 2), supbound(1, 2);
227 Func.GetTolerance(tolerance, tolesp);
228 Func.GetBounds(infbound, supbound);
229 math_FunctionSetRoot rsnld(Func, tolerance, 30);
231 rsnld.Perform(Func, ParDep, infbound, supbound);
233 if (!rsnld.IsDone()) {
237 if (!CheckInside(Func, siturst1, siturst2, decroch)) {
245 State = TestArret(Func, Standard_False, Blend_OK);
246 if (State != Blend_OK) {
250 if (Blend_GettraceDRAWSECT()){
251 Drawsect(param, Func);
255 line->Append(previousP);
257 U = previousP.ParameterOnC1();
258 V = previousP.ParameterOnC2();
259 BRepBlend_Extremity ptf1 (previousP.PointOnC1(),
260 U, previousP.Parameter(),tolesp);
261 BRepBlend_Extremity ptf2 (previousP.PointOnC2(),
262 V, previousP.Parameter(),tolesp);
263 if (!previousP.IsTangencyPoint()) {
264 ptf1.SetTangent(previousP.TangentOnC1());
265 ptf2.SetTangent(previousP.TangentOnC2());
269 line->SetStartPoints(ptf1, ptf2);
272 line->SetEndPoints(ptf1, ptf2);
275 InternalPerform(Func, Finv1, FinvP1, Finv2, FinvP2, Pmax);
276 done = Standard_True;
279 //=======================================================================
280 //function : PerformFirstSection
281 //purpose : Creation of the first section
282 //=======================================================================
284 Standard_Boolean BRepBlend_RstRstLineBuilder::PerformFirstSection
285 (Blend_RstRstFunction& Func,
286 Blend_SurfCurvFuncInv& Finv1,
287 Blend_CurvPointFuncInv& FinvP1,
288 Blend_SurfCurvFuncInv& Finv2,
289 Blend_CurvPointFuncInv& FinvP2,
290 const Standard_Real Pdep,
291 const Standard_Real Pmax,
292 const math_Vector& ParDep,
293 const Standard_Real Tolesp,
294 const Standard_Real TolGuide,
295 const Standard_Boolean RecRst1,
296 const Standard_Boolean RecP1,
297 const Standard_Boolean RecRst2,
298 const Standard_Boolean RecP2,
302 done = Standard_False;
303 iscomplete = Standard_False;
304 comptra = Standard_False;
305 line = new BRepBlend_Line();
306 tolesp = Abs(Tolesp);
307 tolgui = Abs(TolGuide);
308 rebrou = Standard_False;
310 if (Pmax - Pdep >= 0.) {
317 Standard_Boolean recadp1, recadp2, recadrst1, recadrst2;
318 Standard_Real wp1, wp2, wrst1, wrst2;
319 Blend_Status State = Blend_OnRst12;
320 Standard_Real trst11 = 0., trst12 = 0., trst21 = 0., trst22 = 0.;
321 math_Vector infbound(1, 2), supbound(1, 2), tolerance(1, 2);
322 math_Vector solinvp1(1, 2), solinvp2(1, 2), solinvrst1(1, 3), solinvrst2(1, 3);
323 Handle(Adaptor3d_HVertex) Vtxp1, Vtxp2, Vtxrst1, Vtxrst2, Vtxc;
324 Standard_Boolean IsVtxp1 = 0, IsVtxp2 = 0, IsVtxrst1 = 0, IsVtxrst2 = 0;
325 Handle(Adaptor2d_HCurve2d) Arc;
326 wp1 = wp2 = wrst1 = wrst2 = Pmax;
329 Func.GetTolerance(tolerance, tolesp);
330 Func.GetBounds(infbound, supbound);
332 math_FunctionSetRoot rsnld(Func, tolerance, 30);
333 rsnld.Perform(Func, ParDep, infbound, supbound);
334 if (!rsnld.IsDone()) return Standard_False;
337 recadrst1 = RecRst1 && Recadre1(Func, Finv1, solinvrst1, IsVtxrst1, Vtxrst1);
339 wrst1 = solinvrst1(1);
342 recadp1 = RecP1 && Recadre1(FinvP1, solinvp1, IsVtxp1, Vtxp1);
347 recadrst2 = RecRst2 && Recadre2(Func, Finv2, solinvrst2, IsVtxrst2, Vtxrst2);
349 wrst2 = solinvrst2(1);
352 recadp2 = RecP2 && Recadre2(FinvP2, solinvp2, IsVtxp2, Vtxp2);
357 if (!recadrst1 && !recadp1 && !recadrst2 && !recadp2) return Standard_False;
360 // it is checked if the contact was lost or domain 1 was left
361 if (recadp1 && recadrst1) {
362 if (sens * (wrst1 - wp1) > tolgui){ //at first one leaves the domain
364 trst12 = solinvp1(2);
365 trst11 = BRepBlend_BlendTool::Parameter(Vtxp1, rst1);
368 recadrst1 = Standard_False;
370 else { // the contact is lost
371 trst11 = solinvrst1(3);
372 trst12 = solinvrst1(2);
373 recadp1 = Standard_False;
378 trst12 = solinvp1(2);
379 trst11 = BRepBlend_BlendTool::Parameter(Vtxp1, rst1);
383 else if (recadrst1) {
384 trst11 = solinvrst1(3);
385 trst12 = solinvrst1(2);
388 // it is checked if the contact was lost or domain 2 was left
389 if (recadp2 && recadrst2) {
390 if (sens * (wrst2 - wp2) > tolgui) { //at first one leaves the domain
392 trst21 = solinvp2(2);
393 trst22 = BRepBlend_BlendTool::Parameter(Vtxp2, rst2);
396 recadrst2 = Standard_False;
399 trst22 = solinvrst2(3);
400 trst21 = solinvrst2(2);
401 recadp2 = Standard_False;
406 trst21 = solinvp2(2);
407 trst22 = BRepBlend_BlendTool::Parameter(Vtxp2, rst2);
411 else if (recadrst2) {
412 trst22 = solinvrst2(3);
413 trst21 = solinvrst2(2);
416 // it is checked on which curve the contact is lost earlier
417 if (recadrst1 && recadrst2) {
418 if (Abs(wrst1 - wrst2) < tolgui) {
419 State = Blend_OnRst12;
420 param = 0.5 * (wrst1 + wrst2);
424 else if (sens * (wrst1 - wrst2) < 0) {
425 // contact lost on Rst1
426 State = Blend_OnRst1;
432 // contact lost on rst2
433 State = Blend_OnRst2;
440 else if (recadrst1) {
442 State = Blend_OnRst1;
448 else if (recadrst2) {
450 State = Blend_OnRst2;
456 // it is checked on which curves one leaves first
457 else if (recadp1 && recadp2) {
458 if (Abs(wrst1 - wrst2) < tolgui) {
459 State = Blend_OnRst12;
460 param = 0.5 * (wrst1 + wrst2);
464 else if (sens * (wrst1 - wrst2) < 0) {
466 State = Blend_OnRst1;
473 State = Blend_OnRst2;
482 State = Blend_OnRst1;
490 State = Blend_OnRst2;
497 State = TestArret(Func, Standard_False, State);
500 return Standard_True;
503 //=======================================================================
504 //function : Complete
506 //=======================================================================
508 Standard_Boolean BRepBlend_RstRstLineBuilder::Complete(Blend_RstRstFunction& Func,
509 Blend_SurfCurvFuncInv& Finv1,
510 Blend_CurvPointFuncInv& FinvP1,
511 Blend_SurfCurvFuncInv& Finv2,
512 Blend_CurvPointFuncInv& FinvP2,
513 const Standard_Real Pmin)
515 if (!done) {throw StdFail_NotDone();}
516 if (iscomplete) {return Standard_True;}
518 previousP = line->Point(1);
521 previousP = line->Point(line->NbPoints());
524 param = previousP.Parameter();
525 sol(1) = previousP.ParameterOnC1();
526 sol(2) = previousP.ParameterOnC2();
528 InternalPerform(Func, Finv1, FinvP1, Finv2, FinvP2, Pmin);
529 iscomplete = Standard_True;
530 return Standard_True;
533 //=======================================================================
534 //function : InternalPerform
535 //purpose : algorithm of processing without extremities
536 //=======================================================================
538 void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction& Func,
539 Blend_SurfCurvFuncInv& Finv1,
540 Blend_CurvPointFuncInv& FinvP1,
541 Blend_SurfCurvFuncInv& Finv2,
542 Blend_CurvPointFuncInv& FinvP2,
543 const Standard_Real Bound)
545 Standard_Real stepw = pasmax;
546 Standard_Integer nbp = line->NbPoints();
547 if(nbp >= 2){ //The last step is redone if it is not too small.
549 stepw = (line->Point(2).Parameter() - line->Point(1).Parameter());
552 stepw = (line->Point(nbp).Parameter() - line->Point(nbp - 1).Parameter());
554 stepw = Max(stepw, 100. * tolgui);
556 Standard_Real parprec = param;
557 if (sens* (parprec - Bound) >= -tolgui) {
560 Blend_Status State = Blend_OnRst12;
561 Standard_Real trst11 = 0., trst12 = 0., trst21 = 0., trst22 = 0.;
562 TopAbs_State situonc1 = TopAbs_UNKNOWN, situonc2 = TopAbs_UNKNOWN;
563 Blend_DecrochStatus decroch = Blend_NoDecroch;
564 Standard_Boolean Arrive, recadp1, recadp2, recadrst1, recadrst2, echecrecad;
565 Standard_Real wp1, wp2, wrst1, wrst2;
566 math_Vector infbound(1, 2), supbound(1, 2);
567 math_Vector parinit(1, 2), tolerance(1, 2);
568 math_Vector solinvp1(1, 2), solinvp2(1, 2), solinvrst1(1, 3), solinvrst2(1, 3);
569 Handle(Adaptor3d_HVertex) Vtxp1, Vtxp2, Vtxrst1, Vtxrst2;
570 Standard_Boolean IsVtxp1 = 0, IsVtxp2 = 0, IsVtxrst1 = 0, IsVtxrst2 = 0;
571 BRepBlend_Extremity Extrst1, Extrst2;
573 //IntSurf_Transition Tline, Tarc;
575 Func.GetTolerance(tolerance, tolesp);
576 Func.GetBounds(infbound, supbound);
578 math_FunctionSetRoot rsnld(Func, tolerance, 30);
581 Arrive = Standard_False;
582 param = parprec + sens * stepw;
583 if (sens * (param - Bound) > 0.) {
584 stepw = sens * (Bound - parprec) * 0.5;
585 param = parprec + sens * stepw;
589 Standard_Boolean bonpoint = 1;
590 #ifdef OCCT_DEBUG_BBPP_N_TRDERIV
593 rsnld.Perform(Func, parinit, infbound, supbound);
594 if (rsnld.IsDone()) {
597 if(BBPP(param, Func, sol, tolesp, bp1)){
598 Standard_Real dw = 1.e-10;
599 Func.Set(param + dw);
600 rsnld.Perform(Func, parinit, infbound, supbound);
601 if (rsnld.IsDone()) {
604 if(BBPP(param + dw, Func, sol, tolesp, bp2)){
605 tracederiv(Func, bp1, bp2);
613 rsnld.Perform(Func, parinit, infbound, supbound);
615 if (rsnld.IsDone()) {
617 if(!CheckInside(Func, situonc1, situonc2, decroch) && line->NbPoints() == 1){
618 State = Blend_StepTooLarge;
623 State = Blend_StepTooLarge;
627 wp1 = wp2 = wrst1 = wrst2 = Bound;
628 recadp1 = recadp2 = recadrst1 = recadrst2 = Standard_False;
629 echecrecad = Standard_False;
630 if (situonc1 != TopAbs_IN) {
631 // pb inversion rst/rst
632 recadp1 = Recadre1(FinvP1, solinvp1, IsVtxp1, Vtxp1);
637 echecrecad = Standard_True;
641 if (situonc2 != TopAbs_IN) {
642 // pb inversion point/surf
643 recadp2 = Recadre2(FinvP2, solinvp2, IsVtxp2, Vtxp2);
648 echecrecad = Standard_True;
652 if (decroch == Blend_DecrochRst1 || decroch == Blend_DecrochBoth) {
653 // pb inversion rst1/surf1
654 recadrst1 = Recadre1(Func, Finv1, solinvrst1, IsVtxrst1, Vtxrst1);
656 wrst1 = solinvrst1(1);
659 echecrecad = Standard_True;
663 if (decroch == Blend_DecrochRst2 || decroch == Blend_DecrochBoth) {
664 // pb inverse rst2/surf2
665 recadrst2 = Recadre2(Func, Finv2, solinvrst2, IsVtxrst2, Vtxrst2);
667 wrst2 = solinvrst2(1);
670 echecrecad = Standard_True;
674 decroch = Blend_NoDecroch;
675 if (recadp1 || recadp2 || recadrst1 || recadrst2) echecrecad = Standard_False;
678 // it is checked if the contact was lost or domain 1 was left
679 if (recadp1 && recadrst1) {
680 if (sens * (wrst1 - wp1) > tolgui){ //first one leaves the domain
682 trst12 = solinvp1(2);
683 trst11 = BRepBlend_BlendTool::Parameter(Vtxp1, rst1);
686 recadrst1 = Standard_False;
688 else { // contact is lost
689 trst11 = solinvrst1(3);
690 trst12 = solinvrst1(2);
691 recadp1 = Standard_False;
696 trst12 = solinvp1(2);
697 trst11 = BRepBlend_BlendTool::Parameter(Vtxp1, rst1);
701 else if (recadrst1) {
702 trst11 = solinvrst1(3);
703 trst12 = solinvrst1(2);
706 // it is checked if the contact was lost or domain 2 was left
707 if (recadp2 && recadrst2) {
708 if (sens * (wrst2 - wp2) > tolgui) { //first one leaves the domain
710 trst21 = solinvp2(2);
711 trst22 = BRepBlend_BlendTool::Parameter(Vtxp2, rst2);
714 recadrst2 = Standard_False;
717 trst22 = solinvrst2(3);
718 trst21 = solinvrst2(2);
719 recadp2 = Standard_False;
724 trst21 = solinvp2(2);
725 trst22 = BRepBlend_BlendTool::Parameter(Vtxp2, rst2);
729 else if (recadrst2) {
730 trst22 = solinvrst2(3);
731 trst21 = solinvrst2(2);
734 // it is checked on which curve the contact is lost earlier
735 if (recadrst1 && recadrst2) {
736 if (Abs(wrst1 - wrst2) < tolgui) {
737 State = Blend_OnRst12;
738 decroch = Blend_DecrochBoth;
739 param = 0.5 * (wrst1 + wrst2);
743 else if (sens * (wrst1 - wrst2) < 0) {
744 // contact is lost on Rst1
745 State = Blend_OnRst1;
746 decroch = Blend_DecrochRst1;
752 // contact is lost on rst2
753 State = Blend_OnRst2;
754 decroch = Blend_DecrochRst2;
761 else if (recadrst1) {
763 State = Blend_OnRst1;
764 decroch = Blend_DecrochRst1;
770 else if (recadrst2) {
772 State = Blend_OnRst2;
773 decroch = Blend_DecrochRst2;
779 // it is checked on which curve the contact is lost earlier
780 else if (recadp1 && recadp2) {
781 if (Abs(wrst1 - wrst2) < tolgui) {
782 State = Blend_OnRst12;
783 param = 0.5 * (wrst1 + wrst2);
787 else if (sens * (wrst1 - wrst2) < 0) {
789 State = Blend_OnRst1;
796 State = Blend_OnRst2;
805 State = Blend_OnRst1;
813 State = Blend_OnRst2;
823 State = TestArret(Func, Standard_True, State);
826 // reframing failed. Leave with PointsConfondus
828 std::cout<<"reframing failed"<<std::endl;
830 State = Blend_SamePoints;
838 if (Blend_GettraceDRAWSECT()){
839 Drawsect(param, Func);
844 line->Append(previousP);
847 line->Prepend(previousP);
852 if (param == Bound) {
853 Arrive = Standard_True;
854 Extrst1.SetValue(previousP.PointOnC1(),
855 previousP.ParameterOnC1(),
856 previousP.Parameter(), tolesp);
857 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
858 // Show that end is on Bound.
861 param = param + sens * stepw;
862 if (sens * (param - Bound) > - tolgui) {
869 case Blend_StepTooLarge :
872 if (Abs(stepw) < tolgui) {
873 Extrst1.SetValue(previousP.PointOnC1(),
874 previousP.ParameterOnC1(),
875 previousP.Parameter(), tolesp);
876 Extrst2.SetValue(previousP.PointOnC2(),
877 previousP.ParameterOnC2(),
878 previousP.Parameter(), tolesp);
879 Arrive = Standard_True;
881 if (line->NbPoints()>=2) {
882 // Show that there is a stop during processing
883 std::cout<<"No more advancement in the processing"<<std::endl;
888 param = parprec + sens * stepw; // there is no risk to exceed Bound.
893 case Blend_StepTooSmall :
896 if (Blend_GettraceDRAWSECT()){
897 Drawsect(param,Func);
902 line->Append(previousP);
905 line->Prepend(previousP);
910 stepw = Min(1.5 * stepw, pasmax);
911 if (param == Bound) {
912 Arrive = Standard_True;
913 Extrst1.SetValue(previousP.PointOnC1(),
914 previousP.ParameterOnC1(),
915 previousP.Parameter(), tolesp);
916 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
917 // Indicate that end is on Bound.
920 param = param + sens * stepw;
921 if (sens * (param - Bound) > - tolgui) {
931 if (Blend_GettraceDRAWSECT()){
932 Drawsect(param, Func);
936 line->Append(previousP);
939 line->Prepend(previousP);
941 MakeExtremity(Extrst1, Standard_True, rst1, sol(1), IsVtxrst1, Vtxrst1);
942 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
943 Arrive = Standard_True;
950 if (Blend_GettraceDRAWSECT()){
951 Drawsect(param, Func);
955 line->Append(previousP);
958 line->Prepend(previousP);
961 MakeExtremity(Extrst1, Standard_True, rst1, sol(1), IsVtxrst1, Vtxrst1);
962 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
963 Arrive = Standard_True;
970 if (Blend_GettraceDRAWSECT()){
971 Drawsect(param, Func);
975 line->Append(previousP);
978 line->Prepend(previousP);
981 MakeExtremity(Extrst1, Standard_True, rst1, sol(1), IsVtxrst1, Vtxrst1);
982 MakeExtremity(Extrst2, Standard_False, rst2, sol(2), IsVtxrst2, Vtxrst2);
983 Arrive = Standard_True;
987 case Blend_SamePoints :
991 std::cout << " Mixed points in the processing" << std::endl;
993 Extrst1.SetValue(previousP.PointOnC1(),
994 previousP.ParameterOnC1(),
995 previousP.Parameter(), tolesp);
996 Extrst2.SetValue(previousP.PointOnC2(),
997 previousP.ParameterOnC2(),
998 previousP.Parameter(), tolesp);
999 Arrive = Standard_True;
1007 line->SetEndPoints(Extrst1, Extrst2);
1008 decrochfin = decroch;
1011 line->SetStartPoints(Extrst1, Extrst2);
1012 decrochdeb = decroch;
1019 //=======================================================================
1020 //function : Recadre1
1021 //purpose : Contact lost on 1
1022 //=======================================================================
1024 Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre1(Blend_RstRstFunction& Func,
1025 Blend_SurfCurvFuncInv& Finv,
1026 math_Vector& Solinv,
1027 Standard_Boolean& IsVtx,
1028 Handle(Adaptor3d_HVertex)& Vtx)
1030 math_Vector toler(1, 3), infb(1, 3), supb(1, 3);
1031 Finv.GetTolerance(toler, tolesp);
1032 Finv.GetBounds(infb, supb);
1037 // The point where contact is not lost is found
1038 math_FunctionSetRoot rsnld(Finv, toler, 30);
1039 rsnld.Perform(Finv, Solinv, infb, supb);
1040 if (!rsnld.IsDone()) {
1042 std::cout << "RSNLD not done "<< std::endl << std::endl;
1044 return Standard_False;
1049 // It is necessary to check if the function value meets the
1050 // second restriction
1051 if (Finv.IsSolution(Solinv, tolesp)) {
1052 Standard_Real w = Solinv(2);
1053 if(w < rst2->FirstParameter() - toler(2)||
1054 w > rst2->LastParameter() + toler(2)){
1055 return Standard_False;
1058 // it is checked if it is on a Vertex
1059 domain1->Initialize(rst1);
1060 domain1->InitVertexIterator();
1061 IsVtx = !domain1->MoreVertex();
1063 Vtx = domain1->Vertex();
1064 if (Abs(BRepBlend_BlendTool::Parameter(Vtx, rst1)-Solinv(3)) <=
1065 BRepBlend_BlendTool::Tolerance(Vtx, rst1)) {
1066 IsVtx = Standard_True;
1069 domain1->NextVertex();
1070 IsVtx = !domain1->MoreVertex();
1073 if (!domain1->MoreVertex()) {
1074 IsVtx = Standard_False;
1076 // The section is recalculated by direct solution, otherwise return
1077 // incoherences between the parameter and the ground caused by yawn.
1079 math_Vector infbound(1, 2), supbound(1, 2);
1080 math_Vector parinit(1, 2), tolerance(1, 2);
1081 Func.GetTolerance(tolerance, tolesp);
1082 Func.GetBounds(infbound, supbound);
1084 math_FunctionSetRoot rsnld2(Func, tolerance, 30);
1085 parinit(1) = Solinv(3);
1086 parinit(2) = Solinv(2);
1087 Func.Set(Solinv(1));
1088 rsnld2.Perform(Func, parinit, infbound, supbound);
1089 if(!rsnld2.IsDone()) return Standard_False;
1090 rsnld2.Root(parinit);
1091 Solinv(2) = parinit(2);
1092 Solinv(3) = parinit(1);
1093 return Standard_True;
1095 return Standard_False;
1102 //=======================================================================
1103 //function : Recadre2
1104 //purpose : Contact lost on Rst2
1105 //=======================================================================
1107 Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre2(Blend_RstRstFunction& Func,
1108 Blend_SurfCurvFuncInv& Finv,
1109 math_Vector& Solinv,
1110 Standard_Boolean& IsVtx,
1111 Handle(Adaptor3d_HVertex)& Vtx)
1113 math_Vector toler(1, 3), infb(1, 3), supb(1, 3);
1114 Finv.GetTolerance(toler, tolesp);
1115 Finv.GetBounds(infb, supb);
1120 math_FunctionSetRoot rsnld(Finv, toler, 30);
1121 rsnld.Perform(Finv, Solinv, infb, supb);
1122 if (!rsnld.IsDone()) {
1124 std::cout << "RSNLD not done "<< std::endl << std::endl;
1126 return Standard_False;
1131 // It is necessary to check the value of the function
1132 if (Finv.IsSolution(Solinv, tolesp)) {
1133 Standard_Real w = Solinv(2);
1134 if(w < rst1->FirstParameter() - toler(2)||
1135 w > rst1->LastParameter() + toler(2)){
1136 return Standard_False;
1139 domain2->Initialize(rst2);
1140 domain2->InitVertexIterator();
1141 IsVtx = !domain2->MoreVertex();
1143 Vtx = domain2->Vertex();
1144 if (Abs(BRepBlend_BlendTool::Parameter(Vtx, rst2)-Solinv(3)) <=
1145 BRepBlend_BlendTool::Tolerance(Vtx, rst2)) {
1146 IsVtx = Standard_True;
1149 domain2->NextVertex();
1150 IsVtx = !domain2->MoreVertex();
1153 if (!domain2->MoreVertex()) {
1154 IsVtx = Standard_False;
1156 // The section is recalculated by direct solution, otherwise return
1157 // incoherences between the parameter and the ground caused by yawn.
1159 math_Vector infbound(1, 2), supbound(1, 2);
1160 math_Vector parinit(1,2), tolerance(1,2);
1161 Func.GetTolerance(tolerance, tolesp);
1162 Func.GetBounds(infbound, supbound);
1164 math_FunctionSetRoot rsnld2(Func, tolerance, 30);
1165 parinit(1) = Solinv(2);
1166 parinit(2) = Solinv(3);
1167 Func.Set(Solinv(1));
1168 rsnld2.Perform(Func, parinit, infbound, supbound);
1169 if(!rsnld2.IsDone()) return Standard_False;
1170 rsnld2.Root(parinit);
1171 Solinv(2) = parinit(1);
1172 Solinv(3) = parinit(2);
1173 return Standard_True;
1175 return Standard_False;
1178 //=======================================================================
1179 //function : Recadre
1180 //purpose : This is the end of curve rst1
1181 //=======================================================================
1183 Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre1(Blend_CurvPointFuncInv& FinvP,
1184 math_Vector& Solinv,
1185 Standard_Boolean& IsVtx,
1186 Handle(Adaptor3d_HVertex)& Vtx)
1188 // One is located on the last or the first point, following the
1189 // direction of processing.
1191 Standard_Real firstrst1 = rst1->FirstParameter();
1192 Standard_Real lastrst1 = rst1->LastParameter();
1193 Standard_Real upoint = firstrst1;
1195 if((sol(1) - firstrst1) > (lastrst1 - sol(1))) upoint = lastrst1;
1196 p2drst1 = rst1->Value(upoint);
1197 gp_Pnt thepoint = surf1->Value(p2drst1.X(), p2drst1.Y());
1199 FinvP.Set(thepoint);
1200 math_Vector toler(1,2), infb(1, 2), supb(1, 2);
1201 FinvP.GetTolerance(toler, tolesp);
1202 FinvP.GetBounds(infb, supb);
1206 math_FunctionSetRoot rsnld(FinvP, toler, 30);
1207 rsnld.Perform(FinvP, Solinv, infb, supb);
1208 if (!rsnld.IsDone()) {
1210 std::cout << "RSNLD not done "<< std::endl << std::endl;
1212 return Standard_False;
1216 if(FinvP.IsSolution(Solinv, tolesp)){
1217 gp_Pnt2d p2drst2 = rst2->Value(Solinv(2));
1218 TopAbs_State situ = domain2->Classify(p2drst2, toler(2), 0);
1219 if ((situ != TopAbs_IN) && (situ != TopAbs_ON)) {
1220 return Standard_False;
1222 domain1->Initialize(rst1);
1223 domain1->InitVertexIterator();
1224 IsVtx = !domain1->MoreVertex();
1226 Vtx = domain1->Vertex();
1227 if (Abs(BRepBlend_BlendTool::Parameter(Vtx, rst1) - upoint) <=
1228 BRepBlend_BlendTool::Tolerance(Vtx, rst1)) {
1229 IsVtx = Standard_True;
1232 domain1->NextVertex();
1233 IsVtx = !domain1->MoreVertex();
1236 if (!domain1->MoreVertex()) {
1237 IsVtx = Standard_False;
1239 return Standard_True;
1241 return Standard_False;
1246 //=======================================================================
1247 //function : Recadre2
1248 //purpose : This is the end of curve rst2
1249 //=======================================================================
1251 Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre2(Blend_CurvPointFuncInv& FinvP,
1252 math_Vector& Solinv,
1253 Standard_Boolean& IsVtx,
1254 Handle(Adaptor3d_HVertex)& Vtx)
1256 // One is located on the last or the first point, following the
1257 // direction of processing.
1259 Standard_Real firstrst2 = rst2->FirstParameter();
1260 Standard_Real lastrst2 = rst2->LastParameter();
1261 Standard_Real vpoint = firstrst2;
1263 if((sol(2) - firstrst2) > (lastrst2 - sol(2))) vpoint = lastrst2;
1264 p2drst2 = rst2->Value(vpoint);
1265 gp_Pnt thepoint = surf2->Value(p2drst2.X(), p2drst2.Y());
1267 FinvP.Set(thepoint);
1268 math_Vector toler(1,2), infb(1, 2), supb(1, 2);
1269 FinvP.GetTolerance(toler, tolesp);
1270 FinvP.GetBounds(infb, supb);
1274 math_FunctionSetRoot rsnld(FinvP, toler, 30);
1275 rsnld.Perform(FinvP, Solinv, infb, supb);
1276 if (!rsnld.IsDone()) {
1278 std::cout << "RSNLD not done "<< std::endl << std::endl;
1280 return Standard_False;
1284 if(FinvP.IsSolution(Solinv, tolesp)){
1285 gp_Pnt2d p2drst1 = rst1->Value(Solinv(2));
1286 TopAbs_State situ = domain1->Classify(p2drst1, toler(2), 0);
1287 if ((situ != TopAbs_IN) && (situ != TopAbs_ON)) {
1288 return Standard_False;
1290 domain2->Initialize(rst2);
1291 domain2->InitVertexIterator();
1292 IsVtx = !domain2->MoreVertex();
1294 Vtx = domain2->Vertex();
1295 if (Abs(BRepBlend_BlendTool::Parameter(Vtx, rst2) - vpoint) <=
1296 BRepBlend_BlendTool::Tolerance(Vtx, rst2)) {
1297 IsVtx = Standard_True;
1300 domain2->NextVertex();
1301 IsVtx = !domain2->MoreVertex();
1304 if (!domain2->MoreVertex()) {
1305 IsVtx = Standard_False;
1307 return Standard_True;
1309 return Standard_False;
1313 //=======================================================================
1314 //function : Transition
1316 //=======================================================================
1318 void BRepBlend_RstRstLineBuilder::Transition(const Standard_Boolean OnFirst,
1319 const Handle(Adaptor2d_HCurve2d)& Arc,
1320 const Standard_Real Param,
1321 IntSurf_Transition& TLine,
1322 IntSurf_Transition& TArc)
1324 Standard_Boolean computetranstionaveclacorde = 0;
1326 Blend_Point prevprev;
1328 if(previousP.IsTangencyPoint()){
1329 if(line->NbPoints() < 2) return;
1330 computetranstionaveclacorde = 1;
1332 prevprev = line->Point(2);
1335 prevprev = line->Point(line->NbPoints() - 1);
1342 gp_Vec d1u, d1v, normale, tgrst;
1344 Arc->D1(Param, p2d, dp2d);
1346 surf1->D1(p2d.X(), p2d.Y(), pbid, d1u, d1v);
1347 if(!computetranstionaveclacorde) tgline = previousP.TangentOnC1();
1348 else tgline = gp_Vec(prevprev.PointOnC1(), previousP.PointOnC1());
1351 surf2->D1(p2d.X(), p2d.Y(), pbid, d1u, d1v);
1352 if(!computetranstionaveclacorde) tgline = previousP.TangentOnC2();
1353 else tgline = gp_Vec(prevprev.PointOnC2(), previousP.PointOnC2());
1356 tgrst.SetLinearForm(dp2d.X(), d1u, dp2d.Y(), d1v);
1357 normale = d1u.Crossed(d1v);
1359 IntSurf::MakeTransition(tgline, tgrst, normale, TLine, TArc);
1362 //=======================================================================
1363 //function : MakeExtremity
1364 //purpose : produce the extremity of a curve
1365 //=======================================================================
1367 void BRepBlend_RstRstLineBuilder::MakeExtremity(BRepBlend_Extremity& Extrem,
1368 const Standard_Boolean OnFirst,
1369 const Handle(Adaptor2d_HCurve2d)& Arc,
1370 const Standard_Real Param,
1371 const Standard_Boolean IsVtx,
1372 const Handle(Adaptor3d_HVertex)& Vtx)
1374 IntSurf_Transition Tline, Tarc;
1376 Handle(Adaptor3d_TopolTool) Iter;
1378 Extrem.SetValue(previousP.PointOnC1(),
1380 previousP.Parameter(), tolesp);
1381 if (!previousP.IsTangencyPoint())
1382 Extrem.SetTangent(previousP.TangentOnC1());
1386 Extrem.SetValue(previousP.PointOnC2(),
1388 previousP.Parameter(), tolesp);
1389 if (!previousP.IsTangencyPoint())
1390 Extrem.SetTangent(previousP.TangentOnC1());
1396 Transition(OnFirst, Arc, Param, Tline, Tarc);
1397 Extrem.AddArc(Arc, Param, Tline, Tarc);
1400 Extrem.SetVertex(Vtx);
1401 while (Iter->More()) {
1402 Handle(Adaptor2d_HCurve2d) arc = Iter->Value();
1404 Iter->Initialize(arc);
1405 Iter->InitVertexIterator();
1406 while (Iter->MoreVertex()) {
1407 if (Iter->Identical(Vtx, Iter->Vertex())) {
1408 prm = BRepBlend_BlendTool::Parameter(Vtx, arc);
1409 Transition(OnFirst, arc, prm, Tline, Tarc);
1410 Extrem.AddArc(arc, prm, Tline, Tarc);
1416 Transition(OnFirst, arc, Param, Tline, Tarc);
1417 Extrem.AddArc(arc, Param, Tline, Tarc);
1424 //=======================================================================
1425 //function : CheckDeflectionOnRst1
1427 //=======================================================================
1429 Blend_Status BRepBlend_RstRstLineBuilder::CheckDeflectionOnRst1(const Blend_Point& CurPoint)
1431 //Controls 3d of Blend_CSWalking.
1433 // rule by tests in U4 corresponds to 11.478
1434 const Standard_Real CosRef3D = 0.98;
1435 Standard_Real Cosi, Cosi2;
1436 Standard_Boolean curpointistangent = CurPoint.IsTangencyPoint();
1437 Standard_Boolean prevpointistangent = previousP.IsTangencyPoint();
1439 gp_Pnt Psurf = CurPoint.PointOnC1();
1441 if(!curpointistangent){
1442 Tgsurf = CurPoint.TangentOnC1();
1444 gp_Pnt prevP = previousP.PointOnC1();
1446 if(!prevpointistangent){
1447 prevTg = previousP.TangentOnC1();
1449 Standard_Real Norme;
1450 Standard_Real prevNorme = 0.;
1451 gp_Vec Corde(prevP, Psurf);
1452 Norme = Corde.SquareMagnitude();
1453 if (!prevpointistangent) prevNorme = prevTg.SquareMagnitude();
1455 if (Norme <= tolesp * tolesp) {
1456 // it can be necessary to force the same point
1457 return Blend_SamePoints;
1459 if(!prevpointistangent){
1460 if (prevNorme <= tolesp * tolesp) {
1461 return Blend_SamePoints;
1463 Cosi = sens * Corde * prevTg;
1464 if (Cosi < 0.) { // angle 3d>pi/2. --> return back
1465 return Blend_Backward;
1468 Cosi2 = Cosi * Cosi / prevNorme / Norme;
1469 if (Cosi2 < CosRef3D) {
1470 return Blend_StepTooLarge;
1474 if(!curpointistangent){
1475 // Check if it is necessary to control the sign of prevtg*Tgsurf
1476 Cosi = sens * Corde * Tgsurf;
1477 Cosi2 = Cosi * Cosi / Tgsurf.SquareMagnitude() / Norme;
1478 if (Cosi2 < CosRef3D || Cosi < 0.) {
1479 return Blend_StepTooLarge;
1483 if (!curpointistangent && !prevpointistangent) {
1484 // Estimation of the current arrow
1485 Standard_Real FlecheCourante =
1486 (prevTg.Normalized().XYZ() - Tgsurf.Normalized().XYZ()).SquareModulus() * Norme / 64.;
1488 if (FlecheCourante <= 0.25 * fleche * fleche) {
1489 return Blend_StepTooSmall;
1491 if (FlecheCourante > fleche * fleche) {
1493 return Blend_StepTooLarge;
1500 //=======================================================================
1501 //function : CheckDeflectionOnRst2
1503 //=======================================================================
1505 Blend_Status BRepBlend_RstRstLineBuilder::CheckDeflectionOnRst2(const Blend_Point& CurPoint)
1507 //3D Controls of Blend_CSWalking.
1509 // rule by tests in U4 corresponding to 11.478 d
1510 const Standard_Real CosRef3D = 0.98;
1511 Standard_Real Cosi, Cosi2;
1512 Standard_Boolean curpointistangent = CurPoint.IsTangencyPoint();
1513 Standard_Boolean prevpointistangent = previousP.IsTangencyPoint();
1515 gp_Pnt Psurf = CurPoint.PointOnC2();
1518 if (!curpointistangent) {
1519 Tgsurf = CurPoint.TangentOnC2();
1521 gp_Pnt prevP = previousP.PointOnC2();
1523 if (!prevpointistangent) {
1524 prevTg = previousP.TangentOnC2();
1526 Standard_Real Norme;
1527 Standard_Real prevNorme = 0.;
1528 gp_Vec Corde(prevP, Psurf);
1529 Norme = Corde.SquareMagnitude();
1530 if (!prevpointistangent) prevNorme = prevTg.SquareMagnitude();
1532 if (Norme <= tolesp * tolesp){
1533 // it can be necessary to force the same point
1534 return Blend_SamePoints;
1536 if (!prevpointistangent) {
1537 if (prevNorme <= tolesp * tolesp) {
1538 return Blend_SamePoints;
1540 Cosi = sens * Corde * prevTg;
1541 if (Cosi < 0.) { // angle 3d>pi/2. --> return back
1542 return Blend_Backward;
1545 Cosi2 = Cosi * Cosi / prevNorme / Norme;
1546 if (Cosi2 < CosRef3D) {
1547 return Blend_StepTooLarge;
1551 if (!curpointistangent) {
1552 // Check if it is necessary to control the sign of prevtg*Tgsurf
1553 Cosi = sens * Corde * Tgsurf;
1554 Cosi2 = Cosi * Cosi / Tgsurf.SquareMagnitude() / Norme;
1555 if (Cosi2 < CosRef3D || Cosi < 0.) {
1556 return Blend_StepTooLarge;
1560 if(!curpointistangent && !prevpointistangent){
1561 // Estimation of the current arrow
1562 Standard_Real FlecheCourante =
1563 (prevTg.Normalized().XYZ() - Tgsurf.Normalized().XYZ()).SquareModulus() * Norme/64.;
1565 if (FlecheCourante <= 0.25 * fleche * fleche) {
1566 return Blend_StepTooSmall;
1568 if (FlecheCourante > fleche * fleche) {
1570 return Blend_StepTooLarge;
1576 static IntSurf_TypeTrans ConvOrToTra(const TopAbs_Orientation O)
1578 if(O == TopAbs_FORWARD) return IntSurf_In;
1582 //=======================================================================
1583 //function : TestArret
1585 //=======================================================================
1587 Blend_Status BRepBlend_RstRstLineBuilder::TestArret(Blend_RstRstFunction& Func,
1588 const Standard_Boolean TestDeflection,
1589 const Blend_Status State)
1591 gp_Pnt ptrst1, ptrst2;
1592 gp_Pnt2d pt2drst1, pt2drst2;
1593 gp_Vec tgrst1, tgrst2;
1594 gp_Vec2d tg2drst1, tg2drst2;
1595 Blend_Status StateRst1, StateRst2;
1596 IntSurf_TypeTrans trarst1 = IntSurf_Undecided, trarst2 = IntSurf_Undecided;
1597 Blend_Point curpoint;
1599 if (Func.IsSolution(sol, tolesp)) {
1600 Standard_Boolean curpointistangent = Func.IsTangencyPoint();
1601 ptrst1 = Func.PointOnRst1();
1602 ptrst2 = Func.PointOnRst2();
1603 pt2drst1 = Func.Pnt2dOnRst1();
1604 pt2drst2 = Func.Pnt2dOnRst2();
1606 if(curpointistangent){
1607 curpoint.SetValue(ptrst1, ptrst2, param, pt2drst1.X(), pt2drst1.Y(),
1608 pt2drst2.X(), pt2drst2.Y(), sol(1), sol(2));
1611 tgrst1 = Func.TangentOnRst1();
1612 tgrst2 = Func.TangentOnRst2();
1613 tg2drst1 = Func.Tangent2dOnRst1();
1614 tg2drst2 = Func.Tangent2dOnRst2();
1615 curpoint.SetValue(ptrst1, ptrst2, param, pt2drst1.X(), pt2drst1.Y(),
1616 pt2drst2.X(), pt2drst2.Y(), sol(1), sol(2),
1617 tgrst1, tgrst2, tg2drst1, tg2drst2);
1619 if (TestDeflection) {
1620 StateRst1 = CheckDeflectionOnRst1(curpoint);
1621 StateRst2 = CheckDeflectionOnRst2(curpoint);
1624 StateRst1 = StateRst2 = Blend_OK;
1626 if (StateRst1 == Blend_Backward) {
1627 StateRst1 = Blend_StepTooLarge;
1628 rebrou = Standard_True;
1630 if (StateRst2 == Blend_Backward) {
1631 StateRst2 = Blend_StepTooLarge;
1632 rebrou = Standard_True;
1634 if (StateRst1 == Blend_StepTooLarge ||
1635 StateRst2 == Blend_StepTooLarge) {
1636 return Blend_StepTooLarge;
1639 if (!comptra && !curpointistangent) {
1641 gp_Vec2d tg2drstref;
1642 rst1->D1(sol(1), p2drstref, tg2drstref);
1643 Standard_Real testra = tg2drst1.Dot(tg2drstref);
1644 TopAbs_Orientation Or = domain1->Orientation(rst1);
1646 if (Abs(testra) > tolesp) {
1648 trarst1 = ConvOrToTra(TopAbs::Reverse(Or));
1650 else if (testra >0.) {
1651 trarst1 = ConvOrToTra(Or);
1654 rst2->D1(sol(2), p2drstref, tg2drstref);
1655 testra = tg2drst2.Dot(tg2drstref);
1657 Or = domain2->Orientation(rst2);
1658 if (Abs(testra) > tolesp) {
1660 trarst2 = ConvOrToTra(TopAbs::Reverse(Or));
1662 else if (testra >0.) {
1663 trarst2 = ConvOrToTra(Or);
1665 comptra = Standard_True;
1666 line->Set(trarst1, trarst2);
1670 if (StateRst1 == Blend_OK ||
1671 StateRst2 == Blend_OK ) {
1672 previousP = curpoint;
1675 if (StateRst1 == Blend_StepTooSmall &&
1676 StateRst2 == Blend_StepTooSmall) {
1677 previousP = curpoint;
1678 if (State == Blend_OK) {
1679 return Blend_StepTooSmall;
1685 if (State == Blend_OK) {
1686 return Blend_SamePoints;
1692 return Blend_StepTooLarge;
1695 //=======================================================================
1696 //function : CheckInside
1698 //=======================================================================
1700 Standard_Boolean BRepBlend_RstRstLineBuilder::CheckInside(Blend_RstRstFunction& Func,
1701 TopAbs_State& SituOnC1,
1702 TopAbs_State& SituOnC2,
1703 Blend_DecrochStatus & Decroch)
1705 // Standard_Boolean inside = Standard_True;
1706 math_Vector tolerance(1, 2);
1707 Func.GetTolerance(tolerance, tolesp);
1710 Standard_Real v = sol(1);
1711 if(v < rst1->FirstParameter() - tolerance(2)||
1712 v > rst1->LastParameter() + tolerance(2)){
1713 SituOnC1 = TopAbs_OUT;
1715 else if (v > rst1->FirstParameter() &&
1716 v < rst1->LastParameter()){
1717 SituOnC1 = TopAbs_IN;
1719 else SituOnC1 = TopAbs_ON;
1723 if(v < rst2->FirstParameter() - tolerance(2)||
1724 v > rst2->LastParameter() + tolerance(2)){
1725 SituOnC2 = TopAbs_OUT;
1727 else if (v > rst2->FirstParameter() &&
1728 v < rst2->LastParameter()){
1729 SituOnC2 = TopAbs_IN;
1731 else SituOnC2 = TopAbs_ON;
1735 gp_Vec tgrst1, norst1, tgrst2, norst2;
1736 Decroch = Func.Decroch(sol,tgrst1, norst1, tgrst2, norst2);
1738 return (SituOnC1 == TopAbs_IN && SituOnC2 == TopAbs_IN && Decroch == Blend_NoDecroch);