0024023: Revamp the OCCT Handle -- ambiguity
[occt.git] / src / ChFi3d / ChFi3d_Builder_C1.cxx
CommitLineData
b311480e 1// Created on: 1994-03-09
2// Created by: Isabelle GRIGNON
3// Copyright (c) 1994-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// Modified by skv - Mon Jun 7 18:38:57 2004 OCC5898
18// Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222
19
20#include <ChFi3d_Builder.jxx>
21#include <ChFi3d.hxx>
22#include <ChFi3d_Builder_0.hxx>
23
24#include <Precision.hxx>
25
26#include <Standard_Failure.hxx>
27#include <Standard_NotImplemented.hxx>
28#include <StdFail_NotDone.hxx>
29
30
31#include <gp_Pnt.hxx>
32#include <gp_Dir.hxx>
33#include <gp_Vec.hxx>
34#include <gp_Ax3.hxx>
35#include <gp_Pnt2d.hxx>
36#include <gp_Vec2d.hxx>
37#include <gp_Dir2d.hxx>
38#include <gp_Elips.hxx>
39#include <gp_Circ.hxx>
40
41#include <ElCLib.hxx>
42#include <ElSLib.hxx>
43
44#include <Geom_Line.hxx>
45#include <Geom_Circle.hxx>
46#include <Geom_Ellipse.hxx>
47#include <Geom_RectangularTrimmedSurface.hxx>
48#include <Geom_Curve.hxx>
49#include <Geom2d_Line.hxx>
50#include <Geom2d_Curve.hxx>
51#include <Geom_BSplineCurve.hxx>
52#include <Geom_BSplineSurface.hxx>
53#include <Geom_BezierSurface.hxx>
54#include <Geom2d_BSplineCurve.hxx>
55#include <Geom2dAdaptor_HCurve.hxx>
56#include <Geom2d_TrimmedCurve.hxx>
57#include <Geom2dInt_GInter.hxx>
58#include <Geom_TrimmedCurve.hxx>
59#include <GeomAPI_ExtremaCurveCurve.hxx>
60#include <GeomAbs_Shape.hxx>
61#include <GeomAdaptor_HCurve.hxx>
62#include <GeomAdaptor_Surface.hxx>
63#include <GeomAdaptor_HSurface.hxx>
64#include <Geom_BoundedCurve.hxx>
65#include <GeomLib.hxx>
66#include <GeomInt_IntSS.hxx>
67#include <GeomProjLib.hxx>
68
69#include <Adaptor3d_HCurveOnSurface.hxx>
70#include <Adaptor3d_CurveOnSurface.hxx>
71#include <BRepAdaptor_HSurface.hxx>
72#include <BRepAdaptor_Curve.hxx>
73#include <BRepAdaptor_Curve2d.hxx>
74#include <BRepAdaptor_HCurve2d.hxx>
75#include <BRepAdaptor_HCurve.hxx>
76#include <BRepAdaptor_Surface.hxx>
77#include <BRepLib_MakeEdge.hxx>
78#include <BRepAlgo_NormalProjection.hxx>
79#include <BRepExtrema_ExtCC.hxx>
80#include <BRep_Tool.hxx>
81#include <BRepTools.hxx>
82#include <BRep_Builder.hxx>
83#include <IntCurveSurface_HInter.hxx>
84#include <IntCurveSurface_IntersectionPoint.hxx>
85#include <IntRes2d_IntersectionPoint.hxx>
86#include <IntRes2d_Transition.hxx>
87#include <Extrema_LocateExtCC.hxx>
88#include <Extrema_POnCurv.hxx>
89#include <Extrema_ExtPC2d.hxx>
90#include <Extrema_ExtPC.hxx>
91#include <Extrema_ExtPS.hxx>
92#include <Extrema_ExtCC.hxx>
93
94#include <TopoDS.hxx>
95#include <TopoDS_Shape.hxx>
96#include <TopoDS_Face.hxx>
97#include <TopoDS_Edge.hxx>
98#include <TopoDS_Vertex.hxx>
99
100#include <TopAbs.hxx>
101#include <TopAbs_ShapeEnum.hxx>
102#include <TopAbs_Orientation.hxx>
103#include <TopExp.hxx>
104#include <TopExp_Explorer.hxx>
105#include <TopLoc_Location.hxx>
106#include <TopTools_ListIteratorOfListOfShape.hxx>
107
108#include <TopOpeBRepDS_Point.hxx>
109#include <TopOpeBRepDS_Curve.hxx>
110#include <TopOpeBRepDS_Surface.hxx>
111#include <TopOpeBRepDS_SurfaceCurveInterference.hxx>
112#include <TopOpeBRepDS_CurvePointInterference.hxx>
113#include <TopOpeBRepDS_DataStructure.hxx>
114#include <TopOpeBRepDS_ListOfInterference.hxx>
115#include <TopOpeBRepDS_ListIteratorOfListOfInterference.hxx>
116#include <TopOpeBRepDS_SolidSurfaceInterference.hxx>
117#include <TopOpeBRepDS_Kind.hxx>
118#include <TopOpeBRepDS_Transition.hxx>
119#include <TopTools_Array1OfShape.hxx>
120#include <ChFiDS_HData.hxx>
121#include <ChFiDS_SurfData.hxx>
122#include <ChFiDS_CommonPoint.hxx>
123#include <ChFiDS_FaceInterference.hxx>
124#include <ChFiDS_SequenceOfSurfData.hxx>
125#include <ChFiDS_Stripe.hxx>
126#include <ChFiDS_ListIteratorOfListOfStripe.hxx>
127#include <ChFiDS_Map.hxx>
128#include <TColgp_Array1OfPnt.hxx>
129#include <TColgp_Array1OfPnt2d.hxx>
130#include <TColStd_Array1OfReal.hxx>
131#include <TColStd_Array1OfInteger.hxx>
132
0797d9d3 133#ifdef OCCT_DEBUG
7fd59977 134# ifdef DRAW
135#include <OSD_Chronometer.hxx>
136#include <DrawTrSurf.hxx>
137# endif //DRAW
138// Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 Begin
139// The method
140// ChFi3d_Builder::PerformMoreSurfdata(const Standard_Integer Index)
141// is totally rewroted.
142// Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 End
143
144extern Standard_Real t_same,t_inter,t_sameinter;
145extern void ChFi3d_InitChron(OSD_Chronometer& ch);
146extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
147#endif
148#include <Geom2dAPI_ProjectPointOnCurve.hxx>
149#include <math_FunctionSample.hxx>
150#include <Geom2dAdaptor_Curve.hxx>
151#include <IntRes2d_IntersectionSegment.hxx>
ec357c5c 152#include <Geom_BezierCurve.hxx>
7fd59977 153// Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 Begin
154Standard_Boolean isTangentFaces(const TopoDS_Edge &theEdge,
155 const TopoDS_Face &theFace1,
156 const TopoDS_Face &theFace2);
157// Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 End
158
159static Standard_Real recadre(const Standard_Real p,
160 const Standard_Real ref,
161 const Standard_Boolean isfirst,
162 const Standard_Real first,
163 const Standard_Real last)
164{
165 Standard_Real pp = p;
166 if (isfirst) pp -= (last - first);
167 else pp += (last - first);
168 if (Abs(pp - ref) < Abs(p - ref)) return pp;
169 return p;
170}
171
172//=======================================================================
173//function : Update
81bba717 174//purpose : Calculate the intersection of the face at the end of
175// the tangency line to update CommonPoint and its
176// parameter in FaceInterference.
7fd59977 177//=======================================================================
178
179static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& fb,
180 Handle(Adaptor2d_HCurve2d)& pcfb,
181 Handle(Adaptor3d_HSurface)& surf,
182 ChFiDS_FaceInterference& fi,
183 ChFiDS_CommonPoint& cp,
184 gp_Pnt2d& p2dbout,
185 const Standard_Boolean isfirst,
186 Standard_Real& pared,
187 Standard_Real& wop,
188 const Standard_Real tol)
189{
190 Adaptor3d_CurveOnSurface c1(pcfb,fb);
191 Handle(Geom2d_Curve) pc = fi.PCurveOnSurf();
192 Handle(Geom2dAdaptor_HCurve) hpc = new Geom2dAdaptor_HCurve(pc);
193 Adaptor3d_CurveOnSurface c2(hpc,surf);
194 Extrema_LocateExtCC ext(c1,c2,pared,wop);
195 if (ext.IsDone()) {
196 Standard_Real dist2 = ext.SquareDistance();
197 if (dist2 < tol * tol) {
198 Extrema_POnCurv ponc1,ponc2;
199 ext.Point(ponc1,ponc2);
200 Standard_Real parfb = ponc1.Parameter();
201 p2dbout = pcfb->Value(parfb);
202 pared = ponc1.Parameter();
203 wop = ponc2.Parameter();
204 fi.SetParameter(wop,isfirst);
205 cp.Reset();
206 cp.SetPoint(ponc1.Value());
207 return Standard_True;
208 }
209 }
210 return Standard_False;
211}
212
213//=======================================================================
214//function : Update
215//purpose : Intersect surface <fb> and 3d curve <ct>
216// Update <isfirst> parameter of FaceInterference <fi> and point of
217// CommonPoint <cp>. Return new intersection parameters in <wop>
218// and <p2dbout>
219//=======================================================================
220
221static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& fb,
222 Handle(Adaptor3d_HCurve)& ct,
223 ChFiDS_FaceInterference& fi,
224 ChFiDS_CommonPoint& cp,
225 gp_Pnt2d& p2dbout,
226 const Standard_Boolean isfirst,
227 Standard_Real& wop)
228{
229 IntCurveSurface_HInter Intersection;
81bba717 230 //check if in KPart the limits of the tangency line
231 //are already in place at this stage.
232 //Modif lvt : the periodic cases are reframed, espercially if nothing was found.
7fd59977 233 Standard_Real w,uf = ct->FirstParameter(),ul = ct->LastParameter();
7a06c690 234
7fd59977 235 Standard_Real wbis = 0.;
7a06c690 236
7fd59977 237 Standard_Boolean isperiodic = ct->IsPeriodic(),recadrebis = Standard_False;
238 Intersection.Perform(ct,fb);
239 if (Intersection.IsDone()) {
240 Standard_Integer nbp = Intersection.NbPoints(),i,isol = 0,isolbis = 0;
241 Standard_Real dist = Precision::Infinite();
242 Standard_Real distbis = Precision::Infinite();
243 for (i = 1; i <= nbp; i++) {
244 w = Intersection.Point(i).W();
245 if (isperiodic) w = recadre(w,wop,isfirst,uf,ul);
246 if (uf <= w && ul >= w && Abs(w-wop) < dist) {
247 isol = i;
248 dist = Abs(w-wop);
249 }
250 }
251 if (isperiodic) {
252 for (i = 1; i <= nbp; i++) {
253 w = Intersection.Point(i).W();
254 if (uf <= w && ul >= w && Abs(w-wop) < distbis && (Abs(w-ul)<=0.01 || Abs(w-uf)<=0.01)) {
255 isolbis = i;
256 wbis = recadre(w,wop,isfirst,uf,ul);
257 distbis = Abs(wbis-wop);
258 recadrebis = Standard_True;
259 }
260 }
261 }
262 if (isol == 0 && isolbis == 0) {
263 return Standard_False;
264 }
265 if (!recadrebis) {
266 IntCurveSurface_IntersectionPoint pint = Intersection.Point(isol);
267 p2dbout.SetCoord(pint.U(),pint.V());
268 w = pint.W();
269 if (isperiodic) w = ElCLib::InPeriod(w,uf,ul);
270 }
271 else {
272 if (dist>distbis) {
273 IntCurveSurface_IntersectionPoint pint = Intersection.Point(isolbis);
274 p2dbout.SetCoord(pint.U(),pint.V());
275 w = wbis;
276 }
277 else {
278 IntCurveSurface_IntersectionPoint pint = Intersection.Point(isol);
279 p2dbout.SetCoord(pint.U(),pint.V());
280 w = pint.W();
281 w = ElCLib::InPeriod(w,uf,ul);
282 }
283 }
284 fi.SetParameter(w,isfirst);
285 cp.Reset();
286 cp.SetPoint(ct->Value(w));
287 wop = w;
288 return Standard_True;
289 }
290 return Standard_False;
291}
292
293//=======================================================================
294//function : IntersUpdateOnSame
295//purpose : Intersect curve <c3dFI> of ChFi-<Fop> interference with extended
296// surface <HBs> of <Fprol> . Return intersection parameters in
297// <FprolUV>, <c3dU> and updating <FIop> and <CPop>
298// <HGs> is a surface of ChFi
299// <Fop> is a face having 2 edges at corner with OnSame state
300// <Fprol> is a face non-adjacent to spine edge
301// <Vtx> is a corner vertex
302//=======================================================================
303
304static Standard_Boolean IntersUpdateOnSame(Handle(GeomAdaptor_HSurface)& HGs,
305 Handle(BRepAdaptor_HSurface)& HBs,
306 const Handle(Geom_Curve)& c3dFI,
307 const TopoDS_Face& Fop,
308 const TopoDS_Face& Fprol,
309 const TopoDS_Edge& Eprol,
310 const TopoDS_Vertex& Vtx,
311 const Standard_Boolean isFirst,
312 const Standard_Real Tol,
313 ChFiDS_FaceInterference& FIop,
314 ChFiDS_CommonPoint& CPop,
315 gp_Pnt2d& FprolUV,
316 Standard_Real& c3dU)
317{
81bba717 318 // add more or less restrictive criterions to
319 // decide if the intersection is done with the face at
320 // extended end or if the end is sharp.
7fd59977 321 Standard_Real uf = FIop.FirstParameter();
322 Standard_Real ul = FIop.LastParameter();
323 Handle(GeomAdaptor_HCurve) Hc3df;
324 if (c3dFI->IsPeriodic()) Hc3df = new GeomAdaptor_HCurve(c3dFI);
325 else Hc3df = new GeomAdaptor_HCurve(c3dFI,uf,ul);
326
327 if ( Update(HBs,Hc3df,FIop,CPop,FprolUV,isFirst,c3dU) )
328 return Standard_True;
329
330 if (!isTangentFaces(Eprol,Fprol,Fop))
331 return Standard_False;
332
333 Handle(Geom2d_Curve) gpcprol = BRep_Tool::CurveOnSurface(Eprol,Fprol,uf,ul);
334 Handle(Geom2dAdaptor_HCurve) pcprol = new Geom2dAdaptor_HCurve(gpcprol);
335 Standard_Real partemp = BRep_Tool::Parameter(Vtx,Eprol);
336
337 return
338 Update(HBs,pcprol,HGs,FIop,CPop,FprolUV,isFirst,partemp,c3dU,Tol);
339}
340
341//=======================================================================
342//function : Update
81bba717 343//purpose : Calculate the extrema curveonsurf/curveonsurf to prefer
344// the values concerning the trace on surf and the pcurve on the
345// face at end.
7fd59977 346//=======================================================================
347
348static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& face,
349 Handle(Adaptor2d_HCurve2d)& edonface,
350 Handle(Adaptor3d_HSurface)& surf,
351 ChFiDS_FaceInterference& fi,
352 ChFiDS_CommonPoint& cp,
353 const Standard_Boolean isfirst)
354{
355 if (!cp.IsOnArc()) return 0;
356 Adaptor3d_CurveOnSurface c1(edonface,face);
357 Standard_Real pared = cp.ParameterOnArc();
358 Standard_Real parltg = fi.Parameter(isfirst);
359 Handle(Geom2d_Curve) pc = fi.PCurveOnSurf();
360 Standard_Real f = fi.FirstParameter();
361 Standard_Real l = fi.LastParameter();
362 Standard_Real delta = 0.1 * ( l - f );
363 f = Max(f-delta,pc->FirstParameter());
364 l = Min(l+delta,pc->LastParameter());
365 Handle(Geom2dAdaptor_HCurve) hpc = new Geom2dAdaptor_HCurve(pc,f,l);
366 Adaptor3d_CurveOnSurface c2(hpc,surf);
367
368 Extrema_LocateExtCC ext(c1,c2,pared,parltg);
369 if (ext.IsDone()) {
370 Extrema_POnCurv ponc1,ponc2;
371 ext.Point(ponc1,ponc2);
372 pared = ponc1.Parameter();
373 parltg = ponc2.Parameter();
374 if ((parltg > f) && (parltg < l)) {
6504f8cd 375 ////modified by jgv, 10.05.2012 for the bug 23139, 25657////
84e5bff3 376 Handle(Geom2d_Curve) PConF = fi.PCurveOnFace();
377 if (!PConF.IsNull())
378 {
379 Handle(Geom2d_TrimmedCurve) aTrCurve = Handle(Geom2d_TrimmedCurve)::DownCast(PConF);
380 if (!aTrCurve.IsNull())
381 PConF = aTrCurve->BasisCurve();
6504f8cd 382 if (!PConF->IsPeriodic())
84e5bff3 383 {
6504f8cd 384 if (isfirst)
385 {
386 Standard_Real fpar = PConF->FirstParameter();
387 if (parltg < fpar)
388 parltg = fpar;
389 }
390 else
391 {
392 Standard_Real lpar = PConF->LastParameter();
393 if (parltg > lpar)
394 parltg = lpar;
395 }
84e5bff3 396 }
397 }
398 /////////////////////////////////////////////////////
7fd59977 399 fi.SetParameter(parltg,isfirst);
400 cp.SetArc(cp.Tolerance(),cp.Arc(),pared,cp.TransitionOnArc());
401 return Standard_True;
402 }
403 }
404 return Standard_False;
405}
406
407//=======================================================================
408//function : ChFi3d_ExtendSurface
409//purpose :
410//=======================================================================
411
412static void ChFi3d_ExtendSurface (Handle(Geom_Surface) & S ,
413 Standard_Integer & prol )
414{
415 if (prol) return;
416 Handle(Geom_BSplineSurface) S1;
417 Handle(Geom_BezierSurface) S2;
418 Standard_Real length,umin,umax,vmin,vmax;
419 gp_Pnt P1,P2;
420 S->Bounds(umin,umax,vmin,vmax);
421 S->D0(umin,vmin,P1);
422 S->D0(umax,vmax,P2);
423 length=P1.Distance(P2);
424 prol=0;
425 S1=Handle(Geom_BSplineSurface)::DownCast(S);
426 S2=Handle(Geom_BezierSurface)::DownCast(S);
427 if (!S1.IsNull()) {
428 GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,
429 Standard_True);
430 GeomLib::ExtendSurfByLength(S1,length,1,Standard_True,
431 Standard_True);
432 GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,
433 Standard_False);
434 GeomLib::ExtendSurfByLength(S1,length,1,Standard_True,
435 Standard_False);
436 S=S1;
437 prol=1;
438 }
439 if (!S2.IsNull()) {
440 GeomLib::ExtendSurfByLength(S2,length,1,Standard_False,
441 Standard_True);
442 GeomLib::ExtendSurfByLength(S2,length,1,Standard_True,
443 Standard_True);
444 GeomLib::ExtendSurfByLength(S2,length,1,Standard_False,
445 Standard_False);
446 GeomLib::ExtendSurfByLength(S2,length,1,Standard_True,
447 Standard_False);
448 S=S2;
449 prol=2;
450
451 }
452}
453
454//=======================================================================
455//function : ComputeCurve2d
81bba717 456//purpose : calculate the 2d of the curve Ct on face Face
7fd59977 457//=======================================================================
458
459static void ComputeCurve2d (Handle(Geom_Curve )& Ct,
460 TopoDS_Face & Face,
461 Handle(Geom2d_Curve) & C2d)
462{
463 TopoDS_Edge E1;
464 TopTools_IndexedMapOfShape MapE1;
465 BRepLib_MakeEdge Bedge (Ct);
466 TopoDS_Edge edg =Bedge. Edge();
467 BRepAlgo_NormalProjection OrtProj;
468 OrtProj.Init(Face);
469 OrtProj.Add(edg);
470 OrtProj.SetParams(1.e-6, 1.e-6, GeomAbs_C1, 14, 16);
471 OrtProj.SetLimit(Standard_False);
472 OrtProj.Compute3d(Standard_False);
473 OrtProj.Build();
474 Standard_Real up1,up2;
475 if ( OrtProj.IsDone()) {
476 TopExp::MapShapes(OrtProj.Projection() ,TopAbs_EDGE, MapE1);
477 if (MapE1.Extent()!=0) {
478 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE1(1));
479 E1=TopoDS::Edge(aLocalShape );
480// E1=TopoDS::Edge( TopoDS_Shape (MapE1(1)));
481 C2d=BRep_Tool::CurveOnSurface(E1,Face,up1,up2);
482 }
483 }
484}
485
486//=======================================================================
487//function : ChFi3d_Recale
488//purpose :
489//=======================================================================
490
491static void ChFi3d_Recale(BRepAdaptor_Surface& Bs,
492 gp_Pnt2d& p1,
493 gp_Pnt2d& p2,
494 const Standard_Boolean refon1)
495{
496 Handle(Geom_Surface) surf = Bs.ChangeSurface().Surface();
497 Handle(Geom_RectangularTrimmedSurface)
498 ts = Handle(Geom_RectangularTrimmedSurface)::DownCast(surf);
499 if (!ts.IsNull()) surf = ts->BasisSurface();
500 if (surf->IsUPeriodic()) {
501 Standard_Real u1 = p1.X(), u2 = p2.X();
502 Standard_Real uper = surf->UPeriod();
503 if (fabs(u2-u1) > 0.5*uper) {
504 if (u2<u1 && refon1) u2 += uper;
505 else if (u2<u1 && !refon1) u1 -= uper;
506 else if (u1<u2 && refon1) u2 -= uper;
507 else if (u1<u2 && !refon1) u1 += uper;
508 }
509 p1.SetX(u1); p2.SetX(u2);
510 }
511 if (surf->IsVPeriodic()) {
512 Standard_Real v1 = p1.Y(), v2 = p2.Y();
513 Standard_Real vper = surf->VPeriod();
514 if (fabs(v2-v1) > 0.5*vper) {
515 if (v2<v1 && refon1) v2 += vper;
516 else if (v2<v1 && !refon1) v1 -= vper;
517 else if (v1<v2 && refon1) v2 -= vper;
518 else if (v1<v2 && !refon1) v1 += vper;
519 }
520 p1.SetY(v1); p2.SetY(v2);
521 }
522}
523
524//=======================================================================
525//function : ChFi3d_SelectStripe
526//purpose : find stripe with ChFiDS_OnSame state if <thePrepareOnSame> is True
527//=======================================================================
528
529Standard_Boolean ChFi3d_SelectStripe(ChFiDS_ListIteratorOfListOfStripe & It,
530 const TopoDS_Vertex& Vtx,
531 const Standard_Boolean thePrepareOnSame)
532{
533 if (!thePrepareOnSame) return Standard_True;
534
535 for (; It.More(); It.Next()) {
536 Standard_Integer sens = 0;
537 Handle(ChFiDS_Stripe) stripe = It.Value();
538 ChFi3d_IndexOfSurfData(Vtx, stripe, sens);
539 ChFiDS_State stat;
540 if ( sens == 1 )
541 stat = stripe->Spine()->FirstStatus();
542 else
543 stat = stripe->Spine()->LastStatus();
544 if ( stat == ChFiDS_OnSame ) return Standard_True;
545 }
546
547 return Standard_False;
548}
549//=======================================================================
550//function : PerformOneCorner
81bba717 551//purpose : Calculate a corner with three edges and a fillet.
552// 3 separate case: (22/07/94 only 1st is implemented)
7fd59977 553//
81bba717 554// - same concavity on three edges, intersection with the
555// face at end,
556// - concavity of 2 outgoing edges is opposite to the one of the fillet,
557// if the face at end is ready for that, the same in case 1 on extended face,
558// otherwise a small cap is done with GeomFill,
559// - only one outgoing edge has concavity opposed to the edge of the
560// fillet and the third edge, the top of the corner is reread
561// in the empty of the fillet and closed, either by extending the face
562// at end if it is plane and orthogonal to the
563// guiding edge, or by a cap of type GeomFill.
7fd59977 564//
565// <thePrepareOnSame> means that only needed thing is redefinition
566// of intersection pameter of OnSame-Stripe with <Arcprol>
567// (eap, Arp 9 2002, occ266)
568//=======================================================================
569
570void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index,
571 const Standard_Boolean thePrepareOnSame)
572{
573 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
574
0797d9d3 575#ifdef OCCT_DEBUG
81bba717 576 OSD_Chronometer ch;// init perf for PerformSetOfKPart
7fd59977 577#endif
81bba717 578 // the top,
7fd59977 579 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
81bba717 580 // The fillet is returned,
7fd59977 581 ChFiDS_ListIteratorOfListOfStripe StrIt;
582 StrIt.Initialize(myVDataMap(Index));
583 if ( ! ChFi3d_SelectStripe (StrIt, Vtx, thePrepareOnSame)) return;
584 Handle(ChFiDS_Stripe) stripe = StrIt.Value();
585 const Handle(ChFiDS_Spine) spine = stripe->Spine();
586 ChFiDS_SequenceOfSurfData& SeqFil =
587 stripe->ChangeSetOfSurfData()->ChangeSequence();
81bba717 588 // SurfData and its CommonPoints,
7fd59977 589 Standard_Integer sens = 0;
590
81bba717 591 // Choose proper SurfData
7fd59977 592 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
593 Standard_Boolean isfirst = (sens == 1);
594 if (isfirst) {
595 for (; num<SeqFil.Length() && (
596 (SeqFil.Value(num)->IndexOfS1()==0) ||
597 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
81bba717 598 SeqFil.Remove(num); // The surplus is removed
7fd59977 599 }
600 }
601 else {
602 for (; num>1 && (
603 (SeqFil.Value(num)->IndexOfS1()==0) ||
604 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
81bba717 605 SeqFil.Remove(num);// The surplus is removed
7fd59977 606 num--;
607 }
608 }
609
610 Handle(ChFiDS_SurfData)& Fd = SeqFil.ChangeValue(num);
611 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
612 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
81bba717 613 //To evaluate the new points.
7fd59977 614 Bnd_Box box1,box2;
615
81bba717 616 // The cases of cap and intersection are processed separately.
7fd59977 617 // ----------------------------------------------------------
618 ChFiDS_State stat;
619 if (isfirst) stat = spine->FirstStatus();
620 else stat = spine->LastStatus();
621 Standard_Boolean onsame = (stat == ChFiDS_OnSame);
622 TopoDS_Face Fv,Fad,Fop;
623 TopoDS_Edge Arcpiv,Arcprol,Arcspine;
624 if (isfirst) Arcspine = spine->Edges(1);
625 else Arcspine = spine->Edges(spine->NbEdges());
7fd59977 626 TopAbs_Orientation OArcprolv = TopAbs_FORWARD, OArcprolop = TopAbs_FORWARD;
7fd59977 627 Standard_Integer ICurve;
628 Handle(BRepAdaptor_HSurface) HBs = new BRepAdaptor_HSurface();
629 Handle(BRepAdaptor_HSurface) HBad = new BRepAdaptor_HSurface();
630 Handle(BRepAdaptor_HSurface) HBop = new BRepAdaptor_HSurface();
631 BRepAdaptor_Surface& Bs = HBs->ChangeSurface();
632 BRepAdaptor_Surface& Bad = HBad->ChangeSurface();
633 BRepAdaptor_Surface& Bop = HBop->ChangeSurface();
634 Handle(Geom_Curve) Cc;
635 Handle(Geom2d_Curve) Pc,Ps;
636 Standard_Real Ubid,Vbid;//,mu,Mu,mv,Mv;
7fd59977 637 Standard_Real Udeb = 0.,Ufin = 0.;
7fd59977 638// gp_Pnt2d UVf1,UVl1,UVf2,UVl2;
639// Standard_Real Du,Dv,Step;
640 Standard_Boolean inters = Standard_True;
641 Standard_Integer IFadArc = 1, IFopArc = 2;
642 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
643 TopExp_Explorer ex;
644
0797d9d3 645#ifdef OCCT_DEBUG
7fd59977 646 ChFi3d_InitChron(ch); // init perf condition if (onsame)
647#endif
648
649 if (onsame) {
650 if (!CV1.IsOnArc() && !CV2.IsOnArc())
651 Standard_Failure::Raise("Corner OnSame : no point on arc");
652 else if (CV1.IsOnArc() && CV2.IsOnArc()) {
81bba717 653 Standard_Boolean sur1 = 0, sur2 = 0;
7fd59977 654 for(ex.Init(CV1.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()) {
655 if (Vtx.IsSame(ex.Current())) {
656 sur1 = 1;
657 break;
658 }
659 }
660 for(ex.Init(CV2.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()) {
661 if (Vtx.IsSame(ex.Current())) {
662 sur2 = 1;
663 break;
664 }
665 }
666 if (sur1 && sur2) {
667 TopoDS_Edge E[3];
668 E[0] = CV1.Arc(); E[1] = CV2.Arc(); E[2] = Arcspine;
669 if (ChFi3d_EdgeState(E,myEFMap) != ChFiDS_OnDiff) IFadArc = 2;
670 }
671 else if (sur2) IFadArc = 2;
672 }
673 else if (CV2.IsOnArc()) IFadArc = 2;
674 IFopArc = 3-IFadArc;
675
676 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
677 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
678 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
679 TopTools_ListIteratorOfListOfShape It;
81bba717 680 // The face at end is returned without check of its unicity.
7fd59977 681 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
682 if (!Fad.IsSame(It.Value())) {
683 Fv = TopoDS::Face(It.Value());
684 break;
685 }
686 }
687
81bba717 688 // Does the face at bout contain the Vertex ?
7fd59977 689 Standard_Boolean isinface = Standard_False;
690 for (ex.Init(Fv,TopAbs_VERTEX); ex.More(); ex.Next()) {
691 if (ex.Current().IsSame(Vtx)) {
692 isinface = Standard_True;
693 break;
694 }
695 }
696 if (!isinface && Fd->Vertex(isfirst,3-IFadArc).IsOnArc()) {
697 IFadArc = 3-IFadArc;
698 IFopArc = 3-IFopArc;
699 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
700 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
701 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
702 //TopTools_ListIteratorOfListOfShape It;
81bba717 703 // The face at end is returned without check of its unicity.
7fd59977 704 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
705 if (!Fad.IsSame(It.Value())) {
706 Fv = TopoDS::Face(It.Value());
707 break;
708 }
709 }
710 }
711
712 if (Fv.IsNull()) StdFail_NotDone::Raise
81bba717 713 ("OneCorner : face at end not found");
7fd59977 714
715 Fv.Orientation(TopAbs_FORWARD);
716 Fad.Orientation(TopAbs_FORWARD);
717 Fop.Orientation(TopAbs_FORWARD);
718
81bba717 719 // The edge that will be extended is returned.
7fd59977 720 for(It.Initialize(myVEMap(Vtx));It.More() && Arcprol.IsNull();It.Next()) {
721 if (!Arcpiv.IsSame(It.Value())) {
722 for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()) {
723 if (It.Value().IsSame(ex.Current())) {
724 Arcprol = TopoDS::Edge(It.Value());
725 OArcprolv = ex.Current().Orientation();
726 break;
727 }
728 }
729 }
730 }
731 if (Arcprol.IsNull()) /*StdFail_NotDone::Raise
732 ("OneCorner : edge a prolonger non trouve");*/
733 {
734 PerformIntersectionAtEnd(Index);
735 return;
736 }
737 for(ex.Init(Fop,TopAbs_EDGE); ex.More(); ex.Next()) {
738 if (Arcprol.IsSame(ex.Current())) {
739 OArcprolop = ex.Current().Orientation();
740 break;
741 }
742 }
743 TopoDS_Face FFv;
744 Standard_Real tol;
745 Standard_Integer prol=0;
746 BRep_Builder BRE;
747 Handle(Geom_Surface ) Sface;
748 Sface=BRep_Tool::Surface(Fv);
749 ChFi3d_ExtendSurface(Sface,prol);
750 tol=BRep_Tool::Tolerance(Fv);
751 BRE.MakeFace(FFv,Sface,tol);
752 if (prol) {
753 Bs.Initialize(FFv,Standard_False);
754 DStr.SetNewSurface(Fv,Sface);
755 }
756 else Bs.Initialize(Fv,Standard_False);
757 Bad.Initialize(Fad);
758 Bop.Initialize(Fop);
759 }
81bba717 760 //in case of OnSame it is necessary to modify the CommonPoint
761 //in the empty and its parameter in the FaceInterference.
762 //They are both returned in non const references. Attention the modifications are done behind
7fd59977 763 //de CV1,CV2,Fi1,Fi2.
764 ChFiDS_CommonPoint& CPopArc = Fd->ChangeVertex(isfirst,IFopArc);
765 ChFiDS_FaceInterference& FiopArc = Fd->ChangeInterference(IFopArc);
766 ChFiDS_CommonPoint& CPadArc = Fd->ChangeVertex(isfirst,IFadArc);
767 ChFiDS_FaceInterference& FiadArc = Fd->ChangeInterference(IFadArc);
81bba717 768 //the parameter of the vertex in the air is initialiced with the value of
769 //its opposite (point on arc).
7fd59977 770 Standard_Real wop = Fd->ChangeInterference(IFadArc).Parameter(isfirst);
771 Handle(Geom_Curve) c3df;
772 Handle(GeomAdaptor_HSurface)
773 HGs = new GeomAdaptor_HSurface(DStr.Surface(Fd->Surf()).Surface());
774 gp_Pnt2d p2dbout;
775
776 if (onsame) {
777
778 ChFiDS_CommonPoint saveCPopArc = CPopArc;
779 c3df = DStr.Curve(FiopArc.LineIndex()).Curve();
780
781 inters = IntersUpdateOnSame (HGs,HBs,c3df,Fop,Fv,Arcprol,Vtx,isfirst,10*tolesp, // in
782 FiopArc,CPopArc,p2dbout,wop); // out
783
784 Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
785 pced->ChangeCurve2d().Initialize(CPadArc.Arc(),Fv);
786 // in the case of degenerated Fi, parameter difference can be even negative (eap, occ293)
787 if ((FiadArc.LastParameter() - FiadArc.FirstParameter()) > 10*tolesp)
788 Update(HBs,pced,HGs,FiadArc,CPadArc,isfirst);
789
790 if (thePrepareOnSame) {
791 //saveCPopArc.SetParameter(wop);
792 saveCPopArc.SetPoint(CPopArc.Point());
793 CPopArc = saveCPopArc;
794 return;
795 }
796 }
797 else {
798 inters = FindFace(Vtx,CV1,CV2,Fv,Fop);
799 if (!inters) {
800 PerformIntersectionAtEnd(Index);
801 return;
802 }
803 Bs.Initialize(Fv);
804 Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
805 pced->ChangeCurve2d().Initialize(CV1.Arc(),Fv);
806 Update(HBs,pced,HGs,Fd->ChangeInterferenceOnS1(),CV1,isfirst);
807 pced->ChangeCurve2d().Initialize(CV2.Arc(),Fv);
808 Update(HBs,pced,HGs,Fd->ChangeInterferenceOnS2(),CV2,isfirst);
809 }
810
811
0797d9d3 812#ifdef OCCT_DEBUG
7fd59977 813 ChFi3d_ResultChron(ch,t_same); // result perf condition if (same)
814 ChFi3d_InitChron(ch); // init perf condition if (inters)
815#endif
816
817 TopoDS_Edge edgecouture;
818 Standard_Boolean couture,intcouture=Standard_False;;
1d47d8d0 819 Standard_Real tolreached = tolesp;
7fd59977 820 Standard_Real par1 =0.,par2 =0.;
821 Standard_Integer indpt = 0,Icurv1 = 0,Icurv2 = 0;
7fd59977 822 Handle(Geom_TrimmedCurve) curv1,curv2;
823 Handle(Geom2d_Curve) c2d1,c2d2;
824
825 Standard_Integer Isurf=Fd->Surf();
826
827 if (inters) {
828 HGs = ChFi3d_BoundSurf(DStr,Fd,1,2);
829 const ChFiDS_FaceInterference& Fi1 = Fd->InterferenceOnS1();
830 const ChFiDS_FaceInterference& Fi2 = Fd->InterferenceOnS2();
831 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
832 gp_Pnt2d pfil1,pfac1,pfil2,pfac2;
833 Handle(Geom2d_Curve) Hc1,Hc2;
834 if (onsame && IFopArc == 1) pfac1 = p2dbout;
835 else {
836 Hc1 = BRep_Tool::CurveOnSurface(CV1.Arc(),Fv,Ubid,Ubid);
837 pfac1 = Hc1->Value(CV1.ParameterOnArc());
838 }
839 if (onsame && IFopArc == 2) pfac2 = p2dbout;
840 else {
841 Hc2 = BRep_Tool::CurveOnSurface(CV2.Arc(),Fv,Ubid,Ubid);
842 pfac2 = Hc2->Value(CV2.ParameterOnArc());
843 }
844 if (Fi1.LineIndex() != 0) {
845 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));
846 }
847 else {
848 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
849 }
850 if (Fi2.LineIndex() != 0) {
851 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
852 }
853 else {
854 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
855 }
856 if (onsame) ChFi3d_Recale(Bs,pfac1,pfac2,(IFadArc == 1));
857
858 Pardeb(1)= pfil1.X(); Pardeb(2) = pfil1.Y();
859 Pardeb(3)= pfac1.X(); Pardeb(4) = pfac1.Y();
860 Parfin(1)= pfil2.X(); Parfin(2) = pfil2.Y();
861 Parfin(3)= pfac2.X(); Parfin(4) = pfac2.Y();
862
863 Standard_Real uu1,uu2,vv1,vv2;
864 ChFi3d_Boite(pfac1,pfac2,uu1,uu2,vv1,vv2);
865 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
866
867 if (!ChFi3d_ComputeCurves(HGs,HBs,Pardeb,Parfin,Cc,
868 Ps,
869 Pc,tolesp,tol2d,tolreached))
870 Standard_Failure::Raise("OneCorner : echec calcul intersection");
871
872 Udeb = Cc->FirstParameter();
873 Ufin = Cc->LastParameter();
874
81bba717 875 // determine if the curve has an intersection with edge of sewing
7fd59977 876
877 ChFi3d_Couture(Fv,couture,edgecouture);
878
879 if (couture && !BRep_Tool::Degenerated(edgecouture)) {
880
881 //Standard_Real Ubid,Vbid;
882 Handle (Geom_Curve) C=BRep_Tool::Curve(edgecouture,Ubid,Vbid);
883 Handle(Geom_TrimmedCurve) Ctrim=new Geom_TrimmedCurve (C,Ubid,Vbid);
884 GeomAdaptor_Curve cur1(Ctrim->BasisCurve());
885 GeomAdaptor_Curve cur2(Cc);
886 Extrema_ExtCC extCC (cur1,cur2);
887 if (extCC.IsDone()&&extCC.NbExt()!=0)
888 {
889 Standard_Integer imin=0;
890 Standard_Real distmin2 = RealLast();
891 for (Standard_Integer i = 1; i <= extCC.NbExt(); i++)
892 if (extCC.SquareDistance(i) < distmin2)
893 {
894 distmin2 = extCC.SquareDistance(i);
895 imin = i;
896 }
08cd2f6b 897 if (distmin2 <= Precision::SquareConfusion())
7fd59977 898 {
899 Extrema_POnCurv ponc1,ponc2;
900 extCC.Points( imin, ponc1, ponc2 );
901 par1 = ponc1.Parameter();
902 par2 = ponc2.Parameter();
903 Standard_Real Tol = 1.e-4;
904 if (Abs(par2-Udeb) > Tol && Abs(Ufin-par2) > Tol)
905 {
906 gp_Pnt P1 = ponc1.Value();
907 TopOpeBRepDS_Point tpoint( P1, Tol );
908 indpt = DStr.AddPoint(tpoint);
909 intcouture = Standard_True;
910 curv1 = new Geom_TrimmedCurve(Cc,Udeb,par2);
911 curv2 = new Geom_TrimmedCurve(Cc,par2,Ufin);
912 TopOpeBRepDS_Curve tcurv1(curv1,tolreached);
913 TopOpeBRepDS_Curve tcurv2(curv2,tolreached);
914 Icurv1=DStr.AddCurve(tcurv1);
915 Icurv2=DStr.AddCurve(tcurv2);
916 }
917 }
918 }
919 }
920 }
921 else { // (!inters)
922 Standard_NotImplemented::Raise("OneCorner : bouchon non ecrit");
923 }
924 Standard_Integer IShape = DStr.AddShape(Fv);
7fd59977 925 TopAbs_Orientation Et = TopAbs_FORWARD;
7fd59977 926 if (IFadArc == 1) {
927 TopExp_Explorer Exp;
928 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
929 TopAbs_EDGE);Exp.More();Exp.Next()) {
930 if (Exp.Current().IsSame(CV1.Arc())) {
931 Et = TopAbs::Reverse(TopAbs::Compose
932 (Exp.Current().Orientation(),
933 CV1.TransitionOnArc()));
934 break;
935 }
936 }
937 }
938 else {
939 TopExp_Explorer Exp;
940 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
941 TopAbs_EDGE);Exp.More();Exp.Next()) {
942 if (Exp.Current().IsSame(CV2.Arc())) {
943 Et = TopAbs::Compose(Exp.Current().Orientation(),
944 CV2.TransitionOnArc());
945 break;
946 }
947 }
948
949//
950
951
952 }
953
0797d9d3 954#ifdef OCCT_DEBUG
7fd59977 955 ChFi3d_ResultChron(ch ,t_inter); //result perf condition if (inter)
956 ChFi3d_InitChron(ch); // init perf condition if (onsame && inters)
957#endif
958
959 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV1,DStr),isfirst,1);
960 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV2,DStr),isfirst,2);
961
962 if (!intcouture) {
81bba717 963// there is no intersection with the sewing edge
964// the curve Cc is stored in the stripe
965// the storage in the DS is not done by FILDS.
7fd59977 966
967 TopOpeBRepDS_Curve Tc(Cc,tolreached);
968 ICurve = DStr.AddCurve(Tc);
969 Handle(TopOpeBRepDS_SurfaceCurveInterference)
970 Interfc = ChFi3d_FilCurveInDS(ICurve,IShape,Pc,Et);
971
972 // 31/01/02 akm vvv : (OCC119) Prevent the builder from creating
973 // intersecting fillets - they are bad.
974 Geom2dInt_GInter anIntersector;
975 Geom2dAdaptor_Curve aCorkPCurve (Pc, Udeb, Ufin);
976
977 // Take all the interferences with faces from all the stripes
978 // and look if their pcurves intersect our cork pcurve.
979 // Unfortunately, by this moment they do not exist in DStr.
980 ChFiDS_ListIteratorOfListOfStripe aStrIt(myListStripe);
981 for (; aStrIt.More(); aStrIt.Next())
982 {
983 Handle(ChFiDS_Stripe) aCheckStripe = aStrIt.Value();
984 Handle(ChFiDS_HData) aSeqData = aCheckStripe->SetOfSurfData();
985 // Loop on parts of the stripe
986 Standard_Integer iPart;
987 for (iPart=1; iPart<=aSeqData->Length(); iPart++)
988 {
989 Handle(ChFiDS_SurfData) aData = aSeqData->Value(iPart);
990 Geom2dAdaptor_Curve anOtherPCurve;
991 if (IShape == aData->IndexOfS1())
992 {
041bfce9 993 const Handle(Geom2d_Curve)& aPCurve = aData->InterferenceOnS1().PCurveOnFace();
994 if(aPCurve.IsNull())
995 continue;
996
997 anOtherPCurve.Load (aPCurve,
7fd59977 998 aData->InterferenceOnS1().FirstParameter(),
999 aData->InterferenceOnS1().LastParameter());
1000 }
1001 else if (IShape == aData->IndexOfS2())
1002 {
041bfce9 1003 const Handle(Geom2d_Curve)& aPCurve = aData->InterferenceOnS2().PCurveOnFace();
1004 if(aPCurve.IsNull())
1005 continue;
1006
1007 anOtherPCurve.Load (aPCurve,
7fd59977 1008 aData->InterferenceOnS2().FirstParameter(),
1009 aData->InterferenceOnS2().LastParameter());
1010 }
1011 else
1012 {
1013 // Normal case - no common surface
1014 continue;
1015 }
1016 if (IsEqual(anOtherPCurve.LastParameter(),anOtherPCurve.FirstParameter()))
1017 // Degenerates
1018 continue;
1019 anIntersector.Perform (aCorkPCurve, anOtherPCurve,
1020 tol2d, Precision::PConfusion());
1021 if (anIntersector.NbSegments() > 0 ||
1022 anIntersector.NbPoints() > 0)
1023 StdFail_NotDone::Raise ("OneCorner : fillets have too big radiuses");
1024 }
1025 }
1026 TopOpeBRepDS_ListIteratorOfListOfInterference
1027 anIter(DStr.ChangeShapeInterferences(IShape));
1028 for (; anIter.More(); anIter.Next())
1029 {
1030 Handle(TopOpeBRepDS_SurfaceCurveInterference) anOtherIntrf =
1031 Handle(TopOpeBRepDS_SurfaceCurveInterference)::DownCast(anIter.Value());
1032 // We need only interferences between cork face and curves
1033 // of intersection with another fillet surfaces
1034 if (anOtherIntrf.IsNull())
1035 continue;
1036 // Look if there is an intersection between pcurves
1037 Handle(Geom_TrimmedCurve) anOtherCur =
1038 Handle(Geom_TrimmedCurve)::DownCast(DStr.Curve (anOtherIntrf->Geometry()).Curve());
1039 if (anOtherCur.IsNull())
1040 continue;
1041 Geom2dAdaptor_Curve anOtherPCurve (anOtherIntrf->PCurve(),
1042 anOtherCur->FirstParameter(),
1043 anOtherCur->LastParameter());
1044 anIntersector.Perform (aCorkPCurve, anOtherPCurve,
1045 tol2d, Precision::PConfusion());
1046 if (anIntersector.NbSegments() > 0 ||
1047 anIntersector.NbPoints() > 0)
1048 StdFail_NotDone::Raise ("OneCorner : fillets have too big radiuses");
1049 }
1050 // 31/01/02 akm ^^^
1051 DStr.ChangeShapeInterferences(IShape).Append(Interfc);
1052 //// modified by jgv, 26.03.02 for OCC32 ////
1053 ChFiDS_CommonPoint CV [2];
1054 CV[0] = CV1;
1055 CV[1] = CV2;
1056 for (Standard_Integer i = 0; i < 2; i++)
1057 {
1058 if (CV[i].IsOnArc() && ChFi3d_IsPseudoSeam( CV[i].Arc(), Fv ))
1059 {
1060 gp_Pnt2d pfac1, PcF, PcL;
1061 gp_Vec2d DerPc, DerHc;
1062 Standard_Real first, last, prm1, prm2;
1063 Standard_Boolean onfirst, FirstToPar;
1064 Handle(Geom2d_Curve) Hc = BRep_Tool::CurveOnSurface( CV[i].Arc(), Fv, first, last );
1065 pfac1 = Hc->Value( CV[i].ParameterOnArc() );
1066 PcF = Pc->Value( Udeb );
1067 PcL = Pc->Value( Ufin );
1068 onfirst = (pfac1.Distance(PcF) < pfac1.Distance(PcL))? Standard_True : Standard_False;
1069 if (onfirst)
1070 Pc->D1( Udeb, PcF, DerPc );
1071 else
1072 {
1073 Pc->D1( Ufin, PcL, DerPc );
1074 DerPc.Reverse();
1075 }
1076 Hc->D1( CV[i].ParameterOnArc(), pfac1, DerHc );
1077 if (DerHc.Dot(DerPc) > 0.)
1078 {
1079 prm1 = CV[i].ParameterOnArc();
1080 prm2 = last;
1081 FirstToPar = Standard_False;
1082 }
1083 else
1084 {
1085 prm1 = first;
1086 prm2 = CV[i].ParameterOnArc();
1087 FirstToPar = Standard_True;
1088 }
1089 Handle(Geom_Curve) Ct = BRep_Tool::Curve( CV[i].Arc(), first, last );
1090 Ct = new Geom_TrimmedCurve( Ct, prm1, prm2 );
1091 Standard_Real toled = BRep_Tool::Tolerance( CV[i].Arc() );
1092 TopOpeBRepDS_Curve tcurv( Ct, toled );
1093 Handle (TopOpeBRepDS_CurvePointInterference) Interfp1, Interfp2;
1094 Standard_Integer indcurv;
1095 indcurv = DStr.AddCurve( tcurv );
1096 Standard_Integer indpoint = (isfirst)? stripe->IndexFirstPointOnS1() : stripe->IndexLastPointOnS1();
1097 Standard_Integer indvertex = DStr.AddShape(Vtx);
1098 if (FirstToPar)
1099 {
1100 Interfp1 = ChFi3d_FilPointInDS( TopAbs_FORWARD, indcurv, indvertex, prm1, Standard_True );
1101 Interfp2 = ChFi3d_FilPointInDS( TopAbs_REVERSED, indcurv, indpoint, prm2, Standard_False );
1102 }
1103 else
1104 {
1105 Interfp1 = ChFi3d_FilPointInDS( TopAbs_FORWARD, indcurv, indpoint, prm1, Standard_False );
1106 Interfp2 = ChFi3d_FilPointInDS( TopAbs_REVERSED, indcurv, indvertex, prm2, Standard_True );
1107 }
1108 DStr.ChangeCurveInterferences(indcurv).Append(Interfp1);
1109 DStr.ChangeCurveInterferences(indcurv).Append(Interfp2);
1110 Standard_Integer indface = DStr.AddShape( Fv );
1111 Interfc = ChFi3d_FilCurveInDS( indcurv, indface, Hc, CV[i].Arc().Orientation() );
1112 DStr.ChangeShapeInterferences(indface).Append( Interfc );
1113 TopoDS_Edge aLocalEdge = CV[i].Arc();
1114 aLocalEdge.Reverse();
1115 Handle(Geom2d_Curve) HcR = BRep_Tool::CurveOnSurface( aLocalEdge, Fv, first, last );
1116 Interfc = ChFi3d_FilCurveInDS( indcurv, indface, HcR, aLocalEdge.Orientation() );
1117 DStr.ChangeShapeInterferences(indface).Append( Interfc );
1118 //modify degenerated edge
1119 Standard_Boolean DegenExist = Standard_False;
1120 TopoDS_Edge Edeg;
1121 TopExp_Explorer Explo( Fv, TopAbs_EDGE );
1122 for (; Explo.More(); Explo.Next())
1123 {
1124 const TopoDS_Edge& Ecur = TopoDS::Edge( Explo.Current() );
1125 if (BRep_Tool::Degenerated( Ecur ))
1126 {
1127 TopoDS_Vertex Vf, Vl;
1128 TopExp::Vertices( Ecur, Vf, Vl );
1129 if (Vf.IsSame(Vtx) || Vl.IsSame(Vtx))
1130 {
1131 DegenExist = Standard_True;
1132 Edeg = Ecur;
1133 break;
1134 }
1135 }
1136 }
1137 if (DegenExist)
1138 {
1139 Standard_Real fd, ld;
1140 Handle(Geom2d_Curve) Cd = BRep_Tool::CurveOnSurface( Edeg, Fv, fd, ld );
1141 Handle(Geom2d_TrimmedCurve) tCd = Handle(Geom2d_TrimmedCurve)::DownCast(Cd);
1142 if (! tCd.IsNull())
1143 Cd = tCd->BasisCurve();
1144 gp_Pnt2d P2d = (FirstToPar)? Hc->Value(first) : Hc->Value(last);
1145 Geom2dAPI_ProjectPointOnCurve Projector( P2d, Cd );
1146 Standard_Real par = Projector.LowerDistanceParameter();
1147 Standard_Integer Ideg = DStr.AddShape(Edeg);
1148 TopAbs_Orientation ori = (par < fd)? TopAbs_FORWARD : TopAbs_REVERSED; //if par<fd => par>ld
1149 Interfp1 = ChFi3d_FilPointInDS( ori, Ideg, indvertex, par, Standard_True );
1150 DStr.ChangeShapeInterferences(Ideg).Append(Interfp1);
1151 }
1152 }
1153 }
1154 /////////////////////////////////////////////
1155 stripe->ChangePCurve(isfirst)=Ps;
1156 stripe->SetCurve(ICurve,isfirst);
1157 stripe->SetParameters(isfirst,Udeb,Ufin);
1158 }
1159 else {
81bba717 1160// curves curv1 are curv2 stored in the DS
1161// these curves will not be reconstructed by FILDS as
1162// one places stripe->InDS(isfirst);
7fd59977 1163
81bba717 1164 // interferences of curv1 and curv2 on Fv
7fd59977 1165 ComputeCurve2d(curv1,Fv,c2d1);
1166 Handle(TopOpeBRepDS_SurfaceCurveInterference) InterFv;
1167 InterFv = ChFi3d_FilCurveInDS(Icurv1,IShape,c2d1,Et);
1168 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1169 ComputeCurve2d(curv2,Fv,c2d2);
1170 InterFv = ChFi3d_FilCurveInDS(Icurv2,IShape,c2d2,Et);
1171 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
81bba717 1172 // interferences of curv1 and curv2 on Isurf
7fd59977 1173 if (Fd->Orientation()== Fv.Orientation()) Et=TopAbs::Reverse(Et);
1174 c2d1=new Geom2d_TrimmedCurve(Ps,Udeb,par2);
1175 InterFv = ChFi3d_FilCurveInDS(Icurv1,Isurf,c2d1,Et);
1176 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
1177 c2d2=new Geom2d_TrimmedCurve(Ps,par2,Ufin);
1178 InterFv = ChFi3d_FilCurveInDS(Icurv2,Isurf,c2d2,Et);
1179 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
1180
81bba717 1181 // limitation of the sewing edge
7fd59977 1182 Standard_Integer Iarc=DStr.AddShape(edgecouture);
1183 Handle(TopOpeBRepDS_CurvePointInterference) Interfedge;
1184 TopAbs_Orientation ori;
1185 TopoDS_Vertex Vdeb,Vfin;
1186 Vdeb=TopExp::FirstVertex(edgecouture);
1187 Vfin=TopExp::LastVertex(edgecouture);
1188 Standard_Real pard,parf;
1189 pard=BRep_Tool::Parameter(Vdeb,edgecouture);
1190 parf=BRep_Tool::Parameter(Vfin,edgecouture);
1191 if (Abs(par1-pard)<Abs(parf-par1)) ori=TopAbs_FORWARD;
1192 else ori=TopAbs_REVERSED;
1193 Interfedge = ChFi3d_FilPointInDS(ori,Iarc,indpt,par1);
1194 DStr.ChangeShapeInterferences(Iarc).Append(Interfedge);
1195
81bba717 1196 // creation of CurveInterferences from Icurv1 and Icurv2
7fd59977 1197 stripe->InDS(isfirst);
1198 Standard_Integer ind1= stripe->IndexPoint(isfirst,1);
1199 Standard_Integer ind2= stripe->IndexPoint(isfirst,2);
1200 Handle(TopOpeBRepDS_CurvePointInterference)
1201 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv1,ind1,Udeb);
1202 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1203 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv1,indpt,par2);
1204 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1205 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv2,indpt,par2);
1206 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1207 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv2,ind2,Ufin);
1208 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1209
1210 }
1211
1212 ChFi3d_EnlargeBox(HBs,Pc,Udeb,Ufin,box1,box2);
1213
1214 if (onsame && inters) {
1215 // VARIANT 1:
81bba717 1216 // A small missing end of curve is added for the extension
1217 // of the face at end and the limitation of the opposing face.
7fd59977 1218
1219 // VARIANT 2 : extend Arcprol, not create new small edge
1220 // To do: modify for intcouture
3ed30348 1221 #define VARIANT1
7fd59977 1222
81bba717 1223 // First of all the ponts are cut with the edge of the spine.
7fd59977 1224 Standard_Integer IArcspine = DStr.AddShape(Arcspine);
1225 Standard_Integer IVtx = DStr.AddShape(Vtx);
7fd59977 1226 TopAbs_Orientation OVtx = TopAbs_FORWARD;
7fd59977 1227 for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
1228 ex.More(); ex.Next()) {
1229 if (Vtx.IsSame(ex.Current())) {
1230 OVtx = ex.Current().Orientation();
1231 break;
1232 }
1233 }
1234 OVtx = TopAbs::Reverse(OVtx);
1235 Standard_Real parVtx = BRep_Tool::Parameter(Vtx,Arcspine);
1236 Handle(TopOpeBRepDS_CurvePointInterference)
1237 interfv = ChFi3d_FilVertexInDS(OVtx,IArcspine,IVtx,parVtx);
1238 DStr.ChangeShapeInterferences(IArcspine).Append(interfv);
1239
81bba717 1240 // Now the missing curves are constructed.
7fd59977 1241 TopoDS_Vertex V2;
1242 for(ex.Init(Arcprol.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
1243 ex.More(); ex.Next()) {
1244 if (Vtx.IsSame(ex.Current()))
1245 OVtx = ex.Current().Orientation();
1246 else
1247 V2 = TopoDS::Vertex(ex.Current());
1248 }
1249
1250 Handle(Geom2d_Curve) Hc;
3ed30348 1251 #ifdef VARIANT1
7fd59977 1252 parVtx = BRep_Tool::Parameter(Vtx,Arcprol);
3ed30348 1253 #else
7fd59977 1254 parVtx = BRep_Tool::Parameter(V2,Arcprol);
3ed30348 1255 #endif
7fd59977 1256 const ChFiDS_FaceInterference& Fiop = Fd->Interference(IFopArc);
1257 gp_Pnt2d pop1, pop2, pv1, pv2;
1258 Hc = BRep_Tool::CurveOnSurface(Arcprol,Fop,Ubid,Ubid);
1259 pop1 = Hc->Value(parVtx);
1260 pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst));
1261 Hc = BRep_Tool::CurveOnSurface(Arcprol,Fv,Ubid,Ubid);
1262 pv1 = Hc->Value(parVtx);
1263 pv2 = p2dbout;
1264 ChFi3d_Recale(Bs,pv1,pv2,1);
1265 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
1266 Pardeb(1) = pop1.X(); Pardeb(2) = pop1.Y();
1267 Pardeb(3) = pv1.X(); Pardeb(4) = pv1.Y();
1268 Parfin(1) = pop2.X(); Parfin(2) = pop2.Y();
1269 Parfin(3) = pv2.X(); Parfin(4) = pv2.Y();
1270 Standard_Real uu1,uu2,vv1,vv2;
1271 ChFi3d_Boite(pv1,pv2,uu1,uu2,vv1,vv2);
1272 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
1273 ChFi3d_Boite(pop1,pop2,uu1,uu2,vv1,vv2);
1274 ChFi3d_BoundFac(Bop,uu1,uu2,vv1,vv2);
1275
1276 Handle(Geom_Curve) zob3d;
1277 Handle(Geom2d_Curve) zob2dop, zob2dv;
1278 //Standard_Real tolreached;
1279 if (!ChFi3d_ComputeCurves(HBop,HBs,Pardeb,Parfin,zob3d,zob2dop,
1280 zob2dv,tolesp,tol2d,tolreached))
1281 Standard_Failure::Raise("OneCorner : echec calcul intersection");
1282
1283 Udeb = zob3d->FirstParameter();
1284 Ufin = zob3d->LastParameter();
1285 TopOpeBRepDS_Curve Zob(zob3d,tolreached);
1286 Standard_Integer IZob = DStr.AddCurve(Zob);
1287
81bba717 1288// it is determined if Fop has an edge of sewing
1289// it is determined if the curve has an intersection with the edge of sewing
7fd59977 1290
1291 //TopoDS_Edge edgecouture;
1292 //Standard_Boolean couture;
1293 ChFi3d_Couture(Fop,couture,edgecouture);
1294
1295 if (couture && !BRep_Tool::Degenerated(edgecouture)) {
1296 BRepLib_MakeEdge Bedge (zob3d);
1297 TopoDS_Edge edg =Bedge. Edge();
1298 BRepExtrema_ExtCC extCC (edgecouture,edg);
1299 if (extCC.IsDone()&&extCC.NbExt()!=0) {
1300 for (Standard_Integer i=1; i<=extCC.NbExt()&&!intcouture;i++) {
1301 if (extCC.SquareDistance(i)<=1.e-8) {
1302 par1=extCC.ParameterOnE1(i);
1303 par2=extCC.ParameterOnE2(i);
1304 gp_Pnt P1=extCC.PointOnE1(i);
1305 TopOpeBRepDS_Point tpoint(P1,1.e-4);
1306 indpt=DStr.AddPoint(tpoint);
1307 intcouture=Standard_True;
1308 curv1 = new Geom_TrimmedCurve(zob3d,Udeb,par2);
1309 curv2 = new Geom_TrimmedCurve(zob3d,par2,Ufin);
1310 TopOpeBRepDS_Curve tcurv1(curv1,tolreached);
1311 TopOpeBRepDS_Curve tcurv2(curv2,tolreached);
1312 Icurv1=DStr.AddCurve(tcurv1);
1313 Icurv2=DStr.AddCurve(tcurv2);
1314 }
1315 }
1316 }
1317 }
1318 if (intcouture) {
1319
81bba717 1320// interference of curv1 and curv2 on Ishape
7fd59977 1321 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv));
1322 ComputeCurve2d(curv1,Fop,c2d1);
1323 Handle(TopOpeBRepDS_SurfaceCurveInterference)
1324 InterFv = ChFi3d_FilCurveInDS(Icurv1,IShape,/*zob2dv*/c2d1,Et);
1325 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1326 ComputeCurve2d(curv2,Fop,c2d2);
1327 InterFv = ChFi3d_FilCurveInDS(Icurv2,IShape,/*zob2dv*/c2d2,Et);
1328 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1329
81bba717 1330 // limitation of the sewing edge
7fd59977 1331 Standard_Integer Iarc=DStr.AddShape(edgecouture);
1332 Handle(TopOpeBRepDS_CurvePointInterference) Interfedge;
1333 TopAbs_Orientation ori;
1334 TopoDS_Vertex Vdeb,Vfin;
1335 Vdeb=TopExp::FirstVertex(edgecouture);
1336 Vfin=TopExp::LastVertex(edgecouture);
1337 Standard_Real pard,parf;
1338 pard=BRep_Tool::Parameter(Vdeb,edgecouture);
1339 parf=BRep_Tool::Parameter(Vfin,edgecouture);
1340 if (Abs(par1-pard)<Abs(parf-par1)) ori=TopAbs_REVERSED;
1341 else ori=TopAbs_FORWARD;
1342 Interfedge = ChFi3d_FilPointInDS(ori,Iarc,indpt,par1);
1343 DStr.ChangeShapeInterferences(Iarc).Append(Interfedge);
1344
81bba717 1345 // interference of curv1 and curv2 on Iop
7fd59977 1346 Standard_Integer Iop = DStr.AddShape(Fop);
1347 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolop));
1348 Handle(TopOpeBRepDS_SurfaceCurveInterference) Interfop;
1349 ComputeCurve2d(curv1,Fop,c2d1);
1350 Interfop = ChFi3d_FilCurveInDS(Icurv1,Iop,c2d1,Et);
1351 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
1352 ComputeCurve2d(curv2,Fop,c2d2);
1353 Interfop = ChFi3d_FilCurveInDS(Icurv2,Iop,c2d2,Et);
1354 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
1355 Handle(TopOpeBRepDS_CurvePointInterference)
1356 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,Icurv1,IVtx,Udeb);
1357 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1358 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv1,indpt,par2);
1359 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1360 Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc);
1361 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv2,indpt,par2);
1362 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1363 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv2,icc,Ufin);
1364 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1365 }
1366 else {
1367 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv));
1368 Handle(TopOpeBRepDS_SurfaceCurveInterference)
1369 InterFv = ChFi3d_FilCurveInDS(IZob,IShape,zob2dv,Et);
1370 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1371 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolop));
1372 Standard_Integer Iop = DStr.AddShape(Fop);
1373 Handle(TopOpeBRepDS_SurfaceCurveInterference)
1374 Interfop = ChFi3d_FilCurveInDS(IZob,Iop,zob2dop,Et);
1375 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
1376 Handle(TopOpeBRepDS_CurvePointInterference) interfprol;
3ed30348 1377 #ifdef VARIANT1
7fd59977 1378 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IVtx,Udeb);
3ed30348 1379 #else
1380 {
7fd59977 1381 Standard_Integer IV2 = DStr.AddShape(V2); // VARIANT 2
1382 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IV2,Udeb);
1383 }
3ed30348 1384 #endif
7fd59977 1385 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
1386 Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc);
1387 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,IZob,icc,Ufin);
1388 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
3ed30348 1389 #ifdef VARIANT1
1390 {
7fd59977 1391 if (IFopArc == 1) box1.Add( zob3d->Value(Ufin) );
1392 else box2.Add( zob3d->Value(Ufin) );
1393 }
3ed30348 1394 #else
1395 {
7fd59977 1396 // cut off existing Arcprol
1397 Standard_Integer iArcprol = DStr.AddShape(Arcprol);
1398 interfprol = ChFi3d_FilPointInDS(OVtx,iArcprol,icc,Udeb);
1399 DStr.ChangeShapeInterferences(Arcprol).Append(interfprol);
1400 }
3ed30348 1401 #endif
7fd59977 1402 }
1403 }
1404 ChFi3d_EnlargeBox(DStr,stripe,Fd,box1,box2,isfirst);
1405 if (CV1.IsOnArc()) {
1406 ChFi3d_EnlargeBox(CV1.Arc(),myEFMap(CV1.Arc()),CV1.ParameterOnArc(),box1);
1407 }
1408 if (CV2.IsOnArc()) {
1409 ChFi3d_EnlargeBox(CV2.Arc(),myEFMap(CV2.Arc()),CV2.ParameterOnArc(),box2);
1410 }
1411 if (!CV1.IsVertex())
1412 ChFi3d_SetPointTolerance(DStr,box1,stripe->IndexPoint(isfirst,1));
1413 if (!CV2.IsVertex())
1414 ChFi3d_SetPointTolerance(DStr,box2,stripe->IndexPoint(isfirst,2));
1415
0797d9d3 1416#ifdef OCCT_DEBUG
7fd59977 1417 ChFi3d_ResultChron(ch, t_sameinter);//result perf condition if (same &&inter)
1418#endif
1419}
1420
1421//=======================================================================
1422//function : cherche_face
81bba717 1423//purpose : find face F belonging to the map, different from faces
1424// F1 F2 F3 and containing edge E
7fd59977 1425//=======================================================================
1426
1427static void cherche_face (const TopTools_ListOfShape & map,
1428 const TopoDS_Edge & E,
1429 const TopoDS_Face & F1,
1430 const TopoDS_Face & F2,
1431 const TopoDS_Face & F3,
1432 TopoDS_Face & F)
1433{ TopoDS_Face Fcur;
1434 Standard_Boolean trouve=Standard_False;
1435 TopTools_ListIteratorOfListOfShape It;
1436 Standard_Integer ie;
1437 for (It.Initialize(map);It.More()&&!trouve;It.Next())
1438 { Fcur=TopoDS::Face (It.Value());
1439 if (!Fcur.IsSame(F1) && !Fcur.IsSame(F2)&& !Fcur.IsSame(F3) )
1440 { TopTools_IndexedMapOfShape MapE;
1441 TopExp::MapShapes( Fcur,TopAbs_EDGE,MapE);
1442 for ( ie=1; ie<= MapE.Extent()&&!trouve; ie++)
1443 {
1444 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE(ie));
1445 if (E.IsSame(TopoDS::Edge(aLocalShape)))
1446 // if (E.IsSame(TopoDS::Edge(TopoDS_Shape (MapE(ie)))))
1447 { F= Fcur; trouve=Standard_True;}
1448 }
1449 }
1450 }
1451}
1452
1453//=======================================================================
1454//function : cherche_edge1
81bba717 1455//purpose : find common edge between faces F1 and F2
7fd59977 1456//=======================================================================
1457
1458static void cherche_edge1 (const TopoDS_Face & F1,
1459 const TopoDS_Face & F2,
1460 TopoDS_Edge & Edge)
1461{ Standard_Integer i,j;
1462 TopoDS_Edge Ecur1,Ecur2;
1463 Standard_Boolean trouve=Standard_False;
1464 TopTools_IndexedMapOfShape MapE1,MapE2;
1465 TopExp::MapShapes( F1,TopAbs_EDGE,MapE1);
1466 TopExp::MapShapes( F2,TopAbs_EDGE,MapE2);
1467 for ( i=1; i<= MapE1.Extent()&&!trouve; i++)
1468 {
1469 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE1(i));
1470 Ecur1=TopoDS::Edge(aLocalShape);
1471// Ecur1=TopoDS::Edge(TopoDS_Shape (MapE1(i)));
1472 for ( j=1; j<= MapE2.Extent()&&!trouve; j++)
1473 {
1474 aLocalShape = TopoDS_Shape (MapE2(j));
1475 Ecur2=TopoDS::Edge(aLocalShape);
1476// Ecur2=TopoDS::Edge(TopoDS_Shape (MapE2(j)));
1477 if (Ecur2.IsSame(Ecur1))
1478 {Edge=Ecur1;trouve=Standard_True;}
1479 }
1480 }
1481}
1482
1483//=======================================================================
1484//function : containV
81bba717 1485//purpose : return true if vertex V belongs to F1
7fd59977 1486//=======================================================================
1487
1488static Standard_Boolean containV(const TopoDS_Face & F1,
1489 const TopoDS_Vertex & V)
1490{ Standard_Integer i;
1491 TopoDS_Vertex Vcur;
1492 Standard_Boolean trouve=Standard_False;
1493 Standard_Boolean contain=Standard_False;
1494 TopTools_IndexedMapOfShape MapV;
1495 TopExp::MapShapes( F1,TopAbs_VERTEX,MapV);
1496 for ( i=1; i<= MapV.Extent()&&!trouve; i++)
1497 {
1498 TopoDS_Shape aLocalShape = TopoDS_Shape (MapV(i));
1499 Vcur=TopoDS::Vertex(aLocalShape);
1500// Vcur=TopoDS::Vertex(TopoDS_Shape (MapV(i)));
1501 if (Vcur.IsSame(V) )
1502 {contain=Standard_True; trouve=Standard_True;}
1503 }
1504 return contain;
1505}
1506
1507//=======================================================================
1508//function : containE
81bba717 1509//purpose : return true if edge E belongs to F1
7fd59977 1510//=======================================================================
1511
1512static Standard_Boolean containE(const TopoDS_Face & F1,
1513 const TopoDS_Edge & E)
1514{ Standard_Integer i;
1515 TopoDS_Edge Ecur;
1516 Standard_Boolean trouve=Standard_False;
1517 Standard_Boolean contain=Standard_False;
1518 TopTools_IndexedMapOfShape MapE;
1519 TopExp::MapShapes( F1,TopAbs_EDGE,MapE);
1520 for ( i=1; i<= MapE.Extent()&&!trouve; i++)
1521 {
1522 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE(i));
1523 Ecur=TopoDS::Edge(aLocalShape);
1524// Ecur=TopoDS::Edge(TopoDS_Shape (MapE(i)));
1525 if (Ecur.IsSame(E) )
1526 {contain=Standard_True; trouve=Standard_True;}
1527 }
1528 return contain;
1529}
1530
1531
1532//=======================================================================
1533//function : IsShrink
1534//purpose : check if U (if <isU>==True) or V of points of <PC> is within
1535// <tol> from <Param>, check points between <Pf> and <Pl>
1536//=======================================================================
1537
1538static Standard_Boolean IsShrink(const Geom2dAdaptor_Curve PC,
1539 const Standard_Real Pf,
1540 const Standard_Real Pl,
1541 const Standard_Real Param,
1542 const Standard_Boolean isU,
1543 const Standard_Real tol)
1544{
1545 switch (PC.GetType()) {
1546 case GeomAbs_Line: {
1547 gp_Pnt2d P1 = PC.Value(Pf);
1548 gp_Pnt2d P2 = PC.Value(Pl);
1549 if (Abs(P1.Coord(isU ? 1 : 2) - Param) <= tol &&
1550 Abs(P2.Coord(isU ? 1 : 2) - Param) <= tol )
1551 return Standard_True;
1552 else
1553 return Standard_False;
1554 }
1555 case GeomAbs_BezierCurve:
1556 case GeomAbs_BSplineCurve: {
1557 math_FunctionSample aSample (Pf,Pl,10);
1558 Standard_Integer i;
1559 for (i=1; i<=aSample.NbPoints(); i++) {
1560 gp_Pnt2d P = PC.Value(aSample.GetParameter(i));
1561 if (Abs(P.Coord(isU ? 1 : 2) - Param) > tol )
1562 return Standard_False;
1563 }
1564 return Standard_True;
1565 }
1566 default:;
1567 }
1568 return Standard_False;
1569}
1570//=======================================================================
1571//function : PerformIntersectionAtEnd
1572//purpose :
1573//=======================================================================
1574
1575void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
1576{
1577
81bba717 1578 // intersection at end of fillet with at least two faces
1579 // process the following cases:
1580 // - top has n (n>3) adjacent edges
1581 // - top has 3 edges and fillet on one of edges touches
1582 // more than one face
7fd59977 1583
0797d9d3 1584#ifdef OCCT_DEBUG
7fd59977 1585 OSD_Chronometer ch;// init perf
1586#endif
1587
1588 TopOpeBRepDS_DataStructure& DStr= myDS->ChangeDS();
1589 const Standard_Integer nn=15;
1590 ChFiDS_ListIteratorOfListOfStripe It;
1591 It.Initialize(myVDataMap(Index));
1592 Handle(ChFiDS_Stripe) stripe = It.Value();
1593 const Handle(ChFiDS_Spine) spine = stripe->Spine();
1594 ChFiDS_SequenceOfSurfData& SeqFil =
1595 stripe->ChangeSetOfSurfData()->ChangeSequence();
1596 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
1597 Standard_Integer sens = 0,num,num1;
1598 Standard_Boolean couture=Standard_False,isfirst;
1599 //Standard_Integer sense;
1600 TopoDS_Edge edgelibre1,edgelibre2,EdgeSpine;
1601 Standard_Boolean bordlibre;
81bba717 1602 // determine the number of faces and edges
7fd59977 1603 TopTools_Array1OfShape tabedg(0,nn);
1604 TopoDS_Face F1,F2;
1605 Standard_Integer nface=ChFi3d_nbface(myVFMap(Vtx));
1606 TopTools_ListIteratorOfListOfShape ItF;
1607 Standard_Integer nbarete;
1608 nbarete=ChFi3d_NbNotDegeneratedEdges(Vtx,myVEMap);
1609 ChFi3d_ChercheBordsLibres(myVEMap,Vtx,bordlibre,edgelibre1,edgelibre2);
1610 if (bordlibre) nbarete=(nbarete-2)/2 +2;
1611 else nbarete=nbarete/2;
81bba717 1612 // it is determined if there is an edge of sewing and it face
7fd59977 1613
1614 TopoDS_Face facecouture;
1615 TopoDS_Edge edgecouture;
1616
1617 Standard_Boolean trouve=Standard_False;
1618 for(ItF.Initialize(myVFMap(Vtx));ItF.More()&&!couture;ItF.Next()) {
1619 TopoDS_Face fcur = TopoDS::Face(ItF.Value());
1620 ChFi3d_CoutureOnVertex(fcur,Vtx,couture,edgecouture);
1621 if (couture)
1622 facecouture=fcur;
1623 }
81bba717 1624 // it is determined if one of edges adjacent to the fillet is regular
7fd59977 1625 Standard_Boolean reg1,reg2;
1626 TopoDS_Edge Ecur,Eadj1,Eadj2;
1627 TopoDS_Face Fga,Fdr;
1628 TopoDS_Vertex Vbid1;
1629 Standard_Integer nbsurf,nbedge;
1630 reg1=Standard_False;
1631 reg2=Standard_False;
1632 nbsurf= SeqFil.Length();
1633 nbedge = spine->NbEdges();
1634 num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
1635 isfirst = (sens == 1);
1636 ChFiDS_State state;
1637 if (isfirst) {
1638 EdgeSpine=spine->Edges(1);
1639 num1=num+1;
1640 state = spine->FirstStatus();
1641 }
1642 else {
1643 EdgeSpine=spine->Edges(nbedge);
1644 num1=num-1;
1645 state = spine->LastStatus();
1646 }
1647 if (nbsurf!=nbedge && nbsurf!=1) {
1648 ChFi3d_edge_common_faces(myEFMap(EdgeSpine),F1,F2);
1649 if (F1.IsSame(facecouture)) Eadj1=edgecouture;
1650 else ChFi3d_cherche_element(Vtx,EdgeSpine,F1,Eadj1,Vbid1);
1651 ChFi3d_edge_common_faces(myEFMap(Eadj1),Fga,Fdr);
1652// Modified by Sergey KHROMOV - Fri Dec 21 17:57:32 2001 Begin
1653// reg1=BRep_Tool::Continuity(Eadj1,Fga,Fdr)!=GeomAbs_C0;
1654 reg1=isTangentFaces(Eadj1,Fga,Fdr);
1655// Modified by Sergey KHROMOV - Fri Dec 21 17:57:33 2001 End
1656 if (F2.IsSame(facecouture)) Eadj2=edgecouture;
1657 else ChFi3d_cherche_element(Vtx,EdgeSpine,F2,Eadj2,Vbid1);
1658 ChFi3d_edge_common_faces(myEFMap(Eadj2),Fga,Fdr);
1659// Modified by Sergey KHROMOV - Fri Dec 21 17:58:22 2001 Begin
1660// reg2=BRep_Tool::Continuity(Eadj2,Fga,Fdr)!=GeomAbs_C0;
1661 reg2=isTangentFaces(Eadj2,Fga,Fdr);
1662// Modified by Sergey KHROMOV - Fri Dec 21 17:58:24 2001 End
1663
81bba717 1664// two faces common to the edge are found
7fd59977 1665 if (reg1 || reg2) {
1666 Standard_Boolean compoint1=Standard_False;
1667 Standard_Boolean compoint2=Standard_False;
1668 ChFiDS_CommonPoint cp1, cp2;
1669 cp1 = SeqFil(num1)->ChangeVertex (isfirst,1);
1670 cp2 = SeqFil(num1)->ChangeVertex (isfirst,2);
1671 if (cp1.IsOnArc()) {
1672 if (cp1.Arc().IsSame(Eadj1)||cp1.Arc().IsSame(Eadj2))
1673 compoint1=Standard_True;
1674 }
1675 if (cp2.IsOnArc()) {
1676 if (cp2.Arc().IsSame(Eadj1)||cp2.Arc().IsSame(Eadj2))
1677 compoint2=Standard_True;
1678 }
1679 if (compoint1 && compoint2) {
1680 SeqFil.Remove(num);
1681 reg1=Standard_False; reg2=Standard_False;
1682 }
1683 }
1684 }
81bba717 1685// there is only one face at end if FindFace is true and if the face
1686// is not the face with sewing edge
7fd59977 1687 TopoDS_Face face;
1688 Handle(ChFiDS_SurfData) Fd = SeqFil.ChangeValue(num);
1689 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
1690 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
1691 Standard_Boolean onecorner=Standard_False;
1692 if (FindFace(Vtx,CV1,CV2,face)) {
1693 if (!couture) onecorner =Standard_True;
1694 else if (!face.IsSame(facecouture))
1695 onecorner=Standard_True;
1696 }
1697 if (onecorner) {
1698 if (ChFi3d_Builder::MoreSurfdata(Index)) {
1699 ChFi3d_Builder::PerformMoreSurfdata(Index);
1700 return;
1701 }
1702 }
1703 if (!onecorner && (reg1||reg2) && !couture && state!=ChFiDS_OnSame) {
1704 PerformMoreThreeCorner (Index,1);
1705 return;
1706 }
1707 Handle(GeomAdaptor_HSurface) HGs = ChFi3d_BoundSurf(DStr,Fd,1,2);
1708 ChFiDS_FaceInterference Fi1 = Fd->InterferenceOnS1();
1709 ChFiDS_FaceInterference Fi2 = Fd->InterferenceOnS2();
1710 GeomAdaptor_Surface& Gs = HGs->ChangeSurface();
1711 Handle(BRepAdaptor_HSurface) HBs = new BRepAdaptor_HSurface();
1712 BRepAdaptor_Surface& Bs = HBs->ChangeSurface();
1713 Handle(Geom_Curve) Cc;
1714 Handle(Geom2d_Curve) Pc,Ps;
1715 Standard_Real Ubid,Vbid;
1716 TopAbs_Orientation orsurfdata;
1717 orsurfdata=Fd->Orientation();
1718 Standard_Integer IsurfPrev=0, Isurf=Fd->Surf();
1719 Handle(ChFiDS_SurfData) SDprev;
1720 if (num1>0 && num1<=SeqFil.Length()) {
1721 SDprev = SeqFil(num1);
1722 IsurfPrev = SDprev->Surf();
1723 }
81bba717 1724 // calculate the orientation of curves at end
7fd59977 1725
1726 Standard_Real tolpt=1.e-4;
1727 Standard_Real tolreached;
1728 TopAbs_Orientation orcourbe,orface,orien;
1729
1730 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV1,DStr),isfirst,1);
1731 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV2,DStr),isfirst,2);
1732
1733// gp_Pnt p3d;
1734// gp_Pnt2d p2d;
1735 Standard_Real dist;
1736 Standard_Integer Ishape1=Fd->IndexOfS1();
7fd59977 1737 TopAbs_Orientation trafil1 = TopAbs_FORWARD;
7fd59977 1738 if (Ishape1 != 0) {
1739 if (Ishape1 > 0) {
1740 trafil1 = DStr.Shape(Ishape1).Orientation();
1741 }
0797d9d3 1742#ifdef OCCT_DEBUG
7fd59977 1743 else {
1744 cout<<"erreur"<<endl;
1745 }
1746#endif
1747 trafil1 = TopAbs::Compose(trafil1,Fd->Orientation());
1748
1749 trafil1 = TopAbs::Compose(TopAbs::Reverse(Fi1.Transition()),trafil1);
1750 }
0797d9d3 1751#ifdef OCCT_DEBUG
7fd59977 1752 else cout<<"erreur"<<endl;
1753#endif
1754 // eap, Apr 22 2002, occ 293
1755// Fi1.PCurveOnFace()->D0(Fi1.LastParameter(),p2d);
1756// const Handle(Geom_Surface) Stemp =
1757// BRep_Tool::Surface(TopoDS::Face(DStr.Shape(Ishape1)));
1758// Stemp ->D0(p2d.X(),p2d.Y(),p3d);
1759// dist=p3d.Distance(CV1.Point());
1760// if (dist<tolpt) orcourbe=trafil1;
1761// else orcourbe=TopAbs::Reverse(trafil1);
1762 if (!isfirst) orcourbe=trafil1;
1763 else orcourbe=TopAbs::Reverse(trafil1);
1764
1765 // eap, Apr 22 2002, occ 293
1766 // variables to show OnSame situation
1767 Standard_Boolean isOnSame1, isOnSame2;
1768 // In OnSame situation, the case of degenerated FaceInterference curve
1769 // is probable when a corner cuts the ChFi3d earlier built on OnSame edge.
1770 // In such a case, chamfer face can partially shrink to a line and we need
1771 // to cut off that shrinked part
1772 // If <isOnSame1>, FaceInterference with F2 can be degenerated
1773 Standard_Boolean checkShrink, isShrink, isUShrink;
1774 isShrink = isUShrink = isOnSame1 = isOnSame2 = Standard_False;
1775 Standard_Real checkShrParam=0., prevSDParam=0.;
1776 gp_Pnt2d midP2d;
1777 Standard_Integer midIpoint=0;
1778
1779 // find Fi1,Fi2 lengths used to extend ChFi surface
1780 // and by the way define necessity to check shrink
1781 gp_Pnt2d P2d1=Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));
1782 gp_Pnt2d P2d2=Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
1783 gp_Pnt aP1,aP2;
1784 HGs->D0( P2d1.X(),P2d1.Y(),aP1);
1785 HGs->D0( P2d2.X(),P2d2.Y(),aP2);
1786 Standard_Real Fi1Length=aP1.Distance(aP2);
1787// Standard_Real eps = Precision::Confusion();
1788 checkShrink = (Fi1Length <= Precision::Confusion());
1789
1790 gp_Pnt2d P2d3=Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
1791 gp_Pnt2d P2d4=Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
1792 HGs->D0( P2d3.X(),P2d3.Y(),aP1);
1793 HGs->D0( P2d4.X(),P2d4.Y(),aP2);
1794 Standard_Real Fi2Length=aP1.Distance(aP2);
1795 checkShrink = checkShrink || (Fi2Length <= Precision::Confusion());
1796
1797 if (checkShrink) {
1798 if (Abs(P2d2.Y()-P2d4.Y()) <= Precision::PConfusion()) {
1799 isUShrink = Standard_False;
1800 checkShrParam = P2d2.Y();
1801 } else if (Abs(P2d2.X()-P2d4.X()) <= Precision::PConfusion()) {
1802 isUShrink = Standard_True;
1803 checkShrParam = P2d2.X();
1804 }
1805 else
1806 checkShrink = Standard_False;
1807 }
1808
1809 /***********************************************************************/
81bba717 1810 // find faces intersecting with the fillet and edges limiting intersections
1811 // nbface is the nb of faces intersected, Face[i] contais the faces
1812 // to intersect (i=0.. nbface-1). Edge[i] contains edges limiting
1813 // the intersections (i=0 ..nbface)
7fd59977 1814 /**********************************************************************/
1815
1816 Standard_Integer nb = 1,nbface;
1817 TopoDS_Edge E1 ,E2, Edge[nn],E,Ei,edgesau;
1818 TopoDS_Face facesau;
1819 Standard_Boolean oneintersection1=Standard_False;
1820 Standard_Boolean oneintersection2=Standard_False;
1821 TopoDS_Face Face[nn],F,F3;
1822 TopoDS_Vertex V1,V2,V,Vfin;
1823 Standard_Boolean findonf1=Standard_False,findonf2=Standard_False;
1824 TopTools_ListIteratorOfListOfShape It3;
1825 F1=TopoDS::Face(DStr.Shape(Fd->IndexOfS1()));
1826 F2=TopoDS::Face(DStr.Shape(Fd->IndexOfS2()));
1827 F3=F1;
1828 if (couture || bordlibre) nface=nface+1;
1829 if (nface==3) nbface=2;
1830 else nbface=nface-2;
1831 if (!CV1.IsOnArc()||!CV2.IsOnArc()) {
1832 PerformMoreThreeCorner(Index,1);
1833 return;
1834 }
1835
1836 Edge[0]=CV1.Arc();
1837 Edge[nbface]=CV2.Arc();
1838 tabedg.SetValue(0,Edge[0]);
1839 tabedg.SetValue(nbface,Edge[nbface]);
81bba717 1840 // processing of a fillet arriving on a vertex
1841 // edge contained in CV.Arc is not inevitably good
1842 // the edge concerned by the intersection is found
7fd59977 1843
1844 Standard_Real dist1,dist2;
1845 if (CV1.IsVertex()) {
1846 trouve=Standard_False;
1847 /*TopoDS_Vertex */V=CV1.Vertex();
1848 for (It3.Initialize(myVEMap(V));It3.More()&&!trouve;It3.Next()) {
1849 E=TopoDS::Edge (It3.Value());
1850 if (!E.IsSame(Edge[0])&&(containE(F1,E)))
1851 trouve=Standard_True;
1852 }
1853 TopoDS_Vertex Vt,V3,V4;
1854 V1=TopExp::FirstVertex(Edge[0]);
1855 V2=TopExp::LastVertex(Edge[0]);
1856 if (V.IsSame(V1)) Vt=V2;
1857 else Vt=V1;
1858 dist1=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1859 V3=TopExp::FirstVertex(E);
1860 V4=TopExp::LastVertex(E);
1861 if (V.IsSame(V3)) Vt=V4;
1862 else Vt=V3;
1863 dist2=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1864 if (dist2<dist1) {
1865 Edge[0]=E;
1866 TopAbs_Orientation ori;
1867 if (V2.IsSame(V3)||V1.IsSame(V4)) ori=CV1.TransitionOnArc();
1868 else ori=TopAbs::Reverse(CV1.TransitionOnArc());
1869 Standard_Real par= BRep_Tool::Parameter(V,Edge[0]);
1870 Standard_Real tol= CV1.Tolerance();
1871 CV1.SetArc(tol,Edge[0],par,ori);
1872 }
1873 }
1874
1875 if (CV2.IsVertex()) {
1876 trouve=Standard_False;
1877 /*TopoDS_Vertex*/ V=CV2.Vertex();
1878 for (It3.Initialize(myVEMap(V));It3.More()&&!trouve;It3.Next()) {
1879 E=TopoDS::Edge (It3.Value());
1880 if (!E.IsSame(Edge[2])&&(containE(F2,E)))
1881 trouve=Standard_True;
1882 }
1883 TopoDS_Vertex Vt,V3,V4;
1884 V1=TopExp::FirstVertex(Edge[2]);
1885 V2=TopExp::LastVertex(Edge[2]);
1886 if (V.IsSame(V1)) Vt=V2;
1887 else Vt=V1;
1888 dist1=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1889 V3=TopExp::FirstVertex(E);
1890 V4=TopExp::LastVertex(E);
1891 if (V.IsSame(V3)) Vt=V4;
1892 else Vt=V3;
1893 dist2=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1894 if (dist2<dist1) {
1895 Edge[2]=E;
1896 TopAbs_Orientation ori;
1897 if (V2.IsSame(V3)||V1.IsSame(V4)) ori=CV2.TransitionOnArc();
1898 else ori=TopAbs::Reverse(CV2.TransitionOnArc());
1899 Standard_Real par= BRep_Tool::Parameter(V,Edge[2]);
1900 Standard_Real tol= CV2.Tolerance();
1901 CV2.SetArc(tol,Edge[2],par,ori);
1902 }
1903 }
1904 if (!onecorner) {
81bba717 1905 // If there is a regular edge, the faces adjacent to it
1906 // are not in Fd->IndexOfS1 or Fd->IndexOfS2
7fd59977 1907
1908// TopoDS_Face Find1 ,Find2;
1909// if (isfirst)
1910// edge=stripe->Spine()->Edges(1);
1911// else edge=stripe->Spine()->Edges(stripe->Spine()->NbEdges());
1912// It3.Initialize(myEFMap(edge));
1913// Find1=TopoDS::Face(It3.Value());
1914// trouve=Standard_False;
1915// for (It3.Initialize(myEFMap(edge));It3.More()&&!trouve;It3.Next()) {
1916// F=TopoDS::Face (It3.Value());
1917// if (!F.IsSame(Find1)) {
1918// Find2=F;trouve=Standard_True;
1919// }
1920// }
1921
81bba717 1922 // if nface =3 there is a top with 3 edges and a fillet
1923 // and their common points are on different faces
1924 // otherwise there is a case when a top has more than 3 edges
7fd59977 1925
1926 if (nface==3) {
1927 if (CV1.IsVertex ()) findonf1=Standard_True;
1928 if (CV2.IsVertex ()) findonf2=Standard_True;
1929 if (!findonf1) {
1930 TopTools_IndexedMapOfShape MapV;
1931 TopExp::MapShapes(Edge[0], TopAbs_VERTEX, MapV);
1932 if (MapV.Extent()==2)
1933 if (!MapV(1).IsSame(Vtx) && !MapV(2).IsSame(Vtx))
1934 findonf1=Standard_True;
1935 }
1936 if (!findonf2) {
1937 TopTools_IndexedMapOfShape MapV;
1938 TopExp::MapShapes(Edge[2], TopAbs_VERTEX, MapV);
1939 if (MapV.Extent()==2)
1940 if (!MapV(1).IsSame(Vtx) && !MapV(2).IsSame(Vtx))
1941 findonf2=Standard_True;
1942 }
1943
1944 // detect and process OnSame situatuation
1945 if (state == ChFiDS_OnSame) {
1946 TopoDS_Edge threeE[3];
1947 ChFi3d_cherche_element(Vtx,EdgeSpine, F1,threeE[0], V2);
1948 ChFi3d_cherche_element(Vtx,EdgeSpine, F2,threeE[1], V2);
1949 threeE[2] = EdgeSpine;
1950 if (ChFi3d_EdgeState(threeE,myEFMap) == ChFiDS_OnSame) {
1951 isOnSame1 = Standard_True;
1952 nb = 1;
1953 Edge[0] = threeE[0];
1954 ChFi3d_cherche_face1(myEFMap(Edge[0]),F1,Face[0]);
1955 if (findonf2)
1956 findonf1 = Standard_True; // not to look for Face[0] again
1957 else
1958 Edge[1]=CV2.Arc();
1959 }
1960 else {
1961 isOnSame2 = Standard_True;
1962 }
1963 }
1964
81bba717 1965 // findonf1 findonf2 show if F1 and/or F2 are adjacent
1966 // to many faces at end
1967 // the faces at end and intersected edges are found
7fd59977 1968
1969 if (findonf1 && !isOnSame1) {
1970 if (CV1.TransitionOnArc()==TopAbs_FORWARD)
1971 V1=TopExp::FirstVertex(CV1.Arc());
1972 else
1973 V1=TopExp::LastVertex(CV1.Arc());
1974 ChFi3d_cherche_face1(myEFMap(CV1.Arc()),F1,Face[0]);
1975 nb=1;
1976 Ei=Edge[0];
1977 while (!V1.IsSame(Vtx)) {
1978 ChFi3d_cherche_element(V1,Ei,F1,E,V2);
1979 V1=V2; Ei=E;
1980 ChFi3d_cherche_face1(myEFMap(E),F1,Face[nb]);
1981 cherche_edge1(Face[nb-1],Face[nb],Edge[nb]);
1982 nb++;
1983 if (nb>=nn) Standard_Failure::Raise
81bba717 1984 ("IntersectionAtEnd : the max number of faces reached");
7fd59977 1985 }
1986 if (!findonf2) Edge[nb]=CV2.Arc();
1987 }
1988 if (findonf2 && !isOnSame2) {
1989 if (!findonf1 ) nb=1;
1990 V1=Vtx;
1991 if (CV2.TransitionOnArc()==TopAbs_FORWARD)
1992 Vfin=TopExp::LastVertex(CV2.Arc());
1993 else
1994 Vfin=TopExp::FirstVertex(CV2.Arc());
1995 if (!findonf1) ChFi3d_cherche_face1(myEFMap(CV1.Arc()),F1,Face[nb-1]);
1996 ChFi3d_cherche_element(V1,EdgeSpine,F2,E,V2);
1997 Ei=E;V1=V2;
1998 while (!V1.IsSame(Vfin)) {
1999 ChFi3d_cherche_element(V1,Ei,F2,E,V2);
2000 Ei=E;
2001 V1=V2;
2002 ChFi3d_cherche_face1(myEFMap(E),F2,Face[nb]);
2003 cherche_edge1(Face[nb-1],Face[nb],Edge[nb]);
2004 nb++;
2005 if (nb>=nn) Standard_Failure::Raise
81bba717 2006 ("IntersectionAtEnd : the max number of faces reached");
7fd59977 2007 }
2008 Edge[nb]=CV2.Arc();
2009 }
2010 if (isOnSame2) {
2011 cherche_edge1(Face[nb-1],F2,Edge[nb]);
2012 Face[nb] = F2;
2013 }
2014
2015 nbface=nb;
2016 }
2017
2018 else {
2019
81bba717 2020// this is the case when a top has more than three edges
2021// the faces and edges concerned are found
7fd59977 2022 Standard_Boolean /*trouve,*/possible1, possible2;
2023 trouve = possible1 = possible2 = Standard_False;
2024 TopExp_Explorer ex;
2025 nb=0;
2026 for (ex.Init(CV1.Arc(),TopAbs_VERTEX);ex.More();ex.Next()) {
2027 if (Vtx.IsSame(ex.Current())) possible1 = Standard_True;
2028 }
2029 for (ex.Init(CV2.Arc(),TopAbs_VERTEX);ex.More();ex.Next()) {
2030 if (Vtx.IsSame(ex.Current())) possible2 = Standard_True;
2031 }
2032 if ((possible1 && possible2) || (!possible1 && !possible2) || (nbarete > 4)) {
2033 while (!trouve) {
2034 nb++;
2035 if (nb!=1) F3=Face[nb-2];
2036 Face[nb-1]=F3;
2037 if (CV1.Arc().IsSame(edgelibre1))
2038 cherche_face(myVFMap(Vtx),edgelibre2,F1,F2,F3,Face[nb-1]);
2039 else if (CV1.Arc().IsSame(edgelibre2))
2040 cherche_face(myVFMap(Vtx),edgelibre1,F1,F2,F3,Face[nb-1]);
2041 else cherche_face(myVFMap(Vtx),Edge[nb-1],F1,F2,F3,Face[nb-1]);
2042 ChFi3d_cherche_edge(Vtx,tabedg,Face[nb-1],Edge[nb],V);
2043 tabedg.SetValue(nb,Edge[nb]);
2044 if (Edge[nb].IsSame(CV2.Arc())) trouve=Standard_True;
2045 }
2046 nbface=nb;
2047 }
2048 else {
2049 IntersectMoreCorner (Index);
2050 return;
2051 }
2052 if (nbarete==4) {
81bba717 2053 // if two consecutive edges are G1 there is only one face of intersection
7fd59977 2054 Standard_Real ang1=0.0;
2055 TopoDS_Vertex Vcom;
2056 trouve=Standard_False;
2057 ChFi3d_cherche_vertex ( Edge[0],Edge[1],Vcom,trouve);
2058 if (Vcom.IsSame(Vtx)) ang1=ChFi3d_AngleEdge(Vtx,Edge[0],Edge[1]);
c6541a0c 2059 if (Abs(ang1-M_PI)<0.01) {
7fd59977 2060 oneintersection1=Standard_True;
2061 facesau=Face[0];
2062 edgesau=Edge[1];
2063 Face[0]=Face[1];
2064 Edge[1]=Edge[2];
2065 nbface=1;
2066 }
2067
2068 if (!oneintersection1) {
2069 trouve=Standard_False;
2070 ChFi3d_cherche_vertex ( Edge[1],Edge[2],Vcom,trouve);
2071 if (Vcom.IsSame(Vtx)) ang1=ChFi3d_AngleEdge(Vtx,Edge[1],Edge[2]);
c6541a0c 2072 if (Abs(ang1-M_PI)<0.01) {
7fd59977 2073 oneintersection2=Standard_True;
2074 facesau=Face[1];
2075 edgesau=Edge[1];
2076 Edge[1]=Edge[2];
2077 nbface=1;
2078 }
2079 }
2080 }
2081 else if (nbarete==5) {
2082 //pro15368
2083// Modified by Sergey KHROMOV - Fri Dec 21 18:07:43 2001 End
2084 Standard_Boolean isTangent0 = isTangentFaces(Edge[0],F1,Face[0]);
2085 Standard_Boolean isTangent1 = isTangentFaces(Edge[1],Face[0],Face[1]);
2086 Standard_Boolean isTangent2 = isTangentFaces(Edge[2],Face[1],Face[2]);
2087 if ((isTangent0 || isTangent2) && isTangent1) {
2088// GeomAbs_Shape cont0,cont1,cont2;
2089// cont0=BRep_Tool::Continuity(Edge[0],F1,Face[0]);
2090// cont1=BRep_Tool::Continuity(Edge[1],Face[0],Face[1]);
2091// cont2=BRep_Tool::Continuity(Edge[2],Face[1],Face[2]);
2092// if ((cont0!=GeomAbs_C0 || cont2!=GeomAbs_C0) && cont1!=GeomAbs_C0) {
2093// Modified by Sergey KHROMOV - Fri Dec 21 18:07:49 2001 Begin
2094 facesau=Face[0];
2095 edgesau=Edge[0];
2096 nbface=1;
2097 Edge[1]=Edge[3];
2098 Face[0]=Face[2];
2099 oneintersection1=Standard_True;
2100 }
2101 }
2102 }
2103 }
2104 else {
2105 nbface=1;
2106 Face[0]=face;
2107 Edge[1]=Edge[2];
2108 }
2109
2110 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
2111 gp_Pnt2d pfil1,pfac1,pfil2,pfac2,pint,pfildeb;
2112 Handle(Geom2d_Curve) Hc1,Hc2;
2113 IntCurveSurface_HInter inters;
2114 Standard_Integer proledge[nn],prolface[nn+1];// last prolface[nn] is for Fd
2115 Standard_Integer shrink[nn];
2116 TopoDS_Face faceprol[nn];
2117 Standard_Integer indcurve[nn],indpoint2=0,indpoint1 = 0;
2118 Handle (TopOpeBRepDS_CurvePointInterference) Interfp1, Interfp2, Interfedge[nn];
2119 Handle (TopOpeBRepDS_SurfaceCurveInterference) Interfc,InterfPC[nn],InterfPS[nn];
2120 Standard_Real u2,v2,p1,p2,paredge1;
2121 Standard_Real paredge2 = 0.,tolex = 1.e-4;
2122 Standard_Boolean extend=Standard_False;
2123 Handle(Geom_Surface) Sfacemoins1,Sface;
2124 /***************************************************************************/
81bba717 2125 // calculate intersection of the fillet and each face
2126 // and storage in the DS
7fd59977 2127 /***************************************************************************/
2128 for (nb=1;nb<=nbface;nb++) {
2129 prolface[nb-1]=0;
2130 proledge[nb-1]=0;
2131 shrink [nb-1]=0;
2132 }
2133 proledge[nbface]=0;
2134 prolface[nn]=0;
2135 if (oneintersection1||oneintersection2) faceprol[1]=facesau;
2136 if (!isOnSame1 && !isOnSame2)
2137 checkShrink = Standard_False;
2138 // in OnSame situation we need intersect Fd with Edge[0] or Edge[nbface] as well
2139 if (isOnSame1) nb=0;
2140 else nb=1;
2141 Standard_Boolean intersOnSameFailed = Standard_False;
2142
2143 for ( ; nb<=nbface; nb++) {
2144 extend=Standard_False;
2145 E2=Edge[nb];
2146 if (!nb)
2147 F=F1;
2148 else {
2149 F=Face[nb-1];
2150 if (!prolface[nb-1]) faceprol[nb-1]=F;
2151 }
2152 Sfacemoins1=BRep_Tool::Surface(F);
2153 Handle(Geom_Curve) cint;
2154 Handle(Geom2d_Curve) C2dint1, C2dint2,cface,cfacemoins1;
2155
81bba717 2156 ///////////////////////////////////////////////////////
2157 // determine intersections of edges and the fillet
2158 // to find limitations of intersections face - fillet
2159 ///////////////////////////////////////////////////////
7fd59977 2160
2161 if (nb==1) {
2162 Hc1 = BRep_Tool::CurveOnSurface(Edge[0],Face[0],Ubid,Ubid);
2163 if (isOnSame1) {
2164 // update interference param on Fi1 and point of CV1
2165 if (prolface[0]) Bs.Initialize(faceprol[0], Standard_False);
2166 else Bs.Initialize(Face[0], Standard_False);
2167 const Handle(Geom_Curve)& c3df = DStr.Curve(Fi1.LineIndex()).Curve();
2168 Standard_Real Ufi= Fi2.Parameter(isfirst);
2169 ChFiDS_FaceInterference& Fi = Fd->ChangeInterferenceOnS1();
2170 if (!IntersUpdateOnSame (HGs,HBs,c3df,F1,Face[0],Edge[0],Vtx,isfirst,10*tolesp, // in
2171 Fi,CV1,pfac1,Ufi)) // out
2172 Standard_Failure::Raise("IntersectionAtEnd: pb intersection Face - Fi");
2173 Fi1 = Fi;
2174 if (intersOnSameFailed) { // probable at fillet building
2175 // look for paredge2
2176 Geom2dAPI_ProjectPointOnCurve proj;
2177 if (C2dint2.IsNull()) proj.Init(pfac1,Hc1);
2178 else proj.Init(pfac1,C2dint2);
2179 paredge2 = proj.LowerDistanceParameter();
2180 }
2181 // update stripe point
2182 TopOpeBRepDS_Point tpoint (CV1.Point(),tolesp);
2183 indpoint1=DStr.AddPoint(tpoint);
2184 stripe->SetIndexPoint(indpoint1,isfirst,1);
2185 // reset arc of CV1
2186 TopoDS_Vertex vert1,vert2;
2187 TopExp::Vertices(Edge[0],vert1,vert2);
2188 TopAbs_Orientation arcOri = Vtx.IsSame(vert1) ? TopAbs_FORWARD : TopAbs_REVERSED;
2189 CV1.SetArc(tolesp,Edge[0],paredge2,arcOri);
2190 }
2191 else {
2192 if (Hc1.IsNull()) {
81bba717 2193 // curve 2d not found. Sfacemoins1 is extended and projection is done there
7fd59977 2194 // CV1.Point ()
2195 ChFi3d_ExtendSurface(Sfacemoins1,prolface[0]);
2196 if (prolface[0]) {
2197 extend=Standard_True;
2198 BRep_Builder BRE;
2199 Standard_Real tol=BRep_Tool::Tolerance(F);
2200 BRE.MakeFace(faceprol[0],Sfacemoins1,F.Location(),tol);
2201 if (!isOnSame1) {
2202 GeomAdaptor_Surface Asurf;
2203 Asurf.Load(Sfacemoins1);
2204 Extrema_ExtPS ext (CV1.Point(),Asurf, tol,tol);
2205 Standard_Real uc1,vc1;
2206 if (ext.IsDone()) {
2207 ext.Point(1).Parameter(uc1,vc1);
2208 pfac1.SetX(uc1);
2209 pfac1.SetY(vc1);
2210 }
2211 }
2212 }
2213 }
2214 else
2215 pfac1 = Hc1->Value(CV1.ParameterOnArc());
2216 }
2217 paredge1=CV1.ParameterOnArc();
2218 if (Fi1.LineIndex() != 0) {
2219 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));}
2220 else {
2221 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));}
2222 pfildeb=pfil1;
2223 }
2224 else {
2225 pfil1=pfil2;
2226 paredge1=paredge2;
2227 pfac1=pint;
2228 }
2229
2230 if (nb!=nbface || isOnSame2) {
2231 Standard_Integer nbp;
2232
2233 Handle(Geom_Curve) C;
2234 C=BRep_Tool::Curve(E2,Ubid,Vbid);
2235 Handle(Geom_TrimmedCurve) Ctrim = new Geom_TrimmedCurve(C,Ubid,Vbid);
2236 Standard_Real Utrim,Vtrim;
2237 Utrim=Ctrim->BasisCurve()->FirstParameter();
2238 Vtrim=Ctrim->BasisCurve()->LastParameter();
2239 if (Ctrim->IsPeriodic()) {
2240 if (Ubid>Ctrim->Period()) {
2241 Ubid=(Utrim+Vtrim)/2;
2242 Vbid= Vtrim;
2243 }
2244 else {
2245 Ubid=Utrim;
2246 Vbid=(Utrim+Vtrim)/2;
2247 }
2248 }
2249 else {
2250 Ubid=Utrim;
2251 Vbid=Vtrim;
2252 }
2253 Handle(GeomAdaptor_HCurve) HC =
2254 new GeomAdaptor_HCurve(C,Ubid,Vbid);
2255 GeomAdaptor_Curve & Cad =HC->ChangeCurve();
2256 inters.Perform(HC, HGs);
2257 if ( !prolface[nn] && ( !inters.IsDone() || (inters.NbPoints()==0) )) {
2258 // extend surface of conge
2259 Handle(Geom_BSplineSurface) S1=
2260 Handle(Geom_BSplineSurface)::DownCast(DStr.Surface(Fd->Surf()).Surface());
2261 if (!S1.IsNull()) {
2262 Standard_Real length = 0.5 * Max(Fi1Length,Fi2Length);
2263 GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,!isfirst);
2264 prolface[nn] = 1;
2265 if (!stripe->IsInDS(!isfirst)) {
2266 Gs.Load(S1);
2267 inters.Perform(HC, HGs);
2268 if (inters.IsDone()&& inters.NbPoints()!=0) {
2269 Fd->ChangeSurf(DStr.AddSurface(TopOpeBRepDS_Surface(S1, DStr.ChangeSurface(Isurf).Tolerance())));
2270 Isurf=Fd->Surf();
2271 }
2272 }
2273 }
2274 }
2275 if (!inters.IsDone() || (inters.NbPoints()==0)) {
2276 Handle(Geom_BSplineCurve) cd=Handle(Geom_BSplineCurve)::DownCast(C);
2277 Handle(Geom_BezierCurve) cd1=Handle(Geom_BezierCurve)::DownCast(C);
2278 if (!cd.IsNull() || !cd1.IsNull() ) {
2279 BRep_Builder BRE;
2280 Sface=BRep_Tool::Surface(Face[nb]);
2281 ChFi3d_ExtendSurface(Sface,prolface[nb]);
2282 Standard_Real tol=BRep_Tool::Tolerance(F);
2283 BRE.MakeFace(faceprol[nb],Sface,Face[nb].Location(),tol);
2284 if (nb && !prolface[nb-1]) {
2285 ChFi3d_ExtendSurface(Sfacemoins1,prolface[nb-1]);
2286 if (prolface[nb-1]) {
2287 tol=BRep_Tool::Tolerance(F);
2288 BRE.MakeFace(faceprol[nb-1],Sfacemoins1,F.Location(),tol);
2289 }
2290 }
2291 else {
2292 Standard_Integer prol = 0;
2293 ChFi3d_ExtendSurface(Sfacemoins1,prol);
2294 }
2295 GeomInt_IntSS InterSS(Sfacemoins1,Sface,1.e-7,1,1,1);
2296 if (InterSS.IsDone()) {
2297 trouve=Standard_False;
2298 for (Standard_Integer i=1; i<=InterSS.NbLines() && !trouve; i++) {
2299 extend=Standard_True;
2300 cint= InterSS.Line(i);
2301 C2dint1= InterSS.LineOnS1(i);
2302 C2dint2= InterSS.LineOnS2(i);
2303 Cad.Load(cint);
2304 inters.Perform(HC, HGs);
2305 trouve=inters.IsDone()&&inters.NbPoints()!=0;
2306 // eap occ293, eval tolex on finally trimmed curves
2307// Handle(GeomAdaptor_HSurface) H1=new GeomAdaptor_HSurface(Sfacemoins1);
2308// Handle(GeomAdaptor_HSurface) H2=new GeomAdaptor_HSurface(Sface);
2309// tolex=ChFi3d_EvalTolReached(H1,C2dint1,H2,C2dint2,cint);
2310 tolex = InterSS.TolReached3d();
2311 }
2312 }
2313 }
2314 }
2315 if (inters.IsDone()) {
2316 nbp = inters.NbPoints();
2317 if (nbp==0) {
2318 if (nb==0 || nb==nbface)
2319 intersOnSameFailed = Standard_True;
2320 else {
2321 PerformMoreThreeCorner (Index,1);
2322 return;
2323 }
2324 }
2325 else {
2326 gp_Pnt P=BRep_Tool::Pnt(Vtx);
2327 Standard_Real distmin=P.Distance(inters.Point(1).Pnt());
2328 nbp=1;
2329 for (Standard_Integer i=2;i<=inters.NbPoints();i++) {
2330 dist=P.Distance(inters.Point(i).Pnt());
2331 if (dist<distmin) {
2332 distmin=dist;
2333 nbp=i;
2334 }
2335 }
2336 gp_Pnt2d pt2d (inters.Point(nbp).U(),inters.Point(nbp).V());
2337 pfil2=pt2d;
2338 paredge2=inters.Point(nbp).W();
2339 if (!extend) {
2340 cfacemoins1=BRep_Tool::CurveOnSurface(E2,F,u2,v2);
2341 cface=BRep_Tool::CurveOnSurface(E2,Face[nb],u2,v2);
2342 cfacemoins1->D0(paredge2,pfac2);
2343 cface->D0(paredge2,pint);
2344 }
2345 else {
2346 C2dint1->D0(paredge2,pfac2);
2347 C2dint2->D0(paredge2,pint);
2348 }
2349 }
2350 }
2351 else Standard_Failure::Raise("IntersectionAtEnd: pb intersection Face cb");
2352 }
2353 else {
2354 Hc2 = BRep_Tool::CurveOnSurface(E2,Face[nbface-1],Ubid,Ubid);
2355 if (Hc2.IsNull()) {
81bba717 2356 // curve 2d is not found, Sfacemoins1 is extended CV2.Point() is projected there
7fd59977 2357
2358 ChFi3d_ExtendSurface(Sfacemoins1,prolface[0]);
2359 if (prolface[0]) {
2360 BRep_Builder BRE;
2361 extend=Standard_True;
2362 Standard_Real tol=BRep_Tool::Tolerance(F);
2363 BRE.MakeFace(faceprol[nb-1],Sfacemoins1,F.Location(),tol);
2364 GeomAdaptor_Surface Asurf;
2365 Asurf.Load(Sfacemoins1);
2366 Extrema_ExtPS ext (CV2.Point(),Asurf,tol,tol);
2367 Standard_Real uc2,vc2;
2368 if (ext.IsDone()) {
2369 ext.Point(1).Parameter(uc2,vc2);
2370 pfac2.SetX(uc2);
2371 pfac2.SetY(vc2);
2372 }
2373 }
2374 }
2375 else pfac2 = Hc2->Value(CV2.ParameterOnArc());
2376 paredge2=CV2.ParameterOnArc();
2377 if (Fi2.LineIndex() != 0) {
2378 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
2379 }
2380 else {
2381 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
2382 }
2383 }
2384 if (!nb) continue; // found paredge1 on Edge[0] in OnSame situation on F1
2385
2386 if (nb==nbface && isOnSame2) {
2387 // update interference param on Fi2 and point of CV2
2388 if (prolface[nb-1]) Bs.Initialize(faceprol[nb-1]);
2389 else Bs.Initialize(Face[nb-1]);
2390 const Handle(Geom_Curve)& c3df = DStr.Curve(Fi2.LineIndex()).Curve();
2391 Standard_Real Ufi= Fi1.Parameter(isfirst);
2392 ChFiDS_FaceInterference& Fi = Fd->ChangeInterferenceOnS2();
2393 if (!IntersUpdateOnSame (HGs,HBs,c3df,F2,F,Edge[nb],Vtx,isfirst,10*tolesp, // in
2394 Fi,CV2,pfac2,Ufi)) // out
2395 Standard_Failure::Raise("IntersectionAtEnd: pb intersection Face - Fi");
2396 Fi2 = Fi;
2397 if (intersOnSameFailed) { // probable at fillet building
2398 // look for paredge2
2399 Geom2dAPI_ProjectPointOnCurve proj;
2400 if (extend)
2401 proj.Init(pfac2, C2dint2);
2402 else
2403 proj.Init(pfac2, BRep_Tool::CurveOnSurface (E2,Face[nbface-1],Ubid,Ubid));
2404 paredge2 = proj.LowerDistanceParameter();
2405 }
2406 // update stripe point
2407 TopOpeBRepDS_Point tpoint (CV2.Point(),tolesp);
2408 indpoint2=DStr.AddPoint(tpoint);
2409 stripe->SetIndexPoint(indpoint2,isfirst,2);
2410 // reset arc of CV2
2411 TopoDS_Vertex vert1,vert2;
2412 TopExp::Vertices(Edge[nbface],vert1,vert2);
2413 TopAbs_Orientation arcOri = Vtx.IsSame(vert1) ? TopAbs_FORWARD : TopAbs_REVERSED;
2414 CV2.SetArc(tolesp,Edge[nbface],paredge2,arcOri);
2415 }
2416
2417
2418 if (prolface[nb-1]) Bs.Initialize(faceprol[nb-1]);
2419 else Bs.Initialize(Face[nb-1]);
2420
81bba717 2421 // offset of parameters if they are not in the same period
7fd59977 2422
2423 // commented by eap 30 May 2002 occ354
2424 // the following code may cause trimming a wrong part of periodic surface
2425
2426// Standard_Real deb,xx1,xx2;
2427// Standard_Boolean moins2pi,moins2pi1,moins2pi2;
2428// if (DStr.Surface(Fd->Surf()).Surface()->IsUPeriodic()) {
2429// deb=pfildeb.X();
2430// xx1=pfil1.X();
2431// xx2=pfil2.X();
c6541a0c
D
2432// moins2pi=Abs(deb)< Abs(Abs(deb)-2*M_PI);
2433// moins2pi1=Abs(xx1)< Abs(Abs(xx1)-2*M_PI);
2434// moins2pi2=Abs(xx2)< Abs(Abs(xx2)-2*M_PI);
7fd59977 2435// if (moins2pi1!=moins2pi2) {
2436// if (moins2pi) {
c6541a0c
D
2437// if (!moins2pi1) xx1=xx1-2*M_PI;
2438// if (!moins2pi2) xx2=xx2-2*M_PI;
7fd59977 2439// }
2440// else {
c6541a0c
D
2441// if (moins2pi1) xx1=xx1+2*M_PI;
2442// if (moins2pi2) xx2=xx2+2*M_PI;
7fd59977 2443// }
2444// }
2445// pfil1.SetX(xx1);
2446// pfil2.SetX(xx2);
2447// }
2448// if (couture || Sfacemoins1->IsUPeriodic()) {
2449
2450// Standard_Real ufmin,ufmax,vfmin,vfmax;
2451// BRepTools::UVBounds(Face[nb-1],ufmin,ufmax,vfmin,vfmax);
2452// deb=ufmin;
2453// xx1=pfac1.X();
2454// xx2=pfac2.X();
c6541a0c
D
2455// moins2pi=Abs(deb)< Abs(Abs(deb)-2*M_PI);
2456// moins2pi1=Abs(xx1)< Abs(Abs(xx1)-2*M_PI);
2457// moins2pi2=Abs(xx2)< Abs(Abs(xx2)-2*M_PI);
7fd59977 2458// if (moins2pi1!=moins2pi2) {
2459// if (moins2pi) {
c6541a0c
D
2460// if (!moins2pi1) xx1=xx1-2*M_PI;
2461// if (!moins2pi2) xx2=xx2-2*M_PI;
7fd59977 2462// }
2463// else {
c6541a0c
D
2464// if (moins2pi1) xx1=xx1+2*M_PI;
2465// if (moins2pi2) xx2=xx2+2*M_PI;
7fd59977 2466// }
2467// }
2468// pfac1.SetX(xx1);
2469// pfac2.SetX(xx2);
2470// }
2471
2472 Pardeb(1)= pfil1.X();Pardeb(2) = pfil1.Y();
2473 Pardeb(3)= pfac1.X();Pardeb(4) = pfac1.Y();
2474 Parfin(1)= pfil2.X();Parfin(2) = pfil2.Y();
2475 Parfin(3)= pfac2.X();Parfin(4) = pfac2.Y();
2476
2477 Standard_Real uu1,uu2,vv1,vv2;
2478 ChFi3d_Boite(pfac1,pfac2,uu1,uu2,vv1,vv2);
2479 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
2480
2481
2482 //////////////////////////////////////////////////////////////////////
81bba717 2483 // calculate intersections face - fillet
7fd59977 2484 //////////////////////////////////////////////////////////////////////
2485
2486 if (!ChFi3d_ComputeCurves(HGs,HBs,Pardeb,Parfin,Cc,
2487 Ps,Pc,tolesp,tol2d,tolreached,nbface==1)) {
2488 PerformMoreThreeCorner (Index,1);
2489 return;
2490 }
81bba717 2491 // storage of information in the data structure
7fd59977 2492
81bba717 2493 // evaluate tolerances
7fd59977 2494 p1=Cc->FirstParameter();
2495 p2=Cc->LastParameter();
2496 Standard_Real to1,to2;
2497 gp_Pnt2d p2d1,p2d2;
2498 gp_Pnt P1,P2,P3,P4,P5,P6,P7,P8;
2499 HGs->D0(Pardeb(1),Pardeb(2),P1);
2500 HGs->D0(Parfin(1),Parfin(2),P2);
2501 HBs->D0(Pardeb(3),Pardeb(4),P3);
2502 HBs->D0(Parfin(3),Parfin(4),P4);
2503 Pc->D0(p1,p2d1);
2504 Pc->D0(p2,p2d2);
2505 HBs->D0(p2d1.X(),p2d1.Y(),P7);
2506 HBs->D0(p2d2.X(),p2d2.Y(),P8);
2507 Ps->D0(p1,p2d1);
2508 Ps->D0(p2,p2d2);
2509 HGs->D0(p2d1.X(),p2d1.Y(),P5);
2510 HGs->D0(p2d2.X(),p2d2.Y(),P6);
2511 to1 = Max (P1.Distance(P5)+P3.Distance(P7), tolreached);
2512 to2 = Max (P2.Distance(P6)+P4.Distance(P8), tolreached);
2513
2514
2515 //////////////////////////////////////////////////////////////////////
81bba717 2516 // storage in the DS of the intersection curve
7fd59977 2517 //////////////////////////////////////////////////////////////////////
2518
2519 Standard_Boolean Isvtx1=0;
2520 Standard_Boolean Isvtx2=0;
2521 Standard_Integer indice;
2522
2523 if (nb==1)
2524 {
2525 indpoint1 = stripe->IndexPoint(isfirst,1);
2526 if (!CV1.IsVertex()) {
2527 TopOpeBRepDS_Point& tpt= DStr.ChangePoint(indpoint1);
2528 tpt.Tolerance ( Max (tpt.Tolerance(), to1));
2529 }
2530 else Isvtx1=1;
2531 }
2532 if (nb==nbface)
2533 {
2534 indpoint2 = stripe->IndexPoint(isfirst,2);
2535 if (!CV2.IsVertex()) {
2536 TopOpeBRepDS_Point& tpt= DStr.ChangePoint(indpoint2);
2537 tpt.Tolerance ( Max (tpt.Tolerance(), to2));
2538 }
2539 else Isvtx2=1;
2540 }
2541 else
2542 {
2543 gp_Pnt point =Cc->Value(Cc->LastParameter());
2544 TopOpeBRepDS_Point tpoint (point,to2);
2545 indpoint2=DStr.AddPoint(tpoint);
2546 }
2547
2548 if (nb!=1)
2549 {
2550 TopOpeBRepDS_Point& tpt= DStr.ChangePoint(indpoint1);
2551 tpt.Tolerance ( Max (tpt.Tolerance(), to1));
2552 }
2553 TopOpeBRepDS_Curve tcurv3d( Cc,tolreached);
2554 indcurve[nb-1]= DStr.AddCurve(tcurv3d);
2555 Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurve[nb-1],
2556 indpoint1,Cc->FirstParameter(),Isvtx1);
2557 Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurve[nb-1],
2558 indpoint2,Cc->LastParameter(),Isvtx2);
2559
2560 DStr.ChangeCurveInterferences(indcurve[nb-1]).Append(Interfp1);
2561 DStr.ChangeCurveInterferences(indcurve[nb-1]).Append(Interfp2);
2562
2563 //////////////////////////////////////////////////////////////////////
81bba717 2564 // storage for the face
7fd59977 2565 //////////////////////////////////////////////////////////////////////
2566
7fd59977 2567 TopAbs_Orientation ori = TopAbs_FORWARD;
7fd59977 2568 orface=Face[nb-1].Orientation();
2569 if (orface==orsurfdata ) orien = TopAbs::Reverse(orcourbe);
2570 else orien = orcourbe ;
81bba717 2571 // limitation of edges of faces
7fd59977 2572 if (nb==1) {
2573 Standard_Integer Iarc1= DStr.AddShape(Edge[0]);
2574 Interfedge[0]= ChFi3d_FilPointInDS(CV1.TransitionOnArc(),Iarc1,
2575 indpoint1,paredge1,Isvtx1);
2576 //DStr.ChangeShapeInterferences(Edge[0]).Append(Interfp1);
2577 }
2578 if (nb==nbface) {
2579 Standard_Integer Iarc2= DStr.AddShape(Edge[nb]);
2580 Interfedge[nb]= ChFi3d_FilPointInDS(CV2.TransitionOnArc() ,Iarc2,
2581 indpoint2,paredge2,Isvtx2);
2582 //DStr.ChangeShapeInterferences(Edge[nb]).Append(Interfp2);
2583 }
2584
2585 if (nb!=nbface || oneintersection1 || oneintersection2) {
2586 if (nface==3) {
2587 V1= TopExp::FirstVertex(Edge[nb]);
2588 V2= TopExp::LastVertex(Edge[nb]);
2589 if (containV(F1,V1) || containV(F2,V1))
2590 ori=TopAbs_FORWARD;
2591 else if (containV(F1,V2) || containV(F2,V2))
2592 ori=TopAbs_REVERSED;
2593 else
2594 Standard_Failure::Raise("IntersectionAtEnd : pb orientation");
2595
2596 if (containV(F1,V1) && containV(F1,V2)) {
2597 dist1=(BRep_Tool::Pnt(V1)).Distance(BRep_Tool::Pnt(Vtx));
2598 dist2=(BRep_Tool::Pnt(V2)).Distance(BRep_Tool::Pnt(Vtx));
2599 if (dist1<dist2) ori=TopAbs_FORWARD;
2600 else ori=TopAbs_REVERSED;
2601 }
2602 if (containV(F2,V1) && containV(F2,V2)) {
2603 dist1=(BRep_Tool::Pnt(V1)).Distance(BRep_Tool::Pnt(Vtx));
2604 dist2=(BRep_Tool::Pnt(V2)).Distance(BRep_Tool::Pnt(Vtx));
2605 if (dist1<dist2) ori=TopAbs_FORWARD;
2606 else ori=TopAbs_REVERSED;
2607 }
2608 }
2609 else {
2610 if (TopExp::FirstVertex(Edge[nb]).IsSame(Vtx))
2611 ori= TopAbs_FORWARD;
2612 else ori=TopAbs_REVERSED;
2613 }
2614 if (!extend && !(oneintersection1 || oneintersection2)) {
2615 Standard_Integer Iarc2= DStr.AddShape(Edge[nb]);
2616 Interfedge[nb]= ChFi3d_FilPointInDS(ori,Iarc2,
2617 indpoint2,paredge2);
2618 // DStr.ChangeShapeInterferences(Edge[nb]).Append(Interfp2);
2619 }
2620 else {
2621 if (!(oneintersection1 || oneintersection2) ) proledge[nb]=Standard_True;
2622 Standard_Integer indp1,indp2,ind;
2623 gp_Pnt pext;
2624 Standard_Real ubid,vbid;
2625 pext=BRep_Tool::Pnt(Vtx);
2626 GeomAdaptor_Curve cad;
2627 Handle(Geom_Curve) csau;
2628 if ( ! (oneintersection1 || oneintersection2)) {
2629 cad.Load(cint);
2630 csau=cint;
2631 }
2632 else {
2633 csau=BRep_Tool::Curve(edgesau,ubid,vbid );
2634 Handle(Geom_BoundedCurve) C1=
2635 Handle(Geom_BoundedCurve)::DownCast(csau);
2636 if (oneintersection1&&extend) {
2637 if (!C1.IsNull()) {
2638 gp_Pnt Pl;
2639 Pl=C1->Value(C1->LastParameter());
2640 //Standard_Boolean sens;
2641 sens=Pl.Distance(pext)<tolpt;
2642 GeomLib::ExtendCurveToPoint(C1,CV1.Point(),1,sens);
2643 csau=C1;
2644 }
2645 }
2646 else if (oneintersection2&&extend) {
2647 if (!C1.IsNull()) {
2648 gp_Pnt Pl;
2649 Pl=C1->Value(C1->LastParameter());
2650 //Standard_Boolean sens;
2651 sens=Pl.Distance(pext)<tolpt;
2652 GeomLib::ExtendCurveToPoint(C1,CV2.Point(),1,sens);
2653 csau=C1;
2654 }
2655 }
2656 cad.Load(csau);
2657 }
2658 Extrema_ExtPC ext(pext,cad,tolpt);
2659 Standard_Real par1, par2, par, ParVtx;
2660 Standard_Boolean vtx1=Standard_False;
2661 Standard_Boolean vtx2=Standard_False;
2662 par1=ext.Point(1).Parameter();
2663 ParVtx = par1;
2664 if (oneintersection1 || oneintersection2 ) {
2665 if (oneintersection2) {
2666 pext=CV2.Point();
2667 ind=indpoint2;
2668 }
2669 else {
2670 pext=CV1.Point();
2671 ind=indpoint1;
2672 }
2673 Extrema_ExtPC ext2(pext,cad,tolpt);
2674 par2=ext2.Point(1).Parameter();
2675 }
2676 else {
2677 par2=paredge2;
2678 ind=indpoint2;
2679 }
2680 if (par1>par2) {
2681 indp1=ind;
2682 indp2=DStr.AddShape(Vtx);
2683 vtx2=Standard_True;
2684 par=par1;
2685 par1=par2;
2686 par2=par;
2687 }
2688 else {
2689 indp1=DStr.AddShape(Vtx);
2690 indp2=ind;
2691 vtx1=Standard_True;
2692 }
2693 Handle(Geom_Curve) Ct=new Geom_TrimmedCurve (csau,par1,par2);
2694 TopAbs_Orientation orient;
2695 Cc->D0(Cc->FirstParameter(),P1);
2696 Cc->D0(Cc->LastParameter(),P2);
2697 Ct->D0(Ct->FirstParameter(),P3);
2698 Ct->D0(Ct->LastParameter(),P4);
2699 if (P2.Distance(P3)<tolpt || P1.Distance(P4)<tolpt) orient=orien;
2700 else orient=TopAbs::Reverse(orien);
2701 if (oneintersection1||oneintersection2) {
2702 indice=DStr.AddShape(Face[0]);
2703 if (extend) {
2704 DStr.SetNewSurface(Face[0],Sfacemoins1);
2705 ComputeCurve2d(Ct,faceprol[0],C2dint1);
2706 }
2707 else
2708 {
2709 TopoDS_Edge aLocalEdge = edgesau;
2710 if (edgesau.Orientation() != orient)
2711 aLocalEdge.Reverse();
2712 C2dint1 = BRep_Tool::CurveOnSurface(aLocalEdge,Face[0],ubid,vbid);
2713 }
2714 }
2715 else {
2716 indice=DStr.AddShape(Face[nb-1]);
2717 DStr.SetNewSurface(Face[nb-1],Sfacemoins1);
2718 }
2719 //// for periodic 3d curves ////
2720 if (cad.IsPeriodic())
2721 {
2722 gp_Pnt2d P2d = BRep_Tool::Parameters( Vtx, Face[0] );
2723 Geom2dAPI_ProjectPointOnCurve Projector( P2d, C2dint1 );
2724 par = Projector.LowerDistanceParameter();
2725 Standard_Real shift = par-ParVtx;
2726 if (Abs(shift) > Precision::Confusion())
2727 {
2728 par1 += shift;
2729 par2 += shift;
2730 }
2731 }
2732 ////////////////////////////////
2733
2734 Ct=new Geom_TrimmedCurve (csau,par1,par2);
2735 if (oneintersection1||oneintersection2) tolex=10*BRep_Tool::Tolerance(edgesau);
2736 if (extend) {
2737 Handle(GeomAdaptor_HSurface) H1, H2;
2738 H1=new GeomAdaptor_HSurface(Sfacemoins1);
2739 if (Sface.IsNull())
2740 tolex = Max (tolex, ChFi3d_EvalTolReached(H1,C2dint1,H1,C2dint1,Ct));
2741 else {
2742 H2=new GeomAdaptor_HSurface(Sface);
2743 tolex = Max (tolex, ChFi3d_EvalTolReached(H1,C2dint1,H2,C2dint2,Ct));
2744 }
2745 }
2746 TopOpeBRepDS_Curve tcurv( Ct,tolex);
2747 Standard_Integer indcurv;
2748 indcurv=DStr.AddCurve(tcurv);
2749 Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurv,indp1,par1,vtx1);
2750 Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurv,indp2,par2,vtx2);
2751 DStr.ChangeCurveInterferences(indcurv).Append(Interfp1);
2752 DStr.ChangeCurveInterferences(indcurv).Append(Interfp2);
2753
2754 Interfc=ChFi3d_FilCurveInDS(indcurv,indice ,C2dint1,orient);
2755 DStr.ChangeShapeInterferences(indice).Append(Interfc);
2756 if (oneintersection1||oneintersection2) {
2757 indice=DStr.AddShape(facesau);
2758 if (facesau.Orientation()==Face[0].Orientation())
2759 orient=TopAbs::Reverse(orient);
2760 if (extend) {
2761 ComputeCurve2d(Ct,faceprol[1],C2dint2);
2762
2763 }
2764 else
2765 {
2766 TopoDS_Edge aLocalEdge = edgesau;
2767 if (edgesau.Orientation() != orient)
2768 aLocalEdge.Reverse();
2769 C2dint2 = BRep_Tool::CurveOnSurface(aLocalEdge,facesau,ubid,vbid);
2770 //Reverse for case of edgesau on closed surface (Face[0] is equal to facesau)
2771 }
2772 }
2773 else {
2774 indice=DStr.AddShape(Face[nb]);
2775 DStr.SetNewSurface(Face[nb],Sface);
2776 if (Face[nb].Orientation()==Face[nb-1].Orientation())
2777 orient= TopAbs::Reverse(orient);
2778 }
2779 if (!bordlibre) {
2780 Interfc=ChFi3d_FilCurveInDS(indcurv,indice,C2dint2,orient);
2781 DStr.ChangeShapeInterferences(indice).Append(Interfc);
2782 }
2783 }
2784 }
2785
2786 if (checkShrink &&
2787 IsShrink(Ps,p1,p2,checkShrParam,isUShrink,Precision::Parametric(tolreached)))
2788 {
2789 shrink [nb-1] = 1;
2790 // store section face-chamf curve for previous SurfData
2791 // Suppose Fd and SDprev are parametrized similarly
2792 if (!isShrink) { // first time
2793 const ChFiDS_FaceInterference& Fi = SDprev->InterferenceOnS1();
2794 gp_Pnt2d UV = Fi.PCurveOnSurf()->Value(Fi.Parameter(isfirst));
2795 prevSDParam = isUShrink ? UV.X() : UV.Y();
2796 }
2797 gp_Pnt2d UV1=p2d1,UV2=p2d2;
2798 UV1.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2799 UV2.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2800 Standard_Real aTolreached;
2801 ChFi3d_ComputePCurv(Cc,UV1,UV2,Ps,
2802 DStr.Surface(SDprev->Surf()).Surface(),
2803 p1,p2,tolesp,aTolreached);
2804 TopOpeBRepDS_Curve& TCurv = DStr.ChangeCurve(indcurve[nb-1]);
2805 TCurv.Tolerance(Max(TCurv.Tolerance(),aTolreached));
2806
2807 InterfPS[nb-1]=ChFi3d_FilCurveInDS(indcurve[nb-1],IsurfPrev,Ps,orcourbe);
2808 DStr.ChangeSurfaceInterferences(IsurfPrev).Append(InterfPS[nb-1]);
2809
2810 if (isOnSame2) {
2811 midP2d = p2d2;
2812 midIpoint = indpoint2;
2813 }
2814 else if (!isShrink) {
2815 midP2d = p2d1;
2816 midIpoint = indpoint1;
2817 }
2818 isShrink = Standard_True;
2819 } // end if shrink
2820
2821
2822 indice=DStr.AddShape(Face[nb-1]);
2823 InterfPC[nb-1]=ChFi3d_FilCurveInDS(indcurve[nb-1],indice ,Pc,orien);
2824 if (!shrink [nb-1])
2825 InterfPS[nb-1]=ChFi3d_FilCurveInDS(indcurve[nb-1],Isurf,Ps,orcourbe);
2826 indpoint1=indpoint2;
2827
2828 } // end loop on faces being intersected with ChFi
2829
2830
2831 if (isOnSame1) CV1.Reset();
2832 if (isOnSame2) CV2.Reset();
2833
2834 for(nb=1;nb<=nbface;nb++) {
2835 Standard_Integer indice=DStr.AddShape(Face[nb-1]);
2836 DStr.ChangeShapeInterferences(indice).Append(InterfPC[nb-1]);
2837 if (!shrink [nb-1])
2838 DStr.ChangeSurfaceInterferences(Isurf).Append(InterfPS[nb-1]);
2839 if (!proledge[nb-1])
2840 DStr.ChangeShapeInterferences(Edge[nb-1]).Append(Interfedge[nb-1]);
2841 }
2842 DStr.ChangeShapeInterferences(Edge[nbface]).Append(Interfedge[nbface]);
2843
2844 if (!isShrink)
2845 stripe->InDS(isfirst);
2846 else {
2847 // compute curves for !<isfirst> end of <Fd> and <isfirst> end of previous <SurfData>
2848
2849 // for Fd
2850 //Bnd_Box box;
2851 gp_Pnt2d UV, UV1 = midP2d, UV2 = midP2d;
2852 if (isOnSame1)
2853 UV = UV2 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
2854 else
2855 UV = UV1 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
2856 Standard_Real aTolreached;
2857 Handle(Geom_Curve) C3d;
2858 Handle(Geom_Surface) aSurf = DStr.Surface(Fd->Surf()).Surface();
2859 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2860
2861 ChFi3d_ComputeArete(CV1,UV1,CV2,UV2,aSurf, // in
2862 C3d,Ps,p1,p2,tolesp,tol2d,aTolreached,0); // out except tolers
2863
2864 indpoint1 = indpoint2 = midIpoint;
2865 gp_Pnt point;
2866 if (isOnSame1) {
2867 point = C3d->Value(p2);
2868 TopOpeBRepDS_Point tpoint (point,aTolreached);
2869 indpoint2=DStr.AddPoint(tpoint);
2870 UV = Ps->Value(p2);
2871 } else {
2872 point = C3d->Value(p1);
2873 TopOpeBRepDS_Point tpoint (point,aTolreached);
2874 indpoint1=DStr.AddPoint(tpoint);
2875 UV = Ps->Value(p1);
2876 }
2877 //box.Add(point);
2878 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2879
2880 TopOpeBRepDS_Curve Crv = TopOpeBRepDS_Curve(C3d,aTolreached);
2881 Standard_Integer Icurv = DStr.AddCurve(Crv);
2882 Interfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv,indpoint1,p1, Standard_False);
2883 Interfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv,indpoint2,p2, Standard_False);
2884 Interfc = ChFi3d_FilCurveInDS(Icurv,Isurf,Ps,orcourbe);
2885 DStr.ChangeCurveInterferences(Icurv).Append(Interfp1);
2886 DStr.ChangeCurveInterferences(Icurv).Append(Interfp2);
2887 DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc);
2888
2889 // for SDprev
2890 aSurf = DStr.Surface(SDprev->Surf()).Surface();
2891 UV1.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2892 UV2.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2893
2894 ChFi3d_ComputePCurv(C3d,UV1,UV2,Pc,aSurf,p1,p2,tolesp,aTolreached);
2895
2896 Crv.Tolerance(Max(Crv.Tolerance(),aTolreached));
2897 Interfc= ChFi3d_FilCurveInDS (Icurv,IsurfPrev,Pc,TopAbs::Reverse(orcourbe));
2898 DStr.ChangeSurfaceInterferences(IsurfPrev).Append(Interfc);
2899
2900 //UV = isOnSame1 ? UV2 : UV1;
2901 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2902 //UV = Ps->Value(isOnSame1 ? p2 : p1);
2903 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2904 //ChFi3d_SetPointTolerance(DStr,box, isOnSame1 ? indpoint2 : indpoint1);
2905
2906 // to process properly this case in ChFi3d_FilDS()
2907 stripe->InDS(isfirst, 2);
2908 Fd->ChangeInterference(isOnSame1 ? 2 : 1).SetLineIndex(0);
2909 ChFiDS_CommonPoint& CPprev1 = SDprev->ChangeVertex( isfirst,isOnSame1 ? 2 : 1);
2910 ChFiDS_CommonPoint& CPlast1 = Fd-> ChangeVertex( isfirst,isOnSame1 ? 2 : 1);
2911 ChFiDS_CommonPoint& CPlast2 = Fd-> ChangeVertex(!isfirst,isOnSame1 ? 2 : 1);
2912 if (CPprev1.IsOnArc()) {
2913 CPlast1 = CPprev1;
2914 CPprev1.Reset();
2915 CPprev1.SetPoint(CPlast1.Point());
2916 CPlast2.Reset();
2917 CPlast2.SetPoint(CPlast1.Point());
2918 }
2919
2920 // in shrink case, self intersection is possible at <midIpoint>,
2921 // eval its tolerance intersecting Ps and Pcurve at end.
2922 // Find end curves closest to shrinked part
2923 for (nb=0; nb < nbface; nb++)
2924 if (isOnSame1 ? shrink [nb+1] : !shrink [nb]) break;
2925 Handle(Geom_Curve) Cend = DStr.Curve(indcurve[nb]).Curve();
2926 Handle(Geom2d_Curve) PCend = InterfPS[nb]->PCurve();
2927 // point near which self intersection may occure
2928 TopOpeBRepDS_Point& Pds = DStr.ChangePoint(midIpoint);
2929 const gp_Pnt& Pvert = Pds.Point();
2930 Standard_Real tol = Pds.Tolerance();
2931
2932 Geom2dAdaptor_Curve PC1(Ps), PC2(PCend);
2933 Geom2dInt_GInter Intersector(PC1,PC2,Precision::PConfusion(),Precision::PConfusion());
2934 if (!Intersector.IsDone()) return;
2935 for (nb=1; nb <= Intersector.NbPoints(); nb++) {
2936 const IntRes2d_IntersectionPoint& ip = Intersector.Point(nb);
2937 gp_Pnt Pint = C3d->Value(ip.ParamOnFirst());
2938 tol = Max(tol, Pvert.Distance(Pint));
2939 Pint = Cend->Value(ip.ParamOnSecond());
2940 tol = Max(tol, Pvert.Distance(Pint));
2941 }
2942 for (nb=1; nb <= Intersector.NbSegments(); nb++) {
2943 const IntRes2d_IntersectionSegment& is = Intersector.Segment(nb);
2944 if (is.HasFirstPoint()) {
2945 const IntRes2d_IntersectionPoint& ip = is.FirstPoint();
2946 gp_Pnt Pint = C3d->Value(ip.ParamOnFirst());
2947 tol = Max(tol, Pvert.Distance(Pint));
2948 Pint = Cend->Value(ip.ParamOnSecond());
2949 tol = Max(tol, Pvert.Distance(Pint));
2950 }
2951 if (is.HasLastPoint()) {
2952 const IntRes2d_IntersectionPoint& ip = is.LastPoint();
2953 gp_Pnt Pint = C3d->Value(ip.ParamOnFirst());
2954 tol = Max(tol, Pvert.Distance(Pint));
2955 Pint = Cend->Value(ip.ParamOnSecond());
2956 tol = Max(tol, Pvert.Distance(Pint));
2957 }
2958 }
2959 Pds.Tolerance(tol);
2960 }
2961}
2962
2963// Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 Begin
2964
2965//=======================================================================
2966//function : PerformMoreSurfdata
81bba717 2967//purpose : determine intersections at end on several surfdata
7fd59977 2968//=======================================================================
2969void ChFi3d_Builder::PerformMoreSurfdata(const Standard_Integer Index)
2970{
2971 TopOpeBRepDS_DataStructure &DStr = myDS->ChangeDS();
2972 const ChFiDS_ListOfStripe &aLOfStripe = myVDataMap(Index);
2973 Handle(ChFiDS_Stripe) aStripe;
2974 Handle(ChFiDS_Spine) aSpine;
2975 Standard_Real aTol3d = 1.e-4;
2976
2977
2978 if (aLOfStripe.IsEmpty())
2979 return;
2980
2981 aStripe = aLOfStripe.First();
2982 aSpine = aStripe->Spine();
2983
2984 ChFiDS_SequenceOfSurfData &aSeqSurfData =
2985 aStripe->ChangeSetOfSurfData()->ChangeSequence();
2986 const TopoDS_Vertex &aVtx = myVDataMap.FindKey(Index);
2987 Standard_Integer aSens = 0;
2988 Standard_Integer anInd =
2989 ChFi3d_IndexOfSurfData(aVtx,aStripe,aSens);
2990 Standard_Boolean isFirst = (aSens == 1);
2991 Standard_Integer anIndPrev;
2992 Handle(ChFiDS_SurfData) aSurfData;
2993 ChFiDS_CommonPoint aCP1;
2994 ChFiDS_CommonPoint aCP2;
2995
2996 aSurfData = aSeqSurfData.Value(anInd);
2997
2998 aCP1 = aSurfData->Vertex(isFirst,1);
2999 aCP2 = aSurfData->Vertex(isFirst,2);
3000
3001 Handle(Geom_Surface) aSurfPrev;
3002 Handle(Geom_Surface) aSurf;
3003 TopoDS_Face aFace;
3004 TopoDS_Face aNeighborFace;
3005
3006 FindFace(aVtx, aCP1, aCP2, aFace);
3007 aSurfPrev = BRep_Tool::Surface(aFace);
3008
3009 if (aSens==1) anIndPrev=anInd+1;
3010 else anIndPrev=anInd-1;
3011
3012 TopoDS_Edge anArc1;
3013 TopoDS_Edge anArc2;
3014 TopTools_ListIteratorOfListOfShape anIter(myVEMap(aVtx));
3015 Standard_Boolean isFound = Standard_False;
3016
3017 for(; anIter.More() && !isFound; anIter.Next()) {
3018 anArc1 = TopoDS::Edge(anIter.Value());
3019
3020 if (containE(aFace, anArc1))
3021 isFound = Standard_True;
3022 }
3023
3024 isFound = Standard_False;
3025 anIter.Initialize(myVEMap(aVtx));
3026
3027 for(; anIter.More() && !isFound; anIter.Next()) {
3028 anArc2 = TopoDS::Edge(anIter.Value());
3029
3030 if (containE(aFace,anArc2) && !anArc2.IsSame(anArc1))
3031 isFound = Standard_True;
3032 }
3033
3034 // determination of common points aCP1onArc, aCP2onArc and aCP2NotonArc
3035 // aCP1onArc is the point on arc of index anInd
3036 // aCP2onArc is the point on arc of index anIndPrev
3037 // aCP2NotonArc is the point of index anIndPrev which is not on arc.
3038
3039 Standard_Boolean is1stCP1OnArc;
3040 Standard_Boolean is2ndCP1OnArc;
3041 ChFiDS_CommonPoint aCP1onArc;
3042 ChFiDS_CommonPoint aCP2onArc;
3043 ChFiDS_CommonPoint aCP2NotonArc;
3044
3045 aSurfData = aSeqSurfData.Value(anIndPrev);
3046 aCP1 = aSurfData->Vertex(isFirst,1);
3047 aCP2 = aSurfData->Vertex(isFirst,2);
3048
3049 if (aCP1.IsOnArc() &&
3050 (aCP1.Arc().IsSame(anArc1) || aCP1.Arc().IsSame(anArc2))) {
3051 aCP2onArc = aCP1;
3052 aCP2NotonArc = aCP2;
3053 is2ndCP1OnArc = Standard_True;
3054 } else if (aCP2.IsOnArc() &&
3055 (aCP2.Arc().IsSame(anArc1) || aCP2.Arc().IsSame(anArc2))) {
3056 aCP2onArc = aCP2;
3057 aCP2NotonArc = aCP1;
3058 is2ndCP1OnArc = Standard_False;
3059 } else
3060 return;
3061
3062 aSurfData = aSeqSurfData.Value(anInd);
3063 aCP1 = aSurfData->Vertex(isFirst,1);
3064 aCP2 = aSurfData->Vertex(isFirst,2);
3065
3066 if (aCP1.Point().Distance(aCP2onArc.Point()) <= aTol3d){
3067 aCP1onArc = aCP2;
3068 is1stCP1OnArc = Standard_False;
3069 }
3070 else {
3071 aCP1onArc = aCP1;
3072 is1stCP1OnArc = Standard_True;
3073 }
3074
3075 if (!aCP1onArc.IsOnArc())
3076 return;
3077
3078// determination of neighbor surface
3079 Standard_Integer indSurface;
3080 if (is1stCP1OnArc)
3081 indSurface = myListStripe.First()->SetOfSurfData()->Value(anInd)->IndexOfS1();
3082 else
3083 indSurface = myListStripe.First()->SetOfSurfData()->Value(anInd)->IndexOfS2();
3084
3085 aNeighborFace = TopoDS::Face(myDS->Shape(indSurface));
3086
3087// calculation of intersections
3088 Handle(Geom_Curve) aCracc;
3089 Handle(Geom2d_Curve) aPCurv1;
3090 Standard_Real aParf;
3091 Standard_Real aParl;
3092 Standard_Real aTolReached;
3093
3094 aSurfData = aSeqSurfData.Value(anInd);
3095
3096 if (isFirst)
3097 ChFi3d_ComputeArete(aSurfData->VertexLastOnS1(),
3098 aSurfData->InterferenceOnS1().PCurveOnSurf()->
3099 Value(aSurfData->InterferenceOnS1().LastParameter()),
3100 aSurfData->VertexLastOnS2(),
3101 aSurfData->InterferenceOnS2().PCurveOnSurf()->
3102 Value(aSurfData->InterferenceOnS2().LastParameter()),
3103 DStr.Surface(aSurfData->Surf()).Surface(),aCracc,aPCurv1,
3104 aParf,aParl,aTol3d,tol2d,aTolReached,0);
3105 else
3106 ChFi3d_ComputeArete(aSurfData->VertexFirstOnS1(),
3107 aSurfData->InterferenceOnS1().PCurveOnSurf()->
3108 Value(aSurfData->InterferenceOnS1().FirstParameter()),
3109 aSurfData->VertexFirstOnS2(),
3110 aSurfData->InterferenceOnS2().PCurveOnSurf()->
3111 Value(aSurfData->InterferenceOnS2().FirstParameter()),
3112 DStr.Surface(aSurfData->Surf()).Surface(),aCracc,aPCurv1,
3113 aParf,aParl,aTol3d,tol2d,aTolReached,0);
3114
3115// calculation of the index of the line on anInd.
3116// aPClineOnSurf is the pcurve on anInd.
3117// aPClineOnFace is the pcurve on face.
3118 ChFiDS_FaceInterference aFI;
3119
3120 if (is1stCP1OnArc)
3121 aFI = aSurfData->InterferenceOnS1();
3122 else
3123 aFI = aSurfData->InterferenceOnS2();
3124
3125 Handle(Geom_Curve) aCline;
3126 Handle(Geom2d_Curve) aPClineOnSurf;
3127 Handle(Geom2d_Curve) aPClineOnFace;
3128 Standard_Integer indLine;
3129
3130 indLine = aFI.LineIndex();
3131 aCline = DStr.Curve(aFI.LineIndex()).Curve();
3132 aPClineOnSurf = aFI.PCurveOnSurf();
3133 aPClineOnFace = aFI.PCurveOnFace();
3134
3135// intersection between the SurfData number anInd and the Face aFace.
3136// Obtaining of curves aCint1, aPCint11 and aPCint12.
3137 aSurf = DStr.Surface(aSurfData->Surf()).Surface();
3138
3139 GeomInt_IntSS anInterSS(aSurfPrev,aSurf,1.e-7,1,1,1);
3140 Handle(Geom_Curve) aCint1;
3141 Handle(Geom2d_Curve) aPCint11;
3142 Handle(Geom2d_Curve) aPCint12;
3143 Handle(GeomAdaptor_HSurface) H1 = new GeomAdaptor_HSurface(aSurfPrev);
3144 Handle(GeomAdaptor_HSurface) H2 = new GeomAdaptor_HSurface(aSurf);
3145 Standard_Real aTolex1=0.;
3146 Standard_Integer i;
3147 gp_Pnt aPext1;
3148 gp_Pnt aPext2;
3149 gp_Pnt aPext;
3150 Standard_Boolean isPextFound;
3151
3152
3153 if (!anInterSS.IsDone())
3154 return;
3155
3156 isFound = Standard_False;
3157
3158 for (i = 1; i <= anInterSS.NbLines() && !isFound; i++) {
3159 aCint1 = anInterSS.Line(i);
3160 aPCint11 = anInterSS.LineOnS1(i);
3161 aPCint12 = anInterSS.LineOnS2(i);
3162 aTolex1 = ChFi3d_EvalTolReached(H1, aPCint11, H2, aPCint12, aCint1);
3163
3164 aCint1->D0(aCint1->FirstParameter(), aPext1);
3165 aCint1->D0(aCint1->LastParameter(), aPext2);
3166
3167// Modified by skv - Mon Jun 7 18:38:57 2004 OCC5898 Begin
3168// if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d ||
3169// aPext2.Distance(aCP1onArc.Point()))
3170 if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d ||
3171 aPext2.Distance(aCP1onArc.Point()) <= aTol3d)
3172// Modified by skv - Mon Jun 7 18:38:58 2004 OCC5898 End
3173 isFound = Standard_True;
3174 }
3175
3176 if (!isFound)
3177 return;
3178
3179 if (aPext1.Distance(aCP2onArc.Point()) > aTol3d &&
3180 aPext1.Distance(aCP1onArc.Point()) > aTol3d) {
3181 aPext = aPext1;
3182 isPextFound = Standard_True;
3183 } else if (aPext2.Distance(aCP2onArc.Point()) > aTol3d &&
3184 aPext2.Distance(aCP1onArc.Point()) > aTol3d) {
3185 aPext = aPext2;
3186 isPextFound = Standard_True;
3187 } else {
3188 isPextFound = Standard_False;
3189 }
3190
3191
3192 Standard_Boolean isDoSecondSection = Standard_False;
3193 Standard_Real aPar=0.;
3194
3195 if (isPextFound) {
3196 GeomAdaptor_Curve aCad(aCracc);
3197 Extrema_ExtPC anExt(aPext, aCad, aTol3d);
3198
3199 if (!anExt.IsDone())
3200 return;
3201
3202 isFound = Standard_False;
3203 for (i = 1; i <= anExt.NbExt() && !isFound; i++) {
3204 if (anExt.IsMin(i)) {
3205 gp_Pnt aProjPnt = anExt.Point(i).Value();
3206
3207 if (aPext.Distance(aProjPnt) <= aTol3d) {
3208 aPar = anExt.Point(i).Parameter();
3209 isDoSecondSection = Standard_True;
3210 }
3211 }
3212 }
3213 }
3214
3215 Handle(Geom_Curve) aTrCracc;
3216 TopAbs_Orientation anOrSD1;
3217 TopAbs_Orientation anOrSD2;
3218 Standard_Integer indShape;
3219
3220 anOrSD1 = aSurfData->Orientation();
3221 aSurfData = aSeqSurfData.Value(anIndPrev);
3222 anOrSD2 = aSurfData->Orientation();
3223 aSurf = DStr.Surface(aSurfData->Surf()).Surface();
3224
3225// The following variables will be used if isDoSecondSection is true
3226 Handle(Geom_Curve) aCint2;
3227 Handle(Geom2d_Curve) aPCint21;
3228 Handle(Geom2d_Curve) aPCint22;
3229 Standard_Real aTolex2=0.;
3230
3231 if (isDoSecondSection) {
3232 Standard_Real aPar1;
3233
3234 aCracc->D0(aCracc->FirstParameter(), aPext1);
3235
3236 if (aPext1.Distance(aCP2NotonArc.Point()) <= aTol3d)
3237 aPar1 = aCracc->FirstParameter();
3238 else
3239 aPar1 = aCracc->LastParameter();
3240
3241 if (aPar1 < aPar)
3242 aTrCracc = new Geom_TrimmedCurve (aCracc, aPar1, aPar);
3243 else
3244 aTrCracc = new Geom_TrimmedCurve (aCracc, aPar, aPar1);
3245
3246// Second section
3247 GeomInt_IntSS anInterSS2(aSurfPrev,aSurf,1.e-7,1,1,1);
3248
3249 if (!anInterSS2.IsDone())
3250 return;
3251
3252 H1 = new GeomAdaptor_HSurface(aSurfPrev);
3253 H2 = new GeomAdaptor_HSurface(aSurf);
3254
3255 isFound = Standard_False;
3256
3257 for (i = 1; i <= anInterSS2.NbLines() && !isFound; i++) {
3258 aCint2 = anInterSS2.Line(i);
3259 aPCint21 = anInterSS2.LineOnS1(i);
3260 aPCint22 = anInterSS2.LineOnS2(i);
3261 aTolex2 = ChFi3d_EvalTolReached(H1, aPCint21, H2, aPCint22, aCint2);
3262
3263 aCint2->D0(aCint2->FirstParameter(), aPext1);
3264 aCint2->D0(aCint2->LastParameter(), aPext2);
3265
3266 if (aPext1.Distance(aCP2onArc.Point()) <= aTol3d ||
3267 aPext2.Distance(aCP2onArc.Point()) <= aTol3d)
3268 isFound = Standard_True;
3269 }
3270
3271 if (!isFound)
3272 return;
3273
3274 } else {
3275 aTrCracc = new Geom_TrimmedCurve(aCracc,
3276 aCracc->FirstParameter(),
3277 aCracc->LastParameter());
3278 }
3279
3280// Storage of the data structure
3281
3282// calculation of the orientation of line of surfdata number
3283// anIndPrev which contains aCP2onArc
3284
3285 Handle(Geom2d_Curve) aPCraccS = GeomProjLib::Curve2d(aTrCracc,aSurf);
3286
3287 if (is2ndCP1OnArc) {
3288 aFI = aSurfData->InterferenceOnS1();
3289 indShape = aSurfData->IndexOfS1();
3290 } else {
3291 aFI = aSurfData->InterferenceOnS2();
3292 indShape = aSurfData->IndexOfS2();
3293 }
3294
3295 if (indShape <= 0)
3296 return;
3297
3298
3299
3300 TopAbs_Orientation aCurOrient;
3301
3302 aCurOrient = DStr.Shape(indShape).Orientation();
3303 aCurOrient = TopAbs::Compose(aCurOrient, aSurfData->Orientation());
3304 aCurOrient = TopAbs::Compose(TopAbs::Reverse(aFI.Transition()), aCurOrient);
3305
3306
3307// Filling the data structure
3308 aSurfData = aSeqSurfData.Value(anInd);
3309
3310 TopOpeBRepDS_Point aPtCP1(aCP1onArc.Point(),aCP1onArc.Tolerance());
3311 Standard_Integer indCP1onArc = DStr.AddPoint(aPtCP1);
3312 Standard_Integer indSurf1 = aSurfData->Surf();
3313 Standard_Integer indArc1 = DStr.AddShape(aCP1onArc.Arc());
3314 Standard_Integer indSol = aStripe->SolidIndex();
3315
3316 Handle (TopOpeBRepDS_CurvePointInterference) anInterfp1;
3317 Handle (TopOpeBRepDS_CurvePointInterference) anInterfp2;
3318
3319 anInterfp1= ChFi3d_FilPointInDS(aCP1onArc.TransitionOnArc(), indArc1,
3320 indCP1onArc, aCP1onArc.ParameterOnArc());
3321 DStr.ChangeShapeInterferences(aCP1onArc.Arc()).Append(anInterfp1);
3322
3323 TopOpeBRepDS_ListOfInterference &SolidInterfs =
3324 DStr.ChangeShapeInterferences(indSol);
3325 Handle(TopOpeBRepDS_SolidSurfaceInterference) SSI =
3326 new TopOpeBRepDS_SolidSurfaceInterference
3327 (TopOpeBRepDS_Transition(anOrSD1),
3328 TopOpeBRepDS_SOLID, indSol,
3329 TopOpeBRepDS_SURFACE, indSurf1);
3330 SolidInterfs.Append(SSI);
3331
3332// deletion of Surface Data.
3333 aSeqSurfData.Remove(anInd);
3334
3335 if (!isFirst)
3336 anInd--;
3337
3338 aSurfData = aSeqSurfData.Value(anInd);
3339
3340// definition of indices of common points in Data Structure
3341
3342 Standard_Integer indCP2onArc;
3343 Standard_Integer indCP2NotonArc;
3344
3345 if (is2ndCP1OnArc) {
3346 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2onArc, DStr),isFirst,1);
3347 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2NotonArc,DStr),isFirst,2);
3348
3349 if (isFirst) {
3350 indCP2onArc = aStripe->IndexFirstPointOnS1();
3351 indCP2NotonArc = aStripe->IndexFirstPointOnS2();
3352 } else {
3353 indCP2onArc = aStripe->IndexLastPointOnS1();
3354 indCP2NotonArc = aStripe->IndexLastPointOnS2();
3355 }
3356 } else {
3357 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2onArc, DStr),isFirst,2);
3358 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2NotonArc,DStr),isFirst,1);
3359
3360 if (isFirst) {
3361 indCP2onArc = aStripe->IndexFirstPointOnS2();
3362 indCP2NotonArc = aStripe->IndexFirstPointOnS1();
3363 }
3364 else {
3365 indCP2onArc = aStripe->IndexLastPointOnS2();
3366 indCP2NotonArc = aStripe->IndexLastPointOnS1();
3367 }
3368 }
3369
3370 Standard_Integer indPoint1;
3371 Standard_Integer indPoint2;
3372 gp_Pnt aPoint1;
3373 gp_Pnt aPoint2;
3374
3375 if (is2ndCP1OnArc) {
3376 aFI = aSurfData->InterferenceOnS1();
3377 indShape = aSurfData->IndexOfS1();
3378 } else {
3379 aFI = aSurfData->InterferenceOnS2();
3380 indShape = aSurfData->IndexOfS2();
3381 }
3382
3383 gp_Pnt2d aP2d;
3384 Handle (TopOpeBRepDS_SurfaceCurveInterference) anInterfc;
3385 TopAbs_Orientation anOrSurf = aCurOrient;
3386 TopAbs_Orientation anOrFace = aFace.Orientation();
3387 Standard_Integer indaFace = DStr.AddShape(aFace);
3388 Standard_Integer indPoint = indCP2onArc;
3389 Standard_Integer indCurve;
3390
3391 aFI.PCurveOnFace()->D0(aFI.LastParameter(), aP2d);
3392 Handle(Geom_Surface) Stemp2 =
3393 BRep_Tool::Surface(TopoDS::Face(DStr.Shape(indShape)));
3394 Stemp2->D0(aP2d.X(), aP2d.Y(), aPoint2);
3395 aFI.PCurveOnFace()->D0(aFI.FirstParameter(), aP2d);
3396 Stemp2->D0(aP2d.X(), aP2d.Y(), aPoint1);
3397
3398 if (isDoSecondSection) {
3399 TopOpeBRepDS_Point tpoint(aPext, aTolex2);
3400 TopOpeBRepDS_Curve tcint2(aCint2, aTolex2);
3401
3402 indPoint = DStr.AddPoint(tpoint);
3403 indCurve = DStr.AddCurve(tcint2);
3404
3405 aCint2->D0(aCint2->FirstParameter(), aPext1);
3406 aCint2->D0(aCint2->LastParameter(), aPext2);
3407
3408 if (aPext1.Distance(aPext) <= aTol3d){
3409 indPoint1 = indPoint;
3410 indPoint2 = indCP2onArc;
3411 } else {
3412 indPoint1 = indCP2onArc;
3413 indPoint2 = indPoint;
3414 }
3415
3416// define the orientation of aCint2
3417 if (aPext1.Distance(aPoint2) > aTol3d && aPext2.Distance(aPoint1) > aTol3d)
3418 anOrSurf = TopAbs::Reverse(anOrSurf);
3419
3420// ---------------------------------------------------------------
3421// storage of aCint2
3422 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD, indCurve,
3423 indPoint1, aCint2->FirstParameter());
3424 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED, indCurve,
3425 indPoint2, aCint2->LastParameter());
3426 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3427 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3428
3429 // interference of aCint2 on the SurfData number anIndPrev
3430 anInterfc = ChFi3d_FilCurveInDS(indCurve, aSurfData->Surf(),
3431 aPCint22, anOrSurf);
3432
3433 DStr.ChangeSurfaceInterferences(aSurfData->Surf()).Append(anInterfc);
3434 // interference of aCint2 on aFace
3435
3436 if (anOrFace == anOrSD2)
3437 anOrFace = TopAbs::Reverse(anOrSurf);
3438 else
3439 anOrFace = anOrSurf;
3440
3441 anInterfc = ChFi3d_FilCurveInDS(indCurve, indaFace, aPCint21, anOrFace);
3442 DStr.ChangeShapeInterferences(indaFace).Append(anInterfc);
3443 }
3444
3445 aTrCracc->D0(aTrCracc->FirstParameter(), aPext1);
3446 aTrCracc->D0(aTrCracc->LastParameter(), aPext2);
3447 if (aPext1.Distance(aCP2NotonArc.Point()) <= aTol3d){
3448 indPoint1 = indCP2NotonArc;
3449 indPoint2 = indPoint;
3450 } else {
3451 indPoint1 = indPoint;
3452 indPoint2 = indCP2NotonArc;
3453 }
3454
3455// Define the orientation of aTrCracc
3456 Standard_Boolean isToReverse;
3457 gp_Pnt aP1;
3458 gp_Pnt aP2;
3459 gp_Pnt aP3;
3460 gp_Pnt aP4;
3461
3462
3463 if (isDoSecondSection) {
3464 aTrCracc->D0(aTrCracc->FirstParameter(), aP1);
3465 aTrCracc->D0(aTrCracc->LastParameter(), aP2);
3466 aCint2->D0(aCint2->FirstParameter(), aP3);
3467 aCint2->D0(aCint2->LastParameter(), aP4);
3468 isToReverse = (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d);
3469 } else {
3470 isToReverse = (aPext1.Distance(aPoint2) > aTol3d &&
3471 aPext2.Distance(aPoint1) > aTol3d);
3472 }
3473
3474 if (isToReverse)
3475 anOrSurf = TopAbs::Reverse(anOrSurf);
3476
3477// ---------------------------------------------------------------
3478// storage of aTrCracc
3479 TopOpeBRepDS_Curve tct2(aTrCracc, aTolReached);
3480
3481 indCurve = DStr.AddCurve(tct2);
3482 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,indCurve,
3483 indPoint1, aTrCracc->FirstParameter());
3484 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED,indCurve,
3485 indPoint2, aTrCracc->LastParameter());
3486 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3487 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3488
3489 // interference of aTrCracc on the SurfData number anIndPrev
3490
3491 anInterfc = ChFi3d_FilCurveInDS(indCurve,aSurfData->Surf(),aPCraccS, anOrSurf);
3492 DStr.ChangeSurfaceInterferences(aSurfData->Surf()).Append(anInterfc);
3493 aStripe->InDS(isFirst);
3494
3495 // interference of aTrCracc on the SurfData number anInd
3496 if (anOrSD1 == anOrSD2)
3497 anOrSurf = TopAbs::Reverse(anOrSurf);
3498
3499 anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPCurv1, anOrSurf);
3500 DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc);
3501
3502// ---------------------------------------------------------------
3503// storage of aCint1
3504
3505 aCint1->D0(aCint1->FirstParameter(),aPext1);
3506 if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d){
3507 indPoint1 = indCP1onArc;
3508 indPoint2 = indPoint;
3509 } else {
3510 indPoint1 = indPoint;
3511 indPoint2 = indCP1onArc;
3512 }
3513
3514 // definition of the orientation of aCint1
3515
3516 aCint1->D0(aCint1->FirstParameter(), aP1);
3517 aCint1->D0(aCint1->LastParameter(), aP2);
3518 aTrCracc->D0(aTrCracc->FirstParameter(), aP3);
3519 aTrCracc->D0(aTrCracc->LastParameter(), aP4);
3520
3521 if (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d)
3522 anOrSurf=TopAbs::Reverse(anOrSurf);
3523
3524 TopOpeBRepDS_Curve aTCint1(aCint1, aTolex1);
3525 indCurve= DStr.AddCurve(aTCint1);
3526 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD, indCurve,
3527 indPoint1, aCint1->FirstParameter());
3528 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED, indCurve,
3529 indPoint2, aCint1->LastParameter());
3530 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3531 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3532
3533 // interference of aCint1 on the SurfData number anInd
3534
3535 anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPCint12, anOrSurf);
3536 DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc);
3537
3538 // interference of aCint1 on aFace
3539
3540 anOrFace = aFace.Orientation();
3541
3542 if (anOrFace == anOrSD1)
3543 anOrFace = TopAbs::Reverse(anOrSurf);
3544 else
3545 anOrFace = anOrSurf;
3546
3547 anInterfc = ChFi3d_FilCurveInDS(indCurve, indaFace, aPCint11, anOrFace);
3548 DStr.ChangeShapeInterferences(indaFace).Append(anInterfc);
3549// ---------------------------------------------------------------
3550// storage of aCline passing through aCP1onArc and aCP2NotonArc
3551
3552 Handle(Geom_Curve) aTrCline =
3553 new Geom_TrimmedCurve(aCline, aCline->FirstParameter(),
3554 aCline->LastParameter());
3555 Standard_Real aTolerance = DStr.Curve(indLine).Tolerance();
3556 TopOpeBRepDS_Curve aTct3(aTrCline, aTolerance);
3557
3558 indCurve = DStr.AddCurve(aTct3);
3559
3560 aTrCline->D0(aTrCline->FirstParameter(),aPext1);
3561
3562 if (aPext1.Distance(aCP1onArc.Point()) < aTol3d) {
3563 indPoint1 = indCP1onArc;
3564 indPoint2 = indCP2NotonArc;
3565 } else {
3566 indPoint1 = indCP2NotonArc;
3567 indPoint2 = indCP1onArc;
3568 }
3569 // definition of the orientation of aTrCline
3570
3571 aTrCline->D0(aTrCline->FirstParameter(), aP1);
3572 aTrCline->D0(aTrCline->LastParameter(), aP2);
3573 aCint1->D0(aCint1->FirstParameter(), aP3);
3574 aCint1->D0(aCint1->LastParameter(), aP4);
3575
3576 if (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d)
3577 anOrSurf = TopAbs::Reverse(anOrSurf);
3578
3579 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,indCurve,
3580 indPoint1,aTrCline->FirstParameter());
3581 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED,indCurve,
3582 indPoint2,aTrCline->LastParameter());
3583 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3584 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3585
3586 // interference of aTrCline on the SurfData number anInd
3587
3588 anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPClineOnSurf, anOrSurf);
3589 DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc);
3590
3591 // interference de ctlin par rapport a Fvoisin
3592 indShape = DStr.AddShape(aNeighborFace);
3593 anOrFace = aNeighborFace.Orientation();
3594
3595 if (anOrFace == anOrSD1)
3596 anOrFace = TopAbs::Reverse(anOrSurf);
3597 else
3598 anOrFace = anOrSurf;
3599
3600 anInterfc = ChFi3d_FilCurveInDS(indCurve, indShape, aPClineOnFace, anOrFace);
3601 DStr.ChangeShapeInterferences(indShape).Append(anInterfc);
3602}
3603// Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 End
3604
81bba717 3605//==============================================================
7fd59977 3606//function : FindFace
81bba717 3607//purpose : attention it works only if there is only one common face
3608// between P1,P2,V
7fd59977 3609//===========================================================
3610
3611
3612Standard_Boolean ChFi3d_Builder::FindFace(const TopoDS_Vertex& V,
3613 const ChFiDS_CommonPoint& P1,
3614 const ChFiDS_CommonPoint& P2,
3615 TopoDS_Face& Fv) const
3616{
3617 TopoDS_Face Favoid;
3618 return FindFace(V,P1,P2,Fv,Favoid);
3619}
3620
3621Standard_Boolean ChFi3d_Builder::FindFace(const TopoDS_Vertex& V,
3622 const ChFiDS_CommonPoint& P1,
3623 const ChFiDS_CommonPoint& P2,
3624 TopoDS_Face& Fv,
3625 const TopoDS_Face& Favoid) const
3626{
3627 if (P1.IsVertex() || P2.IsVertex()) {
0797d9d3 3628#ifdef OCCT_DEBUG
81bba717 3629 cout<<"change of face on vertex"<<endl;
7fd59977 3630#endif
3631 }
3632 if (!(P1.IsOnArc() && P2.IsOnArc())) {
3633 return Standard_False;
3634 }
3635 TopTools_ListIteratorOfListOfShape It,Jt;
96a95605 3636 Standard_Boolean Found = Standard_False;
7fd59977 3637 for(It.Initialize(myEFMap(P1.Arc()));It.More() && !Found;It.Next()) {
3638 Fv = TopoDS::Face(It.Value());
3639 if(!Fv.IsSame(Favoid)){
3640 for(Jt.Initialize(myEFMap(P2.Arc()));Jt.More() && !Found ;Jt.Next()) {
3641 if (TopoDS::Face(Jt.Value()).IsSame(Fv)) Found = Standard_True;
3642 }
3643 }
3644 }
0797d9d3 3645#ifdef OCCT_DEBUG
96a95605 3646 Standard_Boolean ContainsV = Standard_False;
7fd59977 3647 if (Found) {
3648 for(It.Initialize(myVFMap(V));It.More();It.Next()) {
3649 if (TopoDS::Face(It.Value()).IsSame(Fv)) {
3650 ContainsV = Standard_True;
3651 break;
3652 }
3653 }
3654 }
7fd59977 3655 if(!ContainsV){
81bba717 3656 cout<<"FindFace : the extremity of the spine is not in the end face"<<endl;
7fd59977 3657 }
96a95605
DB
3658#else
3659 (void)V; // avoid compiler warning on unused variable
7fd59977 3660#endif
3661 return Found;
3662}
3663
3664//=======================================================================
3665//function : MoreSurfdata
81bba717 3666//purpose : detects if the intersection at end concerns several Surfdata
7fd59977 3667//=======================================================================
3668Standard_Boolean ChFi3d_Builder::MoreSurfdata(const Standard_Integer Index) const
3669{
81bba717 3670 // intersection at end is created on several surfdata if :
3671 // - the number of surfdata concerning the vertex is more than 1.
3672 // - and if the last but one surfdata has one of commonpoints on one of
3673 // two arcs, which constitute the intersections of the face at end and of the fillet
7fd59977 3674
3675 ChFiDS_ListIteratorOfListOfStripe It;
3676 It.Initialize(myVDataMap(Index));
3677 Handle(ChFiDS_Stripe)& stripe = It.Value();
3678 ChFiDS_SequenceOfSurfData& SeqFil =
3679 stripe->ChangeSetOfSurfData()->ChangeSequence();
3680 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
3681 Standard_Integer sens = 0;
3682 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
3683 Standard_Boolean isfirst = (sens == 1);
3684 Handle(ChFiDS_SurfData)& Fd = SeqFil.ChangeValue(num);
3685 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
3686 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
3687
3688 Standard_Integer num1,num2,nbsurf;
3689 TopoDS_Face Fv;
3690 Standard_Boolean inters,oksurf;
3691 nbsurf= stripe->SetOfSurfData()->Length();
81bba717 3692 // Fv is the face at end
7fd59977 3693 inters = FindFace(Vtx,CV1,CV2,Fv);
3694 if (sens==1) {
3695 num1=1;
3696 num2=num1+1;
3697 }
3698 else {
3699 num1=nbsurf;
3700 num2=num1-1;
3701 }
3702
3703 oksurf=Standard_False;
3704
3705 if (nbsurf!=1 && inters) {
3706
81bba717 3707 // determination of arc1 and arc2 intersection of the fillet and the face at end
7fd59977 3708
3709 TopoDS_Edge arc1,arc2;
3710 TopTools_ListIteratorOfListOfShape ItE;
3711 Standard_Boolean trouve=Standard_False;
3712 for(ItE.Initialize(myVEMap(Vtx));ItE.More()&&!trouve;ItE.Next()) {
3713 arc1=TopoDS::Edge(ItE.Value());
3714 if (containE(Fv,arc1)) trouve=Standard_True;
3715 }
3716 trouve=Standard_False;
3717 for(ItE.Initialize(myVEMap(Vtx));ItE.More()&&!trouve;ItE.Next()) {
3718 arc2=TopoDS::Edge(ItE.Value());
3719 if (containE(Fv,arc2)&& !arc2.IsSame(arc1)) trouve=Standard_True;
3720 }
3721
3722 Handle(ChFiDS_SurfData) Fd1 = SeqFil.ChangeValue(num2);
3723 ChFiDS_CommonPoint& CV3 = Fd1->ChangeVertex(isfirst,1);
3724 ChFiDS_CommonPoint& CV4 = Fd1->ChangeVertex(isfirst,2);
3725
3726 if (CV3.IsOnArc()) {
3727 if (CV3.Arc().IsSame(arc1) ){
3728 if (CV1.Point().Distance(CV3.Point())<1.e-4)
3729 oksurf=Standard_True;
3730 }
3731 else if (CV3.Arc().IsSame(arc2)){
3732 if (CV2.Point().Distance(CV3.Point())<1.e-4)
3733 oksurf=Standard_True;
3734 }
3735 }
3736
3737 if (CV4.IsOnArc()) {
3738 if (CV1.Point().Distance(CV4.Point())<1.e-4)
3739 oksurf=Standard_True;
3740 else if (CV4.Arc().IsSame(arc2)){
3741 if (CV2.Point().Distance(CV4.Point())<1.e-4)
3742 oksurf=Standard_True;
3743 }
3744 }
3745 }
3746 return oksurf;
3747}
3748
3749
81bba717 3750//Case of fillets on top with 4 edges, one of them is on the same geometry as the edgeof the fillet
7fd59977 3751
3752
3753void ChFi3d_Builder::IntersectMoreCorner(const Standard_Integer Index)
3754{
3755 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
3756
0797d9d3 3757#ifdef OCCT_DEBUG
7fd59977 3758 OSD_Chronometer ch;// init perf pour PerformSetOfKPart
3759#endif
81bba717 3760 // The fillet is returned,
7fd59977 3761 ChFiDS_ListIteratorOfListOfStripe StrIt;
3762 StrIt.Initialize(myVDataMap(Index));
3763 Handle(ChFiDS_Stripe) stripe = StrIt.Value();
3764 const Handle(ChFiDS_Spine) spine = stripe->Spine();
3765 ChFiDS_SequenceOfSurfData& SeqFil =
3766 stripe->ChangeSetOfSurfData()->ChangeSequence();
81bba717 3767 // the top,
7fd59977 3768 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
81bba717 3769 // the SurfData concerned and its CommonPoints,
7fd59977 3770 Standard_Integer sens = 0;
3771
81bba717 3772 // Choose the proper SurfData
7fd59977 3773 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
3774 Standard_Boolean isfirst = (sens == 1);
3775 if (isfirst) {
3776 for (; num<SeqFil.Length() && (
3777 (SeqFil.Value(num)->IndexOfS1()==0) ||
3778 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
81bba717 3779 SeqFil.Remove(num); // The surplus is removed
7fd59977 3780 }
3781 }
3782 else {
3783 for (; num>1 && (
3784 (SeqFil.Value(num)->IndexOfS1()==0) ||
3785 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
81bba717 3786 SeqFil.Remove(num);// The surplus is removed
7fd59977 3787 num--;
3788 }
3789 }
3790
3791 Handle(ChFiDS_SurfData)& Fd = SeqFil.ChangeValue(num);
3792 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
3793 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
81bba717 3794 //To evaluate the cloud of new points.
7fd59977 3795 Bnd_Box box1,box2;
3796
81bba717 3797 // The cases of cap are processed separately from intersection.
7fd59977 3798 // ----------------------------------------------------------
3799
3800 TopoDS_Face Fv,Fad,Fop,Fopbis;
3801 TopoDS_Edge Arcpiv,Arcprol,Arcspine,Arcprolbis;
3802 if(isfirst) Arcspine = spine->Edges(1);
3803 else Arcspine = spine->Edges(spine->NbEdges());
1d47d8d0 3804 TopAbs_Orientation OArcprolbis = TopAbs_FORWARD;
7fd59977 3805 TopAbs_Orientation OArcprolv = TopAbs_FORWARD, OArcprolop = TopAbs_FORWARD;
7fd59977 3806 Standard_Integer ICurve;
3807 Handle(BRepAdaptor_HSurface) HBs = new BRepAdaptor_HSurface();
3808 Handle(BRepAdaptor_HSurface) HBad = new BRepAdaptor_HSurface();
3809 Handle(BRepAdaptor_HSurface) HBop = new BRepAdaptor_HSurface();
3810 BRepAdaptor_Surface& Bs = HBs->ChangeSurface();
3811 BRepAdaptor_Surface& Bad = HBad->ChangeSurface();
3812 BRepAdaptor_Surface& Bop = HBop->ChangeSurface();
3813 Handle(Geom_Curve) Cc;
3814 Handle(Geom2d_Curve) Pc,Ps;
3815 Standard_Real Ubid,Vbid;//,mu,Mu,mv,Mv;
7fd59977 3816 Standard_Real Udeb = 0.,Ufin = 0.;
7fd59977 3817 //gp_Pnt2d UVf1,UVl1,UVf2,UVl2;
3818 //Standard_Real Du,Dv,Step;
3819 Standard_Boolean inters = Standard_True;
3820 Standard_Integer IFadArc = 1, IFopArc = 2;
3821 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
3822 TopExp_Explorer ex;
3823
0797d9d3 3824#ifdef OCCT_DEBUG
7fd59977 3825 ChFi3d_InitChron(ch); // init perf condition
3826#endif
3827 {
3828 if(!CV1.IsOnArc() && !CV2.IsOnArc())
3829 Standard_Failure::Raise("Corner intersmore : no point on arc");
3830 else if(CV1.IsOnArc() && CV2.IsOnArc()){
96a95605 3831 Standard_Boolean sur2 = 0;
7fd59977 3832 for(ex.Init(CV1.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()){
3833 if(Vtx.IsSame(ex.Current())) {
7fd59977 3834 break;
3835 }
3836 }
3837 for(ex.Init(CV2.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()){
3838 if(Vtx.IsSame(ex.Current())){
3839 sur2 = 1;
3840 break;
3841 }
3842 }
3843 if(sur2) IFadArc = 2;
3844 }
3845 else if(CV2.IsOnArc()) IFadArc = 2;
3846 IFopArc = 3-IFadArc;
3847
3848 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
3849 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
3850 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
3851 TopTools_ListIteratorOfListOfShape It;
81bba717 3852 // The face at end is returned without control of its unicity.
7fd59977 3853 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
3854 if(!Fad.IsSame(It.Value())){
3855 Fv = TopoDS::Face(It.Value());
3856 break;
3857 }
3858 }
3859
81bba717 3860 // does the face at end contain the Vertex ?
7fd59977 3861 Standard_Boolean isinface = Standard_False;
3862 for (ex.Init(Fv,TopAbs_VERTEX); ex.More(); ex.Next()){
3863 if (ex.Current().IsSame(Vtx)) {
3864 isinface = Standard_True;
3865 break;
3866 }
3867 }
3868 if (!isinface) {
3869 IFadArc = 3-IFadArc;
3870 IFopArc = 3-IFopArc;
3871 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
3872 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
3873 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
3874 //TopTools_ListIteratorOfListOfShape It;
81bba717 3875 // The face at end is returned without control of its unicity.
3876 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
7fd59977 3877 if(!Fad.IsSame(It.Value())){
3878 Fv = TopoDS::Face(It.Value());
3879 break;
3880 }
3881 }
3882 }
3883
3884 if(Fv.IsNull()) StdFail_NotDone::Raise
81bba717 3885 ("OneCorner : face at end is not found");
7fd59977 3886
3887 Fv.Orientation(TopAbs_FORWARD);
3888 Fad.Orientation(TopAbs_FORWARD);
3889
81bba717 3890 // In the same way the edge to be extended is returned.
7fd59977 3891 for(It.Initialize(myVEMap(Vtx));It.More() && Arcprol.IsNull();It.Next()){
3892 if(!Arcpiv.IsSame(It.Value())){
3893 for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()){
3894 if(It.Value().IsSame(ex.Current())) {
3895 Arcprol = TopoDS::Edge(It.Value());
3896 OArcprolv = ex.Current().Orientation();
3897 break;
3898 }
3899 }
3900 }
3901 }
3902
81bba717 3903 //Fopbis is the face containing the trace of fillet CP.Arc() which of does not contain Vtx.
3904 //Normallly Fobis is either the same as Fop (cylinder), or Fobis is G1 with Fop.
7fd59977 3905 Fopbis.Orientation(TopAbs_FORWARD);
3906
81bba717 3907 //Fop calls the 4th face non-used for the vertex
7fd59977 3908 cherche_face(myVFMap(Vtx),Arcprol,Fad,Fv,Fv,Fopbis);
3909 Fop.Orientation(TopAbs_FORWARD);
3910
3911 if(Arcprol.IsNull()) StdFail_NotDone::Raise
81bba717 3912 ("OneCorner : edge to be extended is not found");
7fd59977 3913 for(ex.Init(Fopbis,TopAbs_EDGE); ex.More(); ex.Next()){
3914 if(Arcprol.IsSame(ex.Current())) {
3915 OArcprolop = ex.Current().Orientation();
3916 break;
3917 }
3918 }
3919 TopoDS_Face FFv;
3920 Standard_Real tol;
3921 Standard_Integer prol;
3922 BRep_Builder BRE;
3923 Handle(Geom_Surface ) Sface;
3924 Sface=BRep_Tool::Surface(Fv);
3925 ChFi3d_ExtendSurface(Sface,prol);
3926 tol=BRep_Tool::Tolerance(Fv);
3927 BRE.MakeFace(FFv,Sface,tol);
3928 if (prol) {
3929 Bs.Initialize(FFv,Standard_False);
3930 DStr.SetNewSurface(Fv,Sface);
3931 }
3932 else Bs.Initialize(Fv,Standard_False);
3933 Bad.Initialize(Fad);
3934 Bop.Initialize(Fop);
3935 }
81bba717 3936 // it is necessary to modify the CommonPoint
3937 // in the space and its parameter in FaceInterference.
3938 // So both of them are returned in references
3939 // non const. Attention the modifications are done behind
3940 // CV1,CV2,Fi1,Fi2.
7fd59977 3941 ChFiDS_CommonPoint& CPopArc = Fd->ChangeVertex(isfirst,IFopArc);
3942 ChFiDS_FaceInterference& FiopArc = Fd->ChangeInterference(IFopArc);
3943 ChFiDS_CommonPoint& CPadArc = Fd->ChangeVertex(isfirst,IFadArc);
3944 ChFiDS_FaceInterference& FiadArc = Fd->ChangeInterference(IFadArc);
81bba717 3945 // the parameter of the vertex is initialized with the value
3946 // of its opposing vertex (point on arc).
7fd59977 3947 Standard_Real wop = Fd->ChangeInterference(IFadArc).Parameter(isfirst);
3948 Handle(Geom_Curve) c3df;
3949 Handle(GeomAdaptor_HSurface)
3950 HGs = new GeomAdaptor_HSurface(DStr.Surface(Fd->Surf()).Surface());
3951 gp_Pnt2d p2dbout;
3952 {
3953
81bba717 3954 // add here more or less restrictive criteria to
3955 // decide if the intersection with face is done at the
3956 // extended end or if there will be a cap on sharp end.
7fd59977 3957 c3df = DStr.Curve(FiopArc.LineIndex()).Curve();
3958 Standard_Real uf = FiopArc.FirstParameter();
3959 Standard_Real ul = FiopArc.LastParameter();
3960 Handle(GeomAdaptor_HCurve) Hc3df;
3961 if(c3df->IsPeriodic()){
3962 Hc3df = new GeomAdaptor_HCurve(c3df);
3963 }
3964 else{
3965 Hc3df = new GeomAdaptor_HCurve(c3df,uf,ul);
3966 }
3967 inters = Update(HBs,Hc3df,FiopArc,CPopArc,p2dbout,isfirst,wop);
3968// Modified by Sergey KHROMOV - Fri Dec 21 18:08:27 2001 Begin
3969// if(!inters && BRep_Tool::Continuity(Arcprol,Fv,Fop) != GeomAbs_C0){
3970 if(!inters && isTangentFaces(Arcprol,Fv,Fop)){
3971// Modified by Sergey KHROMOV - Fri Dec 21 18:08:29 2001 End
81bba717 3972 // Arcprol is an edge of tangency, ultimate adjustment by an extrema curve/curve is attempted.
7fd59977 3973 Standard_Real ff,ll;
3974 Handle(Geom2d_Curve) gpcprol = BRep_Tool::CurveOnSurface(Arcprol,Fv,ff,ll);
3975 Handle(Geom2dAdaptor_HCurve) pcprol = new Geom2dAdaptor_HCurve(gpcprol);
3976 Standard_Real partemp = BRep_Tool::Parameter(Vtx,Arcprol);
3977 inters = Update(HBs,pcprol,HGs,FiopArc,CPopArc,p2dbout,
3978 isfirst,partemp,wop,10*tolesp);
3979 }
3980 Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
3981 pced->ChangeCurve2d().Initialize(CPadArc.Arc(),Fv);
3982 Update(HBs,pced,HGs,FiadArc,CPadArc,isfirst);
3983 }
0797d9d3 3984#ifdef OCCT_DEBUG
7fd59977 3985 ChFi3d_ResultChron(ch,t_same); // result perf condition if (same)
3986 ChFi3d_InitChron(ch); // init perf condition if (inters)
3987#endif
3988
3989 TopoDS_Edge edgecouture;
3990 Standard_Boolean couture,intcouture=Standard_False;;
1d47d8d0 3991 Standard_Real tolreached = tolesp;
7fd59977 3992 Standard_Real par1 = 0.,par2 = 0.;
3993 Standard_Integer indpt =0,Icurv1 =0,Icurv2 =0;
7fd59977 3994 Handle(Geom_TrimmedCurve) curv1,curv2;
3995 Handle(Geom2d_Curve) c2d1,c2d2;
3996
3997 Standard_Integer Isurf=Fd->Surf();
3998
3999 if (inters){
4000 HGs = ChFi3d_BoundSurf(DStr,Fd,1,2);
4001 const ChFiDS_FaceInterference& Fi1 = Fd->InterferenceOnS1();
4002 const ChFiDS_FaceInterference& Fi2 = Fd->InterferenceOnS2();
4003 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
4004 gp_Pnt2d pfil1,pfac1,pfil2,pfac2;
4005 Handle(Geom2d_Curve) Hc1,Hc2;
4006 if( IFopArc == 1) pfac1 = p2dbout;
4007 else {
4008 Hc1 = BRep_Tool::CurveOnSurface(CV1.Arc(),Fv,Ubid,Ubid);
4009 pfac1 = Hc1->Value(CV1.ParameterOnArc());
4010 }
4011 if(IFopArc == 2) pfac2 = p2dbout;
4012 else {
4013 Hc2 = BRep_Tool::CurveOnSurface(CV2.Arc(),Fv,Ubid,Ubid);
4014 pfac2 = Hc2->Value(CV2.ParameterOnArc());
4015 }
4016 if(Fi1.LineIndex() != 0){
4017 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));
4018 }
4019 else{
4020 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
4021 }
4022 if(Fi2.LineIndex() != 0){
4023 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
4024 }
4025 else{
4026 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
4027 }
4028 ChFi3d_Recale(Bs,pfac1,pfac2,(IFadArc == 1));
4029 Pardeb(1)= pfil1.X();Pardeb(2) = pfil1.Y();
4030 Pardeb(3)= pfac1.X();Pardeb(4) = pfac1.Y();
4031 Parfin(1)= pfil2.X();Parfin(2) = pfil2.Y();
4032 Parfin(3)= pfac2.X();Parfin(4) = pfac2.Y();
4033 Standard_Real uu1,uu2,vv1,vv2;
4034 ChFi3d_Boite(pfac1,pfac2,uu1,uu2,vv1,vv2);
4035 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
4036
4037 if (!ChFi3d_ComputeCurves(HGs,HBs,Pardeb,Parfin,Cc,
4038 Ps,
4039 Pc,tolesp,tol2d,tolreached))
81bba717 4040 Standard_Failure::Raise("OneCorner : failed calculation intersection");
7fd59977 4041
4042 Udeb = Cc->FirstParameter();
4043 Ufin = Cc->LastParameter();
4044
81bba717 4045 // check if the curve has an intersection with sewing edge
7fd59977 4046
4047 ChFi3d_Couture(Fv,couture,edgecouture);
4048
4049 if (couture && !BRep_Tool::Degenerated(edgecouture)) {
4050
4051 //Standard_Real Ubid,Vbid;
4052 Handle (Geom_Curve) C=BRep_Tool::Curve(edgecouture,Ubid,Vbid);
4053 Handle(Geom_TrimmedCurve) Ctrim=new Geom_TrimmedCurve (C,Ubid,Vbid);
4054 GeomAdaptor_Curve cur1(Ctrim->BasisCurve());
4055 GeomAdaptor_Curve cur2(Cc);
4056 Extrema_ExtCC extCC (cur1,cur2);
4057 if (extCC.IsDone()&&extCC.NbExt()!=0)
4058 {
4059 Standard_Integer imin=0;
4060 Standard_Real dist2min = RealLast();
4061 for (Standard_Integer i = 1; i <= extCC.NbExt(); i++)
4062 if (extCC.SquareDistance(i) < dist2min)
4063 {
4064 dist2min = extCC.SquareDistance(i);
4065 imin = i;
4066 }
08cd2f6b 4067 if (dist2min <= Precision::SquareConfusion())
7fd59977 4068 {
4069 Extrema_POnCurv ponc1,ponc2;
4070 extCC.Points( imin, ponc1, ponc2 );
4071 par1 = ponc1.Parameter();
4072 par2 = ponc2.Parameter();
4073 Standard_Real Tol = 1.e-4;
4074 if (Abs(par2-Udeb) > Tol && Abs(Ufin-par2) > Tol)
4075 {
4076 gp_Pnt P1=ponc1.Value();
4077 TopOpeBRepDS_Point tpoint( P1, Tol );
4078 indpt = DStr.AddPoint(tpoint);
4079 intcouture = Standard_True;
4080 curv1 = new Geom_TrimmedCurve(Cc,Udeb,par2);
4081 curv2 = new Geom_TrimmedCurve(Cc,par2,Ufin);
4082 TopOpeBRepDS_Curve tcurv1(curv1,tolreached);
4083 TopOpeBRepDS_Curve tcurv2(curv2,tolreached);
4084 Icurv1=DStr.AddCurve(tcurv1);
4085 Icurv2=DStr.AddCurve(tcurv2);
4086 }
4087 }
4088 }
4089 }
4090 }
4091
4092 else{
81bba717 4093 Standard_NotImplemented::Raise("OneCorner : cap not written");
7fd59977 4094 }
4095 Standard_Integer IShape = DStr.AddShape(Fv);
7fd59977 4096 TopAbs_Orientation Et = TopAbs_FORWARD;
7fd59977 4097 if(IFadArc == 1){
4098 TopExp_Explorer Exp;
4099 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
4100 TopAbs_EDGE);Exp.More();Exp.Next()) {
4101 if (Exp.Current().IsSame(CV1.Arc())) {
4102 Et = TopAbs::Reverse(TopAbs::Compose
4103 (Exp.Current().Orientation(),
4104 CV1.TransitionOnArc()));
4105 break;
4106 }
4107 }
4108 }
4109 else{
4110 TopExp_Explorer Exp;
4111 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
4112 TopAbs_EDGE);Exp.More();Exp.Next()) {
4113 if (Exp.Current().IsSame(CV2.Arc())) {
4114 Et = TopAbs::Compose(Exp.Current().Orientation(),
4115 CV2.TransitionOnArc());
4116 break;
4117 }
4118 }
4119
4120//
4121
4122
4123 }
4124
0797d9d3 4125#ifdef OCCT_DEBUG
7fd59977 4126 ChFi3d_ResultChron(ch ,t_inter); //result perf condition if (inter)
4127 ChFi3d_InitChron(ch); // init perf condition if ( inters)
4128#endif
4129
4130 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV1,DStr),isfirst,1);
4131 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV2,DStr),isfirst,2);
4132
4133 if (!intcouture) {
81bba717 4134// there is no intersection with edge of sewing
4135// curve Cc is stored in the stripe
4136// the storage in the DS is done by FILDS.
7fd59977 4137
4138 TopOpeBRepDS_Curve Tc(Cc,tolreached);
4139 ICurve = DStr.AddCurve(Tc);
4140 Handle(TopOpeBRepDS_SurfaceCurveInterference)
4141 Interfc = ChFi3d_FilCurveInDS(ICurve,IShape,Pc,Et);
4142 DStr.ChangeShapeInterferences(IShape).Append(Interfc);
4143 stripe->ChangePCurve(isfirst)=Ps;
4144 stripe->SetCurve(ICurve,isfirst);
4145 stripe->SetParameters(isfirst,Udeb,Ufin);
4146 }
4147 else {
81bba717 4148// curves curv1 and curv2 are stored in the DS
4149// these curves are not reconstructed by FILDS as
4150// stripe->InDS(isfirst) is placed;
7fd59977 4151
81bba717 4152 // interferences of curv1 and curv2 on Fv
7fd59977 4153 ComputeCurve2d(curv1,Fv,c2d1);
4154 Handle(TopOpeBRepDS_SurfaceCurveInterference) InterFv;
4155 InterFv = ChFi3d_FilCurveInDS(Icurv1,IShape,c2d1,Et);
4156 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
4157 ComputeCurve2d(curv2,Fv,c2d2);
4158 InterFv = ChFi3d_FilCurveInDS(Icurv2,IShape,c2d2,Et);
4159 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
81bba717 4160 // interferences of curv1 and curv2 on Isurf
7fd59977 4161 if (Fd->Orientation()== Fv.Orientation()) Et=TopAbs::Reverse(Et);
4162 c2d1=new Geom2d_TrimmedCurve(Ps,Udeb,par2);
4163 InterFv = ChFi3d_FilCurveInDS(Icurv1,Isurf,c2d1,Et);
4164 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
4165 c2d2=new Geom2d_TrimmedCurve(Ps,par2,Ufin);
4166 InterFv = ChFi3d_FilCurveInDS(Icurv2,Isurf,c2d2,Et);
4167 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
4168
81bba717 4169 // limitation of the sewing edge
7fd59977 4170 Standard_Integer Iarc=DStr.AddShape(edgecouture);
4171 Handle(TopOpeBRepDS_CurvePointInterference) Interfedge;
4172 TopAbs_Orientation ori;
4173 TopoDS_Vertex Vdeb,Vfin;
4174 Vdeb=TopExp::FirstVertex(edgecouture);
4175 Vfin=TopExp::LastVertex(edgecouture);
4176 Standard_Real pard,parf;
4177 pard=BRep_Tool::Parameter(Vdeb,edgecouture);
4178 parf=BRep_Tool::Parameter(Vfin,edgecouture);
4179 if (Abs(par1-pard)<Abs(parf-par1)) ori=TopAbs_FORWARD;
4180 else ori=TopAbs_REVERSED;
4181 Interfedge = ChFi3d_FilPointInDS(ori,Iarc,indpt,par1);
4182 DStr.ChangeShapeInterferences(Iarc).Append(Interfedge);
4183
81bba717 4184 // creation of CurveInterferences from Icurv1 and Icurv2
7fd59977 4185 stripe->InDS(isfirst);
4186 Standard_Integer ind1= stripe->IndexPoint(isfirst,1);
4187 Standard_Integer ind2= stripe->IndexPoint(isfirst,2);
4188 Handle(TopOpeBRepDS_CurvePointInterference)
4189 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv1,ind1,Udeb);
4190 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
4191 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv1,indpt,par2);
4192 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
4193 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv2,indpt,par2);
4194 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
4195 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv2,ind2,Ufin);
4196 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
4197
4198 }
4199
4200 ChFi3d_EnlargeBox(HBs,Pc,Udeb,Ufin,box1,box2);
4201
4202 if( inters){
4203//
4204
81bba717 4205 // The small end of curve missing for the extension
4206 // of the face at end and the limitation of the opposing face is added.
7fd59977 4207
81bba717 4208 // Above all the points cut the points with the edge of the spine.
7fd59977 4209 Standard_Integer IArcspine = DStr.AddShape(Arcspine);
4210 Standard_Integer IVtx = DStr.AddShape(Vtx);
1d47d8d0 4211 TopAbs_Orientation OVtx2 = TopAbs_FORWARD;
7fd59977 4212 TopAbs_Orientation OVtx = TopAbs_FORWARD;
7fd59977 4213 for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
4214 ex.More(); ex.Next()){
4215 if(Vtx.IsSame(ex.Current())) {
4216 OVtx = ex.Current().Orientation();
4217 break;
4218 }
4219 }
4220 OVtx = TopAbs::Reverse(OVtx);
4221 Standard_Real parVtx = BRep_Tool::Parameter(Vtx,Arcspine);
4222 Handle(TopOpeBRepDS_CurvePointInterference)
4223 interfv = ChFi3d_FilVertexInDS(OVtx,IArcspine,IVtx,parVtx);
4224 DStr.ChangeShapeInterferences(IArcspine).Append(interfv);
4225
4226
81bba717 4227 //Modif of lvt to find the suite of Arcprol in the other face
7fd59977 4228 {
4229 TopTools_ListIteratorOfListOfShape It;
4230 for (It.Initialize(myVEMap(Vtx)); It.More(); It.Next()){
4231 if (!(Arcprol.IsSame(It.Value()) ||
4232 Arcspine.IsSame(It.Value()) ||
4233 Arcpiv.IsSame(It.Value()))) {
4234 Arcprolbis = TopoDS::Edge(It.Value());
4235 break;
4236 }
4237 }
4238 }
81bba717 4239 //end of modif
7fd59977 4240
81bba717 4241 //Now the missing curves are constructed.
7fd59977 4242 for(ex.Init(Arcprolbis.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
4243 ex.More(); ex.Next()){
4244 if(Vtx.IsSame(ex.Current())) {
4245 OVtx2 = ex.Current().Orientation();
4246 break;
4247 }
4248 }
4249 for(ex.Init(Arcprol.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
4250 ex.More(); ex.Next()){
4251 if(Vtx.IsSame(ex.Current())) {
4252 OVtx = ex.Current().Orientation();
4253 break;
4254 }
4255 }
81bba717 4256// it is checked if Fop has a sewing edge
7fd59977 4257
4258// TopoDS_Edge edgecouture;
4259// Standard_Boolean couture;
4260 ChFi3d_Couture(Fop,couture,edgecouture);
4261 Handle(Geom2d_Curve) Hc;
4262// parVtx = BRep_Tool::Parameter(Vtx,Arcprol);
4263 const ChFiDS_FaceInterference& Fiop = Fd->Interference(IFopArc);
4264 gp_Pnt2d pop1, pop2, pv1, pv2;
4265 //deb modif
4266 parVtx = BRep_Tool::Parameter(Vtx,Arcprolbis);
4267// Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 Begin
4268// if(Fop.IsSame(Fopbis)) OArcprolbis = OArcprolop;
4269// else OArcprolbis = Arcprolbis.Orientation();
4270 if(Fop.IsSame(Fopbis)) {
4271 OArcprolbis = OArcprolop;
4272 } else {
4273 for(ex.Init(Fop,TopAbs_EDGE); ex.More(); ex.Next()){
4274 if(Arcprolbis.IsSame(ex.Current())) {
4275 OArcprolbis = ex.Current().Orientation();
4276 break;
4277 }
4278 }
4279 }
4280// Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 End
4281 //fin modif
4282 Hc = BRep_Tool::CurveOnSurface(Arcprolbis,Fop,Ubid,Ubid);
4283 pop1 = Hc->Value(parVtx);
4284 pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst));
4285 Hc = BRep_Tool::CurveOnSurface(Arcprol,Fv,Ubid,Ubid);
4286 //modif
4287 parVtx = BRep_Tool::Parameter(Vtx,Arcprol);
4288 //fin modif
4289 pv1 = Hc->Value(parVtx);
4290 pv2 = p2dbout;
4291 ChFi3d_Recale(Bs,pv1,pv2,1);
4292 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
4293 Pardeb(1) = pop1.X(); Pardeb(2) = pop1.Y();
4294 Pardeb(3) = pv1.X(); Pardeb(4) = pv1.Y();
4295 Parfin(1) = pop2.X(); Parfin(2) = pop2.Y();
4296 Parfin(3) = pv2.X(); Parfin(4) = pv2.Y();
4297 Standard_Real uu1,uu2,vv1,vv2;
4298 ChFi3d_Boite(pv1,pv2,uu1,uu2,vv1,vv2);
4299 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
4300 ChFi3d_Boite(pop1,pop2,uu1,uu2,vv1,vv2);
4301 ChFi3d_BoundFac(Bop,uu1,uu2,vv1,vv2);
4302
4303 Handle(Geom_Curve) zob3d;
4304 Handle(Geom2d_Curve) zob2dop, zob2dv;
4305// Standard_Real tolreached;
4306 if (!ChFi3d_ComputeCurves(HBop,HBs,Pardeb,Parfin,zob3d,zob2dop,
4307 zob2dv,tolesp,tol2d,tolreached))
4308 Standard_Failure::Raise("OneCorner : echec calcul intersection");
4309
4310 Udeb = zob3d->FirstParameter();
4311 Ufin = zob3d->LastParameter();
4312 TopOpeBRepDS_Curve Zob(zob3d,tolreached);
4313 Standard_Integer IZob = DStr.AddCurve(Zob);
4314
81bba717 4315 // it is not determined if the curve has an intersection with the sewing edge
7fd59977 4316
4317
4318 {
4319 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv));
4320 Standard_Integer Iop = DStr.AddShape(Fop);
4321 Handle(TopOpeBRepDS_SurfaceCurveInterference)
4322 InterFv = ChFi3d_FilCurveInDS(IZob,IShape,zob2dv,Et);
4323 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
4324 //OVtx = TopAbs::Reverse(OVtx);
4325// Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 Begin
4326// Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolbis));
4327 Et = TopAbs::Reverse(TopAbs::Compose(OVtx2,OArcprolbis));
4328// Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 End
4329 //OVtx = TopAbs::Reverse(OVtx);
4330// Et = TopAbs::Reverse(Et);
4331 Handle(TopOpeBRepDS_SurfaceCurveInterference)
4332 Interfop = ChFi3d_FilCurveInDS(IZob,Iop,zob2dop,Et);
4333 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
4334 Handle(TopOpeBRepDS_CurvePointInterference)
4335 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IVtx,Udeb);
4336 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
4337 Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc);
4338 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,IZob,icc,Ufin);
4339 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
4340
4341 }
4342 }
4343 ChFi3d_EnlargeBox(DStr,stripe,Fd,box1,box2,isfirst);
4344 if(CV1.IsOnArc()){
4345 ChFi3d_EnlargeBox(CV1.Arc(),myEFMap(CV1.Arc()),CV1.ParameterOnArc(),box1);
4346 }
4347 if(CV2.IsOnArc()){
4348 ChFi3d_EnlargeBox(CV2.Arc(),myEFMap(CV2.Arc()),CV2.ParameterOnArc(),box2);
4349 }
4350 if (!CV1.IsVertex())
4351 ChFi3d_SetPointTolerance(DStr,box1,stripe->IndexPoint(isfirst,1));
4352 if (!CV2.IsVertex())
4353 ChFi3d_SetPointTolerance(DStr,box2,stripe->IndexPoint(isfirst,2));
4354
0797d9d3 4355#ifdef OCCT_DEBUG
7fd59977 4356 ChFi3d_ResultChron(ch, t_sameinter);//result perf condition if (same &&inter)
4357#endif
4358}