1 // Created on: 1993-12-15
2 // Created by: Isabelle GRIGNON
3 // Copyright (c) 1993-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_Curve2d.hxx>
19 #include <Blend_FuncInv.hxx>
20 #include <BRepBlend_Line.hxx>
21 #include <BRepLib_MakeFace.hxx>
22 #include <BRepLProp_SLProps.hxx>
23 #include <BRepTools.hxx>
24 #include <BRepTools_WireExplorer.hxx>
25 #include <BRepTopAdaptor_TopolTool.hxx>
27 #include <ChFi3d_Builder.hxx>
28 #include <ChFi3d_Builder_0.hxx>
29 #include <ChFiDS_ChamfSpine.hxx>
30 #include <ChFiDS_CommonPoint.hxx>
31 #include <ChFiDS_ElSpine.hxx>
32 #include <ChFiDS_ErrorStatus.hxx>
33 #include <ChFiDS_FaceInterference.hxx>
34 #include <ChFiDS_HData.hxx>
35 #include <ChFiDS_ListOfHElSpine.hxx>
36 #include <ChFiDS_SequenceOfSurfData.hxx>
37 #include <ChFiDS_Spine.hxx>
38 #include <ChFiDS_State.hxx>
39 #include <ChFiDS_Stripe.hxx>
40 #include <ChFiDS_SurfData.hxx>
41 #include <ChFiKPart_ComputeData.hxx>
43 #include <Extrema_ExtPS.hxx>
44 #include <Extrema_LocateExtPC.hxx>
45 #include <Extrema_POnCurv.hxx>
46 #include <Geom2d_Curve.hxx>
47 #include <Geom_BSplineSurface.hxx>
48 #include <Geom_Plane.hxx>
49 #include <Geom_Surface.hxx>
50 #include <GeomAdaptor_Surface.hxx>
51 #include <GeomAPI_ProjectPointOnCurve.hxx>
52 #include <GeomFill_ConstrainedFilling.hxx>
54 #include <gp_Pnt2d.hxx>
57 #include <math_Vector.hxx>
58 #include <Precision.hxx>
59 #include <Standard_NotImplemented.hxx>
60 #include <TColStd_Array1OfReal.hxx>
61 #include <TColStd_ListOfInteger.hxx>
63 #include <TopAbs_Orientation.hxx>
64 #include <TopAbs_ShapeEnum.hxx>
66 #include <TopExp_Explorer.hxx>
68 #include <TopoDS_Edge.hxx>
69 #include <TopoDS_Face.hxx>
70 #include <TopoDS_Shape.hxx>
71 #include <TopoDS_Vertex.hxx>
72 #include <TopOpeBRepBuild_HBuilder.hxx>
73 #include <TopOpeBRepDS_HDataStructure.hxx>
77 #include <DrawTrSurf.hxx>
79 #include <OSD_Chronometer.hxx>
80 extern Standard_Real t_perfsetofkpart,t_perfsetofkgen,t_makextremities,t_performsurf,t_startsol;
81 extern Standard_Boolean ChFi3d_GettraceCHRON();
82 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
83 extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real& time);
87 //===================================================================
88 // Definition by a plane
90 // It is considered that P1 and P2 are points associated to commonpoints compoint1 and
91 // compoint2, while E1 and E2 are edges containing P1 and P2.
92 // The plane containing three directions D12 T1 T2 ou D12 represente la direction formee
93 // par les points P1 et P2, T1 la tangente de E1 en P1 et T2 la tangente de
94 // E2 en P2 is found (if exists).
95 // Then fillet HConge is intersected by this plane
96 // to find associated curve 3d C3d and the curve 2d.
98 //====================================================================
99 static void ChFi3d_CoupeParPlan (const ChFiDS_CommonPoint & compoint1,
100 const ChFiDS_CommonPoint & compoint2,
101 Handle(GeomAdaptor_Surface)& HConge,
102 const gp_Pnt2d & UV1,
103 const gp_Pnt2d & UV2,
104 const Standard_Real tol3d,
105 const Standard_Real tol2d,
106 Handle(Geom_Curve) &C3d,
107 Handle(Geom2d_Curve) &pcurve,
108 Standard_Real & tolreached,
109 Standard_Real & Pardeb,
110 Standard_Real & Parfin,
111 Standard_Boolean & plane)
112 { plane=Standard_True;
113 if(compoint1.IsOnArc() && compoint2.IsOnArc() ) {
115 BRepAdaptor_Curve BCurv1(compoint1.Arc());
116 BRepAdaptor_Curve BCurv2(compoint2.Arc());
117 Standard_Real parE1,parE2;
118 parE1=compoint1.ParameterOnArc();
119 parE2=compoint2.ParameterOnArc();
121 BCurv1.D1(parE1,P1,t1);
122 BCurv2.D1(parE2,P2,t2);
125 gp_Vec v12(P2.X()-P1.X(),P2.Y()-P1.Y(),P2.Z()-P1.Z());
127 gp_Dir nor =tgt1.Crossed(d12);
128 Handle (Geom_Plane) Plan=new Geom_Plane(P1,nor);
130 scal=Abs(nor.Dot(tgt2));
132 Handle(GeomAdaptor_Surface) HPlan=new GeomAdaptor_Surface(Plan);
133 Handle(Geom2d_Curve) C2dint2;
134 TColStd_Array1OfReal Pdeb(1,4),Pfin(1,4);
135 GeomAdaptor_Surface AS(Plan);
136 Extrema_ExtPS ext(P1,AS,1.e-3,1.e-3);
137 Extrema_ExtPS ext1 (P2,AS,1.e-3,1.e-3);
139 ext.Point(1).Parameter(u1,v1);
140 Pdeb(1)= UV1.X();Pdeb(2) = UV1.Y();
141 Pdeb(3)= u1;Pdeb(4) =v1;
142 ext1.Point(1).Parameter(u1,v1);
143 Pfin(1)= UV2.X();Pfin(2) = UV2.Y();
144 Pfin(3)= u1;Pfin(4) = v1;
145 if (ChFi3d_ComputeCurves(HConge,HPlan,Pdeb,Pfin,C3d,
146 pcurve,C2dint2,tol3d,tol2d,tolreached)){
147 Pardeb=C3d->FirstParameter();
148 Parfin=C3d->LastParameter();
150 else plane=Standard_False;
152 else plane=Standard_False;
154 else plane=Standard_False;
156 //=======================================================================
157 //function : SortieTangente
159 //=======================================================================
161 static Standard_Boolean SortieTangente(const ChFiDS_CommonPoint& CP,
162 const TopoDS_Face& /*F*/,
163 const Handle(ChFiDS_SurfData)& /*SD*/,
164 const Standard_Integer /*OnS*/,
165 const Standard_Real TolAngular)
167 if(!CP.HasVector()) return Standard_False;
170 Handle(Geom_Curve) C;
171 Standard_Real Uf, Ul;
172 C = BRep_Tool::Curve(CP.Arc(),Uf,Ul);
173 C->D1(CP.ParameterOnArc(), P, Darc);
175 return Dsurf.IsParallel(Darc, TolAngular);
178 //=======================================================================
179 //function : BonVoisin
181 //=======================================================================
183 static Standard_Boolean BonVoisin(const gp_Pnt& Point,
184 Handle(BRepAdaptor_Surface)& HS,
186 Handle(GeomAdaptor_Surface)& plane,
187 const TopoDS_Edge& cured,
190 const ChFiDS_Map& EFMap,
191 const Standard_Real tol3d)
193 Standard_Boolean bonvoisin = 1;
194 Standard_Real winter, Uf, Ul;
195 gp_Pnt papp = HS->Value(XDep, YDep);
196 Standard_Real dist = RealLast();
197 Handle(BRepAdaptor_Curve) hc = new BRepAdaptor_Curve();
198 Handle(Geom2d_Curve) PC;
199 Standard_Boolean found = 0;
202 for(Ex.Init(F,TopAbs_EDGE); Ex.More(); Ex.Next()){
203 const TopoDS_Edge& ecur = TopoDS::Edge(Ex.Current());
204 if(!ecur.IsSame(cured)){
205 hc->Initialize(ecur);
206 Standard_Real tolc = hc->Resolution(tol3d);
207 if(ChFi3d_InterPlaneEdge(plane,hc,winter,1,tolc)){
208 gp_Pnt np = hc->Value(winter);
209 Standard_Real ndist = np.SquareDistance(papp);
211 TopTools_ListIteratorOfListOfShape It;
213 Standard_Boolean isclosed = BRep_Tool::IsClosed(ecur, F);
214 Standard_Boolean isreallyclosed =
215 BRepTools::IsReallyClosed(ecur, F);
216 for(It.Initialize(EFMap(ecur));It.More();It.Next()){
217 ff = TopoDS::Face(It.Value());
218 Standard_Boolean issame = ff.IsSame(F);
219 // Modified by Sergey KHROMOV - Fri Dec 21 17:12:48 2001 Begin
220 // Standard_Boolean istg =
221 // BRep_Tool::Continuity(ecur,ff,F) != GeomAbs_C0;
222 Standard_Boolean istg = ChFi3d::IsTangentFaces(ecur,ff,F);
223 // Modified by Sergey KHROMOV - Fri Dec 21 17:12:51 2001 End
224 if((!issame || (issame && isreallyclosed)) && istg) {
226 TopoDS_Edge newe = ecur;
227 newe.Orientation(TopAbs_FORWARD);
230 if(isclosed && !isreallyclosed){
231 TopoDS_Face fff = ff;
232 fff.Orientation(TopAbs_FORWARD);
234 for(Ex2.Init(fff,TopAbs_EDGE);
235 Ex2.More(); Ex2.Next()){
236 if(newe.IsSame(Ex2.Current())){
237 newe = TopoDS::Edge(Ex2.Current());
238 PC = BRep_Tool::CurveOnSurface(newe,fff,Uf,Ul);
243 else PC = BRep_Tool::CurveOnSurface(newe,ff,Uf,Ul);
244 PC->Value(winter).Coord(XDep,YDep);
246 gp_Pnt spt; gp_Vec sdu,sdv,nors;
247 HS->D1(XDep, YDep, spt, sdu, sdv);
248 nors = sdu.Crossed(sdv);
249 gp_Pnt cpt; gp_Vec cd;
250 hc->D1(winter,cpt,cd);
251 gp_Vec vref(Point, cpt);
252 TopoDS_Face fff = ff;
253 fff.Orientation(TopAbs_FORWARD);
254 if(vref.Dot(nors.Crossed(cd)) < 0.){
255 newe.Orientation(TopAbs_REVERSED);
257 PC = BRep_Tool::CurveOnSurface(newe,fff,Uf,Ul);
258 PC->Value(winter).Coord(XDep, YDep);
267 if(!found) bonvoisin = 0;
271 //=======================================================================
272 //function : Projection
273 //purpose : Projects a point on a curve
274 //=======================================================================
276 static Standard_Boolean Projection(Extrema_ExtPC& PExt,
278 const Adaptor3d_Curve& C,
282 Standard_Real Dist2, daux2;
283 Dist2 = C.Value(W).SquareDistance(P);
285 // It is checked if it is not already a solution
286 if (Dist2 < Tol * Tol)
287 return Standard_True;
289 Standard_Boolean Ok = Standard_False;
291 // On essai une resolution initialise
292 Extrema_LocateExtPC ext(P,C,W,Tol/10);
294 daux2 = C.Value(ext.Point().Parameter()).SquareDistance(P);
296 W = ext.Point().Parameter();
299 if (Dist2 < Tol * Tol)
300 return Standard_True;
306 if ( PExt.IsDone() ) {
307 for (Standard_Integer ii=1; ii<= PExt.NbExt(); ii++) {
308 if (PExt.SquareDistance(ii) < Dist2) {
309 Dist2 = PExt.SquareDistance(ii);
310 W = PExt.Point(ii).Parameter();
318 //=======================================================================
321 //=======================================================================
323 static void TgtKP(const Handle(ChFiDS_SurfData)& CD,
324 const Handle(ChFiDS_Spine)& Spine,
325 const Standard_Integer iedge,
326 const Standard_Boolean isfirst,
330 Standard_Real wtg = CD->InterferenceOnS1().Parameter(isfirst);
331 const BRepAdaptor_Curve& bc = Spine->CurrentElementarySpine(iedge);
332 if(Spine->Edges(iedge).Orientation() == TopAbs_FORWARD)
333 bc.D1(wtg+bc.FirstParameter(),ped,ded);
335 bc.D1(-wtg+bc.LastParameter(),ped,ded);
341 //=======================================================================
343 //purpose : Checks if a vector belongs to a Face
344 //=======================================================================
346 Standard_Boolean IsInput(const gp_Vec& Vec,
347 const TopoDS_Vertex& Ve,
348 const TopoDS_Face& Fa)
350 TopExp_Explorer FaceExp(Fa, TopAbs_WIRE);
351 BRepTools_WireExplorer WireExp;
352 Standard_Integer Trouve = 0;
355 TopoDS_Vertex Vf, Vl;
359 // Find edges and compute 3D vectors
360 for ( ; (FaceExp.More() && (Trouve<2)); FaceExp.Next()) {
361 W = TopoDS::Wire(FaceExp.Current());
362 for (Trouve=0, WireExp.Init(W) ;
363 WireExp.More() && (Trouve<2); WireExp.Next()) {
364 E = TopoDS::Edge(WireExp.Current());
365 TopExp::Vertices(E, Vf, Vl);
367 BRepAdaptor_Curve Cb(E);
368 Cb.D1(BRep_Tool::Parameter(Ve, E), Point, Vec3d[Trouve]);
371 else if (Vl.IsSame(Ve)) {
372 BRepAdaptor_Curve Cb(E);
373 Cb.D1(BRep_Tool::Parameter(Ve, E), Point, Vec3d[Trouve]);
374 Vec3d[Trouve].Reverse();
379 if (Trouve < 2) return Standard_False;
380 // Calculate the normal and the angles in the associated vector plane
382 Normal = Vec3d[0] ^ Vec3d[1];
383 if (Normal.SquareMagnitude() < Precision::Confusion()) {//Colinear case
384 return (Vec.IsParallel(Vec3d[0],Precision::Confusion()));
387 Standard_Real amin, amax;
388 amax = Vec3d[1].AngleWithRef(Vec3d[0], Normal);
395 // Projection of the vector
396 gp_Ax3 Axe(Point, Normal, Vec3d[0]);
398 Transf.SetTransformation (Axe);
399 gp_XYZ coord = Vec.XYZ();
400 Transf.Transforms(coord);
403 Transf.Transforms(coord);
404 gp_Vec theProj(coord);
407 Standard_Real Angle = theProj.AngleWithRef(Vec3d[0], Normal);
408 return ( (Angle >= amin) && (Angle<=amax));
411 //=======================================================================
413 //purpose : Find a neighbor G1 by an edge
414 //=======================================================================
416 Standard_Boolean IsG1(const ChFiDS_Map& TheMap,
417 const TopoDS_Edge& E,
418 const TopoDS_Face& FRef,
421 TopTools_ListIteratorOfListOfShape It;
422 // Find a neighbor of E different from FRef (general case).
423 for(It.Initialize(TheMap(E));It.More();It.Next()) {
424 if (!TopoDS::Face(It.Value()).IsSame(FRef)) {
425 FVoi = TopoDS::Face(It.Value());
426 // Modified by Sergey KHROMOV - Fri Dec 21 17:09:32 2001 Begin
427 // if (BRep_Tool::Continuity(E,FRef,FVoi) != GeomAbs_C0) {
428 if (ChFi3d::IsTangentFaces(E,FRef,FVoi)) {
429 // Modified by Sergey KHROMOV - Fri Dec 21 17:09:33 2001 End
430 return Standard_True;
434 // If is was not found it is checked if E is a cutting edge,
435 // in which case FVoi = FRef is returned (less frequent case).
437 Standard_Boolean orset = Standard_False;
438 TopAbs_Orientation orient = TopAbs_FORWARD ;
440 for(Ex.Init(FRef,TopAbs_EDGE); Ex.More(); Ex.Next()){
441 ed = TopoDS::Edge(Ex.Current());
443 if(!orset){ orient = ed.Orientation(); orset = Standard_True; }
444 else if(ed.Orientation() == TopAbs::Reverse(orient)){
446 // Modified by Sergey KHROMOV - Fri Dec 21 17:15:12 2001 Begin
447 // if (BRep_Tool::Continuity(E,FRef,FRef) >= GeomAbs_G1) {
448 if (ChFi3d::IsTangentFaces(E,FRef,FRef)) {
449 // Modified by Sergey KHROMOV - Fri Dec 21 17:15:16 2001 End
450 return Standard_True;
452 return Standard_False;
456 return Standard_False;
459 //=======================================================================
460 //function : SearchFaceOnV
461 //purpose : Finds the output face(s) of the path by a vertex
462 // The following criteria should be followed
463 // -1 : The face shares regular edges with FRef
464 // (too hard condition that should be reconsidered)
465 // -2 : The vector starting in CommonPoint "belongs" to the face
466 //========================================================================
467 static Standard_Integer SearchFaceOnV(const ChFiDS_CommonPoint& Pc,
468 const TopoDS_Face& FRef,
469 const ChFiDS_Map& VEMap,
470 const ChFiDS_Map& EFMap,
474 // it is checked that it leaves the current face.
475 Standard_Boolean FindFace = IsInput(Pc.Vector(), Pc.Vertex(), FRef);
477 FindFace = IsInput(Pc.Vector().Reversed(), Pc.Vertex(), FRef);
479 // If it does not leave, it is finished
484 Standard_Integer Num = 0;
485 Standard_Boolean Trouve;
486 TopTools_ListIteratorOfListOfShape ItE, ItF;
490 for(ItE.Initialize(VEMap(Pc.Vertex()));
491 ItE.More() && (Num < 2); ItE.Next()) {
492 E = TopoDS::Edge(ItE.Value());
493 for(ItF.Initialize(EFMap(E)), Trouve=Standard_False;
494 ItF.More()&&(!Trouve); ItF.Next()) {
495 if (TopoDS::Face(ItF.Value()).IsSame(FRef)) {
496 Trouve = Standard_True;
499 if (Trouve) Trouve = IsG1(EFMap, E, FRef, FVoi);
500 if (Trouve) Trouve = IsInput(Pc.Vector(), Pc.Vertex(), FVoi);
502 if (Num == 0) F1 = FVoi;
510 //=======================================================================
511 //function : ChangeTransition
512 //purpose : Changes the transition of the second common Point, when the surface
513 // does not cross the arc
514 // As it is supposed that the support Faces are the same, it is enough
515 // to examine the cas of cutting edges.
516 //========================================================================
517 static void ChangeTransition(const ChFiDS_CommonPoint& Precedant,
518 ChFiDS_CommonPoint& Courant,
519 Standard_Integer FaceIndex,
520 const Handle(TopOpeBRepDS_HDataStructure)& DS)
522 Standard_Boolean tochange = Standard_True;
524 const TopoDS_Face& F = TopoDS::Face(DS->Shape(FaceIndex));
525 const TopoDS_Edge& Arc = Precedant.Arc();
526 Handle(Geom2d_Curve) PCurve1, PCurve2;
527 PCurve1 = BRep_Tool::CurveOnSurface(Arc, F, f, l);
528 TopoDS_Shape aLocalShape = Arc.Reversed();
529 PCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(aLocalShape), F, f, l);
530 // PCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(Arc.Reversed()), F, f, l);
531 if (PCurve1 != PCurve2) {
532 // This is a cutting edge, it is necessary to make a small Geometric test
535 BRepAdaptor_Curve AC(Arc);
536 AC.D1(Precedant.ParameterOnArc(), P, tgarc);
537 tochange = tgarc.IsParallel(Precedant.Vector(), Precision::Confusion());
541 Courant.SetArc(Precision::Confusion(),
543 Precedant.ParameterOnArc(),
544 TopAbs::Reverse(Precedant.TransitionOnArc()));
548 //=======================================================================
549 //function : CallPerformSurf
550 //purpose : Encapsulates call to PerformSurf/SimulSurf
551 //========================================================================
553 void ChFi3d_Builder::
554 CallPerformSurf(Handle(ChFiDS_Stripe)& Stripe,
555 const Standard_Boolean Simul,
556 ChFiDS_SequenceOfSurfData& SeqSD,
557 Handle(ChFiDS_SurfData)& SD,
558 const Handle(ChFiDS_ElSpine)& HGuide,
559 const Handle(ChFiDS_Spine)& Spine,
560 const Handle(BRepAdaptor_Surface)& HS1,
561 const Handle(BRepAdaptor_Surface)& HS3,
564 const Handle(Adaptor3d_TopolTool)& It1,
565 const Handle(BRepAdaptor_Surface)& HS2,
566 const Handle(BRepAdaptor_Surface)& HS4,
569 const Handle(Adaptor3d_TopolTool)& It2,
570 const Standard_Real MaxStep,
571 const Standard_Real Fleche,
572 const Standard_Real /*TolGuide*/,
573 Standard_Real& First,
575 const Standard_Boolean Inside,
576 const Standard_Boolean /*Appro*/,
577 const Standard_Boolean forward,
578 const Standard_Boolean RecOnS1,
579 const Standard_Boolean RecOnS2,
581 Standard_Integer& intf,
582 Standard_Integer& intl,
583 Handle(BRepAdaptor_Surface)& Surf1,
584 Handle(BRepAdaptor_Surface)& Surf2)
589 Handle(BRepAdaptor_Surface) HSon1, HSon2;
592 // Definition of the domain of path It1, It2
593 It1->Initialize((const Handle(Adaptor3d_Surface)&)HSon1);
594 It2->Initialize((const Handle(Adaptor3d_Surface)&)HSon2);
597 TopAbs_Orientation Or1 = HS1->Face().Orientation();
598 TopAbs_Orientation Or2 = HS2->Face().Orientation();
599 Standard_Integer Choix =
600 ChFi3d::NextSide(Or1,Or2,
601 Stripe->OrientationOnFace1(),
602 Stripe->OrientationOnFace2(),
604 Soldep(1) = pp1.X(); Soldep(2) = pp1.Y();
605 Soldep(3) = pp2.X(); Soldep(4) = pp2.Y();
607 Standard_Real thef = First, thel = Last;
608 Standard_Boolean isdone;
611 isdone = SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,HS2,It2,tolesp,First,Last,
612 Inside,Inside,forward,RecOnS1,RecOnS2,Soldep,intf,intl);
617 ChFi3d_InitChron(ch1);//initial perform for PerformSurf
620 isdone = PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,HS2,It2,
621 MaxStep,Fleche,tolesp,
622 First,Last,Inside,Inside,forward,
623 RecOnS1,RecOnS2,Soldep,intf,intl);
625 ChFi3d_ResultChron(ch1,t_performsurf);// result perf for PerformSurf
633 Standard_Boolean reprise = Standard_False;
634 if (! HS3.IsNull()) {
636 It1->Initialize((const Handle(Adaptor3d_Surface)&)HS3);
637 Or1 = HS3->Face().Orientation();
638 Soldep(1) = pp3.X(); Soldep(2) = pp3.Y();
639 reprise = Standard_True;
641 else if (! HS4.IsNull()) {
643 It2->Initialize((const Handle(Adaptor3d_Surface)&)HS4);
644 Or2 = HS4->Face().Orientation();
645 Soldep(3) = pp4.X(); Soldep(4) = pp4.Y();
646 reprise = Standard_True;
650 Choix = ChFi3d::NextSide(Or1,Or2,
651 Stripe->OrientationOnFace1(),
652 Stripe->OrientationOnFace2(),
655 isdone = SimulSurf(SD,HGuide,Spine,Choix,HSon1,It1,HSon2,It2,
657 Inside,Inside,forward,RecOnS1,RecOnS2,
663 ChFi3d_InitChron(ch1);//init perf for PerformSurf
666 isdone = PerformSurf(SeqSD,HGuide,Spine,Choix,HSon1,It1,HSon2,It2,
667 MaxStep,Fleche,tolesp,
668 First,Last,Inside,Inside,forward,
669 RecOnS1,RecOnS2,Soldep,intf,intl);
671 ChFi3d_ResultChron(ch1,t_performsurf);// result perf for PerformSurf
680 //=======================================================================
681 //function : StripeOrientation
682 //purpose : Calculates the reference orientation determining the
683 // concave face for construction of the fillet.
684 //=======================================================================
686 Standard_Boolean ChFi3d_Builder::StripeOrientations
687 (const Handle(ChFiDS_Spine)& Spine,
688 TopAbs_Orientation& Or1,
689 TopAbs_Orientation& Or2,
690 Standard_Integer& ChoixConge) const
692 //TopTools_ListIteratorOfListOfShape It;
693 BRepAdaptor_Surface Sb1,Sb2;
694 TopAbs_Orientation Of1,Of2;
696 TopoDS_Edge anEdge = Spine->Edges(1);
697 TopoDS_Face FirstFace = TopoDS::Face(myEdgeFirstFace(anEdge));
698 ChFi3d_conexfaces(anEdge,ff1,ff2,myEFMap);
699 if (ff2.IsSame(FirstFace))
700 { TopoDS_Face TmpFace = ff1; ff1 = ff2; ff2 = TmpFace; }
701 Of1 = ff1.Orientation();
702 ff1.Orientation(TopAbs_FORWARD);
704 Of2 = ff2.Orientation();
705 ff2.Orientation(TopAbs_FORWARD);
708 ChoixConge = ChFi3d::ConcaveSide(Sb1,Sb2,Spine->Edges(1),
710 Or1 = TopAbs::Compose(Or1,Of1);
711 Or2 = TopAbs::Compose(Or2,Of2);
712 return Standard_True;
716 //=======================================================================
717 //function : ConexFaces
719 //=======================================================================
721 void ChFi3d_Builder::ConexFaces (const Handle(ChFiDS_Spine)& Spine,
722 const Standard_Integer IEdge,
723 Handle(BRepAdaptor_Surface)& HS1,
724 Handle(BRepAdaptor_Surface)& HS2) const
726 if(HS1.IsNull()) HS1 = new BRepAdaptor_Surface ();
727 if(HS2.IsNull()) HS2 = new BRepAdaptor_Surface ();
728 BRepAdaptor_Surface& Sb1 = *HS1;
729 BRepAdaptor_Surface& Sb2 = *HS2;
732 TopoDS_Edge anEdge = Spine->Edges(IEdge);
733 ChFi3d_conexfaces(Spine->Edges(IEdge),ff1,ff2,myEFMap);
735 TopoDS_Face FirstFace = TopoDS::Face(myEdgeFirstFace(anEdge));
736 if (ff2.IsSame(FirstFace))
737 { TopoDS_Face TmpFace = ff1; ff1 = ff2; ff2 = TmpFace; }
743 //=======================================================================
744 //function : StartSol
745 //purpose : Calculates a starting solution :
746 // - one starts by parsing about ten points on the spine,
747 // - in case of fail one finds the solution on neighbor faces;
748 // section plane of edges of the adjacent face
749 // and identication of the face by connection to that edge.
750 //=======================================================================
752 void ChFi3d_Builder::StartSol(const Handle(ChFiDS_Stripe)& Stripe,
753 const Handle(ChFiDS_ElSpine)& HGuide,
754 Handle(BRepAdaptor_Surface)& HS1,
755 Handle(BRepAdaptor_Surface)& HS2,
756 Handle(BRepTopAdaptor_TopolTool)& I1,
757 Handle(BRepTopAdaptor_TopolTool)& I2,
760 Standard_Real& First) const
762 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
763 ChFiDS_ElSpine& els = *HGuide;
764 Standard_Integer nbed = Spine->NbEdges();
765 Standard_Integer nbessaimax = 3*nbed;
766 if (nbessaimax < 10) nbessaimax = 10;
767 Standard_Real unsurnbessaimax = 1./nbessaimax;
768 Standard_Real wf = 0.9981 * Spine->FirstParameter(1) +
769 0.0019 * Spine->LastParameter(1);
770 Standard_Real wl = 0.9973 * Spine->LastParameter(nbed) +
771 0.0027 * Spine->FirstParameter(nbed);
773 Standard_Real TolE = 1.0e-7;
774 BRepAdaptor_Surface AS;
776 Standard_Integer nbessai;
777 Standard_Integer iedge = 0;
778 Standard_Integer RC = Stripe->Choix();
783 TopAbs_Orientation Or1,Or2;
784 Standard_Integer Choix = 0;
785 math_Vector SolDep(1,4);
786 Handle(Geom2d_Curve) PC;
789 Spine->FirstParameter(1),
790 Spine->LastParameter(nbed),
791 Precision::Confusion());
792 TopAbs_State Pos1,Pos2;
793 for(nbessai = 0; nbessai <= nbessaimax; nbessai++){
794 Standard_Real t = nbessai*unsurnbessaimax;
795 Standard_Real w = wf * (1. -t) + wl * t;
796 Standard_Integer ie = Spine->Index(w);
799 cured = Spine->Edges(iedge);
800 TolE = BRep_Tool::Tolerance(cured);
801 ConexFaces(Spine,iedge,HS1,HS2);
804 Or1 = f1.Orientation();
805 Or2 = f2.Orientation();
806 Choix = ChFi3d::NextSide(Or1,Or2,
807 Stripe->OrientationOnFace1(),
808 Stripe->OrientationOnFace2(),
812 Standard_Real woned,Uf,Ul, ResU, ResV;
813 Spine->Parameter(iedge,w,woned,Standard_True);
814 cured.Orientation(TopAbs_FORWARD);
815 TopoDS_Face f1forward = f1, f2forward = f2;
816 f1forward.Orientation(TopAbs_FORWARD);
817 f2forward.Orientation(TopAbs_FORWARD);
818 PC = BRep_Tool::CurveOnSurface(cured,f1forward,Uf,Ul);
819 I1->Initialize((const Handle(Adaptor3d_Surface)&)HS1);
820 PC->D1(woned, P1, derive);
821 // There are points on the border, and internal points are found
822 if (derive.Magnitude() > Precision::PConfusion()) {
824 derive.Rotate(M_PI/2);
826 ResU = AS.UResolution(TolE);
827 ResV = AS.VResolution(TolE);
828 derive *= 2*(Abs(derive.X())*ResU + Abs(derive.Y())*ResV);
829 P2d = P1.Translated(derive);
830 if (I1->Classify(P2d, Min(ResU, ResV), 0)== TopAbs_IN) {
834 P2d = P1.Translated(-derive);
835 if (I1->Classify(P2d, Min(ResU, ResV), 0)== TopAbs_IN) {
840 if(f1.IsSame(f2)) cured.Orientation(TopAbs_REVERSED);
841 PC = BRep_Tool::CurveOnSurface(cured,f2forward,Uf,Ul);
842 P2 = PC->Value(woned);
843 const Handle(Adaptor3d_Surface)& HSon2 = HS2; // to avoid ambiguity
844 I2->Initialize(HSon2);
846 SolDep(1) = P1.X(); SolDep(2) = P1.Y();
847 SolDep(3) = P2.X(); SolDep(4) = P2.Y();
848 const BRepAdaptor_Curve& Ced = Spine->CurrentElementarySpine(iedge);
849 gp_Pnt pnt = Ced.Value(woned);
851 if (Projection(PExt, pnt, els, w, tolapp3d) &&
852 PerformFirstSection(Spine,HGuide,Choix,HS1,HS2,
853 I1,I2,w,SolDep,Pos1,Pos2)) {
854 P1.SetCoord(SolDep(1),SolDep(2));
855 P2.SetCoord(SolDep(3),SolDep(4));
860 // No solution was found for the faces adjacent to the trajectory.
861 // Now one tries the neighbor faces.
863 for(nbessai = 0; nbessai <= nbessaimax; nbessai++){
864 Standard_Real t = nbessai*unsurnbessaimax;
865 Standard_Real w = wf * (1. -t) + wl * t;
866 iedge = Spine->Index(w);
867 cured = Spine->Edges(iedge);
868 ConexFaces(Spine,iedge,HS1,HS2);
871 Or1 = f1.Orientation();
872 Or2 = f2.Orientation();
873 Choix = ChFi3d::NextSide(Or1,Or2,
874 Stripe->OrientationOnFace1(),
875 Stripe->OrientationOnFace2(),
877 Standard_Real woned,Uf,Ul;
878 Spine->Parameter(iedge,w,woned,Standard_True);
879 TopoDS_Face f1forward = f1, f2forward = f2;
880 f1forward.Orientation(TopAbs_FORWARD);
881 f2forward.Orientation(TopAbs_FORWARD);
882 PC = BRep_Tool::CurveOnSurface(cured,f1forward,Uf,Ul);
883 P1 = PC->Value(woned);
884 PC = BRep_Tool::CurveOnSurface(cured,f2forward,Uf,Ul);
885 P2 = PC->Value(woned);
886 const Handle(Adaptor3d_Surface)& HSon1 = HS1; // to avoid ambiguity
887 const Handle(Adaptor3d_Surface)& HSon2 = HS2; // to avoid ambiguity
888 I1->Initialize(HSon1);
889 I2->Initialize(HSon2);
890 SolDep(1) = P1.X(); SolDep(2) = P1.Y();
891 SolDep(3) = P2.X(); SolDep(4) = P2.Y();
892 const BRepAdaptor_Curve& Ced = Spine->CurrentElementarySpine(iedge);
893 gp_Pnt pnt = Ced.Value(woned);
894 // Extrema_LocateExtPC ext(pnt,els,w,1.e-8);
896 // w = ext.Point().Parameter();
897 if (Projection(PExt, pnt, els, w, tolapp3d)) {
898 PerformFirstSection(Spine,HGuide,Choix,HS1,HS2,
899 I1,I2,w,SolDep,Pos1,Pos2);
903 Handle(Geom_Plane) pl = new Geom_Plane(P,V);
904 Handle(GeomAdaptor_Surface) plane = new GeomAdaptor_Surface(pl);
906 Standard_Boolean bonvoisin = 1, found = 0;
907 Standard_Integer NbChangement;
908 for (NbChangement = 1; bonvoisin && (!found) && (NbChangement < 5);
910 if(Pos1 != TopAbs_IN){
911 bonvoisin = BonVoisin(P, HS1, f1, plane, cured,
912 SolDep(1),SolDep(2), myEFMap, tolapp3d);
914 if(Pos2 != TopAbs_IN && bonvoisin){
915 bonvoisin = BonVoisin(P, HS2, f2, plane, cured,
916 SolDep(3),SolDep(4), myEFMap, tolapp3d);
921 Or1 = f1.Orientation();
922 Or2 = f2.Orientation();
923 Choix = ChFi3d::NextSide(Or1,Or2,
924 Stripe->OrientationOnFace1(),
925 Stripe->OrientationOnFace2(),
927 const Handle(Adaptor3d_Surface)& HSon1new = HS1; // to avoid ambiguity
928 const Handle(Adaptor3d_Surface)& HSon2new = HS2; // to avoid ambiguity
929 I1->Initialize(HSon1new);
930 I2->Initialize(HSon2new);
931 if(PerformFirstSection(Spine,HGuide,Choix,HS1,HS2,
932 I1,I2,w,SolDep,Pos1,Pos2)){
933 P1.SetCoord(SolDep(1),SolDep(2));
934 P2.SetCoord(SolDep(3),SolDep(4));
936 found = Standard_True;
943 Spine->SetErrorStatus(ChFiDS_StartsolFailure);
944 throw Standard_Failure("StartSol echec");
947 //=======================================================================
948 //function : ChFi3d_BuildPlane
950 //=======================================================================
952 static void ChFi3d_BuildPlane (TopOpeBRepDS_DataStructure& DStr,
953 Handle(BRepAdaptor_Surface)& HS,
955 const Handle(ChFiDS_SurfData)& SD,
956 const Standard_Boolean isfirst,
957 const Standard_Integer ons)
959 Handle(Geom2d_Curve) Hc;
960 TopoDS_Face F = TopoDS::Face(DStr.Shape(SD->Index(ons)));
965 if (SD->Vertex(isfirst,ons).IsOnArc()){
966 Hc = BRep_Tool::CurveOnSurface
967 (SD->Vertex(isfirst,ons).Arc(),F,u,v);
968 Hc->Value(SD->Vertex(isfirst,ons).ParameterOnArc()).Coord(u,v);
969 BRepLProp_SLProps theProp (*HS, u, v, 1, 1.e-12);
970 if (theProp.IsNormalDefined()) {
972 Handle(Geom_Plane) Pln = new Geom_Plane(P, theProp.Normal());
973 TopoDS_Face NewF = BRepLib_MakeFace(Pln, Precision::Confusion());
974 NewF.Orientation(F.Orientation());
975 pons.SetCoord(0.,0.);
976 HS->Initialize(NewF);
977 return; // everything is good !
980 throw Standard_Failure("ChFi3d_BuildPlane : echec .");
983 //=======================================================================
984 //function : StartSol
985 //purpose : If the commonpoint is not OnArc the input face
986 // is returned and 2D point is updated,
988 // if it is detached the input face
989 // is returned and 2D point is updated,
991 // either there is a neighbor tangent face and it is returned
992 // with recalculated 2D point
993 // or if there is no face
994 // if the reference arc is Vref (extremity of the spine)
995 // this is the end and the input face is returned
996 // otherwise this is an obstacle and HC is updated.
997 //=======================================================================
1000 ChFi3d_Builder::StartSol(const Handle(ChFiDS_Spine)& Spine,
1001 Handle(BRepAdaptor_Surface)& HS, // New face
1002 gp_Pnt2d& pons,// " Localization
1003 Handle(BRepAdaptor_Curve2d)& HC, // Representation of the obstacle
1005 const Handle(ChFiDS_SurfData)& SD,
1006 const Standard_Boolean isfirst,
1007 const Standard_Integer ons,
1008 Handle(BRepAdaptor_Surface)& HSref, // The other representation
1009 Handle(BRepAdaptor_Curve2d)& HCref, // of the obstacle
1010 Standard_Boolean& RecP,
1011 Standard_Boolean& RecS,
1012 Standard_Boolean& RecRst,
1013 Standard_Boolean& c1obstacle,
1014 Handle(BRepAdaptor_Surface)& HSBis, // Face of support
1015 gp_Pnt2d& PBis, // and its point
1016 const Standard_Boolean decroch,
1017 const TopoDS_Vertex& Vref) const
1019 RecRst = RecS = RecP = c1obstacle = 0;
1020 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
1021 TopoDS_Face Fv,Fref;
1023 Handle(Geom2d_Curve) pc;
1024 Standard_Real Uf,Ul;
1026 TopoDS_Face F = TopoDS::Face(DStr.Shape(SD->Index(ons)));
1027 if(!HSref.IsNull()) Fref = HSref->Face();
1028 const ChFiDS_CommonPoint& CP = SD->Vertex(isfirst,ons);
1032 Standard_Integer notons;
1033 if (ons == 1) notons = 2;
1035 const ChFiDS_CommonPoint& CPbis = SD->Vertex(isfirst,notons);
1036 if (CPbis.IsOnArc()) { // It is checked if it is not the extension zone
1037 // In case CP is not at the end of surfdata and it is not necessary to take it into account
1038 // except for separate cases (ie pointus) ...
1039 //ts and tns were earlier CP.Parameter() and CPbis.Parameter, but sometimes they had no values.
1040 Standard_Real ts=SD->Interference(ons).Parameter(isfirst), tns=SD->Interference(notons).Parameter(isfirst);
1041 Standard_Boolean isExtend;
1042 // Arbitrary test (to precise)
1043 if (isfirst) isExtend = (ts-tns > 100*tolesp);
1044 else isExtend = (tns-ts > 100*tolesp);
1045 if (isExtend && !CP.Point().IsEqual(CPbis.Point(), 0) ) {
1046 // the state is preserved and False is returned (extension by the expected plane).
1048 pc = SD->Interference(ons).PCurveOnFace();
1049 // The 2nd point is given by its trace on the support surface
1050 RecS = Standard_False;
1051 pons = pc->Value(tns);
1052 return Standard_False;
1057 if (CP.IsVertex() && !HC.IsNull() && !decroch){
1058 //The edge is changed, the parameter is updated and
1059 //eventually the support face and(or) the reference face.
1060 TopoDS_Vertex VCP = CP.Vertex();
1061 TopoDS_Edge EHC = HC->Edge();
1062 //One starts by searching in Fref another edge referencing VCP.
1063 TopExp_Explorer ex1,ex2;
1064 TopoDS_Edge newedge, edgereg;
1065 TopoDS_Face bidface = Fref, facereg;
1066 bidface.Orientation(TopAbs_FORWARD);
1067 for(ex1.Init(bidface,TopAbs_EDGE); ex1.More(); ex1.Next()){
1068 const TopoDS_Edge& cured = TopoDS::Edge(ex1.Current());
1069 Standard_Boolean found = 0;
1070 if(!cured.IsSame(EHC)){
1071 for(ex2.Init(cured,TopAbs_VERTEX); ex2.More() && !found; ex2.Next()){
1072 if(ex2.Current().IsSame(VCP)){
1073 if(IsG1(myEFMap,cured,Fref,Fv)){
1086 if(newedge.IsNull()){
1087 //It is checked if EHC is not a closed edge.
1088 TopoDS_Vertex V1,V2;
1089 TopExp::Vertices(EHC,V1,V2);
1092 Standard_Real w1 = BRep_Tool::Parameter(V1,EHC);
1093 Standard_Real w2 = BRep_Tool::Parameter(V2,EHC);
1094 const ChFiDS_FaceInterference& fi = SD->Interference(ons);
1095 const Handle(Geom2d_Curve)& pcf = fi.PCurveOnFace();
1096 Standard_Real ww = fi.Parameter(isfirst);
1099 if(!pcf.IsNull()) pww = pcf->Value(ww);
1100 else pww = SD->Get2dPoints(isfirst,ons);
1101 gp_Pnt2d p1 = HC->Value(w1);
1102 gp_Pnt2d p2 = HC->Value(w2);
1104 if(p1.Distance(pww) > p2.Distance(pww)){
1112 RecP = c1obstacle = 1;
1115 else if(!edgereg.IsNull()){
1116 // the reference edge and face are changed.
1118 HSref->Initialize(Fref);
1119 for(ex1.Init(facereg,TopAbs_EDGE); ex1.More() && newedge.IsNull(); ex1.Next()){
1120 const TopoDS_Edge& cured = TopoDS::Edge(ex1.Current());
1121 if(!cured.IsSame(edgereg)){
1122 for(ex2.Init(cured,TopAbs_VERTEX); ex2.More(); ex2.Next()){
1123 if(ex2.Current().IsSame(VCP)){
1124 if(!IsG1(myEFMap,cured,Fref,Fv)){
1133 // it is necessary to find the new support face of the fillet :
1134 // connected to FRef along the newedge.
1135 if(newedge.IsNull()) {
1136 throw Standard_Failure("StartSol : chain is not possible, new obstacle not found");
1138 if(IsG1(myEFMap,newedge,Fref,Fv)){
1139 throw Standard_Failure("StartSol : chain is not possible, config non processed");
1141 else if(Fv.IsNull()){
1142 throw Standard_Failure("StartSol : chain is not possible, new obstacle not found");
1146 W = BRep_Tool::Parameter(VCP,newedge);
1147 HCref->Initialize(newedge,Fref);
1148 TopoDS_Face newface = Fv;
1149 newface.Orientation(TopAbs_FORWARD);
1151 for(ex.Init(newface,TopAbs_EDGE); ex.More(); ex.Next()){
1152 if(ex.Current().IsSame(newedge)){
1153 newedge = TopoDS::Edge(ex.Current());
1157 HC->Initialize(newedge,Fv);
1158 pons = HC->Value(W);
1160 RecP = c1obstacle = 1;
1162 } // End of Case Vertex && Obstacle
1164 else if (CP.IsOnArc() && !HC.IsNull() && !decroch){
1165 //Nothing is changed, the parameter is only updated.
1166 W = CP.ParameterOnArc();
1174 const TopoDS_Edge& E = CP.Arc();
1176 HS->Initialize(Fref);
1177 W = CP.ParameterOnArc();
1178 pc = BRep_Tool::CurveOnSurface(E,Fref,Uf,Ul);
1179 pons = pc->Value(W);
1183 if (SearchFace(Spine,CP,F,Fv)){
1186 if (CP.IsVertex()) {
1187 // One goes directly by the Vertex
1188 Standard_Integer Nb;
1190 // And it is checked that there are no other candidates
1191 Nb = SearchFaceOnV(CP, F, myVEMap, myEFMap, Fv, aux);
1193 pons = BRep_Tool::Parameters(CP.Vertex(), Fv);
1196 HSBis = new (BRepAdaptor_Surface)(aux);
1197 PBis = BRep_Tool::Parameters(CP.Vertex(), aux);
1201 // otherwise one passes by the arc...
1203 Fv.Orientation(TopAbs_FORWARD);
1204 TopoDS_Edge newedge;
1206 for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()){
1207 if(ex.Current().IsSame(E)){
1208 newedge = TopoDS::Edge(ex.Current());
1212 //gp_Vec Varc, VSurf;
1213 // In cas of Tangent output, the current face becomes the support face
1214 if (SortieTangente(CP, F, SD, ons, 0.1)) {
1215 pc = BRep_Tool::CurveOnSurface(CP.Arc(),F,Uf,Ul);
1216 HSBis = new (BRepAdaptor_Surface)(F);
1217 PBis = pc->Value(CP.ParameterOnArc());
1221 pc = BRep_Tool::CurveOnSurface(newedge,Fv,Uf,Ul);
1224 TopoDS_Edge newedge = E;
1226 Fv.Orientation(TopAbs_FORWARD);
1227 pc = BRep_Tool::CurveOnSurface(newedge,Fv,Uf,Ul);
1229 pons = pc->Value(CP.ParameterOnArc());
1232 else if(!Fv.IsNull()){
1236 for(ex.Init(E,TopAbs_VERTEX); ex.More(); ex.Next()){
1237 if(ex.Current().IsSame(Vref)){
1245 HSref->Initialize(F);
1246 W = CP.ParameterOnArc();
1247 HC = new BRepAdaptor_Curve2d();
1248 TopoDS_Edge newedge;
1249 TopoDS_Face newface = Fv;
1250 newface.Orientation(TopAbs_FORWARD);
1252 for(ex.Init(newface,TopAbs_EDGE); ex.More(); ex.Next()){
1253 if(ex.Current().IsSame(E)){
1254 newedge = TopoDS::Edge(ex.Current());
1258 HC->Initialize(newedge,Fv);
1259 pons = HC->Value(W);
1260 HCref->Initialize(E,F);
1261 if(CP.IsVertex()) RecP = 1;
1267 W = CP.ParameterOnArc();
1268 pc = BRep_Tool::CurveOnSurface(E,F,Uf,Ul);
1269 pons = pc->Value(W);
1270 return Standard_False;
1273 else{ // there is no neighbor face, the state is preserved and False is returned.
1275 W = CP.ParameterOnArc();
1276 pc = BRep_Tool::CurveOnSurface(E,F,Uf,Ul);
1277 pons = pc->Value(W);
1278 return Standard_False;
1283 const ChFiDS_FaceInterference& FI = SD->Interference(ons);
1284 if(FI.PCurveOnFace().IsNull()) pons = SD->Get2dPoints(isfirst,ons);
1285 else pons = FI.PCurveOnFace()->Value(FI.Parameter(isfirst));
1287 return Standard_True;
1290 //=======================================================================
1291 //function : SearchFace
1293 //=======================================================================
1295 Standard_Boolean ChFi3d_Builder::SearchFace
1296 (const Handle(ChFiDS_Spine)& Spine,
1297 const ChFiDS_CommonPoint& Pc,
1298 const TopoDS_Face& FRef,
1299 TopoDS_Face& FVoi) const
1301 Standard_Boolean Trouve = Standard_False;
1302 if (! Pc.IsOnArc()) return Standard_False;
1306 // attention it is necessary to analyze all faces that turn around of the vertex
1308 std::cout<<"Commonpoint on vertex, the process hangs up"<<std::endl;
1310 if (Pc.HasVector()) { //General processing
1312 Standard_Integer nb_faces;
1313 nb_faces = SearchFaceOnV(Pc, FRef, myVEMap, myEFMap, FVoi, Fbis);
1314 return ( nb_faces > 0);
1316 else { // Processing using the spine
1317 Standard_Boolean FindFace=Standard_False;
1320 Spine->D1(Pc.Parameter(), Point, VecSpine);
1322 // It is checked if one leaves from the current face.
1323 FindFace = IsInput(VecSpine, Pc.Vertex(), FRef);
1326 FindFace = IsInput(VecSpine, Pc.Vertex(), FRef);
1328 // If one does not leave, it is ended
1331 return Standard_True;
1334 // Otherwise one finds the next among shared Faces
1335 // by a common edge G1
1336 TopTools_ListIteratorOfListOfShape ItE, ItF;
1337 for(ItE.Initialize(myVEMap(Pc.Vertex()));
1338 ItE.More() && (!FindFace); ItE.Next()) {
1339 E = TopoDS::Edge(ItE.Value());
1340 Trouve=Standard_False;
1341 for(ItF.Initialize(myEFMap(E));//, Trouve=Standard_False; 15.11.99 SVV
1342 ItF.More()&&(!Trouve); ItF.Next()) {
1343 if (TopoDS::Face(ItF.Value()).IsSame(FRef)) {
1344 Trouve = Standard_True;
1347 if (Trouve) FindFace = IsG1(myEFMap, E, FRef, FVoi);
1349 FindFace = Standard_False;
1350 if (Spine.IsNull()) {
1351 //La Spine peut etre nulle (ThreeCorner)
1353 std::cout << "FindFace sur vertex avec spine nulle! QUEZAKO ?" << std::endl;
1355 return Standard_False;
1358 // It is checked if the selected face actually possesses edges of the spine
1359 // containing the vertex on its front
1360 // This processing should go only if the Vertex belongs to the spine
1361 // This is a single case, for other vertexes it is required to do other things
1362 Trouve=Standard_False;
1363 for (Standard_Integer IE=1;//, Trouve=Standard_False; 15.11.99 SVV
1364 (IE<=Spine->NbEdges()) && (!Trouve); IE++) {
1365 E = Spine->Edges(IE);
1366 if ( (TopExp::FirstVertex(E).IsSame(Pc.Vertex()))
1367 ||(TopExp::LastVertex(E) .IsSame(Pc.Vertex())) ) {
1368 for(ItF.Initialize(myEFMap(E)), Trouve=Standard_False;
1369 ItF.More()&&(!Trouve); ItF.Next()) {
1370 if (TopoDS::Face(ItF.Value()).IsSame(FVoi)) {
1371 Trouve = Standard_True;
1382 return IsG1(myEFMap, Pc.Arc(), FRef, FVoi);
1384 return Standard_False;
1388 //=======================================================================
1389 //function : ChFi3d_SingularExtremity
1390 //purpose : load the vertex in the DS and calculate the pcurve
1391 // for an extremity in case of singular freeboundary
1392 // or periodic and singular at the cut.
1393 //=======================================================================
1394 static void ChFi3d_SingularExtremity( Handle(ChFiDS_Stripe)& stripe,
1395 TopOpeBRepDS_DataStructure& DStr,
1396 const TopoDS_Vertex& Vtx,
1397 const Standard_Real tol3d,
1398 const Standard_Real tol2d)
1400 Handle(ChFiDS_SurfData) Fd;
1401 Standard_Real tolreached;
1402 Standard_Real Pardeb, Parfin;
1403 gp_Pnt2d VOnS1, VOnS2;
1404 Handle(Geom_Curve) C3d;
1405 Handle(Geom2d_Curve) PCurv;
1406 TopOpeBRepDS_Curve Crv;
1407 // SurfData and its CommonPoints,
1408 Standard_Integer Ivtx, Icurv;
1409 Standard_Boolean isfirst;
1411 if (stripe->Spine()->IsPeriodic()) {
1412 isfirst = Standard_True;
1413 Fd = stripe->SetOfSurfData()->Sequence().First();
1416 Standard_Integer sens;
1417 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
1418 Fd = stripe->SetOfSurfData()->Sequence().Value(num);
1419 isfirst = (sens == 1);
1422 const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1);
1423 const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2);
1424 // Is it always degenerated ?
1425 if ( CV1.Point().IsEqual( CV2.Point(), 0) ) {
1426 Ivtx = ChFi3d_IndexPointInDS(CV1, DStr);
1428 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
1429 Value(Fd->InterferenceOnS1().FirstParameter());
1430 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
1431 Value(Fd->InterferenceOnS2().FirstParameter());
1434 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
1435 Value(Fd->InterferenceOnS1().LastParameter());
1436 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
1437 Value(Fd->InterferenceOnS2().LastParameter());
1440 ChFi3d_ComputeArete(CV1, VOnS1,
1442 DStr.Surface(Fd->Surf()).Surface(),
1444 Pardeb,Parfin, tol3d, tol2d, tolreached,0);
1445 Crv = TopOpeBRepDS_Curve(C3d,tolreached);
1446 Icurv = DStr.AddCurve(Crv);
1448 stripe->SetCurve(Icurv, isfirst);
1449 stripe->SetParameters(isfirst, Pardeb,Parfin);
1450 stripe->ChangePCurve(isfirst) = PCurv;
1451 stripe->SetIndexPoint(Ivtx, isfirst, 1);
1452 stripe->SetIndexPoint(Ivtx, isfirst, 2);
1454 if (stripe->Spine()->IsPeriodic()) {
1455 // periodic case : The operation is renewed
1456 // the curve 3d is not shared.
1457 // 2 degenerated edges coinciding in 3d
1458 isfirst = Standard_False;
1459 Fd = stripe->SetOfSurfData()->Sequence().Last();
1460 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
1461 Value(Fd->InterferenceOnS1().LastParameter());
1462 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
1463 Value(Fd->InterferenceOnS2().LastParameter());
1465 ChFi3d_ComputeArete(CV1, VOnS1,
1467 DStr.Surface(Fd->Surf()).Surface(),
1469 Pardeb,Parfin, tol3d, tol2d, tolreached,0);
1470 Crv = TopOpeBRepDS_Curve(C3d,tolreached);
1471 Icurv = DStr.AddCurve(Crv);
1473 stripe->SetCurve(Icurv, isfirst);
1474 stripe->SetParameters(isfirst, Pardeb,Parfin);
1475 stripe->ChangePCurve(isfirst) = PCurv;
1476 stripe->SetIndexPoint(Ivtx, isfirst, 1);
1477 stripe->SetIndexPoint(Ivtx, isfirst, 2);
1482 //=======================================================================
1483 //function : ChFi3d_MakeExtremities
1484 //purpose : calculate Curves3d and pcurves of extremities in
1485 // periodic and freeboundary cases.
1486 //=======================================================================
1487 static Standard_Boolean IsFree(const TopoDS_Shape& E,
1488 const ChFiDS_Map& EFMap)
1490 if(!EFMap.Contains(E)) return 0;
1491 TopTools_ListIteratorOfListOfShape It;
1493 for(It.Initialize(EFMap(E)); It.More(); It.Next()){
1494 if(Fref.IsNull()) Fref = It.Value();
1495 else if(!Fref.IsSame(It.Value())) return 0;
1500 static void ChFi3d_MakeExtremities(Handle(ChFiDS_Stripe)& Stripe,
1501 TopOpeBRepDS_DataStructure& DStr,
1502 const ChFiDS_Map& EFMap,
1503 const Standard_Real tol3d,
1504 const Standard_Real tol2d)
1506 Handle(ChFiDS_Spine)& sp = Stripe->ChangeSpine();
1507 Standard_Real Pardeb,Parfin;
1508 Handle(Geom_Curve) C3d;
1509 Standard_Real tolreached;
1510 if(sp->IsPeriodic()){
1512 const Handle(ChFiDS_SurfData)&
1513 SDF = Stripe->SetOfSurfData()->Sequence().First();
1514 const ChFiDS_CommonPoint& CV1 = SDF->VertexFirstOnS1();
1515 const ChFiDS_CommonPoint& CV2 = SDF->VertexFirstOnS2();
1516 if ( !CV1.Point().IsEqual(CV2.Point(), 0) ) {
1517 ChFi3d_ComputeArete(CV1,
1518 SDF->InterferenceOnS1().PCurveOnSurf()->
1519 Value(SDF->InterferenceOnS1().FirstParameter()),
1521 SDF->InterferenceOnS2().PCurveOnSurf()->
1522 Value(SDF->InterferenceOnS2().FirstParameter()),
1523 DStr.Surface(SDF->Surf()).Surface(),C3d,
1524 Stripe->ChangeFirstPCurve(),Pardeb,Parfin,
1525 tol3d,tol2d,tolreached,0);
1526 TopOpeBRepDS_Curve Crv(C3d,tolreached);
1527 Stripe->ChangeFirstCurve(DStr.AddCurve(Crv));
1528 Stripe->ChangeFirstParameters(Pardeb,Parfin);
1529 Stripe->ChangeIndexFirstPointOnS1
1530 (ChFi3d_IndexPointInDS(SDF->VertexFirstOnS1(),DStr));
1531 Stripe->ChangeIndexFirstPointOnS2
1532 (ChFi3d_IndexPointInDS(SDF->VertexFirstOnS2(),DStr));
1533 Standard_Integer ICurv = Stripe->FirstCurve();
1534 Stripe->ChangeLastParameters(Pardeb,Parfin);
1535 Stripe->ChangeLastCurve(ICurv);
1536 Stripe->ChangeIndexLastPointOnS1(Stripe->IndexFirstPointOnS1());
1537 Stripe->ChangeIndexLastPointOnS2(Stripe->IndexFirstPointOnS2());
1539 const Handle(ChFiDS_SurfData)&
1540 SDL = Stripe->SetOfSurfData()->Sequence().Last();
1543 ChFi3d_ComputePCurv(C3d,
1544 SDL->InterferenceOnS1().PCurveOnSurf()->
1545 Value(SDL->InterferenceOnS1().LastParameter()),
1546 SDL->InterferenceOnS2().PCurveOnSurf()->
1547 Value(SDL->InterferenceOnS2().LastParameter()),
1548 Stripe->ChangeLastPCurve(),
1549 DStr.Surface(SDL->Surf()).Surface(),
1550 Pardeb,Parfin,tol3d,tolreached);
1551 Standard_Real oldtol = DStr.ChangeCurve(ICurv).Tolerance();
1552 DStr.ChangeCurve(ICurv).Tolerance(Max(oldtol,tolreached));
1554 ChFi3d_EnlargeBox(CV1.Arc(),EFMap(CV1.Arc()),CV1.ParameterOnArc(),b1);
1558 ChFi3d_EnlargeBox(CV2.Arc(),EFMap(CV2.Arc()),CV2.ParameterOnArc(),b2);
1560 ChFi3d_EnlargeBox(DStr,Stripe,SDF,b1,b2,1);
1561 ChFi3d_EnlargeBox(DStr,Stripe,SDL,b1,b2,0);
1562 if (!CV1.IsVertex())
1563 ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexFirstPointOnS1());
1564 if (!CV2.IsVertex())
1565 ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexFirstPointOnS2());
1568 // Case of the single extremity
1569 if (CV1.IsVertex()) {
1570 ChFi3d_SingularExtremity(Stripe, DStr, CV1.Vertex(), tol3d, tol2d);
1573 else { std::cout << "MakeExtremities : Singularity out of Vertex !!" << std::endl; }
1579 const Handle(ChFiDS_SurfData)&
1580 SDdeb = Stripe->SetOfSurfData()->Sequence().First();
1582 const ChFiDS_CommonPoint& cpdeb1 = SDdeb->VertexFirstOnS1();
1583 const ChFiDS_CommonPoint& cpdeb2 = SDdeb->VertexFirstOnS2();
1584 Standard_Boolean freedeb = sp->FirstStatus() == ChFiDS_FreeBoundary;
1585 if(!freedeb && cpdeb1.IsOnArc() && cpdeb2.IsOnArc()){
1586 freedeb = (IsFree(cpdeb1.Arc(),EFMap) && IsFree(cpdeb2.Arc(),EFMap));
1589 sp->SetFirstStatus(ChFiDS_FreeBoundary);
1591 if ( !cpdeb1.Point().IsEqual(cpdeb2.Point(), 0) ) {
1592 Standard_Boolean plane;
1594 UV1=SDdeb->InterferenceOnS1().PCurveOnSurf()->
1595 Value(SDdeb->InterferenceOnS1().FirstParameter());
1596 UV2=SDdeb->InterferenceOnS2().PCurveOnSurf()->
1597 Value(SDdeb->InterferenceOnS2().FirstParameter());
1598 // The intersection of the fillet by a plane is attempted
1600 Handle(GeomAdaptor_Surface) HConge=ChFi3d_BoundSurf(DStr,SDdeb,1,2);
1601 ChFi3d_CoupeParPlan(cpdeb1,cpdeb2,HConge,UV1,UV2,
1602 tol3d,tol2d,C3d,Stripe->ChangeFirstPCurve(),tolreached,
1603 Pardeb,Parfin,plane);
1605 ChFi3d_ComputeArete(cpdeb1,
1606 SDdeb->InterferenceOnS1().PCurveOnSurf()->
1607 Value(SDdeb->InterferenceOnS1().FirstParameter()),
1609 SDdeb->InterferenceOnS2().PCurveOnSurf()->
1610 Value(SDdeb->InterferenceOnS2().FirstParameter()),
1611 DStr.Surface(SDdeb->Surf()).Surface(),C3d,
1612 Stripe->ChangeFirstPCurve(),Pardeb,Parfin,
1613 tol3d,tol2d,tolreached,0);
1614 TopOpeBRepDS_Curve Crv(C3d,tolreached);
1615 Stripe->ChangeFirstCurve(DStr.AddCurve(Crv));
1616 Stripe->ChangeFirstParameters(Pardeb,Parfin);
1617 Stripe->ChangeIndexFirstPointOnS1
1618 (ChFi3d_IndexPointInDS(SDdeb->VertexFirstOnS1(),DStr));
1619 Stripe->ChangeIndexFirstPointOnS2
1620 (ChFi3d_IndexPointInDS(SDdeb->VertexFirstOnS2(),DStr));
1621 if(cpdeb1.IsOnArc()){
1622 ChFi3d_EnlargeBox(cpdeb1.Arc(),EFMap(cpdeb1.Arc()),cpdeb1.ParameterOnArc(),b1);
1624 if(cpdeb2.IsOnArc()){
1625 ChFi3d_EnlargeBox(cpdeb2.Arc(),EFMap(cpdeb2.Arc()),cpdeb2.ParameterOnArc(),b2);
1627 ChFi3d_EnlargeBox(DStr,Stripe,SDdeb,b1,b2,1);
1628 if (!cpdeb1.IsVertex())
1629 ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexFirstPointOnS1());
1630 if (!cpdeb2.IsVertex())
1631 ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexFirstPointOnS2());
1633 else { // Case of a singular extremity
1634 if (cpdeb1.IsVertex()) {
1635 ChFi3d_SingularExtremity(Stripe, DStr, cpdeb1.Vertex(), tol3d, tol2d);
1638 else { std::cout << "MakeExtremities : Singularity out of Vertex !!" << std::endl; }
1642 const Handle(ChFiDS_SurfData)&
1643 SDfin = Stripe->SetOfSurfData()->Sequence().Last();
1644 const ChFiDS_CommonPoint& cpfin1 = SDfin->VertexLastOnS1();
1645 const ChFiDS_CommonPoint& cpfin2 = SDfin->VertexLastOnS2();
1646 Standard_Boolean freefin = sp->LastStatus() == ChFiDS_FreeBoundary;
1647 if(!freefin && cpfin1.IsOnArc() && cpfin2.IsOnArc()){
1648 freefin = (IsFree(cpfin1.Arc(),EFMap) && IsFree(cpfin2.Arc(),EFMap));
1651 sp->SetLastStatus(ChFiDS_FreeBoundary);
1653 if ( !cpfin1.Point().IsEqual(cpfin2.Point(), 0) ) {
1654 Standard_Boolean plane;
1656 UV1=SDfin->InterferenceOnS1().PCurveOnSurf()->
1657 Value(SDfin->InterferenceOnS1().LastParameter());
1658 UV2=SDfin->InterferenceOnS2().PCurveOnSurf()->
1659 Value(SDfin->InterferenceOnS2().LastParameter());
1660 // Intersection of the fillet by a plane is attempted
1662 Handle(GeomAdaptor_Surface) HConge=ChFi3d_BoundSurf(DStr,SDfin,1,2);
1663 ChFi3d_CoupeParPlan(cpfin1,cpfin2,HConge,UV1,UV2,
1664 tol3d,tol2d,C3d,Stripe->ChangeLastPCurve(),tolreached,
1665 Pardeb,Parfin,plane);
1667 ChFi3d_ComputeArete(cpfin1,
1668 SDfin->InterferenceOnS1().PCurveOnSurf()->
1669 Value(SDfin->InterferenceOnS1().LastParameter()),
1671 SDfin->InterferenceOnS2().PCurveOnSurf()->
1672 Value(SDfin->InterferenceOnS2().LastParameter()),
1673 DStr.Surface(SDfin->Surf()).Surface(),C3d,
1674 Stripe->ChangeLastPCurve(),Pardeb,Parfin,
1675 tol3d,tol2d,tolreached,0);
1676 TopOpeBRepDS_Curve Crv(C3d,tolreached);
1677 Stripe->ChangeLastCurve(DStr.AddCurve(Crv));
1678 Stripe->ChangeLastParameters(Pardeb,Parfin);
1679 Stripe->ChangeIndexLastPointOnS1
1680 (ChFi3d_IndexPointInDS(SDfin->VertexLastOnS1(),DStr));
1681 Stripe->ChangeIndexLastPointOnS2
1682 (ChFi3d_IndexPointInDS(SDfin->VertexLastOnS2(),DStr));
1683 if(cpfin1.IsOnArc()){
1684 ChFi3d_EnlargeBox(cpfin1.Arc(),EFMap(cpfin1.Arc()),cpfin1.ParameterOnArc(),b1);
1686 if(cpfin2.IsOnArc()){
1687 ChFi3d_EnlargeBox(cpfin2.Arc(),EFMap(cpfin2.Arc()),cpfin2.ParameterOnArc(),b2);
1689 ChFi3d_EnlargeBox(DStr,Stripe,SDfin,b1,b2,0);
1690 if (!cpfin1.IsVertex())
1691 ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexLastPointOnS1());
1692 if (!cpfin2.IsVertex())
1693 ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexLastPointOnS2());
1695 else { // Case of the single extremity
1696 if (cpfin1.IsVertex()) {
1697 ChFi3d_SingularExtremity(Stripe, DStr, cpfin1.Vertex(), tol3d, tol2d);
1700 else { std::cout << "MakeExtremities : Singularity out of Vertex !!" << std::endl; }
1706 //=======================================================================
1707 //function : ChFi3d_Purge
1709 //=======================================================================
1711 static void ChFi3d_Purge (Handle(ChFiDS_Stripe)& Stripe,
1712 Handle(ChFiDS_SurfData)& SD,
1713 const ChFiDS_CommonPoint& VRef,
1714 const Standard_Boolean isfirst,
1715 const Standard_Integer ons,
1716 Standard_Integer& intf,
1717 Standard_Integer& intl)
1719 if (isfirst) intf = 1; else intl = 1; // End.
1720 Standard_Integer opp = 3-ons;
1721 if (!SD->Vertex(isfirst,opp).IsOnArc() ||
1722 SD->TwistOnS1() || SD->TwistOnS2() ) {
1724 std::cout<<"ChFi3d_Purge : No output on extension."<<std::endl;
1726 ChFiDS_SequenceOfSurfData& Seq =
1727 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1728 if(isfirst) Seq.Remove(1);
1729 else Seq.Remove(Seq.Length());
1732 if (ons == 1) SD->ChangeIndexOfS1(0);
1733 else SD->ChangeIndexOfS2(0);
1735 SD->ChangeVertex(!isfirst,ons) = VRef;
1736 SD->ChangeVertex(isfirst,ons) = VRef;
1738 ChFiDS_FaceInterference& fi = SD->ChangeInterference(ons);
1739 if(isfirst) fi.SetFirstParameter(fi.LastParameter());
1740 else fi.SetLastParameter(fi.FirstParameter());
1744 //=======================================================================
1745 //function : InsertAfter
1746 //purpose : insert Item after ref in Seq. If ref is null, the item is
1747 // inserted at the beginning.
1748 //=======================================================================
1750 static void InsertAfter (Handle(ChFiDS_Stripe)& Stripe,
1751 Handle(ChFiDS_SurfData)& Ref,
1752 Handle(ChFiDS_SurfData)& Item)
1755 throw Standard_Failure("InsertAfter : twice the same surfdata.");
1757 ChFiDS_SequenceOfSurfData& Seq =
1758 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1760 if (Seq.IsEmpty() || Ref.IsNull()) {
1763 for (Standard_Integer i = 1; i <= Seq.Length(); i++) {
1764 if (Seq.Value(i) == Ref) {
1765 Seq.InsertAfter(i,Item);
1771 //=======================================================================
1772 //function : RemoveSD
1774 //=======================================================================
1776 static void RemoveSD (Handle(ChFiDS_Stripe)& Stripe,
1777 Handle(ChFiDS_SurfData)& Prev,
1778 Handle(ChFiDS_SurfData)& Next)
1780 ChFiDS_SequenceOfSurfData& Seq =
1781 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1782 if(Seq.IsEmpty()) return;
1783 Standard_Integer iprev = 0, inext = 0;
1784 for (Standard_Integer i = 1; i <= Seq.Length(); i++) {
1785 if (Seq.Value(i) == Prev) iprev = i + 1;
1786 if (Seq.Value(i) == Next) { inext = i - 1; break; }
1788 if(Prev.IsNull()) iprev = 1;
1789 if(Next.IsNull()) inext = Seq.Length();
1790 if(iprev <= inext) Seq.Remove(iprev,inext);
1793 //=======================================================================
1794 //function : InsertBefore
1795 //purpose : Insert item before ref in Seq. If ref is null, the item is
1796 // inserted in the queue.
1797 //=======================================================================
1799 static void InsertBefore (Handle(ChFiDS_Stripe)& Stripe,
1800 Handle(ChFiDS_SurfData)& Ref,
1801 Handle(ChFiDS_SurfData)& Item)
1804 throw Standard_Failure("InsertBefore : twice the same surfdata.");
1806 ChFiDS_SequenceOfSurfData& Seq =
1807 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1809 if (Seq.IsEmpty() || Ref.IsNull()) {
1812 for (Standard_Integer i = 1; i <= Seq.Length(); i++) {
1813 if (Seq.Value(i) == Ref) {
1814 Seq.InsertBefore(i,Item);
1821 //=======================================================================
1822 //function : PerformSetOfSurfOnElSpine
1824 //=======================================================================
1826 void ChFi3d_Builder::PerformSetOfSurfOnElSpine
1827 (const Handle(ChFiDS_ElSpine)& HGuide,
1828 Handle(ChFiDS_Stripe)& Stripe,
1829 Handle(BRepTopAdaptor_TopolTool)& It1,
1830 Handle(BRepTopAdaptor_TopolTool)& It2,
1831 const Standard_Boolean Simul)
1834 OSD_Chronometer ch1;
1840 //( HGuide->Curve() ).D1(HGuide->FirstParameter(),ptgui,d1gui);
1842 ChFiDS_ElSpine& Guide = *HGuide;
1844 Handle(ChFiDS_ElSpine) OffsetHGuide;
1845 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
1846 if (Spine->Mode() == ChFiDS_ConstThroatWithPenetrationChamfer)
1848 ChFiDS_ListOfHElSpine& ll = Spine->ChangeElSpines();
1849 ChFiDS_ListOfHElSpine& ll_offset = Spine->ChangeOffsetElSpines();
1850 ChFiDS_ListIteratorOfListOfHElSpine ILES(ll), ILES_offset(ll_offset);
1851 for ( ; ILES.More(); ILES.Next(),ILES_offset.Next())
1853 const Handle(ChFiDS_ElSpine)& aHElSpine = ILES.Value();
1854 if (aHElSpine == HGuide)
1855 OffsetHGuide = ILES_offset.Value();
1859 Standard_Real wf = Guide.FirstParameter();
1860 Standard_Real wl = Guide.LastParameter();
1861 Standard_Real locfleche = (wl - wf) * fleche;
1862 Standard_Real wfsav = wf, wlsav = wl;
1863 if (!Guide.IsPeriodic())
1865 //Now the ElSpine is artificially extended to help rsnld.
1866 Standard_Real prab = 0.01;
1867 Guide.FirstParameter(wf-prab*(wl-wf));
1868 Guide.LastParameter (wl+prab*(wl-wf));
1869 if (!OffsetHGuide.IsNull())
1871 OffsetHGuide->FirstParameter(wf-prab*(wl-wf));
1872 OffsetHGuide->LastParameter (wl+prab*(wl-wf));
1875 //Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
1876 Standard_Integer ii, nbed = Spine->NbEdges();
1877 Standard_Real lastedlastp = Spine->LastParameter(nbed);
1879 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
1881 Handle(ChFiDS_SurfData) ref = Guide.Previous();
1882 Handle(ChFiDS_SurfData) refbis, SD;
1883 Handle(ChFiDS_SurfData) raf = Guide.Next();
1884 RemoveSD(Stripe,ref,raf);
1886 Handle(BRepAdaptor_Surface) HS1 = new BRepAdaptor_Surface();
1887 Handle(BRepAdaptor_Surface) HS2 = new BRepAdaptor_Surface();
1888 Handle(BRepAdaptor_Surface) HS3, HS4;
1889 Handle(BRepAdaptor_Surface) HSref1 = new BRepAdaptor_Surface();
1890 Handle(BRepAdaptor_Surface) HSref2 = new BRepAdaptor_Surface();
1891 Handle(BRepAdaptor_Curve2d) HC1,HC2;
1892 Handle(BRepAdaptor_Curve2d) HCref1 = new BRepAdaptor_Curve2d();
1893 Handle(BRepAdaptor_Curve2d) HCref2 = new BRepAdaptor_Curve2d();
1894 Standard_Boolean decroch1 = Standard_False, decroch2 = Standard_False;
1895 Standard_Boolean RecP1 = Standard_False, RecS1 = Standard_False, RecRst1 = Standard_False, obstacleon1 = Standard_False;
1896 Standard_Boolean RecP2 = Standard_False, RecS2 = Standard_False, RecRst2 = Standard_False, obstacleon2 = Standard_False;
1897 gp_Pnt2d pp1,pp2,pp3,pp4;
1898 Standard_Real w1 = 0.,w2 = 0.;
1899 math_Vector Soldep(1,4);
1900 math_Vector SoldepCS(1,3);
1901 math_Vector SoldepCC(1,2);
1903 // Restore a neighboring KPart.
1904 // If no neighbor calculation start point.
1905 Standard_Boolean forward = Standard_True;
1906 Standard_Boolean Inside = Standard_False;
1907 Standard_Real First = wf;
1908 Standard_Real Last = wl;
1909 Standard_Boolean Ok1 = 1,Ok2 = 1;
1910 // Restore the next KPart if it exists
1912 if(ref.IsNull() && raf.IsNull()){
1913 //sinon solution approchee.
1914 Inside = Standard_True;
1917 ChFi3d_InitChron(ch1);// init perf for StartSol
1920 StartSol(Stripe,HGuide,HS1,HS2,It1,It2,pp1,pp2,First);
1923 ChFi3d_ResultChron(ch1,t_startsol); // result perf for StartSol
1927 if(Guide.IsPeriodic()) {
1928 Last = First - Guide.Period();
1929 Guide.SaveFirstParameter();
1930 Guide.FirstParameter(Last);
1931 Guide.SaveLastParameter();
1932 Guide.LastParameter (First * 1.1);//Extension to help rsnld.
1933 if (!OffsetHGuide.IsNull())
1935 OffsetHGuide->SaveFirstParameter();
1936 OffsetHGuide->FirstParameter(Last);
1937 OffsetHGuide->SaveLastParameter();
1938 OffsetHGuide->LastParameter (First * 1.1);//Extension to help rsnld.
1943 if(!Spine->IsPeriodic() && (wl - lastedlastp > -tolesp)){
1944 Vref = Spine->LastVertex();
1947 if(!Spine->IsPeriodic() && (wf < tolesp)){
1948 Vref = Spine->FirstVertex();
1951 forward = Standard_False;
1952 First = wl; Last = Guide.FirstParameter();
1956 ChFi3d_InitChron(ch1);// init perf for startsol
1960 Ok1 = StartSol(Spine,HS1,pp1,HC1,w1,ref,!forward,1,
1961 HSref1,HCref1,RecP1,RecS1,RecRst1,obstacleon1,
1962 HS3,pp3,decroch1,Vref);
1963 Ok2 = StartSol(Spine,HS2,pp2,HC2,w2,ref,!forward,2,
1964 HSref2,HCref2, RecP2,RecS2,RecRst2,obstacleon2,
1965 HS4,pp4,decroch2,Vref);
1970 ChFi3d_ResultChron(ch1,t_startsol); // result perf for startsol
1974 if(Ok1 == 1 && Ok2 == 1) {
1977 Guide.FirstParameter(wf);
1978 if (!OffsetHGuide.IsNull())
1979 OffsetHGuide->FirstParameter(wf);
1983 Guide.LastParameter(wl);
1984 if (!OffsetHGuide.IsNull())
1985 OffsetHGuide->LastParameter(wl);
1989 Standard_Boolean fini = Standard_False;
1990 Standard_Boolean complete = Inside;
1991 if(!Guide.IsPeriodic()){
1992 Standard_Integer indf = Spine->Index(wf);
1993 Standard_Integer indl = Spine->Index(wl,0);
1994 if(Spine->IsPeriodic() && (indl < indf)) indl += nbed;
1997 // No Max at the touch : 20 points by edge at average without
1998 // counting the extensions.
2000 Standard_Real bidf = wf, bidl = wl;
2001 if(!Spine->IsPeriodic()) {
2003 bidl = Min(wl,Spine->LastParameter(Spine->NbEdges()));
2004 // PMN 20/07/98 : Attention in case if there is only extension
2005 if ((bidl-bidf) < 0.01 * Spine->LastParameter(Spine->NbEdges())) {
2010 Standard_Real MaxStep = (bidl-bidf)*0.05/nbed;
2011 Standard_Real Firstsov = 0.;
2012 Standard_Integer intf = 0, intl = 0;
2014 // are these the ends (no extension on periodic).
2016 if(!Spine->IsPeriodic()){
2017 if(wf < tolesp && (complete == Inside)){
2018 if(Spine->FirstStatus() == ChFiDS_OnSame) intf = 2;
2021 if(Spine->IsTangencyExtremity(Standard_True)){
2023 Guide.FirstParameter(wfsav);
2024 if (!OffsetHGuide.IsNull())
2025 OffsetHGuide->FirstParameter(wfsav);
2027 if(wl - lastedlastp > -tolesp){
2028 if(Spine->LastStatus() == ChFiDS_OnSame) intl = 2;
2031 if(Spine->IsTangencyExtremity(Standard_False)){
2033 Guide.LastParameter(wlsav);
2034 if (!OffsetHGuide.IsNull())
2035 OffsetHGuide->LastParameter(wlsav);
2038 if(intf && !forward) Vref = Spine->FirstVertex();
2039 if(intl && forward) Vref = Spine->LastVertex();
2043 ChFi3d_InitChron(ch1);// init perf for StartSol
2046 Ok1 = StartSol(Spine,HS1,pp1,HC1,w1,ref,!forward,1,
2047 HSref1,HCref1, RecP1,RecS1,RecRst1,obstacleon1,
2048 HS3,pp3,decroch1,Vref);
2049 Ok2 = StartSol(Spine,HS2,pp2,HC2,w2,ref,!forward,2,
2050 HSref2,HCref2, RecP2,RecS2,RecRst2,obstacleon2,
2051 HS4,pp4,decroch2,Vref);
2054 ChFi3d_ResultChron(ch1,t_startsol); // result perf for StartSol
2059 // No more connected faces. Construction of the tangent plane to continue the path
2060 // till the output on the other face.
2061 if ((!Ok1 && HC1.IsNull()) || (!Ok2 && HC2.IsNull())) {
2062 if ((intf && !forward) || (intl && forward)) {
2063 if (!Ok1) ChFi3d_BuildPlane (DStr,HS1,pp1,ref,!forward,1);
2064 if (!Ok2) ChFi3d_BuildPlane (DStr,HS2,pp2,ref,!forward,2);
2066 else if(intl) intl = 5;
2069 Guide.FirstParameter(wf);
2070 if (!OffsetHGuide.IsNull())
2071 OffsetHGuide->FirstParameter(wf);
2075 Guide.LastParameter(wl);
2076 if (!OffsetHGuide.IsNull())
2077 OffsetHGuide->LastParameter(wl);
2080 else throw Standard_Failure("PerformSetOfSurfOnElSpine : Chaining is impossible.");
2083 // Definition of the domain of patch It1, It2
2084 const Handle(Adaptor3d_Surface)& HSon1 = HS1; // to avoid ambiguity
2085 const Handle(Adaptor3d_Surface)& HSon2 = HS2; // to avoid ambiguity
2086 It1->Initialize(HSon1);
2087 It2->Initialize(HSon2);
2089 // Calculate one (several if singularity) SurfaData
2090 SD = new ChFiDS_SurfData();
2091 ChFiDS_SequenceOfSurfData SeqSD;
2094 if(obstacleon1 && obstacleon2){
2095 TopAbs_Orientation Or1 = HSref1->Face().Orientation();
2096 TopAbs_Orientation Or2 = HSref2->Face().Orientation();
2097 Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2,
2098 Stripe->OrientationOnFace1(),
2099 Stripe->OrientationOnFace2(),
2103 // Calculate the criterion of Choice edge / edge
2104 if (Choix%2 == 0) Choix = 4;
2107 SoldepCC(1) = w1; SoldepCC(2) = w2;
2109 SimulSurf(SD,HGuide,Spine,Choix,
2110 HS1,It1,HC1,HSref1,HCref1,decroch1,Or1,
2111 HS2,It2,HC2,HSref2,HCref2,decroch2,Or2,
2112 locfleche,tolesp,First,Last,Inside,Inside,forward,
2113 RecP1,RecRst1,RecP2,RecRst2,SoldepCC);
2117 ChFi3d_InitChron(ch1); // init perf for PerformSurf
2119 PerformSurf(SeqSD,HGuide,Spine,Choix,
2120 HS1,It1,HC1,HSref1,HCref1,decroch1,Or1,
2121 HS2,It2,HC2,HSref2,HCref2,decroch2,Or2,
2122 MaxStep,locfleche,tolesp,First,Last,Inside,Inside,forward,
2123 RecP1,RecRst1,RecP2,RecRst2,SoldepCC);
2125 ChFi3d_ResultChron(ch1,t_performsurf); //result perf for PerformSurf
2128 SD->ChangeIndexOfS1(DStr.AddShape(HS1->Face()));
2129 SD->ChangeIndexOfS2(DStr.AddShape(HS2->Face()));
2131 else if (obstacleon1){
2132 TopAbs_Orientation Or1 = HSref1->Face().Orientation();
2133 TopAbs_Orientation Or2 = HS2->Face().Orientation();
2134 Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2,
2135 Stripe->OrientationOnFace1(),
2136 Stripe->OrientationOnFace2(),
2138 if(Choix%2 == 1) Choix++;
2140 SoldepCS(3) = w1; SoldepCS(1) = pp2.X(); SoldepCS(2) = pp2.Y();
2142 SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,HC1,HSref1,HCref1,decroch1,
2143 HS2,It2,Or2,locfleche,tolesp,First,Last,
2144 Inside,Inside,forward,RecP1,RecS2,RecRst1,SoldepCS);
2148 ChFi3d_InitChron(ch1); // init perf for PerformSurf
2150 PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,HC1,HSref1,HCref1,decroch1,
2151 HS2,It2,Or2,MaxStep,locfleche,tolesp,First,Last,
2152 Inside,Inside,forward,RecP1,RecS2,RecRst1,SoldepCS);
2154 ChFi3d_ResultChron(ch1,t_performsurf);//result perf for PerformSurf
2157 SD->ChangeIndexOfS1(DStr.AddShape(HS1->Face()));
2158 SD->ChangeIndexOfS2(DStr.AddShape(HS2->Face()));
2161 else if (obstacleon2){
2162 TopAbs_Orientation Or1 = HS1->Face().Orientation();
2163 TopAbs_Orientation Or2 = HSref2->Face().Orientation();
2164 Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2,
2165 Stripe->OrientationOnFace1(),
2166 Stripe->OrientationOnFace2(),
2168 SoldepCS(3) = w2; SoldepCS(1) = pp1.X(); SoldepCS(2) = pp1.Y();
2170 SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,Or1,
2171 HS2,It2,HC2,HSref2,HCref2,decroch2,locfleche,tolesp,
2172 First,Last,Inside,Inside,forward,RecP2,RecS1,RecRst2,SoldepCS);
2176 ChFi3d_InitChron(ch1); // init perf for PerformSurf
2178 PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,Or1,
2179 HS2,It2,HC2,HSref2,HCref2,decroch2,MaxStep,locfleche,tolesp,
2180 First,Last,Inside,Inside,forward,RecP2,RecS1,RecRst2,SoldepCS);
2182 ChFi3d_ResultChron(ch1,t_performsurf); //result perf for PerformSurf
2185 SD->ChangeIndexOfS1(DStr.AddShape(HS1->Face()));
2186 SD->ChangeIndexOfS2(DStr.AddShape(HS2->Face()));
2190 const Handle(Adaptor3d_TopolTool)& aTT1 = It1; // to avoid ambiguity
2191 const Handle(Adaptor3d_TopolTool)& aTT2 = It2; // to avoid ambiguity
2192 CallPerformSurf(Stripe, Simul, SeqSD, SD,
2194 HS1, HS3, pp1, pp3, aTT1,
2195 HS2, HS4, pp2, pp4, aTT2,
2196 MaxStep,locfleche,tolesp,
2197 First,Last,Inside,Inside,forward,
2198 RecS1,RecS2,Soldep,intf,intl,
2200 decroch1 = decroch2 = 0;
2203 if(!done) { // Case of fail
2204 if ((!Ok1 && !obstacleon1) || (!Ok2 && !obstacleon2)) {
2205 //Fail in a part of extension is not serious
2207 done = Standard_True;
2208 Inside = Standard_False;
2209 if (forward) intl = 1;
2212 else { // Otherwise invalidation of the stripe.
2213 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
2214 throw Standard_Failure("CallPerformSurf : Path failed!");
2221 for (ii=1; ii<=SeqSD.Length(); ii++) {
2223 SD->ChangeIndexOfS1(DStr.AddShape(HS1->Face()));
2224 if(obstacleon1) SD->SetIndexOfC1(DStr.AddShape(HC1->Edge()));
2225 SD->ChangeIndexOfS2(DStr.AddShape(HS2->Face()));
2226 if(obstacleon2) SD->SetIndexOfC2(DStr.AddShape(HC2->Edge()));
2227 InsertAfter (Stripe, refbis, SD);
2232 for (ii=SeqSD.Length(); ii>=1; ii--) {
2234 SD->ChangeIndexOfS1(DStr.AddShape(HS1->Face()));
2235 if(obstacleon1) SD->SetIndexOfC1(DStr.AddShape(HC1->Edge()));
2236 SD->ChangeIndexOfS2(DStr.AddShape(HS2->Face()));
2237 if(obstacleon2) SD->SetIndexOfC2(DStr.AddShape(HC2->Edge()));
2238 InsertBefore(Stripe,refbis,SD);
2243 if (!Ok1 && !obstacleon1)
2244 // clean infos on the plane of extension.
2245 ChFi3d_Purge (Stripe,SD,ref->Vertex(!forward,1),!forward,1,intf,intl);
2247 if (!Ok2 && !obstacleon2)
2248 // clean infos on the plane of extension.
2249 ChFi3d_Purge (Stripe,SD,ref->Vertex(!forward,2),!forward,2,intf,intl);
2251 // The end. The reference is changed.
2255 if(Inside){// There are starting solutions for the next.
2256 Inside = Standard_False;
2258 if(Guide.IsPeriodic()) {
2259 complete = Standard_False;
2260 wf = Guide.FirstParameter();
2261 wl = Guide.LastParameter();
2265 fini = ((wl - Last) <= 10.*tolesp ||
2266 (intl && !(obstacleon1 || obstacleon2))); //General case
2268 if (!fini && Guide.IsPeriodic() &&
2269 ((wl - Last)< Guide.Period()*1.e-3)) {
2270 // It is tested if reframing of extremes is done at the same edge
2272 Handle(ChFiDS_SurfData) thefirst, thelast;
2273 thefirst = Stripe->SetOfSurfData()->Sequence().First();
2274 thelast = Stripe->SetOfSurfData()->Sequence().Last();
2276 if (thefirst->VertexFirstOnS1().IsOnArc() &&
2277 thelast->VertexLastOnS1().IsOnArc())
2278 fini = thefirst->VertexFirstOnS1().Arc().IsSame
2279 (thelast->VertexLastOnS1().Arc());
2281 thefirst->VertexFirstOnS2().IsOnArc() &&
2282 thelast->VertexLastOnS2().IsOnArc())
2283 fini = thefirst->VertexFirstOnS2().Arc().IsSame
2284 (thelast->VertexLastOnS2().Arc());
2287 return; //It is ended!
2290 if(fini && complete) {
2291 // restart in the opposite direction.
2292 ref = Stripe->SetOfSurfData()->Sequence().First();
2293 forward = Standard_False;
2294 fini = Standard_False;
2303 fini = ((First - wf) <= 10.*tolesp ||
2304 (intf && !(obstacleon1 || obstacleon2)));
2305 complete = Standard_False;
2309 // The initial state is restored
2310 if(!Guide.IsPeriodic()){
2311 Guide.FirstParameter(wfsav);
2312 Guide.LastParameter (wlsav);
2313 if (!OffsetHGuide.IsNull())
2315 OffsetHGuide->FirstParameter(wfsav);
2316 OffsetHGuide->LastParameter (wlsav);
2322 //=======================================================================
2323 //function : PerformSetOfKPart
2325 //=======================================================================
2327 void ChFi3d_Builder::PerformSetOfKPart(Handle(ChFiDS_Stripe)& Stripe,
2328 const Standard_Boolean Simul)
2330 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
2331 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
2332 Handle(BRepAdaptor_Surface) HS1,HS2;
2333 TopAbs_Orientation Or1,Or2,RefOr1,RefOr2;
2334 Standard_Integer RefChoix;
2336 // initialization of the stripe.
2338 Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData();
2339 HData = new ChFiDS_HData();
2340 ChFiDS_SequenceOfSurfData& SeqSurf = HData->ChangeSequence();
2342 StripeOrientations(Spine,RefOr1,RefOr2,RefChoix);
2343 Stripe->OrientationOnFace1(RefOr1);
2344 Stripe->OrientationOnFace2(RefOr2);
2345 Stripe->Choix(RefChoix);
2347 Handle(BRepTopAdaptor_TopolTool) It1 = new BRepTopAdaptor_TopolTool();
2348 Handle(BRepTopAdaptor_TopolTool) It2 = new BRepTopAdaptor_TopolTool();
2350 Standard_Real WFirst,WLast = 0.;
2351 gp_Vec TFirst,TLast,TEndPeriodic;
2352 gp_Pnt PFirst,PLast,PEndPeriodic;
2353 Standard_Boolean intf = Standard_False, intl = Standard_False;
2355 ChFiDS_ElSpine anElSpine, anOffsetElSpine;
2356 Handle(ChFiDS_ElSpine) CurrentHE = new ChFiDS_ElSpine(anElSpine);
2357 Handle(ChFiDS_ElSpine) CurrentOffsetHE = new ChFiDS_ElSpine(anOffsetElSpine);
2358 Spine->D1(Spine->FirstParameter(),PFirst,TFirst);
2359 CurrentHE->FirstParameter(Spine->FirstParameter());
2360 CurrentHE->SetFirstPointAndTgt(PFirst,TFirst);
2361 CurrentOffsetHE->FirstParameter(Spine->FirstParameter());
2362 CurrentOffsetHE->SetFirstPointAndTgt(PFirst,TFirst);
2364 Standard_Boolean YaKPart = Standard_False;
2365 Standard_Integer iedgelastkpart = 0;
2367 Standard_Real WStartPeriodic = 0.;
2368 Standard_Real WEndPeriodic = Spine->LastParameter(Spine->NbEdges());
2369 Spine->D1(WEndPeriodic,PEndPeriodic,TEndPeriodic);
2371 // Construction of particular cases.
2373 for (Standard_Integer iedge = 1; iedge <= Spine->NbEdges(); iedge++){
2375 ConexFaces(Spine,iedge,HS1,HS2);
2377 if (ChFi3d_KParticular (Spine, iedge, *HS1, *HS2)) {
2378 intf = ((iedge == 1) && !Spine->IsPeriodic());
2379 intl = ((iedge == Spine->NbEdges()) && !Spine->IsPeriodic());
2380 Or1 = HS1->Face().Orientation();
2381 Or2 = HS2->Face().Orientation();
2382 ChFi3d::NextSide(Or1,Or2,RefOr1,RefOr2,RefChoix);
2383 const Handle(Adaptor3d_Surface)& HSon1 = HS1; // to avoid ambiguity
2384 const Handle(Adaptor3d_Surface)& HSon2 = HS2; // to avoid ambiguity
2385 It1->Initialize(HSon1);
2386 It2->Initialize(HSon2);
2388 Handle(ChFiDS_SurfData) SD = new ChFiDS_SurfData();
2389 ChFiDS_SequenceOfSurfData LSD;
2391 if(!ChFiKPart_ComputeData::Compute(DStr,SD,HS1,HS2,Or1,Or2,Spine,iedge)){
2393 std::cout<<"failed calculation KPart"<<std::endl;
2396 else if(!SplitKPart(SD,LSD,Spine,iedge,HS1,It1,HS2,It2,intf,intl)){
2398 std::cout<<"failed calculation KPart"<<std::endl;
2402 else iedgelastkpart = iedge;
2403 if(Spine->IsPeriodic()){//debug provisory for SD that arrive in desorder.
2404 Standard_Integer nbsd = LSD.Length();
2405 Standard_Real period = Spine->Period();
2406 Standard_Real wfp = WStartPeriodic, wlp = WEndPeriodic;
2407 // modified by NIZHNY-EAP Thu Nov 25 12:57:53 1999 ___BEGIN___
2408 if(!YaKPart && nbsd>0){
2410 // modified by NIZHNY-EAP Thu Nov 25 12:57:57 1999 ___END___
2411 Handle(ChFiDS_SurfData) firstSD = LSD.ChangeValue(1);
2412 Standard_Real wwf = firstSD->FirstSpineParam();
2413 Standard_Real wwl = firstSD->LastSpineParam();
2414 wwf = ChFi3d_InPeriod(wwf,wfp,wlp,tolesp);
2415 wwl = ChFi3d_InPeriod(wwl,wfp,wlp,tolesp);
2416 if (wwl <= wwf + tolesp) wwl += period;
2420 for(Standard_Integer j = 1; j < nbsd; j++){
2421 Handle(ChFiDS_SurfData) jSD = LSD.Value(j);
2422 for(Standard_Integer k = j+1; k <= nbsd; k++){
2423 Handle(ChFiDS_SurfData) kSD = LSD.Value(k);
2424 Standard_Real jwf = jSD->FirstSpineParam();
2425 jwf = ChFi3d_InPeriod(jwf,wfp,wlp,tolesp);
2426 Standard_Real kwf = kSD->FirstSpineParam();
2427 kwf = ChFi3d_InPeriod(kwf,wfp,wlp,tolesp);
2429 LSD.SetValue(j,kSD);
2430 LSD.SetValue(k,jSD);
2435 TColStd_ListOfInteger li;
2436 for(Standard_Integer j = 1; j <= LSD.Length(); j++){
2437 Handle(ChFiDS_SurfData)& curSD = LSD.ChangeValue(j);
2438 if(Simul) SimulKPart(curSD);
2439 SeqSurf.Append(curSD);
2440 if(!Simul) li.Append(curSD->Surf());
2441 WFirst = LSD.Value(j)->FirstSpineParam();
2442 WLast = LSD.Value(j)->LastSpineParam();
2443 if(Spine->IsPeriodic()){
2444 WFirst = ChFi3d_InPeriod(WFirst,WStartPeriodic,WEndPeriodic,tolesp);
2445 WLast = ChFi3d_InPeriod(WLast ,WStartPeriodic,WEndPeriodic,tolesp);
2446 if (WLast <= WFirst + tolesp) WLast+= Spine->Period();
2448 TgtKP(LSD.Value(j),Spine,iedge,1,PFirst,TFirst);
2449 TgtKP(LSD.Value(j),Spine,iedge,0,PLast,TLast);
2451 // Determine the sections to approximate
2453 if(Spine->IsPeriodic()){
2454 WStartPeriodic = WFirst;
2455 WEndPeriodic = WStartPeriodic + Spine->Period();
2456 WLast = ElCLib::InPeriod(WLast,WStartPeriodic,WEndPeriodic);
2457 if (WLast <= WFirst + tolesp) WLast+= Spine->Period();
2458 PEndPeriodic = PFirst;
2459 TEndPeriodic = TFirst;
2460 Spine->SetFirstParameter(WStartPeriodic);
2461 Spine->SetLastParameter(WEndPeriodic);
2463 else if(!intf || (iedge > 1)){
2464 // start section -> first KPart
2465 // update of extension.
2466 Spine->SetFirstTgt(Min(0.,WFirst));
2467 CurrentHE->LastParameter (WFirst);
2468 CurrentHE->SetLastPointAndTgt(PFirst,TFirst);
2469 Spine->AppendElSpine(CurrentHE);
2470 CurrentHE->ChangeNext() = LSD.Value(j);
2471 CurrentHE = new ChFiDS_ElSpine();
2473 CurrentOffsetHE->LastParameter (WFirst);
2474 CurrentOffsetHE->SetLastPointAndTgt(PFirst,TFirst);
2475 Spine->AppendOffsetElSpine(CurrentOffsetHE);
2476 CurrentOffsetHE->ChangeNext() = LSD.Value(j);
2477 CurrentOffsetHE = new ChFiDS_ElSpine();
2479 CurrentHE->FirstParameter(WLast);
2480 CurrentHE->SetFirstPointAndTgt(PLast,TLast);
2481 CurrentHE->ChangePrevious() = LSD.Value(j);
2482 CurrentOffsetHE->FirstParameter(WLast);
2483 CurrentOffsetHE->SetFirstPointAndTgt(PLast,TLast);
2484 CurrentOffsetHE->ChangePrevious() = LSD.Value(j);
2485 YaKPart = Standard_True;
2488 if (WFirst - CurrentHE->FirstParameter() > tolesp) {
2489 // section between two KPart
2490 CurrentHE->LastParameter(WFirst);
2491 CurrentHE->SetLastPointAndTgt(PFirst,TFirst);
2492 Spine->AppendElSpine(CurrentHE);
2493 CurrentHE->ChangeNext() = LSD.Value(j);
2494 CurrentHE = new ChFiDS_ElSpine();
2496 CurrentOffsetHE->LastParameter(WFirst);
2497 CurrentOffsetHE->SetLastPointAndTgt(PFirst,TFirst);
2498 Spine->AppendOffsetElSpine(CurrentOffsetHE);
2499 CurrentOffsetHE->ChangeNext() = LSD.Value(j);
2500 CurrentOffsetHE = new ChFiDS_ElSpine();
2502 CurrentHE->FirstParameter(WLast);
2503 CurrentHE->SetFirstPointAndTgt(PLast,TLast);
2504 CurrentHE->ChangePrevious() = LSD.Value(j);
2505 CurrentOffsetHE->FirstParameter(WLast);
2506 CurrentOffsetHE->SetFirstPointAndTgt(PLast,TLast);
2507 CurrentOffsetHE->ChangePrevious() = LSD.Value(j);
2510 if(!li.IsEmpty()) myEVIMap.Bind(Spine->Edges(iedge),li);
2514 if (!intl || (iedgelastkpart < Spine->NbEdges())) {
2515 // section last KPart(or start of the spine) -> End of the spine.
2516 // update of the extension.
2518 if(Spine->IsPeriodic()){
2519 if(WEndPeriodic - WLast > tolesp){
2520 CurrentHE->LastParameter(WEndPeriodic);
2521 CurrentHE->SetLastPointAndTgt(PEndPeriodic,TEndPeriodic);
2522 if(!YaKPart) CurrentHE->SetPeriodic(Standard_True);
2523 Spine->AppendElSpine(CurrentHE);
2525 CurrentOffsetHE->LastParameter(WEndPeriodic);
2526 CurrentOffsetHE->SetLastPointAndTgt(PEndPeriodic,TEndPeriodic);
2527 if(!YaKPart) CurrentOffsetHE->SetPeriodic(Standard_True);
2528 Spine->AppendOffsetElSpine(CurrentOffsetHE);
2532 Spine->D1(Spine->LastParameter(),PLast,TLast);
2533 Spine->SetLastTgt(Max(Spine->LastParameter(Spine->NbEdges()),
2535 if (Spine->LastParameter() - WLast > tolesp) {
2536 CurrentHE->LastParameter(Spine->LastParameter());
2537 CurrentHE->SetLastPointAndTgt(PLast,TLast);
2538 Spine->AppendElSpine(CurrentHE);
2540 CurrentOffsetHE->LastParameter(Spine->LastParameter());
2541 CurrentOffsetHE->SetLastPointAndTgt(PLast,TLast);
2542 Spine->AppendOffsetElSpine(CurrentOffsetHE);
2547 ChFiDS_ListOfHElSpine& ll = Spine->ChangeElSpines();
2548 ChFiDS_ListIteratorOfListOfHElSpine ILES(ll);
2549 for ( ; ILES.More(); ILES.Next()) {
2551 if(ChFi3d_GettraceCHRON()) elspine.Start();
2553 ChFi3d_PerformElSpine(ILES.ChangeValue(),Spine,myConti,tolesp);
2555 if(ChFi3d_GettraceCHRON()) { elspine.Stop(); }
2558 if (Spine->Mode() == ChFiDS_ConstThroatWithPenetrationChamfer)
2560 ChFiDS_ListOfHElSpine& offsetll = Spine->ChangeOffsetElSpines();
2561 for (ILES.Initialize(offsetll); ILES.More(); ILES.Next())
2562 ChFi3d_PerformElSpine(ILES.ChangeValue(),Spine,myConti,tolesp,Standard_True);
2564 Spine->SplitDone(Standard_True);
2567 static Standard_Real ChFi3d_BoxDiag(const Bnd_Box& box)
2569 Standard_Real a,b,c,d,e,f;
2570 box.Get(a,b,c,d,e,f);
2573 Standard_Real diag = sqrt(d + e + f);
2577 //=======================================================================
2578 //function : PerformSetOfKGen
2580 //=======================================================================
2582 void ChFi3d_Builder::PerformSetOfKGen(Handle(ChFiDS_Stripe)& Stripe,
2583 const Standard_Boolean Simul)
2585 Handle(BRepTopAdaptor_TopolTool) It1 = new BRepTopAdaptor_TopolTool();
2586 Handle(BRepTopAdaptor_TopolTool) It2 = new BRepTopAdaptor_TopolTool();
2587 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
2588 ChFiDS_ListOfHElSpine& ll = Spine->ChangeElSpines();
2589 ChFiDS_ListIteratorOfListOfHElSpine ILES(ll);
2590 for ( ; ILES.More(); ILES.Next()) {
2592 if(ChFi3d_GettraceCHRON()) { chemine.Start(); }
2594 PerformSetOfSurfOnElSpine(ILES.Value(),Stripe,It1,It2,Simul);
2596 if(ChFi3d_GettraceCHRON()) chemine.Stop();
2600 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
2601 Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData();
2602 ChFiDS_SequenceOfSurfData& SeqSurf = HData->ChangeSequence();
2603 Standard_Integer len = SeqSurf.Length();
2604 Standard_Integer last = len, i;
2605 Standard_Boolean periodic = Spine->IsPeriodic();
2606 if(periodic) last++;
2607 // It is attempted to reprocess the squares that bore.
2608 for(i = 1; i <= len; i++){
2609 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2610 Standard_Boolean tw1 = cursd->TwistOnS1();
2611 Standard_Boolean tw2 = cursd->TwistOnS2();
2612 Handle(ChFiDS_SurfData) prevsd, nextsd;
2613 Standard_Integer iprev = i-1;
2615 if(periodic) iprev = len;
2617 Standard_Integer inext = i + 1;
2619 if(periodic) inext = 1;
2623 // For the moment only the surfaces where the twist is
2624 // detected at the path are corrected, it is necessary to control
2625 // more subtly the ugly traces (size, curvature, inflexion... )
2626 if(!tw1 && !tw2) continue;
2628 // It is decided (fairly at random) if the extended surface is ready for the filling.
2629 ChFiDS_FaceInterference& intf1 = cursd->ChangeInterferenceOnS1();
2630 ChFiDS_FaceInterference& intf2 = cursd->ChangeInterferenceOnS2();
2631 Standard_Integer cursurf1 = cursd->IndexOfS1();
2632 Standard_Integer cursurf2 = cursd->IndexOfS2();
2633 ChFiDS_CommonPoint& cpd1 = cursd->ChangeVertexFirstOnS1();
2634 ChFiDS_CommonPoint& cpd2 = cursd->ChangeVertexFirstOnS2();
2635 ChFiDS_CommonPoint& cpf1 = cursd->ChangeVertexLastOnS1();
2636 ChFiDS_CommonPoint& cpf2 = cursd->ChangeVertexLastOnS2();
2637 const gp_Pnt& pd1 = cpd1.Point();
2638 const gp_Pnt& pd2 = cpd2.Point();
2639 const gp_Pnt& pf1 = cpf1.Point();
2640 const gp_Pnt& pf2 = cpf2.Point();
2641 Standard_Real ddeb = pd1.Distance(pd2);
2642 Standard_Real dfin = pf1.Distance(pf2);
2643 Standard_Real don1 = pd1.Distance(pf1);
2644 Standard_Real don2 = pd2.Distance(pf2);
2645 Standard_Boolean possibleon1 = (don1 < 2*(ddeb + dfin));
2646 Standard_Boolean possibleon2 = (don2 < 2*(ddeb + dfin));
2647 if((tw1 && !possibleon1) || (tw2 && !possibleon2)) {
2648 Spine->SetErrorStatus(ChFiDS_TwistedSurface);
2649 throw Standard_Failure("adjustment by reprocessing the non-written points");
2652 // It is checked if there are presentable neighbors
2653 Standard_Boolean yaprevon1 = 0, yaprevon2 = 0;
2654 Standard_Boolean samesurfon1 = 0, samesurfon2 = 0;
2656 prevsd = SeqSurf.ChangeValue(iprev);
2657 yaprevon1 = !prevsd->TwistOnS1();
2658 samesurfon1 = (prevsd->IndexOfS1() == cursurf1);
2659 yaprevon2 = !prevsd->TwistOnS2();
2660 samesurfon2 = (prevsd->IndexOfS2() == cursurf2);
2662 Standard_Boolean yanexton1 = 0, yanexton2 = 0;
2664 nextsd = SeqSurf.ChangeValue(inext);
2665 yanexton1 = !nextsd->TwistOnS1();
2666 if(samesurfon1) samesurfon1 = (nextsd->IndexOfS1() == cursurf1);
2667 yanexton2 = !nextsd->TwistOnS2();
2668 if(samesurfon2) samesurfon2 = (nextsd->IndexOfS2() == cursurf2);
2670 // A contour of filling is constructed
2671 Handle(Geom2d_Curve) PC1 = intf1.PCurveOnFace();
2672 Handle(Geom2d_Curve) PC2 = intf2.PCurveOnFace();
2673 Handle(BRepAdaptor_Surface) S1 = new BRepAdaptor_Surface();
2674 TopoDS_Face F1 = TopoDS::Face(DStr.Shape(cursurf1));
2676 Handle(BRepAdaptor_Surface) S2 = new BRepAdaptor_Surface();
2677 TopoDS_Face F2 = TopoDS::Face(DStr.Shape(cursurf2));
2679 Handle(GeomFill_Boundary) Bdeb,Bfin,Bon1,Bon2;
2680 Standard_Boolean pointuon1 = 0, pointuon2 = 0;
2682 if(!yaprevon1 || !yanexton1){
2683 Spine->SetErrorStatus(ChFiDS_TwistedSurface);
2684 throw Standard_Failure("adjustment by reprocessing the non-written points: no neighbor");
2686 ChFiDS_FaceInterference& previntf1 = prevsd->ChangeInterferenceOnS1();
2687 ChFiDS_FaceInterference& nextintf1 = nextsd->ChangeInterferenceOnS1();
2688 Standard_Real prevpar1 = previntf1.LastParameter();
2689 Standard_Real nextpar1 = nextintf1.FirstParameter();
2691 // It is checked if it is possible to intersect traces of neighbors
2692 // to create a sharp end.
2693 Handle(Geom2d_Curve) pcprev1 = previntf1.PCurveOnFace();
2694 Handle(Geom2d_Curve) pcnext1 = nextintf1.PCurveOnFace();
2695 Standard_Real nprevpar1,nnextpar1;
2697 // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 Begin
2698 // if(ChFi3d_IntTraces(prevsd,prevpar1,nprevpar1,1,1,
2699 // nextsd,nextpar1,nnextpar1,1,-1,p2d)){
2700 if(ChFi3d_IntTraces(prevsd,prevpar1,nprevpar1,1,1,
2701 nextsd,nextpar1,nnextpar1,1,-1,p2d,
2702 Standard_False, Standard_True)){
2703 // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 End
2704 previntf1.SetLastParameter(nprevpar1);
2705 nextintf1.SetFirstParameter(nnextpar1);
2710 gp_Pnt2d pdeb1,pfin1;
2711 gp_Vec2d vdeb1,vfin1;
2712 pcprev1->D1(prevpar1,pdeb1,vdeb1);
2713 pcnext1->D1(nextpar1,pfin1,vfin1);
2714 Bon1 = ChFi3d_mkbound(S1,PC1,-1,pdeb1,vdeb1,1,
2715 pfin1,vfin1,tolapp3d,2.e-4);
2719 //here the base is on 3D tangents of neighbors.
2720 const Handle(Geom_Curve)& c3dprev1 =
2721 DStr.Curve(previntf1.LineIndex()).Curve();
2722 const Handle(Geom_Curve)& c3dnext1 =
2723 DStr.Curve(nextintf1.LineIndex()).Curve();
2724 gp_Pnt Pdeb1, Pfin1;
2725 gp_Vec Vdeb1, Vfin1;
2726 c3dprev1->D1(prevpar1,Pdeb1,Vdeb1);
2727 c3dnext1->D1(nextpar1,Pfin1,Vfin1);
2728 gp_Pnt2d pdeb1,pfin1;
2729 Standard_Real pardeb1 = intf1.FirstParameter();
2730 Standard_Real parfin1 = intf1.LastParameter();
2731 pdeb1 = PC1->Value(pardeb1);
2732 pfin1 = PC1->Value(parfin1);
2733 Bon1 = ChFi3d_mkbound(S1,PC1,-1,pdeb1,Vdeb1,1,
2734 pfin1,Vfin1,tolapp3d,2.e-4);
2738 Bon1 = ChFi3d_mkbound(S1,PC1,tolapp3d,2.e-4);
2741 if(!yaprevon2 || !yanexton2){
2742 throw Standard_Failure("adjustment by reprocessing the non-written points: no neighbor");
2744 ChFiDS_FaceInterference& previntf2 = prevsd->ChangeInterferenceOnS2();
2745 ChFiDS_FaceInterference& nextintf2 = nextsd->ChangeInterferenceOnS2();
2746 Standard_Real prevpar2 = previntf2.LastParameter();
2747 Standard_Real nextpar2 = nextintf2.FirstParameter();
2749 // It is checked if it is possible to intersect traces of neighbors
2750 // to create a sharp end.
2751 Handle(Geom2d_Curve) pcprev2 = previntf2.PCurveOnFace();
2752 Handle(Geom2d_Curve) pcnext2 = nextintf2.PCurveOnFace();
2753 Standard_Real nprevpar2,nnextpar2;
2755 // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 Begin
2756 // if(ChFi3d_IntTraces(prevsd,prevpar2,nprevpar2,2,1,
2757 // nextsd,nextpar2,nnextpar2,2,-1,p2d)){
2758 if(ChFi3d_IntTraces(prevsd,prevpar2,nprevpar2,2,1,
2759 nextsd,nextpar2,nnextpar2,2,-1,p2d,
2760 Standard_False, Standard_True)){
2761 // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 End
2762 previntf2.SetLastParameter(nprevpar2);
2763 nextintf2.SetFirstParameter(nnextpar2);
2768 gp_Pnt2d pdeb2,pfin2;
2769 gp_Vec2d vdeb2,vfin2;
2770 pcprev2->D1(prevpar2,pdeb2,vdeb2);
2771 pcnext2->D1(nextpar2,pfin2,vfin2);
2772 Bon2 = ChFi3d_mkbound(S2,PC2,-1,pdeb2,vdeb2,1,
2773 pfin2,vfin2,tolapp3d,2.e-4);
2777 //here the base is on 3D tangents of neighbors.
2778 const Handle(Geom_Curve)& c3dprev2 =
2779 DStr.Curve(previntf2.LineIndex()).Curve();
2780 const Handle(Geom_Curve)& c3dnext2 =
2781 DStr.Curve(nextintf2.LineIndex()).Curve();
2782 gp_Pnt Pdeb2, Pfin2;
2783 gp_Vec Vdeb2, Vfin2;
2784 c3dprev2->D1(prevpar2,Pdeb2,Vdeb2);
2785 c3dnext2->D1(nextpar2,Pfin2,Vfin2);
2786 gp_Pnt2d pdeb2,pfin2;
2787 Standard_Real pardeb2 = intf2.FirstParameter();
2788 Standard_Real parfin2 = intf2.LastParameter();
2789 pdeb2 = PC2->Value(pardeb2);
2790 pfin2 = PC2->Value(parfin2);
2791 Bon2 = ChFi3d_mkbound(S2,PC2,-1,pdeb2,Vdeb2,1,
2792 pfin2,Vfin2,tolapp3d,2.e-4);
2796 Bon2 = ChFi3d_mkbound(S2,PC2,tolapp3d,2.e-4);
2798 // The parameters of neighbor traces are updated, so
2799 // straight lines uv are pulled.
2800 const Handle(Geom_Surface)&
2801 sprev = DStr.Surface(prevsd->Surf()).Surface();
2802 const Handle(Geom_Surface)&
2803 snext = DStr.Surface(nextsd->Surf()).Surface();
2804 ChFiDS_FaceInterference& previntf1 = prevsd->ChangeInterferenceOnS1();
2805 ChFiDS_FaceInterference& nextintf1 = nextsd->ChangeInterferenceOnS1();
2806 ChFiDS_FaceInterference& previntf2 = prevsd->ChangeInterferenceOnS2();
2807 ChFiDS_FaceInterference& nextintf2 = nextsd->ChangeInterferenceOnS2();
2808 Handle(Geom2d_Curve) pcsprev1 = previntf1.PCurveOnSurf();
2809 Handle(Geom2d_Curve) pcsnext1 = nextintf1.PCurveOnSurf();
2810 Standard_Real prevpar1 = previntf1.LastParameter();
2811 Standard_Real nextpar1 = nextintf1.FirstParameter();
2812 Handle(Geom2d_Curve) pcsprev2 = previntf2.PCurveOnSurf();
2813 Handle(Geom2d_Curve) pcsnext2 = nextintf2.PCurveOnSurf();
2814 Standard_Real prevpar2 = previntf2.LastParameter();
2815 Standard_Real nextpar2 = nextintf2.FirstParameter();
2816 gp_Pnt2d pdebs1 = pcsprev1->Value(prevpar1);
2817 gp_Pnt2d pdebs2 = pcsprev2->Value(prevpar2);
2818 gp_Pnt2d pfins1 = pcsnext1->Value(nextpar1);
2819 gp_Pnt2d pfins2 = pcsnext2->Value(nextpar2);
2820 Bdeb = ChFi3d_mkbound(sprev,pdebs1,pdebs2,tolapp3d,2.e-4);
2821 Bfin = ChFi3d_mkbound(snext,pfins1,pfins2,tolapp3d,2.e-4);
2823 GeomFill_ConstrainedFilling fil(11,20);
2824 if(pointuon1) fil.Init(Bon2,Bfin,Bdeb,1);
2825 else if(pointuon2) fil.Init(Bon1,Bfin,Bdeb,1);
2826 else fil.Init(Bon1,Bfin,Bon2,Bdeb,1);
2828 ChFi3d_ReparamPcurv(0.,1.,PC1);
2829 ChFi3d_ReparamPcurv(0.,1.,PC2);
2830 Handle(Geom_Surface) newsurf = fil.Surface();
2834 char* pops = "newsurf";
2835 DrawTrSurf::Set(pops,newsurf);
2839 newsurf->VReverse(); // we return to direction 1 from 2;
2840 done = CompleteData(cursd,newsurf,S1,PC1,S2,PC2,
2841 F2.Orientation(),0,0,0,0,0);
2842 cursd->ChangeIndexOfS1(0);
2845 done = CompleteData(cursd,newsurf,S1,PC1,S2,PC2,
2846 F1.Orientation(),1,0,0,0,0);
2847 if(pointuon2) cursd->ChangeIndexOfS2(0);
2850 prevsd->ChangeVertexLastOnS1().SetPoint(cpd1.Point());
2851 nextsd->ChangeVertexFirstOnS1().SetPoint(cpf1.Point());
2854 prevsd->ChangeVertexLastOnS2().SetPoint(cpd2.Point());
2855 nextsd->ChangeVertexFirstOnS2().SetPoint(cpf2.Point());
2858 // The tolerance of points is updated.
2859 for(i = 1; i < last; i++){
2860 Standard_Integer j = i%len + 1;
2861 Standard_Integer curs1, curs2;
2862 Standard_Integer nexts1, nexts2;
2863 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2864 Handle(ChFiDS_SurfData)& nextsd = SeqSurf.ChangeValue(j);
2865 ChFiDS_CommonPoint& curp1 = cursd->ChangeVertexLastOnS1();
2866 ChFiDS_CommonPoint& nextp1 = nextsd->ChangeVertexFirstOnS1();
2867 if (cursd->IsOnCurve1()) curs1 = cursd->IndexOfC1();
2868 else curs1 = cursd->IndexOfS1();
2869 if (cursd->IsOnCurve2()) curs2 = cursd->IndexOfC2();
2870 else curs2 = cursd->IndexOfS2();
2871 Standard_Real tol1 = Max(curp1.Tolerance(),nextp1.Tolerance());
2872 ChFiDS_CommonPoint& curp2 = cursd->ChangeVertexLastOnS2();
2873 ChFiDS_CommonPoint& nextp2 = nextsd->ChangeVertexFirstOnS2();
2874 Standard_Real tol2 = Max(curp2.Tolerance(),nextp2.Tolerance());
2875 if (nextsd->IsOnCurve1()) nexts1 = nextsd->IndexOfC1();
2876 else nexts1 = nextsd->IndexOfS1();
2877 if (nextsd->IsOnCurve2()) nexts2 = nextsd->IndexOfC2();
2878 else nexts2 = nextsd->IndexOfS2();
2880 if(!curp1.IsOnArc() && nextp1.IsOnArc()){
2882 if ( (curs1 == nexts1) && !nextsd->IsOnCurve1())
2883 // Case when it is not possible to pass along the border without leaving
2884 ChangeTransition(nextp1, curp1, nexts1, myDS);
2886 else if(curp1.IsOnArc() && !nextp1.IsOnArc()) {
2888 if ( (curs1 == nexts1) && !cursd->IsOnCurve1())
2889 ChangeTransition(curp1, nextp1, curs1, myDS);
2892 if(!curp2.IsOnArc() && nextp2.IsOnArc()) {
2894 if ( (curs2 == nexts2) && !nextsd->IsOnCurve2())
2895 ChangeTransition(nextp2, curp2, curs2, myDS);
2897 else if(curp2.IsOnArc() && !nextp2.IsOnArc()){
2899 if ( (curs2 == nexts2) && !cursd->IsOnCurve2())
2900 ChangeTransition(curp2, nextp2, curs2, myDS);
2903 curp1.SetTolerance(tol1); nextp1.SetTolerance(tol1);
2904 curp2.SetTolerance(tol2); nextp2.SetTolerance(tol2);
2907 if(curp1.IsOnArc()){
2908 ChFi3d_EnlargeBox(curp1.Arc(),myEFMap(curp1.Arc()),curp1.ParameterOnArc(),b1);
2910 if(curp2.IsOnArc()){
2911 ChFi3d_EnlargeBox(curp2.Arc(),myEFMap(curp2.Arc()),curp2.ParameterOnArc(),b2);
2913 Handle(ChFiDS_Stripe) bidst;
2914 ChFi3d_EnlargeBox(DStr,bidst,cursd,b1,b2,0);
2915 ChFi3d_EnlargeBox(DStr,bidst,nextsd,b1,b2,1);
2916 tol1 = ChFi3d_BoxDiag(b1);
2917 tol2 = ChFi3d_BoxDiag(b2);
2918 curp1.SetTolerance(tol1); nextp1.SetTolerance(tol1);
2919 curp2.SetTolerance(tol2); nextp2.SetTolerance(tol2);
2921 // The connections edge/new faces are updated.
2922 for (ILES.Initialize(ll) ; ILES.More(); ILES.Next()) {
2923 const Handle(ChFiDS_ElSpine)& curhels = ILES.Value();
2924 Standard_Real WF = curhels->FirstParameter();
2925 Standard_Real WL = curhels->LastParameter();
2926 Standard_Integer IF,IL;
2927 Standard_Real nwf = WF, nwl = WL;
2928 Standard_Real period = 0.;
2929 Standard_Integer nbed = Spine->NbEdges();
2931 period = Spine->Period();
2932 nwf = ElCLib::InPeriod(WF,-tolesp,period-tolesp);
2933 IF = Spine->Index(nwf,1);
2934 nwl = ElCLib::InPeriod(WL,tolesp,period+tolesp);
2935 IL = Spine->Index(nwl,0);
2936 if(nwl<nwf+tolesp) IL += nbed;
2939 IF = Spine->Index(WF,1);
2940 IL = Spine->Index(WL,0);
2944 Standard_Integer IFloc = IF;
2945 if(periodic) IFloc = (IF - 1)%nbed + 1;
2946 const TopoDS_Edge& Ej = Spine->Edges(IFloc);
2947 for(i = 1; i <= len; i++){
2948 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2949 Standard_Real fp = cursd->FirstSpineParam();
2950 Standard_Real lp = cursd->LastSpineParam();
2951 if(lp < WF+tolesp || fp > WL-tolesp) continue;
2952 if(!myEVIMap.IsBound(Ej)) {
2953 TColStd_ListOfInteger li;
2954 myEVIMap.Bind(Ej,li);
2956 myEVIMap.ChangeFind(Ej).Append(cursd->Surf());
2960 TColStd_Array1OfReal wv(IF,IL - 1);
2962 std::cout<<"length of the trajectory : "<<(WL-WF)<<std::endl;
2964 for(i = IF; i < IL; i++){
2965 Standard_Integer iloc = i;
2966 if(periodic) iloc = (i - 1)%nbed + 1;
2967 Standard_Real wi = Spine->LastParameter(iloc);
2968 if(periodic) wi = ElCLib::InPeriod(wi,WF,WF+period);
2969 gp_Pnt pv = Spine->Value(wi);
2971 gp_Pnt pelsapp = curhels->Value(wi);
2972 Standard_Real distinit = pv.Distance(pelsapp);
2973 std::cout<<"distance psp/papp : "<<distinit<<std::endl;
2975 Extrema_LocateExtPC ext(pv,*curhels,wi,1.e-8);
2978 wv(i) = ext.Point().Parameter();
2982 std::cout<<"fail of projection vertex ElSpine!!!"<<std::endl;
2986 for(i = 1; i <= len; i++){
2987 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2988 Standard_Real fp = cursd->FirstSpineParam();
2989 Standard_Real lp = cursd->LastSpineParam();
2991 Standard_Integer jf = 0, jl = 0;
2992 if(lp < WF+tolesp || fp > WL-tolesp) continue;
2993 for(j = IF; j < IL; j++){
2995 if(fp < wv(j) - tolesp) break;
2997 for(j = IF; j < IL; j++){
2999 if(lp < wv(j) + tolesp) break;
3001 for(j = jf; j <= jl; j++){
3002 Standard_Integer jloc = j;
3003 if(periodic) jloc = (j - 1)%nbed + 1;
3004 const TopoDS_Edge& Ej = Spine->Edges(jloc);
3005 if(!myEVIMap.IsBound(Ej)) {
3006 TColStd_ListOfInteger li;
3007 myEVIMap.Bind(Ej,li);
3009 myEVIMap.ChangeFind(Ej).Append(cursd->Surf());
3017 //=======================================================================
3018 //function : PerformSetOfSurf
3020 //=======================================================================
3022 void ChFi3d_Builder::PerformSetOfSurf(Handle(ChFiDS_Stripe)& Stripe,
3023 const Standard_Boolean Simul)
3025 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
3029 ChFi3d_InitChron(ch);// init perf for PerformSetOfKPart
3032 const Handle(ChFiDS_Spine)& sp = Stripe->Spine();
3033 Standard_Integer SI = ChFi3d_SolidIndex(sp,DStr,myESoMap,myEShMap);
3034 Stripe->SetSolidIndex(SI);
3035 if(!sp->SplitDone()) PerformSetOfKPart(Stripe,Simul);
3038 ChFi3d_ResultChron(ch ,t_perfsetofkpart); // result perf PerformSetOfKPart(
3039 ChFi3d_InitChron(ch); // init perf for PerformSetOfKGen
3042 PerformSetOfKGen(Stripe,Simul);
3045 ChFi3d_ResultChron(ch, t_perfsetofkgen);//result perf PerformSetOfKGen
3046 ChFi3d_InitChron(ch); // init perf for ChFi3d_MakeExtremities
3049 if(!Simul) ChFi3d_MakeExtremities(Stripe,DStr,myEFMap,tolapp3d,tol2d);
3052 ChFi3d_ResultChron(ch, t_makextremities); // result perf t_makextremities