1 // Created on: 1992-05-06
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License 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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <IntCurve_IntConicConic_Tool.hxx>
21 #define TOLERANCE_ANGULAIRE 0.00000001
25 //======================================================================
26 //=== R e s s o u r c e s G e n e r a l e s ===
27 //======================================================================
29 void Determine_Transition_LC(const IntRes2d_Position Pos1,
31 const gp_Vec2d& Norm1,
32 IntRes2d_Transition& T1,
33 const IntRes2d_Position Pos2,
35 const gp_Vec2d& Norm2,
36 IntRes2d_Transition& T2,
37 const Standard_Real ) {
40 Standard_Real sgn=Tan1.Crossed(Tan2);
41 Standard_Real norm=Tan1.Magnitude()*Tan2.Magnitude();
43 if (Abs(sgn)<=TOLERANCE_ANGULAIRE*norm) { // Transition TOUCH #########
44 Standard_Boolean opos=(Tan1.Dot(Tan2))<0;
47 // Modified by Sergey KHROMOV - Thu Nov 2 17:57:15 2000 Begin
49 // Modified by Sergey KHROMOV - Thu Nov 2 17:57:16 2000 End
50 Norm.SetCoord(-Tan1.Y(),Tan1.X());
52 Standard_Real Val1=Norm.Dot(Norm1);
53 Standard_Real Val2=Norm.Dot(Norm2);
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);
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); }
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); }
71 T1.SetValue(Standard_False,Pos1,IntRes2d_In);
72 T2.SetValue(Standard_False,Pos2,IntRes2d_Out);
75 T1.SetValue(Standard_False,Pos1,IntRes2d_Out);
76 T2.SetValue(Standard_False,Pos2,IntRes2d_In);
79 //----------------------------------------------------------------------
80 Standard_Real NormalizeOnCircleDomain(const Standard_Real _Param
81 ,const IntRes2d_Domain& TheDomain) {
82 Standard_Real Param=_Param;
83 while(Param<TheDomain.FirstParameter()) {
86 while(Param>TheDomain.LastParameter()) {
91 //----------------------------------------------------------------------
92 PeriodicInterval PeriodicInterval::FirstIntersection(PeriodicInterval& PInter)
95 if(PInter.isnull || isnull) {
96 PeriodicInterval PourSGI; return(PourSGI);
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;
108 if(PInter.Binf >= Bsup) {
109 while(PInter.Binf >=Bsup && PInter.Bsup >= Bsup) {
110 PInter.Binf-=PIpPI; PInter.Bsup-=PIpPI;
113 if((PInter.Bsup < Binf) || (PInter.Binf > Bsup)) {
114 PeriodicInterval PourSGI; return(PourSGI);
118 a=(PInter.Binf > Binf)? PInter.Binf : Binf;
119 b=(PInter.Bsup < Bsup)? PInter.Bsup : Bsup;
121 return(PeriodicInterval(a,b));
123 //----------------------------------------------------------------------
124 PeriodicInterval PeriodicInterval::SecondIntersection(PeriodicInterval& PInter)
131 || this->Length()>=PIpPI
132 || PInter.Length()>=PIpPI) {
133 PeriodicInterval PourSGI; return(PourSGI);
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;
142 if((PInter_sup < Binf) || (PInter_inf > Bsup)) {
143 PeriodicInterval PourSGI; return(PourSGI);
146 a=(PInter_inf > Binf)? PInter_inf : Binf;
147 b=(PInter_sup < Bsup)? PInter_sup : Bsup;
149 return(PeriodicInterval(a,b));
151 //----------------------------------------------------------------------
152 Interval::Interval() :
155 HasFirstBound(Standard_False),
156 HasLastBound(Standard_False)
157 { IsNull=Standard_True; }
159 Interval::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;
166 Interval::Interval(const IntRes2d_Domain& Domain) {
167 IsNull=Standard_False;
168 if(Domain.HasFirstPoint()) {
169 HasFirstBound=Standard_True;
170 Binf=Domain.FirstParameter()-Domain.FirstTolerance();
173 HasFirstBound=Standard_False;
174 if(Domain.HasLastPoint()) {
175 HasLastBound=Standard_True;
176 Bsup=Domain.LastParameter()+Domain.LastTolerance();
178 else HasLastBound=Standard_False;
181 Interval::Interval( const Standard_Real a,const Standard_Boolean hf
182 ,const Standard_Real b,const Standard_Boolean hl) {
184 IsNull=Standard_False;
189 Standard_Real Interval::Length() { return((IsNull)? -1.0 :Abs(Bsup-Binf)); }
191 Interval 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));
197 if(Inter.Bsup < Binf) { Interval PourSGI; return(PourSGI); }
198 a=(Inter.Binf < Binf)? Binf : Inter.Binf;
200 else { a=Inter.Binf; }
203 if(Inter.Binf > Bsup) { Interval PourSGI; return(PourSGI); }
204 b=(Inter.Bsup > Bsup)? Bsup : Inter.Bsup;
206 else { b=Inter.Bsup; }
207 return(Interval(a,b));