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