0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / Law / Law_Interpol.cxx
1 // pmn -> modified 17/01/1996 : utilisation de Curve() et SetCurve()
2
3 #include <Law_Interpol.ixx>
4 #include <Precision.hxx>
5 #include <TColStd_HArray1OfReal.hxx>
6 #include <gp_Pnt2d.hxx>
7 #include <gp_Vec2d.hxx>
8 #include <Law_Interpolate.hxx>
9
10 #ifdef DEB
11 #ifdef DRAW
12
13 // Pour le dessin.
14 #include <Draw_Appli.hxx>
15 #include <Draw_Display.hxx>
16 #include <Draw.hxx>
17 #include <Draw_Segment3D.hxx>
18 #include <Draw_Segment2D.hxx>
19 #include <Draw_Marker2D.hxx>
20 #include <Draw_ColorKind.hxx>
21 #include <Draw_MarkerShape.hxx>
22
23 static void Law_draw1dcurve(const Handle(Law_BSpline)& bs,
24                             const gp_Vec2d&            tra,
25                             const Standard_Real        scal)
26 {
27   TColStd_Array1OfReal pol(1,bs->NbPoles());
28   bs->Poles(pol);
29   TColStd_Array1OfReal knots(1,bs->NbKnots());
30   bs->Knots(knots);
31   TColStd_Array1OfInteger  mults(1,bs->NbKnots());
32   bs->Multiplicities(mults);
33   Standard_Integer deg = bs->Degree();
34   Standard_Integer nbk = knots.Length();
35   
36   Handle(Draw_Marker2D) mar;
37   gp_Pnt2d pp(knots(1),scal*bs->Value(knots(1)));
38   pp.Translate(tra);
39   gp_Pnt2d qq;
40   mar = new Draw_Marker2D(pp,Draw_Square,Draw_cyan);
41   dout<<mar;
42   Handle(Draw_Segment2D) seg;
43   for(Standard_Integer i = 1; i < nbk; i++){
44     Standard_Real f = knots(i);
45     Standard_Real l = knots(i+1);
46     for (Standard_Integer iu = 1; iu <= 30; iu++){
47       Standard_Real uu = iu/30.;
48       uu = f+uu*(l-f);
49       qq.SetCoord(uu,scal*bs->Value(uu));
50       qq.Translate(tra);
51       seg = new Draw_Segment2D(pp,qq,Draw_jaune);
52       dout<<seg;
53       pp = qq;
54     }
55     mar = new Draw_Marker2D(pp,Draw_Square,Draw_cyan);
56     dout<<mar;
57   }
58 }
59
60 static void Law_draw1dcurve(const TColStd_Array1OfReal&    pol,
61                             const TColStd_Array1OfReal&    knots,
62                             const TColStd_Array1OfInteger& mults,
63                             const Standard_Integer         deg, 
64                             const gp_Vec2d&                tra,
65                             const Standard_Real            scal)
66 {
67   Handle(Law_BSpline) bs = new Law_BSpline(pol,knots,mults,deg);
68   Law_draw1dcurve(bs,tra,scal);
69 }
70
71 static Standard_Boolean Affich = 0;
72
73 #endif
74 #endif
75
76 //=======================================================================
77 //function : Law_Interpol
78 //purpose  : 
79 //=======================================================================
80
81 Law_Interpol::Law_Interpol()
82 {
83 }
84
85 //=======================================================================
86 //function : Set
87 //purpose  : 
88 //=======================================================================
89
90 void Law_Interpol::Set(const TColgp_Array1OfPnt2d& ParAndRad,
91                        const Standard_Boolean Periodic)
92 {
93   Standard_Integer l = ParAndRad.Lower();
94   Standard_Integer nbp = ParAndRad.Length();
95
96   Handle(TColStd_HArray1OfReal) par = new TColStd_HArray1OfReal(1,nbp);
97   Handle(TColStd_HArray1OfReal) rad;
98   if(Periodic) rad = new TColStd_HArray1OfReal(1,nbp - 1);
99   else rad = new TColStd_HArray1OfReal(1,nbp);
100   Standard_Real x,y;
101   Standard_Integer i;
102   for(i = 1; i <= nbp; i++){
103     ParAndRad(l + i - 1).Coord(x,y);
104     par->SetValue(i,x);
105     if(!Periodic || i != nbp) rad->SetValue(i,y);
106   }
107   Law_Interpolate inter(rad,par,Periodic,Precision::Confusion());
108   inter.Perform();
109   SetCurve(inter.Curve()); 
110 #ifdef DEB
111 #ifdef DRAW
112   if (Affich) {
113     gp_Vec2d veve(0.,0.);
114     Law_draw1dcurve(Curve(),veve,1.);
115   }
116 #endif
117 #endif
118 }
119
120 //=======================================================================
121 //function : SetInRelative
122 //purpose  : 
123 //=======================================================================
124
125 void Law_Interpol::SetInRelative(const TColgp_Array1OfPnt2d& ParAndRad,
126                                  const Standard_Real Ud,
127                                  const Standard_Real Uf,
128                                  const Standard_Boolean Periodic)
129 {
130   Standard_Integer l = ParAndRad.Lower(), u = ParAndRad.Upper();
131   Standard_Real wd = ParAndRad(l).X(),wf = ParAndRad(u).X();
132   Standard_Integer nbp = ParAndRad.Length();
133   Handle(TColStd_HArray1OfReal) par = new TColStd_HArray1OfReal(1,nbp);
134   Handle(TColStd_HArray1OfReal) rad;
135   if(Periodic) rad = new TColStd_HArray1OfReal(1,nbp - 1);
136   else rad = new TColStd_HArray1OfReal(1,nbp);
137   Standard_Real x,y;
138   Standard_Integer i;
139   for(i = 1; i <= nbp; i++){
140     ParAndRad(l + i - 1).Coord(x,y);
141     par->SetValue(i,(Uf*(x-wd)+Ud*(wf-x))/(wf-wd));
142     if(!Periodic || i != nbp) rad->SetValue(i,y);
143   }
144   Law_Interpolate inter(rad,par,Periodic,Precision::Confusion());
145   inter.Perform();
146   SetCurve(inter.Curve()); 
147 #ifdef DEB
148 #ifdef DRAW
149   if (Affich) {
150     gp_Vec2d veve(0.,0.);
151     Law_draw1dcurve(Curve(),veve,1.);
152   }
153 #endif
154 #endif
155 }
156
157 //=======================================================================
158 //function : Set
159 //purpose  : 
160 //=======================================================================
161
162 void Law_Interpol::Set(const TColgp_Array1OfPnt2d& ParAndRad,
163                        const Standard_Real Dd,
164                        const Standard_Real Df,
165                        const Standard_Boolean Periodic)
166 {
167   Standard_Integer l = ParAndRad.Lower();
168   Standard_Integer nbp = ParAndRad.Length();
169
170   Handle(TColStd_HArray1OfReal) par = new TColStd_HArray1OfReal(1,nbp);
171   Handle(TColStd_HArray1OfReal) rad;
172   if(Periodic) rad = new TColStd_HArray1OfReal(1,nbp - 1);
173   else rad = new TColStd_HArray1OfReal(1,nbp);
174   Standard_Real x,y;
175   Standard_Integer i;
176   for(i = 1; i <= nbp; i++){
177     ParAndRad(l + i - 1).Coord(x,y);
178     par->SetValue(i,x);
179     if(!Periodic || i != nbp) rad->SetValue(i,y);
180   }
181   Law_Interpolate inter(rad,par,Periodic,Precision::Confusion());
182   inter.Load(Dd,Df);
183   inter.Perform();
184   SetCurve(inter.Curve()); 
185 }
186
187 //=======================================================================
188 //function : SetInRelative
189 //purpose  : 
190 //=======================================================================
191
192 void Law_Interpol::SetInRelative(const TColgp_Array1OfPnt2d& ParAndRad,
193                                  const Standard_Real Ud,
194                                  const Standard_Real Uf,
195                                  const Standard_Real Dd,
196                                  const Standard_Real Df,
197                                  const Standard_Boolean Periodic)
198 {
199   Standard_Integer l = ParAndRad.Lower(), u = ParAndRad.Upper();
200   Standard_Real wd = ParAndRad(l).X(),wf = ParAndRad(u).X();
201   Standard_Integer nbp = ParAndRad.Length();
202   Handle(TColStd_HArray1OfReal) par = new TColStd_HArray1OfReal(1,nbp);
203   Handle(TColStd_HArray1OfReal) rad;
204   if(Periodic) rad = new TColStd_HArray1OfReal(1,nbp - 1);
205   else rad = new TColStd_HArray1OfReal(1,nbp);
206   Standard_Real x,y;
207   Standard_Integer i;
208   for(i = 1; i <= nbp; i++){
209     ParAndRad(l + i - 1).Coord(x,y);
210     par->SetValue(i,(Uf*(x-wd)+Ud*(wf-x))/(wf-wd));
211     if(!Periodic || i != nbp) rad->SetValue(i,y);
212   }
213   Law_Interpolate inter(rad,par,Periodic,Precision::Confusion());
214   inter.Load(Dd,Df);
215   inter.Perform();
216   SetCurve(inter.Curve()); 
217 }