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