0024510: Remove unused local variables
[occt.git] / src / GccAna / GccAna_Lin2dTanPar.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
973c2be1 6// This library is free software; you can redistribute it and / or modify it
7// under the terms of the GNU Lesser General Public version 2.1 as published
8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
7fd59977 14
15//========================================================================
0d969553
Y
16// CREATION of a LINE TANGENT to a CIRCLE or PASSING by a POINT +
17// and PARALLEL to a STRAIGHT DROITE. +
7fd59977 18//========================================================================
19
20#include <GccAna_Lin2dTanPar.ixx>
21
22#include <ElCLib.hxx>
23#include <StdFail_NotDone.hxx>
24#include <gp_XY.hxx>
25#include <gp_Dir2d.hxx>
26#include <gp_Vec2d.hxx>
27#include <gp_Circ2d.hxx>
28#include <Standard_OutOfRange.hxx>
29#include <GccEnt_BadQualifier.hxx>
30
31//========================================================================
0d969553
Y
32// Passing by a point : +
33// Create the straight line with origin ThePoint and +
34// direction Lin1.Direction(). +
7fd59977 35//========================================================================
36
37GccAna_Lin2dTanPar::
38 GccAna_Lin2dTanPar (const gp_Pnt2d& ThePoint ,
39 const gp_Lin2d& Lin1 ):
40 linsol(1,1),
41 qualifier1(1,1) ,
42 pnttg1sol(1,1),
43 par1sol(1,1),
44 pararg1(1,1)
45{
46
47 linsol(1) = gp_Lin2d(ThePoint,Lin1.Direction());
48// ===============================================
49 qualifier1(1) = GccEnt_noqualifier;
50 pnttg1sol(1) = ThePoint;
51 par1sol(1) = 0.;
52 pararg1(1) = 0.;
53 NbrSol = 1;
54 WellDone = Standard_True;
55}
56
57//========================================================================
0d969553
Y
58// Tangent to a circle : +
59// Create following the qualifier the straight line +
60// - with origin P1 (P1 is a point of intersection between C1 and +
61// a straight line passing by the center of C1 and +
62// direction the normal to Lin1). +
63// the choice of the point of intersection depends +
64// on the qualifier. +
65// - with direction the direction of Lin1. +
7fd59977 66//========================================================================
67
68GccAna_Lin2dTanPar::
69 GccAna_Lin2dTanPar (const GccEnt_QualifiedCirc& Qualified1,
70 const gp_Lin2d& Lin1 ):
71 linsol(1,2),
72 qualifier1(1,2) ,
73 pnttg1sol(1,2),
74 par1sol(1,2),
75 pararg1(1,2)
76{
77
78 WellDone = Standard_False;
79 Standard_Integer signe = 0;
80 Standard_Integer nbsol = 0;
81 NbrSol = 0;
82 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
83 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
84 GccEnt_BadQualifier::Raise();
85 return;
86 }
87 gp_Circ2d C1 = Qualified1.Qualified();
88 Standard_Real xdir = (Lin1.Direction()).X();
89 Standard_Real ydir = (Lin1.Direction()).Y();
90
91 if (Qualified1.IsEnclosed()) { GccEnt_BadQualifier::Raise(); }
92// ============================
93 else if (Qualified1.IsEnclosing()) {
94// ==================================
95 nbsol = 1;
96 signe = 1;
97 qualifier1(1) = GccEnt_enclosing;
98 }
99 else if (Qualified1.IsOutside()) {
100// ===================================
101 nbsol = 1;
102 signe = -1;
103 qualifier1(1) = GccEnt_outside;
104 }
105 else {
106 nbsol = 2;
107 signe = -1;
108 qualifier1(1) = GccEnt_outside;
109 qualifier1(2) = GccEnt_enclosing;
110 }
111 gp_XY xy(-C1.Radius()*ydir,C1.Radius()*xdir);
112 for (Standard_Integer j = 1 ; j <= nbsol ; j++) {
113 signe = -signe;
114 NbrSol++;
115 linsol(NbrSol) = gp_Lin2d(gp_Pnt2d((C1.Location().XY()).Added(signe*xy)),
116// =========================================================================
117 Lin1.Direction());
118// =================
119 pnttg1sol(NbrSol) = gp_Pnt2d((C1.Location().XY()).Added(signe*xy));
120 par1sol(NbrSol) = 0.;
121 pararg1(NbrSol)=ElCLib::Parameter(C1,pnttg1sol(NbrSol));
122 WellDone = Standard_True;
123 }
124 }
125
126Standard_Boolean GccAna_Lin2dTanPar::
127 IsDone () const { return WellDone; }
128
129Standard_Integer GccAna_Lin2dTanPar::NbSolutions () const
130{
131 if (!WellDone)
132 StdFail_NotDone::Raise();
133 return NbrSol;
134}
135
136gp_Lin2d GccAna_Lin2dTanPar::ThisSolution (const Standard_Integer Index) const
137{
138 if (!WellDone) { StdFail_NotDone::Raise(); }
139 else if (Index <= 0 || Index > NbrSol) { Standard_OutOfRange::Raise(); }
140 return linsol(Index);
141}
142
143void GccAna_Lin2dTanPar::
144 WhichQualifier(const Standard_Integer Index ,
145 GccEnt_Position& Qualif1 ) const
146{
147 if (!WellDone) { StdFail_NotDone::Raise(); }
148 else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
149 else {
150 Qualif1 = qualifier1(Index);
151 }
152}
153
154void GccAna_Lin2dTanPar::
155 Tangency1 (const Standard_Integer Index,
156 Standard_Real& ParSol,
157 Standard_Real& ParArg,
158 gp_Pnt2d& Pnt) const {
159 if (!WellDone) { StdFail_NotDone::Raise(); }
160 else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
161 else {
162 ParSol = par1sol(Index);
163 ParArg = pararg1(Index);
164 Pnt = gp_Pnt2d(pnttg1sol(Index));
165 }
166 }