1 // Created on: 1994-03-09
2 // Created by: Isabelle GRIGNON
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 // Modified by skv - Mon Jun 7 18:38:57 2004 OCC5898
23 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222
25 #include <ChFi3d_Builder.jxx>
27 #include <ChFi3d_Builder_0.hxx>
29 #include <Precision.hxx>
31 #include <Standard_Failure.hxx>
32 #include <Standard_NotImplemented.hxx>
33 #include <StdFail_NotDone.hxx>
40 #include <gp_Pnt2d.hxx>
41 #include <gp_Vec2d.hxx>
42 #include <gp_Dir2d.hxx>
43 #include <gp_Elips.hxx>
44 #include <gp_Circ.hxx>
49 #include <Geom_Line.hxx>
50 #include <Geom_Circle.hxx>
51 #include <Geom_Ellipse.hxx>
52 #include <Geom_RectangularTrimmedSurface.hxx>
53 #include <Geom_Curve.hxx>
54 #include <Geom2d_Line.hxx>
55 #include <Geom2d_Curve.hxx>
56 #include <Geom_BSplineCurve.hxx>
57 #include <Geom_BSplineSurface.hxx>
58 #include <Geom_BezierSurface.hxx>
59 #include <Geom2d_BSplineCurve.hxx>
60 #include <Geom2dAdaptor_HCurve.hxx>
61 #include <Geom2d_TrimmedCurve.hxx>
62 #include <Geom2dInt_GInter.hxx>
63 #include <Geom_TrimmedCurve.hxx>
64 #include <GeomAPI_ExtremaCurveCurve.hxx>
65 #include <GeomAbs_Shape.hxx>
66 #include <GeomAdaptor_HCurve.hxx>
67 #include <GeomAdaptor_Surface.hxx>
68 #include <GeomAdaptor_HSurface.hxx>
69 #include <Geom_BoundedCurve.hxx>
70 #include <GeomLib.hxx>
71 #include <GeomInt_IntSS.hxx>
72 #include <GeomProjLib.hxx>
74 #include <Adaptor3d_HCurveOnSurface.hxx>
75 #include <Adaptor3d_CurveOnSurface.hxx>
76 #include <BRepAdaptor_HSurface.hxx>
77 #include <BRepAdaptor_Curve.hxx>
78 #include <BRepAdaptor_Curve2d.hxx>
79 #include <BRepAdaptor_HCurve2d.hxx>
80 #include <BRepAdaptor_HCurve.hxx>
81 #include <BRepAdaptor_Surface.hxx>
82 #include <BRepLib_MakeEdge.hxx>
83 #include <BRepAlgo_NormalProjection.hxx>
84 #include <BRepExtrema_ExtCC.hxx>
85 #include <BRep_Tool.hxx>
86 #include <BRepTools.hxx>
87 #include <BRep_Builder.hxx>
88 #include <IntCurveSurface_HInter.hxx>
89 #include <IntCurveSurface_IntersectionPoint.hxx>
90 #include <IntRes2d_IntersectionPoint.hxx>
91 #include <IntRes2d_Transition.hxx>
92 #include <Extrema_LocateExtCC.hxx>
93 #include <Extrema_POnCurv.hxx>
94 #include <Extrema_ExtPC2d.hxx>
95 #include <Extrema_ExtPC.hxx>
96 #include <Extrema_ExtPS.hxx>
97 #include <Extrema_ExtCC.hxx>
100 #include <TopoDS_Shape.hxx>
101 #include <TopoDS_Face.hxx>
102 #include <TopoDS_Edge.hxx>
103 #include <TopoDS_Vertex.hxx>
105 #include <TopAbs.hxx>
106 #include <TopAbs_ShapeEnum.hxx>
107 #include <TopAbs_Orientation.hxx>
108 #include <TopExp.hxx>
109 #include <TopExp_Explorer.hxx>
110 #include <TopLoc_Location.hxx>
111 #include <TopTools_ListIteratorOfListOfShape.hxx>
113 #include <TopOpeBRepDS_Point.hxx>
114 #include <TopOpeBRepDS_Curve.hxx>
115 #include <TopOpeBRepDS_Surface.hxx>
116 #include <TopOpeBRepDS_SurfaceCurveInterference.hxx>
117 #include <TopOpeBRepDS_CurvePointInterference.hxx>
118 #include <TopOpeBRepDS_DataStructure.hxx>
119 #include <TopOpeBRepDS_ListOfInterference.hxx>
120 #include <TopOpeBRepDS_ListIteratorOfListOfInterference.hxx>
121 #include <TopOpeBRepDS_SolidSurfaceInterference.hxx>
122 #include <TopOpeBRepDS_Kind.hxx>
123 #include <TopOpeBRepDS_Transition.hxx>
124 #include <TopTools_Array1OfShape.hxx>
125 #include <ChFiDS_HData.hxx>
126 #include <ChFiDS_SurfData.hxx>
127 #include <ChFiDS_CommonPoint.hxx>
128 #include <ChFiDS_FaceInterference.hxx>
129 #include <ChFiDS_SequenceOfSurfData.hxx>
130 #include <ChFiDS_Stripe.hxx>
131 #include <ChFiDS_ListIteratorOfListOfStripe.hxx>
132 #include <ChFiDS_Map.hxx>
133 #include <TColgp_Array1OfPnt.hxx>
134 #include <TColgp_Array1OfPnt2d.hxx>
135 #include <TColStd_Array1OfReal.hxx>
136 #include <TColStd_Array1OfInteger.hxx>
140 #include <OSD_Chronometer.hxx>
141 #include <DrawTrSurf.hxx>
143 // Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 Begin
145 // ChFi3d_Builder::PerformMoreSurfdata(const Standard_Integer Index)
146 // is totally rewroted.
147 // Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 End
149 extern Standard_Real t_same,t_inter,t_sameinter;
150 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
151 extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
153 #include <Geom2dAPI_ProjectPointOnCurve.hxx>
154 #include <math_FunctionSample.hxx>
155 #include <Geom2dAdaptor_Curve.hxx>
156 #include <IntRes2d_IntersectionSegment.hxx>
157 // Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 Begin
158 Standard_Boolean isTangentFaces(const TopoDS_Edge &theEdge,
159 const TopoDS_Face &theFace1,
160 const TopoDS_Face &theFace2);
161 // Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 End
163 static Standard_Real recadre(const Standard_Real p,
164 const Standard_Real ref,
165 const Standard_Boolean isfirst,
166 const Standard_Real first,
167 const Standard_Real last)
169 Standard_Real pp = p;
170 if (isfirst) pp -= (last - first);
171 else pp += (last - first);
172 if (Abs(pp - ref) < Abs(p - ref)) return pp;
176 //=======================================================================
178 //purpose : Calculate the intersection of the face at the end of
179 // the tangency line to update CommonPoint and its
180 // parameter in FaceInterference.
181 //=======================================================================
183 static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& fb,
184 Handle(Adaptor2d_HCurve2d)& pcfb,
185 Handle(Adaptor3d_HSurface)& surf,
186 ChFiDS_FaceInterference& fi,
187 ChFiDS_CommonPoint& cp,
189 const Standard_Boolean isfirst,
190 Standard_Real& pared,
192 const Standard_Real tol)
194 Adaptor3d_CurveOnSurface c1(pcfb,fb);
195 Handle(Geom2d_Curve) pc = fi.PCurveOnSurf();
196 Handle(Geom2dAdaptor_HCurve) hpc = new Geom2dAdaptor_HCurve(pc);
197 Adaptor3d_CurveOnSurface c2(hpc,surf);
198 Extrema_LocateExtCC ext(c1,c2,pared,wop);
200 Standard_Real dist2 = ext.SquareDistance();
201 if (dist2 < tol * tol) {
202 Extrema_POnCurv ponc1,ponc2;
203 ext.Point(ponc1,ponc2);
204 Standard_Real parfb = ponc1.Parameter();
205 p2dbout = pcfb->Value(parfb);
206 pared = ponc1.Parameter();
207 wop = ponc2.Parameter();
208 fi.SetParameter(wop,isfirst);
210 cp.SetPoint(ponc1.Value());
211 return Standard_True;
214 return Standard_False;
217 //=======================================================================
219 //purpose : Intersect surface <fb> and 3d curve <ct>
220 // Update <isfirst> parameter of FaceInterference <fi> and point of
221 // CommonPoint <cp>. Return new intersection parameters in <wop>
223 //=======================================================================
225 static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& fb,
226 Handle(Adaptor3d_HCurve)& ct,
227 ChFiDS_FaceInterference& fi,
228 ChFiDS_CommonPoint& cp,
230 const Standard_Boolean isfirst,
233 IntCurveSurface_HInter Intersection;
234 //check if in KPart the limits of the tangency line
235 //are already in place at this stage.
236 //Modif lvt : the periodic cases are reframed, espercially if nothing was found.
237 Standard_Real w,uf = ct->FirstParameter(),ul = ct->LastParameter();
239 Standard_Real wbis = 0.;
243 Standard_Boolean isperiodic = ct->IsPeriodic(),recadrebis = Standard_False;
244 Intersection.Perform(ct,fb);
245 if (Intersection.IsDone()) {
246 Standard_Integer nbp = Intersection.NbPoints(),i,isol = 0,isolbis = 0;
247 Standard_Real dist = Precision::Infinite();
248 Standard_Real distbis = Precision::Infinite();
249 for (i = 1; i <= nbp; i++) {
250 w = Intersection.Point(i).W();
251 if (isperiodic) w = recadre(w,wop,isfirst,uf,ul);
252 if (uf <= w && ul >= w && Abs(w-wop) < dist) {
258 for (i = 1; i <= nbp; i++) {
259 w = Intersection.Point(i).W();
260 if (uf <= w && ul >= w && Abs(w-wop) < distbis && (Abs(w-ul)<=0.01 || Abs(w-uf)<=0.01)) {
262 wbis = recadre(w,wop,isfirst,uf,ul);
263 distbis = Abs(wbis-wop);
264 recadrebis = Standard_True;
268 if (isol == 0 && isolbis == 0) {
269 return Standard_False;
272 IntCurveSurface_IntersectionPoint pint = Intersection.Point(isol);
273 p2dbout.SetCoord(pint.U(),pint.V());
275 if (isperiodic) w = ElCLib::InPeriod(w,uf,ul);
279 IntCurveSurface_IntersectionPoint pint = Intersection.Point(isolbis);
280 p2dbout.SetCoord(pint.U(),pint.V());
284 IntCurveSurface_IntersectionPoint pint = Intersection.Point(isol);
285 p2dbout.SetCoord(pint.U(),pint.V());
287 w = ElCLib::InPeriod(w,uf,ul);
290 fi.SetParameter(w,isfirst);
292 cp.SetPoint(ct->Value(w));
294 return Standard_True;
296 return Standard_False;
299 //=======================================================================
300 //function : IntersUpdateOnSame
301 //purpose : Intersect curve <c3dFI> of ChFi-<Fop> interference with extended
302 // surface <HBs> of <Fprol> . Return intersection parameters in
303 // <FprolUV>, <c3dU> and updating <FIop> and <CPop>
304 // <HGs> is a surface of ChFi
305 // <Fop> is a face having 2 edges at corner with OnSame state
306 // <Fprol> is a face non-adjacent to spine edge
307 // <Vtx> is a corner vertex
308 //=======================================================================
310 static Standard_Boolean IntersUpdateOnSame(Handle(GeomAdaptor_HSurface)& HGs,
311 Handle(BRepAdaptor_HSurface)& HBs,
312 const Handle(Geom_Curve)& c3dFI,
313 const TopoDS_Face& Fop,
314 const TopoDS_Face& Fprol,
315 const TopoDS_Edge& Eprol,
316 const TopoDS_Vertex& Vtx,
317 const Standard_Boolean isFirst,
318 const Standard_Real Tol,
319 ChFiDS_FaceInterference& FIop,
320 ChFiDS_CommonPoint& CPop,
324 // add more or less restrictive criterions to
325 // decide if the intersection is done with the face at
326 // extended end or if the end is sharp.
327 Standard_Real uf = FIop.FirstParameter();
328 Standard_Real ul = FIop.LastParameter();
329 Handle(GeomAdaptor_HCurve) Hc3df;
330 if (c3dFI->IsPeriodic()) Hc3df = new GeomAdaptor_HCurve(c3dFI);
331 else Hc3df = new GeomAdaptor_HCurve(c3dFI,uf,ul);
333 if ( Update(HBs,Hc3df,FIop,CPop,FprolUV,isFirst,c3dU) )
334 return Standard_True;
336 if (!isTangentFaces(Eprol,Fprol,Fop))
337 return Standard_False;
339 Handle(Geom2d_Curve) gpcprol = BRep_Tool::CurveOnSurface(Eprol,Fprol,uf,ul);
340 Handle(Geom2dAdaptor_HCurve) pcprol = new Geom2dAdaptor_HCurve(gpcprol);
341 Standard_Real partemp = BRep_Tool::Parameter(Vtx,Eprol);
344 Update(HBs,pcprol,HGs,FIop,CPop,FprolUV,isFirst,partemp,c3dU,Tol);
347 //=======================================================================
349 //purpose : Calculate the extrema curveonsurf/curveonsurf to prefer
350 // the values concerning the trace on surf and the pcurve on the
352 //=======================================================================
354 static Standard_Boolean Update(Handle(Adaptor3d_HSurface)& face,
355 Handle(Adaptor2d_HCurve2d)& edonface,
356 Handle(Adaptor3d_HSurface)& surf,
357 ChFiDS_FaceInterference& fi,
358 ChFiDS_CommonPoint& cp,
359 const Standard_Boolean isfirst)
361 if (!cp.IsOnArc()) return 0;
362 Adaptor3d_CurveOnSurface c1(edonface,face);
363 Standard_Real pared = cp.ParameterOnArc();
364 Standard_Real parltg = fi.Parameter(isfirst);
365 Handle(Geom2d_Curve) pc = fi.PCurveOnSurf();
366 Standard_Real f = fi.FirstParameter();
367 Standard_Real l = fi.LastParameter();
368 Standard_Real delta = 0.1 * ( l - f );
369 f = Max(f-delta,pc->FirstParameter());
370 l = Min(l+delta,pc->LastParameter());
371 Handle(Geom2dAdaptor_HCurve) hpc = new Geom2dAdaptor_HCurve(pc,f,l);
372 Adaptor3d_CurveOnSurface c2(hpc,surf);
374 Extrema_LocateExtCC ext(c1,c2,pared,parltg);
376 Extrema_POnCurv ponc1,ponc2;
377 ext.Point(ponc1,ponc2);
378 pared = ponc1.Parameter();
379 parltg = ponc2.Parameter();
380 if ((parltg > f) && (parltg < l)) {
381 ////modified by jgv, 10.05.2012 for the bug 23139////
382 Handle(Geom2d_Curve) PConF = fi.PCurveOnFace();
385 Handle(Geom2d_TrimmedCurve) aTrCurve = Handle(Geom2d_TrimmedCurve)::DownCast(PConF);
386 if (!aTrCurve.IsNull())
387 PConF = aTrCurve->BasisCurve();
390 Standard_Real fpar = PConF->FirstParameter();
396 Standard_Real lpar = PConF->LastParameter();
401 /////////////////////////////////////////////////////
402 fi.SetParameter(parltg,isfirst);
403 cp.SetArc(cp.Tolerance(),cp.Arc(),pared,cp.TransitionOnArc());
404 return Standard_True;
407 return Standard_False;
410 //=======================================================================
411 //function : ChFi3d_ExtendSurface
413 //=======================================================================
415 static void ChFi3d_ExtendSurface (Handle(Geom_Surface) & S ,
416 Standard_Integer & prol )
419 Handle(Geom_BSplineSurface) S1;
420 Handle(Geom_BezierSurface) S2;
421 Standard_Real length,umin,umax,vmin,vmax;
423 S->Bounds(umin,umax,vmin,vmax);
426 length=P1.Distance(P2);
428 S1=Handle(Geom_BSplineSurface)::DownCast(S);
429 S2=Handle(Geom_BezierSurface)::DownCast(S);
431 GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,
433 GeomLib::ExtendSurfByLength(S1,length,1,Standard_True,
435 GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,
437 GeomLib::ExtendSurfByLength(S1,length,1,Standard_True,
443 GeomLib::ExtendSurfByLength(S2,length,1,Standard_False,
445 GeomLib::ExtendSurfByLength(S2,length,1,Standard_True,
447 GeomLib::ExtendSurfByLength(S2,length,1,Standard_False,
449 GeomLib::ExtendSurfByLength(S2,length,1,Standard_True,
457 //=======================================================================
458 //function : ComputeCurve2d
459 //purpose : calculate the 2d of the curve Ct on face Face
460 //=======================================================================
462 static void ComputeCurve2d (Handle(Geom_Curve )& Ct,
464 Handle(Geom2d_Curve) & C2d)
467 TopTools_IndexedMapOfShape MapE1;
468 BRepLib_MakeEdge Bedge (Ct);
469 TopoDS_Edge edg =Bedge. Edge();
470 BRepAlgo_NormalProjection OrtProj;
473 OrtProj.SetParams(1.e-6, 1.e-6, GeomAbs_C1, 14, 16);
474 OrtProj.SetLimit(Standard_False);
475 OrtProj.Compute3d(Standard_False);
477 Standard_Real up1,up2;
478 if ( OrtProj.IsDone()) {
479 TopExp::MapShapes(OrtProj.Projection() ,TopAbs_EDGE, MapE1);
480 if (MapE1.Extent()!=0) {
481 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE1(1));
482 E1=TopoDS::Edge(aLocalShape );
483 // E1=TopoDS::Edge( TopoDS_Shape (MapE1(1)));
484 C2d=BRep_Tool::CurveOnSurface(E1,Face,up1,up2);
489 //=======================================================================
490 //function : ChFi3d_Recale
492 //=======================================================================
494 static void ChFi3d_Recale(BRepAdaptor_Surface& Bs,
497 const Standard_Boolean refon1)
499 Handle(Geom_Surface) surf = Bs.ChangeSurface().Surface();
500 Handle(Geom_RectangularTrimmedSurface)
501 ts = Handle(Geom_RectangularTrimmedSurface)::DownCast(surf);
502 if (!ts.IsNull()) surf = ts->BasisSurface();
503 if (surf->IsUPeriodic()) {
504 Standard_Real u1 = p1.X(), u2 = p2.X();
505 Standard_Real uper = surf->UPeriod();
506 if (fabs(u2-u1) > 0.5*uper) {
507 if (u2<u1 && refon1) u2 += uper;
508 else if (u2<u1 && !refon1) u1 -= uper;
509 else if (u1<u2 && refon1) u2 -= uper;
510 else if (u1<u2 && !refon1) u1 += uper;
512 p1.SetX(u1); p2.SetX(u2);
514 if (surf->IsVPeriodic()) {
515 Standard_Real v1 = p1.Y(), v2 = p2.Y();
516 Standard_Real vper = surf->VPeriod();
517 if (fabs(v2-v1) > 0.5*vper) {
518 if (v2<v1 && refon1) v2 += vper;
519 else if (v2<v1 && !refon1) v1 -= vper;
520 else if (v1<v2 && refon1) v2 -= vper;
521 else if (v1<v2 && !refon1) v1 += vper;
523 p1.SetY(v1); p2.SetY(v2);
527 //=======================================================================
528 //function : ChFi3d_SelectStripe
529 //purpose : find stripe with ChFiDS_OnSame state if <thePrepareOnSame> is True
530 //=======================================================================
532 Standard_Boolean ChFi3d_SelectStripe(ChFiDS_ListIteratorOfListOfStripe & It,
533 const TopoDS_Vertex& Vtx,
534 const Standard_Boolean thePrepareOnSame)
536 if (!thePrepareOnSame) return Standard_True;
538 for (; It.More(); It.Next()) {
539 Standard_Integer sens = 0;
540 Handle(ChFiDS_Stripe) stripe = It.Value();
541 ChFi3d_IndexOfSurfData(Vtx, stripe, sens);
544 stat = stripe->Spine()->FirstStatus();
546 stat = stripe->Spine()->LastStatus();
547 if ( stat == ChFiDS_OnSame ) return Standard_True;
550 return Standard_False;
552 //=======================================================================
553 //function : PerformOneCorner
554 //purpose : Calculate a corner with three edges and a fillet.
555 // 3 separate case: (22/07/94 only 1st is implemented)
557 // - same concavity on three edges, intersection with the
559 // - concavity of 2 outgoing edges is opposite to the one of the fillet,
560 // if the face at end is ready for that, the same in case 1 on extended face,
561 // otherwise a small cap is done with GeomFill,
562 // - only one outgoing edge has concavity opposed to the edge of the
563 // fillet and the third edge, the top of the corner is reread
564 // in the empty of the fillet and closed, either by extending the face
565 // at end if it is plane and orthogonal to the
566 // guiding edge, or by a cap of type GeomFill.
568 // <thePrepareOnSame> means that only needed thing is redefinition
569 // of intersection pameter of OnSame-Stripe with <Arcprol>
570 // (eap, Arp 9 2002, occ266)
571 //=======================================================================
573 void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index,
574 const Standard_Boolean thePrepareOnSame)
576 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
579 OSD_Chronometer ch;// init perf for PerformSetOfKPart
582 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
583 // The fillet is returned,
584 ChFiDS_ListIteratorOfListOfStripe StrIt;
585 StrIt.Initialize(myVDataMap(Index));
586 if ( ! ChFi3d_SelectStripe (StrIt, Vtx, thePrepareOnSame)) return;
587 Handle(ChFiDS_Stripe) stripe = StrIt.Value();
588 const Handle(ChFiDS_Spine) spine = stripe->Spine();
589 ChFiDS_SequenceOfSurfData& SeqFil =
590 stripe->ChangeSetOfSurfData()->ChangeSequence();
591 // SurfData and its CommonPoints,
592 Standard_Integer sens = 0;
594 // Choose proper SurfData
595 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
596 Standard_Boolean isfirst = (sens == 1);
598 for (; num<SeqFil.Length() && (
599 (SeqFil.Value(num)->IndexOfS1()==0) ||
600 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
601 SeqFil.Remove(num); // The surplus is removed
606 (SeqFil.Value(num)->IndexOfS1()==0) ||
607 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
608 SeqFil.Remove(num);// The surplus is removed
613 Handle(ChFiDS_SurfData)& Fd = SeqFil.ChangeValue(num);
614 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
615 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
616 //To evaluate the new points.
619 // The cases of cap and intersection are processed separately.
620 // ----------------------------------------------------------
622 if (isfirst) stat = spine->FirstStatus();
623 else stat = spine->LastStatus();
624 Standard_Boolean onsame = (stat == ChFiDS_OnSame);
625 TopoDS_Face Fv,Fad,Fop;
626 TopoDS_Edge Arcpiv,Arcprol,Arcspine;
627 if (isfirst) Arcspine = spine->Edges(1);
628 else Arcspine = spine->Edges(spine->NbEdges());
630 TopAbs_Orientation OArcprolv = TopAbs_FORWARD, OArcprolop = TopAbs_FORWARD;
632 TopAbs_Orientation OArcprolv,OArcprolop;
634 Standard_Integer ICurve;
635 Handle(BRepAdaptor_HSurface) HBs = new BRepAdaptor_HSurface();
636 Handle(BRepAdaptor_HSurface) HBad = new BRepAdaptor_HSurface();
637 Handle(BRepAdaptor_HSurface) HBop = new BRepAdaptor_HSurface();
638 BRepAdaptor_Surface& Bs = HBs->ChangeSurface();
639 BRepAdaptor_Surface& Bad = HBad->ChangeSurface();
640 BRepAdaptor_Surface& Bop = HBop->ChangeSurface();
641 Handle(Geom_Curve) Cc;
642 Handle(Geom2d_Curve) Pc,Ps;
643 Standard_Real Ubid,Vbid;//,mu,Mu,mv,Mv;
645 Standard_Real Udeb = 0.,Ufin = 0.;
647 Standard_Real Udeb,Ufin;
649 // gp_Pnt2d UVf1,UVl1,UVf2,UVl2;
650 // Standard_Real Du,Dv,Step;
651 Standard_Boolean inters = Standard_True;
652 Standard_Integer IFadArc = 1, IFopArc = 2;
653 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
657 ChFi3d_InitChron(ch); // init perf condition if (onsame)
661 if (!CV1.IsOnArc() && !CV2.IsOnArc())
662 Standard_Failure::Raise("Corner OnSame : no point on arc");
663 else if (CV1.IsOnArc() && CV2.IsOnArc()) {
664 Standard_Boolean sur1 = 0, sur2 = 0;
665 for(ex.Init(CV1.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()) {
666 if (Vtx.IsSame(ex.Current())) {
671 for(ex.Init(CV2.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()) {
672 if (Vtx.IsSame(ex.Current())) {
679 E[0] = CV1.Arc(); E[1] = CV2.Arc(); E[2] = Arcspine;
680 if (ChFi3d_EdgeState(E,myEFMap) != ChFiDS_OnDiff) IFadArc = 2;
682 else if (sur2) IFadArc = 2;
684 else if (CV2.IsOnArc()) IFadArc = 2;
687 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
688 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
689 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
690 TopTools_ListIteratorOfListOfShape It;
691 // The face at end is returned without check of its unicity.
692 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
693 if (!Fad.IsSame(It.Value())) {
694 Fv = TopoDS::Face(It.Value());
699 // Does the face at bout contain the Vertex ?
700 Standard_Boolean isinface = Standard_False;
701 for (ex.Init(Fv,TopAbs_VERTEX); ex.More(); ex.Next()) {
702 if (ex.Current().IsSame(Vtx)) {
703 isinface = Standard_True;
707 if (!isinface && Fd->Vertex(isfirst,3-IFadArc).IsOnArc()) {
710 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
711 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
712 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
713 //TopTools_ListIteratorOfListOfShape It;
714 // The face at end is returned without check of its unicity.
715 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
716 if (!Fad.IsSame(It.Value())) {
717 Fv = TopoDS::Face(It.Value());
723 if (Fv.IsNull()) StdFail_NotDone::Raise
724 ("OneCorner : face at end not found");
726 Fv.Orientation(TopAbs_FORWARD);
727 Fad.Orientation(TopAbs_FORWARD);
728 Fop.Orientation(TopAbs_FORWARD);
730 // The edge that will be extended is returned.
731 for(It.Initialize(myVEMap(Vtx));It.More() && Arcprol.IsNull();It.Next()) {
732 if (!Arcpiv.IsSame(It.Value())) {
733 for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()) {
734 if (It.Value().IsSame(ex.Current())) {
735 Arcprol = TopoDS::Edge(It.Value());
736 OArcprolv = ex.Current().Orientation();
742 if (Arcprol.IsNull()) /*StdFail_NotDone::Raise
743 ("OneCorner : edge a prolonger non trouve");*/
745 PerformIntersectionAtEnd(Index);
748 for(ex.Init(Fop,TopAbs_EDGE); ex.More(); ex.Next()) {
749 if (Arcprol.IsSame(ex.Current())) {
750 OArcprolop = ex.Current().Orientation();
756 Standard_Integer prol=0;
758 Handle(Geom_Surface ) Sface;
759 Sface=BRep_Tool::Surface(Fv);
760 ChFi3d_ExtendSurface(Sface,prol);
761 tol=BRep_Tool::Tolerance(Fv);
762 BRE.MakeFace(FFv,Sface,tol);
764 Bs.Initialize(FFv,Standard_False);
765 DStr.SetNewSurface(Fv,Sface);
767 else Bs.Initialize(Fv,Standard_False);
771 //in case of OnSame it is necessary to modify the CommonPoint
772 //in the empty and its parameter in the FaceInterference.
773 //They are both returned in non const references. Attention the modifications are done behind
774 //de CV1,CV2,Fi1,Fi2.
775 ChFiDS_CommonPoint& CPopArc = Fd->ChangeVertex(isfirst,IFopArc);
776 ChFiDS_FaceInterference& FiopArc = Fd->ChangeInterference(IFopArc);
777 ChFiDS_CommonPoint& CPadArc = Fd->ChangeVertex(isfirst,IFadArc);
778 ChFiDS_FaceInterference& FiadArc = Fd->ChangeInterference(IFadArc);
779 //the parameter of the vertex in the air is initialiced with the value of
780 //its opposite (point on arc).
781 Standard_Real wop = Fd->ChangeInterference(IFadArc).Parameter(isfirst);
782 Handle(Geom_Curve) c3df;
783 Handle(GeomAdaptor_HSurface)
784 HGs = new GeomAdaptor_HSurface(DStr.Surface(Fd->Surf()).Surface());
789 ChFiDS_CommonPoint saveCPopArc = CPopArc;
790 c3df = DStr.Curve(FiopArc.LineIndex()).Curve();
792 inters = IntersUpdateOnSame (HGs,HBs,c3df,Fop,Fv,Arcprol,Vtx,isfirst,10*tolesp, // in
793 FiopArc,CPopArc,p2dbout,wop); // out
795 Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
796 pced->ChangeCurve2d().Initialize(CPadArc.Arc(),Fv);
797 // in the case of degenerated Fi, parameter difference can be even negative (eap, occ293)
798 if ((FiadArc.LastParameter() - FiadArc.FirstParameter()) > 10*tolesp)
799 Update(HBs,pced,HGs,FiadArc,CPadArc,isfirst);
801 if (thePrepareOnSame) {
802 //saveCPopArc.SetParameter(wop);
803 saveCPopArc.SetPoint(CPopArc.Point());
804 CPopArc = saveCPopArc;
809 inters = FindFace(Vtx,CV1,CV2,Fv,Fop);
811 PerformIntersectionAtEnd(Index);
815 Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
816 pced->ChangeCurve2d().Initialize(CV1.Arc(),Fv);
817 Update(HBs,pced,HGs,Fd->ChangeInterferenceOnS1(),CV1,isfirst);
818 pced->ChangeCurve2d().Initialize(CV2.Arc(),Fv);
819 Update(HBs,pced,HGs,Fd->ChangeInterferenceOnS2(),CV2,isfirst);
824 ChFi3d_ResultChron(ch,t_same); // result perf condition if (same)
825 ChFi3d_InitChron(ch); // init perf condition if (inters)
828 TopoDS_Edge edgecouture;
829 Standard_Boolean couture,intcouture=Standard_False;;
830 Standard_Real tolreached;
832 Standard_Real par1 =0.,par2 =0.;
833 Standard_Integer indpt = 0,Icurv1 = 0,Icurv2 = 0;
835 Standard_Real par1,par2;
836 Standard_Integer indpt,Icurv1,Icurv2;
838 Handle(Geom_TrimmedCurve) curv1,curv2;
839 Handle(Geom2d_Curve) c2d1,c2d2;
841 Standard_Integer Isurf=Fd->Surf();
844 HGs = ChFi3d_BoundSurf(DStr,Fd,1,2);
845 const ChFiDS_FaceInterference& Fi1 = Fd->InterferenceOnS1();
846 const ChFiDS_FaceInterference& Fi2 = Fd->InterferenceOnS2();
847 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
848 gp_Pnt2d pfil1,pfac1,pfil2,pfac2;
849 Handle(Geom2d_Curve) Hc1,Hc2;
850 if (onsame && IFopArc == 1) pfac1 = p2dbout;
852 Hc1 = BRep_Tool::CurveOnSurface(CV1.Arc(),Fv,Ubid,Ubid);
853 pfac1 = Hc1->Value(CV1.ParameterOnArc());
855 if (onsame && IFopArc == 2) pfac2 = p2dbout;
857 Hc2 = BRep_Tool::CurveOnSurface(CV2.Arc(),Fv,Ubid,Ubid);
858 pfac2 = Hc2->Value(CV2.ParameterOnArc());
860 if (Fi1.LineIndex() != 0) {
861 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));
864 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
866 if (Fi2.LineIndex() != 0) {
867 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
870 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
872 if (onsame) ChFi3d_Recale(Bs,pfac1,pfac2,(IFadArc == 1));
874 Pardeb(1)= pfil1.X(); Pardeb(2) = pfil1.Y();
875 Pardeb(3)= pfac1.X(); Pardeb(4) = pfac1.Y();
876 Parfin(1)= pfil2.X(); Parfin(2) = pfil2.Y();
877 Parfin(3)= pfac2.X(); Parfin(4) = pfac2.Y();
879 Standard_Real uu1,uu2,vv1,vv2;
880 ChFi3d_Boite(pfac1,pfac2,uu1,uu2,vv1,vv2);
881 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
883 if (!ChFi3d_ComputeCurves(HGs,HBs,Pardeb,Parfin,Cc,
885 Pc,tolesp,tol2d,tolreached))
886 Standard_Failure::Raise("OneCorner : echec calcul intersection");
888 Udeb = Cc->FirstParameter();
889 Ufin = Cc->LastParameter();
891 // determine if the curve has an intersection with edge of sewing
893 ChFi3d_Couture(Fv,couture,edgecouture);
895 if (couture && !BRep_Tool::Degenerated(edgecouture)) {
897 //Standard_Real Ubid,Vbid;
898 Handle (Geom_Curve) C=BRep_Tool::Curve(edgecouture,Ubid,Vbid);
899 Handle(Geom_TrimmedCurve) Ctrim=new Geom_TrimmedCurve (C,Ubid,Vbid);
900 GeomAdaptor_Curve cur1(Ctrim->BasisCurve());
901 GeomAdaptor_Curve cur2(Cc);
902 Extrema_ExtCC extCC (cur1,cur2);
903 if (extCC.IsDone()&&extCC.NbExt()!=0)
905 Standard_Integer imin=0;
906 Standard_Real distmin2 = RealLast();
907 for (Standard_Integer i = 1; i <= extCC.NbExt(); i++)
908 if (extCC.SquareDistance(i) < distmin2)
910 distmin2 = extCC.SquareDistance(i);
913 if (distmin2 <= Precision::SquareConfusion())
915 Extrema_POnCurv ponc1,ponc2;
916 extCC.Points( imin, ponc1, ponc2 );
917 par1 = ponc1.Parameter();
918 par2 = ponc2.Parameter();
919 Standard_Real Tol = 1.e-4;
920 if (Abs(par2-Udeb) > Tol && Abs(Ufin-par2) > Tol)
922 gp_Pnt P1 = ponc1.Value();
923 TopOpeBRepDS_Point tpoint( P1, Tol );
924 indpt = DStr.AddPoint(tpoint);
925 intcouture = Standard_True;
926 curv1 = new Geom_TrimmedCurve(Cc,Udeb,par2);
927 curv2 = new Geom_TrimmedCurve(Cc,par2,Ufin);
928 TopOpeBRepDS_Curve tcurv1(curv1,tolreached);
929 TopOpeBRepDS_Curve tcurv2(curv2,tolreached);
930 Icurv1=DStr.AddCurve(tcurv1);
931 Icurv2=DStr.AddCurve(tcurv2);
938 Standard_NotImplemented::Raise("OneCorner : bouchon non ecrit");
940 Standard_Integer IShape = DStr.AddShape(Fv);
942 TopAbs_Orientation Et = TopAbs_FORWARD;
944 TopAbs_Orientation Et;
948 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
949 TopAbs_EDGE);Exp.More();Exp.Next()) {
950 if (Exp.Current().IsSame(CV1.Arc())) {
951 Et = TopAbs::Reverse(TopAbs::Compose
952 (Exp.Current().Orientation(),
953 CV1.TransitionOnArc()));
960 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
961 TopAbs_EDGE);Exp.More();Exp.Next()) {
962 if (Exp.Current().IsSame(CV2.Arc())) {
963 Et = TopAbs::Compose(Exp.Current().Orientation(),
964 CV2.TransitionOnArc());
975 ChFi3d_ResultChron(ch ,t_inter); //result perf condition if (inter)
976 ChFi3d_InitChron(ch); // init perf condition if (onsame && inters)
979 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV1,DStr),isfirst,1);
980 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV2,DStr),isfirst,2);
983 // there is no intersection with the sewing edge
984 // the curve Cc is stored in the stripe
985 // the storage in the DS is not done by FILDS.
987 TopOpeBRepDS_Curve Tc(Cc,tolreached);
988 ICurve = DStr.AddCurve(Tc);
989 Handle(TopOpeBRepDS_SurfaceCurveInterference)
990 Interfc = ChFi3d_FilCurveInDS(ICurve,IShape,Pc,Et);
992 // 31/01/02 akm vvv : (OCC119) Prevent the builder from creating
993 // intersecting fillets - they are bad.
994 Geom2dInt_GInter anIntersector;
995 Geom2dAdaptor_Curve aCorkPCurve (Pc, Udeb, Ufin);
997 // Take all the interferences with faces from all the stripes
998 // and look if their pcurves intersect our cork pcurve.
999 // Unfortunately, by this moment they do not exist in DStr.
1000 ChFiDS_ListIteratorOfListOfStripe aStrIt(myListStripe);
1001 for (; aStrIt.More(); aStrIt.Next())
1003 Handle(ChFiDS_Stripe) aCheckStripe = aStrIt.Value();
1004 Handle(ChFiDS_HData) aSeqData = aCheckStripe->SetOfSurfData();
1005 // Loop on parts of the stripe
1006 Standard_Integer iPart;
1007 for (iPart=1; iPart<=aSeqData->Length(); iPart++)
1009 Handle(ChFiDS_SurfData) aData = aSeqData->Value(iPart);
1010 Geom2dAdaptor_Curve anOtherPCurve;
1011 if (IShape == aData->IndexOfS1())
1013 const Handle(Geom2d_Curve)& aPCurve = aData->InterferenceOnS1().PCurveOnFace();
1014 if(aPCurve.IsNull())
1017 anOtherPCurve.Load (aPCurve,
1018 aData->InterferenceOnS1().FirstParameter(),
1019 aData->InterferenceOnS1().LastParameter());
1021 else if (IShape == aData->IndexOfS2())
1023 const Handle(Geom2d_Curve)& aPCurve = aData->InterferenceOnS2().PCurveOnFace();
1024 if(aPCurve.IsNull())
1027 anOtherPCurve.Load (aPCurve,
1028 aData->InterferenceOnS2().FirstParameter(),
1029 aData->InterferenceOnS2().LastParameter());
1033 // Normal case - no common surface
1036 if (IsEqual(anOtherPCurve.LastParameter(),anOtherPCurve.FirstParameter()))
1039 anIntersector.Perform (aCorkPCurve, anOtherPCurve,
1040 tol2d, Precision::PConfusion());
1041 if (anIntersector.NbSegments() > 0 ||
1042 anIntersector.NbPoints() > 0)
1043 StdFail_NotDone::Raise ("OneCorner : fillets have too big radiuses");
1046 TopOpeBRepDS_ListIteratorOfListOfInterference
1047 anIter(DStr.ChangeShapeInterferences(IShape));
1048 for (; anIter.More(); anIter.Next())
1050 Handle(TopOpeBRepDS_SurfaceCurveInterference) anOtherIntrf =
1051 Handle(TopOpeBRepDS_SurfaceCurveInterference)::DownCast(anIter.Value());
1052 // We need only interferences between cork face and curves
1053 // of intersection with another fillet surfaces
1054 if (anOtherIntrf.IsNull())
1056 // Look if there is an intersection between pcurves
1057 Handle(Geom_TrimmedCurve) anOtherCur =
1058 Handle(Geom_TrimmedCurve)::DownCast(DStr.Curve (anOtherIntrf->Geometry()).Curve());
1059 if (anOtherCur.IsNull())
1061 Geom2dAdaptor_Curve anOtherPCurve (anOtherIntrf->PCurve(),
1062 anOtherCur->FirstParameter(),
1063 anOtherCur->LastParameter());
1064 anIntersector.Perform (aCorkPCurve, anOtherPCurve,
1065 tol2d, Precision::PConfusion());
1066 if (anIntersector.NbSegments() > 0 ||
1067 anIntersector.NbPoints() > 0)
1068 StdFail_NotDone::Raise ("OneCorner : fillets have too big radiuses");
1071 DStr.ChangeShapeInterferences(IShape).Append(Interfc);
1072 //// modified by jgv, 26.03.02 for OCC32 ////
1073 ChFiDS_CommonPoint CV [2];
1076 for (Standard_Integer i = 0; i < 2; i++)
1078 if (CV[i].IsOnArc() && ChFi3d_IsPseudoSeam( CV[i].Arc(), Fv ))
1080 gp_Pnt2d pfac1, PcF, PcL;
1081 gp_Vec2d DerPc, DerHc;
1082 Standard_Real first, last, prm1, prm2;
1083 Standard_Boolean onfirst, FirstToPar;
1084 Handle(Geom2d_Curve) Hc = BRep_Tool::CurveOnSurface( CV[i].Arc(), Fv, first, last );
1085 pfac1 = Hc->Value( CV[i].ParameterOnArc() );
1086 PcF = Pc->Value( Udeb );
1087 PcL = Pc->Value( Ufin );
1088 onfirst = (pfac1.Distance(PcF) < pfac1.Distance(PcL))? Standard_True : Standard_False;
1090 Pc->D1( Udeb, PcF, DerPc );
1093 Pc->D1( Ufin, PcL, DerPc );
1096 Hc->D1( CV[i].ParameterOnArc(), pfac1, DerHc );
1097 if (DerHc.Dot(DerPc) > 0.)
1099 prm1 = CV[i].ParameterOnArc();
1101 FirstToPar = Standard_False;
1106 prm2 = CV[i].ParameterOnArc();
1107 FirstToPar = Standard_True;
1109 Handle(Geom_Curve) Ct = BRep_Tool::Curve( CV[i].Arc(), first, last );
1110 Ct = new Geom_TrimmedCurve( Ct, prm1, prm2 );
1111 Standard_Real toled = BRep_Tool::Tolerance( CV[i].Arc() );
1112 TopOpeBRepDS_Curve tcurv( Ct, toled );
1113 Handle (TopOpeBRepDS_CurvePointInterference) Interfp1, Interfp2;
1114 Standard_Integer indcurv;
1115 indcurv = DStr.AddCurve( tcurv );
1116 Standard_Integer indpoint = (isfirst)? stripe->IndexFirstPointOnS1() : stripe->IndexLastPointOnS1();
1117 Standard_Integer indvertex = DStr.AddShape(Vtx);
1120 Interfp1 = ChFi3d_FilPointInDS( TopAbs_FORWARD, indcurv, indvertex, prm1, Standard_True );
1121 Interfp2 = ChFi3d_FilPointInDS( TopAbs_REVERSED, indcurv, indpoint, prm2, Standard_False );
1125 Interfp1 = ChFi3d_FilPointInDS( TopAbs_FORWARD, indcurv, indpoint, prm1, Standard_False );
1126 Interfp2 = ChFi3d_FilPointInDS( TopAbs_REVERSED, indcurv, indvertex, prm2, Standard_True );
1128 DStr.ChangeCurveInterferences(indcurv).Append(Interfp1);
1129 DStr.ChangeCurveInterferences(indcurv).Append(Interfp2);
1130 Standard_Integer indface = DStr.AddShape( Fv );
1131 Interfc = ChFi3d_FilCurveInDS( indcurv, indface, Hc, CV[i].Arc().Orientation() );
1132 DStr.ChangeShapeInterferences(indface).Append( Interfc );
1133 TopoDS_Edge aLocalEdge = CV[i].Arc();
1134 aLocalEdge.Reverse();
1135 Handle(Geom2d_Curve) HcR = BRep_Tool::CurveOnSurface( aLocalEdge, Fv, first, last );
1136 Interfc = ChFi3d_FilCurveInDS( indcurv, indface, HcR, aLocalEdge.Orientation() );
1137 DStr.ChangeShapeInterferences(indface).Append( Interfc );
1138 //modify degenerated edge
1139 Standard_Boolean DegenExist = Standard_False;
1141 TopExp_Explorer Explo( Fv, TopAbs_EDGE );
1142 for (; Explo.More(); Explo.Next())
1144 const TopoDS_Edge& Ecur = TopoDS::Edge( Explo.Current() );
1145 if (BRep_Tool::Degenerated( Ecur ))
1147 TopoDS_Vertex Vf, Vl;
1148 TopExp::Vertices( Ecur, Vf, Vl );
1149 if (Vf.IsSame(Vtx) || Vl.IsSame(Vtx))
1151 DegenExist = Standard_True;
1159 Standard_Real fd, ld;
1160 Handle(Geom2d_Curve) Cd = BRep_Tool::CurveOnSurface( Edeg, Fv, fd, ld );
1161 Handle(Geom2d_TrimmedCurve) tCd = Handle(Geom2d_TrimmedCurve)::DownCast(Cd);
1163 Cd = tCd->BasisCurve();
1164 gp_Pnt2d P2d = (FirstToPar)? Hc->Value(first) : Hc->Value(last);
1165 Geom2dAPI_ProjectPointOnCurve Projector( P2d, Cd );
1166 Standard_Real par = Projector.LowerDistanceParameter();
1167 Standard_Integer Ideg = DStr.AddShape(Edeg);
1168 TopAbs_Orientation ori = (par < fd)? TopAbs_FORWARD : TopAbs_REVERSED; //if par<fd => par>ld
1169 Interfp1 = ChFi3d_FilPointInDS( ori, Ideg, indvertex, par, Standard_True );
1170 DStr.ChangeShapeInterferences(Ideg).Append(Interfp1);
1174 /////////////////////////////////////////////
1175 stripe->ChangePCurve(isfirst)=Ps;
1176 stripe->SetCurve(ICurve,isfirst);
1177 stripe->SetParameters(isfirst,Udeb,Ufin);
1180 // curves curv1 are curv2 stored in the DS
1181 // these curves will not be reconstructed by FILDS as
1182 // one places stripe->InDS(isfirst);
1184 // interferences of curv1 and curv2 on Fv
1185 ComputeCurve2d(curv1,Fv,c2d1);
1186 Handle(TopOpeBRepDS_SurfaceCurveInterference) InterFv;
1187 InterFv = ChFi3d_FilCurveInDS(Icurv1,IShape,c2d1,Et);
1188 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1189 ComputeCurve2d(curv2,Fv,c2d2);
1190 InterFv = ChFi3d_FilCurveInDS(Icurv2,IShape,c2d2,Et);
1191 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1192 // interferences of curv1 and curv2 on Isurf
1193 if (Fd->Orientation()== Fv.Orientation()) Et=TopAbs::Reverse(Et);
1194 c2d1=new Geom2d_TrimmedCurve(Ps,Udeb,par2);
1195 InterFv = ChFi3d_FilCurveInDS(Icurv1,Isurf,c2d1,Et);
1196 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
1197 c2d2=new Geom2d_TrimmedCurve(Ps,par2,Ufin);
1198 InterFv = ChFi3d_FilCurveInDS(Icurv2,Isurf,c2d2,Et);
1199 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
1201 // limitation of the sewing edge
1202 Standard_Integer Iarc=DStr.AddShape(edgecouture);
1203 Handle(TopOpeBRepDS_CurvePointInterference) Interfedge;
1204 TopAbs_Orientation ori;
1205 TopoDS_Vertex Vdeb,Vfin;
1206 Vdeb=TopExp::FirstVertex(edgecouture);
1207 Vfin=TopExp::LastVertex(edgecouture);
1208 Standard_Real pard,parf;
1209 pard=BRep_Tool::Parameter(Vdeb,edgecouture);
1210 parf=BRep_Tool::Parameter(Vfin,edgecouture);
1211 if (Abs(par1-pard)<Abs(parf-par1)) ori=TopAbs_FORWARD;
1212 else ori=TopAbs_REVERSED;
1213 Interfedge = ChFi3d_FilPointInDS(ori,Iarc,indpt,par1);
1214 DStr.ChangeShapeInterferences(Iarc).Append(Interfedge);
1216 // creation of CurveInterferences from Icurv1 and Icurv2
1217 stripe->InDS(isfirst);
1218 Standard_Integer ind1= stripe->IndexPoint(isfirst,1);
1219 Standard_Integer ind2= stripe->IndexPoint(isfirst,2);
1220 Handle(TopOpeBRepDS_CurvePointInterference)
1221 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv1,ind1,Udeb);
1222 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1223 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv1,indpt,par2);
1224 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1225 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv2,indpt,par2);
1226 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1227 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv2,ind2,Ufin);
1228 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1232 ChFi3d_EnlargeBox(HBs,Pc,Udeb,Ufin,box1,box2);
1234 if (onsame && inters) {
1236 // A small missing end of curve is added for the extension
1237 // of the face at end and the limitation of the opposing face.
1239 // VARIANT 2 : extend Arcprol, not create new small edge
1240 // To do: modify for intcouture
1241 const Standard_Boolean variant1 = Standard_True;
1243 // First of all the ponts are cut with the edge of the spine.
1244 Standard_Integer IArcspine = DStr.AddShape(Arcspine);
1245 Standard_Integer IVtx = DStr.AddShape(Vtx);
1247 TopAbs_Orientation OVtx = TopAbs_FORWARD;
1249 TopAbs_Orientation OVtx;
1251 for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
1252 ex.More(); ex.Next()) {
1253 if (Vtx.IsSame(ex.Current())) {
1254 OVtx = ex.Current().Orientation();
1258 OVtx = TopAbs::Reverse(OVtx);
1259 Standard_Real parVtx = BRep_Tool::Parameter(Vtx,Arcspine);
1260 Handle(TopOpeBRepDS_CurvePointInterference)
1261 interfv = ChFi3d_FilVertexInDS(OVtx,IArcspine,IVtx,parVtx);
1262 DStr.ChangeShapeInterferences(IArcspine).Append(interfv);
1264 // Now the missing curves are constructed.
1266 for(ex.Init(Arcprol.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
1267 ex.More(); ex.Next()) {
1268 if (Vtx.IsSame(ex.Current()))
1269 OVtx = ex.Current().Orientation();
1271 V2 = TopoDS::Vertex(ex.Current());
1274 Handle(Geom2d_Curve) Hc;
1276 parVtx = BRep_Tool::Parameter(Vtx,Arcprol);
1278 parVtx = BRep_Tool::Parameter(V2,Arcprol);
1279 const ChFiDS_FaceInterference& Fiop = Fd->Interference(IFopArc);
1280 gp_Pnt2d pop1, pop2, pv1, pv2;
1281 Hc = BRep_Tool::CurveOnSurface(Arcprol,Fop,Ubid,Ubid);
1282 pop1 = Hc->Value(parVtx);
1283 pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst));
1284 Hc = BRep_Tool::CurveOnSurface(Arcprol,Fv,Ubid,Ubid);
1285 pv1 = Hc->Value(parVtx);
1287 ChFi3d_Recale(Bs,pv1,pv2,1);
1288 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
1289 Pardeb(1) = pop1.X(); Pardeb(2) = pop1.Y();
1290 Pardeb(3) = pv1.X(); Pardeb(4) = pv1.Y();
1291 Parfin(1) = pop2.X(); Parfin(2) = pop2.Y();
1292 Parfin(3) = pv2.X(); Parfin(4) = pv2.Y();
1293 Standard_Real uu1,uu2,vv1,vv2;
1294 ChFi3d_Boite(pv1,pv2,uu1,uu2,vv1,vv2);
1295 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
1296 ChFi3d_Boite(pop1,pop2,uu1,uu2,vv1,vv2);
1297 ChFi3d_BoundFac(Bop,uu1,uu2,vv1,vv2);
1299 Handle(Geom_Curve) zob3d;
1300 Handle(Geom2d_Curve) zob2dop, zob2dv;
1301 //Standard_Real tolreached;
1302 if (!ChFi3d_ComputeCurves(HBop,HBs,Pardeb,Parfin,zob3d,zob2dop,
1303 zob2dv,tolesp,tol2d,tolreached))
1304 Standard_Failure::Raise("OneCorner : echec calcul intersection");
1306 Udeb = zob3d->FirstParameter();
1307 Ufin = zob3d->LastParameter();
1308 TopOpeBRepDS_Curve Zob(zob3d,tolreached);
1309 Standard_Integer IZob = DStr.AddCurve(Zob);
1311 // it is determined if Fop has an edge of sewing
1312 // it is determined if the curve has an intersection with the edge of sewing
1314 //TopoDS_Edge edgecouture;
1315 //Standard_Boolean couture;
1316 ChFi3d_Couture(Fop,couture,edgecouture);
1318 if (couture && !BRep_Tool::Degenerated(edgecouture)) {
1319 BRepLib_MakeEdge Bedge (zob3d);
1320 TopoDS_Edge edg =Bedge. Edge();
1321 BRepExtrema_ExtCC extCC (edgecouture,edg);
1322 if (extCC.IsDone()&&extCC.NbExt()!=0) {
1323 for (Standard_Integer i=1; i<=extCC.NbExt()&&!intcouture;i++) {
1324 if (extCC.SquareDistance(i)<=1.e-8) {
1325 par1=extCC.ParameterOnE1(i);
1326 par2=extCC.ParameterOnE2(i);
1327 gp_Pnt P1=extCC.PointOnE1(i);
1328 TopOpeBRepDS_Point tpoint(P1,1.e-4);
1329 indpt=DStr.AddPoint(tpoint);
1330 intcouture=Standard_True;
1331 curv1 = new Geom_TrimmedCurve(zob3d,Udeb,par2);
1332 curv2 = new Geom_TrimmedCurve(zob3d,par2,Ufin);
1333 TopOpeBRepDS_Curve tcurv1(curv1,tolreached);
1334 TopOpeBRepDS_Curve tcurv2(curv2,tolreached);
1335 Icurv1=DStr.AddCurve(tcurv1);
1336 Icurv2=DStr.AddCurve(tcurv2);
1343 // interference of curv1 and curv2 on Ishape
1344 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv));
1345 ComputeCurve2d(curv1,Fop,c2d1);
1346 Handle(TopOpeBRepDS_SurfaceCurveInterference)
1347 InterFv = ChFi3d_FilCurveInDS(Icurv1,IShape,/*zob2dv*/c2d1,Et);
1348 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1349 ComputeCurve2d(curv2,Fop,c2d2);
1350 InterFv = ChFi3d_FilCurveInDS(Icurv2,IShape,/*zob2dv*/c2d2,Et);
1351 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1353 // limitation of the sewing edge
1354 Standard_Integer Iarc=DStr.AddShape(edgecouture);
1355 Handle(TopOpeBRepDS_CurvePointInterference) Interfedge;
1356 TopAbs_Orientation ori;
1357 TopoDS_Vertex Vdeb,Vfin;
1358 Vdeb=TopExp::FirstVertex(edgecouture);
1359 Vfin=TopExp::LastVertex(edgecouture);
1360 Standard_Real pard,parf;
1361 pard=BRep_Tool::Parameter(Vdeb,edgecouture);
1362 parf=BRep_Tool::Parameter(Vfin,edgecouture);
1363 if (Abs(par1-pard)<Abs(parf-par1)) ori=TopAbs_REVERSED;
1364 else ori=TopAbs_FORWARD;
1365 Interfedge = ChFi3d_FilPointInDS(ori,Iarc,indpt,par1);
1366 DStr.ChangeShapeInterferences(Iarc).Append(Interfedge);
1368 // interference of curv1 and curv2 on Iop
1369 Standard_Integer Iop = DStr.AddShape(Fop);
1370 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolop));
1371 Handle(TopOpeBRepDS_SurfaceCurveInterference) Interfop;
1372 ComputeCurve2d(curv1,Fop,c2d1);
1373 Interfop = ChFi3d_FilCurveInDS(Icurv1,Iop,c2d1,Et);
1374 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
1375 ComputeCurve2d(curv2,Fop,c2d2);
1376 Interfop = ChFi3d_FilCurveInDS(Icurv2,Iop,c2d2,Et);
1377 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
1378 Handle(TopOpeBRepDS_CurvePointInterference)
1379 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,Icurv1,IVtx,Udeb);
1380 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1381 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv1,indpt,par2);
1382 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1383 Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc);
1384 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv2,indpt,par2);
1385 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1386 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv2,icc,Ufin);
1387 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1390 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv));
1391 Handle(TopOpeBRepDS_SurfaceCurveInterference)
1392 InterFv = ChFi3d_FilCurveInDS(IZob,IShape,zob2dv,Et);
1393 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1394 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolop));
1395 Standard_Integer Iop = DStr.AddShape(Fop);
1396 Handle(TopOpeBRepDS_SurfaceCurveInterference)
1397 Interfop = ChFi3d_FilCurveInDS(IZob,Iop,zob2dop,Et);
1398 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
1399 Handle(TopOpeBRepDS_CurvePointInterference) interfprol;
1401 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IVtx,Udeb);
1403 Standard_Integer IV2 = DStr.AddShape(V2); // VARIANT 2
1404 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IV2,Udeb);
1406 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
1407 Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc);
1408 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,IZob,icc,Ufin);
1409 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
1411 if (IFopArc == 1) box1.Add( zob3d->Value(Ufin) );
1412 else box2.Add( zob3d->Value(Ufin) );
1415 // cut off existing Arcprol
1416 Standard_Integer iArcprol = DStr.AddShape(Arcprol);
1417 interfprol = ChFi3d_FilPointInDS(OVtx,iArcprol,icc,Udeb);
1418 DStr.ChangeShapeInterferences(Arcprol).Append(interfprol);
1422 ChFi3d_EnlargeBox(DStr,stripe,Fd,box1,box2,isfirst);
1423 if (CV1.IsOnArc()) {
1424 ChFi3d_EnlargeBox(CV1.Arc(),myEFMap(CV1.Arc()),CV1.ParameterOnArc(),box1);
1426 if (CV2.IsOnArc()) {
1427 ChFi3d_EnlargeBox(CV2.Arc(),myEFMap(CV2.Arc()),CV2.ParameterOnArc(),box2);
1429 if (!CV1.IsVertex())
1430 ChFi3d_SetPointTolerance(DStr,box1,stripe->IndexPoint(isfirst,1));
1431 if (!CV2.IsVertex())
1432 ChFi3d_SetPointTolerance(DStr,box2,stripe->IndexPoint(isfirst,2));
1435 ChFi3d_ResultChron(ch, t_sameinter);//result perf condition if (same &&inter)
1439 //=======================================================================
1440 //function : cherche_face
1441 //purpose : find face F belonging to the map, different from faces
1442 // F1 F2 F3 and containing edge E
1443 //=======================================================================
1445 static void cherche_face (const TopTools_ListOfShape & map,
1446 const TopoDS_Edge & E,
1447 const TopoDS_Face & F1,
1448 const TopoDS_Face & F2,
1449 const TopoDS_Face & F3,
1452 Standard_Boolean trouve=Standard_False;
1453 TopTools_ListIteratorOfListOfShape It;
1454 Standard_Integer ie;
1455 for (It.Initialize(map);It.More()&&!trouve;It.Next())
1456 { Fcur=TopoDS::Face (It.Value());
1457 if (!Fcur.IsSame(F1) && !Fcur.IsSame(F2)&& !Fcur.IsSame(F3) )
1458 { TopTools_IndexedMapOfShape MapE;
1459 TopExp::MapShapes( Fcur,TopAbs_EDGE,MapE);
1460 for ( ie=1; ie<= MapE.Extent()&&!trouve; ie++)
1462 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE(ie));
1463 if (E.IsSame(TopoDS::Edge(aLocalShape)))
1464 // if (E.IsSame(TopoDS::Edge(TopoDS_Shape (MapE(ie)))))
1465 { F= Fcur; trouve=Standard_True;}
1471 //=======================================================================
1472 //function : cherche_edge1
1473 //purpose : find common edge between faces F1 and F2
1474 //=======================================================================
1476 static void cherche_edge1 (const TopoDS_Face & F1,
1477 const TopoDS_Face & F2,
1479 { Standard_Integer i,j;
1480 TopoDS_Edge Ecur1,Ecur2;
1481 Standard_Boolean trouve=Standard_False;
1482 TopTools_IndexedMapOfShape MapE1,MapE2;
1483 TopExp::MapShapes( F1,TopAbs_EDGE,MapE1);
1484 TopExp::MapShapes( F2,TopAbs_EDGE,MapE2);
1485 for ( i=1; i<= MapE1.Extent()&&!trouve; i++)
1487 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE1(i));
1488 Ecur1=TopoDS::Edge(aLocalShape);
1489 // Ecur1=TopoDS::Edge(TopoDS_Shape (MapE1(i)));
1490 for ( j=1; j<= MapE2.Extent()&&!trouve; j++)
1492 aLocalShape = TopoDS_Shape (MapE2(j));
1493 Ecur2=TopoDS::Edge(aLocalShape);
1494 // Ecur2=TopoDS::Edge(TopoDS_Shape (MapE2(j)));
1495 if (Ecur2.IsSame(Ecur1))
1496 {Edge=Ecur1;trouve=Standard_True;}
1501 //=======================================================================
1502 //function : containV
1503 //purpose : return true if vertex V belongs to F1
1504 //=======================================================================
1506 static Standard_Boolean containV(const TopoDS_Face & F1,
1507 const TopoDS_Vertex & V)
1508 { Standard_Integer i;
1510 Standard_Boolean trouve=Standard_False;
1511 Standard_Boolean contain=Standard_False;
1512 TopTools_IndexedMapOfShape MapV;
1513 TopExp::MapShapes( F1,TopAbs_VERTEX,MapV);
1514 for ( i=1; i<= MapV.Extent()&&!trouve; i++)
1516 TopoDS_Shape aLocalShape = TopoDS_Shape (MapV(i));
1517 Vcur=TopoDS::Vertex(aLocalShape);
1518 // Vcur=TopoDS::Vertex(TopoDS_Shape (MapV(i)));
1519 if (Vcur.IsSame(V) )
1520 {contain=Standard_True; trouve=Standard_True;}
1525 //=======================================================================
1526 //function : containE
1527 //purpose : return true if edge E belongs to F1
1528 //=======================================================================
1530 static Standard_Boolean containE(const TopoDS_Face & F1,
1531 const TopoDS_Edge & E)
1532 { Standard_Integer i;
1534 Standard_Boolean trouve=Standard_False;
1535 Standard_Boolean contain=Standard_False;
1536 TopTools_IndexedMapOfShape MapE;
1537 TopExp::MapShapes( F1,TopAbs_EDGE,MapE);
1538 for ( i=1; i<= MapE.Extent()&&!trouve; i++)
1540 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE(i));
1541 Ecur=TopoDS::Edge(aLocalShape);
1542 // Ecur=TopoDS::Edge(TopoDS_Shape (MapE(i)));
1543 if (Ecur.IsSame(E) )
1544 {contain=Standard_True; trouve=Standard_True;}
1550 //=======================================================================
1551 //function : IsShrink
1552 //purpose : check if U (if <isU>==True) or V of points of <PC> is within
1553 // <tol> from <Param>, check points between <Pf> and <Pl>
1554 //=======================================================================
1556 static Standard_Boolean IsShrink(const Geom2dAdaptor_Curve PC,
1557 const Standard_Real Pf,
1558 const Standard_Real Pl,
1559 const Standard_Real Param,
1560 const Standard_Boolean isU,
1561 const Standard_Real tol)
1563 switch (PC.GetType()) {
1564 case GeomAbs_Line: {
1565 gp_Pnt2d P1 = PC.Value(Pf);
1566 gp_Pnt2d P2 = PC.Value(Pl);
1567 if (Abs(P1.Coord(isU ? 1 : 2) - Param) <= tol &&
1568 Abs(P2.Coord(isU ? 1 : 2) - Param) <= tol )
1569 return Standard_True;
1571 return Standard_False;
1573 case GeomAbs_BezierCurve:
1574 case GeomAbs_BSplineCurve: {
1575 math_FunctionSample aSample (Pf,Pl,10);
1577 for (i=1; i<=aSample.NbPoints(); i++) {
1578 gp_Pnt2d P = PC.Value(aSample.GetParameter(i));
1579 if (Abs(P.Coord(isU ? 1 : 2) - Param) > tol )
1580 return Standard_False;
1582 return Standard_True;
1586 return Standard_False;
1588 //=======================================================================
1589 //function : PerformIntersectionAtEnd
1591 //=======================================================================
1593 void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
1596 // intersection at end of fillet with at least two faces
1597 // process the following cases:
1598 // - top has n (n>3) adjacent edges
1599 // - top has 3 edges and fillet on one of edges touches
1600 // more than one face
1603 OSD_Chronometer ch;// init perf
1606 TopOpeBRepDS_DataStructure& DStr= myDS->ChangeDS();
1607 const Standard_Integer nn=15;
1608 ChFiDS_ListIteratorOfListOfStripe It;
1609 It.Initialize(myVDataMap(Index));
1610 Handle(ChFiDS_Stripe) stripe = It.Value();
1611 const Handle(ChFiDS_Spine) spine = stripe->Spine();
1612 ChFiDS_SequenceOfSurfData& SeqFil =
1613 stripe->ChangeSetOfSurfData()->ChangeSequence();
1614 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
1615 Standard_Integer sens = 0,num,num1;
1616 Standard_Boolean couture=Standard_False,isfirst;
1617 //Standard_Integer sense;
1618 TopoDS_Edge edgelibre1,edgelibre2,EdgeSpine;
1619 Standard_Boolean bordlibre;
1620 // determine the number of faces and edges
1621 TopTools_Array1OfShape tabedg(0,nn);
1623 Standard_Integer nface=ChFi3d_nbface(myVFMap(Vtx));
1624 TopTools_ListIteratorOfListOfShape ItF;
1625 Standard_Integer nbarete;
1626 nbarete=ChFi3d_NbNotDegeneratedEdges(Vtx,myVEMap);
1627 ChFi3d_ChercheBordsLibres(myVEMap,Vtx,bordlibre,edgelibre1,edgelibre2);
1628 if (bordlibre) nbarete=(nbarete-2)/2 +2;
1629 else nbarete=nbarete/2;
1630 // it is determined if there is an edge of sewing and it face
1632 TopoDS_Face facecouture;
1633 TopoDS_Edge edgecouture;
1635 Standard_Boolean trouve=Standard_False;
1636 for(ItF.Initialize(myVFMap(Vtx));ItF.More()&&!couture;ItF.Next()) {
1637 TopoDS_Face fcur = TopoDS::Face(ItF.Value());
1638 ChFi3d_CoutureOnVertex(fcur,Vtx,couture,edgecouture);
1642 // it is determined if one of edges adjacent to the fillet is regular
1643 Standard_Boolean reg1,reg2;
1644 TopoDS_Edge Ecur,Eadj1,Eadj2;
1645 TopoDS_Face Fga,Fdr;
1646 TopoDS_Vertex Vbid1;
1647 Standard_Integer nbsurf,nbedge;
1648 reg1=Standard_False;
1649 reg2=Standard_False;
1650 nbsurf= SeqFil.Length();
1651 nbedge = spine->NbEdges();
1652 num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
1653 isfirst = (sens == 1);
1656 EdgeSpine=spine->Edges(1);
1658 state = spine->FirstStatus();
1661 EdgeSpine=spine->Edges(nbedge);
1663 state = spine->LastStatus();
1665 if (nbsurf!=nbedge && nbsurf!=1) {
1666 ChFi3d_edge_common_faces(myEFMap(EdgeSpine),F1,F2);
1667 if (F1.IsSame(facecouture)) Eadj1=edgecouture;
1668 else ChFi3d_cherche_element(Vtx,EdgeSpine,F1,Eadj1,Vbid1);
1669 ChFi3d_edge_common_faces(myEFMap(Eadj1),Fga,Fdr);
1670 // Modified by Sergey KHROMOV - Fri Dec 21 17:57:32 2001 Begin
1671 // reg1=BRep_Tool::Continuity(Eadj1,Fga,Fdr)!=GeomAbs_C0;
1672 reg1=isTangentFaces(Eadj1,Fga,Fdr);
1673 // Modified by Sergey KHROMOV - Fri Dec 21 17:57:33 2001 End
1674 if (F2.IsSame(facecouture)) Eadj2=edgecouture;
1675 else ChFi3d_cherche_element(Vtx,EdgeSpine,F2,Eadj2,Vbid1);
1676 ChFi3d_edge_common_faces(myEFMap(Eadj2),Fga,Fdr);
1677 // Modified by Sergey KHROMOV - Fri Dec 21 17:58:22 2001 Begin
1678 // reg2=BRep_Tool::Continuity(Eadj2,Fga,Fdr)!=GeomAbs_C0;
1679 reg2=isTangentFaces(Eadj2,Fga,Fdr);
1680 // Modified by Sergey KHROMOV - Fri Dec 21 17:58:24 2001 End
1682 // two faces common to the edge are found
1684 Standard_Boolean compoint1=Standard_False;
1685 Standard_Boolean compoint2=Standard_False;
1686 ChFiDS_CommonPoint cp1, cp2;
1687 cp1 = SeqFil(num1)->ChangeVertex (isfirst,1);
1688 cp2 = SeqFil(num1)->ChangeVertex (isfirst,2);
1689 if (cp1.IsOnArc()) {
1690 if (cp1.Arc().IsSame(Eadj1)||cp1.Arc().IsSame(Eadj2))
1691 compoint1=Standard_True;
1693 if (cp2.IsOnArc()) {
1694 if (cp2.Arc().IsSame(Eadj1)||cp2.Arc().IsSame(Eadj2))
1695 compoint2=Standard_True;
1697 if (compoint1 && compoint2) {
1699 reg1=Standard_False; reg2=Standard_False;
1703 // there is only one face at end if FindFace is true and if the face
1704 // is not the face with sewing edge
1706 Handle(ChFiDS_SurfData) Fd = SeqFil.ChangeValue(num);
1707 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
1708 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
1709 Standard_Boolean onecorner=Standard_False;
1710 if (FindFace(Vtx,CV1,CV2,face)) {
1711 if (!couture) onecorner =Standard_True;
1712 else if (!face.IsSame(facecouture))
1713 onecorner=Standard_True;
1716 if (ChFi3d_Builder::MoreSurfdata(Index)) {
1717 ChFi3d_Builder::PerformMoreSurfdata(Index);
1721 if (!onecorner && (reg1||reg2) && !couture && state!=ChFiDS_OnSame) {
1722 PerformMoreThreeCorner (Index,1);
1725 Handle(GeomAdaptor_HSurface) HGs = ChFi3d_BoundSurf(DStr,Fd,1,2);
1726 ChFiDS_FaceInterference Fi1 = Fd->InterferenceOnS1();
1727 ChFiDS_FaceInterference Fi2 = Fd->InterferenceOnS2();
1728 GeomAdaptor_Surface& Gs = HGs->ChangeSurface();
1729 Handle(BRepAdaptor_HSurface) HBs = new BRepAdaptor_HSurface();
1730 BRepAdaptor_Surface& Bs = HBs->ChangeSurface();
1731 Handle(Geom_Curve) Cc;
1732 Handle(Geom2d_Curve) Pc,Ps;
1733 Standard_Real Ubid,Vbid;
1734 TopAbs_Orientation orsurfdata;
1735 orsurfdata=Fd->Orientation();
1736 Standard_Integer IsurfPrev=0, Isurf=Fd->Surf();
1737 Handle(ChFiDS_SurfData) SDprev;
1738 if (num1>0 && num1<=SeqFil.Length()) {
1739 SDprev = SeqFil(num1);
1740 IsurfPrev = SDprev->Surf();
1742 // calculate the orientation of curves at end
1744 Standard_Real tolpt=1.e-4;
1745 Standard_Real tolreached;
1746 TopAbs_Orientation orcourbe,orface,orien;
1748 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV1,DStr),isfirst,1);
1749 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV2,DStr),isfirst,2);
1754 Standard_Integer Ishape1=Fd->IndexOfS1();
1756 TopAbs_Orientation trafil1 = TopAbs_FORWARD;
1758 TopAbs_Orientation trafil1;
1762 trafil1 = DStr.Shape(Ishape1).Orientation();
1766 cout<<"erreur"<<endl;
1769 trafil1 = TopAbs::Compose(trafil1,Fd->Orientation());
1771 trafil1 = TopAbs::Compose(TopAbs::Reverse(Fi1.Transition()),trafil1);
1774 else cout<<"erreur"<<endl;
1776 // eap, Apr 22 2002, occ 293
1777 // Fi1.PCurveOnFace()->D0(Fi1.LastParameter(),p2d);
1778 // const Handle(Geom_Surface) Stemp =
1779 // BRep_Tool::Surface(TopoDS::Face(DStr.Shape(Ishape1)));
1780 // Stemp ->D0(p2d.X(),p2d.Y(),p3d);
1781 // dist=p3d.Distance(CV1.Point());
1782 // if (dist<tolpt) orcourbe=trafil1;
1783 // else orcourbe=TopAbs::Reverse(trafil1);
1784 if (!isfirst) orcourbe=trafil1;
1785 else orcourbe=TopAbs::Reverse(trafil1);
1787 // eap, Apr 22 2002, occ 293
1788 // variables to show OnSame situation
1789 Standard_Boolean isOnSame1, isOnSame2;
1790 // In OnSame situation, the case of degenerated FaceInterference curve
1791 // is probable when a corner cuts the ChFi3d earlier built on OnSame edge.
1792 // In such a case, chamfer face can partially shrink to a line and we need
1793 // to cut off that shrinked part
1794 // If <isOnSame1>, FaceInterference with F2 can be degenerated
1795 Standard_Boolean checkShrink, isShrink, isUShrink;
1796 isShrink = isUShrink = isOnSame1 = isOnSame2 = Standard_False;
1797 Standard_Real checkShrParam=0., prevSDParam=0.;
1799 Standard_Integer midIpoint=0;
1801 // find Fi1,Fi2 lengths used to extend ChFi surface
1802 // and by the way define necessity to check shrink
1803 gp_Pnt2d P2d1=Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));
1804 gp_Pnt2d P2d2=Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
1806 HGs->D0( P2d1.X(),P2d1.Y(),aP1);
1807 HGs->D0( P2d2.X(),P2d2.Y(),aP2);
1808 Standard_Real Fi1Length=aP1.Distance(aP2);
1809 // Standard_Real eps = Precision::Confusion();
1810 checkShrink = (Fi1Length <= Precision::Confusion());
1812 gp_Pnt2d P2d3=Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
1813 gp_Pnt2d P2d4=Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
1814 HGs->D0( P2d3.X(),P2d3.Y(),aP1);
1815 HGs->D0( P2d4.X(),P2d4.Y(),aP2);
1816 Standard_Real Fi2Length=aP1.Distance(aP2);
1817 checkShrink = checkShrink || (Fi2Length <= Precision::Confusion());
1820 if (Abs(P2d2.Y()-P2d4.Y()) <= Precision::PConfusion()) {
1821 isUShrink = Standard_False;
1822 checkShrParam = P2d2.Y();
1823 } else if (Abs(P2d2.X()-P2d4.X()) <= Precision::PConfusion()) {
1824 isUShrink = Standard_True;
1825 checkShrParam = P2d2.X();
1828 checkShrink = Standard_False;
1831 /***********************************************************************/
1832 // find faces intersecting with the fillet and edges limiting intersections
1833 // nbface is the nb of faces intersected, Face[i] contais the faces
1834 // to intersect (i=0.. nbface-1). Edge[i] contains edges limiting
1835 // the intersections (i=0 ..nbface)
1836 /**********************************************************************/
1838 Standard_Integer nb = 1,nbface;
1839 TopoDS_Edge E1 ,E2, Edge[nn],E,Ei,edgesau;
1840 TopoDS_Face facesau;
1841 Standard_Boolean oneintersection1=Standard_False;
1842 Standard_Boolean oneintersection2=Standard_False;
1843 TopoDS_Face Face[nn],F,F3;
1844 TopoDS_Vertex V1,V2,V,Vfin;
1845 Standard_Boolean findonf1=Standard_False,findonf2=Standard_False;
1846 TopTools_ListIteratorOfListOfShape It3;
1847 F1=TopoDS::Face(DStr.Shape(Fd->IndexOfS1()));
1848 F2=TopoDS::Face(DStr.Shape(Fd->IndexOfS2()));
1850 if (couture || bordlibre) nface=nface+1;
1851 if (nface==3) nbface=2;
1852 else nbface=nface-2;
1853 if (!CV1.IsOnArc()||!CV2.IsOnArc()) {
1854 PerformMoreThreeCorner(Index,1);
1859 Edge[nbface]=CV2.Arc();
1860 tabedg.SetValue(0,Edge[0]);
1861 tabedg.SetValue(nbface,Edge[nbface]);
1862 // processing of a fillet arriving on a vertex
1863 // edge contained in CV.Arc is not inevitably good
1864 // the edge concerned by the intersection is found
1866 Standard_Real dist1,dist2;
1867 if (CV1.IsVertex()) {
1868 trouve=Standard_False;
1869 /*TopoDS_Vertex */V=CV1.Vertex();
1870 for (It3.Initialize(myVEMap(V));It3.More()&&!trouve;It3.Next()) {
1871 E=TopoDS::Edge (It3.Value());
1872 if (!E.IsSame(Edge[0])&&(containE(F1,E)))
1873 trouve=Standard_True;
1875 TopoDS_Vertex Vt,V3,V4;
1876 V1=TopExp::FirstVertex(Edge[0]);
1877 V2=TopExp::LastVertex(Edge[0]);
1878 if (V.IsSame(V1)) Vt=V2;
1880 dist1=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1881 V3=TopExp::FirstVertex(E);
1882 V4=TopExp::LastVertex(E);
1883 if (V.IsSame(V3)) Vt=V4;
1885 dist2=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1888 TopAbs_Orientation ori;
1889 if (V2.IsSame(V3)||V1.IsSame(V4)) ori=CV1.TransitionOnArc();
1890 else ori=TopAbs::Reverse(CV1.TransitionOnArc());
1891 Standard_Real par= BRep_Tool::Parameter(V,Edge[0]);
1892 Standard_Real tol= CV1.Tolerance();
1893 CV1.SetArc(tol,Edge[0],par,ori);
1897 if (CV2.IsVertex()) {
1898 trouve=Standard_False;
1899 /*TopoDS_Vertex*/ V=CV2.Vertex();
1900 for (It3.Initialize(myVEMap(V));It3.More()&&!trouve;It3.Next()) {
1901 E=TopoDS::Edge (It3.Value());
1902 if (!E.IsSame(Edge[2])&&(containE(F2,E)))
1903 trouve=Standard_True;
1905 TopoDS_Vertex Vt,V3,V4;
1906 V1=TopExp::FirstVertex(Edge[2]);
1907 V2=TopExp::LastVertex(Edge[2]);
1908 if (V.IsSame(V1)) Vt=V2;
1910 dist1=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1911 V3=TopExp::FirstVertex(E);
1912 V4=TopExp::LastVertex(E);
1913 if (V.IsSame(V3)) Vt=V4;
1915 dist2=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1918 TopAbs_Orientation ori;
1919 if (V2.IsSame(V3)||V1.IsSame(V4)) ori=CV2.TransitionOnArc();
1920 else ori=TopAbs::Reverse(CV2.TransitionOnArc());
1921 Standard_Real par= BRep_Tool::Parameter(V,Edge[2]);
1922 Standard_Real tol= CV2.Tolerance();
1923 CV2.SetArc(tol,Edge[2],par,ori);
1927 // If there is a regular edge, the faces adjacent to it
1928 // are not in Fd->IndexOfS1 or Fd->IndexOfS2
1930 // TopoDS_Face Find1 ,Find2;
1932 // edge=stripe->Spine()->Edges(1);
1933 // else edge=stripe->Spine()->Edges(stripe->Spine()->NbEdges());
1934 // It3.Initialize(myEFMap(edge));
1935 // Find1=TopoDS::Face(It3.Value());
1936 // trouve=Standard_False;
1937 // for (It3.Initialize(myEFMap(edge));It3.More()&&!trouve;It3.Next()) {
1938 // F=TopoDS::Face (It3.Value());
1939 // if (!F.IsSame(Find1)) {
1940 // Find2=F;trouve=Standard_True;
1944 // if nface =3 there is a top with 3 edges and a fillet
1945 // and their common points are on different faces
1946 // otherwise there is a case when a top has more than 3 edges
1949 if (CV1.IsVertex ()) findonf1=Standard_True;
1950 if (CV2.IsVertex ()) findonf2=Standard_True;
1952 TopTools_IndexedMapOfShape MapV;
1953 TopExp::MapShapes(Edge[0], TopAbs_VERTEX, MapV);
1954 if (MapV.Extent()==2)
1955 if (!MapV(1).IsSame(Vtx) && !MapV(2).IsSame(Vtx))
1956 findonf1=Standard_True;
1959 TopTools_IndexedMapOfShape MapV;
1960 TopExp::MapShapes(Edge[2], TopAbs_VERTEX, MapV);
1961 if (MapV.Extent()==2)
1962 if (!MapV(1).IsSame(Vtx) && !MapV(2).IsSame(Vtx))
1963 findonf2=Standard_True;
1966 // detect and process OnSame situatuation
1967 if (state == ChFiDS_OnSame) {
1968 TopoDS_Edge threeE[3];
1969 ChFi3d_cherche_element(Vtx,EdgeSpine, F1,threeE[0], V2);
1970 ChFi3d_cherche_element(Vtx,EdgeSpine, F2,threeE[1], V2);
1971 threeE[2] = EdgeSpine;
1972 if (ChFi3d_EdgeState(threeE,myEFMap) == ChFiDS_OnSame) {
1973 isOnSame1 = Standard_True;
1975 Edge[0] = threeE[0];
1976 ChFi3d_cherche_face1(myEFMap(Edge[0]),F1,Face[0]);
1978 findonf1 = Standard_True; // not to look for Face[0] again
1983 isOnSame2 = Standard_True;
1987 // findonf1 findonf2 show if F1 and/or F2 are adjacent
1988 // to many faces at end
1989 // the faces at end and intersected edges are found
1991 if (findonf1 && !isOnSame1) {
1992 if (CV1.TransitionOnArc()==TopAbs_FORWARD)
1993 V1=TopExp::FirstVertex(CV1.Arc());
1995 V1=TopExp::LastVertex(CV1.Arc());
1996 ChFi3d_cherche_face1(myEFMap(CV1.Arc()),F1,Face[0]);
1999 while (!V1.IsSame(Vtx)) {
2000 ChFi3d_cherche_element(V1,Ei,F1,E,V2);
2002 ChFi3d_cherche_face1(myEFMap(E),F1,Face[nb]);
2003 cherche_edge1(Face[nb-1],Face[nb],Edge[nb]);
2005 if (nb>=nn) Standard_Failure::Raise
2006 ("IntersectionAtEnd : the max number of faces reached");
2008 if (!findonf2) Edge[nb]=CV2.Arc();
2010 if (findonf2 && !isOnSame2) {
2011 if (!findonf1 ) nb=1;
2013 if (CV2.TransitionOnArc()==TopAbs_FORWARD)
2014 Vfin=TopExp::LastVertex(CV2.Arc());
2016 Vfin=TopExp::FirstVertex(CV2.Arc());
2017 if (!findonf1) ChFi3d_cherche_face1(myEFMap(CV1.Arc()),F1,Face[nb-1]);
2018 ChFi3d_cherche_element(V1,EdgeSpine,F2,E,V2);
2020 while (!V1.IsSame(Vfin)) {
2021 ChFi3d_cherche_element(V1,Ei,F2,E,V2);
2024 ChFi3d_cherche_face1(myEFMap(E),F2,Face[nb]);
2025 cherche_edge1(Face[nb-1],Face[nb],Edge[nb]);
2027 if (nb>=nn) Standard_Failure::Raise
2028 ("IntersectionAtEnd : the max number of faces reached");
2033 cherche_edge1(Face[nb-1],F2,Edge[nb]);
2042 // this is the case when a top has more than three edges
2043 // the faces and edges concerned are found
2044 Standard_Boolean /*trouve,*/possible1, possible2;
2045 trouve = possible1 = possible2 = Standard_False;
2048 for (ex.Init(CV1.Arc(),TopAbs_VERTEX);ex.More();ex.Next()) {
2049 if (Vtx.IsSame(ex.Current())) possible1 = Standard_True;
2051 for (ex.Init(CV2.Arc(),TopAbs_VERTEX);ex.More();ex.Next()) {
2052 if (Vtx.IsSame(ex.Current())) possible2 = Standard_True;
2054 if ((possible1 && possible2) || (!possible1 && !possible2) || (nbarete > 4)) {
2057 if (nb!=1) F3=Face[nb-2];
2059 if (CV1.Arc().IsSame(edgelibre1))
2060 cherche_face(myVFMap(Vtx),edgelibre2,F1,F2,F3,Face[nb-1]);
2061 else if (CV1.Arc().IsSame(edgelibre2))
2062 cherche_face(myVFMap(Vtx),edgelibre1,F1,F2,F3,Face[nb-1]);
2063 else cherche_face(myVFMap(Vtx),Edge[nb-1],F1,F2,F3,Face[nb-1]);
2064 ChFi3d_cherche_edge(Vtx,tabedg,Face[nb-1],Edge[nb],V);
2065 tabedg.SetValue(nb,Edge[nb]);
2066 if (Edge[nb].IsSame(CV2.Arc())) trouve=Standard_True;
2071 IntersectMoreCorner (Index);
2075 // if two consecutive edges are G1 there is only one face of intersection
2076 Standard_Real ang1=0.0;
2078 trouve=Standard_False;
2079 ChFi3d_cherche_vertex ( Edge[0],Edge[1],Vcom,trouve);
2080 if (Vcom.IsSame(Vtx)) ang1=ChFi3d_AngleEdge(Vtx,Edge[0],Edge[1]);
2081 if (Abs(ang1-M_PI)<0.01) {
2082 oneintersection1=Standard_True;
2090 if (!oneintersection1) {
2091 trouve=Standard_False;
2092 ChFi3d_cherche_vertex ( Edge[1],Edge[2],Vcom,trouve);
2093 if (Vcom.IsSame(Vtx)) ang1=ChFi3d_AngleEdge(Vtx,Edge[1],Edge[2]);
2094 if (Abs(ang1-M_PI)<0.01) {
2095 oneintersection2=Standard_True;
2103 else if (nbarete==5) {
2105 // Modified by Sergey KHROMOV - Fri Dec 21 18:07:43 2001 End
2106 Standard_Boolean isTangent0 = isTangentFaces(Edge[0],F1,Face[0]);
2107 Standard_Boolean isTangent1 = isTangentFaces(Edge[1],Face[0],Face[1]);
2108 Standard_Boolean isTangent2 = isTangentFaces(Edge[2],Face[1],Face[2]);
2109 if ((isTangent0 || isTangent2) && isTangent1) {
2110 // GeomAbs_Shape cont0,cont1,cont2;
2111 // cont0=BRep_Tool::Continuity(Edge[0],F1,Face[0]);
2112 // cont1=BRep_Tool::Continuity(Edge[1],Face[0],Face[1]);
2113 // cont2=BRep_Tool::Continuity(Edge[2],Face[1],Face[2]);
2114 // if ((cont0!=GeomAbs_C0 || cont2!=GeomAbs_C0) && cont1!=GeomAbs_C0) {
2115 // Modified by Sergey KHROMOV - Fri Dec 21 18:07:49 2001 Begin
2121 oneintersection1=Standard_True;
2132 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
2133 gp_Pnt2d pfil1,pfac1,pfil2,pfac2,pint,pfildeb;
2134 Handle(Geom2d_Curve) Hc1,Hc2;
2135 IntCurveSurface_HInter inters;
2136 Standard_Integer proledge[nn],prolface[nn+1];// last prolface[nn] is for Fd
2137 Standard_Integer shrink[nn];
2138 TopoDS_Face faceprol[nn];
2139 Standard_Integer indcurve[nn],indpoint2=0,indpoint1 = 0;
2140 Handle (TopOpeBRepDS_CurvePointInterference) Interfp1, Interfp2, Interfedge[nn];
2141 Handle (TopOpeBRepDS_SurfaceCurveInterference) Interfc,InterfPC[nn],InterfPS[nn];
2142 Standard_Real u2,v2,p1,p2,paredge1;
2143 Standard_Real paredge2 = 0.,tolex = 1.e-4;
2144 Standard_Boolean extend=Standard_False;
2145 Handle(Geom_Surface) Sfacemoins1,Sface;
2146 /***************************************************************************/
2147 // calculate intersection of the fillet and each face
2148 // and storage in the DS
2149 /***************************************************************************/
2150 for (nb=1;nb<=nbface;nb++) {
2157 if (oneintersection1||oneintersection2) faceprol[1]=facesau;
2158 if (!isOnSame1 && !isOnSame2)
2159 checkShrink = Standard_False;
2160 // in OnSame situation we need intersect Fd with Edge[0] or Edge[nbface] as well
2161 if (isOnSame1) nb=0;
2163 Standard_Boolean intersOnSameFailed = Standard_False;
2165 for ( ; nb<=nbface; nb++) {
2166 extend=Standard_False;
2172 if (!prolface[nb-1]) faceprol[nb-1]=F;
2174 Sfacemoins1=BRep_Tool::Surface(F);
2175 Handle(Geom_Curve) cint;
2176 Handle(Geom2d_Curve) C2dint1, C2dint2,cface,cfacemoins1;
2178 ///////////////////////////////////////////////////////
2179 // determine intersections of edges and the fillet
2180 // to find limitations of intersections face - fillet
2181 ///////////////////////////////////////////////////////
2184 Hc1 = BRep_Tool::CurveOnSurface(Edge[0],Face[0],Ubid,Ubid);
2186 // update interference param on Fi1 and point of CV1
2187 if (prolface[0]) Bs.Initialize(faceprol[0], Standard_False);
2188 else Bs.Initialize(Face[0], Standard_False);
2189 const Handle(Geom_Curve)& c3df = DStr.Curve(Fi1.LineIndex()).Curve();
2190 Standard_Real Ufi= Fi2.Parameter(isfirst);
2191 ChFiDS_FaceInterference& Fi = Fd->ChangeInterferenceOnS1();
2192 if (!IntersUpdateOnSame (HGs,HBs,c3df,F1,Face[0],Edge[0],Vtx,isfirst,10*tolesp, // in
2193 Fi,CV1,pfac1,Ufi)) // out
2194 Standard_Failure::Raise("IntersectionAtEnd: pb intersection Face - Fi");
2196 if (intersOnSameFailed) { // probable at fillet building
2197 // look for paredge2
2198 Geom2dAPI_ProjectPointOnCurve proj;
2199 if (C2dint2.IsNull()) proj.Init(pfac1,Hc1);
2200 else proj.Init(pfac1,C2dint2);
2201 paredge2 = proj.LowerDistanceParameter();
2203 // update stripe point
2204 TopOpeBRepDS_Point tpoint (CV1.Point(),tolesp);
2205 indpoint1=DStr.AddPoint(tpoint);
2206 stripe->SetIndexPoint(indpoint1,isfirst,1);
2208 TopoDS_Vertex vert1,vert2;
2209 TopExp::Vertices(Edge[0],vert1,vert2);
2210 TopAbs_Orientation arcOri = Vtx.IsSame(vert1) ? TopAbs_FORWARD : TopAbs_REVERSED;
2211 CV1.SetArc(tolesp,Edge[0],paredge2,arcOri);
2215 // curve 2d not found. Sfacemoins1 is extended and projection is done there
2217 ChFi3d_ExtendSurface(Sfacemoins1,prolface[0]);
2219 extend=Standard_True;
2221 Standard_Real tol=BRep_Tool::Tolerance(F);
2222 BRE.MakeFace(faceprol[0],Sfacemoins1,F.Location(),tol);
2224 GeomAdaptor_Surface Asurf;
2225 Asurf.Load(Sfacemoins1);
2226 Extrema_ExtPS ext (CV1.Point(),Asurf, tol,tol);
2227 Standard_Real uc1,vc1;
2229 ext.Point(1).Parameter(uc1,vc1);
2237 pfac1 = Hc1->Value(CV1.ParameterOnArc());
2239 paredge1=CV1.ParameterOnArc();
2240 if (Fi1.LineIndex() != 0) {
2241 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));}
2243 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));}
2252 if (nb!=nbface || isOnSame2) {
2253 Standard_Integer nbp;
2255 Handle(Geom_Curve) C;
2256 C=BRep_Tool::Curve(E2,Ubid,Vbid);
2257 Handle(Geom_TrimmedCurve) Ctrim = new Geom_TrimmedCurve(C,Ubid,Vbid);
2258 Standard_Real Utrim,Vtrim;
2259 Utrim=Ctrim->BasisCurve()->FirstParameter();
2260 Vtrim=Ctrim->BasisCurve()->LastParameter();
2261 if (Ctrim->IsPeriodic()) {
2262 if (Ubid>Ctrim->Period()) {
2263 Ubid=(Utrim+Vtrim)/2;
2268 Vbid=(Utrim+Vtrim)/2;
2275 Handle(GeomAdaptor_HCurve) HC =
2276 new GeomAdaptor_HCurve(C,Ubid,Vbid);
2277 GeomAdaptor_Curve & Cad =HC->ChangeCurve();
2278 inters.Perform(HC, HGs);
2279 if ( !prolface[nn] && ( !inters.IsDone() || (inters.NbPoints()==0) )) {
2280 // extend surface of conge
2281 Handle(Geom_BSplineSurface) S1=
2282 Handle(Geom_BSplineSurface)::DownCast(DStr.Surface(Fd->Surf()).Surface());
2284 Standard_Real length = 0.5 * Max(Fi1Length,Fi2Length);
2285 GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,!isfirst);
2287 if (!stripe->IsInDS(!isfirst)) {
2289 inters.Perform(HC, HGs);
2290 if (inters.IsDone()&& inters.NbPoints()!=0) {
2291 Fd->ChangeSurf(DStr.AddSurface(TopOpeBRepDS_Surface(S1, DStr.ChangeSurface(Isurf).Tolerance())));
2297 if (!inters.IsDone() || (inters.NbPoints()==0)) {
2298 Handle(Geom_BSplineCurve) cd=Handle(Geom_BSplineCurve)::DownCast(C);
2299 Handle(Geom_BezierCurve) cd1=Handle(Geom_BezierCurve)::DownCast(C);
2300 if (!cd.IsNull() || !cd1.IsNull() ) {
2302 Sface=BRep_Tool::Surface(Face[nb]);
2303 ChFi3d_ExtendSurface(Sface,prolface[nb]);
2304 Standard_Real tol=BRep_Tool::Tolerance(F);
2305 BRE.MakeFace(faceprol[nb],Sface,Face[nb].Location(),tol);
2306 if (nb && !prolface[nb-1]) {
2307 ChFi3d_ExtendSurface(Sfacemoins1,prolface[nb-1]);
2308 if (prolface[nb-1]) {
2309 tol=BRep_Tool::Tolerance(F);
2310 BRE.MakeFace(faceprol[nb-1],Sfacemoins1,F.Location(),tol);
2314 Standard_Integer prol = 0;
2315 ChFi3d_ExtendSurface(Sfacemoins1,prol);
2317 GeomInt_IntSS InterSS(Sfacemoins1,Sface,1.e-7,1,1,1);
2318 if (InterSS.IsDone()) {
2319 trouve=Standard_False;
2320 for (Standard_Integer i=1; i<=InterSS.NbLines() && !trouve; i++) {
2321 extend=Standard_True;
2322 cint= InterSS.Line(i);
2323 C2dint1= InterSS.LineOnS1(i);
2324 C2dint2= InterSS.LineOnS2(i);
2326 inters.Perform(HC, HGs);
2327 trouve=inters.IsDone()&&inters.NbPoints()!=0;
2328 // eap occ293, eval tolex on finally trimmed curves
2329 // Handle(GeomAdaptor_HSurface) H1=new GeomAdaptor_HSurface(Sfacemoins1);
2330 // Handle(GeomAdaptor_HSurface) H2=new GeomAdaptor_HSurface(Sface);
2331 // tolex=ChFi3d_EvalTolReached(H1,C2dint1,H2,C2dint2,cint);
2332 tolex = InterSS.TolReached3d();
2337 if (inters.IsDone()) {
2338 nbp = inters.NbPoints();
2340 if (nb==0 || nb==nbface)
2341 intersOnSameFailed = Standard_True;
2343 PerformMoreThreeCorner (Index,1);
2348 gp_Pnt P=BRep_Tool::Pnt(Vtx);
2349 Standard_Real distmin=P.Distance(inters.Point(1).Pnt());
2351 for (Standard_Integer i=2;i<=inters.NbPoints();i++) {
2352 dist=P.Distance(inters.Point(i).Pnt());
2358 gp_Pnt2d pt2d (inters.Point(nbp).U(),inters.Point(nbp).V());
2360 paredge2=inters.Point(nbp).W();
2362 cfacemoins1=BRep_Tool::CurveOnSurface(E2,F,u2,v2);
2363 cface=BRep_Tool::CurveOnSurface(E2,Face[nb],u2,v2);
2364 cfacemoins1->D0(paredge2,pfac2);
2365 cface->D0(paredge2,pint);
2368 C2dint1->D0(paredge2,pfac2);
2369 C2dint2->D0(paredge2,pint);
2373 else Standard_Failure::Raise("IntersectionAtEnd: pb intersection Face cb");
2376 Hc2 = BRep_Tool::CurveOnSurface(E2,Face[nbface-1],Ubid,Ubid);
2378 // curve 2d is not found, Sfacemoins1 is extended CV2.Point() is projected there
2380 ChFi3d_ExtendSurface(Sfacemoins1,prolface[0]);
2383 extend=Standard_True;
2384 Standard_Real tol=BRep_Tool::Tolerance(F);
2385 BRE.MakeFace(faceprol[nb-1],Sfacemoins1,F.Location(),tol);
2386 GeomAdaptor_Surface Asurf;
2387 Asurf.Load(Sfacemoins1);
2388 Extrema_ExtPS ext (CV2.Point(),Asurf,tol,tol);
2389 Standard_Real uc2,vc2;
2391 ext.Point(1).Parameter(uc2,vc2);
2397 else pfac2 = Hc2->Value(CV2.ParameterOnArc());
2398 paredge2=CV2.ParameterOnArc();
2399 if (Fi2.LineIndex() != 0) {
2400 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
2403 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
2406 if (!nb) continue; // found paredge1 on Edge[0] in OnSame situation on F1
2408 if (nb==nbface && isOnSame2) {
2409 // update interference param on Fi2 and point of CV2
2410 if (prolface[nb-1]) Bs.Initialize(faceprol[nb-1]);
2411 else Bs.Initialize(Face[nb-1]);
2412 const Handle(Geom_Curve)& c3df = DStr.Curve(Fi2.LineIndex()).Curve();
2413 Standard_Real Ufi= Fi1.Parameter(isfirst);
2414 ChFiDS_FaceInterference& Fi = Fd->ChangeInterferenceOnS2();
2415 if (!IntersUpdateOnSame (HGs,HBs,c3df,F2,F,Edge[nb],Vtx,isfirst,10*tolesp, // in
2416 Fi,CV2,pfac2,Ufi)) // out
2417 Standard_Failure::Raise("IntersectionAtEnd: pb intersection Face - Fi");
2419 if (intersOnSameFailed) { // probable at fillet building
2420 // look for paredge2
2421 Geom2dAPI_ProjectPointOnCurve proj;
2423 proj.Init(pfac2, C2dint2);
2425 proj.Init(pfac2, BRep_Tool::CurveOnSurface (E2,Face[nbface-1],Ubid,Ubid));
2426 paredge2 = proj.LowerDistanceParameter();
2428 // update stripe point
2429 TopOpeBRepDS_Point tpoint (CV2.Point(),tolesp);
2430 indpoint2=DStr.AddPoint(tpoint);
2431 stripe->SetIndexPoint(indpoint2,isfirst,2);
2433 TopoDS_Vertex vert1,vert2;
2434 TopExp::Vertices(Edge[nbface],vert1,vert2);
2435 TopAbs_Orientation arcOri = Vtx.IsSame(vert1) ? TopAbs_FORWARD : TopAbs_REVERSED;
2436 CV2.SetArc(tolesp,Edge[nbface],paredge2,arcOri);
2440 if (prolface[nb-1]) Bs.Initialize(faceprol[nb-1]);
2441 else Bs.Initialize(Face[nb-1]);
2443 // offset of parameters if they are not in the same period
2445 // commented by eap 30 May 2002 occ354
2446 // the following code may cause trimming a wrong part of periodic surface
2448 // Standard_Real deb,xx1,xx2;
2449 // Standard_Boolean moins2pi,moins2pi1,moins2pi2;
2450 // if (DStr.Surface(Fd->Surf()).Surface()->IsUPeriodic()) {
2454 // moins2pi=Abs(deb)< Abs(Abs(deb)-2*M_PI);
2455 // moins2pi1=Abs(xx1)< Abs(Abs(xx1)-2*M_PI);
2456 // moins2pi2=Abs(xx2)< Abs(Abs(xx2)-2*M_PI);
2457 // if (moins2pi1!=moins2pi2) {
2459 // if (!moins2pi1) xx1=xx1-2*M_PI;
2460 // if (!moins2pi2) xx2=xx2-2*M_PI;
2463 // if (moins2pi1) xx1=xx1+2*M_PI;
2464 // if (moins2pi2) xx2=xx2+2*M_PI;
2470 // if (couture || Sfacemoins1->IsUPeriodic()) {
2472 // Standard_Real ufmin,ufmax,vfmin,vfmax;
2473 // BRepTools::UVBounds(Face[nb-1],ufmin,ufmax,vfmin,vfmax);
2477 // moins2pi=Abs(deb)< Abs(Abs(deb)-2*M_PI);
2478 // moins2pi1=Abs(xx1)< Abs(Abs(xx1)-2*M_PI);
2479 // moins2pi2=Abs(xx2)< Abs(Abs(xx2)-2*M_PI);
2480 // if (moins2pi1!=moins2pi2) {
2482 // if (!moins2pi1) xx1=xx1-2*M_PI;
2483 // if (!moins2pi2) xx2=xx2-2*M_PI;
2486 // if (moins2pi1) xx1=xx1+2*M_PI;
2487 // if (moins2pi2) xx2=xx2+2*M_PI;
2494 Pardeb(1)= pfil1.X();Pardeb(2) = pfil1.Y();
2495 Pardeb(3)= pfac1.X();Pardeb(4) = pfac1.Y();
2496 Parfin(1)= pfil2.X();Parfin(2) = pfil2.Y();
2497 Parfin(3)= pfac2.X();Parfin(4) = pfac2.Y();
2499 Standard_Real uu1,uu2,vv1,vv2;
2500 ChFi3d_Boite(pfac1,pfac2,uu1,uu2,vv1,vv2);
2501 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
2504 //////////////////////////////////////////////////////////////////////
2505 // calculate intersections face - fillet
2506 //////////////////////////////////////////////////////////////////////
2508 if (!ChFi3d_ComputeCurves(HGs,HBs,Pardeb,Parfin,Cc,
2509 Ps,Pc,tolesp,tol2d,tolreached,nbface==1)) {
2510 PerformMoreThreeCorner (Index,1);
2513 // storage of information in the data structure
2515 // evaluate tolerances
2516 p1=Cc->FirstParameter();
2517 p2=Cc->LastParameter();
2518 Standard_Real to1,to2;
2520 gp_Pnt P1,P2,P3,P4,P5,P6,P7,P8;
2521 HGs->D0(Pardeb(1),Pardeb(2),P1);
2522 HGs->D0(Parfin(1),Parfin(2),P2);
2523 HBs->D0(Pardeb(3),Pardeb(4),P3);
2524 HBs->D0(Parfin(3),Parfin(4),P4);
2527 HBs->D0(p2d1.X(),p2d1.Y(),P7);
2528 HBs->D0(p2d2.X(),p2d2.Y(),P8);
2531 HGs->D0(p2d1.X(),p2d1.Y(),P5);
2532 HGs->D0(p2d2.X(),p2d2.Y(),P6);
2533 to1 = Max (P1.Distance(P5)+P3.Distance(P7), tolreached);
2534 to2 = Max (P2.Distance(P6)+P4.Distance(P8), tolreached);
2537 //////////////////////////////////////////////////////////////////////
2538 // storage in the DS of the intersection curve
2539 //////////////////////////////////////////////////////////////////////
2541 Standard_Boolean Isvtx1=0;
2542 Standard_Boolean Isvtx2=0;
2543 Standard_Integer indice;
2547 indpoint1 = stripe->IndexPoint(isfirst,1);
2548 if (!CV1.IsVertex()) {
2549 TopOpeBRepDS_Point& tpt= DStr.ChangePoint(indpoint1);
2550 tpt.Tolerance ( Max (tpt.Tolerance(), to1));
2556 indpoint2 = stripe->IndexPoint(isfirst,2);
2557 if (!CV2.IsVertex()) {
2558 TopOpeBRepDS_Point& tpt= DStr.ChangePoint(indpoint2);
2559 tpt.Tolerance ( Max (tpt.Tolerance(), to2));
2565 gp_Pnt point =Cc->Value(Cc->LastParameter());
2566 TopOpeBRepDS_Point tpoint (point,to2);
2567 indpoint2=DStr.AddPoint(tpoint);
2572 TopOpeBRepDS_Point& tpt= DStr.ChangePoint(indpoint1);
2573 tpt.Tolerance ( Max (tpt.Tolerance(), to1));
2575 TopOpeBRepDS_Curve tcurv3d( Cc,tolreached);
2576 indcurve[nb-1]= DStr.AddCurve(tcurv3d);
2577 Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurve[nb-1],
2578 indpoint1,Cc->FirstParameter(),Isvtx1);
2579 Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurve[nb-1],
2580 indpoint2,Cc->LastParameter(),Isvtx2);
2582 DStr.ChangeCurveInterferences(indcurve[nb-1]).Append(Interfp1);
2583 DStr.ChangeCurveInterferences(indcurve[nb-1]).Append(Interfp2);
2585 //////////////////////////////////////////////////////////////////////
2586 // storage for the face
2587 //////////////////////////////////////////////////////////////////////
2590 TopAbs_Orientation ori = TopAbs_FORWARD;
2592 TopAbs_Orientation ori;
2594 orface=Face[nb-1].Orientation();
2595 if (orface==orsurfdata ) orien = TopAbs::Reverse(orcourbe);
2596 else orien = orcourbe ;
2597 // limitation of edges of faces
2599 Standard_Integer Iarc1= DStr.AddShape(Edge[0]);
2600 Interfedge[0]= ChFi3d_FilPointInDS(CV1.TransitionOnArc(),Iarc1,
2601 indpoint1,paredge1,Isvtx1);
2602 //DStr.ChangeShapeInterferences(Edge[0]).Append(Interfp1);
2605 Standard_Integer Iarc2= DStr.AddShape(Edge[nb]);
2606 Interfedge[nb]= ChFi3d_FilPointInDS(CV2.TransitionOnArc() ,Iarc2,
2607 indpoint2,paredge2,Isvtx2);
2608 //DStr.ChangeShapeInterferences(Edge[nb]).Append(Interfp2);
2611 if (nb!=nbface || oneintersection1 || oneintersection2) {
2613 V1= TopExp::FirstVertex(Edge[nb]);
2614 V2= TopExp::LastVertex(Edge[nb]);
2615 if (containV(F1,V1) || containV(F2,V1))
2617 else if (containV(F1,V2) || containV(F2,V2))
2618 ori=TopAbs_REVERSED;
2620 Standard_Failure::Raise("IntersectionAtEnd : pb orientation");
2622 if (containV(F1,V1) && containV(F1,V2)) {
2623 dist1=(BRep_Tool::Pnt(V1)).Distance(BRep_Tool::Pnt(Vtx));
2624 dist2=(BRep_Tool::Pnt(V2)).Distance(BRep_Tool::Pnt(Vtx));
2625 if (dist1<dist2) ori=TopAbs_FORWARD;
2626 else ori=TopAbs_REVERSED;
2628 if (containV(F2,V1) && containV(F2,V2)) {
2629 dist1=(BRep_Tool::Pnt(V1)).Distance(BRep_Tool::Pnt(Vtx));
2630 dist2=(BRep_Tool::Pnt(V2)).Distance(BRep_Tool::Pnt(Vtx));
2631 if (dist1<dist2) ori=TopAbs_FORWARD;
2632 else ori=TopAbs_REVERSED;
2636 if (TopExp::FirstVertex(Edge[nb]).IsSame(Vtx))
2637 ori= TopAbs_FORWARD;
2638 else ori=TopAbs_REVERSED;
2640 if (!extend && !(oneintersection1 || oneintersection2)) {
2641 Standard_Integer Iarc2= DStr.AddShape(Edge[nb]);
2642 Interfedge[nb]= ChFi3d_FilPointInDS(ori,Iarc2,
2643 indpoint2,paredge2);
2644 // DStr.ChangeShapeInterferences(Edge[nb]).Append(Interfp2);
2647 if (!(oneintersection1 || oneintersection2) ) proledge[nb]=Standard_True;
2648 Standard_Integer indp1,indp2,ind;
2650 Standard_Real ubid,vbid;
2651 pext=BRep_Tool::Pnt(Vtx);
2652 GeomAdaptor_Curve cad;
2653 Handle(Geom_Curve) csau;
2654 if ( ! (oneintersection1 || oneintersection2)) {
2659 csau=BRep_Tool::Curve(edgesau,ubid,vbid );
2660 Handle(Geom_BoundedCurve) C1=
2661 Handle(Geom_BoundedCurve)::DownCast(csau);
2662 if (oneintersection1&&extend) {
2665 Pl=C1->Value(C1->LastParameter());
2666 //Standard_Boolean sens;
2667 sens=Pl.Distance(pext)<tolpt;
2668 GeomLib::ExtendCurveToPoint(C1,CV1.Point(),1,sens);
2672 else if (oneintersection2&&extend) {
2675 Pl=C1->Value(C1->LastParameter());
2676 //Standard_Boolean sens;
2677 sens=Pl.Distance(pext)<tolpt;
2678 GeomLib::ExtendCurveToPoint(C1,CV2.Point(),1,sens);
2684 Extrema_ExtPC ext(pext,cad,tolpt);
2685 Standard_Real par1, par2, par, ParVtx;
2686 Standard_Boolean vtx1=Standard_False;
2687 Standard_Boolean vtx2=Standard_False;
2688 par1=ext.Point(1).Parameter();
2690 if (oneintersection1 || oneintersection2 ) {
2691 if (oneintersection2) {
2699 Extrema_ExtPC ext2(pext,cad,tolpt);
2700 par2=ext2.Point(1).Parameter();
2708 indp2=DStr.AddShape(Vtx);
2715 indp1=DStr.AddShape(Vtx);
2719 Handle(Geom_Curve) Ct=new Geom_TrimmedCurve (csau,par1,par2);
2720 TopAbs_Orientation orient;
2721 Cc->D0(Cc->FirstParameter(),P1);
2722 Cc->D0(Cc->LastParameter(),P2);
2723 Ct->D0(Ct->FirstParameter(),P3);
2724 Ct->D0(Ct->LastParameter(),P4);
2725 if (P2.Distance(P3)<tolpt || P1.Distance(P4)<tolpt) orient=orien;
2726 else orient=TopAbs::Reverse(orien);
2727 if (oneintersection1||oneintersection2) {
2728 indice=DStr.AddShape(Face[0]);
2730 DStr.SetNewSurface(Face[0],Sfacemoins1);
2731 ComputeCurve2d(Ct,faceprol[0],C2dint1);
2735 TopoDS_Edge aLocalEdge = edgesau;
2736 if (edgesau.Orientation() != orient)
2737 aLocalEdge.Reverse();
2738 C2dint1 = BRep_Tool::CurveOnSurface(aLocalEdge,Face[0],ubid,vbid);
2742 indice=DStr.AddShape(Face[nb-1]);
2743 DStr.SetNewSurface(Face[nb-1],Sfacemoins1);
2745 //// for periodic 3d curves ////
2746 if (cad.IsPeriodic())
2748 gp_Pnt2d P2d = BRep_Tool::Parameters( Vtx, Face[0] );
2749 Geom2dAPI_ProjectPointOnCurve Projector( P2d, C2dint1 );
2750 par = Projector.LowerDistanceParameter();
2751 Standard_Real shift = par-ParVtx;
2752 if (Abs(shift) > Precision::Confusion())
2758 ////////////////////////////////
2760 Ct=new Geom_TrimmedCurve (csau,par1,par2);
2761 if (oneintersection1||oneintersection2) tolex=10*BRep_Tool::Tolerance(edgesau);
2763 Handle(GeomAdaptor_HSurface) H1, H2;
2764 H1=new GeomAdaptor_HSurface(Sfacemoins1);
2766 tolex = Max (tolex, ChFi3d_EvalTolReached(H1,C2dint1,H1,C2dint1,Ct));
2768 H2=new GeomAdaptor_HSurface(Sface);
2769 tolex = Max (tolex, ChFi3d_EvalTolReached(H1,C2dint1,H2,C2dint2,Ct));
2772 TopOpeBRepDS_Curve tcurv( Ct,tolex);
2773 Standard_Integer indcurv;
2774 indcurv=DStr.AddCurve(tcurv);
2775 Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurv,indp1,par1,vtx1);
2776 Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurv,indp2,par2,vtx2);
2777 DStr.ChangeCurveInterferences(indcurv).Append(Interfp1);
2778 DStr.ChangeCurveInterferences(indcurv).Append(Interfp2);
2780 Interfc=ChFi3d_FilCurveInDS(indcurv,indice ,C2dint1,orient);
2781 DStr.ChangeShapeInterferences(indice).Append(Interfc);
2782 if (oneintersection1||oneintersection2) {
2783 indice=DStr.AddShape(facesau);
2784 if (facesau.Orientation()==Face[0].Orientation())
2785 orient=TopAbs::Reverse(orient);
2787 ComputeCurve2d(Ct,faceprol[1],C2dint2);
2792 TopoDS_Edge aLocalEdge = edgesau;
2793 if (edgesau.Orientation() != orient)
2794 aLocalEdge.Reverse();
2795 C2dint2 = BRep_Tool::CurveOnSurface(aLocalEdge,facesau,ubid,vbid);
2796 //Reverse for case of edgesau on closed surface (Face[0] is equal to facesau)
2800 indice=DStr.AddShape(Face[nb]);
2801 DStr.SetNewSurface(Face[nb],Sface);
2802 if (Face[nb].Orientation()==Face[nb-1].Orientation())
2803 orient= TopAbs::Reverse(orient);
2806 Interfc=ChFi3d_FilCurveInDS(indcurv,indice,C2dint2,orient);
2807 DStr.ChangeShapeInterferences(indice).Append(Interfc);
2813 IsShrink(Ps,p1,p2,checkShrParam,isUShrink,Precision::Parametric(tolreached)))
2816 // store section face-chamf curve for previous SurfData
2817 // Suppose Fd and SDprev are parametrized similarly
2818 if (!isShrink) { // first time
2819 const ChFiDS_FaceInterference& Fi = SDprev->InterferenceOnS1();
2820 gp_Pnt2d UV = Fi.PCurveOnSurf()->Value(Fi.Parameter(isfirst));
2821 prevSDParam = isUShrink ? UV.X() : UV.Y();
2823 gp_Pnt2d UV1=p2d1,UV2=p2d2;
2824 UV1.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2825 UV2.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2826 Standard_Real aTolreached;
2827 ChFi3d_ComputePCurv(Cc,UV1,UV2,Ps,
2828 DStr.Surface(SDprev->Surf()).Surface(),
2829 p1,p2,tolesp,aTolreached);
2830 TopOpeBRepDS_Curve& TCurv = DStr.ChangeCurve(indcurve[nb-1]);
2831 TCurv.Tolerance(Max(TCurv.Tolerance(),aTolreached));
2833 InterfPS[nb-1]=ChFi3d_FilCurveInDS(indcurve[nb-1],IsurfPrev,Ps,orcourbe);
2834 DStr.ChangeSurfaceInterferences(IsurfPrev).Append(InterfPS[nb-1]);
2838 midIpoint = indpoint2;
2840 else if (!isShrink) {
2842 midIpoint = indpoint1;
2844 isShrink = Standard_True;
2848 indice=DStr.AddShape(Face[nb-1]);
2849 InterfPC[nb-1]=ChFi3d_FilCurveInDS(indcurve[nb-1],indice ,Pc,orien);
2851 InterfPS[nb-1]=ChFi3d_FilCurveInDS(indcurve[nb-1],Isurf,Ps,orcourbe);
2852 indpoint1=indpoint2;
2854 } // end loop on faces being intersected with ChFi
2857 if (isOnSame1) CV1.Reset();
2858 if (isOnSame2) CV2.Reset();
2860 for(nb=1;nb<=nbface;nb++) {
2861 Standard_Integer indice=DStr.AddShape(Face[nb-1]);
2862 DStr.ChangeShapeInterferences(indice).Append(InterfPC[nb-1]);
2864 DStr.ChangeSurfaceInterferences(Isurf).Append(InterfPS[nb-1]);
2865 if (!proledge[nb-1])
2866 DStr.ChangeShapeInterferences(Edge[nb-1]).Append(Interfedge[nb-1]);
2868 DStr.ChangeShapeInterferences(Edge[nbface]).Append(Interfedge[nbface]);
2871 stripe->InDS(isfirst);
2873 // compute curves for !<isfirst> end of <Fd> and <isfirst> end of previous <SurfData>
2877 gp_Pnt2d UV, UV1 = midP2d, UV2 = midP2d;
2879 UV = UV2 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
2881 UV = UV1 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
2882 Standard_Real aTolreached;
2883 Handle(Geom_Curve) C3d;
2884 Handle(Geom_Surface) aSurf = DStr.Surface(Fd->Surf()).Surface();
2885 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2887 ChFi3d_ComputeArete(CV1,UV1,CV2,UV2,aSurf, // in
2888 C3d,Ps,p1,p2,tolesp,tol2d,aTolreached,0); // out except tolers
2890 indpoint1 = indpoint2 = midIpoint;
2893 point = C3d->Value(p2);
2894 TopOpeBRepDS_Point tpoint (point,aTolreached);
2895 indpoint2=DStr.AddPoint(tpoint);
2898 point = C3d->Value(p1);
2899 TopOpeBRepDS_Point tpoint (point,aTolreached);
2900 indpoint1=DStr.AddPoint(tpoint);
2904 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2906 TopOpeBRepDS_Curve Crv = TopOpeBRepDS_Curve(C3d,aTolreached);
2907 Standard_Integer Icurv = DStr.AddCurve(Crv);
2908 Interfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv,indpoint1,p1, Standard_False);
2909 Interfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv,indpoint2,p2, Standard_False);
2910 Interfc = ChFi3d_FilCurveInDS(Icurv,Isurf,Ps,orcourbe);
2911 DStr.ChangeCurveInterferences(Icurv).Append(Interfp1);
2912 DStr.ChangeCurveInterferences(Icurv).Append(Interfp2);
2913 DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc);
2916 aSurf = DStr.Surface(SDprev->Surf()).Surface();
2917 UV1.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2918 UV2.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2920 ChFi3d_ComputePCurv(C3d,UV1,UV2,Pc,aSurf,p1,p2,tolesp,aTolreached);
2922 Crv.Tolerance(Max(Crv.Tolerance(),aTolreached));
2923 Interfc= ChFi3d_FilCurveInDS (Icurv,IsurfPrev,Pc,TopAbs::Reverse(orcourbe));
2924 DStr.ChangeSurfaceInterferences(IsurfPrev).Append(Interfc);
2926 //UV = isOnSame1 ? UV2 : UV1;
2927 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2928 //UV = Ps->Value(isOnSame1 ? p2 : p1);
2929 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2930 //ChFi3d_SetPointTolerance(DStr,box, isOnSame1 ? indpoint2 : indpoint1);
2932 // to process properly this case in ChFi3d_FilDS()
2933 stripe->InDS(isfirst, 2);
2934 Fd->ChangeInterference(isOnSame1 ? 2 : 1).SetLineIndex(0);
2935 ChFiDS_CommonPoint& CPprev1 = SDprev->ChangeVertex( isfirst,isOnSame1 ? 2 : 1);
2936 ChFiDS_CommonPoint& CPlast1 = Fd-> ChangeVertex( isfirst,isOnSame1 ? 2 : 1);
2937 ChFiDS_CommonPoint& CPlast2 = Fd-> ChangeVertex(!isfirst,isOnSame1 ? 2 : 1);
2938 if (CPprev1.IsOnArc()) {
2941 CPprev1.SetPoint(CPlast1.Point());
2943 CPlast2.SetPoint(CPlast1.Point());
2946 // in shrink case, self intersection is possible at <midIpoint>,
2947 // eval its tolerance intersecting Ps and Pcurve at end.
2948 // Find end curves closest to shrinked part
2949 for (nb=0; nb < nbface; nb++)
2950 if (isOnSame1 ? shrink [nb+1] : !shrink [nb]) break;
2951 Handle(Geom_Curve) Cend = DStr.Curve(indcurve[nb]).Curve();
2952 Handle(Geom2d_Curve) PCend = InterfPS[nb]->PCurve();
2953 // point near which self intersection may occure
2954 TopOpeBRepDS_Point& Pds = DStr.ChangePoint(midIpoint);
2955 const gp_Pnt& Pvert = Pds.Point();
2956 Standard_Real tol = Pds.Tolerance();
2958 Geom2dAdaptor_Curve PC1(Ps), PC2(PCend);
2959 Geom2dInt_GInter Intersector(PC1,PC2,Precision::PConfusion(),Precision::PConfusion());
2960 if (!Intersector.IsDone()) return;
2961 for (nb=1; nb <= Intersector.NbPoints(); nb++) {
2962 const IntRes2d_IntersectionPoint& ip = Intersector.Point(nb);
2963 gp_Pnt Pint = C3d->Value(ip.ParamOnFirst());
2964 tol = Max(tol, Pvert.Distance(Pint));
2965 Pint = Cend->Value(ip.ParamOnSecond());
2966 tol = Max(tol, Pvert.Distance(Pint));
2968 for (nb=1; nb <= Intersector.NbSegments(); nb++) {
2969 const IntRes2d_IntersectionSegment& is = Intersector.Segment(nb);
2970 if (is.HasFirstPoint()) {
2971 const IntRes2d_IntersectionPoint& ip = is.FirstPoint();
2972 gp_Pnt Pint = C3d->Value(ip.ParamOnFirst());
2973 tol = Max(tol, Pvert.Distance(Pint));
2974 Pint = Cend->Value(ip.ParamOnSecond());
2975 tol = Max(tol, Pvert.Distance(Pint));
2977 if (is.HasLastPoint()) {
2978 const IntRes2d_IntersectionPoint& ip = is.LastPoint();
2979 gp_Pnt Pint = C3d->Value(ip.ParamOnFirst());
2980 tol = Max(tol, Pvert.Distance(Pint));
2981 Pint = Cend->Value(ip.ParamOnSecond());
2982 tol = Max(tol, Pvert.Distance(Pint));
2989 // Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 Begin
2991 //=======================================================================
2992 //function : PerformMoreSurfdata
2993 //purpose : determine intersections at end on several surfdata
2994 //=======================================================================
2995 void ChFi3d_Builder::PerformMoreSurfdata(const Standard_Integer Index)
2997 TopOpeBRepDS_DataStructure &DStr = myDS->ChangeDS();
2998 const ChFiDS_ListOfStripe &aLOfStripe = myVDataMap(Index);
2999 Handle(ChFiDS_Stripe) aStripe;
3000 Handle(ChFiDS_Spine) aSpine;
3001 Standard_Real aTol3d = 1.e-4;
3004 if (aLOfStripe.IsEmpty())
3007 aStripe = aLOfStripe.First();
3008 aSpine = aStripe->Spine();
3010 ChFiDS_SequenceOfSurfData &aSeqSurfData =
3011 aStripe->ChangeSetOfSurfData()->ChangeSequence();
3012 const TopoDS_Vertex &aVtx = myVDataMap.FindKey(Index);
3013 Standard_Integer aSens = 0;
3014 Standard_Integer anInd =
3015 ChFi3d_IndexOfSurfData(aVtx,aStripe,aSens);
3016 Standard_Boolean isFirst = (aSens == 1);
3017 Standard_Integer anIndPrev;
3018 Handle(ChFiDS_SurfData) aSurfData;
3019 ChFiDS_CommonPoint aCP1;
3020 ChFiDS_CommonPoint aCP2;
3022 aSurfData = aSeqSurfData.Value(anInd);
3024 aCP1 = aSurfData->Vertex(isFirst,1);
3025 aCP2 = aSurfData->Vertex(isFirst,2);
3027 Handle(Geom_Surface) aSurfPrev;
3028 Handle(Geom_Surface) aSurf;
3030 TopoDS_Face aNeighborFace;
3032 FindFace(aVtx, aCP1, aCP2, aFace);
3033 aSurfPrev = BRep_Tool::Surface(aFace);
3035 if (aSens==1) anIndPrev=anInd+1;
3036 else anIndPrev=anInd-1;
3040 TopTools_ListIteratorOfListOfShape anIter(myVEMap(aVtx));
3041 Standard_Boolean isFound = Standard_False;
3043 for(; anIter.More() && !isFound; anIter.Next()) {
3044 anArc1 = TopoDS::Edge(anIter.Value());
3046 if (containE(aFace, anArc1))
3047 isFound = Standard_True;
3050 isFound = Standard_False;
3051 anIter.Initialize(myVEMap(aVtx));
3053 for(; anIter.More() && !isFound; anIter.Next()) {
3054 anArc2 = TopoDS::Edge(anIter.Value());
3056 if (containE(aFace,anArc2) && !anArc2.IsSame(anArc1))
3057 isFound = Standard_True;
3060 // determination of common points aCP1onArc, aCP2onArc and aCP2NotonArc
3061 // aCP1onArc is the point on arc of index anInd
3062 // aCP2onArc is the point on arc of index anIndPrev
3063 // aCP2NotonArc is the point of index anIndPrev which is not on arc.
3065 Standard_Boolean is1stCP1OnArc;
3066 Standard_Boolean is2ndCP1OnArc;
3067 ChFiDS_CommonPoint aCP1onArc;
3068 ChFiDS_CommonPoint aCP2onArc;
3069 ChFiDS_CommonPoint aCP2NotonArc;
3071 aSurfData = aSeqSurfData.Value(anIndPrev);
3072 aCP1 = aSurfData->Vertex(isFirst,1);
3073 aCP2 = aSurfData->Vertex(isFirst,2);
3075 if (aCP1.IsOnArc() &&
3076 (aCP1.Arc().IsSame(anArc1) || aCP1.Arc().IsSame(anArc2))) {
3078 aCP2NotonArc = aCP2;
3079 is2ndCP1OnArc = Standard_True;
3080 } else if (aCP2.IsOnArc() &&
3081 (aCP2.Arc().IsSame(anArc1) || aCP2.Arc().IsSame(anArc2))) {
3083 aCP2NotonArc = aCP1;
3084 is2ndCP1OnArc = Standard_False;
3088 aSurfData = aSeqSurfData.Value(anInd);
3089 aCP1 = aSurfData->Vertex(isFirst,1);
3090 aCP2 = aSurfData->Vertex(isFirst,2);
3092 if (aCP1.Point().Distance(aCP2onArc.Point()) <= aTol3d){
3094 is1stCP1OnArc = Standard_False;
3098 is1stCP1OnArc = Standard_True;
3101 if (!aCP1onArc.IsOnArc())
3104 // determination of neighbor surface
3105 Standard_Integer indSurface;
3107 indSurface = myListStripe.First()->SetOfSurfData()->Value(anInd)->IndexOfS1();
3109 indSurface = myListStripe.First()->SetOfSurfData()->Value(anInd)->IndexOfS2();
3111 aNeighborFace = TopoDS::Face(myDS->Shape(indSurface));
3113 // calculation of intersections
3114 Handle(Geom_Curve) aCracc;
3115 Handle(Geom2d_Curve) aPCurv1;
3116 Standard_Real aParf;
3117 Standard_Real aParl;
3118 Standard_Real aTolReached;
3120 aSurfData = aSeqSurfData.Value(anInd);
3123 ChFi3d_ComputeArete(aSurfData->VertexLastOnS1(),
3124 aSurfData->InterferenceOnS1().PCurveOnSurf()->
3125 Value(aSurfData->InterferenceOnS1().LastParameter()),
3126 aSurfData->VertexLastOnS2(),
3127 aSurfData->InterferenceOnS2().PCurveOnSurf()->
3128 Value(aSurfData->InterferenceOnS2().LastParameter()),
3129 DStr.Surface(aSurfData->Surf()).Surface(),aCracc,aPCurv1,
3130 aParf,aParl,aTol3d,tol2d,aTolReached,0);
3132 ChFi3d_ComputeArete(aSurfData->VertexFirstOnS1(),
3133 aSurfData->InterferenceOnS1().PCurveOnSurf()->
3134 Value(aSurfData->InterferenceOnS1().FirstParameter()),
3135 aSurfData->VertexFirstOnS2(),
3136 aSurfData->InterferenceOnS2().PCurveOnSurf()->
3137 Value(aSurfData->InterferenceOnS2().FirstParameter()),
3138 DStr.Surface(aSurfData->Surf()).Surface(),aCracc,aPCurv1,
3139 aParf,aParl,aTol3d,tol2d,aTolReached,0);
3141 // calculation of the index of the line on anInd.
3142 // aPClineOnSurf is the pcurve on anInd.
3143 // aPClineOnFace is the pcurve on face.
3144 ChFiDS_FaceInterference aFI;
3147 aFI = aSurfData->InterferenceOnS1();
3149 aFI = aSurfData->InterferenceOnS2();
3151 Handle(Geom_Curve) aCline;
3152 Handle(Geom2d_Curve) aPClineOnSurf;
3153 Handle(Geom2d_Curve) aPClineOnFace;
3154 Standard_Integer indLine;
3156 indLine = aFI.LineIndex();
3157 aCline = DStr.Curve(aFI.LineIndex()).Curve();
3158 aPClineOnSurf = aFI.PCurveOnSurf();
3159 aPClineOnFace = aFI.PCurveOnFace();
3161 // intersection between the SurfData number anInd and the Face aFace.
3162 // Obtaining of curves aCint1, aPCint11 and aPCint12.
3163 aSurf = DStr.Surface(aSurfData->Surf()).Surface();
3165 GeomInt_IntSS anInterSS(aSurfPrev,aSurf,1.e-7,1,1,1);
3166 Handle(Geom_Curve) aCint1;
3167 Handle(Geom2d_Curve) aPCint11;
3168 Handle(Geom2d_Curve) aPCint12;
3169 Handle(GeomAdaptor_HSurface) H1 = new GeomAdaptor_HSurface(aSurfPrev);
3170 Handle(GeomAdaptor_HSurface) H2 = new GeomAdaptor_HSurface(aSurf);
3171 Standard_Real aTolex1=0.;
3176 Standard_Boolean isPextFound;
3179 if (!anInterSS.IsDone())
3182 isFound = Standard_False;
3184 for (i = 1; i <= anInterSS.NbLines() && !isFound; i++) {
3185 aCint1 = anInterSS.Line(i);
3186 aPCint11 = anInterSS.LineOnS1(i);
3187 aPCint12 = anInterSS.LineOnS2(i);
3188 aTolex1 = ChFi3d_EvalTolReached(H1, aPCint11, H2, aPCint12, aCint1);
3190 aCint1->D0(aCint1->FirstParameter(), aPext1);
3191 aCint1->D0(aCint1->LastParameter(), aPext2);
3193 // Modified by skv - Mon Jun 7 18:38:57 2004 OCC5898 Begin
3194 // if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d ||
3195 // aPext2.Distance(aCP1onArc.Point()))
3196 if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d ||
3197 aPext2.Distance(aCP1onArc.Point()) <= aTol3d)
3198 // Modified by skv - Mon Jun 7 18:38:58 2004 OCC5898 End
3199 isFound = Standard_True;
3205 if (aPext1.Distance(aCP2onArc.Point()) > aTol3d &&
3206 aPext1.Distance(aCP1onArc.Point()) > aTol3d) {
3208 isPextFound = Standard_True;
3209 } else if (aPext2.Distance(aCP2onArc.Point()) > aTol3d &&
3210 aPext2.Distance(aCP1onArc.Point()) > aTol3d) {
3212 isPextFound = Standard_True;
3214 isPextFound = Standard_False;
3218 Standard_Boolean isDoSecondSection = Standard_False;
3219 Standard_Real aPar=0.;
3222 GeomAdaptor_Curve aCad(aCracc);
3223 Extrema_ExtPC anExt(aPext, aCad, aTol3d);
3225 if (!anExt.IsDone())
3228 isFound = Standard_False;
3229 for (i = 1; i <= anExt.NbExt() && !isFound; i++) {
3230 if (anExt.IsMin(i)) {
3231 gp_Pnt aProjPnt = anExt.Point(i).Value();
3233 if (aPext.Distance(aProjPnt) <= aTol3d) {
3234 aPar = anExt.Point(i).Parameter();
3235 isDoSecondSection = Standard_True;
3241 Handle(Geom_Curve) aTrCracc;
3242 TopAbs_Orientation anOrSD1;
3243 TopAbs_Orientation anOrSD2;
3244 Standard_Integer indShape;
3246 anOrSD1 = aSurfData->Orientation();
3247 aSurfData = aSeqSurfData.Value(anIndPrev);
3248 anOrSD2 = aSurfData->Orientation();
3249 aSurf = DStr.Surface(aSurfData->Surf()).Surface();
3251 // The following variables will be used if isDoSecondSection is true
3252 Handle(Geom_Curve) aCint2;
3253 Handle(Geom2d_Curve) aPCint21;
3254 Handle(Geom2d_Curve) aPCint22;
3255 Standard_Real aTolex2=0.;
3257 if (isDoSecondSection) {
3258 Standard_Real aPar1;
3260 aCracc->D0(aCracc->FirstParameter(), aPext1);
3262 if (aPext1.Distance(aCP2NotonArc.Point()) <= aTol3d)
3263 aPar1 = aCracc->FirstParameter();
3265 aPar1 = aCracc->LastParameter();
3268 aTrCracc = new Geom_TrimmedCurve (aCracc, aPar1, aPar);
3270 aTrCracc = new Geom_TrimmedCurve (aCracc, aPar, aPar1);
3273 GeomInt_IntSS anInterSS2(aSurfPrev,aSurf,1.e-7,1,1,1);
3275 if (!anInterSS2.IsDone())
3278 H1 = new GeomAdaptor_HSurface(aSurfPrev);
3279 H2 = new GeomAdaptor_HSurface(aSurf);
3281 isFound = Standard_False;
3283 for (i = 1; i <= anInterSS2.NbLines() && !isFound; i++) {
3284 aCint2 = anInterSS2.Line(i);
3285 aPCint21 = anInterSS2.LineOnS1(i);
3286 aPCint22 = anInterSS2.LineOnS2(i);
3287 aTolex2 = ChFi3d_EvalTolReached(H1, aPCint21, H2, aPCint22, aCint2);
3289 aCint2->D0(aCint2->FirstParameter(), aPext1);
3290 aCint2->D0(aCint2->LastParameter(), aPext2);
3292 if (aPext1.Distance(aCP2onArc.Point()) <= aTol3d ||
3293 aPext2.Distance(aCP2onArc.Point()) <= aTol3d)
3294 isFound = Standard_True;
3301 aTrCracc = new Geom_TrimmedCurve(aCracc,
3302 aCracc->FirstParameter(),
3303 aCracc->LastParameter());
3306 // Storage of the data structure
3308 // calculation of the orientation of line of surfdata number
3309 // anIndPrev which contains aCP2onArc
3311 Handle(Geom2d_Curve) aPCraccS = GeomProjLib::Curve2d(aTrCracc,aSurf);
3313 if (is2ndCP1OnArc) {
3314 aFI = aSurfData->InterferenceOnS1();
3315 indShape = aSurfData->IndexOfS1();
3317 aFI = aSurfData->InterferenceOnS2();
3318 indShape = aSurfData->IndexOfS2();
3326 TopAbs_Orientation aCurOrient;
3328 aCurOrient = DStr.Shape(indShape).Orientation();
3329 aCurOrient = TopAbs::Compose(aCurOrient, aSurfData->Orientation());
3330 aCurOrient = TopAbs::Compose(TopAbs::Reverse(aFI.Transition()), aCurOrient);
3333 // Filling the data structure
3334 aSurfData = aSeqSurfData.Value(anInd);
3336 TopOpeBRepDS_Point aPtCP1(aCP1onArc.Point(),aCP1onArc.Tolerance());
3337 Standard_Integer indCP1onArc = DStr.AddPoint(aPtCP1);
3338 Standard_Integer indSurf1 = aSurfData->Surf();
3339 Standard_Integer indArc1 = DStr.AddShape(aCP1onArc.Arc());
3340 Standard_Integer indSol = aStripe->SolidIndex();
3342 Handle (TopOpeBRepDS_CurvePointInterference) anInterfp1;
3343 Handle (TopOpeBRepDS_CurvePointInterference) anInterfp2;
3345 anInterfp1= ChFi3d_FilPointInDS(aCP1onArc.TransitionOnArc(), indArc1,
3346 indCP1onArc, aCP1onArc.ParameterOnArc());
3347 DStr.ChangeShapeInterferences(aCP1onArc.Arc()).Append(anInterfp1);
3349 TopOpeBRepDS_ListOfInterference &SolidInterfs =
3350 DStr.ChangeShapeInterferences(indSol);
3351 Handle(TopOpeBRepDS_SolidSurfaceInterference) SSI =
3352 new TopOpeBRepDS_SolidSurfaceInterference
3353 (TopOpeBRepDS_Transition(anOrSD1),
3354 TopOpeBRepDS_SOLID, indSol,
3355 TopOpeBRepDS_SURFACE, indSurf1);
3356 SolidInterfs.Append(SSI);
3358 // deletion of Surface Data.
3359 aSeqSurfData.Remove(anInd);
3364 aSurfData = aSeqSurfData.Value(anInd);
3366 // definition of indices of common points in Data Structure
3368 Standard_Integer indCP2onArc;
3369 Standard_Integer indCP2NotonArc;
3371 if (is2ndCP1OnArc) {
3372 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2onArc, DStr),isFirst,1);
3373 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2NotonArc,DStr),isFirst,2);
3376 indCP2onArc = aStripe->IndexFirstPointOnS1();
3377 indCP2NotonArc = aStripe->IndexFirstPointOnS2();
3379 indCP2onArc = aStripe->IndexLastPointOnS1();
3380 indCP2NotonArc = aStripe->IndexLastPointOnS2();
3383 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2onArc, DStr),isFirst,2);
3384 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2NotonArc,DStr),isFirst,1);
3387 indCP2onArc = aStripe->IndexFirstPointOnS2();
3388 indCP2NotonArc = aStripe->IndexFirstPointOnS1();
3391 indCP2onArc = aStripe->IndexLastPointOnS2();
3392 indCP2NotonArc = aStripe->IndexLastPointOnS1();
3396 Standard_Integer indPoint1;
3397 Standard_Integer indPoint2;
3401 if (is2ndCP1OnArc) {
3402 aFI = aSurfData->InterferenceOnS1();
3403 indShape = aSurfData->IndexOfS1();
3405 aFI = aSurfData->InterferenceOnS2();
3406 indShape = aSurfData->IndexOfS2();
3410 Handle (TopOpeBRepDS_SurfaceCurveInterference) anInterfc;
3411 TopAbs_Orientation anOrSurf = aCurOrient;
3412 TopAbs_Orientation anOrFace = aFace.Orientation();
3413 Standard_Integer indaFace = DStr.AddShape(aFace);
3414 Standard_Integer indPoint = indCP2onArc;
3415 Standard_Integer indCurve;
3417 aFI.PCurveOnFace()->D0(aFI.LastParameter(), aP2d);
3418 Handle(Geom_Surface) Stemp2 =
3419 BRep_Tool::Surface(TopoDS::Face(DStr.Shape(indShape)));
3420 Stemp2->D0(aP2d.X(), aP2d.Y(), aPoint2);
3421 aFI.PCurveOnFace()->D0(aFI.FirstParameter(), aP2d);
3422 Stemp2->D0(aP2d.X(), aP2d.Y(), aPoint1);
3424 if (isDoSecondSection) {
3425 TopOpeBRepDS_Point tpoint(aPext, aTolex2);
3426 TopOpeBRepDS_Curve tcint2(aCint2, aTolex2);
3428 indPoint = DStr.AddPoint(tpoint);
3429 indCurve = DStr.AddCurve(tcint2);
3431 aCint2->D0(aCint2->FirstParameter(), aPext1);
3432 aCint2->D0(aCint2->LastParameter(), aPext2);
3434 if (aPext1.Distance(aPext) <= aTol3d){
3435 indPoint1 = indPoint;
3436 indPoint2 = indCP2onArc;
3438 indPoint1 = indCP2onArc;
3439 indPoint2 = indPoint;
3442 // define the orientation of aCint2
3443 if (aPext1.Distance(aPoint2) > aTol3d && aPext2.Distance(aPoint1) > aTol3d)
3444 anOrSurf = TopAbs::Reverse(anOrSurf);
3446 // ---------------------------------------------------------------
3447 // storage of aCint2
3448 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD, indCurve,
3449 indPoint1, aCint2->FirstParameter());
3450 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED, indCurve,
3451 indPoint2, aCint2->LastParameter());
3452 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3453 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3455 // interference of aCint2 on the SurfData number anIndPrev
3456 anInterfc = ChFi3d_FilCurveInDS(indCurve, aSurfData->Surf(),
3457 aPCint22, anOrSurf);
3459 DStr.ChangeSurfaceInterferences(aSurfData->Surf()).Append(anInterfc);
3460 // interference of aCint2 on aFace
3462 if (anOrFace == anOrSD2)
3463 anOrFace = TopAbs::Reverse(anOrSurf);
3465 anOrFace = anOrSurf;
3467 anInterfc = ChFi3d_FilCurveInDS(indCurve, indaFace, aPCint21, anOrFace);
3468 DStr.ChangeShapeInterferences(indaFace).Append(anInterfc);
3471 aTrCracc->D0(aTrCracc->FirstParameter(), aPext1);
3472 aTrCracc->D0(aTrCracc->LastParameter(), aPext2);
3473 if (aPext1.Distance(aCP2NotonArc.Point()) <= aTol3d){
3474 indPoint1 = indCP2NotonArc;
3475 indPoint2 = indPoint;
3477 indPoint1 = indPoint;
3478 indPoint2 = indCP2NotonArc;
3481 // Define the orientation of aTrCracc
3482 Standard_Boolean isToReverse;
3489 if (isDoSecondSection) {
3490 aTrCracc->D0(aTrCracc->FirstParameter(), aP1);
3491 aTrCracc->D0(aTrCracc->LastParameter(), aP2);
3492 aCint2->D0(aCint2->FirstParameter(), aP3);
3493 aCint2->D0(aCint2->LastParameter(), aP4);
3494 isToReverse = (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d);
3496 isToReverse = (aPext1.Distance(aPoint2) > aTol3d &&
3497 aPext2.Distance(aPoint1) > aTol3d);
3501 anOrSurf = TopAbs::Reverse(anOrSurf);
3503 // ---------------------------------------------------------------
3504 // storage of aTrCracc
3505 TopOpeBRepDS_Curve tct2(aTrCracc, aTolReached);
3507 indCurve = DStr.AddCurve(tct2);
3508 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,indCurve,
3509 indPoint1, aTrCracc->FirstParameter());
3510 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED,indCurve,
3511 indPoint2, aTrCracc->LastParameter());
3512 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3513 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3515 // interference of aTrCracc on the SurfData number anIndPrev
3517 anInterfc = ChFi3d_FilCurveInDS(indCurve,aSurfData->Surf(),aPCraccS, anOrSurf);
3518 DStr.ChangeSurfaceInterferences(aSurfData->Surf()).Append(anInterfc);
3519 aStripe->InDS(isFirst);
3521 // interference of aTrCracc on the SurfData number anInd
3522 if (anOrSD1 == anOrSD2)
3523 anOrSurf = TopAbs::Reverse(anOrSurf);
3525 anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPCurv1, anOrSurf);
3526 DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc);
3528 // ---------------------------------------------------------------
3529 // storage of aCint1
3531 aCint1->D0(aCint1->FirstParameter(),aPext1);
3532 if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d){
3533 indPoint1 = indCP1onArc;
3534 indPoint2 = indPoint;
3536 indPoint1 = indPoint;
3537 indPoint2 = indCP1onArc;
3540 // definition of the orientation of aCint1
3542 aCint1->D0(aCint1->FirstParameter(), aP1);
3543 aCint1->D0(aCint1->LastParameter(), aP2);
3544 aTrCracc->D0(aTrCracc->FirstParameter(), aP3);
3545 aTrCracc->D0(aTrCracc->LastParameter(), aP4);
3547 if (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d)
3548 anOrSurf=TopAbs::Reverse(anOrSurf);
3550 TopOpeBRepDS_Curve aTCint1(aCint1, aTolex1);
3551 indCurve= DStr.AddCurve(aTCint1);
3552 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD, indCurve,
3553 indPoint1, aCint1->FirstParameter());
3554 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED, indCurve,
3555 indPoint2, aCint1->LastParameter());
3556 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3557 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3559 // interference of aCint1 on the SurfData number anInd
3561 anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPCint12, anOrSurf);
3562 DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc);
3564 // interference of aCint1 on aFace
3566 anOrFace = aFace.Orientation();
3568 if (anOrFace == anOrSD1)
3569 anOrFace = TopAbs::Reverse(anOrSurf);
3571 anOrFace = anOrSurf;
3573 anInterfc = ChFi3d_FilCurveInDS(indCurve, indaFace, aPCint11, anOrFace);
3574 DStr.ChangeShapeInterferences(indaFace).Append(anInterfc);
3575 // ---------------------------------------------------------------
3576 // storage of aCline passing through aCP1onArc and aCP2NotonArc
3578 Handle(Geom_Curve) aTrCline =
3579 new Geom_TrimmedCurve(aCline, aCline->FirstParameter(),
3580 aCline->LastParameter());
3581 Standard_Real aTolerance = DStr.Curve(indLine).Tolerance();
3582 TopOpeBRepDS_Curve aTct3(aTrCline, aTolerance);
3584 indCurve = DStr.AddCurve(aTct3);
3586 aTrCline->D0(aTrCline->FirstParameter(),aPext1);
3588 if (aPext1.Distance(aCP1onArc.Point()) < aTol3d) {
3589 indPoint1 = indCP1onArc;
3590 indPoint2 = indCP2NotonArc;
3592 indPoint1 = indCP2NotonArc;
3593 indPoint2 = indCP1onArc;
3595 // definition of the orientation of aTrCline
3597 aTrCline->D0(aTrCline->FirstParameter(), aP1);
3598 aTrCline->D0(aTrCline->LastParameter(), aP2);
3599 aCint1->D0(aCint1->FirstParameter(), aP3);
3600 aCint1->D0(aCint1->LastParameter(), aP4);
3602 if (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d)
3603 anOrSurf = TopAbs::Reverse(anOrSurf);
3605 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,indCurve,
3606 indPoint1,aTrCline->FirstParameter());
3607 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED,indCurve,
3608 indPoint2,aTrCline->LastParameter());
3609 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3610 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3612 // interference of aTrCline on the SurfData number anInd
3614 anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPClineOnSurf, anOrSurf);
3615 DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc);
3617 // interference de ctlin par rapport a Fvoisin
3618 indShape = DStr.AddShape(aNeighborFace);
3619 anOrFace = aNeighborFace.Orientation();
3621 if (anOrFace == anOrSD1)
3622 anOrFace = TopAbs::Reverse(anOrSurf);
3624 anOrFace = anOrSurf;
3626 anInterfc = ChFi3d_FilCurveInDS(indCurve, indShape, aPClineOnFace, anOrFace);
3627 DStr.ChangeShapeInterferences(indShape).Append(anInterfc);
3629 // Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 End
3631 //==============================================================
3632 //function : FindFace
3633 //purpose : attention it works only if there is only one common face
3635 //===========================================================
3638 Standard_Boolean ChFi3d_Builder::FindFace(const TopoDS_Vertex& V,
3639 const ChFiDS_CommonPoint& P1,
3640 const ChFiDS_CommonPoint& P2,
3641 TopoDS_Face& Fv) const
3644 return FindFace(V,P1,P2,Fv,Favoid);
3647 Standard_Boolean ChFi3d_Builder::FindFace(const TopoDS_Vertex& V,
3648 const ChFiDS_CommonPoint& P1,
3649 const ChFiDS_CommonPoint& P2,
3651 const TopoDS_Face& Favoid) const
3653 if (P1.IsVertex() || P2.IsVertex()) {
3655 cout<<"change of face on vertex"<<endl;
3658 if (!(P1.IsOnArc() && P2.IsOnArc())) {
3659 return Standard_False;
3661 TopTools_ListIteratorOfListOfShape It,Jt;
3662 Standard_Boolean Found = Standard_False, ContainsV = Standard_False;
3663 for(It.Initialize(myEFMap(P1.Arc()));It.More() && !Found;It.Next()) {
3664 Fv = TopoDS::Face(It.Value());
3665 if(!Fv.IsSame(Favoid)){
3666 for(Jt.Initialize(myEFMap(P2.Arc()));Jt.More() && !Found ;Jt.Next()) {
3667 if (TopoDS::Face(Jt.Value()).IsSame(Fv)) Found = Standard_True;
3672 for(It.Initialize(myVFMap(V));It.More();It.Next()) {
3673 if (TopoDS::Face(It.Value()).IsSame(Fv)) {
3674 ContainsV = Standard_True;
3681 cout<<"FindFace : the extremity of the spine is not in the end face"<<endl;
3687 //=======================================================================
3688 //function : MoreSurfdata
3689 //purpose : detects if the intersection at end concerns several Surfdata
3690 //=======================================================================
3691 Standard_Boolean ChFi3d_Builder::MoreSurfdata(const Standard_Integer Index) const
3693 // intersection at end is created on several surfdata if :
3694 // - the number of surfdata concerning the vertex is more than 1.
3695 // - and if the last but one surfdata has one of commonpoints on one of
3696 // two arcs, which constitute the intersections of the face at end and of the fillet
3698 ChFiDS_ListIteratorOfListOfStripe It;
3699 It.Initialize(myVDataMap(Index));
3700 Handle(ChFiDS_Stripe)& stripe = It.Value();
3701 ChFiDS_SequenceOfSurfData& SeqFil =
3702 stripe->ChangeSetOfSurfData()->ChangeSequence();
3703 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
3704 Standard_Integer sens = 0;
3705 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
3706 Standard_Boolean isfirst = (sens == 1);
3707 Handle(ChFiDS_SurfData)& Fd = SeqFil.ChangeValue(num);
3708 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
3709 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
3711 Standard_Integer num1,num2,nbsurf;
3713 Standard_Boolean inters,oksurf;
3714 nbsurf= stripe->SetOfSurfData()->Length();
3715 // Fv is the face at end
3716 inters = FindFace(Vtx,CV1,CV2,Fv);
3726 oksurf=Standard_False;
3728 if (nbsurf!=1 && inters) {
3730 // determination of arc1 and arc2 intersection of the fillet and the face at end
3732 TopoDS_Edge arc1,arc2;
3733 TopTools_ListIteratorOfListOfShape ItE;
3734 Standard_Boolean trouve=Standard_False;
3735 for(ItE.Initialize(myVEMap(Vtx));ItE.More()&&!trouve;ItE.Next()) {
3736 arc1=TopoDS::Edge(ItE.Value());
3737 if (containE(Fv,arc1)) trouve=Standard_True;
3739 trouve=Standard_False;
3740 for(ItE.Initialize(myVEMap(Vtx));ItE.More()&&!trouve;ItE.Next()) {
3741 arc2=TopoDS::Edge(ItE.Value());
3742 if (containE(Fv,arc2)&& !arc2.IsSame(arc1)) trouve=Standard_True;
3745 Handle(ChFiDS_SurfData) Fd1 = SeqFil.ChangeValue(num2);
3746 ChFiDS_CommonPoint& CV3 = Fd1->ChangeVertex(isfirst,1);
3747 ChFiDS_CommonPoint& CV4 = Fd1->ChangeVertex(isfirst,2);
3749 if (CV3.IsOnArc()) {
3750 if (CV3.Arc().IsSame(arc1) ){
3751 if (CV1.Point().Distance(CV3.Point())<1.e-4)
3752 oksurf=Standard_True;
3754 else if (CV3.Arc().IsSame(arc2)){
3755 if (CV2.Point().Distance(CV3.Point())<1.e-4)
3756 oksurf=Standard_True;
3760 if (CV4.IsOnArc()) {
3761 if (CV1.Point().Distance(CV4.Point())<1.e-4)
3762 oksurf=Standard_True;
3763 else if (CV4.Arc().IsSame(arc2)){
3764 if (CV2.Point().Distance(CV4.Point())<1.e-4)
3765 oksurf=Standard_True;
3773 //Case of fillets on top with 4 edges, one of them is on the same geometry as the edgeof the fillet
3776 void ChFi3d_Builder::IntersectMoreCorner(const Standard_Integer Index)
3778 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
3781 OSD_Chronometer ch;// init perf pour PerformSetOfKPart
3783 // The fillet is returned,
3784 ChFiDS_ListIteratorOfListOfStripe StrIt;
3785 StrIt.Initialize(myVDataMap(Index));
3786 Handle(ChFiDS_Stripe) stripe = StrIt.Value();
3787 const Handle(ChFiDS_Spine) spine = stripe->Spine();
3788 ChFiDS_SequenceOfSurfData& SeqFil =
3789 stripe->ChangeSetOfSurfData()->ChangeSequence();
3791 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
3792 // the SurfData concerned and its CommonPoints,
3793 Standard_Integer sens = 0;
3795 // Choose the proper SurfData
3796 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
3797 Standard_Boolean isfirst = (sens == 1);
3799 for (; num<SeqFil.Length() && (
3800 (SeqFil.Value(num)->IndexOfS1()==0) ||
3801 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
3802 SeqFil.Remove(num); // The surplus is removed
3807 (SeqFil.Value(num)->IndexOfS1()==0) ||
3808 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
3809 SeqFil.Remove(num);// The surplus is removed
3814 Handle(ChFiDS_SurfData)& Fd = SeqFil.ChangeValue(num);
3815 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
3816 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
3817 //To evaluate the cloud of new points.
3820 // The cases of cap are processed separately from intersection.
3821 // ----------------------------------------------------------
3823 TopoDS_Face Fv,Fad,Fop,Fopbis;
3824 TopoDS_Edge Arcpiv,Arcprol,Arcspine,Arcprolbis;
3825 if(isfirst) Arcspine = spine->Edges(1);
3826 else Arcspine = spine->Edges(spine->NbEdges());
3827 TopAbs_Orientation OArcprolbis;
3829 TopAbs_Orientation OArcprolv = TopAbs_FORWARD, OArcprolop = TopAbs_FORWARD;
3831 TopAbs_Orientation OArcprolv, OArcprolop;
3833 Standard_Integer ICurve;
3834 Handle(BRepAdaptor_HSurface) HBs = new BRepAdaptor_HSurface();
3835 Handle(BRepAdaptor_HSurface) HBad = new BRepAdaptor_HSurface();
3836 Handle(BRepAdaptor_HSurface) HBop = new BRepAdaptor_HSurface();
3837 BRepAdaptor_Surface& Bs = HBs->ChangeSurface();
3838 BRepAdaptor_Surface& Bad = HBad->ChangeSurface();
3839 BRepAdaptor_Surface& Bop = HBop->ChangeSurface();
3840 Handle(Geom_Curve) Cc;
3841 Handle(Geom2d_Curve) Pc,Ps;
3842 Standard_Real Ubid,Vbid;//,mu,Mu,mv,Mv;
3844 Standard_Real Udeb = 0.,Ufin = 0.;
3846 Standard_Real Udeb,Ufin;
3848 //gp_Pnt2d UVf1,UVl1,UVf2,UVl2;
3849 //Standard_Real Du,Dv,Step;
3850 Standard_Boolean inters = Standard_True;
3851 Standard_Integer IFadArc = 1, IFopArc = 2;
3852 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
3856 ChFi3d_InitChron(ch); // init perf condition
3859 if(!CV1.IsOnArc() && !CV2.IsOnArc())
3860 Standard_Failure::Raise("Corner intersmore : no point on arc");
3861 else if(CV1.IsOnArc() && CV2.IsOnArc()){
3862 Standard_Boolean sur1 = 0, sur2 = 0;
3863 for(ex.Init(CV1.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()){
3864 if(Vtx.IsSame(ex.Current())) {
3869 for(ex.Init(CV2.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()){
3870 if(Vtx.IsSame(ex.Current())){
3875 if(sur2) IFadArc = 2;
3877 else if(CV2.IsOnArc()) IFadArc = 2;
3878 IFopArc = 3-IFadArc;
3880 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
3881 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
3882 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
3883 TopTools_ListIteratorOfListOfShape It;
3884 // The face at end is returned without control of its unicity.
3885 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
3886 if(!Fad.IsSame(It.Value())){
3887 Fv = TopoDS::Face(It.Value());
3892 // does the face at end contain the Vertex ?
3893 Standard_Boolean isinface = Standard_False;
3894 for (ex.Init(Fv,TopAbs_VERTEX); ex.More(); ex.Next()){
3895 if (ex.Current().IsSame(Vtx)) {
3896 isinface = Standard_True;
3901 IFadArc = 3-IFadArc;
3902 IFopArc = 3-IFopArc;
3903 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
3904 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
3905 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
3906 //TopTools_ListIteratorOfListOfShape It;
3907 // The face at end is returned without control of its unicity.
3908 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
3909 if(!Fad.IsSame(It.Value())){
3910 Fv = TopoDS::Face(It.Value());
3916 if(Fv.IsNull()) StdFail_NotDone::Raise
3917 ("OneCorner : face at end is not found");
3919 Fv.Orientation(TopAbs_FORWARD);
3920 Fad.Orientation(TopAbs_FORWARD);
3922 // In the same way the edge to be extended is returned.
3923 for(It.Initialize(myVEMap(Vtx));It.More() && Arcprol.IsNull();It.Next()){
3924 if(!Arcpiv.IsSame(It.Value())){
3925 for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()){
3926 if(It.Value().IsSame(ex.Current())) {
3927 Arcprol = TopoDS::Edge(It.Value());
3928 OArcprolv = ex.Current().Orientation();
3935 //Fopbis is the face containing the trace of fillet CP.Arc() which of does not contain Vtx.
3936 //Normallly Fobis is either the same as Fop (cylinder), or Fobis is G1 with Fop.
3937 Fopbis.Orientation(TopAbs_FORWARD);
3939 //Fop calls the 4th face non-used for the vertex
3940 cherche_face(myVFMap(Vtx),Arcprol,Fad,Fv,Fv,Fopbis);
3941 Fop.Orientation(TopAbs_FORWARD);
3943 if(Arcprol.IsNull()) StdFail_NotDone::Raise
3944 ("OneCorner : edge to be extended is not found");
3945 for(ex.Init(Fopbis,TopAbs_EDGE); ex.More(); ex.Next()){
3946 if(Arcprol.IsSame(ex.Current())) {
3947 OArcprolop = ex.Current().Orientation();
3953 Standard_Integer prol;
3955 Handle(Geom_Surface ) Sface;
3956 Sface=BRep_Tool::Surface(Fv);
3957 ChFi3d_ExtendSurface(Sface,prol);
3958 tol=BRep_Tool::Tolerance(Fv);
3959 BRE.MakeFace(FFv,Sface,tol);
3961 Bs.Initialize(FFv,Standard_False);
3962 DStr.SetNewSurface(Fv,Sface);
3964 else Bs.Initialize(Fv,Standard_False);
3965 Bad.Initialize(Fad);
3966 Bop.Initialize(Fop);
3968 // it is necessary to modify the CommonPoint
3969 // in the space and its parameter in FaceInterference.
3970 // So both of them are returned in references
3971 // non const. Attention the modifications are done behind
3973 ChFiDS_CommonPoint& CPopArc = Fd->ChangeVertex(isfirst,IFopArc);
3974 ChFiDS_FaceInterference& FiopArc = Fd->ChangeInterference(IFopArc);
3975 ChFiDS_CommonPoint& CPadArc = Fd->ChangeVertex(isfirst,IFadArc);
3976 ChFiDS_FaceInterference& FiadArc = Fd->ChangeInterference(IFadArc);
3977 // the parameter of the vertex is initialized with the value
3978 // of its opposing vertex (point on arc).
3979 Standard_Real wop = Fd->ChangeInterference(IFadArc).Parameter(isfirst);
3980 Handle(Geom_Curve) c3df;
3981 Handle(GeomAdaptor_HSurface)
3982 HGs = new GeomAdaptor_HSurface(DStr.Surface(Fd->Surf()).Surface());
3986 // add here more or less restrictive criteria to
3987 // decide if the intersection with face is done at the
3988 // extended end or if there will be a cap on sharp end.
3989 c3df = DStr.Curve(FiopArc.LineIndex()).Curve();
3990 Standard_Real uf = FiopArc.FirstParameter();
3991 Standard_Real ul = FiopArc.LastParameter();
3992 Handle(GeomAdaptor_HCurve) Hc3df;
3993 if(c3df->IsPeriodic()){
3994 Hc3df = new GeomAdaptor_HCurve(c3df);
3997 Hc3df = new GeomAdaptor_HCurve(c3df,uf,ul);
3999 inters = Update(HBs,Hc3df,FiopArc,CPopArc,p2dbout,isfirst,wop);
4000 // Modified by Sergey KHROMOV - Fri Dec 21 18:08:27 2001 Begin
4001 // if(!inters && BRep_Tool::Continuity(Arcprol,Fv,Fop) != GeomAbs_C0){
4002 if(!inters && isTangentFaces(Arcprol,Fv,Fop)){
4003 // Modified by Sergey KHROMOV - Fri Dec 21 18:08:29 2001 End
4004 // Arcprol is an edge of tangency, ultimate adjustment by an extrema curve/curve is attempted.
4005 Standard_Real ff,ll;
4006 Handle(Geom2d_Curve) gpcprol = BRep_Tool::CurveOnSurface(Arcprol,Fv,ff,ll);
4007 Handle(Geom2dAdaptor_HCurve) pcprol = new Geom2dAdaptor_HCurve(gpcprol);
4008 Standard_Real partemp = BRep_Tool::Parameter(Vtx,Arcprol);
4009 inters = Update(HBs,pcprol,HGs,FiopArc,CPopArc,p2dbout,
4010 isfirst,partemp,wop,10*tolesp);
4012 Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
4013 pced->ChangeCurve2d().Initialize(CPadArc.Arc(),Fv);
4014 Update(HBs,pced,HGs,FiadArc,CPadArc,isfirst);
4017 ChFi3d_ResultChron(ch,t_same); // result perf condition if (same)
4018 ChFi3d_InitChron(ch); // init perf condition if (inters)
4021 TopoDS_Edge edgecouture;
4022 Standard_Boolean couture,intcouture=Standard_False;;
4023 Standard_Real tolreached;
4025 Standard_Real par1 = 0.,par2 = 0.;
4026 Standard_Integer indpt =0,Icurv1 =0,Icurv2 =0;
4028 Standard_Real par1,par2;
4029 Standard_Integer indpt,Icurv1,Icurv2;
4031 Handle(Geom_TrimmedCurve) curv1,curv2;
4032 Handle(Geom2d_Curve) c2d1,c2d2;
4034 Standard_Integer Isurf=Fd->Surf();
4037 HGs = ChFi3d_BoundSurf(DStr,Fd,1,2);
4038 const ChFiDS_FaceInterference& Fi1 = Fd->InterferenceOnS1();
4039 const ChFiDS_FaceInterference& Fi2 = Fd->InterferenceOnS2();
4040 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
4041 gp_Pnt2d pfil1,pfac1,pfil2,pfac2;
4042 Handle(Geom2d_Curve) Hc1,Hc2;
4043 if( IFopArc == 1) pfac1 = p2dbout;
4045 Hc1 = BRep_Tool::CurveOnSurface(CV1.Arc(),Fv,Ubid,Ubid);
4046 pfac1 = Hc1->Value(CV1.ParameterOnArc());
4048 if(IFopArc == 2) pfac2 = p2dbout;
4050 Hc2 = BRep_Tool::CurveOnSurface(CV2.Arc(),Fv,Ubid,Ubid);
4051 pfac2 = Hc2->Value(CV2.ParameterOnArc());
4053 if(Fi1.LineIndex() != 0){
4054 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));
4057 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
4059 if(Fi2.LineIndex() != 0){
4060 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
4063 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
4065 ChFi3d_Recale(Bs,pfac1,pfac2,(IFadArc == 1));
4066 Pardeb(1)= pfil1.X();Pardeb(2) = pfil1.Y();
4067 Pardeb(3)= pfac1.X();Pardeb(4) = pfac1.Y();
4068 Parfin(1)= pfil2.X();Parfin(2) = pfil2.Y();
4069 Parfin(3)= pfac2.X();Parfin(4) = pfac2.Y();
4070 Standard_Real uu1,uu2,vv1,vv2;
4071 ChFi3d_Boite(pfac1,pfac2,uu1,uu2,vv1,vv2);
4072 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
4074 if (!ChFi3d_ComputeCurves(HGs,HBs,Pardeb,Parfin,Cc,
4076 Pc,tolesp,tol2d,tolreached))
4077 Standard_Failure::Raise("OneCorner : failed calculation intersection");
4079 Udeb = Cc->FirstParameter();
4080 Ufin = Cc->LastParameter();
4082 // check if the curve has an intersection with sewing edge
4084 ChFi3d_Couture(Fv,couture,edgecouture);
4086 if (couture && !BRep_Tool::Degenerated(edgecouture)) {
4088 //Standard_Real Ubid,Vbid;
4089 Handle (Geom_Curve) C=BRep_Tool::Curve(edgecouture,Ubid,Vbid);
4090 Handle(Geom_TrimmedCurve) Ctrim=new Geom_TrimmedCurve (C,Ubid,Vbid);
4091 GeomAdaptor_Curve cur1(Ctrim->BasisCurve());
4092 GeomAdaptor_Curve cur2(Cc);
4093 Extrema_ExtCC extCC (cur1,cur2);
4094 if (extCC.IsDone()&&extCC.NbExt()!=0)
4096 Standard_Integer imin=0;
4097 Standard_Real dist2min = RealLast();
4098 for (Standard_Integer i = 1; i <= extCC.NbExt(); i++)
4099 if (extCC.SquareDistance(i) < dist2min)
4101 dist2min = extCC.SquareDistance(i);
4104 if (dist2min <= Precision::SquareConfusion())
4106 Extrema_POnCurv ponc1,ponc2;
4107 extCC.Points( imin, ponc1, ponc2 );
4108 par1 = ponc1.Parameter();
4109 par2 = ponc2.Parameter();
4110 Standard_Real Tol = 1.e-4;
4111 if (Abs(par2-Udeb) > Tol && Abs(Ufin-par2) > Tol)
4113 gp_Pnt P1=ponc1.Value();
4114 TopOpeBRepDS_Point tpoint( P1, Tol );
4115 indpt = DStr.AddPoint(tpoint);
4116 intcouture = Standard_True;
4117 curv1 = new Geom_TrimmedCurve(Cc,Udeb,par2);
4118 curv2 = new Geom_TrimmedCurve(Cc,par2,Ufin);
4119 TopOpeBRepDS_Curve tcurv1(curv1,tolreached);
4120 TopOpeBRepDS_Curve tcurv2(curv2,tolreached);
4121 Icurv1=DStr.AddCurve(tcurv1);
4122 Icurv2=DStr.AddCurve(tcurv2);
4130 Standard_NotImplemented::Raise("OneCorner : cap not written");
4132 Standard_Integer IShape = DStr.AddShape(Fv);
4134 TopAbs_Orientation Et = TopAbs_FORWARD;
4136 TopAbs_Orientation Et;
4139 TopExp_Explorer Exp;
4140 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
4141 TopAbs_EDGE);Exp.More();Exp.Next()) {
4142 if (Exp.Current().IsSame(CV1.Arc())) {
4143 Et = TopAbs::Reverse(TopAbs::Compose
4144 (Exp.Current().Orientation(),
4145 CV1.TransitionOnArc()));
4151 TopExp_Explorer Exp;
4152 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
4153 TopAbs_EDGE);Exp.More();Exp.Next()) {
4154 if (Exp.Current().IsSame(CV2.Arc())) {
4155 Et = TopAbs::Compose(Exp.Current().Orientation(),
4156 CV2.TransitionOnArc());
4167 ChFi3d_ResultChron(ch ,t_inter); //result perf condition if (inter)
4168 ChFi3d_InitChron(ch); // init perf condition if ( inters)
4171 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV1,DStr),isfirst,1);
4172 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV2,DStr),isfirst,2);
4175 // there is no intersection with edge of sewing
4176 // curve Cc is stored in the stripe
4177 // the storage in the DS is done by FILDS.
4179 TopOpeBRepDS_Curve Tc(Cc,tolreached);
4180 ICurve = DStr.AddCurve(Tc);
4181 Handle(TopOpeBRepDS_SurfaceCurveInterference)
4182 Interfc = ChFi3d_FilCurveInDS(ICurve,IShape,Pc,Et);
4183 DStr.ChangeShapeInterferences(IShape).Append(Interfc);
4184 stripe->ChangePCurve(isfirst)=Ps;
4185 stripe->SetCurve(ICurve,isfirst);
4186 stripe->SetParameters(isfirst,Udeb,Ufin);
4189 // curves curv1 and curv2 are stored in the DS
4190 // these curves are not reconstructed by FILDS as
4191 // stripe->InDS(isfirst) is placed;
4193 // interferences of curv1 and curv2 on Fv
4194 ComputeCurve2d(curv1,Fv,c2d1);
4195 Handle(TopOpeBRepDS_SurfaceCurveInterference) InterFv;
4196 InterFv = ChFi3d_FilCurveInDS(Icurv1,IShape,c2d1,Et);
4197 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
4198 ComputeCurve2d(curv2,Fv,c2d2);
4199 InterFv = ChFi3d_FilCurveInDS(Icurv2,IShape,c2d2,Et);
4200 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
4201 // interferences of curv1 and curv2 on Isurf
4202 if (Fd->Orientation()== Fv.Orientation()) Et=TopAbs::Reverse(Et);
4203 c2d1=new Geom2d_TrimmedCurve(Ps,Udeb,par2);
4204 InterFv = ChFi3d_FilCurveInDS(Icurv1,Isurf,c2d1,Et);
4205 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
4206 c2d2=new Geom2d_TrimmedCurve(Ps,par2,Ufin);
4207 InterFv = ChFi3d_FilCurveInDS(Icurv2,Isurf,c2d2,Et);
4208 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
4210 // limitation of the sewing edge
4211 Standard_Integer Iarc=DStr.AddShape(edgecouture);
4212 Handle(TopOpeBRepDS_CurvePointInterference) Interfedge;
4213 TopAbs_Orientation ori;
4214 TopoDS_Vertex Vdeb,Vfin;
4215 Vdeb=TopExp::FirstVertex(edgecouture);
4216 Vfin=TopExp::LastVertex(edgecouture);
4217 Standard_Real pard,parf;
4218 pard=BRep_Tool::Parameter(Vdeb,edgecouture);
4219 parf=BRep_Tool::Parameter(Vfin,edgecouture);
4220 if (Abs(par1-pard)<Abs(parf-par1)) ori=TopAbs_FORWARD;
4221 else ori=TopAbs_REVERSED;
4222 Interfedge = ChFi3d_FilPointInDS(ori,Iarc,indpt,par1);
4223 DStr.ChangeShapeInterferences(Iarc).Append(Interfedge);
4225 // creation of CurveInterferences from Icurv1 and Icurv2
4226 stripe->InDS(isfirst);
4227 Standard_Integer ind1= stripe->IndexPoint(isfirst,1);
4228 Standard_Integer ind2= stripe->IndexPoint(isfirst,2);
4229 Handle(TopOpeBRepDS_CurvePointInterference)
4230 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv1,ind1,Udeb);
4231 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
4232 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv1,indpt,par2);
4233 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
4234 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv2,indpt,par2);
4235 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
4236 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv2,ind2,Ufin);
4237 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
4241 ChFi3d_EnlargeBox(HBs,Pc,Udeb,Ufin,box1,box2);
4246 // The small end of curve missing for the extension
4247 // of the face at end and the limitation of the opposing face is added.
4249 // Above all the points cut the points with the edge of the spine.
4250 Standard_Integer IArcspine = DStr.AddShape(Arcspine);
4251 Standard_Integer IVtx = DStr.AddShape(Vtx);
4252 TopAbs_Orientation OVtx2;
4254 TopAbs_Orientation OVtx = TopAbs_FORWARD;
4256 TopAbs_Orientation OVtx;
4258 for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
4259 ex.More(); ex.Next()){
4260 if(Vtx.IsSame(ex.Current())) {
4261 OVtx = ex.Current().Orientation();
4265 OVtx = TopAbs::Reverse(OVtx);
4266 Standard_Real parVtx = BRep_Tool::Parameter(Vtx,Arcspine);
4267 Handle(TopOpeBRepDS_CurvePointInterference)
4268 interfv = ChFi3d_FilVertexInDS(OVtx,IArcspine,IVtx,parVtx);
4269 DStr.ChangeShapeInterferences(IArcspine).Append(interfv);
4272 //Modif of lvt to find the suite of Arcprol in the other face
4274 TopTools_ListIteratorOfListOfShape It;
4275 for (It.Initialize(myVEMap(Vtx)); It.More(); It.Next()){
4276 if (!(Arcprol.IsSame(It.Value()) ||
4277 Arcspine.IsSame(It.Value()) ||
4278 Arcpiv.IsSame(It.Value()))) {
4279 Arcprolbis = TopoDS::Edge(It.Value());
4286 //Now the missing curves are constructed.
4287 for(ex.Init(Arcprolbis.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
4288 ex.More(); ex.Next()){
4289 if(Vtx.IsSame(ex.Current())) {
4290 OVtx2 = ex.Current().Orientation();
4294 for(ex.Init(Arcprol.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
4295 ex.More(); ex.Next()){
4296 if(Vtx.IsSame(ex.Current())) {
4297 OVtx = ex.Current().Orientation();
4301 // it is checked if Fop has a sewing edge
4303 // TopoDS_Edge edgecouture;
4304 // Standard_Boolean couture;
4305 ChFi3d_Couture(Fop,couture,edgecouture);
4306 Handle(Geom2d_Curve) Hc;
4307 // parVtx = BRep_Tool::Parameter(Vtx,Arcprol);
4308 const ChFiDS_FaceInterference& Fiop = Fd->Interference(IFopArc);
4309 gp_Pnt2d pop1, pop2, pv1, pv2;
4311 parVtx = BRep_Tool::Parameter(Vtx,Arcprolbis);
4312 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 Begin
4313 // if(Fop.IsSame(Fopbis)) OArcprolbis = OArcprolop;
4314 // else OArcprolbis = Arcprolbis.Orientation();
4315 if(Fop.IsSame(Fopbis)) {
4316 OArcprolbis = OArcprolop;
4318 for(ex.Init(Fop,TopAbs_EDGE); ex.More(); ex.Next()){
4319 if(Arcprolbis.IsSame(ex.Current())) {
4320 OArcprolbis = ex.Current().Orientation();
4325 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 End
4327 Hc = BRep_Tool::CurveOnSurface(Arcprolbis,Fop,Ubid,Ubid);
4328 pop1 = Hc->Value(parVtx);
4329 pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst));
4330 Hc = BRep_Tool::CurveOnSurface(Arcprol,Fv,Ubid,Ubid);
4332 parVtx = BRep_Tool::Parameter(Vtx,Arcprol);
4334 pv1 = Hc->Value(parVtx);
4336 ChFi3d_Recale(Bs,pv1,pv2,1);
4337 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
4338 Pardeb(1) = pop1.X(); Pardeb(2) = pop1.Y();
4339 Pardeb(3) = pv1.X(); Pardeb(4) = pv1.Y();
4340 Parfin(1) = pop2.X(); Parfin(2) = pop2.Y();
4341 Parfin(3) = pv2.X(); Parfin(4) = pv2.Y();
4342 Standard_Real uu1,uu2,vv1,vv2;
4343 ChFi3d_Boite(pv1,pv2,uu1,uu2,vv1,vv2);
4344 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
4345 ChFi3d_Boite(pop1,pop2,uu1,uu2,vv1,vv2);
4346 ChFi3d_BoundFac(Bop,uu1,uu2,vv1,vv2);
4348 Handle(Geom_Curve) zob3d;
4349 Handle(Geom2d_Curve) zob2dop, zob2dv;
4350 // Standard_Real tolreached;
4351 if (!ChFi3d_ComputeCurves(HBop,HBs,Pardeb,Parfin,zob3d,zob2dop,
4352 zob2dv,tolesp,tol2d,tolreached))
4353 Standard_Failure::Raise("OneCorner : echec calcul intersection");
4355 Udeb = zob3d->FirstParameter();
4356 Ufin = zob3d->LastParameter();
4357 TopOpeBRepDS_Curve Zob(zob3d,tolreached);
4358 Standard_Integer IZob = DStr.AddCurve(Zob);
4360 // it is not determined if the curve has an intersection with the sewing edge
4364 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv));
4365 Standard_Integer Iop = DStr.AddShape(Fop);
4366 Handle(TopOpeBRepDS_SurfaceCurveInterference)
4367 InterFv = ChFi3d_FilCurveInDS(IZob,IShape,zob2dv,Et);
4368 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
4369 //OVtx = TopAbs::Reverse(OVtx);
4370 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 Begin
4371 // Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolbis));
4372 Et = TopAbs::Reverse(TopAbs::Compose(OVtx2,OArcprolbis));
4373 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 End
4374 //OVtx = TopAbs::Reverse(OVtx);
4375 // Et = TopAbs::Reverse(Et);
4376 Handle(TopOpeBRepDS_SurfaceCurveInterference)
4377 Interfop = ChFi3d_FilCurveInDS(IZob,Iop,zob2dop,Et);
4378 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
4379 Handle(TopOpeBRepDS_CurvePointInterference)
4380 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IVtx,Udeb);
4381 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
4382 Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc);
4383 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,IZob,icc,Ufin);
4384 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
4388 ChFi3d_EnlargeBox(DStr,stripe,Fd,box1,box2,isfirst);
4390 ChFi3d_EnlargeBox(CV1.Arc(),myEFMap(CV1.Arc()),CV1.ParameterOnArc(),box1);
4393 ChFi3d_EnlargeBox(CV2.Arc(),myEFMap(CV2.Arc()),CV2.ParameterOnArc(),box2);
4395 if (!CV1.IsVertex())
4396 ChFi3d_SetPointTolerance(DStr,box1,stripe->IndexPoint(isfirst,1));
4397 if (!CV2.IsVertex())
4398 ChFi3d_SetPointTolerance(DStr,box2,stripe->IndexPoint(isfirst,2));
4401 ChFi3d_ResultChron(ch, t_sameinter);//result perf condition if (same &&inter)