0024510: Remove unused local variables
[occt.git] / src / IntCurve / IntCurve_IntConicConic_Tool.cxx
CommitLineData
b311480e 1// Created on: 1992-05-06
2// Created by: Laurent BUCHARD
3// Copyright (c) 1992-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 <IntCurve_IntConicConic_Tool.hxx>
18#include <gp.hxx>
19
20
21#define TOLERANCE_ANGULAIRE 0.00000001
22
23
24
25//======================================================================
26//=== R e s s o u r c e s G e n e r a l e s ===
27//======================================================================
28
29void Determine_Transition_LC(const IntRes2d_Position Pos1,
30 gp_Vec2d& Tan1,
31 const gp_Vec2d& Norm1,
32 IntRes2d_Transition& T1,
33 const IntRes2d_Position Pos2,
34 gp_Vec2d& Tan2,
35 const gp_Vec2d& Norm2,
36 IntRes2d_Transition& T2,
37 const Standard_Real ) {
38
39
40 Standard_Real sgn=Tan1.Crossed(Tan2);
41 Standard_Real norm=Tan1.Magnitude()*Tan2.Magnitude();
42
43 if (Abs(sgn)<=TOLERANCE_ANGULAIRE*norm) { // Transition TOUCH #########
44 Standard_Boolean opos=(Tan1.Dot(Tan2))<0;
45
46 gp_Vec2d Norm;
47// Modified by Sergey KHROMOV - Thu Nov 2 17:57:15 2000 Begin
48 Tan1.Normalize();
49// Modified by Sergey KHROMOV - Thu Nov 2 17:57:16 2000 End
50 Norm.SetCoord(-Tan1.Y(),Tan1.X());
51
52 Standard_Real Val1=Norm.Dot(Norm1);
53 Standard_Real Val2=Norm.Dot(Norm2);
54
55 if (Abs(Val1-Val2) <= gp::Resolution()) {
56 T1.SetValue(Standard_True,Pos1,IntRes2d_Unknown,opos);
57 T2.SetValue(Standard_True,Pos2,IntRes2d_Unknown,opos);
58 }
59 else if (Val2 > Val1) {
60 T2.SetValue(Standard_True,Pos2,IntRes2d_Inside,opos);
61 if (opos) { T1.SetValue(Standard_True,Pos1,IntRes2d_Inside,opos); }
62 else { T1.SetValue(Standard_True,Pos1,IntRes2d_Outside,opos); }
63 }
64 else { // Val1 > Val2
65 T2.SetValue(Standard_True,Pos2,IntRes2d_Outside,opos);
66 if (opos) { T1.SetValue(Standard_True,Pos1,IntRes2d_Outside,opos); }
67 else { T1.SetValue(Standard_True,Pos1,IntRes2d_Inside,opos); }
68 }
69 }
70 else if (sgn<0) {
71 T1.SetValue(Standard_False,Pos1,IntRes2d_In);
72 T2.SetValue(Standard_False,Pos2,IntRes2d_Out);
73 }
74 else {
75 T1.SetValue(Standard_False,Pos1,IntRes2d_Out);
76 T2.SetValue(Standard_False,Pos2,IntRes2d_In);
77 }
78}
79//----------------------------------------------------------------------
80Standard_Real NormalizeOnCircleDomain(const Standard_Real _Param
81 ,const IntRes2d_Domain& TheDomain) {
82 Standard_Real Param=_Param;
83 while(Param<TheDomain.FirstParameter()) {
84 Param+=PIpPI;
85 }
86 while(Param>TheDomain.LastParameter()) {
87 Param-=PIpPI;
88 }
89 return(Param);
90}
91//----------------------------------------------------------------------
92PeriodicInterval PeriodicInterval::FirstIntersection(PeriodicInterval& PInter)
93{
94 Standard_Real a,b;
95 if(PInter.isnull || isnull) {
96 PeriodicInterval PourSGI; return(PourSGI);
97 }
98 else {
99 if(Length() >= PIpPI)
100 return(PeriodicInterval(PInter.Binf,PInter.Bsup));
101 if(PInter.Length()>=PIpPI)
102 return(PeriodicInterval(Binf,Bsup));
103 if(PInter.Bsup<=Binf) {
104 while(PInter.Binf <= Binf && PInter.Bsup <= Binf) {
105 PInter.Binf+=PIpPI; PInter.Bsup+=PIpPI;
106 }
107 }
108 if(PInter.Binf >= Bsup) {
109 while(PInter.Binf >=Bsup && PInter.Bsup >= Bsup) {
110 PInter.Binf-=PIpPI; PInter.Bsup-=PIpPI;
111 }
112 }
113 if((PInter.Bsup < Binf) || (PInter.Binf > Bsup)) {
114 PeriodicInterval PourSGI; return(PourSGI);
115 }
116 }
117
118 a=(PInter.Binf > Binf)? PInter.Binf : Binf;
119 b=(PInter.Bsup < Bsup)? PInter.Bsup : Bsup;
120
121 return(PeriodicInterval(a,b));
122}
123//----------------------------------------------------------------------
124PeriodicInterval PeriodicInterval::SecondIntersection(PeriodicInterval& PInter)
125{
126 Standard_Real a,b;
127
128
129 if(PInter.isnull
130 || isnull
131 || this->Length()>=PIpPI
132 || PInter.Length()>=PIpPI) {
133 PeriodicInterval PourSGI; return(PourSGI);
134 }
135
136 Standard_Real PInter_inf=PInter.Binf+PIpPI;
137 Standard_Real PInter_sup=PInter.Bsup+PIpPI;
138 if(PInter_inf > Bsup) {
139 PInter_inf=PInter.Binf-PIpPI;
140 PInter_sup=PInter.Bsup-PIpPI;
141 }
142 if((PInter_sup < Binf) || (PInter_inf > Bsup)) {
143 PeriodicInterval PourSGI; return(PourSGI);
144 }
145 else {
146 a=(PInter_inf > Binf)? PInter_inf : Binf;
147 b=(PInter_sup < Bsup)? PInter_sup : Bsup;
148 }
149 return(PeriodicInterval(a,b));
150}
151//----------------------------------------------------------------------
c24d4017 152Interval::Interval() :
153 Binf(0.),
154 Bsup(0.),
155 HasFirstBound(Standard_False),
156 HasLastBound(Standard_False)
157{ IsNull=Standard_True; }
7fd59977 158
159Interval::Interval(const Standard_Real a,const Standard_Real b) {
160 HasFirstBound=HasLastBound=Standard_True;
161 if(a<b) { Binf=a; Bsup=b; }
162 else { Binf=b; Bsup=a; }
163 IsNull=Standard_False;
164}
165
166Interval::Interval(const IntRes2d_Domain& Domain) {
167 IsNull=Standard_False;
168 if(Domain.HasFirstPoint()) {
169 HasFirstBound=Standard_True;
170 Binf=Domain.FirstParameter()-Domain.FirstTolerance();
171 }
172 else
173 HasFirstBound=Standard_False;
174 if(Domain.HasLastPoint()) {
175 HasLastBound=Standard_True;
176 Bsup=Domain.LastParameter()+Domain.LastTolerance();
177 }
178 else HasLastBound=Standard_False;
179}
180
181Interval::Interval( const Standard_Real a,const Standard_Boolean hf
182 ,const Standard_Real b,const Standard_Boolean hl) {
183 Binf=a; Bsup=b;
184 IsNull=Standard_False;
185 HasFirstBound=hf;
186 HasLastBound=hl;
187}
188
189Standard_Real Interval::Length() { return((IsNull)? -1.0 :Abs(Bsup-Binf)); }
190
191Interval Interval::IntersectionWithBounded(const Interval& Inter) {
192 if(IsNull || Inter.IsNull) { Interval PourSGI; return(PourSGI); }
193 if(!(HasFirstBound || HasLastBound))
194 return(Interval(Inter.Binf,Inter.Bsup));
195 Standard_Real a,b;
196 if(HasFirstBound) {
197 if(Inter.Bsup < Binf) { Interval PourSGI; return(PourSGI); }
198 a=(Inter.Binf < Binf)? Binf : Inter.Binf;
199 }
200 else { a=Inter.Binf; }
201
202 if(HasLastBound) {
203 if(Inter.Binf > Bsup) { Interval PourSGI; return(PourSGI); }
204 b=(Inter.Bsup > Bsup)? Bsup : Inter.Bsup;
205 }
206 else { b=Inter.Bsup; }
207 return(Interval(a,b));
208}