Test for 0022778: Bug in BRepMesh
[occt.git] / src / IntPatch / IntPatch_ImpImpIntersection_3.gxx
1 // Created on: 1992-05-07
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 //modified by NIZNHY-PKV Thu Sep 15 11:09:12 2011
23 static 
24   void SeamPosition(const gp_Pnt& aPLoc, 
25                     const gp_Ax3& aPos,
26                     gp_Ax2& aSeamPos);
27 static
28   void AdjustToSeam (const gp_Cylinder& aQuad,
29                      gp_Circ& aCirc);
30 static
31   void AdjustToSeam (const gp_Sphere& aQuad,
32                      gp_Circ& aCirc,
33                      const Standard_Real aTolAng);
34 static
35   void AdjustToSeam (const gp_Cone& aQuad,
36                      gp_Circ& aCirc);
37 //modified by NIZNHY-PKV Thu Sep 15 11:09:13 2011
38
39 //=======================================================================
40 //function : IntPP
41 //purpose  : 
42 // Traitement du cas Plan/Plan
43 //=======================================================================
44 Standard_Boolean IntPP (const IntSurf_Quadric& Quad1,
45                         const IntSurf_Quadric& Quad2,
46                         const Standard_Real Tolang,
47                         const Standard_Real TolTang,
48                         Standard_Boolean& Same,
49                         IntPatch_SequenceOfLine& slin)
50
51 {
52   IntSurf_TypeTrans trans1,trans2;
53   IntAna_ResultType typint;
54   gp_Pln pl1(Quad1.Plane());
55   gp_Pln pl2(Quad2.Plane());
56   
57   IntAna_QuadQuadGeo inter(pl1,pl2,Tolang,TolTang);
58   if (!inter.IsDone()) {return Standard_False;}
59   Same = Standard_False;
60   typint = inter.TypeInter();
61   if (typint == IntAna_Same) { // cas faces confondues
62     Same = Standard_True;
63   }
64   else if (typint != IntAna_Empty) { // on a une ligne
65     gp_Lin linsol = inter.Line(1);
66     Standard_Real discri = linsol.Direction().DotCross
67       (Quad2.Normale(linsol.Location()),
68        Quad1.Normale(linsol.Location()));
69     
70     if (discri>0.0) {
71       trans1 = IntSurf_Out;
72       trans2 = IntSurf_In;
73     }
74     else {
75       trans1 = IntSurf_In;
76       trans2 = IntSurf_Out;
77     }
78     Handle(IntPatch_GLine) glig = 
79       new IntPatch_GLine (linsol,Standard_False,trans1,trans2);
80     slin.Append(glig);
81   }
82   return Standard_True;
83 }
84 //=======================================================================
85 //function : IntPCy
86 //purpose  : 
87 // Traitement du cas Plan/Cylindre et reciproquement
88 //=======================================================================
89 Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
90                          const IntSurf_Quadric& Quad2,
91                          const Standard_Real Tolang,
92                          const Standard_Real TolTang,
93                          const Standard_Boolean Reversed,
94                          Standard_Boolean& Empty,
95                          IntPatch_SequenceOfLine& slin)
96
97 {
98   gp_Pln Pl;
99   gp_Cylinder Cy;
100
101   IntSurf_TypeTrans trans1,trans2;
102   IntAna_ResultType typint;
103
104   IntAna_QuadQuadGeo inter;
105   if (!Reversed) {
106     Pl = Quad1.Plane();
107     Cy = Quad2.Cylinder();
108   }
109   else {
110     Pl = Quad2.Plane();
111     Cy = Quad1.Cylinder();
112   }
113   inter.Perform(Pl,Cy,Tolang,TolTang);
114   if (!inter.IsDone()) {return Standard_False;}
115   typint = inter.TypeInter();
116   Standard_Integer NbSol = inter.NbSolutions();
117   Empty = Standard_False;
118
119   switch (typint) {
120             
121     case IntAna_Empty :    {
122       Empty = Standard_True;
123     }
124       break;
125
126     case IntAna_Line:    {
127       gp_Lin linsol = inter.Line(1);
128       gp_Pnt orig(linsol.Location());
129       if (NbSol == 1) {                 // ligne de tangence
130         gp_Vec TestCurvature(orig,Cy.Location());
131         gp_Vec Normp,Normcyl;
132         if (!Reversed) {
133           Normp = Quad1.Normale(orig);
134           Normcyl = Quad2.Normale(orig);
135         }
136         else {
137           Normp = Quad2.Normale(orig);
138           Normcyl = Quad1.Normale(orig);
139         }
140         
141         IntSurf_Situation situcyl;
142         IntSurf_Situation situp;
143
144         if (Normp.Dot(TestCurvature) > 0.) {
145           situcyl = IntSurf_Outside;
146           if (Normp.Dot(Normcyl) > 0.) {
147             situp = IntSurf_Inside;
148           }
149           else {
150             situp = IntSurf_Outside;
151           }
152         }
153         else {
154           situcyl = IntSurf_Inside;
155           if (Normp.Dot(Normcyl) > 0.) {
156             situp = IntSurf_Outside;
157           }
158           else {
159             situp = IntSurf_Inside;
160           }
161         }
162         Handle(IntPatch_GLine) glig;
163         if (!Reversed) {
164           glig = new IntPatch_GLine(linsol, Standard_True, situp, situcyl);
165         }
166         else {
167           glig = new IntPatch_GLine(linsol, Standard_True, situcyl, situp);
168         }
169         slin.Append(glig);
170       }
171       else {      
172         // on a 2 droites. Il faut determiner les transitions
173         // de chacune.
174         
175         if (linsol.Direction().DotCross(Quad2.Normale(orig),
176                                         Quad1.Normale(orig)) >0.) {
177           trans1 = IntSurf_Out;
178           trans2 = IntSurf_In;
179         }
180         else {
181           trans1 = IntSurf_In;
182           trans2 = IntSurf_Out;
183         }
184         Handle(IntPatch_GLine) glig = 
185           new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
186         slin.Append(glig);
187         
188         linsol = inter.Line(2);
189         orig = linsol.Location();
190
191         if (linsol.Direction().DotCross(Quad2.Normale(orig),
192                                         Quad1.Normale(orig)) >0.) {
193           trans1 = IntSurf_Out;
194           trans2 = IntSurf_In;
195         }
196         else {
197           trans1 = IntSurf_In;
198           trans2 = IntSurf_Out;
199         }
200         glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
201         slin.Append(glig);
202       }
203     }
204       break;
205       //
206     case IntAna_Circle:    {
207       gp_Circ cirsol;
208       gp_Pnt ptref;
209       gp_Vec Tgt;
210       //
211       cirsol = inter.Circle(1);
212       //modified by NIZNHY-PKV Thu Sep 15 11:30:03 2011f
213       AdjustToSeam(Cy, cirsol);
214       //modified by NIZNHY-PKV Thu Sep 15 11:30:15 2011t
215       ElCLib::D1(0.,cirsol,ptref,Tgt);
216       
217       if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) > 0.0) {
218         trans1 = IntSurf_Out;
219         trans2 = IntSurf_In;
220       }
221       else {
222         trans1 = IntSurf_In;
223         trans2 = IntSurf_Out;
224       }
225       Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
226       slin.Append(glig);
227     }
228       break;
229       // 
230     case IntAna_Ellipse:    {
231       gp_Elips elipsol = inter.Ellipse(1);
232       gp_Pnt ptref;
233       gp_Vec Tgt;
234       ElCLib::D1(0.,elipsol,ptref,Tgt);
235       
236       if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) > 0.0) {
237         trans1 = IntSurf_Out;
238         trans2 = IntSurf_In;
239       }
240       else {
241         trans1 = IntSurf_In;
242         trans2 = IntSurf_Out;
243       }
244       Handle(IntPatch_GLine) glig = new IntPatch_GLine(elipsol,Standard_False,trans1,trans2);
245       slin.Append(glig);
246     }
247       break;
248       //
249     default:    {
250       return Standard_False; // on ne doit pas passer ici
251     }
252   }
253   return Standard_True;
254 }
255 //=======================================================================
256 //function : IntPSp
257 //purpose  : 
258 // Traitement du cas Plan/Sphere et reciproquement
259 //=======================================================================
260 Standard_Boolean IntPSp (const IntSurf_Quadric& Quad1,
261                          const IntSurf_Quadric& Quad2,
262                          //modified by NIZNHY-PKV Tue Sep 20 08:59:36 2011f
263                          const Standard_Real Tolang,
264                          //modified by NIZNHY-PKV Tue Sep 20 08:59:39 2011t
265                          const Standard_Real TolTang,
266                          const Standard_Boolean Reversed,
267                          Standard_Boolean& Empty,
268                          IntPatch_SequenceOfLine& slin,
269                          IntPatch_SequenceOfPoint& spnt)
270
271
272 {
273   gp_Circ cirsol;
274   gp_Pln Pl;
275   gp_Sphere Sp;
276   IntSurf_TypeTrans trans1,trans2;
277   IntAna_ResultType typint;
278
279   IntAna_QuadQuadGeo inter;
280   if (!Reversed) {
281     Pl = Quad1.Plane();
282     Sp = Quad2.Sphere();
283   }
284   else {
285     Pl = Quad2.Plane();
286     Sp = Quad1.Sphere();
287   }
288   inter.Perform(Pl,Sp);
289
290   if (!inter.IsDone()) {return Standard_False;}
291
292   typint = inter.TypeInter();
293   Empty = Standard_False;
294
295   switch (typint) {
296     case IntAna_Empty :    {
297       Empty = Standard_True;
298     }
299       break;
300       //
301     case IntAna_Point:    {
302       gp_Pnt psol = inter.Point(1);
303       Standard_Real U1,V1,U2,V2;
304       Quad1.Parameters(psol,U1,V1);
305       Quad2.Parameters(psol,U2,V2);
306       IntPatch_Point ptsol;
307       ptsol.SetValue(psol,TolTang,Standard_True);
308       ptsol.SetParameters(U1,V1,U2,V2);
309       spnt.Append(ptsol);
310     }
311       break;
312       //
313     case IntAna_Circle:    {
314       cirsol = inter.Circle(1);
315       //modified by NIZNHY-PKV Thu Sep 15 11:30:03 2011f
316       AdjustToSeam(Sp, cirsol, Tolang);
317       //modified by NIZNHY-PKV Thu Sep 15 11:30:15 2011t
318       gp_Pnt ptref;
319       gp_Vec Tgt;
320       ElCLib::D1(0.,cirsol,ptref,Tgt);
321
322       if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
323         trans1 = IntSurf_Out;
324         trans2 = IntSurf_In;
325       }
326       else {
327         trans1 = IntSurf_In;
328         trans2 = IntSurf_Out;
329       }
330       Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
331       slin.Append(glig);
332     }
333       break;
334       
335     default:    {
336       return Standard_False;  // on ne doit pas passer ici
337     }
338   }
339   return Standard_True;
340 }
341 //=======================================================================
342 //function : IntPCo
343 //purpose  : 
344 // Traitement du cas Plan/Cone et reciproquement
345 //=======================================================================
346 Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
347                          const IntSurf_Quadric& Quad2,
348                          const Standard_Real Tolang,
349                          const Standard_Real TolTang,
350                          const Standard_Boolean Reversed,
351                          Standard_Boolean& Empty,
352                          Standard_Boolean& Multpoint,
353                          IntPatch_SequenceOfLine& slin,
354                          IntPatch_SequenceOfPoint& spnt)
355
356
357 {
358   gp_Pnt apex;
359
360   gp_Pln Pl;
361   gp_Cone Co;
362
363   IntSurf_TypeTrans trans1,trans2;
364   IntAna_ResultType typint;
365
366   IntAna_QuadQuadGeo inter;
367   if (!Reversed) {
368     Pl = Quad1.Plane();
369     Co = Quad2.Cone();
370     apex = Co.Apex();
371   }
372   else {
373     Pl = Quad2.Plane();
374     Co = Quad1.Cone();
375     apex = Co.Apex();
376   }
377
378   inter.Perform(Pl,Co,Tolang,TolTang);
379   if (!inter.IsDone()) {
380     return Standard_False;
381   }
382   //
383   typint = inter.TypeInter();
384   Standard_Integer NbSol = inter.NbSolutions();
385   Empty = Standard_False;
386
387   switch (typint) {
388     case IntAna_Point:    {
389       gp_Pnt psol = inter.Point(1);
390       Standard_Real U1,V1,U2,V2;
391       Quad1.Parameters(psol,U1,V1);
392       Quad2.Parameters(psol,U2,V2);
393       IntPatch_Point ptsol;
394       ptsol.SetValue(psol,TolTang,Standard_False);
395       ptsol.SetParameters(U1,V1,U2,V2);
396       spnt.Append(ptsol);
397     }
398       break;
399       
400     case IntAna_Line:    {
401       gp_Lin linsol = inter.Line(1);
402       if (linsol.Direction().Dot(Co.Axis().Direction()) <0.) {
403         linsol.SetDirection(linsol.Direction().Reversed());
404       }
405       Standard_Real para = ElCLib::Parameter(linsol, apex);
406       gp_Pnt ptbid (ElCLib::Value(para+5.,linsol));
407       Standard_Real U1,V1,U2,V2;
408       Quad1.Parameters(apex,U1,V1);
409       Quad2.Parameters(apex,U2,V2);
410       
411       if (NbSol == 1) {                 // ligne de tangence
412         IntPatch_Point ptsol;
413         ptsol.SetValue(apex,TolTang,Standard_False);
414         ptsol.SetParameters(U1,V1,U2,V2);
415         ptsol.SetParameter(para);
416         gp_Pnt ptbid2(apex.XYZ() + 5.*Co.Axis().Direction().XYZ());
417         gp_Vec TestCurvature(ptbid,ptbid2);
418         gp_Vec Normp,Normco;
419         if (!Reversed) {
420           Normp = Quad1.Normale(ptbid);
421           Normco = Quad2.Normale(ptbid);
422         }
423         else {
424           Normp = Quad2.Normale(ptbid);
425           Normco = Quad1.Normale(ptbid);
426         }
427         IntSurf_Situation situco,situco_otherside;
428         IntSurf_Situation situp,situp_otherside;
429         
430         if (Normp.Dot(TestCurvature) > 0.) {
431           situco           = IntSurf_Outside;
432           situco_otherside = IntSurf_Inside;
433           if (Normp.Dot(Normco) > 0.) {
434             situp           = IntSurf_Inside;
435             situp_otherside = IntSurf_Outside;
436           }
437           else {
438             situp           = IntSurf_Outside;
439             situp_otherside = IntSurf_Inside;
440           }
441         }
442         else {
443           situco           = IntSurf_Inside;
444           situco_otherside = IntSurf_Outside;
445           if (Normp.Dot(Normco) > 0.) {
446             situp           = IntSurf_Outside;
447             situp_otherside = IntSurf_Inside;
448           }
449           else {
450             situp           = IntSurf_Inside;
451             situp_otherside = IntSurf_Outside;
452           }
453         }
454         //----------------------------------------------------------
455         //--              Apex ---> Cone.Direction
456         //--
457         Handle(IntPatch_GLine) glig;
458         if (!Reversed) {
459           glig = new IntPatch_GLine(linsol, Standard_True, situp, situco);
460         }
461         else {
462           glig = new IntPatch_GLine(linsol, Standard_True, situco, situp);
463         }
464         glig->AddVertex(ptsol);
465         glig->SetFirstPoint(1);
466         slin.Append(glig);
467         //----------------------------------------------------------
468         //--   -Cone.Direction <------- Apex
469         //--
470         linsol.SetDirection(linsol.Direction().Reversed());
471         if (!Reversed) {
472           glig = new IntPatch_GLine(linsol, Standard_True, situp_otherside, situco_otherside);
473         }
474         else {
475           glig = new IntPatch_GLine(linsol, Standard_True, situco_otherside, situp_otherside);
476         }
477         glig->AddVertex(ptsol);
478         glig->SetFirstPoint(1);
479         slin.Append(glig);
480       }
481       else {      
482         // on a 2 droites. Il faut determiner les transitions
483         // de chacune. On oriente chaque ligne dans le sens
484         // de l axe du cone. Les transitions de chaque ligne seront
485         // inverses l une de l autre => on ne fait le calcul que sur
486         // la premiere.
487         if (linsol.Direction().DotCross
488             (Quad2.Normale(ptbid),Quad1.Normale(ptbid)) >0.) {
489           trans1 = IntSurf_Out;
490           trans2 = IntSurf_In;
491         }
492         else {
493           trans1 = IntSurf_In;
494           trans2 = IntSurf_Out;
495         }
496
497         Multpoint = Standard_True;
498         //------------------------------------------- Ligne 1 -------
499         IntPatch_Point ptsol;
500         ptsol.SetValue(apex,TolTang,Standard_False);
501         ptsol.SetParameters(U1,V1,U2,V2);
502         ptsol.SetParameter(para);
503         ptsol.SetMultiple(Standard_True);
504         Handle(IntPatch_GLine) glig;
505         glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
506         glig->AddVertex(ptsol);
507         glig->SetFirstPoint(1);
508         slin.Append(glig);
509         //-----------------------------------------------------------
510         //-- Other Side : Les transitions restent les memes
511         //--    linsol -> -linsol   et Quad1(2).N -> -Quad1(2).N
512         //-- 
513         linsol.SetDirection(linsol.Direction().Reversed());
514         glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
515         para = ElCLib::Parameter(linsol, apex);
516         ptsol.SetParameter(para);
517         glig->AddVertex(ptsol);
518         glig->SetFirstPoint(1);
519         slin.Append(glig);
520         
521         //------------------------------------------- Ligne 2 -------
522         linsol = inter.Line(2);
523         if (linsol.Direction().Dot(Co.Axis().Direction()) <0.) {
524           linsol.SetDirection(linsol.Direction().Reversed());
525         }
526         para = ElCLib::Parameter(linsol, apex);
527         ptbid  = ElCLib::Value(para+5.,linsol);
528         if (linsol.Direction().DotCross
529             (Quad2.Normale(ptbid),Quad1.Normale(ptbid)) >0.) {
530           trans1 = IntSurf_Out;
531           trans2 = IntSurf_In;
532         }
533         else {
534           trans1 = IntSurf_In;
535           trans2 = IntSurf_Out;
536         }
537         ptsol.SetParameter(para);
538         glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
539         para = ElCLib::Parameter(linsol, apex);
540         ptsol.SetParameter(para);
541         glig->AddVertex(ptsol);
542         glig->SetFirstPoint(1);
543         slin.Append(glig);
544         //-----------------------------------------------------------
545         //-- Other Side : Les transitions restent les memes
546         //--    linsol -> -linsol   et Quad1(2).N -> -Quad1(2).N
547         //-- 
548         linsol.SetDirection(linsol.Direction().Reversed());
549         glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
550         para = ElCLib::Parameter(linsol, apex);
551         ptsol.SetParameter(para);
552         glig->AddVertex(ptsol);
553         glig->SetFirstPoint(1);
554         slin.Append(glig);
555       }
556     }
557     break;
558       
559     case IntAna_Circle:    {
560       gp_Circ cirsol = inter.Circle(1);
561       //modified by NIZNHY-PKV Thu Sep 15 11:34:04 2011f
562       AdjustToSeam(Co, cirsol);
563       //modified by NIZNHY-PKV Thu Sep 15 11:36:08 2011t
564       gp_Pnt ptref;
565       gp_Vec Tgt;
566       ElCLib::D1(0.,cirsol,ptref,Tgt);
567       
568       if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
569         trans1 = IntSurf_Out;
570         trans2 = IntSurf_In;
571       }
572       else {
573         trans1 = IntSurf_In;
574         trans2 = IntSurf_Out;
575       }
576       Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
577       slin.Append(glig);
578     }
579       break;
580       
581     case IntAna_Ellipse:    {
582       gp_Elips  elipsol = inter.Ellipse(1);
583       gp_Pnt ptref;
584       gp_Vec Tgt;
585       ElCLib::D1(0.,elipsol,ptref,Tgt);
586       
587       if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
588         trans1 = IntSurf_Out;
589         trans2 = IntSurf_In;
590       }
591       else {
592         trans1 = IntSurf_In;
593         trans2 = IntSurf_Out;
594       }
595       Handle(IntPatch_GLine) glig = new IntPatch_GLine(elipsol,Standard_False,trans1,trans2);
596       slin.Append(glig);
597     }
598       break;
599       
600     case IntAna_Parabola:    {
601       gp_Parab parabsol = inter.Parabola(1);
602       
603       gp_Vec Tgtorig(parabsol.YAxis().Direction());
604       Standard_Real ptran = Tgtorig.DotCross(Quad2.Normale(parabsol.Location()),
605                                              Quad1.Normale(parabsol.Location()));
606       if (ptran >0.00000001) {
607         trans1 = IntSurf_Out;
608         trans2 = IntSurf_In;
609       }
610       else if (ptran <-0.00000001) {
611         trans1 = IntSurf_In;
612         trans2 = IntSurf_Out;
613       }
614       else { 
615         trans1=trans2=IntSurf_Undecided; 
616       }
617       Handle(IntPatch_GLine) glig = new IntPatch_GLine(parabsol,Standard_False,trans1,trans2);
618       slin.Append(glig);
619     }
620       break;
621       
622     case IntAna_Hyperbola:    {
623       gp_Pnt tophypr;
624       gp_Vec Tgttop;
625       
626       for(Standard_Integer i=1; i<=2; i++) { 
627         gp_Hypr hyprsol = inter.Hyperbola(i);
628         tophypr = ElCLib::Value(hyprsol.MajorRadius(), 
629                                 hyprsol.XAxis());
630         Tgttop = hyprsol.YAxis().Direction();
631         Standard_Real qwe = Tgttop.DotCross(Quad2.Normale(tophypr),
632                                             Quad1.Normale(tophypr));
633         
634         if (qwe>0.00000001) { 
635           trans1 = IntSurf_Out;
636           trans2 = IntSurf_In;
637         }
638         else if (qwe<-0.00000001){
639           trans1 = IntSurf_In;
640           trans2 = IntSurf_Out;
641         }
642         else { 
643           trans1=trans2=IntSurf_Undecided;
644         }
645         Handle(IntPatch_GLine) glig = new IntPatch_GLine(hyprsol,Standard_False,trans1,trans2);
646         slin.Append(glig);
647       }
648     }
649       break;
650       
651     default:    {
652       return Standard_False;
653     }
654   }
655   return Standard_True;
656 }
657 //
658 //modified by NIZNHY-PKV Thu Sep 15 10:53:39 2011f
659 //=======================================================================
660 //function : AdjustToSeam
661 //purpose  : 
662 //=======================================================================
663 void AdjustToSeam (const gp_Cone& aQuad,
664                    gp_Circ& aCirc)
665 {
666    gp_Ax2 aAx2;
667    //
668    const gp_Pnt& aPLoc=aCirc.Location();
669    const gp_Ax3& aAx3=aQuad.Position();
670    SeamPosition(aPLoc, aAx3, aAx2);
671    aCirc.SetPosition(aAx2);
672
673 //=======================================================================
674 //function : AdjustToSeam
675 //purpose  : 
676 //=======================================================================
677 void AdjustToSeam (const gp_Sphere& aQuad,
678                    gp_Circ& aCirc,
679                    const Standard_Real aTolAng)
680 {
681    gp_Ax2 aAx2;
682    //
683    const gp_Ax1& aAx1C=aCirc.Axis();
684    const gp_Ax3& aAx3=aQuad.Position();
685    const gp_Ax1& aAx1Q=aAx3.Axis();
686    //
687    const gp_Dir& aDirC=aAx1C.Direction();
688    const gp_Dir& aDirQ=aAx1Q.Direction();
689    if (aDirC.IsParallel(aDirQ, aTolAng)) {
690      const gp_Pnt& aPLoc=aCirc.Location();
691      SeamPosition(aPLoc, aAx3, aAx2);
692      aCirc.SetPosition(aAx2);
693    }
694
695 //=======================================================================
696 //function : AdjustToSeam
697 //purpose  : 
698 //=======================================================================
699 void AdjustToSeam (const gp_Cylinder& aQuad,
700                    gp_Circ& aCirc)
701 {
702    gp_Ax2 aAx2;
703    //
704    const gp_Pnt& aPLoc=aCirc.Location();
705    const gp_Ax3& aAx3=aQuad.Position();
706    SeamPosition(aPLoc, aAx3, aAx2);
707    aCirc.SetPosition(aAx2);
708
709 //=======================================================================
710 //function : SeamPosition
711 //purpose  : 
712 //=======================================================================
713 void SeamPosition(const gp_Pnt& aPLoc, 
714                   const gp_Ax3& aPos, 
715                   gp_Ax2& aSeamPos)
716 {
717   const gp_Dir& aDZ=aPos.Direction();
718   const gp_Dir& aDX=aPos.XDirection();
719   gp_Ax2 aAx2(aPLoc, aDZ, aDX);
720   aSeamPos=aAx2;
721 }
722                             
723 //modified by NIZNHY-PKV Thu Sep 15 10:53:41 2011t