0024023: Revamp the OCCT Handle -- general
[occt.git] / src / ChFi3d / ChFi3d_Builder_2.cxx
CommitLineData
b311480e 1// Created on: 1993-12-15
2// Created by: Isabelle GRIGNON
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <ChFi3d_Builder.jxx>
18
19#include <Precision.hxx>
20
21#include <Standard_NotImplemented.hxx>
22#include <TColStd_Array1OfReal.hxx>
23#include <TColStd_Array1OfInteger.hxx>
24#include <TColStd_ListOfInteger.hxx>
25
26#include <math_Vector.hxx>
27#include <gp_Pnt.hxx>
28#include <gp_XYZ.hxx>
29#include <gp_Vec.hxx>
30#include <gp_Pnt2d.hxx>
31#include <gp_Pln.hxx>
32#include <TColgp_Array1OfPnt.hxx>
33#include <TColgp_Array1OfVec.hxx>
34#include <ElCLib.hxx>
35
36#include <Geom_BSplineCurve.hxx>
c04c30b3 37#include <Geom_BSplineSurface.hxx>
7fd59977 38#include <Geom_Line.hxx>
39#include <Geom_Plane.hxx>
40#include <Geom2d_Curve.hxx>
41#include <GeomAPI_ProjectPointOnCurve.hxx>
42
43#include <TopoDS.hxx>
44#include <TopoDS_Shape.hxx>
45#include <TopoDS_Face.hxx>
46#include <TopoDS_Wire.hxx>
47#include <TopoDS_Edge.hxx>
48#include <TopoDS_Vertex.hxx>
49
50#include <GeomAdaptor_Surface.hxx>
51#include <GeomAdaptor_HSurface.hxx>
52#include <GeomAdaptor_HCurve.hxx>
53
54#include <BRepAdaptor_Curve.hxx>
55#include <BRepAdaptor_HCurve.hxx>
56#include <BRepAdaptor_Surface.hxx>
57#include <BRepAdaptor_HSurface.hxx>
58#include <BRepTopAdaptor_TopolTool.hxx>
59#include <BRepLProp_SLProps.hxx>
60#include <Adaptor3d_TopolTool.hxx>
61
62#include <TopAbs.hxx>
63#include <TopAbs_ShapeEnum.hxx>
64#include <TopAbs_Orientation.hxx>
65#include <BRep_Tool.hxx>
66#include <BRepTools.hxx>
67#include <BRepTools_WireExplorer.hxx>
68#include <BRepLib_MakeFace.hxx>
69#include <TopExp.hxx>
70#include <TopExp_Explorer.hxx>
71#include <TopTools_ListIteratorOfListOfShape.hxx>
72
73#include <Extrema_ExtPC.hxx>
74#include <Extrema_LocateExtPC.hxx>
75#include <Extrema_POnCurv.hxx>
76
77#include <ChFiDS_ErrorStatus.hxx>
78#include <ChFiDS_State.hxx>
79#include <ChFiDS_SurfData.hxx>
80#include <ChFiDS_CommonPoint.hxx>
81#include <ChFiDS_FaceInterference.hxx>
82#include <ChFiDS_Spine.hxx>
83#include <ChFiDS_FilSpine.hxx>
84#include <ChFiDS_ChamfSpine.hxx>
85#include <ChFiDS_SequenceOfSurfData.hxx>
86#include <ChFiDS_Stripe.hxx>
87#include <ChFiDS_HData.hxx>
88#include <ChFiDS_ElSpine.hxx>
89#include <ChFiDS_ListOfHElSpine.hxx>
90#include <ChFiDS_ListIteratorOfListOfHElSpine.hxx>
91#include <Extrema_ExtPS.hxx>
92#include <ChFiKPart_ComputeData.hxx>
93#include <ChFi3d.hxx>
94#include <ChFi3d_Builder_0.hxx>
95
0797d9d3 96#ifdef OCCT_DEBUG
7fd59977 97#ifdef DRAW
98#include <DrawTrSurf.hxx>
99#endif
100#include <OSD_Chronometer.hxx>
1d0a9d4d 101extern Standard_Real t_perfsetofkpart,t_perfsetofkgen,t_makextremities,t_performsurf,t_startsol;
102extern Standard_Boolean ChFi3d_GettraceCHRON();
103extern void ChFi3d_InitChron(OSD_Chronometer& ch);
104extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real& time);
7fd59977 105#endif
106
107// Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 Begin
108Standard_Boolean isTangentFaces(const TopoDS_Edge &theEdge,
109 const TopoDS_Face &theFace1,
110 const TopoDS_Face &theFace2);
111// Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 End
112
113//===================================================================
81bba717 114// Definition by a plane
7fd59977 115//
81bba717 116// It is considered that P1 and P2 are points associated to commonpoints compoint1 and
117// compoint2, while E1 and E2 are edges containing P1 and P2.
118// The plane containing three directions D12 T1 T2 ou D12 represente la direction formee
7fd59977 119// par les points P1 et P2, T1 la tangente de E1 en P1 et T2 la tangente de
81bba717 120// E2 en P2 is found (if exists).
121// Then fillet HConge is intersected by this plane
122// to find associated curve 3d C3d and the curve 2d.
7fd59977 123//
124//====================================================================
125static void ChFi3d_CoupeParPlan (const ChFiDS_CommonPoint & compoint1,
126 const ChFiDS_CommonPoint & compoint2,
127 Handle(GeomAdaptor_HSurface)& HConge,
128 const gp_Pnt2d & UV1,
129 const gp_Pnt2d & UV2,
130 const Standard_Real tol3d,
131 const Standard_Real tol2d,
132 Handle(Geom_Curve) &C3d,
133 Handle(Geom2d_Curve) &pcurve,
134 Standard_Real & tolreached,
135 Standard_Real & Pardeb,
136 Standard_Real & Parfin,
137 Standard_Boolean & plane)
138{ plane=Standard_True;
139 if(compoint1.IsOnArc() && compoint2.IsOnArc() ) {
140 gp_Pnt P1,P2;
141 BRepAdaptor_Curve BCurv1(compoint1.Arc());
142 BRepAdaptor_Curve BCurv2(compoint2.Arc());
143 Standard_Real parE1,parE2;
144 parE1=compoint1.ParameterOnArc();
145 parE2=compoint2.ParameterOnArc();
146 gp_Vec t1,t2;
147 BCurv1.D1(parE1,P1,t1);
148 BCurv2.D1(parE2,P2,t2);
149 gp_Dir tgt1(t1);
150 gp_Dir tgt2(t2);
151 gp_Vec v12(P2.X()-P1.X(),P2.Y()-P1.Y(),P2.Z()-P1.Z());
152 gp_Dir d12(v12);
153 gp_Dir nor =tgt1.Crossed(d12);
154 Handle (Geom_Plane) Plan=new Geom_Plane(P1,nor);
155 Standard_Real scal;
156 scal=Abs(nor.Dot(tgt2));
157 if (scal<0.01) {
158 Handle(GeomAdaptor_HSurface) HPlan=new GeomAdaptor_HSurface(Plan);
159 Handle(Geom2d_Curve) C2dint2;
160 TColStd_Array1OfReal Pdeb(1,4),Pfin(1,4);
161 GeomAdaptor_Surface AS(Plan);
162 Extrema_ExtPS ext(P1,AS,1.e-3,1.e-3);
163 Extrema_ExtPS ext1 (P2,AS,1.e-3,1.e-3);
164 Standard_Real u1,v1;
165 ext.Point(1).Parameter(u1,v1);
166 Pdeb(1)= UV1.X();Pdeb(2) = UV1.Y();
167 Pdeb(3)= u1;Pdeb(4) =v1;
168 ext1.Point(1).Parameter(u1,v1);
169 Pfin(1)= UV2.X();Pfin(2) = UV2.Y();
170 Pfin(3)= u1;Pfin(4) = v1;
171 if (ChFi3d_ComputeCurves(HConge,HPlan,Pdeb,Pfin,C3d,
172 pcurve,C2dint2,tol3d,tol2d,tolreached)){
173 Pardeb=C3d->FirstParameter();
174 Parfin=C3d->LastParameter();
175 }
176 else plane=Standard_False;
177 }
178 else plane=Standard_False;
179 }
180 else plane=Standard_False;
181}
182//=======================================================================
183//function : SortieTangente
184//purpose :
185//=======================================================================
186
187static Standard_Boolean SortieTangente(const ChFiDS_CommonPoint& CP,
188 const TopoDS_Face& /*F*/,
189 const Handle(ChFiDS_SurfData)& /*SD*/,
190 const Standard_Integer /*OnS*/,
191 const Standard_Real TolAngular)
192{
193 if(!CP.HasVector()) return Standard_False;
194 gp_Pnt P;
195 gp_Vec Darc, Dsurf;
196 Handle(Geom_Curve) C;
197 Standard_Real Uf, Ul;
198 C = BRep_Tool::Curve(CP.Arc(),Uf,Ul);
199 C->D1(CP.ParameterOnArc(), P, Darc);
200 Dsurf = CP.Vector();
201 return Dsurf.IsParallel(Darc, TolAngular);
202}
203
204//=======================================================================
205//function : BonVoisin
206//purpose :
207//=======================================================================
208
209static Standard_Boolean BonVoisin(const gp_Pnt& Point,
210 Handle(BRepAdaptor_HSurface)& HS,
211 TopoDS_Face& F,
212 Handle(GeomAdaptor_HSurface)& plane,
213 const TopoDS_Edge& cured,
214 Standard_Real& XDep,
215 Standard_Real& YDep,
216 const ChFiDS_Map& EFMap,
217 const Standard_Real tolesp)
218{
219 Standard_Boolean bonvoisin = 1;
220 Standard_Real winter, Uf, Ul;
221 gp_Pnt papp = HS->Value(XDep, YDep);
222 Standard_Real dist = RealLast();
223 Handle(BRepAdaptor_HCurve) hc = new BRepAdaptor_HCurve();
224 Handle(Geom2d_Curve) PC;
225 Standard_Boolean found = 0;
226
227 TopExp_Explorer Ex;
228 for(Ex.Init(F,TopAbs_EDGE); Ex.More(); Ex.Next()){
229 const TopoDS_Edge& ecur = TopoDS::Edge(Ex.Current());
230 if(!ecur.IsSame(cured)){
231 hc->ChangeCurve().Initialize(ecur);
232 Standard_Real tolc = hc->ChangeCurve().Resolution(tolesp);
233 if(ChFi3d_InterPlaneEdge(plane,hc,winter,1,tolc)){
234 gp_Pnt np = hc->Value(winter);
235 Standard_Real ndist = np.SquareDistance(papp);
236 if(ndist<dist){
237 TopTools_ListIteratorOfListOfShape It;
238 TopoDS_Face ff;
239 Standard_Boolean isclosed = BRep_Tool::IsClosed(ecur, F);
240 Standard_Boolean isreallyclosed =
241 BRepTools::IsReallyClosed(ecur, F);
242 for(It.Initialize(EFMap(ecur));It.More();It.Next()){
243 ff = TopoDS::Face(It.Value());
244 Standard_Boolean issame = ff.IsSame(F);
245// Modified by Sergey KHROMOV - Fri Dec 21 17:12:48 2001 Begin
246// Standard_Boolean istg =
247// BRep_Tool::Continuity(ecur,ff,F) != GeomAbs_C0;
248 Standard_Boolean istg = isTangentFaces(ecur,ff,F);
249// Modified by Sergey KHROMOV - Fri Dec 21 17:12:51 2001 End
250 if((!issame || (issame && isreallyclosed)) && istg) {
251 found = 1;
252 TopoDS_Edge newe = ecur;
253 newe.Orientation(TopAbs_FORWARD);
254 dist = ndist;
255 HS->ChangeSurface().Initialize(ff);
256 if(isclosed && !isreallyclosed){
257 TopoDS_Face fff = ff;
258 fff.Orientation(TopAbs_FORWARD);
259 TopExp_Explorer Ex2;
260 for(Ex2.Init(fff,TopAbs_EDGE);
261 Ex2.More(); Ex2.Next()){
262 if(newe.IsSame(Ex2.Current())){
263 newe = TopoDS::Edge(Ex2.Current());
264 PC = BRep_Tool::CurveOnSurface(newe,fff,Uf,Ul);
265 break;
266 }
267 }
268 }
269 else PC = BRep_Tool::CurveOnSurface(newe,ff,Uf,Ul);
270 PC->Value(winter).Coord(XDep,YDep);
271 if(issame){
272 gp_Pnt spt; gp_Vec sdu,sdv,nors;
273 HS->D1(XDep, YDep, spt, sdu, sdv);
274 nors = sdu.Crossed(sdv);
275 gp_Pnt cpt; gp_Vec cd;
276 hc->D1(winter,cpt,cd);
277 gp_Vec vref(Point, cpt);
278 TopoDS_Face fff = ff;
279 fff.Orientation(TopAbs_FORWARD);
280 if(vref.Dot(nors.Crossed(cd)) < 0.){
281 newe.Orientation(TopAbs_REVERSED);
282 }
283 PC = BRep_Tool::CurveOnSurface(newe,fff,Uf,Ul);
284 PC->Value(winter).Coord(XDep, YDep);
285 }
286 break;
287 }
288 }
289 }
290 }
291 }
292 }
293 if(!found) bonvoisin = 0;
294 return bonvoisin;
295}
296
297//=======================================================================
298//function : Projection
81bba717 299//purpose : Projects a point on a curve
7fd59977 300//=======================================================================
301
302static Standard_Boolean Projection(Extrema_ExtPC& PExt,
303 const gp_Pnt& P,
304 const Adaptor3d_Curve& C,
305 Standard_Real& W,
306 Standard_Real Tol)
307{
308 Standard_Real Dist2, daux2;
309 Dist2 = C.Value(W).SquareDistance(P);
310
81bba717 311 // It is checked if it is not already a solution
7fd59977 312 if (Dist2 < Tol * Tol)
313 return Standard_True;
314
315 Standard_Boolean Ok = Standard_False;
316
317 // On essai une resolution initialise
318 Extrema_LocateExtPC ext(P,C,W,Tol/10);
319 if(ext.IsDone()) {
320 daux2 = C.Value(ext.Point().Parameter()).SquareDistance(P);
321 if (daux2 <Dist2 ) {
322 W = ext.Point().Parameter();
323 Dist2 = daux2;
324 Ok = Standard_True;
325 if (Dist2 < Tol * Tol)
326 return Standard_True;
327 }
328 }
329
81bba717 330 // Global resolution
7fd59977 331 PExt.Perform(P);
332 if ( PExt.IsDone() ) {
333 for (Standard_Integer ii=1; ii<= PExt.NbExt(); ii++) {
334 if (PExt.SquareDistance(ii) < Dist2) {
335 Dist2 = PExt.SquareDistance(ii);
336 W = PExt.Point(ii).Parameter();
337 Ok = Standard_True;
338 }
339 }
340 }
341 return Ok;
342}
343
344//=======================================================================
345//function : TgtKP
346//purpose :
347//=======================================================================
348
349static void TgtKP(const Handle(ChFiDS_SurfData)& CD,
350 const Handle(ChFiDS_Spine)& Spine,
351 const Standard_Integer iedge,
352 const Standard_Boolean isfirst,
353 gp_Pnt& ped,
354 gp_Vec& ded)
355{
356 Standard_Real wtg = CD->InterferenceOnS1().Parameter(isfirst);
357 const BRepAdaptor_Curve& bc = Spine->CurrentElementarySpine(iedge);
358 if(Spine->Edges(iedge).Orientation() == TopAbs_FORWARD)
359 bc.D1(wtg+bc.FirstParameter(),ped,ded);
360 else{
361 bc.D1(-wtg+bc.LastParameter(),ped,ded);
362 ded.Reverse();
363 }
364 ded.Normalize();
365}
366
367//=======================================================================
368//function : IsInput
81bba717 369//purpose : Checks if a vector belongs to a Face
7fd59977 370//=======================================================================
371
372Standard_Boolean IsInput(const gp_Vec& Vec,
373 const TopoDS_Vertex& Ve,
374 const TopoDS_Face& Fa)
375{
376 TopExp_Explorer FaceExp(Fa, TopAbs_WIRE);
377 BRepTools_WireExplorer WireExp;
378 Standard_Integer Trouve = 0;
379 TopoDS_Wire W;
380 TopoDS_Edge E;
381 TopoDS_Vertex Vf, Vl;
382 gp_Vec Vec3d[2];
383 gp_Pnt Point;
384
81bba717 385 // Find edges and compute 3D vectors
7fd59977 386 for ( ; (FaceExp.More() && (Trouve<2)); FaceExp.Next()) {
387 W = TopoDS::Wire(FaceExp.Current());
388 for (Trouve=0, WireExp.Init(W) ;
389 WireExp.More() && (Trouve<2); WireExp.Next()) {
390 E = TopoDS::Edge(WireExp.Current());
391 TopExp::Vertices(E, Vf, Vl);
392 if (Vf.IsSame(Ve)) {
393 BRepAdaptor_Curve Cb(E);
394 Cb.D1(BRep_Tool::Parameter(Ve, E), Point, Vec3d[Trouve]);
395 Trouve++;
396 }
397 else if (Vl.IsSame(Ve)) {
398 BRepAdaptor_Curve Cb(E);
399 Cb.D1(BRep_Tool::Parameter(Ve, E), Point, Vec3d[Trouve]);
400 Vec3d[Trouve].Reverse();
401 Trouve++;
402 }
403 }
404 }
405 if (Trouve < 2) return Standard_False;
81bba717 406 // Calculate the normal and the angles in the asssociated vector plane
7fd59977 407 gp_Vec Normal;
408 Normal = Vec3d[0] ^ Vec3d[1];
81bba717 409 if (Normal.SquareMagnitude() < Precision::Confusion()) {//Colinear case
7fd59977 410 return (Vec.IsParallel(Vec3d[0],Precision::Confusion()));
411 }
412
413 Standard_Real amin, amax;
414 amax = Vec3d[1].AngleWithRef(Vec3d[0], Normal);
415 if (amax <0) {
416 amin = amax;
417 amax = 0;
418 }
419 else amin = 0;
420
81bba717 421 // Projection of the vector
7fd59977 422 gp_Ax3 Axe(Point, Normal, Vec3d[0]);
423 gp_Trsf Transf;
424 Transf.SetTransformation (Axe);
425 gp_XYZ coord = Vec.XYZ();
426 Transf.Transforms(coord);
427 coord.SetZ(0);
428 Transf.Invert();
429 Transf.Transforms(coord);
430 gp_Vec theProj(coord);
431
81bba717 432 // and finally...
7fd59977 433 Standard_Real Angle = theProj.AngleWithRef(Vec3d[0], Normal);
434 return ( (Angle >= amin) && (Angle<=amax));
435}
436
437//=======================================================================
438//function : IsG1
81bba717 439//purpose : Find a neighbor G1 by an edge
7fd59977 440//=======================================================================
441
442Standard_Boolean IsG1(const ChFiDS_Map& TheMap,
443 const TopoDS_Edge& E,
444 const TopoDS_Face& FRef,
445 TopoDS_Face& FVoi)
446{
447 TopTools_ListIteratorOfListOfShape It;
81bba717 448 // Find a neighbor of E different from FRef (general case).
7fd59977 449 for(It.Initialize(TheMap(E));It.More();It.Next()) {
450 if (!TopoDS::Face(It.Value()).IsSame(FRef)) {
451 FVoi = TopoDS::Face(It.Value());
452// Modified by Sergey KHROMOV - Fri Dec 21 17:09:32 2001 Begin
453// if (BRep_Tool::Continuity(E,FRef,FVoi) != GeomAbs_C0) {
454 if (isTangentFaces(E,FRef,FVoi)) {
455// Modified by Sergey KHROMOV - Fri Dec 21 17:09:33 2001 End
456 return Standard_True;
457 }
458 }
459 }
81bba717 460 // If is was not found it is checked if E is a cutting edge,
461 // in which case FVoi = FRef is returned (less frequent case).
7fd59977 462 TopExp_Explorer Ex;
463 Standard_Boolean orset = Standard_False;
7fd59977 464 TopAbs_Orientation orient = TopAbs_FORWARD ;
7fd59977 465 TopoDS_Edge ed;
466 for(Ex.Init(FRef,TopAbs_EDGE); Ex.More(); Ex.Next()){
467 ed = TopoDS::Edge(Ex.Current());
468 if(ed.IsSame(E)){
469 if(!orset){ orient = ed.Orientation(); orset = Standard_True; }
470 else if(ed.Orientation() == TopAbs::Reverse(orient)){
471 FVoi = FRef;
472// Modified by Sergey KHROMOV - Fri Dec 21 17:15:12 2001 Begin
473// if (BRep_Tool::Continuity(E,FRef,FRef) >= GeomAbs_G1) {
474 if (isTangentFaces(E,FRef,FRef)) {
475// Modified by Sergey KHROMOV - Fri Dec 21 17:15:16 2001 End
476 return Standard_True;
477 }
478 return Standard_False;
479 }
480 }
481 }
482 return Standard_False;
483}
484
485//=======================================================================
486//function : SearchFaceOnV
81bba717 487//purpose : Finds the output face(s) of the path by a vertex
488// The following criteria should be followed
489// -1 : The face shares regular edges with FRef
490// (too hard condition that should be reconsidered)
491// -2 : The vector starting in CommonPoint "belongs" to the face
7fd59977 492//========================================================================
493static Standard_Integer SearchFaceOnV(const ChFiDS_CommonPoint& Pc,
494 const TopoDS_Face& FRef,
495 const ChFiDS_Map& VEMap,
496 const ChFiDS_Map& EFMap,
497 TopoDS_Face& F1,
498 TopoDS_Face& F2)
499{
81bba717 500 // it is checked that it leaves the current face.
7fd59977 501 Standard_Boolean FindFace = IsInput(Pc.Vector(), Pc.Vertex(), FRef);
502 if (FindFace) {
503 FindFace = IsInput(Pc.Vector().Reversed(), Pc.Vertex(), FRef);
504 }
81bba717 505 // If it does not leave, it is finished
7fd59977 506 if (FindFace) {
507 F1 = FRef;
508 return 1;
509 }
510 Standard_Integer Num = 0;
511 Standard_Boolean Trouve;
512 TopTools_ListIteratorOfListOfShape ItE, ItF;
513 TopoDS_Edge E;
514 TopoDS_Face FVoi;
515
516 for(ItE.Initialize(VEMap(Pc.Vertex()));
517 ItE.More() && (Num < 2); ItE.Next()) {
518 E = TopoDS::Edge(ItE.Value());
519 for(ItF.Initialize(EFMap(E)), Trouve=Standard_False;
520 ItF.More()&&(!Trouve); ItF.Next()) {
521 if (TopoDS::Face(ItF.Value()).IsSame(FRef)) {
522 Trouve = Standard_True;
523 }
524 }
525 if (Trouve) Trouve = IsG1(EFMap, E, FRef, FVoi);
526 if (Trouve) Trouve = IsInput(Pc.Vector(), Pc.Vertex(), FVoi);
527 if (Trouve) {
528 if (Num == 0) F1 = FVoi;
529 else F2 = FVoi;
530 Num++;
531 }
532 }
533 return Num;
534}
535
536//=======================================================================
537//function : ChangeTransition
81bba717 538//purpose : Changes the transition of the second common Point, when the surface
539// does not cross the arc
540// As it is supposed that the support Faces are the same, it is enough
541// to examine the cas of cutting edges.
7fd59977 542//========================================================================
543static void ChangeTransition(const ChFiDS_CommonPoint& Precedant,
544 ChFiDS_CommonPoint& Courant,
545 Standard_Integer FaceIndex,
546 const Handle(TopOpeBRepDS_HDataStructure)& DS)
547{
548 Standard_Boolean tochange = Standard_True;
549 Standard_Real f,l;
550 const TopoDS_Face& F = TopoDS::Face(DS->Shape(FaceIndex));
551 const TopoDS_Edge& Arc = Precedant.Arc();
552 Handle(Geom2d_Curve) PCurve1, PCurve2;
553 PCurve1 = BRep_Tool::CurveOnSurface(Arc, F, f, l);
554 TopoDS_Shape aLocalShape = Arc.Reversed();
555 PCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(aLocalShape), F, f, l);
556// PCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(Arc.Reversed()), F, f, l);
557 if (PCurve1 != PCurve2) {
81bba717 558 // This is a cutting edge, it is necessary to make a small Geometric test
7fd59977 559 gp_Vec tgarc;
560 gp_Pnt P;
561 BRepAdaptor_Curve AC(Arc);
562 AC.D1(Precedant.ParameterOnArc(), P, tgarc);
563 tochange = tgarc.IsParallel(Precedant.Vector(), Precision::Confusion());
564 }
565
566 if (tochange)
567 Courant.SetArc(Precision::Confusion(),
568 Arc,
569 Precedant.ParameterOnArc(),
570 TopAbs::Reverse(Precedant.TransitionOnArc()));
571
572}
573
574//=======================================================================
575//function : CallPerformSurf
81bba717 576//purpose : Encapsulates call to PerformSurf/SimulSurf
7fd59977 577//========================================================================
578
579void ChFi3d_Builder::
580CallPerformSurf(Handle(ChFiDS_Stripe)& Stripe,
581 const Standard_Boolean Simul,
582 ChFiDS_SequenceOfSurfData& SeqSD,
583 Handle(ChFiDS_SurfData)& SD,
584 const Handle(ChFiDS_HElSpine)& HGuide,
585 const Handle(ChFiDS_Spine)& Spine,
586 const Handle(BRepAdaptor_HSurface)& HS1,
587 const Handle(BRepAdaptor_HSurface)& HS3,
588 const gp_Pnt2d& pp1,
589 const gp_Pnt2d& pp3,
590 Handle(Adaptor3d_TopolTool)& It1,
591 const Handle(BRepAdaptor_HSurface)& HS2,
592 const Handle(BRepAdaptor_HSurface)& HS4,
593 const gp_Pnt2d& pp2,
594 const gp_Pnt2d& pp4,
595 Handle(Adaptor3d_TopolTool)& It2,
596 const Standard_Real MaxStep,
597 const Standard_Real Fleche,
598 const Standard_Real /*TolGuide*/,
599 Standard_Real& First,
600 Standard_Real& Last,
601 const Standard_Boolean Inside,
602 const Standard_Boolean /*Appro*/,
603 const Standard_Boolean forward,
604 const Standard_Boolean RecOnS1,
605 const Standard_Boolean RecOnS2,
606 math_Vector& Soldep,
607 Standard_Boolean& intf,
608 Standard_Boolean& intl,
609 Handle(BRepAdaptor_HSurface)& Surf1,
610 Handle(BRepAdaptor_HSurface)& Surf2)
611{
0797d9d3 612#ifdef OCCT_DEBUG
7fd59977 613 OSD_Chronometer ch1;
614#endif
615 Handle(BRepAdaptor_HSurface) HSon1, HSon2;
616 HSon1 = HS1;
617 HSon2 = HS2;
81bba717 618 // Definition of the domain of path It1, It2
7fd59977 619 It1->Initialize(HS1);
620 It2->Initialize(HS2);
621
622
623 TopAbs_Orientation Or1 = HS1->ChangeSurface().Face().Orientation();
624 TopAbs_Orientation Or2 = HS2->ChangeSurface().Face().Orientation();
625 Standard_Integer Choix =
626 ChFi3d::NextSide(Or1,Or2,
627 Stripe->OrientationOnFace1(),
628 Stripe->OrientationOnFace2(),
629 Stripe->Choix());
630 Soldep(1) = pp1.X(); Soldep(2) = pp1.Y();
631 Soldep(3) = pp2.X(); Soldep(4) = pp2.Y();
632
633 Standard_Real thef = First, thel = Last;
634 Standard_Boolean isdone;
635
636 if(Simul){
637 isdone = SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,HS2,It2,tolesp,First,Last,
638 Inside,Inside,forward,RecOnS1,RecOnS2,Soldep,intf,intl);
639 }
640 else{
641
0797d9d3 642#ifdef OCCT_DEBUG
81bba717 643 ChFi3d_InitChron(ch1);//initial perform for PerformSurf
7fd59977 644#endif
645
646 isdone = PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,HS2,It2,
647 MaxStep,Fleche,tolesp,
648 First,Last,Inside,Inside,forward,
649 RecOnS1,RecOnS2,Soldep,intf,intl);
0797d9d3 650#ifdef OCCT_DEBUG
81bba717 651 ChFi3d_ResultChron(ch1,t_performsurf);// result perf for PerformSurf
7fd59977 652#endif
653 }
654
81bba717 655 // Case of error
7fd59977 656 if (!isdone) {
657 First = thef;
658 Last = thel;
659 Standard_Boolean reprise = Standard_False;
660 if (! HS3.IsNull()) {
661 HSon1 = HS3;
662 It1->Initialize(HS3);
663 Or1 = HS3->ChangeSurface().Face().Orientation();
664 Soldep(1) = pp3.X(); Soldep(2) = pp3.Y();
665 reprise = Standard_True;
666 }
667 else if (! HS4.IsNull()) {
668 HSon2 = HS4;
669 It2->Initialize(HS4);
670 Or2 = HS4->ChangeSurface().Face().Orientation();
671 Soldep(3) = pp4.X(); Soldep(4) = pp4.Y();
672 reprise = Standard_True;
673 }
674
675 if (reprise) {
676 Choix = ChFi3d::NextSide(Or1,Or2,
677 Stripe->OrientationOnFace1(),
678 Stripe->OrientationOnFace2(),
679 Stripe->Choix());
680 if(Simul){
681 isdone = SimulSurf(SD,HGuide,Spine,Choix,HSon1,It1,HSon2,It2,
682 tolesp,First,Last,
683 Inside,Inside,forward,RecOnS1,RecOnS2,
684 Soldep,intf,intl);
685 }
686 else{
687
0797d9d3 688#ifdef OCCT_DEBUG
81bba717 689 ChFi3d_InitChron(ch1);//init perf for PerformSurf
7fd59977 690#endif
691
692 isdone = PerformSurf(SeqSD,HGuide,Spine,Choix,HSon1,It1,HSon2,It2,
693 MaxStep,Fleche,tolesp,
694 First,Last,Inside,Inside,forward,
695 RecOnS1,RecOnS2,Soldep,intf,intl);
0797d9d3 696#ifdef OCCT_DEBUG
81bba717 697 ChFi3d_ResultChron(ch1,t_performsurf);// result perf for PerformSurf
7fd59977 698#endif
699 }
700 }
701 }
702 Surf1 = HSon1;
703 Surf2 = HSon2;
704}
705
706//=======================================================================
707//function : StripeOrientation
81bba717 708//purpose : Calculates the reference orientation determining the
709// concave face for construction of the fillet.
7fd59977 710//=======================================================================
711
712Standard_Boolean ChFi3d_Builder::StripeOrientations
713(const Handle(ChFiDS_Spine)& Spine,
714 TopAbs_Orientation& Or1,
715 TopAbs_Orientation& Or2,
716 Standard_Integer& ChoixConge) const
717{
718 //TopTools_ListIteratorOfListOfShape It;
719 BRepAdaptor_Surface Sb1,Sb2;
720 TopAbs_Orientation Of1,Of2;
721 TopoDS_Face ff1,ff2;
722 ChFi3d_conexfaces(Spine->Edges(1),ff1,ff2,myEFMap);
723 Of1 = ff1.Orientation();
724 ff1.Orientation(TopAbs_FORWARD);
725 Sb1.Initialize(ff1);
726 Of2 = ff2.Orientation();
727 ff2.Orientation(TopAbs_FORWARD);
728 Sb2.Initialize(ff2);
729
730 ChoixConge = ChFi3d::ConcaveSide(Sb1,Sb2,Spine->Edges(1),
731 Or1,Or2);
732 Or1 = TopAbs::Compose(Or1,Of1);
733 Or2 = TopAbs::Compose(Or2,Of2);
734 return Standard_True;
735}
736
737
738//=======================================================================
739//function : ConexFaces
740//purpose :
741//=======================================================================
742
743void ChFi3d_Builder::ConexFaces (const Handle(ChFiDS_Spine)& Spine,
744 const Standard_Integer IEdge,
745 const Standard_Integer RC,
746 Handle(BRepAdaptor_HSurface)& HS1,
747 Handle(BRepAdaptor_HSurface)& HS2) const
748{
749 if(HS1.IsNull()) HS1 = new BRepAdaptor_HSurface ();
750 if(HS2.IsNull()) HS2 = new BRepAdaptor_HSurface ();
751 BRepAdaptor_Surface& Sb1 = HS1->ChangeSurface();
752 BRepAdaptor_Surface& Sb2 = HS2->ChangeSurface();
753
754 TopoDS_Face ff1,ff2;
755 ChFi3d_conexfaces(Spine->Edges(IEdge),ff1,ff2,myEFMap);
756
757 Sb1.Initialize(ff1);
758 Sb2.Initialize(ff2);
759
760 TopAbs_Orientation Or1,Or2;
761 Standard_Integer Choix = ChFi3d::ConcaveSide(Sb1,Sb2,Spine->Edges(IEdge),
762 Or1,Or2);
763 if (RC%2 != Choix%2) {
764 Sb1.Initialize(ff2);
765 Sb2.Initialize(ff1);
766 }
767}
768
769//=======================================================================
770//function : StartSol
81bba717 771//purpose : Calculates a starting solution :
772// - one starts by parsing about ten points on the spine,
773// - in case of fail one finds the solution on neighbor faces;
774// section plane of edges of the adjacent face
775// and identication of the face by connection to that edge.
7fd59977 776//=======================================================================
777
778void ChFi3d_Builder::StartSol(const Handle(ChFiDS_Stripe)& Stripe,
779 const Handle(ChFiDS_HElSpine)& HGuide,
780 Handle(BRepAdaptor_HSurface)& HS1,
781 Handle(BRepAdaptor_HSurface)& HS2,
782 Handle(BRepTopAdaptor_TopolTool)& I1,
783 Handle(BRepTopAdaptor_TopolTool)& I2,
784 gp_Pnt2d& P1,
785 gp_Pnt2d& P2,
786 Standard_Real& First) const
787{
788 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
789 ChFiDS_ElSpine& els = HGuide->ChangeCurve();
790 Standard_Integer nbed = Spine->NbEdges();
791 Standard_Integer nbessaimax = 3*nbed;
792 if (nbessaimax < 10) nbessaimax = 10;
793 Standard_Real unsurnbessaimax = 1./nbessaimax;
7fd59977 794 Standard_Real wf = 0.9981 * Spine->FirstParameter(1) +
795 0.0019 * Spine->LastParameter(1);
796 Standard_Real wl = 0.9973 * Spine->LastParameter(nbed) +
797 0.0027 * Spine->FirstParameter(nbed);
798
7fd59977 799 Standard_Real TolE = 1.0e-7;
7fd59977 800 BRepAdaptor_Surface AS;
801
802 Standard_Integer nbessai;
803 Standard_Integer iedge = 0;
804 Standard_Integer RC = Stripe->Choix();
805 gp_Vec2d derive;
806 gp_Pnt2d P2d;
807 TopoDS_Edge cured;
808 TopoDS_Face f1,f2;
809 TopAbs_Orientation Or1,Or2;
7fd59977 810 Standard_Integer Choix = 0;
7fd59977 811 math_Vector SolDep(1,4);
812 Handle(Geom2d_Curve) PC;
813 Extrema_ExtPC PExt;
814 PExt.Initialize(els,
815 Spine->FirstParameter(1),
816 Spine->LastParameter(nbed),
817 Precision::Confusion());
818 TopAbs_State Pos1,Pos2;
819 for(nbessai = 0; nbessai <= nbessaimax; nbessai++){
820 Standard_Real t = nbessai*unsurnbessaimax;
821 Standard_Real w = wf * (1. -t) + wl * t;
822 Standard_Integer ie = Spine->Index(w);
823 if(iedge != ie){
824 iedge = ie;
825 cured = Spine->Edges(iedge);
826 TolE = BRep_Tool::Tolerance(cured);
827 ConexFaces(Spine,iedge,RC,HS1,HS2);
828 f1 = HS1->ChangeSurface().Face();
829 f2 = HS2->ChangeSurface().Face();
830 Or1 = f1.Orientation();
831 Or2 = f2.Orientation();
832 Choix = ChFi3d::NextSide(Or1,Or2,
833 Stripe->OrientationOnFace1(),
834 Stripe->OrientationOnFace2(),
835 RC);
836 }
837
838 Standard_Real woned,Uf,Ul, ResU, ResV;
839 Spine->Parameter(iedge,w,woned,Standard_True);
840 cured.Orientation(TopAbs_FORWARD);
841 TopoDS_Face f1forward = f1, f2forward = f2;
842 f1forward.Orientation(TopAbs_FORWARD);
843 f2forward.Orientation(TopAbs_FORWARD);
844 PC = BRep_Tool::CurveOnSurface(cured,f1forward,Uf,Ul);
845 I1->Initialize(HS1);
846 PC->D1(woned, P1, derive);
81bba717 847 // There are ponts on the border, and internal points are found
7fd59977 848 if (derive.Magnitude() > Precision::PConfusion()) {
849 derive.Normalized();
c6541a0c 850 derive.Rotate(M_PI/2);
7fd59977 851 AS.Initialize(f1);
852 ResU = AS.UResolution(TolE);
853 ResV = AS.VResolution(TolE);
854 derive *= 2*(Abs(derive.X())*ResU + Abs(derive.Y())*ResV);
855 P2d = P1.Translated(derive);
856 if (I1->Classify(P2d, Min(ResU, ResV), 0)== TopAbs_IN) {
857 P1 = P2d;
858 }
859 else {
860 P2d = P1.Translated(-derive);
861 if (I1->Classify(P2d, Min(ResU, ResV), 0)== TopAbs_IN) {
862 P1 = P2d;
863 }
864 }
865 }
866 if(f1.IsSame(f2)) cured.Orientation(TopAbs_REVERSED);
867 PC = BRep_Tool::CurveOnSurface(cured,f2forward,Uf,Ul);
868 P2 = PC->Value(woned);
869 I2->Initialize(HS2);
870
871 SolDep(1) = P1.X(); SolDep(2) = P1.Y();
872 SolDep(3) = P2.X(); SolDep(4) = P2.Y();
873 const BRepAdaptor_Curve& Ced = Spine->CurrentElementarySpine(iedge);
874 gp_Pnt pnt = Ced.Value(woned);
875
876 if (Projection(PExt, pnt, els, w, tolesp) &&
877 PerformFirstSection(Spine,HGuide,Choix,HS1,HS2,
878 I1,I2,w,SolDep,Pos1,Pos2)) {
879 P1.SetCoord(SolDep(1),SolDep(2));
880 P2.SetCoord(SolDep(3),SolDep(4));
881 First = w;
882 return;
883 }
884 }
81bba717 885 // No solution was found for the faces adjacent to the trajectory.
886 // Now one tries the neighbor faces.
7fd59977 887 iedge = 0;
888 for(nbessai = 0; nbessai <= nbessaimax; nbessai++){
889 Standard_Real t = nbessai*unsurnbessaimax;
890 Standard_Real w = wf * (1. -t) + wl * t;
891 iedge = Spine->Index(w);
892 cured = Spine->Edges(iedge);
893 ConexFaces(Spine,iedge,RC,HS1,HS2);
894 f1 = HS1->ChangeSurface().Face();
895 f2 = HS2->ChangeSurface().Face();
896 Or1 = f1.Orientation();
897 Or2 = f2.Orientation();
898 Choix = ChFi3d::NextSide(Or1,Or2,
899 Stripe->OrientationOnFace1(),
900 Stripe->OrientationOnFace2(),
901 RC);
902 Standard_Real woned,Uf,Ul;
903 Spine->Parameter(iedge,w,woned,Standard_True);
904 TopoDS_Face f1forward = f1, f2forward = f2;
905 f1forward.Orientation(TopAbs_FORWARD);
906 f2forward.Orientation(TopAbs_FORWARD);
907 PC = BRep_Tool::CurveOnSurface(cured,f1forward,Uf,Ul);
908 P1 = PC->Value(woned);
909 PC = BRep_Tool::CurveOnSurface(cured,f2forward,Uf,Ul);
910 P2 = PC->Value(woned);
911 I1->Initialize(HS1);
912 I2->Initialize(HS2);
913 SolDep(1) = P1.X(); SolDep(2) = P1.Y();
914 SolDep(3) = P2.X(); SolDep(4) = P2.Y();
915 const BRepAdaptor_Curve& Ced = Spine->CurrentElementarySpine(iedge);
916 gp_Pnt pnt = Ced.Value(woned);
917// Extrema_LocateExtPC ext(pnt,els,w,1.e-8);
918// if(ext.IsDone()){
919// w = ext.Point().Parameter();
920 if (Projection(PExt, pnt, els, w, tolesp)) {
921 PerformFirstSection(Spine,HGuide,Choix,HS1,HS2,
922 I1,I2,w,SolDep,Pos1,Pos2);
923 gp_Pnt P;
924 gp_Vec V;
925 HGuide->D1(w,P,V);
926 Handle(Geom_Plane) pl = new Geom_Plane(P,V);
927 Handle(GeomAdaptor_HSurface) plane = new GeomAdaptor_HSurface(pl);
928
929 Standard_Boolean bonvoisin = 1, found = 0;
930 Standard_Integer NbChangement;
931 for (NbChangement = 1; bonvoisin && (!found) && (NbChangement < 5);
932 NbChangement++) {
933 if(Pos1 != TopAbs_IN){
934 bonvoisin = BonVoisin(P, HS1, f1, plane, cured,
935 SolDep(1),SolDep(2), myEFMap, tolesp);
936 }
937 if(Pos2 != TopAbs_IN && bonvoisin){
938 bonvoisin = BonVoisin(P, HS2, f2, plane, cured,
939 SolDep(3),SolDep(4), myEFMap, tolesp);
940 }
941 if(bonvoisin){
942 f1 = HS1->ChangeSurface().Face();
943 f2 = HS2->ChangeSurface().Face();
944 Or1 = f1.Orientation();
945 Or2 = f2.Orientation();
946 Choix = ChFi3d::NextSide(Or1,Or2,
947 Stripe->OrientationOnFace1(),
948 Stripe->OrientationOnFace2(),
949 RC);
950 I1->Initialize(HS1);
951 I2->Initialize(HS2);
952 if(PerformFirstSection(Spine,HGuide,Choix,HS1,HS2,
953 I1,I2,w,SolDep,Pos1,Pos2)){
954 P1.SetCoord(SolDep(1),SolDep(2));
955 P2.SetCoord(SolDep(3),SolDep(4));
956 First = w;
957 found = Standard_True;
958 }
959 }
960 }
961 if (found) return;
962 }
963 }
964 Spine->SetErrorStatus(ChFiDS_StartsolFailure);
965 Standard_Failure::Raise("StartSol echec");
966}
967
968//=======================================================================
969//function : ChFi3d_BuildPlane
970//purpose :
971//=======================================================================
972
973static void ChFi3d_BuildPlane (TopOpeBRepDS_DataStructure& DStr,
974 Handle(BRepAdaptor_HSurface)& HS,
975 gp_Pnt2d& pons,
976 const Handle(ChFiDS_SurfData)& SD,
977 const Standard_Boolean isfirst,
978 const Standard_Integer ons)
979{
980 Handle(Geom2d_Curve) Hc;
981 TopoDS_Face F = TopoDS::Face(DStr.Shape(SD->Index(ons)));
982 Standard_Real u,v;
983 gp_Pnt P;
984 //gp_Vec V1,V2;
985
986 if (SD->Vertex(isfirst,ons).IsOnArc()){
987 Hc = BRep_Tool::CurveOnSurface
988 (SD->Vertex(isfirst,ons).Arc(),F,u,v);
989 Hc->Value(SD->Vertex(isfirst,ons).ParameterOnArc()).Coord(u,v);
990 BRepLProp_SLProps theProp(HS->ChangeSurface(), u, v, 1, 1.e-12);
991 if (theProp.IsNormalDefined()) {
992 P = theProp.Value();
993 Handle(Geom_Plane) Pln = new Geom_Plane(P, theProp.Normal());
1c72dff6 994 TopoDS_Face NewF = BRepLib_MakeFace(Pln, Precision::Confusion());
7fd59977 995 NewF.Orientation(F.Orientation());
996 pons.SetCoord(0.,0.);
997 HS->ChangeSurface().Initialize(NewF);
81bba717 998 return; // everything is good !
7fd59977 999 }
1000 }
1001 Standard_Failure::Raise("ChFi3d_BuildPlane : echec .");
1002}
1003
1004//=======================================================================
1005//function : StartSol
81bba717 1006//purpose : If the commonpoint is not OnArc the input face
1007// is returned and 2D point is updated,
1008// if it is OnArc
1009// if it is detached the input face
1010// is returned and 2D point is updated,
1011// otherwise
1012// either there is a neighbor tangent face and it is returned
1013// with recalculated 2D point
1014// or if there is no face
1015// if the reference arc is Vref (extremity of the spine)
1016// this is the end and the input face is returned
1017// otherwise this is an obstacle and HC is updated.
7fd59977 1018//=======================================================================
1019
1020Standard_Boolean
1021ChFi3d_Builder::StartSol(const Handle(ChFiDS_Spine)& Spine,
81bba717 1022 Handle(BRepAdaptor_HSurface)& HS, // New face
1023 gp_Pnt2d& pons,// " Localization
1024 Handle(BRepAdaptor_HCurve2d)& HC, // Representation of the obstacle
7fd59977 1025 Standard_Real& W,
1026 const Handle(ChFiDS_SurfData)& SD,
1027 const Standard_Boolean isfirst,
1028 const Standard_Integer ons,
81bba717 1029 Handle(BRepAdaptor_HSurface)& HSref, // The other representation
1030 Handle(BRepAdaptor_HCurve2d)& HCref, // of the obstacle
7fd59977 1031 Standard_Boolean& RecP,
1032 Standard_Boolean& RecS,
1033 Standard_Boolean& RecRst,
1034 Standard_Boolean& c1obstacle,
81bba717 1035 Handle(BRepAdaptor_HSurface)& HSBis, // Face of support
1036 gp_Pnt2d& PBis, // and its point
7fd59977 1037 const Standard_Boolean decroch,
1038 const TopoDS_Vertex& Vref) const
1039{
1040 RecRst = RecS = RecP = c1obstacle = 0;
1041 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
1042 TopoDS_Face Fv,Fref;
1043 //gp_Pnt2d pp1,pp2;
1044 Handle(Geom2d_Curve) pc;
1045 Standard_Real Uf,Ul;
1046
1047 TopoDS_Face F = TopoDS::Face(DStr.Shape(SD->Index(ons)));
1048 if(!HSref.IsNull()) Fref = HSref->ChangeSurface().Face();
1049 const ChFiDS_CommonPoint& CP = SD->Vertex(isfirst,ons);
1050 HSBis.Nullify();
1051
1052 if (CP.IsOnArc()) {
1053 Standard_Integer notons;
1054 if (ons == 1) notons = 2;
1055 else notons = 1;
1056 const ChFiDS_CommonPoint& CPbis = SD->Vertex(isfirst,notons);
81bba717 1057 if (CPbis.IsOnArc()) { // It is checked if it is not the extension zone
1058 // In case CP is not at the end of surfdata and it is not necesary to take it into account
1059 // except for separate cases (ie pointus) ...
1060 //ts and tns were earlier CP.Parameter() and CPbis.Parameter, but sometimes they had no values.
7fd59977 1061 Standard_Real ts=SD->Interference(ons).Parameter(isfirst), tns=SD->Interference(notons).Parameter(isfirst);
1062 Standard_Boolean isExtend;
81bba717 1063 // Arbitrary test (to precise)
7fd59977 1064 if (isfirst) isExtend = (ts-tns > 100*tolesp);
1065 else isExtend = (tns-ts > 100*tolesp);
1066 if (isExtend && !CP.Point().IsEqual(CPbis.Point(), 0) ) {
81bba717 1067 // the state is preserved and False is returned (extension by the expected plane).
7fd59977 1068 HS->ChangeSurface().Initialize(F);
1069 pc = SD->Interference(ons).PCurveOnFace();
81bba717 1070 // The 2nd point is given by its trace on the support surface
7fd59977 1071 RecS = Standard_False;
1072 pons = pc->Value(tns);
1073 return Standard_False;
1074 }
1075 }
1076 }
1077
1078 if (CP.IsVertex() && !HC.IsNull() && !decroch){
81bba717 1079 //The edge is changed, the parameter is updated and
1080 //eventually the support face and(or) the reference face.
7fd59977 1081 TopoDS_Vertex VCP = CP.Vertex();
1082 TopoDS_Edge EHC = HC->ChangeCurve2d().Edge();
81bba717 1083 //One starts by searching in Fref another edge referencing VCP.
7fd59977 1084 TopExp_Explorer ex1,ex2;
1085 TopoDS_Edge newedge, edgereg;
1086 TopoDS_Face bidface = Fref, facereg;
1087 bidface.Orientation(TopAbs_FORWARD);
1088 for(ex1.Init(bidface,TopAbs_EDGE); ex1.More(); ex1.Next()){
1089 const TopoDS_Edge& cured = TopoDS::Edge(ex1.Current());
1090 Standard_Boolean found = 0;
1091 if(!cured.IsSame(EHC)){
1092 for(ex2.Init(cured,TopAbs_VERTEX); ex2.More() && !found; ex2.Next()){
1093 if(ex2.Current().IsSame(VCP)){
1094 if(IsG1(myEFMap,cured,Fref,Fv)){
1095 edgereg = cured;
1096 facereg = Fv;
1097 }
1098 else found = 1;
1099 }
1100 }
1101 }
1102 if(found) {
1103 newedge = cured;
1104 break;
1105 }
1106 }
1107 if(newedge.IsNull()){
81bba717 1108 //It is checked if EHC is not a closed edge.
7fd59977 1109 TopoDS_Vertex V1,V2;
1110 TopExp::Vertices(EHC,V1,V2);
1111 if(V1.IsSame(V2)){
1112 newedge = EHC;
1113 Standard_Real w1 = BRep_Tool::Parameter(V1,EHC);
1114 Standard_Real w2 = BRep_Tool::Parameter(V2,EHC);
1115 const ChFiDS_FaceInterference& fi = SD->Interference(ons);
1116 const Handle(Geom2d_Curve)& pcf = fi.PCurveOnFace();
1117 Standard_Real ww = fi.Parameter(isfirst);
1118
1119 gp_Pnt2d pww;
1120 if(!pcf.IsNull()) pww = pcf->Value(ww);
1121 else pww = SD->Get2dPoints(isfirst,ons);
1122 gp_Pnt2d p1 = HC->Value(w1);
1123 gp_Pnt2d p2 = HC->Value(w2);
1124
1125 if(p1.Distance(pww) > p2.Distance(pww)){
1126 W = w1;
1127 pons = p1;
1128 }
1129 else {
1130 W = w2;
1131 pons = p2;
1132 }
1133 RecP = c1obstacle = 1;
1134 return 1;
1135 }
1136 else if(!edgereg.IsNull()){
81bba717 1137 // the reference edge and face are changed.
7fd59977 1138 Fref = facereg;
1139 HSref->ChangeSurface().Initialize(Fref);
1140 for(ex1.Init(facereg,TopAbs_EDGE); ex1.More() && newedge.IsNull(); ex1.Next()){
1141 const TopoDS_Edge& cured = TopoDS::Edge(ex1.Current());
1142 if(!cured.IsSame(edgereg)){
1143 for(ex2.Init(cured,TopAbs_VERTEX); ex2.More(); ex2.Next()){
1144 if(ex2.Current().IsSame(VCP)){
1145 if(!IsG1(myEFMap,cured,Fref,Fv)){
1146 newedge = cured;
1147 }
1148 }
1149 }
1150 }
1151 }
1152 }
1153 }
81bba717 1154 // it is necessary to find the new support face of the fillet :
1155 // connected to FRef along the newedge.
7fd59977 1156 if(newedge.IsNull()) {
1157 Standard_Failure::Raise
81bba717 1158 ("StartSol : chain is not possible, new obstacle not found");
7fd59977 1159 }
1160 if(IsG1(myEFMap,newedge,Fref,Fv)){
1161 Standard_Failure::Raise
81bba717 1162 ("StartSol : chain is not possible, config non processed");
7fd59977 1163 }
1164 else if(Fv.IsNull()){
1165 Standard_Failure::Raise
81bba717 1166 ("StartSol : chain is not possible, new obstacle not found");
7fd59977 1167 }
1168 else{
1169 HS->ChangeSurface().Initialize(Fv);
1170 W = BRep_Tool::Parameter(VCP,newedge);
1171 HCref->ChangeCurve2d().Initialize(newedge,Fref);
1172 TopoDS_Face newface = Fv;
1173 newface.Orientation(TopAbs_FORWARD);
1174 TopExp_Explorer ex;
1175 for(ex.Init(newface,TopAbs_EDGE); ex.More(); ex.Next()){
1176 if(ex.Current().IsSame(newedge)){
1177 newedge = TopoDS::Edge(ex.Current());
1178 break;
1179 }
1180 }
1181 HC->ChangeCurve2d().Initialize(newedge,Fv);
1182 pons = HC->Value(W);
1183 }
1184 RecP = c1obstacle = 1;
1185 return 1;
81bba717 1186 } // End of Case Vertex && Obstacle
7fd59977 1187
1188 else if (CP.IsOnArc() && !HC.IsNull() && !decroch){
81bba717 1189 //Nothing is changed, the parameter is only updated.
7fd59977 1190 W = CP.ParameterOnArc();
1191 c1obstacle = 1;
1192 return 1;
1193 }
1194
1195 HC.Nullify();
1196
1197 if (CP.IsOnArc()){
1198 const TopoDS_Edge& E = CP.Arc();
1199 if(decroch){
1200 HS->ChangeSurface().Initialize(Fref);
1201 W = CP.ParameterOnArc();
1202 pc = BRep_Tool::CurveOnSurface(E,Fref,Uf,Ul);
1203 pons = pc->Value(W);
1204 RecS = 1;
1205 return 1;
1206 }
1207 if (SearchFace(Spine,CP,F,Fv)){
1208 HS->ChangeSurface().Initialize(Fv);
1209 RecS = 1;
1210 if (CP.IsVertex()) {
81bba717 1211 // One goes directly by the Vertex
7fd59977 1212 Standard_Integer Nb;
1213 TopoDS_Face aux;
81bba717 1214 // And it is checked that there are no other candidates
7fd59977 1215 Nb = SearchFaceOnV(CP, F, myVEMap, myEFMap, Fv, aux);
1216
1217 pons = BRep_Tool::Parameters(CP.Vertex(), Fv);
1218 HS->ChangeSurface().Initialize(Fv);
1219 if (Nb >=2) {
1220 HSBis = new (BRepAdaptor_HSurface)(aux);
1221 PBis = BRep_Tool::Parameters(CP.Vertex(), aux);
1222 }
1223 return 1;
1224 }
81bba717 1225 // otherwise one passes by the arc...
7fd59977 1226 if(!Fv.IsSame(F)){
1227 Fv.Orientation(TopAbs_FORWARD);
1228 TopoDS_Edge newedge;
1229 TopExp_Explorer ex;
1230 for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()){
1231 if(ex.Current().IsSame(E)){
1232 newedge = TopoDS::Edge(ex.Current());
1233 break;
1234 }
1235 }
1236 //gp_Vec Varc, VSurf;
81bba717 1237 // In cas of Tangent output, the current face becomes the support face
7fd59977 1238 if (SortieTangente(CP, F, SD, ons, 0.1)) {
1239 pc = BRep_Tool::CurveOnSurface(CP.Arc(),F,Uf,Ul);
1240 HSBis = new (BRepAdaptor_HSurface)(F);
1241 PBis = pc->Value(CP.ParameterOnArc());
1242 }
1243
1244
1245 pc = BRep_Tool::CurveOnSurface(newedge,Fv,Uf,Ul);
1246 }
1247 else{
1248 TopoDS_Edge newedge = E;
1249 newedge.Reverse();
1250 Fv.Orientation(TopAbs_FORWARD);
1251 pc = BRep_Tool::CurveOnSurface(newedge,Fv,Uf,Ul);
1252 }
1253 pons = pc->Value(CP.ParameterOnArc());
1254 return 1;
1255 }
1256 else if(!Fv.IsNull()){
1257 c1obstacle = 1;
1258 if(!Vref.IsNull()){
1259 TopExp_Explorer ex;
1260 for(ex.Init(E,TopAbs_VERTEX); ex.More(); ex.Next()){
1261 if(ex.Current().IsSame(Vref)){
1262 c1obstacle = 0;
1263 break;
1264 }
1265 }
1266 }
1267 if(c1obstacle){
1268 HS->ChangeSurface().Initialize(Fv);
1269 HSref->ChangeSurface().Initialize(F);
1270 W = CP.ParameterOnArc();
1271 HC = new BRepAdaptor_HCurve2d();
1272 TopoDS_Edge newedge;
1273 TopoDS_Face newface = Fv;
1274 newface.Orientation(TopAbs_FORWARD);
1275 TopExp_Explorer ex;
1276 for(ex.Init(newface,TopAbs_EDGE); ex.More(); ex.Next()){
1277 if(ex.Current().IsSame(E)){
1278 newedge = TopoDS::Edge(ex.Current());
1279 break;
1280 }
1281 }
1282 HC->ChangeCurve2d().Initialize(newedge,Fv);
1283 pons = HC->Value(W);
1284 HCref->ChangeCurve2d().Initialize(E,F);
1285 if(CP.IsVertex()) RecP = 1;
1286 else RecRst = 1;
1287 return 1;
1288 }
1289 else{
1290 HS->ChangeSurface().Initialize(F);
1291 W = CP.ParameterOnArc();
1292 pc = BRep_Tool::CurveOnSurface(E,F,Uf,Ul);
1293 pons = pc->Value(W);
1294 return Standard_False;
1295 }
1296 }
81bba717 1297 else{ // there is no neighbor face, the state is preserved and False is returned.
7fd59977 1298 HS->ChangeSurface().Initialize(F);
1299 W = CP.ParameterOnArc();
1300 pc = BRep_Tool::CurveOnSurface(E,F,Uf,Ul);
1301 pons = pc->Value(W);
1302 return Standard_False;
1303 }
1304 }
1305 else{
1306 HS->ChangeSurface().Initialize(F);
1307 const ChFiDS_FaceInterference& FI = SD->Interference(ons);
1308 if(FI.PCurveOnFace().IsNull()) pons = SD->Get2dPoints(isfirst,ons);
1309 else pons = FI.PCurveOnFace()->Value(FI.Parameter(isfirst));
1310 }
1311 return Standard_True;
1312}
1313
1314//=======================================================================
1315//function : SearchFace
1316//purpose :
1317//=======================================================================
1318
1319Standard_Boolean ChFi3d_Builder::SearchFace
1320 (const Handle(ChFiDS_Spine)& Spine,
1321 const ChFiDS_CommonPoint& Pc,
1322 const TopoDS_Face& FRef,
1323 TopoDS_Face& FVoi) const
1324{
1325 Standard_Boolean Trouve = Standard_False;
1326 if (! Pc.IsOnArc()) return Standard_False;
1327 FVoi.Nullify();
1328 TopoDS_Edge E;
1329 if (Pc.IsVertex()){
81bba717 1330 // attention it is necessary to analyze all faces that turn around of the vertex
0797d9d3 1331#ifdef OCCT_DEBUG
81bba717 1332 cout<<"Commonpoint on vertex, the process hangs up"<<endl;
7fd59977 1333#endif
81bba717 1334 if (Pc.HasVector()) { //General processing
7fd59977 1335 TopoDS_Face Fbis;
1336 Standard_Integer nb_faces;
1337 nb_faces = SearchFaceOnV(Pc, FRef, myVEMap, myEFMap, FVoi, Fbis);
1338 return ( nb_faces > 0);
1339 }
81bba717 1340 else { // Processing using the spine
7fd59977 1341 Standard_Boolean FindFace=Standard_False;
1342 gp_Pnt Point;
1343 gp_Vec VecSpine;
1344 Spine->D1(Pc.Parameter(), Point, VecSpine);
1345
81bba717 1346 // It is checked if one leaves from the current face.
7fd59977 1347 FindFace = IsInput(VecSpine, Pc.Vertex(), FRef);
1348 if (FindFace) {
1349 VecSpine.Reverse();
1350 FindFace = IsInput(VecSpine, Pc.Vertex(), FRef);
1351 }
81bba717 1352 // If one does not leave, it is ended
7fd59977 1353 if (FindFace) {
1354 FVoi = FRef;
1355 return Standard_True;
1356 }
1357
81bba717 1358 // Otherwise one finds the next among shared Faces
1359 // by a common edge G1
7fd59977 1360 TopTools_ListIteratorOfListOfShape ItE, ItF;
1361 for(ItE.Initialize(myVEMap(Pc.Vertex()));
1362 ItE.More() && (!FindFace); ItE.Next()) {
1363 E = TopoDS::Edge(ItE.Value());
1364 Trouve=Standard_False;
1365 for(ItF.Initialize(myEFMap(E));//, Trouve=Standard_False; 15.11.99 SVV
1366 ItF.More()&&(!Trouve); ItF.Next()) {
1367 if (TopoDS::Face(ItF.Value()).IsSame(FRef)) {
1368 Trouve = Standard_True;
1369 }
1370 }
1371 if (Trouve) FindFace = IsG1(myEFMap, E, FRef, FVoi);
1372 if (FindFace) {
1373 FindFace = Standard_False;
1374 if (Spine.IsNull()) {
1375 //La Spine peut etre nulle (ThreeCorner)
0797d9d3 1376#ifdef OCCT_DEBUG
7fd59977 1377 cout << "FindFace sur vertex avec spine nulle! QUEZAKO ?" << endl;
1378#endif
1379 return Standard_False;
1380 }
1381
81bba717 1382 // It is checked if the selected face actually possesses edges of the spine
1383 // containing the vertex on its front
1384 // This processing should go only if the Vertex belongs to the spine
1385 // This is a single case, for other vertexes it is required to do other things
7fd59977 1386 Trouve=Standard_False;
1387 for (Standard_Integer IE=1;//, Trouve=Standard_False; 15.11.99 SVV
1388 (IE<=Spine->NbEdges()) && (!Trouve); IE++) {
1389 E = Spine->Edges(IE);
1390 if ( (TopExp::FirstVertex(E).IsSame(Pc.Vertex()))
1391 ||(TopExp::LastVertex(E) .IsSame(Pc.Vertex())) ) {
1392 for(ItF.Initialize(myEFMap(E)), Trouve=Standard_False;
1393 ItF.More()&&(!Trouve); ItF.Next()) {
1394 if (TopoDS::Face(ItF.Value()).IsSame(FVoi)) {
1395 Trouve = Standard_True;
1396 }
1397 }
1398 }
1399 }
1400 FindFace = Trouve;
1401 }
1402 }
1403 }
1404 }
1405 else {
1406 return IsG1(myEFMap, Pc.Arc(), FRef, FVoi);
1407 }
1408 return Standard_False;
1409}
1410
1411
1412//=======================================================================
1413//function : ChFi3d_SingularExtremity
81bba717 1414//purpose : load the vertex in the DS and calculate the pcurve
1415// for an extremity in case of singular freeboundary
1416// or periodic and singular at the cut.
7fd59977 1417//=======================================================================
1418static void ChFi3d_SingularExtremity( Handle(ChFiDS_Stripe)& stripe,
1419 TopOpeBRepDS_DataStructure& DStr,
1420 const TopoDS_Vertex& Vtx,
1421 const Standard_Real tol3d,
1422 const Standard_Real tol2d)
1423{
1424 Handle(ChFiDS_SurfData) Fd;
1425 Standard_Real tolreached;
1426 Standard_Real Pardeb, Parfin;
1427 gp_Pnt2d VOnS1, VOnS2;
1428 Handle(Geom_Curve) C3d;
1429 Handle(Geom2d_Curve) PCurv;
1430 TopOpeBRepDS_Curve Crv;
81bba717 1431 // SurfData and its CommonPoints,
7fd59977 1432 Standard_Integer Ivtx, Icurv;
1433 Standard_Boolean isfirst;
1434
1435 if (stripe->Spine()->IsPeriodic()) {
1436 isfirst = Standard_True;
1437 Fd = stripe->SetOfSurfData()->Sequence().First();
1438 }
1439 else {
1440 Standard_Integer sens;
1441 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
1442 Fd = stripe->SetOfSurfData()->Sequence().Value(num);
1443 isfirst = (sens == 1);
1444 }
1445
1446 const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1);
1447 const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2);
81bba717 1448 // Is it always degenerated ?
7fd59977 1449 if ( CV1.Point().IsEqual( CV2.Point(), 0) ) {
1450 Ivtx = ChFi3d_IndexPointInDS(CV1, DStr);
1451 if (isfirst) {
1452 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
1453 Value(Fd->InterferenceOnS1().FirstParameter());
1454 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
1455 Value(Fd->InterferenceOnS2().FirstParameter());
1456 }
1457 else {
1458 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
1459 Value(Fd->InterferenceOnS1().LastParameter());
1460 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
1461 Value(Fd->InterferenceOnS2().LastParameter());
1462 }
1463
1464 ChFi3d_ComputeArete(CV1, VOnS1,
1465 CV2, VOnS2,
1466 DStr.Surface(Fd->Surf()).Surface(),
1467 C3d, PCurv,
1468 Pardeb,Parfin, tol3d, tol2d, tolreached,0);
1469 Crv = TopOpeBRepDS_Curve(C3d,tolreached);
1470 Icurv = DStr.AddCurve(Crv);
1471
1472 stripe->SetCurve(Icurv, isfirst);
1473 stripe->SetParameters(isfirst, Pardeb,Parfin);
1474 stripe->ChangePCurve(isfirst) = PCurv;
1475 stripe->SetIndexPoint(Ivtx, isfirst, 1);
1476 stripe->SetIndexPoint(Ivtx, isfirst, 2);
1477
1478 if (stripe->Spine()->IsPeriodic()) {
81bba717 1479 // periodic case : The operation is renewed
1480 // the curve 3d is not shared.
1481 // 2 degenerated edges coinciding in 3d
7fd59977 1482 isfirst = Standard_False;
1483 Fd = stripe->SetOfSurfData()->Sequence().Last();
1484 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
1485 Value(Fd->InterferenceOnS1().LastParameter());
1486 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
1487 Value(Fd->InterferenceOnS2().LastParameter());
1488
1489 ChFi3d_ComputeArete(CV1, VOnS1,
1490 CV2, VOnS2,
1491 DStr.Surface(Fd->Surf()).Surface(),
1492 C3d, PCurv,
1493 Pardeb,Parfin, tol3d, tol2d, tolreached,0);
1494 Crv = TopOpeBRepDS_Curve(C3d,tolreached);
1495 Icurv = DStr.AddCurve(Crv);
1496
1497 stripe->SetCurve(Icurv, isfirst);
1498 stripe->SetParameters(isfirst, Pardeb,Parfin);
1499 stripe->ChangePCurve(isfirst) = PCurv;
1500 stripe->SetIndexPoint(Ivtx, isfirst, 1);
1501 stripe->SetIndexPoint(Ivtx, isfirst, 2);
1502 }
1503 }
1504}
1505
1506//=======================================================================
1507//function : ChFi3d_MakeExtremities
81bba717 1508//purpose : calculate Curves3d and pcurves of extremities in
1509// periodic and freeboundary cases.
7fd59977 1510//=======================================================================
1511static Standard_Boolean IsFree(const TopoDS_Shape& E,
1512 const ChFiDS_Map& EFMap)
1513{
1514 if(!EFMap.Contains(E)) return 0;
1515 TopTools_ListIteratorOfListOfShape It;
1516 TopoDS_Shape Fref;
1517 for(It.Initialize(EFMap(E)); It.More(); It.Next()){
1518 if(Fref.IsNull()) Fref = It.Value();
1519 else if(!Fref.IsSame(It.Value())) return 0;
1520 }
1521 return 1;
1522}
1523
1524static void ChFi3d_MakeExtremities(Handle(ChFiDS_Stripe)& Stripe,
1525 TopOpeBRepDS_DataStructure& DStr,
1526 const ChFiDS_Map& EFMap,
1527 const Standard_Real tol3d,
1528 const Standard_Real tol2d)
1529{
1530 Handle(ChFiDS_Spine)& sp = Stripe->ChangeSpine();
1531 Standard_Real Pardeb,Parfin;
1532 Handle(Geom_Curve) C3d;
1533 Standard_Real tolreached;
1534 if(sp->IsPeriodic()){
1535 Bnd_Box b1,b2;
1536 const Handle(ChFiDS_SurfData)&
1537 SDF = Stripe->SetOfSurfData()->Sequence().First();
1538 const ChFiDS_CommonPoint& CV1 = SDF->VertexFirstOnS1();
1539 const ChFiDS_CommonPoint& CV2 = SDF->VertexFirstOnS2();
1540 if ( !CV1.Point().IsEqual(CV2.Point(), 0) ) {
1541 ChFi3d_ComputeArete(CV1,
1542 SDF->InterferenceOnS1().PCurveOnSurf()->
1543 Value(SDF->InterferenceOnS1().FirstParameter()),
1544 CV2,
1545 SDF->InterferenceOnS2().PCurveOnSurf()->
1546 Value(SDF->InterferenceOnS2().FirstParameter()),
1547 DStr.Surface(SDF->Surf()).Surface(),C3d,
1548 Stripe->ChangeFirstPCurve(),Pardeb,Parfin,
1549 tol3d,tol2d,tolreached,0);
1550 TopOpeBRepDS_Curve Crv(C3d,tolreached);
1551 Stripe->ChangeFirstCurve(DStr.AddCurve(Crv));
1552 Stripe->ChangeFirstParameters(Pardeb,Parfin);
1553 Stripe->ChangeIndexFirstPointOnS1
1554 (ChFi3d_IndexPointInDS(SDF->VertexFirstOnS1(),DStr));
1555 Stripe->ChangeIndexFirstPointOnS2
1556 (ChFi3d_IndexPointInDS(SDF->VertexFirstOnS2(),DStr));
1557 Standard_Integer ICurv = Stripe->FirstCurve();
1558 Stripe->ChangeLastParameters(Pardeb,Parfin);
1559 Stripe->ChangeLastCurve(ICurv);
1560 Stripe->ChangeIndexLastPointOnS1(Stripe->IndexFirstPointOnS1());
1561 Stripe->ChangeIndexLastPointOnS2(Stripe->IndexFirstPointOnS2());
1562
1563 const Handle(ChFiDS_SurfData)&
1564 SDL = Stripe->SetOfSurfData()->Sequence().Last();
1565
1566
1567 ChFi3d_ComputePCurv(C3d,
1568 SDL->InterferenceOnS1().PCurveOnSurf()->
1569 Value(SDL->InterferenceOnS1().LastParameter()),
1570 SDL->InterferenceOnS2().PCurveOnSurf()->
1571 Value(SDL->InterferenceOnS2().LastParameter()),
1572 Stripe->ChangeLastPCurve(),
1573 DStr.Surface(SDL->Surf()).Surface(),
1574 Pardeb,Parfin,tol3d,tolreached);
1575 Standard_Real oldtol = DStr.ChangeCurve(ICurv).Tolerance();
1576 DStr.ChangeCurve(ICurv).Tolerance(Max(oldtol,tolreached));
1577 if(CV1.IsOnArc()){
1578 ChFi3d_EnlargeBox(CV1.Arc(),EFMap(CV1.Arc()),CV1.ParameterOnArc(),b1);
1579 }
1580
1581 if(CV2.IsOnArc()){
1582 ChFi3d_EnlargeBox(CV2.Arc(),EFMap(CV2.Arc()),CV2.ParameterOnArc(),b2);
1583 }
1584 ChFi3d_EnlargeBox(DStr,Stripe,SDF,b1,b2,1);
1585 ChFi3d_EnlargeBox(DStr,Stripe,SDL,b1,b2,0);
1586 if (!CV1.IsVertex())
1587 ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexFirstPointOnS1());
1588 if (!CV2.IsVertex())
1589 ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexFirstPointOnS2());
1590 }
1591 else {
81bba717 1592 // Case of the single extremity
7fd59977 1593 if (CV1.IsVertex()) {
1594 ChFi3d_SingularExtremity(Stripe, DStr, CV1.Vertex(), tol3d, tol2d);
1595 }
63c629aa 1596# if CHFI3D_DEB
81bba717 1597 else { cout << "MakeExtremities : Singularity out of Vertex !!" << endl; }
7fd59977 1598# endif
1599 }
1600 return;
1601 }
1602
1603 const Handle(ChFiDS_SurfData)&
1604 SDdeb = Stripe->SetOfSurfData()->Sequence().First();
1605
1606 const ChFiDS_CommonPoint& cpdeb1 = SDdeb->VertexFirstOnS1();
1607 const ChFiDS_CommonPoint& cpdeb2 = SDdeb->VertexFirstOnS2();
1608 Standard_Boolean freedeb = sp->FirstStatus() == ChFiDS_FreeBoundary;
1609 if(!freedeb && cpdeb1.IsOnArc() && cpdeb2.IsOnArc()){
1610 freedeb = (IsFree(cpdeb1.Arc(),EFMap) && IsFree(cpdeb2.Arc(),EFMap));
1611 }
1612 if(freedeb){
1613 sp->SetFirstStatus(ChFiDS_FreeBoundary);
1614 Bnd_Box b1,b2;
1615 if ( !cpdeb1.Point().IsEqual(cpdeb2.Point(), 0) ) {
1616 Standard_Boolean plane;
1617 gp_Pnt2d UV1,UV2;
1618 UV1=SDdeb->InterferenceOnS1().PCurveOnSurf()->
1619 Value(SDdeb->InterferenceOnS1().FirstParameter());
1620 UV2=SDdeb->InterferenceOnS2().PCurveOnSurf()->
1621 Value(SDdeb->InterferenceOnS2().FirstParameter());
81bba717 1622// The intersection of the fillet by a plane is attempted
7fd59977 1623
1624 Handle(GeomAdaptor_HSurface) HConge=ChFi3d_BoundSurf(DStr,SDdeb,1,2);
1625 ChFi3d_CoupeParPlan(cpdeb1,cpdeb2,HConge,UV1,UV2,
1626 tol3d,tol2d,C3d,Stripe->ChangeFirstPCurve(),tolreached,
1627 Pardeb,Parfin,plane);
1628 if (!plane)
1629 ChFi3d_ComputeArete(cpdeb1,
1630 SDdeb->InterferenceOnS1().PCurveOnSurf()->
1631 Value(SDdeb->InterferenceOnS1().FirstParameter()),
1632 cpdeb2,
1633 SDdeb->InterferenceOnS2().PCurveOnSurf()->
1634 Value(SDdeb->InterferenceOnS2().FirstParameter()),
1635 DStr.Surface(SDdeb->Surf()).Surface(),C3d,
1636 Stripe->ChangeFirstPCurve(),Pardeb,Parfin,
1637 tol3d,tol2d,tolreached,0);
1638 TopOpeBRepDS_Curve Crv(C3d,tolreached);
1639 Stripe->ChangeFirstCurve(DStr.AddCurve(Crv));
1640 Stripe->ChangeFirstParameters(Pardeb,Parfin);
1641 Stripe->ChangeIndexFirstPointOnS1
1642 (ChFi3d_IndexPointInDS(SDdeb->VertexFirstOnS1(),DStr));
1643 Stripe->ChangeIndexFirstPointOnS2
1644 (ChFi3d_IndexPointInDS(SDdeb->VertexFirstOnS2(),DStr));
1645 if(cpdeb1.IsOnArc()){
1646 ChFi3d_EnlargeBox(cpdeb1.Arc(),EFMap(cpdeb1.Arc()),cpdeb1.ParameterOnArc(),b1);
1647 }
1648 if(cpdeb2.IsOnArc()){
1649 ChFi3d_EnlargeBox(cpdeb2.Arc(),EFMap(cpdeb2.Arc()),cpdeb2.ParameterOnArc(),b2);
1650 }
1651 ChFi3d_EnlargeBox(DStr,Stripe,SDdeb,b1,b2,1);
1652 if (!cpdeb1.IsVertex())
1653 ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexFirstPointOnS1());
1654 if (!cpdeb2.IsVertex())
1655 ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexFirstPointOnS2());
1656 }
81bba717 1657 else { // Case of a singular extremity
7fd59977 1658 if (cpdeb1.IsVertex()) {
1659 ChFi3d_SingularExtremity(Stripe, DStr, cpdeb1.Vertex(), tol3d, tol2d);
1660 }
63c629aa 1661# if CHFI3D_DEB
81bba717 1662 else { cout << "MakeExtremities : Singularity out of Vertex !!" << endl; }
7fd59977 1663# endif
1664 }
1665 }
1666 const Handle(ChFiDS_SurfData)&
1667 SDfin = Stripe->SetOfSurfData()->Sequence().Last();
1668 const ChFiDS_CommonPoint& cpfin1 = SDfin->VertexLastOnS1();
1669 const ChFiDS_CommonPoint& cpfin2 = SDfin->VertexLastOnS2();
1670 Standard_Boolean freefin = sp->LastStatus() == ChFiDS_FreeBoundary;
1671 if(!freefin && cpfin1.IsOnArc() && cpfin2.IsOnArc()){
1672 freefin = (IsFree(cpfin1.Arc(),EFMap) && IsFree(cpfin2.Arc(),EFMap));
1673 }
1674 if(freefin){
1675 sp->SetLastStatus(ChFiDS_FreeBoundary);
1676 Bnd_Box b1,b2;
1677 if ( !cpfin1.Point().IsEqual(cpfin2.Point(), 0) ) {
1678 Standard_Boolean plane;
1679 gp_Pnt2d UV1,UV2;
1680 UV1=SDfin->InterferenceOnS1().PCurveOnSurf()->
1681 Value(SDfin->InterferenceOnS1().LastParameter());
1682 UV2=SDfin->InterferenceOnS2().PCurveOnSurf()->
1683 Value(SDfin->InterferenceOnS2().LastParameter());
81bba717 1684// Intersection of the fillet by a plane is attempted
7fd59977 1685
1686 Handle(GeomAdaptor_HSurface) HConge=ChFi3d_BoundSurf(DStr,SDfin,1,2);
1687 ChFi3d_CoupeParPlan(cpfin1,cpfin2,HConge,UV1,UV2,
1688 tol3d,tol2d,C3d,Stripe->ChangeLastPCurve(),tolreached,
1689 Pardeb,Parfin,plane);
1690 if (!plane)
1691 ChFi3d_ComputeArete(cpfin1,
1692 SDfin->InterferenceOnS1().PCurveOnSurf()->
1693 Value(SDfin->InterferenceOnS1().LastParameter()),
1694 cpfin2,
1695 SDfin->InterferenceOnS2().PCurveOnSurf()->
1696 Value(SDfin->InterferenceOnS2().LastParameter()),
1697 DStr.Surface(SDfin->Surf()).Surface(),C3d,
1698 Stripe->ChangeLastPCurve(),Pardeb,Parfin,
1699 tol3d,tol2d,tolreached,0);
1700 TopOpeBRepDS_Curve Crv(C3d,tolreached);
1701 Stripe->ChangeLastCurve(DStr.AddCurve(Crv));
1702 Stripe->ChangeLastParameters(Pardeb,Parfin);
1703 Stripe->ChangeIndexLastPointOnS1
1704 (ChFi3d_IndexPointInDS(SDfin->VertexLastOnS1(),DStr));
1705 Stripe->ChangeIndexLastPointOnS2
1706 (ChFi3d_IndexPointInDS(SDfin->VertexLastOnS2(),DStr));
1707 if(cpfin1.IsOnArc()){
1708 ChFi3d_EnlargeBox(cpfin1.Arc(),EFMap(cpfin1.Arc()),cpfin1.ParameterOnArc(),b1);
1709 }
1710 if(cpfin2.IsOnArc()){
1711 ChFi3d_EnlargeBox(cpfin2.Arc(),EFMap(cpfin2.Arc()),cpfin2.ParameterOnArc(),b2);
1712 }
1713 ChFi3d_EnlargeBox(DStr,Stripe,SDfin,b1,b2,0);
1714 if (!cpfin1.IsVertex())
1715 ChFi3d_SetPointTolerance(DStr,b1,Stripe->IndexLastPointOnS1());
1716 if (!cpfin2.IsVertex())
1717 ChFi3d_SetPointTolerance(DStr,b2,Stripe->IndexLastPointOnS2());
1718 }
81bba717 1719 else { // Case of the single extremity
7fd59977 1720 if (cpfin1.IsVertex()) {
1721 ChFi3d_SingularExtremity(Stripe, DStr, cpfin1.Vertex(), tol3d, tol2d);
1722 }
63c629aa 1723# if CHFI3D_DEB
81bba717 1724 else { cout << "MakeExtremities : Singularity out of Vertex !!" << endl; }
7fd59977 1725# endif
1726 }
1727 }
1728}
1729
1730//=======================================================================
1731//function : ChFi3d_Purge
1732//purpose :
1733//=======================================================================
1734
1735static void ChFi3d_Purge (Handle(ChFiDS_Stripe)& Stripe,
1736 Handle(ChFiDS_SurfData)& SD,
1737 const ChFiDS_CommonPoint& VRef,
1738 const Standard_Boolean isfirst,
1739 const Standard_Integer ons,
1740 Standard_Boolean& intf,
1741 Standard_Boolean& intl)
1742{
81bba717 1743 if (isfirst) intf = 1; else intl = 1; // End.
7fd59977 1744 Standard_Integer opp = 3-ons;
1745 if (!SD->Vertex(isfirst,opp).IsOnArc() ||
1746 SD->TwistOnS1() || SD->TwistOnS2() ) {
0797d9d3 1747#ifdef OCCT_DEBUG
81bba717 1748 cout<<"ChFi3d_Purge : No output on extension."<<endl;
7fd59977 1749#endif
1750 ChFiDS_SequenceOfSurfData& Seq =
1751 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1752 if(isfirst) Seq.Remove(1);
1753 else Seq.Remove(Seq.Length());
1754 return;
1755 }
1756 if (ons == 1) SD->ChangeIndexOfS1(0);
1757 else SD->ChangeIndexOfS2(0);
1758
1759 SD->ChangeVertex(!isfirst,ons) = VRef;
1760 SD->ChangeVertex(isfirst,ons) = VRef;
1761
1762 ChFiDS_FaceInterference& fi = SD->ChangeInterference(ons);
1763 if(isfirst) fi.SetFirstParameter(fi.LastParameter());
1764 else fi.SetLastParameter(fi.FirstParameter());
1765 fi.SetLineIndex(0);
1766}
1767
1768//=======================================================================
1769//function : InsertAfter
81bba717 1770//purpose : insert Item after ref in Seq. If ref is null, the item is
1771// inserted at the beginning.
7fd59977 1772//=======================================================================
1773
1774static void InsertAfter (Handle(ChFiDS_Stripe)& Stripe,
1775 Handle(ChFiDS_SurfData)& Ref,
1776 Handle(ChFiDS_SurfData)& Item)
1777{
1778 if (Ref == Item)
81bba717 1779 Standard_Failure::Raise("InsertAfter : twice the same surfdata.");
7fd59977 1780
1781 ChFiDS_SequenceOfSurfData& Seq =
1782 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1783
1784 if (Seq.IsEmpty() || Ref.IsNull()) {
1785 Seq.Prepend(Item);
1786 }
1787 for (Standard_Integer i = 1; i <= Seq.Length(); i++) {
1788 if (Seq.Value(i) == Ref) {
1789 Seq.InsertAfter(i,Item);
1790 break;
1791 }
1792 }
1793}
1794
1795//=======================================================================
1796//function : RemoveSD
1797//purpose :
1798//=======================================================================
1799
1800static void RemoveSD (Handle(ChFiDS_Stripe)& Stripe,
1801 Handle(ChFiDS_SurfData)& Prev,
1802 Handle(ChFiDS_SurfData)& Next)
1803{
1804 ChFiDS_SequenceOfSurfData& Seq =
1805 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1806 if(Seq.IsEmpty()) return;
1807 Standard_Integer iprev = 0, inext = 0;
1808 for (Standard_Integer i = 1; i <= Seq.Length(); i++) {
1809 if (Seq.Value(i) == Prev) iprev = i + 1;
1810 if (Seq.Value(i) == Next) { inext = i - 1; break; }
1811 }
1812 if(Prev.IsNull()) iprev = 1;
1813 if(Next.IsNull()) inext = Seq.Length();
1814 if(iprev <= inext) Seq.Remove(iprev,inext);
1815}
1816
1817//=======================================================================
1818//function : InsertBefore
81bba717 1819//purpose : Insert item before ref in Seq. If ref is null, the item is
1820// inserted in the queue.
7fd59977 1821//=======================================================================
1822
1823static void InsertBefore (Handle(ChFiDS_Stripe)& Stripe,
1824 Handle(ChFiDS_SurfData)& Ref,
1825 Handle(ChFiDS_SurfData)& Item)
1826{
1827 if (Ref == Item)
81bba717 1828 Standard_Failure::Raise("InsertBefore : twice the same surfdata.");
7fd59977 1829
1830 ChFiDS_SequenceOfSurfData& Seq =
1831 Stripe->ChangeSetOfSurfData()->ChangeSequence();
1832
1833 if (Seq.IsEmpty() || Ref.IsNull()) {
1834 Seq.Append(Item);
1835 }
1836 for (Standard_Integer i = 1; i <= Seq.Length(); i++) {
1837 if (Seq.Value(i) == Ref) {
1838 Seq.InsertBefore(i,Item);
1839 break;
1840 }
1841 }
1842}
1843
1844
1845//=======================================================================
1846//function : PerformSetOfSurfOnElSpine
1847//purpose :
1848//=======================================================================
1849
1850void ChFi3d_Builder::PerformSetOfSurfOnElSpine
1851(const Handle(ChFiDS_HElSpine)& HGuide,
1852 Handle(ChFiDS_Stripe)& Stripe,
1853 Handle(BRepTopAdaptor_TopolTool)& It1,
1854 Handle(BRepTopAdaptor_TopolTool)& It2,
1855 const Standard_Boolean Simul)
1856{
0797d9d3 1857#ifdef OCCT_DEBUG
7fd59977 1858 OSD_Chronometer ch1;
1859#endif
1860
1861 ChFiDS_ElSpine& Guide = HGuide->ChangeCurve();
1862 Standard_Real wf = Guide.FirstParameter();
1863 Standard_Real wl = Guide.LastParameter();
1864 Standard_Real locfleche = (wl - wf) * fleche;
1865 Standard_Real wfsav = wf, wlsav = wl;
73d0a668 1866 if (!Guide.IsPeriodic())
1867 {
1868 //Now the ElSpine is artificially extended to help rsnld.
1869 Standard_Real prab = 0.01;
1870 Guide.FirstParameter(wf-prab*(wl-wf));
1871 Guide.LastParameter (wl+prab*(wl-wf));
1872 }
7fd59977 1873 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
1874 Standard_Integer ii, nbed = Spine->NbEdges();
1875 Standard_Real lastedlastp = Spine->LastParameter(nbed);
1876
1877 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
1878
1879 Handle(ChFiDS_SurfData) ref = Guide.Previous();
1880 Handle(ChFiDS_SurfData) refbis, SD;
1881 Handle(ChFiDS_SurfData) raf = Guide.Next();
1882 RemoveSD(Stripe,ref,raf);
1883
1884 Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface();
1885 Handle(BRepAdaptor_HSurface) HS2 = new BRepAdaptor_HSurface();
1886 Handle(BRepAdaptor_HSurface) HS3, HS4;
1887 Handle(BRepAdaptor_HSurface) HSref1 = new BRepAdaptor_HSurface();
1888 Handle(BRepAdaptor_HSurface) HSref2 = new BRepAdaptor_HSurface();
1889 Handle(BRepAdaptor_HCurve2d) HC1,HC2;
1890 Handle(BRepAdaptor_HCurve2d) HCref1 = new BRepAdaptor_HCurve2d();
1891 Handle(BRepAdaptor_HCurve2d) HCref2 = new BRepAdaptor_HCurve2d();
1d47d8d0 1892 Standard_Boolean decroch1 = Standard_False, decroch2 = Standard_False;
1893 Standard_Boolean RecP1 = Standard_False, RecS1 = Standard_False, RecRst1 = Standard_False, obstacleon1 = Standard_False;
1894 Standard_Boolean RecP2 = Standard_False, RecS2 = Standard_False, RecRst2 = Standard_False, obstacleon2 = Standard_False;
7fd59977 1895 gp_Pnt2d pp1,pp2,pp3,pp4;
1d47d8d0 1896 Standard_Real w1 = 0.,w2 = 0.;
7fd59977 1897 math_Vector Soldep(1,4);
1898 math_Vector SoldepCS(1,3);
1899 math_Vector SoldepCC(1,2);
1900
81bba717 1901 // Restore a neighboring KPart.
1902 // If no neighbor calculation start point.
7fd59977 1903 Standard_Boolean forward = Standard_True;
1904 Standard_Boolean Inside = Standard_False;
1905 Standard_Real First = wf;
1906 Standard_Real Last = wl;
1907 Standard_Boolean Ok1 = 1,Ok2 = 1;
81bba717 1908 // Restore the next KPart if it exists
7fd59977 1909 TopoDS_Vertex Vref;
1910 if(ref.IsNull() && raf.IsNull()){
1911 //sinon solution approchee.
1912 Inside = Standard_True;
1913
0797d9d3 1914#ifdef OCCT_DEBUG
81bba717 1915 ChFi3d_InitChron(ch1);// init perf for StartSol
7fd59977 1916#endif
1917
1918 StartSol(Stripe,HGuide,HS1,HS2,It1,It2,pp1,pp2,First);
1919
0797d9d3 1920#ifdef OCCT_DEBUG
81bba717 1921 ChFi3d_ResultChron(ch1,t_startsol); // result perf for StartSol
7fd59977 1922#endif
1923
1924 Last = wf;
1925 if(Guide.IsPeriodic()) {
1926 Last = First - Guide.Period();
73d0a668 1927 Guide.SaveFirstParameter();
7fd59977 1928 Guide.FirstParameter(Last);
73d0a668 1929 Guide.SaveLastParameter();
81bba717 1930 Guide.LastParameter (First * 1.1);//Extension to help rsnld.
7fd59977 1931 }
1932 }
1933 else{
1934 if(!Spine->IsPeriodic() && (wl - lastedlastp > -tolesp)){
1935 Vref = Spine->LastVertex();
1936 }
1937 if (ref.IsNull()) {
1938 if(!Spine->IsPeriodic() && (wf < tolesp)){
1939 Vref = Spine->FirstVertex();
1940 }
1941 ref = raf;
1942 forward = Standard_False;
1943 First = wl; Last = Guide.FirstParameter();
1944 }
1945
0797d9d3 1946#ifdef OCCT_DEBUG
81bba717 1947 ChFi3d_InitChron(ch1);// init perf for startsol
7fd59977 1948#endif
1949
1950
1951 Ok1 = StartSol(Spine,HS1,pp1,HC1,w1,ref,!forward,1,
1952 HSref1,HCref1,RecP1,RecS1,RecRst1,obstacleon1,
1953 HS3,pp3,decroch1,Vref);
1954 Ok2 = StartSol(Spine,HS2,pp2,HC2,w2,ref,!forward,2,
1955 HSref2,HCref2, RecP2,RecS2,RecRst2,obstacleon2,
1956 HS4,pp4,decroch2,Vref);
1957 HC1.Nullify();
1958 HC2.Nullify();
1959
0797d9d3 1960#ifdef OCCT_DEBUG
81bba717 1961 ChFi3d_ResultChron(ch1,t_startsol); // result perf for startsol
7fd59977 1962#endif
1963
1964
1965 if(Ok1 == 1 && Ok2 == 1) {
1966 if(forward) Guide.FirstParameter(wf);
1967 else Guide.LastParameter(wl);
1968 }
1969 }
1970 Standard_Boolean fini = Standard_False;
1971 Standard_Boolean complete = Inside;
1972 if(!Guide.IsPeriodic()){
1973 Standard_Integer indf = Spine->Index(wf);
1974 Standard_Integer indl = Spine->Index(wl,0);
1975 if(Spine->IsPeriodic() && (indl < indf)) indl += nbed;
1976 nbed = indl-indf+1;
1977 }
81bba717 1978 // No Max at the touch : 20 points by edge at average without
1979 // counting the extensions.
7fd59977 1980
1981 Standard_Real bidf = wf, bidl = wl;
1982 if(!Spine->IsPeriodic()) {
1983 bidf = Max(0.,wf);
1984 bidl = Min(wl,Spine->LastParameter(Spine->NbEdges()));
81bba717 1985 // PMN 20/07/98 : Attention in case if there is only extension
7fd59977 1986 if ((bidl-bidf) < 0.01 * Spine->LastParameter(Spine->NbEdges())) {
1987 bidf = wf;
1988 bidl = wl;
1989 }
1990 }
1991 Standard_Real MaxStep = (bidl-bidf)*0.05/nbed;
7fd59977 1992 Standard_Real Firstsov = 0.;
7fd59977 1993 Standard_Boolean intf = 0, intl = 0;
1994 while(!fini){
81bba717 1995 // are these the ends (no extension on periodic).
7fd59977 1996 Ok1 = 1,Ok2 = 1;
1997 if(!Spine->IsPeriodic()){
1998 if(wf < tolesp && (complete == Inside)){
1999 if(Spine->FirstStatus() == ChFiDS_OnSame) intf = 2;
2000 else intf = 1;
2001 }
2002 if(Spine->IsTangencyExtremity(Standard_True)){
2003 intf = 4;
2004 Guide.FirstParameter(wfsav);
2005 }
2006 if(wl - lastedlastp > -tolesp){
2007 if(Spine->LastStatus() == ChFiDS_OnSame) intl = 2;
2008 else intl = 1;
2009 }
2010 if(Spine->IsTangencyExtremity(Standard_False)){
2011 intl = 4;
2012 Guide.LastParameter(wlsav);
2013 }
2014 }
2015 if(intf && !forward) Vref = Spine->FirstVertex();
2016 if(intl && forward) Vref = Spine->LastVertex();
2017 if(!ref.IsNull()){
2018
0797d9d3 2019#ifdef OCCT_DEBUG
81bba717 2020 ChFi3d_InitChron(ch1);// init perf for StartSol
7fd59977 2021#endif
2022
2023 Ok1 = StartSol(Spine,HS1,pp1,HC1,w1,ref,!forward,1,
2024 HSref1,HCref1, RecP1,RecS1,RecRst1,obstacleon1,
2025 HS3,pp3,decroch1,Vref);
2026 Ok2 = StartSol(Spine,HS2,pp2,HC2,w2,ref,!forward,2,
2027 HSref2,HCref2, RecP2,RecS2,RecRst2,obstacleon2,
2028 HS4,pp4,decroch2,Vref);
2029
0797d9d3 2030#ifdef OCCT_DEBUG
81bba717 2031 ChFi3d_ResultChron(ch1,t_startsol); // result perf for StartSol
7fd59977 2032#endif
2033
2034 }
2035
81bba717 2036 // No more connected faces. Construction of the tangent plane to continue the path
2037 // till the output on the other face.
7fd59977 2038 if ((!Ok1 && HC1.IsNull()) || (!Ok2 && HC2.IsNull())) {
2039 if ((intf && !forward) || (intl && forward)) {
2040 if (!Ok1) ChFi3d_BuildPlane (DStr,HS1,pp1,ref,!forward,1);
2041 if (!Ok2) ChFi3d_BuildPlane (DStr,HS2,pp2,ref,!forward,2);
2042 if(intf) intf = 5;
2043 else if(intl) intl = 5;
2044 if(forward) Guide.FirstParameter(wf);
2045 else Guide.LastParameter(wl);
2046 }
81bba717 2047 else Standard_Failure::Raise("PerformSetOfSurfOnElSpine : Chaining is impossible.");
7fd59977 2048 }
2049
81bba717 2050 // Definition of the domain of path It1, It2
7fd59977 2051 It1->Initialize(HS1);
2052 It2->Initialize(HS2);
2053
81bba717 2054 // Calculate one (several if singularity) SurfaData
7fd59977 2055 SD = new ChFiDS_SurfData();
2056 ChFiDS_SequenceOfSurfData SeqSD;
2057 SeqSD.Append(SD);
2058
2059 if(obstacleon1 && obstacleon2){
2060 TopAbs_Orientation Or1 = HSref1->ChangeSurface().Face().Orientation();
2061 TopAbs_Orientation Or2 = HSref2->ChangeSurface().Face().Orientation();
2062 Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2,
2063 Stripe->OrientationOnFace1(),
2064 Stripe->OrientationOnFace2(),
2065 Stripe->Choix());
2066
2067
81bba717 2068 // Calculate the criterion of Choice edge / edge
7fd59977 2069 if (Choix%2 == 0) Choix = 4;
2070 else Choix = 1;
2071
2072 SoldepCC(1) = w1; SoldepCC(2) = w2;
2073 if(Simul){
2074 SimulSurf(SD,HGuide,Spine,Choix,
2075 HS1,It1,HC1,HSref1,HCref1,decroch1,Or1,
2076 HS2,It2,HC2,HSref2,HCref2,decroch2,Or2,
2077 locfleche,tolesp,First,Last,Inside,Inside,forward,
2078 RecP1,RecRst1,RecP2,RecRst2,SoldepCC);
2079 }
2080 else{
0797d9d3 2081#ifdef OCCT_DEBUG
81bba717 2082 ChFi3d_InitChron(ch1); // init perf for PerformSurf
7fd59977 2083#endif
2084 PerformSurf(SeqSD,HGuide,Spine,Choix,
2085 HS1,It1,HC1,HSref1,HCref1,decroch1,Or1,
2086 HS2,It2,HC2,HSref2,HCref2,decroch2,Or2,
2087 MaxStep,locfleche,tolesp,First,Last,Inside,Inside,forward,
2088 RecP1,RecRst1,RecP2,RecRst2,SoldepCC);
0797d9d3 2089#ifdef OCCT_DEBUG
81bba717 2090 ChFi3d_ResultChron(ch1,t_performsurf); //result perf for PerformSurf
7fd59977 2091#endif
2092 }
2093 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2094 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2095 }
2096 else if (obstacleon1){
2097 TopAbs_Orientation Or1 = HSref1->ChangeSurface().Face().Orientation();
2098 TopAbs_Orientation Or2 = HS2->ChangeSurface().Face().Orientation();
2099 Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2,
2100 Stripe->OrientationOnFace1(),
2101 Stripe->OrientationOnFace2(),
2102 -Stripe->Choix());
2103 if(Choix%2 == 1) Choix++;
2104 else Choix--;
2105 SoldepCS(3) = w1; SoldepCS(1) = pp2.X(); SoldepCS(2) = pp2.Y();
2106 if(Simul){
2107 SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,HC1,HSref1,HCref1,decroch1,
2108 HS2,It2,Or2,locfleche,tolesp,First,Last,
2109 Inside,Inside,forward,RecP1,RecS2,RecRst1,SoldepCS);
2110 }
2111 else{
0797d9d3 2112#ifdef OCCT_DEBUG
81bba717 2113 ChFi3d_InitChron(ch1); // init perf for PerformSurf
7fd59977 2114#endif
2115 PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,HC1,HSref1,HCref1,decroch1,
2116 HS2,It2,Or2,MaxStep,locfleche,tolesp,First,Last,
2117 Inside,Inside,forward,RecP1,RecS2,RecRst1,SoldepCS);
0797d9d3 2118#ifdef OCCT_DEBUG
81bba717 2119 ChFi3d_ResultChron(ch1,t_performsurf);//result perf for PerformSurf
7fd59977 2120#endif
2121 }
2122 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2123 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2124 decroch2 = 0;
2125 }
2126 else if (obstacleon2){
2127 TopAbs_Orientation Or1 = HS1->ChangeSurface().Face().Orientation();
2128 TopAbs_Orientation Or2 = HSref2->ChangeSurface().Face().Orientation();
2129 Standard_Integer Choix = ChFi3d::NextSide(Or1,Or2,
2130 Stripe->OrientationOnFace1(),
2131 Stripe->OrientationOnFace2(),
2132 Stripe->Choix());
2133 SoldepCS(3) = w2; SoldepCS(1) = pp1.X(); SoldepCS(2) = pp1.Y();
2134 if(Simul){
2135 SimulSurf(SD,HGuide,Spine,Choix,HS1,It1,Or1,
2136 HS2,It2,HC2,HSref2,HCref2,decroch2,locfleche,tolesp,
2137 First,Last,Inside,Inside,forward,RecP2,RecS1,RecRst2,SoldepCS);
2138 }
2139 else{
0797d9d3 2140#ifdef OCCT_DEBUG
81bba717 2141 ChFi3d_InitChron(ch1); // init perf for PerformSurf
7fd59977 2142#endif
2143 PerformSurf(SeqSD,HGuide,Spine,Choix,HS1,It1,Or1,
2144 HS2,It2,HC2,HSref2,HCref2,decroch2,MaxStep,locfleche,tolesp,
2145 First,Last,Inside,Inside,forward,RecP2,RecS1,RecRst2,SoldepCS);
0797d9d3 2146#ifdef OCCT_DEBUG
81bba717 2147 ChFi3d_ResultChron(ch1,t_performsurf); //result perf for PerformSurf
7fd59977 2148#endif
2149 }
2150 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2151 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2152 decroch1 = 0;
2153 }
2154 else{
2155 CallPerformSurf(Stripe, Simul, SeqSD, SD,
2156 HGuide,Spine,
2157 HS1, HS3, pp1, pp3, It1,
2158 HS2, HS4, pp2, pp4, It2,
2159 MaxStep,locfleche,tolesp,
2160 First,Last,Inside,Inside,forward,
2161 RecS1,RecS2,Soldep,intf,intl,
2162 HS1, HS2);
2163 decroch1 = decroch2 = 0;
2164 }
2165
81bba717 2166 if(!done) { // Case of fail
7fd59977 2167 if ((!Ok1 && !obstacleon1) || (!Ok2 && !obstacleon2)) {
81bba717 2168 //Fail in a part of extension is not serious
2169 //Here one stops.
7fd59977 2170 done = Standard_True;
2171 Inside = Standard_False;
2172 if (forward) intl = 1;
2173 else intf = 1;
2174 }
81bba717 2175 else { // Otherwise invalidation of the stripe.
7fd59977 2176 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
81bba717 2177 Standard_Failure::Raise("CallPerformSurf : Path failed!");
7fd59977 2178 }
2179 }
2180
2181 else {
2182 refbis = ref;
2183 if(forward) {
2184 for (ii=1; ii<=SeqSD.Length(); ii++) {
2185 SD = SeqSD(ii);
2186 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2187 if(obstacleon1) SD->SetIndexOfC1(DStr.AddShape(HC1->ChangeCurve2d().Edge()));
2188 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2189 if(obstacleon2) SD->SetIndexOfC2(DStr.AddShape(HC2->ChangeCurve2d().Edge()));
2190 InsertAfter (Stripe, refbis, SD);
2191 refbis = SD;
2192 }
2193 }
2194 else {
2195 for (ii=SeqSD.Length(); ii>=1; ii--) {
2196 SD = SeqSD(ii);
2197 SD->ChangeIndexOfS1(DStr.AddShape(HS1->ChangeSurface().Face()));
2198 if(obstacleon1) SD->SetIndexOfC1(DStr.AddShape(HC1->ChangeCurve2d().Edge()));
2199 SD->ChangeIndexOfS2(DStr.AddShape(HS2->ChangeSurface().Face()));
2200 if(obstacleon2) SD->SetIndexOfC2(DStr.AddShape(HC2->ChangeCurve2d().Edge()));
2201 InsertBefore(Stripe,refbis,SD);
2202 refbis = SD;
2203 }
2204 }
2205
2206 if (!Ok1 && !obstacleon1)
81bba717 2207 // clean infos on the plane of extension.
7fd59977 2208 ChFi3d_Purge (Stripe,SD,ref->Vertex(!forward,1),!forward,1,intf,intl);
2209
2210 if (!Ok2 && !obstacleon2)
81bba717 2211 // clean infos on the plane of extension.
7fd59977 2212 ChFi3d_Purge (Stripe,SD,ref->Vertex(!forward,2),!forward,2,intf,intl);
2213
81bba717 2214 // The end. The reference is changed.
7fd59977 2215 ref = refbis;
2216 }
2217
81bba717 2218 if(Inside){// There are starting solutions for the next.
7fd59977 2219 Inside = Standard_False;
2220 Firstsov = First;
2221 if(Guide.IsPeriodic()) {
2222 complete = Standard_False;
2223 wf = Guide.FirstParameter();
2224 wl = Guide.LastParameter();
2225 }
2226 }
2227 if(forward){
2228 fini = ((wl - Last) <= 10.*tolesp ||
81bba717 2229 (intl && !(obstacleon1 || obstacleon2))); //General case
7fd59977 2230
2231 if (!fini && Guide.IsPeriodic() &&
2232 ((wl - Last)< Guide.Period()*1.e-3)) {
81bba717 2233 // It is tested if reframing of extremes is done at the same edge
2234 // Loop Condition
7fd59977 2235 Handle(ChFiDS_SurfData) thefirst, thelast;
2236 thefirst = Stripe->SetOfSurfData()->Sequence().First();
2237 thelast = Stripe->SetOfSurfData()->Sequence().Last();
2238
2239 if (thefirst->VertexFirstOnS1().IsOnArc() &&
2240 thelast->VertexLastOnS1().IsOnArc())
2241 fini = thefirst->VertexFirstOnS1().Arc().IsSame
2242 (thelast->VertexLastOnS1().Arc());
2243 if (!fini &&
2244 thefirst->VertexFirstOnS2().IsOnArc() &&
2245 thelast->VertexLastOnS2().IsOnArc())
2246 fini = thefirst->VertexFirstOnS2().Arc().IsSame
2247 (thelast->VertexLastOnS2().Arc());
2248
2249 if (fini)
81bba717 2250 return; //It is ended!
7fd59977 2251 }
2252
2253 if(fini && complete) {
81bba717 2254 // restart in the opposite direction.
7fd59977 2255 ref = Stripe->SetOfSurfData()->Sequence().First();
2256 forward = Standard_False;
2257 fini = Standard_False;
2258 First = Firstsov;
2259 }
2260 else {
2261 First = Last;
2262 Last = wl;
2263 }
2264 }
2265 if(!forward){
2266 fini = ((First - wf) <= 10.*tolesp ||
2267 (intf && !(obstacleon1 || obstacleon2)));
2268 complete = Standard_False;
2269 Last = wf;
2270 }
2271 }
81bba717 2272 // The initial state is restored
7fd59977 2273 if(!Guide.IsPeriodic()){
2274 Guide.FirstParameter(wfsav);
2275 Guide.LastParameter (wlsav);
2276 }
2277
2278}
2279
2280//=======================================================================
2281//function : PerformSetOfKPart
2282//purpose :
2283//=======================================================================
2284
2285void ChFi3d_Builder::PerformSetOfKPart(Handle(ChFiDS_Stripe)& Stripe,
2286 const Standard_Boolean Simul)
2287{
2288 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
2289 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
2290 Handle(BRepAdaptor_HSurface) HS1,HS2;
2291 TopAbs_Orientation Or1,Or2,RefOr1,RefOr2;
96a95605 2292 Standard_Integer RefChoix;
7fd59977 2293
81bba717 2294 // initialization of the stripe.
7fd59977 2295 Stripe->Reset();
2296 Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData();
2297 HData = new ChFiDS_HData();
2298 ChFiDS_SequenceOfSurfData& SeqSurf = HData->ChangeSequence();
2299
2300 StripeOrientations(Spine,RefOr1,RefOr2,RefChoix);
2301 Stripe->OrientationOnFace1(RefOr1);
2302 Stripe->OrientationOnFace2(RefOr2);
2303 Stripe->Choix(RefChoix);
2304
2305 Handle(BRepTopAdaptor_TopolTool) It1 = new BRepTopAdaptor_TopolTool();
2306 Handle(BRepTopAdaptor_TopolTool) It2 = new BRepTopAdaptor_TopolTool();
2307
2308 Standard_Real WFirst,WLast = 0.;
2309 gp_Vec TFirst,TLast,TEndPeriodic;
2310 gp_Pnt PFirst,PLast,PEndPeriodic;
2311 Standard_Boolean intf = 0, intl = 0;
2312
2313 Handle(ChFiDS_HElSpine) CurrentHE = new ChFiDS_HElSpine();
2314 Spine->D1(Spine->FirstParameter(),PFirst,TFirst);
2315 CurrentHE->ChangeCurve().FirstParameter(Spine->FirstParameter());
2316 CurrentHE->ChangeCurve().SetFirstPointAndTgt(PFirst,TFirst);
2317
2318 Standard_Boolean YaKPart = Standard_False;
2319 Standard_Integer iedgelastkpart = 0;
2320
2321 Standard_Real WStartPeriodic = 0.;
2322 Standard_Real WEndPeriodic = Spine->LastParameter(Spine->NbEdges());
2323 Spine->D1(WEndPeriodic,PEndPeriodic,TEndPeriodic);
2324
81bba717 2325 // Construction of particular cases.
7fd59977 2326
2327 for (Standard_Integer iedge = 1; iedge <= Spine->NbEdges(); iedge++){
2328
2329 ConexFaces(Spine,iedge,RefChoix,HS1,HS2);
2330
2331 if (ChFi3d_KParticular(Spine,iedge,HS1->ChangeSurface(),HS2->ChangeSurface())) {
2332 intf = ((iedge == 1) && !Spine->IsPeriodic());
2333 intl = ((iedge == Spine->NbEdges()) && !Spine->IsPeriodic());
2334 Or1 = HS1->ChangeSurface().Face().Orientation();
2335 Or2 = HS2->ChangeSurface().Face().Orientation();
96a95605 2336 ChFi3d::NextSide(Or1,Or2,RefOr1,RefOr2,RefChoix);
7fd59977 2337 It1->Initialize(HS1);
2338 It2->Initialize(HS2);
2339
2340 Handle(ChFiDS_SurfData) SD = new ChFiDS_SurfData();
2341 ChFiDS_SequenceOfSurfData LSD;
2342
2343 if(!ChFiKPart_ComputeData::Compute(DStr,SD,HS1,HS2,Or1,Or2,Spine,iedge)){
0797d9d3 2344#ifdef OCCT_DEBUG
81bba717 2345 cout<<"failed calculation KPart"<<endl;
7fd59977 2346#endif
2347 }
2348 else if(!SplitKPart(SD,LSD,Spine,iedge,HS1,It1,HS2,It2,intf,intl)){
0797d9d3 2349#ifdef OCCT_DEBUG
81bba717 2350 cout<<"failed calculation KPart"<<endl;
7fd59977 2351#endif
2352 LSD.Clear();
2353 }
2354 else iedgelastkpart = iedge;
81bba717 2355 if(Spine->IsPeriodic()){//debug provisory for SD that arrive in desorder.
7fd59977 2356 Standard_Integer nbsd = LSD.Length();
2357 Standard_Real period = Spine->Period();
2358 Standard_Real wfp = WStartPeriodic, wlp = WEndPeriodic;
2359// modified by NIZHNY-EAP Thu Nov 25 12:57:53 1999 ___BEGIN___
2360 if(!YaKPart && nbsd>0){
2361// if(!YaKPart){
2362// modified by NIZHNY-EAP Thu Nov 25 12:57:57 1999 ___END___
2363 Handle(ChFiDS_SurfData) firstSD = LSD.ChangeValue(1);
2364 Standard_Real wwf = firstSD->FirstSpineParam();
2365 Standard_Real wwl = firstSD->LastSpineParam();
2366 wwf = ChFi3d_InPeriod(wwf,wfp,wlp,tolesp);
2367 wwl = ChFi3d_InPeriod(wwl,wfp,wlp,tolesp);
2368 if (wwl <= wwf + tolesp) wwl += period;
2369 wfp = wwf;
2370 wlp = wfp + period;
2371 }
2372 for(Standard_Integer j = 1; j < nbsd; j++){
2373 Handle(ChFiDS_SurfData) jSD = LSD.Value(j);
2374 for(Standard_Integer k = j+1; k <= nbsd; k++){
2375 Handle(ChFiDS_SurfData) kSD = LSD.Value(k);
2376 Standard_Real jwf = jSD->FirstSpineParam();
2377 jwf = ChFi3d_InPeriod(jwf,wfp,wlp,tolesp);
2378 Standard_Real kwf = kSD->FirstSpineParam();
2379 kwf = ChFi3d_InPeriod(kwf,wfp,wlp,tolesp);
2380 if(kwf < jwf){
2381 LSD.SetValue(j,kSD);
2382 LSD.SetValue(k,jSD);
2383 }
2384 }
2385 }
2386 }
2387 TColStd_ListOfInteger li;
2388 for(Standard_Integer j = 1; j <= LSD.Length(); j++){
2389 Handle(ChFiDS_SurfData)& curSD = LSD.ChangeValue(j);
2390 if(Simul) SimulKPart(curSD);
2391 SeqSurf.Append(curSD);
2392 if(!Simul) li.Append(curSD->Surf());
2393 WFirst = LSD.Value(j)->FirstSpineParam();
2394 WLast = LSD.Value(j)->LastSpineParam();
2395 if(Spine->IsPeriodic()){
2396 WFirst = ChFi3d_InPeriod(WFirst,WStartPeriodic,WEndPeriodic,tolesp);
2397 WLast = ChFi3d_InPeriod(WLast ,WStartPeriodic,WEndPeriodic,tolesp);
2398 if (WLast <= WFirst + tolesp) WLast+= Spine->Period();
2399 }
2400 TgtKP(LSD.Value(j),Spine,iedge,1,PFirst,TFirst);
2401 TgtKP(LSD.Value(j),Spine,iedge,0,PLast,TLast);
2402
81bba717 2403 // Determine the sections to approximate
7fd59977 2404 if(!YaKPart){
2405 if(Spine->IsPeriodic()){
2406 WStartPeriodic = WFirst;
2407 WEndPeriodic = WStartPeriodic + Spine->Period();
2408 WLast = ElCLib::InPeriod(WLast,WStartPeriodic,WEndPeriodic);
2409 if (WLast <= WFirst + tolesp) WLast+= Spine->Period();
2410 PEndPeriodic = PFirst;
2411 TEndPeriodic = TFirst;
2412 Spine->SetFirstParameter(WStartPeriodic);
2413 Spine->SetLastParameter(WEndPeriodic);
2414 }
2415 else if(!intf || (iedge > 1)){
81bba717 2416 // start section -> first KPart
2417 // update of extension.
7fd59977 2418 Spine->SetFirstTgt(Min(0.,WFirst));
2419 CurrentHE->ChangeCurve().LastParameter (WFirst);
2420 CurrentHE->ChangeCurve().SetLastPointAndTgt(PFirst,TFirst);
2421 Spine->AppendElSpine(CurrentHE);
2422 CurrentHE->ChangeCurve().ChangeNext() = LSD.Value(j);
2423 CurrentHE = new ChFiDS_HElSpine();
2424 }
2425 CurrentHE->ChangeCurve().FirstParameter(WLast);
2426 CurrentHE->ChangeCurve().SetFirstPointAndTgt(PLast,TLast);
2427 CurrentHE->ChangeCurve().ChangePrevious() = LSD.Value(j);
2428 YaKPart = Standard_True;
2429 }
2430 else {
2431 if (WFirst - CurrentHE->FirstParameter() > tolesp) {
81bba717 2432 // section between two KPart
7fd59977 2433 CurrentHE->ChangeCurve().LastParameter(WFirst);
2434 CurrentHE->ChangeCurve().SetLastPointAndTgt(PFirst,TFirst);
2435 Spine->AppendElSpine(CurrentHE);
2436 CurrentHE->ChangeCurve().ChangeNext() = LSD.Value(j);
2437 CurrentHE = new ChFiDS_HElSpine();
2438 }
2439 CurrentHE->ChangeCurve().FirstParameter(WLast);
2440 CurrentHE->ChangeCurve().SetFirstPointAndTgt(PLast,TLast);
2441 CurrentHE->ChangeCurve().ChangePrevious() = LSD.Value(j);
2442 }
2443 }
2444 if(!li.IsEmpty()) myEVIMap.Bind(Spine->Edges(iedge),li);
2445 }
2446 }
2447
2448 if (!intl || (iedgelastkpart < Spine->NbEdges())) {
81bba717 2449 // section last KPart(or start of the spine) -> End of the spine.
2450 // update of the extension.
7fd59977 2451
2452 if(Spine->IsPeriodic()){
2453 if(WEndPeriodic - WLast > tolesp){
2454 CurrentHE->ChangeCurve().LastParameter(WEndPeriodic);
2455 CurrentHE->ChangeCurve().SetLastPointAndTgt(PEndPeriodic,TEndPeriodic);
2456 if(!YaKPart) CurrentHE->ChangeCurve().SetPeriodic(Standard_True);
2457 Spine->AppendElSpine(CurrentHE);
2458 }
2459 }
2460 else{
2461 Spine->D1(Spine->LastParameter(),PLast,TLast);
2462 Spine->SetLastTgt(Max(Spine->LastParameter(Spine->NbEdges()),
2463 WLast));
2464 if (Spine->LastParameter() - WLast > tolesp) {
2465 CurrentHE->ChangeCurve().LastParameter(Spine->LastParameter());
2466 CurrentHE->ChangeCurve().SetLastPointAndTgt(PLast,TLast);
2467 Spine->AppendElSpine(CurrentHE);
2468 }
2469 }
2470 }
2471
2472 ChFiDS_ListOfHElSpine& ll = Spine->ChangeElSpines();
2473 ChFiDS_ListIteratorOfListOfHElSpine ILES(ll);
2474 for ( ; ILES.More(); ILES.Next()) {
0797d9d3 2475#ifdef OCCT_DEBUG
7fd59977 2476 if(ChFi3d_GettraceCHRON()) elspine.Start();
2477#endif
2478 ChFi3d_PerformElSpine(ILES.Value(),Spine,myConti,tolesp);
0797d9d3 2479#ifdef OCCT_DEBUG
7fd59977 2480 if(ChFi3d_GettraceCHRON()) { elspine.Stop(); }
2481#endif
2482 }
2483 Spine->SplitDone(Standard_True);
2484}
2485
2486static Standard_Real ChFi3d_BoxDiag(const Bnd_Box& box)
2487{
2488 Standard_Real a,b,c,d,e,f;
2489 box.Get(a,b,c,d,e,f);
2490 d-=a; e-=b; f-=c;
2491 d*=d; e*=e; f*=f;
2492 Standard_Real diag = sqrt(d + e + f);
2493 return diag;
2494}
2495
2496//=======================================================================
2497//function : PerformSetOfKGen
2498//purpose :
2499//=======================================================================
2500
2501void ChFi3d_Builder::PerformSetOfKGen(Handle(ChFiDS_Stripe)& Stripe,
2502 const Standard_Boolean Simul)
2503{
2504 Handle(BRepTopAdaptor_TopolTool) It1 = new BRepTopAdaptor_TopolTool();
2505 Handle(BRepTopAdaptor_TopolTool) It2 = new BRepTopAdaptor_TopolTool();
2506 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
2507 ChFiDS_ListOfHElSpine& ll = Spine->ChangeElSpines();
2508 ChFiDS_ListIteratorOfListOfHElSpine ILES(ll);
2509 for ( ; ILES.More(); ILES.Next()) {
0797d9d3 2510#ifdef OCCT_DEBUG
7fd59977 2511 if(ChFi3d_GettraceCHRON()) { chemine.Start(); }
2512#endif
2513 PerformSetOfSurfOnElSpine(ILES.Value(),Stripe,It1,It2,Simul);
0797d9d3 2514#ifdef OCCT_DEBUG
7fd59977 2515 if(ChFi3d_GettraceCHRON()) chemine.Stop();
2516#endif
2517 }
2518 if(!Simul){
2519 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
2520 Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData();
2521 ChFiDS_SequenceOfSurfData& SeqSurf = HData->ChangeSequence();
2522 Standard_Integer len = SeqSurf.Length();
2523 Standard_Integer last = len, i;
2524 Standard_Boolean periodic = Spine->IsPeriodic();
2525 if(periodic) last++;
81bba717 2526 // It is attempted to reprocess the squares that bore.
7fd59977 2527 for(i = 1; i <= len; i++){
2528 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2529 Standard_Boolean tw1 = cursd->TwistOnS1();
2530 Standard_Boolean tw2 = cursd->TwistOnS2();
2531 Handle(ChFiDS_SurfData) prevsd, nextsd;
2532 Standard_Integer iprev = i-1;
2533 if(iprev == 0) {
2534 if(periodic) iprev = len;
2535 }
2536 Standard_Integer inext = i + 1;
2537 if(inext > len) {
2538 if(periodic) inext = 1;
2539 else inext = 0;
2540 }
2541
81bba717 2542 // For the moment only the surfaces where the twist is
2543 // detected at the path are corrected, it is necessary to control
2544 // more subtly the ugly traces (size, curvature, inflexion... )
7fd59977 2545 if(!tw1 && !tw2) continue;
2546
81bba717 2547 // It is decided (fairly at random) if the extended surface is ready for the filling.
7fd59977 2548 ChFiDS_FaceInterference& intf1 = cursd->ChangeInterferenceOnS1();
2549 ChFiDS_FaceInterference& intf2 = cursd->ChangeInterferenceOnS2();
2550 Standard_Integer cursurf1 = cursd->IndexOfS1();
2551 Standard_Integer cursurf2 = cursd->IndexOfS2();
2552 ChFiDS_CommonPoint& cpd1 = cursd->ChangeVertexFirstOnS1();
2553 ChFiDS_CommonPoint& cpd2 = cursd->ChangeVertexFirstOnS2();
2554 ChFiDS_CommonPoint& cpf1 = cursd->ChangeVertexLastOnS1();
2555 ChFiDS_CommonPoint& cpf2 = cursd->ChangeVertexLastOnS2();
2556 const gp_Pnt& pd1 = cpd1.Point();
2557 const gp_Pnt& pd2 = cpd2.Point();
2558 const gp_Pnt& pf1 = cpf1.Point();
2559 const gp_Pnt& pf2 = cpf2.Point();
2560 Standard_Real ddeb = pd1.Distance(pd2);
2561 Standard_Real dfin = pf1.Distance(pf2);
2562 Standard_Real don1 = pd1.Distance(pf1);
2563 Standard_Real don2 = pd2.Distance(pf2);
2564 Standard_Boolean possibleon1 = (don1 < 2*(ddeb + dfin));
2565 Standard_Boolean possibleon2 = (don2 < 2*(ddeb + dfin));
2566 if((tw1 && !possibleon1) || (tw2 && !possibleon2)) {
2567 Spine->SetErrorStatus(ChFiDS_TwistedSurface);
81bba717 2568 Standard_Failure::Raise("adjustment by reprocessing the non-written points");
7fd59977 2569 }
2570
81bba717 2571 // It is checked if there are presentable neighbors
7fd59977 2572 Standard_Boolean yaprevon1 = 0, yaprevon2 = 0;
2573 Standard_Boolean samesurfon1 = 0, samesurfon2 = 0;
2574 if(iprev){
2575 prevsd = SeqSurf.ChangeValue(iprev);
2576 yaprevon1 = !prevsd->TwistOnS1();
2577 samesurfon1 = (prevsd->IndexOfS1() == cursurf1);
2578 yaprevon2 = !prevsd->TwistOnS2();
2579 samesurfon2 = (prevsd->IndexOfS2() == cursurf2);
2580 }
2581 Standard_Boolean yanexton1 = 0, yanexton2 = 0;
2582 if(inext){
2583 nextsd = SeqSurf.ChangeValue(inext);
2584 yanexton1 = !nextsd->TwistOnS1();
2585 if(samesurfon1) samesurfon1 = (nextsd->IndexOfS1() == cursurf1);
2586 yanexton2 = !nextsd->TwistOnS2();
2587 if(samesurfon2) samesurfon2 = (nextsd->IndexOfS2() == cursurf2);
2588 }
81bba717 2589 // A contour of filling is constructed
7fd59977 2590 Handle(Geom2d_Curve) PC1 = intf1.PCurveOnFace();
2591 Handle(Geom2d_Curve) PC2 = intf2.PCurveOnFace();
2592 Handle(BRepAdaptor_HSurface) S1 = new BRepAdaptor_HSurface();
2593 TopoDS_Face F1 = TopoDS::Face(DStr.Shape(cursurf1));
2594 S1->ChangeSurface().Initialize(F1);
2595 Handle(BRepAdaptor_HSurface) S2 = new BRepAdaptor_HSurface();
2596 TopoDS_Face F2 = TopoDS::Face(DStr.Shape(cursurf2));
2597 S2->ChangeSurface().Initialize(F2);
2598 Handle(GeomFill_Boundary) Bdeb,Bfin,Bon1,Bon2;
2599 Standard_Boolean pointuon1 = 0, pointuon2 = 0;
2600 if(tw1){
2601 if(!yaprevon1 || !yanexton1){
2602 Spine->SetErrorStatus(ChFiDS_TwistedSurface);
2603 Standard_Failure::Raise
81bba717 2604 ("adjustment by reprocessing the non-written points: no neighbor");
7fd59977 2605 }
2606 ChFiDS_FaceInterference& previntf1 = prevsd->ChangeInterferenceOnS1();
2607 ChFiDS_FaceInterference& nextintf1 = nextsd->ChangeInterferenceOnS1();
2608 Standard_Real prevpar1 = previntf1.LastParameter();
2609 Standard_Real nextpar1 = nextintf1.FirstParameter();
2610 if(samesurfon1){
81bba717 2611 // It is checked if it is possible to intersect traces of neighbors
2612 // to create a sharp end.
7fd59977 2613 Handle(Geom2d_Curve) pcprev1 = previntf1.PCurveOnFace();
2614 Handle(Geom2d_Curve) pcnext1 = nextintf1.PCurveOnFace();
2615 Standard_Real nprevpar1,nnextpar1;
2616 gp_Pnt2d p2d;
2617// Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 Begin
2618// if(ChFi3d_IntTraces(prevsd,prevpar1,nprevpar1,1,1,
2619// nextsd,nextpar1,nnextpar1,1,-1,p2d)){
2620 if(ChFi3d_IntTraces(prevsd,prevpar1,nprevpar1,1,1,
2621 nextsd,nextpar1,nnextpar1,1,-1,p2d,
2622 Standard_False, Standard_True)){
2623// Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 End
2624 previntf1.SetLastParameter(nprevpar1);
2625 nextintf1.SetFirstParameter(nnextpar1);
2626 pointuon1 = 1;
2627 PC1.Nullify();
2628 }
2629 else{
2630 gp_Pnt2d pdeb1,pfin1;
2631 gp_Vec2d vdeb1,vfin1;
2632 pcprev1->D1(prevpar1,pdeb1,vdeb1);
2633 pcnext1->D1(nextpar1,pfin1,vfin1);
2634 Bon1 = ChFi3d_mkbound(S1,PC1,-1,pdeb1,vdeb1,1,
2635 pfin1,vfin1,tolesp,2.e-4);
2636 }
2637 }
2638 else{
81bba717 2639 //here the base is on 3D tangents of neighbors.
7fd59977 2640 const Handle(Geom_Curve)& c3dprev1 =
2641 DStr.Curve(previntf1.LineIndex()).Curve();
2642 const Handle(Geom_Curve)& c3dnext1 =
2643 DStr.Curve(nextintf1.LineIndex()).Curve();
2644 gp_Pnt Pdeb1, Pfin1;
2645 gp_Vec Vdeb1, Vfin1;
2646 c3dprev1->D1(prevpar1,Pdeb1,Vdeb1);
2647 c3dnext1->D1(nextpar1,Pfin1,Vfin1);
2648 gp_Pnt2d pdeb1,pfin1;
2649 Standard_Real pardeb1 = intf1.FirstParameter();
2650 Standard_Real parfin1 = intf1.LastParameter();
2651 pdeb1 = PC1->Value(pardeb1);
2652 pfin1 = PC1->Value(parfin1);
2653 Bon1 = ChFi3d_mkbound(S1,PC1,-1,pdeb1,Vdeb1,1,
2654 pfin1,Vfin1,tolesp,2.e-4);
2655 }
2656 }
2657 else{
2658 Bon1 = ChFi3d_mkbound(S1,PC1,tolesp,2.e-4);
2659 }
2660 if(tw2){
2661 if(!yaprevon2 || !yanexton2){
2662 Standard_Failure::Raise
81bba717 2663 ("adjustment by reprocessing the non-written points: no neighbor");
7fd59977 2664 }
2665 ChFiDS_FaceInterference& previntf2 = prevsd->ChangeInterferenceOnS2();
2666 ChFiDS_FaceInterference& nextintf2 = nextsd->ChangeInterferenceOnS2();
2667 Standard_Real prevpar2 = previntf2.LastParameter();
2668 Standard_Real nextpar2 = nextintf2.FirstParameter();
2669 if(samesurfon2){
81bba717 2670 // It is checked if it is possible to intersect traces of neighbors
2671 // to create a sharp end.
7fd59977 2672 Handle(Geom2d_Curve) pcprev2 = previntf2.PCurveOnFace();
2673 Handle(Geom2d_Curve) pcnext2 = nextintf2.PCurveOnFace();
2674 Standard_Real nprevpar2,nnextpar2;
2675 gp_Pnt2d p2d;
2676// Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 Begin
2677// if(ChFi3d_IntTraces(prevsd,prevpar2,nprevpar2,2,1,
2678// nextsd,nextpar2,nnextpar2,2,-1,p2d)){
2679 if(ChFi3d_IntTraces(prevsd,prevpar2,nprevpar2,2,1,
2680 nextsd,nextpar2,nnextpar2,2,-1,p2d,
2681 Standard_False, Standard_True)){
2682// Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 End
2683 previntf2.SetLastParameter(nprevpar2);
2684 nextintf2.SetFirstParameter(nnextpar2);
2685 pointuon2 = 1;
2686 PC2.Nullify();
2687 }
2688 else{
2689 gp_Pnt2d pdeb2,pfin2;
2690 gp_Vec2d vdeb2,vfin2;
2691 pcprev2->D1(prevpar2,pdeb2,vdeb2);
2692 pcnext2->D1(nextpar2,pfin2,vfin2);
2693 Bon2 = ChFi3d_mkbound(S2,PC2,-1,pdeb2,vdeb2,1,
2694 pfin2,vfin2,tolesp,2.e-4);
2695 }
2696 }
2697 else{
81bba717 2698 //here the base is on 3D tangents of neighbors.
7fd59977 2699 const Handle(Geom_Curve)& c3dprev2 =
2700 DStr.Curve(previntf2.LineIndex()).Curve();
2701 const Handle(Geom_Curve)& c3dnext2 =
2702 DStr.Curve(nextintf2.LineIndex()).Curve();
2703 gp_Pnt Pdeb2, Pfin2;
2704 gp_Vec Vdeb2, Vfin2;
2705 c3dprev2->D1(prevpar2,Pdeb2,Vdeb2);
2706 c3dnext2->D1(nextpar2,Pfin2,Vfin2);
2707 gp_Pnt2d pdeb2,pfin2;
2708 Standard_Real pardeb2 = intf2.FirstParameter();
2709 Standard_Real parfin2 = intf2.LastParameter();
2710 pdeb2 = PC2->Value(pardeb2);
2711 pfin2 = PC2->Value(parfin2);
2712 Bon2 = ChFi3d_mkbound(S2,PC2,-1,pdeb2,Vdeb2,1,
2713 pfin2,Vfin2,tolesp,2.e-4);
2714 }
2715 }
2716 else{
2717 Bon2 = ChFi3d_mkbound(S2,PC2,tolesp,2.e-4);
2718 }
81bba717 2719 // The parameters of neighbor traces are updated, so
2720 // straight lines uv are pulled.
7fd59977 2721 const Handle(Geom_Surface)&
2722 sprev = DStr.Surface(prevsd->Surf()).Surface();
2723 const Handle(Geom_Surface)&
2724 snext = DStr.Surface(nextsd->Surf()).Surface();
2725 ChFiDS_FaceInterference& previntf1 = prevsd->ChangeInterferenceOnS1();
2726 ChFiDS_FaceInterference& nextintf1 = nextsd->ChangeInterferenceOnS1();
2727 ChFiDS_FaceInterference& previntf2 = prevsd->ChangeInterferenceOnS2();
2728 ChFiDS_FaceInterference& nextintf2 = nextsd->ChangeInterferenceOnS2();
2729 Handle(Geom2d_Curve) pcsprev1 = previntf1.PCurveOnSurf();
2730 Handle(Geom2d_Curve) pcsnext1 = nextintf1.PCurveOnSurf();
2731 Standard_Real prevpar1 = previntf1.LastParameter();
2732 Standard_Real nextpar1 = nextintf1.FirstParameter();
2733 Handle(Geom2d_Curve) pcsprev2 = previntf2.PCurveOnSurf();
2734 Handle(Geom2d_Curve) pcsnext2 = nextintf2.PCurveOnSurf();
2735 Standard_Real prevpar2 = previntf2.LastParameter();
2736 Standard_Real nextpar2 = nextintf2.FirstParameter();
2737 gp_Pnt2d pdebs1 = pcsprev1->Value(prevpar1);
2738 gp_Pnt2d pdebs2 = pcsprev2->Value(prevpar2);
2739 gp_Pnt2d pfins1 = pcsnext1->Value(nextpar1);
2740 gp_Pnt2d pfins2 = pcsnext2->Value(nextpar2);
2741 Bdeb = ChFi3d_mkbound(sprev,pdebs1,pdebs2,tolesp,2.e-4);
2742 Bfin = ChFi3d_mkbound(snext,pfins1,pfins2,tolesp,2.e-4);
2743
2744 GeomFill_ConstrainedFilling fil(11,20);
2745 if(pointuon1) fil.Init(Bon2,Bfin,Bdeb,1);
2746 else if(pointuon2) fil.Init(Bon1,Bfin,Bdeb,1);
2747 else fil.Init(Bon1,Bfin,Bon2,Bdeb,1);
2748
2749 ChFi3d_ReparamPcurv(0.,1.,PC1);
2750 ChFi3d_ReparamPcurv(0.,1.,PC2);
2751 Handle(Geom_Surface) newsurf = fil.Surface();
0797d9d3 2752#ifdef OCCT_DEBUG
7fd59977 2753#ifdef DRAW
81bba717 2754 //POP for NT
7fd59977 2755 char* pops = "newsurf";
2756 DrawTrSurf::Set(pops,newsurf);
2757#endif
2758#endif
2759 if(pointuon1) {
81bba717 2760 newsurf->VReverse(); // we return to direction 1 from 2;
7fd59977 2761 done = CompleteData(cursd,newsurf,S1,PC1,S2,PC2,
2762 F2.Orientation(),0,0,0,0,0);
2763 cursd->ChangeIndexOfS1(0);
2764 }
2765 else{
2766 done = CompleteData(cursd,newsurf,S1,PC1,S2,PC2,
2767 F1.Orientation(),1,0,0,0,0);
2768 if(pointuon2) cursd->ChangeIndexOfS2(0);
2769 }
2770 if(tw1){
2771 prevsd->ChangeVertexLastOnS1().SetPoint(cpd1.Point());
2772 nextsd->ChangeVertexFirstOnS1().SetPoint(cpf1.Point());
2773 }
2774 if(tw2){
2775 prevsd->ChangeVertexLastOnS2().SetPoint(cpd2.Point());
2776 nextsd->ChangeVertexFirstOnS2().SetPoint(cpf2.Point());
2777 }
2778 }
81bba717 2779 // The tolerance of points is updated.
7fd59977 2780 for(i = 1; i < last; i++){
2781 Standard_Integer j = i%len + 1;
2782 Standard_Integer curs1, curs2;
2783 Standard_Integer nexts1, nexts2;
2784 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2785 Handle(ChFiDS_SurfData)& nextsd = SeqSurf.ChangeValue(j);
2786 ChFiDS_CommonPoint& curp1 = cursd->ChangeVertexLastOnS1();
2787 ChFiDS_CommonPoint& nextp1 = nextsd->ChangeVertexFirstOnS1();
2788 if (cursd->IsOnCurve1()) curs1 = cursd->IndexOfC1();
2789 else curs1 = cursd->IndexOfS1();
2790 if (cursd->IsOnCurve2()) curs2 = cursd->IndexOfC2();
2791 else curs2 = cursd->IndexOfS2();
2792 Standard_Real tol1 = Max(curp1.Tolerance(),nextp1.Tolerance());
2793 ChFiDS_CommonPoint& curp2 = cursd->ChangeVertexLastOnS2();
2794 ChFiDS_CommonPoint& nextp2 = nextsd->ChangeVertexFirstOnS2();
2795 Standard_Real tol2 = Max(curp2.Tolerance(),nextp2.Tolerance());
2796 if (nextsd->IsOnCurve1()) nexts1 = nextsd->IndexOfC1();
2797 else nexts1 = nextsd->IndexOfS1();
2798 if (nextsd->IsOnCurve2()) nexts2 = nextsd->IndexOfC2();
2799 else nexts2 = nextsd->IndexOfS2();
2800
2801 if(!curp1.IsOnArc() && nextp1.IsOnArc()){
2802 curp1 = nextp1;
2803 if ( (curs1 == nexts1) && !nextsd->IsOnCurve1())
81bba717 2804 // Case when it is not possible to pass along the border without leaving
7fd59977 2805 ChangeTransition(nextp1, curp1, nexts1, myDS);
2806 }
2807 else if(curp1.IsOnArc() && !nextp1.IsOnArc()) {
2808 nextp1 = curp1;
2809 if ( (curs1 == nexts1) && !cursd->IsOnCurve1())
2810 ChangeTransition(curp1, nextp1, curs1, myDS);
2811 }
2812
2813 if(!curp2.IsOnArc() && nextp2.IsOnArc()) {
2814 curp2 = nextp2;
2815 if ( (curs2 == nexts2) && !nextsd->IsOnCurve2())
2816 ChangeTransition(nextp2, curp2, curs2, myDS);
2817 }
2818 else if(curp2.IsOnArc() && !nextp2.IsOnArc()){
2819 nextp2 = curp2;
2820 if ( (curs2 == nexts2) && !cursd->IsOnCurve2())
2821 ChangeTransition(curp2, nextp2, curs2, myDS);
2822 }
2823
2824 curp1.SetTolerance(tol1); nextp1.SetTolerance(tol1);
2825 curp2.SetTolerance(tol2); nextp2.SetTolerance(tol2);
2826
2827 Bnd_Box b1,b2;
2828 if(curp1.IsOnArc()){
2829 ChFi3d_EnlargeBox(curp1.Arc(),myEFMap(curp1.Arc()),curp1.ParameterOnArc(),b1);
2830 }
2831 if(curp2.IsOnArc()){
2832 ChFi3d_EnlargeBox(curp2.Arc(),myEFMap(curp2.Arc()),curp2.ParameterOnArc(),b2);
2833 }
2834 Handle(ChFiDS_Stripe) bidst;
2835 ChFi3d_EnlargeBox(DStr,bidst,cursd,b1,b2,0);
2836 ChFi3d_EnlargeBox(DStr,bidst,nextsd,b1,b2,1);
2837 tol1 = ChFi3d_BoxDiag(b1);
2838 tol2 = ChFi3d_BoxDiag(b2);
2839 curp1.SetTolerance(tol1); nextp1.SetTolerance(tol1);
2840 curp2.SetTolerance(tol2); nextp2.SetTolerance(tol2);
2841 }
81bba717 2842 // The connections edge/new faces are updated.
7fd59977 2843 for (ILES.Initialize(ll) ; ILES.More(); ILES.Next()) {
2844 const Handle(ChFiDS_HElSpine)& curhels = ILES.Value();
2845 const ChFiDS_ElSpine& curels = curhels->ChangeCurve();
2846 Standard_Real WF = curels.FirstParameter();
2847 Standard_Real WL = curels.LastParameter();
2848 Standard_Integer IF,IL;
2849 Standard_Real nwf = WF, nwl = WL;
2850 Standard_Real period = 0.;
2851 Standard_Integer nbed = Spine->NbEdges();
2852 if(periodic){
2853 period = Spine->Period();
2854 nwf = ElCLib::InPeriod(WF,-tolesp,period-tolesp);
2855 IF = Spine->Index(nwf,1);
2856 nwl = ElCLib::InPeriod(WL,tolesp,period+tolesp);
2857 IL = Spine->Index(nwl,0);
2858 if(nwl<nwf+tolesp) IL += nbed;
2859 }
2860 else{
2861 IF = Spine->Index(WF,1);
2862 IL = Spine->Index(WL,0);
2863 }
2864 if(IF == IL) {
81bba717 2865 //fast processing
7fd59977 2866 Standard_Integer IFloc = IF;
2867 if(periodic) IFloc = (IF - 1)%nbed + 1;
2868 const TopoDS_Edge& Ej = Spine->Edges(IFloc);
2869 for(i = 1; i <= len; i++){
2870 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2871 Standard_Real fp = cursd->FirstSpineParam();
2872 Standard_Real lp = cursd->LastSpineParam();
2873 if(lp < WF+tolesp || fp > WL-tolesp) continue;
2874 if(!myEVIMap.IsBound(Ej)) {
2875 TColStd_ListOfInteger li;
2876 myEVIMap.Bind(Ej,li);
2877 }
2878 myEVIMap.ChangeFind(Ej).Append(cursd->Surf());
2879 }
2880 }
2881 else if(IF < IL){
2882 TColStd_Array1OfReal wv(IF,IL - 1);
0797d9d3 2883#ifdef OCCT_DEBUG
81bba717 2884 cout<<"length of the trajectory : "<<(WL-WF)<<endl;
7fd59977 2885#endif
2886 for(i = IF; i < IL; i++){
2887 Standard_Integer iloc = i;
2888 if(periodic) iloc = (i - 1)%nbed + 1;
2889 Standard_Real wi = Spine->LastParameter(iloc);
2890 if(periodic) wi = ElCLib::InPeriod(wi,WF,WF+period);
2891 gp_Pnt pv = Spine->Value(wi);
0797d9d3 2892#ifdef OCCT_DEBUG
7fd59977 2893 gp_Pnt pelsapp = curels.Value(wi);
2894 Standard_Real distinit = pv.Distance(pelsapp);
2895 cout<<"distance psp/papp : "<<distinit<<endl;
2896#endif
2897 Extrema_LocateExtPC ext(pv,curels,wi,1.e-8);
2898 wv(i) = wi;
2899 if(ext.IsDone()){
2900 wv(i) = ext.Point().Parameter();
2901 }
2902 else {
0797d9d3 2903#ifdef OCCT_DEBUG
81bba717 2904 cout<<"fail of projection vertex ElSpine!!!"<<endl;
7fd59977 2905#endif
2906 }
2907 }
2908 for(i = 1; i <= len; i++){
2909 Handle(ChFiDS_SurfData)& cursd = SeqSurf.ChangeValue(i);
2910 Standard_Real fp = cursd->FirstSpineParam();
2911 Standard_Real lp = cursd->LastSpineParam();
2912 Standard_Integer j;
7fd59977 2913 Standard_Integer jf = 0, jl = 0;
7fd59977 2914 if(lp < WF+tolesp || fp > WL-tolesp) continue;
2915 for(j = IF; j < IL; j++){
2916 jf = j;
2917 if(fp < wv(j) - tolesp) break;
2918 }
2919 for(j = IF; j < IL; j++){
2920 jl = j;
2921 if(lp < wv(j) + tolesp) break;
2922 }
2923 for(j = jf; j <= jl; j++){
2924 Standard_Integer jloc = j;
2925 if(periodic) jloc = (j - 1)%nbed + 1;
2926 const TopoDS_Edge& Ej = Spine->Edges(jloc);
2927 if(!myEVIMap.IsBound(Ej)) {
2928 TColStd_ListOfInteger li;
2929 myEVIMap.Bind(Ej,li);
2930 }
2931 myEVIMap.ChangeFind(Ej).Append(cursd->Surf());
2932 }
2933 }
2934 }
2935 }
2936 }
2937}
2938
2939//=======================================================================
2940//function : PerformSetOfSurf
2941//purpose :
2942//=======================================================================
2943
2944void ChFi3d_Builder::PerformSetOfSurf(Handle(ChFiDS_Stripe)& Stripe,
2945 const Standard_Boolean Simul)
2946{
2947 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
2948
0797d9d3 2949#ifdef OCCT_DEBUG
7fd59977 2950 OSD_Chronometer ch;
81bba717 2951 ChFi3d_InitChron(ch);// init perf for PerformSetOfKPart
7fd59977 2952#endif
2953
2954 const Handle(ChFiDS_Spine)& sp = Stripe->Spine();
2955 Standard_Integer SI = ChFi3d_SolidIndex(sp,DStr,myESoMap,myEShMap);
2956 Stripe->SetSolidIndex(SI);
2957 if(!sp->SplitDone()) PerformSetOfKPart(Stripe,Simul);
2958
0797d9d3 2959#ifdef OCCT_DEBUG
7fd59977 2960 ChFi3d_ResultChron(ch ,t_perfsetofkpart); // result perf PerformSetOfKPart(
81bba717 2961 ChFi3d_InitChron(ch); // init perf for PerformSetOfKGen
7fd59977 2962#endif
2963
2964 PerformSetOfKGen(Stripe,Simul);
2965
0797d9d3 2966#ifdef OCCT_DEBUG
7fd59977 2967 ChFi3d_ResultChron(ch, t_perfsetofkgen);//result perf PerformSetOfKGen
81bba717 2968 ChFi3d_InitChron(ch); // init perf for ChFi3d_MakeExtremities
7fd59977 2969#endif
2970
2971 if(!Simul) ChFi3d_MakeExtremities(Stripe,DStr,myEFMap,tolesp,tol2d);
2972
0797d9d3 2973#ifdef OCCT_DEBUG
7fd59977 2974 ChFi3d_ResultChron(ch, t_makextremities); // result perf t_makextremities
2975#endif
2976}