0024510: Remove unused local variables
[occt.git] / src / GccAna / GccAna_Lin2dBisec.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.
b311480e 14
7fd59977 15//=========================================================================
0d969553 16// CREATION of the BISSECTICE between two STRAIGHT LINES. +
7fd59977 17//=========================================================================
18
19#include <GccAna_Lin2dBisec.ixx>
20
21#include <ElCLib.hxx>
22#include <gp_XY.hxx>
23#include <gp_Dir2d.hxx>
24#include <gp_Vec2d.hxx>
25#include <gp.hxx>
26#include <Standard_OutOfRange.hxx>
27#include <GccEnt_BadQualifier.hxx>
28#include <StdFail_NotDone.hxx>
29#include <IntAna2d_AnaIntersection.hxx>
30#include <IntAna2d_IntPoint.hxx>
31
32//=========================================================================
0d969553
Y
33// The first calculated bissectrice is the interior bisectrice, the +
34// second is the exterior bissectrice. +
35// the direction of the first bissectrice is such that its scalar product +
36// with direction of Lin1 is always positive. +
37// The second bissectrice is turned in the positive direction. +
7fd59977 38//=========================================================================
39
40GccAna_Lin2dBisec::
41 GccAna_Lin2dBisec (const gp_Lin2d& Lin1,
42 const gp_Lin2d& Lin2):
43 linsol(1,2) ,
44 pntint1sol(1,2),
45 pntint2sol(1,2),
46 par1sol(1,2),
47 par2sol(1,2),
48 pararg1(1,2),
49 pararg2(1,2) {
50
51 WellDone = Standard_False;
52 NbrSol = 0;
53
54 IntAna2d_AnaIntersection Intp(Lin1,Lin2);
55 if (Intp.IsDone()) {
56
57 if (Intp.ParallelElements()) {
58 if (Intp.IdenticalElements()) {
59 NbrSol = 1;
60 WellDone = Standard_True;
61 linsol(NbrSol) = gp_Lin2d(Lin1);
62 }
63 else {
0d969553
Y
64 // Attention : do not use dist = Lin1.Distance(Lin2);
65 // as straight lines can be concurrent for gp_Lin2d
66 // so dist = 0.0 (test of the angle too strict ?)
7fd59977 67 Standard_Real dist = Lin1.Distance(Lin2.Location())/2.0;
68 Standard_Real cross =
69 gp_Vec2d ( -Lin2.Direction().Y() , Lin2.Direction().X() )
70 .Dot ( gp_Vec2d ( Lin2.Location() , Lin1.Location() ) );
71 if (cross < 0) dist = -dist;
72 NbrSol++;
73 WellDone = Standard_True;
74 linsol(NbrSol) = gp_Lin2d(gp_Pnt2d(Lin2.Location().XY()+
75// ========================================================
76 gp_XY(-Lin2.Direction().Y()*dist,Lin2.Direction().X()*dist)),
77// =============================================================
78 Lin2.Direction());
79// =================
80 }
81 }
82
83 else {
84 if (!Intp.IsEmpty()) {
85 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
86 NbrSol++;
87 linsol(NbrSol) = gp_Lin2d(Intp.Point(i).Value(),
88// ================================================
89 gp_Dir2d(Lin1.Direction().XY()+Lin2.Direction().XY()));
90// ======================================================
91 NbrSol++;
92 linsol(NbrSol) = gp_Lin2d(Intp.Point(i).Value(),
93// ===============================================
94 gp_Dir2d(Lin1.Direction().XY()-Lin2.Direction().XY()));
95// ======================================================
96 if (Lin1.Angle(Lin2) >= 0.) { linsol(NbrSol).Reverse(); }
97 WellDone = Standard_True;
98 }
99 }
100 }
101 }
102
103 for (Standard_Integer i = 1 ; i <= NbrSol ; i++) {
104 pntint1sol(i) = linsol(i).Location();
105 pntint2sol(i) = pntint1sol(i);
106 par1sol(i)=ElCLib::Parameter(linsol(i),pntint1sol(i));
107 par2sol(i)=ElCLib::Parameter(linsol(i),pntint2sol(i));
108 pararg1(i)=ElCLib::Parameter(Lin1,pntint1sol(i));
109 pararg2(i)=ElCLib::Parameter(Lin2,pntint2sol(i));
110 }
111
112 }
113
114//=========================================================================
115
116Standard_Boolean GccAna_Lin2dBisec::
117 IsDone () const { return WellDone; }
118
119
120Standard_Integer GccAna_Lin2dBisec::
121 NbSolutions () const
122{
123 if (!WellDone)
124 StdFail_NotDone::Raise();
125 return NbrSol;
126}
127
128gp_Lin2d GccAna_Lin2dBisec::
129 ThisSolution (const Standard_Integer Index) const
130{
131 if (!WellDone)
132 StdFail_NotDone::Raise();
133 if (Index <= 0 || Index > NbrSol)
134 Standard_OutOfRange::Raise();
135 return linsol(Index);
136}
137
138void GccAna_Lin2dBisec::
139 Intersection1 (const Standard_Integer Index,
140 Standard_Real& ParSol,
141 Standard_Real& ParArg,
142 gp_Pnt2d& PntSol) const{
143 if (!WellDone) { StdFail_NotDone::Raise(); }
144 else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
145 else {
146 ParSol = par1sol(Index);
147 ParArg = pararg1(Index);
148 PntSol = gp_Pnt2d(pntint1sol(Index));
149 }
150 }
151
152
153void GccAna_Lin2dBisec::
154 Intersection2 (const Standard_Integer Index,
155 Standard_Real& ParSol,
156 Standard_Real& ParArg,
157 gp_Pnt2d& PntSol) const{
158 if (!WellDone) { StdFail_NotDone::Raise(); }
159 else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
160 else {
161 ParSol = par2sol(Index);
162 ParArg = pararg2(Index);
163 PntSol = gp_Pnt2d(pntint2sol(Index));
164 }
165 }
166