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)) {
382 ////modified by jgv, 10.05.2012 for the bug 23139////
383 Handle(Geom2d_Curve) PConF = fi.PCurveOnFace();
386 Handle(Geom2d_TrimmedCurve) aTrCurve = Handle(Geom2d_TrimmedCurve)::DownCast(PConF);
387 if (!aTrCurve.IsNull())
388 PConF = aTrCurve->BasisCurve();
391 Standard_Real fpar = PConF->FirstParameter();
397 Standard_Real lpar = PConF->LastParameter();
402 /////////////////////////////////////////////////////
404 fi.SetParameter(parltg,isfirst);
405 cp.SetArc(cp.Tolerance(),cp.Arc(),pared,cp.TransitionOnArc());
406 return Standard_True;
409 return Standard_False;
412 //=======================================================================
413 //function : ChFi3d_ExtendSurface
415 //=======================================================================
417 static void ChFi3d_ExtendSurface (Handle(Geom_Surface) & S ,
418 Standard_Integer & prol )
421 Handle(Geom_BSplineSurface) S1;
422 Handle(Geom_BezierSurface) S2;
423 Standard_Real length,umin,umax,vmin,vmax;
425 S->Bounds(umin,umax,vmin,vmax);
428 length=P1.Distance(P2);
430 S1=Handle(Geom_BSplineSurface)::DownCast(S);
431 S2=Handle(Geom_BezierSurface)::DownCast(S);
433 GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,
435 GeomLib::ExtendSurfByLength(S1,length,1,Standard_True,
437 GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,
439 GeomLib::ExtendSurfByLength(S1,length,1,Standard_True,
445 GeomLib::ExtendSurfByLength(S2,length,1,Standard_False,
447 GeomLib::ExtendSurfByLength(S2,length,1,Standard_True,
449 GeomLib::ExtendSurfByLength(S2,length,1,Standard_False,
451 GeomLib::ExtendSurfByLength(S2,length,1,Standard_True,
459 //=======================================================================
460 //function : ComputeCurve2d
461 //purpose : calculate the 2d of the curve Ct on face Face
462 //=======================================================================
464 static void ComputeCurve2d (Handle(Geom_Curve )& Ct,
466 Handle(Geom2d_Curve) & C2d)
469 TopTools_IndexedMapOfShape MapE1;
470 BRepLib_MakeEdge Bedge (Ct);
471 TopoDS_Edge edg =Bedge. Edge();
472 BRepAlgo_NormalProjection OrtProj;
475 OrtProj.SetParams(1.e-6, 1.e-6, GeomAbs_C1, 14, 16);
476 OrtProj.SetLimit(Standard_False);
477 OrtProj.Compute3d(Standard_False);
479 Standard_Real up1,up2;
480 if ( OrtProj.IsDone()) {
481 TopExp::MapShapes(OrtProj.Projection() ,TopAbs_EDGE, MapE1);
482 if (MapE1.Extent()!=0) {
483 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE1(1));
484 E1=TopoDS::Edge(aLocalShape );
485 // E1=TopoDS::Edge( TopoDS_Shape (MapE1(1)));
486 C2d=BRep_Tool::CurveOnSurface(E1,Face,up1,up2);
491 //=======================================================================
492 //function : ChFi3d_Recale
494 //=======================================================================
496 static void ChFi3d_Recale(BRepAdaptor_Surface& Bs,
499 const Standard_Boolean refon1)
501 Handle(Geom_Surface) surf = Bs.ChangeSurface().Surface();
502 Handle(Geom_RectangularTrimmedSurface)
503 ts = Handle(Geom_RectangularTrimmedSurface)::DownCast(surf);
504 if (!ts.IsNull()) surf = ts->BasisSurface();
505 if (surf->IsUPeriodic()) {
506 Standard_Real u1 = p1.X(), u2 = p2.X();
507 Standard_Real uper = surf->UPeriod();
508 if (fabs(u2-u1) > 0.5*uper) {
509 if (u2<u1 && refon1) u2 += uper;
510 else if (u2<u1 && !refon1) u1 -= uper;
511 else if (u1<u2 && refon1) u2 -= uper;
512 else if (u1<u2 && !refon1) u1 += uper;
514 p1.SetX(u1); p2.SetX(u2);
516 if (surf->IsVPeriodic()) {
517 Standard_Real v1 = p1.Y(), v2 = p2.Y();
518 Standard_Real vper = surf->VPeriod();
519 if (fabs(v2-v1) > 0.5*vper) {
520 if (v2<v1 && refon1) v2 += vper;
521 else if (v2<v1 && !refon1) v1 -= vper;
522 else if (v1<v2 && refon1) v2 -= vper;
523 else if (v1<v2 && !refon1) v1 += vper;
525 p1.SetY(v1); p2.SetY(v2);
529 //=======================================================================
530 //function : ChFi3d_SelectStripe
531 //purpose : find stripe with ChFiDS_OnSame state if <thePrepareOnSame> is True
532 //=======================================================================
534 Standard_Boolean ChFi3d_SelectStripe(ChFiDS_ListIteratorOfListOfStripe & It,
535 const TopoDS_Vertex& Vtx,
536 const Standard_Boolean thePrepareOnSame)
538 if (!thePrepareOnSame) return Standard_True;
540 for (; It.More(); It.Next()) {
541 Standard_Integer sens = 0;
542 Handle(ChFiDS_Stripe) stripe = It.Value();
543 ChFi3d_IndexOfSurfData(Vtx, stripe, sens);
546 stat = stripe->Spine()->FirstStatus();
548 stat = stripe->Spine()->LastStatus();
549 if ( stat == ChFiDS_OnSame ) return Standard_True;
552 return Standard_False;
554 //=======================================================================
555 //function : PerformOneCorner
556 //purpose : Calculate a corner with three edges and a fillet.
557 // 3 separate case: (22/07/94 only 1st is implemented)
559 // - same concavity on three edges, intersection with the
561 // - concavity of 2 outgoing edges is opposite to the one of the fillet,
562 // if the face at end is ready for that, the same in case 1 on extended face,
563 // otherwise a small cap is done with GeomFill,
564 // - only one outgoing edge has concavity opposed to the edge of the
565 // fillet and the third edge, the top of the corner is reread
566 // in the empty of the fillet and closed, either by extending the face
567 // at end if it is plane and orthogonal to the
568 // guiding edge, or by a cap of type GeomFill.
570 // <thePrepareOnSame> means that only needed thing is redefinition
571 // of intersection pameter of OnSame-Stripe with <Arcprol>
572 // (eap, Arp 9 2002, occ266)
573 //=======================================================================
575 void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index,
576 const Standard_Boolean thePrepareOnSame)
578 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
581 OSD_Chronometer ch;// init perf for PerformSetOfKPart
584 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
585 // The fillet is returned,
586 ChFiDS_ListIteratorOfListOfStripe StrIt;
587 StrIt.Initialize(myVDataMap(Index));
588 if ( ! ChFi3d_SelectStripe (StrIt, Vtx, thePrepareOnSame)) return;
589 Handle(ChFiDS_Stripe) stripe = StrIt.Value();
590 const Handle(ChFiDS_Spine) spine = stripe->Spine();
591 ChFiDS_SequenceOfSurfData& SeqFil =
592 stripe->ChangeSetOfSurfData()->ChangeSequence();
593 // SurfData and its CommonPoints,
594 Standard_Integer sens = 0;
596 // Choose proper SurfData
597 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
598 Standard_Boolean isfirst = (sens == 1);
600 for (; num<SeqFil.Length() && (
601 (SeqFil.Value(num)->IndexOfS1()==0) ||
602 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
603 SeqFil.Remove(num); // The surplus is removed
608 (SeqFil.Value(num)->IndexOfS1()==0) ||
609 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
610 SeqFil.Remove(num);// The surplus is removed
615 Handle(ChFiDS_SurfData)& Fd = SeqFil.ChangeValue(num);
616 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
617 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
618 //To evaluate the new points.
621 // The cases of cap and intersection are processed separately.
622 // ----------------------------------------------------------
624 if (isfirst) stat = spine->FirstStatus();
625 else stat = spine->LastStatus();
626 Standard_Boolean onsame = (stat == ChFiDS_OnSame);
627 TopoDS_Face Fv,Fad,Fop;
628 TopoDS_Edge Arcpiv,Arcprol,Arcspine;
629 if (isfirst) Arcspine = spine->Edges(1);
630 else Arcspine = spine->Edges(spine->NbEdges());
632 TopAbs_Orientation OArcprolv = TopAbs_FORWARD, OArcprolop = TopAbs_FORWARD;
634 TopAbs_Orientation OArcprolv,OArcprolop;
636 Standard_Integer ICurve;
637 Handle(BRepAdaptor_HSurface) HBs = new BRepAdaptor_HSurface();
638 Handle(BRepAdaptor_HSurface) HBad = new BRepAdaptor_HSurface();
639 Handle(BRepAdaptor_HSurface) HBop = new BRepAdaptor_HSurface();
640 BRepAdaptor_Surface& Bs = HBs->ChangeSurface();
641 BRepAdaptor_Surface& Bad = HBad->ChangeSurface();
642 BRepAdaptor_Surface& Bop = HBop->ChangeSurface();
643 Handle(Geom_Curve) Cc;
644 Handle(Geom2d_Curve) Pc,Ps;
645 Standard_Real Ubid,Vbid;//,mu,Mu,mv,Mv;
647 Standard_Real Udeb = 0.,Ufin = 0.;
649 Standard_Real Udeb,Ufin;
651 // gp_Pnt2d UVf1,UVl1,UVf2,UVl2;
652 // Standard_Real Du,Dv,Step;
653 Standard_Boolean inters = Standard_True;
654 Standard_Integer IFadArc = 1, IFopArc = 2;
655 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
659 ChFi3d_InitChron(ch); // init perf condition if (onsame)
663 if (!CV1.IsOnArc() && !CV2.IsOnArc())
664 Standard_Failure::Raise("Corner OnSame : no point on arc");
665 else if (CV1.IsOnArc() && CV2.IsOnArc()) {
666 Standard_Boolean sur1 = 0, sur2 = 0;
667 for(ex.Init(CV1.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()) {
668 if (Vtx.IsSame(ex.Current())) {
673 for(ex.Init(CV2.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()) {
674 if (Vtx.IsSame(ex.Current())) {
681 E[0] = CV1.Arc(); E[1] = CV2.Arc(); E[2] = Arcspine;
682 if (ChFi3d_EdgeState(E,myEFMap) != ChFiDS_OnDiff) IFadArc = 2;
684 else if (sur2) IFadArc = 2;
686 else if (CV2.IsOnArc()) IFadArc = 2;
689 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
690 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
691 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
692 TopTools_ListIteratorOfListOfShape It;
693 // The face at end is returned without check of its unicity.
694 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
695 if (!Fad.IsSame(It.Value())) {
696 Fv = TopoDS::Face(It.Value());
701 // Does the face at bout contain the Vertex ?
702 Standard_Boolean isinface = Standard_False;
703 for (ex.Init(Fv,TopAbs_VERTEX); ex.More(); ex.Next()) {
704 if (ex.Current().IsSame(Vtx)) {
705 isinface = Standard_True;
709 if (!isinface && Fd->Vertex(isfirst,3-IFadArc).IsOnArc()) {
712 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
713 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
714 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
715 //TopTools_ListIteratorOfListOfShape It;
716 // The face at end is returned without check of its unicity.
717 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
718 if (!Fad.IsSame(It.Value())) {
719 Fv = TopoDS::Face(It.Value());
725 if (Fv.IsNull()) StdFail_NotDone::Raise
726 ("OneCorner : face at end not found");
728 Fv.Orientation(TopAbs_FORWARD);
729 Fad.Orientation(TopAbs_FORWARD);
730 Fop.Orientation(TopAbs_FORWARD);
732 // The edge that will be extended is returned.
733 for(It.Initialize(myVEMap(Vtx));It.More() && Arcprol.IsNull();It.Next()) {
734 if (!Arcpiv.IsSame(It.Value())) {
735 for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()) {
736 if (It.Value().IsSame(ex.Current())) {
737 Arcprol = TopoDS::Edge(It.Value());
738 OArcprolv = ex.Current().Orientation();
744 if (Arcprol.IsNull()) /*StdFail_NotDone::Raise
745 ("OneCorner : edge a prolonger non trouve");*/
747 PerformIntersectionAtEnd(Index);
750 for(ex.Init(Fop,TopAbs_EDGE); ex.More(); ex.Next()) {
751 if (Arcprol.IsSame(ex.Current())) {
752 OArcprolop = ex.Current().Orientation();
758 Standard_Integer prol=0;
760 Handle(Geom_Surface ) Sface;
761 Sface=BRep_Tool::Surface(Fv);
762 ChFi3d_ExtendSurface(Sface,prol);
763 tol=BRep_Tool::Tolerance(Fv);
764 BRE.MakeFace(FFv,Sface,tol);
766 Bs.Initialize(FFv,Standard_False);
767 DStr.SetNewSurface(Fv,Sface);
769 else Bs.Initialize(Fv,Standard_False);
773 //in case of OnSame it is necessary to modify the CommonPoint
774 //in the empty and its parameter in the FaceInterference.
775 //They are both returned in non const references. Attention the modifications are done behind
776 //de CV1,CV2,Fi1,Fi2.
777 ChFiDS_CommonPoint& CPopArc = Fd->ChangeVertex(isfirst,IFopArc);
778 ChFiDS_FaceInterference& FiopArc = Fd->ChangeInterference(IFopArc);
779 ChFiDS_CommonPoint& CPadArc = Fd->ChangeVertex(isfirst,IFadArc);
780 ChFiDS_FaceInterference& FiadArc = Fd->ChangeInterference(IFadArc);
781 //the parameter of the vertex in the air is initialiced with the value of
782 //its opposite (point on arc).
783 Standard_Real wop = Fd->ChangeInterference(IFadArc).Parameter(isfirst);
784 Handle(Geom_Curve) c3df;
785 Handle(GeomAdaptor_HSurface)
786 HGs = new GeomAdaptor_HSurface(DStr.Surface(Fd->Surf()).Surface());
791 ChFiDS_CommonPoint saveCPopArc = CPopArc;
792 c3df = DStr.Curve(FiopArc.LineIndex()).Curve();
794 inters = IntersUpdateOnSame (HGs,HBs,c3df,Fop,Fv,Arcprol,Vtx,isfirst,10*tolesp, // in
795 FiopArc,CPopArc,p2dbout,wop); // out
797 Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
798 pced->ChangeCurve2d().Initialize(CPadArc.Arc(),Fv);
799 // in the case of degenerated Fi, parameter difference can be even negative (eap, occ293)
800 if ((FiadArc.LastParameter() - FiadArc.FirstParameter()) > 10*tolesp)
801 Update(HBs,pced,HGs,FiadArc,CPadArc,isfirst);
803 if (thePrepareOnSame) {
804 //saveCPopArc.SetParameter(wop);
805 saveCPopArc.SetPoint(CPopArc.Point());
806 CPopArc = saveCPopArc;
811 inters = FindFace(Vtx,CV1,CV2,Fv,Fop);
813 PerformIntersectionAtEnd(Index);
817 Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
818 pced->ChangeCurve2d().Initialize(CV1.Arc(),Fv);
819 Update(HBs,pced,HGs,Fd->ChangeInterferenceOnS1(),CV1,isfirst);
820 pced->ChangeCurve2d().Initialize(CV2.Arc(),Fv);
821 Update(HBs,pced,HGs,Fd->ChangeInterferenceOnS2(),CV2,isfirst);
826 ChFi3d_ResultChron(ch,t_same); // result perf condition if (same)
827 ChFi3d_InitChron(ch); // init perf condition if (inters)
830 TopoDS_Edge edgecouture;
831 Standard_Boolean couture,intcouture=Standard_False;;
832 Standard_Real tolreached;
834 Standard_Real par1 =0.,par2 =0.;
835 Standard_Integer indpt = 0,Icurv1 = 0,Icurv2 = 0;
837 Standard_Real par1,par2;
838 Standard_Integer indpt,Icurv1,Icurv2;
840 Handle(Geom_TrimmedCurve) curv1,curv2;
841 Handle(Geom2d_Curve) c2d1,c2d2;
843 Standard_Integer Isurf=Fd->Surf();
846 HGs = ChFi3d_BoundSurf(DStr,Fd,1,2);
847 const ChFiDS_FaceInterference& Fi1 = Fd->InterferenceOnS1();
848 const ChFiDS_FaceInterference& Fi2 = Fd->InterferenceOnS2();
849 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
850 gp_Pnt2d pfil1,pfac1,pfil2,pfac2;
851 Handle(Geom2d_Curve) Hc1,Hc2;
852 if (onsame && IFopArc == 1) pfac1 = p2dbout;
854 Hc1 = BRep_Tool::CurveOnSurface(CV1.Arc(),Fv,Ubid,Ubid);
855 pfac1 = Hc1->Value(CV1.ParameterOnArc());
857 if (onsame && IFopArc == 2) pfac2 = p2dbout;
859 Hc2 = BRep_Tool::CurveOnSurface(CV2.Arc(),Fv,Ubid,Ubid);
860 pfac2 = Hc2->Value(CV2.ParameterOnArc());
862 if (Fi1.LineIndex() != 0) {
863 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));
866 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
868 if (Fi2.LineIndex() != 0) {
869 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
872 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
874 if (onsame) ChFi3d_Recale(Bs,pfac1,pfac2,(IFadArc == 1));
876 Pardeb(1)= pfil1.X(); Pardeb(2) = pfil1.Y();
877 Pardeb(3)= pfac1.X(); Pardeb(4) = pfac1.Y();
878 Parfin(1)= pfil2.X(); Parfin(2) = pfil2.Y();
879 Parfin(3)= pfac2.X(); Parfin(4) = pfac2.Y();
881 Standard_Real uu1,uu2,vv1,vv2;
882 ChFi3d_Boite(pfac1,pfac2,uu1,uu2,vv1,vv2);
883 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
885 if (!ChFi3d_ComputeCurves(HGs,HBs,Pardeb,Parfin,Cc,
887 Pc,tolesp,tol2d,tolreached))
888 Standard_Failure::Raise("OneCorner : echec calcul intersection");
890 Udeb = Cc->FirstParameter();
891 Ufin = Cc->LastParameter();
893 // determine if the curve has an intersection with edge of sewing
895 ChFi3d_Couture(Fv,couture,edgecouture);
897 if (couture && !BRep_Tool::Degenerated(edgecouture)) {
899 //Standard_Real Ubid,Vbid;
900 Handle (Geom_Curve) C=BRep_Tool::Curve(edgecouture,Ubid,Vbid);
901 Handle(Geom_TrimmedCurve) Ctrim=new Geom_TrimmedCurve (C,Ubid,Vbid);
902 GeomAdaptor_Curve cur1(Ctrim->BasisCurve());
903 GeomAdaptor_Curve cur2(Cc);
904 Extrema_ExtCC extCC (cur1,cur2);
905 if (extCC.IsDone()&&extCC.NbExt()!=0)
907 Standard_Integer imin=0;
908 Standard_Real distmin2 = RealLast();
909 for (Standard_Integer i = 1; i <= extCC.NbExt(); i++)
910 if (extCC.SquareDistance(i) < distmin2)
912 distmin2 = extCC.SquareDistance(i);
915 if (distmin2 <= Precision::SquareConfusion())
917 Extrema_POnCurv ponc1,ponc2;
918 extCC.Points( imin, ponc1, ponc2 );
919 par1 = ponc1.Parameter();
920 par2 = ponc2.Parameter();
921 Standard_Real Tol = 1.e-4;
922 if (Abs(par2-Udeb) > Tol && Abs(Ufin-par2) > Tol)
924 gp_Pnt P1 = ponc1.Value();
925 TopOpeBRepDS_Point tpoint( P1, Tol );
926 indpt = DStr.AddPoint(tpoint);
927 intcouture = Standard_True;
928 curv1 = new Geom_TrimmedCurve(Cc,Udeb,par2);
929 curv2 = new Geom_TrimmedCurve(Cc,par2,Ufin);
930 TopOpeBRepDS_Curve tcurv1(curv1,tolreached);
931 TopOpeBRepDS_Curve tcurv2(curv2,tolreached);
932 Icurv1=DStr.AddCurve(tcurv1);
933 Icurv2=DStr.AddCurve(tcurv2);
940 Standard_NotImplemented::Raise("OneCorner : bouchon non ecrit");
942 Standard_Integer IShape = DStr.AddShape(Fv);
944 TopAbs_Orientation Et = TopAbs_FORWARD;
946 TopAbs_Orientation Et;
950 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
951 TopAbs_EDGE);Exp.More();Exp.Next()) {
952 if (Exp.Current().IsSame(CV1.Arc())) {
953 Et = TopAbs::Reverse(TopAbs::Compose
954 (Exp.Current().Orientation(),
955 CV1.TransitionOnArc()));
962 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
963 TopAbs_EDGE);Exp.More();Exp.Next()) {
964 if (Exp.Current().IsSame(CV2.Arc())) {
965 Et = TopAbs::Compose(Exp.Current().Orientation(),
966 CV2.TransitionOnArc());
977 ChFi3d_ResultChron(ch ,t_inter); //result perf condition if (inter)
978 ChFi3d_InitChron(ch); // init perf condition if (onsame && inters)
981 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV1,DStr),isfirst,1);
982 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV2,DStr),isfirst,2);
985 // there is no intersection with the sewing edge
986 // the curve Cc is stored in the stripe
987 // the storage in the DS is not done by FILDS.
989 TopOpeBRepDS_Curve Tc(Cc,tolreached);
990 ICurve = DStr.AddCurve(Tc);
991 Handle(TopOpeBRepDS_SurfaceCurveInterference)
992 Interfc = ChFi3d_FilCurveInDS(ICurve,IShape,Pc,Et);
994 // 31/01/02 akm vvv : (OCC119) Prevent the builder from creating
995 // intersecting fillets - they are bad.
996 Geom2dInt_GInter anIntersector;
997 Geom2dAdaptor_Curve aCorkPCurve (Pc, Udeb, Ufin);
999 // Take all the interferences with faces from all the stripes
1000 // and look if their pcurves intersect our cork pcurve.
1001 // Unfortunately, by this moment they do not exist in DStr.
1002 ChFiDS_ListIteratorOfListOfStripe aStrIt(myListStripe);
1003 for (; aStrIt.More(); aStrIt.Next())
1005 Handle(ChFiDS_Stripe) aCheckStripe = aStrIt.Value();
1006 Handle(ChFiDS_HData) aSeqData = aCheckStripe->SetOfSurfData();
1007 // Loop on parts of the stripe
1008 Standard_Integer iPart;
1009 for (iPart=1; iPart<=aSeqData->Length(); iPart++)
1011 Handle(ChFiDS_SurfData) aData = aSeqData->Value(iPart);
1012 Geom2dAdaptor_Curve anOtherPCurve;
1013 if (IShape == aData->IndexOfS1())
1015 const Handle(Geom2d_Curve)& aPCurve = aData->InterferenceOnS1().PCurveOnFace();
1016 if(aPCurve.IsNull())
1019 anOtherPCurve.Load (aPCurve,
1020 aData->InterferenceOnS1().FirstParameter(),
1021 aData->InterferenceOnS1().LastParameter());
1023 else if (IShape == aData->IndexOfS2())
1025 const Handle(Geom2d_Curve)& aPCurve = aData->InterferenceOnS2().PCurveOnFace();
1026 if(aPCurve.IsNull())
1029 anOtherPCurve.Load (aPCurve,
1030 aData->InterferenceOnS2().FirstParameter(),
1031 aData->InterferenceOnS2().LastParameter());
1035 // Normal case - no common surface
1038 if (IsEqual(anOtherPCurve.LastParameter(),anOtherPCurve.FirstParameter()))
1041 anIntersector.Perform (aCorkPCurve, anOtherPCurve,
1042 tol2d, Precision::PConfusion());
1043 if (anIntersector.NbSegments() > 0 ||
1044 anIntersector.NbPoints() > 0)
1045 StdFail_NotDone::Raise ("OneCorner : fillets have too big radiuses");
1048 TopOpeBRepDS_ListIteratorOfListOfInterference
1049 anIter(DStr.ChangeShapeInterferences(IShape));
1050 for (; anIter.More(); anIter.Next())
1052 Handle(TopOpeBRepDS_SurfaceCurveInterference) anOtherIntrf =
1053 Handle(TopOpeBRepDS_SurfaceCurveInterference)::DownCast(anIter.Value());
1054 // We need only interferences between cork face and curves
1055 // of intersection with another fillet surfaces
1056 if (anOtherIntrf.IsNull())
1058 // Look if there is an intersection between pcurves
1059 Handle(Geom_TrimmedCurve) anOtherCur =
1060 Handle(Geom_TrimmedCurve)::DownCast(DStr.Curve (anOtherIntrf->Geometry()).Curve());
1061 if (anOtherCur.IsNull())
1063 Geom2dAdaptor_Curve anOtherPCurve (anOtherIntrf->PCurve(),
1064 anOtherCur->FirstParameter(),
1065 anOtherCur->LastParameter());
1066 anIntersector.Perform (aCorkPCurve, anOtherPCurve,
1067 tol2d, Precision::PConfusion());
1068 if (anIntersector.NbSegments() > 0 ||
1069 anIntersector.NbPoints() > 0)
1070 StdFail_NotDone::Raise ("OneCorner : fillets have too big radiuses");
1073 DStr.ChangeShapeInterferences(IShape).Append(Interfc);
1074 //// modified by jgv, 26.03.02 for OCC32 ////
1075 ChFiDS_CommonPoint CV [2];
1078 for (Standard_Integer i = 0; i < 2; i++)
1080 if (CV[i].IsOnArc() && ChFi3d_IsPseudoSeam( CV[i].Arc(), Fv ))
1082 gp_Pnt2d pfac1, PcF, PcL;
1083 gp_Vec2d DerPc, DerHc;
1084 Standard_Real first, last, prm1, prm2;
1085 Standard_Boolean onfirst, FirstToPar;
1086 Handle(Geom2d_Curve) Hc = BRep_Tool::CurveOnSurface( CV[i].Arc(), Fv, first, last );
1087 pfac1 = Hc->Value( CV[i].ParameterOnArc() );
1088 PcF = Pc->Value( Udeb );
1089 PcL = Pc->Value( Ufin );
1090 onfirst = (pfac1.Distance(PcF) < pfac1.Distance(PcL))? Standard_True : Standard_False;
1092 Pc->D1( Udeb, PcF, DerPc );
1095 Pc->D1( Ufin, PcL, DerPc );
1098 Hc->D1( CV[i].ParameterOnArc(), pfac1, DerHc );
1099 if (DerHc.Dot(DerPc) > 0.)
1101 prm1 = CV[i].ParameterOnArc();
1103 FirstToPar = Standard_False;
1108 prm2 = CV[i].ParameterOnArc();
1109 FirstToPar = Standard_True;
1111 Handle(Geom_Curve) Ct = BRep_Tool::Curve( CV[i].Arc(), first, last );
1112 Ct = new Geom_TrimmedCurve( Ct, prm1, prm2 );
1113 Standard_Real toled = BRep_Tool::Tolerance( CV[i].Arc() );
1114 TopOpeBRepDS_Curve tcurv( Ct, toled );
1115 Handle (TopOpeBRepDS_CurvePointInterference) Interfp1, Interfp2;
1116 Standard_Integer indcurv;
1117 indcurv = DStr.AddCurve( tcurv );
1118 Standard_Integer indpoint = (isfirst)? stripe->IndexFirstPointOnS1() : stripe->IndexLastPointOnS1();
1119 Standard_Integer indvertex = DStr.AddShape(Vtx);
1122 Interfp1 = ChFi3d_FilPointInDS( TopAbs_FORWARD, indcurv, indvertex, prm1, Standard_True );
1123 Interfp2 = ChFi3d_FilPointInDS( TopAbs_REVERSED, indcurv, indpoint, prm2, Standard_False );
1127 Interfp1 = ChFi3d_FilPointInDS( TopAbs_FORWARD, indcurv, indpoint, prm1, Standard_False );
1128 Interfp2 = ChFi3d_FilPointInDS( TopAbs_REVERSED, indcurv, indvertex, prm2, Standard_True );
1130 DStr.ChangeCurveInterferences(indcurv).Append(Interfp1);
1131 DStr.ChangeCurveInterferences(indcurv).Append(Interfp2);
1132 Standard_Integer indface = DStr.AddShape( Fv );
1133 Interfc = ChFi3d_FilCurveInDS( indcurv, indface, Hc, CV[i].Arc().Orientation() );
1134 DStr.ChangeShapeInterferences(indface).Append( Interfc );
1135 TopoDS_Edge aLocalEdge = CV[i].Arc();
1136 aLocalEdge.Reverse();
1137 Handle(Geom2d_Curve) HcR = BRep_Tool::CurveOnSurface( aLocalEdge, Fv, first, last );
1138 Interfc = ChFi3d_FilCurveInDS( indcurv, indface, HcR, aLocalEdge.Orientation() );
1139 DStr.ChangeShapeInterferences(indface).Append( Interfc );
1140 //modify degenerated edge
1141 Standard_Boolean DegenExist = Standard_False;
1143 TopExp_Explorer Explo( Fv, TopAbs_EDGE );
1144 for (; Explo.More(); Explo.Next())
1146 const TopoDS_Edge& Ecur = TopoDS::Edge( Explo.Current() );
1147 if (BRep_Tool::Degenerated( Ecur ))
1149 TopoDS_Vertex Vf, Vl;
1150 TopExp::Vertices( Ecur, Vf, Vl );
1151 if (Vf.IsSame(Vtx) || Vl.IsSame(Vtx))
1153 DegenExist = Standard_True;
1161 Standard_Real fd, ld;
1162 Handle(Geom2d_Curve) Cd = BRep_Tool::CurveOnSurface( Edeg, Fv, fd, ld );
1163 Handle(Geom2d_TrimmedCurve) tCd = Handle(Geom2d_TrimmedCurve)::DownCast(Cd);
1165 Cd = tCd->BasisCurve();
1166 gp_Pnt2d P2d = (FirstToPar)? Hc->Value(first) : Hc->Value(last);
1167 Geom2dAPI_ProjectPointOnCurve Projector( P2d, Cd );
1168 Standard_Real par = Projector.LowerDistanceParameter();
1169 Standard_Integer Ideg = DStr.AddShape(Edeg);
1170 TopAbs_Orientation ori = (par < fd)? TopAbs_FORWARD : TopAbs_REVERSED; //if par<fd => par>ld
1171 Interfp1 = ChFi3d_FilPointInDS( ori, Ideg, indvertex, par, Standard_True );
1172 DStr.ChangeShapeInterferences(Ideg).Append(Interfp1);
1176 /////////////////////////////////////////////
1177 stripe->ChangePCurve(isfirst)=Ps;
1178 stripe->SetCurve(ICurve,isfirst);
1179 stripe->SetParameters(isfirst,Udeb,Ufin);
1182 // curves curv1 are curv2 stored in the DS
1183 // these curves will not be reconstructed by FILDS as
1184 // one places stripe->InDS(isfirst);
1186 // interferences of curv1 and curv2 on Fv
1187 ComputeCurve2d(curv1,Fv,c2d1);
1188 Handle(TopOpeBRepDS_SurfaceCurveInterference) InterFv;
1189 InterFv = ChFi3d_FilCurveInDS(Icurv1,IShape,c2d1,Et);
1190 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1191 ComputeCurve2d(curv2,Fv,c2d2);
1192 InterFv = ChFi3d_FilCurveInDS(Icurv2,IShape,c2d2,Et);
1193 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1194 // interferences of curv1 and curv2 on Isurf
1195 if (Fd->Orientation()== Fv.Orientation()) Et=TopAbs::Reverse(Et);
1196 c2d1=new Geom2d_TrimmedCurve(Ps,Udeb,par2);
1197 InterFv = ChFi3d_FilCurveInDS(Icurv1,Isurf,c2d1,Et);
1198 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
1199 c2d2=new Geom2d_TrimmedCurve(Ps,par2,Ufin);
1200 InterFv = ChFi3d_FilCurveInDS(Icurv2,Isurf,c2d2,Et);
1201 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
1203 // limitation of the sewing edge
1204 Standard_Integer Iarc=DStr.AddShape(edgecouture);
1205 Handle(TopOpeBRepDS_CurvePointInterference) Interfedge;
1206 TopAbs_Orientation ori;
1207 TopoDS_Vertex Vdeb,Vfin;
1208 Vdeb=TopExp::FirstVertex(edgecouture);
1209 Vfin=TopExp::LastVertex(edgecouture);
1210 Standard_Real pard,parf;
1211 pard=BRep_Tool::Parameter(Vdeb,edgecouture);
1212 parf=BRep_Tool::Parameter(Vfin,edgecouture);
1213 if (Abs(par1-pard)<Abs(parf-par1)) ori=TopAbs_FORWARD;
1214 else ori=TopAbs_REVERSED;
1215 Interfedge = ChFi3d_FilPointInDS(ori,Iarc,indpt,par1);
1216 DStr.ChangeShapeInterferences(Iarc).Append(Interfedge);
1218 // creation of CurveInterferences from Icurv1 and Icurv2
1219 stripe->InDS(isfirst);
1220 Standard_Integer ind1= stripe->IndexPoint(isfirst,1);
1221 Standard_Integer ind2= stripe->IndexPoint(isfirst,2);
1222 Handle(TopOpeBRepDS_CurvePointInterference)
1223 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv1,ind1,Udeb);
1224 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1225 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv1,indpt,par2);
1226 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1227 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv2,indpt,par2);
1228 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1229 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv2,ind2,Ufin);
1230 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1234 ChFi3d_EnlargeBox(HBs,Pc,Udeb,Ufin,box1,box2);
1236 if (onsame && inters) {
1238 // A small missing end of curve is added for the extension
1239 // of the face at end and the limitation of the opposing face.
1241 // VARIANT 2 : extend Arcprol, not create new small edge
1242 // To do: modify for intcouture
1243 const Standard_Boolean variant1 = Standard_True;
1245 // First of all the ponts are cut with the edge of the spine.
1246 Standard_Integer IArcspine = DStr.AddShape(Arcspine);
1247 Standard_Integer IVtx = DStr.AddShape(Vtx);
1249 TopAbs_Orientation OVtx = TopAbs_FORWARD;
1251 TopAbs_Orientation OVtx;
1253 for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
1254 ex.More(); ex.Next()) {
1255 if (Vtx.IsSame(ex.Current())) {
1256 OVtx = ex.Current().Orientation();
1260 OVtx = TopAbs::Reverse(OVtx);
1261 Standard_Real parVtx = BRep_Tool::Parameter(Vtx,Arcspine);
1262 Handle(TopOpeBRepDS_CurvePointInterference)
1263 interfv = ChFi3d_FilVertexInDS(OVtx,IArcspine,IVtx,parVtx);
1264 DStr.ChangeShapeInterferences(IArcspine).Append(interfv);
1266 // Now the missing curves are constructed.
1268 for(ex.Init(Arcprol.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
1269 ex.More(); ex.Next()) {
1270 if (Vtx.IsSame(ex.Current()))
1271 OVtx = ex.Current().Orientation();
1273 V2 = TopoDS::Vertex(ex.Current());
1276 Handle(Geom2d_Curve) Hc;
1278 parVtx = BRep_Tool::Parameter(Vtx,Arcprol);
1280 parVtx = BRep_Tool::Parameter(V2,Arcprol);
1281 const ChFiDS_FaceInterference& Fiop = Fd->Interference(IFopArc);
1282 gp_Pnt2d pop1, pop2, pv1, pv2;
1283 Hc = BRep_Tool::CurveOnSurface(Arcprol,Fop,Ubid,Ubid);
1284 pop1 = Hc->Value(parVtx);
1285 pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst));
1286 Hc = BRep_Tool::CurveOnSurface(Arcprol,Fv,Ubid,Ubid);
1287 pv1 = Hc->Value(parVtx);
1289 ChFi3d_Recale(Bs,pv1,pv2,1);
1290 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
1291 Pardeb(1) = pop1.X(); Pardeb(2) = pop1.Y();
1292 Pardeb(3) = pv1.X(); Pardeb(4) = pv1.Y();
1293 Parfin(1) = pop2.X(); Parfin(2) = pop2.Y();
1294 Parfin(3) = pv2.X(); Parfin(4) = pv2.Y();
1295 Standard_Real uu1,uu2,vv1,vv2;
1296 ChFi3d_Boite(pv1,pv2,uu1,uu2,vv1,vv2);
1297 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
1298 ChFi3d_Boite(pop1,pop2,uu1,uu2,vv1,vv2);
1299 ChFi3d_BoundFac(Bop,uu1,uu2,vv1,vv2);
1301 Handle(Geom_Curve) zob3d;
1302 Handle(Geom2d_Curve) zob2dop, zob2dv;
1303 //Standard_Real tolreached;
1304 if (!ChFi3d_ComputeCurves(HBop,HBs,Pardeb,Parfin,zob3d,zob2dop,
1305 zob2dv,tolesp,tol2d,tolreached))
1306 Standard_Failure::Raise("OneCorner : echec calcul intersection");
1308 Udeb = zob3d->FirstParameter();
1309 Ufin = zob3d->LastParameter();
1310 TopOpeBRepDS_Curve Zob(zob3d,tolreached);
1311 Standard_Integer IZob = DStr.AddCurve(Zob);
1313 // it is determined if Fop has an edge of sewing
1314 // it is determined if the curve has an intersection with the edge of sewing
1316 //TopoDS_Edge edgecouture;
1317 //Standard_Boolean couture;
1318 ChFi3d_Couture(Fop,couture,edgecouture);
1320 if (couture && !BRep_Tool::Degenerated(edgecouture)) {
1321 BRepLib_MakeEdge Bedge (zob3d);
1322 TopoDS_Edge edg =Bedge. Edge();
1323 BRepExtrema_ExtCC extCC (edgecouture,edg);
1324 if (extCC.IsDone()&&extCC.NbExt()!=0) {
1325 for (Standard_Integer i=1; i<=extCC.NbExt()&&!intcouture;i++) {
1326 if (extCC.SquareDistance(i)<=1.e-8) {
1327 par1=extCC.ParameterOnE1(i);
1328 par2=extCC.ParameterOnE2(i);
1329 gp_Pnt P1=extCC.PointOnE1(i);
1330 TopOpeBRepDS_Point tpoint(P1,1.e-4);
1331 indpt=DStr.AddPoint(tpoint);
1332 intcouture=Standard_True;
1333 curv1 = new Geom_TrimmedCurve(zob3d,Udeb,par2);
1334 curv2 = new Geom_TrimmedCurve(zob3d,par2,Ufin);
1335 TopOpeBRepDS_Curve tcurv1(curv1,tolreached);
1336 TopOpeBRepDS_Curve tcurv2(curv2,tolreached);
1337 Icurv1=DStr.AddCurve(tcurv1);
1338 Icurv2=DStr.AddCurve(tcurv2);
1345 // interference of curv1 and curv2 on Ishape
1346 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv));
1347 ComputeCurve2d(curv1,Fop,c2d1);
1348 Handle(TopOpeBRepDS_SurfaceCurveInterference)
1349 InterFv = ChFi3d_FilCurveInDS(Icurv1,IShape,/*zob2dv*/c2d1,Et);
1350 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1351 ComputeCurve2d(curv2,Fop,c2d2);
1352 InterFv = ChFi3d_FilCurveInDS(Icurv2,IShape,/*zob2dv*/c2d2,Et);
1353 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1355 // limitation of the sewing edge
1356 Standard_Integer Iarc=DStr.AddShape(edgecouture);
1357 Handle(TopOpeBRepDS_CurvePointInterference) Interfedge;
1358 TopAbs_Orientation ori;
1359 TopoDS_Vertex Vdeb,Vfin;
1360 Vdeb=TopExp::FirstVertex(edgecouture);
1361 Vfin=TopExp::LastVertex(edgecouture);
1362 Standard_Real pard,parf;
1363 pard=BRep_Tool::Parameter(Vdeb,edgecouture);
1364 parf=BRep_Tool::Parameter(Vfin,edgecouture);
1365 if (Abs(par1-pard)<Abs(parf-par1)) ori=TopAbs_REVERSED;
1366 else ori=TopAbs_FORWARD;
1367 Interfedge = ChFi3d_FilPointInDS(ori,Iarc,indpt,par1);
1368 DStr.ChangeShapeInterferences(Iarc).Append(Interfedge);
1370 // interference of curv1 and curv2 on Iop
1371 Standard_Integer Iop = DStr.AddShape(Fop);
1372 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolop));
1373 Handle(TopOpeBRepDS_SurfaceCurveInterference) Interfop;
1374 ComputeCurve2d(curv1,Fop,c2d1);
1375 Interfop = ChFi3d_FilCurveInDS(Icurv1,Iop,c2d1,Et);
1376 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
1377 ComputeCurve2d(curv2,Fop,c2d2);
1378 Interfop = ChFi3d_FilCurveInDS(Icurv2,Iop,c2d2,Et);
1379 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
1380 Handle(TopOpeBRepDS_CurvePointInterference)
1381 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,Icurv1,IVtx,Udeb);
1382 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1383 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv1,indpt,par2);
1384 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
1385 Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc);
1386 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv2,indpt,par2);
1387 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1388 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv2,icc,Ufin);
1389 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
1392 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv));
1393 Handle(TopOpeBRepDS_SurfaceCurveInterference)
1394 InterFv = ChFi3d_FilCurveInDS(IZob,IShape,zob2dv,Et);
1395 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
1396 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolop));
1397 Standard_Integer Iop = DStr.AddShape(Fop);
1398 Handle(TopOpeBRepDS_SurfaceCurveInterference)
1399 Interfop = ChFi3d_FilCurveInDS(IZob,Iop,zob2dop,Et);
1400 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
1401 Handle(TopOpeBRepDS_CurvePointInterference) interfprol;
1403 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IVtx,Udeb);
1405 Standard_Integer IV2 = DStr.AddShape(V2); // VARIANT 2
1406 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IV2,Udeb);
1408 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
1409 Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc);
1410 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,IZob,icc,Ufin);
1411 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
1413 if (IFopArc == 1) box1.Add( zob3d->Value(Ufin) );
1414 else box2.Add( zob3d->Value(Ufin) );
1417 // cut off existing Arcprol
1418 Standard_Integer iArcprol = DStr.AddShape(Arcprol);
1419 interfprol = ChFi3d_FilPointInDS(OVtx,iArcprol,icc,Udeb);
1420 DStr.ChangeShapeInterferences(Arcprol).Append(interfprol);
1424 ChFi3d_EnlargeBox(DStr,stripe,Fd,box1,box2,isfirst);
1425 if (CV1.IsOnArc()) {
1426 ChFi3d_EnlargeBox(CV1.Arc(),myEFMap(CV1.Arc()),CV1.ParameterOnArc(),box1);
1428 if (CV2.IsOnArc()) {
1429 ChFi3d_EnlargeBox(CV2.Arc(),myEFMap(CV2.Arc()),CV2.ParameterOnArc(),box2);
1431 if (!CV1.IsVertex())
1432 ChFi3d_SetPointTolerance(DStr,box1,stripe->IndexPoint(isfirst,1));
1433 if (!CV2.IsVertex())
1434 ChFi3d_SetPointTolerance(DStr,box2,stripe->IndexPoint(isfirst,2));
1437 ChFi3d_ResultChron(ch, t_sameinter);//result perf condition if (same &&inter)
1441 //=======================================================================
1442 //function : cherche_face
1443 //purpose : find face F belonging to the map, different from faces
1444 // F1 F2 F3 and containing edge E
1445 //=======================================================================
1447 static void cherche_face (const TopTools_ListOfShape & map,
1448 const TopoDS_Edge & E,
1449 const TopoDS_Face & F1,
1450 const TopoDS_Face & F2,
1451 const TopoDS_Face & F3,
1454 Standard_Boolean trouve=Standard_False;
1455 TopTools_ListIteratorOfListOfShape It;
1456 Standard_Integer ie;
1457 for (It.Initialize(map);It.More()&&!trouve;It.Next())
1458 { Fcur=TopoDS::Face (It.Value());
1459 if (!Fcur.IsSame(F1) && !Fcur.IsSame(F2)&& !Fcur.IsSame(F3) )
1460 { TopTools_IndexedMapOfShape MapE;
1461 TopExp::MapShapes( Fcur,TopAbs_EDGE,MapE);
1462 for ( ie=1; ie<= MapE.Extent()&&!trouve; ie++)
1464 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE(ie));
1465 if (E.IsSame(TopoDS::Edge(aLocalShape)))
1466 // if (E.IsSame(TopoDS::Edge(TopoDS_Shape (MapE(ie)))))
1467 { F= Fcur; trouve=Standard_True;}
1473 //=======================================================================
1474 //function : cherche_edge1
1475 //purpose : find common edge between faces F1 and F2
1476 //=======================================================================
1478 static void cherche_edge1 (const TopoDS_Face & F1,
1479 const TopoDS_Face & F2,
1481 { Standard_Integer i,j;
1482 TopoDS_Edge Ecur1,Ecur2;
1483 Standard_Boolean trouve=Standard_False;
1484 TopTools_IndexedMapOfShape MapE1,MapE2;
1485 TopExp::MapShapes( F1,TopAbs_EDGE,MapE1);
1486 TopExp::MapShapes( F2,TopAbs_EDGE,MapE2);
1487 for ( i=1; i<= MapE1.Extent()&&!trouve; i++)
1489 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE1(i));
1490 Ecur1=TopoDS::Edge(aLocalShape);
1491 // Ecur1=TopoDS::Edge(TopoDS_Shape (MapE1(i)));
1492 for ( j=1; j<= MapE2.Extent()&&!trouve; j++)
1494 aLocalShape = TopoDS_Shape (MapE2(j));
1495 Ecur2=TopoDS::Edge(aLocalShape);
1496 // Ecur2=TopoDS::Edge(TopoDS_Shape (MapE2(j)));
1497 if (Ecur2.IsSame(Ecur1))
1498 {Edge=Ecur1;trouve=Standard_True;}
1503 //=======================================================================
1504 //function : containV
1505 //purpose : return true if vertex V belongs to F1
1506 //=======================================================================
1508 static Standard_Boolean containV(const TopoDS_Face & F1,
1509 const TopoDS_Vertex & V)
1510 { Standard_Integer i;
1512 Standard_Boolean trouve=Standard_False;
1513 Standard_Boolean contain=Standard_False;
1514 TopTools_IndexedMapOfShape MapV;
1515 TopExp::MapShapes( F1,TopAbs_VERTEX,MapV);
1516 for ( i=1; i<= MapV.Extent()&&!trouve; i++)
1518 TopoDS_Shape aLocalShape = TopoDS_Shape (MapV(i));
1519 Vcur=TopoDS::Vertex(aLocalShape);
1520 // Vcur=TopoDS::Vertex(TopoDS_Shape (MapV(i)));
1521 if (Vcur.IsSame(V) )
1522 {contain=Standard_True; trouve=Standard_True;}
1527 //=======================================================================
1528 //function : containE
1529 //purpose : return true if edge E belongs to F1
1530 //=======================================================================
1532 static Standard_Boolean containE(const TopoDS_Face & F1,
1533 const TopoDS_Edge & E)
1534 { Standard_Integer i;
1536 Standard_Boolean trouve=Standard_False;
1537 Standard_Boolean contain=Standard_False;
1538 TopTools_IndexedMapOfShape MapE;
1539 TopExp::MapShapes( F1,TopAbs_EDGE,MapE);
1540 for ( i=1; i<= MapE.Extent()&&!trouve; i++)
1542 TopoDS_Shape aLocalShape = TopoDS_Shape (MapE(i));
1543 Ecur=TopoDS::Edge(aLocalShape);
1544 // Ecur=TopoDS::Edge(TopoDS_Shape (MapE(i)));
1545 if (Ecur.IsSame(E) )
1546 {contain=Standard_True; trouve=Standard_True;}
1552 //=======================================================================
1553 //function : IsShrink
1554 //purpose : check if U (if <isU>==True) or V of points of <PC> is within
1555 // <tol> from <Param>, check points between <Pf> and <Pl>
1556 //=======================================================================
1558 static Standard_Boolean IsShrink(const Geom2dAdaptor_Curve PC,
1559 const Standard_Real Pf,
1560 const Standard_Real Pl,
1561 const Standard_Real Param,
1562 const Standard_Boolean isU,
1563 const Standard_Real tol)
1565 switch (PC.GetType()) {
1566 case GeomAbs_Line: {
1567 gp_Pnt2d P1 = PC.Value(Pf);
1568 gp_Pnt2d P2 = PC.Value(Pl);
1569 if (Abs(P1.Coord(isU ? 1 : 2) - Param) <= tol &&
1570 Abs(P2.Coord(isU ? 1 : 2) - Param) <= tol )
1571 return Standard_True;
1573 return Standard_False;
1575 case GeomAbs_BezierCurve:
1576 case GeomAbs_BSplineCurve: {
1577 math_FunctionSample aSample (Pf,Pl,10);
1579 for (i=1; i<=aSample.NbPoints(); i++) {
1580 gp_Pnt2d P = PC.Value(aSample.GetParameter(i));
1581 if (Abs(P.Coord(isU ? 1 : 2) - Param) > tol )
1582 return Standard_False;
1584 return Standard_True;
1588 return Standard_False;
1590 //=======================================================================
1591 //function : PerformIntersectionAtEnd
1593 //=======================================================================
1595 void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
1598 // intersection at end of fillet with at least two faces
1599 // process the following cases:
1600 // - top has n (n>3) adjacent edges
1601 // - top has 3 edges and fillet on one of edges touches
1602 // more than one face
1605 OSD_Chronometer ch;// init perf
1608 TopOpeBRepDS_DataStructure& DStr= myDS->ChangeDS();
1609 const Standard_Integer nn=15;
1610 ChFiDS_ListIteratorOfListOfStripe It;
1611 It.Initialize(myVDataMap(Index));
1612 Handle(ChFiDS_Stripe) stripe = It.Value();
1613 const Handle(ChFiDS_Spine) spine = stripe->Spine();
1614 ChFiDS_SequenceOfSurfData& SeqFil =
1615 stripe->ChangeSetOfSurfData()->ChangeSequence();
1616 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
1617 Standard_Integer sens = 0,num,num1;
1618 Standard_Boolean couture=Standard_False,isfirst;
1619 //Standard_Integer sense;
1620 TopoDS_Edge edgelibre1,edgelibre2,EdgeSpine;
1621 Standard_Boolean bordlibre;
1622 // determine the number of faces and edges
1623 TopTools_Array1OfShape tabedg(0,nn);
1625 Standard_Integer nface=ChFi3d_nbface(myVFMap(Vtx));
1626 TopTools_ListIteratorOfListOfShape ItF;
1627 Standard_Integer nbarete;
1628 nbarete=ChFi3d_NbNotDegeneratedEdges(Vtx,myVEMap);
1629 ChFi3d_ChercheBordsLibres(myVEMap,Vtx,bordlibre,edgelibre1,edgelibre2);
1630 if (bordlibre) nbarete=(nbarete-2)/2 +2;
1631 else nbarete=nbarete/2;
1632 // it is determined if there is an edge of sewing and it face
1634 TopoDS_Face facecouture;
1635 TopoDS_Edge edgecouture;
1637 Standard_Boolean trouve=Standard_False;
1638 for(ItF.Initialize(myVFMap(Vtx));ItF.More()&&!couture;ItF.Next()) {
1639 TopoDS_Face fcur = TopoDS::Face(ItF.Value());
1640 ChFi3d_CoutureOnVertex(fcur,Vtx,couture,edgecouture);
1644 // it is determined if one of edges adjacent to the fillet is regular
1645 Standard_Boolean reg1,reg2;
1646 TopoDS_Edge Ecur,Eadj1,Eadj2;
1647 TopoDS_Face Fga,Fdr;
1648 TopoDS_Vertex Vbid1;
1649 Standard_Integer nbsurf,nbedge;
1650 reg1=Standard_False;
1651 reg2=Standard_False;
1652 nbsurf= SeqFil.Length();
1653 nbedge = spine->NbEdges();
1654 num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
1655 isfirst = (sens == 1);
1658 EdgeSpine=spine->Edges(1);
1660 state = spine->FirstStatus();
1663 EdgeSpine=spine->Edges(nbedge);
1665 state = spine->LastStatus();
1667 if (nbsurf!=nbedge && nbsurf!=1) {
1668 ChFi3d_edge_common_faces(myEFMap(EdgeSpine),F1,F2);
1669 if (F1.IsSame(facecouture)) Eadj1=edgecouture;
1670 else ChFi3d_cherche_element(Vtx,EdgeSpine,F1,Eadj1,Vbid1);
1671 ChFi3d_edge_common_faces(myEFMap(Eadj1),Fga,Fdr);
1672 // Modified by Sergey KHROMOV - Fri Dec 21 17:57:32 2001 Begin
1673 // reg1=BRep_Tool::Continuity(Eadj1,Fga,Fdr)!=GeomAbs_C0;
1674 reg1=isTangentFaces(Eadj1,Fga,Fdr);
1675 // Modified by Sergey KHROMOV - Fri Dec 21 17:57:33 2001 End
1676 if (F2.IsSame(facecouture)) Eadj2=edgecouture;
1677 else ChFi3d_cherche_element(Vtx,EdgeSpine,F2,Eadj2,Vbid1);
1678 ChFi3d_edge_common_faces(myEFMap(Eadj2),Fga,Fdr);
1679 // Modified by Sergey KHROMOV - Fri Dec 21 17:58:22 2001 Begin
1680 // reg2=BRep_Tool::Continuity(Eadj2,Fga,Fdr)!=GeomAbs_C0;
1681 reg2=isTangentFaces(Eadj2,Fga,Fdr);
1682 // Modified by Sergey KHROMOV - Fri Dec 21 17:58:24 2001 End
1684 // two faces common to the edge are found
1686 Standard_Boolean compoint1=Standard_False;
1687 Standard_Boolean compoint2=Standard_False;
1688 ChFiDS_CommonPoint cp1, cp2;
1689 cp1 = SeqFil(num1)->ChangeVertex (isfirst,1);
1690 cp2 = SeqFil(num1)->ChangeVertex (isfirst,2);
1691 if (cp1.IsOnArc()) {
1692 if (cp1.Arc().IsSame(Eadj1)||cp1.Arc().IsSame(Eadj2))
1693 compoint1=Standard_True;
1695 if (cp2.IsOnArc()) {
1696 if (cp2.Arc().IsSame(Eadj1)||cp2.Arc().IsSame(Eadj2))
1697 compoint2=Standard_True;
1699 if (compoint1 && compoint2) {
1701 reg1=Standard_False; reg2=Standard_False;
1705 // there is only one face at end if FindFace is true and if the face
1706 // is not the face with sewing edge
1708 Handle(ChFiDS_SurfData) Fd = SeqFil.ChangeValue(num);
1709 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
1710 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
1711 Standard_Boolean onecorner=Standard_False;
1712 if (FindFace(Vtx,CV1,CV2,face)) {
1713 if (!couture) onecorner =Standard_True;
1714 else if (!face.IsSame(facecouture))
1715 onecorner=Standard_True;
1718 if (ChFi3d_Builder::MoreSurfdata(Index)) {
1719 ChFi3d_Builder::PerformMoreSurfdata(Index);
1723 if (!onecorner && (reg1||reg2) && !couture && state!=ChFiDS_OnSame) {
1724 PerformMoreThreeCorner (Index,1);
1727 Handle(GeomAdaptor_HSurface) HGs = ChFi3d_BoundSurf(DStr,Fd,1,2);
1728 ChFiDS_FaceInterference Fi1 = Fd->InterferenceOnS1();
1729 ChFiDS_FaceInterference Fi2 = Fd->InterferenceOnS2();
1730 GeomAdaptor_Surface& Gs = HGs->ChangeSurface();
1731 Handle(BRepAdaptor_HSurface) HBs = new BRepAdaptor_HSurface();
1732 BRepAdaptor_Surface& Bs = HBs->ChangeSurface();
1733 Handle(Geom_Curve) Cc;
1734 Handle(Geom2d_Curve) Pc,Ps;
1735 Standard_Real Ubid,Vbid;
1736 TopAbs_Orientation orsurfdata;
1737 orsurfdata=Fd->Orientation();
1738 Standard_Integer IsurfPrev=0, Isurf=Fd->Surf();
1739 Handle(ChFiDS_SurfData) SDprev;
1740 if (num1>0 && num1<=SeqFil.Length()) {
1741 SDprev = SeqFil(num1);
1742 IsurfPrev = SDprev->Surf();
1744 // calculate the orientation of curves at end
1746 Standard_Real tolpt=1.e-4;
1747 Standard_Real tolreached;
1748 TopAbs_Orientation orcourbe,orface,orien;
1750 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV1,DStr),isfirst,1);
1751 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV2,DStr),isfirst,2);
1756 Standard_Integer Ishape1=Fd->IndexOfS1();
1758 TopAbs_Orientation trafil1 = TopAbs_FORWARD;
1760 TopAbs_Orientation trafil1;
1764 trafil1 = DStr.Shape(Ishape1).Orientation();
1768 cout<<"erreur"<<endl;
1771 trafil1 = TopAbs::Compose(trafil1,Fd->Orientation());
1773 trafil1 = TopAbs::Compose(TopAbs::Reverse(Fi1.Transition()),trafil1);
1776 else cout<<"erreur"<<endl;
1778 // eap, Apr 22 2002, occ 293
1779 // Fi1.PCurveOnFace()->D0(Fi1.LastParameter(),p2d);
1780 // const Handle(Geom_Surface) Stemp =
1781 // BRep_Tool::Surface(TopoDS::Face(DStr.Shape(Ishape1)));
1782 // Stemp ->D0(p2d.X(),p2d.Y(),p3d);
1783 // dist=p3d.Distance(CV1.Point());
1784 // if (dist<tolpt) orcourbe=trafil1;
1785 // else orcourbe=TopAbs::Reverse(trafil1);
1786 if (!isfirst) orcourbe=trafil1;
1787 else orcourbe=TopAbs::Reverse(trafil1);
1789 // eap, Apr 22 2002, occ 293
1790 // variables to show OnSame situation
1791 Standard_Boolean isOnSame1, isOnSame2;
1792 // In OnSame situation, the case of degenerated FaceInterference curve
1793 // is probable when a corner cuts the ChFi3d earlier built on OnSame edge.
1794 // In such a case, chamfer face can partially shrink to a line and we need
1795 // to cut off that shrinked part
1796 // If <isOnSame1>, FaceInterference with F2 can be degenerated
1797 Standard_Boolean checkShrink, isShrink, isUShrink;
1798 isShrink = isUShrink = isOnSame1 = isOnSame2 = Standard_False;
1799 Standard_Real checkShrParam=0., prevSDParam=0.;
1801 Standard_Integer midIpoint=0;
1803 // find Fi1,Fi2 lengths used to extend ChFi surface
1804 // and by the way define necessity to check shrink
1805 gp_Pnt2d P2d1=Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));
1806 gp_Pnt2d P2d2=Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
1808 HGs->D0( P2d1.X(),P2d1.Y(),aP1);
1809 HGs->D0( P2d2.X(),P2d2.Y(),aP2);
1810 Standard_Real Fi1Length=aP1.Distance(aP2);
1811 // Standard_Real eps = Precision::Confusion();
1812 checkShrink = (Fi1Length <= Precision::Confusion());
1814 gp_Pnt2d P2d3=Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
1815 gp_Pnt2d P2d4=Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
1816 HGs->D0( P2d3.X(),P2d3.Y(),aP1);
1817 HGs->D0( P2d4.X(),P2d4.Y(),aP2);
1818 Standard_Real Fi2Length=aP1.Distance(aP2);
1819 checkShrink = checkShrink || (Fi2Length <= Precision::Confusion());
1822 if (Abs(P2d2.Y()-P2d4.Y()) <= Precision::PConfusion()) {
1823 isUShrink = Standard_False;
1824 checkShrParam = P2d2.Y();
1825 } else if (Abs(P2d2.X()-P2d4.X()) <= Precision::PConfusion()) {
1826 isUShrink = Standard_True;
1827 checkShrParam = P2d2.X();
1830 checkShrink = Standard_False;
1833 /***********************************************************************/
1834 // find faces intersecting with the fillet and edges limiting intersections
1835 // nbface is the nb of faces intersected, Face[i] contais the faces
1836 // to intersect (i=0.. nbface-1). Edge[i] contains edges limiting
1837 // the intersections (i=0 ..nbface)
1838 /**********************************************************************/
1840 Standard_Integer nb = 1,nbface;
1841 TopoDS_Edge E1 ,E2, Edge[nn],E,Ei,edgesau;
1842 TopoDS_Face facesau;
1843 Standard_Boolean oneintersection1=Standard_False;
1844 Standard_Boolean oneintersection2=Standard_False;
1845 TopoDS_Face Face[nn],F,F3;
1846 TopoDS_Vertex V1,V2,V,Vfin;
1847 Standard_Boolean findonf1=Standard_False,findonf2=Standard_False;
1848 TopTools_ListIteratorOfListOfShape It3;
1849 F1=TopoDS::Face(DStr.Shape(Fd->IndexOfS1()));
1850 F2=TopoDS::Face(DStr.Shape(Fd->IndexOfS2()));
1852 if (couture || bordlibre) nface=nface+1;
1853 if (nface==3) nbface=2;
1854 else nbface=nface-2;
1855 if (!CV1.IsOnArc()||!CV2.IsOnArc()) {
1856 PerformMoreThreeCorner(Index,1);
1861 Edge[nbface]=CV2.Arc();
1862 tabedg.SetValue(0,Edge[0]);
1863 tabedg.SetValue(nbface,Edge[nbface]);
1864 // processing of a fillet arriving on a vertex
1865 // edge contained in CV.Arc is not inevitably good
1866 // the edge concerned by the intersection is found
1868 Standard_Real dist1,dist2;
1869 if (CV1.IsVertex()) {
1870 trouve=Standard_False;
1871 /*TopoDS_Vertex */V=CV1.Vertex();
1872 for (It3.Initialize(myVEMap(V));It3.More()&&!trouve;It3.Next()) {
1873 E=TopoDS::Edge (It3.Value());
1874 if (!E.IsSame(Edge[0])&&(containE(F1,E)))
1875 trouve=Standard_True;
1877 TopoDS_Vertex Vt,V3,V4;
1878 V1=TopExp::FirstVertex(Edge[0]);
1879 V2=TopExp::LastVertex(Edge[0]);
1880 if (V.IsSame(V1)) Vt=V2;
1882 dist1=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1883 V3=TopExp::FirstVertex(E);
1884 V4=TopExp::LastVertex(E);
1885 if (V.IsSame(V3)) Vt=V4;
1887 dist2=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1890 TopAbs_Orientation ori;
1891 if (V2.IsSame(V3)||V1.IsSame(V4)) ori=CV1.TransitionOnArc();
1892 else ori=TopAbs::Reverse(CV1.TransitionOnArc());
1893 Standard_Real par= BRep_Tool::Parameter(V,Edge[0]);
1894 Standard_Real tol= CV1.Tolerance();
1895 CV1.SetArc(tol,Edge[0],par,ori);
1899 if (CV2.IsVertex()) {
1900 trouve=Standard_False;
1901 /*TopoDS_Vertex*/ V=CV2.Vertex();
1902 for (It3.Initialize(myVEMap(V));It3.More()&&!trouve;It3.Next()) {
1903 E=TopoDS::Edge (It3.Value());
1904 if (!E.IsSame(Edge[2])&&(containE(F2,E)))
1905 trouve=Standard_True;
1907 TopoDS_Vertex Vt,V3,V4;
1908 V1=TopExp::FirstVertex(Edge[2]);
1909 V2=TopExp::LastVertex(Edge[2]);
1910 if (V.IsSame(V1)) Vt=V2;
1912 dist1=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1913 V3=TopExp::FirstVertex(E);
1914 V4=TopExp::LastVertex(E);
1915 if (V.IsSame(V3)) Vt=V4;
1917 dist2=(BRep_Tool::Pnt(Vt)).Distance(BRep_Tool::Pnt(Vtx));
1920 TopAbs_Orientation ori;
1921 if (V2.IsSame(V3)||V1.IsSame(V4)) ori=CV2.TransitionOnArc();
1922 else ori=TopAbs::Reverse(CV2.TransitionOnArc());
1923 Standard_Real par= BRep_Tool::Parameter(V,Edge[2]);
1924 Standard_Real tol= CV2.Tolerance();
1925 CV2.SetArc(tol,Edge[2],par,ori);
1929 // If there is a regular edge, the faces adjacent to it
1930 // are not in Fd->IndexOfS1 or Fd->IndexOfS2
1932 // TopoDS_Face Find1 ,Find2;
1934 // edge=stripe->Spine()->Edges(1);
1935 // else edge=stripe->Spine()->Edges(stripe->Spine()->NbEdges());
1936 // It3.Initialize(myEFMap(edge));
1937 // Find1=TopoDS::Face(It3.Value());
1938 // trouve=Standard_False;
1939 // for (It3.Initialize(myEFMap(edge));It3.More()&&!trouve;It3.Next()) {
1940 // F=TopoDS::Face (It3.Value());
1941 // if (!F.IsSame(Find1)) {
1942 // Find2=F;trouve=Standard_True;
1946 // if nface =3 there is a top with 3 edges and a fillet
1947 // and their common points are on different faces
1948 // otherwise there is a case when a top has more than 3 edges
1951 if (CV1.IsVertex ()) findonf1=Standard_True;
1952 if (CV2.IsVertex ()) findonf2=Standard_True;
1954 TopTools_IndexedMapOfShape MapV;
1955 TopExp::MapShapes(Edge[0], TopAbs_VERTEX, MapV);
1956 if (MapV.Extent()==2)
1957 if (!MapV(1).IsSame(Vtx) && !MapV(2).IsSame(Vtx))
1958 findonf1=Standard_True;
1961 TopTools_IndexedMapOfShape MapV;
1962 TopExp::MapShapes(Edge[2], TopAbs_VERTEX, MapV);
1963 if (MapV.Extent()==2)
1964 if (!MapV(1).IsSame(Vtx) && !MapV(2).IsSame(Vtx))
1965 findonf2=Standard_True;
1968 // detect and process OnSame situatuation
1969 if (state == ChFiDS_OnSame) {
1970 TopoDS_Edge threeE[3];
1971 ChFi3d_cherche_element(Vtx,EdgeSpine, F1,threeE[0], V2);
1972 ChFi3d_cherche_element(Vtx,EdgeSpine, F2,threeE[1], V2);
1973 threeE[2] = EdgeSpine;
1974 if (ChFi3d_EdgeState(threeE,myEFMap) == ChFiDS_OnSame) {
1975 isOnSame1 = Standard_True;
1977 Edge[0] = threeE[0];
1978 ChFi3d_cherche_face1(myEFMap(Edge[0]),F1,Face[0]);
1980 findonf1 = Standard_True; // not to look for Face[0] again
1985 isOnSame2 = Standard_True;
1989 // findonf1 findonf2 show if F1 and/or F2 are adjacent
1990 // to many faces at end
1991 // the faces at end and intersected edges are found
1993 if (findonf1 && !isOnSame1) {
1994 if (CV1.TransitionOnArc()==TopAbs_FORWARD)
1995 V1=TopExp::FirstVertex(CV1.Arc());
1997 V1=TopExp::LastVertex(CV1.Arc());
1998 ChFi3d_cherche_face1(myEFMap(CV1.Arc()),F1,Face[0]);
2001 while (!V1.IsSame(Vtx)) {
2002 ChFi3d_cherche_element(V1,Ei,F1,E,V2);
2004 ChFi3d_cherche_face1(myEFMap(E),F1,Face[nb]);
2005 cherche_edge1(Face[nb-1],Face[nb],Edge[nb]);
2007 if (nb>=nn) Standard_Failure::Raise
2008 ("IntersectionAtEnd : the max number of faces reached");
2010 if (!findonf2) Edge[nb]=CV2.Arc();
2012 if (findonf2 && !isOnSame2) {
2013 if (!findonf1 ) nb=1;
2015 if (CV2.TransitionOnArc()==TopAbs_FORWARD)
2016 Vfin=TopExp::LastVertex(CV2.Arc());
2018 Vfin=TopExp::FirstVertex(CV2.Arc());
2019 if (!findonf1) ChFi3d_cherche_face1(myEFMap(CV1.Arc()),F1,Face[nb-1]);
2020 ChFi3d_cherche_element(V1,EdgeSpine,F2,E,V2);
2022 while (!V1.IsSame(Vfin)) {
2023 ChFi3d_cherche_element(V1,Ei,F2,E,V2);
2026 ChFi3d_cherche_face1(myEFMap(E),F2,Face[nb]);
2027 cherche_edge1(Face[nb-1],Face[nb],Edge[nb]);
2029 if (nb>=nn) Standard_Failure::Raise
2030 ("IntersectionAtEnd : the max number of faces reached");
2035 cherche_edge1(Face[nb-1],F2,Edge[nb]);
2044 // this is the case when a top has more than three edges
2045 // the faces and edges concerned are found
2046 Standard_Boolean /*trouve,*/possible1, possible2;
2047 trouve = possible1 = possible2 = Standard_False;
2050 for (ex.Init(CV1.Arc(),TopAbs_VERTEX);ex.More();ex.Next()) {
2051 if (Vtx.IsSame(ex.Current())) possible1 = Standard_True;
2053 for (ex.Init(CV2.Arc(),TopAbs_VERTEX);ex.More();ex.Next()) {
2054 if (Vtx.IsSame(ex.Current())) possible2 = Standard_True;
2056 if ((possible1 && possible2) || (!possible1 && !possible2) || (nbarete > 4)) {
2059 if (nb!=1) F3=Face[nb-2];
2061 if (CV1.Arc().IsSame(edgelibre1))
2062 cherche_face(myVFMap(Vtx),edgelibre2,F1,F2,F3,Face[nb-1]);
2063 else if (CV1.Arc().IsSame(edgelibre2))
2064 cherche_face(myVFMap(Vtx),edgelibre1,F1,F2,F3,Face[nb-1]);
2065 else cherche_face(myVFMap(Vtx),Edge[nb-1],F1,F2,F3,Face[nb-1]);
2066 ChFi3d_cherche_edge(Vtx,tabedg,Face[nb-1],Edge[nb],V);
2067 tabedg.SetValue(nb,Edge[nb]);
2068 if (Edge[nb].IsSame(CV2.Arc())) trouve=Standard_True;
2073 IntersectMoreCorner (Index);
2077 // if two consecutive edges are G1 there is only one face of intersection
2078 Standard_Real ang1=0.0;
2080 trouve=Standard_False;
2081 ChFi3d_cherche_vertex ( Edge[0],Edge[1],Vcom,trouve);
2082 if (Vcom.IsSame(Vtx)) ang1=ChFi3d_AngleEdge(Vtx,Edge[0],Edge[1]);
2083 if (Abs(ang1-M_PI)<0.01) {
2084 oneintersection1=Standard_True;
2092 if (!oneintersection1) {
2093 trouve=Standard_False;
2094 ChFi3d_cherche_vertex ( Edge[1],Edge[2],Vcom,trouve);
2095 if (Vcom.IsSame(Vtx)) ang1=ChFi3d_AngleEdge(Vtx,Edge[1],Edge[2]);
2096 if (Abs(ang1-M_PI)<0.01) {
2097 oneintersection2=Standard_True;
2105 else if (nbarete==5) {
2107 // Modified by Sergey KHROMOV - Fri Dec 21 18:07:43 2001 End
2108 Standard_Boolean isTangent0 = isTangentFaces(Edge[0],F1,Face[0]);
2109 Standard_Boolean isTangent1 = isTangentFaces(Edge[1],Face[0],Face[1]);
2110 Standard_Boolean isTangent2 = isTangentFaces(Edge[2],Face[1],Face[2]);
2111 if ((isTangent0 || isTangent2) && isTangent1) {
2112 // GeomAbs_Shape cont0,cont1,cont2;
2113 // cont0=BRep_Tool::Continuity(Edge[0],F1,Face[0]);
2114 // cont1=BRep_Tool::Continuity(Edge[1],Face[0],Face[1]);
2115 // cont2=BRep_Tool::Continuity(Edge[2],Face[1],Face[2]);
2116 // if ((cont0!=GeomAbs_C0 || cont2!=GeomAbs_C0) && cont1!=GeomAbs_C0) {
2117 // Modified by Sergey KHROMOV - Fri Dec 21 18:07:49 2001 Begin
2123 oneintersection1=Standard_True;
2134 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
2135 gp_Pnt2d pfil1,pfac1,pfil2,pfac2,pint,pfildeb;
2136 Handle(Geom2d_Curve) Hc1,Hc2;
2137 IntCurveSurface_HInter inters;
2138 Standard_Integer proledge[nn],prolface[nn+1];// last prolface[nn] is for Fd
2139 Standard_Integer shrink[nn];
2140 TopoDS_Face faceprol[nn];
2141 Standard_Integer indcurve[nn],indpoint2=0,indpoint1 = 0;
2142 Handle (TopOpeBRepDS_CurvePointInterference) Interfp1, Interfp2, Interfedge[nn];
2143 Handle (TopOpeBRepDS_SurfaceCurveInterference) Interfc,InterfPC[nn],InterfPS[nn];
2144 Standard_Real u2,v2,p1,p2,paredge1;
2145 Standard_Real paredge2 = 0.,tolex = 1.e-4;
2146 Standard_Boolean extend=Standard_False;
2147 Handle(Geom_Surface) Sfacemoins1,Sface;
2148 /***************************************************************************/
2149 // calculate intersection of the fillet and each face
2150 // and storage in the DS
2151 /***************************************************************************/
2152 for (nb=1;nb<=nbface;nb++) {
2159 if (oneintersection1||oneintersection2) faceprol[1]=facesau;
2160 if (!isOnSame1 && !isOnSame2)
2161 checkShrink = Standard_False;
2162 // in OnSame situation we need intersect Fd with Edge[0] or Edge[nbface] as well
2163 if (isOnSame1) nb=0;
2165 Standard_Boolean intersOnSameFailed = Standard_False;
2167 for ( ; nb<=nbface; nb++) {
2168 extend=Standard_False;
2174 if (!prolface[nb-1]) faceprol[nb-1]=F;
2176 Sfacemoins1=BRep_Tool::Surface(F);
2177 Handle(Geom_Curve) cint;
2178 Handle(Geom2d_Curve) C2dint1, C2dint2,cface,cfacemoins1;
2180 ///////////////////////////////////////////////////////
2181 // determine intersections of edges and the fillet
2182 // to find limitations of intersections face - fillet
2183 ///////////////////////////////////////////////////////
2186 Hc1 = BRep_Tool::CurveOnSurface(Edge[0],Face[0],Ubid,Ubid);
2188 // update interference param on Fi1 and point of CV1
2189 if (prolface[0]) Bs.Initialize(faceprol[0], Standard_False);
2190 else Bs.Initialize(Face[0], Standard_False);
2191 const Handle(Geom_Curve)& c3df = DStr.Curve(Fi1.LineIndex()).Curve();
2192 Standard_Real Ufi= Fi2.Parameter(isfirst);
2193 ChFiDS_FaceInterference& Fi = Fd->ChangeInterferenceOnS1();
2194 if (!IntersUpdateOnSame (HGs,HBs,c3df,F1,Face[0],Edge[0],Vtx,isfirst,10*tolesp, // in
2195 Fi,CV1,pfac1,Ufi)) // out
2196 Standard_Failure::Raise("IntersectionAtEnd: pb intersection Face - Fi");
2198 if (intersOnSameFailed) { // probable at fillet building
2199 // look for paredge2
2200 Geom2dAPI_ProjectPointOnCurve proj;
2201 if (C2dint2.IsNull()) proj.Init(pfac1,Hc1);
2202 else proj.Init(pfac1,C2dint2);
2203 paredge2 = proj.LowerDistanceParameter();
2205 // update stripe point
2206 TopOpeBRepDS_Point tpoint (CV1.Point(),tolesp);
2207 indpoint1=DStr.AddPoint(tpoint);
2208 stripe->SetIndexPoint(indpoint1,isfirst,1);
2210 TopoDS_Vertex vert1,vert2;
2211 TopExp::Vertices(Edge[0],vert1,vert2);
2212 TopAbs_Orientation arcOri = Vtx.IsSame(vert1) ? TopAbs_FORWARD : TopAbs_REVERSED;
2213 CV1.SetArc(tolesp,Edge[0],paredge2,arcOri);
2217 // curve 2d not found. Sfacemoins1 is extended and projection is done there
2219 ChFi3d_ExtendSurface(Sfacemoins1,prolface[0]);
2221 extend=Standard_True;
2223 Standard_Real tol=BRep_Tool::Tolerance(F);
2224 BRE.MakeFace(faceprol[0],Sfacemoins1,F.Location(),tol);
2226 GeomAdaptor_Surface Asurf;
2227 Asurf.Load(Sfacemoins1);
2228 Extrema_ExtPS ext (CV1.Point(),Asurf, tol,tol);
2229 Standard_Real uc1,vc1;
2231 ext.Point(1).Parameter(uc1,vc1);
2239 pfac1 = Hc1->Value(CV1.ParameterOnArc());
2241 paredge1=CV1.ParameterOnArc();
2242 if (Fi1.LineIndex() != 0) {
2243 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));}
2245 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));}
2254 if (nb!=nbface || isOnSame2) {
2255 Standard_Integer nbp;
2257 Handle(Geom_Curve) C;
2258 C=BRep_Tool::Curve(E2,Ubid,Vbid);
2259 Handle(Geom_TrimmedCurve) Ctrim = new Geom_TrimmedCurve(C,Ubid,Vbid);
2260 Standard_Real Utrim,Vtrim;
2261 Utrim=Ctrim->BasisCurve()->FirstParameter();
2262 Vtrim=Ctrim->BasisCurve()->LastParameter();
2263 if (Ctrim->IsPeriodic()) {
2264 if (Ubid>Ctrim->Period()) {
2265 Ubid=(Utrim+Vtrim)/2;
2270 Vbid=(Utrim+Vtrim)/2;
2277 Handle(GeomAdaptor_HCurve) HC =
2278 new GeomAdaptor_HCurve(C,Ubid,Vbid);
2279 GeomAdaptor_Curve & Cad =HC->ChangeCurve();
2280 inters.Perform(HC, HGs);
2281 if ( !prolface[nn] && ( !inters.IsDone() || (inters.NbPoints()==0) )) {
2282 // extend surface of conge
2283 Handle(Geom_BSplineSurface) S1=
2284 Handle(Geom_BSplineSurface)::DownCast(DStr.Surface(Fd->Surf()).Surface());
2286 Standard_Real length = 0.5 * Max(Fi1Length,Fi2Length);
2287 GeomLib::ExtendSurfByLength(S1,length,1,Standard_False,!isfirst);
2289 if (!stripe->IsInDS(!isfirst)) {
2291 inters.Perform(HC, HGs);
2292 if (inters.IsDone()&& inters.NbPoints()!=0) {
2293 Fd->ChangeSurf(DStr.AddSurface(TopOpeBRepDS_Surface(S1, DStr.ChangeSurface(Isurf).Tolerance())));
2299 if (!inters.IsDone() || (inters.NbPoints()==0)) {
2300 Handle(Geom_BSplineCurve) cd=Handle(Geom_BSplineCurve)::DownCast(C);
2301 Handle(Geom_BezierCurve) cd1=Handle(Geom_BezierCurve)::DownCast(C);
2302 if (!cd.IsNull() || !cd1.IsNull() ) {
2304 Sface=BRep_Tool::Surface(Face[nb]);
2305 ChFi3d_ExtendSurface(Sface,prolface[nb]);
2306 Standard_Real tol=BRep_Tool::Tolerance(F);
2307 BRE.MakeFace(faceprol[nb],Sface,Face[nb].Location(),tol);
2308 if (nb && !prolface[nb-1]) {
2309 ChFi3d_ExtendSurface(Sfacemoins1,prolface[nb-1]);
2310 if (prolface[nb-1]) {
2311 tol=BRep_Tool::Tolerance(F);
2312 BRE.MakeFace(faceprol[nb-1],Sfacemoins1,F.Location(),tol);
2316 Standard_Integer prol = 0;
2317 ChFi3d_ExtendSurface(Sfacemoins1,prol);
2319 GeomInt_IntSS InterSS(Sfacemoins1,Sface,1.e-7,1,1,1);
2320 if (InterSS.IsDone()) {
2321 trouve=Standard_False;
2322 for (Standard_Integer i=1; i<=InterSS.NbLines() && !trouve; i++) {
2323 extend=Standard_True;
2324 cint= InterSS.Line(i);
2325 C2dint1= InterSS.LineOnS1(i);
2326 C2dint2= InterSS.LineOnS2(i);
2328 inters.Perform(HC, HGs);
2329 trouve=inters.IsDone()&&inters.NbPoints()!=0;
2330 // eap occ293, eval tolex on finally trimmed curves
2331 // Handle(GeomAdaptor_HSurface) H1=new GeomAdaptor_HSurface(Sfacemoins1);
2332 // Handle(GeomAdaptor_HSurface) H2=new GeomAdaptor_HSurface(Sface);
2333 // tolex=ChFi3d_EvalTolReached(H1,C2dint1,H2,C2dint2,cint);
2334 tolex = InterSS.TolReached3d();
2339 if (inters.IsDone()) {
2340 nbp = inters.NbPoints();
2342 if (nb==0 || nb==nbface)
2343 intersOnSameFailed = Standard_True;
2345 PerformMoreThreeCorner (Index,1);
2350 gp_Pnt P=BRep_Tool::Pnt(Vtx);
2351 Standard_Real distmin=P.Distance(inters.Point(1).Pnt());
2353 for (Standard_Integer i=2;i<=inters.NbPoints();i++) {
2354 dist=P.Distance(inters.Point(i).Pnt());
2360 gp_Pnt2d pt2d (inters.Point(nbp).U(),inters.Point(nbp).V());
2362 paredge2=inters.Point(nbp).W();
2364 cfacemoins1=BRep_Tool::CurveOnSurface(E2,F,u2,v2);
2365 cface=BRep_Tool::CurveOnSurface(E2,Face[nb],u2,v2);
2366 cfacemoins1->D0(paredge2,pfac2);
2367 cface->D0(paredge2,pint);
2370 C2dint1->D0(paredge2,pfac2);
2371 C2dint2->D0(paredge2,pint);
2375 else Standard_Failure::Raise("IntersectionAtEnd: pb intersection Face cb");
2378 Hc2 = BRep_Tool::CurveOnSurface(E2,Face[nbface-1],Ubid,Ubid);
2380 // curve 2d is not found, Sfacemoins1 is extended CV2.Point() is projected there
2382 ChFi3d_ExtendSurface(Sfacemoins1,prolface[0]);
2385 extend=Standard_True;
2386 Standard_Real tol=BRep_Tool::Tolerance(F);
2387 BRE.MakeFace(faceprol[nb-1],Sfacemoins1,F.Location(),tol);
2388 GeomAdaptor_Surface Asurf;
2389 Asurf.Load(Sfacemoins1);
2390 Extrema_ExtPS ext (CV2.Point(),Asurf,tol,tol);
2391 Standard_Real uc2,vc2;
2393 ext.Point(1).Parameter(uc2,vc2);
2399 else pfac2 = Hc2->Value(CV2.ParameterOnArc());
2400 paredge2=CV2.ParameterOnArc();
2401 if (Fi2.LineIndex() != 0) {
2402 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
2405 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
2408 if (!nb) continue; // found paredge1 on Edge[0] in OnSame situation on F1
2410 if (nb==nbface && isOnSame2) {
2411 // update interference param on Fi2 and point of CV2
2412 if (prolface[nb-1]) Bs.Initialize(faceprol[nb-1]);
2413 else Bs.Initialize(Face[nb-1]);
2414 const Handle(Geom_Curve)& c3df = DStr.Curve(Fi2.LineIndex()).Curve();
2415 Standard_Real Ufi= Fi1.Parameter(isfirst);
2416 ChFiDS_FaceInterference& Fi = Fd->ChangeInterferenceOnS2();
2417 if (!IntersUpdateOnSame (HGs,HBs,c3df,F2,F,Edge[nb],Vtx,isfirst,10*tolesp, // in
2418 Fi,CV2,pfac2,Ufi)) // out
2419 Standard_Failure::Raise("IntersectionAtEnd: pb intersection Face - Fi");
2421 if (intersOnSameFailed) { // probable at fillet building
2422 // look for paredge2
2423 Geom2dAPI_ProjectPointOnCurve proj;
2425 proj.Init(pfac2, C2dint2);
2427 proj.Init(pfac2, BRep_Tool::CurveOnSurface (E2,Face[nbface-1],Ubid,Ubid));
2428 paredge2 = proj.LowerDistanceParameter();
2430 // update stripe point
2431 TopOpeBRepDS_Point tpoint (CV2.Point(),tolesp);
2432 indpoint2=DStr.AddPoint(tpoint);
2433 stripe->SetIndexPoint(indpoint2,isfirst,2);
2435 TopoDS_Vertex vert1,vert2;
2436 TopExp::Vertices(Edge[nbface],vert1,vert2);
2437 TopAbs_Orientation arcOri = Vtx.IsSame(vert1) ? TopAbs_FORWARD : TopAbs_REVERSED;
2438 CV2.SetArc(tolesp,Edge[nbface],paredge2,arcOri);
2442 if (prolface[nb-1]) Bs.Initialize(faceprol[nb-1]);
2443 else Bs.Initialize(Face[nb-1]);
2445 // offset of parameters if they are not in the same period
2447 // commented by eap 30 May 2002 occ354
2448 // the following code may cause trimming a wrong part of periodic surface
2450 // Standard_Real deb,xx1,xx2;
2451 // Standard_Boolean moins2pi,moins2pi1,moins2pi2;
2452 // if (DStr.Surface(Fd->Surf()).Surface()->IsUPeriodic()) {
2456 // moins2pi=Abs(deb)< Abs(Abs(deb)-2*M_PI);
2457 // moins2pi1=Abs(xx1)< Abs(Abs(xx1)-2*M_PI);
2458 // moins2pi2=Abs(xx2)< Abs(Abs(xx2)-2*M_PI);
2459 // if (moins2pi1!=moins2pi2) {
2461 // if (!moins2pi1) xx1=xx1-2*M_PI;
2462 // if (!moins2pi2) xx2=xx2-2*M_PI;
2465 // if (moins2pi1) xx1=xx1+2*M_PI;
2466 // if (moins2pi2) xx2=xx2+2*M_PI;
2472 // if (couture || Sfacemoins1->IsUPeriodic()) {
2474 // Standard_Real ufmin,ufmax,vfmin,vfmax;
2475 // BRepTools::UVBounds(Face[nb-1],ufmin,ufmax,vfmin,vfmax);
2479 // moins2pi=Abs(deb)< Abs(Abs(deb)-2*M_PI);
2480 // moins2pi1=Abs(xx1)< Abs(Abs(xx1)-2*M_PI);
2481 // moins2pi2=Abs(xx2)< Abs(Abs(xx2)-2*M_PI);
2482 // if (moins2pi1!=moins2pi2) {
2484 // if (!moins2pi1) xx1=xx1-2*M_PI;
2485 // if (!moins2pi2) xx2=xx2-2*M_PI;
2488 // if (moins2pi1) xx1=xx1+2*M_PI;
2489 // if (moins2pi2) xx2=xx2+2*M_PI;
2496 Pardeb(1)= pfil1.X();Pardeb(2) = pfil1.Y();
2497 Pardeb(3)= pfac1.X();Pardeb(4) = pfac1.Y();
2498 Parfin(1)= pfil2.X();Parfin(2) = pfil2.Y();
2499 Parfin(3)= pfac2.X();Parfin(4) = pfac2.Y();
2501 Standard_Real uu1,uu2,vv1,vv2;
2502 ChFi3d_Boite(pfac1,pfac2,uu1,uu2,vv1,vv2);
2503 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
2506 //////////////////////////////////////////////////////////////////////
2507 // calculate intersections face - fillet
2508 //////////////////////////////////////////////////////////////////////
2510 if (!ChFi3d_ComputeCurves(HGs,HBs,Pardeb,Parfin,Cc,
2511 Ps,Pc,tolesp,tol2d,tolreached,nbface==1)) {
2512 PerformMoreThreeCorner (Index,1);
2515 // storage of information in the data structure
2517 // evaluate tolerances
2518 p1=Cc->FirstParameter();
2519 p2=Cc->LastParameter();
2520 Standard_Real to1,to2;
2522 gp_Pnt P1,P2,P3,P4,P5,P6,P7,P8;
2523 HGs->D0(Pardeb(1),Pardeb(2),P1);
2524 HGs->D0(Parfin(1),Parfin(2),P2);
2525 HBs->D0(Pardeb(3),Pardeb(4),P3);
2526 HBs->D0(Parfin(3),Parfin(4),P4);
2529 HBs->D0(p2d1.X(),p2d1.Y(),P7);
2530 HBs->D0(p2d2.X(),p2d2.Y(),P8);
2533 HGs->D0(p2d1.X(),p2d1.Y(),P5);
2534 HGs->D0(p2d2.X(),p2d2.Y(),P6);
2535 to1 = Max (P1.Distance(P5)+P3.Distance(P7), tolreached);
2536 to2 = Max (P2.Distance(P6)+P4.Distance(P8), tolreached);
2539 //////////////////////////////////////////////////////////////////////
2540 // storage in the DS of the intersection curve
2541 //////////////////////////////////////////////////////////////////////
2543 Standard_Boolean Isvtx1=0;
2544 Standard_Boolean Isvtx2=0;
2545 Standard_Integer indice;
2549 indpoint1 = stripe->IndexPoint(isfirst,1);
2550 if (!CV1.IsVertex()) {
2551 TopOpeBRepDS_Point& tpt= DStr.ChangePoint(indpoint1);
2552 tpt.Tolerance ( Max (tpt.Tolerance(), to1));
2558 indpoint2 = stripe->IndexPoint(isfirst,2);
2559 if (!CV2.IsVertex()) {
2560 TopOpeBRepDS_Point& tpt= DStr.ChangePoint(indpoint2);
2561 tpt.Tolerance ( Max (tpt.Tolerance(), to2));
2567 gp_Pnt point =Cc->Value(Cc->LastParameter());
2568 TopOpeBRepDS_Point tpoint (point,to2);
2569 indpoint2=DStr.AddPoint(tpoint);
2574 TopOpeBRepDS_Point& tpt= DStr.ChangePoint(indpoint1);
2575 tpt.Tolerance ( Max (tpt.Tolerance(), to1));
2577 TopOpeBRepDS_Curve tcurv3d( Cc,tolreached);
2578 indcurve[nb-1]= DStr.AddCurve(tcurv3d);
2579 Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurve[nb-1],
2580 indpoint1,Cc->FirstParameter(),Isvtx1);
2581 Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurve[nb-1],
2582 indpoint2,Cc->LastParameter(),Isvtx2);
2584 DStr.ChangeCurveInterferences(indcurve[nb-1]).Append(Interfp1);
2585 DStr.ChangeCurveInterferences(indcurve[nb-1]).Append(Interfp2);
2587 //////////////////////////////////////////////////////////////////////
2588 // storage for the face
2589 //////////////////////////////////////////////////////////////////////
2592 TopAbs_Orientation ori = TopAbs_FORWARD;
2594 TopAbs_Orientation ori;
2596 orface=Face[nb-1].Orientation();
2597 if (orface==orsurfdata ) orien = TopAbs::Reverse(orcourbe);
2598 else orien = orcourbe ;
2599 // limitation of edges of faces
2601 Standard_Integer Iarc1= DStr.AddShape(Edge[0]);
2602 Interfedge[0]= ChFi3d_FilPointInDS(CV1.TransitionOnArc(),Iarc1,
2603 indpoint1,paredge1,Isvtx1);
2604 //DStr.ChangeShapeInterferences(Edge[0]).Append(Interfp1);
2607 Standard_Integer Iarc2= DStr.AddShape(Edge[nb]);
2608 Interfedge[nb]= ChFi3d_FilPointInDS(CV2.TransitionOnArc() ,Iarc2,
2609 indpoint2,paredge2,Isvtx2);
2610 //DStr.ChangeShapeInterferences(Edge[nb]).Append(Interfp2);
2613 if (nb!=nbface || oneintersection1 || oneintersection2) {
2615 V1= TopExp::FirstVertex(Edge[nb]);
2616 V2= TopExp::LastVertex(Edge[nb]);
2617 if (containV(F1,V1) || containV(F2,V1))
2619 else if (containV(F1,V2) || containV(F2,V2))
2620 ori=TopAbs_REVERSED;
2622 Standard_Failure::Raise("IntersectionAtEnd : pb orientation");
2624 if (containV(F1,V1) && containV(F1,V2)) {
2625 dist1=(BRep_Tool::Pnt(V1)).Distance(BRep_Tool::Pnt(Vtx));
2626 dist2=(BRep_Tool::Pnt(V2)).Distance(BRep_Tool::Pnt(Vtx));
2627 if (dist1<dist2) ori=TopAbs_FORWARD;
2628 else ori=TopAbs_REVERSED;
2630 if (containV(F2,V1) && containV(F2,V2)) {
2631 dist1=(BRep_Tool::Pnt(V1)).Distance(BRep_Tool::Pnt(Vtx));
2632 dist2=(BRep_Tool::Pnt(V2)).Distance(BRep_Tool::Pnt(Vtx));
2633 if (dist1<dist2) ori=TopAbs_FORWARD;
2634 else ori=TopAbs_REVERSED;
2638 if (TopExp::FirstVertex(Edge[nb]).IsSame(Vtx))
2639 ori= TopAbs_FORWARD;
2640 else ori=TopAbs_REVERSED;
2642 if (!extend && !(oneintersection1 || oneintersection2)) {
2643 Standard_Integer Iarc2= DStr.AddShape(Edge[nb]);
2644 Interfedge[nb]= ChFi3d_FilPointInDS(ori,Iarc2,
2645 indpoint2,paredge2);
2646 // DStr.ChangeShapeInterferences(Edge[nb]).Append(Interfp2);
2649 if (!(oneintersection1 || oneintersection2) ) proledge[nb]=Standard_True;
2650 Standard_Integer indp1,indp2,ind;
2652 Standard_Real ubid,vbid;
2653 pext=BRep_Tool::Pnt(Vtx);
2654 GeomAdaptor_Curve cad;
2655 Handle(Geom_Curve) csau;
2656 if ( ! (oneintersection1 || oneintersection2)) {
2661 csau=BRep_Tool::Curve(edgesau,ubid,vbid );
2662 Handle(Geom_BoundedCurve) C1=
2663 Handle(Geom_BoundedCurve)::DownCast(csau);
2664 if (oneintersection1&&extend) {
2667 Pl=C1->Value(C1->LastParameter());
2668 //Standard_Boolean sens;
2669 sens=Pl.Distance(pext)<tolpt;
2670 GeomLib::ExtendCurveToPoint(C1,CV1.Point(),1,sens);
2674 else if (oneintersection2&&extend) {
2677 Pl=C1->Value(C1->LastParameter());
2678 //Standard_Boolean sens;
2679 sens=Pl.Distance(pext)<tolpt;
2680 GeomLib::ExtendCurveToPoint(C1,CV2.Point(),1,sens);
2686 Extrema_ExtPC ext(pext,cad,tolpt);
2687 Standard_Real par1, par2, par, ParVtx;
2688 Standard_Boolean vtx1=Standard_False;
2689 Standard_Boolean vtx2=Standard_False;
2690 par1=ext.Point(1).Parameter();
2692 if (oneintersection1 || oneintersection2 ) {
2693 if (oneintersection2) {
2701 Extrema_ExtPC ext2(pext,cad,tolpt);
2702 par2=ext2.Point(1).Parameter();
2710 indp2=DStr.AddShape(Vtx);
2717 indp1=DStr.AddShape(Vtx);
2721 Handle(Geom_Curve) Ct=new Geom_TrimmedCurve (csau,par1,par2);
2722 TopAbs_Orientation orient;
2723 Cc->D0(Cc->FirstParameter(),P1);
2724 Cc->D0(Cc->LastParameter(),P2);
2725 Ct->D0(Ct->FirstParameter(),P3);
2726 Ct->D0(Ct->LastParameter(),P4);
2727 if (P2.Distance(P3)<tolpt || P1.Distance(P4)<tolpt) orient=orien;
2728 else orient=TopAbs::Reverse(orien);
2729 if (oneintersection1||oneintersection2) {
2730 indice=DStr.AddShape(Face[0]);
2732 DStr.SetNewSurface(Face[0],Sfacemoins1);
2733 ComputeCurve2d(Ct,faceprol[0],C2dint1);
2737 TopoDS_Edge aLocalEdge = edgesau;
2738 if (edgesau.Orientation() != orient)
2739 aLocalEdge.Reverse();
2740 C2dint1 = BRep_Tool::CurveOnSurface(aLocalEdge,Face[0],ubid,vbid);
2744 indice=DStr.AddShape(Face[nb-1]);
2745 DStr.SetNewSurface(Face[nb-1],Sfacemoins1);
2747 //// for periodic 3d curves ////
2748 if (cad.IsPeriodic())
2750 gp_Pnt2d P2d = BRep_Tool::Parameters( Vtx, Face[0] );
2751 Geom2dAPI_ProjectPointOnCurve Projector( P2d, C2dint1 );
2752 par = Projector.LowerDistanceParameter();
2753 Standard_Real shift = par-ParVtx;
2754 if (Abs(shift) > Precision::Confusion())
2760 ////////////////////////////////
2762 Ct=new Geom_TrimmedCurve (csau,par1,par2);
2763 if (oneintersection1||oneintersection2) tolex=10*BRep_Tool::Tolerance(edgesau);
2765 Handle(GeomAdaptor_HSurface) H1, H2;
2766 H1=new GeomAdaptor_HSurface(Sfacemoins1);
2768 tolex = Max (tolex, ChFi3d_EvalTolReached(H1,C2dint1,H1,C2dint1,Ct));
2770 H2=new GeomAdaptor_HSurface(Sface);
2771 tolex = Max (tolex, ChFi3d_EvalTolReached(H1,C2dint1,H2,C2dint2,Ct));
2774 TopOpeBRepDS_Curve tcurv( Ct,tolex);
2775 Standard_Integer indcurv;
2776 indcurv=DStr.AddCurve(tcurv);
2777 Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurv,indp1,par1,vtx1);
2778 Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurv,indp2,par2,vtx2);
2779 DStr.ChangeCurveInterferences(indcurv).Append(Interfp1);
2780 DStr.ChangeCurveInterferences(indcurv).Append(Interfp2);
2782 Interfc=ChFi3d_FilCurveInDS(indcurv,indice ,C2dint1,orient);
2783 DStr.ChangeShapeInterferences(indice).Append(Interfc);
2784 if (oneintersection1||oneintersection2) {
2785 indice=DStr.AddShape(facesau);
2786 if (facesau.Orientation()==Face[0].Orientation())
2787 orient=TopAbs::Reverse(orient);
2789 ComputeCurve2d(Ct,faceprol[1],C2dint2);
2794 TopoDS_Edge aLocalEdge = edgesau;
2795 if (edgesau.Orientation() != orient)
2796 aLocalEdge.Reverse();
2797 C2dint2 = BRep_Tool::CurveOnSurface(aLocalEdge,facesau,ubid,vbid);
2798 //Reverse for case of edgesau on closed surface (Face[0] is equal to facesau)
2802 indice=DStr.AddShape(Face[nb]);
2803 DStr.SetNewSurface(Face[nb],Sface);
2804 if (Face[nb].Orientation()==Face[nb-1].Orientation())
2805 orient= TopAbs::Reverse(orient);
2808 Interfc=ChFi3d_FilCurveInDS(indcurv,indice,C2dint2,orient);
2809 DStr.ChangeShapeInterferences(indice).Append(Interfc);
2815 IsShrink(Ps,p1,p2,checkShrParam,isUShrink,Precision::Parametric(tolreached)))
2818 // store section face-chamf curve for previous SurfData
2819 // Suppose Fd and SDprev are parametrized similarly
2820 if (!isShrink) { // first time
2821 const ChFiDS_FaceInterference& Fi = SDprev->InterferenceOnS1();
2822 gp_Pnt2d UV = Fi.PCurveOnSurf()->Value(Fi.Parameter(isfirst));
2823 prevSDParam = isUShrink ? UV.X() : UV.Y();
2825 gp_Pnt2d UV1=p2d1,UV2=p2d2;
2826 UV1.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2827 UV2.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2828 Standard_Real aTolreached;
2829 ChFi3d_ComputePCurv(Cc,UV1,UV2,Ps,
2830 DStr.Surface(SDprev->Surf()).Surface(),
2831 p1,p2,tolesp,aTolreached);
2832 TopOpeBRepDS_Curve& TCurv = DStr.ChangeCurve(indcurve[nb-1]);
2833 TCurv.Tolerance(Max(TCurv.Tolerance(),aTolreached));
2835 InterfPS[nb-1]=ChFi3d_FilCurveInDS(indcurve[nb-1],IsurfPrev,Ps,orcourbe);
2836 DStr.ChangeSurfaceInterferences(IsurfPrev).Append(InterfPS[nb-1]);
2840 midIpoint = indpoint2;
2842 else if (!isShrink) {
2844 midIpoint = indpoint1;
2846 isShrink = Standard_True;
2850 indice=DStr.AddShape(Face[nb-1]);
2851 InterfPC[nb-1]=ChFi3d_FilCurveInDS(indcurve[nb-1],indice ,Pc,orien);
2853 InterfPS[nb-1]=ChFi3d_FilCurveInDS(indcurve[nb-1],Isurf,Ps,orcourbe);
2854 indpoint1=indpoint2;
2856 } // end loop on faces being intersected with ChFi
2859 if (isOnSame1) CV1.Reset();
2860 if (isOnSame2) CV2.Reset();
2862 for(nb=1;nb<=nbface;nb++) {
2863 Standard_Integer indice=DStr.AddShape(Face[nb-1]);
2864 DStr.ChangeShapeInterferences(indice).Append(InterfPC[nb-1]);
2866 DStr.ChangeSurfaceInterferences(Isurf).Append(InterfPS[nb-1]);
2867 if (!proledge[nb-1])
2868 DStr.ChangeShapeInterferences(Edge[nb-1]).Append(Interfedge[nb-1]);
2870 DStr.ChangeShapeInterferences(Edge[nbface]).Append(Interfedge[nbface]);
2873 stripe->InDS(isfirst);
2875 // compute curves for !<isfirst> end of <Fd> and <isfirst> end of previous <SurfData>
2879 gp_Pnt2d UV, UV1 = midP2d, UV2 = midP2d;
2881 UV = UV2 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
2883 UV = UV1 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
2884 Standard_Real aTolreached;
2885 Handle(Geom_Curve) C3d;
2886 Handle(Geom_Surface) aSurf = DStr.Surface(Fd->Surf()).Surface();
2887 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2889 ChFi3d_ComputeArete(CV1,UV1,CV2,UV2,aSurf, // in
2890 C3d,Ps,p1,p2,tolesp,tol2d,aTolreached,0); // out except tolers
2892 indpoint1 = indpoint2 = midIpoint;
2895 point = C3d->Value(p2);
2896 TopOpeBRepDS_Point tpoint (point,aTolreached);
2897 indpoint2=DStr.AddPoint(tpoint);
2900 point = C3d->Value(p1);
2901 TopOpeBRepDS_Point tpoint (point,aTolreached);
2902 indpoint1=DStr.AddPoint(tpoint);
2906 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2908 TopOpeBRepDS_Curve Crv = TopOpeBRepDS_Curve(C3d,aTolreached);
2909 Standard_Integer Icurv = DStr.AddCurve(Crv);
2910 Interfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv,indpoint1,p1, Standard_False);
2911 Interfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv,indpoint2,p2, Standard_False);
2912 Interfc = ChFi3d_FilCurveInDS(Icurv,Isurf,Ps,orcourbe);
2913 DStr.ChangeCurveInterferences(Icurv).Append(Interfp1);
2914 DStr.ChangeCurveInterferences(Icurv).Append(Interfp2);
2915 DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc);
2918 aSurf = DStr.Surface(SDprev->Surf()).Surface();
2919 UV1.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2920 UV2.SetCoord(isUShrink ? 1 : 2, prevSDParam);
2922 ChFi3d_ComputePCurv(C3d,UV1,UV2,Pc,aSurf,p1,p2,tolesp,aTolreached);
2924 Crv.Tolerance(Max(Crv.Tolerance(),aTolreached));
2925 Interfc= ChFi3d_FilCurveInDS (Icurv,IsurfPrev,Pc,TopAbs::Reverse(orcourbe));
2926 DStr.ChangeSurfaceInterferences(IsurfPrev).Append(Interfc);
2928 //UV = isOnSame1 ? UV2 : UV1;
2929 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2930 //UV = Ps->Value(isOnSame1 ? p2 : p1);
2931 //box.Add(aSurf->Value(UV.X(), UV.Y()));
2932 //ChFi3d_SetPointTolerance(DStr,box, isOnSame1 ? indpoint2 : indpoint1);
2934 // to process properly this case in ChFi3d_FilDS()
2935 stripe->InDS(isfirst, 2);
2936 Fd->ChangeInterference(isOnSame1 ? 2 : 1).SetLineIndex(0);
2937 ChFiDS_CommonPoint& CPprev1 = SDprev->ChangeVertex( isfirst,isOnSame1 ? 2 : 1);
2938 ChFiDS_CommonPoint& CPlast1 = Fd-> ChangeVertex( isfirst,isOnSame1 ? 2 : 1);
2939 ChFiDS_CommonPoint& CPlast2 = Fd-> ChangeVertex(!isfirst,isOnSame1 ? 2 : 1);
2940 if (CPprev1.IsOnArc()) {
2943 CPprev1.SetPoint(CPlast1.Point());
2945 CPlast2.SetPoint(CPlast1.Point());
2948 // in shrink case, self intersection is possible at <midIpoint>,
2949 // eval its tolerance intersecting Ps and Pcurve at end.
2950 // Find end curves closest to shrinked part
2951 for (nb=0; nb < nbface; nb++)
2952 if (isOnSame1 ? shrink [nb+1] : !shrink [nb]) break;
2953 Handle(Geom_Curve) Cend = DStr.Curve(indcurve[nb]).Curve();
2954 Handle(Geom2d_Curve) PCend = InterfPS[nb]->PCurve();
2955 // point near which self intersection may occure
2956 TopOpeBRepDS_Point& Pds = DStr.ChangePoint(midIpoint);
2957 const gp_Pnt& Pvert = Pds.Point();
2958 Standard_Real tol = Pds.Tolerance();
2960 Geom2dAdaptor_Curve PC1(Ps), PC2(PCend);
2961 Geom2dInt_GInter Intersector(PC1,PC2,Precision::PConfusion(),Precision::PConfusion());
2962 if (!Intersector.IsDone()) return;
2963 for (nb=1; nb <= Intersector.NbPoints(); nb++) {
2964 const IntRes2d_IntersectionPoint& ip = Intersector.Point(nb);
2965 gp_Pnt Pint = C3d->Value(ip.ParamOnFirst());
2966 tol = Max(tol, Pvert.Distance(Pint));
2967 Pint = Cend->Value(ip.ParamOnSecond());
2968 tol = Max(tol, Pvert.Distance(Pint));
2970 for (nb=1; nb <= Intersector.NbSegments(); nb++) {
2971 const IntRes2d_IntersectionSegment& is = Intersector.Segment(nb);
2972 if (is.HasFirstPoint()) {
2973 const IntRes2d_IntersectionPoint& ip = is.FirstPoint();
2974 gp_Pnt Pint = C3d->Value(ip.ParamOnFirst());
2975 tol = Max(tol, Pvert.Distance(Pint));
2976 Pint = Cend->Value(ip.ParamOnSecond());
2977 tol = Max(tol, Pvert.Distance(Pint));
2979 if (is.HasLastPoint()) {
2980 const IntRes2d_IntersectionPoint& ip = is.LastPoint();
2981 gp_Pnt Pint = C3d->Value(ip.ParamOnFirst());
2982 tol = Max(tol, Pvert.Distance(Pint));
2983 Pint = Cend->Value(ip.ParamOnSecond());
2984 tol = Max(tol, Pvert.Distance(Pint));
2991 // Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 Begin
2993 //=======================================================================
2994 //function : PerformMoreSurfdata
2995 //purpose : determine intersections at end on several surfdata
2996 //=======================================================================
2997 void ChFi3d_Builder::PerformMoreSurfdata(const Standard_Integer Index)
2999 TopOpeBRepDS_DataStructure &DStr = myDS->ChangeDS();
3000 const ChFiDS_ListOfStripe &aLOfStripe = myVDataMap(Index);
3001 Handle(ChFiDS_Stripe) aStripe;
3002 Handle(ChFiDS_Spine) aSpine;
3003 Standard_Real aTol3d = 1.e-4;
3006 if (aLOfStripe.IsEmpty())
3009 aStripe = aLOfStripe.First();
3010 aSpine = aStripe->Spine();
3012 ChFiDS_SequenceOfSurfData &aSeqSurfData =
3013 aStripe->ChangeSetOfSurfData()->ChangeSequence();
3014 const TopoDS_Vertex &aVtx = myVDataMap.FindKey(Index);
3015 Standard_Integer aSens = 0;
3016 Standard_Integer anInd =
3017 ChFi3d_IndexOfSurfData(aVtx,aStripe,aSens);
3018 Standard_Boolean isFirst = (aSens == 1);
3019 Standard_Integer anIndPrev;
3020 Handle(ChFiDS_SurfData) aSurfData;
3021 ChFiDS_CommonPoint aCP1;
3022 ChFiDS_CommonPoint aCP2;
3024 aSurfData = aSeqSurfData.Value(anInd);
3026 aCP1 = aSurfData->Vertex(isFirst,1);
3027 aCP2 = aSurfData->Vertex(isFirst,2);
3029 Handle(Geom_Surface) aSurfPrev;
3030 Handle(Geom_Surface) aSurf;
3032 TopoDS_Face aNeighborFace;
3034 FindFace(aVtx, aCP1, aCP2, aFace);
3035 aSurfPrev = BRep_Tool::Surface(aFace);
3037 if (aSens==1) anIndPrev=anInd+1;
3038 else anIndPrev=anInd-1;
3042 TopTools_ListIteratorOfListOfShape anIter(myVEMap(aVtx));
3043 Standard_Boolean isFound = Standard_False;
3045 for(; anIter.More() && !isFound; anIter.Next()) {
3046 anArc1 = TopoDS::Edge(anIter.Value());
3048 if (containE(aFace, anArc1))
3049 isFound = Standard_True;
3052 isFound = Standard_False;
3053 anIter.Initialize(myVEMap(aVtx));
3055 for(; anIter.More() && !isFound; anIter.Next()) {
3056 anArc2 = TopoDS::Edge(anIter.Value());
3058 if (containE(aFace,anArc2) && !anArc2.IsSame(anArc1))
3059 isFound = Standard_True;
3062 // determination of common points aCP1onArc, aCP2onArc and aCP2NotonArc
3063 // aCP1onArc is the point on arc of index anInd
3064 // aCP2onArc is the point on arc of index anIndPrev
3065 // aCP2NotonArc is the point of index anIndPrev which is not on arc.
3067 Standard_Boolean is1stCP1OnArc;
3068 Standard_Boolean is2ndCP1OnArc;
3069 ChFiDS_CommonPoint aCP1onArc;
3070 ChFiDS_CommonPoint aCP2onArc;
3071 ChFiDS_CommonPoint aCP2NotonArc;
3073 aSurfData = aSeqSurfData.Value(anIndPrev);
3074 aCP1 = aSurfData->Vertex(isFirst,1);
3075 aCP2 = aSurfData->Vertex(isFirst,2);
3077 if (aCP1.IsOnArc() &&
3078 (aCP1.Arc().IsSame(anArc1) || aCP1.Arc().IsSame(anArc2))) {
3080 aCP2NotonArc = aCP2;
3081 is2ndCP1OnArc = Standard_True;
3082 } else if (aCP2.IsOnArc() &&
3083 (aCP2.Arc().IsSame(anArc1) || aCP2.Arc().IsSame(anArc2))) {
3085 aCP2NotonArc = aCP1;
3086 is2ndCP1OnArc = Standard_False;
3090 aSurfData = aSeqSurfData.Value(anInd);
3091 aCP1 = aSurfData->Vertex(isFirst,1);
3092 aCP2 = aSurfData->Vertex(isFirst,2);
3094 if (aCP1.Point().Distance(aCP2onArc.Point()) <= aTol3d){
3096 is1stCP1OnArc = Standard_False;
3100 is1stCP1OnArc = Standard_True;
3103 if (!aCP1onArc.IsOnArc())
3106 // determination of neighbor surface
3107 Standard_Integer indSurface;
3109 indSurface = myListStripe.First()->SetOfSurfData()->Value(anInd)->IndexOfS1();
3111 indSurface = myListStripe.First()->SetOfSurfData()->Value(anInd)->IndexOfS2();
3113 aNeighborFace = TopoDS::Face(myDS->Shape(indSurface));
3115 // calculation of intersections
3116 Handle(Geom_Curve) aCracc;
3117 Handle(Geom2d_Curve) aPCurv1;
3118 Standard_Real aParf;
3119 Standard_Real aParl;
3120 Standard_Real aTolReached;
3122 aSurfData = aSeqSurfData.Value(anInd);
3125 ChFi3d_ComputeArete(aSurfData->VertexLastOnS1(),
3126 aSurfData->InterferenceOnS1().PCurveOnSurf()->
3127 Value(aSurfData->InterferenceOnS1().LastParameter()),
3128 aSurfData->VertexLastOnS2(),
3129 aSurfData->InterferenceOnS2().PCurveOnSurf()->
3130 Value(aSurfData->InterferenceOnS2().LastParameter()),
3131 DStr.Surface(aSurfData->Surf()).Surface(),aCracc,aPCurv1,
3132 aParf,aParl,aTol3d,tol2d,aTolReached,0);
3134 ChFi3d_ComputeArete(aSurfData->VertexFirstOnS1(),
3135 aSurfData->InterferenceOnS1().PCurveOnSurf()->
3136 Value(aSurfData->InterferenceOnS1().FirstParameter()),
3137 aSurfData->VertexFirstOnS2(),
3138 aSurfData->InterferenceOnS2().PCurveOnSurf()->
3139 Value(aSurfData->InterferenceOnS2().FirstParameter()),
3140 DStr.Surface(aSurfData->Surf()).Surface(),aCracc,aPCurv1,
3141 aParf,aParl,aTol3d,tol2d,aTolReached,0);
3143 // calculation of the index of the line on anInd.
3144 // aPClineOnSurf is the pcurve on anInd.
3145 // aPClineOnFace is the pcurve on face.
3146 ChFiDS_FaceInterference aFI;
3149 aFI = aSurfData->InterferenceOnS1();
3151 aFI = aSurfData->InterferenceOnS2();
3153 Handle(Geom_Curve) aCline;
3154 Handle(Geom2d_Curve) aPClineOnSurf;
3155 Handle(Geom2d_Curve) aPClineOnFace;
3156 Standard_Integer indLine;
3158 indLine = aFI.LineIndex();
3159 aCline = DStr.Curve(aFI.LineIndex()).Curve();
3160 aPClineOnSurf = aFI.PCurveOnSurf();
3161 aPClineOnFace = aFI.PCurveOnFace();
3163 // intersection between the SurfData number anInd and the Face aFace.
3164 // Obtaining of curves aCint1, aPCint11 and aPCint12.
3165 aSurf = DStr.Surface(aSurfData->Surf()).Surface();
3167 GeomInt_IntSS anInterSS(aSurfPrev,aSurf,1.e-7,1,1,1);
3168 Handle(Geom_Curve) aCint1;
3169 Handle(Geom2d_Curve) aPCint11;
3170 Handle(Geom2d_Curve) aPCint12;
3171 Handle(GeomAdaptor_HSurface) H1 = new GeomAdaptor_HSurface(aSurfPrev);
3172 Handle(GeomAdaptor_HSurface) H2 = new GeomAdaptor_HSurface(aSurf);
3173 Standard_Real aTolex1=0.;
3178 Standard_Boolean isPextFound;
3181 if (!anInterSS.IsDone())
3184 isFound = Standard_False;
3186 for (i = 1; i <= anInterSS.NbLines() && !isFound; i++) {
3187 aCint1 = anInterSS.Line(i);
3188 aPCint11 = anInterSS.LineOnS1(i);
3189 aPCint12 = anInterSS.LineOnS2(i);
3190 aTolex1 = ChFi3d_EvalTolReached(H1, aPCint11, H2, aPCint12, aCint1);
3192 aCint1->D0(aCint1->FirstParameter(), aPext1);
3193 aCint1->D0(aCint1->LastParameter(), aPext2);
3195 // Modified by skv - Mon Jun 7 18:38:57 2004 OCC5898 Begin
3196 // if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d ||
3197 // aPext2.Distance(aCP1onArc.Point()))
3198 if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d ||
3199 aPext2.Distance(aCP1onArc.Point()) <= aTol3d)
3200 // Modified by skv - Mon Jun 7 18:38:58 2004 OCC5898 End
3201 isFound = Standard_True;
3207 if (aPext1.Distance(aCP2onArc.Point()) > aTol3d &&
3208 aPext1.Distance(aCP1onArc.Point()) > aTol3d) {
3210 isPextFound = Standard_True;
3211 } else if (aPext2.Distance(aCP2onArc.Point()) > aTol3d &&
3212 aPext2.Distance(aCP1onArc.Point()) > aTol3d) {
3214 isPextFound = Standard_True;
3216 isPextFound = Standard_False;
3220 Standard_Boolean isDoSecondSection = Standard_False;
3221 Standard_Real aPar=0.;
3224 GeomAdaptor_Curve aCad(aCracc);
3225 Extrema_ExtPC anExt(aPext, aCad, aTol3d);
3227 if (!anExt.IsDone())
3230 isFound = Standard_False;
3231 for (i = 1; i <= anExt.NbExt() && !isFound; i++) {
3232 if (anExt.IsMin(i)) {
3233 gp_Pnt aProjPnt = anExt.Point(i).Value();
3235 if (aPext.Distance(aProjPnt) <= aTol3d) {
3236 aPar = anExt.Point(i).Parameter();
3237 isDoSecondSection = Standard_True;
3243 Handle(Geom_Curve) aTrCracc;
3244 TopAbs_Orientation anOrSD1;
3245 TopAbs_Orientation anOrSD2;
3246 Standard_Integer indShape;
3248 anOrSD1 = aSurfData->Orientation();
3249 aSurfData = aSeqSurfData.Value(anIndPrev);
3250 anOrSD2 = aSurfData->Orientation();
3251 aSurf = DStr.Surface(aSurfData->Surf()).Surface();
3253 // The following variables will be used if isDoSecondSection is true
3254 Handle(Geom_Curve) aCint2;
3255 Handle(Geom2d_Curve) aPCint21;
3256 Handle(Geom2d_Curve) aPCint22;
3257 Standard_Real aTolex2=0.;
3259 if (isDoSecondSection) {
3260 Standard_Real aPar1;
3262 aCracc->D0(aCracc->FirstParameter(), aPext1);
3264 if (aPext1.Distance(aCP2NotonArc.Point()) <= aTol3d)
3265 aPar1 = aCracc->FirstParameter();
3267 aPar1 = aCracc->LastParameter();
3270 aTrCracc = new Geom_TrimmedCurve (aCracc, aPar1, aPar);
3272 aTrCracc = new Geom_TrimmedCurve (aCracc, aPar, aPar1);
3275 GeomInt_IntSS anInterSS2(aSurfPrev,aSurf,1.e-7,1,1,1);
3277 if (!anInterSS2.IsDone())
3280 H1 = new GeomAdaptor_HSurface(aSurfPrev);
3281 H2 = new GeomAdaptor_HSurface(aSurf);
3283 isFound = Standard_False;
3285 for (i = 1; i <= anInterSS2.NbLines() && !isFound; i++) {
3286 aCint2 = anInterSS2.Line(i);
3287 aPCint21 = anInterSS2.LineOnS1(i);
3288 aPCint22 = anInterSS2.LineOnS2(i);
3289 aTolex2 = ChFi3d_EvalTolReached(H1, aPCint21, H2, aPCint22, aCint2);
3291 aCint2->D0(aCint2->FirstParameter(), aPext1);
3292 aCint2->D0(aCint2->LastParameter(), aPext2);
3294 if (aPext1.Distance(aCP2onArc.Point()) <= aTol3d ||
3295 aPext2.Distance(aCP2onArc.Point()) <= aTol3d)
3296 isFound = Standard_True;
3303 aTrCracc = new Geom_TrimmedCurve(aCracc,
3304 aCracc->FirstParameter(),
3305 aCracc->LastParameter());
3308 // Storage of the data structure
3310 // calculation of the orientation of line of surfdata number
3311 // anIndPrev which contains aCP2onArc
3313 Handle(Geom2d_Curve) aPCraccS = GeomProjLib::Curve2d(aTrCracc,aSurf);
3315 if (is2ndCP1OnArc) {
3316 aFI = aSurfData->InterferenceOnS1();
3317 indShape = aSurfData->IndexOfS1();
3319 aFI = aSurfData->InterferenceOnS2();
3320 indShape = aSurfData->IndexOfS2();
3328 TopAbs_Orientation aCurOrient;
3330 aCurOrient = DStr.Shape(indShape).Orientation();
3331 aCurOrient = TopAbs::Compose(aCurOrient, aSurfData->Orientation());
3332 aCurOrient = TopAbs::Compose(TopAbs::Reverse(aFI.Transition()), aCurOrient);
3335 // Filling the data structure
3336 aSurfData = aSeqSurfData.Value(anInd);
3338 TopOpeBRepDS_Point aPtCP1(aCP1onArc.Point(),aCP1onArc.Tolerance());
3339 Standard_Integer indCP1onArc = DStr.AddPoint(aPtCP1);
3340 Standard_Integer indSurf1 = aSurfData->Surf();
3341 Standard_Integer indArc1 = DStr.AddShape(aCP1onArc.Arc());
3342 Standard_Integer indSol = aStripe->SolidIndex();
3344 Handle (TopOpeBRepDS_CurvePointInterference) anInterfp1;
3345 Handle (TopOpeBRepDS_CurvePointInterference) anInterfp2;
3347 anInterfp1= ChFi3d_FilPointInDS(aCP1onArc.TransitionOnArc(), indArc1,
3348 indCP1onArc, aCP1onArc.ParameterOnArc());
3349 DStr.ChangeShapeInterferences(aCP1onArc.Arc()).Append(anInterfp1);
3351 TopOpeBRepDS_ListOfInterference &SolidInterfs =
3352 DStr.ChangeShapeInterferences(indSol);
3353 Handle(TopOpeBRepDS_SolidSurfaceInterference) SSI =
3354 new TopOpeBRepDS_SolidSurfaceInterference
3355 (TopOpeBRepDS_Transition(anOrSD1),
3356 TopOpeBRepDS_SOLID, indSol,
3357 TopOpeBRepDS_SURFACE, indSurf1);
3358 SolidInterfs.Append(SSI);
3360 // deletion of Surface Data.
3361 aSeqSurfData.Remove(anInd);
3366 aSurfData = aSeqSurfData.Value(anInd);
3368 // definition of indices of common points in Data Structure
3370 Standard_Integer indCP2onArc;
3371 Standard_Integer indCP2NotonArc;
3373 if (is2ndCP1OnArc) {
3374 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2onArc, DStr),isFirst,1);
3375 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2NotonArc,DStr),isFirst,2);
3378 indCP2onArc = aStripe->IndexFirstPointOnS1();
3379 indCP2NotonArc = aStripe->IndexFirstPointOnS2();
3381 indCP2onArc = aStripe->IndexLastPointOnS1();
3382 indCP2NotonArc = aStripe->IndexLastPointOnS2();
3385 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2onArc, DStr),isFirst,2);
3386 aStripe->SetIndexPoint(ChFi3d_IndexPointInDS(aCP2NotonArc,DStr),isFirst,1);
3389 indCP2onArc = aStripe->IndexFirstPointOnS2();
3390 indCP2NotonArc = aStripe->IndexFirstPointOnS1();
3393 indCP2onArc = aStripe->IndexLastPointOnS2();
3394 indCP2NotonArc = aStripe->IndexLastPointOnS1();
3398 Standard_Integer indPoint1;
3399 Standard_Integer indPoint2;
3403 if (is2ndCP1OnArc) {
3404 aFI = aSurfData->InterferenceOnS1();
3405 indShape = aSurfData->IndexOfS1();
3407 aFI = aSurfData->InterferenceOnS2();
3408 indShape = aSurfData->IndexOfS2();
3412 Handle (TopOpeBRepDS_SurfaceCurveInterference) anInterfc;
3413 TopAbs_Orientation anOrSurf = aCurOrient;
3414 TopAbs_Orientation anOrFace = aFace.Orientation();
3415 Standard_Integer indaFace = DStr.AddShape(aFace);
3416 Standard_Integer indPoint = indCP2onArc;
3417 Standard_Integer indCurve;
3419 aFI.PCurveOnFace()->D0(aFI.LastParameter(), aP2d);
3420 Handle(Geom_Surface) Stemp2 =
3421 BRep_Tool::Surface(TopoDS::Face(DStr.Shape(indShape)));
3422 Stemp2->D0(aP2d.X(), aP2d.Y(), aPoint2);
3423 aFI.PCurveOnFace()->D0(aFI.FirstParameter(), aP2d);
3424 Stemp2->D0(aP2d.X(), aP2d.Y(), aPoint1);
3426 if (isDoSecondSection) {
3427 TopOpeBRepDS_Point tpoint(aPext, aTolex2);
3428 TopOpeBRepDS_Curve tcint2(aCint2, aTolex2);
3430 indPoint = DStr.AddPoint(tpoint);
3431 indCurve = DStr.AddCurve(tcint2);
3433 aCint2->D0(aCint2->FirstParameter(), aPext1);
3434 aCint2->D0(aCint2->LastParameter(), aPext2);
3436 if (aPext1.Distance(aPext) <= aTol3d){
3437 indPoint1 = indPoint;
3438 indPoint2 = indCP2onArc;
3440 indPoint1 = indCP2onArc;
3441 indPoint2 = indPoint;
3444 // define the orientation of aCint2
3445 if (aPext1.Distance(aPoint2) > aTol3d && aPext2.Distance(aPoint1) > aTol3d)
3446 anOrSurf = TopAbs::Reverse(anOrSurf);
3448 // ---------------------------------------------------------------
3449 // storage of aCint2
3450 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD, indCurve,
3451 indPoint1, aCint2->FirstParameter());
3452 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED, indCurve,
3453 indPoint2, aCint2->LastParameter());
3454 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3455 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3457 // interference of aCint2 on the SurfData number anIndPrev
3458 anInterfc = ChFi3d_FilCurveInDS(indCurve, aSurfData->Surf(),
3459 aPCint22, anOrSurf);
3461 DStr.ChangeSurfaceInterferences(aSurfData->Surf()).Append(anInterfc);
3462 // interference of aCint2 on aFace
3464 if (anOrFace == anOrSD2)
3465 anOrFace = TopAbs::Reverse(anOrSurf);
3467 anOrFace = anOrSurf;
3469 anInterfc = ChFi3d_FilCurveInDS(indCurve, indaFace, aPCint21, anOrFace);
3470 DStr.ChangeShapeInterferences(indaFace).Append(anInterfc);
3473 aTrCracc->D0(aTrCracc->FirstParameter(), aPext1);
3474 aTrCracc->D0(aTrCracc->LastParameter(), aPext2);
3475 if (aPext1.Distance(aCP2NotonArc.Point()) <= aTol3d){
3476 indPoint1 = indCP2NotonArc;
3477 indPoint2 = indPoint;
3479 indPoint1 = indPoint;
3480 indPoint2 = indCP2NotonArc;
3483 // Define the orientation of aTrCracc
3484 Standard_Boolean isToReverse;
3491 if (isDoSecondSection) {
3492 aTrCracc->D0(aTrCracc->FirstParameter(), aP1);
3493 aTrCracc->D0(aTrCracc->LastParameter(), aP2);
3494 aCint2->D0(aCint2->FirstParameter(), aP3);
3495 aCint2->D0(aCint2->LastParameter(), aP4);
3496 isToReverse = (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d);
3498 isToReverse = (aPext1.Distance(aPoint2) > aTol3d &&
3499 aPext2.Distance(aPoint1) > aTol3d);
3503 anOrSurf = TopAbs::Reverse(anOrSurf);
3505 // ---------------------------------------------------------------
3506 // storage of aTrCracc
3507 TopOpeBRepDS_Curve tct2(aTrCracc, aTolReached);
3509 indCurve = DStr.AddCurve(tct2);
3510 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,indCurve,
3511 indPoint1, aTrCracc->FirstParameter());
3512 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED,indCurve,
3513 indPoint2, aTrCracc->LastParameter());
3514 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3515 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3517 // interference of aTrCracc on the SurfData number anIndPrev
3519 anInterfc = ChFi3d_FilCurveInDS(indCurve,aSurfData->Surf(),aPCraccS, anOrSurf);
3520 DStr.ChangeSurfaceInterferences(aSurfData->Surf()).Append(anInterfc);
3521 aStripe->InDS(isFirst);
3523 // interference of aTrCracc on the SurfData number anInd
3524 if (anOrSD1 == anOrSD2)
3525 anOrSurf = TopAbs::Reverse(anOrSurf);
3527 anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPCurv1, anOrSurf);
3528 DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc);
3530 // ---------------------------------------------------------------
3531 // storage of aCint1
3533 aCint1->D0(aCint1->FirstParameter(),aPext1);
3534 if (aPext1.Distance(aCP1onArc.Point()) <= aTol3d){
3535 indPoint1 = indCP1onArc;
3536 indPoint2 = indPoint;
3538 indPoint1 = indPoint;
3539 indPoint2 = indCP1onArc;
3542 // definition of the orientation of aCint1
3544 aCint1->D0(aCint1->FirstParameter(), aP1);
3545 aCint1->D0(aCint1->LastParameter(), aP2);
3546 aTrCracc->D0(aTrCracc->FirstParameter(), aP3);
3547 aTrCracc->D0(aTrCracc->LastParameter(), aP4);
3549 if (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d)
3550 anOrSurf=TopAbs::Reverse(anOrSurf);
3552 TopOpeBRepDS_Curve aTCint1(aCint1, aTolex1);
3553 indCurve= DStr.AddCurve(aTCint1);
3554 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD, indCurve,
3555 indPoint1, aCint1->FirstParameter());
3556 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED, indCurve,
3557 indPoint2, aCint1->LastParameter());
3558 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3559 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3561 // interference of aCint1 on the SurfData number anInd
3563 anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPCint12, anOrSurf);
3564 DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc);
3566 // interference of aCint1 on aFace
3568 anOrFace = aFace.Orientation();
3570 if (anOrFace == anOrSD1)
3571 anOrFace = TopAbs::Reverse(anOrSurf);
3573 anOrFace = anOrSurf;
3575 anInterfc = ChFi3d_FilCurveInDS(indCurve, indaFace, aPCint11, anOrFace);
3576 DStr.ChangeShapeInterferences(indaFace).Append(anInterfc);
3577 // ---------------------------------------------------------------
3578 // storage of aCline passing through aCP1onArc and aCP2NotonArc
3580 Handle(Geom_Curve) aTrCline =
3581 new Geom_TrimmedCurve(aCline, aCline->FirstParameter(),
3582 aCline->LastParameter());
3583 Standard_Real aTolerance = DStr.Curve(indLine).Tolerance();
3584 TopOpeBRepDS_Curve aTct3(aTrCline, aTolerance);
3586 indCurve = DStr.AddCurve(aTct3);
3588 aTrCline->D0(aTrCline->FirstParameter(),aPext1);
3590 if (aPext1.Distance(aCP1onArc.Point()) < aTol3d) {
3591 indPoint1 = indCP1onArc;
3592 indPoint2 = indCP2NotonArc;
3594 indPoint1 = indCP2NotonArc;
3595 indPoint2 = indCP1onArc;
3597 // definition of the orientation of aTrCline
3599 aTrCline->D0(aTrCline->FirstParameter(), aP1);
3600 aTrCline->D0(aTrCline->LastParameter(), aP2);
3601 aCint1->D0(aCint1->FirstParameter(), aP3);
3602 aCint1->D0(aCint1->LastParameter(), aP4);
3604 if (aP1.Distance(aP4) > aTol3d && aP2.Distance(aP3) > aTol3d)
3605 anOrSurf = TopAbs::Reverse(anOrSurf);
3607 anInterfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,indCurve,
3608 indPoint1,aTrCline->FirstParameter());
3609 anInterfp2 = ChFi3d_FilPointInDS(TopAbs_REVERSED,indCurve,
3610 indPoint2,aTrCline->LastParameter());
3611 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp1);
3612 DStr.ChangeCurveInterferences(indCurve).Append(anInterfp2);
3614 // interference of aTrCline on the SurfData number anInd
3616 anInterfc = ChFi3d_FilCurveInDS(indCurve, indSurf1, aPClineOnSurf, anOrSurf);
3617 DStr.ChangeSurfaceInterferences(indSurf1).Append(anInterfc);
3619 // interference de ctlin par rapport a Fvoisin
3620 indShape = DStr.AddShape(aNeighborFace);
3621 anOrFace = aNeighborFace.Orientation();
3623 if (anOrFace == anOrSD1)
3624 anOrFace = TopAbs::Reverse(anOrSurf);
3626 anOrFace = anOrSurf;
3628 anInterfc = ChFi3d_FilCurveInDS(indCurve, indShape, aPClineOnFace, anOrFace);
3629 DStr.ChangeShapeInterferences(indShape).Append(anInterfc);
3631 // Modified by Sergey KHROMOV - Thu Apr 11 12:23:40 2002 End
3633 //==============================================================
3634 //function : FindFace
3635 //purpose : attention it works only if there is only one common face
3637 //===========================================================
3640 Standard_Boolean ChFi3d_Builder::FindFace(const TopoDS_Vertex& V,
3641 const ChFiDS_CommonPoint& P1,
3642 const ChFiDS_CommonPoint& P2,
3643 TopoDS_Face& Fv) const
3646 return FindFace(V,P1,P2,Fv,Favoid);
3649 Standard_Boolean ChFi3d_Builder::FindFace(const TopoDS_Vertex& V,
3650 const ChFiDS_CommonPoint& P1,
3651 const ChFiDS_CommonPoint& P2,
3653 const TopoDS_Face& Favoid) const
3655 if (P1.IsVertex() || P2.IsVertex()) {
3657 cout<<"change of face on vertex"<<endl;
3660 if (!(P1.IsOnArc() && P2.IsOnArc())) {
3661 return Standard_False;
3663 TopTools_ListIteratorOfListOfShape It,Jt;
3664 Standard_Boolean Found = Standard_False, ContainsV = Standard_False;
3665 for(It.Initialize(myEFMap(P1.Arc()));It.More() && !Found;It.Next()) {
3666 Fv = TopoDS::Face(It.Value());
3667 if(!Fv.IsSame(Favoid)){
3668 for(Jt.Initialize(myEFMap(P2.Arc()));Jt.More() && !Found ;Jt.Next()) {
3669 if (TopoDS::Face(Jt.Value()).IsSame(Fv)) Found = Standard_True;
3674 for(It.Initialize(myVFMap(V));It.More();It.Next()) {
3675 if (TopoDS::Face(It.Value()).IsSame(Fv)) {
3676 ContainsV = Standard_True;
3683 cout<<"FindFace : the extremity of the spine is not in the end face"<<endl;
3689 //=======================================================================
3690 //function : MoreSurfdata
3691 //purpose : detects if the intersection at end concerns several Surfdata
3692 //=======================================================================
3693 Standard_Boolean ChFi3d_Builder::MoreSurfdata(const Standard_Integer Index) const
3695 // intersection at end is created on several surfdata if :
3696 // - the number of surfdata concerning the vertex is more than 1.
3697 // - and if the last but one surfdata has one of commonpoints on one of
3698 // two arcs, which constitute the intersections of the face at end and of the fillet
3700 ChFiDS_ListIteratorOfListOfStripe It;
3701 It.Initialize(myVDataMap(Index));
3702 Handle(ChFiDS_Stripe)& stripe = It.Value();
3703 ChFiDS_SequenceOfSurfData& SeqFil =
3704 stripe->ChangeSetOfSurfData()->ChangeSequence();
3705 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
3706 Standard_Integer sens = 0;
3707 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
3708 Standard_Boolean isfirst = (sens == 1);
3709 Handle(ChFiDS_SurfData)& Fd = SeqFil.ChangeValue(num);
3710 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
3711 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
3713 Standard_Integer num1,num2,nbsurf;
3715 Standard_Boolean inters,oksurf;
3716 nbsurf= stripe->SetOfSurfData()->Length();
3717 // Fv is the face at end
3718 inters = FindFace(Vtx,CV1,CV2,Fv);
3728 oksurf=Standard_False;
3730 if (nbsurf!=1 && inters) {
3732 // determination of arc1 and arc2 intersection of the fillet and the face at end
3734 TopoDS_Edge arc1,arc2;
3735 TopTools_ListIteratorOfListOfShape ItE;
3736 Standard_Boolean trouve=Standard_False;
3737 for(ItE.Initialize(myVEMap(Vtx));ItE.More()&&!trouve;ItE.Next()) {
3738 arc1=TopoDS::Edge(ItE.Value());
3739 if (containE(Fv,arc1)) trouve=Standard_True;
3741 trouve=Standard_False;
3742 for(ItE.Initialize(myVEMap(Vtx));ItE.More()&&!trouve;ItE.Next()) {
3743 arc2=TopoDS::Edge(ItE.Value());
3744 if (containE(Fv,arc2)&& !arc2.IsSame(arc1)) trouve=Standard_True;
3747 Handle(ChFiDS_SurfData) Fd1 = SeqFil.ChangeValue(num2);
3748 ChFiDS_CommonPoint& CV3 = Fd1->ChangeVertex(isfirst,1);
3749 ChFiDS_CommonPoint& CV4 = Fd1->ChangeVertex(isfirst,2);
3751 if (CV3.IsOnArc()) {
3752 if (CV3.Arc().IsSame(arc1) ){
3753 if (CV1.Point().Distance(CV3.Point())<1.e-4)
3754 oksurf=Standard_True;
3756 else if (CV3.Arc().IsSame(arc2)){
3757 if (CV2.Point().Distance(CV3.Point())<1.e-4)
3758 oksurf=Standard_True;
3762 if (CV4.IsOnArc()) {
3763 if (CV1.Point().Distance(CV4.Point())<1.e-4)
3764 oksurf=Standard_True;
3765 else if (CV4.Arc().IsSame(arc2)){
3766 if (CV2.Point().Distance(CV4.Point())<1.e-4)
3767 oksurf=Standard_True;
3775 //Case of fillets on top with 4 edges, one of them is on the same geometry as the edgeof the fillet
3778 void ChFi3d_Builder::IntersectMoreCorner(const Standard_Integer Index)
3780 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
3783 OSD_Chronometer ch;// init perf pour PerformSetOfKPart
3785 // The fillet is returned,
3786 ChFiDS_ListIteratorOfListOfStripe StrIt;
3787 StrIt.Initialize(myVDataMap(Index));
3788 Handle(ChFiDS_Stripe) stripe = StrIt.Value();
3789 const Handle(ChFiDS_Spine) spine = stripe->Spine();
3790 ChFiDS_SequenceOfSurfData& SeqFil =
3791 stripe->ChangeSetOfSurfData()->ChangeSequence();
3793 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
3794 // the SurfData concerned and its CommonPoints,
3795 Standard_Integer sens = 0;
3797 // Choose the proper SurfData
3798 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
3799 Standard_Boolean isfirst = (sens == 1);
3801 for (; num<SeqFil.Length() && (
3802 (SeqFil.Value(num)->IndexOfS1()==0) ||
3803 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
3804 SeqFil.Remove(num); // The surplus is removed
3809 (SeqFil.Value(num)->IndexOfS1()==0) ||
3810 (SeqFil.Value(num)->IndexOfS2()==0) ); ) {
3811 SeqFil.Remove(num);// The surplus is removed
3816 Handle(ChFiDS_SurfData)& Fd = SeqFil.ChangeValue(num);
3817 ChFiDS_CommonPoint& CV1 = Fd->ChangeVertex(isfirst,1);
3818 ChFiDS_CommonPoint& CV2 = Fd->ChangeVertex(isfirst,2);
3819 //To evaluate the cloud of new points.
3822 // The cases of cap are processed separately from intersection.
3823 // ----------------------------------------------------------
3825 TopoDS_Face Fv,Fad,Fop,Fopbis;
3826 TopoDS_Edge Arcpiv,Arcprol,Arcspine,Arcprolbis;
3827 if(isfirst) Arcspine = spine->Edges(1);
3828 else Arcspine = spine->Edges(spine->NbEdges());
3829 TopAbs_Orientation OArcprolbis;
3831 TopAbs_Orientation OArcprolv = TopAbs_FORWARD, OArcprolop = TopAbs_FORWARD;
3833 TopAbs_Orientation OArcprolv, OArcprolop;
3835 Standard_Integer ICurve;
3836 Handle(BRepAdaptor_HSurface) HBs = new BRepAdaptor_HSurface();
3837 Handle(BRepAdaptor_HSurface) HBad = new BRepAdaptor_HSurface();
3838 Handle(BRepAdaptor_HSurface) HBop = new BRepAdaptor_HSurface();
3839 BRepAdaptor_Surface& Bs = HBs->ChangeSurface();
3840 BRepAdaptor_Surface& Bad = HBad->ChangeSurface();
3841 BRepAdaptor_Surface& Bop = HBop->ChangeSurface();
3842 Handle(Geom_Curve) Cc;
3843 Handle(Geom2d_Curve) Pc,Ps;
3844 Standard_Real Ubid,Vbid;//,mu,Mu,mv,Mv;
3846 Standard_Real Udeb = 0.,Ufin = 0.;
3848 Standard_Real Udeb,Ufin;
3850 //gp_Pnt2d UVf1,UVl1,UVf2,UVl2;
3851 //Standard_Real Du,Dv,Step;
3852 Standard_Boolean inters = Standard_True;
3853 Standard_Integer IFadArc = 1, IFopArc = 2;
3854 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
3858 ChFi3d_InitChron(ch); // init perf condition
3861 if(!CV1.IsOnArc() && !CV2.IsOnArc())
3862 Standard_Failure::Raise("Corner intersmore : no point on arc");
3863 else if(CV1.IsOnArc() && CV2.IsOnArc()){
3864 Standard_Boolean sur1 = 0, sur2 = 0;
3865 for(ex.Init(CV1.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()){
3866 if(Vtx.IsSame(ex.Current())) {
3871 for(ex.Init(CV2.Arc(),TopAbs_VERTEX); ex.More(); ex.Next()){
3872 if(Vtx.IsSame(ex.Current())){
3877 if(sur2) IFadArc = 2;
3879 else if(CV2.IsOnArc()) IFadArc = 2;
3880 IFopArc = 3-IFadArc;
3882 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
3883 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
3884 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
3885 TopTools_ListIteratorOfListOfShape It;
3886 // The face at end is returned without control of its unicity.
3887 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
3888 if(!Fad.IsSame(It.Value())){
3889 Fv = TopoDS::Face(It.Value());
3894 // does the face at end contain the Vertex ?
3895 Standard_Boolean isinface = Standard_False;
3896 for (ex.Init(Fv,TopAbs_VERTEX); ex.More(); ex.Next()){
3897 if (ex.Current().IsSame(Vtx)) {
3898 isinface = Standard_True;
3903 IFadArc = 3-IFadArc;
3904 IFopArc = 3-IFopArc;
3905 Arcpiv = Fd->Vertex(isfirst,IFadArc).Arc();
3906 Fad = TopoDS::Face(DStr.Shape(Fd->Index(IFadArc)));
3907 Fop = TopoDS::Face(DStr.Shape(Fd->Index(IFopArc)));
3908 //TopTools_ListIteratorOfListOfShape It;
3909 // The face at end is returned without control of its unicity.
3910 for(It.Initialize(myEFMap(Arcpiv));It.More();It.Next()) {
3911 if(!Fad.IsSame(It.Value())){
3912 Fv = TopoDS::Face(It.Value());
3918 if(Fv.IsNull()) StdFail_NotDone::Raise
3919 ("OneCorner : face at end is not found");
3921 Fv.Orientation(TopAbs_FORWARD);
3922 Fad.Orientation(TopAbs_FORWARD);
3924 // In the same way the edge to be extended is returned.
3925 for(It.Initialize(myVEMap(Vtx));It.More() && Arcprol.IsNull();It.Next()){
3926 if(!Arcpiv.IsSame(It.Value())){
3927 for(ex.Init(Fv,TopAbs_EDGE); ex.More(); ex.Next()){
3928 if(It.Value().IsSame(ex.Current())) {
3929 Arcprol = TopoDS::Edge(It.Value());
3930 OArcprolv = ex.Current().Orientation();
3937 //Fopbis is the face containing the trace of fillet CP.Arc() which of does not contain Vtx.
3938 //Normallly Fobis is either the same as Fop (cylinder), or Fobis is G1 with Fop.
3939 Fopbis.Orientation(TopAbs_FORWARD);
3941 //Fop calls the 4th face non-used for the vertex
3942 cherche_face(myVFMap(Vtx),Arcprol,Fad,Fv,Fv,Fopbis);
3943 Fop.Orientation(TopAbs_FORWARD);
3945 if(Arcprol.IsNull()) StdFail_NotDone::Raise
3946 ("OneCorner : edge to be extended is not found");
3947 for(ex.Init(Fopbis,TopAbs_EDGE); ex.More(); ex.Next()){
3948 if(Arcprol.IsSame(ex.Current())) {
3949 OArcprolop = ex.Current().Orientation();
3955 Standard_Integer prol;
3957 Handle(Geom_Surface ) Sface;
3958 Sface=BRep_Tool::Surface(Fv);
3959 ChFi3d_ExtendSurface(Sface,prol);
3960 tol=BRep_Tool::Tolerance(Fv);
3961 BRE.MakeFace(FFv,Sface,tol);
3963 Bs.Initialize(FFv,Standard_False);
3964 DStr.SetNewSurface(Fv,Sface);
3966 else Bs.Initialize(Fv,Standard_False);
3967 Bad.Initialize(Fad);
3968 Bop.Initialize(Fop);
3970 // it is necessary to modify the CommonPoint
3971 // in the space and its parameter in FaceInterference.
3972 // So both of them are returned in references
3973 // non const. Attention the modifications are done behind
3975 ChFiDS_CommonPoint& CPopArc = Fd->ChangeVertex(isfirst,IFopArc);
3976 ChFiDS_FaceInterference& FiopArc = Fd->ChangeInterference(IFopArc);
3977 ChFiDS_CommonPoint& CPadArc = Fd->ChangeVertex(isfirst,IFadArc);
3978 ChFiDS_FaceInterference& FiadArc = Fd->ChangeInterference(IFadArc);
3979 // the parameter of the vertex is initialized with the value
3980 // of its opposing vertex (point on arc).
3981 Standard_Real wop = Fd->ChangeInterference(IFadArc).Parameter(isfirst);
3982 Handle(Geom_Curve) c3df;
3983 Handle(GeomAdaptor_HSurface)
3984 HGs = new GeomAdaptor_HSurface(DStr.Surface(Fd->Surf()).Surface());
3988 // add here more or less restrictive criteria to
3989 // decide if the intersection with face is done at the
3990 // extended end or if there will be a cap on sharp end.
3991 c3df = DStr.Curve(FiopArc.LineIndex()).Curve();
3992 Standard_Real uf = FiopArc.FirstParameter();
3993 Standard_Real ul = FiopArc.LastParameter();
3994 Handle(GeomAdaptor_HCurve) Hc3df;
3995 if(c3df->IsPeriodic()){
3996 Hc3df = new GeomAdaptor_HCurve(c3df);
3999 Hc3df = new GeomAdaptor_HCurve(c3df,uf,ul);
4001 inters = Update(HBs,Hc3df,FiopArc,CPopArc,p2dbout,isfirst,wop);
4002 // Modified by Sergey KHROMOV - Fri Dec 21 18:08:27 2001 Begin
4003 // if(!inters && BRep_Tool::Continuity(Arcprol,Fv,Fop) != GeomAbs_C0){
4004 if(!inters && isTangentFaces(Arcprol,Fv,Fop)){
4005 // Modified by Sergey KHROMOV - Fri Dec 21 18:08:29 2001 End
4006 // Arcprol is an edge of tangency, ultimate adjustment by an extrema curve/curve is attempted.
4007 Standard_Real ff,ll;
4008 Handle(Geom2d_Curve) gpcprol = BRep_Tool::CurveOnSurface(Arcprol,Fv,ff,ll);
4009 Handle(Geom2dAdaptor_HCurve) pcprol = new Geom2dAdaptor_HCurve(gpcprol);
4010 Standard_Real partemp = BRep_Tool::Parameter(Vtx,Arcprol);
4011 inters = Update(HBs,pcprol,HGs,FiopArc,CPopArc,p2dbout,
4012 isfirst,partemp,wop,10*tolesp);
4014 Handle(BRepAdaptor_HCurve2d) pced = new BRepAdaptor_HCurve2d();
4015 pced->ChangeCurve2d().Initialize(CPadArc.Arc(),Fv);
4016 Update(HBs,pced,HGs,FiadArc,CPadArc,isfirst);
4019 ChFi3d_ResultChron(ch,t_same); // result perf condition if (same)
4020 ChFi3d_InitChron(ch); // init perf condition if (inters)
4023 TopoDS_Edge edgecouture;
4024 Standard_Boolean couture,intcouture=Standard_False;;
4025 Standard_Real tolreached;
4027 Standard_Real par1 = 0.,par2 = 0.;
4028 Standard_Integer indpt =0,Icurv1 =0,Icurv2 =0;
4030 Standard_Real par1,par2;
4031 Standard_Integer indpt,Icurv1,Icurv2;
4033 Handle(Geom_TrimmedCurve) curv1,curv2;
4034 Handle(Geom2d_Curve) c2d1,c2d2;
4036 Standard_Integer Isurf=Fd->Surf();
4039 HGs = ChFi3d_BoundSurf(DStr,Fd,1,2);
4040 const ChFiDS_FaceInterference& Fi1 = Fd->InterferenceOnS1();
4041 const ChFiDS_FaceInterference& Fi2 = Fd->InterferenceOnS2();
4042 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
4043 gp_Pnt2d pfil1,pfac1,pfil2,pfac2;
4044 Handle(Geom2d_Curve) Hc1,Hc2;
4045 if( IFopArc == 1) pfac1 = p2dbout;
4047 Hc1 = BRep_Tool::CurveOnSurface(CV1.Arc(),Fv,Ubid,Ubid);
4048 pfac1 = Hc1->Value(CV1.ParameterOnArc());
4050 if(IFopArc == 2) pfac2 = p2dbout;
4052 Hc2 = BRep_Tool::CurveOnSurface(CV2.Arc(),Fv,Ubid,Ubid);
4053 pfac2 = Hc2->Value(CV2.ParameterOnArc());
4055 if(Fi1.LineIndex() != 0){
4056 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(isfirst));
4059 pfil1 = Fi1.PCurveOnSurf()->Value(Fi1.Parameter(!isfirst));
4061 if(Fi2.LineIndex() != 0){
4062 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(isfirst));
4065 pfil2 = Fi2.PCurveOnSurf()->Value(Fi2.Parameter(!isfirst));
4067 ChFi3d_Recale(Bs,pfac1,pfac2,(IFadArc == 1));
4068 Pardeb(1)= pfil1.X();Pardeb(2) = pfil1.Y();
4069 Pardeb(3)= pfac1.X();Pardeb(4) = pfac1.Y();
4070 Parfin(1)= pfil2.X();Parfin(2) = pfil2.Y();
4071 Parfin(3)= pfac2.X();Parfin(4) = pfac2.Y();
4072 Standard_Real uu1,uu2,vv1,vv2;
4073 ChFi3d_Boite(pfac1,pfac2,uu1,uu2,vv1,vv2);
4074 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
4076 if (!ChFi3d_ComputeCurves(HGs,HBs,Pardeb,Parfin,Cc,
4078 Pc,tolesp,tol2d,tolreached))
4079 Standard_Failure::Raise("OneCorner : failed calculation intersection");
4081 Udeb = Cc->FirstParameter();
4082 Ufin = Cc->LastParameter();
4084 // check if the curve has an intersection with sewing edge
4086 ChFi3d_Couture(Fv,couture,edgecouture);
4088 if (couture && !BRep_Tool::Degenerated(edgecouture)) {
4090 //Standard_Real Ubid,Vbid;
4091 Handle (Geom_Curve) C=BRep_Tool::Curve(edgecouture,Ubid,Vbid);
4092 Handle(Geom_TrimmedCurve) Ctrim=new Geom_TrimmedCurve (C,Ubid,Vbid);
4093 GeomAdaptor_Curve cur1(Ctrim->BasisCurve());
4094 GeomAdaptor_Curve cur2(Cc);
4095 Extrema_ExtCC extCC (cur1,cur2);
4096 if (extCC.IsDone()&&extCC.NbExt()!=0)
4098 Standard_Integer imin=0;
4099 Standard_Real dist2min = RealLast();
4100 for (Standard_Integer i = 1; i <= extCC.NbExt(); i++)
4101 if (extCC.SquareDistance(i) < dist2min)
4103 dist2min = extCC.SquareDistance(i);
4106 if (dist2min <= Precision::SquareConfusion())
4108 Extrema_POnCurv ponc1,ponc2;
4109 extCC.Points( imin, ponc1, ponc2 );
4110 par1 = ponc1.Parameter();
4111 par2 = ponc2.Parameter();
4112 Standard_Real Tol = 1.e-4;
4113 if (Abs(par2-Udeb) > Tol && Abs(Ufin-par2) > Tol)
4115 gp_Pnt P1=ponc1.Value();
4116 TopOpeBRepDS_Point tpoint( P1, Tol );
4117 indpt = DStr.AddPoint(tpoint);
4118 intcouture = Standard_True;
4119 curv1 = new Geom_TrimmedCurve(Cc,Udeb,par2);
4120 curv2 = new Geom_TrimmedCurve(Cc,par2,Ufin);
4121 TopOpeBRepDS_Curve tcurv1(curv1,tolreached);
4122 TopOpeBRepDS_Curve tcurv2(curv2,tolreached);
4123 Icurv1=DStr.AddCurve(tcurv1);
4124 Icurv2=DStr.AddCurve(tcurv2);
4132 Standard_NotImplemented::Raise("OneCorner : cap not written");
4134 Standard_Integer IShape = DStr.AddShape(Fv);
4136 TopAbs_Orientation Et = TopAbs_FORWARD;
4138 TopAbs_Orientation Et;
4141 TopExp_Explorer Exp;
4142 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
4143 TopAbs_EDGE);Exp.More();Exp.Next()) {
4144 if (Exp.Current().IsSame(CV1.Arc())) {
4145 Et = TopAbs::Reverse(TopAbs::Compose
4146 (Exp.Current().Orientation(),
4147 CV1.TransitionOnArc()));
4153 TopExp_Explorer Exp;
4154 for (Exp.Init(Fv.Oriented(TopAbs_FORWARD),
4155 TopAbs_EDGE);Exp.More();Exp.Next()) {
4156 if (Exp.Current().IsSame(CV2.Arc())) {
4157 Et = TopAbs::Compose(Exp.Current().Orientation(),
4158 CV2.TransitionOnArc());
4169 ChFi3d_ResultChron(ch ,t_inter); //result perf condition if (inter)
4170 ChFi3d_InitChron(ch); // init perf condition if ( inters)
4173 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV1,DStr),isfirst,1);
4174 stripe->SetIndexPoint(ChFi3d_IndexPointInDS(CV2,DStr),isfirst,2);
4177 // there is no intersection with edge of sewing
4178 // curve Cc is stored in the stripe
4179 // the storage in the DS is done by FILDS.
4181 TopOpeBRepDS_Curve Tc(Cc,tolreached);
4182 ICurve = DStr.AddCurve(Tc);
4183 Handle(TopOpeBRepDS_SurfaceCurveInterference)
4184 Interfc = ChFi3d_FilCurveInDS(ICurve,IShape,Pc,Et);
4185 DStr.ChangeShapeInterferences(IShape).Append(Interfc);
4186 stripe->ChangePCurve(isfirst)=Ps;
4187 stripe->SetCurve(ICurve,isfirst);
4188 stripe->SetParameters(isfirst,Udeb,Ufin);
4191 // curves curv1 and curv2 are stored in the DS
4192 // these curves are not reconstructed by FILDS as
4193 // stripe->InDS(isfirst) is placed;
4195 // interferences of curv1 and curv2 on Fv
4196 ComputeCurve2d(curv1,Fv,c2d1);
4197 Handle(TopOpeBRepDS_SurfaceCurveInterference) InterFv;
4198 InterFv = ChFi3d_FilCurveInDS(Icurv1,IShape,c2d1,Et);
4199 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
4200 ComputeCurve2d(curv2,Fv,c2d2);
4201 InterFv = ChFi3d_FilCurveInDS(Icurv2,IShape,c2d2,Et);
4202 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
4203 // interferences of curv1 and curv2 on Isurf
4204 if (Fd->Orientation()== Fv.Orientation()) Et=TopAbs::Reverse(Et);
4205 c2d1=new Geom2d_TrimmedCurve(Ps,Udeb,par2);
4206 InterFv = ChFi3d_FilCurveInDS(Icurv1,Isurf,c2d1,Et);
4207 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
4208 c2d2=new Geom2d_TrimmedCurve(Ps,par2,Ufin);
4209 InterFv = ChFi3d_FilCurveInDS(Icurv2,Isurf,c2d2,Et);
4210 DStr.ChangeSurfaceInterferences(Isurf).Append(InterFv);
4212 // limitation of the sewing edge
4213 Standard_Integer Iarc=DStr.AddShape(edgecouture);
4214 Handle(TopOpeBRepDS_CurvePointInterference) Interfedge;
4215 TopAbs_Orientation ori;
4216 TopoDS_Vertex Vdeb,Vfin;
4217 Vdeb=TopExp::FirstVertex(edgecouture);
4218 Vfin=TopExp::LastVertex(edgecouture);
4219 Standard_Real pard,parf;
4220 pard=BRep_Tool::Parameter(Vdeb,edgecouture);
4221 parf=BRep_Tool::Parameter(Vfin,edgecouture);
4222 if (Abs(par1-pard)<Abs(parf-par1)) ori=TopAbs_FORWARD;
4223 else ori=TopAbs_REVERSED;
4224 Interfedge = ChFi3d_FilPointInDS(ori,Iarc,indpt,par1);
4225 DStr.ChangeShapeInterferences(Iarc).Append(Interfedge);
4227 // creation of CurveInterferences from Icurv1 and Icurv2
4228 stripe->InDS(isfirst);
4229 Standard_Integer ind1= stripe->IndexPoint(isfirst,1);
4230 Standard_Integer ind2= stripe->IndexPoint(isfirst,2);
4231 Handle(TopOpeBRepDS_CurvePointInterference)
4232 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv1,ind1,Udeb);
4233 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
4234 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv1,indpt,par2);
4235 DStr.ChangeCurveInterferences(Icurv1).Append(interfprol);
4236 interfprol = ChFi3d_FilPointInDS(TopAbs_FORWARD,Icurv2,indpt,par2);
4237 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
4238 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,Icurv2,ind2,Ufin);
4239 DStr.ChangeCurveInterferences(Icurv2).Append(interfprol);
4243 ChFi3d_EnlargeBox(HBs,Pc,Udeb,Ufin,box1,box2);
4248 // The small end of curve missing for the extension
4249 // of the face at end and the limitation of the opposing face is added.
4251 // Above all the points cut the points with the edge of the spine.
4252 Standard_Integer IArcspine = DStr.AddShape(Arcspine);
4253 Standard_Integer IVtx = DStr.AddShape(Vtx);
4254 TopAbs_Orientation OVtx2;
4256 TopAbs_Orientation OVtx = TopAbs_FORWARD;
4258 TopAbs_Orientation OVtx;
4260 for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
4261 ex.More(); ex.Next()){
4262 if(Vtx.IsSame(ex.Current())) {
4263 OVtx = ex.Current().Orientation();
4267 OVtx = TopAbs::Reverse(OVtx);
4268 Standard_Real parVtx = BRep_Tool::Parameter(Vtx,Arcspine);
4269 Handle(TopOpeBRepDS_CurvePointInterference)
4270 interfv = ChFi3d_FilVertexInDS(OVtx,IArcspine,IVtx,parVtx);
4271 DStr.ChangeShapeInterferences(IArcspine).Append(interfv);
4274 //Modif of lvt to find the suite of Arcprol in the other face
4276 TopTools_ListIteratorOfListOfShape It;
4277 for (It.Initialize(myVEMap(Vtx)); It.More(); It.Next()){
4278 if (!(Arcprol.IsSame(It.Value()) ||
4279 Arcspine.IsSame(It.Value()) ||
4280 Arcpiv.IsSame(It.Value()))) {
4281 Arcprolbis = TopoDS::Edge(It.Value());
4288 //Now the missing curves are constructed.
4289 for(ex.Init(Arcprolbis.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
4290 ex.More(); ex.Next()){
4291 if(Vtx.IsSame(ex.Current())) {
4292 OVtx2 = ex.Current().Orientation();
4296 for(ex.Init(Arcprol.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
4297 ex.More(); ex.Next()){
4298 if(Vtx.IsSame(ex.Current())) {
4299 OVtx = ex.Current().Orientation();
4303 // it is checked if Fop has a sewing edge
4305 // TopoDS_Edge edgecouture;
4306 // Standard_Boolean couture;
4307 ChFi3d_Couture(Fop,couture,edgecouture);
4308 Handle(Geom2d_Curve) Hc;
4309 // parVtx = BRep_Tool::Parameter(Vtx,Arcprol);
4310 const ChFiDS_FaceInterference& Fiop = Fd->Interference(IFopArc);
4311 gp_Pnt2d pop1, pop2, pv1, pv2;
4313 parVtx = BRep_Tool::Parameter(Vtx,Arcprolbis);
4314 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 Begin
4315 // if(Fop.IsSame(Fopbis)) OArcprolbis = OArcprolop;
4316 // else OArcprolbis = Arcprolbis.Orientation();
4317 if(Fop.IsSame(Fopbis)) {
4318 OArcprolbis = OArcprolop;
4320 for(ex.Init(Fop,TopAbs_EDGE); ex.More(); ex.Next()){
4321 if(Arcprolbis.IsSame(ex.Current())) {
4322 OArcprolbis = ex.Current().Orientation();
4327 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 End
4329 Hc = BRep_Tool::CurveOnSurface(Arcprolbis,Fop,Ubid,Ubid);
4330 pop1 = Hc->Value(parVtx);
4331 pop2 = Fiop.PCurveOnFace()->Value(Fiop.Parameter(isfirst));
4332 Hc = BRep_Tool::CurveOnSurface(Arcprol,Fv,Ubid,Ubid);
4334 parVtx = BRep_Tool::Parameter(Vtx,Arcprol);
4336 pv1 = Hc->Value(parVtx);
4338 ChFi3d_Recale(Bs,pv1,pv2,1);
4339 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
4340 Pardeb(1) = pop1.X(); Pardeb(2) = pop1.Y();
4341 Pardeb(3) = pv1.X(); Pardeb(4) = pv1.Y();
4342 Parfin(1) = pop2.X(); Parfin(2) = pop2.Y();
4343 Parfin(3) = pv2.X(); Parfin(4) = pv2.Y();
4344 Standard_Real uu1,uu2,vv1,vv2;
4345 ChFi3d_Boite(pv1,pv2,uu1,uu2,vv1,vv2);
4346 ChFi3d_BoundFac(Bs,uu1,uu2,vv1,vv2);
4347 ChFi3d_Boite(pop1,pop2,uu1,uu2,vv1,vv2);
4348 ChFi3d_BoundFac(Bop,uu1,uu2,vv1,vv2);
4350 Handle(Geom_Curve) zob3d;
4351 Handle(Geom2d_Curve) zob2dop, zob2dv;
4352 // Standard_Real tolreached;
4353 if (!ChFi3d_ComputeCurves(HBop,HBs,Pardeb,Parfin,zob3d,zob2dop,
4354 zob2dv,tolesp,tol2d,tolreached))
4355 Standard_Failure::Raise("OneCorner : echec calcul intersection");
4357 Udeb = zob3d->FirstParameter();
4358 Ufin = zob3d->LastParameter();
4359 TopOpeBRepDS_Curve Zob(zob3d,tolreached);
4360 Standard_Integer IZob = DStr.AddCurve(Zob);
4362 // it is not determined if the curve has an intersection with the sewing edge
4366 Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolv));
4367 Standard_Integer Iop = DStr.AddShape(Fop);
4368 Handle(TopOpeBRepDS_SurfaceCurveInterference)
4369 InterFv = ChFi3d_FilCurveInDS(IZob,IShape,zob2dv,Et);
4370 DStr.ChangeShapeInterferences(IShape).Append(InterFv);
4371 //OVtx = TopAbs::Reverse(OVtx);
4372 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 Begin
4373 // Et = TopAbs::Reverse(TopAbs::Compose(OVtx,OArcprolbis));
4374 Et = TopAbs::Reverse(TopAbs::Compose(OVtx2,OArcprolbis));
4375 // Modified by skv - Thu Aug 21 11:55:58 2008 OCC20222 End
4376 //OVtx = TopAbs::Reverse(OVtx);
4377 // Et = TopAbs::Reverse(Et);
4378 Handle(TopOpeBRepDS_SurfaceCurveInterference)
4379 Interfop = ChFi3d_FilCurveInDS(IZob,Iop,zob2dop,Et);
4380 DStr.ChangeShapeInterferences(Iop).Append(Interfop);
4381 Handle(TopOpeBRepDS_CurvePointInterference)
4382 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IVtx,Udeb);
4383 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
4384 Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc);
4385 interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,IZob,icc,Ufin);
4386 DStr.ChangeCurveInterferences(IZob).Append(interfprol);
4390 ChFi3d_EnlargeBox(DStr,stripe,Fd,box1,box2,isfirst);
4392 ChFi3d_EnlargeBox(CV1.Arc(),myEFMap(CV1.Arc()),CV1.ParameterOnArc(),box1);
4395 ChFi3d_EnlargeBox(CV2.Arc(),myEFMap(CV2.Arc()),CV2.ParameterOnArc(),box2);
4397 if (!CV1.IsVertex())
4398 ChFi3d_SetPointTolerance(DStr,box1,stripe->IndexPoint(isfirst,1));
4399 if (!CV2.IsVertex())
4400 ChFi3d_SetPointTolerance(DStr,box2,stripe->IndexPoint(isfirst,2));
4403 ChFi3d_ResultChron(ch, t_sameinter);//result perf condition if (same &&inter)