0024428: Implementation of LGPL license
[occt.git] / src / GccAna / GccAna_Circ2d2TanRad_5.cxx
CommitLineData
b311480e 1// Created on: 1991-09-24
2// Created by: Remi GILET
3// Copyright (c) 1991-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//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public version 2.1 as published
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 <GccAna_Circ2d2TanRad.jxx>
18
19#include <ElCLib.hxx>
20#include <gp_Circ2d.hxx>
21#include <gp_Lin2d.hxx>
22#include <gp_Ax2d.hxx>
23#include <IntAna2d_AnaIntersection.hxx>
24#include <IntAna2d_IntPoint.hxx>
25#include <Standard_NegativeValue.hxx>
26#include <GccEnt_BadQualifier.hxx>
27
0d969553 28// Circle passing by two points of given radius.
7fd59977 29// ==============================================
30
0d969553
Y
31//==============================================================================
32// Solution of the equation of second degree showing that the center of the +
33// circle is equidistant from two points. +
34//==============================================================================
7fd59977 35
36GccAna_Circ2d2TanRad::
37 GccAna_Circ2d2TanRad (const gp_Pnt2d& Point1 ,
38 const gp_Pnt2d& Point2 ,
39 const Standard_Real Radius ,
40 const Standard_Real Tolerance ):
41 qualifier1(1,2) ,
42 qualifier2(1,2),
43 TheSame1(1,2) ,
44 TheSame2(1,2) ,
45 cirsol(1,2) ,
46 pnttg1sol(1,2) ,
47 pnttg2sol(1,2) ,
48 par1sol(1,2) ,
49 par2sol(1,2) ,
50 pararg1(1,2) ,
51 pararg2(1,2)
52{
53
54 gp_Dir2d dirx(1.0,0.0);
55 Standard_Real Tol = Abs(Tolerance);
56 NbrSol = 0;
57 WellDone = Standard_False;
58 if (Radius < 0.0) { Standard_NegativeValue::Raise(); }
59 else {
60 if (Point1.Distance(Point2)-Radius*2.0 > Tol) { WellDone = Standard_True; }
61 else {
62 if (Point1.Distance(Point2)-Radius*2.0 >0.0) {
63 WellDone = Standard_True;
64 NbrSol = 1;
65 gp_Ax2d axe(gp_Pnt2d(0.5*(Point1.XY()+Point2.XY())),dirx);
66 cirsol(1) = gp_Circ2d(axe,Radius);
67// =================================
68 qualifier1(1) = GccEnt_noqualifier;
69 qualifier2(1) = GccEnt_noqualifier;
70 TheSame1(1) = 0;
71 TheSame2(1) = 0;
72 pnttg1sol(1) = Point1;
73 pnttg2sol(1) = Point2;
74 }
75 else {
76 gp_Circ2d C1(gp_Ax2d(Point1,dirx),Radius);
77 gp_Circ2d C2(gp_Ax2d(Point2,dirx),Radius);
78 IntAna2d_AnaIntersection Intp(C1,C2);
79 if (Intp.IsDone()) {
80 if (!Intp.IsEmpty()) {
81 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
82 NbrSol++;
83 gp_Pnt2d Center(Intp.Point(i).Value());
84 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
85// =======================================================
86 qualifier1(NbrSol) = GccEnt_noqualifier;
87 qualifier2(NbrSol) = GccEnt_noqualifier;
88 TheSame1(NbrSol) = 0;
89 TheSame2(NbrSol) = 0;
90 pnttg1sol(NbrSol) = Point1;
91 pnttg2sol(NbrSol) = Point2;
92 }
93 }
94 WellDone = Standard_True;
95 }
96 }
97 }
98 }
99 for (Standard_Integer i = 1 ; i <= NbrSol ; i++) {
100 pararg1(i) = 0.;
101 pararg2(i) = 0.;
102 par1sol(i)=ElCLib::Parameter(cirsol(i),pnttg1sol(i));
103 par2sol(i)=ElCLib::Parameter(cirsol(i),pnttg2sol(i));
104 }
105}
106