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_Line.hxx>
38 #include <Geom_Plane.hxx>
39 #include <Geom2d_Curve.hxx>
40 #include <GeomAPI_ProjectPointOnCurve.hxx>
43 #include <TopoDS_Shape.hxx>
44 #include <TopoDS_Face.hxx>
45 #include <TopoDS_Wire.hxx>
46 #include <TopoDS_Edge.hxx>
47 #include <TopoDS_Vertex.hxx>
49 #include <GeomAdaptor_Surface.hxx>
50 #include <GeomAdaptor_HSurface.hxx>
51 #include <GeomAdaptor_HCurve.hxx>
53 #include <BRepAdaptor_Curve.hxx>
54 #include <BRepAdaptor_HCurve.hxx>
55 #include <BRepAdaptor_Surface.hxx>
56 #include <BRepAdaptor_HSurface.hxx>
57 #include <BRepTopAdaptor_TopolTool.hxx>
58 #include <BRepLProp_SLProps.hxx>
59 #include <Adaptor3d_TopolTool.hxx>
62 #include <TopAbs_ShapeEnum.hxx>
63 #include <TopAbs_Orientation.hxx>
64 #include <BRep_Tool.hxx>
65 #include <BRepTools.hxx>
66 #include <BRepTools_WireExplorer.hxx>
67 #include <BRepLib_MakeFace.hxx>
69 #include <TopExp_Explorer.hxx>
70 #include <TopTools_ListIteratorOfListOfShape.hxx>
72 #include <Extrema_ExtPC.hxx>
73 #include <Extrema_LocateExtPC.hxx>
74 #include <Extrema_POnCurv.hxx>
76 #include <ChFiDS_ErrorStatus.hxx>
77 #include <ChFiDS_State.hxx>
78 #include <ChFiDS_SurfData.hxx>
79 #include <ChFiDS_CommonPoint.hxx>
80 #include <ChFiDS_FaceInterference.hxx>
81 #include <ChFiDS_Spine.hxx>
82 #include <ChFiDS_FilSpine.hxx>
83 #include <ChFiDS_ChamfSpine.hxx>
84 #include <ChFiDS_SequenceOfSurfData.hxx>
85 #include <ChFiDS_Stripe.hxx>
86 #include <ChFiDS_HData.hxx>
87 #include <ChFiDS_ElSpine.hxx>
88 #include <ChFiDS_ListOfHElSpine.hxx>
89 #include <ChFiDS_ListIteratorOfListOfHElSpine.hxx>
90 #include <Extrema_ExtPS.hxx>
91 #include <ChFiKPart_ComputeData.hxx>
93 #include <ChFi3d_Builder_0.hxx>
97 #include <DrawTrSurf.hxx>
99 #include <OSD_Chronometer.hxx>
100 extern Standard_Real t_perfsetofkpart,t_perfsetofkgen,t_makextremities,t_performsurf,t_startsol;
101 extern Standard_Boolean ChFi3d_GettraceCHRON();
102 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
103 extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real& time);
106 // Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 Begin
107 Standard_Boolean isTangentFaces(const TopoDS_Edge &theEdge,
108 const TopoDS_Face &theFace1,
109 const TopoDS_Face &theFace2);
110 // Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 End
112 //===================================================================
113 // Definition by a plane
115 // It is considered that P1 and P2 are points associated to commonpoints compoint1 and
116 // compoint2, while E1 and E2 are edges containing P1 and P2.
117 // The plane containing three directions D12 T1 T2 ou D12 represente la direction formee
118 // par les points P1 et P2, T1 la tangente de E1 en P1 et T2 la tangente de
119 // E2 en P2 is found (if exists).
120 // Then fillet HConge is intersected by this plane
121 // to find associated curve 3d C3d and the curve 2d.
123 //====================================================================
124 static void ChFi3d_CoupeParPlan (const ChFiDS_CommonPoint & compoint1,
125 const ChFiDS_CommonPoint & compoint2,
126 Handle(GeomAdaptor_HSurface)& HConge,
127 const gp_Pnt2d & UV1,
128 const gp_Pnt2d & UV2,
129 const Standard_Real tol3d,
130 const Standard_Real tol2d,
131 Handle(Geom_Curve) &C3d,
132 Handle(Geom2d_Curve) &pcurve,
133 Standard_Real & tolreached,
134 Standard_Real & Pardeb,
135 Standard_Real & Parfin,
136 Standard_Boolean & plane)
137 { plane=Standard_True;
138 if(compoint1.IsOnArc() && compoint2.IsOnArc() ) {
140 BRepAdaptor_Curve BCurv1(compoint1.Arc());
141 BRepAdaptor_Curve BCurv2(compoint2.Arc());
142 Standard_Real parE1,parE2;
143 parE1=compoint1.ParameterOnArc();
144 parE2=compoint2.ParameterOnArc();
146 BCurv1.D1(parE1,P1,t1);
147 BCurv2.D1(parE2,P2,t2);
150 gp_Vec v12(P2.X()-P1.X(),P2.Y()-P1.Y(),P2.Z()-P1.Z());
152 gp_Dir nor =tgt1.Crossed(d12);
153 Handle (Geom_Plane) Plan=new Geom_Plane(P1,nor);
155 scal=Abs(nor.Dot(tgt2));
157 Handle(GeomAdaptor_HSurface) HPlan=new GeomAdaptor_HSurface(Plan);
158 Handle(Geom2d_Curve) C2dint2;
159 TColStd_Array1OfReal Pdeb(1,4),Pfin(1,4);
160 GeomAdaptor_Surface AS(Plan);
161 Extrema_ExtPS ext(P1,AS,1.e-3,1.e-3);
162 Extrema_ExtPS ext1 (P2,AS,1.e-3,1.e-3);
164 ext.Point(1).Parameter(u1,v1);
165 Pdeb(1)= UV1.X();Pdeb(2) = UV1.Y();
166 Pdeb(3)= u1;Pdeb(4) =v1;
167 ext1.Point(1).Parameter(u1,v1);
168 Pfin(1)= UV2.X();Pfin(2) = UV2.Y();
169 Pfin(3)= u1;Pfin(4) = v1;
170 if (ChFi3d_ComputeCurves(HConge,HPlan,Pdeb,Pfin,C3d,
171 pcurve,C2dint2,tol3d,tol2d,tolreached)){
172 Pardeb=C3d->FirstParameter();
173 Parfin=C3d->LastParameter();
175 else plane=Standard_False;
177 else plane=Standard_False;
179 else plane=Standard_False;
181 //=======================================================================
182 //function : SortieTangente
184 //=======================================================================
186 static Standard_Boolean SortieTangente(const ChFiDS_CommonPoint& CP,
187 const TopoDS_Face& /*F*/,
188 const Handle(ChFiDS_SurfData)& /*SD*/,
189 const Standard_Integer /*OnS*/,
190 const Standard_Real TolAngular)
192 if(!CP.HasVector()) return Standard_False;
195 Handle(Geom_Curve) C;
196 Standard_Real Uf, Ul;
197 C = BRep_Tool::Curve(CP.Arc(),Uf,Ul);
198 C->D1(CP.ParameterOnArc(), P, Darc);
200 return Dsurf.IsParallel(Darc, TolAngular);
203 //=======================================================================
204 //function : BonVoisin
206 //=======================================================================
208 static Standard_Boolean BonVoisin(const gp_Pnt& Point,
209 Handle(BRepAdaptor_HSurface)& HS,
211 Handle(GeomAdaptor_HSurface)& plane,
212 const TopoDS_Edge& cured,
215 const ChFiDS_Map& EFMap,
216 const Standard_Real tolesp)
218 Standard_Boolean bonvoisin = 1;
219 Standard_Real winter, Uf, Ul;
220 gp_Pnt papp = HS->Value(XDep, YDep);
221 Standard_Real dist = RealLast();
222 Handle(BRepAdaptor_HCurve) hc = new BRepAdaptor_HCurve();
223 Handle(Geom2d_Curve) PC;
224 Standard_Boolean found = 0;
227 for(Ex.Init(F,TopAbs_EDGE); Ex.More(); Ex.Next()){
228 const TopoDS_Edge& ecur = TopoDS::Edge(Ex.Current());
229 if(!ecur.IsSame(cured)){
230 hc->ChangeCurve().Initialize(ecur);
231 Standard_Real tolc = hc->ChangeCurve().Resolution(tolesp);
232 if(ChFi3d_InterPlaneEdge(plane,hc,winter,1,tolc)){
233 gp_Pnt np = hc->Value(winter);
234 Standard_Real ndist = np.SquareDistance(papp);
236 TopTools_ListIteratorOfListOfShape It;
238 Standard_Boolean isclosed = BRep_Tool::IsClosed(ecur, F);
239 Standard_Boolean isreallyclosed =
240 BRepTools::IsReallyClosed(ecur, F);
241 for(It.Initialize(EFMap(ecur));It.More();It.Next()){
242 ff = TopoDS::Face(It.Value());
243 Standard_Boolean issame = ff.IsSame(F);
244 // Modified by Sergey KHROMOV - Fri Dec 21 17:12:48 2001 Begin
245 // Standard_Boolean istg =
246 // BRep_Tool::Continuity(ecur,ff,F) != GeomAbs_C0;
247 Standard_Boolean istg = isTangentFaces(ecur,ff,F);
248 // Modified by Sergey KHROMOV - Fri Dec 21 17:12:51 2001 End
249 if((!issame || (issame && isreallyclosed)) && istg) {
251 TopoDS_Edge newe = ecur;
252 newe.Orientation(TopAbs_FORWARD);
254 HS->ChangeSurface().Initialize(ff);
255 if(isclosed && !isreallyclosed){
256 TopoDS_Face fff = ff;
257 fff.Orientation(TopAbs_FORWARD);
259 for(Ex2.Init(fff,TopAbs_EDGE);
260 Ex2.More(); Ex2.Next()){
261 if(newe.IsSame(Ex2.Current())){
262 newe = TopoDS::Edge(Ex2.Current());
263 PC = BRep_Tool::CurveOnSurface(newe,fff,Uf,Ul);
268 else PC = BRep_Tool::CurveOnSurface(newe,ff,Uf,Ul);
269 PC->Value(winter).Coord(XDep,YDep);
271 gp_Pnt spt; gp_Vec sdu,sdv,nors;
272 HS->D1(XDep, YDep, spt, sdu, sdv);
273 nors = sdu.Crossed(sdv);
274 gp_Pnt cpt; gp_Vec cd;
275 hc->D1(winter,cpt,cd);
276 gp_Vec vref(Point, cpt);
277 TopoDS_Face fff = ff;
278 fff.Orientation(TopAbs_FORWARD);
279 if(vref.Dot(nors.Crossed(cd)) < 0.){
280 newe.Orientation(TopAbs_REVERSED);
282 PC = BRep_Tool::CurveOnSurface(newe,fff,Uf,Ul);
283 PC->Value(winter).Coord(XDep, YDep);
292 if(!found) bonvoisin = 0;
296 //=======================================================================
297 //function : Projection
298 //purpose : Projects a point on a curve
299 //=======================================================================
301 static Standard_Boolean Projection(Extrema_ExtPC& PExt,
303 const Adaptor3d_Curve& C,
307 Standard_Real Dist2, daux2;
308 Dist2 = C.Value(W).SquareDistance(P);
310 // It is checked if it is not already a solution
311 if (Dist2 < Tol * Tol)
312 return Standard_True;
314 Standard_Boolean Ok = Standard_False;
316 // On essai une resolution initialise
317 Extrema_LocateExtPC ext(P,C,W,Tol/10);
319 daux2 = C.Value(ext.Point().Parameter()).SquareDistance(P);
321 W = ext.Point().Parameter();
324 if (Dist2 < Tol * Tol)
325 return Standard_True;
331 if ( PExt.IsDone() ) {
332 for (Standard_Integer ii=1; ii<= PExt.NbExt(); ii++) {
333 if (PExt.SquareDistance(ii) < Dist2) {
334 Dist2 = PExt.SquareDistance(ii);
335 W = PExt.Point(ii).Parameter();
343 //=======================================================================
346 //=======================================================================
348 static void TgtKP(const Handle(ChFiDS_SurfData)& CD,
349 const Handle(ChFiDS_Spine)& Spine,
350 const Standard_Integer iedge,
351 const Standard_Boolean isfirst,
355 Standard_Real wtg = CD->InterferenceOnS1().Parameter(isfirst);
356 const BRepAdaptor_Curve& bc = Spine->CurrentElementarySpine(iedge);
357 if(Spine->Edges(iedge).Orientation() == TopAbs_FORWARD)
358 bc.D1(wtg+bc.FirstParameter(),ped,ded);
360 bc.D1(-wtg+bc.LastParameter(),ped,ded);
366 //=======================================================================
368 //purpose : Checks if a vector belongs to a Face
369 //=======================================================================
371 Standard_Boolean IsInput(const gp_Vec& Vec,
372 const TopoDS_Vertex& Ve,
373 const TopoDS_Face& Fa)
375 TopExp_Explorer FaceExp(Fa, TopAbs_WIRE);
376 BRepTools_WireExplorer WireExp;
377 Standard_Integer Trouve = 0;
380 TopoDS_Vertex Vf, Vl;
384 // Find edges and compute 3D vectors
385 for ( ; (FaceExp.More() && (Trouve<2)); FaceExp.Next()) {
386 W = TopoDS::Wire(FaceExp.Current());
387 for (Trouve=0, WireExp.Init(W) ;
388 WireExp.More() && (Trouve<2); WireExp.Next()) {
389 E = TopoDS::Edge(WireExp.Current());
390 TopExp::Vertices(E, Vf, Vl);
392 BRepAdaptor_Curve Cb(E);
393 Cb.D1(BRep_Tool::Parameter(Ve, E), Point, Vec3d[Trouve]);
396 else if (Vl.IsSame(Ve)) {
397 BRepAdaptor_Curve Cb(E);
398 Cb.D1(BRep_Tool::Parameter(Ve, E), Point, Vec3d[Trouve]);
399 Vec3d[Trouve].Reverse();
404 if (Trouve < 2) return Standard_False;
405 // Calculate the normal and the angles in the asssociated vector plane
407 Normal = Vec3d[0] ^ Vec3d[1];
408 if (Normal.SquareMagnitude() < Precision::Confusion()) {//Colinear case
409 return (Vec.IsParallel(Vec3d[0],Precision::Confusion()));
412 Standard_Real amin, amax;
413 amax = Vec3d[1].AngleWithRef(Vec3d[0], Normal);
420 // Projection of the vector
421 gp_Ax3 Axe(Point, Normal, Vec3d[0]);
423 Transf.SetTransformation (Axe);
424 gp_XYZ coord = Vec.XYZ();
425 Transf.Transforms(coord);
428 Transf.Transforms(coord);
429 gp_Vec theProj(coord);
432 Standard_Real Angle = theProj.AngleWithRef(Vec3d[0], Normal);
433 return ( (Angle >= amin) && (Angle<=amax));
436 //=======================================================================
438 //purpose : Find a neighbor G1 by an edge
439 //=======================================================================
441 Standard_Boolean IsG1(const ChFiDS_Map& TheMap,
442 const TopoDS_Edge& E,
443 const TopoDS_Face& FRef,
446 TopTools_ListIteratorOfListOfShape It;
447 // Find a neighbor of E different from FRef (general case).
448 for(It.Initialize(TheMap(E));It.More();It.Next()) {
449 if (!TopoDS::Face(It.Value()).IsSame(FRef)) {
450 FVoi = TopoDS::Face(It.Value());
451 // Modified by Sergey KHROMOV - Fri Dec 21 17:09:32 2001 Begin
452 // if (BRep_Tool::Continuity(E,FRef,FVoi) != GeomAbs_C0) {
453 if (isTangentFaces(E,FRef,FVoi)) {
454 // Modified by Sergey KHROMOV - Fri Dec 21 17:09:33 2001 End
455 return Standard_True;
459 // If is was not found it is checked if E is a cutting edge,
460 // in which case FVoi = FRef is returned (less frequent case).
462 Standard_Boolean orset = Standard_False;
463 TopAbs_Orientation orient = TopAbs_FORWARD ;
465 for(Ex.Init(FRef,TopAbs_EDGE); Ex.More(); Ex.Next()){
466 ed = TopoDS::Edge(Ex.Current());
468 if(!orset){ orient = ed.Orientation(); orset = Standard_True; }
469 else if(ed.Orientation() == TopAbs::Reverse(orient)){
471 // Modified by Sergey KHROMOV - Fri Dec 21 17:15:12 2001 Begin
472 // if (BRep_Tool::Continuity(E,FRef,FRef) >= GeomAbs_G1) {
473 if (isTangentFaces(E,FRef,FRef)) {
474 // Modified by Sergey KHROMOV - Fri Dec 21 17:15:16 2001 End
475 return Standard_True;
477 return Standard_False;
481 return Standard_False;
484 //=======================================================================
485 //function : SearchFaceOnV
486 //purpose : Finds the output face(s) of the path by a vertex
487 // The following criteria should be followed
488 // -1 : The face shares regular edges with FRef
489 // (too hard condition that should be reconsidered)
490 // -2 : The vector starting in CommonPoint "belongs" to the face
491 //========================================================================
492 static Standard_Integer SearchFaceOnV(const ChFiDS_CommonPoint& Pc,
493 const TopoDS_Face& FRef,
494 const ChFiDS_Map& VEMap,
495 const ChFiDS_Map& EFMap,
499 // it is checked that it leaves the current face.
500 Standard_Boolean FindFace = IsInput(Pc.Vector(), Pc.Vertex(), FRef);
502 FindFace = IsInput(Pc.Vector().Reversed(), Pc.Vertex(), FRef);
504 // If it does not leave, it is finished
509 Standard_Integer Num = 0;
510 Standard_Boolean Trouve;
511 TopTools_ListIteratorOfListOfShape ItE, ItF;
515 for(ItE.Initialize(VEMap(Pc.Vertex()));
516 ItE.More() && (Num < 2); ItE.Next()) {
517 E = TopoDS::Edge(ItE.Value());
518 for(ItF.Initialize(EFMap(E)), Trouve=Standard_False;
519 ItF.More()&&(!Trouve); ItF.Next()) {
520 if (TopoDS::Face(ItF.Value()).IsSame(FRef)) {
521 Trouve = Standard_True;
524 if (Trouve) Trouve = IsG1(EFMap, E, FRef, FVoi);
525 if (Trouve) Trouve = IsInput(Pc.Vector(), Pc.Vertex(), FVoi);
527 if (Num == 0) F1 = FVoi;
535 //=======================================================================
536 //function : ChangeTransition
537 //purpose : Changes the transition of the second common Point, when the surface
538 // does not cross the arc
539 // As it is supposed that the support Faces are the same, it is enough
540 // to examine the cas of cutting edges.
541 //========================================================================
542 static void ChangeTransition(const ChFiDS_CommonPoint& Precedant,
543 ChFiDS_CommonPoint& Courant,
544 Standard_Integer FaceIndex,
545 const Handle(TopOpeBRepDS_HDataStructure)& DS)
547 Standard_Boolean tochange = Standard_True;
549 const TopoDS_Face& F = TopoDS::Face(DS->Shape(FaceIndex));
550 const TopoDS_Edge& Arc = Precedant.Arc();
551 Handle(Geom2d_Curve) PCurve1, PCurve2;
552 PCurve1 = BRep_Tool::CurveOnSurface(Arc, F, f, l);
553 TopoDS_Shape aLocalShape = Arc.Reversed();
554 PCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(aLocalShape), F, f, l);
555 // PCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(Arc.Reversed()), F, f, l);
556 if (PCurve1 != PCurve2) {
557 // This is a cutting edge, it is necessary to make a small Geometric test
560 BRepAdaptor_Curve AC(Arc);
561 AC.D1(Precedant.ParameterOnArc(), P, tgarc);
562 tochange = tgarc.IsParallel(Precedant.Vector(), Precision::Confusion());
566 Courant.SetArc(Precision::Confusion(),
568 Precedant.ParameterOnArc(),
569 TopAbs::Reverse(Precedant.TransitionOnArc()));
573 //=======================================================================
574 //function : CallPerformSurf
575 //purpose : Encapsulates call to PerformSurf/SimulSurf
576 //========================================================================
578 void ChFi3d_Builder::
579 CallPerformSurf(Handle(ChFiDS_Stripe)& Stripe,
580 const Standard_Boolean Simul,
581 ChFiDS_SequenceOfSurfData& SeqSD,
582 Handle(ChFiDS_SurfData)& SD,
583 const Handle(ChFiDS_HElSpine)& HGuide,
584 const Handle(ChFiDS_Spine)& Spine,
585 const Handle(BRepAdaptor_HSurface)& HS1,
586 const Handle(BRepAdaptor_HSurface)& HS3,
589 Handle(Adaptor3d_TopolTool)& It1,
590 const Handle(BRepAdaptor_HSurface)& HS2,
591 const Handle(BRepAdaptor_HSurface)& HS4,
594 Handle(Adaptor3d_TopolTool)& It2,
595 const Standard_Real MaxStep,
596 const Standard_Real Fleche,
597 const Standard_Real /*TolGuide*/,
598 Standard_Real& First,
600 const Standard_Boolean Inside,
601 const Standard_Boolean /*Appro*/,
602 const Standard_Boolean forward,
603 const Standard_Boolean RecOnS1,
604 const Standard_Boolean RecOnS2,
606 Standard_Boolean& intf,
607 Standard_Boolean& intl,
608 Handle(BRepAdaptor_HSurface)& Surf1,
609 Handle(BRepAdaptor_HSurface)& Surf2)
614 Handle(BRepAdaptor_HSurface) HSon1, HSon2;
617 // Definition of the domain of path It1, It2
618 It1->Initialize(HS1);
619 It2->Initialize(HS2);
622 TopAbs_Orientation Or1 = HS1->ChangeSurface().Face().Orientation();
623 TopAbs_Orientation Or2 = HS2->ChangeSurface().Face().Orientation();
624 Standard_Integer Choix =
625 ChFi3d::NextSide(Or1,Or2,
626 Stripe->OrientationOnFace1(),
627 Stripe->OrientationOnFace2(),
629 Soldep(1) = pp1.X(); Soldep(2) = pp1.Y();
630 Soldep(3) = pp2.X(); Soldep(4) = pp2.Y();
632 Standard_Real thef = First, thel = Last;
633 Standard_Boolean isdone;
636 isdone = SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,HS2,It2,tolesp,First,Last,
637 Inside,Inside,forward,RecOnS1,RecOnS2,Soldep,intf,intl);
642 ChFi3d_InitChron(ch1);//initial perform for PerformSurf
645 isdone = PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,HS2,It2,
646 MaxStep,Fleche,tolesp,
647 First,Last,Inside,Inside,forward,
648 RecOnS1,RecOnS2,Soldep,intf,intl);
650 ChFi3d_ResultChron(ch1,t_performsurf);// result perf for PerformSurf
658 Standard_Boolean reprise = Standard_False;
659 if (! HS3.IsNull()) {
661 It1->Initialize(HS3);
662 Or1 = HS3->ChangeSurface().Face().Orientation();
663 Soldep(1) = pp3.X(); Soldep(2) = pp3.Y();
664 reprise = Standard_True;
666 else if (! HS4.IsNull()) {
668 It2->Initialize(HS4);
669 Or2 = HS4->ChangeSurface().Face().Orientation();
670 Soldep(3) = pp4.X(); Soldep(4) = pp4.Y();
671 reprise = Standard_True;
675 Choix = ChFi3d::NextSide(Or1,Or2,
676 Stripe->OrientationOnFace1(),
677 Stripe->OrientationOnFace2(),
680 isdone = SimulSurf(SD,HGuide,Spine,Choix,HSon1,It1,HSon2,It2,
682 Inside,Inside,forward,RecOnS1,RecOnS2,
688 ChFi3d_InitChron(ch1);//init perf for PerformSurf
691 isdone = PerformSurf(SeqSD,HGuide,Spine,Choix,HSon1,It1,HSon2,It2,
692 MaxStep,Fleche,tolesp,
693 First,Last,Inside,Inside,forward,
694 RecOnS1,RecOnS2,Soldep,intf,intl);
696 ChFi3d_ResultChron(ch1,t_performsurf);// result perf for PerformSurf
705 //=======================================================================
706 //function : StripeOrientation
707 //purpose : Calculates the reference orientation determining the
708 // concave face for construction of the fillet.
709 //=======================================================================
711 Standard_Boolean ChFi3d_Builder::StripeOrientations
712 (const Handle(ChFiDS_Spine)& Spine,
713 TopAbs_Orientation& Or1,
714 TopAbs_Orientation& Or2,
715 Standard_Integer& ChoixConge) const
717 //TopTools_ListIteratorOfListOfShape It;
718 BRepAdaptor_Surface Sb1,Sb2;
719 TopAbs_Orientation Of1,Of2;
721 ChFi3d_conexfaces(Spine->Edges(1),ff1,ff2,myEFMap);
722 Of1 = ff1.Orientation();
723 ff1.Orientation(TopAbs_FORWARD);
725 Of2 = ff2.Orientation();
726 ff2.Orientation(TopAbs_FORWARD);
729 ChoixConge = ChFi3d::ConcaveSide(Sb1,Sb2,Spine->Edges(1),
731 Or1 = TopAbs::Compose(Or1,Of1);
732 Or2 = TopAbs::Compose(Or2,Of2);
733 return Standard_True;
737 //=======================================================================
738 //function : ConexFaces
740 //=======================================================================
742 void ChFi3d_Builder::ConexFaces (const Handle(ChFiDS_Spine)& Spine,
743 const Standard_Integer IEdge,
744 const Standard_Integer RC,
745 Handle(BRepAdaptor_HSurface)& HS1,
746 Handle(BRepAdaptor_HSurface)& HS2) const
748 if(HS1.IsNull()) HS1 = new BRepAdaptor_HSurface ();
749 if(HS2.IsNull()) HS2 = new BRepAdaptor_HSurface ();
750 BRepAdaptor_Surface& Sb1 = HS1->ChangeSurface();
751 BRepAdaptor_Surface& Sb2 = HS2->ChangeSurface();
754 ChFi3d_conexfaces(Spine->Edges(IEdge),ff1,ff2,myEFMap);
759 TopAbs_Orientation Or1,Or2;
760 Standard_Integer Choix = ChFi3d::ConcaveSide(Sb1,Sb2,Spine->Edges(IEdge),
762 if (RC%2 != Choix%2) {
768 //=======================================================================
769 //function : StartSol
770 //purpose : Calculates a starting solution :
771 // - one starts by parsing about ten points on the spine,
772 // - in case of fail one finds the solution on neighbor faces;
773 // section plane of edges of the adjacent face
774 // and identication of the face by connection to that edge.
775 //=======================================================================
777 void ChFi3d_Builder::StartSol(const Handle(ChFiDS_Stripe)& Stripe,
778 const Handle(ChFiDS_HElSpine)& HGuide,
779 Handle(BRepAdaptor_HSurface)& HS1,
780 Handle(BRepAdaptor_HSurface)& HS2,
781 Handle(BRepTopAdaptor_TopolTool)& I1,
782 Handle(BRepTopAdaptor_TopolTool)& I2,
785 Standard_Real& First) const
787 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
788 ChFiDS_ElSpine& els = HGuide->ChangeCurve();
789 Standard_Integer nbed = Spine->NbEdges();
790 Standard_Integer nbessaimax = 3*nbed;
791 if (nbessaimax < 10) nbessaimax = 10;
792 Standard_Real unsurnbessaimax = 1./nbessaimax;
793 Standard_Real wf = 0.9981 * Spine->FirstParameter(1) +
794 0.0019 * Spine->LastParameter(1);
795 Standard_Real wl = 0.9973 * Spine->LastParameter(nbed) +
796 0.0027 * Spine->FirstParameter(nbed);
798 Standard_Real TolE = 1.0e-7;
799 BRepAdaptor_Surface AS;
801 Standard_Integer nbessai;
802 Standard_Integer iedge = 0;
803 Standard_Integer RC = Stripe->Choix();
808 TopAbs_Orientation Or1,Or2;
809 Standard_Integer Choix = 0;
810 math_Vector SolDep(1,4);
811 Handle(Geom2d_Curve) PC;
814 Spine->FirstParameter(1),
815 Spine->LastParameter(nbed),
816 Precision::Confusion());
817 TopAbs_State Pos1,Pos2;
818 for(nbessai = 0; nbessai <= nbessaimax; nbessai++){
819 Standard_Real t = nbessai*unsurnbessaimax;
820 Standard_Real w = wf * (1. -t) + wl * t;
821 Standard_Integer ie = Spine->Index(w);
824 cured = Spine->Edges(iedge);
825 TolE = BRep_Tool::Tolerance(cured);
826 ConexFaces(Spine,iedge,RC,HS1,HS2);
827 f1 = HS1->ChangeSurface().Face();
828 f2 = HS2->ChangeSurface().Face();
829 Or1 = f1.Orientation();
830 Or2 = f2.Orientation();
831 Choix = ChFi3d::NextSide(Or1,Or2,
832 Stripe->OrientationOnFace1(),
833 Stripe->OrientationOnFace2(),
837 Standard_Real woned,Uf,Ul, ResU, ResV;
838 Spine->Parameter(iedge,w,woned,Standard_True);
839 cured.Orientation(TopAbs_FORWARD);
840 TopoDS_Face f1forward = f1, f2forward = f2;
841 f1forward.Orientation(TopAbs_FORWARD);
842 f2forward.Orientation(TopAbs_FORWARD);
843 PC = BRep_Tool::CurveOnSurface(cured,f1forward,Uf,Ul);
845 PC->D1(woned, P1, derive);
846 // There are ponts on the border, and internal points are found
847 if (derive.Magnitude() > Precision::PConfusion()) {
849 derive.Rotate(M_PI/2);
851 ResU = AS.UResolution(TolE);
852 ResV = AS.VResolution(TolE);
853 derive *= 2*(Abs(derive.X())*ResU + Abs(derive.Y())*ResV);
854 P2d = P1.Translated(derive);
855 if (I1->Classify(P2d, Min(ResU, ResV), 0)== TopAbs_IN) {
859 P2d = P1.Translated(-derive);
860 if (I1->Classify(P2d, Min(ResU, ResV), 0)== TopAbs_IN) {
865 if(f1.IsSame(f2)) cured.Orientation(TopAbs_REVERSED);
866 PC = BRep_Tool::CurveOnSurface(cured,f2forward,Uf,Ul);
867 P2 = PC->Value(woned);
870 SolDep(1) = P1.X(); SolDep(2) = P1.Y();
871 SolDep(3) = P2.X(); SolDep(4) = P2.Y();
872 const BRepAdaptor_Curve& Ced = Spine->CurrentElementarySpine(iedge);
873 gp_Pnt pnt = Ced.Value(woned);
875 if (Projection(PExt, pnt, els, w, tolesp) &&
876 PerformFirstSection(Spine,HGuide,Choix,HS1,HS2,
877 I1,I2,w,SolDep,Pos1,Pos2)) {
878 P1.SetCoord(SolDep(1),SolDep(2));
879 P2.SetCoord(SolDep(3),SolDep(4));
884 // No solution was found for the faces adjacent to the trajectory.
885 // Now one tries the neighbor faces.
887 for(nbessai = 0; nbessai <= nbessaimax; nbessai++){
888 Standard_Real t = nbessai*unsurnbessaimax;
889 Standard_Real w = wf * (1. -t) + wl * t;
890 iedge = Spine->Index(w);
891 cured = Spine->Edges(iedge);
892 ConexFaces(Spine,iedge,RC,HS1,HS2);
893 f1 = HS1->ChangeSurface().Face();
894 f2 = HS2->ChangeSurface().Face();
895 Or1 = f1.Orientation();
896 Or2 = f2.Orientation();
897 Choix = ChFi3d::NextSide(Or1,Or2,
898 Stripe->OrientationOnFace1(),
899 Stripe->OrientationOnFace2(),
901 Standard_Real woned,Uf,Ul;
902 Spine->Parameter(iedge,w,woned,Standard_True);
903 TopoDS_Face f1forward = f1, f2forward = f2;
904 f1forward.Orientation(TopAbs_FORWARD);
905 f2forward.Orientation(TopAbs_FORWARD);
906 PC = BRep_Tool::CurveOnSurface(cured,f1forward,Uf,Ul);
907 P1 = PC->Value(woned);
908 PC = BRep_Tool::CurveOnSurface(cured,f2forward,Uf,Ul);
909 P2 = PC->Value(woned);
912 SolDep(1) = P1.X(); SolDep(2) = P1.Y();
913 SolDep(3) = P2.X(); SolDep(4) = P2.Y();
914 const BRepAdaptor_Curve& Ced = Spine->CurrentElementarySpine(iedge);
915 gp_Pnt pnt = Ced.Value(woned);
916 // Extrema_LocateExtPC ext(pnt,els,w,1.e-8);
918 // w = ext.Point().Parameter();
919 if (Projection(PExt, pnt, els, w, tolesp)) {
920 PerformFirstSection(Spine,HGuide,Choix,HS1,HS2,
921 I1,I2,w,SolDep,Pos1,Pos2);
925 Handle(Geom_Plane) pl = new Geom_Plane(P,V);
926 Handle(GeomAdaptor_HSurface) plane = new GeomAdaptor_HSurface(pl);
928 Standard_Boolean bonvoisin = 1, found = 0;
929 Standard_Integer NbChangement;
930 for (NbChangement = 1; bonvoisin && (!found) && (NbChangement < 5);
932 if(Pos1 != TopAbs_IN){
933 bonvoisin = BonVoisin(P, HS1, f1, plane, cured,
934 SolDep(1),SolDep(2), myEFMap, tolesp);
936 if(Pos2 != TopAbs_IN && bonvoisin){
937 bonvoisin = BonVoisin(P, HS2, f2, plane, cured,
938 SolDep(3),SolDep(4), myEFMap, tolesp);
941 f1 = HS1->ChangeSurface().Face();
942 f2 = HS2->ChangeSurface().Face();
943 Or1 = f1.Orientation();
944 Or2 = f2.Orientation();
945 Choix = ChFi3d::NextSide(Or1,Or2,
946 Stripe->OrientationOnFace1(),
947 Stripe->OrientationOnFace2(),
951 if(PerformFirstSection(Spine,HGuide,Choix,HS1,HS2,
952 I1,I2,w,SolDep,Pos1,Pos2)){
953 P1.SetCoord(SolDep(1),SolDep(2));
954 P2.SetCoord(SolDep(3),SolDep(4));
956 found = Standard_True;
963 Spine->SetErrorStatus(ChFiDS_StartsolFailure);
964 Standard_Failure::Raise("StartSol echec");
967 //=======================================================================
968 //function : ChFi3d_BuildPlane
970 //=======================================================================
972 static void ChFi3d_BuildPlane (TopOpeBRepDS_DataStructure& DStr,
973 Handle(BRepAdaptor_HSurface)& HS,
975 const Handle(ChFiDS_SurfData)& SD,
976 const Standard_Boolean isfirst,
977 const Standard_Integer ons)
979 Handle(Geom2d_Curve) Hc;
980 TopoDS_Face F = TopoDS::Face(DStr.Shape(SD->Index(ons)));
985 if (SD->Vertex(isfirst,ons).IsOnArc()){
986 Hc = BRep_Tool::CurveOnSurface
987 (SD->Vertex(isfirst,ons).Arc(),F,u,v);
988 Hc->Value(SD->Vertex(isfirst,ons).ParameterOnArc()).Coord(u,v);
989 BRepLProp_SLProps theProp(HS->ChangeSurface(), u, v, 1, 1.e-12);
990 if (theProp.IsNormalDefined()) {
992 Handle(Geom_Plane) Pln = new Geom_Plane(P, theProp.Normal());
993 TopoDS_Face NewF = BRepLib_MakeFace(Pln, Precision::Confusion());
994 NewF.Orientation(F.Orientation());
995 pons.SetCoord(0.,0.);
996 HS->ChangeSurface().Initialize(NewF);
997 return; // everything is good !
1000 Standard_Failure::Raise("ChFi3d_BuildPlane : echec .");
1003 //=======================================================================
1004 //function : StartSol
1005 //purpose : If the commonpoint is not OnArc the input face
1006 // is returned and 2D point is updated,
1008 // if it is detached the input face
1009 // is returned and 2D point is updated,
1011 // either there is a neighbor tangent face and it is returned
1012 // with recalculated 2D point
1013 // or if there is no face
1014 // if the reference arc is Vref (extremity of the spine)
1015 // this is the end and the input face is returned
1016 // otherwise this is an obstacle and HC is updated.
1017 //=======================================================================
1020 ChFi3d_Builder::StartSol(const Handle(ChFiDS_Spine)& Spine,
1021 Handle(BRepAdaptor_HSurface)& HS, // New face
1022 gp_Pnt2d& pons,// " Localization
1023 Handle(BRepAdaptor_HCurve2d)& HC, // Representation of the obstacle
1025 const Handle(ChFiDS_SurfData)& SD,
1026 const Standard_Boolean isfirst,
1027 const Standard_Integer ons,
1028 Handle(BRepAdaptor_HSurface)& HSref, // The other representation
1029 Handle(BRepAdaptor_HCurve2d)& HCref, // of the obstacle
1030 Standard_Boolean& RecP,
1031 Standard_Boolean& RecS,
1032 Standard_Boolean& RecRst,
1033 Standard_Boolean& c1obstacle,
1034 Handle(BRepAdaptor_HSurface)& HSBis, // Face of support
1035 gp_Pnt2d& PBis, // and its point
1036 const Standard_Boolean decroch,
1037 const TopoDS_Vertex& Vref) const
1039 RecRst = RecS = RecP = c1obstacle = 0;
1040 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
1041 TopoDS_Face Fv,Fref;
1043 Handle(Geom2d_Curve) pc;
1044 Standard_Real Uf,Ul;
1046 TopoDS_Face F = TopoDS::Face(DStr.Shape(SD->Index(ons)));
1047 if(!HSref.IsNull()) Fref = HSref->ChangeSurface().Face();
1048 const ChFiDS_CommonPoint& CP = SD->Vertex(isfirst,ons);
1052 Standard_Integer notons;
1053 if (ons == 1) notons = 2;
1055 const ChFiDS_CommonPoint& CPbis = SD->Vertex(isfirst,notons);
1056 if (CPbis.IsOnArc()) { // It is checked if it is not the extension zone
1057 // In case CP is not at the end of surfdata and it is not necesary to take it into account
1058 // except for separate cases (ie pointus) ...
1059 //ts and tns were earlier CP.Parameter() and CPbis.Parameter, but sometimes they had no values.
1060 Standard_Real ts=SD->Interference(ons).Parameter(isfirst), tns=SD->Interference(notons).Parameter(isfirst);
1061 Standard_Boolean isExtend;
1062 // Arbitrary test (to precise)
1063 if (isfirst) isExtend = (ts-tns > 100*tolesp);
1064 else isExtend = (tns-ts > 100*tolesp);
1065 if (isExtend && !CP.Point().IsEqual(CPbis.Point(), 0) ) {
1066 // the state is preserved and False is returned (extension by the expected plane).
1067 HS->ChangeSurface().Initialize(F);
1068 pc = SD->Interference(ons).PCurveOnFace();
1069 // The 2nd point is given by its trace on the support surface
1070 RecS = Standard_False;
1071 pons = pc->Value(tns);
1072 return Standard_False;
1077 if (CP.IsVertex() && !HC.IsNull() && !decroch){
1078 //The edge is changed, the parameter is updated and
1079 //eventually the support face and(or) the reference face.
1080 TopoDS_Vertex VCP = CP.Vertex();
1081 TopoDS_Edge EHC = HC->ChangeCurve2d().Edge();
1082 //One starts by searching in Fref another edge referencing VCP.
1083 TopExp_Explorer ex1,ex2;
1084 TopoDS_Edge newedge, edgereg;
1085 TopoDS_Face bidface = Fref, facereg;
1086 bidface.Orientation(TopAbs_FORWARD);
1087 for(ex1.Init(bidface,TopAbs_EDGE); ex1.More(); ex1.Next()){
1088 const TopoDS_Edge& cured = TopoDS::Edge(ex1.Current());
1089 Standard_Boolean found = 0;
1090 if(!cured.IsSame(EHC)){
1091 for(ex2.Init(cured,TopAbs_VERTEX); ex2.More() && !found; ex2.Next()){
1092 if(ex2.Current().IsSame(VCP)){
1093 if(IsG1(myEFMap,cured,Fref,Fv)){
1106 if(newedge.IsNull()){
1107 //It is checked if EHC is not a closed edge.
1108 TopoDS_Vertex V1,V2;
1109 TopExp::Vertices(EHC,V1,V2);
1112 Standard_Real w1 = BRep_Tool::Parameter(V1,EHC);
1113 Standard_Real w2 = BRep_Tool::Parameter(V2,EHC);
1114 const ChFiDS_FaceInterference& fi = SD->Interference(ons);
1115 const Handle(Geom2d_Curve)& pcf = fi.PCurveOnFace();
1116 Standard_Real ww = fi.Parameter(isfirst);
1119 if(!pcf.IsNull()) pww = pcf->Value(ww);
1120 else pww = SD->Get2dPoints(isfirst,ons);
1121 gp_Pnt2d p1 = HC->Value(w1);
1122 gp_Pnt2d p2 = HC->Value(w2);
1124 if(p1.Distance(pww) > p2.Distance(pww)){
1132 RecP = c1obstacle = 1;
1135 else if(!edgereg.IsNull()){
1136 // the reference edge and face are changed.
1138 HSref->ChangeSurface().Initialize(Fref);
1139 for(ex1.Init(facereg,TopAbs_EDGE); ex1.More() && newedge.IsNull(); ex1.Next()){
1140 const TopoDS_Edge& cured = TopoDS::Edge(ex1.Current());
1141 if(!cured.IsSame(edgereg)){
1142 for(ex2.Init(cured,TopAbs_VERTEX); ex2.More(); ex2.Next()){
1143 if(ex2.Current().IsSame(VCP)){
1144 if(!IsG1(myEFMap,cured,Fref,Fv)){
1153 // it is necessary to find the new support face of the fillet :
1154 // connected to FRef along the newedge.
1155 if(newedge.IsNull()) {
1156 Standard_Failure::Raise
1157 ("StartSol : chain is not possible, new obstacle not found");
1159 if(IsG1(myEFMap,newedge,Fref,Fv)){
1160 Standard_Failure::Raise
1161 ("StartSol : chain is not possible, config non processed");
1163 else if(Fv.IsNull()){
1164 Standard_Failure::Raise
1165 ("StartSol : chain is not possible, new obstacle not found");
1168 HS->ChangeSurface().Initialize(Fv);
1169 W = BRep_Tool::Parameter(VCP,newedge);
1170 HCref->ChangeCurve2d().Initialize(newedge,Fref);
1171 TopoDS_Face newface = Fv;
1172 newface.Orientation(TopAbs_FORWARD);
1174 for(ex.Init(newface,TopAbs_EDGE); ex.More(); ex.Next()){
1175 if(ex.Current().IsSame(newedge)){
1176 newedge = TopoDS::Edge(ex.Current());
1180 HC->ChangeCurve2d().Initialize(newedge,Fv);
1181 pons = HC->Value(W);
1183 RecP = c1obstacle = 1;
1185 } // End of Case Vertex && Obstacle
1187 else if (CP.IsOnArc() && !HC.IsNull() && !decroch){
1188 //Nothing is changed, the parameter is only updated.
1189 W = CP.ParameterOnArc();
1197 const TopoDS_Edge& E = CP.Arc();
1199 HS->ChangeSurface().Initialize(Fref);
1200 W = CP.ParameterOnArc();
1201 pc = BRep_Tool::CurveOnSurface(E,Fref,Uf,Ul);
1202 pons = pc->Value(W);
1206 if (SearchFace(Spine,CP,F,Fv)){
1207 HS->ChangeSurface().Initialize(Fv);
1209 if (CP.IsVertex()) {
1210 // One goes directly by the Vertex
1211 Standard_Integer Nb;
1213 // And it is checked that there are no other candidates
1214 Nb = SearchFaceOnV(CP, F, myVEMap, myEFMap, Fv, aux);
1216 pons = BRep_Tool::Parameters(CP.Vertex(), Fv);
1217 HS->ChangeSurface().Initialize(Fv);
1219 HSBis = new (BRepAdaptor_HSurface)(aux);
1220 PBis = BRep_Tool::Parameters(CP.Vertex(), aux);
1224 // otherwise one passes by the arc...
1226 Fv.Orientation(TopAbs_FORWARD);
1227 TopoDS_Edge newedge;
1229 for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()){
1230 if(ex.Current().IsSame(E)){
1231 newedge = TopoDS::Edge(ex.Current());
1235 //gp_Vec Varc, VSurf;
1236 // In cas of Tangent output, the current face becomes the support face
1237 if (SortieTangente(CP, F, SD, ons, 0.1)) {
1238 pc = BRep_Tool::CurveOnSurface(CP.Arc(),F,Uf,Ul);
1239 HSBis = new (BRepAdaptor_HSurface)(F);
1240 PBis = pc->Value(CP.ParameterOnArc());
1244 pc = BRep_Tool::CurveOnSurface(newedge,Fv,Uf,Ul);
1247 TopoDS_Edge newedge = E;
1249 Fv.Orientation(TopAbs_FORWARD);
1250 pc = BRep_Tool::CurveOnSurface(newedge,Fv,Uf,Ul);
1252 pons = pc->Value(CP.ParameterOnArc());
1255 else if(!Fv.IsNull()){
1259 for(ex.Init(E,TopAbs_VERTEX); ex.More(); ex.Next()){
1260 if(ex.Current().IsSame(Vref)){
1267 HS->ChangeSurface().Initialize(Fv);
1268 HSref->ChangeSurface().Initialize(F);
1269 W = CP.ParameterOnArc();
1270 HC = new BRepAdaptor_HCurve2d();
1271 TopoDS_Edge newedge;
1272 TopoDS_Face newface = Fv;
1273 newface.Orientation(TopAbs_FORWARD);
1275 for(ex.Init(newface,TopAbs_EDGE); ex.More(); ex.Next()){
1276 if(ex.Current().IsSame(E)){
1277 newedge = TopoDS::Edge(ex.Current());
1281 HC->ChangeCurve2d().Initialize(newedge,Fv);
1282 pons = HC->Value(W);
1283 HCref->ChangeCurve2d().Initialize(E,F);
1284 if(CP.IsVertex()) RecP = 1;
1289 HS->ChangeSurface().Initialize(F);
1290 W = CP.ParameterOnArc();
1291 pc = BRep_Tool::CurveOnSurface(E,F,Uf,Ul);
1292 pons = pc->Value(W);
1293 return Standard_False;
1296 else{ // there is no neighbor face, the state is preserved and False is returned.
1297 HS->ChangeSurface().Initialize(F);
1298 W = CP.ParameterOnArc();
1299 pc = BRep_Tool::CurveOnSurface(E,F,Uf,Ul);
1300 pons = pc->Value(W);
1301 return Standard_False;
1305 HS->ChangeSurface().Initialize(F);
1306 const ChFiDS_FaceInterference& FI = SD->Interference(ons);
1307 if(FI.PCurveOnFace().IsNull()) pons = SD->Get2dPoints(isfirst,ons);
1308 else pons = FI.PCurveOnFace()->Value(FI.Parameter(isfirst));
1310 return Standard_True;
1313 //=======================================================================
1314 //function : SearchFace
1316 //=======================================================================
1318 Standard_Boolean ChFi3d_Builder::SearchFace
1319 (const Handle(ChFiDS_Spine)& Spine,
1320 const ChFiDS_CommonPoint& Pc,
1321 const TopoDS_Face& FRef,
1322 TopoDS_Face& FVoi) const
1324 Standard_Boolean Trouve = Standard_False;
1325 if (! Pc.IsOnArc()) return Standard_False;
1329 // attention it is necessary to analyze all faces that turn around of the vertex
1331 cout<<"Commonpoint on vertex, the process hangs up"<<endl;
1333 if (Pc.HasVector()) { //General processing
1335 Standard_Integer nb_faces;
1336 nb_faces = SearchFaceOnV(Pc, FRef, myVEMap, myEFMap, FVoi, Fbis);
1337 return ( nb_faces > 0);
1339 else { // Processing using the spine
1340 Standard_Boolean FindFace=Standard_False;
1343 Spine->D1(Pc.Parameter(), Point, VecSpine);
1345 // It is checked if one leaves from the current face.
1346 FindFace = IsInput(VecSpine, Pc.Vertex(), FRef);
1349 FindFace = IsInput(VecSpine, Pc.Vertex(), FRef);
1351 // If one does not leave, it is ended
1354 return Standard_True;
1357 // Otherwise one finds the next among shared Faces
1358 // by a common edge G1
1359 TopTools_ListIteratorOfListOfShape ItE, ItF;
1360 for(ItE.Initialize(myVEMap(Pc.Vertex()));
1361 ItE.More() && (!FindFace); ItE.Next()) {
1362 E = TopoDS::Edge(ItE.Value());
1363 Trouve=Standard_False;
1364 for(ItF.Initialize(myEFMap(E));//, Trouve=Standard_False; 15.11.99 SVV
1365 ItF.More()&&(!Trouve); ItF.Next()) {
1366 if (TopoDS::Face(ItF.Value()).IsSame(FRef)) {
1367 Trouve = Standard_True;
1370 if (Trouve) FindFace = IsG1(myEFMap, E, FRef, FVoi);
1372 FindFace = Standard_False;
1373 if (Spine.IsNull()) {
1374 //La Spine peut etre nulle (ThreeCorner)
1376 cout << "FindFace sur vertex avec spine nulle! QUEZAKO ?" << endl;
1378 return Standard_False;
1381 // It is checked if the selected face actually possesses edges of the spine
1382 // containing the vertex on its front
1383 // This processing should go only if the Vertex belongs to the spine
1384 // This is a single case, for other vertexes it is required to do other things
1385 Trouve=Standard_False;
1386 for (Standard_Integer IE=1;//, Trouve=Standard_False; 15.11.99 SVV
1387 (IE<=Spine->NbEdges()) && (!Trouve); IE++) {
1388 E = Spine->Edges(IE);
1389 if ( (TopExp::FirstVertex(E).IsSame(Pc.Vertex()))
1390 ||(TopExp::LastVertex(E) .IsSame(Pc.Vertex())) ) {
1391 for(ItF.Initialize(myEFMap(E)), Trouve=Standard_False;
1392 ItF.More()&&(!Trouve); ItF.Next()) {
1393 if (TopoDS::Face(ItF.Value()).IsSame(FVoi)) {
1394 Trouve = Standard_True;
1405 return IsG1(myEFMap, Pc.Arc(), FRef, FVoi);
1407 return Standard_False;
1411 //=======================================================================
1412 //function : ChFi3d_SingularExtremity
1413 //purpose : load the vertex in the DS and calculate the pcurve
1414 // for an extremity in case of singular freeboundary
1415 // or periodic and singular at the cut.
1416 //=======================================================================
1417 static void ChFi3d_SingularExtremity( Handle(ChFiDS_Stripe)& stripe,
1418 TopOpeBRepDS_DataStructure& DStr,
1419 const TopoDS_Vertex& Vtx,
1420 const Standard_Real tol3d,
1421 const Standard_Real tol2d)
1423 Handle(ChFiDS_SurfData) Fd;
1424 Standard_Real tolreached;
1425 Standard_Real Pardeb, Parfin;
1426 gp_Pnt2d VOnS1, VOnS2;
1427 Handle(Geom_Curve) C3d;
1428 Handle(Geom2d_Curve) PCurv;
1429 TopOpeBRepDS_Curve Crv;
1430 // SurfData and its CommonPoints,
1431 Standard_Integer Ivtx, Icurv;
1432 Standard_Boolean isfirst;
1434 if (stripe->Spine()->IsPeriodic()) {
1435 isfirst = Standard_True;
1436 Fd = stripe->SetOfSurfData()->Sequence().First();
1439 Standard_Integer sens;
1440 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
1441 Fd = stripe->SetOfSurfData()->Sequence().Value(num);
1442 isfirst = (sens == 1);
1445 const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1);
1446 const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2);
1447 // Is it always degenerated ?
1448 if ( CV1.Point().IsEqual( CV2.Point(), 0) ) {
1449 Ivtx = ChFi3d_IndexPointInDS(CV1, DStr);
1451 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
1452 Value(Fd->InterferenceOnS1().FirstParameter());
1453 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
1454 Value(Fd->InterferenceOnS2().FirstParameter());
1457 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
1458 Value(Fd->InterferenceOnS1().LastParameter());
1459 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
1460 Value(Fd->InterferenceOnS2().LastParameter());
1463 ChFi3d_ComputeArete(CV1, VOnS1,
1465 DStr.Surface(Fd->Surf()).Surface(),
1467 Pardeb,Parfin, tol3d, tol2d, tolreached,0);
1468 Crv = TopOpeBRepDS_Curve(C3d,tolreached);
1469 Icurv = DStr.AddCurve(Crv);
1471 stripe->SetCurve(Icurv, isfirst);
1472 stripe->SetParameters(isfirst, Pardeb,Parfin);
1473 stripe->ChangePCurve(isfirst) = PCurv;
1474 stripe->SetIndexPoint(Ivtx, isfirst, 1);
1475 stripe->SetIndexPoint(Ivtx, isfirst, 2);
1477 if (stripe->Spine()->IsPeriodic()) {
1478 // periodic case : The operation is renewed
1479 // the curve 3d is not shared.
1480 // 2 degenerated edges coinciding in 3d
1481 isfirst = Standard_False;
1482 Fd = stripe->SetOfSurfData()->Sequence().Last();
1483 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
1484 Value(Fd->InterferenceOnS1().LastParameter());
1485 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
1486 Value(Fd->InterferenceOnS2().LastParameter());
1488 ChFi3d_ComputeArete(CV1, VOnS1,
1490 DStr.Surface(Fd->Surf()).Surface(),
1492 Pardeb,Parfin, tol3d, tol2d, tolreached,0);
1493 Crv = TopOpeBRepDS_Curve(C3d,tolreached);
1494 Icurv = DStr.AddCurve(Crv);
1496 stripe->SetCurve(Icurv, isfirst);
1497 stripe->SetParameters(isfirst, Pardeb,Parfin);
1498 stripe->ChangePCurve(isfirst) = PCurv;
1499 stripe->SetIndexPoint(Ivtx, isfirst, 1);
1500 stripe->SetIndexPoint(Ivtx, isfirst, 2);
1505 //=======================================================================
1506 //function : ChFi3d_MakeExtremities
1507 //purpose : calculate Curves3d and pcurves of extremities in
1508 // periodic and freeboundary cases.
1509 //=======================================================================
1510 static Standard_Boolean IsFree(const TopoDS_Shape& E,
1511 const ChFiDS_Map& EFMap)
1513 if(!EFMap.Contains(E)) return 0;
1514 TopTools_ListIteratorOfListOfShape It;
1516 for(It.Initialize(EFMap(E)); It.More(); It.Next()){
1517 if(Fref.IsNull()) Fref = It.Value();
1518 else if(!Fref.IsSame(It.Value())) return 0;
1523 static void ChFi3d_MakeExtremities(Handle(ChFiDS_Stripe)& Stripe,
1524 TopOpeBRepDS_DataStructure& DStr,
1525 const ChFiDS_Map& EFMap,
1526 const Standard_Real tol3d,
1527 const Standard_Real tol2d)
1529 Handle(ChFiDS_Spine)& sp = Stripe->ChangeSpine();
1530 Standard_Real Pardeb,Parfin;
1531 Handle(Geom_Curve) C3d;
1532 Standard_Real tolreached;
1533 if(sp->IsPeriodic()){
1535 const Handle(ChFiDS_SurfData)&
1536 SDF = Stripe->SetOfSurfData()->Sequence().First();
1537 const ChFiDS_CommonPoint& CV1 = SDF->VertexFirstOnS1();
1538 const ChFiDS_CommonPoint& CV2 = SDF->VertexFirstOnS2();
1539 if ( !CV1.Point().IsEqual(CV2.Point(), 0) ) {
1540 ChFi3d_ComputeArete(CV1,
1541 SDF->InterferenceOnS1().PCurveOnSurf()->
1542 Value(SDF->InterferenceOnS1().FirstParameter()),
1544 SDF->InterferenceOnS2().PCurveOnSurf()->
1545 Value(SDF->InterferenceOnS2().FirstParameter()),
1546 DStr.Surface(SDF->Surf()).Surface(),C3d,
1547 Stripe->ChangeFirstPCurve(),Pardeb,Parfin,
1548 tol3d,tol2d,tolreached,0);
1549 TopOpeBRepDS_Curve Crv(C3d,tolreached);
1550 Stripe->ChangeFirstCurve(DStr.AddCurve(Crv));
1551 Stripe->ChangeFirstParameters(Pardeb,Parfin);
1552 Stripe->ChangeIndexFirstPointOnS1
1553 (ChFi3d_IndexPointInDS(SDF->VertexFirstOnS1(),DStr));
1554 Stripe->ChangeIndexFirstPointOnS2
1555 (ChFi3d_IndexPointInDS(SDF->VertexFirstOnS2(),DStr));
1556 Standard_Integer ICurv = Stripe->FirstCurve();
1557 Stripe->ChangeLastParameters(Pardeb,Parfin);
1558 Stripe->ChangeLastCurve(ICurv);
1559 Stripe->ChangeIndexLastPointOnS1(Stripe->IndexFirstPointOnS1());
1560 Stripe->ChangeIndexLastPointOnS2(Stripe->IndexFirstPointOnS2());
1562 const Handle(ChFiDS_SurfData)&
1563 SDL = Stripe->SetOfSurfData()->Sequence().Last();
1566 ChFi3d_ComputePCurv(C3d,
1567 SDL->InterferenceOnS1().PCurveOnSurf()->
1568 Value(SDL->InterferenceOnS1().LastParameter()),
1569 SDL->InterferenceOnS2().PCurveOnSurf()->
1570 Value(SDL->InterferenceOnS2().LastParameter()),
1571 Stripe->ChangeLastPCurve(),
1572 DStr.Surface(SDL->Surf()).Surface(),
1573 Pardeb,Parfin,tol3d,tolreached);
1574 Standard_Real oldtol = DStr.ChangeCurve(ICurv).Tolerance();
1575 DStr.ChangeCurve(ICurv).Tolerance(Max(oldtol,tolreached));
1577 ChFi3d_EnlargeBox(CV1.Arc(),EFMap(CV1.Arc()),CV1.ParameterOnArc(),b1);
1581 ChFi3d_EnlargeBox(CV2.Arc(),EFMap(CV2.Arc()),CV2.ParameterOnArc(),b2);
1583 ChFi3d_EnlargeBox(DStr,Stripe,SDF,b1,b2,1);
1584 ChFi3d_EnlargeBox(DStr,Stripe,SDL,b1,b2,0);
1585 if (!CV1.IsVertex())
1586 ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexFirstPointOnS1());
1587 if (!CV2.IsVertex())
1588 ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexFirstPointOnS2());
1591 // Case of the single extremity
1592 if (CV1.IsVertex()) {
1593 ChFi3d_SingularExtremity(Stripe, DStr, CV1.Vertex(), tol3d, tol2d);
1596 else { cout << "MakeExtremities : Singularity out of Vertex !!" << endl; }
1602 const Handle(ChFiDS_SurfData)&
1603 SDdeb = Stripe->SetOfSurfData()->Sequence().First();
1605 const ChFiDS_CommonPoint& cpdeb1 = SDdeb->VertexFirstOnS1();
1606 const ChFiDS_CommonPoint& cpdeb2 = SDdeb->VertexFirstOnS2();
1607 Standard_Boolean freedeb = sp->FirstStatus() == ChFiDS_FreeBoundary;
1608 if(!freedeb && cpdeb1.IsOnArc() && cpdeb2.IsOnArc()){
1609 freedeb = (IsFree(cpdeb1.Arc(),EFMap) && IsFree(cpdeb2.Arc(),EFMap));
1612 sp->SetFirstStatus(ChFiDS_FreeBoundary);
1614 if ( !cpdeb1.Point().IsEqual(cpdeb2.Point(), 0) ) {
1615 Standard_Boolean plane;
1617 UV1=SDdeb->InterferenceOnS1().PCurveOnSurf()->
1618 Value(SDdeb->InterferenceOnS1().FirstParameter());
1619 UV2=SDdeb->InterferenceOnS2().PCurveOnSurf()->
1620 Value(SDdeb->InterferenceOnS2().FirstParameter());
1621 // The intersection of the fillet by a plane is attempted
1623 Handle(GeomAdaptor_HSurface) HConge=ChFi3d_BoundSurf(DStr,SDdeb,1,2);
1624 ChFi3d_CoupeParPlan(cpdeb1,cpdeb2,HConge,UV1,UV2,
1625 tol3d,tol2d,C3d,Stripe->ChangeFirstPCurve(),tolreached,
1626 Pardeb,Parfin,plane);
1628 ChFi3d_ComputeArete(cpdeb1,
1629 SDdeb->InterferenceOnS1().PCurveOnSurf()->
1630 Value(SDdeb->InterferenceOnS1().FirstParameter()),
1632 SDdeb->InterferenceOnS2().PCurveOnSurf()->
1633 Value(SDdeb->InterferenceOnS2().FirstParameter()),
1634 DStr.Surface(SDdeb->Surf()).Surface(),C3d,
1635 Stripe->ChangeFirstPCurve(),Pardeb,Parfin,
1636 tol3d,tol2d,tolreached,0);
1637 TopOpeBRepDS_Curve Crv(C3d,tolreached);
1638 Stripe->ChangeFirstCurve(DStr.AddCurve(Crv));
1639 Stripe->ChangeFirstParameters(Pardeb,Parfin);
1640 Stripe->ChangeIndexFirstPointOnS1
1641 (ChFi3d_IndexPointInDS(SDdeb->VertexFirstOnS1(),DStr));
1642 Stripe->ChangeIndexFirstPointOnS2
1643 (ChFi3d_IndexPointInDS(SDdeb->VertexFirstOnS2(),DStr));
1644 if(cpdeb1.IsOnArc()){
1645 ChFi3d_EnlargeBox(cpdeb1.Arc(),EFMap(cpdeb1.Arc()),cpdeb1.ParameterOnArc(),b1);
1647 if(cpdeb2.IsOnArc()){
1648 ChFi3d_EnlargeBox(cpdeb2.Arc(),EFMap(cpdeb2.Arc()),cpdeb2.ParameterOnArc(),b2);
1650 ChFi3d_EnlargeBox(DStr,Stripe,SDdeb,b1,b2,1);
1651 if (!cpdeb1.IsVertex())
1652 ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexFirstPointOnS1());
1653 if (!cpdeb2.IsVertex())
1654 ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexFirstPointOnS2());
1656 else { // Case of a singular extremity
1657 if (cpdeb1.IsVertex()) {
1658 ChFi3d_SingularExtremity(Stripe, DStr, cpdeb1.Vertex(), tol3d, tol2d);
1661 else { cout << "MakeExtremities : Singularity out of Vertex !!" << endl; }
1665 const Handle(ChFiDS_SurfData)&
1666 SDfin = Stripe->SetOfSurfData()->Sequence().Last();
1667 const ChFiDS_CommonPoint& cpfin1 = SDfin->VertexLastOnS1();
1668 const ChFiDS_CommonPoint& cpfin2 = SDfin->VertexLastOnS2();
1669 Standard_Boolean freefin = sp->LastStatus() == ChFiDS_FreeBoundary;
1670 if(!freefin && cpfin1.IsOnArc() && cpfin2.IsOnArc()){
1671 freefin = (IsFree(cpfin1.Arc(),EFMap) && IsFree(cpfin2.Arc(),EFMap));
1674 sp->SetLastStatus(ChFiDS_FreeBoundary);
1676 if ( !cpfin1.Point().IsEqual(cpfin2.Point(), 0) ) {
1677 Standard_Boolean plane;
1679 UV1=SDfin->InterferenceOnS1().PCurveOnSurf()->
1680 Value(SDfin->InterferenceOnS1().LastParameter());
1681 UV2=SDfin->InterferenceOnS2().PCurveOnSurf()->
1682 Value(SDfin->InterferenceOnS2().LastParameter());
1683 // Intersection of the fillet by a plane is attempted
1685 Handle(GeomAdaptor_HSurface) HConge=ChFi3d_BoundSurf(DStr,SDfin,1,2);
1686 ChFi3d_CoupeParPlan(cpfin1,cpfin2,HConge,UV1,UV2,
1687 tol3d,tol2d,C3d,Stripe->ChangeLastPCurve(),tolreached,
1688 Pardeb,Parfin,plane);
1690 ChFi3d_ComputeArete(cpfin1,
1691 SDfin->InterferenceOnS1().PCurveOnSurf()->
1692 Value(SDfin->InterferenceOnS1().LastParameter()),
1694 SDfin->InterferenceOnS2().PCurveOnSurf()->
1695 Value(SDfin->InterferenceOnS2().LastParameter()),
1696 DStr.Surface(SDfin->Surf()).Surface(),C3d,
1697 Stripe->ChangeLastPCurve(),Pardeb,Parfin,
1698 tol3d,tol2d,tolreached,0);
1699 TopOpeBRepDS_Curve Crv(C3d,tolreached);
1700 Stripe->ChangeLastCurve(DStr.AddCurve(Crv));
1701 Stripe->ChangeLastParameters(Pardeb,Parfin);
1702 Stripe->ChangeIndexLastPointOnS1
1703 (ChFi3d_IndexPointInDS(SDfin->VertexLastOnS1(),DStr));
1704 Stripe->ChangeIndexLastPointOnS2
1705 (ChFi3d_IndexPointInDS(SDfin->VertexLastOnS2(),DStr));
1706 if(cpfin1.IsOnArc()){
1707 ChFi3d_EnlargeBox(cpfin1.Arc(),EFMap(cpfin1.Arc()),cpfin1.ParameterOnArc(),b1);
1709 if(cpfin2.IsOnArc()){
1710 ChFi3d_EnlargeBox(cpfin2.Arc(),EFMap(cpfin2.Arc()),cpfin2.ParameterOnArc(),b2);
1712 ChFi3d_EnlargeBox(DStr,Stripe,SDfin,b1,b2,0);
1713 if (!cpfin1.IsVertex())
1714 ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexLastPointOnS1());
1715 if (!cpfin2.IsVertex())
1716 ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexLastPointOnS2());
1718 else { // Case of the single extremity
1719 if (cpfin1.IsVertex()) {
1720 ChFi3d_SingularExtremity(Stripe, DStr, cpfin1.Vertex(), tol3d, tol2d);
1723 else { cout << "MakeExtremities : Singularity out of Vertex !!" << endl; }
1729 //=======================================================================
1730 //function : ChFi3d_Purge
1732 //=======================================================================
1734 static void ChFi3d_Purge (Handle(ChFiDS_Stripe)& Stripe,
1735 Handle(ChFiDS_SurfData)& SD,
1736 const ChFiDS_CommonPoint& VRef,
1737 const Standard_Boolean isfirst,
1738 const Standard_Integer ons,
1739 Standard_Boolean& intf,
1740 Standard_Boolean& intl)
1742 if (isfirst) intf = 1; else intl = 1; // End.
1743 Standard_Integer opp = 3-ons;
1744 if (!SD->Vertex(isfirst,opp).IsOnArc() ||
1745 SD->TwistOnS1() || SD->TwistOnS2() ) {
1747 cout<<"ChFi3d_Purge : No output on extension."<<endl;
1749 ChFiDS_SequenceOfSurfData& Seq =
1750 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1751 if(isfirst) Seq.Remove(1);
1752 else Seq.Remove(Seq.Length());
1755 if (ons == 1) SD->ChangeIndexOfS1(0);
1756 else SD->ChangeIndexOfS2(0);
1758 SD->ChangeVertex(!isfirst,ons) = VRef;
1759 SD->ChangeVertex(isfirst,ons) = VRef;
1761 ChFiDS_FaceInterference& fi = SD->ChangeInterference(ons);
1762 if(isfirst) fi.SetFirstParameter(fi.LastParameter());
1763 else fi.SetLastParameter(fi.FirstParameter());
1767 //=======================================================================
1768 //function : InsertAfter
1769 //purpose : insert Item after ref in Seq. If ref is null, the item is
1770 // inserted at the beginning.
1771 //=======================================================================
1773 static void InsertAfter (Handle(ChFiDS_Stripe)& Stripe,
1774 Handle(ChFiDS_SurfData)& Ref,
1775 Handle(ChFiDS_SurfData)& Item)
1778 Standard_Failure::Raise("InsertAfter : twice the same surfdata.");
1780 ChFiDS_SequenceOfSurfData& Seq =
1781 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1783 if (Seq.IsEmpty() || Ref.IsNull()) {
1786 for (Standard_Integer i = 1; i <= Seq.Length(); i++) {
1787 if (Seq.Value(i) == Ref) {
1788 Seq.InsertAfter(i,Item);
1794 //=======================================================================
1795 //function : RemoveSD
1797 //=======================================================================
1799 static void RemoveSD (Handle(ChFiDS_Stripe)& Stripe,
1800 Handle(ChFiDS_SurfData)& Prev,
1801 Handle(ChFiDS_SurfData)& Next)
1803 ChFiDS_SequenceOfSurfData& Seq =
1804 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1805 if(Seq.IsEmpty()) return;
1806 Standard_Integer iprev = 0, inext = 0;
1807 for (Standard_Integer i = 1; i <= Seq.Length(); i++) {
1808 if (Seq.Value(i) == Prev) iprev = i + 1;
1809 if (Seq.Value(i) == Next) { inext = i - 1; break; }
1811 if(Prev.IsNull()) iprev = 1;
1812 if(Next.IsNull()) inext = Seq.Length();
1813 if(iprev <= inext) Seq.Remove(iprev,inext);
1816 //=======================================================================
1817 //function : InsertBefore
1818 //purpose : Insert item before ref in Seq. If ref is null, the item is
1819 // inserted in the queue.
1820 //=======================================================================
1822 static void InsertBefore (Handle(ChFiDS_Stripe)& Stripe,
1823 Handle(ChFiDS_SurfData)& Ref,
1824 Handle(ChFiDS_SurfData)& Item)
1827 Standard_Failure::Raise("InsertBefore : twice the same surfdata.");
1829 ChFiDS_SequenceOfSurfData& Seq =
1830 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1832 if (Seq.IsEmpty() || Ref.IsNull()) {
1835 for (Standard_Integer i = 1; i <= Seq.Length(); i++) {
1836 if (Seq.Value(i) == Ref) {
1837 Seq.InsertBefore(i,Item);
1844 //=======================================================================
1845 //function : PerformSetOfSurfOnElSpine
1847 //=======================================================================
1849 void ChFi3d_Builder::PerformSetOfSurfOnElSpine
1850 (const Handle(ChFiDS_HElSpine)& HGuide,
1851 Handle(ChFiDS_Stripe)& Stripe,
1852 Handle(BRepTopAdaptor_TopolTool)& It1,
1853 Handle(BRepTopAdaptor_TopolTool)& It2,
1854 const Standard_Boolean Simul)
1857 OSD_Chronometer ch1;
1860 ChFiDS_ElSpine& Guide = HGuide->ChangeCurve();
1861 Standard_Real wf = Guide.FirstParameter();
1862 Standard_Real wl = Guide.LastParameter();
1863 Standard_Real locfleche = (wl - wf) * fleche;
1864 Standard_Real wfsav = wf, wlsav = wl;
1865 //Now the ElSpine is artificially extended to help rsnld.
1866 Standard_Real prab = 0.01;
1867 Guide.FirstParameter(wf-prab*(wl-wf));
1868 Guide.LastParameter (wl+prab*(wl-wf));
1869 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
1870 Standard_Integer ii, nbed = Spine->NbEdges();
1871 Standard_Real lastedlastp = Spine->LastParameter(nbed);
1873 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
1875 Handle(ChFiDS_SurfData) ref = Guide.Previous();
1876 Handle(ChFiDS_SurfData) refbis, SD;
1877 Handle(ChFiDS_SurfData) raf = Guide.Next();
1878 RemoveSD(Stripe,ref,raf);
1880 Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface();
1881 Handle(BRepAdaptor_HSurface) HS2 = new BRepAdaptor_HSurface();
1882 Handle(BRepAdaptor_HSurface) HS3, HS4;
1883 Handle(BRepAdaptor_HSurface) HSref1 = new BRepAdaptor_HSurface();
1884 Handle(BRepAdaptor_HSurface) HSref2 = new BRepAdaptor_HSurface();
1885 Handle(BRepAdaptor_HCurve2d) HC1,HC2;
1886 Handle(BRepAdaptor_HCurve2d) HCref1 = new BRepAdaptor_HCurve2d();
1887 Handle(BRepAdaptor_HCurve2d) HCref2 = new BRepAdaptor_HCurve2d();
1888 Standard_Boolean decroch1 = Standard_False, decroch2 = Standard_False;
1889 Standard_Boolean RecP1 = Standard_False, RecS1 = Standard_False, RecRst1 = Standard_False, obstacleon1 = Standard_False;
1890 Standard_Boolean RecP2 = Standard_False, RecS2 = Standard_False, RecRst2 = Standard_False, obstacleon2 = Standard_False;
1891 gp_Pnt2d pp1,pp2,pp3,pp4;
1892 Standard_Real w1 = 0.,w2 = 0.;
1893 math_Vector Soldep(1,4);
1894 math_Vector SoldepCS(1,3);
1895 math_Vector SoldepCC(1,2);
1897 // Restore a neighboring KPart.
1898 // If no neighbor calculation start point.
1899 Standard_Boolean forward = Standard_True;
1900 Standard_Boolean Inside = Standard_False;
1901 Standard_Real First = wf;
1902 Standard_Real Last = wl;
1903 Standard_Boolean Ok1 = 1,Ok2 = 1;
1904 // Restore the next KPart if it exists
1906 if(ref.IsNull() && raf.IsNull()){
1907 //sinon solution approchee.
1908 Inside = Standard_True;
1911 ChFi3d_InitChron(ch1);// init perf for StartSol
1914 StartSol(Stripe,HGuide,HS1,HS2,It1,It2,pp1,pp2,First);
1917 ChFi3d_ResultChron(ch1,t_startsol); // result perf for StartSol
1921 if(Guide.IsPeriodic()) {
1922 Last = First - Guide.Period();
1923 Guide.FirstParameter(Last);
1924 Guide.LastParameter (First * 1.1);//Extension to help rsnld.
1928 if(!Spine->IsPeriodic() && (wl - lastedlastp > -tolesp)){
1929 Vref = Spine->LastVertex();
1932 if(!Spine->IsPeriodic() && (wf < tolesp)){
1933 Vref = Spine->FirstVertex();
1936 forward = Standard_False;
1937 First = wl; Last = Guide.FirstParameter();
1941 ChFi3d_InitChron(ch1);// init perf for startsol
1945 Ok1 = StartSol(Spine,HS1,pp1,HC1,w1,ref,!forward,1,
1946 HSref1,HCref1,RecP1,RecS1,RecRst1,obstacleon1,
1947 HS3,pp3,decroch1,Vref);
1948 Ok2 = StartSol(Spine,HS2,pp2,HC2,w2,ref,!forward,2,
1949 HSref2,HCref2, RecP2,RecS2,RecRst2,obstacleon2,
1950 HS4,pp4,decroch2,Vref);
1955 ChFi3d_ResultChron(ch1,t_startsol); // result perf for startsol
1959 if(Ok1 == 1 && Ok2 == 1) {
1960 if(forward) Guide.FirstParameter(wf);
1961 else Guide.LastParameter(wl);
1964 Standard_Boolean fini = Standard_False;
1965 Standard_Boolean complete = Inside;
1966 if(!Guide.IsPeriodic()){
1967 Standard_Integer indf = Spine->Index(wf);
1968 Standard_Integer indl = Spine->Index(wl,0);
1969 if(Spine->IsPeriodic() && (indl < indf)) indl += nbed;
1972 // No Max at the touch : 20 points by edge at average without
1973 // counting the extensions.
1975 Standard_Real bidf = wf, bidl = wl;
1976 if(!Spine->IsPeriodic()) {
1978 bidl = Min(wl,Spine->LastParameter(Spine->NbEdges()));
1979 // PMN 20/07/98 : Attention in case if there is only extension
1980 if ((bidl-bidf) < 0.01 * Spine->LastParameter(Spine->NbEdges())) {
1985 Standard_Real MaxStep = (bidl-bidf)*0.05/nbed;
1986 Standard_Real Firstsov = 0.;
1987 Standard_Boolean intf = 0, intl = 0;
1989 // are these the ends (no extension on periodic).
1991 if(!Spine->IsPeriodic()){
1992 if(wf < tolesp && (complete == Inside)){
1993 if(Spine->FirstStatus() == ChFiDS_OnSame) intf = 2;
1996 if(Spine->IsTangencyExtremity(Standard_True)){
1998 Guide.FirstParameter(wfsav);
2000 if(wl - lastedlastp > -tolesp){
2001 if(Spine->LastStatus() == ChFiDS_OnSame) intl = 2;
2004 if(Spine->IsTangencyExtremity(Standard_False)){
2006 Guide.LastParameter(wlsav);
2009 if(intf && !forward) Vref = Spine->FirstVertex();
2010 if(intl && forward) Vref = Spine->LastVertex();
2014 ChFi3d_InitChron(ch1);// init perf for StartSol
2017 Ok1 = StartSol(Spine,HS1,pp1,HC1,w1,ref,!forward,1,
2018 HSref1,HCref1, RecP1,RecS1,RecRst1,obstacleon1,
2019 HS3,pp3,decroch1,Vref);
2020 Ok2 = StartSol(Spine,HS2,pp2,HC2,w2,ref,!forward,2,
2021 HSref2,HCref2, RecP2,RecS2,RecRst2,obstacleon2,
2022 HS4,pp4,decroch2,Vref);
2025 ChFi3d_ResultChron(ch1,t_startsol); // result perf for StartSol
2030 // No more connected faces. Construction of the tangent plane to continue the path
2031 // till the output on the other face.
2032 if ((!Ok1 && HC1.IsNull()) || (!Ok2 && HC2.IsNull())) {
2033 if ((intf && !forward) || (intl && forward)) {
2034 if (!Ok1) ChFi3d_BuildPlane (DStr,HS1,pp1,ref,!forward,1);
2035 if (!Ok2) ChFi3d_BuildPlane (DStr,HS2,pp2,ref,!forward,2);
2037 else if(intl) intl = 5;
2038 if(forward) Guide.FirstParameter(wf);
2039 else Guide.LastParameter(wl);
2041 else Standard_Failure::Raise("PerformSetOfSurfOnElSpine : Chaining is impossible.");
2044 // Definition of the domain of path It1, It2
2045 It1->Initialize(HS1);
2046 It2->Initialize(HS2);
2048 // Calculate one (several if singularity) SurfaData
2049 SD = new ChFiDS_SurfData();
2050 ChFiDS_SequenceOfSurfData SeqSD;
2053 if(obstacleon1 && obstacleon2){
2054 TopAbs_Orientation Or1 = HSref1->ChangeSurface().Face().Orientation();
2055 TopAbs_Orientation Or2 = HSref2->ChangeSurface().Face().Orientation();
2056 Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2,
2057 Stripe->OrientationOnFace1(),
2058 Stripe->OrientationOnFace2(),
2062 // Calculate the criterion of Choice edge / edge
2063 if (Choix%2 == 0) Choix = 4;
2066 SoldepCC(1) = w1; SoldepCC(2) = w2;
2068 SimulSurf(SD,HGuide,Spine,Choix,
2069 HS1,It1,HC1,HSref1,HCref1,decroch1,Or1,
2070 HS2,It2,HC2,HSref2,HCref2,decroch2,Or2,
2071 locfleche,tolesp,First,Last,Inside,Inside,forward,
2072 RecP1,RecRst1,RecP2,RecRst2,SoldepCC);
2076 ChFi3d_InitChron(ch1); // init perf for PerformSurf
2078 PerformSurf(SeqSD,HGuide,Spine,Choix,
2079 HS1,It1,HC1,HSref1,HCref1,decroch1,Or1,
2080 HS2,It2,HC2,HSref2,HCref2,decroch2,Or2,
2081 MaxStep,locfleche,tolesp,First,Last,Inside,Inside,forward,
2082 RecP1,RecRst1,RecP2,RecRst2,SoldepCC);
2084 ChFi3d_ResultChron(ch1,t_performsurf); //result perf for PerformSurf
2087 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2088 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2090 else if (obstacleon1){
2091 TopAbs_Orientation Or1 = HSref1->ChangeSurface().Face().Orientation();
2092 TopAbs_Orientation Or2 = HS2->ChangeSurface().Face().Orientation();
2093 Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2,
2094 Stripe->OrientationOnFace1(),
2095 Stripe->OrientationOnFace2(),
2097 if(Choix%2 == 1) Choix++;
2099 SoldepCS(3) = w1; SoldepCS(1) = pp2.X(); SoldepCS(2) = pp2.Y();
2101 SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,HC1,HSref1,HCref1,decroch1,
2102 HS2,It2,Or2,locfleche,tolesp,First,Last,
2103 Inside,Inside,forward,RecP1,RecS2,RecRst1,SoldepCS);
2107 ChFi3d_InitChron(ch1); // init perf for PerformSurf
2109 PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,HC1,HSref1,HCref1,decroch1,
2110 HS2,It2,Or2,MaxStep,locfleche,tolesp,First,Last,
2111 Inside,Inside,forward,RecP1,RecS2,RecRst1,SoldepCS);
2113 ChFi3d_ResultChron(ch1,t_performsurf);//result perf for PerformSurf
2116 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2117 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2120 else if (obstacleon2){
2121 TopAbs_Orientation Or1 = HS1->ChangeSurface().Face().Orientation();
2122 TopAbs_Orientation Or2 = HSref2->ChangeSurface().Face().Orientation();
2123 Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2,
2124 Stripe->OrientationOnFace1(),
2125 Stripe->OrientationOnFace2(),
2127 SoldepCS(3) = w2; SoldepCS(1) = pp1.X(); SoldepCS(2) = pp1.Y();
2129 SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,Or1,
2130 HS2,It2,HC2,HSref2,HCref2,decroch2,locfleche,tolesp,
2131 First,Last,Inside,Inside,forward,RecP2,RecS1,RecRst2,SoldepCS);
2135 ChFi3d_InitChron(ch1); // init perf for PerformSurf
2137 PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,Or1,
2138 HS2,It2,HC2,HSref2,HCref2,decroch2,MaxStep,locfleche,tolesp,
2139 First,Last,Inside,Inside,forward,RecP2,RecS1,RecRst2,SoldepCS);
2141 ChFi3d_ResultChron(ch1,t_performsurf); //result perf for PerformSurf
2144 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2145 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2149 CallPerformSurf(Stripe, Simul, SeqSD, SD,
2151 HS1, HS3, pp1, pp3, It1,
2152 HS2, HS4, pp2, pp4, It2,
2153 MaxStep,locfleche,tolesp,
2154 First,Last,Inside,Inside,forward,
2155 RecS1,RecS2,Soldep,intf,intl,
2157 decroch1 = decroch2 = 0;
2160 if(!done) { // Case of fail
2161 if ((!Ok1 && !obstacleon1) || (!Ok2 && !obstacleon2)) {
2162 //Fail in a part of extension is not serious
2164 done = Standard_True;
2165 Inside = Standard_False;
2166 if (forward) intl = 1;
2169 else { // Otherwise invalidation of the stripe.
2170 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
2171 Standard_Failure::Raise("CallPerformSurf : Path failed!");
2178 for (ii=1; ii<=SeqSD.Length(); ii++) {
2180 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2181 if(obstacleon1) SD->SetIndexOfC1(DStr.AddShape(HC1->ChangeCurve2d().Edge()));
2182 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2183 if(obstacleon2) SD->SetIndexOfC2(DStr.AddShape(HC2->ChangeCurve2d().Edge()));
2184 InsertAfter (Stripe, refbis, SD);
2189 for (ii=SeqSD.Length(); ii>=1; ii--) {
2191 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2192 if(obstacleon1) SD->SetIndexOfC1(DStr.AddShape(HC1->ChangeCurve2d().Edge()));
2193 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2194 if(obstacleon2) SD->SetIndexOfC2(DStr.AddShape(HC2->ChangeCurve2d().Edge()));
2195 InsertBefore(Stripe,refbis,SD);
2200 if (!Ok1 && !obstacleon1)
2201 // clean infos on the plane of extension.
2202 ChFi3d_Purge (Stripe,SD,ref->Vertex(!forward,1),!forward,1,intf,intl);
2204 if (!Ok2 && !obstacleon2)
2205 // clean infos on the plane of extension.
2206 ChFi3d_Purge (Stripe,SD,ref->Vertex(!forward,2),!forward,2,intf,intl);
2208 // The end. The reference is changed.
2212 if(Inside){// There are starting solutions for the next.
2213 Inside = Standard_False;
2215 if(Guide.IsPeriodic()) {
2216 complete = Standard_False;
2217 wf = Guide.FirstParameter();
2218 wl = Guide.LastParameter();
2222 fini = ((wl - Last) <= 10.*tolesp ||
2223 (intl && !(obstacleon1 || obstacleon2))); //General case
2225 if (!fini && Guide.IsPeriodic() &&
2226 ((wl - Last)< Guide.Period()*1.e-3)) {
2227 // It is tested if reframing of extremes is done at the same edge
2229 Handle(ChFiDS_SurfData) thefirst, thelast;
2230 thefirst = Stripe->SetOfSurfData()->Sequence().First();
2231 thelast = Stripe->SetOfSurfData()->Sequence().Last();
2233 if (thefirst->VertexFirstOnS1().IsOnArc() &&
2234 thelast->VertexLastOnS1().IsOnArc())
2235 fini = thefirst->VertexFirstOnS1().Arc().IsSame
2236 (thelast->VertexLastOnS1().Arc());
2238 thefirst->VertexFirstOnS2().IsOnArc() &&
2239 thelast->VertexLastOnS2().IsOnArc())
2240 fini = thefirst->VertexFirstOnS2().Arc().IsSame
2241 (thelast->VertexLastOnS2().Arc());
2244 return; //It is ended!
2247 if(fini && complete) {
2248 // restart in the opposite direction.
2249 ref = Stripe->SetOfSurfData()->Sequence().First();
2250 forward = Standard_False;
2251 fini = Standard_False;
2260 fini = ((First - wf) <= 10.*tolesp ||
2261 (intf && !(obstacleon1 || obstacleon2)));
2262 complete = Standard_False;
2266 // The initial state is restored
2267 if(!Guide.IsPeriodic()){
2268 Guide.FirstParameter(wfsav);
2269 Guide.LastParameter (wlsav);
2274 //=======================================================================
2275 //function : PerformSetOfKPart
2277 //=======================================================================
2279 void ChFi3d_Builder::PerformSetOfKPart(Handle(ChFiDS_Stripe)& Stripe,
2280 const Standard_Boolean Simul)
2282 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
2283 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
2284 Handle(BRepAdaptor_HSurface) HS1,HS2;
2285 TopAbs_Orientation Or1,Or2,RefOr1,RefOr2;
2286 Standard_Integer RefChoix;
2288 // initialization of the stripe.
2290 Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData();
2291 HData = new ChFiDS_HData();
2292 ChFiDS_SequenceOfSurfData& SeqSurf = HData->ChangeSequence();
2294 StripeOrientations(Spine,RefOr1,RefOr2,RefChoix);
2295 Stripe->OrientationOnFace1(RefOr1);
2296 Stripe->OrientationOnFace2(RefOr2);
2297 Stripe->Choix(RefChoix);
2299 Handle(BRepTopAdaptor_TopolTool) It1 = new BRepTopAdaptor_TopolTool();
2300 Handle(BRepTopAdaptor_TopolTool) It2 = new BRepTopAdaptor_TopolTool();
2302 Standard_Real WFirst,WLast = 0.;
2303 gp_Vec TFirst,TLast,TEndPeriodic;
2304 gp_Pnt PFirst,PLast,PEndPeriodic;
2305 Standard_Boolean intf = 0, intl = 0;
2307 Handle(ChFiDS_HElSpine) CurrentHE = new ChFiDS_HElSpine();
2308 Spine->D1(Spine->FirstParameter(),PFirst,TFirst);
2309 CurrentHE->ChangeCurve().FirstParameter(Spine->FirstParameter());
2310 CurrentHE->ChangeCurve().SetFirstPointAndTgt(PFirst,TFirst);
2312 Standard_Boolean YaKPart = Standard_False;
2313 Standard_Integer iedgelastkpart = 0;
2315 Standard_Real WStartPeriodic = 0.;
2316 Standard_Real WEndPeriodic = Spine->LastParameter(Spine->NbEdges());
2317 Spine->D1(WEndPeriodic,PEndPeriodic,TEndPeriodic);
2319 // Construction of particular cases.
2321 for (Standard_Integer iedge = 1; iedge <= Spine->NbEdges(); iedge++){
2323 ConexFaces(Spine,iedge,RefChoix,HS1,HS2);
2325 if (ChFi3d_KParticular(Spine,iedge,HS1->ChangeSurface(),HS2->ChangeSurface())) {
2326 intf = ((iedge == 1) && !Spine->IsPeriodic());
2327 intl = ((iedge == Spine->NbEdges()) && !Spine->IsPeriodic());
2328 Or1 = HS1->ChangeSurface().Face().Orientation();
2329 Or2 = HS2->ChangeSurface().Face().Orientation();
2330 ChFi3d::NextSide(Or1,Or2,RefOr1,RefOr2,RefChoix);
2331 It1->Initialize(HS1);
2332 It2->Initialize(HS2);
2334 Handle(ChFiDS_SurfData) SD = new ChFiDS_SurfData();
2335 ChFiDS_SequenceOfSurfData LSD;
2337 if(!ChFiKPart_ComputeData::Compute(DStr,SD,HS1,HS2,Or1,Or2,Spine,iedge)){
2339 cout<<"failed calculation KPart"<<endl;
2342 else if(!SplitKPart(SD,LSD,Spine,iedge,HS1,It1,HS2,It2,intf,intl)){
2344 cout<<"failed calculation KPart"<<endl;
2348 else iedgelastkpart = iedge;
2349 if(Spine->IsPeriodic()){//debug provisory for SD that arrive in desorder.
2350 Standard_Integer nbsd = LSD.Length();
2351 Standard_Real period = Spine->Period();
2352 Standard_Real wfp = WStartPeriodic, wlp = WEndPeriodic;
2353 // modified by NIZHNY-EAP Thu Nov 25 12:57:53 1999 ___BEGIN___
2354 if(!YaKPart && nbsd>0){
2356 // modified by NIZHNY-EAP Thu Nov 25 12:57:57 1999 ___END___
2357 Handle(ChFiDS_SurfData) firstSD = LSD.ChangeValue(1);
2358 Standard_Real wwf = firstSD->FirstSpineParam();
2359 Standard_Real wwl = firstSD->LastSpineParam();
2360 wwf = ChFi3d_InPeriod(wwf,wfp,wlp,tolesp);
2361 wwl = ChFi3d_InPeriod(wwl,wfp,wlp,tolesp);
2362 if (wwl <= wwf + tolesp) wwl += period;
2366 for(Standard_Integer j = 1; j < nbsd; j++){
2367 Handle(ChFiDS_SurfData) jSD = LSD.Value(j);
2368 for(Standard_Integer k = j+1; k <= nbsd; k++){
2369 Handle(ChFiDS_SurfData) kSD = LSD.Value(k);
2370 Standard_Real jwf = jSD->FirstSpineParam();
2371 jwf = ChFi3d_InPeriod(jwf,wfp,wlp,tolesp);
2372 Standard_Real kwf = kSD->FirstSpineParam();
2373 kwf = ChFi3d_InPeriod(kwf,wfp,wlp,tolesp);
2375 LSD.SetValue(j,kSD);
2376 LSD.SetValue(k,jSD);
2381 TColStd_ListOfInteger li;
2382 for(Standard_Integer j = 1; j <= LSD.Length(); j++){
2383 Handle(ChFiDS_SurfData)& curSD = LSD.ChangeValue(j);
2384 if(Simul) SimulKPart(curSD);
2385 SeqSurf.Append(curSD);
2386 if(!Simul) li.Append(curSD->Surf());
2387 WFirst = LSD.Value(j)->FirstSpineParam();
2388 WLast = LSD.Value(j)->LastSpineParam();
2389 if(Spine->IsPeriodic()){
2390 WFirst = ChFi3d_InPeriod(WFirst,WStartPeriodic,WEndPeriodic,tolesp);
2391 WLast = ChFi3d_InPeriod(WLast ,WStartPeriodic,WEndPeriodic,tolesp);
2392 if (WLast <= WFirst + tolesp) WLast+= Spine->Period();
2394 TgtKP(LSD.Value(j),Spine,iedge,1,PFirst,TFirst);
2395 TgtKP(LSD.Value(j),Spine,iedge,0,PLast,TLast);
2397 // Determine the sections to approximate
2399 if(Spine->IsPeriodic()){
2400 WStartPeriodic = WFirst;
2401 WEndPeriodic = WStartPeriodic + Spine->Period();
2402 WLast = ElCLib::InPeriod(WLast,WStartPeriodic,WEndPeriodic);
2403 if (WLast <= WFirst + tolesp) WLast+= Spine->Period();
2404 PEndPeriodic = PFirst;
2405 TEndPeriodic = TFirst;
2406 Spine->SetFirstParameter(WStartPeriodic);
2407 Spine->SetLastParameter(WEndPeriodic);
2409 else if(!intf || (iedge > 1)){
2410 // start section -> first KPart
2411 // update of extension.
2412 Spine->SetFirstTgt(Min(0.,WFirst));
2413 CurrentHE->ChangeCurve().LastParameter (WFirst);
2414 CurrentHE->ChangeCurve().SetLastPointAndTgt(PFirst,TFirst);
2415 Spine->AppendElSpine(CurrentHE);
2416 CurrentHE->ChangeCurve().ChangeNext() = LSD.Value(j);
2417 CurrentHE = new ChFiDS_HElSpine();
2419 CurrentHE->ChangeCurve().FirstParameter(WLast);
2420 CurrentHE->ChangeCurve().SetFirstPointAndTgt(PLast,TLast);
2421 CurrentHE->ChangeCurve().ChangePrevious() = LSD.Value(j);
2422 YaKPart = Standard_True;
2425 if (WFirst - CurrentHE->FirstParameter() > tolesp) {
2426 // section between two KPart
2427 CurrentHE->ChangeCurve().LastParameter(WFirst);
2428 CurrentHE->ChangeCurve().SetLastPointAndTgt(PFirst,TFirst);
2429 Spine->AppendElSpine(CurrentHE);
2430 CurrentHE->ChangeCurve().ChangeNext() = LSD.Value(j);
2431 CurrentHE = new ChFiDS_HElSpine();
2433 CurrentHE->ChangeCurve().FirstParameter(WLast);
2434 CurrentHE->ChangeCurve().SetFirstPointAndTgt(PLast,TLast);
2435 CurrentHE->ChangeCurve().ChangePrevious() = LSD.Value(j);
2438 if(!li.IsEmpty()) myEVIMap.Bind(Spine->Edges(iedge),li);
2442 if (!intl || (iedgelastkpart < Spine->NbEdges())) {
2443 // section last KPart(or start of the spine) -> End of the spine.
2444 // update of the extension.
2446 if(Spine->IsPeriodic()){
2447 if(WEndPeriodic - WLast > tolesp){
2448 CurrentHE->ChangeCurve().LastParameter(WEndPeriodic);
2449 CurrentHE->ChangeCurve().SetLastPointAndTgt(PEndPeriodic,TEndPeriodic);
2450 if(!YaKPart) CurrentHE->ChangeCurve().SetPeriodic(Standard_True);
2451 Spine->AppendElSpine(CurrentHE);
2455 Spine->D1(Spine->LastParameter(),PLast,TLast);
2456 Spine->SetLastTgt(Max(Spine->LastParameter(Spine->NbEdges()),
2458 if (Spine->LastParameter() - WLast > tolesp) {
2459 CurrentHE->ChangeCurve().LastParameter(Spine->LastParameter());
2460 CurrentHE->ChangeCurve().SetLastPointAndTgt(PLast,TLast);
2461 Spine->AppendElSpine(CurrentHE);
2466 ChFiDS_ListOfHElSpine& ll = Spine->ChangeElSpines();
2467 ChFiDS_ListIteratorOfListOfHElSpine ILES(ll);
2468 for ( ; ILES.More(); ILES.Next()) {
2470 if(ChFi3d_GettraceCHRON()) elspine.Start();
2472 ChFi3d_PerformElSpine(ILES.Value(),Spine,myConti,tolesp);
2474 if(ChFi3d_GettraceCHRON()) { elspine.Stop(); }
2477 Spine->SplitDone(Standard_True);
2480 static Standard_Real ChFi3d_BoxDiag(const Bnd_Box& box)
2482 Standard_Real a,b,c,d,e,f;
2483 box.Get(a,b,c,d,e,f);
2486 Standard_Real diag = sqrt(d + e + f);
2490 //=======================================================================
2491 //function : PerformSetOfKGen
2493 //=======================================================================
2495 void ChFi3d_Builder::PerformSetOfKGen(Handle(ChFiDS_Stripe)& Stripe,
2496 const Standard_Boolean Simul)
2498 Handle(BRepTopAdaptor_TopolTool) It1 = new BRepTopAdaptor_TopolTool();
2499 Handle(BRepTopAdaptor_TopolTool) It2 = new BRepTopAdaptor_TopolTool();
2500 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
2501 ChFiDS_ListOfHElSpine& ll = Spine->ChangeElSpines();
2502 ChFiDS_ListIteratorOfListOfHElSpine ILES(ll);
2503 for ( ; ILES.More(); ILES.Next()) {
2505 if(ChFi3d_GettraceCHRON()) { chemine.Start(); }
2507 PerformSetOfSurfOnElSpine(ILES.Value(),Stripe,It1,It2,Simul);
2509 if(ChFi3d_GettraceCHRON()) chemine.Stop();
2513 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
2514 Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData();
2515 ChFiDS_SequenceOfSurfData& SeqSurf = HData->ChangeSequence();
2516 Standard_Integer len = SeqSurf.Length();
2517 Standard_Integer last = len, i;
2518 Standard_Boolean periodic = Spine->IsPeriodic();
2519 if(periodic) last++;
2520 // It is attempted to reprocess the squares that bore.
2521 for(i = 1; i <= len; i++){
2522 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2523 Standard_Boolean tw1 = cursd->TwistOnS1();
2524 Standard_Boolean tw2 = cursd->TwistOnS2();
2525 Handle(ChFiDS_SurfData) prevsd, nextsd;
2526 Standard_Integer iprev = i-1;
2528 if(periodic) iprev = len;
2530 Standard_Integer inext = i + 1;
2532 if(periodic) inext = 1;
2536 // For the moment only the surfaces where the twist is
2537 // detected at the path are corrected, it is necessary to control
2538 // more subtly the ugly traces (size, curvature, inflexion... )
2539 if(!tw1 && !tw2) continue;
2541 // It is decided (fairly at random) if the extended surface is ready for the filling.
2542 ChFiDS_FaceInterference& intf1 = cursd->ChangeInterferenceOnS1();
2543 ChFiDS_FaceInterference& intf2 = cursd->ChangeInterferenceOnS2();
2544 Standard_Integer cursurf1 = cursd->IndexOfS1();
2545 Standard_Integer cursurf2 = cursd->IndexOfS2();
2546 ChFiDS_CommonPoint& cpd1 = cursd->ChangeVertexFirstOnS1();
2547 ChFiDS_CommonPoint& cpd2 = cursd->ChangeVertexFirstOnS2();
2548 ChFiDS_CommonPoint& cpf1 = cursd->ChangeVertexLastOnS1();
2549 ChFiDS_CommonPoint& cpf2 = cursd->ChangeVertexLastOnS2();
2550 const gp_Pnt& pd1 = cpd1.Point();
2551 const gp_Pnt& pd2 = cpd2.Point();
2552 const gp_Pnt& pf1 = cpf1.Point();
2553 const gp_Pnt& pf2 = cpf2.Point();
2554 Standard_Real ddeb = pd1.Distance(pd2);
2555 Standard_Real dfin = pf1.Distance(pf2);
2556 Standard_Real don1 = pd1.Distance(pf1);
2557 Standard_Real don2 = pd2.Distance(pf2);
2558 Standard_Boolean possibleon1 = (don1 < 2*(ddeb + dfin));
2559 Standard_Boolean possibleon2 = (don2 < 2*(ddeb + dfin));
2560 if((tw1 && !possibleon1) || (tw2 && !possibleon2)) {
2561 Spine->SetErrorStatus(ChFiDS_TwistedSurface);
2562 Standard_Failure::Raise("adjustment by reprocessing the non-written points");
2565 // It is checked if there are presentable neighbors
2566 Standard_Boolean yaprevon1 = 0, yaprevon2 = 0;
2567 Standard_Boolean samesurfon1 = 0, samesurfon2 = 0;
2569 prevsd = SeqSurf.ChangeValue(iprev);
2570 yaprevon1 = !prevsd->TwistOnS1();
2571 samesurfon1 = (prevsd->IndexOfS1() == cursurf1);
2572 yaprevon2 = !prevsd->TwistOnS2();
2573 samesurfon2 = (prevsd->IndexOfS2() == cursurf2);
2575 Standard_Boolean yanexton1 = 0, yanexton2 = 0;
2577 nextsd = SeqSurf.ChangeValue(inext);
2578 yanexton1 = !nextsd->TwistOnS1();
2579 if(samesurfon1) samesurfon1 = (nextsd->IndexOfS1() == cursurf1);
2580 yanexton2 = !nextsd->TwistOnS2();
2581 if(samesurfon2) samesurfon2 = (nextsd->IndexOfS2() == cursurf2);
2583 // A contour of filling is constructed
2584 Handle(Geom2d_Curve) PC1 = intf1.PCurveOnFace();
2585 Handle(Geom2d_Curve) PC2 = intf2.PCurveOnFace();
2586 Handle(BRepAdaptor_HSurface) S1 = new BRepAdaptor_HSurface();
2587 TopoDS_Face F1 = TopoDS::Face(DStr.Shape(cursurf1));
2588 S1->ChangeSurface().Initialize(F1);
2589 Handle(BRepAdaptor_HSurface) S2 = new BRepAdaptor_HSurface();
2590 TopoDS_Face F2 = TopoDS::Face(DStr.Shape(cursurf2));
2591 S2->ChangeSurface().Initialize(F2);
2592 Handle(GeomFill_Boundary) Bdeb,Bfin,Bon1,Bon2;
2593 Standard_Boolean pointuon1 = 0, pointuon2 = 0;
2595 if(!yaprevon1 || !yanexton1){
2596 Spine->SetErrorStatus(ChFiDS_TwistedSurface);
2597 Standard_Failure::Raise
2598 ("adjustment by reprocessing the non-written points: no neighbor");
2600 ChFiDS_FaceInterference& previntf1 = prevsd->ChangeInterferenceOnS1();
2601 ChFiDS_FaceInterference& nextintf1 = nextsd->ChangeInterferenceOnS1();
2602 Standard_Real prevpar1 = previntf1.LastParameter();
2603 Standard_Real nextpar1 = nextintf1.FirstParameter();
2605 // It is checked if it is possible to intersect traces of neighbors
2606 // to create a sharp end.
2607 Handle(Geom2d_Curve) pcprev1 = previntf1.PCurveOnFace();
2608 Handle(Geom2d_Curve) pcnext1 = nextintf1.PCurveOnFace();
2609 Standard_Real nprevpar1,nnextpar1;
2611 // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 Begin
2612 // if(ChFi3d_IntTraces(prevsd,prevpar1,nprevpar1,1,1,
2613 // nextsd,nextpar1,nnextpar1,1,-1,p2d)){
2614 if(ChFi3d_IntTraces(prevsd,prevpar1,nprevpar1,1,1,
2615 nextsd,nextpar1,nnextpar1,1,-1,p2d,
2616 Standard_False, Standard_True)){
2617 // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 End
2618 previntf1.SetLastParameter(nprevpar1);
2619 nextintf1.SetFirstParameter(nnextpar1);
2624 gp_Pnt2d pdeb1,pfin1;
2625 gp_Vec2d vdeb1,vfin1;
2626 pcprev1->D1(prevpar1,pdeb1,vdeb1);
2627 pcnext1->D1(nextpar1,pfin1,vfin1);
2628 Bon1 = ChFi3d_mkbound(S1,PC1,-1,pdeb1,vdeb1,1,
2629 pfin1,vfin1,tolesp,2.e-4);
2633 //here the base is on 3D tangents of neighbors.
2634 const Handle(Geom_Curve)& c3dprev1 =
2635 DStr.Curve(previntf1.LineIndex()).Curve();
2636 const Handle(Geom_Curve)& c3dnext1 =
2637 DStr.Curve(nextintf1.LineIndex()).Curve();
2638 gp_Pnt Pdeb1, Pfin1;
2639 gp_Vec Vdeb1, Vfin1;
2640 c3dprev1->D1(prevpar1,Pdeb1,Vdeb1);
2641 c3dnext1->D1(nextpar1,Pfin1,Vfin1);
2642 gp_Pnt2d pdeb1,pfin1;
2643 Standard_Real pardeb1 = intf1.FirstParameter();
2644 Standard_Real parfin1 = intf1.LastParameter();
2645 pdeb1 = PC1->Value(pardeb1);
2646 pfin1 = PC1->Value(parfin1);
2647 Bon1 = ChFi3d_mkbound(S1,PC1,-1,pdeb1,Vdeb1,1,
2648 pfin1,Vfin1,tolesp,2.e-4);
2652 Bon1 = ChFi3d_mkbound(S1,PC1,tolesp,2.e-4);
2655 if(!yaprevon2 || !yanexton2){
2656 Standard_Failure::Raise
2657 ("adjustment by reprocessing the non-written points: no neighbor");
2659 ChFiDS_FaceInterference& previntf2 = prevsd->ChangeInterferenceOnS2();
2660 ChFiDS_FaceInterference& nextintf2 = nextsd->ChangeInterferenceOnS2();
2661 Standard_Real prevpar2 = previntf2.LastParameter();
2662 Standard_Real nextpar2 = nextintf2.FirstParameter();
2664 // It is checked if it is possible to intersect traces of neighbors
2665 // to create a sharp end.
2666 Handle(Geom2d_Curve) pcprev2 = previntf2.PCurveOnFace();
2667 Handle(Geom2d_Curve) pcnext2 = nextintf2.PCurveOnFace();
2668 Standard_Real nprevpar2,nnextpar2;
2670 // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 Begin
2671 // if(ChFi3d_IntTraces(prevsd,prevpar2,nprevpar2,2,1,
2672 // nextsd,nextpar2,nnextpar2,2,-1,p2d)){
2673 if(ChFi3d_IntTraces(prevsd,prevpar2,nprevpar2,2,1,
2674 nextsd,nextpar2,nnextpar2,2,-1,p2d,
2675 Standard_False, Standard_True)){
2676 // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 End
2677 previntf2.SetLastParameter(nprevpar2);
2678 nextintf2.SetFirstParameter(nnextpar2);
2683 gp_Pnt2d pdeb2,pfin2;
2684 gp_Vec2d vdeb2,vfin2;
2685 pcprev2->D1(prevpar2,pdeb2,vdeb2);
2686 pcnext2->D1(nextpar2,pfin2,vfin2);
2687 Bon2 = ChFi3d_mkbound(S2,PC2,-1,pdeb2,vdeb2,1,
2688 pfin2,vfin2,tolesp,2.e-4);
2692 //here the base is on 3D tangents of neighbors.
2693 const Handle(Geom_Curve)& c3dprev2 =
2694 DStr.Curve(previntf2.LineIndex()).Curve();
2695 const Handle(Geom_Curve)& c3dnext2 =
2696 DStr.Curve(nextintf2.LineIndex()).Curve();
2697 gp_Pnt Pdeb2, Pfin2;
2698 gp_Vec Vdeb2, Vfin2;
2699 c3dprev2->D1(prevpar2,Pdeb2,Vdeb2);
2700 c3dnext2->D1(nextpar2,Pfin2,Vfin2);
2701 gp_Pnt2d pdeb2,pfin2;
2702 Standard_Real pardeb2 = intf2.FirstParameter();
2703 Standard_Real parfin2 = intf2.LastParameter();
2704 pdeb2 = PC2->Value(pardeb2);
2705 pfin2 = PC2->Value(parfin2);
2706 Bon2 = ChFi3d_mkbound(S2,PC2,-1,pdeb2,Vdeb2,1,
2707 pfin2,Vfin2,tolesp,2.e-4);
2711 Bon2 = ChFi3d_mkbound(S2,PC2,tolesp,2.e-4);
2713 // The parameters of neighbor traces are updated, so
2714 // straight lines uv are pulled.
2715 const Handle(Geom_Surface)&
2716 sprev = DStr.Surface(prevsd->Surf()).Surface();
2717 const Handle(Geom_Surface)&
2718 snext = DStr.Surface(nextsd->Surf()).Surface();
2719 ChFiDS_FaceInterference& previntf1 = prevsd->ChangeInterferenceOnS1();
2720 ChFiDS_FaceInterference& nextintf1 = nextsd->ChangeInterferenceOnS1();
2721 ChFiDS_FaceInterference& previntf2 = prevsd->ChangeInterferenceOnS2();
2722 ChFiDS_FaceInterference& nextintf2 = nextsd->ChangeInterferenceOnS2();
2723 Handle(Geom2d_Curve) pcsprev1 = previntf1.PCurveOnSurf();
2724 Handle(Geom2d_Curve) pcsnext1 = nextintf1.PCurveOnSurf();
2725 Standard_Real prevpar1 = previntf1.LastParameter();
2726 Standard_Real nextpar1 = nextintf1.FirstParameter();
2727 Handle(Geom2d_Curve) pcsprev2 = previntf2.PCurveOnSurf();
2728 Handle(Geom2d_Curve) pcsnext2 = nextintf2.PCurveOnSurf();
2729 Standard_Real prevpar2 = previntf2.LastParameter();
2730 Standard_Real nextpar2 = nextintf2.FirstParameter();
2731 gp_Pnt2d pdebs1 = pcsprev1->Value(prevpar1);
2732 gp_Pnt2d pdebs2 = pcsprev2->Value(prevpar2);
2733 gp_Pnt2d pfins1 = pcsnext1->Value(nextpar1);
2734 gp_Pnt2d pfins2 = pcsnext2->Value(nextpar2);
2735 Bdeb = ChFi3d_mkbound(sprev,pdebs1,pdebs2,tolesp,2.e-4);
2736 Bfin = ChFi3d_mkbound(snext,pfins1,pfins2,tolesp,2.e-4);
2738 GeomFill_ConstrainedFilling fil(11,20);
2739 if(pointuon1) fil.Init(Bon2,Bfin,Bdeb,1);
2740 else if(pointuon2) fil.Init(Bon1,Bfin,Bdeb,1);
2741 else fil.Init(Bon1,Bfin,Bon2,Bdeb,1);
2743 ChFi3d_ReparamPcurv(0.,1.,PC1);
2744 ChFi3d_ReparamPcurv(0.,1.,PC2);
2745 Handle(Geom_Surface) newsurf = fil.Surface();
2749 char* pops = "newsurf";
2750 DrawTrSurf::Set(pops,newsurf);
2754 newsurf->VReverse(); // we return to direction 1 from 2;
2755 done = CompleteData(cursd,newsurf,S1,PC1,S2,PC2,
2756 F2.Orientation(),0,0,0,0,0);
2757 cursd->ChangeIndexOfS1(0);
2760 done = CompleteData(cursd,newsurf,S1,PC1,S2,PC2,
2761 F1.Orientation(),1,0,0,0,0);
2762 if(pointuon2) cursd->ChangeIndexOfS2(0);
2765 prevsd->ChangeVertexLastOnS1().SetPoint(cpd1.Point());
2766 nextsd->ChangeVertexFirstOnS1().SetPoint(cpf1.Point());
2769 prevsd->ChangeVertexLastOnS2().SetPoint(cpd2.Point());
2770 nextsd->ChangeVertexFirstOnS2().SetPoint(cpf2.Point());
2773 // The tolerance of points is updated.
2774 for(i = 1; i < last; i++){
2775 Standard_Integer j = i%len + 1;
2776 Standard_Integer curs1, curs2;
2777 Standard_Integer nexts1, nexts2;
2778 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2779 Handle(ChFiDS_SurfData)& nextsd = SeqSurf.ChangeValue(j);
2780 ChFiDS_CommonPoint& curp1 = cursd->ChangeVertexLastOnS1();
2781 ChFiDS_CommonPoint& nextp1 = nextsd->ChangeVertexFirstOnS1();
2782 if (cursd->IsOnCurve1()) curs1 = cursd->IndexOfC1();
2783 else curs1 = cursd->IndexOfS1();
2784 if (cursd->IsOnCurve2()) curs2 = cursd->IndexOfC2();
2785 else curs2 = cursd->IndexOfS2();
2786 Standard_Real tol1 = Max(curp1.Tolerance(),nextp1.Tolerance());
2787 ChFiDS_CommonPoint& curp2 = cursd->ChangeVertexLastOnS2();
2788 ChFiDS_CommonPoint& nextp2 = nextsd->ChangeVertexFirstOnS2();
2789 Standard_Real tol2 = Max(curp2.Tolerance(),nextp2.Tolerance());
2790 if (nextsd->IsOnCurve1()) nexts1 = nextsd->IndexOfC1();
2791 else nexts1 = nextsd->IndexOfS1();
2792 if (nextsd->IsOnCurve2()) nexts2 = nextsd->IndexOfC2();
2793 else nexts2 = nextsd->IndexOfS2();
2795 if(!curp1.IsOnArc() && nextp1.IsOnArc()){
2797 if ( (curs1 == nexts1) && !nextsd->IsOnCurve1())
2798 // Case when it is not possible to pass along the border without leaving
2799 ChangeTransition(nextp1, curp1, nexts1, myDS);
2801 else if(curp1.IsOnArc() && !nextp1.IsOnArc()) {
2803 if ( (curs1 == nexts1) && !cursd->IsOnCurve1())
2804 ChangeTransition(curp1, nextp1, curs1, myDS);
2807 if(!curp2.IsOnArc() && nextp2.IsOnArc()) {
2809 if ( (curs2 == nexts2) && !nextsd->IsOnCurve2())
2810 ChangeTransition(nextp2, curp2, curs2, myDS);
2812 else if(curp2.IsOnArc() && !nextp2.IsOnArc()){
2814 if ( (curs2 == nexts2) && !cursd->IsOnCurve2())
2815 ChangeTransition(curp2, nextp2, curs2, myDS);
2818 curp1.SetTolerance(tol1); nextp1.SetTolerance(tol1);
2819 curp2.SetTolerance(tol2); nextp2.SetTolerance(tol2);
2822 if(curp1.IsOnArc()){
2823 ChFi3d_EnlargeBox(curp1.Arc(),myEFMap(curp1.Arc()),curp1.ParameterOnArc(),b1);
2825 if(curp2.IsOnArc()){
2826 ChFi3d_EnlargeBox(curp2.Arc(),myEFMap(curp2.Arc()),curp2.ParameterOnArc(),b2);
2828 Handle(ChFiDS_Stripe) bidst;
2829 ChFi3d_EnlargeBox(DStr,bidst,cursd,b1,b2,0);
2830 ChFi3d_EnlargeBox(DStr,bidst,nextsd,b1,b2,1);
2831 tol1 = ChFi3d_BoxDiag(b1);
2832 tol2 = ChFi3d_BoxDiag(b2);
2833 curp1.SetTolerance(tol1); nextp1.SetTolerance(tol1);
2834 curp2.SetTolerance(tol2); nextp2.SetTolerance(tol2);
2836 // The connections edge/new faces are updated.
2837 for (ILES.Initialize(ll) ; ILES.More(); ILES.Next()) {
2838 const Handle(ChFiDS_HElSpine)& curhels = ILES.Value();
2839 const ChFiDS_ElSpine& curels = curhels->ChangeCurve();
2840 Standard_Real WF = curels.FirstParameter();
2841 Standard_Real WL = curels.LastParameter();
2842 Standard_Integer IF,IL;
2843 Standard_Real nwf = WF, nwl = WL;
2844 Standard_Real period = 0.;
2845 Standard_Integer nbed = Spine->NbEdges();
2847 period = Spine->Period();
2848 nwf = ElCLib::InPeriod(WF,-tolesp,period-tolesp);
2849 IF = Spine->Index(nwf,1);
2850 nwl = ElCLib::InPeriod(WL,tolesp,period+tolesp);
2851 IL = Spine->Index(nwl,0);
2852 if(nwl<nwf+tolesp) IL += nbed;
2855 IF = Spine->Index(WF,1);
2856 IL = Spine->Index(WL,0);
2860 Standard_Integer IFloc = IF;
2861 if(periodic) IFloc = (IF - 1)%nbed + 1;
2862 const TopoDS_Edge& Ej = Spine->Edges(IFloc);
2863 for(i = 1; i <= len; i++){
2864 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2865 Standard_Real fp = cursd->FirstSpineParam();
2866 Standard_Real lp = cursd->LastSpineParam();
2867 if(lp < WF+tolesp || fp > WL-tolesp) continue;
2868 if(!myEVIMap.IsBound(Ej)) {
2869 TColStd_ListOfInteger li;
2870 myEVIMap.Bind(Ej,li);
2872 myEVIMap.ChangeFind(Ej).Append(cursd->Surf());
2876 TColStd_Array1OfReal wv(IF,IL - 1);
2878 cout<<"length of the trajectory : "<<(WL-WF)<<endl;
2880 for(i = IF; i < IL; i++){
2881 Standard_Integer iloc = i;
2882 if(periodic) iloc = (i - 1)%nbed + 1;
2883 Standard_Real wi = Spine->LastParameter(iloc);
2884 if(periodic) wi = ElCLib::InPeriod(wi,WF,WF+period);
2885 gp_Pnt pv = Spine->Value(wi);
2887 gp_Pnt pelsapp = curels.Value(wi);
2888 Standard_Real distinit = pv.Distance(pelsapp);
2889 cout<<"distance psp/papp : "<<distinit<<endl;
2891 Extrema_LocateExtPC ext(pv,curels,wi,1.e-8);
2894 wv(i) = ext.Point().Parameter();
2898 cout<<"fail of projection vertex ElSpine!!!"<<endl;
2902 for(i = 1; i <= len; i++){
2903 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2904 Standard_Real fp = cursd->FirstSpineParam();
2905 Standard_Real lp = cursd->LastSpineParam();
2907 Standard_Integer jf = 0, jl = 0;
2908 if(lp < WF+tolesp || fp > WL-tolesp) continue;
2909 for(j = IF; j < IL; j++){
2911 if(fp < wv(j) - tolesp) break;
2913 for(j = IF; j < IL; j++){
2915 if(lp < wv(j) + tolesp) break;
2917 for(j = jf; j <= jl; j++){
2918 Standard_Integer jloc = j;
2919 if(periodic) jloc = (j - 1)%nbed + 1;
2920 const TopoDS_Edge& Ej = Spine->Edges(jloc);
2921 if(!myEVIMap.IsBound(Ej)) {
2922 TColStd_ListOfInteger li;
2923 myEVIMap.Bind(Ej,li);
2925 myEVIMap.ChangeFind(Ej).Append(cursd->Surf());
2933 //=======================================================================
2934 //function : PerformSetOfSurf
2936 //=======================================================================
2938 void ChFi3d_Builder::PerformSetOfSurf(Handle(ChFiDS_Stripe)& Stripe,
2939 const Standard_Boolean Simul)
2941 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
2945 ChFi3d_InitChron(ch);// init perf for PerformSetOfKPart
2948 const Handle(ChFiDS_Spine)& sp = Stripe->Spine();
2949 Standard_Integer SI = ChFi3d_SolidIndex(sp,DStr,myESoMap,myEShMap);
2950 Stripe->SetSolidIndex(SI);
2951 if(!sp->SplitDone()) PerformSetOfKPart(Stripe,Simul);
2954 ChFi3d_ResultChron(ch ,t_perfsetofkpart); // result perf PerformSetOfKPart(
2955 ChFi3d_InitChron(ch); // init perf for PerformSetOfKGen
2958 PerformSetOfKGen(Stripe,Simul);
2961 ChFi3d_ResultChron(ch, t_perfsetofkgen);//result perf PerformSetOfKGen
2962 ChFi3d_InitChron(ch); // init perf for ChFi3d_MakeExtremities
2965 if(!Simul) ChFi3d_MakeExtremities(Stripe,DStr,myEFMap,tolesp,tol2d);
2968 ChFi3d_ResultChron(ch, t_makextremities); // result perf t_makextremities