Integration of OCCT 6.5.0 from SVN
[occt.git] / src / GeomFill / GeomFill_SweepFunction.cxx
CommitLineData
7fd59977 1// File: GeomFill_SweepFunction.cxx
2// Created: Fri Nov 21 15:18:48 1997
3// Author: Philippe MANGIN
4// <pmn@sgi29>
5
6#ifndef DEB
7#define No_Standard_RangeError
8#define No_Standard_OutOfRange
9#define No_Standard_DimensionError
10#endif
11
12
13#include <GeomFill_SweepFunction.ixx>
14
15#include <TColStd_SequenceOfReal.hxx>
16#include <GeomLib.hxx>
17#include <Precision.hxx>
18
19
20//=======================================================================
21//function : GeomFill_SweepFunction
22//purpose :
23//=======================================================================
24GeomFill_SweepFunction::
25GeomFill_SweepFunction(const Handle(GeomFill_SectionLaw)& Section,
26 const Handle(GeomFill_LocationLaw)& Location,
27 const Standard_Real FirstParameter,
28 const Standard_Real FirstParameterOnS,
29 const Standard_Real RatioParameterOnS)
30{
31 myLoc = Location;
32 mySec = Section;
33 myf = FirstParameter;
34 myfOnS = FirstParameterOnS;
35 myRatio = RatioParameterOnS;
36}
37
38//=======================================================================
39//function : D0
40//purpose :
41//=======================================================================
42Standard_Boolean GeomFill_SweepFunction::D0(const Standard_Real Param,
43 const Standard_Real,
44 const Standard_Real,
45 TColgp_Array1OfPnt& Poles,
46 TColgp_Array1OfPnt2d& Poles2d,
47 TColStd_Array1OfReal& Weigths)
48{
49 Standard_Integer ii, L;
50 Standard_Boolean Ok;
51 Standard_Real T = myfOnS + (Param - myf) * myRatio;
52 L = Poles.Length();
53
54 Ok = myLoc->D0(Param, M, V, Poles2d);
55 if (!Ok) return Ok;
56 Ok = mySec->D0(T, Poles, Weigths);
57 if (!Ok) return Ok;
58
59 for (ii=1; ii<=L; ii++) {
60 gp_XYZ& aux = Poles(ii).ChangeCoord();
61 aux *= M;
62 aux += V.XYZ();
63 }
64 return Standard_True;
65}
66
67//=======================================================================
68//function : D1
69//purpose :
70//=======================================================================
71 Standard_Boolean GeomFill_SweepFunction::D1(const Standard_Real Param,
72 const Standard_Real,
73 const Standard_Real,
74 TColgp_Array1OfPnt& Poles,
75 TColgp_Array1OfVec& DPoles,
76 TColgp_Array1OfPnt2d& Poles2d,
77 TColgp_Array1OfVec2d& DPoles2d,
78 TColStd_Array1OfReal& Weigths,
79 TColStd_Array1OfReal& DWeigths)
80{
81 Standard_Integer ii, L;
82 Standard_Boolean Ok;
83 Standard_Real T = myfOnS + (Param - myf) * myRatio;
84 gp_XYZ PPrim;
85 L = Poles.Length();
86
87 Ok = myLoc->D1(Param, M, V, DM, DV, Poles2d, DPoles2d);
88 if (!Ok) return Ok;
89 Ok = mySec->D1(T, Poles, DPoles, Weigths, DWeigths);
90 if (!Ok) return Ok;
91
92 for (ii=1; ii<=L; ii++) {
93 PPrim = DPoles(ii).XYZ();
94 gp_XYZ& P = Poles(ii).ChangeCoord();
95 PPrim *= myRatio;
96 DWeigths(ii) *= myRatio;
97 PPrim *= M;
98 PPrim += DM*P;
99 PPrim += DV.XYZ();
100 DPoles(ii).SetXYZ(PPrim);
101
102 P *= M;
103 P += V.XYZ();
104 }
105 return Standard_True;
106}
107
108//=======================================================================
109//function : D2
110//purpose :
111//=======================================================================
112 Standard_Boolean GeomFill_SweepFunction::D2(const Standard_Real Param,
113 const Standard_Real,
114 const Standard_Real ,
115 TColgp_Array1OfPnt& Poles,
116 TColgp_Array1OfVec& DPoles,
117 TColgp_Array1OfVec& D2Poles,
118 TColgp_Array1OfPnt2d& Poles2d,
119 TColgp_Array1OfVec2d& DPoles2d,
120 TColgp_Array1OfVec2d& D2Poles2d,
121 TColStd_Array1OfReal& Weigths,
122 TColStd_Array1OfReal& DWeigths,
123 TColStd_Array1OfReal& D2Weigths)
124{
125 Standard_Integer ii, L;
126 Standard_Boolean Ok;
127 Standard_Real T = myfOnS + (Param - myf) * myRatio;
128 Standard_Real squareratio = myRatio*myRatio;
129 L = Poles.Length();
130
131 Ok = myLoc->D2(Param, M, V, DM, DV, D2M, D2V,
132 Poles2d, DPoles2d, D2Poles2d);
133 if (!Ok) return Ok;
134 Ok = mySec->D2(T, Poles, DPoles, D2Poles,
135 Weigths, DWeigths, D2Weigths);
136 if (!Ok) return Ok;
137
138 for (ii=1; ii<=L; ii++) {
139 gp_XYZ PSecn = D2Poles(ii).XYZ();
140 gp_XYZ PPrim = DPoles(ii).XYZ();
141 PPrim *= myRatio;
142 DWeigths(ii) *= myRatio;
143 PSecn *= squareratio;
144 D2Weigths(ii) *= squareratio;
145 gp_XYZ& P = Poles(ii).ChangeCoord();
146
147 PSecn *= M;
148 PSecn += 2*(DM*PPrim);
149 PSecn += D2M*P;
150 PSecn += D2V.XYZ();
151 D2Poles(ii).SetXYZ(PSecn);
152
153 PPrim *= M;
154 PPrim += DM*P;
155 PPrim += DV.XYZ();
156 DPoles(ii).SetXYZ(PPrim);
157
158 P *= M;
159 P += V.XYZ();
160 }
161 return Standard_True;
162}
163
164//=======================================================================
165//function : Nb2dCurves
166//purpose :
167//=======================================================================
168 Standard_Integer GeomFill_SweepFunction::Nb2dCurves() const
169{
170 return myLoc->Nb2dCurves();
171}
172
173//=======================================================================
174//function : SectionShape
175//purpose :
176//=======================================================================
177 void GeomFill_SweepFunction::SectionShape(Standard_Integer& NbPoles,
178 Standard_Integer& NbKnots,
179 Standard_Integer& Degree) const
180{
181 mySec->SectionShape(NbPoles, NbKnots, Degree);
182}
183
184//=======================================================================
185//function : Knots
186//purpose :
187//=======================================================================
188 void GeomFill_SweepFunction::Knots(TColStd_Array1OfReal& TKnots) const
189{
190 mySec->Knots(TKnots);
191}
192
193//=======================================================================
194//function : Mults
195//purpose :
196//=======================================================================
197 void GeomFill_SweepFunction::Mults(TColStd_Array1OfInteger& TMults) const
198{
199 mySec->Mults(TMults);
200}
201
202//=======================================================================
203//function : IsRational
204//purpose :
205//=======================================================================
206 Standard_Boolean GeomFill_SweepFunction::IsRational() const
207{
208 return mySec->IsRational();
209}
210
211//=======================================================================
212//function : NbIntervals
213//purpose :
214//=======================================================================
215 Standard_Integer GeomFill_SweepFunction::NbIntervals(const GeomAbs_Shape S) const
216{
217 Standard_Integer Nb_Sec, Nb_Loc;
218 Nb_Sec = mySec->NbIntervals(S);
219 Nb_Loc = myLoc->NbIntervals(S);
220
221 if (Nb_Sec==1) {
222 return Nb_Loc;
223 }
224 else if (Nb_Loc==1) {
225 return Nb_Sec;
226 }
227
228 TColStd_Array1OfReal IntS(1, Nb_Sec+1);
229 TColStd_Array1OfReal IntL(1, Nb_Loc+1);
230 TColStd_SequenceOfReal Inter;
231 Standard_Real T;
232 Standard_Integer ii;
233 mySec->Intervals(IntS, S);
234 for (ii=1; ii<=Nb_Sec+1; ii++) {
235 T = (IntS(ii) - myfOnS) / myRatio + myf;
236 IntS(ii) = T;
237 }
238 myLoc->Intervals(IntL, S);
239
240 GeomLib::FuseIntervals( IntS, IntL, Inter, Precision::PConfusion()*0.99);
241 return Inter.Length()-1;
242}
243
244//=======================================================================
245//function : Intervals
246//purpose :
247//=======================================================================
248 void GeomFill_SweepFunction::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const
249{
250 Standard_Integer Nb_Sec, Nb_Loc, ii;
251 Nb_Sec = mySec->NbIntervals(S);
252 Nb_Loc = myLoc->NbIntervals(S);
253
254 if (Nb_Sec==1) {
255 myLoc->Intervals(T, S);
256 return;
257 }
258 else if (Nb_Loc==1) {
259 Standard_Real t;
260 mySec->Intervals(T, S);
261 for (ii=1; ii<=Nb_Sec+1; ii++) {
262 t = (T(ii) - myfOnS) / myRatio + myf;
263 T(ii) = t;
264 }
265 return;
266 }
267
268 TColStd_Array1OfReal IntS(1, Nb_Sec+1);
269 TColStd_Array1OfReal IntL(1, Nb_Loc+1);
270 TColStd_SequenceOfReal Inter;
271 Standard_Real t;
272
273 mySec->Intervals(IntS, S);
274 for (ii=1; ii<=Nb_Sec+1; ii++) {
275 t = (IntS(ii) - myfOnS) / myRatio + myf;
276 IntS(ii) = t;
277 }
278 myLoc->Intervals(IntL, S);
279
280 GeomLib::FuseIntervals(IntS, IntL, Inter, Precision::PConfusion()*0.99);
281 for (ii=1; ii<=Inter.Length(); ii++)
282 T(ii) = Inter(ii);
283}
284
285//=======================================================================
286//function : SetInterval
287//purpose :
288//=======================================================================
289 void GeomFill_SweepFunction::SetInterval(const Standard_Real First,
290 const Standard_Real Last)
291{
292 Standard_Real uf, ul;
293 myLoc->SetInterval(First, Last);
294 uf = myf + (First - myf) * myRatio;
295 ul = myf + (Last - myf) * myRatio;
296 mySec->SetInterval(uf, ul);
297}
298
299//=======================================================================
300//function :
301//purpose :
302//=======================================================================
303 void GeomFill_SweepFunction::GetTolerance(const Standard_Real BoundTol,
304 const Standard_Real SurfTol,
305 const Standard_Real AngleTol,
306 TColStd_Array1OfReal& Tol3d) const
307{
308 mySec->GetTolerance( BoundTol, SurfTol, AngleTol, Tol3d);
309}
310
311
312//=======================================================================
313//function : Resolution
314//purpose :
315//=======================================================================
316void GeomFill_SweepFunction::Resolution(const Standard_Integer Index,
317 const Standard_Real Tol,
318 Standard_Real& TolU,
319 Standard_Real& TolV)const
320{
321 myLoc->Resolution(Index, Tol, TolU, TolV);
322}
323
324//=======================================================================
325//function :
326//purpose :
327//=======================================================================
328 void GeomFill_SweepFunction::SetTolerance(const Standard_Real Tol3d,
329 const Standard_Real Tol2d)
330{
331 mySec->SetTolerance(Tol3d, Tol2d);
332 myLoc->SetTolerance(Tol3d, Tol2d);
333}
334
335//=======================================================================
336//function :
337//purpose :
338//=======================================================================
339 gp_Pnt GeomFill_SweepFunction::BarycentreOfSurf() const
340{
341 gp_Pnt Bary;
342 gp_Vec Translate;
343 gp_Mat M;
344
345 Bary = mySec->BarycentreOfSurf();
346 myLoc->GetAverageLaw(M, Translate);
347 Bary.ChangeCoord() *= M;
348 Bary.ChangeCoord() += Translate.XYZ();
349
350 return Bary;
351}
352
353//=======================================================================
354//function :
355//purpose :
356//=======================================================================
357 Standard_Real GeomFill_SweepFunction::MaximalSection() const
358{
359 Standard_Real L = mySec->MaximalSection();
360 L *= myLoc->GetMaximalNorm();
361 return L;
362}
363
364//=======================================================================
365//function :
366//purpose :
367//=======================================================================
368 void GeomFill_SweepFunction::GetMinimalWeight(TColStd_Array1OfReal& Weigths) const
369{
370 mySec->GetMinimalWeight(Weigths);
371}
372
373
374
375
376
377
378
379
380
381
382
383
384