0024275: Cppcheck warnings on uninitialized class members
[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
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22#include <IntCurve_IntConicConic_Tool.hxx>
23#include <gp.hxx>
24
25
26#define TOLERANCE_ANGULAIRE 0.00000001
27
28
29
30//======================================================================
31//=== R e s s o u r c e s G e n e r a l e s ===
32//======================================================================
33
34void Determine_Transition_LC(const IntRes2d_Position Pos1,
35 gp_Vec2d& Tan1,
36 const gp_Vec2d& Norm1,
37 IntRes2d_Transition& T1,
38 const IntRes2d_Position Pos2,
39 gp_Vec2d& Tan2,
40 const gp_Vec2d& Norm2,
41 IntRes2d_Transition& T2,
42 const Standard_Real ) {
43
44
45 Standard_Real sgn=Tan1.Crossed(Tan2);
46 Standard_Real norm=Tan1.Magnitude()*Tan2.Magnitude();
47
48 if (Abs(sgn)<=TOLERANCE_ANGULAIRE*norm) { // Transition TOUCH #########
49 Standard_Boolean opos=(Tan1.Dot(Tan2))<0;
50
51 gp_Vec2d Norm;
52// Modified by Sergey KHROMOV - Thu Nov 2 17:57:15 2000 Begin
53 Tan1.Normalize();
54// Modified by Sergey KHROMOV - Thu Nov 2 17:57:16 2000 End
55 Norm.SetCoord(-Tan1.Y(),Tan1.X());
56
57 Standard_Real Val1=Norm.Dot(Norm1);
58 Standard_Real Val2=Norm.Dot(Norm2);
59
60 if (Abs(Val1-Val2) <= gp::Resolution()) {
61 T1.SetValue(Standard_True,Pos1,IntRes2d_Unknown,opos);
62 T2.SetValue(Standard_True,Pos2,IntRes2d_Unknown,opos);
63 }
64 else if (Val2 > Val1) {
65 T2.SetValue(Standard_True,Pos2,IntRes2d_Inside,opos);
66 if (opos) { T1.SetValue(Standard_True,Pos1,IntRes2d_Inside,opos); }
67 else { T1.SetValue(Standard_True,Pos1,IntRes2d_Outside,opos); }
68 }
69 else { // Val1 > Val2
70 T2.SetValue(Standard_True,Pos2,IntRes2d_Outside,opos);
71 if (opos) { T1.SetValue(Standard_True,Pos1,IntRes2d_Outside,opos); }
72 else { T1.SetValue(Standard_True,Pos1,IntRes2d_Inside,opos); }
73 }
74 }
75 else if (sgn<0) {
76 T1.SetValue(Standard_False,Pos1,IntRes2d_In);
77 T2.SetValue(Standard_False,Pos2,IntRes2d_Out);
78 }
79 else {
80 T1.SetValue(Standard_False,Pos1,IntRes2d_Out);
81 T2.SetValue(Standard_False,Pos2,IntRes2d_In);
82 }
83}
84//----------------------------------------------------------------------
85Standard_Real NormalizeOnCircleDomain(const Standard_Real _Param
86 ,const IntRes2d_Domain& TheDomain) {
87 Standard_Real Param=_Param;
88 while(Param<TheDomain.FirstParameter()) {
89 Param+=PIpPI;
90 }
91 while(Param>TheDomain.LastParameter()) {
92 Param-=PIpPI;
93 }
94 return(Param);
95}
96//----------------------------------------------------------------------
97PeriodicInterval PeriodicInterval::FirstIntersection(PeriodicInterval& PInter)
98{
99 Standard_Real a,b;
100 if(PInter.isnull || isnull) {
101 PeriodicInterval PourSGI; return(PourSGI);
102 }
103 else {
104 if(Length() >= PIpPI)
105 return(PeriodicInterval(PInter.Binf,PInter.Bsup));
106 if(PInter.Length()>=PIpPI)
107 return(PeriodicInterval(Binf,Bsup));
108 if(PInter.Bsup<=Binf) {
109 while(PInter.Binf <= Binf && PInter.Bsup <= Binf) {
110 PInter.Binf+=PIpPI; PInter.Bsup+=PIpPI;
111 }
112 }
113 if(PInter.Binf >= Bsup) {
114 while(PInter.Binf >=Bsup && PInter.Bsup >= Bsup) {
115 PInter.Binf-=PIpPI; PInter.Bsup-=PIpPI;
116 }
117 }
118 if((PInter.Bsup < Binf) || (PInter.Binf > Bsup)) {
119 PeriodicInterval PourSGI; return(PourSGI);
120 }
121 }
122
123 a=(PInter.Binf > Binf)? PInter.Binf : Binf;
124 b=(PInter.Bsup < Bsup)? PInter.Bsup : Bsup;
125
126 return(PeriodicInterval(a,b));
127}
128//----------------------------------------------------------------------
129PeriodicInterval PeriodicInterval::SecondIntersection(PeriodicInterval& PInter)
130{
131 Standard_Real a,b;
132
133
134 if(PInter.isnull
135 || isnull
136 || this->Length()>=PIpPI
137 || PInter.Length()>=PIpPI) {
138 PeriodicInterval PourSGI; return(PourSGI);
139 }
140
141 Standard_Real PInter_inf=PInter.Binf+PIpPI;
142 Standard_Real PInter_sup=PInter.Bsup+PIpPI;
143 if(PInter_inf > Bsup) {
144 PInter_inf=PInter.Binf-PIpPI;
145 PInter_sup=PInter.Bsup-PIpPI;
146 }
147 if((PInter_sup < Binf) || (PInter_inf > Bsup)) {
148 PeriodicInterval PourSGI; return(PourSGI);
149 }
150 else {
151 a=(PInter_inf > Binf)? PInter_inf : Binf;
152 b=(PInter_sup < Bsup)? PInter_sup : Bsup;
153 }
154 return(PeriodicInterval(a,b));
155}
156//----------------------------------------------------------------------
c24d4017 157Interval::Interval() :
158 Binf(0.),
159 Bsup(0.),
160 HasFirstBound(Standard_False),
161 HasLastBound(Standard_False)
162{ IsNull=Standard_True; }
7fd59977 163
164Interval::Interval(const Standard_Real a,const Standard_Real b) {
165 HasFirstBound=HasLastBound=Standard_True;
166 if(a<b) { Binf=a; Bsup=b; }
167 else { Binf=b; Bsup=a; }
168 IsNull=Standard_False;
169}
170
171Interval::Interval(const IntRes2d_Domain& Domain) {
172 IsNull=Standard_False;
173 if(Domain.HasFirstPoint()) {
174 HasFirstBound=Standard_True;
175 Binf=Domain.FirstParameter()-Domain.FirstTolerance();
176 }
177 else
178 HasFirstBound=Standard_False;
179 if(Domain.HasLastPoint()) {
180 HasLastBound=Standard_True;
181 Bsup=Domain.LastParameter()+Domain.LastTolerance();
182 }
183 else HasLastBound=Standard_False;
184}
185
186Interval::Interval( const Standard_Real a,const Standard_Boolean hf
187 ,const Standard_Real b,const Standard_Boolean hl) {
188 Binf=a; Bsup=b;
189 IsNull=Standard_False;
190 HasFirstBound=hf;
191 HasLastBound=hl;
192}
193
194Standard_Real Interval::Length() { return((IsNull)? -1.0 :Abs(Bsup-Binf)); }
195
196Interval Interval::IntersectionWithBounded(const Interval& Inter) {
197 if(IsNull || Inter.IsNull) { Interval PourSGI; return(PourSGI); }
198 if(!(HasFirstBound || HasLastBound))
199 return(Interval(Inter.Binf,Inter.Bsup));
200 Standard_Real a,b;
201 if(HasFirstBound) {
202 if(Inter.Bsup < Binf) { Interval PourSGI; return(PourSGI); }
203 a=(Inter.Binf < Binf)? Binf : Inter.Binf;
204 }
205 else { a=Inter.Binf; }
206
207 if(HasLastBound) {
208 if(Inter.Binf > Bsup) { Interval PourSGI; return(PourSGI); }
209 b=(Inter.Bsup > Bsup)? Bsup : Inter.Bsup;
210 }
211 else { b=Inter.Bsup; }
212 return(Interval(a,b));
213}