0025307: Problems resulted from re-triangulation
[occt.git] / src / ChFiKPart / ChFiKPart_ComputeData_ChAsymPlnCyl.cxx
CommitLineData
b311480e 1// Created on: 1998-06-16
2// Created by: Philippe NOUAILLE
3// Copyright (c) 1998-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#include <ChFiKPart_ComputeData.ixx>
18
19#include <Precision.hxx>
20#include <gp.hxx>
21#include <gp_Ax22d.hxx>
22#include <gp_Pnt2d.hxx>
23#include <gp_Dir2d.hxx>
24#include <gp_Circ2d.hxx>
25#include <gp_Pnt.hxx>
26#include <gp_Dir.hxx>
27#include <gp_Vec.hxx>
28#include <gp_Circ.hxx>
29#include <gp_Ax2.hxx>
30#include <gp_Ax3.hxx>
31#include <gp_Lin2d.hxx>
32
33#include <ElCLib.hxx>
34#include <ElSLib.hxx>
35
36#include <Geom_ConicalSurface.hxx>
37#include <Geom2d_Line.hxx>
38#include <Geom_Line.hxx>
39#include <Geom2d_Circle.hxx>
40#include <Geom_Circle.hxx>
41#include <Geom_Plane.hxx>
42#include <IntAna_QuadQuadGeo.hxx>
43
44#include <ChFiKPart_ComputeData_Fcts.hxx>
45
46
47//pour tester
48
49#include <Geom_CylindricalSurface.hxx>
50
51
52//=======================================================================
53//function : MakeChAsym
54//purpose : Compute the chamfer in the particular case Plane/Cylinder
55// or Cylinder/Plane
56// Compute the SurfData <Data> of the chamfer build on the <Spine>
57// between the plane <Pln> and the cylinder <Cyl>, with the
58// distances <Dis> and <Angle> on <Pln> on <Cyl>.
59// <Or1> and <Or2> are the orientations of <Pln> and <Cyl>
60// and <Ofpl> this of the face carried by <Pln>.
61// <First> is the start point on the <Spine>
62// <Plandab> is equal to True if the plane is the surface S1
63// <fu> and <lu> are the first and last u parameters of the
64// cylinder
65// DisOnPlan is equal to True if Dis on plan, else False
66//out : True if the chanfer has been computed
67// False else
68//=======================================================================
69
70Standard_Boolean ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr,
71 const Handle(ChFiDS_SurfData)& Data,
72 const gp_Pln& Pln,
73 const gp_Cylinder& Cyl,
74 const Standard_Real fu,
75 const Standard_Real lu,
76 const TopAbs_Orientation Or1,
77 const TopAbs_Orientation Or2,
78 const Standard_Real Dis,
79 const Standard_Real Angle,
80 const gp_Circ& Spine,
81 const Standard_Real First,
82 const TopAbs_Orientation Ofpl,
83 const Standard_Boolean plandab,
84 const Standard_Boolean DisOnP)
85{
86 // compute the chamfer surface(cone)
87
88 // compute the normals to the plane surface & to the plane face
89 gp_Ax3 PosPl = Pln.Position();
90 gp_Dir Dpl = PosPl.XDirection().Crossed(PosPl.YDirection());
91 gp_Dir norf = Dpl;
92 if ( Ofpl == TopAbs_REVERSED) norf.Reverse();
93 if (Or1 == TopAbs_REVERSED) Dpl.Reverse();
94
95 // compute the origin Or of the cone
96 gp_Pnt Or = Cyl.Location();
97 Standard_Real u, v;
98 ElSLib::PlaneParameters(PosPl, Or, u, v);
99 gp_Pnt2d pt2dPln(u, v);
100 ElSLib::PlaneD0(u, v, PosPl, Or);
101 gp_Pnt PtPl = Or; // projection of the cylinder origin
102 //on the plane
103
104 gp_Pnt PtSp;//start 3d point on the Spine
105 gp_Vec DSp; //tangent vector to the spine on PtSp
106 ElCLib::D1(First, Spine, PtSp, DSp);
107 gp_Dir Dx(gp_Vec(Or, PtSp));
108 gp_Dir Dy(DSp);
109 ElSLib::Parameters(Cyl, PtSp, u, v);
110 gp_Pnt PtCyl;//point on the cylinder and on the Spine
111 gp_Vec Vu, Vv;
112 ElSLib::D1(u, v, Cyl, PtCyl, Vu, Vv);
113 gp_Dir Dcyl(Vu.Crossed(Vv));//normal to the cylinder in PtSp
114 if (Or2 == TopAbs_REVERSED) Dcyl.Reverse();
115 Standard_Boolean dedans = ( Dcyl.Dot(Dx) <= 0.);
116
117 Standard_Boolean pointu = Standard_False;
118 Standard_Real ConRad, Rad, SemiAngl;
119
81bba717 120 //Calculation of distance
7fd59977 121 Standard_Real dis1, dis2, cosNPCyl, sinNPCyl;
122
123 if ( (plandab && DisOnP) || (!plandab && !DisOnP) ) {
124 dis1 = Dis;
125 cosNPCyl = Dpl.Dot(Dcyl);
126 sinNPCyl = sqrt(1. - cosNPCyl * cosNPCyl);
127 dis2 = Dis / (sinNPCyl / tan(Angle) - cosNPCyl);
128 }
129 else {
130 dis2 = Dis;
131 cosNPCyl = Dpl.Dot(Dcyl);
132 sinNPCyl = sqrt(1. - cosNPCyl * cosNPCyl);
133 dis1 = Dis / (sinNPCyl / tan(Angle) - cosNPCyl);
134 }
135
136 Or.SetCoord(Or.X() + dis2 * Dpl.X(),
137 Or.Y() + dis2 * Dpl.Y(),
138 Or.Z() + dis2 * Dpl.Z());
139
140 // variables used to compute the semiangle of the cone
141 gp_Dir Vec1(Or.X() - PtPl.X(), Or.Y() - PtPl.Y(), Or.Z() - PtPl.Z());
142 gp_Pnt Pt(Or.X() + dis1*PosPl.XDirection().X(),
143 Or.Y() + dis1*PosPl.XDirection().Y(),
144 Or.Z() + dis1*PosPl.XDirection().Z());
145 gp_Dir Vec2( Pt.X() - PtPl.X(), Pt.Y() - PtPl.Y(), Pt.Z() - PtPl.Z());
146
147 // compute the parameters of the conical surface
148 if (dedans) {
149 Rad = Cyl.Radius() - dis1;
150 if ( Abs(Rad) <= Precision::Confusion() ) pointu = Standard_True;
151 if(Rad < 0 ) {
63c629aa 152#ifdef CHFIKPART_DEB
81bba717 153 cout<<"the chamfer can't pass"<<endl;
63c629aa 154#endif
7fd59977 155 return Standard_False;
156 }
157 }
158 else {
159 Rad = Cyl.Radius() + dis1;
160 gp_Dir Dplr = Dpl.Reversed();
161 Dpl = Dplr;
162 }
163 ConRad = Cyl.Radius();
164 SemiAngl = Vec1.Angle(Vec2);
165 gp_Ax3 ConAx3(Or, Dpl, Dx);
166
167 Handle (Geom_ConicalSurface)
168 gcon = new Geom_ConicalSurface( ConAx3, SemiAngl, ConRad );
169
170 // changes due to the fact the parameters of the chamfer must go increasing
171 // from surface S1 to surface S2
172 if ( (dedans && !plandab) || (!dedans && plandab) ) {
173 gcon->VReverse();// be carefull : the SemiAngle was changed
174 ConAx3 = gcon->Position();
175 SemiAngl = gcon->SemiAngle();
176 }
177
178 // changes due to the fact we have reversed the V direction of
179 // parametrization
180 if (ConAx3.YDirection().Dot(DSp) <= 0.) {
181 ConAx3.YReverse();
182 gcon->SetPosition(ConAx3);
183 }
184
185 Data->ChangeSurf(ChFiKPart_IndexSurfaceInDS(gcon, DStr));
186
187 // compute the chamfer's orientation according to the orientation
188 // of the faces
189
190 //search the normal to the cone
191 gp_Vec deru, derv;
192 ElSLib::ConeD1(0., 0., ConAx3, ConRad, SemiAngl, Pt, deru, derv);
193
194 gp_Dir norCon(deru.Crossed(derv));
195
196 Standard_Boolean toreverse = ( norCon.Dot(norf) <= 0.);
197 if (toreverse) {
198 Data->ChangeOrientation() = TopAbs_REVERSED;
199 }
200 else {
201 Data->ChangeOrientation() = TopAbs_FORWARD;
202 }
203
204 //we load of the faceInterference with the pcurves and
205 // the 3d curves
206
207 // Case of the plane face
208 // NB: in the case 'pointu', no pcurve on the plane surface
209 // and no intersection plane-chamfer are needed
210 Handle(Geom2d_Circle) GCir2dPln;
211 Handle(Geom_Circle) GCirPln;
212 gp_Ax2 CirAx2 = ConAx3.Ax2();
213 CirAx2.SetLocation(PtPl);
214
215 if (!pointu) {
216 // intersection plane-chamfer
217 gp_Circ CirPln(CirAx2, Rad);
218 GCirPln = new Geom_Circle(CirPln);
219
220 //pcurve on the plane
221 ElSLib::PlaneParameters(PosPl, Pt, u, v);
222 gp_Pnt2d p2dPln(u, v);
223 gp_Dir2d d2d(DSp.Dot(PosPl.XDirection()), DSp.Dot(PosPl.YDirection()));
224 gp_Ax22d ax2dPln(pt2dPln, gp_Dir2d(gp_Vec2d(pt2dPln, p2dPln)), d2d);
225 gp_Circ2d cir2dPln(ax2dPln, Rad);
226 GCir2dPln = new Geom2d_Circle(cir2dPln);
227 }
228
229 //pcurve on the chamfer
230 gp_Pnt2d p2dch;
231 if (plandab)
232 v= -sqrt(dis1 * dis1 + dis2 * dis2);
233 else
234 v = sqrt(dis1 * dis1 + dis2 * dis2);
235 p2dch.SetCoord(0., v);
236 ElSLib::ConeD1(0., v, ConAx3, ConRad, SemiAngl, Pt, deru, derv);
237 gp_Lin2d lin2dch(p2dch, gp::DX2d());
238 Handle(Geom2d_Line) GLin2dCh1 = new Geom2d_Line(lin2dch);
239
240 //orientation
241 TopAbs_Orientation trans;
242 gp_Dir norpl = PosPl.XDirection().Crossed(PosPl.YDirection());
243 toreverse = ( norCon.Dot(norpl) <= 0. );
244 if ((toreverse && plandab) || (!toreverse && !plandab)){
245 trans = TopAbs_FORWARD;
246 }
247 else {
248 trans = TopAbs_REVERSED;
249 }
250
251
252 if(plandab){
253 Data->ChangeInterferenceOnS1().
254 SetInterference(ChFiKPart_IndexCurveInDS(GCirPln, DStr),
255 trans, GCir2dPln, GLin2dCh1);
256 }
257 else{
258 Data->ChangeInterferenceOnS2().
259 SetInterference(ChFiKPart_IndexCurveInDS(GCirPln, DStr),
260 trans,GCir2dPln, GLin2dCh1);
261 }
262
263 // Case of the cylindrical face
264
265 //intersection cylinder-chamfer
266 CirAx2.SetLocation(Or);
267 gp_Circ CirCyl(CirAx2, ConRad);
268 Handle(Geom_Circle) GCirCyl = new Geom_Circle(CirCyl);
269
270 //pcurve on the chamfer
271 p2dch.SetCoord(0., 0.);
272 ElSLib::ConeD1(0., 0., ConAx3, ConRad, SemiAngl, Pt, deru, derv);
273 lin2dch.SetLocation(p2dch);
274 Handle(Geom2d_Line) GLin2dCh2 = new Geom2d_Line(lin2dch);
275
276 //pcurve on the cylinder
277 norCon.SetXYZ (deru.Crossed(derv).XYZ());
278
279 Pt.SetCoord(Or.X() + ConRad * Dx.X(),
280 Or.Y() + ConRad * Dx.Y(),
281 Or.Z() + ConRad * Dx.Z());
282 ElSLib::Parameters(Cyl, Pt ,u, v);
283 Standard_Real tol = Precision::PConfusion();
284 Standard_Boolean careaboutsens = 0;
c6541a0c 285 if(Abs(lu - fu - 2 * M_PI) < tol) careaboutsens = 1;
7fd59977 286 if(u >= fu - tol && u < fu) u = fu;
287 if(u <= lu + tol && u > lu) u = lu;
c6541a0c 288 if(u < fu || u > lu) u = ChFiKPart_InPeriod(u, fu, fu + 2 * M_PI, tol);
7fd59977 289
290 ElSLib::D1(u, v, Cyl, Pt, deru, derv);
291 gp_Dir norcyl = deru.Crossed(derv);
292 gp_Dir2d d2dCyl = gp::DX2d();
293 if( deru.Dot(Dy) < 0. ){
294 d2dCyl.Reverse();
295 if(careaboutsens && Abs(fu - u)<tol) u = lu;
296 }
297 else if(careaboutsens && Abs(lu - u)<tol) u = fu;
298 gp_Pnt2d p2dCyl(u, v);
299 gp_Lin2d lin2dCyl(p2dCyl, d2dCyl);
300 Handle(Geom2d_Line) GLin2dCyl = new Geom2d_Line(lin2dCyl);
301
302 //orientation
303 toreverse = ( norCon.Dot(norcyl) <= 0. );
304 if ((toreverse && plandab) || (!toreverse && !plandab) ) {
305 trans = TopAbs_REVERSED;
306 }
307 else {
308 trans = TopAbs_FORWARD;
309 }
310
311 if(plandab){
312 Data->ChangeInterferenceOnS2().
313 SetInterference(ChFiKPart_IndexCurveInDS(GCirCyl, DStr),
314 trans, GLin2dCyl, GLin2dCh2);
315 }
316 else{
317 Data->ChangeInterferenceOnS1().
318 SetInterference(ChFiKPart_IndexCurveInDS(GCirCyl, DStr),
319 trans, GLin2dCyl, GLin2dCh2);
320 }
321
322 return Standard_True;
323}
324
325
326//=======================================================================
327//function : MakeChAsym
81bba717 328//purpose : case cylinder/plane or plane/cylinder.
7fd59977 329//=======================================================================
330
331Standard_Boolean ChFiKPart_MakeChAsym(TopOpeBRepDS_DataStructure& DStr,
332 const Handle(ChFiDS_SurfData)& Data,
333 const gp_Pln& Pln,
334 const gp_Cylinder& Cyl,
35e08fe8 335 const Standard_Real /*fu*/,
336 const Standard_Real /*lu*/,
7fd59977 337 const TopAbs_Orientation Or1,
338 const TopAbs_Orientation Or2,
339 const Standard_Real Dis,
340 const Standard_Real Angle,
341 const gp_Lin& Spine,
342 const Standard_Real First,
343 const TopAbs_Orientation Ofpl,
344 const Standard_Boolean plandab,
345 const Standard_Boolean DisOnP)
346{
81bba717 347 // calculation of the fillet plane.
348 // or1 and or2 permit to determine in which of four sides created by
349 // intersection of 2 surfaces we are
350 // _|_ Ofpl is orientation of the plane face allowing
351 // |4 to determine the side of the material
7fd59977 352
353 gp_Pnt OrSpine = ElCLib::Value(First, Spine);
354 gp_Pnt POnCyl, POnPln, OrCyl;
355
356 gp_Dir XDir = Spine.Direction();
357 gp_Ax3 AxPln = Pln.Position();
358 gp_Dir NorPln = AxPln.XDirection().Crossed(AxPln.YDirection());
359 gp_Dir NorF(NorPln);
360 if (Or1 == TopAbs_REVERSED)
361 {NorF.Reverse();}
362
363 gp_Ax3 AxCyl = Cyl.Position();
81bba717 364 // OrCyl is the point on axis of cylinder in the plane normal to the
365 // axis containing OrSpine
7fd59977 366 gp_Pnt Loc = AxCyl.Location();
367 gp_Vec LocSp(Loc, OrSpine);
368 gp_XYZ temp = AxCyl.Direction().XYZ();
369 temp = temp.Multiplied(LocSp.XYZ().Multiplied(temp) );
370 OrCyl.SetXYZ( (Loc.XYZ()).Added(temp) );
371
81bba717 372 //construction of POnPln
7fd59977 373 gp_Vec VecTranslPln,tmp;
374
375 tmp = gp_Vec(OrSpine,OrCyl);
376 if ((Or2 == TopAbs_FORWARD && Cyl.Direct()) ||
377 (Or2 == TopAbs_REVERSED && !Cyl.Direct()))
378 {tmp.Reverse();}
379
380 VecTranslPln = gp_Vec( XDir.Crossed(NorPln) );
381 if( VecTranslPln.Dot(tmp) <= 0. )
382 {VecTranslPln.Reverse();}
383
384 gp_Vec VecTranslCyl;
385 VecTranslCyl = gp_Vec(OrSpine,OrCyl);
386
81bba717 387 // Calculation of distances dis1 and dis2, depending on Dis and Angle
7fd59977 388 gp_Vec DirSOrC = VecTranslCyl.Normalized();
389 Standard_Real cosA1 = DirSOrC.Dot(VecTranslPln.Normalized());
390 Standard_Real sinA1 = Sqrt(1. - cosA1 * cosA1);
7fd59977 391 Standard_Real dis1 = 0.;
7fd59977 392 Standard_Real dis2, ray = Cyl.Radius();
393 Standard_Boolean IsDisOnP = ( (plandab && DisOnP) || (!plandab && !DisOnP) );
394
395 if (IsDisOnP) {
396 dis1 = Dis;
397 Standard_Real sinAl = Sin(Angle), cosAl = Cos(Angle);
398 Standard_Real h = dis1 * sinAl;
399 Standard_Real cosAhOC = cosA1 * sinAl + sinA1 * cosAl;
400 Standard_Real sinAhOC = sinA1 * sinAl - cosA1 * cosAl;
401 if (cosA1 > 0) sinAhOC = -sinAhOC;
402 Standard_Real temp1 = h / ray,
403 temp2 = sinAhOC * sinAhOC + temp1 * cosAhOC;
404
405 dis2 = temp2 + temp1 * (cosAhOC - temp1);
406
407 if (dis2 < -1.E-09) {
63c629aa 408#ifdef CHFIKPART_DEB
81bba717 409 cout<<"too great angle of chamfer"<<endl;
63c629aa 410#endif
7fd59977 411 return Standard_False;
412 }
413 else if (dis2 < 1.E-09) {
414 dis2 = ray * Sqrt(2. * temp2);
415 }
416 else {
417 dis2 = ray * Sqrt(2. * (temp2 - sinAhOC * Sqrt(dis2)) );
418 }
419 }
420 else {
421 dis2 = Dis;
422 }
423
81bba717 424 //construction of POnCyl
7fd59977 425 Standard_Real alpha = ( 2*ASin(dis2*0.5/ray) );
426 gp_Vec VecTemp = VecTranslCyl.Reversed();
427
428 if ( ( XDir.Crossed(gp_Dir(VecTranslCyl)) ).Dot(NorF) < 0.) {
429 VecTemp.Rotate(gp_Ax1(OrCyl,XDir),alpha);
430 }
431 else {
432 VecTemp.Rotate(gp_Ax1(OrCyl,XDir.Reversed()),alpha);}
433
434 POnCyl.SetXYZ( OrCyl.XYZ().Added(VecTemp.XYZ()) );
435 Standard_Real UOnCyl,VOnCyl,UOnPln,VOnPln;
436 gp_Vec DUOnCyl, DVOnCyl;
437 ElSLib::Parameters(Cyl,POnCyl,UOnCyl,VOnCyl);
438 ElSLib::CylinderD1(UOnCyl, VOnCyl, AxCyl, Cyl.Radius(),
439 POnCyl, DUOnCyl, DVOnCyl);
440
81bba717 441 // Construction of the point on the plane
7fd59977 442 if (!IsDisOnP) {
443 gp_Vec Corde(POnCyl, OrSpine);
444 gp_Vec TCyl = DUOnCyl.Crossed(DVOnCyl);
445
446 TCyl = XDir.Crossed(TCyl);
447 TCyl.Normalize();
448 Corde.Normalize();
449 Standard_Real cosCorTan = TCyl.Dot(Corde);
450 Standard_Real tgCorTan = 1. / (cosCorTan * cosCorTan);
451 tgCorTan = Sqrt(tgCorTan - 1.);
452
453 Standard_Real tgAng = tan(Angle);
454 tgAng = (tgAng + tgCorTan) / (1. - tgAng * tgCorTan);
455
456 Standard_Real cosA11 = dis2 / (2. * ray);
457 Standard_Real sinA11 = Sqrt(1. - cosA11 * cosA11);
458 if (cosA1 > 0) sinA11 = -sinA11;
459 dis1 = (sinA1 + cosA1 * tgAng) * cosA11;
460 dis1 -= (cosA1 - sinA1 * tgAng) * sinA11;
461 dis1 = (dis2 * tgAng) / dis1;
462 }
463
464 VecTranslPln.Multiply(dis1);
465
466 POnPln.SetXYZ( (OrSpine.XYZ()).Added(VecTranslPln.XYZ()) );
467
81bba717 468 //construction of the chamfer
7fd59977 469 ElSLib::Parameters(Pln,POnPln,UOnPln,VOnPln);
470 POnPln = ElSLib::PlaneValue(UOnPln,VOnPln,AxPln);
471
81bba717 472 //construction of YDir to go from face1 to face2.
7fd59977 473 gp_Vec YDir(POnPln,POnCyl);
474 if (!plandab){
475 YDir.Reverse();
476 }
477 gp_Ax3 AxCh(POnPln,XDir.Crossed(YDir),XDir);
478
479 Handle(Geom_Plane) Chamfer = new Geom_Plane(AxCh);
480 Data->ChangeSurf(ChFiKPart_IndexSurfaceInDS(Chamfer,DStr));
481
81bba717 482 // FaceInterferences are loaded with pcurves and curves 3d.
7fd59977 483 //----------- edge plan-Chamfer
484 gp_Pnt2d PPln2d(UOnPln,VOnPln);
485 gp_Dir2d VPln2d(XDir.Dot(AxPln.XDirection()),
486 XDir.Dot(AxPln.YDirection()));
487 gp_Lin2d Lin2dPln(PPln2d,VPln2d);
488
489 POnPln = ElSLib::Value(UOnPln,VOnPln,Pln);
490 gp_Lin C3d(POnPln,XDir);
491
492 Standard_Real U,VOnChamfer;
493 ElSLib::PlaneParameters(AxCh,POnPln,U,VOnChamfer);
494 gp_Lin2d LOnChamfer(gp_Pnt2d(U,VOnChamfer),gp::DX2d());
495
496 Handle(Geom_Line) L3d = new Geom_Line (C3d);
497 Handle(Geom2d_Line) LFac = new Geom2d_Line(Lin2dPln);
498 Handle(Geom2d_Line) LFil = new Geom2d_Line(LOnChamfer);
499
500 gp_Dir NorFil=AxCh.Direction();
501 Standard_Boolean toreverse = ( NorFil.Dot(NorPln) <= 0. );
502 gp_Dir DirPlnCyl(gp_Vec(POnPln, POnCyl));
503 gp_Dir DirSPln(gp_Vec(OrSpine, POnPln));
504 Standard_Boolean PosChamfPln = DirPlnCyl.Dot(DirSPln) > 0;
505
506 if ( !IsDisOnP && PosChamfPln )
507 toreverse = !toreverse;
81bba717 508 // It is checked if the orientation of the Chamfer is the same as of the plane
7fd59977 509 if (toreverse)
510 {Data->ChangeOrientation() = TopAbs::Reverse(Ofpl);}
511 else
512 {Data->ChangeOrientation() = Ofpl;}
513
514 TopAbs_Orientation trans = TopAbs_FORWARD;
515 if ((!plandab && toreverse) || (plandab && !toreverse))
516 {trans=TopAbs_REVERSED;}
517
81bba717 518 //trans allows to determine the "material" side on S1(2) limited by L3d
7fd59977 519 if (plandab)
520 {Data->ChangeInterferenceOnS1().
521 SetInterference(ChFiKPart_IndexCurveInDS(L3d,DStr),trans,LFac,LFil);}
522 else
523 {Data->ChangeInterferenceOnS2().
524 SetInterference(ChFiKPart_IndexCurveInDS(L3d,DStr),trans,LFac,LFil);}
525
526 //------------edge cylindre-Chamfer
527 gp_Pnt2d PCyl2d(UOnCyl,VOnCyl);
528 gp_Dir2d VCyl2d=gp::DY2d();
529 if ( XDir.Dot(AxCyl.Direction())<0 )
530 {VCyl2d.Reverse();}
531 gp_Lin2d Lin2dCyl(PCyl2d,VCyl2d);
532
533 POnCyl = ElSLib::Value(UOnCyl,VOnCyl,Cyl);
534 C3d = gp_Lin(POnCyl,XDir);
535
536 ElSLib::PlaneParameters(AxCh,POnCyl,U,VOnChamfer);
537 LOnChamfer = gp_Lin2d(gp_Pnt2d(U,VOnChamfer),gp::DX2d());
538
539 L3d = new Geom_Line (C3d);
540 LFac = new Geom2d_Line(Lin2dCyl);
541 LFil = new Geom2d_Line(LOnChamfer);
542
543 gp_Vec deru,derv;
544 ElSLib::CylinderD1(UOnCyl,VOnCyl,AxCyl,Cyl.Radius(),POnCyl,deru,derv);
545 gp_Dir NorCyl(deru.Crossed(derv));
546 gp_Dir DirSCyl(gp_Vec(OrSpine, POnCyl));
547 Standard_Boolean PosChamfCyl = DirPlnCyl.Dot(DirSCyl) < 0;
548 toreverse = ( NorFil.Dot(NorCyl) <= 0. );
549
550
551 if ( IsDisOnP && PosChamfCyl)
552 toreverse = !toreverse;
553 trans = TopAbs_REVERSED;
554 if ((!plandab && toreverse) || (plandab && !toreverse))
555 {trans=TopAbs_FORWARD;}
556
557 if (plandab)
558 Data->ChangeInterferenceOnS2().
559 SetInterference(ChFiKPart_IndexCurveInDS(L3d,DStr),trans,LFac,LFil);
560 else
561 Data->ChangeInterferenceOnS1().
562 SetInterference(ChFiKPart_IndexCurveInDS(L3d,DStr),trans,LFac,LFil);
563 return Standard_True;
564}
565
566
567
568
569
570
571