1 // Created on: 1994-03-09
2 // Created by: Isabelle GRIGNON
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Modified by skv - Mon Jun 7 18:38:57 2004 OCC5898
18 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222
20 #include <ChFi3d_Builder.jxx>
22 #include <ChFi3d_Builder_0.hxx>
24 #include <Precision.hxx>
26 #include <Standard_Failure.hxx>
27 #include <Standard_NotImplemented.hxx>
28 #include <StdFail_NotDone.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>
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>
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>
95 #include <TopoDS_Shape.hxx>
96 #include <TopoDS_Face.hxx>
97 #include <TopoDS_Edge.hxx>
98 #include <TopoDS_Vertex.hxx>
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>
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>
135 #include <OSD_Chronometer.hxx>
136 #include <DrawTrSurf.hxx>
138 // Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 Begin
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
144 extern Standard_Real t_same,t_inter,t_sameinter;
145 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
146 extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
148 #include <Geom2dAPI_ProjectPointOnCurve.hxx>
149 #include <math_FunctionSample.hxx>
150 #include <Geom2dAdaptor_Curve.hxx>
151 #include <IntRes2d_IntersectionSegment.hxx>
152 // Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 Begin
153 Standard_Boolean isTangentFaces(const TopoDS_Edge &theEdge,
154 const TopoDS_Face &theFace1,
155 const TopoDS_Face &theFace2);
156 // Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 End
158 static Standard_Real recadre(const Standard_Real p,
159 const Standard_Real ref,
160 const Standard_Boolean isfirst,
161 const Standard_Real first,
162 const Standard_Real last)
164 Standard_Real pp = p;
165 if (isfirst) pp -= (last - first);
166 else pp += (last - first);
167 if (Abs(pp - ref) < Abs(p - ref)) return pp;
171 //=======================================================================
173 //purpose : Calculate the intersection of the face at the end of
174 // the tangency line to update CommonPoint and its
175 // parameter in FaceInterference.
176 //=======================================================================
178 static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& fb,
179 Handle(Adaptor2d_HCurve2d)& pcfb,
180 Handle(Adaptor3d_HSurface)& surf,
181 ChFiDS_FaceInterference& fi,
182 ChFiDS_CommonPoint& cp,
184 const Standard_Boolean isfirst,
185 Standard_Real& pared,
187 const Standard_Real tol)
189 Adaptor3d_CurveOnSurface c1(pcfb,fb);
190 Handle(Geom2d_Curve) pc = fi.PCurveOnSurf();
191 Handle(Geom2dAdaptor_HCurve) hpc = new Geom2dAdaptor_HCurve(pc);
192 Adaptor3d_CurveOnSurface c2(hpc,surf);
193 Extrema_LocateExtCC ext(c1,c2,pared,wop);
195 Standard_Real dist2 = ext.SquareDistance();
196 if (dist2 < tol * tol) {
197 Extrema_POnCurv ponc1,ponc2;
198 ext.Point(ponc1,ponc2);
199 Standard_Real parfb = ponc1.Parameter();
200 p2dbout = pcfb->Value(parfb);
201 pared = ponc1.Parameter();
202 wop = ponc2.Parameter();
203 fi.SetParameter(wop,isfirst);
205 cp.SetPoint(ponc1.Value());
206 return Standard_True;
209 return Standard_False;
212 //=======================================================================
214 //purpose : Intersect surface <fb> and 3d curve <ct>
215 // Update <isfirst> parameter of FaceInterference <fi> and point of
216 // CommonPoint <cp>. Return new intersection parameters in <wop>
218 //=======================================================================
220 static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& fb,
221 Handle(Adaptor3d_HCurve)& ct,
222 ChFiDS_FaceInterference& fi,
223 ChFiDS_CommonPoint& cp,
225 const Standard_Boolean isfirst,
228 IntCurveSurface_HInter Intersection;
229 //check if in KPart the limits of the tangency line
230 //are already in place at this stage.
231 //Modif lvt : the periodic cases are reframed, espercially if nothing was found.
232 Standard_Real w,uf = ct->FirstParameter(),ul = ct->LastParameter();
234 Standard_Real wbis = 0.;
236 Standard_Boolean isperiodic = ct->IsPeriodic(),recadrebis = Standard_False;
237 Intersection.Perform(ct,fb);
238 if (Intersection.IsDone()) {
239 Standard_Integer nbp = Intersection.NbPoints(),i,isol = 0,isolbis = 0;
240 Standard_Real dist = Precision::Infinite();
241 Standard_Real distbis = Precision::Infinite();
242 for (i = 1; i <= nbp; i++) {
243 w = Intersection.Point(i).W();
244 if (isperiodic) w = recadre(w,wop,isfirst,uf,ul);
245 if (uf <= w && ul >= w && Abs(w-wop) < dist) {
251 for (i = 1; i <= nbp; i++) {
252 w = Intersection.Point(i).W();
253 if (uf <= w && ul >= w && Abs(w-wop) < distbis && (Abs(w-ul)<=0.01 || Abs(w-uf)<=0.01)) {
255 wbis = recadre(w,wop,isfirst,uf,ul);
256 distbis = Abs(wbis-wop);
257 recadrebis = Standard_True;
261 if (isol == 0 && isolbis == 0) {
262 return Standard_False;
265 IntCurveSurface_IntersectionPoint pint = Intersection.Point(isol);
266 p2dbout.SetCoord(pint.U(),pint.V());
268 if (isperiodic) w = ElCLib::InPeriod(w,uf,ul);
272 IntCurveSurface_IntersectionPoint pint = Intersection.Point(isolbis);
273 p2dbout.SetCoord(pint.U(),pint.V());
277 IntCurveSurface_IntersectionPoint pint = Intersection.Point(isol);
278 p2dbout.SetCoord(pint.U(),pint.V());
280 w = ElCLib::InPeriod(w,uf,ul);
283 fi.SetParameter(w,isfirst);
285 cp.SetPoint(ct->Value(w));
287 return Standard_True;
289 return Standard_False;
292 //=======================================================================
293 //function : IntersUpdateOnSame
294 //purpose : Intersect curve <c3dFI> of ChFi-<Fop> interference with extended
295 // surface <HBs> of <Fprol> . Return intersection parameters in
296 // <FprolUV>, <c3dU> and updating <FIop> and <CPop>
297 // <HGs> is a surface of ChFi
298 // <Fop> is a face having 2 edges at corner with OnSame state
299 // <Fprol> is a face non-adjacent to spine edge
300 // <Vtx> is a corner vertex
301 //=======================================================================
303 static Standard_Boolean IntersUpdateOnSame(Handle(GeomAdaptor_HSurface)& HGs,
304 Handle(BRepAdaptor_HSurface)& HBs,
305 const Handle(Geom_Curve)& c3dFI,
306 const TopoDS_Face& Fop,
307 const TopoDS_Face& Fprol,
308 const TopoDS_Edge& Eprol,
309 const TopoDS_Vertex& Vtx,
310 const Standard_Boolean isFirst,
311 const Standard_Real Tol,
312 ChFiDS_FaceInterference& FIop,
313 ChFiDS_CommonPoint& CPop,
317 // add more or less restrictive criterions to
318 // decide if the intersection is done with the face at
319 // extended end or if the end is sharp.
320 Standard_Real uf = FIop.FirstParameter();
321 Standard_Real ul = FIop.LastParameter();
322 Handle(GeomAdaptor_HCurve) Hc3df;
323 if (c3dFI->IsPeriodic()) Hc3df = new GeomAdaptor_HCurve(c3dFI);
324 else Hc3df = new GeomAdaptor_HCurve(c3dFI,uf,ul);
326 if ( Update(HBs,Hc3df,FIop,CPop,FprolUV,isFirst,c3dU) )
327 return Standard_True;
329 if (!isTangentFaces(Eprol,Fprol,Fop))
330 return Standard_False;
332 Handle(Geom2d_Curve) gpcprol = BRep_Tool::CurveOnSurface(Eprol,Fprol,uf,ul);
333 Handle(Geom2dAdaptor_HCurve) pcprol = new Geom2dAdaptor_HCurve(gpcprol);
334 Standard_Real partemp = BRep_Tool::Parameter(Vtx,Eprol);
337 Update(HBs,pcprol,HGs,FIop,CPop,FprolUV,isFirst,partemp,c3dU,Tol);
340 //=======================================================================
342 //purpose : Calculate the extrema curveonsurf/curveonsurf to prefer
343 // the values concerning the trace on surf and the pcurve on the
345 //=======================================================================
347 static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& face,
348 Handle(Adaptor2d_HCurve2d)& edonface,
349 Handle(Adaptor3d_HSurface)& surf,
350 ChFiDS_FaceInterference& fi,
351 ChFiDS_CommonPoint& cp,
352 const Standard_Boolean isfirst)
354 if (!cp.IsOnArc()) return 0;
355 Adaptor3d_CurveOnSurface c1(edonface,face);
356 Standard_Real pared = cp.ParameterOnArc();
357 Standard_Real parltg = fi.Parameter(isfirst);
358 Handle(Geom2d_Curve) pc = fi.PCurveOnSurf();
359 Standard_Real f = fi.FirstParameter();
360 Standard_Real l = fi.LastParameter();
361 Standard_Real delta = 0.1 * ( l - f );
362 f = Max(f-delta,pc->FirstParameter());
363 l = Min(l+delta,pc->LastParameter());
364 Handle(Geom2dAdaptor_HCurve) hpc = new Geom2dAdaptor_HCurve(pc,f,l);
365 Adaptor3d_CurveOnSurface c2(hpc,surf);
367 Extrema_LocateExtCC ext(c1,c2,pared,parltg);
369 Extrema_POnCurv ponc1,ponc2;
370 ext.Point(ponc1,ponc2);
371 pared = ponc1.Parameter();
372 parltg = ponc2.Parameter();
373 if ((parltg > f) && (parltg < l)) {
375 ////modified by jgv, 10.05.2012 for the bug 23139////
376 Handle(Geom2d_Curve) PConF = fi.PCurveOnFace();
379 Handle(Geom2d_TrimmedCurve) aTrCurve = Handle(Geom2d_TrimmedCurve)::DownCast(PConF);
380 if (!aTrCurve.IsNull())
381 PConF = aTrCurve->BasisCurve();
384 Standard_Real fpar = PConF->FirstParameter();
390 Standard_Real lpar = PConF->LastParameter();
395 /////////////////////////////////////////////////////
397 fi.SetParameter(parltg,isfirst);
398 cp.SetArc(cp.Tolerance(),cp.Arc(),pared,cp.TransitionOnArc());
399 return Standard_True;
402 return Standard_False;
405 //=======================================================================
406 //function : ChFi3d_ExtendSurface
408 //=======================================================================
410 static void ChFi3d_ExtendSurface (Handle(Geom_Surface) & S ,
411 Standard_Integer & prol )
414 Handle(Geom_BSplineSurface) S1;
415 Handle(Geom_BezierSurface) S2;
416 Standard_Real length,umin,umax,vmin,vmax;
418 S->Bounds(umin,umax,vmin,vmax);
421 length=P1.Distance(P2);
423 S1=Handle(Geom_BSplineSurface)::DownCast(S);
424 S2=Handle(Geom_BezierSurface)::DownCast(S);
426 GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,
428 GeomLib::ExtendSurfByLength(S1,length,1,Standard_True,
430 GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,
432 GeomLib::ExtendSurfByLength(S1,length,1,Standard_True,
438 GeomLib::ExtendSurfByLength(S2,length,1,Standard_False,
440 GeomLib::ExtendSurfByLength(S2,length,1,Standard_True,
442 GeomLib::ExtendSurfByLength(S2,length,1,Standard_False,
444 GeomLib::ExtendSurfByLength(S2,length,1,Standard_True,
452 //=======================================================================
453 //function : ComputeCurve2d
454 //purpose : calculate the 2d of the curve Ct on face Face
455 //=======================================================================
457 static void ComputeCurve2d (Handle(Geom_Curve )& Ct,
459 Handle(Geom2d_Curve) & C2d)
462 TopTools_IndexedMapOfShape MapE1;
463 BRepLib_MakeEdge Bedge (Ct);
464 TopoDS_Edge edg =Bedge. Edge();
465 BRepAlgo_NormalProjection OrtProj;
468 OrtProj.SetParams(1.e-6, 1.e-6, GeomAbs_C1, 14, 16);
469 OrtProj.SetLimit(Standard_False);
470 OrtProj.Compute3d(Standard_False);
472 Standard_Real up1,up2;
473 if ( OrtProj.IsDone()) {
474 TopExp::MapShapes(OrtProj.Projection() ,TopAbs_EDGE, MapE1);
475 if (MapE1.Extent()!=0) {
476 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE1(1));
477 E1=TopoDS::Edge(aLocalShape );
478 // E1=TopoDS::Edge( TopoDS_Shape (MapE1(1)));
479 C2d=BRep_Tool::CurveOnSurface(E1,Face,up1,up2);
484 //=======================================================================
485 //function : ChFi3d_Recale
487 //=======================================================================
489 static void ChFi3d_Recale(BRepAdaptor_Surface& Bs,
492 const Standard_Boolean refon1)
494 Handle(Geom_Surface) surf = Bs.ChangeSurface().Surface();
495 Handle(Geom_RectangularTrimmedSurface)
496 ts = Handle(Geom_RectangularTrimmedSurface)::DownCast(surf);
497 if (!ts.IsNull()) surf = ts->BasisSurface();
498 if (surf->IsUPeriodic()) {
499 Standard_Real u1 = p1.X(), u2 = p2.X();
500 Standard_Real uper = surf->UPeriod();
501 if (fabs(u2-u1) > 0.5*uper) {
502 if (u2<u1 && refon1) u2 += uper;
503 else if (u2<u1 && !refon1) u1 -= uper;
504 else if (u1<u2 && refon1) u2 -= uper;
505 else if (u1<u2 && !refon1) u1 += uper;
507 p1.SetX(u1); p2.SetX(u2);
509 if (surf->IsVPeriodic()) {
510 Standard_Real v1 = p1.Y(), v2 = p2.Y();
511 Standard_Real vper = surf->VPeriod();
512 if (fabs(v2-v1) > 0.5*vper) {
513 if (v2<v1 && refon1) v2 += vper;
514 else if (v2<v1 && !refon1) v1 -= vper;
515 else if (v1<v2 && refon1) v2 -= vper;
516 else if (v1<v2 && !refon1) v1 += vper;
518 p1.SetY(v1); p2.SetY(v2);
522 //=======================================================================
523 //function : ChFi3d_SelectStripe
524 //purpose : find stripe with ChFiDS_OnSame state if <thePrepareOnSame> is True
525 //=======================================================================
527 Standard_Boolean ChFi3d_SelectStripe(ChFiDS_ListIteratorOfListOfStripe & It,
528 const TopoDS_Vertex& Vtx,
529 const Standard_Boolean thePrepareOnSame)
531 if (!thePrepareOnSame) return Standard_True;
533 for (; It.More(); It.Next()) {
534 Standard_Integer sens = 0;
535 Handle(ChFiDS_Stripe) stripe = It.Value();
536 ChFi3d_IndexOfSurfData(Vtx, stripe, sens);
539 stat = stripe->Spine()->FirstStatus();
541 stat = stripe->Spine()->LastStatus();
542 if ( stat == ChFiDS_OnSame ) return Standard_True;
545 return Standard_False;
547 //=======================================================================
548 //function : PerformOneCorner
549 //purpose : Calculate a corner with three edges and a fillet.
550 // 3 separate case: (22/07/94 only 1st is implemented)
552 // - same concavity on three edges, intersection with the
554 // - concavity of 2 outgoing edges is opposite to the one of the fillet,
555 // if the face at end is ready for that, the same in case 1 on extended face,
556 // otherwise a small cap is done with GeomFill,
557 // - only one outgoing edge has concavity opposed to the edge of the
558 // fillet and the third edge, the top of the corner is reread
559 // in the empty of the fillet and closed, either by extending the face
560 // at end if it is plane and orthogonal to the
561 // guiding edge, or by a cap of type GeomFill.
563 // <thePrepareOnSame> means that only needed thing is redefinition
564 // of intersection pameter of OnSame-Stripe with <Arcprol>
565 // (eap, Arp 9 2002, occ266)
566 //=======================================================================
568 void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index,
569 const Standard_Boolean thePrepareOnSame)
571 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
574 OSD_Chronometer ch;// init perf for PerformSetOfKPart
577 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
578 // The fillet is returned,
579 ChFiDS_ListIteratorOfListOfStripe StrIt;
580 StrIt.Initialize(myVDataMap(Index));
581 if ( ! ChFi3d_SelectStripe (StrIt, Vtx, thePrepareOnSame)) return;
582 Handle(ChFiDS_Stripe) stripe = StrIt.Value();
583 const Handle(ChFiDS_Spine) spine = stripe->Spine();
584 ChFiDS_SequenceOfSurfData& SeqFil =
585 stripe->ChangeSetOfSurfData()->ChangeSequence();
586 // SurfData and its CommonPoints,
587 Standard_Integer sens = 0;
589 // Choose proper SurfData
590 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
591 Standard_Boolean isfirst = (sens == 1);
593 for (; num<SeqFil.Length() && (
594 (SeqFil.Value(num)->IndexOfS1()==0) ||
595 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
596 SeqFil.Remove(num); // The surplus is removed
601 (SeqFil.Value(num)->IndexOfS1()==0) ||
602 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
603 SeqFil.Remove(num);// The surplus is removed
608 Handle(ChFiDS_SurfData)& Fd = SeqFil.ChangeValue(num);
609 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
610 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
611 //To evaluate the new points.
614 // The cases of cap and intersection are processed separately.
615 // ----------------------------------------------------------
617 if (isfirst) stat = spine->FirstStatus();
618 else stat = spine->LastStatus();
619 Standard_Boolean onsame = (stat == ChFiDS_OnSame);
620 TopoDS_Face Fv,Fad,Fop;
621 TopoDS_Edge Arcpiv,Arcprol,Arcspine;
622 if (isfirst) Arcspine = spine->Edges(1);
623 else Arcspine = spine->Edges(spine->NbEdges());
624 TopAbs_Orientation OArcprolv = TopAbs_FORWARD, OArcprolop = TopAbs_FORWARD;
625 Standard_Integer ICurve;
626 Handle(BRepAdaptor_HSurface) HBs = new BRepAdaptor_HSurface();
627 Handle(BRepAdaptor_HSurface) HBad = new BRepAdaptor_HSurface();
628 Handle(BRepAdaptor_HSurface) HBop = new BRepAdaptor_HSurface();
629 BRepAdaptor_Surface& Bs = HBs->ChangeSurface();
630 BRepAdaptor_Surface& Bad = HBad->ChangeSurface();
631 BRepAdaptor_Surface& Bop = HBop->ChangeSurface();
632 Handle(Geom_Curve) Cc;
633 Handle(Geom2d_Curve) Pc,Ps;
634 Standard_Real Ubid,Vbid;//,mu,Mu,mv,Mv;
635 Standard_Real Udeb = 0.,Ufin = 0.;
636 // gp_Pnt2d UVf1,UVl1,UVf2,UVl2;
637 // Standard_Real Du,Dv,Step;
638 Standard_Boolean inters = Standard_True;
639 Standard_Integer IFadArc = 1, IFopArc = 2;
640 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
644 ChFi3d_InitChron(ch); // init perf condition if (onsame)
648 if (!CV1.IsOnArc() && !CV2.IsOnArc())
649 Standard_Failure::Raise("Corner OnSame : no point on arc");
650 else if (CV1.IsOnArc() && CV2.IsOnArc()) {
651 Standard_Boolean sur1 = 0, sur2 = 0;
652 for(ex.Init(CV1.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()) {
653 if (Vtx.IsSame(ex.Current())) {
658 for(ex.Init(CV2.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()) {
659 if (Vtx.IsSame(ex.Current())) {
666 E[0] = CV1.Arc(); E[1] = CV2.Arc(); E[2] = Arcspine;
667 if (ChFi3d_EdgeState(E,myEFMap) != ChFiDS_OnDiff) IFadArc = 2;
669 else if (sur2) IFadArc = 2;
671 else if (CV2.IsOnArc()) IFadArc = 2;
674 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
675 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
676 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
677 TopTools_ListIteratorOfListOfShape It;
678 // The face at end is returned without check of its unicity.
679 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
680 if (!Fad.IsSame(It.Value())) {
681 Fv = TopoDS::Face(It.Value());
686 // Does the face at bout contain the Vertex ?
687 Standard_Boolean isinface = Standard_False;
688 for (ex.Init(Fv,TopAbs_VERTEX); ex.More(); ex.Next()) {
689 if (ex.Current().IsSame(Vtx)) {
690 isinface = Standard_True;
694 if (!isinface && Fd->Vertex(isfirst,3-IFadArc).IsOnArc()) {
697 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
698 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
699 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
700 //TopTools_ListIteratorOfListOfShape It;
701 // The face at end is returned without check of its unicity.
702 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
703 if (!Fad.IsSame(It.Value())) {
704 Fv = TopoDS::Face(It.Value());
710 if (Fv.IsNull()) StdFail_NotDone::Raise
711 ("OneCorner : face at end not found");
713 Fv.Orientation(TopAbs_FORWARD);
714 Fad.Orientation(TopAbs_FORWARD);
715 Fop.Orientation(TopAbs_FORWARD);
717 // The edge that will be extended is returned.
718 for(It.Initialize(myVEMap(Vtx));It.More() && Arcprol.IsNull();It.Next()) {
719 if (!Arcpiv.IsSame(It.Value())) {
720 for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()) {
721 if (It.Value().IsSame(ex.Current())) {
722 Arcprol = TopoDS::Edge(It.Value());
723 OArcprolv = ex.Current().Orientation();
729 if (Arcprol.IsNull()) /*StdFail_NotDone::Raise
730 ("OneCorner : edge a prolonger non trouve");*/
732 PerformIntersectionAtEnd(Index);
735 for(ex.Init(Fop,TopAbs_EDGE); ex.More(); ex.Next()) {
736 if (Arcprol.IsSame(ex.Current())) {
737 OArcprolop = ex.Current().Orientation();
743 Standard_Integer prol=0;
745 Handle(Geom_Surface ) Sface;
746 Sface=BRep_Tool::Surface(Fv);
747 ChFi3d_ExtendSurface(Sface,prol);
748 tol=BRep_Tool::Tolerance(Fv);
749 BRE.MakeFace(FFv,Sface,tol);
751 Bs.Initialize(FFv,Standard_False);
752 DStr.SetNewSurface(Fv,Sface);
754 else Bs.Initialize(Fv,Standard_False);
758 //in case of OnSame it is necessary to modify the CommonPoint
759 //in the empty and its parameter in the FaceInterference.
760 //They are both returned in non const references. Attention the modifications are done behind
761 //de CV1,CV2,Fi1,Fi2.
762 ChFiDS_CommonPoint& CPopArc = Fd->ChangeVertex(isfirst,IFopArc);
763 ChFiDS_FaceInterference& FiopArc = Fd->ChangeInterference(IFopArc);
764 ChFiDS_CommonPoint& CPadArc = Fd->ChangeVertex(isfirst,IFadArc);
765 ChFiDS_FaceInterference& FiadArc = Fd->ChangeInterference(IFadArc);
766 //the parameter of the vertex in the air is initialiced with the value of
767 //its opposite (point on arc).
768 Standard_Real wop = Fd->ChangeInterference(IFadArc).Parameter(isfirst);
769 Handle(Geom_Curve) c3df;
770 Handle(GeomAdaptor_HSurface)
771 HGs = new GeomAdaptor_HSurface(DStr.Surface(Fd->Surf()).Surface());
776 ChFiDS_CommonPoint saveCPopArc = CPopArc;
777 c3df = DStr.Curve(FiopArc.LineIndex()).Curve();
779 inters = IntersUpdateOnSame (HGs,HBs,c3df,Fop,Fv,Arcprol,Vtx,isfirst,10*tolesp, // in
780 FiopArc,CPopArc,p2dbout,wop); // out
782 Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
783 pced->ChangeCurve2d().Initialize(CPadArc.Arc(),Fv);
784 // in the case of degenerated Fi, parameter difference can be even negative (eap, occ293)
785 if ((FiadArc.LastParameter() - FiadArc.FirstParameter()) > 10*tolesp)
786 Update(HBs,pced,HGs,FiadArc,CPadArc,isfirst);
788 if (thePrepareOnSame) {
789 //saveCPopArc.SetParameter(wop);
790 saveCPopArc.SetPoint(CPopArc.Point());
791 CPopArc = saveCPopArc;
796 inters = FindFace(Vtx,CV1,CV2,Fv,Fop);
798 PerformIntersectionAtEnd(Index);
802 Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
803 pced->ChangeCurve2d().Initialize(CV1.Arc(),Fv);
804 Update(HBs,pced,HGs,Fd->ChangeInterferenceOnS1(),CV1,isfirst);
805 pced->ChangeCurve2d().Initialize(CV2.Arc(),Fv);
806 Update(HBs,pced,HGs,Fd->ChangeInterferenceOnS2(),CV2,isfirst);
811 ChFi3d_ResultChron(ch,t_same); // result perf condition if (same)
812 ChFi3d_InitChron(ch); // init perf condition if (inters)
815 TopoDS_Edge edgecouture;
816 Standard_Boolean couture,intcouture=Standard_False;;
817 Standard_Real tolreached = tolesp;
818 Standard_Real par1 =0.,par2 =0.;
819 Standard_Integer indpt = 0,Icurv1 = 0,Icurv2 = 0;
820 Handle(Geom_TrimmedCurve) curv1,curv2;
821 Handle(Geom2d_Curve) c2d1,c2d2;
823 Standard_Integer Isurf=Fd->Surf();
826 HGs = ChFi3d_BoundSurf(DStr,Fd,1,2);
827 const ChFiDS_FaceInterference& Fi1 = Fd->InterferenceOnS1();
828 const ChFiDS_FaceInterference& Fi2 = Fd->InterferenceOnS2();
829 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
830 gp_Pnt2d pfil1,pfac1,pfil2,pfac2;
831 Handle(Geom2d_Curve) Hc1,Hc2;
832 if (onsame && IFopArc == 1) pfac1 = p2dbout;
834 Hc1 = BRep_Tool::CurveOnSurface(CV1.Arc(),Fv,Ubid,Ubid);
835 pfac1 = Hc1->Value(CV1.ParameterOnArc());
837 if (onsame && IFopArc == 2) pfac2 = p2dbout;
839 Hc2 = BRep_Tool::CurveOnSurface(CV2.Arc(),Fv,Ubid,Ubid);
840 pfac2 = Hc2->Value(CV2.ParameterOnArc());
842 if (Fi1.LineIndex() != 0) {
843 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));
846 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
848 if (Fi2.LineIndex() != 0) {
849 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
852 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
854 if (onsame) ChFi3d_Recale(Bs,pfac1,pfac2,(IFadArc == 1));
856 Pardeb(1)= pfil1.X(); Pardeb(2) = pfil1.Y();
857 Pardeb(3)= pfac1.X(); Pardeb(4) = pfac1.Y();
858 Parfin(1)= pfil2.X(); Parfin(2) = pfil2.Y();
859 Parfin(3)= pfac2.X(); Parfin(4) = pfac2.Y();
861 Standard_Real uu1,uu2,vv1,vv2;
862 ChFi3d_Boite(pfac1,pfac2,uu1,uu2,vv1,vv2);
863 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
865 if (!ChFi3d_ComputeCurves(HGs,HBs,Pardeb,Parfin,Cc,
867 Pc,tolesp,tol2d,tolreached))
868 Standard_Failure::Raise("OneCorner : echec calcul intersection");
870 Udeb = Cc->FirstParameter();
871 Ufin = Cc->LastParameter();
873 // determine if the curve has an intersection with edge of sewing
875 ChFi3d_Couture(Fv,couture,edgecouture);
877 if (couture && !BRep_Tool::Degenerated(edgecouture)) {
879 //Standard_Real Ubid,Vbid;
880 Handle (Geom_Curve) C=BRep_Tool::Curve(edgecouture,Ubid,Vbid);
881 Handle(Geom_TrimmedCurve) Ctrim=new Geom_TrimmedCurve (C,Ubid,Vbid);
882 GeomAdaptor_Curve cur1(Ctrim->BasisCurve());
883 GeomAdaptor_Curve cur2(Cc);
884 Extrema_ExtCC extCC (cur1,cur2);
885 if (extCC.IsDone()&&extCC.NbExt()!=0)
887 Standard_Integer imin=0;
888 Standard_Real distmin2 = RealLast();
889 for (Standard_Integer i = 1; i <= extCC.NbExt(); i++)
890 if (extCC.SquareDistance(i) < distmin2)
892 distmin2 = extCC.SquareDistance(i);
895 if (distmin2 <= Precision::SquareConfusion())
897 Extrema_POnCurv ponc1,ponc2;
898 extCC.Points( imin, ponc1, ponc2 );
899 par1 = ponc1.Parameter();
900 par2 = ponc2.Parameter();
901 Standard_Real Tol = 1.e-4;
902 if (Abs(par2-Udeb) > Tol && Abs(Ufin-par2) > Tol)
904 gp_Pnt P1 = ponc1.Value();
905 TopOpeBRepDS_Point tpoint( P1, Tol );
906 indpt = DStr.AddPoint(tpoint);
907 intcouture = Standard_True;
908 curv1 = new Geom_TrimmedCurve(Cc,Udeb,par2);
909 curv2 = new Geom_TrimmedCurve(Cc,par2,Ufin);
910 TopOpeBRepDS_Curve tcurv1(curv1,tolreached);
911 TopOpeBRepDS_Curve tcurv2(curv2,tolreached);
912 Icurv1=DStr.AddCurve(tcurv1);
913 Icurv2=DStr.AddCurve(tcurv2);
920 Standard_NotImplemented::Raise("OneCorner : bouchon non ecrit");
922 Standard_Integer IShape = DStr.AddShape(Fv);
923 TopAbs_Orientation Et = TopAbs_FORWARD;
926 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
927 TopAbs_EDGE);Exp.More();Exp.Next()) {
928 if (Exp.Current().IsSame(CV1.Arc())) {
929 Et = TopAbs::Reverse(TopAbs::Compose
930 (Exp.Current().Orientation(),
931 CV1.TransitionOnArc()));
938 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
939 TopAbs_EDGE);Exp.More();Exp.Next()) {
940 if (Exp.Current().IsSame(CV2.Arc())) {
941 Et = TopAbs::Compose(Exp.Current().Orientation(),
942 CV2.TransitionOnArc());
953 ChFi3d_ResultChron(ch ,t_inter); //result perf condition if (inter)
954 ChFi3d_InitChron(ch); // init perf condition if (onsame && inters)
957 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV1,DStr),isfirst,1);
958 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV2,DStr),isfirst,2);
961 // there is no intersection with the sewing edge
962 // the curve Cc is stored in the stripe
963 // the storage in the DS is not done by FILDS.
965 TopOpeBRepDS_Curve Tc(Cc,tolreached);
966 ICurve = DStr.AddCurve(Tc);
967 Handle(TopOpeBRepDS_SurfaceCurveInterference)
968 Interfc = ChFi3d_FilCurveInDS(ICurve,IShape,Pc,Et);
970 // 31/01/02 akm vvv : (OCC119) Prevent the builder from creating
971 // intersecting fillets - they are bad.
972 Geom2dInt_GInter anIntersector;
973 Geom2dAdaptor_Curve aCorkPCurve (Pc, Udeb, Ufin);
975 // Take all the interferences with faces from all the stripes
976 // and look if their pcurves intersect our cork pcurve.
977 // Unfortunately, by this moment they do not exist in DStr.
978 ChFiDS_ListIteratorOfListOfStripe aStrIt(myListStripe);
979 for (; aStrIt.More(); aStrIt.Next())
981 Handle(ChFiDS_Stripe) aCheckStripe = aStrIt.Value();
982 Handle(ChFiDS_HData) aSeqData = aCheckStripe->SetOfSurfData();
983 // Loop on parts of the stripe
984 Standard_Integer iPart;
985 for (iPart=1; iPart<=aSeqData->Length(); iPart++)
987 Handle(ChFiDS_SurfData) aData = aSeqData->Value(iPart);
988 Geom2dAdaptor_Curve anOtherPCurve;
989 if (IShape == aData->IndexOfS1())
991 const Handle(Geom2d_Curve)& aPCurve = aData->InterferenceOnS1().PCurveOnFace();
995 anOtherPCurve.Load (aPCurve,
996 aData->InterferenceOnS1().FirstParameter(),
997 aData->InterferenceOnS1().LastParameter());
999 else if (IShape == aData->IndexOfS2())
1001 const Handle(Geom2d_Curve)& aPCurve = aData->InterferenceOnS2().PCurveOnFace();
1002 if(aPCurve.IsNull())
1005 anOtherPCurve.Load (aPCurve,
1006 aData->InterferenceOnS2().FirstParameter(),
1007 aData->InterferenceOnS2().LastParameter());
1011 // Normal case - no common surface
1014 if (IsEqual(anOtherPCurve.LastParameter(),anOtherPCurve.FirstParameter()))
1017 anIntersector.Perform (aCorkPCurve, anOtherPCurve,
1018 tol2d, Precision::PConfusion());
1019 if (anIntersector.NbSegments() > 0 ||
1020 anIntersector.NbPoints() > 0)
1021 StdFail_NotDone::Raise ("OneCorner : fillets have too big radiuses");
1024 TopOpeBRepDS_ListIteratorOfListOfInterference
1025 anIter(DStr.ChangeShapeInterferences(IShape));
1026 for (; anIter.More(); anIter.Next())
1028 Handle(TopOpeBRepDS_SurfaceCurveInterference) anOtherIntrf =
1029 Handle(TopOpeBRepDS_SurfaceCurveInterference)::DownCast(anIter.Value());
1030 // We need only interferences between cork face and curves
1031 // of intersection with another fillet surfaces
1032 if (anOtherIntrf.IsNull())
1034 // Look if there is an intersection between pcurves
1035 Handle(Geom_TrimmedCurve) anOtherCur =
1036 Handle(Geom_TrimmedCurve)::DownCast(DStr.Curve (anOtherIntrf->Geometry()).Curve());
1037 if (anOtherCur.IsNull())
1039 Geom2dAdaptor_Curve anOtherPCurve (anOtherIntrf->PCurve(),
1040 anOtherCur->FirstParameter(),
1041 anOtherCur->LastParameter());
1042 anIntersector.Perform (aCorkPCurve, anOtherPCurve,
1043 tol2d, Precision::PConfusion());
1044 if (anIntersector.NbSegments() > 0 ||
1045 anIntersector.NbPoints() > 0)
1046 StdFail_NotDone::Raise ("OneCorner : fillets have too big radiuses");
1049 DStr.ChangeShapeInterferences(IShape).Append(Interfc);
1050 //// modified by jgv, 26.03.02 for OCC32 ////
1051 ChFiDS_CommonPoint CV [2];
1054 for (Standard_Integer i = 0; i < 2; i++)
1056 if (CV[i].IsOnArc() && ChFi3d_IsPseudoSeam( CV[i].Arc(), Fv ))
1058 gp_Pnt2d pfac1, PcF, PcL;
1059 gp_Vec2d DerPc, DerHc;
1060 Standard_Real first, last, prm1, prm2;
1061 Standard_Boolean onfirst, FirstToPar;
1062 Handle(Geom2d_Curve) Hc = BRep_Tool::CurveOnSurface( CV[i].Arc(), Fv, first, last );
1063 pfac1 = Hc->Value( CV[i].ParameterOnArc() );
1064 PcF = Pc->Value( Udeb );
1065 PcL = Pc->Value( Ufin );
1066 onfirst = (pfac1.Distance(PcF) < pfac1.Distance(PcL))? Standard_True : Standard_False;
1068 Pc->D1( Udeb, PcF, DerPc );
1071 Pc->D1( Ufin, PcL, DerPc );
1074 Hc->D1( CV[i].ParameterOnArc(), pfac1, DerHc );
1075 if (DerHc.Dot(DerPc) > 0.)
1077 prm1 = CV[i].ParameterOnArc();
1079 FirstToPar = Standard_False;
1084 prm2 = CV[i].ParameterOnArc();
1085 FirstToPar = Standard_True;
1087 Handle(Geom_Curve) Ct = BRep_Tool::Curve( CV[i].Arc(), first, last );
1088 Ct = new Geom_TrimmedCurve( Ct, prm1, prm2 );
1089 Standard_Real toled = BRep_Tool::Tolerance( CV[i].Arc() );
1090 TopOpeBRepDS_Curve tcurv( Ct, toled );
1091 Handle (TopOpeBRepDS_CurvePointInterference) Interfp1, Interfp2;
1092 Standard_Integer indcurv;
1093 indcurv = DStr.AddCurve( tcurv );
1094 Standard_Integer indpoint = (isfirst)? stripe->IndexFirstPointOnS1() : stripe->IndexLastPointOnS1();
1095 Standard_Integer indvertex = DStr.AddShape(Vtx);
1098 Interfp1 = ChFi3d_FilPointInDS( TopAbs_FORWARD, indcurv, indvertex, prm1, Standard_True );
1099 Interfp2 = ChFi3d_FilPointInDS( TopAbs_REVERSED, indcurv, indpoint, prm2, Standard_False );
1103 Interfp1 = ChFi3d_FilPointInDS( TopAbs_FORWARD, indcurv, indpoint, prm1, Standard_False );
1104 Interfp2 = ChFi3d_FilPointInDS( TopAbs_REVERSED, indcurv, indvertex, prm2, Standard_True );
1106 DStr.ChangeCurveInterferences(indcurv).Append(Interfp1);
1107 DStr.ChangeCurveInterferences(indcurv).Append(Interfp2);
1108 Standard_Integer indface = DStr.AddShape( Fv );
1109 Interfc = ChFi3d_FilCurveInDS( indcurv, indface, Hc, CV[i].Arc().Orientation() );
1110 DStr.ChangeShapeInterferences(indface).Append( Interfc );
1111 TopoDS_Edge aLocalEdge = CV[i].Arc();
1112 aLocalEdge.Reverse();
1113 Handle(Geom2d_Curve) HcR = BRep_Tool::CurveOnSurface( aLocalEdge, Fv, first, last );
1114 Interfc = ChFi3d_FilCurveInDS( indcurv, indface, HcR, aLocalEdge.Orientation() );
1115 DStr.ChangeShapeInterferences(indface).Append( Interfc );
1116 //modify degenerated edge
1117 Standard_Boolean DegenExist = Standard_False;
1119 TopExp_Explorer Explo( Fv, TopAbs_EDGE );
1120 for (; Explo.More(); Explo.Next())
1122 const TopoDS_Edge& Ecur = TopoDS::Edge( Explo.Current() );
1123 if (BRep_Tool::Degenerated( Ecur ))
1125 TopoDS_Vertex Vf, Vl;
1126 TopExp::Vertices( Ecur, Vf, Vl );
1127 if (Vf.IsSame(Vtx) || Vl.IsSame(Vtx))
1129 DegenExist = Standard_True;
1137 Standard_Real fd, ld;
1138 Handle(Geom2d_Curve) Cd = BRep_Tool::CurveOnSurface( Edeg, Fv, fd, ld );
1139 Handle(Geom2d_TrimmedCurve) tCd = Handle(Geom2d_TrimmedCurve)::DownCast(Cd);
1141 Cd = tCd->BasisCurve();
1142 gp_Pnt2d P2d = (FirstToPar)? Hc->Value(first) : Hc->Value(last);
1143 Geom2dAPI_ProjectPointOnCurve Projector( P2d, Cd );
1144 Standard_Real par = Projector.LowerDistanceParameter();
1145 Standard_Integer Ideg = DStr.AddShape(Edeg);
1146 TopAbs_Orientation ori = (par < fd)? TopAbs_FORWARD : TopAbs_REVERSED; //if par<fd => par>ld
1147 Interfp1 = ChFi3d_FilPointInDS( ori, Ideg, indvertex, par, Standard_True );
1148 DStr.ChangeShapeInterferences(Ideg).Append(Interfp1);
1152 /////////////////////////////////////////////
1153 stripe->ChangePCurve(isfirst)=Ps;
1154 stripe->SetCurve(ICurve,isfirst);
1155 stripe->SetParameters(isfirst,Udeb,Ufin);
1158 // curves curv1 are curv2 stored in the DS
1159 // these curves will not be reconstructed by FILDS as
1160 // one places stripe->InDS(isfirst);
1162 // interferences of curv1 and curv2 on Fv
1163 ComputeCurve2d(curv1,Fv,c2d1);
1164 Handle(TopOpeBRepDS_SurfaceCurveInterference) InterFv;
1165 InterFv = ChFi3d_FilCurveInDS(Icurv1,IShape,c2d1,Et);
1166 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1167 ComputeCurve2d(curv2,Fv,c2d2);
1168 InterFv = ChFi3d_FilCurveInDS(Icurv2,IShape,c2d2,Et);
1169 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1170 // interferences of curv1 and curv2 on Isurf
1171 if (Fd->Orientation()== Fv.Orientation()) Et=TopAbs::Reverse(Et);
1172 c2d1=new Geom2d_TrimmedCurve(Ps,Udeb,par2);
1173 InterFv = ChFi3d_FilCurveInDS(Icurv1,Isurf,c2d1,Et);
1174 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
1175 c2d2=new Geom2d_TrimmedCurve(Ps,par2,Ufin);
1176 InterFv = ChFi3d_FilCurveInDS(Icurv2,Isurf,c2d2,Et);
1177 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
1179 // limitation of the sewing edge
1180 Standard_Integer Iarc=DStr.AddShape(edgecouture);
1181 Handle(TopOpeBRepDS_CurvePointInterference) Interfedge;
1182 TopAbs_Orientation ori;
1183 TopoDS_Vertex Vdeb,Vfin;
1184 Vdeb=TopExp::FirstVertex(edgecouture);
1185 Vfin=TopExp::LastVertex(edgecouture);
1186 Standard_Real pard,parf;
1187 pard=BRep_Tool::Parameter(Vdeb,edgecouture);
1188 parf=BRep_Tool::Parameter(Vfin,edgecouture);
1189 if (Abs(par1-pard)<Abs(parf-par1)) ori=TopAbs_FORWARD;
1190 else ori=TopAbs_REVERSED;
1191 Interfedge = ChFi3d_FilPointInDS(ori,Iarc,indpt,par1);
1192 DStr.ChangeShapeInterferences(Iarc).Append(Interfedge);
1194 // creation of CurveInterferences from Icurv1 and Icurv2
1195 stripe->InDS(isfirst);
1196 Standard_Integer ind1= stripe->IndexPoint(isfirst,1);
1197 Standard_Integer ind2= stripe->IndexPoint(isfirst,2);
1198 Handle(TopOpeBRepDS_CurvePointInterference)
1199 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv1,ind1,Udeb);
1200 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1201 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv1,indpt,par2);
1202 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1203 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv2,indpt,par2);
1204 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1205 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv2,ind2,Ufin);
1206 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1210 ChFi3d_EnlargeBox(HBs,Pc,Udeb,Ufin,box1,box2);
1212 if (onsame && inters) {
1214 // A small missing end of curve is added for the extension
1215 // of the face at end and the limitation of the opposing face.
1217 // VARIANT 2 : extend Arcprol, not create new small edge
1218 // To do: modify for intcouture
1221 // First of all the ponts are cut with the edge of the spine.
1222 Standard_Integer IArcspine = DStr.AddShape(Arcspine);
1223 Standard_Integer IVtx = DStr.AddShape(Vtx);
1224 TopAbs_Orientation OVtx = TopAbs_FORWARD;
1225 for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
1226 ex.More(); ex.Next()) {
1227 if (Vtx.IsSame(ex.Current())) {
1228 OVtx = ex.Current().Orientation();
1232 OVtx = TopAbs::Reverse(OVtx);
1233 Standard_Real parVtx = BRep_Tool::Parameter(Vtx,Arcspine);
1234 Handle(TopOpeBRepDS_CurvePointInterference)
1235 interfv = ChFi3d_FilVertexInDS(OVtx,IArcspine,IVtx,parVtx);
1236 DStr.ChangeShapeInterferences(IArcspine).Append(interfv);
1238 // Now the missing curves are constructed.
1240 for(ex.Init(Arcprol.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
1241 ex.More(); ex.Next()) {
1242 if (Vtx.IsSame(ex.Current()))
1243 OVtx = ex.Current().Orientation();
1245 V2 = TopoDS::Vertex(ex.Current());
1248 Handle(Geom2d_Curve) Hc;
1250 parVtx = BRep_Tool::Parameter(Vtx,Arcprol);
1252 parVtx = BRep_Tool::Parameter(V2,Arcprol);
1254 const ChFiDS_FaceInterference& Fiop = Fd->Interference(IFopArc);
1255 gp_Pnt2d pop1, pop2, pv1, pv2;
1256 Hc = BRep_Tool::CurveOnSurface(Arcprol,Fop,Ubid,Ubid);
1257 pop1 = Hc->Value(parVtx);
1258 pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst));
1259 Hc = BRep_Tool::CurveOnSurface(Arcprol,Fv,Ubid,Ubid);
1260 pv1 = Hc->Value(parVtx);
1262 ChFi3d_Recale(Bs,pv1,pv2,1);
1263 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
1264 Pardeb(1) = pop1.X(); Pardeb(2) = pop1.Y();
1265 Pardeb(3) = pv1.X(); Pardeb(4) = pv1.Y();
1266 Parfin(1) = pop2.X(); Parfin(2) = pop2.Y();
1267 Parfin(3) = pv2.X(); Parfin(4) = pv2.Y();
1268 Standard_Real uu1,uu2,vv1,vv2;
1269 ChFi3d_Boite(pv1,pv2,uu1,uu2,vv1,vv2);
1270 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
1271 ChFi3d_Boite(pop1,pop2,uu1,uu2,vv1,vv2);
1272 ChFi3d_BoundFac(Bop,uu1,uu2,vv1,vv2);
1274 Handle(Geom_Curve) zob3d;
1275 Handle(Geom2d_Curve) zob2dop, zob2dv;
1276 //Standard_Real tolreached;
1277 if (!ChFi3d_ComputeCurves(HBop,HBs,Pardeb,Parfin,zob3d,zob2dop,
1278 zob2dv,tolesp,tol2d,tolreached))
1279 Standard_Failure::Raise("OneCorner : echec calcul intersection");
1281 Udeb = zob3d->FirstParameter();
1282 Ufin = zob3d->LastParameter();
1283 TopOpeBRepDS_Curve Zob(zob3d,tolreached);
1284 Standard_Integer IZob = DStr.AddCurve(Zob);
1286 // it is determined if Fop has an edge of sewing
1287 // it is determined if the curve has an intersection with the edge of sewing
1289 //TopoDS_Edge edgecouture;
1290 //Standard_Boolean couture;
1291 ChFi3d_Couture(Fop,couture,edgecouture);
1293 if (couture && !BRep_Tool::Degenerated(edgecouture)) {
1294 BRepLib_MakeEdge Bedge (zob3d);
1295 TopoDS_Edge edg =Bedge. Edge();
1296 BRepExtrema_ExtCC extCC (edgecouture,edg);
1297 if (extCC.IsDone()&&extCC.NbExt()!=0) {
1298 for (Standard_Integer i=1; i<=extCC.NbExt()&&!intcouture;i++) {
1299 if (extCC.SquareDistance(i)<=1.e-8) {
1300 par1=extCC.ParameterOnE1(i);
1301 par2=extCC.ParameterOnE2(i);
1302 gp_Pnt P1=extCC.PointOnE1(i);
1303 TopOpeBRepDS_Point tpoint(P1,1.e-4);
1304 indpt=DStr.AddPoint(tpoint);
1305 intcouture=Standard_True;
1306 curv1 = new Geom_TrimmedCurve(zob3d,Udeb,par2);
1307 curv2 = new Geom_TrimmedCurve(zob3d,par2,Ufin);
1308 TopOpeBRepDS_Curve tcurv1(curv1,tolreached);
1309 TopOpeBRepDS_Curve tcurv2(curv2,tolreached);
1310 Icurv1=DStr.AddCurve(tcurv1);
1311 Icurv2=DStr.AddCurve(tcurv2);
1318 // interference of curv1 and curv2 on Ishape
1319 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv));
1320 ComputeCurve2d(curv1,Fop,c2d1);
1321 Handle(TopOpeBRepDS_SurfaceCurveInterference)
1322 InterFv = ChFi3d_FilCurveInDS(Icurv1,IShape,/*zob2dv*/c2d1,Et);
1323 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1324 ComputeCurve2d(curv2,Fop,c2d2);
1325 InterFv = ChFi3d_FilCurveInDS(Icurv2,IShape,/*zob2dv*/c2d2,Et);
1326 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1328 // limitation of the sewing edge
1329 Standard_Integer Iarc=DStr.AddShape(edgecouture);
1330 Handle(TopOpeBRepDS_CurvePointInterference) Interfedge;
1331 TopAbs_Orientation ori;
1332 TopoDS_Vertex Vdeb,Vfin;
1333 Vdeb=TopExp::FirstVertex(edgecouture);
1334 Vfin=TopExp::LastVertex(edgecouture);
1335 Standard_Real pard,parf;
1336 pard=BRep_Tool::Parameter(Vdeb,edgecouture);
1337 parf=BRep_Tool::Parameter(Vfin,edgecouture);
1338 if (Abs(par1-pard)<Abs(parf-par1)) ori=TopAbs_REVERSED;
1339 else ori=TopAbs_FORWARD;
1340 Interfedge = ChFi3d_FilPointInDS(ori,Iarc,indpt,par1);
1341 DStr.ChangeShapeInterferences(Iarc).Append(Interfedge);
1343 // interference of curv1 and curv2 on Iop
1344 Standard_Integer Iop = DStr.AddShape(Fop);
1345 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolop));
1346 Handle(TopOpeBRepDS_SurfaceCurveInterference) Interfop;
1347 ComputeCurve2d(curv1,Fop,c2d1);
1348 Interfop = ChFi3d_FilCurveInDS(Icurv1,Iop,c2d1,Et);
1349 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
1350 ComputeCurve2d(curv2,Fop,c2d2);
1351 Interfop = ChFi3d_FilCurveInDS(Icurv2,Iop,c2d2,Et);
1352 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
1353 Handle(TopOpeBRepDS_CurvePointInterference)
1354 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,Icurv1,IVtx,Udeb);
1355 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1356 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv1,indpt,par2);
1357 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1358 Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc);
1359 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv2,indpt,par2);
1360 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1361 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv2,icc,Ufin);
1362 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1365 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv));
1366 Handle(TopOpeBRepDS_SurfaceCurveInterference)
1367 InterFv = ChFi3d_FilCurveInDS(IZob,IShape,zob2dv,Et);
1368 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1369 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolop));
1370 Standard_Integer Iop = DStr.AddShape(Fop);
1371 Handle(TopOpeBRepDS_SurfaceCurveInterference)
1372 Interfop = ChFi3d_FilCurveInDS(IZob,Iop,zob2dop,Et);
1373 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
1374 Handle(TopOpeBRepDS_CurvePointInterference) interfprol;
1376 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IVtx,Udeb);
1379 Standard_Integer IV2 = DStr.AddShape(V2); // VARIANT 2
1380 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IV2,Udeb);
1383 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
1384 Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc);
1385 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,IZob,icc,Ufin);
1386 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
1389 if (IFopArc == 1) box1.Add( zob3d->Value(Ufin) );
1390 else box2.Add( zob3d->Value(Ufin) );
1394 // cut off existing Arcprol
1395 Standard_Integer iArcprol = DStr.AddShape(Arcprol);
1396 interfprol = ChFi3d_FilPointInDS(OVtx,iArcprol,icc,Udeb);
1397 DStr.ChangeShapeInterferences(Arcprol).Append(interfprol);
1402 ChFi3d_EnlargeBox(DStr,stripe,Fd,box1,box2,isfirst);
1403 if (CV1.IsOnArc()) {
1404 ChFi3d_EnlargeBox(CV1.Arc(),myEFMap(CV1.Arc()),CV1.ParameterOnArc(),box1);
1406 if (CV2.IsOnArc()) {
1407 ChFi3d_EnlargeBox(CV2.Arc(),myEFMap(CV2.Arc()),CV2.ParameterOnArc(),box2);
1409 if (!CV1.IsVertex())
1410 ChFi3d_SetPointTolerance(DStr,box1,stripe->IndexPoint(isfirst,1));
1411 if (!CV2.IsVertex())
1412 ChFi3d_SetPointTolerance(DStr,box2,stripe->IndexPoint(isfirst,2));
1415 ChFi3d_ResultChron(ch, t_sameinter);//result perf condition if (same &&inter)
1419 //=======================================================================
1420 //function : cherche_face
1421 //purpose : find face F belonging to the map, different from faces
1422 // F1 F2 F3 and containing edge E
1423 //=======================================================================
1425 static void cherche_face (const TopTools_ListOfShape & map,
1426 const TopoDS_Edge & E,
1427 const TopoDS_Face & F1,
1428 const TopoDS_Face & F2,
1429 const TopoDS_Face & F3,
1432 Standard_Boolean trouve=Standard_False;
1433 TopTools_ListIteratorOfListOfShape It;
1434 Standard_Integer ie;
1435 for (It.Initialize(map);It.More()&&!trouve;It.Next())
1436 { Fcur=TopoDS::Face (It.Value());
1437 if (!Fcur.IsSame(F1) && !Fcur.IsSame(F2)&& !Fcur.IsSame(F3) )
1438 { TopTools_IndexedMapOfShape MapE;
1439 TopExp::MapShapes( Fcur,TopAbs_EDGE,MapE);
1440 for ( ie=1; ie<= MapE.Extent()&&!trouve; ie++)
1442 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE(ie));
1443 if (E.IsSame(TopoDS::Edge(aLocalShape)))
1444 // if (E.IsSame(TopoDS::Edge(TopoDS_Shape (MapE(ie)))))
1445 { F= Fcur; trouve=Standard_True;}
1451 //=======================================================================
1452 //function : cherche_edge1
1453 //purpose : find common edge between faces F1 and F2
1454 //=======================================================================
1456 static void cherche_edge1 (const TopoDS_Face & F1,
1457 const TopoDS_Face & F2,
1459 { Standard_Integer i,j;
1460 TopoDS_Edge Ecur1,Ecur2;
1461 Standard_Boolean trouve=Standard_False;
1462 TopTools_IndexedMapOfShape MapE1,MapE2;
1463 TopExp::MapShapes( F1,TopAbs_EDGE,MapE1);
1464 TopExp::MapShapes( F2,TopAbs_EDGE,MapE2);
1465 for ( i=1; i<= MapE1.Extent()&&!trouve; i++)
1467 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE1(i));
1468 Ecur1=TopoDS::Edge(aLocalShape);
1469 // Ecur1=TopoDS::Edge(TopoDS_Shape (MapE1(i)));
1470 for ( j=1; j<= MapE2.Extent()&&!trouve; j++)
1472 aLocalShape = TopoDS_Shape (MapE2(j));
1473 Ecur2=TopoDS::Edge(aLocalShape);
1474 // Ecur2=TopoDS::Edge(TopoDS_Shape (MapE2(j)));
1475 if (Ecur2.IsSame(Ecur1))
1476 {Edge=Ecur1;trouve=Standard_True;}
1481 //=======================================================================
1482 //function : containV
1483 //purpose : return true if vertex V belongs to F1
1484 //=======================================================================
1486 static Standard_Boolean containV(const TopoDS_Face & F1,
1487 const TopoDS_Vertex & V)
1488 { Standard_Integer i;
1490 Standard_Boolean trouve=Standard_False;
1491 Standard_Boolean contain=Standard_False;
1492 TopTools_IndexedMapOfShape MapV;
1493 TopExp::MapShapes( F1,TopAbs_VERTEX,MapV);
1494 for ( i=1; i<= MapV.Extent()&&!trouve; i++)
1496 TopoDS_Shape aLocalShape = TopoDS_Shape (MapV(i));
1497 Vcur=TopoDS::Vertex(aLocalShape);
1498 // Vcur=TopoDS::Vertex(TopoDS_Shape (MapV(i)));
1499 if (Vcur.IsSame(V) )
1500 {contain=Standard_True; trouve=Standard_True;}
1505 //=======================================================================
1506 //function : containE
1507 //purpose : return true if edge E belongs to F1
1508 //=======================================================================
1510 static Standard_Boolean containE(const TopoDS_Face & F1,
1511 const TopoDS_Edge & E)
1512 { Standard_Integer i;
1514 Standard_Boolean trouve=Standard_False;
1515 Standard_Boolean contain=Standard_False;
1516 TopTools_IndexedMapOfShape MapE;
1517 TopExp::MapShapes( F1,TopAbs_EDGE,MapE);
1518 for ( i=1; i<= MapE.Extent()&&!trouve; i++)
1520 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE(i));
1521 Ecur=TopoDS::Edge(aLocalShape);
1522 // Ecur=TopoDS::Edge(TopoDS_Shape (MapE(i)));
1523 if (Ecur.IsSame(E) )
1524 {contain=Standard_True; trouve=Standard_True;}
1530 //=======================================================================
1531 //function : IsShrink
1532 //purpose : check if U (if <isU>==True) or V of points of <PC> is within
1533 // <tol> from <Param>, check points between <Pf> and <Pl>
1534 //=======================================================================
1536 static Standard_Boolean IsShrink(const Geom2dAdaptor_Curve PC,
1537 const Standard_Real Pf,
1538 const Standard_Real Pl,
1539 const Standard_Real Param,
1540 const Standard_Boolean isU,
1541 const Standard_Real tol)
1543 switch (PC.GetType()) {
1544 case GeomAbs_Line: {
1545 gp_Pnt2d P1 = PC.Value(Pf);
1546 gp_Pnt2d P2 = PC.Value(Pl);
1547 if (Abs(P1.Coord(isU ? 1 : 2) - Param) <= tol &&
1548 Abs(P2.Coord(isU ? 1 : 2) - Param) <= tol )
1549 return Standard_True;
1551 return Standard_False;
1553 case GeomAbs_BezierCurve:
1554 case GeomAbs_BSplineCurve: {
1555 math_FunctionSample aSample (Pf,Pl,10);
1557 for (i=1; i<=aSample.NbPoints(); i++) {
1558 gp_Pnt2d P = PC.Value(aSample.GetParameter(i));
1559 if (Abs(P.Coord(isU ? 1 : 2) - Param) > tol )
1560 return Standard_False;
1562 return Standard_True;
1566 return Standard_False;
1568 //=======================================================================
1569 //function : PerformIntersectionAtEnd
1571 //=======================================================================
1573 void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
1576 // intersection at end of fillet with at least two faces
1577 // process the following cases:
1578 // - top has n (n>3) adjacent edges
1579 // - top has 3 edges and fillet on one of edges touches
1580 // more than one face
1583 OSD_Chronometer ch;// init perf
1586 TopOpeBRepDS_DataStructure& DStr= myDS->ChangeDS();
1587 const Standard_Integer nn=15;
1588 ChFiDS_ListIteratorOfListOfStripe It;
1589 It.Initialize(myVDataMap(Index));
1590 Handle(ChFiDS_Stripe) stripe = It.Value();
1591 const Handle(ChFiDS_Spine) spine = stripe->Spine();
1592 ChFiDS_SequenceOfSurfData& SeqFil =
1593 stripe->ChangeSetOfSurfData()->ChangeSequence();
1594 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
1595 Standard_Integer sens = 0,num,num1;
1596 Standard_Boolean couture=Standard_False,isfirst;
1597 //Standard_Integer sense;
1598 TopoDS_Edge edgelibre1,edgelibre2,EdgeSpine;
1599 Standard_Boolean bordlibre;
1600 // determine the number of faces and edges
1601 TopTools_Array1OfShape tabedg(0,nn);
1603 Standard_Integer nface=ChFi3d_nbface(myVFMap(Vtx));
1604 TopTools_ListIteratorOfListOfShape ItF;
1605 Standard_Integer nbarete;
1606 nbarete=ChFi3d_NbNotDegeneratedEdges(Vtx,myVEMap);
1607 ChFi3d_ChercheBordsLibres(myVEMap,Vtx,bordlibre,edgelibre1,edgelibre2);
1608 if (bordlibre) nbarete=(nbarete-2)/2 +2;
1609 else nbarete=nbarete/2;
1610 // it is determined if there is an edge of sewing and it face
1612 TopoDS_Face facecouture;
1613 TopoDS_Edge edgecouture;
1615 Standard_Boolean trouve=Standard_False;
1616 for(ItF.Initialize(myVFMap(Vtx));ItF.More()&&!couture;ItF.Next()) {
1617 TopoDS_Face fcur = TopoDS::Face(ItF.Value());
1618 ChFi3d_CoutureOnVertex(fcur,Vtx,couture,edgecouture);
1622 // it is determined if one of edges adjacent to the fillet is regular
1623 Standard_Boolean reg1,reg2;
1624 TopoDS_Edge Ecur,Eadj1,Eadj2;
1625 TopoDS_Face Fga,Fdr;
1626 TopoDS_Vertex Vbid1;
1627 Standard_Integer nbsurf,nbedge;
1628 reg1=Standard_False;
1629 reg2=Standard_False;
1630 nbsurf= SeqFil.Length();
1631 nbedge = spine->NbEdges();
1632 num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
1633 isfirst = (sens == 1);
1636 EdgeSpine=spine->Edges(1);
1638 state = spine->FirstStatus();
1641 EdgeSpine=spine->Edges(nbedge);
1643 state = spine->LastStatus();
1645 if (nbsurf!=nbedge && nbsurf!=1) {
1646 ChFi3d_edge_common_faces(myEFMap(EdgeSpine),F1,F2);
1647 if (F1.IsSame(facecouture)) Eadj1=edgecouture;
1648 else ChFi3d_cherche_element(Vtx,EdgeSpine,F1,Eadj1,Vbid1);
1649 ChFi3d_edge_common_faces(myEFMap(Eadj1),Fga,Fdr);
1650 // Modified by Sergey KHROMOV - Fri Dec 21 17:57:32 2001 Begin
1651 // reg1=BRep_Tool::Continuity(Eadj1,Fga,Fdr)!=GeomAbs_C0;
1652 reg1=isTangentFaces(Eadj1,Fga,Fdr);
1653 // Modified by Sergey KHROMOV - Fri Dec 21 17:57:33 2001 End
1654 if (F2.IsSame(facecouture)) Eadj2=edgecouture;
1655 else ChFi3d_cherche_element(Vtx,EdgeSpine,F2,Eadj2,Vbid1);
1656 ChFi3d_edge_common_faces(myEFMap(Eadj2),Fga,Fdr);
1657 // Modified by Sergey KHROMOV - Fri Dec 21 17:58:22 2001 Begin
1658 // reg2=BRep_Tool::Continuity(Eadj2,Fga,Fdr)!=GeomAbs_C0;
1659 reg2=isTangentFaces(Eadj2,Fga,Fdr);
1660 // Modified by Sergey KHROMOV - Fri Dec 21 17:58:24 2001 End
1662 // two faces common to the edge are found
1664 Standard_Boolean compoint1=Standard_False;
1665 Standard_Boolean compoint2=Standard_False;
1666 ChFiDS_CommonPoint cp1, cp2;
1667 cp1 = SeqFil(num1)->ChangeVertex (isfirst,1);
1668 cp2 = SeqFil(num1)->ChangeVertex (isfirst,2);
1669 if (cp1.IsOnArc()) {
1670 if (cp1.Arc().IsSame(Eadj1)||cp1.Arc().IsSame(Eadj2))
1671 compoint1=Standard_True;
1673 if (cp2.IsOnArc()) {
1674 if (cp2.Arc().IsSame(Eadj1)||cp2.Arc().IsSame(Eadj2))
1675 compoint2=Standard_True;
1677 if (compoint1 && compoint2) {
1679 reg1=Standard_False; reg2=Standard_False;
1683 // there is only one face at end if FindFace is true and if the face
1684 // is not the face with sewing edge
1686 Handle(ChFiDS_SurfData) Fd = SeqFil.ChangeValue(num);
1687 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
1688 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
1689 Standard_Boolean onecorner=Standard_False;
1690 if (FindFace(Vtx,CV1,CV2,face)) {
1691 if (!couture) onecorner =Standard_True;
1692 else if (!face.IsSame(facecouture))
1693 onecorner=Standard_True;
1696 if (ChFi3d_Builder::MoreSurfdata(Index)) {
1697 ChFi3d_Builder::PerformMoreSurfdata(Index);
1701 if (!onecorner && (reg1||reg2) && !couture && state!=ChFiDS_OnSame) {
1702 PerformMoreThreeCorner (Index,1);
1705 Handle(GeomAdaptor_HSurface) HGs = ChFi3d_BoundSurf(DStr,Fd,1,2);
1706 ChFiDS_FaceInterference Fi1 = Fd->InterferenceOnS1();
1707 ChFiDS_FaceInterference Fi2 = Fd->InterferenceOnS2();
1708 GeomAdaptor_Surface& Gs = HGs->ChangeSurface();
1709 Handle(BRepAdaptor_HSurface) HBs = new BRepAdaptor_HSurface();
1710 BRepAdaptor_Surface& Bs = HBs->ChangeSurface();
1711 Handle(Geom_Curve) Cc;
1712 Handle(Geom2d_Curve) Pc,Ps;
1713 Standard_Real Ubid,Vbid;
1714 TopAbs_Orientation orsurfdata;
1715 orsurfdata=Fd->Orientation();
1716 Standard_Integer IsurfPrev=0, Isurf=Fd->Surf();
1717 Handle(ChFiDS_SurfData) SDprev;
1718 if (num1>0 && num1<=SeqFil.Length()) {
1719 SDprev = SeqFil(num1);
1720 IsurfPrev = SDprev->Surf();
1722 // calculate the orientation of curves at end
1724 Standard_Real tolpt=1.e-4;
1725 Standard_Real tolreached;
1726 TopAbs_Orientation orcourbe,orface,orien;
1728 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV1,DStr),isfirst,1);
1729 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV2,DStr),isfirst,2);
1734 Standard_Integer Ishape1=Fd->IndexOfS1();
1735 TopAbs_Orientation trafil1 = TopAbs_FORWARD;
1738 trafil1 = DStr.Shape(Ishape1).Orientation();
1742 cout<<"erreur"<<endl;
1745 trafil1 = TopAbs::Compose(trafil1,Fd->Orientation());
1747 trafil1 = TopAbs::Compose(TopAbs::Reverse(Fi1.Transition()),trafil1);
1750 else cout<<"erreur"<<endl;
1752 // eap, Apr 22 2002, occ 293
1753 // Fi1.PCurveOnFace()->D0(Fi1.LastParameter(),p2d);
1754 // const Handle(Geom_Surface) Stemp =
1755 // BRep_Tool::Surface(TopoDS::Face(DStr.Shape(Ishape1)));
1756 // Stemp ->D0(p2d.X(),p2d.Y(),p3d);
1757 // dist=p3d.Distance(CV1.Point());
1758 // if (dist<tolpt) orcourbe=trafil1;
1759 // else orcourbe=TopAbs::Reverse(trafil1);
1760 if (!isfirst) orcourbe=trafil1;
1761 else orcourbe=TopAbs::Reverse(trafil1);
1763 // eap, Apr 22 2002, occ 293
1764 // variables to show OnSame situation
1765 Standard_Boolean isOnSame1, isOnSame2;
1766 // In OnSame situation, the case of degenerated FaceInterference curve
1767 // is probable when a corner cuts the ChFi3d earlier built on OnSame edge.
1768 // In such a case, chamfer face can partially shrink to a line and we need
1769 // to cut off that shrinked part
1770 // If <isOnSame1>, FaceInterference with F2 can be degenerated
1771 Standard_Boolean checkShrink, isShrink, isUShrink;
1772 isShrink = isUShrink = isOnSame1 = isOnSame2 = Standard_False;
1773 Standard_Real checkShrParam=0., prevSDParam=0.;
1775 Standard_Integer midIpoint=0;
1777 // find Fi1,Fi2 lengths used to extend ChFi surface
1778 // and by the way define necessity to check shrink
1779 gp_Pnt2d P2d1=Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));
1780 gp_Pnt2d P2d2=Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
1782 HGs->D0( P2d1.X(),P2d1.Y(),aP1);
1783 HGs->D0( P2d2.X(),P2d2.Y(),aP2);
1784 Standard_Real Fi1Length=aP1.Distance(aP2);
1785 // Standard_Real eps = Precision::Confusion();
1786 checkShrink = (Fi1Length <= Precision::Confusion());
1788 gp_Pnt2d P2d3=Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
1789 gp_Pnt2d P2d4=Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
1790 HGs->D0( P2d3.X(),P2d3.Y(),aP1);
1791 HGs->D0( P2d4.X(),P2d4.Y(),aP2);
1792 Standard_Real Fi2Length=aP1.Distance(aP2);
1793 checkShrink = checkShrink || (Fi2Length <= Precision::Confusion());
1796 if (Abs(P2d2.Y()-P2d4.Y()) <= Precision::PConfusion()) {
1797 isUShrink = Standard_False;
1798 checkShrParam = P2d2.Y();
1799 } else if (Abs(P2d2.X()-P2d4.X()) <= Precision::PConfusion()) {
1800 isUShrink = Standard_True;
1801 checkShrParam = P2d2.X();
1804 checkShrink = Standard_False;
1807 /***********************************************************************/
1808 // find faces intersecting with the fillet and edges limiting intersections
1809 // nbface is the nb of faces intersected, Face[i] contais the faces
1810 // to intersect (i=0.. nbface-1). Edge[i] contains edges limiting
1811 // the intersections (i=0 ..nbface)
1812 /**********************************************************************/
1814 Standard_Integer nb = 1,nbface;
1815 TopoDS_Edge E1 ,E2, Edge[nn],E,Ei,edgesau;
1816 TopoDS_Face facesau;
1817 Standard_Boolean oneintersection1=Standard_False;
1818 Standard_Boolean oneintersection2=Standard_False;
1819 TopoDS_Face Face[nn],F,F3;
1820 TopoDS_Vertex V1,V2,V,Vfin;
1821 Standard_Boolean findonf1=Standard_False,findonf2=Standard_False;
1822 TopTools_ListIteratorOfListOfShape It3;
1823 F1=TopoDS::Face(DStr.Shape(Fd->IndexOfS1()));
1824 F2=TopoDS::Face(DStr.Shape(Fd->IndexOfS2()));
1826 if (couture || bordlibre) nface=nface+1;
1827 if (nface==3) nbface=2;
1828 else nbface=nface-2;
1829 if (!CV1.IsOnArc()||!CV2.IsOnArc()) {
1830 PerformMoreThreeCorner(Index,1);
1835 Edge[nbface]=CV2.Arc();
1836 tabedg.SetValue(0,Edge[0]);
1837 tabedg.SetValue(nbface,Edge[nbface]);
1838 // processing of a fillet arriving on a vertex
1839 // edge contained in CV.Arc is not inevitably good
1840 // the edge concerned by the intersection is found
1842 Standard_Real dist1,dist2;
1843 if (CV1.IsVertex()) {
1844 trouve=Standard_False;
1845 /*TopoDS_Vertex */V=CV1.Vertex();
1846 for (It3.Initialize(myVEMap(V));It3.More()&&!trouve;It3.Next()) {
1847 E=TopoDS::Edge (It3.Value());
1848 if (!E.IsSame(Edge[0])&&(containE(F1,E)))
1849 trouve=Standard_True;
1851 TopoDS_Vertex Vt,V3,V4;
1852 V1=TopExp::FirstVertex(Edge[0]);
1853 V2=TopExp::LastVertex(Edge[0]);
1854 if (V.IsSame(V1)) Vt=V2;
1856 dist1=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1857 V3=TopExp::FirstVertex(E);
1858 V4=TopExp::LastVertex(E);
1859 if (V.IsSame(V3)) Vt=V4;
1861 dist2=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1864 TopAbs_Orientation ori;
1865 if (V2.IsSame(V3)||V1.IsSame(V4)) ori=CV1.TransitionOnArc();
1866 else ori=TopAbs::Reverse(CV1.TransitionOnArc());
1867 Standard_Real par= BRep_Tool::Parameter(V,Edge[0]);
1868 Standard_Real tol= CV1.Tolerance();
1869 CV1.SetArc(tol,Edge[0],par,ori);
1873 if (CV2.IsVertex()) {
1874 trouve=Standard_False;
1875 /*TopoDS_Vertex*/ V=CV2.Vertex();
1876 for (It3.Initialize(myVEMap(V));It3.More()&&!trouve;It3.Next()) {
1877 E=TopoDS::Edge (It3.Value());
1878 if (!E.IsSame(Edge[2])&&(containE(F2,E)))
1879 trouve=Standard_True;
1881 TopoDS_Vertex Vt,V3,V4;
1882 V1=TopExp::FirstVertex(Edge[2]);
1883 V2=TopExp::LastVertex(Edge[2]);
1884 if (V.IsSame(V1)) Vt=V2;
1886 dist1=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1887 V3=TopExp::FirstVertex(E);
1888 V4=TopExp::LastVertex(E);
1889 if (V.IsSame(V3)) Vt=V4;
1891 dist2=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1894 TopAbs_Orientation ori;
1895 if (V2.IsSame(V3)||V1.IsSame(V4)) ori=CV2.TransitionOnArc();
1896 else ori=TopAbs::Reverse(CV2.TransitionOnArc());
1897 Standard_Real par= BRep_Tool::Parameter(V,Edge[2]);
1898 Standard_Real tol= CV2.Tolerance();
1899 CV2.SetArc(tol,Edge[2],par,ori);
1903 // If there is a regular edge, the faces adjacent to it
1904 // are not in Fd->IndexOfS1 or Fd->IndexOfS2
1906 // TopoDS_Face Find1 ,Find2;
1908 // edge=stripe->Spine()->Edges(1);
1909 // else edge=stripe->Spine()->Edges(stripe->Spine()->NbEdges());
1910 // It3.Initialize(myEFMap(edge));
1911 // Find1=TopoDS::Face(It3.Value());
1912 // trouve=Standard_False;
1913 // for (It3.Initialize(myEFMap(edge));It3.More()&&!trouve;It3.Next()) {
1914 // F=TopoDS::Face (It3.Value());
1915 // if (!F.IsSame(Find1)) {
1916 // Find2=F;trouve=Standard_True;
1920 // if nface =3 there is a top with 3 edges and a fillet
1921 // and their common points are on different faces
1922 // otherwise there is a case when a top has more than 3 edges
1925 if (CV1.IsVertex ()) findonf1=Standard_True;
1926 if (CV2.IsVertex ()) findonf2=Standard_True;
1928 TopTools_IndexedMapOfShape MapV;
1929 TopExp::MapShapes(Edge[0], TopAbs_VERTEX, MapV);
1930 if (MapV.Extent()==2)
1931 if (!MapV(1).IsSame(Vtx) && !MapV(2).IsSame(Vtx))
1932 findonf1=Standard_True;
1935 TopTools_IndexedMapOfShape MapV;
1936 TopExp::MapShapes(Edge[2], TopAbs_VERTEX, MapV);
1937 if (MapV.Extent()==2)
1938 if (!MapV(1).IsSame(Vtx) && !MapV(2).IsSame(Vtx))
1939 findonf2=Standard_True;
1942 // detect and process OnSame situatuation
1943 if (state == ChFiDS_OnSame) {
1944 TopoDS_Edge threeE[3];
1945 ChFi3d_cherche_element(Vtx,EdgeSpine, F1,threeE[0], V2);
1946 ChFi3d_cherche_element(Vtx,EdgeSpine, F2,threeE[1], V2);
1947 threeE[2] = EdgeSpine;
1948 if (ChFi3d_EdgeState(threeE,myEFMap) == ChFiDS_OnSame) {
1949 isOnSame1 = Standard_True;
1951 Edge[0] = threeE[0];
1952 ChFi3d_cherche_face1(myEFMap(Edge[0]),F1,Face[0]);
1954 findonf1 = Standard_True; // not to look for Face[0] again
1959 isOnSame2 = Standard_True;
1963 // findonf1 findonf2 show if F1 and/or F2 are adjacent
1964 // to many faces at end
1965 // the faces at end and intersected edges are found
1967 if (findonf1 && !isOnSame1) {
1968 if (CV1.TransitionOnArc()==TopAbs_FORWARD)
1969 V1=TopExp::FirstVertex(CV1.Arc());
1971 V1=TopExp::LastVertex(CV1.Arc());
1972 ChFi3d_cherche_face1(myEFMap(CV1.Arc()),F1,Face[0]);
1975 while (!V1.IsSame(Vtx)) {
1976 ChFi3d_cherche_element(V1,Ei,F1,E,V2);
1978 ChFi3d_cherche_face1(myEFMap(E),F1,Face[nb]);
1979 cherche_edge1(Face[nb-1],Face[nb],Edge[nb]);
1981 if (nb>=nn) Standard_Failure::Raise
1982 ("IntersectionAtEnd : the max number of faces reached");
1984 if (!findonf2) Edge[nb]=CV2.Arc();
1986 if (findonf2 && !isOnSame2) {
1987 if (!findonf1 ) nb=1;
1989 if (CV2.TransitionOnArc()==TopAbs_FORWARD)
1990 Vfin=TopExp::LastVertex(CV2.Arc());
1992 Vfin=TopExp::FirstVertex(CV2.Arc());
1993 if (!findonf1) ChFi3d_cherche_face1(myEFMap(CV1.Arc()),F1,Face[nb-1]);
1994 ChFi3d_cherche_element(V1,EdgeSpine,F2,E,V2);
1996 while (!V1.IsSame(Vfin)) {
1997 ChFi3d_cherche_element(V1,Ei,F2,E,V2);
2000 ChFi3d_cherche_face1(myEFMap(E),F2,Face[nb]);
2001 cherche_edge1(Face[nb-1],Face[nb],Edge[nb]);
2003 if (nb>=nn) Standard_Failure::Raise
2004 ("IntersectionAtEnd : the max number of faces reached");
2009 cherche_edge1(Face[nb-1],F2,Edge[nb]);
2018 // this is the case when a top has more than three edges
2019 // the faces and edges concerned are found
2020 Standard_Boolean /*trouve,*/possible1, possible2;
2021 trouve = possible1 = possible2 = Standard_False;
2024 for (ex.Init(CV1.Arc(),TopAbs_VERTEX);ex.More();ex.Next()) {
2025 if (Vtx.IsSame(ex.Current())) possible1 = Standard_True;
2027 for (ex.Init(CV2.Arc(),TopAbs_VERTEX);ex.More();ex.Next()) {
2028 if (Vtx.IsSame(ex.Current())) possible2 = Standard_True;
2030 if ((possible1 && possible2) || (!possible1 && !possible2) || (nbarete > 4)) {
2033 if (nb!=1) F3=Face[nb-2];
2035 if (CV1.Arc().IsSame(edgelibre1))
2036 cherche_face(myVFMap(Vtx),edgelibre2,F1,F2,F3,Face[nb-1]);
2037 else if (CV1.Arc().IsSame(edgelibre2))
2038 cherche_face(myVFMap(Vtx),edgelibre1,F1,F2,F3,Face[nb-1]);
2039 else cherche_face(myVFMap(Vtx),Edge[nb-1],F1,F2,F3,Face[nb-1]);
2040 ChFi3d_cherche_edge(Vtx,tabedg,Face[nb-1],Edge[nb],V);
2041 tabedg.SetValue(nb,Edge[nb]);
2042 if (Edge[nb].IsSame(CV2.Arc())) trouve=Standard_True;
2047 IntersectMoreCorner (Index);
2051 // if two consecutive edges are G1 there is only one face of intersection
2052 Standard_Real ang1=0.0;
2054 trouve=Standard_False;
2055 ChFi3d_cherche_vertex ( Edge[0],Edge[1],Vcom,trouve);
2056 if (Vcom.IsSame(Vtx)) ang1=ChFi3d_AngleEdge(Vtx,Edge[0],Edge[1]);
2057 if (Abs(ang1-M_PI)<0.01) {
2058 oneintersection1=Standard_True;
2066 if (!oneintersection1) {
2067 trouve=Standard_False;
2068 ChFi3d_cherche_vertex ( Edge[1],Edge[2],Vcom,trouve);
2069 if (Vcom.IsSame(Vtx)) ang1=ChFi3d_AngleEdge(Vtx,Edge[1],Edge[2]);
2070 if (Abs(ang1-M_PI)<0.01) {
2071 oneintersection2=Standard_True;
2079 else if (nbarete==5) {
2081 // Modified by Sergey KHROMOV - Fri Dec 21 18:07:43 2001 End
2082 Standard_Boolean isTangent0 = isTangentFaces(Edge[0],F1,Face[0]);
2083 Standard_Boolean isTangent1 = isTangentFaces(Edge[1],Face[0],Face[1]);
2084 Standard_Boolean isTangent2 = isTangentFaces(Edge[2],Face[1],Face[2]);
2085 if ((isTangent0 || isTangent2) && isTangent1) {
2086 // GeomAbs_Shape cont0,cont1,cont2;
2087 // cont0=BRep_Tool::Continuity(Edge[0],F1,Face[0]);
2088 // cont1=BRep_Tool::Continuity(Edge[1],Face[0],Face[1]);
2089 // cont2=BRep_Tool::Continuity(Edge[2],Face[1],Face[2]);
2090 // if ((cont0!=GeomAbs_C0 || cont2!=GeomAbs_C0) && cont1!=GeomAbs_C0) {
2091 // Modified by Sergey KHROMOV - Fri Dec 21 18:07:49 2001 Begin
2097 oneintersection1=Standard_True;
2108 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
2109 gp_Pnt2d pfil1,pfac1,pfil2,pfac2,pint,pfildeb;
2110 Handle(Geom2d_Curve) Hc1,Hc2;
2111 IntCurveSurface_HInter inters;
2112 Standard_Integer proledge[nn],prolface[nn+1];// last prolface[nn] is for Fd
2113 Standard_Integer shrink[nn];
2114 TopoDS_Face faceprol[nn];
2115 Standard_Integer indcurve[nn],indpoint2=0,indpoint1 = 0;
2116 Handle (TopOpeBRepDS_CurvePointInterference) Interfp1, Interfp2, Interfedge[nn];
2117 Handle (TopOpeBRepDS_SurfaceCurveInterference) Interfc,InterfPC[nn],InterfPS[nn];
2118 Standard_Real u2,v2,p1,p2,paredge1;
2119 Standard_Real paredge2 = 0.,tolex = 1.e-4;
2120 Standard_Boolean extend=Standard_False;
2121 Handle(Geom_Surface) Sfacemoins1,Sface;
2122 /***************************************************************************/
2123 // calculate intersection of the fillet and each face
2124 // and storage in the DS
2125 /***************************************************************************/
2126 for (nb=1;nb<=nbface;nb++) {
2133 if (oneintersection1||oneintersection2) faceprol[1]=facesau;
2134 if (!isOnSame1 && !isOnSame2)
2135 checkShrink = Standard_False;
2136 // in OnSame situation we need intersect Fd with Edge[0] or Edge[nbface] as well
2137 if (isOnSame1) nb=0;
2139 Standard_Boolean intersOnSameFailed = Standard_False;
2141 for ( ; nb<=nbface; nb++) {
2142 extend=Standard_False;
2148 if (!prolface[nb-1]) faceprol[nb-1]=F;
2150 Sfacemoins1=BRep_Tool::Surface(F);
2151 Handle(Geom_Curve) cint;
2152 Handle(Geom2d_Curve) C2dint1, C2dint2,cface,cfacemoins1;
2154 ///////////////////////////////////////////////////////
2155 // determine intersections of edges and the fillet
2156 // to find limitations of intersections face - fillet
2157 ///////////////////////////////////////////////////////
2160 Hc1 = BRep_Tool::CurveOnSurface(Edge[0],Face[0],Ubid,Ubid);
2162 // update interference param on Fi1 and point of CV1
2163 if (prolface[0]) Bs.Initialize(faceprol[0], Standard_False);
2164 else Bs.Initialize(Face[0], Standard_False);
2165 const Handle(Geom_Curve)& c3df = DStr.Curve(Fi1.LineIndex()).Curve();
2166 Standard_Real Ufi= Fi2.Parameter(isfirst);
2167 ChFiDS_FaceInterference& Fi = Fd->ChangeInterferenceOnS1();
2168 if (!IntersUpdateOnSame (HGs,HBs,c3df,F1,Face[0],Edge[0],Vtx,isfirst,10*tolesp, // in
2169 Fi,CV1,pfac1,Ufi)) // out
2170 Standard_Failure::Raise("IntersectionAtEnd: pb intersection Face - Fi");
2172 if (intersOnSameFailed) { // probable at fillet building
2173 // look for paredge2
2174 Geom2dAPI_ProjectPointOnCurve proj;
2175 if (C2dint2.IsNull()) proj.Init(pfac1,Hc1);
2176 else proj.Init(pfac1,C2dint2);
2177 paredge2 = proj.LowerDistanceParameter();
2179 // update stripe point
2180 TopOpeBRepDS_Point tpoint (CV1.Point(),tolesp);
2181 indpoint1=DStr.AddPoint(tpoint);
2182 stripe->SetIndexPoint(indpoint1,isfirst,1);
2184 TopoDS_Vertex vert1,vert2;
2185 TopExp::Vertices(Edge[0],vert1,vert2);
2186 TopAbs_Orientation arcOri = Vtx.IsSame(vert1) ? TopAbs_FORWARD : TopAbs_REVERSED;
2187 CV1.SetArc(tolesp,Edge[0],paredge2,arcOri);
2191 // curve 2d not found. Sfacemoins1 is extended and projection is done there
2193 ChFi3d_ExtendSurface(Sfacemoins1,prolface[0]);
2195 extend=Standard_True;
2197 Standard_Real tol=BRep_Tool::Tolerance(F);
2198 BRE.MakeFace(faceprol[0],Sfacemoins1,F.Location(),tol);
2200 GeomAdaptor_Surface Asurf;
2201 Asurf.Load(Sfacemoins1);
2202 Extrema_ExtPS ext (CV1.Point(),Asurf, tol,tol);
2203 Standard_Real uc1,vc1;
2205 ext.Point(1).Parameter(uc1,vc1);
2213 pfac1 = Hc1->Value(CV1.ParameterOnArc());
2215 paredge1=CV1.ParameterOnArc();
2216 if (Fi1.LineIndex() != 0) {
2217 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));}
2219 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));}
2228 if (nb!=nbface || isOnSame2) {
2229 Standard_Integer nbp;
2231 Handle(Geom_Curve) C;
2232 C=BRep_Tool::Curve(E2,Ubid,Vbid);
2233 Handle(Geom_TrimmedCurve) Ctrim = new Geom_TrimmedCurve(C,Ubid,Vbid);
2234 Standard_Real Utrim,Vtrim;
2235 Utrim=Ctrim->BasisCurve()->FirstParameter();
2236 Vtrim=Ctrim->BasisCurve()->LastParameter();
2237 if (Ctrim->IsPeriodic()) {
2238 if (Ubid>Ctrim->Period()) {
2239 Ubid=(Utrim+Vtrim)/2;
2244 Vbid=(Utrim+Vtrim)/2;
2251 Handle(GeomAdaptor_HCurve) HC =
2252 new GeomAdaptor_HCurve(C,Ubid,Vbid);
2253 GeomAdaptor_Curve & Cad =HC->ChangeCurve();
2254 inters.Perform(HC, HGs);
2255 if ( !prolface[nn] && ( !inters.IsDone() || (inters.NbPoints()==0) )) {
2256 // extend surface of conge
2257 Handle(Geom_BSplineSurface) S1=
2258 Handle(Geom_BSplineSurface)::DownCast(DStr.Surface(Fd->Surf()).Surface());
2260 Standard_Real length = 0.5 * Max(Fi1Length,Fi2Length);
2261 GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,!isfirst);
2263 if (!stripe->IsInDS(!isfirst)) {
2265 inters.Perform(HC, HGs);
2266 if (inters.IsDone()&& inters.NbPoints()!=0) {
2267 Fd->ChangeSurf(DStr.AddSurface(TopOpeBRepDS_Surface(S1, DStr.ChangeSurface(Isurf).Tolerance())));
2273 if (!inters.IsDone() || (inters.NbPoints()==0)) {
2274 Handle(Geom_BSplineCurve) cd=Handle(Geom_BSplineCurve)::DownCast(C);
2275 Handle(Geom_BezierCurve) cd1=Handle(Geom_BezierCurve)::DownCast(C);
2276 if (!cd.IsNull() || !cd1.IsNull() ) {
2278 Sface=BRep_Tool::Surface(Face[nb]);
2279 ChFi3d_ExtendSurface(Sface,prolface[nb]);
2280 Standard_Real tol=BRep_Tool::Tolerance(F);
2281 BRE.MakeFace(faceprol[nb],Sface,Face[nb].Location(),tol);
2282 if (nb && !prolface[nb-1]) {
2283 ChFi3d_ExtendSurface(Sfacemoins1,prolface[nb-1]);
2284 if (prolface[nb-1]) {
2285 tol=BRep_Tool::Tolerance(F);
2286 BRE.MakeFace(faceprol[nb-1],Sfacemoins1,F.Location(),tol);
2290 Standard_Integer prol = 0;
2291 ChFi3d_ExtendSurface(Sfacemoins1,prol);
2293 GeomInt_IntSS InterSS(Sfacemoins1,Sface,1.e-7,1,1,1);
2294 if (InterSS.IsDone()) {
2295 trouve=Standard_False;
2296 for (Standard_Integer i=1; i<=InterSS.NbLines() && !trouve; i++) {
2297 extend=Standard_True;
2298 cint= InterSS.Line(i);
2299 C2dint1= InterSS.LineOnS1(i);
2300 C2dint2= InterSS.LineOnS2(i);
2302 inters.Perform(HC, HGs);
2303 trouve=inters.IsDone()&&inters.NbPoints()!=0;
2304 // eap occ293, eval tolex on finally trimmed curves
2305 // Handle(GeomAdaptor_HSurface) H1=new GeomAdaptor_HSurface(Sfacemoins1);
2306 // Handle(GeomAdaptor_HSurface) H2=new GeomAdaptor_HSurface(Sface);
2307 // tolex=ChFi3d_EvalTolReached(H1,C2dint1,H2,C2dint2,cint);
2308 tolex = InterSS.TolReached3d();
2313 if (inters.IsDone()) {
2314 nbp = inters.NbPoints();
2316 if (nb==0 || nb==nbface)
2317 intersOnSameFailed = Standard_True;
2319 PerformMoreThreeCorner (Index,1);
2324 gp_Pnt P=BRep_Tool::Pnt(Vtx);
2325 Standard_Real distmin=P.Distance(inters.Point(1).Pnt());
2327 for (Standard_Integer i=2;i<=inters.NbPoints();i++) {
2328 dist=P.Distance(inters.Point(i).Pnt());
2334 gp_Pnt2d pt2d (inters.Point(nbp).U(),inters.Point(nbp).V());
2336 paredge2=inters.Point(nbp).W();
2338 cfacemoins1=BRep_Tool::CurveOnSurface(E2,F,u2,v2);
2339 cface=BRep_Tool::CurveOnSurface(E2,Face[nb],u2,v2);
2340 cfacemoins1->D0(paredge2,pfac2);
2341 cface->D0(paredge2,pint);
2344 C2dint1->D0(paredge2,pfac2);
2345 C2dint2->D0(paredge2,pint);
2349 else Standard_Failure::Raise("IntersectionAtEnd: pb intersection Face cb");
2352 Hc2 = BRep_Tool::CurveOnSurface(E2,Face[nbface-1],Ubid,Ubid);
2354 // curve 2d is not found, Sfacemoins1 is extended CV2.Point() is projected there
2356 ChFi3d_ExtendSurface(Sfacemoins1,prolface[0]);
2359 extend=Standard_True;
2360 Standard_Real tol=BRep_Tool::Tolerance(F);
2361 BRE.MakeFace(faceprol[nb-1],Sfacemoins1,F.Location(),tol);
2362 GeomAdaptor_Surface Asurf;
2363 Asurf.Load(Sfacemoins1);
2364 Extrema_ExtPS ext (CV2.Point(),Asurf,tol,tol);
2365 Standard_Real uc2,vc2;
2367 ext.Point(1).Parameter(uc2,vc2);
2373 else pfac2 = Hc2->Value(CV2.ParameterOnArc());
2374 paredge2=CV2.ParameterOnArc();
2375 if (Fi2.LineIndex() != 0) {
2376 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
2379 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
2382 if (!nb) continue; // found paredge1 on Edge[0] in OnSame situation on F1
2384 if (nb==nbface && isOnSame2) {
2385 // update interference param on Fi2 and point of CV2
2386 if (prolface[nb-1]) Bs.Initialize(faceprol[nb-1]);
2387 else Bs.Initialize(Face[nb-1]);
2388 const Handle(Geom_Curve)& c3df = DStr.Curve(Fi2.LineIndex()).Curve();
2389 Standard_Real Ufi= Fi1.Parameter(isfirst);
2390 ChFiDS_FaceInterference& Fi = Fd->ChangeInterferenceOnS2();
2391 if (!IntersUpdateOnSame (HGs,HBs,c3df,F2,F,Edge[nb],Vtx,isfirst,10*tolesp, // in
2392 Fi,CV2,pfac2,Ufi)) // out
2393 Standard_Failure::Raise("IntersectionAtEnd: pb intersection Face - Fi");
2395 if (intersOnSameFailed) { // probable at fillet building
2396 // look for paredge2
2397 Geom2dAPI_ProjectPointOnCurve proj;
2399 proj.Init(pfac2, C2dint2);
2401 proj.Init(pfac2, BRep_Tool::CurveOnSurface (E2,Face[nbface-1],Ubid,Ubid));
2402 paredge2 = proj.LowerDistanceParameter();
2404 // update stripe point
2405 TopOpeBRepDS_Point tpoint (CV2.Point(),tolesp);
2406 indpoint2=DStr.AddPoint(tpoint);
2407 stripe->SetIndexPoint(indpoint2,isfirst,2);
2409 TopoDS_Vertex vert1,vert2;
2410 TopExp::Vertices(Edge[nbface],vert1,vert2);
2411 TopAbs_Orientation arcOri = Vtx.IsSame(vert1) ? TopAbs_FORWARD : TopAbs_REVERSED;
2412 CV2.SetArc(tolesp,Edge[nbface],paredge2,arcOri);
2416 if (prolface[nb-1]) Bs.Initialize(faceprol[nb-1]);
2417 else Bs.Initialize(Face[nb-1]);
2419 // offset of parameters if they are not in the same period
2421 // commented by eap 30 May 2002 occ354
2422 // the following code may cause trimming a wrong part of periodic surface
2424 // Standard_Real deb,xx1,xx2;
2425 // Standard_Boolean moins2pi,moins2pi1,moins2pi2;
2426 // if (DStr.Surface(Fd->Surf()).Surface()->IsUPeriodic()) {
2430 // moins2pi=Abs(deb)< Abs(Abs(deb)-2*M_PI);
2431 // moins2pi1=Abs(xx1)< Abs(Abs(xx1)-2*M_PI);
2432 // moins2pi2=Abs(xx2)< Abs(Abs(xx2)-2*M_PI);
2433 // if (moins2pi1!=moins2pi2) {
2435 // if (!moins2pi1) xx1=xx1-2*M_PI;
2436 // if (!moins2pi2) xx2=xx2-2*M_PI;
2439 // if (moins2pi1) xx1=xx1+2*M_PI;
2440 // if (moins2pi2) xx2=xx2+2*M_PI;
2446 // if (couture || Sfacemoins1->IsUPeriodic()) {
2448 // Standard_Real ufmin,ufmax,vfmin,vfmax;
2449 // BRepTools::UVBounds(Face[nb-1],ufmin,ufmax,vfmin,vfmax);
2453 // moins2pi=Abs(deb)< Abs(Abs(deb)-2*M_PI);
2454 // moins2pi1=Abs(xx1)< Abs(Abs(xx1)-2*M_PI);
2455 // moins2pi2=Abs(xx2)< Abs(Abs(xx2)-2*M_PI);
2456 // if (moins2pi1!=moins2pi2) {
2458 // if (!moins2pi1) xx1=xx1-2*M_PI;
2459 // if (!moins2pi2) xx2=xx2-2*M_PI;
2462 // if (moins2pi1) xx1=xx1+2*M_PI;
2463 // if (moins2pi2) xx2=xx2+2*M_PI;
2470 Pardeb(1)= pfil1.X();Pardeb(2) = pfil1.Y();
2471 Pardeb(3)= pfac1.X();Pardeb(4) = pfac1.Y();
2472 Parfin(1)= pfil2.X();Parfin(2) = pfil2.Y();
2473 Parfin(3)= pfac2.X();Parfin(4) = pfac2.Y();
2475 Standard_Real uu1,uu2,vv1,vv2;
2476 ChFi3d_Boite(pfac1,pfac2,uu1,uu2,vv1,vv2);
2477 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
2480 //////////////////////////////////////////////////////////////////////
2481 // calculate intersections face - fillet
2482 //////////////////////////////////////////////////////////////////////
2484 if (!ChFi3d_ComputeCurves(HGs,HBs,Pardeb,Parfin,Cc,
2485 Ps,Pc,tolesp,tol2d,tolreached,nbface==1)) {
2486 PerformMoreThreeCorner (Index,1);
2489 // storage of information in the data structure
2491 // evaluate tolerances
2492 p1=Cc->FirstParameter();
2493 p2=Cc->LastParameter();
2494 Standard_Real to1,to2;
2496 gp_Pnt P1,P2,P3,P4,P5,P6,P7,P8;
2497 HGs->D0(Pardeb(1),Pardeb(2),P1);
2498 HGs->D0(Parfin(1),Parfin(2),P2);
2499 HBs->D0(Pardeb(3),Pardeb(4),P3);
2500 HBs->D0(Parfin(3),Parfin(4),P4);
2503 HBs->D0(p2d1.X(),p2d1.Y(),P7);
2504 HBs->D0(p2d2.X(),p2d2.Y(),P8);
2507 HGs->D0(p2d1.X(),p2d1.Y(),P5);
2508 HGs->D0(p2d2.X(),p2d2.Y(),P6);
2509 to1 = Max (P1.Distance(P5)+P3.Distance(P7), tolreached);
2510 to2 = Max (P2.Distance(P6)+P4.Distance(P8), tolreached);
2513 //////////////////////////////////////////////////////////////////////
2514 // storage in the DS of the intersection curve
2515 //////////////////////////////////////////////////////////////////////
2517 Standard_Boolean Isvtx1=0;
2518 Standard_Boolean Isvtx2=0;
2519 Standard_Integer indice;
2523 indpoint1 = stripe->IndexPoint(isfirst,1);
2524 if (!CV1.IsVertex()) {
2525 TopOpeBRepDS_Point& tpt= DStr.ChangePoint(indpoint1);
2526 tpt.Tolerance ( Max (tpt.Tolerance(), to1));
2532 indpoint2 = stripe->IndexPoint(isfirst,2);
2533 if (!CV2.IsVertex()) {
2534 TopOpeBRepDS_Point& tpt= DStr.ChangePoint(indpoint2);
2535 tpt.Tolerance ( Max (tpt.Tolerance(), to2));
2541 gp_Pnt point =Cc->Value(Cc->LastParameter());
2542 TopOpeBRepDS_Point tpoint (point,to2);
2543 indpoint2=DStr.AddPoint(tpoint);
2548 TopOpeBRepDS_Point& tpt= DStr.ChangePoint(indpoint1);
2549 tpt.Tolerance ( Max (tpt.Tolerance(), to1));
2551 TopOpeBRepDS_Curve tcurv3d( Cc,tolreached);
2552 indcurve[nb-1]= DStr.AddCurve(tcurv3d);
2553 Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurve[nb-1],
2554 indpoint1,Cc->FirstParameter(),Isvtx1);
2555 Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurve[nb-1],
2556 indpoint2,Cc->LastParameter(),Isvtx2);
2558 DStr.ChangeCurveInterferences(indcurve[nb-1]).Append(Interfp1);
2559 DStr.ChangeCurveInterferences(indcurve[nb-1]).Append(Interfp2);
2561 //////////////////////////////////////////////////////////////////////
2562 // storage for the face
2563 //////////////////////////////////////////////////////////////////////
2565 TopAbs_Orientation ori = TopAbs_FORWARD;
2566 orface=Face[nb-1].Orientation();
2567 if (orface==orsurfdata ) orien = TopAbs::Reverse(orcourbe);
2568 else orien = orcourbe ;
2569 // limitation of edges of faces
2571 Standard_Integer Iarc1= DStr.AddShape(Edge[0]);
2572 Interfedge[0]= ChFi3d_FilPointInDS(CV1.TransitionOnArc(),Iarc1,
2573 indpoint1,paredge1,Isvtx1);
2574 //DStr.ChangeShapeInterferences(Edge[0]).Append(Interfp1);
2577 Standard_Integer Iarc2= DStr.AddShape(Edge[nb]);
2578 Interfedge[nb]= ChFi3d_FilPointInDS(CV2.TransitionOnArc() ,Iarc2,
2579 indpoint2,paredge2,Isvtx2);
2580 //DStr.ChangeShapeInterferences(Edge[nb]).Append(Interfp2);
2583 if (nb!=nbface || oneintersection1 || oneintersection2) {
2585 V1= TopExp::FirstVertex(Edge[nb]);
2586 V2= TopExp::LastVertex(Edge[nb]);
2587 if (containV(F1,V1) || containV(F2,V1))
2589 else if (containV(F1,V2) || containV(F2,V2))
2590 ori=TopAbs_REVERSED;
2592 Standard_Failure::Raise("IntersectionAtEnd : pb orientation");
2594 if (containV(F1,V1) && containV(F1,V2)) {
2595 dist1=(BRep_Tool::Pnt(V1)).Distance(BRep_Tool::Pnt(Vtx));
2596 dist2=(BRep_Tool::Pnt(V2)).Distance(BRep_Tool::Pnt(Vtx));
2597 if (dist1<dist2) ori=TopAbs_FORWARD;
2598 else ori=TopAbs_REVERSED;
2600 if (containV(F2,V1) && containV(F2,V2)) {
2601 dist1=(BRep_Tool::Pnt(V1)).Distance(BRep_Tool::Pnt(Vtx));
2602 dist2=(BRep_Tool::Pnt(V2)).Distance(BRep_Tool::Pnt(Vtx));
2603 if (dist1<dist2) ori=TopAbs_FORWARD;
2604 else ori=TopAbs_REVERSED;
2608 if (TopExp::FirstVertex(Edge[nb]).IsSame(Vtx))
2609 ori= TopAbs_FORWARD;
2610 else ori=TopAbs_REVERSED;
2612 if (!extend && !(oneintersection1 || oneintersection2)) {
2613 Standard_Integer Iarc2= DStr.AddShape(Edge[nb]);
2614 Interfedge[nb]= ChFi3d_FilPointInDS(ori,Iarc2,
2615 indpoint2,paredge2);
2616 // DStr.ChangeShapeInterferences(Edge[nb]).Append(Interfp2);
2619 if (!(oneintersection1 || oneintersection2) ) proledge[nb]=Standard_True;
2620 Standard_Integer indp1,indp2,ind;
2622 Standard_Real ubid,vbid;
2623 pext=BRep_Tool::Pnt(Vtx);
2624 GeomAdaptor_Curve cad;
2625 Handle(Geom_Curve) csau;
2626 if ( ! (oneintersection1 || oneintersection2)) {
2631 csau=BRep_Tool::Curve(edgesau,ubid,vbid );
2632 Handle(Geom_BoundedCurve) C1=
2633 Handle(Geom_BoundedCurve)::DownCast(csau);
2634 if (oneintersection1&&extend) {
2637 Pl=C1->Value(C1->LastParameter());
2638 //Standard_Boolean sens;
2639 sens=Pl.Distance(pext)<tolpt;
2640 GeomLib::ExtendCurveToPoint(C1,CV1.Point(),1,sens);
2644 else if (oneintersection2&&extend) {
2647 Pl=C1->Value(C1->LastParameter());
2648 //Standard_Boolean sens;
2649 sens=Pl.Distance(pext)<tolpt;
2650 GeomLib::ExtendCurveToPoint(C1,CV2.Point(),1,sens);
2656 Extrema_ExtPC ext(pext,cad,tolpt);
2657 Standard_Real par1, par2, par, ParVtx;
2658 Standard_Boolean vtx1=Standard_False;
2659 Standard_Boolean vtx2=Standard_False;
2660 par1=ext.Point(1).Parameter();
2662 if (oneintersection1 || oneintersection2 ) {
2663 if (oneintersection2) {
2671 Extrema_ExtPC ext2(pext,cad,tolpt);
2672 par2=ext2.Point(1).Parameter();
2680 indp2=DStr.AddShape(Vtx);
2687 indp1=DStr.AddShape(Vtx);
2691 Handle(Geom_Curve) Ct=new Geom_TrimmedCurve (csau,par1,par2);
2692 TopAbs_Orientation orient;
2693 Cc->D0(Cc->FirstParameter(),P1);
2694 Cc->D0(Cc->LastParameter(),P2);
2695 Ct->D0(Ct->FirstParameter(),P3);
2696 Ct->D0(Ct->LastParameter(),P4);
2697 if (P2.Distance(P3)<tolpt || P1.Distance(P4)<tolpt) orient=orien;
2698 else orient=TopAbs::Reverse(orien);
2699 if (oneintersection1||oneintersection2) {
2700 indice=DStr.AddShape(Face[0]);
2702 DStr.SetNewSurface(Face[0],Sfacemoins1);
2703 ComputeCurve2d(Ct,faceprol[0],C2dint1);
2707 TopoDS_Edge aLocalEdge = edgesau;
2708 if (edgesau.Orientation() != orient)
2709 aLocalEdge.Reverse();
2710 C2dint1 = BRep_Tool::CurveOnSurface(aLocalEdge,Face[0],ubid,vbid);
2714 indice=DStr.AddShape(Face[nb-1]);
2715 DStr.SetNewSurface(Face[nb-1],Sfacemoins1);
2717 //// for periodic 3d curves ////
2718 if (cad.IsPeriodic())
2720 gp_Pnt2d P2d = BRep_Tool::Parameters( Vtx, Face[0] );
2721 Geom2dAPI_ProjectPointOnCurve Projector( P2d, C2dint1 );
2722 par = Projector.LowerDistanceParameter();
2723 Standard_Real shift = par-ParVtx;
2724 if (Abs(shift) > Precision::Confusion())
2730 ////////////////////////////////
2732 Ct=new Geom_TrimmedCurve (csau,par1,par2);
2733 if (oneintersection1||oneintersection2) tolex=10*BRep_Tool::Tolerance(edgesau);
2735 Handle(GeomAdaptor_HSurface) H1, H2;
2736 H1=new GeomAdaptor_HSurface(Sfacemoins1);
2738 tolex = Max (tolex, ChFi3d_EvalTolReached(H1,C2dint1,H1,C2dint1,Ct));
2740 H2=new GeomAdaptor_HSurface(Sface);
2741 tolex = Max (tolex, ChFi3d_EvalTolReached(H1,C2dint1,H2,C2dint2,Ct));
2744 TopOpeBRepDS_Curve tcurv( Ct,tolex);
2745 Standard_Integer indcurv;
2746 indcurv=DStr.AddCurve(tcurv);
2747 Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurv,indp1,par1,vtx1);
2748 Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurv,indp2,par2,vtx2);
2749 DStr.ChangeCurveInterferences(indcurv).Append(Interfp1);
2750 DStr.ChangeCurveInterferences(indcurv).Append(Interfp2);
2752 Interfc=ChFi3d_FilCurveInDS(indcurv,indice ,C2dint1,orient);
2753 DStr.ChangeShapeInterferences(indice).Append(Interfc);
2754 if (oneintersection1||oneintersection2) {
2755 indice=DStr.AddShape(facesau);
2756 if (facesau.Orientation()==Face[0].Orientation())
2757 orient=TopAbs::Reverse(orient);
2759 ComputeCurve2d(Ct,faceprol[1],C2dint2);
2764 TopoDS_Edge aLocalEdge = edgesau;
2765 if (edgesau.Orientation() != orient)
2766 aLocalEdge.Reverse();
2767 C2dint2 = BRep_Tool::CurveOnSurface(aLocalEdge,facesau,ubid,vbid);
2768 //Reverse for case of edgesau on closed surface (Face[0] is equal to facesau)
2772 indice=DStr.AddShape(Face[nb]);
2773 DStr.SetNewSurface(Face[nb],Sface);
2774 if (Face[nb].Orientation()==Face[nb-1].Orientation())
2775 orient= TopAbs::Reverse(orient);
2778 Interfc=ChFi3d_FilCurveInDS(indcurv,indice,C2dint2,orient);
2779 DStr.ChangeShapeInterferences(indice).Append(Interfc);
2785 IsShrink(Ps,p1,p2,checkShrParam,isUShrink,Precision::Parametric(tolreached)))
2788 // store section face-chamf curve for previous SurfData
2789 // Suppose Fd and SDprev are parametrized similarly
2790 if (!isShrink) { // first time
2791 const ChFiDS_FaceInterference& Fi = SDprev->InterferenceOnS1();
2792 gp_Pnt2d UV = Fi.PCurveOnSurf()->Value(Fi.Parameter(isfirst));
2793 prevSDParam = isUShrink ? UV.X() : UV.Y();
2795 gp_Pnt2d UV1=p2d1,UV2=p2d2;
2796 UV1.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2797 UV2.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2798 Standard_Real aTolreached;
2799 ChFi3d_ComputePCurv(Cc,UV1,UV2,Ps,
2800 DStr.Surface(SDprev->Surf()).Surface(),
2801 p1,p2,tolesp,aTolreached);
2802 TopOpeBRepDS_Curve& TCurv = DStr.ChangeCurve(indcurve[nb-1]);
2803 TCurv.Tolerance(Max(TCurv.Tolerance(),aTolreached));
2805 InterfPS[nb-1]=ChFi3d_FilCurveInDS(indcurve[nb-1],IsurfPrev,Ps,orcourbe);
2806 DStr.ChangeSurfaceInterferences(IsurfPrev).Append(InterfPS[nb-1]);
2810 midIpoint = indpoint2;
2812 else if (!isShrink) {
2814 midIpoint = indpoint1;
2816 isShrink = Standard_True;
2820 indice=DStr.AddShape(Face[nb-1]);
2821 InterfPC[nb-1]=ChFi3d_FilCurveInDS(indcurve[nb-1],indice ,Pc,orien);
2823 InterfPS[nb-1]=ChFi3d_FilCurveInDS(indcurve[nb-1],Isurf,Ps,orcourbe);
2824 indpoint1=indpoint2;
2826 } // end loop on faces being intersected with ChFi
2829 if (isOnSame1) CV1.Reset();
2830 if (isOnSame2) CV2.Reset();
2832 for(nb=1;nb<=nbface;nb++) {
2833 Standard_Integer indice=DStr.AddShape(Face[nb-1]);
2834 DStr.ChangeShapeInterferences(indice).Append(InterfPC[nb-1]);
2836 DStr.ChangeSurfaceInterferences(Isurf).Append(InterfPS[nb-1]);
2837 if (!proledge[nb-1])
2838 DStr.ChangeShapeInterferences(Edge[nb-1]).Append(Interfedge[nb-1]);
2840 DStr.ChangeShapeInterferences(Edge[nbface]).Append(Interfedge[nbface]);
2843 stripe->InDS(isfirst);
2845 // compute curves for !<isfirst> end of <Fd> and <isfirst> end of previous <SurfData>
2849 gp_Pnt2d UV, UV1 = midP2d, UV2 = midP2d;
2851 UV = UV2 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
2853 UV = UV1 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
2854 Standard_Real aTolreached;
2855 Handle(Geom_Curve) C3d;
2856 Handle(Geom_Surface) aSurf = DStr.Surface(Fd->Surf()).Surface();
2857 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2859 ChFi3d_ComputeArete(CV1,UV1,CV2,UV2,aSurf, // in
2860 C3d,Ps,p1,p2,tolesp,tol2d,aTolreached,0); // out except tolers
2862 indpoint1 = indpoint2 = midIpoint;
2865 point = C3d->Value(p2);
2866 TopOpeBRepDS_Point tpoint (point,aTolreached);
2867 indpoint2=DStr.AddPoint(tpoint);
2870 point = C3d->Value(p1);
2871 TopOpeBRepDS_Point tpoint (point,aTolreached);
2872 indpoint1=DStr.AddPoint(tpoint);
2876 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2878 TopOpeBRepDS_Curve Crv = TopOpeBRepDS_Curve(C3d,aTolreached);
2879 Standard_Integer Icurv = DStr.AddCurve(Crv);
2880 Interfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv,indpoint1,p1, Standard_False);
2881 Interfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv,indpoint2,p2, Standard_False);
2882 Interfc = ChFi3d_FilCurveInDS(Icurv,Isurf,Ps,orcourbe);
2883 DStr.ChangeCurveInterferences(Icurv).Append(Interfp1);
2884 DStr.ChangeCurveInterferences(Icurv).Append(Interfp2);
2885 DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc);
2888 aSurf = DStr.Surface(SDprev->Surf()).Surface();
2889 UV1.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2890 UV2.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2892 ChFi3d_ComputePCurv(C3d,UV1,UV2,Pc,aSurf,p1,p2,tolesp,aTolreached);
2894 Crv.Tolerance(Max(Crv.Tolerance(),aTolreached));
2895 Interfc= ChFi3d_FilCurveInDS (Icurv,IsurfPrev,Pc,TopAbs::Reverse(orcourbe));
2896 DStr.ChangeSurfaceInterferences(IsurfPrev).Append(Interfc);
2898 //UV = isOnSame1 ? UV2 : UV1;
2899 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2900 //UV = Ps->Value(isOnSame1 ? p2 : p1);
2901 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2902 //ChFi3d_SetPointTolerance(DStr,box, isOnSame1 ? indpoint2 : indpoint1);
2904 // to process properly this case in ChFi3d_FilDS()
2905 stripe->InDS(isfirst, 2);
2906 Fd->ChangeInterference(isOnSame1 ? 2 : 1).SetLineIndex(0);
2907 ChFiDS_CommonPoint& CPprev1 = SDprev->ChangeVertex( isfirst,isOnSame1 ? 2 : 1);
2908 ChFiDS_CommonPoint& CPlast1 = Fd-> ChangeVertex( isfirst,isOnSame1 ? 2 : 1);
2909 ChFiDS_CommonPoint& CPlast2 = Fd-> ChangeVertex(!isfirst,isOnSame1 ? 2 : 1);
2910 if (CPprev1.IsOnArc()) {
2913 CPprev1.SetPoint(CPlast1.Point());
2915 CPlast2.SetPoint(CPlast1.Point());
2918 // in shrink case, self intersection is possible at <midIpoint>,
2919 // eval its tolerance intersecting Ps and Pcurve at end.
2920 // Find end curves closest to shrinked part
2921 for (nb=0; nb < nbface; nb++)
2922 if (isOnSame1 ? shrink [nb+1] : !shrink [nb]) break;
2923 Handle(Geom_Curve) Cend = DStr.Curve(indcurve[nb]).Curve();
2924 Handle(Geom2d_Curve) PCend = InterfPS[nb]->PCurve();
2925 // point near which self intersection may occure
2926 TopOpeBRepDS_Point& Pds = DStr.ChangePoint(midIpoint);
2927 const gp_Pnt& Pvert = Pds.Point();
2928 Standard_Real tol = Pds.Tolerance();
2930 Geom2dAdaptor_Curve PC1(Ps), PC2(PCend);
2931 Geom2dInt_GInter Intersector(PC1,PC2,Precision::PConfusion(),Precision::PConfusion());
2932 if (!Intersector.IsDone()) return;
2933 for (nb=1; nb <= Intersector.NbPoints(); nb++) {
2934 const IntRes2d_IntersectionPoint& ip = Intersector.Point(nb);
2935 gp_Pnt Pint = C3d->Value(ip.ParamOnFirst());
2936 tol = Max(tol, Pvert.Distance(Pint));
2937 Pint = Cend->Value(ip.ParamOnSecond());
2938 tol = Max(tol, Pvert.Distance(Pint));
2940 for (nb=1; nb <= Intersector.NbSegments(); nb++) {
2941 const IntRes2d_IntersectionSegment& is = Intersector.Segment(nb);
2942 if (is.HasFirstPoint()) {
2943 const IntRes2d_IntersectionPoint& ip = is.FirstPoint();
2944 gp_Pnt Pint = C3d->Value(ip.ParamOnFirst());
2945 tol = Max(tol, Pvert.Distance(Pint));
2946 Pint = Cend->Value(ip.ParamOnSecond());
2947 tol = Max(tol, Pvert.Distance(Pint));
2949 if (is.HasLastPoint()) {
2950 const IntRes2d_IntersectionPoint& ip = is.LastPoint();
2951 gp_Pnt Pint = C3d->Value(ip.ParamOnFirst());
2952 tol = Max(tol, Pvert.Distance(Pint));
2953 Pint = Cend->Value(ip.ParamOnSecond());
2954 tol = Max(tol, Pvert.Distance(Pint));
2961 // Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 Begin
2963 //=======================================================================
2964 //function : PerformMoreSurfdata
2965 //purpose : determine intersections at end on several surfdata
2966 //=======================================================================
2967 void ChFi3d_Builder::PerformMoreSurfdata(const Standard_Integer Index)
2969 TopOpeBRepDS_DataStructure &DStr = myDS->ChangeDS();
2970 const ChFiDS_ListOfStripe &aLOfStripe = myVDataMap(Index);
2971 Handle(ChFiDS_Stripe) aStripe;
2972 Handle(ChFiDS_Spine) aSpine;
2973 Standard_Real aTol3d = 1.e-4;
2976 if (aLOfStripe.IsEmpty())
2979 aStripe = aLOfStripe.First();
2980 aSpine = aStripe->Spine();
2982 ChFiDS_SequenceOfSurfData &aSeqSurfData =
2983 aStripe->ChangeSetOfSurfData()->ChangeSequence();
2984 const TopoDS_Vertex &aVtx = myVDataMap.FindKey(Index);
2985 Standard_Integer aSens = 0;
2986 Standard_Integer anInd =
2987 ChFi3d_IndexOfSurfData(aVtx,aStripe,aSens);
2988 Standard_Boolean isFirst = (aSens == 1);
2989 Standard_Integer anIndPrev;
2990 Handle(ChFiDS_SurfData) aSurfData;
2991 ChFiDS_CommonPoint aCP1;
2992 ChFiDS_CommonPoint aCP2;
2994 aSurfData = aSeqSurfData.Value(anInd);
2996 aCP1 = aSurfData->Vertex(isFirst,1);
2997 aCP2 = aSurfData->Vertex(isFirst,2);
2999 Handle(Geom_Surface) aSurfPrev;
3000 Handle(Geom_Surface) aSurf;
3002 TopoDS_Face aNeighborFace;
3004 FindFace(aVtx, aCP1, aCP2, aFace);
3005 aSurfPrev = BRep_Tool::Surface(aFace);
3007 if (aSens==1) anIndPrev=anInd+1;
3008 else anIndPrev=anInd-1;
3012 TopTools_ListIteratorOfListOfShape anIter(myVEMap(aVtx));
3013 Standard_Boolean isFound = Standard_False;
3015 for(; anIter.More() && !isFound; anIter.Next()) {
3016 anArc1 = TopoDS::Edge(anIter.Value());
3018 if (containE(aFace, anArc1))
3019 isFound = Standard_True;
3022 isFound = Standard_False;
3023 anIter.Initialize(myVEMap(aVtx));
3025 for(; anIter.More() && !isFound; anIter.Next()) {
3026 anArc2 = TopoDS::Edge(anIter.Value());
3028 if (containE(aFace,anArc2) && !anArc2.IsSame(anArc1))
3029 isFound = Standard_True;
3032 // determination of common points aCP1onArc, aCP2onArc and aCP2NotonArc
3033 // aCP1onArc is the point on arc of index anInd
3034 // aCP2onArc is the point on arc of index anIndPrev
3035 // aCP2NotonArc is the point of index anIndPrev which is not on arc.
3037 Standard_Boolean is1stCP1OnArc;
3038 Standard_Boolean is2ndCP1OnArc;
3039 ChFiDS_CommonPoint aCP1onArc;
3040 ChFiDS_CommonPoint aCP2onArc;
3041 ChFiDS_CommonPoint aCP2NotonArc;
3043 aSurfData = aSeqSurfData.Value(anIndPrev);
3044 aCP1 = aSurfData->Vertex(isFirst,1);
3045 aCP2 = aSurfData->Vertex(isFirst,2);
3047 if (aCP1.IsOnArc() &&
3048 (aCP1.Arc().IsSame(anArc1) || aCP1.Arc().IsSame(anArc2))) {
3050 aCP2NotonArc = aCP2;
3051 is2ndCP1OnArc = Standard_True;
3052 } else if (aCP2.IsOnArc() &&
3053 (aCP2.Arc().IsSame(anArc1) || aCP2.Arc().IsSame(anArc2))) {
3055 aCP2NotonArc = aCP1;
3056 is2ndCP1OnArc = Standard_False;
3060 aSurfData = aSeqSurfData.Value(anInd);
3061 aCP1 = aSurfData->Vertex(isFirst,1);
3062 aCP2 = aSurfData->Vertex(isFirst,2);
3064 if (aCP1.Point().Distance(aCP2onArc.Point()) <= aTol3d){
3066 is1stCP1OnArc = Standard_False;
3070 is1stCP1OnArc = Standard_True;
3073 if (!aCP1onArc.IsOnArc())
3076 // determination of neighbor surface
3077 Standard_Integer indSurface;
3079 indSurface = myListStripe.First()->SetOfSurfData()->Value(anInd)->IndexOfS1();
3081 indSurface = myListStripe.First()->SetOfSurfData()->Value(anInd)->IndexOfS2();
3083 aNeighborFace = TopoDS::Face(myDS->Shape(indSurface));
3085 // calculation of intersections
3086 Handle(Geom_Curve) aCracc;
3087 Handle(Geom2d_Curve) aPCurv1;
3088 Standard_Real aParf;
3089 Standard_Real aParl;
3090 Standard_Real aTolReached;
3092 aSurfData = aSeqSurfData.Value(anInd);
3095 ChFi3d_ComputeArete(aSurfData->VertexLastOnS1(),
3096 aSurfData->InterferenceOnS1().PCurveOnSurf()->
3097 Value(aSurfData->InterferenceOnS1().LastParameter()),
3098 aSurfData->VertexLastOnS2(),
3099 aSurfData->InterferenceOnS2().PCurveOnSurf()->
3100 Value(aSurfData->InterferenceOnS2().LastParameter()),
3101 DStr.Surface(aSurfData->Surf()).Surface(),aCracc,aPCurv1,
3102 aParf,aParl,aTol3d,tol2d,aTolReached,0);
3104 ChFi3d_ComputeArete(aSurfData->VertexFirstOnS1(),
3105 aSurfData->InterferenceOnS1().PCurveOnSurf()->
3106 Value(aSurfData->InterferenceOnS1().FirstParameter()),
3107 aSurfData->VertexFirstOnS2(),
3108 aSurfData->InterferenceOnS2().PCurveOnSurf()->
3109 Value(aSurfData->InterferenceOnS2().FirstParameter()),
3110 DStr.Surface(aSurfData->Surf()).Surface(),aCracc,aPCurv1,
3111 aParf,aParl,aTol3d,tol2d,aTolReached,0);
3113 // calculation of the index of the line on anInd.
3114 // aPClineOnSurf is the pcurve on anInd.
3115 // aPClineOnFace is the pcurve on face.
3116 ChFiDS_FaceInterference aFI;
3119 aFI = aSurfData->InterferenceOnS1();
3121 aFI = aSurfData->InterferenceOnS2();
3123 Handle(Geom_Curve) aCline;
3124 Handle(Geom2d_Curve) aPClineOnSurf;
3125 Handle(Geom2d_Curve) aPClineOnFace;
3126 Standard_Integer indLine;
3128 indLine = aFI.LineIndex();
3129 aCline = DStr.Curve(aFI.LineIndex()).Curve();
3130 aPClineOnSurf = aFI.PCurveOnSurf();
3131 aPClineOnFace = aFI.PCurveOnFace();
3133 // intersection between the SurfData number anInd and the Face aFace.
3134 // Obtaining of curves aCint1, aPCint11 and aPCint12.
3135 aSurf = DStr.Surface(aSurfData->Surf()).Surface();
3137 GeomInt_IntSS anInterSS(aSurfPrev,aSurf,1.e-7,1,1,1);
3138 Handle(Geom_Curve) aCint1;
3139 Handle(Geom2d_Curve) aPCint11;
3140 Handle(Geom2d_Curve) aPCint12;
3141 Handle(GeomAdaptor_HSurface) H1 = new GeomAdaptor_HSurface(aSurfPrev);
3142 Handle(GeomAdaptor_HSurface) H2 = new GeomAdaptor_HSurface(aSurf);
3143 Standard_Real aTolex1=0.;
3148 Standard_Boolean isPextFound;
3151 if (!anInterSS.IsDone())
3154 isFound = Standard_False;
3156 for (i = 1; i <= anInterSS.NbLines() && !isFound; i++) {
3157 aCint1 = anInterSS.Line(i);
3158 aPCint11 = anInterSS.LineOnS1(i);
3159 aPCint12 = anInterSS.LineOnS2(i);
3160 aTolex1 = ChFi3d_EvalTolReached(H1, aPCint11, H2, aPCint12, aCint1);
3162 aCint1->D0(aCint1->FirstParameter(), aPext1);
3163 aCint1->D0(aCint1->LastParameter(), aPext2);
3165 // Modified by skv - Mon Jun 7 18:38:57 2004 OCC5898 Begin
3166 // if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d ||
3167 // aPext2.Distance(aCP1onArc.Point()))
3168 if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d ||
3169 aPext2.Distance(aCP1onArc.Point()) <= aTol3d)
3170 // Modified by skv - Mon Jun 7 18:38:58 2004 OCC5898 End
3171 isFound = Standard_True;
3177 if (aPext1.Distance(aCP2onArc.Point()) > aTol3d &&
3178 aPext1.Distance(aCP1onArc.Point()) > aTol3d) {
3180 isPextFound = Standard_True;
3181 } else if (aPext2.Distance(aCP2onArc.Point()) > aTol3d &&
3182 aPext2.Distance(aCP1onArc.Point()) > aTol3d) {
3184 isPextFound = Standard_True;
3186 isPextFound = Standard_False;
3190 Standard_Boolean isDoSecondSection = Standard_False;
3191 Standard_Real aPar=0.;
3194 GeomAdaptor_Curve aCad(aCracc);
3195 Extrema_ExtPC anExt(aPext, aCad, aTol3d);
3197 if (!anExt.IsDone())
3200 isFound = Standard_False;
3201 for (i = 1; i <= anExt.NbExt() && !isFound; i++) {
3202 if (anExt.IsMin(i)) {
3203 gp_Pnt aProjPnt = anExt.Point(i).Value();
3205 if (aPext.Distance(aProjPnt) <= aTol3d) {
3206 aPar = anExt.Point(i).Parameter();
3207 isDoSecondSection = Standard_True;
3213 Handle(Geom_Curve) aTrCracc;
3214 TopAbs_Orientation anOrSD1;
3215 TopAbs_Orientation anOrSD2;
3216 Standard_Integer indShape;
3218 anOrSD1 = aSurfData->Orientation();
3219 aSurfData = aSeqSurfData.Value(anIndPrev);
3220 anOrSD2 = aSurfData->Orientation();
3221 aSurf = DStr.Surface(aSurfData->Surf()).Surface();
3223 // The following variables will be used if isDoSecondSection is true
3224 Handle(Geom_Curve) aCint2;
3225 Handle(Geom2d_Curve) aPCint21;
3226 Handle(Geom2d_Curve) aPCint22;
3227 Standard_Real aTolex2=0.;
3229 if (isDoSecondSection) {
3230 Standard_Real aPar1;
3232 aCracc->D0(aCracc->FirstParameter(), aPext1);
3234 if (aPext1.Distance(aCP2NotonArc.Point()) <= aTol3d)
3235 aPar1 = aCracc->FirstParameter();
3237 aPar1 = aCracc->LastParameter();
3240 aTrCracc = new Geom_TrimmedCurve (aCracc, aPar1, aPar);
3242 aTrCracc = new Geom_TrimmedCurve (aCracc, aPar, aPar1);
3245 GeomInt_IntSS anInterSS2(aSurfPrev,aSurf,1.e-7,1,1,1);
3247 if (!anInterSS2.IsDone())
3250 H1 = new GeomAdaptor_HSurface(aSurfPrev);
3251 H2 = new GeomAdaptor_HSurface(aSurf);
3253 isFound = Standard_False;
3255 for (i = 1; i <= anInterSS2.NbLines() && !isFound; i++) {
3256 aCint2 = anInterSS2.Line(i);
3257 aPCint21 = anInterSS2.LineOnS1(i);
3258 aPCint22 = anInterSS2.LineOnS2(i);
3259 aTolex2 = ChFi3d_EvalTolReached(H1, aPCint21, H2, aPCint22, aCint2);
3261 aCint2->D0(aCint2->FirstParameter(), aPext1);
3262 aCint2->D0(aCint2->LastParameter(), aPext2);
3264 if (aPext1.Distance(aCP2onArc.Point()) <= aTol3d ||
3265 aPext2.Distance(aCP2onArc.Point()) <= aTol3d)
3266 isFound = Standard_True;
3273 aTrCracc = new Geom_TrimmedCurve(aCracc,
3274 aCracc->FirstParameter(),
3275 aCracc->LastParameter());
3278 // Storage of the data structure
3280 // calculation of the orientation of line of surfdata number
3281 // anIndPrev which contains aCP2onArc
3283 Handle(Geom2d_Curve) aPCraccS = GeomProjLib::Curve2d(aTrCracc,aSurf);
3285 if (is2ndCP1OnArc) {
3286 aFI = aSurfData->InterferenceOnS1();
3287 indShape = aSurfData->IndexOfS1();
3289 aFI = aSurfData->InterferenceOnS2();
3290 indShape = aSurfData->IndexOfS2();
3298 TopAbs_Orientation aCurOrient;
3300 aCurOrient = DStr.Shape(indShape).Orientation();
3301 aCurOrient = TopAbs::Compose(aCurOrient, aSurfData->Orientation());
3302 aCurOrient = TopAbs::Compose(TopAbs::Reverse(aFI.Transition()), aCurOrient);
3305 // Filling the data structure
3306 aSurfData = aSeqSurfData.Value(anInd);
3308 TopOpeBRepDS_Point aPtCP1(aCP1onArc.Point(),aCP1onArc.Tolerance());
3309 Standard_Integer indCP1onArc = DStr.AddPoint(aPtCP1);
3310 Standard_Integer indSurf1 = aSurfData->Surf();
3311 Standard_Integer indArc1 = DStr.AddShape(aCP1onArc.Arc());
3312 Standard_Integer indSol = aStripe->SolidIndex();
3314 Handle (TopOpeBRepDS_CurvePointInterference) anInterfp1;
3315 Handle (TopOpeBRepDS_CurvePointInterference) anInterfp2;
3317 anInterfp1= ChFi3d_FilPointInDS(aCP1onArc.TransitionOnArc(), indArc1,
3318 indCP1onArc, aCP1onArc.ParameterOnArc());
3319 DStr.ChangeShapeInterferences(aCP1onArc.Arc()).Append(anInterfp1);
3321 TopOpeBRepDS_ListOfInterference &SolidInterfs =
3322 DStr.ChangeShapeInterferences(indSol);
3323 Handle(TopOpeBRepDS_SolidSurfaceInterference) SSI =
3324 new TopOpeBRepDS_SolidSurfaceInterference
3325 (TopOpeBRepDS_Transition(anOrSD1),
3326 TopOpeBRepDS_SOLID, indSol,
3327 TopOpeBRepDS_SURFACE, indSurf1);
3328 SolidInterfs.Append(SSI);
3330 // deletion of Surface Data.
3331 aSeqSurfData.Remove(anInd);
3336 aSurfData = aSeqSurfData.Value(anInd);
3338 // definition of indices of common points in Data Structure
3340 Standard_Integer indCP2onArc;
3341 Standard_Integer indCP2NotonArc;
3343 if (is2ndCP1OnArc) {
3344 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2onArc, DStr),isFirst,1);
3345 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2NotonArc,DStr),isFirst,2);
3348 indCP2onArc = aStripe->IndexFirstPointOnS1();
3349 indCP2NotonArc = aStripe->IndexFirstPointOnS2();
3351 indCP2onArc = aStripe->IndexLastPointOnS1();
3352 indCP2NotonArc = aStripe->IndexLastPointOnS2();
3355 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2onArc, DStr),isFirst,2);
3356 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2NotonArc,DStr),isFirst,1);
3359 indCP2onArc = aStripe->IndexFirstPointOnS2();
3360 indCP2NotonArc = aStripe->IndexFirstPointOnS1();
3363 indCP2onArc = aStripe->IndexLastPointOnS2();
3364 indCP2NotonArc = aStripe->IndexLastPointOnS1();
3368 Standard_Integer indPoint1;
3369 Standard_Integer indPoint2;
3373 if (is2ndCP1OnArc) {
3374 aFI = aSurfData->InterferenceOnS1();
3375 indShape = aSurfData->IndexOfS1();
3377 aFI = aSurfData->InterferenceOnS2();
3378 indShape = aSurfData->IndexOfS2();
3382 Handle (TopOpeBRepDS_SurfaceCurveInterference) anInterfc;
3383 TopAbs_Orientation anOrSurf = aCurOrient;
3384 TopAbs_Orientation anOrFace = aFace.Orientation();
3385 Standard_Integer indaFace = DStr.AddShape(aFace);
3386 Standard_Integer indPoint = indCP2onArc;
3387 Standard_Integer indCurve;
3389 aFI.PCurveOnFace()->D0(aFI.LastParameter(), aP2d);
3390 Handle(Geom_Surface) Stemp2 =
3391 BRep_Tool::Surface(TopoDS::Face(DStr.Shape(indShape)));
3392 Stemp2->D0(aP2d.X(), aP2d.Y(), aPoint2);
3393 aFI.PCurveOnFace()->D0(aFI.FirstParameter(), aP2d);
3394 Stemp2->D0(aP2d.X(), aP2d.Y(), aPoint1);
3396 if (isDoSecondSection) {
3397 TopOpeBRepDS_Point tpoint(aPext, aTolex2);
3398 TopOpeBRepDS_Curve tcint2(aCint2, aTolex2);
3400 indPoint = DStr.AddPoint(tpoint);
3401 indCurve = DStr.AddCurve(tcint2);
3403 aCint2->D0(aCint2->FirstParameter(), aPext1);
3404 aCint2->D0(aCint2->LastParameter(), aPext2);
3406 if (aPext1.Distance(aPext) <= aTol3d){
3407 indPoint1 = indPoint;
3408 indPoint2 = indCP2onArc;
3410 indPoint1 = indCP2onArc;
3411 indPoint2 = indPoint;
3414 // define the orientation of aCint2
3415 if (aPext1.Distance(aPoint2) > aTol3d && aPext2.Distance(aPoint1) > aTol3d)
3416 anOrSurf = TopAbs::Reverse(anOrSurf);
3418 // ---------------------------------------------------------------
3419 // storage of aCint2
3420 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD, indCurve,
3421 indPoint1, aCint2->FirstParameter());
3422 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED, indCurve,
3423 indPoint2, aCint2->LastParameter());
3424 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3425 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3427 // interference of aCint2 on the SurfData number anIndPrev
3428 anInterfc = ChFi3d_FilCurveInDS(indCurve, aSurfData->Surf(),
3429 aPCint22, anOrSurf);
3431 DStr.ChangeSurfaceInterferences(aSurfData->Surf()).Append(anInterfc);
3432 // interference of aCint2 on aFace
3434 if (anOrFace == anOrSD2)
3435 anOrFace = TopAbs::Reverse(anOrSurf);
3437 anOrFace = anOrSurf;
3439 anInterfc = ChFi3d_FilCurveInDS(indCurve, indaFace, aPCint21, anOrFace);
3440 DStr.ChangeShapeInterferences(indaFace).Append(anInterfc);
3443 aTrCracc->D0(aTrCracc->FirstParameter(), aPext1);
3444 aTrCracc->D0(aTrCracc->LastParameter(), aPext2);
3445 if (aPext1.Distance(aCP2NotonArc.Point()) <= aTol3d){
3446 indPoint1 = indCP2NotonArc;
3447 indPoint2 = indPoint;
3449 indPoint1 = indPoint;
3450 indPoint2 = indCP2NotonArc;
3453 // Define the orientation of aTrCracc
3454 Standard_Boolean isToReverse;
3461 if (isDoSecondSection) {
3462 aTrCracc->D0(aTrCracc->FirstParameter(), aP1);
3463 aTrCracc->D0(aTrCracc->LastParameter(), aP2);
3464 aCint2->D0(aCint2->FirstParameter(), aP3);
3465 aCint2->D0(aCint2->LastParameter(), aP4);
3466 isToReverse = (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d);
3468 isToReverse = (aPext1.Distance(aPoint2) > aTol3d &&
3469 aPext2.Distance(aPoint1) > aTol3d);
3473 anOrSurf = TopAbs::Reverse(anOrSurf);
3475 // ---------------------------------------------------------------
3476 // storage of aTrCracc
3477 TopOpeBRepDS_Curve tct2(aTrCracc, aTolReached);
3479 indCurve = DStr.AddCurve(tct2);
3480 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,indCurve,
3481 indPoint1, aTrCracc->FirstParameter());
3482 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED,indCurve,
3483 indPoint2, aTrCracc->LastParameter());
3484 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3485 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3487 // interference of aTrCracc on the SurfData number anIndPrev
3489 anInterfc = ChFi3d_FilCurveInDS(indCurve,aSurfData->Surf(),aPCraccS, anOrSurf);
3490 DStr.ChangeSurfaceInterferences(aSurfData->Surf()).Append(anInterfc);
3491 aStripe->InDS(isFirst);
3493 // interference of aTrCracc on the SurfData number anInd
3494 if (anOrSD1 == anOrSD2)
3495 anOrSurf = TopAbs::Reverse(anOrSurf);
3497 anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPCurv1, anOrSurf);
3498 DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc);
3500 // ---------------------------------------------------------------
3501 // storage of aCint1
3503 aCint1->D0(aCint1->FirstParameter(),aPext1);
3504 if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d){
3505 indPoint1 = indCP1onArc;
3506 indPoint2 = indPoint;
3508 indPoint1 = indPoint;
3509 indPoint2 = indCP1onArc;
3512 // definition of the orientation of aCint1
3514 aCint1->D0(aCint1->FirstParameter(), aP1);
3515 aCint1->D0(aCint1->LastParameter(), aP2);
3516 aTrCracc->D0(aTrCracc->FirstParameter(), aP3);
3517 aTrCracc->D0(aTrCracc->LastParameter(), aP4);
3519 if (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d)
3520 anOrSurf=TopAbs::Reverse(anOrSurf);
3522 TopOpeBRepDS_Curve aTCint1(aCint1, aTolex1);
3523 indCurve= DStr.AddCurve(aTCint1);
3524 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD, indCurve,
3525 indPoint1, aCint1->FirstParameter());
3526 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED, indCurve,
3527 indPoint2, aCint1->LastParameter());
3528 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3529 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3531 // interference of aCint1 on the SurfData number anInd
3533 anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPCint12, anOrSurf);
3534 DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc);
3536 // interference of aCint1 on aFace
3538 anOrFace = aFace.Orientation();
3540 if (anOrFace == anOrSD1)
3541 anOrFace = TopAbs::Reverse(anOrSurf);
3543 anOrFace = anOrSurf;
3545 anInterfc = ChFi3d_FilCurveInDS(indCurve, indaFace, aPCint11, anOrFace);
3546 DStr.ChangeShapeInterferences(indaFace).Append(anInterfc);
3547 // ---------------------------------------------------------------
3548 // storage of aCline passing through aCP1onArc and aCP2NotonArc
3550 Handle(Geom_Curve) aTrCline =
3551 new Geom_TrimmedCurve(aCline, aCline->FirstParameter(),
3552 aCline->LastParameter());
3553 Standard_Real aTolerance = DStr.Curve(indLine).Tolerance();
3554 TopOpeBRepDS_Curve aTct3(aTrCline, aTolerance);
3556 indCurve = DStr.AddCurve(aTct3);
3558 aTrCline->D0(aTrCline->FirstParameter(),aPext1);
3560 if (aPext1.Distance(aCP1onArc.Point()) < aTol3d) {
3561 indPoint1 = indCP1onArc;
3562 indPoint2 = indCP2NotonArc;
3564 indPoint1 = indCP2NotonArc;
3565 indPoint2 = indCP1onArc;
3567 // definition of the orientation of aTrCline
3569 aTrCline->D0(aTrCline->FirstParameter(), aP1);
3570 aTrCline->D0(aTrCline->LastParameter(), aP2);
3571 aCint1->D0(aCint1->FirstParameter(), aP3);
3572 aCint1->D0(aCint1->LastParameter(), aP4);
3574 if (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d)
3575 anOrSurf = TopAbs::Reverse(anOrSurf);
3577 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,indCurve,
3578 indPoint1,aTrCline->FirstParameter());
3579 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED,indCurve,
3580 indPoint2,aTrCline->LastParameter());
3581 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3582 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3584 // interference of aTrCline on the SurfData number anInd
3586 anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPClineOnSurf, anOrSurf);
3587 DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc);
3589 // interference de ctlin par rapport a Fvoisin
3590 indShape = DStr.AddShape(aNeighborFace);
3591 anOrFace = aNeighborFace.Orientation();
3593 if (anOrFace == anOrSD1)
3594 anOrFace = TopAbs::Reverse(anOrSurf);
3596 anOrFace = anOrSurf;
3598 anInterfc = ChFi3d_FilCurveInDS(indCurve, indShape, aPClineOnFace, anOrFace);
3599 DStr.ChangeShapeInterferences(indShape).Append(anInterfc);
3601 // Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 End
3603 //==============================================================
3604 //function : FindFace
3605 //purpose : attention it works only if there is only one common face
3607 //===========================================================
3610 Standard_Boolean ChFi3d_Builder::FindFace(const TopoDS_Vertex& V,
3611 const ChFiDS_CommonPoint& P1,
3612 const ChFiDS_CommonPoint& P2,
3613 TopoDS_Face& Fv) const
3616 return FindFace(V,P1,P2,Fv,Favoid);
3619 Standard_Boolean ChFi3d_Builder::FindFace(const TopoDS_Vertex& V,
3620 const ChFiDS_CommonPoint& P1,
3621 const ChFiDS_CommonPoint& P2,
3623 const TopoDS_Face& Favoid) const
3625 if (P1.IsVertex() || P2.IsVertex()) {
3627 cout<<"change of face on vertex"<<endl;
3630 if (!(P1.IsOnArc() && P2.IsOnArc())) {
3631 return Standard_False;
3633 TopTools_ListIteratorOfListOfShape It,Jt;
3634 Standard_Boolean Found = Standard_False;
3635 for(It.Initialize(myEFMap(P1.Arc()));It.More() && !Found;It.Next()) {
3636 Fv = TopoDS::Face(It.Value());
3637 if(!Fv.IsSame(Favoid)){
3638 for(Jt.Initialize(myEFMap(P2.Arc()));Jt.More() && !Found ;Jt.Next()) {
3639 if (TopoDS::Face(Jt.Value()).IsSame(Fv)) Found = Standard_True;
3644 Standard_Boolean ContainsV = Standard_False;
3646 for(It.Initialize(myVFMap(V));It.More();It.Next()) {
3647 if (TopoDS::Face(It.Value()).IsSame(Fv)) {
3648 ContainsV = Standard_True;
3654 cout<<"FindFace : the extremity of the spine is not in the end face"<<endl;
3657 (void)V; // avoid compiler warning on unused variable
3662 //=======================================================================
3663 //function : MoreSurfdata
3664 //purpose : detects if the intersection at end concerns several Surfdata
3665 //=======================================================================
3666 Standard_Boolean ChFi3d_Builder::MoreSurfdata(const Standard_Integer Index) const
3668 // intersection at end is created on several surfdata if :
3669 // - the number of surfdata concerning the vertex is more than 1.
3670 // - and if the last but one surfdata has one of commonpoints on one of
3671 // two arcs, which constitute the intersections of the face at end and of the fillet
3673 ChFiDS_ListIteratorOfListOfStripe It;
3674 It.Initialize(myVDataMap(Index));
3675 Handle(ChFiDS_Stripe)& stripe = It.Value();
3676 ChFiDS_SequenceOfSurfData& SeqFil =
3677 stripe->ChangeSetOfSurfData()->ChangeSequence();
3678 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
3679 Standard_Integer sens = 0;
3680 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
3681 Standard_Boolean isfirst = (sens == 1);
3682 Handle(ChFiDS_SurfData)& Fd = SeqFil.ChangeValue(num);
3683 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
3684 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
3686 Standard_Integer num1,num2,nbsurf;
3688 Standard_Boolean inters,oksurf;
3689 nbsurf= stripe->SetOfSurfData()->Length();
3690 // Fv is the face at end
3691 inters = FindFace(Vtx,CV1,CV2,Fv);
3701 oksurf=Standard_False;
3703 if (nbsurf!=1 && inters) {
3705 // determination of arc1 and arc2 intersection of the fillet and the face at end
3707 TopoDS_Edge arc1,arc2;
3708 TopTools_ListIteratorOfListOfShape ItE;
3709 Standard_Boolean trouve=Standard_False;
3710 for(ItE.Initialize(myVEMap(Vtx));ItE.More()&&!trouve;ItE.Next()) {
3711 arc1=TopoDS::Edge(ItE.Value());
3712 if (containE(Fv,arc1)) trouve=Standard_True;
3714 trouve=Standard_False;
3715 for(ItE.Initialize(myVEMap(Vtx));ItE.More()&&!trouve;ItE.Next()) {
3716 arc2=TopoDS::Edge(ItE.Value());
3717 if (containE(Fv,arc2)&& !arc2.IsSame(arc1)) trouve=Standard_True;
3720 Handle(ChFiDS_SurfData) Fd1 = SeqFil.ChangeValue(num2);
3721 ChFiDS_CommonPoint& CV3 = Fd1->ChangeVertex(isfirst,1);
3722 ChFiDS_CommonPoint& CV4 = Fd1->ChangeVertex(isfirst,2);
3724 if (CV3.IsOnArc()) {
3725 if (CV3.Arc().IsSame(arc1) ){
3726 if (CV1.Point().Distance(CV3.Point())<1.e-4)
3727 oksurf=Standard_True;
3729 else if (CV3.Arc().IsSame(arc2)){
3730 if (CV2.Point().Distance(CV3.Point())<1.e-4)
3731 oksurf=Standard_True;
3735 if (CV4.IsOnArc()) {
3736 if (CV1.Point().Distance(CV4.Point())<1.e-4)
3737 oksurf=Standard_True;
3738 else if (CV4.Arc().IsSame(arc2)){
3739 if (CV2.Point().Distance(CV4.Point())<1.e-4)
3740 oksurf=Standard_True;
3748 //Case of fillets on top with 4 edges, one of them is on the same geometry as the edgeof the fillet
3751 void ChFi3d_Builder::IntersectMoreCorner(const Standard_Integer Index)
3753 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
3756 OSD_Chronometer ch;// init perf pour PerformSetOfKPart
3758 // The fillet is returned,
3759 ChFiDS_ListIteratorOfListOfStripe StrIt;
3760 StrIt.Initialize(myVDataMap(Index));
3761 Handle(ChFiDS_Stripe) stripe = StrIt.Value();
3762 const Handle(ChFiDS_Spine) spine = stripe->Spine();
3763 ChFiDS_SequenceOfSurfData& SeqFil =
3764 stripe->ChangeSetOfSurfData()->ChangeSequence();
3766 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
3767 // the SurfData concerned and its CommonPoints,
3768 Standard_Integer sens = 0;
3770 // Choose the proper SurfData
3771 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
3772 Standard_Boolean isfirst = (sens == 1);
3774 for (; num<SeqFil.Length() && (
3775 (SeqFil.Value(num)->IndexOfS1()==0) ||
3776 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
3777 SeqFil.Remove(num); // The surplus is removed
3782 (SeqFil.Value(num)->IndexOfS1()==0) ||
3783 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
3784 SeqFil.Remove(num);// The surplus is removed
3789 Handle(ChFiDS_SurfData)& Fd = SeqFil.ChangeValue(num);
3790 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
3791 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
3792 //To evaluate the cloud of new points.
3795 // The cases of cap are processed separately from intersection.
3796 // ----------------------------------------------------------
3798 TopoDS_Face Fv,Fad,Fop,Fopbis;
3799 TopoDS_Edge Arcpiv,Arcprol,Arcspine,Arcprolbis;
3800 if(isfirst) Arcspine = spine->Edges(1);
3801 else Arcspine = spine->Edges(spine->NbEdges());
3802 TopAbs_Orientation OArcprolbis = TopAbs_FORWARD;
3803 TopAbs_Orientation OArcprolv = TopAbs_FORWARD, OArcprolop = TopAbs_FORWARD;
3804 Standard_Integer ICurve;
3805 Handle(BRepAdaptor_HSurface) HBs = new BRepAdaptor_HSurface();
3806 Handle(BRepAdaptor_HSurface) HBad = new BRepAdaptor_HSurface();
3807 Handle(BRepAdaptor_HSurface) HBop = new BRepAdaptor_HSurface();
3808 BRepAdaptor_Surface& Bs = HBs->ChangeSurface();
3809 BRepAdaptor_Surface& Bad = HBad->ChangeSurface();
3810 BRepAdaptor_Surface& Bop = HBop->ChangeSurface();
3811 Handle(Geom_Curve) Cc;
3812 Handle(Geom2d_Curve) Pc,Ps;
3813 Standard_Real Ubid,Vbid;//,mu,Mu,mv,Mv;
3814 Standard_Real Udeb = 0.,Ufin = 0.;
3815 //gp_Pnt2d UVf1,UVl1,UVf2,UVl2;
3816 //Standard_Real Du,Dv,Step;
3817 Standard_Boolean inters = Standard_True;
3818 Standard_Integer IFadArc = 1, IFopArc = 2;
3819 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
3823 ChFi3d_InitChron(ch); // init perf condition
3826 if(!CV1.IsOnArc() && !CV2.IsOnArc())
3827 Standard_Failure::Raise("Corner intersmore : no point on arc");
3828 else if(CV1.IsOnArc() && CV2.IsOnArc()){
3829 Standard_Boolean sur2 = 0;
3830 for(ex.Init(CV1.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()){
3831 if(Vtx.IsSame(ex.Current())) {
3835 for(ex.Init(CV2.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()){
3836 if(Vtx.IsSame(ex.Current())){
3841 if(sur2) IFadArc = 2;
3843 else if(CV2.IsOnArc()) IFadArc = 2;
3844 IFopArc = 3-IFadArc;
3846 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
3847 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
3848 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
3849 TopTools_ListIteratorOfListOfShape It;
3850 // The face at end is returned without control of its unicity.
3851 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
3852 if(!Fad.IsSame(It.Value())){
3853 Fv = TopoDS::Face(It.Value());
3858 // does the face at end contain the Vertex ?
3859 Standard_Boolean isinface = Standard_False;
3860 for (ex.Init(Fv,TopAbs_VERTEX); ex.More(); ex.Next()){
3861 if (ex.Current().IsSame(Vtx)) {
3862 isinface = Standard_True;
3867 IFadArc = 3-IFadArc;
3868 IFopArc = 3-IFopArc;
3869 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
3870 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
3871 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
3872 //TopTools_ListIteratorOfListOfShape It;
3873 // The face at end is returned without control of its unicity.
3874 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
3875 if(!Fad.IsSame(It.Value())){
3876 Fv = TopoDS::Face(It.Value());
3882 if(Fv.IsNull()) StdFail_NotDone::Raise
3883 ("OneCorner : face at end is not found");
3885 Fv.Orientation(TopAbs_FORWARD);
3886 Fad.Orientation(TopAbs_FORWARD);
3888 // In the same way the edge to be extended is returned.
3889 for(It.Initialize(myVEMap(Vtx));It.More() && Arcprol.IsNull();It.Next()){
3890 if(!Arcpiv.IsSame(It.Value())){
3891 for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()){
3892 if(It.Value().IsSame(ex.Current())) {
3893 Arcprol = TopoDS::Edge(It.Value());
3894 OArcprolv = ex.Current().Orientation();
3901 //Fopbis is the face containing the trace of fillet CP.Arc() which of does not contain Vtx.
3902 //Normallly Fobis is either the same as Fop (cylinder), or Fobis is G1 with Fop.
3903 Fopbis.Orientation(TopAbs_FORWARD);
3905 //Fop calls the 4th face non-used for the vertex
3906 cherche_face(myVFMap(Vtx),Arcprol,Fad,Fv,Fv,Fopbis);
3907 Fop.Orientation(TopAbs_FORWARD);
3909 if(Arcprol.IsNull()) StdFail_NotDone::Raise
3910 ("OneCorner : edge to be extended is not found");
3911 for(ex.Init(Fopbis,TopAbs_EDGE); ex.More(); ex.Next()){
3912 if(Arcprol.IsSame(ex.Current())) {
3913 OArcprolop = ex.Current().Orientation();
3919 Standard_Integer prol;
3921 Handle(Geom_Surface ) Sface;
3922 Sface=BRep_Tool::Surface(Fv);
3923 ChFi3d_ExtendSurface(Sface,prol);
3924 tol=BRep_Tool::Tolerance(Fv);
3925 BRE.MakeFace(FFv,Sface,tol);
3927 Bs.Initialize(FFv,Standard_False);
3928 DStr.SetNewSurface(Fv,Sface);
3930 else Bs.Initialize(Fv,Standard_False);
3931 Bad.Initialize(Fad);
3932 Bop.Initialize(Fop);
3934 // it is necessary to modify the CommonPoint
3935 // in the space and its parameter in FaceInterference.
3936 // So both of them are returned in references
3937 // non const. Attention the modifications are done behind
3939 ChFiDS_CommonPoint& CPopArc = Fd->ChangeVertex(isfirst,IFopArc);
3940 ChFiDS_FaceInterference& FiopArc = Fd->ChangeInterference(IFopArc);
3941 ChFiDS_CommonPoint& CPadArc = Fd->ChangeVertex(isfirst,IFadArc);
3942 ChFiDS_FaceInterference& FiadArc = Fd->ChangeInterference(IFadArc);
3943 // the parameter of the vertex is initialized with the value
3944 // of its opposing vertex (point on arc).
3945 Standard_Real wop = Fd->ChangeInterference(IFadArc).Parameter(isfirst);
3946 Handle(Geom_Curve) c3df;
3947 Handle(GeomAdaptor_HSurface)
3948 HGs = new GeomAdaptor_HSurface(DStr.Surface(Fd->Surf()).Surface());
3952 // add here more or less restrictive criteria to
3953 // decide if the intersection with face is done at the
3954 // extended end or if there will be a cap on sharp end.
3955 c3df = DStr.Curve(FiopArc.LineIndex()).Curve();
3956 Standard_Real uf = FiopArc.FirstParameter();
3957 Standard_Real ul = FiopArc.LastParameter();
3958 Handle(GeomAdaptor_HCurve) Hc3df;
3959 if(c3df->IsPeriodic()){
3960 Hc3df = new GeomAdaptor_HCurve(c3df);
3963 Hc3df = new GeomAdaptor_HCurve(c3df,uf,ul);
3965 inters = Update(HBs,Hc3df,FiopArc,CPopArc,p2dbout,isfirst,wop);
3966 // Modified by Sergey KHROMOV - Fri Dec 21 18:08:27 2001 Begin
3967 // if(!inters && BRep_Tool::Continuity(Arcprol,Fv,Fop) != GeomAbs_C0){
3968 if(!inters && isTangentFaces(Arcprol,Fv,Fop)){
3969 // Modified by Sergey KHROMOV - Fri Dec 21 18:08:29 2001 End
3970 // Arcprol is an edge of tangency, ultimate adjustment by an extrema curve/curve is attempted.
3971 Standard_Real ff,ll;
3972 Handle(Geom2d_Curve) gpcprol = BRep_Tool::CurveOnSurface(Arcprol,Fv,ff,ll);
3973 Handle(Geom2dAdaptor_HCurve) pcprol = new Geom2dAdaptor_HCurve(gpcprol);
3974 Standard_Real partemp = BRep_Tool::Parameter(Vtx,Arcprol);
3975 inters = Update(HBs,pcprol,HGs,FiopArc,CPopArc,p2dbout,
3976 isfirst,partemp,wop,10*tolesp);
3978 Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
3979 pced->ChangeCurve2d().Initialize(CPadArc.Arc(),Fv);
3980 Update(HBs,pced,HGs,FiadArc,CPadArc,isfirst);
3983 ChFi3d_ResultChron(ch,t_same); // result perf condition if (same)
3984 ChFi3d_InitChron(ch); // init perf condition if (inters)
3987 TopoDS_Edge edgecouture;
3988 Standard_Boolean couture,intcouture=Standard_False;;
3989 Standard_Real tolreached = tolesp;
3990 Standard_Real par1 = 0.,par2 = 0.;
3991 Standard_Integer indpt =0,Icurv1 =0,Icurv2 =0;
3992 Handle(Geom_TrimmedCurve) curv1,curv2;
3993 Handle(Geom2d_Curve) c2d1,c2d2;
3995 Standard_Integer Isurf=Fd->Surf();
3998 HGs = ChFi3d_BoundSurf(DStr,Fd,1,2);
3999 const ChFiDS_FaceInterference& Fi1 = Fd->InterferenceOnS1();
4000 const ChFiDS_FaceInterference& Fi2 = Fd->InterferenceOnS2();
4001 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
4002 gp_Pnt2d pfil1,pfac1,pfil2,pfac2;
4003 Handle(Geom2d_Curve) Hc1,Hc2;
4004 if( IFopArc == 1) pfac1 = p2dbout;
4006 Hc1 = BRep_Tool::CurveOnSurface(CV1.Arc(),Fv,Ubid,Ubid);
4007 pfac1 = Hc1->Value(CV1.ParameterOnArc());
4009 if(IFopArc == 2) pfac2 = p2dbout;
4011 Hc2 = BRep_Tool::CurveOnSurface(CV2.Arc(),Fv,Ubid,Ubid);
4012 pfac2 = Hc2->Value(CV2.ParameterOnArc());
4014 if(Fi1.LineIndex() != 0){
4015 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));
4018 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
4020 if(Fi2.LineIndex() != 0){
4021 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
4024 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
4026 ChFi3d_Recale(Bs,pfac1,pfac2,(IFadArc == 1));
4027 Pardeb(1)= pfil1.X();Pardeb(2) = pfil1.Y();
4028 Pardeb(3)= pfac1.X();Pardeb(4) = pfac1.Y();
4029 Parfin(1)= pfil2.X();Parfin(2) = pfil2.Y();
4030 Parfin(3)= pfac2.X();Parfin(4) = pfac2.Y();
4031 Standard_Real uu1,uu2,vv1,vv2;
4032 ChFi3d_Boite(pfac1,pfac2,uu1,uu2,vv1,vv2);
4033 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
4035 if (!ChFi3d_ComputeCurves(HGs,HBs,Pardeb,Parfin,Cc,
4037 Pc,tolesp,tol2d,tolreached))
4038 Standard_Failure::Raise("OneCorner : failed calculation intersection");
4040 Udeb = Cc->FirstParameter();
4041 Ufin = Cc->LastParameter();
4043 // check if the curve has an intersection with sewing edge
4045 ChFi3d_Couture(Fv,couture,edgecouture);
4047 if (couture && !BRep_Tool::Degenerated(edgecouture)) {
4049 //Standard_Real Ubid,Vbid;
4050 Handle (Geom_Curve) C=BRep_Tool::Curve(edgecouture,Ubid,Vbid);
4051 Handle(Geom_TrimmedCurve) Ctrim=new Geom_TrimmedCurve (C,Ubid,Vbid);
4052 GeomAdaptor_Curve cur1(Ctrim->BasisCurve());
4053 GeomAdaptor_Curve cur2(Cc);
4054 Extrema_ExtCC extCC (cur1,cur2);
4055 if (extCC.IsDone()&&extCC.NbExt()!=0)
4057 Standard_Integer imin=0;
4058 Standard_Real dist2min = RealLast();
4059 for (Standard_Integer i = 1; i <= extCC.NbExt(); i++)
4060 if (extCC.SquareDistance(i) < dist2min)
4062 dist2min = extCC.SquareDistance(i);
4065 if (dist2min <= Precision::SquareConfusion())
4067 Extrema_POnCurv ponc1,ponc2;
4068 extCC.Points( imin, ponc1, ponc2 );
4069 par1 = ponc1.Parameter();
4070 par2 = ponc2.Parameter();
4071 Standard_Real Tol = 1.e-4;
4072 if (Abs(par2-Udeb) > Tol && Abs(Ufin-par2) > Tol)
4074 gp_Pnt P1=ponc1.Value();
4075 TopOpeBRepDS_Point tpoint( P1, Tol );
4076 indpt = DStr.AddPoint(tpoint);
4077 intcouture = Standard_True;
4078 curv1 = new Geom_TrimmedCurve(Cc,Udeb,par2);
4079 curv2 = new Geom_TrimmedCurve(Cc,par2,Ufin);
4080 TopOpeBRepDS_Curve tcurv1(curv1,tolreached);
4081 TopOpeBRepDS_Curve tcurv2(curv2,tolreached);
4082 Icurv1=DStr.AddCurve(tcurv1);
4083 Icurv2=DStr.AddCurve(tcurv2);
4091 Standard_NotImplemented::Raise("OneCorner : cap not written");
4093 Standard_Integer IShape = DStr.AddShape(Fv);
4094 TopAbs_Orientation Et = TopAbs_FORWARD;
4096 TopExp_Explorer Exp;
4097 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
4098 TopAbs_EDGE);Exp.More();Exp.Next()) {
4099 if (Exp.Current().IsSame(CV1.Arc())) {
4100 Et = TopAbs::Reverse(TopAbs::Compose
4101 (Exp.Current().Orientation(),
4102 CV1.TransitionOnArc()));
4108 TopExp_Explorer Exp;
4109 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
4110 TopAbs_EDGE);Exp.More();Exp.Next()) {
4111 if (Exp.Current().IsSame(CV2.Arc())) {
4112 Et = TopAbs::Compose(Exp.Current().Orientation(),
4113 CV2.TransitionOnArc());
4124 ChFi3d_ResultChron(ch ,t_inter); //result perf condition if (inter)
4125 ChFi3d_InitChron(ch); // init perf condition if ( inters)
4128 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV1,DStr),isfirst,1);
4129 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV2,DStr),isfirst,2);
4132 // there is no intersection with edge of sewing
4133 // curve Cc is stored in the stripe
4134 // the storage in the DS is done by FILDS.
4136 TopOpeBRepDS_Curve Tc(Cc,tolreached);
4137 ICurve = DStr.AddCurve(Tc);
4138 Handle(TopOpeBRepDS_SurfaceCurveInterference)
4139 Interfc = ChFi3d_FilCurveInDS(ICurve,IShape,Pc,Et);
4140 DStr.ChangeShapeInterferences(IShape).Append(Interfc);
4141 stripe->ChangePCurve(isfirst)=Ps;
4142 stripe->SetCurve(ICurve,isfirst);
4143 stripe->SetParameters(isfirst,Udeb,Ufin);
4146 // curves curv1 and curv2 are stored in the DS
4147 // these curves are not reconstructed by FILDS as
4148 // stripe->InDS(isfirst) is placed;
4150 // interferences of curv1 and curv2 on Fv
4151 ComputeCurve2d(curv1,Fv,c2d1);
4152 Handle(TopOpeBRepDS_SurfaceCurveInterference) InterFv;
4153 InterFv = ChFi3d_FilCurveInDS(Icurv1,IShape,c2d1,Et);
4154 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
4155 ComputeCurve2d(curv2,Fv,c2d2);
4156 InterFv = ChFi3d_FilCurveInDS(Icurv2,IShape,c2d2,Et);
4157 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
4158 // interferences of curv1 and curv2 on Isurf
4159 if (Fd->Orientation()== Fv.Orientation()) Et=TopAbs::Reverse(Et);
4160 c2d1=new Geom2d_TrimmedCurve(Ps,Udeb,par2);
4161 InterFv = ChFi3d_FilCurveInDS(Icurv1,Isurf,c2d1,Et);
4162 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
4163 c2d2=new Geom2d_TrimmedCurve(Ps,par2,Ufin);
4164 InterFv = ChFi3d_FilCurveInDS(Icurv2,Isurf,c2d2,Et);
4165 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
4167 // limitation of the sewing edge
4168 Standard_Integer Iarc=DStr.AddShape(edgecouture);
4169 Handle(TopOpeBRepDS_CurvePointInterference) Interfedge;
4170 TopAbs_Orientation ori;
4171 TopoDS_Vertex Vdeb,Vfin;
4172 Vdeb=TopExp::FirstVertex(edgecouture);
4173 Vfin=TopExp::LastVertex(edgecouture);
4174 Standard_Real pard,parf;
4175 pard=BRep_Tool::Parameter(Vdeb,edgecouture);
4176 parf=BRep_Tool::Parameter(Vfin,edgecouture);
4177 if (Abs(par1-pard)<Abs(parf-par1)) ori=TopAbs_FORWARD;
4178 else ori=TopAbs_REVERSED;
4179 Interfedge = ChFi3d_FilPointInDS(ori,Iarc,indpt,par1);
4180 DStr.ChangeShapeInterferences(Iarc).Append(Interfedge);
4182 // creation of CurveInterferences from Icurv1 and Icurv2
4183 stripe->InDS(isfirst);
4184 Standard_Integer ind1= stripe->IndexPoint(isfirst,1);
4185 Standard_Integer ind2= stripe->IndexPoint(isfirst,2);
4186 Handle(TopOpeBRepDS_CurvePointInterference)
4187 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv1,ind1,Udeb);
4188 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
4189 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv1,indpt,par2);
4190 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
4191 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv2,indpt,par2);
4192 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
4193 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv2,ind2,Ufin);
4194 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
4198 ChFi3d_EnlargeBox(HBs,Pc,Udeb,Ufin,box1,box2);
4203 // The small end of curve missing for the extension
4204 // of the face at end and the limitation of the opposing face is added.
4206 // Above all the points cut the points with the edge of the spine.
4207 Standard_Integer IArcspine = DStr.AddShape(Arcspine);
4208 Standard_Integer IVtx = DStr.AddShape(Vtx);
4209 TopAbs_Orientation OVtx2 = TopAbs_FORWARD;
4210 TopAbs_Orientation OVtx = TopAbs_FORWARD;
4211 for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
4212 ex.More(); ex.Next()){
4213 if(Vtx.IsSame(ex.Current())) {
4214 OVtx = ex.Current().Orientation();
4218 OVtx = TopAbs::Reverse(OVtx);
4219 Standard_Real parVtx = BRep_Tool::Parameter(Vtx,Arcspine);
4220 Handle(TopOpeBRepDS_CurvePointInterference)
4221 interfv = ChFi3d_FilVertexInDS(OVtx,IArcspine,IVtx,parVtx);
4222 DStr.ChangeShapeInterferences(IArcspine).Append(interfv);
4225 //Modif of lvt to find the suite of Arcprol in the other face
4227 TopTools_ListIteratorOfListOfShape It;
4228 for (It.Initialize(myVEMap(Vtx)); It.More(); It.Next()){
4229 if (!(Arcprol.IsSame(It.Value()) ||
4230 Arcspine.IsSame(It.Value()) ||
4231 Arcpiv.IsSame(It.Value()))) {
4232 Arcprolbis = TopoDS::Edge(It.Value());
4239 //Now the missing curves are constructed.
4240 for(ex.Init(Arcprolbis.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
4241 ex.More(); ex.Next()){
4242 if(Vtx.IsSame(ex.Current())) {
4243 OVtx2 = ex.Current().Orientation();
4247 for(ex.Init(Arcprol.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
4248 ex.More(); ex.Next()){
4249 if(Vtx.IsSame(ex.Current())) {
4250 OVtx = ex.Current().Orientation();
4254 // it is checked if Fop has a sewing edge
4256 // TopoDS_Edge edgecouture;
4257 // Standard_Boolean couture;
4258 ChFi3d_Couture(Fop,couture,edgecouture);
4259 Handle(Geom2d_Curve) Hc;
4260 // parVtx = BRep_Tool::Parameter(Vtx,Arcprol);
4261 const ChFiDS_FaceInterference& Fiop = Fd->Interference(IFopArc);
4262 gp_Pnt2d pop1, pop2, pv1, pv2;
4264 parVtx = BRep_Tool::Parameter(Vtx,Arcprolbis);
4265 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 Begin
4266 // if(Fop.IsSame(Fopbis)) OArcprolbis = OArcprolop;
4267 // else OArcprolbis = Arcprolbis.Orientation();
4268 if(Fop.IsSame(Fopbis)) {
4269 OArcprolbis = OArcprolop;
4271 for(ex.Init(Fop,TopAbs_EDGE); ex.More(); ex.Next()){
4272 if(Arcprolbis.IsSame(ex.Current())) {
4273 OArcprolbis = ex.Current().Orientation();
4278 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 End
4280 Hc = BRep_Tool::CurveOnSurface(Arcprolbis,Fop,Ubid,Ubid);
4281 pop1 = Hc->Value(parVtx);
4282 pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst));
4283 Hc = BRep_Tool::CurveOnSurface(Arcprol,Fv,Ubid,Ubid);
4285 parVtx = BRep_Tool::Parameter(Vtx,Arcprol);
4287 pv1 = Hc->Value(parVtx);
4289 ChFi3d_Recale(Bs,pv1,pv2,1);
4290 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
4291 Pardeb(1) = pop1.X(); Pardeb(2) = pop1.Y();
4292 Pardeb(3) = pv1.X(); Pardeb(4) = pv1.Y();
4293 Parfin(1) = pop2.X(); Parfin(2) = pop2.Y();
4294 Parfin(3) = pv2.X(); Parfin(4) = pv2.Y();
4295 Standard_Real uu1,uu2,vv1,vv2;
4296 ChFi3d_Boite(pv1,pv2,uu1,uu2,vv1,vv2);
4297 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
4298 ChFi3d_Boite(pop1,pop2,uu1,uu2,vv1,vv2);
4299 ChFi3d_BoundFac(Bop,uu1,uu2,vv1,vv2);
4301 Handle(Geom_Curve) zob3d;
4302 Handle(Geom2d_Curve) zob2dop, zob2dv;
4303 // Standard_Real tolreached;
4304 if (!ChFi3d_ComputeCurves(HBop,HBs,Pardeb,Parfin,zob3d,zob2dop,
4305 zob2dv,tolesp,tol2d,tolreached))
4306 Standard_Failure::Raise("OneCorner : echec calcul intersection");
4308 Udeb = zob3d->FirstParameter();
4309 Ufin = zob3d->LastParameter();
4310 TopOpeBRepDS_Curve Zob(zob3d,tolreached);
4311 Standard_Integer IZob = DStr.AddCurve(Zob);
4313 // it is not determined if the curve has an intersection with the sewing edge
4317 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv));
4318 Standard_Integer Iop = DStr.AddShape(Fop);
4319 Handle(TopOpeBRepDS_SurfaceCurveInterference)
4320 InterFv = ChFi3d_FilCurveInDS(IZob,IShape,zob2dv,Et);
4321 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
4322 //OVtx = TopAbs::Reverse(OVtx);
4323 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 Begin
4324 // Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolbis));
4325 Et = TopAbs::Reverse(TopAbs::Compose(OVtx2,OArcprolbis));
4326 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 End
4327 //OVtx = TopAbs::Reverse(OVtx);
4328 // Et = TopAbs::Reverse(Et);
4329 Handle(TopOpeBRepDS_SurfaceCurveInterference)
4330 Interfop = ChFi3d_FilCurveInDS(IZob,Iop,zob2dop,Et);
4331 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
4332 Handle(TopOpeBRepDS_CurvePointInterference)
4333 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IVtx,Udeb);
4334 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
4335 Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc);
4336 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,IZob,icc,Ufin);
4337 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
4341 ChFi3d_EnlargeBox(DStr,stripe,Fd,box1,box2,isfirst);
4343 ChFi3d_EnlargeBox(CV1.Arc(),myEFMap(CV1.Arc()),CV1.ParameterOnArc(),box1);
4346 ChFi3d_EnlargeBox(CV2.Arc(),myEFMap(CV2.Arc()),CV2.ParameterOnArc(),box2);
4348 if (!CV1.IsVertex())
4349 ChFi3d_SetPointTolerance(DStr,box1,stripe->IndexPoint(isfirst,1));
4350 if (!CV2.IsVertex())
4351 ChFi3d_SetPointTolerance(DStr,box2,stripe->IndexPoint(isfirst,2));
4354 ChFi3d_ResultChron(ch, t_sameinter);//result perf condition if (same &&inter)