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