summaryrefslogtreecommitdiff
path: root/src/GccAna/GccAna_Circ2d2TanRad_5.cxx
blob: 9e03f450d4ba98527ee0a66c1873164a96dc1831 (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
// File:	GccAna_Circ2d2TanRad_5.cxx
// Created:	Tue Sep 24 09:17:30 1991
// Author:	Remi GILET
//		<reg@topsn2>

#include <GccAna_Circ2d2TanRad.jxx>

#include <ElCLib.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Ax2d.hxx>
#include <IntAna2d_AnaIntersection.hxx>
#include <IntAna2d_IntPoint.hxx>
#include <Standard_NegativeValue.hxx>
#include <GccEnt_BadQualifier.hxx>

//   Cercle passant par deux points de rayon donne.
//   ==============================================

//=========================================================================
//   Resolution de l equation du second degre indiquant que le centre du  +
//   cercle est equidistant des deux points.                              +
//=========================================================================

GccAna_Circ2d2TanRad::
   GccAna_Circ2d2TanRad (const gp_Pnt2d&             Point1     ,
                         const gp_Pnt2d&             Point2     ,
                         const Standard_Real         Radius     ,
			 const Standard_Real         Tolerance  ):
   qualifier1(1,2) ,
   qualifier2(1,2),
   TheSame1(1,2)   ,
   TheSame2(1,2)   ,
   cirsol(1,2)     ,
   pnttg1sol(1,2)  ,
   pnttg2sol(1,2)  ,
   par1sol(1,2)    ,
   par2sol(1,2)    ,
   pararg1(1,2)    ,
   pararg2(1,2)    
{

  gp_Dir2d dirx(1.0,0.0);
  Standard_Real Tol = Abs(Tolerance);
  NbrSol = 0;
  WellDone = Standard_False;
  if (Radius < 0.0) { Standard_NegativeValue::Raise(); }
  else {
    if (Point1.Distance(Point2)-Radius*2.0 > Tol) { WellDone = Standard_True; }
    else {
      if (Point1.Distance(Point2)-Radius*2.0 >0.0) {
	WellDone = Standard_True;
	NbrSol = 1;
	gp_Ax2d axe(gp_Pnt2d(0.5*(Point1.XY()+Point2.XY())),dirx);
	cirsol(1) = gp_Circ2d(axe,Radius);
//      =================================
	qualifier1(1) = GccEnt_noqualifier;
	qualifier2(1) = GccEnt_noqualifier;
	TheSame1(1) = 0;
	TheSame2(1) = 0;
	pnttg1sol(1) = Point1;
	pnttg2sol(1) = Point2;
      }
      else {
	gp_Circ2d C1(gp_Ax2d(Point1,dirx),Radius);
	gp_Circ2d C2(gp_Ax2d(Point2,dirx),Radius);
	IntAna2d_AnaIntersection Intp(C1,C2);
	if (Intp.IsDone()) {
	  if (!Intp.IsEmpty()) {
	    for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
	      NbrSol++;
	      gp_Pnt2d Center(Intp.Point(i).Value());
	      cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
//            =======================================================
	      qualifier1(NbrSol) = GccEnt_noqualifier;
	      qualifier2(NbrSol) = GccEnt_noqualifier;
	      TheSame1(NbrSol) = 0;
	      TheSame2(NbrSol) = 0;
	      pnttg1sol(NbrSol) = Point1;
	      pnttg2sol(NbrSol) = Point2;
	    }
	  }
	  WellDone = Standard_True;
	}
      }
    }
  }
  for (Standard_Integer i = 1 ; i <= NbrSol ; i++) {
    pararg1(i) = 0.;
    pararg2(i) = 0.;
    par1sol(i)=ElCLib::Parameter(cirsol(i),pnttg1sol(i));
    par2sol(i)=ElCLib::Parameter(cirsol(i),pnttg2sol(i));
  }
}