7fd59977 |
1 | // File: ChFi3d_Builder_C2.cxx |
2 | // Created: Tue Aug 20 14:14:29 1996 |
3 | // Author: Stagiaire Xuan Tang PHAMPHU |
4 | // <xpu@pomalox.paris1.matra-dtv.fr> |
5 | |
6 | #include <ChFi3d_Builder.jxx> |
7 | #include <ChFi3d.hxx> |
8 | #include <ChFi3d_Builder_0.hxx> |
9 | |
10 | #include <Precision.hxx> |
11 | |
12 | #include <Standard_Failure.hxx> |
13 | #include <Standard_NotImplemented.hxx> |
14 | #include <StdFail_NotDone.hxx> |
15 | |
16 | |
17 | #include <gp_Pnt.hxx> |
18 | #include <gp_Dir.hxx> |
19 | #include <gp_Vec.hxx> |
20 | #include <gp_Ax3.hxx> |
21 | #include <gp_Pnt2d.hxx> |
22 | #include <gp_Vec2d.hxx> |
23 | #include <gp_Dir2d.hxx> |
24 | #include <GeomLib.hxx> |
25 | #include <Extrema_ExtPC.hxx> |
26 | #include <Geom_Curve.hxx> |
27 | #include <Geom2d_Curve.hxx> |
28 | #include <Geom_BoundedCurve.hxx> |
29 | |
30 | #include <Geom2dAdaptor_HCurve.hxx> |
31 | #include <GeomAbs_Shape.hxx> |
32 | #include <GeomAdaptor_HCurve.hxx> |
33 | #include <GeomAdaptor_Surface.hxx> |
34 | #include <GeomAdaptor_HSurface.hxx> |
35 | |
36 | #include <Adaptor3d_HCurveOnSurface.hxx> |
37 | #include <BRepAdaptor_HSurface.hxx> |
38 | #include <BRepAdaptor_Curve.hxx> |
39 | #include <BRepAdaptor_Curve2d.hxx> |
40 | #include <BRepAdaptor_HCurve.hxx> |
41 | #include <BRepAdaptor_Surface.hxx> |
42 | |
43 | #include <BRep_Tool.hxx> |
44 | |
45 | #include <TopoDS.hxx> |
46 | #include <TopoDS_Shape.hxx> |
47 | #include <TopoDS_Face.hxx> |
48 | #include <TopoDS_Edge.hxx> |
49 | #include <TopoDS_Vertex.hxx> |
50 | |
51 | #include <TopAbs.hxx> |
52 | #include <TopAbs_ShapeEnum.hxx> |
53 | #include <TopAbs_Orientation.hxx> |
54 | |
55 | #include <TopExp.hxx> |
56 | #include <TopExp_Explorer.hxx> |
57 | |
58 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
59 | |
60 | #include <TopOpeBRepDS_Point.hxx> |
61 | #include <TopOpeBRepDS_Curve.hxx> |
62 | #include <TopOpeBRepDS_Surface.hxx> |
63 | #include <TopOpeBRepDS_SurfaceCurveInterference.hxx> |
64 | #include <TopOpeBRepDS_CurvePointInterference.hxx> |
65 | #include <TopOpeBRepDS_DataStructure.hxx> |
66 | #include <TopOpeBRepDS_ListOfInterference.hxx> |
67 | |
68 | #include <ChFiDS_HData.hxx> |
69 | #include <ChFiDS_SurfData.hxx> |
70 | #include <ChFiDS_CommonPoint.hxx> |
71 | #include <ChFiDS_FaceInterference.hxx> |
72 | #include <ChFiDS_SequenceOfSurfData.hxx> |
73 | #include <ChFiDS_Stripe.hxx> |
74 | #include <ChFiDS_ListIteratorOfListOfStripe.hxx> |
75 | |
76 | #include <TColStd_Array1OfReal.hxx> |
77 | |
78 | static void Reduce(const Standard_Real& p1, |
79 | const Standard_Real& p2, |
80 | Handle(GeomAdaptor_HSurface)& hs1, |
81 | Handle(GeomAdaptor_HSurface)& hs2) |
82 | { |
83 | GeomAdaptor_Surface& s1 = hs1->ChangeSurface(); |
84 | GeomAdaptor_Surface& s2 = hs2->ChangeSurface(); |
85 | const Handle(Geom_Surface&) surf = s1.Surface(); |
86 | Standard_Real ud,uf,vd,vf; |
87 | surf->Bounds(ud,uf,vd,vf); |
88 | Standard_Real milmoins = 0.51*vd+0.49*vf, milplus = 0.49*vd+0.51*vf; |
89 | if(p1 < p2) { |
90 | s1.Load(surf,ud,uf,vd,milmoins); |
91 | s2.Load(surf,ud,uf,milplus,vf); |
92 | } |
93 | else{ |
94 | s1.Load(surf,ud,uf,milplus,vf); |
95 | s2.Load(surf,ud,uf,vd,milmoins); |
96 | } |
97 | } |
98 | |
99 | static void Reduce(const Standard_Real& p1, |
100 | const Standard_Real& p2, |
101 | Handle(GeomAdaptor_HCurve)& hc) |
102 | { |
103 | GeomAdaptor_Curve& c = hc->ChangeCurve(); |
104 | Standard_Real f = c.FirstParameter(); |
105 | Standard_Real l = c.LastParameter(); |
106 | Standard_Real milmoins = 0.51*f+0.49*l, milplus = 0.49*f+0.51*l; |
107 | if(p1 < p2) { |
108 | c.Load(c.Curve(),f,milmoins); |
109 | } |
110 | else{ |
111 | c.Load(c.Curve(),milplus,l); |
112 | } |
113 | } |
114 | |
115 | |
116 | //======================================================================= |
117 | //function : PerformTwoCornerbyInter |
118 | //purpose : Effectue un PerformTwoCorner par intersection. |
119 | // Dans le cas Biseau on utilise pour tous les cas le |
120 | // cheminement biparam/biparam; on reapproxime alors la courbe |
121 | // 3d et les 2 pcurves . |
122 | //======================================================================= |
123 | |
124 | Standard_Integer ChFi3d_Builder::PerformTwoCornerbyInter(const Standard_Integer Index) |
125 | |
126 | { |
127 | done = 0; |
128 | const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index); |
129 | TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS(); |
130 | |
131 | //On extrait les informations necessaires sur les conges |
132 | //------------------------------------------------------ |
133 | |
134 | //le premier |
135 | //---------- |
136 | ChFiDS_ListIteratorOfListOfStripe It; |
137 | It.Initialize(myVDataMap(Index)); |
138 | Handle(ChFiDS_Stripe)& Corner1 = It.Value(); |
139 | Standard_Integer Sens1; |
140 | Standard_Integer IFd1 = |
141 | ChFi3d_IndexOfSurfData(Vtx,Corner1,Sens1); |
142 | ChFiDS_SequenceOfSurfData& SeqFil1 = |
143 | Corner1->ChangeSetOfSurfData()->ChangeSequence(); |
144 | Handle(ChFiDS_SurfData)& Fd1 = SeqFil1.ChangeValue(IFd1); |
145 | |
146 | //le deuxieme |
147 | //---------- |
148 | It.Next(); |
149 | Handle(ChFiDS_Stripe)& Corner2 = It.Value(); |
150 | Standard_Integer Sens2; |
151 | Standard_Integer IFd2; |
152 | if(Corner2 == Corner1) { |
153 | Sens2 = -1; |
154 | IFd2 = Corner2->SetOfSurfData()->Length(); |
155 | } |
156 | else{ IFd2 = ChFi3d_IndexOfSurfData(Vtx,Corner2,Sens2); } |
157 | ChFiDS_SequenceOfSurfData& SeqFil2 = |
158 | Corner2->ChangeSetOfSurfData()->ChangeSequence(); |
159 | Handle(ChFiDS_SurfData)& Fd2 = SeqFil2.ChangeValue(IFd2); |
160 | |
161 | // On analyse les concavites, dans le cas de concavites differentes, |
162 | // prevoir un raccord evolutif du type ThreeCorner de R vers 0. |
163 | // Sinon on recherche la face en vis a vis |
164 | // et l intersection eventuelle des 2 pcurves sur cette face. |
165 | |
166 | ChFiDS_State Stat1,Stat2; |
167 | Standard_Boolean isfirst1 = (Sens1 == 1); |
168 | Standard_Boolean isfirst2 = (Sens2 == 1); |
169 | Stat1 = Corner1->Spine()->Status(isfirst1); |
170 | Stat2 = Corner2->Spine()->Status(isfirst2); |
171 | /*#ifdef DEB |
172 | Standard_Boolean evolcoin = ((Stat1 == ChFiDS_OnSame && Stat2 == ChFiDS_OnDiff) || |
173 | (Stat2 == ChFiDS_OnSame && Stat1 == ChFiDS_OnDiff)); |
174 | #endif*/ |
175 | Standard_Boolean OkinterCC,Okvisavis,SameSide; |
176 | Standard_Integer IFaCo1,IFaCo2; |
177 | Standard_Real UIntPC1,UIntPC2; |
178 | TopoDS_Face FaCo; |
179 | OkinterCC = ChFi3d_IsInFront(DStr,Corner1,Corner2,IFd1,IFd2,Sens1,Sens2, |
180 | UIntPC1,UIntPC2,FaCo,SameSide, |
181 | IFaCo1,IFaCo2,Okvisavis,Vtx,Standard_True); |
182 | if (!Okvisavis) { |
183 | #if DEB |
184 | cout<<"TwoCorner : pas de face commune"<<endl; |
185 | #endif |
186 | done=Standard_False; |
187 | return done; |
188 | } |
189 | if (!OkinterCC) { |
190 | // On calcule l'intersection des pcurves sans les restreindre par les |
191 | // common point |
192 | OkinterCC= ChFi3d_IsInFront(DStr,Corner1,Corner2,IFd1,IFd2,Sens1,Sens2, |
193 | UIntPC1,UIntPC2,FaCo,SameSide, |
194 | IFaCo1,IFaCo2,Okvisavis,Vtx,Standard_True,1); |
195 | } |
196 | |
197 | if (!Okvisavis) { |
198 | #if DEB |
199 | cout<<"TwoCorner : pas de face commune"<<endl; |
200 | #endif |
201 | done=Standard_False; |
202 | return done; |
203 | } |
204 | if (!OkinterCC) { |
205 | #if DEB |
206 | cout<<"biseau : echec intersection des lignes de tangence sur face commune"<<endl; |
207 | #endif |
208 | done=Standard_False; |
209 | return done; |
210 | } |
211 | Standard_Integer IFaArc1 = 3-IFaCo1, IFaArc2 = 3-IFaCo2; |
212 | |
213 | // On verifie que les conges ont bien un commonpoint sur un arc commun. |
214 | // Cet edge est le pivot du biseau ou de la rotule. |
215 | |
216 | ChFiDS_CommonPoint& CP1 = Fd1->ChangeVertex(isfirst1,IFaArc1); |
217 | ChFiDS_CommonPoint& CP2 = Fd2->ChangeVertex(isfirst2,IFaArc2); |
218 | |
219 | if (!CP1.IsOnArc() || !CP2.IsOnArc()) { |
220 | #if DEB |
221 | cout<<"echec 1 des 2 conges n est pas sur arc"<<endl; |
222 | #endif |
223 | done=Standard_False; |
224 | return done; |
225 | } |
226 | if ( ! CP1.Arc().IsSame( CP2.Arc()) ) { |
227 | // look like OnSame + OnDiff case (eap, Arp 9 2002, occ266) |
228 | #if DEB |
229 | cout<<"PerformTwoCornerbyInter(): conges ne sont pas sur la meme arc"<<endl; |
230 | #endif |
231 | done = Standard_True; |
232 | PerformMoreThreeCorner(Index, 2); |
233 | return done; |
234 | } |
235 | |
236 | TopoDS_Edge pivot; |
237 | pivot = CP1.Arc(); |
238 | Standard_Real parCP1 = CP1.ParameterOnArc(); |
239 | Standard_Real parCP2 = CP2.ParameterOnArc(); |
240 | Handle(BRepAdaptor_HCurve) Hpivot = new BRepAdaptor_HCurve(pivot); |
241 | if (!pivot.IsSame(CP2.Arc())){ |
242 | Handle(Geom_Curve) csau; |
243 | Standard_Real ubid,vbid; |
244 | csau=BRep_Tool::Curve(pivot,ubid,vbid ); |
245 | Handle(Geom_BoundedCurve) C1= Handle(Geom_BoundedCurve)::DownCast(csau); |
246 | if (! C1.IsNull()) { |
247 | GeomLib::ExtendCurveToPoint(C1,CP2.Point(),1,Standard_False); |
248 | GeomAdaptor_Curve cad; |
249 | cad.Load(C1); |
250 | Extrema_ExtPC ext(CP2.Point(),cad,1.e-4); |
251 | parCP2 = ext.Point(1).Parameter(); |
252 | } |
253 | } |
254 | gp_Pnt psp1 = Hpivot->Value(parCP1); |
255 | gp_Pnt psp2 = Hpivot->Value(parCP2); |
256 | Standard_Real sameparam = (psp1.Distance(psp2) < 10 * tolesp); |
257 | |
258 | TopoDS_Face FF1 = TopoDS::Face(DStr.Shape(Fd1->Index(IFaArc1))); |
259 | TopoDS_Face FF2 = TopoDS::Face(DStr.Shape(Fd2->Index(IFaArc2))); |
260 | TopTools_ListIteratorOfListOfShape Kt; |
261 | Standard_Boolean ok1 = Standard_False, ok2 = Standard_False; |
262 | for (Kt.Initialize(myEFMap(pivot)); Kt.More(); Kt.Next()){ |
263 | TopoDS_Face F = TopoDS::Face(Kt.Value()); |
264 | if(!ok1 && FF1.IsSame(F)){ |
265 | ok1 = Standard_True; |
266 | } |
267 | if(!ok2 && FF2.IsSame(F)){ |
268 | ok2 = Standard_True; |
269 | } |
270 | } |
271 | if(!ok1 || !ok2){ |
272 | //On est dans un contexte merdique |
273 | #if DEB |
274 | cout<<"echec une des surfaces n a pas de face d appui commune avec l edge pivot"<<endl; |
275 | #endif |
276 | done=Standard_False; |
277 | return done; |
278 | } |
279 | |
280 | Handle(GeomAdaptor_HSurface) HS1, HS2; |
281 | HS1 = ChFi3d_BoundSurf (DStr,Fd1,IFaCo1,IFaArc1); |
282 | HS2 = ChFi3d_BoundSurf (DStr,Fd2,IFaCo2,IFaArc2); |
283 | |
284 | TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4); |
285 | |
286 | Handle(Geom2d_Curve) PGc1,PGc2; |
287 | Handle(Geom_Curve) Gc; |
288 | |
289 | if(sameparam) { |
290 | // Du cote face commune, calcul de Pardeb. |
291 | ChFi3d_ComputesIntPC (Fd1->Interference(IFaCo1), |
292 | Fd2->Interference(IFaCo2), |
293 | HS1,HS2,UIntPC1,UIntPC2); |
294 | gp_Pnt2d UV; |
295 | UV = Fd1->Interference(IFaCo1).PCurveOnSurf()->Value(UIntPC1); |
296 | Pardeb(1)= UV.X(); Pardeb(2)=UV.Y(); |
297 | UV = Fd2->Interference(IFaCo2).PCurveOnSurf()->Value(UIntPC2); |
298 | Pardeb(3)= UV.X(); Pardeb(4)=UV.Y(); |
299 | gp_Pnt PFaCo = HS1->Surface().Value(Pardeb(1),Pardeb(2)); |
300 | |
301 | // Du cote arc, calcul de Parfin. |
302 | Standard_Real UIntArc1 = Fd1->Interference(IFaArc1).Parameter(isfirst1); |
303 | Standard_Real UIntArc2 = Fd2->Interference(IFaArc2).Parameter(isfirst2); |
304 | |
305 | ChFi3d_ComputesIntPC (Fd1->Interference(IFaArc1),Fd2->Interference(IFaArc2), |
306 | HS1,HS2,UIntArc1,UIntArc2); |
307 | UV = Fd1->Interference(IFaArc1).PCurveOnSurf()->Value(UIntArc1); |
308 | Parfin(1)= UV.X(); Parfin(2)=UV.Y(); |
309 | UV = Fd2->Interference(IFaArc2).PCurveOnSurf()->Value(UIntArc2); |
310 | Parfin(3)= UV.X(); Parfin(4)=UV.Y(); |
311 | |
312 | if(Fd1->Surf() == Fd2->Surf()){ |
313 | Reduce(UIntPC1,UIntPC2,HS1,HS2); |
314 | } |
315 | |
316 | Standard_Real tolreached; |
317 | if (IFaCo1 == 1 && |
318 | !ChFi3d_ComputeCurves(HS1,HS2,Pardeb,Parfin,Gc, |
319 | PGc1,PGc2,tolesp,tol2d,tolreached)) { |
320 | #if DEB |
321 | cout<<"echec calcul biseau echec interSS"<<endl; |
322 | #endif |
323 | done=Standard_False; |
324 | return done; |
325 | } |
326 | else if (IFaCo1 == 2 && |
327 | !ChFi3d_ComputeCurves(HS1,HS2,Parfin,Pardeb,Gc, |
328 | PGc1,PGc2,tolesp,tol2d,tolreached)) { |
329 | #if DEB |
330 | cout<<"echec calcul biseau echec interSS"<<endl; |
331 | #endif |
332 | done=Standard_False; |
333 | return done; |
334 | } |
335 | // On met a jour les CornerData avec les resultats de l intersection. |
336 | Standard_Real WFirst = Gc->FirstParameter(); |
337 | Standard_Real WLast = Gc->LastParameter(); |
338 | Standard_Integer Ipoin1; |
339 | Standard_Integer Ipoin2; |
340 | ChFiDS_CommonPoint& cpco1 = Fd1->ChangeVertex(isfirst1,IFaCo1); |
341 | ChFiDS_CommonPoint& cpco2 = Fd2->ChangeVertex(isfirst2,IFaCo2); |
342 | Standard_Real tolpco = Max(cpco1.Tolerance(),cpco2.Tolerance()); |
343 | ChFiDS_CommonPoint& cparc1 = Fd1->ChangeVertex(isfirst1,IFaArc1); |
344 | ChFiDS_CommonPoint& cparc2 = Fd2->ChangeVertex(isfirst2,IFaArc2); |
345 | Standard_Real tolparc = Max(cparc1.Tolerance(),cparc2.Tolerance()); |
346 | Standard_Integer ICurv = DStr.AddCurve(TopOpeBRepDS_Curve(Gc,tolreached)); |
347 | //Corner1 |
348 | Corner1->SetParameters(isfirst1,WFirst,WLast); |
349 | Corner1->SetCurve(ICurv,isfirst1); |
350 | Corner1->ChangePCurve(isfirst1) = PGc1; |
351 | cpco1.Reset(); |
352 | cpco1.SetPoint(PFaCo); |
353 | cpco1.SetTolerance(Max(tolreached,tolpco)); |
354 | Fd1->ChangeInterference(IFaCo1).SetParameter(UIntPC1,isfirst1); |
355 | tolparc = Max(tolparc,tolreached); |
356 | cparc1.SetTolerance(Max(tolparc,tolreached)); |
357 | Ipoin1 = ChFi3d_IndexPointInDS(Fd1->Vertex(isfirst1,1),DStr); |
358 | Corner1->SetIndexPoint(Ipoin1,isfirst1,1); |
359 | Ipoin2 = ChFi3d_IndexPointInDS(Fd1->Vertex(isfirst1,2),DStr); |
360 | Corner1->SetIndexPoint(Ipoin2,isfirst1,2); |
361 | //Corner2 |
362 | Corner2->SetParameters(isfirst2,WFirst,WLast); |
363 | Corner2->SetCurve(ICurv,isfirst2); |
364 | Corner2->ChangePCurve(isfirst2) = PGc2; |
365 | Fd2->ChangeInterference(IFaCo2).SetParameter(UIntPC2,isfirst2); |
366 | Fd2->ChangeVertex(isfirst2,IFaCo2) = Fd1->Vertex(isfirst1,IFaCo1); |
367 | Fd2->ChangeVertex(isfirst2,IFaArc2) = Fd1->Vertex(isfirst1,IFaArc1); |
368 | if (IFaCo1!=IFaCo2) Corner2->SetOrientation(TopAbs_REVERSED,isfirst2); |
369 | Corner2->SetIndexPoint(Corner1->IndexPoint(isfirst1,IFaCo1), |
370 | isfirst2,IFaCo2); |
371 | Corner2->SetIndexPoint(Corner1->IndexPoint(isfirst1,IFaArc1), |
372 | isfirst2,IFaArc2); |
373 | //On update les tolerances des points. |
374 | Bnd_Box bco,barc; |
375 | if(IFaCo1 == 1) ChFi3d_EnlargeBox(DStr,Corner1,Fd1,bco,barc,isfirst1); |
376 | else ChFi3d_EnlargeBox(DStr,Corner1,Fd1,barc,bco,isfirst1); |
377 | if(IFaCo2 == 1) ChFi3d_EnlargeBox(DStr,Corner2,Fd2,bco,barc,isfirst2); |
378 | else ChFi3d_EnlargeBox(DStr,Corner2,Fd2,barc,bco,isfirst2); |
379 | const ChFiDS_CommonPoint& cparc = Fd1->Vertex(isfirst1,IFaArc1); |
380 | ChFi3d_EnlargeBox(cparc.Arc(),myEFMap(cparc.Arc()),cparc.ParameterOnArc(),barc); |
381 | ChFi3d_SetPointTolerance(DStr,barc,Corner1->IndexPoint(isfirst1,IFaArc1)); |
382 | ChFi3d_SetPointTolerance(DStr,bco,Corner1->IndexPoint(isfirst1,IFaCo1)); |
383 | } |
384 | else { |
385 | // Il faut identifier la surface qui deborde, |
386 | // trouver le point de fin de l intersection Surf/Surf |
387 | // par l intersection de la ligne de tangence du petit sur |
388 | // la face opposee avec la surface du gros, |
389 | // et enfin intersecter le gros avec la face en bout |
390 | // entre ce point et le point sur arc. |
391 | #ifndef DEB |
392 | Standard_Boolean parcrois = Standard_False ; |
393 | #else |
394 | Standard_Boolean parcrois; |
395 | #endif |
396 | TopExp_Explorer Expl; |
397 | for(Expl.Init(pivot.Oriented(TopAbs_FORWARD),TopAbs_VERTEX); |
398 | Expl.More(); Expl.Next()){ |
399 | if(Expl.Current().IsSame(Vtx)){ |
400 | parcrois = (Expl.Current().Orientation() == TopAbs_FORWARD); |
401 | break; |
402 | } |
403 | } |
404 | Handle(ChFiDS_Stripe) BigCD, SmaCD; |
405 | Handle(ChFiDS_SurfData) BigFD, SmaFD; |
406 | Handle(GeomAdaptor_HSurface) BigHS, SmaHS; |
407 | Standard_Integer IFaCoBig, IFaCoSma, IFaArcBig, IFaArcSma; |
408 | Standard_Boolean isfirstBig, isfirstSma; |
409 | Standard_Real UIntPCBig, UIntPCSma; |
410 | |
411 | if((parcrois && parCP2 > parCP1) || (!parcrois && parCP2 < parCP1)){ |
412 | UIntPCBig = UIntPC2; UIntPCSma = UIntPC1; |
413 | BigHS = HS2; SmaHS = HS1; |
414 | BigCD = Corner2; SmaCD = Corner1; |
415 | BigFD = Fd2; SmaFD = Fd1; |
416 | IFaCoBig = IFaCo2; IFaCoSma = IFaCo1; |
417 | IFaArcBig = IFaArc2; IFaArcSma = IFaArc1; |
418 | isfirstBig = isfirst2; isfirstSma = isfirst1; |
419 | } |
420 | else{ |
421 | UIntPCBig = UIntPC1, UIntPCSma = UIntPC2; |
422 | BigHS = HS1; SmaHS = HS2; |
423 | BigCD = Corner1; SmaCD = Corner2; |
424 | BigFD = Fd1; SmaFD = Fd2; |
425 | IFaCoBig = IFaCo1; IFaCoSma = IFaCo2; |
426 | IFaArcBig = IFaArc1; IFaArcSma = IFaArc2; |
427 | isfirstBig = isfirst1; isfirstSma = isfirst2; |
428 | } |
429 | |
430 | //Intersection du gros avec le petit : |
431 | //------------------------------------ |
432 | |
433 | // Pardeb (parametres du point PFaCo) |
434 | // on verifie l'intersection |
435 | ChFi3d_ComputesIntPC (SmaFD->Interference(IFaCoSma), |
436 | BigFD->Interference(IFaCoBig), |
437 | SmaHS,BigHS,UIntPCSma,UIntPCBig); |
438 | gp_Pnt2d UVi; |
439 | UVi = BigFD->Interference(IFaCoBig).PCurveOnSurf()->Value(UIntPCBig); |
440 | Pardeb(3)= UVi.X(); Pardeb(4)=UVi.Y(); |
441 | UVi = SmaFD->Interference(IFaCoSma).PCurveOnSurf()->Value(UIntPCSma); |
442 | Pardeb(1)= UVi.X(); Pardeb(2)=UVi.Y(); |
443 | gp_Pnt PFaCo = SmaHS->Value(UVi.X(),UVi.Y()); |
444 | |
445 | // Parfin (parametres du point PMil) |
446 | const ChFiDS_FaceInterference& FiArcSma = SmaFD->Interference(IFaArcSma); |
447 | Handle(Geom_Curve) ctg = DStr.Curve(FiArcSma.LineIndex()).Curve(); |
448 | Handle(GeomAdaptor_HCurve) Hctg = new GeomAdaptor_HCurve(); |
449 | GeomAdaptor_Curve& bid = Hctg->ChangeCurve(); |
450 | Standard_Real temp,wi; |
451 | |
452 | if (isfirstSma) { |
453 | wi = temp = FiArcSma.FirstParameter(); |
454 | if (UIntPCSma < temp) |
455 | temp = UIntPCSma; |
456 | bid.Load(ctg,temp,FiArcSma.LastParameter()); |
457 | } |
458 | else { |
459 | wi = temp = FiArcSma.LastParameter(); |
460 | if (UIntPCSma > temp) |
461 | temp = UIntPCSma; |
462 | bid.Load(ctg,FiArcSma.FirstParameter(),temp); |
463 | } |
464 | if(SmaFD->Surf() == BigFD->Surf()){ |
465 | Reduce(UIntPCSma,UIntPCBig,SmaHS,BigHS); |
466 | Reduce(UIntPCSma,UIntPCBig,Hctg); |
467 | } |
468 | if(!ChFi3d_IntCS(BigHS,Hctg,UVi,wi)){ |
469 | #if DEB |
470 | cout<<"biseau : echec inter C S"<<endl; |
471 | #endif |
472 | done=Standard_False; |
473 | return done; |
474 | } |
475 | Parfin(3) = UVi.X(); Parfin(4) = UVi.Y(); |
476 | UVi = FiArcSma.PCurveOnSurf()->Value(wi); |
477 | Parfin(1) = UVi.X(); Parfin(2) = UVi.Y(); |
478 | gp_Pnt PMil = SmaHS->Value(Parfin(1),Parfin(2)); |
479 | |
480 | Standard_Real tolreached; |
481 | if (!ChFi3d_ComputeCurves(SmaHS,BigHS,Pardeb,Parfin,Gc, |
482 | PGc1,PGc2,tolesp,tol2d,tolreached)) { |
483 | #if DEB |
484 | cout<<"echec calcul biseau echec interSS"<<endl; |
485 | #endif |
486 | done=Standard_False; |
487 | return done; |
488 | } |
489 | // On met a jour la SmaCD, c est fini pour elle. |
490 | Standard_Real WFirst = Gc->FirstParameter(); |
491 | Standard_Real WLast = Gc->LastParameter(); |
492 | Standard_Integer IpointCo, IpointMil, IpointArc; |
493 | ChFiDS_CommonPoint& psmaco = SmaFD->ChangeVertex(isfirstSma,IFaCoSma); |
494 | ChFiDS_CommonPoint& pbigco = BigFD->ChangeVertex(isfirstBig,IFaCoBig); |
495 | Standard_Real tolpco = Max(psmaco.Tolerance(),pbigco.Tolerance()); |
496 | ChFiDS_CommonPoint& psmamil = SmaFD->ChangeVertex(isfirstSma,IFaArcSma); |
497 | Standard_Real tolpmil = psmamil.Tolerance(); |
498 | Standard_Integer ICurv = DStr.AddCurve(TopOpeBRepDS_Curve(Gc,tolreached)); |
499 | |
500 | SmaCD->SetParameters(isfirstSma,WFirst,WLast); |
501 | SmaCD->SetCurve(ICurv,isfirstSma); |
502 | SmaCD->ChangePCurve(isfirstSma) = PGc1; |
503 | psmaco.Reset(); |
504 | psmaco.SetPoint(PFaCo); |
505 | psmaco.SetTolerance(Max(tolpco,tolreached)); |
506 | SmaFD->ChangeInterference(IFaCoSma).SetParameter(UIntPCSma,isfirstSma); |
507 | psmamil.Reset(); |
508 | psmamil.SetPoint(PMil); |
509 | psmamil.SetTolerance(Max(tolpmil,tolreached)); |
510 | SmaFD->ChangeInterference(IFaArcSma).SetParameter(wi,isfirstSma); |
511 | IpointCo = ChFi3d_IndexPointInDS(psmaco,DStr); |
512 | SmaCD->SetIndexPoint(IpointCo,isfirstSma,IFaCoSma); |
513 | IpointMil = ChFi3d_IndexPointInDS(psmamil,DStr); |
514 | SmaCD->SetIndexPoint(IpointMil,isfirstSma,IFaArcSma); |
515 | if (IFaCoSma == 2) SmaCD->SetOrientation(TopAbs_REVERSED,isfirstSma); |
516 | |
517 | // Pour la BigCD on met ces premiers resultats dans la DS. |
518 | BigCD->SetIndexPoint(IpointCo,isfirstBig,IFaCoBig); |
519 | BigFD->ChangeVertex(isfirstBig,IFaCoBig) = psmaco; |
520 | BigFD->ChangeInterference(IFaCoBig).SetParameter(UIntPCBig,isfirstBig); |
521 | |
522 | TopOpeBRepDS_ListOfInterference& Li = DStr.ChangeCurveInterferences(ICurv); |
523 | Handle(TopOpeBRepDS_CurvePointInterference) Interfp; |
524 | Interfp = ChFi3d_FilPointInDS(TopAbs_FORWARD,ICurv,IpointCo,WFirst); |
525 | Li.Append(Interfp); |
526 | Interfp = ChFi3d_FilPointInDS(TopAbs_REVERSED,ICurv,IpointMil,WLast); |
527 | Li.Append(Interfp); |
528 | |
529 | // la transition des courbes d intersection sur la Big |
530 | TopAbs_Orientation tra = BigFD->InterferenceOnS1().Transition(); |
531 | TopAbs_Orientation ofac = DStr.Shape(BigFD->IndexOfS1()).Orientation(); |
532 | TopAbs_Orientation ofil = BigFD->Orientation(); |
533 | TopAbs_Orientation tracurv = TopAbs::Compose(ofac,ofil); |
534 | tracurv = TopAbs::Compose(tracurv,tra); |
535 | if(!isfirstBig) tracurv = TopAbs::Reverse(tracurv); |
536 | if(IFaCoBig != 1) tracurv = TopAbs::Reverse(tracurv); |
537 | |
538 | Handle(TopOpeBRepDS_SurfaceCurveInterference) Interfc; |
539 | Standard_Integer ISurf = BigFD->Surf(); |
540 | Interfc = ChFi3d_FilCurveInDS (ICurv,ISurf,PGc2,tracurv); |
541 | DStr.ChangeSurfaceInterferences(ISurf).Append(Interfc); |
542 | |
543 | //On update les tolerances des points (on commence). |
544 | Bnd_Box bco,bmil,barc; |
545 | if(IFaCoSma == 1) ChFi3d_EnlargeBox(DStr,SmaCD,SmaFD,bco,bmil,isfirstSma); |
546 | else ChFi3d_EnlargeBox(DStr,SmaCD,SmaFD,bmil,bco,isfirstSma); |
547 | ChFi3d_EnlargeBox(BigHS,PGc2,WFirst,WLast,bco,bmil); |
548 | |
549 | // Intersection du gros avec la face en bout : |
550 | // ------------------------------------------- |
551 | |
552 | // Pardeb (parametres de PMil) |
553 | // On rejoue l intersection courbe surface mais avec la representation |
554 | // pcurve on face de la courbe pour etre bien sur. |
555 | TopoDS_Face F = TopoDS::Face(DStr.Shape(SmaFD->Index(IFaArcSma))); |
556 | Handle(BRepAdaptor_HSurface) HF = new BRepAdaptor_HSurface(F); |
557 | Standard_Real fsma = FiArcSma.FirstParameter(); |
558 | Standard_Real lsma = FiArcSma.LastParameter(); |
559 | Standard_Real deltSma = 0.05 * (lsma - fsma); |
560 | Handle(Geom2d_Curve) pcpc = SmaFD->Interference(IFaArcSma).PCurveOnFace(); |
561 | fsma = Max(pcpc->FirstParameter(),wi-deltSma); |
562 | lsma = Min(pcpc->LastParameter(),wi+deltSma); |
563 | if ( lsma<fsma ) { |
564 | done=Standard_False; |
565 | return done; |
566 | } |
567 | Handle(Geom2dAdaptor_HCurve) c2df = |
568 | new Geom2dAdaptor_HCurve(SmaFD->Interference(IFaArcSma).PCurveOnFace(),fsma,lsma); |
569 | Adaptor3d_CurveOnSurface consf(c2df,HF); |
570 | Handle(Adaptor3d_HCurveOnSurface) Hconsf = new Adaptor3d_HCurveOnSurface(consf); |
571 | if(!ChFi3d_IntCS(BigHS,Hconsf,UVi,wi)) { |
572 | #if DEB |
573 | cout<<"biseau : echec inter C S"<<endl; |
574 | #endif |
575 | done=Standard_False; |
576 | return done; |
577 | } |
578 | Pardeb(3) = UVi.X(); Pardeb(4) = UVi.Y(); |
579 | UVi = SmaFD->Interference(IFaArcSma).PCurveOnFace()->Value(wi); |
580 | Pardeb(1) = UVi.X(); Pardeb(2) = UVi.Y(); |
581 | gp_Pnt2d ppff1 = UVi; |
582 | |
583 | // Parfin (parametres du point cpend) |
584 | Standard_Real ptg = BigFD->Interference(IFaArcBig).Parameter(isfirstBig); |
585 | UVi = BigFD->Interference(IFaArcBig).PCurveOnSurf()->Value(ptg); |
586 | Parfin(3) = UVi.X(); Parfin(4) = UVi.Y(); |
587 | ChFiDS_CommonPoint& cpend = BigFD->ChangeVertex(isfirstBig,IFaArcBig); |
588 | TopoDS_Edge etest = cpend.Arc(); |
589 | if(BRep_Tool::IsClosed(etest,F)) etest.Reverse(); |
590 | BRepAdaptor_Curve2d arc(etest,F); |
591 | UVi = arc.Value(cpend.ParameterOnArc()); |
592 | Parfin(1) = UVi.X(); Parfin(2) = UVi.Y(); |
593 | gp_Pnt2d ppff2 = UVi; |
594 | |
595 | // Intersection. |
596 | Standard_Real uu1,uu2,vv1,vv2; |
597 | ChFi3d_Boite(ppff1,ppff2,uu1,uu2,vv1,vv2); |
598 | // pour le cas ou les deux chanfreins sont sur deux aretes OnSame, |
599 | // il faut etendre la surface portant F, sinon, au moins ne pas la |
600 | // restreindre. |
601 | ChFi3d_BoundFac(HF->ChangeSurface(),uu1,uu2,vv1,vv2,Standard_True); |
602 | |
603 | if (!ChFi3d_ComputeCurves(HF,BigHS,Pardeb,Parfin,Gc, |
604 | PGc1,PGc2,tolesp,tol2d,tolreached)) { |
605 | #if DEB |
606 | cout<<"echec calcul biseau echec interSS"<<endl; |
607 | #endif |
608 | done=Standard_False; |
609 | return done; |
610 | } |
611 | |
612 | // On finit de mettre a jour la BigCD et la DS. |
613 | WFirst = Gc->FirstParameter(); |
614 | WLast = Gc->LastParameter(); |
615 | ICurv = DStr.AddCurve(TopOpeBRepDS_Curve(Gc,tolreached)); |
616 | cpend.SetTolerance(Max(cpend.Tolerance(),tolreached)); |
617 | IpointArc = ChFi3d_IndexPointInDS(cpend,DStr); |
618 | BigCD->SetIndexPoint(IpointArc,isfirstBig,IFaArcBig); |
619 | |
620 | TopOpeBRepDS_ListOfInterference& Li7 = DStr.ChangeCurveInterferences(ICurv); |
621 | Interfp = ChFi3d_FilPointInDS(TopAbs_FORWARD,ICurv,IpointMil,WFirst); |
622 | Li7.Append(Interfp); |
623 | Interfp = ChFi3d_FilPointInDS(TopAbs_REVERSED,ICurv,IpointArc,WLast); |
624 | Li7.Append(Interfp); |
625 | Interfc = ChFi3d_FilCurveInDS (ICurv,ISurf,PGc2,tracurv); |
626 | DStr.ChangeSurfaceInterferences(ISurf).Append(Interfc); |
627 | BigCD->InDS(isfirstBig); |
628 | |
629 | // Et enfin on met dans la DS les informations cote face. |
630 | Standard_Integer IShape = DStr.AddShape(F); |
631 | if(SmaFD->Surf() == BigFD->Surf()){ |
632 | tracurv = TopAbs::Compose(etest.Orientation(), |
633 | cpend.TransitionOnArc()); |
634 | } |
635 | else { |
636 | TopExp_Explorer Exp; |
637 | for (Exp.Init(F.Oriented(TopAbs_FORWARD), |
638 | TopAbs_EDGE);Exp.More();Exp.Next()) { |
639 | if (Exp.Current().IsSame(etest)) { |
640 | tracurv = TopAbs::Compose(Exp.Current().Orientation(), |
641 | cpend.TransitionOnArc()); |
642 | break; |
643 | } |
644 | } |
645 | } |
646 | Interfc = ChFi3d_FilCurveInDS(ICurv,IShape,PGc1,tracurv); |
647 | DStr.ChangeShapeInterferences(IShape).Append(Interfc); |
648 | |
649 | //On update les tolerances des points (on finit). |
650 | Handle(ChFiDS_Stripe) bidst; |
651 | if(IFaCoBig == 1) ChFi3d_EnlargeBox(DStr,bidst,BigFD,bco,barc,isfirstBig); |
652 | else ChFi3d_EnlargeBox(DStr,bidst,BigFD,barc,bco,isfirstBig); |
653 | ChFi3d_EnlargeBox(BigHS,PGc2,WFirst,WLast,bmil,barc); |
654 | ChFi3d_EnlargeBox(HF,PGc1,WFirst,WLast,bmil,barc); |
655 | ChFi3d_EnlargeBox(Gc,WFirst,WLast,bmil,barc); |
656 | const ChFiDS_CommonPoint& cparc = BigFD->Vertex(isfirstBig,IFaArcBig); |
657 | ChFi3d_EnlargeBox(cparc.Arc(),myEFMap(cparc.Arc()),cparc.ParameterOnArc(),barc); |
658 | |
659 | ChFi3d_SetPointTolerance(DStr,bco,SmaCD->IndexPoint(isfirstSma,IFaCoSma)); |
660 | ChFi3d_SetPointTolerance(DStr,bmil,SmaCD->IndexPoint(isfirstSma,IFaArcSma)); |
661 | ChFi3d_SetPointTolerance(DStr,barc,BigCD->IndexPoint(isfirstBig,IFaArcBig)); |
662 | } |
663 | done = 1; |
664 | |
665 | return done; |
666 | } |
667 | |
668 | |
669 | |
670 | |
671 | |
672 | |