summaryrefslogtreecommitdiff
path: root/inc/IntPatch_ImpImpIntersection_3.gxx
blob: c9e9eb7cbee71e52dfacea041a47b9f0d8e1c941 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
// File:      IntPatch_ImpImpIntersection_3.gxx
// Created:   Thu May  7 08:47:45 1992
// Author:    Jacques GOUSSARD
// Copyright: OPEN CASCADE 1992

//modified by NIZNHY-PKV Thu Sep 15 11:09:12 2011
static 
  void SeamPosition(const gp_Pnt& aPLoc, 
		    const gp_Ax3& aPos,
		    gp_Ax2& aSeamPos);
static
  void AdjustToSeam (const gp_Cylinder& aQuad,
		     gp_Circ& aCirc);
static
  void AdjustToSeam (const gp_Sphere& aQuad,
		     gp_Circ& aCirc,
		     const Standard_Real aTolAng);
static
  void AdjustToSeam (const gp_Cone& aQuad,
		     gp_Circ& aCirc);
//modified by NIZNHY-PKV Thu Sep 15 11:09:13 2011

//=======================================================================
//function : IntPP
//purpose  : 
// Traitement du cas Plan/Plan
//=======================================================================
Standard_Boolean IntPP (const IntSurf_Quadric& Quad1,
			const IntSurf_Quadric& Quad2,
			const Standard_Real Tolang,
			const Standard_Real TolTang,
			Standard_Boolean& Same,
			IntPatch_SequenceOfLine& slin)

{
  IntSurf_TypeTrans trans1,trans2;
  IntAna_ResultType typint;
  gp_Pln pl1(Quad1.Plane());
  gp_Pln pl2(Quad2.Plane());
  
  IntAna_QuadQuadGeo inter(pl1,pl2,Tolang,TolTang);
  if (!inter.IsDone()) {return Standard_False;}
  Same = Standard_False;
  typint = inter.TypeInter();
  if (typint == IntAna_Same) { // cas faces confondues
    Same = Standard_True;
  }
  else if (typint != IntAna_Empty) { // on a une ligne
    gp_Lin linsol = inter.Line(1);
    Standard_Real discri = linsol.Direction().DotCross
      (Quad2.Normale(linsol.Location()),
       Quad1.Normale(linsol.Location()));
    
    if (discri>0.0) {
      trans1 = IntSurf_Out;
      trans2 = IntSurf_In;
    }
    else {
      trans1 = IntSurf_In;
      trans2 = IntSurf_Out;
    }
    Handle(IntPatch_GLine) glig = 
      new IntPatch_GLine (linsol,Standard_False,trans1,trans2);
    slin.Append(glig);
  }
  return Standard_True;
}
//=======================================================================
//function : IntPCy
//purpose  : 
// Traitement du cas Plan/Cylindre et reciproquement
//=======================================================================
Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
			 const IntSurf_Quadric& Quad2,
			 const Standard_Real Tolang,
			 const Standard_Real TolTang,
			 const Standard_Boolean Reversed,
			 Standard_Boolean& Empty,
			 IntPatch_SequenceOfLine& slin)

{
  gp_Pln Pl;
  gp_Cylinder Cy;

  IntSurf_TypeTrans trans1,trans2;
  IntAna_ResultType typint;

  IntAna_QuadQuadGeo inter;
  if (!Reversed) {
    Pl = Quad1.Plane();
    Cy = Quad2.Cylinder();
  }
  else {
    Pl = Quad2.Plane();
    Cy = Quad1.Cylinder();
  }
  inter.Perform(Pl,Cy,Tolang,TolTang);
  if (!inter.IsDone()) {return Standard_False;}
  typint = inter.TypeInter();
  Standard_Integer NbSol = inter.NbSolutions();
  Empty = Standard_False;

  switch (typint) {
	    
    case IntAna_Empty :    {
      Empty = Standard_True;
    }
      break;

    case IntAna_Line:    {
      gp_Lin linsol = inter.Line(1);
      gp_Pnt orig(linsol.Location());
      if (NbSol == 1) {                 // ligne de tangence
	gp_Vec TestCurvature(orig,Cy.Location());
	gp_Vec Normp,Normcyl;
	if (!Reversed) {
	  Normp = Quad1.Normale(orig);
	  Normcyl = Quad2.Normale(orig);
	}
	else {
	  Normp = Quad2.Normale(orig);
	  Normcyl = Quad1.Normale(orig);
	}
	
	IntSurf_Situation situcyl;
	IntSurf_Situation situp;

	if (Normp.Dot(TestCurvature) > 0.) {
	  situcyl = IntSurf_Outside;
	  if (Normp.Dot(Normcyl) > 0.) {
	    situp = IntSurf_Inside;
	  }
	  else {
	    situp = IntSurf_Outside;
	  }
	}
	else {
	  situcyl = IntSurf_Inside;
	  if (Normp.Dot(Normcyl) > 0.) {
	    situp = IntSurf_Outside;
	  }
	  else {
	    situp = IntSurf_Inside;
	  }
	}
	Handle(IntPatch_GLine) glig;
	if (!Reversed) {
	  glig = new IntPatch_GLine(linsol, Standard_True, situp, situcyl);
	}
	else {
	  glig = new IntPatch_GLine(linsol, Standard_True, situcyl, situp);
	}
	slin.Append(glig);
      }
      else {      
	// on a 2 droites. Il faut determiner les transitions
	// de chacune.
	
	if (linsol.Direction().DotCross(Quad2.Normale(orig),
					Quad1.Normale(orig)) >0.) {
	  trans1 = IntSurf_Out;
	  trans2 = IntSurf_In;
	}
	else {
	  trans1 = IntSurf_In;
	  trans2 = IntSurf_Out;
	}
	Handle(IntPatch_GLine) glig = 
	  new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
	slin.Append(glig);
	
	linsol = inter.Line(2);
	orig = linsol.Location();

	if (linsol.Direction().DotCross(Quad2.Normale(orig),
					Quad1.Normale(orig)) >0.) {
	  trans1 = IntSurf_Out;
	  trans2 = IntSurf_In;
	}
	else {
	  trans1 = IntSurf_In;
	  trans2 = IntSurf_Out;
	}
	glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
	slin.Append(glig);
      }
    }
      break;
      //
    case IntAna_Circle:    {
      gp_Circ cirsol;
      gp_Pnt ptref;
      gp_Vec Tgt;
      //
      cirsol = inter.Circle(1);
      //modified by NIZNHY-PKV Thu Sep 15 11:30:03 2011f
      AdjustToSeam(Cy, cirsol);
      //modified by NIZNHY-PKV Thu Sep 15 11:30:15 2011t
      ElCLib::D1(0.,cirsol,ptref,Tgt);
      
      if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) > 0.0) {
	trans1 = IntSurf_Out;
	trans2 = IntSurf_In;
      }
      else {
	trans1 = IntSurf_In;
	trans2 = IntSurf_Out;
      }
      Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
      slin.Append(glig);
    }
      break;
      // 
    case IntAna_Ellipse:    {
      gp_Elips elipsol = inter.Ellipse(1);
      gp_Pnt ptref;
      gp_Vec Tgt;
      ElCLib::D1(0.,elipsol,ptref,Tgt);
      
      if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) > 0.0) {
	trans1 = IntSurf_Out;
	trans2 = IntSurf_In;
      }
      else {
	trans1 = IntSurf_In;
	trans2 = IntSurf_Out;
      }
      Handle(IntPatch_GLine) glig = new IntPatch_GLine(elipsol,Standard_False,trans1,trans2);
      slin.Append(glig);
    }
      break;
      //
    default:    {
      return Standard_False; // on ne doit pas passer ici
    }
  }
  return Standard_True;
}
//=======================================================================
//function : IntPSp
//purpose  : 
// Traitement du cas Plan/Sphere et reciproquement
//=======================================================================
Standard_Boolean IntPSp (const IntSurf_Quadric& Quad1,
			 const IntSurf_Quadric& Quad2,
			 //modified by NIZNHY-PKV Tue Sep 20 08:59:36 2011f
			 const Standard_Real Tolang,
			 //modified by NIZNHY-PKV Tue Sep 20 08:59:39 2011t
			 const Standard_Real TolTang,
			 const Standard_Boolean Reversed,
			 Standard_Boolean& Empty,
			 IntPatch_SequenceOfLine& slin,
			 IntPatch_SequenceOfPoint& spnt)


{
  gp_Circ cirsol;
  gp_Pln Pl;
  gp_Sphere Sp;
  IntSurf_TypeTrans trans1,trans2;
  IntAna_ResultType typint;

  IntAna_QuadQuadGeo inter;
  if (!Reversed) {
    Pl = Quad1.Plane();
    Sp = Quad2.Sphere();
  }
  else {
    Pl = Quad2.Plane();
    Sp = Quad1.Sphere();
  }
  inter.Perform(Pl,Sp);

  if (!inter.IsDone()) {return Standard_False;}

  typint = inter.TypeInter();
  Empty = Standard_False;

  switch (typint) {
    case IntAna_Empty :    {
      Empty = Standard_True;
    }
      break;
      //
    case IntAna_Point:    {
      gp_Pnt psol = inter.Point(1);
      Standard_Real U1,V1,U2,V2;
      Quad1.Parameters(psol,U1,V1);
      Quad2.Parameters(psol,U2,V2);
      IntPatch_Point ptsol;
      ptsol.SetValue(psol,TolTang,Standard_True);
      ptsol.SetParameters(U1,V1,U2,V2);
      spnt.Append(ptsol);
    }
      break;
      //
    case IntAna_Circle:    {
      cirsol = inter.Circle(1);
      //modified by NIZNHY-PKV Thu Sep 15 11:30:03 2011f
      AdjustToSeam(Sp, cirsol, Tolang);
      //modified by NIZNHY-PKV Thu Sep 15 11:30:15 2011t
      gp_Pnt ptref;
      gp_Vec Tgt;
      ElCLib::D1(0.,cirsol,ptref,Tgt);

      if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
	trans1 = IntSurf_Out;
	trans2 = IntSurf_In;
      }
      else {
	trans1 = IntSurf_In;
	trans2 = IntSurf_Out;
      }
      Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
      slin.Append(glig);
    }
      break;
      
    default:    {
      return Standard_False;  // on ne doit pas passer ici
    }
  }
  return Standard_True;
}
//=======================================================================
//function : IntPCo
//purpose  : 
// Traitement du cas Plan/Cone et reciproquement
//=======================================================================
Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
			 const IntSurf_Quadric& Quad2,
			 const Standard_Real Tolang,
			 const Standard_Real TolTang,
			 const Standard_Boolean Reversed,
			 Standard_Boolean& Empty,
			 Standard_Boolean& Multpoint,
			 IntPatch_SequenceOfLine& slin,
			 IntPatch_SequenceOfPoint& spnt)


{
  gp_Pnt apex;

  gp_Pln Pl;
  gp_Cone Co;

  IntSurf_TypeTrans trans1,trans2;
  IntAna_ResultType typint;

  IntAna_QuadQuadGeo inter;
  if (!Reversed) {
    Pl = Quad1.Plane();
    Co = Quad2.Cone();
    apex = Co.Apex();
  }
  else {
    Pl = Quad2.Plane();
    Co = Quad1.Cone();
    apex = Co.Apex();
  }

  inter.Perform(Pl,Co,Tolang,TolTang);
  if (!inter.IsDone()) {
    return Standard_False;
  }
  //
  typint = inter.TypeInter();
  Standard_Integer NbSol = inter.NbSolutions();
  Empty = Standard_False;

  switch (typint) {
    case IntAna_Point:    {
      gp_Pnt psol = inter.Point(1);
      Standard_Real U1,V1,U2,V2;
      Quad1.Parameters(psol,U1,V1);
      Quad2.Parameters(psol,U2,V2);
      IntPatch_Point ptsol;
      ptsol.SetValue(psol,TolTang,Standard_False);
      ptsol.SetParameters(U1,V1,U2,V2);
      spnt.Append(ptsol);
    }
      break;
      
    case IntAna_Line:    {
      gp_Lin linsol = inter.Line(1);
      if (linsol.Direction().Dot(Co.Axis().Direction()) <0.) {
	linsol.SetDirection(linsol.Direction().Reversed());
      }
      Standard_Real para = ElCLib::Parameter(linsol, apex);
      gp_Pnt ptbid (ElCLib::Value(para+5.,linsol));
      Standard_Real U1,V1,U2,V2;
      Quad1.Parameters(apex,U1,V1);
      Quad2.Parameters(apex,U2,V2);
      
      if (NbSol == 1) {                 // ligne de tangence
	IntPatch_Point ptsol;
	ptsol.SetValue(apex,TolTang,Standard_False);
	ptsol.SetParameters(U1,V1,U2,V2);
	ptsol.SetParameter(para);
	gp_Pnt ptbid2(apex.XYZ() + 5.*Co.Axis().Direction().XYZ());
	gp_Vec TestCurvature(ptbid,ptbid2);
	gp_Vec Normp,Normco;
	if (!Reversed) {
	  Normp = Quad1.Normale(ptbid);
	  Normco = Quad2.Normale(ptbid);
	}
	else {
	  Normp = Quad2.Normale(ptbid);
	  Normco = Quad1.Normale(ptbid);
	}
	IntSurf_Situation situco,situco_otherside;
	IntSurf_Situation situp,situp_otherside;
	
	if (Normp.Dot(TestCurvature) > 0.) {
	  situco           = IntSurf_Outside;
	  situco_otherside = IntSurf_Inside;
	  if (Normp.Dot(Normco) > 0.) {
	    situp           = IntSurf_Inside;
	    situp_otherside = IntSurf_Outside;
	  }
	  else {
	    situp           = IntSurf_Outside;
	    situp_otherside = IntSurf_Inside;
	  }
	}
	else {
	  situco           = IntSurf_Inside;
	  situco_otherside = IntSurf_Outside;
	  if (Normp.Dot(Normco) > 0.) {
	    situp           = IntSurf_Outside;
	    situp_otherside = IntSurf_Inside;
	  }
	  else {
	    situp           = IntSurf_Inside;
	    situp_otherside = IntSurf_Outside;
	  }
	}
	//----------------------------------------------------------
	//--              Apex ---> Cone.Direction
	//--
	Handle(IntPatch_GLine) glig;
	if (!Reversed) {
	  glig = new IntPatch_GLine(linsol, Standard_True, situp, situco);
	}
	else {
	  glig = new IntPatch_GLine(linsol, Standard_True, situco, situp);
	}
	glig->AddVertex(ptsol);
	glig->SetFirstPoint(1);
	slin.Append(glig);
	//----------------------------------------------------------
	//--   -Cone.Direction <------- Apex
	//--
	linsol.SetDirection(linsol.Direction().Reversed());
	if (!Reversed) {
	  glig = new IntPatch_GLine(linsol, Standard_True, situp_otherside, situco_otherside);
	}
	else {
	  glig = new IntPatch_GLine(linsol, Standard_True, situco_otherside, situp_otherside);
	}
	glig->AddVertex(ptsol);
	glig->SetFirstPoint(1);
	slin.Append(glig);
      }
      else {      
	// on a 2 droites. Il faut determiner les transitions
	// de chacune. On oriente chaque ligne dans le sens
	// de l axe du cone. Les transitions de chaque ligne seront
	// inverses l une de l autre => on ne fait le calcul que sur
	// la premiere.
	if (linsol.Direction().DotCross
	    (Quad2.Normale(ptbid),Quad1.Normale(ptbid)) >0.) {
	  trans1 = IntSurf_Out;
	  trans2 = IntSurf_In;
	}
	else {
	  trans1 = IntSurf_In;
	  trans2 = IntSurf_Out;
	}

	Multpoint = Standard_True;
	//------------------------------------------- Ligne 1 -------
	IntPatch_Point ptsol;
	ptsol.SetValue(apex,TolTang,Standard_False);
	ptsol.SetParameters(U1,V1,U2,V2);
	ptsol.SetParameter(para);
	ptsol.SetMultiple(Standard_True);
	Handle(IntPatch_GLine) glig;
	glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
	glig->AddVertex(ptsol);
	glig->SetFirstPoint(1);
	slin.Append(glig);
	//-----------------------------------------------------------
	//-- Other Side : Les transitions restent les memes
	//--    linsol -> -linsol   et Quad1(2).N -> -Quad1(2).N
	//-- 
	linsol.SetDirection(linsol.Direction().Reversed());
	glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
	para = ElCLib::Parameter(linsol, apex);
	ptsol.SetParameter(para);
	glig->AddVertex(ptsol);
	glig->SetFirstPoint(1);
	slin.Append(glig);
	
	//------------------------------------------- Ligne 2 -------
	linsol = inter.Line(2);
	if (linsol.Direction().Dot(Co.Axis().Direction()) <0.) {
	  linsol.SetDirection(linsol.Direction().Reversed());
	}
	para = ElCLib::Parameter(linsol, apex);
	ptbid  = ElCLib::Value(para+5.,linsol);
	if (linsol.Direction().DotCross
	    (Quad2.Normale(ptbid),Quad1.Normale(ptbid)) >0.) {
	  trans1 = IntSurf_Out;
	  trans2 = IntSurf_In;
	}
	else {
	  trans1 = IntSurf_In;
	  trans2 = IntSurf_Out;
	}
	ptsol.SetParameter(para);
	glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
	para = ElCLib::Parameter(linsol, apex);
	ptsol.SetParameter(para);
	glig->AddVertex(ptsol);
	glig->SetFirstPoint(1);
	slin.Append(glig);
	//-----------------------------------------------------------
	//-- Other Side : Les transitions restent les memes
	//--    linsol -> -linsol   et Quad1(2).N -> -Quad1(2).N
	//-- 
	linsol.SetDirection(linsol.Direction().Reversed());
	glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
	para = ElCLib::Parameter(linsol, apex);
	ptsol.SetParameter(para);
	glig->AddVertex(ptsol);
	glig->SetFirstPoint(1);
	slin.Append(glig);
      }
    }
    break;
      
    case IntAna_Circle:    {
      gp_Circ cirsol = inter.Circle(1);
      //modified by NIZNHY-PKV Thu Sep 15 11:34:04 2011f
      AdjustToSeam(Co, cirsol);
      //modified by NIZNHY-PKV Thu Sep 15 11:36:08 2011t
      gp_Pnt ptref;
      gp_Vec Tgt;
      ElCLib::D1(0.,cirsol,ptref,Tgt);
      
      if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
	trans1 = IntSurf_Out;
	trans2 = IntSurf_In;
      }
      else {
	trans1 = IntSurf_In;
	trans2 = IntSurf_Out;
      }
      Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
      slin.Append(glig);
    }
      break;
      
    case IntAna_Ellipse:    {
      gp_Elips  elipsol = inter.Ellipse(1);
      gp_Pnt ptref;
      gp_Vec Tgt;
      ElCLib::D1(0.,elipsol,ptref,Tgt);
      
      if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
	trans1 = IntSurf_Out;
	trans2 = IntSurf_In;
      }
      else {
	trans1 = IntSurf_In;
	trans2 = IntSurf_Out;
      }
      Handle(IntPatch_GLine) glig = new IntPatch_GLine(elipsol,Standard_False,trans1,trans2);
      slin.Append(glig);
    }
      break;
      
    case IntAna_Parabola:    {
      gp_Parab parabsol = inter.Parabola(1);
      
      gp_Vec Tgtorig(parabsol.YAxis().Direction());
      Standard_Real ptran = Tgtorig.DotCross(Quad2.Normale(parabsol.Location()),
					     Quad1.Normale(parabsol.Location()));
      if (ptran >0.00000001) {
	trans1 = IntSurf_Out;
	trans2 = IntSurf_In;
      }
      else if (ptran <-0.00000001) {
	trans1 = IntSurf_In;
	trans2 = IntSurf_Out;
      }
      else { 
	trans1=trans2=IntSurf_Undecided; 
      }
      Handle(IntPatch_GLine) glig = new IntPatch_GLine(parabsol,Standard_False,trans1,trans2);
      slin.Append(glig);
    }
      break;
      
    case IntAna_Hyperbola:    {
      gp_Pnt tophypr;
      gp_Vec Tgttop;
      
      for(Standard_Integer i=1; i<=2; i++) { 
	gp_Hypr hyprsol = inter.Hyperbola(i);
	tophypr = ElCLib::Value(hyprsol.MajorRadius(), 
				hyprsol.XAxis());
	Tgttop = hyprsol.YAxis().Direction();
	Standard_Real qwe = Tgttop.DotCross(Quad2.Normale(tophypr),
					    Quad1.Normale(tophypr));
	
	if (qwe>0.00000001) { 
	  trans1 = IntSurf_Out;
	  trans2 = IntSurf_In;
	}
	else if (qwe<-0.00000001){
	  trans1 = IntSurf_In;
	  trans2 = IntSurf_Out;
	}
	else { 
	  trans1=trans2=IntSurf_Undecided;
	}
	Handle(IntPatch_GLine) glig = new IntPatch_GLine(hyprsol,Standard_False,trans1,trans2);
	slin.Append(glig);
      }
    }
      break;
      
    default:    {
      return Standard_False;
    }
  }
  return Standard_True;
}
//
//modified by NIZNHY-PKV Thu Sep 15 10:53:39 2011f
//=======================================================================
//function : AdjustToSeam
//purpose  : 
//=======================================================================
void AdjustToSeam (const gp_Cone& aQuad,
		   gp_Circ& aCirc)
{
   gp_Ax2 aAx2;
   //
   const gp_Pnt& aPLoc=aCirc.Location();
   const gp_Ax3& aAx3=aQuad.Position();
   SeamPosition(aPLoc, aAx3, aAx2);
   aCirc.SetPosition(aAx2);
} 
//=======================================================================
//function : AdjustToSeam
//purpose  : 
//=======================================================================
void AdjustToSeam (const gp_Sphere& aQuad,
		   gp_Circ& aCirc,
		   const Standard_Real aTolAng)
{
   gp_Ax2 aAx2;
   //
   const gp_Ax1& aAx1C=aCirc.Axis();
   const gp_Ax3& aAx3=aQuad.Position();
   const gp_Ax1& aAx1Q=aAx3.Axis();
   //
   const gp_Dir& aDirC=aAx1C.Direction();
   const gp_Dir& aDirQ=aAx1Q.Direction();
   if (aDirC.IsParallel(aDirQ, aTolAng)) {
     const gp_Pnt& aPLoc=aCirc.Location();
     SeamPosition(aPLoc, aAx3, aAx2);
     aCirc.SetPosition(aAx2);
   }
} 
//=======================================================================
//function : AdjustToSeam
//purpose  : 
//=======================================================================
void AdjustToSeam (const gp_Cylinder& aQuad,
		   gp_Circ& aCirc)
{
   gp_Ax2 aAx2;
   //
   const gp_Pnt& aPLoc=aCirc.Location();
   const gp_Ax3& aAx3=aQuad.Position();
   SeamPosition(aPLoc, aAx3, aAx2);
   aCirc.SetPosition(aAx2);
} 
//=======================================================================
//function : SeamPosition
//purpose  : 
//=======================================================================
void SeamPosition(const gp_Pnt& aPLoc, 
		  const gp_Ax3& aPos, 
		  gp_Ax2& aSeamPos)
{
  const gp_Dir& aDZ=aPos.Direction();
  const gp_Dir& aDX=aPos.XDirection();
  gp_Ax2 aAx2(aPLoc, aDZ, aDX);
  aSeamPos=aAx2;
}
			    
//modified by NIZNHY-PKV Thu Sep 15 10:53:41 2011t