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.
17 #include <ChFi3d_Builder.jxx>
19 #include <Precision.hxx>
21 #include <Standard_NotImplemented.hxx>
22 #include <TColStd_Array1OfReal.hxx>
23 #include <TColStd_Array1OfInteger.hxx>
24 #include <TColStd_ListOfInteger.hxx>
26 #include <math_Vector.hxx>
30 #include <gp_Pnt2d.hxx>
32 #include <TColgp_Array1OfPnt.hxx>
33 #include <TColgp_Array1OfVec.hxx>
36 #include <Geom_BSplineCurve.hxx>
37 #include <Geom_BSplineSurface.hxx>
38 #include <Geom_Line.hxx>
39 #include <Geom_Plane.hxx>
40 #include <Geom2d_Curve.hxx>
41 #include <GeomAPI_ProjectPointOnCurve.hxx>
44 #include <TopoDS_Shape.hxx>
45 #include <TopoDS_Face.hxx>
46 #include <TopoDS_Wire.hxx>
47 #include <TopoDS_Edge.hxx>
48 #include <TopoDS_Vertex.hxx>
50 #include <GeomAdaptor_Surface.hxx>
51 #include <GeomAdaptor_HSurface.hxx>
52 #include <GeomAdaptor_HCurve.hxx>
54 #include <BRepAdaptor_Curve.hxx>
55 #include <BRepAdaptor_HCurve.hxx>
56 #include <BRepAdaptor_Surface.hxx>
57 #include <BRepAdaptor_HSurface.hxx>
58 #include <BRepTopAdaptor_TopolTool.hxx>
59 #include <BRepLProp_SLProps.hxx>
60 #include <Adaptor3d_TopolTool.hxx>
63 #include <TopAbs_ShapeEnum.hxx>
64 #include <TopAbs_Orientation.hxx>
65 #include <BRep_Tool.hxx>
66 #include <BRepTools.hxx>
67 #include <BRepTools_WireExplorer.hxx>
68 #include <BRepLib_MakeFace.hxx>
70 #include <TopExp_Explorer.hxx>
71 #include <TopTools_ListIteratorOfListOfShape.hxx>
73 #include <Extrema_ExtPC.hxx>
74 #include <Extrema_LocateExtPC.hxx>
75 #include <Extrema_POnCurv.hxx>
77 #include <ChFiDS_ErrorStatus.hxx>
78 #include <ChFiDS_State.hxx>
79 #include <ChFiDS_SurfData.hxx>
80 #include <ChFiDS_CommonPoint.hxx>
81 #include <ChFiDS_FaceInterference.hxx>
82 #include <ChFiDS_Spine.hxx>
83 #include <ChFiDS_FilSpine.hxx>
84 #include <ChFiDS_ChamfSpine.hxx>
85 #include <ChFiDS_SequenceOfSurfData.hxx>
86 #include <ChFiDS_Stripe.hxx>
87 #include <ChFiDS_HData.hxx>
88 #include <ChFiDS_ElSpine.hxx>
89 #include <ChFiDS_ListOfHElSpine.hxx>
90 #include <ChFiDS_ListIteratorOfListOfHElSpine.hxx>
91 #include <Extrema_ExtPS.hxx>
92 #include <ChFiKPart_ComputeData.hxx>
94 #include <ChFi3d_Builder_0.hxx>
98 #include <DrawTrSurf.hxx>
100 #include <OSD_Chronometer.hxx>
101 extern Standard_Real t_perfsetofkpart,t_perfsetofkgen,t_makextremities,t_performsurf,t_startsol;
102 extern Standard_Boolean ChFi3d_GettraceCHRON();
103 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
104 extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real& time);
107 // Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 Begin
108 Standard_Boolean isTangentFaces(const TopoDS_Edge &theEdge,
109 const TopoDS_Face &theFace1,
110 const TopoDS_Face &theFace2);
111 // Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 End
113 //===================================================================
114 // Definition by a plane
116 // It is considered that P1 and P2 are points associated to commonpoints compoint1 and
117 // compoint2, while E1 and E2 are edges containing P1 and P2.
118 // The plane containing three directions D12 T1 T2 ou D12 represente la direction formee
119 // par les points P1 et P2, T1 la tangente de E1 en P1 et T2 la tangente de
120 // E2 en P2 is found (if exists).
121 // Then fillet HConge is intersected by this plane
122 // to find associated curve 3d C3d and the curve 2d.
124 //====================================================================
125 static void ChFi3d_CoupeParPlan (const ChFiDS_CommonPoint & compoint1,
126 const ChFiDS_CommonPoint & compoint2,
127 Handle(GeomAdaptor_HSurface)& HConge,
128 const gp_Pnt2d & UV1,
129 const gp_Pnt2d & UV2,
130 const Standard_Real tol3d,
131 const Standard_Real tol2d,
132 Handle(Geom_Curve) &C3d,
133 Handle(Geom2d_Curve) &pcurve,
134 Standard_Real & tolreached,
135 Standard_Real & Pardeb,
136 Standard_Real & Parfin,
137 Standard_Boolean & plane)
138 { plane=Standard_True;
139 if(compoint1.IsOnArc() && compoint2.IsOnArc() ) {
141 BRepAdaptor_Curve BCurv1(compoint1.Arc());
142 BRepAdaptor_Curve BCurv2(compoint2.Arc());
143 Standard_Real parE1,parE2;
144 parE1=compoint1.ParameterOnArc();
145 parE2=compoint2.ParameterOnArc();
147 BCurv1.D1(parE1,P1,t1);
148 BCurv2.D1(parE2,P2,t2);
151 gp_Vec v12(P2.X()-P1.X(),P2.Y()-P1.Y(),P2.Z()-P1.Z());
153 gp_Dir nor =tgt1.Crossed(d12);
154 Handle (Geom_Plane) Plan=new Geom_Plane(P1,nor);
156 scal=Abs(nor.Dot(tgt2));
158 Handle(GeomAdaptor_HSurface) HPlan=new GeomAdaptor_HSurface(Plan);
159 Handle(Geom2d_Curve) C2dint2;
160 TColStd_Array1OfReal Pdeb(1,4),Pfin(1,4);
161 GeomAdaptor_Surface AS(Plan);
162 Extrema_ExtPS ext(P1,AS,1.e-3,1.e-3);
163 Extrema_ExtPS ext1 (P2,AS,1.e-3,1.e-3);
165 ext.Point(1).Parameter(u1,v1);
166 Pdeb(1)= UV1.X();Pdeb(2) = UV1.Y();
167 Pdeb(3)= u1;Pdeb(4) =v1;
168 ext1.Point(1).Parameter(u1,v1);
169 Pfin(1)= UV2.X();Pfin(2) = UV2.Y();
170 Pfin(3)= u1;Pfin(4) = v1;
171 if (ChFi3d_ComputeCurves(HConge,HPlan,Pdeb,Pfin,C3d,
172 pcurve,C2dint2,tol3d,tol2d,tolreached)){
173 Pardeb=C3d->FirstParameter();
174 Parfin=C3d->LastParameter();
176 else plane=Standard_False;
178 else plane=Standard_False;
180 else plane=Standard_False;
182 //=======================================================================
183 //function : SortieTangente
185 //=======================================================================
187 static Standard_Boolean SortieTangente(const ChFiDS_CommonPoint& CP,
188 const TopoDS_Face& /*F*/,
189 const Handle(ChFiDS_SurfData)& /*SD*/,
190 const Standard_Integer /*OnS*/,
191 const Standard_Real TolAngular)
193 if(!CP.HasVector()) return Standard_False;
196 Handle(Geom_Curve) C;
197 Standard_Real Uf, Ul;
198 C = BRep_Tool::Curve(CP.Arc(),Uf,Ul);
199 C->D1(CP.ParameterOnArc(), P, Darc);
201 return Dsurf.IsParallel(Darc, TolAngular);
204 //=======================================================================
205 //function : BonVoisin
207 //=======================================================================
209 static Standard_Boolean BonVoisin(const gp_Pnt& Point,
210 Handle(BRepAdaptor_HSurface)& HS,
212 Handle(GeomAdaptor_HSurface)& plane,
213 const TopoDS_Edge& cured,
216 const ChFiDS_Map& EFMap,
217 const Standard_Real tolesp)
219 Standard_Boolean bonvoisin = 1;
220 Standard_Real winter, Uf, Ul;
221 gp_Pnt papp = HS->Value(XDep, YDep);
222 Standard_Real dist = RealLast();
223 Handle(BRepAdaptor_HCurve) hc = new BRepAdaptor_HCurve();
224 Handle(Geom2d_Curve) PC;
225 Standard_Boolean found = 0;
228 for(Ex.Init(F,TopAbs_EDGE); Ex.More(); Ex.Next()){
229 const TopoDS_Edge& ecur = TopoDS::Edge(Ex.Current());
230 if(!ecur.IsSame(cured)){
231 hc->ChangeCurve().Initialize(ecur);
232 Standard_Real tolc = hc->ChangeCurve().Resolution(tolesp);
233 if(ChFi3d_InterPlaneEdge(plane,hc,winter,1,tolc)){
234 gp_Pnt np = hc->Value(winter);
235 Standard_Real ndist = np.SquareDistance(papp);
237 TopTools_ListIteratorOfListOfShape It;
239 Standard_Boolean isclosed = BRep_Tool::IsClosed(ecur, F);
240 Standard_Boolean isreallyclosed =
241 BRepTools::IsReallyClosed(ecur, F);
242 for(It.Initialize(EFMap(ecur));It.More();It.Next()){
243 ff = TopoDS::Face(It.Value());
244 Standard_Boolean issame = ff.IsSame(F);
245 // Modified by Sergey KHROMOV - Fri Dec 21 17:12:48 2001 Begin
246 // Standard_Boolean istg =
247 // BRep_Tool::Continuity(ecur,ff,F) != GeomAbs_C0;
248 Standard_Boolean istg = isTangentFaces(ecur,ff,F);
249 // Modified by Sergey KHROMOV - Fri Dec 21 17:12:51 2001 End
250 if((!issame || (issame && isreallyclosed)) && istg) {
252 TopoDS_Edge newe = ecur;
253 newe.Orientation(TopAbs_FORWARD);
255 HS->ChangeSurface().Initialize(ff);
256 if(isclosed && !isreallyclosed){
257 TopoDS_Face fff = ff;
258 fff.Orientation(TopAbs_FORWARD);
260 for(Ex2.Init(fff,TopAbs_EDGE);
261 Ex2.More(); Ex2.Next()){
262 if(newe.IsSame(Ex2.Current())){
263 newe = TopoDS::Edge(Ex2.Current());
264 PC = BRep_Tool::CurveOnSurface(newe,fff,Uf,Ul);
269 else PC = BRep_Tool::CurveOnSurface(newe,ff,Uf,Ul);
270 PC->Value(winter).Coord(XDep,YDep);
272 gp_Pnt spt; gp_Vec sdu,sdv,nors;
273 HS->D1(XDep, YDep, spt, sdu, sdv);
274 nors = sdu.Crossed(sdv);
275 gp_Pnt cpt; gp_Vec cd;
276 hc->D1(winter,cpt,cd);
277 gp_Vec vref(Point, cpt);
278 TopoDS_Face fff = ff;
279 fff.Orientation(TopAbs_FORWARD);
280 if(vref.Dot(nors.Crossed(cd)) < 0.){
281 newe.Orientation(TopAbs_REVERSED);
283 PC = BRep_Tool::CurveOnSurface(newe,fff,Uf,Ul);
284 PC->Value(winter).Coord(XDep, YDep);
293 if(!found) bonvoisin = 0;
297 //=======================================================================
298 //function : Projection
299 //purpose : Projects a point on a curve
300 //=======================================================================
302 static Standard_Boolean Projection(Extrema_ExtPC& PExt,
304 const Adaptor3d_Curve& C,
308 Standard_Real Dist2, daux2;
309 Dist2 = C.Value(W).SquareDistance(P);
311 // It is checked if it is not already a solution
312 if (Dist2 < Tol * Tol)
313 return Standard_True;
315 Standard_Boolean Ok = Standard_False;
317 // On essai une resolution initialise
318 Extrema_LocateExtPC ext(P,C,W,Tol/10);
320 daux2 = C.Value(ext.Point().Parameter()).SquareDistance(P);
322 W = ext.Point().Parameter();
325 if (Dist2 < Tol * Tol)
326 return Standard_True;
332 if ( PExt.IsDone() ) {
333 for (Standard_Integer ii=1; ii<= PExt.NbExt(); ii++) {
334 if (PExt.SquareDistance(ii) < Dist2) {
335 Dist2 = PExt.SquareDistance(ii);
336 W = PExt.Point(ii).Parameter();
344 //=======================================================================
347 //=======================================================================
349 static void TgtKP(const Handle(ChFiDS_SurfData)& CD,
350 const Handle(ChFiDS_Spine)& Spine,
351 const Standard_Integer iedge,
352 const Standard_Boolean isfirst,
356 Standard_Real wtg = CD->InterferenceOnS1().Parameter(isfirst);
357 const BRepAdaptor_Curve& bc = Spine->CurrentElementarySpine(iedge);
358 if(Spine->Edges(iedge).Orientation() == TopAbs_FORWARD)
359 bc.D1(wtg+bc.FirstParameter(),ped,ded);
361 bc.D1(-wtg+bc.LastParameter(),ped,ded);
367 //=======================================================================
369 //purpose : Checks if a vector belongs to a Face
370 //=======================================================================
372 Standard_Boolean IsInput(const gp_Vec& Vec,
373 const TopoDS_Vertex& Ve,
374 const TopoDS_Face& Fa)
376 TopExp_Explorer FaceExp(Fa, TopAbs_WIRE);
377 BRepTools_WireExplorer WireExp;
378 Standard_Integer Trouve = 0;
381 TopoDS_Vertex Vf, Vl;
385 // Find edges and compute 3D vectors
386 for ( ; (FaceExp.More() && (Trouve<2)); FaceExp.Next()) {
387 W = TopoDS::Wire(FaceExp.Current());
388 for (Trouve=0, WireExp.Init(W) ;
389 WireExp.More() && (Trouve<2); WireExp.Next()) {
390 E = TopoDS::Edge(WireExp.Current());
391 TopExp::Vertices(E, Vf, Vl);
393 BRepAdaptor_Curve Cb(E);
394 Cb.D1(BRep_Tool::Parameter(Ve, E), Point, Vec3d[Trouve]);
397 else if (Vl.IsSame(Ve)) {
398 BRepAdaptor_Curve Cb(E);
399 Cb.D1(BRep_Tool::Parameter(Ve, E), Point, Vec3d[Trouve]);
400 Vec3d[Trouve].Reverse();
405 if (Trouve < 2) return Standard_False;
406 // Calculate the normal and the angles in the asssociated vector plane
408 Normal = Vec3d[0] ^ Vec3d[1];
409 if (Normal.SquareMagnitude() < Precision::Confusion()) {//Colinear case
410 return (Vec.IsParallel(Vec3d[0],Precision::Confusion()));
413 Standard_Real amin, amax;
414 amax = Vec3d[1].AngleWithRef(Vec3d[0], Normal);
421 // Projection of the vector
422 gp_Ax3 Axe(Point, Normal, Vec3d[0]);
424 Transf.SetTransformation (Axe);
425 gp_XYZ coord = Vec.XYZ();
426 Transf.Transforms(coord);
429 Transf.Transforms(coord);
430 gp_Vec theProj(coord);
433 Standard_Real Angle = theProj.AngleWithRef(Vec3d[0], Normal);
434 return ( (Angle >= amin) && (Angle<=amax));
437 //=======================================================================
439 //purpose : Find a neighbor G1 by an edge
440 //=======================================================================
442 Standard_Boolean IsG1(const ChFiDS_Map& TheMap,
443 const TopoDS_Edge& E,
444 const TopoDS_Face& FRef,
447 TopTools_ListIteratorOfListOfShape It;
448 // Find a neighbor of E different from FRef (general case).
449 for(It.Initialize(TheMap(E));It.More();It.Next()) {
450 if (!TopoDS::Face(It.Value()).IsSame(FRef)) {
451 FVoi = TopoDS::Face(It.Value());
452 // Modified by Sergey KHROMOV - Fri Dec 21 17:09:32 2001 Begin
453 // if (BRep_Tool::Continuity(E,FRef,FVoi) != GeomAbs_C0) {
454 if (isTangentFaces(E,FRef,FVoi)) {
455 // Modified by Sergey KHROMOV - Fri Dec 21 17:09:33 2001 End
456 return Standard_True;
460 // If is was not found it is checked if E is a cutting edge,
461 // in which case FVoi = FRef is returned (less frequent case).
463 Standard_Boolean orset = Standard_False;
464 TopAbs_Orientation orient = TopAbs_FORWARD ;
466 for(Ex.Init(FRef,TopAbs_EDGE); Ex.More(); Ex.Next()){
467 ed = TopoDS::Edge(Ex.Current());
469 if(!orset){ orient = ed.Orientation(); orset = Standard_True; }
470 else if(ed.Orientation() == TopAbs::Reverse(orient)){
472 // Modified by Sergey KHROMOV - Fri Dec 21 17:15:12 2001 Begin
473 // if (BRep_Tool::Continuity(E,FRef,FRef) >= GeomAbs_G1) {
474 if (isTangentFaces(E,FRef,FRef)) {
475 // Modified by Sergey KHROMOV - Fri Dec 21 17:15:16 2001 End
476 return Standard_True;
478 return Standard_False;
482 return Standard_False;
485 //=======================================================================
486 //function : SearchFaceOnV
487 //purpose : Finds the output face(s) of the path by a vertex
488 // The following criteria should be followed
489 // -1 : The face shares regular edges with FRef
490 // (too hard condition that should be reconsidered)
491 // -2 : The vector starting in CommonPoint "belongs" to the face
492 //========================================================================
493 static Standard_Integer SearchFaceOnV(const ChFiDS_CommonPoint& Pc,
494 const TopoDS_Face& FRef,
495 const ChFiDS_Map& VEMap,
496 const ChFiDS_Map& EFMap,
500 // it is checked that it leaves the current face.
501 Standard_Boolean FindFace = IsInput(Pc.Vector(), Pc.Vertex(), FRef);
503 FindFace = IsInput(Pc.Vector().Reversed(), Pc.Vertex(), FRef);
505 // If it does not leave, it is finished
510 Standard_Integer Num = 0;
511 Standard_Boolean Trouve;
512 TopTools_ListIteratorOfListOfShape ItE, ItF;
516 for(ItE.Initialize(VEMap(Pc.Vertex()));
517 ItE.More() && (Num < 2); ItE.Next()) {
518 E = TopoDS::Edge(ItE.Value());
519 for(ItF.Initialize(EFMap(E)), Trouve=Standard_False;
520 ItF.More()&&(!Trouve); ItF.Next()) {
521 if (TopoDS::Face(ItF.Value()).IsSame(FRef)) {
522 Trouve = Standard_True;
525 if (Trouve) Trouve = IsG1(EFMap, E, FRef, FVoi);
526 if (Trouve) Trouve = IsInput(Pc.Vector(), Pc.Vertex(), FVoi);
528 if (Num == 0) F1 = FVoi;
536 //=======================================================================
537 //function : ChangeTransition
538 //purpose : Changes the transition of the second common Point, when the surface
539 // does not cross the arc
540 // As it is supposed that the support Faces are the same, it is enough
541 // to examine the cas of cutting edges.
542 //========================================================================
543 static void ChangeTransition(const ChFiDS_CommonPoint& Precedant,
544 ChFiDS_CommonPoint& Courant,
545 Standard_Integer FaceIndex,
546 const Handle(TopOpeBRepDS_HDataStructure)& DS)
548 Standard_Boolean tochange = Standard_True;
550 const TopoDS_Face& F = TopoDS::Face(DS->Shape(FaceIndex));
551 const TopoDS_Edge& Arc = Precedant.Arc();
552 Handle(Geom2d_Curve) PCurve1, PCurve2;
553 PCurve1 = BRep_Tool::CurveOnSurface(Arc, F, f, l);
554 TopoDS_Shape aLocalShape = Arc.Reversed();
555 PCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(aLocalShape), F, f, l);
556 // PCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(Arc.Reversed()), F, f, l);
557 if (PCurve1 != PCurve2) {
558 // This is a cutting edge, it is necessary to make a small Geometric test
561 BRepAdaptor_Curve AC(Arc);
562 AC.D1(Precedant.ParameterOnArc(), P, tgarc);
563 tochange = tgarc.IsParallel(Precedant.Vector(), Precision::Confusion());
567 Courant.SetArc(Precision::Confusion(),
569 Precedant.ParameterOnArc(),
570 TopAbs::Reverse(Precedant.TransitionOnArc()));
574 //=======================================================================
575 //function : CallPerformSurf
576 //purpose : Encapsulates call to PerformSurf/SimulSurf
577 //========================================================================
579 void ChFi3d_Builder::
580 CallPerformSurf(Handle(ChFiDS_Stripe)& Stripe,
581 const Standard_Boolean Simul,
582 ChFiDS_SequenceOfSurfData& SeqSD,
583 Handle(ChFiDS_SurfData)& SD,
584 const Handle(ChFiDS_HElSpine)& HGuide,
585 const Handle(ChFiDS_Spine)& Spine,
586 const Handle(BRepAdaptor_HSurface)& HS1,
587 const Handle(BRepAdaptor_HSurface)& HS3,
590 Handle(Adaptor3d_TopolTool)& It1,
591 const Handle(BRepAdaptor_HSurface)& HS2,
592 const Handle(BRepAdaptor_HSurface)& HS4,
595 Handle(Adaptor3d_TopolTool)& It2,
596 const Standard_Real MaxStep,
597 const Standard_Real Fleche,
598 const Standard_Real /*TolGuide*/,
599 Standard_Real& First,
601 const Standard_Boolean Inside,
602 const Standard_Boolean /*Appro*/,
603 const Standard_Boolean forward,
604 const Standard_Boolean RecOnS1,
605 const Standard_Boolean RecOnS2,
607 Standard_Boolean& intf,
608 Standard_Boolean& intl,
609 Handle(BRepAdaptor_HSurface)& Surf1,
610 Handle(BRepAdaptor_HSurface)& Surf2)
615 Handle(BRepAdaptor_HSurface) HSon1, HSon2;
618 // Definition of the domain of path It1, It2
619 It1->Initialize(HS1);
620 It2->Initialize(HS2);
623 TopAbs_Orientation Or1 = HS1->ChangeSurface().Face().Orientation();
624 TopAbs_Orientation Or2 = HS2->ChangeSurface().Face().Orientation();
625 Standard_Integer Choix =
626 ChFi3d::NextSide(Or1,Or2,
627 Stripe->OrientationOnFace1(),
628 Stripe->OrientationOnFace2(),
630 Soldep(1) = pp1.X(); Soldep(2) = pp1.Y();
631 Soldep(3) = pp2.X(); Soldep(4) = pp2.Y();
633 Standard_Real thef = First, thel = Last;
634 Standard_Boolean isdone;
637 isdone = SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,HS2,It2,tolesp,First,Last,
638 Inside,Inside,forward,RecOnS1,RecOnS2,Soldep,intf,intl);
643 ChFi3d_InitChron(ch1);//initial perform for PerformSurf
646 isdone = PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,HS2,It2,
647 MaxStep,Fleche,tolesp,
648 First,Last,Inside,Inside,forward,
649 RecOnS1,RecOnS2,Soldep,intf,intl);
651 ChFi3d_ResultChron(ch1,t_performsurf);// result perf for PerformSurf
659 Standard_Boolean reprise = Standard_False;
660 if (! HS3.IsNull()) {
662 It1->Initialize(HS3);
663 Or1 = HS3->ChangeSurface().Face().Orientation();
664 Soldep(1) = pp3.X(); Soldep(2) = pp3.Y();
665 reprise = Standard_True;
667 else if (! HS4.IsNull()) {
669 It2->Initialize(HS4);
670 Or2 = HS4->ChangeSurface().Face().Orientation();
671 Soldep(3) = pp4.X(); Soldep(4) = pp4.Y();
672 reprise = Standard_True;
676 Choix = ChFi3d::NextSide(Or1,Or2,
677 Stripe->OrientationOnFace1(),
678 Stripe->OrientationOnFace2(),
681 isdone = SimulSurf(SD,HGuide,Spine,Choix,HSon1,It1,HSon2,It2,
683 Inside,Inside,forward,RecOnS1,RecOnS2,
689 ChFi3d_InitChron(ch1);//init perf for PerformSurf
692 isdone = PerformSurf(SeqSD,HGuide,Spine,Choix,HSon1,It1,HSon2,It2,
693 MaxStep,Fleche,tolesp,
694 First,Last,Inside,Inside,forward,
695 RecOnS1,RecOnS2,Soldep,intf,intl);
697 ChFi3d_ResultChron(ch1,t_performsurf);// result perf for PerformSurf
706 //=======================================================================
707 //function : StripeOrientation
708 //purpose : Calculates the reference orientation determining the
709 // concave face for construction of the fillet.
710 //=======================================================================
712 Standard_Boolean ChFi3d_Builder::StripeOrientations
713 (const Handle(ChFiDS_Spine)& Spine,
714 TopAbs_Orientation& Or1,
715 TopAbs_Orientation& Or2,
716 Standard_Integer& ChoixConge) const
718 //TopTools_ListIteratorOfListOfShape It;
719 BRepAdaptor_Surface Sb1,Sb2;
720 TopAbs_Orientation Of1,Of2;
722 ChFi3d_conexfaces(Spine->Edges(1),ff1,ff2,myEFMap);
723 Of1 = ff1.Orientation();
724 ff1.Orientation(TopAbs_FORWARD);
726 Of2 = ff2.Orientation();
727 ff2.Orientation(TopAbs_FORWARD);
730 ChoixConge = ChFi3d::ConcaveSide(Sb1,Sb2,Spine->Edges(1),
732 Or1 = TopAbs::Compose(Or1,Of1);
733 Or2 = TopAbs::Compose(Or2,Of2);
734 return Standard_True;
738 //=======================================================================
739 //function : ConexFaces
741 //=======================================================================
743 void ChFi3d_Builder::ConexFaces (const Handle(ChFiDS_Spine)& Spine,
744 const Standard_Integer IEdge,
745 const Standard_Integer RC,
746 Handle(BRepAdaptor_HSurface)& HS1,
747 Handle(BRepAdaptor_HSurface)& HS2) const
749 if(HS1.IsNull()) HS1 = new BRepAdaptor_HSurface ();
750 if(HS2.IsNull()) HS2 = new BRepAdaptor_HSurface ();
751 BRepAdaptor_Surface& Sb1 = HS1->ChangeSurface();
752 BRepAdaptor_Surface& Sb2 = HS2->ChangeSurface();
755 ChFi3d_conexfaces(Spine->Edges(IEdge),ff1,ff2,myEFMap);
760 TopAbs_Orientation Or1,Or2;
761 Standard_Integer Choix = ChFi3d::ConcaveSide(Sb1,Sb2,Spine->Edges(IEdge),
763 if (RC%2 != Choix%2) {
769 //=======================================================================
770 //function : StartSol
771 //purpose : Calculates a starting solution :
772 // - one starts by parsing about ten points on the spine,
773 // - in case of fail one finds the solution on neighbor faces;
774 // section plane of edges of the adjacent face
775 // and identication of the face by connection to that edge.
776 //=======================================================================
778 void ChFi3d_Builder::StartSol(const Handle(ChFiDS_Stripe)& Stripe,
779 const Handle(ChFiDS_HElSpine)& HGuide,
780 Handle(BRepAdaptor_HSurface)& HS1,
781 Handle(BRepAdaptor_HSurface)& HS2,
782 Handle(BRepTopAdaptor_TopolTool)& I1,
783 Handle(BRepTopAdaptor_TopolTool)& I2,
786 Standard_Real& First) const
788 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
789 ChFiDS_ElSpine& els = HGuide->ChangeCurve();
790 Standard_Integer nbed = Spine->NbEdges();
791 Standard_Integer nbessaimax = 3*nbed;
792 if (nbessaimax < 10) nbessaimax = 10;
793 Standard_Real unsurnbessaimax = 1./nbessaimax;
794 Standard_Real wf = 0.9981 * Spine->FirstParameter(1) +
795 0.0019 * Spine->LastParameter(1);
796 Standard_Real wl = 0.9973 * Spine->LastParameter(nbed) +
797 0.0027 * Spine->FirstParameter(nbed);
799 Standard_Real TolE = 1.0e-7;
800 BRepAdaptor_Surface AS;
802 Standard_Integer nbessai;
803 Standard_Integer iedge = 0;
804 Standard_Integer RC = Stripe->Choix();
809 TopAbs_Orientation Or1,Or2;
810 Standard_Integer Choix = 0;
811 math_Vector SolDep(1,4);
812 Handle(Geom2d_Curve) PC;
815 Spine->FirstParameter(1),
816 Spine->LastParameter(nbed),
817 Precision::Confusion());
818 TopAbs_State Pos1,Pos2;
819 for(nbessai = 0; nbessai <= nbessaimax; nbessai++){
820 Standard_Real t = nbessai*unsurnbessaimax;
821 Standard_Real w = wf * (1. -t) + wl * t;
822 Standard_Integer ie = Spine->Index(w);
825 cured = Spine->Edges(iedge);
826 TolE = BRep_Tool::Tolerance(cured);
827 ConexFaces(Spine,iedge,RC,HS1,HS2);
828 f1 = HS1->ChangeSurface().Face();
829 f2 = HS2->ChangeSurface().Face();
830 Or1 = f1.Orientation();
831 Or2 = f2.Orientation();
832 Choix = ChFi3d::NextSide(Or1,Or2,
833 Stripe->OrientationOnFace1(),
834 Stripe->OrientationOnFace2(),
838 Standard_Real woned,Uf,Ul, ResU, ResV;
839 Spine->Parameter(iedge,w,woned,Standard_True);
840 cured.Orientation(TopAbs_FORWARD);
841 TopoDS_Face f1forward = f1, f2forward = f2;
842 f1forward.Orientation(TopAbs_FORWARD);
843 f2forward.Orientation(TopAbs_FORWARD);
844 PC = BRep_Tool::CurveOnSurface(cured,f1forward,Uf,Ul);
846 PC->D1(woned, P1, derive);
847 // There are ponts on the border, and internal points are found
848 if (derive.Magnitude() > Precision::PConfusion()) {
850 derive.Rotate(M_PI/2);
852 ResU = AS.UResolution(TolE);
853 ResV = AS.VResolution(TolE);
854 derive *= 2*(Abs(derive.X())*ResU + Abs(derive.Y())*ResV);
855 P2d = P1.Translated(derive);
856 if (I1->Classify(P2d, Min(ResU, ResV), 0)== TopAbs_IN) {
860 P2d = P1.Translated(-derive);
861 if (I1->Classify(P2d, Min(ResU, ResV), 0)== TopAbs_IN) {
866 if(f1.IsSame(f2)) cured.Orientation(TopAbs_REVERSED);
867 PC = BRep_Tool::CurveOnSurface(cured,f2forward,Uf,Ul);
868 P2 = PC->Value(woned);
871 SolDep(1) = P1.X(); SolDep(2) = P1.Y();
872 SolDep(3) = P2.X(); SolDep(4) = P2.Y();
873 const BRepAdaptor_Curve& Ced = Spine->CurrentElementarySpine(iedge);
874 gp_Pnt pnt = Ced.Value(woned);
876 if (Projection(PExt, pnt, els, w, tolesp) &&
877 PerformFirstSection(Spine,HGuide,Choix,HS1,HS2,
878 I1,I2,w,SolDep,Pos1,Pos2)) {
879 P1.SetCoord(SolDep(1),SolDep(2));
880 P2.SetCoord(SolDep(3),SolDep(4));
885 // No solution was found for the faces adjacent to the trajectory.
886 // Now one tries the neighbor faces.
888 for(nbessai = 0; nbessai <= nbessaimax; nbessai++){
889 Standard_Real t = nbessai*unsurnbessaimax;
890 Standard_Real w = wf * (1. -t) + wl * t;
891 iedge = Spine->Index(w);
892 cured = Spine->Edges(iedge);
893 ConexFaces(Spine,iedge,RC,HS1,HS2);
894 f1 = HS1->ChangeSurface().Face();
895 f2 = HS2->ChangeSurface().Face();
896 Or1 = f1.Orientation();
897 Or2 = f2.Orientation();
898 Choix = ChFi3d::NextSide(Or1,Or2,
899 Stripe->OrientationOnFace1(),
900 Stripe->OrientationOnFace2(),
902 Standard_Real woned,Uf,Ul;
903 Spine->Parameter(iedge,w,woned,Standard_True);
904 TopoDS_Face f1forward = f1, f2forward = f2;
905 f1forward.Orientation(TopAbs_FORWARD);
906 f2forward.Orientation(TopAbs_FORWARD);
907 PC = BRep_Tool::CurveOnSurface(cured,f1forward,Uf,Ul);
908 P1 = PC->Value(woned);
909 PC = BRep_Tool::CurveOnSurface(cured,f2forward,Uf,Ul);
910 P2 = PC->Value(woned);
913 SolDep(1) = P1.X(); SolDep(2) = P1.Y();
914 SolDep(3) = P2.X(); SolDep(4) = P2.Y();
915 const BRepAdaptor_Curve& Ced = Spine->CurrentElementarySpine(iedge);
916 gp_Pnt pnt = Ced.Value(woned);
917 // Extrema_LocateExtPC ext(pnt,els,w,1.e-8);
919 // w = ext.Point().Parameter();
920 if (Projection(PExt, pnt, els, w, tolesp)) {
921 PerformFirstSection(Spine,HGuide,Choix,HS1,HS2,
922 I1,I2,w,SolDep,Pos1,Pos2);
926 Handle(Geom_Plane) pl = new Geom_Plane(P,V);
927 Handle(GeomAdaptor_HSurface) plane = new GeomAdaptor_HSurface(pl);
929 Standard_Boolean bonvoisin = 1, found = 0;
930 Standard_Integer NbChangement;
931 for (NbChangement = 1; bonvoisin && (!found) && (NbChangement < 5);
933 if(Pos1 != TopAbs_IN){
934 bonvoisin = BonVoisin(P, HS1, f1, plane, cured,
935 SolDep(1),SolDep(2), myEFMap, tolesp);
937 if(Pos2 != TopAbs_IN && bonvoisin){
938 bonvoisin = BonVoisin(P, HS2, f2, plane, cured,
939 SolDep(3),SolDep(4), myEFMap, tolesp);
942 f1 = HS1->ChangeSurface().Face();
943 f2 = HS2->ChangeSurface().Face();
944 Or1 = f1.Orientation();
945 Or2 = f2.Orientation();
946 Choix = ChFi3d::NextSide(Or1,Or2,
947 Stripe->OrientationOnFace1(),
948 Stripe->OrientationOnFace2(),
952 if(PerformFirstSection(Spine,HGuide,Choix,HS1,HS2,
953 I1,I2,w,SolDep,Pos1,Pos2)){
954 P1.SetCoord(SolDep(1),SolDep(2));
955 P2.SetCoord(SolDep(3),SolDep(4));
957 found = Standard_True;
964 Spine->SetErrorStatus(ChFiDS_StartsolFailure);
965 Standard_Failure::Raise("StartSol echec");
968 //=======================================================================
969 //function : ChFi3d_BuildPlane
971 //=======================================================================
973 static void ChFi3d_BuildPlane (TopOpeBRepDS_DataStructure& DStr,
974 Handle(BRepAdaptor_HSurface)& HS,
976 const Handle(ChFiDS_SurfData)& SD,
977 const Standard_Boolean isfirst,
978 const Standard_Integer ons)
980 Handle(Geom2d_Curve) Hc;
981 TopoDS_Face F = TopoDS::Face(DStr.Shape(SD->Index(ons)));
986 if (SD->Vertex(isfirst,ons).IsOnArc()){
987 Hc = BRep_Tool::CurveOnSurface
988 (SD->Vertex(isfirst,ons).Arc(),F,u,v);
989 Hc->Value(SD->Vertex(isfirst,ons).ParameterOnArc()).Coord(u,v);
990 BRepLProp_SLProps theProp(HS->ChangeSurface(), u, v, 1, 1.e-12);
991 if (theProp.IsNormalDefined()) {
993 Handle(Geom_Plane) Pln = new Geom_Plane(P, theProp.Normal());
994 TopoDS_Face NewF = BRepLib_MakeFace(Pln, Precision::Confusion());
995 NewF.Orientation(F.Orientation());
996 pons.SetCoord(0.,0.);
997 HS->ChangeSurface().Initialize(NewF);
998 return; // everything is good !
1001 Standard_Failure::Raise("ChFi3d_BuildPlane : echec .");
1004 //=======================================================================
1005 //function : StartSol
1006 //purpose : If the commonpoint is not OnArc the input face
1007 // is returned and 2D point is updated,
1009 // if it is detached the input face
1010 // is returned and 2D point is updated,
1012 // either there is a neighbor tangent face and it is returned
1013 // with recalculated 2D point
1014 // or if there is no face
1015 // if the reference arc is Vref (extremity of the spine)
1016 // this is the end and the input face is returned
1017 // otherwise this is an obstacle and HC is updated.
1018 //=======================================================================
1021 ChFi3d_Builder::StartSol(const Handle(ChFiDS_Spine)& Spine,
1022 Handle(BRepAdaptor_HSurface)& HS, // New face
1023 gp_Pnt2d& pons,// " Localization
1024 Handle(BRepAdaptor_HCurve2d)& HC, // Representation of the obstacle
1026 const Handle(ChFiDS_SurfData)& SD,
1027 const Standard_Boolean isfirst,
1028 const Standard_Integer ons,
1029 Handle(BRepAdaptor_HSurface)& HSref, // The other representation
1030 Handle(BRepAdaptor_HCurve2d)& HCref, // of the obstacle
1031 Standard_Boolean& RecP,
1032 Standard_Boolean& RecS,
1033 Standard_Boolean& RecRst,
1034 Standard_Boolean& c1obstacle,
1035 Handle(BRepAdaptor_HSurface)& HSBis, // Face of support
1036 gp_Pnt2d& PBis, // and its point
1037 const Standard_Boolean decroch,
1038 const TopoDS_Vertex& Vref) const
1040 RecRst = RecS = RecP = c1obstacle = 0;
1041 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
1042 TopoDS_Face Fv,Fref;
1044 Handle(Geom2d_Curve) pc;
1045 Standard_Real Uf,Ul;
1047 TopoDS_Face F = TopoDS::Face(DStr.Shape(SD->Index(ons)));
1048 if(!HSref.IsNull()) Fref = HSref->ChangeSurface().Face();
1049 const ChFiDS_CommonPoint& CP = SD->Vertex(isfirst,ons);
1053 Standard_Integer notons;
1054 if (ons == 1) notons = 2;
1056 const ChFiDS_CommonPoint& CPbis = SD->Vertex(isfirst,notons);
1057 if (CPbis.IsOnArc()) { // It is checked if it is not the extension zone
1058 // In case CP is not at the end of surfdata and it is not necesary to take it into account
1059 // except for separate cases (ie pointus) ...
1060 //ts and tns were earlier CP.Parameter() and CPbis.Parameter, but sometimes they had no values.
1061 Standard_Real ts=SD->Interference(ons).Parameter(isfirst), tns=SD->Interference(notons).Parameter(isfirst);
1062 Standard_Boolean isExtend;
1063 // Arbitrary test (to precise)
1064 if (isfirst) isExtend = (ts-tns > 100*tolesp);
1065 else isExtend = (tns-ts > 100*tolesp);
1066 if (isExtend && !CP.Point().IsEqual(CPbis.Point(), 0) ) {
1067 // the state is preserved and False is returned (extension by the expected plane).
1068 HS->ChangeSurface().Initialize(F);
1069 pc = SD->Interference(ons).PCurveOnFace();
1070 // The 2nd point is given by its trace on the support surface
1071 RecS = Standard_False;
1072 pons = pc->Value(tns);
1073 return Standard_False;
1078 if (CP.IsVertex() && !HC.IsNull() && !decroch){
1079 //The edge is changed, the parameter is updated and
1080 //eventually the support face and(or) the reference face.
1081 TopoDS_Vertex VCP = CP.Vertex();
1082 TopoDS_Edge EHC = HC->ChangeCurve2d().Edge();
1083 //One starts by searching in Fref another edge referencing VCP.
1084 TopExp_Explorer ex1,ex2;
1085 TopoDS_Edge newedge, edgereg;
1086 TopoDS_Face bidface = Fref, facereg;
1087 bidface.Orientation(TopAbs_FORWARD);
1088 for(ex1.Init(bidface,TopAbs_EDGE); ex1.More(); ex1.Next()){
1089 const TopoDS_Edge& cured = TopoDS::Edge(ex1.Current());
1090 Standard_Boolean found = 0;
1091 if(!cured.IsSame(EHC)){
1092 for(ex2.Init(cured,TopAbs_VERTEX); ex2.More() && !found; ex2.Next()){
1093 if(ex2.Current().IsSame(VCP)){
1094 if(IsG1(myEFMap,cured,Fref,Fv)){
1107 if(newedge.IsNull()){
1108 //It is checked if EHC is not a closed edge.
1109 TopoDS_Vertex V1,V2;
1110 TopExp::Vertices(EHC,V1,V2);
1113 Standard_Real w1 = BRep_Tool::Parameter(V1,EHC);
1114 Standard_Real w2 = BRep_Tool::Parameter(V2,EHC);
1115 const ChFiDS_FaceInterference& fi = SD->Interference(ons);
1116 const Handle(Geom2d_Curve)& pcf = fi.PCurveOnFace();
1117 Standard_Real ww = fi.Parameter(isfirst);
1120 if(!pcf.IsNull()) pww = pcf->Value(ww);
1121 else pww = SD->Get2dPoints(isfirst,ons);
1122 gp_Pnt2d p1 = HC->Value(w1);
1123 gp_Pnt2d p2 = HC->Value(w2);
1125 if(p1.Distance(pww) > p2.Distance(pww)){
1133 RecP = c1obstacle = 1;
1136 else if(!edgereg.IsNull()){
1137 // the reference edge and face are changed.
1139 HSref->ChangeSurface().Initialize(Fref);
1140 for(ex1.Init(facereg,TopAbs_EDGE); ex1.More() && newedge.IsNull(); ex1.Next()){
1141 const TopoDS_Edge& cured = TopoDS::Edge(ex1.Current());
1142 if(!cured.IsSame(edgereg)){
1143 for(ex2.Init(cured,TopAbs_VERTEX); ex2.More(); ex2.Next()){
1144 if(ex2.Current().IsSame(VCP)){
1145 if(!IsG1(myEFMap,cured,Fref,Fv)){
1154 // it is necessary to find the new support face of the fillet :
1155 // connected to FRef along the newedge.
1156 if(newedge.IsNull()) {
1157 Standard_Failure::Raise
1158 ("StartSol : chain is not possible, new obstacle not found");
1160 if(IsG1(myEFMap,newedge,Fref,Fv)){
1161 Standard_Failure::Raise
1162 ("StartSol : chain is not possible, config non processed");
1164 else if(Fv.IsNull()){
1165 Standard_Failure::Raise
1166 ("StartSol : chain is not possible, new obstacle not found");
1169 HS->ChangeSurface().Initialize(Fv);
1170 W = BRep_Tool::Parameter(VCP,newedge);
1171 HCref->ChangeCurve2d().Initialize(newedge,Fref);
1172 TopoDS_Face newface = Fv;
1173 newface.Orientation(TopAbs_FORWARD);
1175 for(ex.Init(newface,TopAbs_EDGE); ex.More(); ex.Next()){
1176 if(ex.Current().IsSame(newedge)){
1177 newedge = TopoDS::Edge(ex.Current());
1181 HC->ChangeCurve2d().Initialize(newedge,Fv);
1182 pons = HC->Value(W);
1184 RecP = c1obstacle = 1;
1186 } // End of Case Vertex && Obstacle
1188 else if (CP.IsOnArc() && !HC.IsNull() && !decroch){
1189 //Nothing is changed, the parameter is only updated.
1190 W = CP.ParameterOnArc();
1198 const TopoDS_Edge& E = CP.Arc();
1200 HS->ChangeSurface().Initialize(Fref);
1201 W = CP.ParameterOnArc();
1202 pc = BRep_Tool::CurveOnSurface(E,Fref,Uf,Ul);
1203 pons = pc->Value(W);
1207 if (SearchFace(Spine,CP,F,Fv)){
1208 HS->ChangeSurface().Initialize(Fv);
1210 if (CP.IsVertex()) {
1211 // One goes directly by the Vertex
1212 Standard_Integer Nb;
1214 // And it is checked that there are no other candidates
1215 Nb = SearchFaceOnV(CP, F, myVEMap, myEFMap, Fv, aux);
1217 pons = BRep_Tool::Parameters(CP.Vertex(), Fv);
1218 HS->ChangeSurface().Initialize(Fv);
1220 HSBis = new (BRepAdaptor_HSurface)(aux);
1221 PBis = BRep_Tool::Parameters(CP.Vertex(), aux);
1225 // otherwise one passes by the arc...
1227 Fv.Orientation(TopAbs_FORWARD);
1228 TopoDS_Edge newedge;
1230 for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()){
1231 if(ex.Current().IsSame(E)){
1232 newedge = TopoDS::Edge(ex.Current());
1236 //gp_Vec Varc, VSurf;
1237 // In cas of Tangent output, the current face becomes the support face
1238 if (SortieTangente(CP, F, SD, ons, 0.1)) {
1239 pc = BRep_Tool::CurveOnSurface(CP.Arc(),F,Uf,Ul);
1240 HSBis = new (BRepAdaptor_HSurface)(F);
1241 PBis = pc->Value(CP.ParameterOnArc());
1245 pc = BRep_Tool::CurveOnSurface(newedge,Fv,Uf,Ul);
1248 TopoDS_Edge newedge = E;
1250 Fv.Orientation(TopAbs_FORWARD);
1251 pc = BRep_Tool::CurveOnSurface(newedge,Fv,Uf,Ul);
1253 pons = pc->Value(CP.ParameterOnArc());
1256 else if(!Fv.IsNull()){
1260 for(ex.Init(E,TopAbs_VERTEX); ex.More(); ex.Next()){
1261 if(ex.Current().IsSame(Vref)){
1268 HS->ChangeSurface().Initialize(Fv);
1269 HSref->ChangeSurface().Initialize(F);
1270 W = CP.ParameterOnArc();
1271 HC = new BRepAdaptor_HCurve2d();
1272 TopoDS_Edge newedge;
1273 TopoDS_Face newface = Fv;
1274 newface.Orientation(TopAbs_FORWARD);
1276 for(ex.Init(newface,TopAbs_EDGE); ex.More(); ex.Next()){
1277 if(ex.Current().IsSame(E)){
1278 newedge = TopoDS::Edge(ex.Current());
1282 HC->ChangeCurve2d().Initialize(newedge,Fv);
1283 pons = HC->Value(W);
1284 HCref->ChangeCurve2d().Initialize(E,F);
1285 if(CP.IsVertex()) RecP = 1;
1290 HS->ChangeSurface().Initialize(F);
1291 W = CP.ParameterOnArc();
1292 pc = BRep_Tool::CurveOnSurface(E,F,Uf,Ul);
1293 pons = pc->Value(W);
1294 return Standard_False;
1297 else{ // there is no neighbor face, the state is preserved and False is returned.
1298 HS->ChangeSurface().Initialize(F);
1299 W = CP.ParameterOnArc();
1300 pc = BRep_Tool::CurveOnSurface(E,F,Uf,Ul);
1301 pons = pc->Value(W);
1302 return Standard_False;
1306 HS->ChangeSurface().Initialize(F);
1307 const ChFiDS_FaceInterference& FI = SD->Interference(ons);
1308 if(FI.PCurveOnFace().IsNull()) pons = SD->Get2dPoints(isfirst,ons);
1309 else pons = FI.PCurveOnFace()->Value(FI.Parameter(isfirst));
1311 return Standard_True;
1314 //=======================================================================
1315 //function : SearchFace
1317 //=======================================================================
1319 Standard_Boolean ChFi3d_Builder::SearchFace
1320 (const Handle(ChFiDS_Spine)& Spine,
1321 const ChFiDS_CommonPoint& Pc,
1322 const TopoDS_Face& FRef,
1323 TopoDS_Face& FVoi) const
1325 Standard_Boolean Trouve = Standard_False;
1326 if (! Pc.IsOnArc()) return Standard_False;
1330 // attention it is necessary to analyze all faces that turn around of the vertex
1332 cout<<"Commonpoint on vertex, the process hangs up"<<endl;
1334 if (Pc.HasVector()) { //General processing
1336 Standard_Integer nb_faces;
1337 nb_faces = SearchFaceOnV(Pc, FRef, myVEMap, myEFMap, FVoi, Fbis);
1338 return ( nb_faces > 0);
1340 else { // Processing using the spine
1341 Standard_Boolean FindFace=Standard_False;
1344 Spine->D1(Pc.Parameter(), Point, VecSpine);
1346 // It is checked if one leaves from the current face.
1347 FindFace = IsInput(VecSpine, Pc.Vertex(), FRef);
1350 FindFace = IsInput(VecSpine, Pc.Vertex(), FRef);
1352 // If one does not leave, it is ended
1355 return Standard_True;
1358 // Otherwise one finds the next among shared Faces
1359 // by a common edge G1
1360 TopTools_ListIteratorOfListOfShape ItE, ItF;
1361 for(ItE.Initialize(myVEMap(Pc.Vertex()));
1362 ItE.More() && (!FindFace); ItE.Next()) {
1363 E = TopoDS::Edge(ItE.Value());
1364 Trouve=Standard_False;
1365 for(ItF.Initialize(myEFMap(E));//, Trouve=Standard_False; 15.11.99 SVV
1366 ItF.More()&&(!Trouve); ItF.Next()) {
1367 if (TopoDS::Face(ItF.Value()).IsSame(FRef)) {
1368 Trouve = Standard_True;
1371 if (Trouve) FindFace = IsG1(myEFMap, E, FRef, FVoi);
1373 FindFace = Standard_False;
1374 if (Spine.IsNull()) {
1375 //La Spine peut etre nulle (ThreeCorner)
1377 cout << "FindFace sur vertex avec spine nulle! QUEZAKO ?" << endl;
1379 return Standard_False;
1382 // It is checked if the selected face actually possesses edges of the spine
1383 // containing the vertex on its front
1384 // This processing should go only if the Vertex belongs to the spine
1385 // This is a single case, for other vertexes it is required to do other things
1386 Trouve=Standard_False;
1387 for (Standard_Integer IE=1;//, Trouve=Standard_False; 15.11.99 SVV
1388 (IE<=Spine->NbEdges()) && (!Trouve); IE++) {
1389 E = Spine->Edges(IE);
1390 if ( (TopExp::FirstVertex(E).IsSame(Pc.Vertex()))
1391 ||(TopExp::LastVertex(E) .IsSame(Pc.Vertex())) ) {
1392 for(ItF.Initialize(myEFMap(E)), Trouve=Standard_False;
1393 ItF.More()&&(!Trouve); ItF.Next()) {
1394 if (TopoDS::Face(ItF.Value()).IsSame(FVoi)) {
1395 Trouve = Standard_True;
1406 return IsG1(myEFMap, Pc.Arc(), FRef, FVoi);
1408 return Standard_False;
1412 //=======================================================================
1413 //function : ChFi3d_SingularExtremity
1414 //purpose : load the vertex in the DS and calculate the pcurve
1415 // for an extremity in case of singular freeboundary
1416 // or periodic and singular at the cut.
1417 //=======================================================================
1418 static void ChFi3d_SingularExtremity( Handle(ChFiDS_Stripe)& stripe,
1419 TopOpeBRepDS_DataStructure& DStr,
1420 const TopoDS_Vertex& Vtx,
1421 const Standard_Real tol3d,
1422 const Standard_Real tol2d)
1424 Handle(ChFiDS_SurfData) Fd;
1425 Standard_Real tolreached;
1426 Standard_Real Pardeb, Parfin;
1427 gp_Pnt2d VOnS1, VOnS2;
1428 Handle(Geom_Curve) C3d;
1429 Handle(Geom2d_Curve) PCurv;
1430 TopOpeBRepDS_Curve Crv;
1431 // SurfData and its CommonPoints,
1432 Standard_Integer Ivtx, Icurv;
1433 Standard_Boolean isfirst;
1435 if (stripe->Spine()->IsPeriodic()) {
1436 isfirst = Standard_True;
1437 Fd = stripe->SetOfSurfData()->Sequence().First();
1440 Standard_Integer sens;
1441 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
1442 Fd = stripe->SetOfSurfData()->Sequence().Value(num);
1443 isfirst = (sens == 1);
1446 const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1);
1447 const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2);
1448 // Is it always degenerated ?
1449 if ( CV1.Point().IsEqual( CV2.Point(), 0) ) {
1450 Ivtx = ChFi3d_IndexPointInDS(CV1, DStr);
1452 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
1453 Value(Fd->InterferenceOnS1().FirstParameter());
1454 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
1455 Value(Fd->InterferenceOnS2().FirstParameter());
1458 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
1459 Value(Fd->InterferenceOnS1().LastParameter());
1460 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
1461 Value(Fd->InterferenceOnS2().LastParameter());
1464 ChFi3d_ComputeArete(CV1, VOnS1,
1466 DStr.Surface(Fd->Surf()).Surface(),
1468 Pardeb,Parfin, tol3d, tol2d, tolreached,0);
1469 Crv = TopOpeBRepDS_Curve(C3d,tolreached);
1470 Icurv = DStr.AddCurve(Crv);
1472 stripe->SetCurve(Icurv, isfirst);
1473 stripe->SetParameters(isfirst, Pardeb,Parfin);
1474 stripe->ChangePCurve(isfirst) = PCurv;
1475 stripe->SetIndexPoint(Ivtx, isfirst, 1);
1476 stripe->SetIndexPoint(Ivtx, isfirst, 2);
1478 if (stripe->Spine()->IsPeriodic()) {
1479 // periodic case : The operation is renewed
1480 // the curve 3d is not shared.
1481 // 2 degenerated edges coinciding in 3d
1482 isfirst = Standard_False;
1483 Fd = stripe->SetOfSurfData()->Sequence().Last();
1484 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
1485 Value(Fd->InterferenceOnS1().LastParameter());
1486 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
1487 Value(Fd->InterferenceOnS2().LastParameter());
1489 ChFi3d_ComputeArete(CV1, VOnS1,
1491 DStr.Surface(Fd->Surf()).Surface(),
1493 Pardeb,Parfin, tol3d, tol2d, tolreached,0);
1494 Crv = TopOpeBRepDS_Curve(C3d,tolreached);
1495 Icurv = DStr.AddCurve(Crv);
1497 stripe->SetCurve(Icurv, isfirst);
1498 stripe->SetParameters(isfirst, Pardeb,Parfin);
1499 stripe->ChangePCurve(isfirst) = PCurv;
1500 stripe->SetIndexPoint(Ivtx, isfirst, 1);
1501 stripe->SetIndexPoint(Ivtx, isfirst, 2);
1506 //=======================================================================
1507 //function : ChFi3d_MakeExtremities
1508 //purpose : calculate Curves3d and pcurves of extremities in
1509 // periodic and freeboundary cases.
1510 //=======================================================================
1511 static Standard_Boolean IsFree(const TopoDS_Shape& E,
1512 const ChFiDS_Map& EFMap)
1514 if(!EFMap.Contains(E)) return 0;
1515 TopTools_ListIteratorOfListOfShape It;
1517 for(It.Initialize(EFMap(E)); It.More(); It.Next()){
1518 if(Fref.IsNull()) Fref = It.Value();
1519 else if(!Fref.IsSame(It.Value())) return 0;
1524 static void ChFi3d_MakeExtremities(Handle(ChFiDS_Stripe)& Stripe,
1525 TopOpeBRepDS_DataStructure& DStr,
1526 const ChFiDS_Map& EFMap,
1527 const Standard_Real tol3d,
1528 const Standard_Real tol2d)
1530 Handle(ChFiDS_Spine)& sp = Stripe->ChangeSpine();
1531 Standard_Real Pardeb,Parfin;
1532 Handle(Geom_Curve) C3d;
1533 Standard_Real tolreached;
1534 if(sp->IsPeriodic()){
1536 const Handle(ChFiDS_SurfData)&
1537 SDF = Stripe->SetOfSurfData()->Sequence().First();
1538 const ChFiDS_CommonPoint& CV1 = SDF->VertexFirstOnS1();
1539 const ChFiDS_CommonPoint& CV2 = SDF->VertexFirstOnS2();
1540 if ( !CV1.Point().IsEqual(CV2.Point(), 0) ) {
1541 ChFi3d_ComputeArete(CV1,
1542 SDF->InterferenceOnS1().PCurveOnSurf()->
1543 Value(SDF->InterferenceOnS1().FirstParameter()),
1545 SDF->InterferenceOnS2().PCurveOnSurf()->
1546 Value(SDF->InterferenceOnS2().FirstParameter()),
1547 DStr.Surface(SDF->Surf()).Surface(),C3d,
1548 Stripe->ChangeFirstPCurve(),Pardeb,Parfin,
1549 tol3d,tol2d,tolreached,0);
1550 TopOpeBRepDS_Curve Crv(C3d,tolreached);
1551 Stripe->ChangeFirstCurve(DStr.AddCurve(Crv));
1552 Stripe->ChangeFirstParameters(Pardeb,Parfin);
1553 Stripe->ChangeIndexFirstPointOnS1
1554 (ChFi3d_IndexPointInDS(SDF->VertexFirstOnS1(),DStr));
1555 Stripe->ChangeIndexFirstPointOnS2
1556 (ChFi3d_IndexPointInDS(SDF->VertexFirstOnS2(),DStr));
1557 Standard_Integer ICurv = Stripe->FirstCurve();
1558 Stripe->ChangeLastParameters(Pardeb,Parfin);
1559 Stripe->ChangeLastCurve(ICurv);
1560 Stripe->ChangeIndexLastPointOnS1(Stripe->IndexFirstPointOnS1());
1561 Stripe->ChangeIndexLastPointOnS2(Stripe->IndexFirstPointOnS2());
1563 const Handle(ChFiDS_SurfData)&
1564 SDL = Stripe->SetOfSurfData()->Sequence().Last();
1567 ChFi3d_ComputePCurv(C3d,
1568 SDL->InterferenceOnS1().PCurveOnSurf()->
1569 Value(SDL->InterferenceOnS1().LastParameter()),
1570 SDL->InterferenceOnS2().PCurveOnSurf()->
1571 Value(SDL->InterferenceOnS2().LastParameter()),
1572 Stripe->ChangeLastPCurve(),
1573 DStr.Surface(SDL->Surf()).Surface(),
1574 Pardeb,Parfin,tol3d,tolreached);
1575 Standard_Real oldtol = DStr.ChangeCurve(ICurv).Tolerance();
1576 DStr.ChangeCurve(ICurv).Tolerance(Max(oldtol,tolreached));
1578 ChFi3d_EnlargeBox(CV1.Arc(),EFMap(CV1.Arc()),CV1.ParameterOnArc(),b1);
1582 ChFi3d_EnlargeBox(CV2.Arc(),EFMap(CV2.Arc()),CV2.ParameterOnArc(),b2);
1584 ChFi3d_EnlargeBox(DStr,Stripe,SDF,b1,b2,1);
1585 ChFi3d_EnlargeBox(DStr,Stripe,SDL,b1,b2,0);
1586 if (!CV1.IsVertex())
1587 ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexFirstPointOnS1());
1588 if (!CV2.IsVertex())
1589 ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexFirstPointOnS2());
1592 // Case of the single extremity
1593 if (CV1.IsVertex()) {
1594 ChFi3d_SingularExtremity(Stripe, DStr, CV1.Vertex(), tol3d, tol2d);
1597 else { cout << "MakeExtremities : Singularity out of Vertex !!" << endl; }
1603 const Handle(ChFiDS_SurfData)&
1604 SDdeb = Stripe->SetOfSurfData()->Sequence().First();
1606 const ChFiDS_CommonPoint& cpdeb1 = SDdeb->VertexFirstOnS1();
1607 const ChFiDS_CommonPoint& cpdeb2 = SDdeb->VertexFirstOnS2();
1608 Standard_Boolean freedeb = sp->FirstStatus() == ChFiDS_FreeBoundary;
1609 if(!freedeb && cpdeb1.IsOnArc() && cpdeb2.IsOnArc()){
1610 freedeb = (IsFree(cpdeb1.Arc(),EFMap) && IsFree(cpdeb2.Arc(),EFMap));
1613 sp->SetFirstStatus(ChFiDS_FreeBoundary);
1615 if ( !cpdeb1.Point().IsEqual(cpdeb2.Point(), 0) ) {
1616 Standard_Boolean plane;
1618 UV1=SDdeb->InterferenceOnS1().PCurveOnSurf()->
1619 Value(SDdeb->InterferenceOnS1().FirstParameter());
1620 UV2=SDdeb->InterferenceOnS2().PCurveOnSurf()->
1621 Value(SDdeb->InterferenceOnS2().FirstParameter());
1622 // The intersection of the fillet by a plane is attempted
1624 Handle(GeomAdaptor_HSurface) HConge=ChFi3d_BoundSurf(DStr,SDdeb,1,2);
1625 ChFi3d_CoupeParPlan(cpdeb1,cpdeb2,HConge,UV1,UV2,
1626 tol3d,tol2d,C3d,Stripe->ChangeFirstPCurve(),tolreached,
1627 Pardeb,Parfin,plane);
1629 ChFi3d_ComputeArete(cpdeb1,
1630 SDdeb->InterferenceOnS1().PCurveOnSurf()->
1631 Value(SDdeb->InterferenceOnS1().FirstParameter()),
1633 SDdeb->InterferenceOnS2().PCurveOnSurf()->
1634 Value(SDdeb->InterferenceOnS2().FirstParameter()),
1635 DStr.Surface(SDdeb->Surf()).Surface(),C3d,
1636 Stripe->ChangeFirstPCurve(),Pardeb,Parfin,
1637 tol3d,tol2d,tolreached,0);
1638 TopOpeBRepDS_Curve Crv(C3d,tolreached);
1639 Stripe->ChangeFirstCurve(DStr.AddCurve(Crv));
1640 Stripe->ChangeFirstParameters(Pardeb,Parfin);
1641 Stripe->ChangeIndexFirstPointOnS1
1642 (ChFi3d_IndexPointInDS(SDdeb->VertexFirstOnS1(),DStr));
1643 Stripe->ChangeIndexFirstPointOnS2
1644 (ChFi3d_IndexPointInDS(SDdeb->VertexFirstOnS2(),DStr));
1645 if(cpdeb1.IsOnArc()){
1646 ChFi3d_EnlargeBox(cpdeb1.Arc(),EFMap(cpdeb1.Arc()),cpdeb1.ParameterOnArc(),b1);
1648 if(cpdeb2.IsOnArc()){
1649 ChFi3d_EnlargeBox(cpdeb2.Arc(),EFMap(cpdeb2.Arc()),cpdeb2.ParameterOnArc(),b2);
1651 ChFi3d_EnlargeBox(DStr,Stripe,SDdeb,b1,b2,1);
1652 if (!cpdeb1.IsVertex())
1653 ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexFirstPointOnS1());
1654 if (!cpdeb2.IsVertex())
1655 ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexFirstPointOnS2());
1657 else { // Case of a singular extremity
1658 if (cpdeb1.IsVertex()) {
1659 ChFi3d_SingularExtremity(Stripe, DStr, cpdeb1.Vertex(), tol3d, tol2d);
1662 else { cout << "MakeExtremities : Singularity out of Vertex !!" << endl; }
1666 const Handle(ChFiDS_SurfData)&
1667 SDfin = Stripe->SetOfSurfData()->Sequence().Last();
1668 const ChFiDS_CommonPoint& cpfin1 = SDfin->VertexLastOnS1();
1669 const ChFiDS_CommonPoint& cpfin2 = SDfin->VertexLastOnS2();
1670 Standard_Boolean freefin = sp->LastStatus() == ChFiDS_FreeBoundary;
1671 if(!freefin && cpfin1.IsOnArc() && cpfin2.IsOnArc()){
1672 freefin = (IsFree(cpfin1.Arc(),EFMap) && IsFree(cpfin2.Arc(),EFMap));
1675 sp->SetLastStatus(ChFiDS_FreeBoundary);
1677 if ( !cpfin1.Point().IsEqual(cpfin2.Point(), 0) ) {
1678 Standard_Boolean plane;
1680 UV1=SDfin->InterferenceOnS1().PCurveOnSurf()->
1681 Value(SDfin->InterferenceOnS1().LastParameter());
1682 UV2=SDfin->InterferenceOnS2().PCurveOnSurf()->
1683 Value(SDfin->InterferenceOnS2().LastParameter());
1684 // Intersection of the fillet by a plane is attempted
1686 Handle(GeomAdaptor_HSurface) HConge=ChFi3d_BoundSurf(DStr,SDfin,1,2);
1687 ChFi3d_CoupeParPlan(cpfin1,cpfin2,HConge,UV1,UV2,
1688 tol3d,tol2d,C3d,Stripe->ChangeLastPCurve(),tolreached,
1689 Pardeb,Parfin,plane);
1691 ChFi3d_ComputeArete(cpfin1,
1692 SDfin->InterferenceOnS1().PCurveOnSurf()->
1693 Value(SDfin->InterferenceOnS1().LastParameter()),
1695 SDfin->InterferenceOnS2().PCurveOnSurf()->
1696 Value(SDfin->InterferenceOnS2().LastParameter()),
1697 DStr.Surface(SDfin->Surf()).Surface(),C3d,
1698 Stripe->ChangeLastPCurve(),Pardeb,Parfin,
1699 tol3d,tol2d,tolreached,0);
1700 TopOpeBRepDS_Curve Crv(C3d,tolreached);
1701 Stripe->ChangeLastCurve(DStr.AddCurve(Crv));
1702 Stripe->ChangeLastParameters(Pardeb,Parfin);
1703 Stripe->ChangeIndexLastPointOnS1
1704 (ChFi3d_IndexPointInDS(SDfin->VertexLastOnS1(),DStr));
1705 Stripe->ChangeIndexLastPointOnS2
1706 (ChFi3d_IndexPointInDS(SDfin->VertexLastOnS2(),DStr));
1707 if(cpfin1.IsOnArc()){
1708 ChFi3d_EnlargeBox(cpfin1.Arc(),EFMap(cpfin1.Arc()),cpfin1.ParameterOnArc(),b1);
1710 if(cpfin2.IsOnArc()){
1711 ChFi3d_EnlargeBox(cpfin2.Arc(),EFMap(cpfin2.Arc()),cpfin2.ParameterOnArc(),b2);
1713 ChFi3d_EnlargeBox(DStr,Stripe,SDfin,b1,b2,0);
1714 if (!cpfin1.IsVertex())
1715 ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexLastPointOnS1());
1716 if (!cpfin2.IsVertex())
1717 ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexLastPointOnS2());
1719 else { // Case of the single extremity
1720 if (cpfin1.IsVertex()) {
1721 ChFi3d_SingularExtremity(Stripe, DStr, cpfin1.Vertex(), tol3d, tol2d);
1724 else { cout << "MakeExtremities : Singularity out of Vertex !!" << endl; }
1730 //=======================================================================
1731 //function : ChFi3d_Purge
1733 //=======================================================================
1735 static void ChFi3d_Purge (Handle(ChFiDS_Stripe)& Stripe,
1736 Handle(ChFiDS_SurfData)& SD,
1737 const ChFiDS_CommonPoint& VRef,
1738 const Standard_Boolean isfirst,
1739 const Standard_Integer ons,
1740 Standard_Boolean& intf,
1741 Standard_Boolean& intl)
1743 if (isfirst) intf = 1; else intl = 1; // End.
1744 Standard_Integer opp = 3-ons;
1745 if (!SD->Vertex(isfirst,opp).IsOnArc() ||
1746 SD->TwistOnS1() || SD->TwistOnS2() ) {
1748 cout<<"ChFi3d_Purge : No output on extension."<<endl;
1750 ChFiDS_SequenceOfSurfData& Seq =
1751 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1752 if(isfirst) Seq.Remove(1);
1753 else Seq.Remove(Seq.Length());
1756 if (ons == 1) SD->ChangeIndexOfS1(0);
1757 else SD->ChangeIndexOfS2(0);
1759 SD->ChangeVertex(!isfirst,ons) = VRef;
1760 SD->ChangeVertex(isfirst,ons) = VRef;
1762 ChFiDS_FaceInterference& fi = SD->ChangeInterference(ons);
1763 if(isfirst) fi.SetFirstParameter(fi.LastParameter());
1764 else fi.SetLastParameter(fi.FirstParameter());
1768 //=======================================================================
1769 //function : InsertAfter
1770 //purpose : insert Item after ref in Seq. If ref is null, the item is
1771 // inserted at the beginning.
1772 //=======================================================================
1774 static void InsertAfter (Handle(ChFiDS_Stripe)& Stripe,
1775 Handle(ChFiDS_SurfData)& Ref,
1776 Handle(ChFiDS_SurfData)& Item)
1779 Standard_Failure::Raise("InsertAfter : twice the same surfdata.");
1781 ChFiDS_SequenceOfSurfData& Seq =
1782 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1784 if (Seq.IsEmpty() || Ref.IsNull()) {
1787 for (Standard_Integer i = 1; i <= Seq.Length(); i++) {
1788 if (Seq.Value(i) == Ref) {
1789 Seq.InsertAfter(i,Item);
1795 //=======================================================================
1796 //function : RemoveSD
1798 //=======================================================================
1800 static void RemoveSD (Handle(ChFiDS_Stripe)& Stripe,
1801 Handle(ChFiDS_SurfData)& Prev,
1802 Handle(ChFiDS_SurfData)& Next)
1804 ChFiDS_SequenceOfSurfData& Seq =
1805 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1806 if(Seq.IsEmpty()) return;
1807 Standard_Integer iprev = 0, inext = 0;
1808 for (Standard_Integer i = 1; i <= Seq.Length(); i++) {
1809 if (Seq.Value(i) == Prev) iprev = i + 1;
1810 if (Seq.Value(i) == Next) { inext = i - 1; break; }
1812 if(Prev.IsNull()) iprev = 1;
1813 if(Next.IsNull()) inext = Seq.Length();
1814 if(iprev <= inext) Seq.Remove(iprev,inext);
1817 //=======================================================================
1818 //function : InsertBefore
1819 //purpose : Insert item before ref in Seq. If ref is null, the item is
1820 // inserted in the queue.
1821 //=======================================================================
1823 static void InsertBefore (Handle(ChFiDS_Stripe)& Stripe,
1824 Handle(ChFiDS_SurfData)& Ref,
1825 Handle(ChFiDS_SurfData)& Item)
1828 Standard_Failure::Raise("InsertBefore : twice the same surfdata.");
1830 ChFiDS_SequenceOfSurfData& Seq =
1831 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1833 if (Seq.IsEmpty() || Ref.IsNull()) {
1836 for (Standard_Integer i = 1; i <= Seq.Length(); i++) {
1837 if (Seq.Value(i) == Ref) {
1838 Seq.InsertBefore(i,Item);
1845 //=======================================================================
1846 //function : PerformSetOfSurfOnElSpine
1848 //=======================================================================
1850 void ChFi3d_Builder::PerformSetOfSurfOnElSpine
1851 (const Handle(ChFiDS_HElSpine)& HGuide,
1852 Handle(ChFiDS_Stripe)& Stripe,
1853 Handle(BRepTopAdaptor_TopolTool)& It1,
1854 Handle(BRepTopAdaptor_TopolTool)& It2,
1855 const Standard_Boolean Simul)
1858 OSD_Chronometer ch1;
1861 ChFiDS_ElSpine& Guide = HGuide->ChangeCurve();
1862 Standard_Real wf = Guide.FirstParameter();
1863 Standard_Real wl = Guide.LastParameter();
1864 Standard_Real locfleche = (wl - wf) * fleche;
1865 Standard_Real wfsav = wf, wlsav = wl;
1866 if (!Guide.IsPeriodic())
1868 //Now the ElSpine is artificially extended to help rsnld.
1869 Standard_Real prab = 0.01;
1870 Guide.FirstParameter(wf-prab*(wl-wf));
1871 Guide.LastParameter (wl+prab*(wl-wf));
1873 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
1874 Standard_Integer ii, nbed = Spine->NbEdges();
1875 Standard_Real lastedlastp = Spine->LastParameter(nbed);
1877 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
1879 Handle(ChFiDS_SurfData) ref = Guide.Previous();
1880 Handle(ChFiDS_SurfData) refbis, SD;
1881 Handle(ChFiDS_SurfData) raf = Guide.Next();
1882 RemoveSD(Stripe,ref,raf);
1884 Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface();
1885 Handle(BRepAdaptor_HSurface) HS2 = new BRepAdaptor_HSurface();
1886 Handle(BRepAdaptor_HSurface) HS3, HS4;
1887 Handle(BRepAdaptor_HSurface) HSref1 = new BRepAdaptor_HSurface();
1888 Handle(BRepAdaptor_HSurface) HSref2 = new BRepAdaptor_HSurface();
1889 Handle(BRepAdaptor_HCurve2d) HC1,HC2;
1890 Handle(BRepAdaptor_HCurve2d) HCref1 = new BRepAdaptor_HCurve2d();
1891 Handle(BRepAdaptor_HCurve2d) HCref2 = new BRepAdaptor_HCurve2d();
1892 Standard_Boolean decroch1 = Standard_False, decroch2 = Standard_False;
1893 Standard_Boolean RecP1 = Standard_False, RecS1 = Standard_False, RecRst1 = Standard_False, obstacleon1 = Standard_False;
1894 Standard_Boolean RecP2 = Standard_False, RecS2 = Standard_False, RecRst2 = Standard_False, obstacleon2 = Standard_False;
1895 gp_Pnt2d pp1,pp2,pp3,pp4;
1896 Standard_Real w1 = 0.,w2 = 0.;
1897 math_Vector Soldep(1,4);
1898 math_Vector SoldepCS(1,3);
1899 math_Vector SoldepCC(1,2);
1901 // Restore a neighboring KPart.
1902 // If no neighbor calculation start point.
1903 Standard_Boolean forward = Standard_True;
1904 Standard_Boolean Inside = Standard_False;
1905 Standard_Real First = wf;
1906 Standard_Real Last = wl;
1907 Standard_Boolean Ok1 = 1,Ok2 = 1;
1908 // Restore the next KPart if it exists
1910 if(ref.IsNull() && raf.IsNull()){
1911 //sinon solution approchee.
1912 Inside = Standard_True;
1915 ChFi3d_InitChron(ch1);// init perf for StartSol
1918 StartSol(Stripe,HGuide,HS1,HS2,It1,It2,pp1,pp2,First);
1921 ChFi3d_ResultChron(ch1,t_startsol); // result perf for StartSol
1925 if(Guide.IsPeriodic()) {
1926 Last = First - Guide.Period();
1927 Guide.SaveFirstParameter();
1928 Guide.FirstParameter(Last);
1929 Guide.SaveLastParameter();
1930 Guide.LastParameter (First * 1.1);//Extension to help rsnld.
1934 if(!Spine->IsPeriodic() && (wl - lastedlastp > -tolesp)){
1935 Vref = Spine->LastVertex();
1938 if(!Spine->IsPeriodic() && (wf < tolesp)){
1939 Vref = Spine->FirstVertex();
1942 forward = Standard_False;
1943 First = wl; Last = Guide.FirstParameter();
1947 ChFi3d_InitChron(ch1);// init perf for startsol
1951 Ok1 = StartSol(Spine,HS1,pp1,HC1,w1,ref,!forward,1,
1952 HSref1,HCref1,RecP1,RecS1,RecRst1,obstacleon1,
1953 HS3,pp3,decroch1,Vref);
1954 Ok2 = StartSol(Spine,HS2,pp2,HC2,w2,ref,!forward,2,
1955 HSref2,HCref2, RecP2,RecS2,RecRst2,obstacleon2,
1956 HS4,pp4,decroch2,Vref);
1961 ChFi3d_ResultChron(ch1,t_startsol); // result perf for startsol
1965 if(Ok1 == 1 && Ok2 == 1) {
1966 if(forward) Guide.FirstParameter(wf);
1967 else Guide.LastParameter(wl);
1970 Standard_Boolean fini = Standard_False;
1971 Standard_Boolean complete = Inside;
1972 if(!Guide.IsPeriodic()){
1973 Standard_Integer indf = Spine->Index(wf);
1974 Standard_Integer indl = Spine->Index(wl,0);
1975 if(Spine->IsPeriodic() && (indl < indf)) indl += nbed;
1978 // No Max at the touch : 20 points by edge at average without
1979 // counting the extensions.
1981 Standard_Real bidf = wf, bidl = wl;
1982 if(!Spine->IsPeriodic()) {
1984 bidl = Min(wl,Spine->LastParameter(Spine->NbEdges()));
1985 // PMN 20/07/98 : Attention in case if there is only extension
1986 if ((bidl-bidf) < 0.01 * Spine->LastParameter(Spine->NbEdges())) {
1991 Standard_Real MaxStep = (bidl-bidf)*0.05/nbed;
1992 Standard_Real Firstsov = 0.;
1993 Standard_Boolean intf = 0, intl = 0;
1995 // are these the ends (no extension on periodic).
1997 if(!Spine->IsPeriodic()){
1998 if(wf < tolesp && (complete == Inside)){
1999 if(Spine->FirstStatus() == ChFiDS_OnSame) intf = 2;
2002 if(Spine->IsTangencyExtremity(Standard_True)){
2004 Guide.FirstParameter(wfsav);
2006 if(wl - lastedlastp > -tolesp){
2007 if(Spine->LastStatus() == ChFiDS_OnSame) intl = 2;
2010 if(Spine->IsTangencyExtremity(Standard_False)){
2012 Guide.LastParameter(wlsav);
2015 if(intf && !forward) Vref = Spine->FirstVertex();
2016 if(intl && forward) Vref = Spine->LastVertex();
2020 ChFi3d_InitChron(ch1);// init perf for StartSol
2023 Ok1 = StartSol(Spine,HS1,pp1,HC1,w1,ref,!forward,1,
2024 HSref1,HCref1, RecP1,RecS1,RecRst1,obstacleon1,
2025 HS3,pp3,decroch1,Vref);
2026 Ok2 = StartSol(Spine,HS2,pp2,HC2,w2,ref,!forward,2,
2027 HSref2,HCref2, RecP2,RecS2,RecRst2,obstacleon2,
2028 HS4,pp4,decroch2,Vref);
2031 ChFi3d_ResultChron(ch1,t_startsol); // result perf for StartSol
2036 // No more connected faces. Construction of the tangent plane to continue the path
2037 // till the output on the other face.
2038 if ((!Ok1 && HC1.IsNull()) || (!Ok2 && HC2.IsNull())) {
2039 if ((intf && !forward) || (intl && forward)) {
2040 if (!Ok1) ChFi3d_BuildPlane (DStr,HS1,pp1,ref,!forward,1);
2041 if (!Ok2) ChFi3d_BuildPlane (DStr,HS2,pp2,ref,!forward,2);
2043 else if(intl) intl = 5;
2044 if(forward) Guide.FirstParameter(wf);
2045 else Guide.LastParameter(wl);
2047 else Standard_Failure::Raise("PerformSetOfSurfOnElSpine : Chaining is impossible.");
2050 // Definition of the domain of path It1, It2
2051 It1->Initialize(HS1);
2052 It2->Initialize(HS2);
2054 // Calculate one (several if singularity) SurfaData
2055 SD = new ChFiDS_SurfData();
2056 ChFiDS_SequenceOfSurfData SeqSD;
2059 if(obstacleon1 && obstacleon2){
2060 TopAbs_Orientation Or1 = HSref1->ChangeSurface().Face().Orientation();
2061 TopAbs_Orientation Or2 = HSref2->ChangeSurface().Face().Orientation();
2062 Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2,
2063 Stripe->OrientationOnFace1(),
2064 Stripe->OrientationOnFace2(),
2068 // Calculate the criterion of Choice edge / edge
2069 if (Choix%2 == 0) Choix = 4;
2072 SoldepCC(1) = w1; SoldepCC(2) = w2;
2074 SimulSurf(SD,HGuide,Spine,Choix,
2075 HS1,It1,HC1,HSref1,HCref1,decroch1,Or1,
2076 HS2,It2,HC2,HSref2,HCref2,decroch2,Or2,
2077 locfleche,tolesp,First,Last,Inside,Inside,forward,
2078 RecP1,RecRst1,RecP2,RecRst2,SoldepCC);
2082 ChFi3d_InitChron(ch1); // init perf for PerformSurf
2084 PerformSurf(SeqSD,HGuide,Spine,Choix,
2085 HS1,It1,HC1,HSref1,HCref1,decroch1,Or1,
2086 HS2,It2,HC2,HSref2,HCref2,decroch2,Or2,
2087 MaxStep,locfleche,tolesp,First,Last,Inside,Inside,forward,
2088 RecP1,RecRst1,RecP2,RecRst2,SoldepCC);
2090 ChFi3d_ResultChron(ch1,t_performsurf); //result perf for PerformSurf
2093 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2094 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2096 else if (obstacleon1){
2097 TopAbs_Orientation Or1 = HSref1->ChangeSurface().Face().Orientation();
2098 TopAbs_Orientation Or2 = HS2->ChangeSurface().Face().Orientation();
2099 Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2,
2100 Stripe->OrientationOnFace1(),
2101 Stripe->OrientationOnFace2(),
2103 if(Choix%2 == 1) Choix++;
2105 SoldepCS(3) = w1; SoldepCS(1) = pp2.X(); SoldepCS(2) = pp2.Y();
2107 SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,HC1,HSref1,HCref1,decroch1,
2108 HS2,It2,Or2,locfleche,tolesp,First,Last,
2109 Inside,Inside,forward,RecP1,RecS2,RecRst1,SoldepCS);
2113 ChFi3d_InitChron(ch1); // init perf for PerformSurf
2115 PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,HC1,HSref1,HCref1,decroch1,
2116 HS2,It2,Or2,MaxStep,locfleche,tolesp,First,Last,
2117 Inside,Inside,forward,RecP1,RecS2,RecRst1,SoldepCS);
2119 ChFi3d_ResultChron(ch1,t_performsurf);//result perf for PerformSurf
2122 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2123 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2126 else if (obstacleon2){
2127 TopAbs_Orientation Or1 = HS1->ChangeSurface().Face().Orientation();
2128 TopAbs_Orientation Or2 = HSref2->ChangeSurface().Face().Orientation();
2129 Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2,
2130 Stripe->OrientationOnFace1(),
2131 Stripe->OrientationOnFace2(),
2133 SoldepCS(3) = w2; SoldepCS(1) = pp1.X(); SoldepCS(2) = pp1.Y();
2135 SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,Or1,
2136 HS2,It2,HC2,HSref2,HCref2,decroch2,locfleche,tolesp,
2137 First,Last,Inside,Inside,forward,RecP2,RecS1,RecRst2,SoldepCS);
2141 ChFi3d_InitChron(ch1); // init perf for PerformSurf
2143 PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,Or1,
2144 HS2,It2,HC2,HSref2,HCref2,decroch2,MaxStep,locfleche,tolesp,
2145 First,Last,Inside,Inside,forward,RecP2,RecS1,RecRst2,SoldepCS);
2147 ChFi3d_ResultChron(ch1,t_performsurf); //result perf for PerformSurf
2150 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2151 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2155 CallPerformSurf(Stripe, Simul, SeqSD, SD,
2157 HS1, HS3, pp1, pp3, It1,
2158 HS2, HS4, pp2, pp4, It2,
2159 MaxStep,locfleche,tolesp,
2160 First,Last,Inside,Inside,forward,
2161 RecS1,RecS2,Soldep,intf,intl,
2163 decroch1 = decroch2 = 0;
2166 if(!done) { // Case of fail
2167 if ((!Ok1 && !obstacleon1) || (!Ok2 && !obstacleon2)) {
2168 //Fail in a part of extension is not serious
2170 done = Standard_True;
2171 Inside = Standard_False;
2172 if (forward) intl = 1;
2175 else { // Otherwise invalidation of the stripe.
2176 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
2177 Standard_Failure::Raise("CallPerformSurf : Path failed!");
2184 for (ii=1; ii<=SeqSD.Length(); ii++) {
2186 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2187 if(obstacleon1) SD->SetIndexOfC1(DStr.AddShape(HC1->ChangeCurve2d().Edge()));
2188 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2189 if(obstacleon2) SD->SetIndexOfC2(DStr.AddShape(HC2->ChangeCurve2d().Edge()));
2190 InsertAfter (Stripe, refbis, SD);
2195 for (ii=SeqSD.Length(); ii>=1; ii--) {
2197 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2198 if(obstacleon1) SD->SetIndexOfC1(DStr.AddShape(HC1->ChangeCurve2d().Edge()));
2199 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2200 if(obstacleon2) SD->SetIndexOfC2(DStr.AddShape(HC2->ChangeCurve2d().Edge()));
2201 InsertBefore(Stripe,refbis,SD);
2206 if (!Ok1 && !obstacleon1)
2207 // clean infos on the plane of extension.
2208 ChFi3d_Purge (Stripe,SD,ref->Vertex(!forward,1),!forward,1,intf,intl);
2210 if (!Ok2 && !obstacleon2)
2211 // clean infos on the plane of extension.
2212 ChFi3d_Purge (Stripe,SD,ref->Vertex(!forward,2),!forward,2,intf,intl);
2214 // The end. The reference is changed.
2218 if(Inside){// There are starting solutions for the next.
2219 Inside = Standard_False;
2221 if(Guide.IsPeriodic()) {
2222 complete = Standard_False;
2223 wf = Guide.FirstParameter();
2224 wl = Guide.LastParameter();
2228 fini = ((wl - Last) <= 10.*tolesp ||
2229 (intl && !(obstacleon1 || obstacleon2))); //General case
2231 if (!fini && Guide.IsPeriodic() &&
2232 ((wl - Last)< Guide.Period()*1.e-3)) {
2233 // It is tested if reframing of extremes is done at the same edge
2235 Handle(ChFiDS_SurfData) thefirst, thelast;
2236 thefirst = Stripe->SetOfSurfData()->Sequence().First();
2237 thelast = Stripe->SetOfSurfData()->Sequence().Last();
2239 if (thefirst->VertexFirstOnS1().IsOnArc() &&
2240 thelast->VertexLastOnS1().IsOnArc())
2241 fini = thefirst->VertexFirstOnS1().Arc().IsSame
2242 (thelast->VertexLastOnS1().Arc());
2244 thefirst->VertexFirstOnS2().IsOnArc() &&
2245 thelast->VertexLastOnS2().IsOnArc())
2246 fini = thefirst->VertexFirstOnS2().Arc().IsSame
2247 (thelast->VertexLastOnS2().Arc());
2250 return; //It is ended!
2253 if(fini && complete) {
2254 // restart in the opposite direction.
2255 ref = Stripe->SetOfSurfData()->Sequence().First();
2256 forward = Standard_False;
2257 fini = Standard_False;
2266 fini = ((First - wf) <= 10.*tolesp ||
2267 (intf && !(obstacleon1 || obstacleon2)));
2268 complete = Standard_False;
2272 // The initial state is restored
2273 if(!Guide.IsPeriodic()){
2274 Guide.FirstParameter(wfsav);
2275 Guide.LastParameter (wlsav);
2280 //=======================================================================
2281 //function : PerformSetOfKPart
2283 //=======================================================================
2285 void ChFi3d_Builder::PerformSetOfKPart(Handle(ChFiDS_Stripe)& Stripe,
2286 const Standard_Boolean Simul)
2288 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
2289 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
2290 Handle(BRepAdaptor_HSurface) HS1,HS2;
2291 TopAbs_Orientation Or1,Or2,RefOr1,RefOr2;
2292 Standard_Integer RefChoix;
2294 // initialization of the stripe.
2296 Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData();
2297 HData = new ChFiDS_HData();
2298 ChFiDS_SequenceOfSurfData& SeqSurf = HData->ChangeSequence();
2300 StripeOrientations(Spine,RefOr1,RefOr2,RefChoix);
2301 Stripe->OrientationOnFace1(RefOr1);
2302 Stripe->OrientationOnFace2(RefOr2);
2303 Stripe->Choix(RefChoix);
2305 Handle(BRepTopAdaptor_TopolTool) It1 = new BRepTopAdaptor_TopolTool();
2306 Handle(BRepTopAdaptor_TopolTool) It2 = new BRepTopAdaptor_TopolTool();
2308 Standard_Real WFirst,WLast = 0.;
2309 gp_Vec TFirst,TLast,TEndPeriodic;
2310 gp_Pnt PFirst,PLast,PEndPeriodic;
2311 Standard_Boolean intf = 0, intl = 0;
2313 Handle(ChFiDS_HElSpine) CurrentHE = new ChFiDS_HElSpine();
2314 Spine->D1(Spine->FirstParameter(),PFirst,TFirst);
2315 CurrentHE->ChangeCurve().FirstParameter(Spine->FirstParameter());
2316 CurrentHE->ChangeCurve().SetFirstPointAndTgt(PFirst,TFirst);
2318 Standard_Boolean YaKPart = Standard_False;
2319 Standard_Integer iedgelastkpart = 0;
2321 Standard_Real WStartPeriodic = 0.;
2322 Standard_Real WEndPeriodic = Spine->LastParameter(Spine->NbEdges());
2323 Spine->D1(WEndPeriodic,PEndPeriodic,TEndPeriodic);
2325 // Construction of particular cases.
2327 for (Standard_Integer iedge = 1; iedge <= Spine->NbEdges(); iedge++){
2329 ConexFaces(Spine,iedge,RefChoix,HS1,HS2);
2331 if (ChFi3d_KParticular(Spine,iedge,HS1->ChangeSurface(),HS2->ChangeSurface())) {
2332 intf = ((iedge == 1) && !Spine->IsPeriodic());
2333 intl = ((iedge == Spine->NbEdges()) && !Spine->IsPeriodic());
2334 Or1 = HS1->ChangeSurface().Face().Orientation();
2335 Or2 = HS2->ChangeSurface().Face().Orientation();
2336 ChFi3d::NextSide(Or1,Or2,RefOr1,RefOr2,RefChoix);
2337 It1->Initialize(HS1);
2338 It2->Initialize(HS2);
2340 Handle(ChFiDS_SurfData) SD = new ChFiDS_SurfData();
2341 ChFiDS_SequenceOfSurfData LSD;
2343 if(!ChFiKPart_ComputeData::Compute(DStr,SD,HS1,HS2,Or1,Or2,Spine,iedge)){
2345 cout<<"failed calculation KPart"<<endl;
2348 else if(!SplitKPart(SD,LSD,Spine,iedge,HS1,It1,HS2,It2,intf,intl)){
2350 cout<<"failed calculation KPart"<<endl;
2354 else iedgelastkpart = iedge;
2355 if(Spine->IsPeriodic()){//debug provisory for SD that arrive in desorder.
2356 Standard_Integer nbsd = LSD.Length();
2357 Standard_Real period = Spine->Period();
2358 Standard_Real wfp = WStartPeriodic, wlp = WEndPeriodic;
2359 // modified by NIZHNY-EAP Thu Nov 25 12:57:53 1999 ___BEGIN___
2360 if(!YaKPart && nbsd>0){
2362 // modified by NIZHNY-EAP Thu Nov 25 12:57:57 1999 ___END___
2363 Handle(ChFiDS_SurfData) firstSD = LSD.ChangeValue(1);
2364 Standard_Real wwf = firstSD->FirstSpineParam();
2365 Standard_Real wwl = firstSD->LastSpineParam();
2366 wwf = ChFi3d_InPeriod(wwf,wfp,wlp,tolesp);
2367 wwl = ChFi3d_InPeriod(wwl,wfp,wlp,tolesp);
2368 if (wwl <= wwf + tolesp) wwl += period;
2372 for(Standard_Integer j = 1; j < nbsd; j++){
2373 Handle(ChFiDS_SurfData) jSD = LSD.Value(j);
2374 for(Standard_Integer k = j+1; k <= nbsd; k++){
2375 Handle(ChFiDS_SurfData) kSD = LSD.Value(k);
2376 Standard_Real jwf = jSD->FirstSpineParam();
2377 jwf = ChFi3d_InPeriod(jwf,wfp,wlp,tolesp);
2378 Standard_Real kwf = kSD->FirstSpineParam();
2379 kwf = ChFi3d_InPeriod(kwf,wfp,wlp,tolesp);
2381 LSD.SetValue(j,kSD);
2382 LSD.SetValue(k,jSD);
2387 TColStd_ListOfInteger li;
2388 for(Standard_Integer j = 1; j <= LSD.Length(); j++){
2389 Handle(ChFiDS_SurfData)& curSD = LSD.ChangeValue(j);
2390 if(Simul) SimulKPart(curSD);
2391 SeqSurf.Append(curSD);
2392 if(!Simul) li.Append(curSD->Surf());
2393 WFirst = LSD.Value(j)->FirstSpineParam();
2394 WLast = LSD.Value(j)->LastSpineParam();
2395 if(Spine->IsPeriodic()){
2396 WFirst = ChFi3d_InPeriod(WFirst,WStartPeriodic,WEndPeriodic,tolesp);
2397 WLast = ChFi3d_InPeriod(WLast ,WStartPeriodic,WEndPeriodic,tolesp);
2398 if (WLast <= WFirst + tolesp) WLast+= Spine->Period();
2400 TgtKP(LSD.Value(j),Spine,iedge,1,PFirst,TFirst);
2401 TgtKP(LSD.Value(j),Spine,iedge,0,PLast,TLast);
2403 // Determine the sections to approximate
2405 if(Spine->IsPeriodic()){
2406 WStartPeriodic = WFirst;
2407 WEndPeriodic = WStartPeriodic + Spine->Period();
2408 WLast = ElCLib::InPeriod(WLast,WStartPeriodic,WEndPeriodic);
2409 if (WLast <= WFirst + tolesp) WLast+= Spine->Period();
2410 PEndPeriodic = PFirst;
2411 TEndPeriodic = TFirst;
2412 Spine->SetFirstParameter(WStartPeriodic);
2413 Spine->SetLastParameter(WEndPeriodic);
2415 else if(!intf || (iedge > 1)){
2416 // start section -> first KPart
2417 // update of extension.
2418 Spine->SetFirstTgt(Min(0.,WFirst));
2419 CurrentHE->ChangeCurve().LastParameter (WFirst);
2420 CurrentHE->ChangeCurve().SetLastPointAndTgt(PFirst,TFirst);
2421 Spine->AppendElSpine(CurrentHE);
2422 CurrentHE->ChangeCurve().ChangeNext() = LSD.Value(j);
2423 CurrentHE = new ChFiDS_HElSpine();
2425 CurrentHE->ChangeCurve().FirstParameter(WLast);
2426 CurrentHE->ChangeCurve().SetFirstPointAndTgt(PLast,TLast);
2427 CurrentHE->ChangeCurve().ChangePrevious() = LSD.Value(j);
2428 YaKPart = Standard_True;
2431 if (WFirst - CurrentHE->FirstParameter() > tolesp) {
2432 // section between two KPart
2433 CurrentHE->ChangeCurve().LastParameter(WFirst);
2434 CurrentHE->ChangeCurve().SetLastPointAndTgt(PFirst,TFirst);
2435 Spine->AppendElSpine(CurrentHE);
2436 CurrentHE->ChangeCurve().ChangeNext() = LSD.Value(j);
2437 CurrentHE = new ChFiDS_HElSpine();
2439 CurrentHE->ChangeCurve().FirstParameter(WLast);
2440 CurrentHE->ChangeCurve().SetFirstPointAndTgt(PLast,TLast);
2441 CurrentHE->ChangeCurve().ChangePrevious() = LSD.Value(j);
2444 if(!li.IsEmpty()) myEVIMap.Bind(Spine->Edges(iedge),li);
2448 if (!intl || (iedgelastkpart < Spine->NbEdges())) {
2449 // section last KPart(or start of the spine) -> End of the spine.
2450 // update of the extension.
2452 if(Spine->IsPeriodic()){
2453 if(WEndPeriodic - WLast > tolesp){
2454 CurrentHE->ChangeCurve().LastParameter(WEndPeriodic);
2455 CurrentHE->ChangeCurve().SetLastPointAndTgt(PEndPeriodic,TEndPeriodic);
2456 if(!YaKPart) CurrentHE->ChangeCurve().SetPeriodic(Standard_True);
2457 Spine->AppendElSpine(CurrentHE);
2461 Spine->D1(Spine->LastParameter(),PLast,TLast);
2462 Spine->SetLastTgt(Max(Spine->LastParameter(Spine->NbEdges()),
2464 if (Spine->LastParameter() - WLast > tolesp) {
2465 CurrentHE->ChangeCurve().LastParameter(Spine->LastParameter());
2466 CurrentHE->ChangeCurve().SetLastPointAndTgt(PLast,TLast);
2467 Spine->AppendElSpine(CurrentHE);
2472 ChFiDS_ListOfHElSpine& ll = Spine->ChangeElSpines();
2473 ChFiDS_ListIteratorOfListOfHElSpine ILES(ll);
2474 for ( ; ILES.More(); ILES.Next()) {
2476 if(ChFi3d_GettraceCHRON()) elspine.Start();
2478 ChFi3d_PerformElSpine(ILES.Value(),Spine,myConti,tolesp);
2480 if(ChFi3d_GettraceCHRON()) { elspine.Stop(); }
2483 Spine->SplitDone(Standard_True);
2486 static Standard_Real ChFi3d_BoxDiag(const Bnd_Box& box)
2488 Standard_Real a,b,c,d,e,f;
2489 box.Get(a,b,c,d,e,f);
2492 Standard_Real diag = sqrt(d + e + f);
2496 //=======================================================================
2497 //function : PerformSetOfKGen
2499 //=======================================================================
2501 void ChFi3d_Builder::PerformSetOfKGen(Handle(ChFiDS_Stripe)& Stripe,
2502 const Standard_Boolean Simul)
2504 Handle(BRepTopAdaptor_TopolTool) It1 = new BRepTopAdaptor_TopolTool();
2505 Handle(BRepTopAdaptor_TopolTool) It2 = new BRepTopAdaptor_TopolTool();
2506 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
2507 ChFiDS_ListOfHElSpine& ll = Spine->ChangeElSpines();
2508 ChFiDS_ListIteratorOfListOfHElSpine ILES(ll);
2509 for ( ; ILES.More(); ILES.Next()) {
2511 if(ChFi3d_GettraceCHRON()) { chemine.Start(); }
2513 PerformSetOfSurfOnElSpine(ILES.Value(),Stripe,It1,It2,Simul);
2515 if(ChFi3d_GettraceCHRON()) chemine.Stop();
2519 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
2520 Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData();
2521 ChFiDS_SequenceOfSurfData& SeqSurf = HData->ChangeSequence();
2522 Standard_Integer len = SeqSurf.Length();
2523 Standard_Integer last = len, i;
2524 Standard_Boolean periodic = Spine->IsPeriodic();
2525 if(periodic) last++;
2526 // It is attempted to reprocess the squares that bore.
2527 for(i = 1; i <= len; i++){
2528 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2529 Standard_Boolean tw1 = cursd->TwistOnS1();
2530 Standard_Boolean tw2 = cursd->TwistOnS2();
2531 Handle(ChFiDS_SurfData) prevsd, nextsd;
2532 Standard_Integer iprev = i-1;
2534 if(periodic) iprev = len;
2536 Standard_Integer inext = i + 1;
2538 if(periodic) inext = 1;
2542 // For the moment only the surfaces where the twist is
2543 // detected at the path are corrected, it is necessary to control
2544 // more subtly the ugly traces (size, curvature, inflexion... )
2545 if(!tw1 && !tw2) continue;
2547 // It is decided (fairly at random) if the extended surface is ready for the filling.
2548 ChFiDS_FaceInterference& intf1 = cursd->ChangeInterferenceOnS1();
2549 ChFiDS_FaceInterference& intf2 = cursd->ChangeInterferenceOnS2();
2550 Standard_Integer cursurf1 = cursd->IndexOfS1();
2551 Standard_Integer cursurf2 = cursd->IndexOfS2();
2552 ChFiDS_CommonPoint& cpd1 = cursd->ChangeVertexFirstOnS1();
2553 ChFiDS_CommonPoint& cpd2 = cursd->ChangeVertexFirstOnS2();
2554 ChFiDS_CommonPoint& cpf1 = cursd->ChangeVertexLastOnS1();
2555 ChFiDS_CommonPoint& cpf2 = cursd->ChangeVertexLastOnS2();
2556 const gp_Pnt& pd1 = cpd1.Point();
2557 const gp_Pnt& pd2 = cpd2.Point();
2558 const gp_Pnt& pf1 = cpf1.Point();
2559 const gp_Pnt& pf2 = cpf2.Point();
2560 Standard_Real ddeb = pd1.Distance(pd2);
2561 Standard_Real dfin = pf1.Distance(pf2);
2562 Standard_Real don1 = pd1.Distance(pf1);
2563 Standard_Real don2 = pd2.Distance(pf2);
2564 Standard_Boolean possibleon1 = (don1 < 2*(ddeb + dfin));
2565 Standard_Boolean possibleon2 = (don2 < 2*(ddeb + dfin));
2566 if((tw1 && !possibleon1) || (tw2 && !possibleon2)) {
2567 Spine->SetErrorStatus(ChFiDS_TwistedSurface);
2568 Standard_Failure::Raise("adjustment by reprocessing the non-written points");
2571 // It is checked if there are presentable neighbors
2572 Standard_Boolean yaprevon1 = 0, yaprevon2 = 0;
2573 Standard_Boolean samesurfon1 = 0, samesurfon2 = 0;
2575 prevsd = SeqSurf.ChangeValue(iprev);
2576 yaprevon1 = !prevsd->TwistOnS1();
2577 samesurfon1 = (prevsd->IndexOfS1() == cursurf1);
2578 yaprevon2 = !prevsd->TwistOnS2();
2579 samesurfon2 = (prevsd->IndexOfS2() == cursurf2);
2581 Standard_Boolean yanexton1 = 0, yanexton2 = 0;
2583 nextsd = SeqSurf.ChangeValue(inext);
2584 yanexton1 = !nextsd->TwistOnS1();
2585 if(samesurfon1) samesurfon1 = (nextsd->IndexOfS1() == cursurf1);
2586 yanexton2 = !nextsd->TwistOnS2();
2587 if(samesurfon2) samesurfon2 = (nextsd->IndexOfS2() == cursurf2);
2589 // A contour of filling is constructed
2590 Handle(Geom2d_Curve) PC1 = intf1.PCurveOnFace();
2591 Handle(Geom2d_Curve) PC2 = intf2.PCurveOnFace();
2592 Handle(BRepAdaptor_HSurface) S1 = new BRepAdaptor_HSurface();
2593 TopoDS_Face F1 = TopoDS::Face(DStr.Shape(cursurf1));
2594 S1->ChangeSurface().Initialize(F1);
2595 Handle(BRepAdaptor_HSurface) S2 = new BRepAdaptor_HSurface();
2596 TopoDS_Face F2 = TopoDS::Face(DStr.Shape(cursurf2));
2597 S2->ChangeSurface().Initialize(F2);
2598 Handle(GeomFill_Boundary) Bdeb,Bfin,Bon1,Bon2;
2599 Standard_Boolean pointuon1 = 0, pointuon2 = 0;
2601 if(!yaprevon1 || !yanexton1){
2602 Spine->SetErrorStatus(ChFiDS_TwistedSurface);
2603 Standard_Failure::Raise
2604 ("adjustment by reprocessing the non-written points: no neighbor");
2606 ChFiDS_FaceInterference& previntf1 = prevsd->ChangeInterferenceOnS1();
2607 ChFiDS_FaceInterference& nextintf1 = nextsd->ChangeInterferenceOnS1();
2608 Standard_Real prevpar1 = previntf1.LastParameter();
2609 Standard_Real nextpar1 = nextintf1.FirstParameter();
2611 // It is checked if it is possible to intersect traces of neighbors
2612 // to create a sharp end.
2613 Handle(Geom2d_Curve) pcprev1 = previntf1.PCurveOnFace();
2614 Handle(Geom2d_Curve) pcnext1 = nextintf1.PCurveOnFace();
2615 Standard_Real nprevpar1,nnextpar1;
2617 // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 Begin
2618 // if(ChFi3d_IntTraces(prevsd,prevpar1,nprevpar1,1,1,
2619 // nextsd,nextpar1,nnextpar1,1,-1,p2d)){
2620 if(ChFi3d_IntTraces(prevsd,prevpar1,nprevpar1,1,1,
2621 nextsd,nextpar1,nnextpar1,1,-1,p2d,
2622 Standard_False, Standard_True)){
2623 // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 End
2624 previntf1.SetLastParameter(nprevpar1);
2625 nextintf1.SetFirstParameter(nnextpar1);
2630 gp_Pnt2d pdeb1,pfin1;
2631 gp_Vec2d vdeb1,vfin1;
2632 pcprev1->D1(prevpar1,pdeb1,vdeb1);
2633 pcnext1->D1(nextpar1,pfin1,vfin1);
2634 Bon1 = ChFi3d_mkbound(S1,PC1,-1,pdeb1,vdeb1,1,
2635 pfin1,vfin1,tolesp,2.e-4);
2639 //here the base is on 3D tangents of neighbors.
2640 const Handle(Geom_Curve)& c3dprev1 =
2641 DStr.Curve(previntf1.LineIndex()).Curve();
2642 const Handle(Geom_Curve)& c3dnext1 =
2643 DStr.Curve(nextintf1.LineIndex()).Curve();
2644 gp_Pnt Pdeb1, Pfin1;
2645 gp_Vec Vdeb1, Vfin1;
2646 c3dprev1->D1(prevpar1,Pdeb1,Vdeb1);
2647 c3dnext1->D1(nextpar1,Pfin1,Vfin1);
2648 gp_Pnt2d pdeb1,pfin1;
2649 Standard_Real pardeb1 = intf1.FirstParameter();
2650 Standard_Real parfin1 = intf1.LastParameter();
2651 pdeb1 = PC1->Value(pardeb1);
2652 pfin1 = PC1->Value(parfin1);
2653 Bon1 = ChFi3d_mkbound(S1,PC1,-1,pdeb1,Vdeb1,1,
2654 pfin1,Vfin1,tolesp,2.e-4);
2658 Bon1 = ChFi3d_mkbound(S1,PC1,tolesp,2.e-4);
2661 if(!yaprevon2 || !yanexton2){
2662 Standard_Failure::Raise
2663 ("adjustment by reprocessing the non-written points: no neighbor");
2665 ChFiDS_FaceInterference& previntf2 = prevsd->ChangeInterferenceOnS2();
2666 ChFiDS_FaceInterference& nextintf2 = nextsd->ChangeInterferenceOnS2();
2667 Standard_Real prevpar2 = previntf2.LastParameter();
2668 Standard_Real nextpar2 = nextintf2.FirstParameter();
2670 // It is checked if it is possible to intersect traces of neighbors
2671 // to create a sharp end.
2672 Handle(Geom2d_Curve) pcprev2 = previntf2.PCurveOnFace();
2673 Handle(Geom2d_Curve) pcnext2 = nextintf2.PCurveOnFace();
2674 Standard_Real nprevpar2,nnextpar2;
2676 // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 Begin
2677 // if(ChFi3d_IntTraces(prevsd,prevpar2,nprevpar2,2,1,
2678 // nextsd,nextpar2,nnextpar2,2,-1,p2d)){
2679 if(ChFi3d_IntTraces(prevsd,prevpar2,nprevpar2,2,1,
2680 nextsd,nextpar2,nnextpar2,2,-1,p2d,
2681 Standard_False, Standard_True)){
2682 // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 End
2683 previntf2.SetLastParameter(nprevpar2);
2684 nextintf2.SetFirstParameter(nnextpar2);
2689 gp_Pnt2d pdeb2,pfin2;
2690 gp_Vec2d vdeb2,vfin2;
2691 pcprev2->D1(prevpar2,pdeb2,vdeb2);
2692 pcnext2->D1(nextpar2,pfin2,vfin2);
2693 Bon2 = ChFi3d_mkbound(S2,PC2,-1,pdeb2,vdeb2,1,
2694 pfin2,vfin2,tolesp,2.e-4);
2698 //here the base is on 3D tangents of neighbors.
2699 const Handle(Geom_Curve)& c3dprev2 =
2700 DStr.Curve(previntf2.LineIndex()).Curve();
2701 const Handle(Geom_Curve)& c3dnext2 =
2702 DStr.Curve(nextintf2.LineIndex()).Curve();
2703 gp_Pnt Pdeb2, Pfin2;
2704 gp_Vec Vdeb2, Vfin2;
2705 c3dprev2->D1(prevpar2,Pdeb2,Vdeb2);
2706 c3dnext2->D1(nextpar2,Pfin2,Vfin2);
2707 gp_Pnt2d pdeb2,pfin2;
2708 Standard_Real pardeb2 = intf2.FirstParameter();
2709 Standard_Real parfin2 = intf2.LastParameter();
2710 pdeb2 = PC2->Value(pardeb2);
2711 pfin2 = PC2->Value(parfin2);
2712 Bon2 = ChFi3d_mkbound(S2,PC2,-1,pdeb2,Vdeb2,1,
2713 pfin2,Vfin2,tolesp,2.e-4);
2717 Bon2 = ChFi3d_mkbound(S2,PC2,tolesp,2.e-4);
2719 // The parameters of neighbor traces are updated, so
2720 // straight lines uv are pulled.
2721 const Handle(Geom_Surface)&
2722 sprev = DStr.Surface(prevsd->Surf()).Surface();
2723 const Handle(Geom_Surface)&
2724 snext = DStr.Surface(nextsd->Surf()).Surface();
2725 ChFiDS_FaceInterference& previntf1 = prevsd->ChangeInterferenceOnS1();
2726 ChFiDS_FaceInterference& nextintf1 = nextsd->ChangeInterferenceOnS1();
2727 ChFiDS_FaceInterference& previntf2 = prevsd->ChangeInterferenceOnS2();
2728 ChFiDS_FaceInterference& nextintf2 = nextsd->ChangeInterferenceOnS2();
2729 Handle(Geom2d_Curve) pcsprev1 = previntf1.PCurveOnSurf();
2730 Handle(Geom2d_Curve) pcsnext1 = nextintf1.PCurveOnSurf();
2731 Standard_Real prevpar1 = previntf1.LastParameter();
2732 Standard_Real nextpar1 = nextintf1.FirstParameter();
2733 Handle(Geom2d_Curve) pcsprev2 = previntf2.PCurveOnSurf();
2734 Handle(Geom2d_Curve) pcsnext2 = nextintf2.PCurveOnSurf();
2735 Standard_Real prevpar2 = previntf2.LastParameter();
2736 Standard_Real nextpar2 = nextintf2.FirstParameter();
2737 gp_Pnt2d pdebs1 = pcsprev1->Value(prevpar1);
2738 gp_Pnt2d pdebs2 = pcsprev2->Value(prevpar2);
2739 gp_Pnt2d pfins1 = pcsnext1->Value(nextpar1);
2740 gp_Pnt2d pfins2 = pcsnext2->Value(nextpar2);
2741 Bdeb = ChFi3d_mkbound(sprev,pdebs1,pdebs2,tolesp,2.e-4);
2742 Bfin = ChFi3d_mkbound(snext,pfins1,pfins2,tolesp,2.e-4);
2744 GeomFill_ConstrainedFilling fil(11,20);
2745 if(pointuon1) fil.Init(Bon2,Bfin,Bdeb,1);
2746 else if(pointuon2) fil.Init(Bon1,Bfin,Bdeb,1);
2747 else fil.Init(Bon1,Bfin,Bon2,Bdeb,1);
2749 ChFi3d_ReparamPcurv(0.,1.,PC1);
2750 ChFi3d_ReparamPcurv(0.,1.,PC2);
2751 Handle(Geom_Surface) newsurf = fil.Surface();
2755 char* pops = "newsurf";
2756 DrawTrSurf::Set(pops,newsurf);
2760 newsurf->VReverse(); // we return to direction 1 from 2;
2761 done = CompleteData(cursd,newsurf,S1,PC1,S2,PC2,
2762 F2.Orientation(),0,0,0,0,0);
2763 cursd->ChangeIndexOfS1(0);
2766 done = CompleteData(cursd,newsurf,S1,PC1,S2,PC2,
2767 F1.Orientation(),1,0,0,0,0);
2768 if(pointuon2) cursd->ChangeIndexOfS2(0);
2771 prevsd->ChangeVertexLastOnS1().SetPoint(cpd1.Point());
2772 nextsd->ChangeVertexFirstOnS1().SetPoint(cpf1.Point());
2775 prevsd->ChangeVertexLastOnS2().SetPoint(cpd2.Point());
2776 nextsd->ChangeVertexFirstOnS2().SetPoint(cpf2.Point());
2779 // The tolerance of points is updated.
2780 for(i = 1; i < last; i++){
2781 Standard_Integer j = i%len + 1;
2782 Standard_Integer curs1, curs2;
2783 Standard_Integer nexts1, nexts2;
2784 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2785 Handle(ChFiDS_SurfData)& nextsd = SeqSurf.ChangeValue(j);
2786 ChFiDS_CommonPoint& curp1 = cursd->ChangeVertexLastOnS1();
2787 ChFiDS_CommonPoint& nextp1 = nextsd->ChangeVertexFirstOnS1();
2788 if (cursd->IsOnCurve1()) curs1 = cursd->IndexOfC1();
2789 else curs1 = cursd->IndexOfS1();
2790 if (cursd->IsOnCurve2()) curs2 = cursd->IndexOfC2();
2791 else curs2 = cursd->IndexOfS2();
2792 Standard_Real tol1 = Max(curp1.Tolerance(),nextp1.Tolerance());
2793 ChFiDS_CommonPoint& curp2 = cursd->ChangeVertexLastOnS2();
2794 ChFiDS_CommonPoint& nextp2 = nextsd->ChangeVertexFirstOnS2();
2795 Standard_Real tol2 = Max(curp2.Tolerance(),nextp2.Tolerance());
2796 if (nextsd->IsOnCurve1()) nexts1 = nextsd->IndexOfC1();
2797 else nexts1 = nextsd->IndexOfS1();
2798 if (nextsd->IsOnCurve2()) nexts2 = nextsd->IndexOfC2();
2799 else nexts2 = nextsd->IndexOfS2();
2801 if(!curp1.IsOnArc() && nextp1.IsOnArc()){
2803 if ( (curs1 == nexts1) && !nextsd->IsOnCurve1())
2804 // Case when it is not possible to pass along the border without leaving
2805 ChangeTransition(nextp1, curp1, nexts1, myDS);
2807 else if(curp1.IsOnArc() && !nextp1.IsOnArc()) {
2809 if ( (curs1 == nexts1) && !cursd->IsOnCurve1())
2810 ChangeTransition(curp1, nextp1, curs1, myDS);
2813 if(!curp2.IsOnArc() && nextp2.IsOnArc()) {
2815 if ( (curs2 == nexts2) && !nextsd->IsOnCurve2())
2816 ChangeTransition(nextp2, curp2, curs2, myDS);
2818 else if(curp2.IsOnArc() && !nextp2.IsOnArc()){
2820 if ( (curs2 == nexts2) && !cursd->IsOnCurve2())
2821 ChangeTransition(curp2, nextp2, curs2, myDS);
2824 curp1.SetTolerance(tol1); nextp1.SetTolerance(tol1);
2825 curp2.SetTolerance(tol2); nextp2.SetTolerance(tol2);
2828 if(curp1.IsOnArc()){
2829 ChFi3d_EnlargeBox(curp1.Arc(),myEFMap(curp1.Arc()),curp1.ParameterOnArc(),b1);
2831 if(curp2.IsOnArc()){
2832 ChFi3d_EnlargeBox(curp2.Arc(),myEFMap(curp2.Arc()),curp2.ParameterOnArc(),b2);
2834 Handle(ChFiDS_Stripe) bidst;
2835 ChFi3d_EnlargeBox(DStr,bidst,cursd,b1,b2,0);
2836 ChFi3d_EnlargeBox(DStr,bidst,nextsd,b1,b2,1);
2837 tol1 = ChFi3d_BoxDiag(b1);
2838 tol2 = ChFi3d_BoxDiag(b2);
2839 curp1.SetTolerance(tol1); nextp1.SetTolerance(tol1);
2840 curp2.SetTolerance(tol2); nextp2.SetTolerance(tol2);
2842 // The connections edge/new faces are updated.
2843 for (ILES.Initialize(ll) ; ILES.More(); ILES.Next()) {
2844 const Handle(ChFiDS_HElSpine)& curhels = ILES.Value();
2845 const ChFiDS_ElSpine& curels = curhels->ChangeCurve();
2846 Standard_Real WF = curels.FirstParameter();
2847 Standard_Real WL = curels.LastParameter();
2848 Standard_Integer IF,IL;
2849 Standard_Real nwf = WF, nwl = WL;
2850 Standard_Real period = 0.;
2851 Standard_Integer nbed = Spine->NbEdges();
2853 period = Spine->Period();
2854 nwf = ElCLib::InPeriod(WF,-tolesp,period-tolesp);
2855 IF = Spine->Index(nwf,1);
2856 nwl = ElCLib::InPeriod(WL,tolesp,period+tolesp);
2857 IL = Spine->Index(nwl,0);
2858 if(nwl<nwf+tolesp) IL += nbed;
2861 IF = Spine->Index(WF,1);
2862 IL = Spine->Index(WL,0);
2866 Standard_Integer IFloc = IF;
2867 if(periodic) IFloc = (IF - 1)%nbed + 1;
2868 const TopoDS_Edge& Ej = Spine->Edges(IFloc);
2869 for(i = 1; i <= len; i++){
2870 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2871 Standard_Real fp = cursd->FirstSpineParam();
2872 Standard_Real lp = cursd->LastSpineParam();
2873 if(lp < WF+tolesp || fp > WL-tolesp) continue;
2874 if(!myEVIMap.IsBound(Ej)) {
2875 TColStd_ListOfInteger li;
2876 myEVIMap.Bind(Ej,li);
2878 myEVIMap.ChangeFind(Ej).Append(cursd->Surf());
2882 TColStd_Array1OfReal wv(IF,IL - 1);
2884 cout<<"length of the trajectory : "<<(WL-WF)<<endl;
2886 for(i = IF; i < IL; i++){
2887 Standard_Integer iloc = i;
2888 if(periodic) iloc = (i - 1)%nbed + 1;
2889 Standard_Real wi = Spine->LastParameter(iloc);
2890 if(periodic) wi = ElCLib::InPeriod(wi,WF,WF+period);
2891 gp_Pnt pv = Spine->Value(wi);
2893 gp_Pnt pelsapp = curels.Value(wi);
2894 Standard_Real distinit = pv.Distance(pelsapp);
2895 cout<<"distance psp/papp : "<<distinit<<endl;
2897 Extrema_LocateExtPC ext(pv,curels,wi,1.e-8);
2900 wv(i) = ext.Point().Parameter();
2904 cout<<"fail of projection vertex ElSpine!!!"<<endl;
2908 for(i = 1; i <= len; i++){
2909 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2910 Standard_Real fp = cursd->FirstSpineParam();
2911 Standard_Real lp = cursd->LastSpineParam();
2913 Standard_Integer jf = 0, jl = 0;
2914 if(lp < WF+tolesp || fp > WL-tolesp) continue;
2915 for(j = IF; j < IL; j++){
2917 if(fp < wv(j) - tolesp) break;
2919 for(j = IF; j < IL; j++){
2921 if(lp < wv(j) + tolesp) break;
2923 for(j = jf; j <= jl; j++){
2924 Standard_Integer jloc = j;
2925 if(periodic) jloc = (j - 1)%nbed + 1;
2926 const TopoDS_Edge& Ej = Spine->Edges(jloc);
2927 if(!myEVIMap.IsBound(Ej)) {
2928 TColStd_ListOfInteger li;
2929 myEVIMap.Bind(Ej,li);
2931 myEVIMap.ChangeFind(Ej).Append(cursd->Surf());
2939 //=======================================================================
2940 //function : PerformSetOfSurf
2942 //=======================================================================
2944 void ChFi3d_Builder::PerformSetOfSurf(Handle(ChFiDS_Stripe)& Stripe,
2945 const Standard_Boolean Simul)
2947 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
2951 ChFi3d_InitChron(ch);// init perf for PerformSetOfKPart
2954 const Handle(ChFiDS_Spine)& sp = Stripe->Spine();
2955 Standard_Integer SI = ChFi3d_SolidIndex(sp,DStr,myESoMap,myEShMap);
2956 Stripe->SetSolidIndex(SI);
2957 if(!sp->SplitDone()) PerformSetOfKPart(Stripe,Simul);
2960 ChFi3d_ResultChron(ch ,t_perfsetofkpart); // result perf PerformSetOfKPart(
2961 ChFi3d_InitChron(ch); // init perf for PerformSetOfKGen
2964 PerformSetOfKGen(Stripe,Simul);
2967 ChFi3d_ResultChron(ch, t_perfsetofkgen);//result perf PerformSetOfKGen
2968 ChFi3d_InitChron(ch); // init perf for ChFi3d_MakeExtremities
2971 if(!Simul) ChFi3d_MakeExtremities(Stripe,DStr,myEFMap,tolesp,tol2d);
2974 ChFi3d_ResultChron(ch, t_makextremities); // result perf t_makextremities