1 // File: GeomFill_SweepFunction.cxx
2 // Created: Fri Nov 21 15:18:48 1997
3 // Author: Philippe MANGIN
7 #define No_Standard_RangeError
8 #define No_Standard_OutOfRange
9 #define No_Standard_DimensionError
13 #include <GeomFill_SweepFunction.ixx>
15 #include <TColStd_SequenceOfReal.hxx>
16 #include <GeomLib.hxx>
17 #include <Precision.hxx>
20 //=======================================================================
21 //function : GeomFill_SweepFunction
23 //=======================================================================
24 GeomFill_SweepFunction::
25 GeomFill_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)
34 myfOnS = FirstParameterOnS;
35 myRatio = RatioParameterOnS;
38 //=======================================================================
41 //=======================================================================
42 Standard_Boolean GeomFill_SweepFunction::D0(const Standard_Real Param,
45 TColgp_Array1OfPnt& Poles,
46 TColgp_Array1OfPnt2d& Poles2d,
47 TColStd_Array1OfReal& Weigths)
49 Standard_Integer ii, L;
51 Standard_Real T = myfOnS + (Param - myf) * myRatio;
54 Ok = myLoc->D0(Param, M, V, Poles2d);
56 Ok = mySec->D0(T, Poles, Weigths);
59 for (ii=1; ii<=L; ii++) {
60 gp_XYZ& aux = Poles(ii).ChangeCoord();
67 //=======================================================================
70 //=======================================================================
71 Standard_Boolean GeomFill_SweepFunction::D1(const Standard_Real Param,
74 TColgp_Array1OfPnt& Poles,
75 TColgp_Array1OfVec& DPoles,
76 TColgp_Array1OfPnt2d& Poles2d,
77 TColgp_Array1OfVec2d& DPoles2d,
78 TColStd_Array1OfReal& Weigths,
79 TColStd_Array1OfReal& DWeigths)
81 Standard_Integer ii, L;
83 Standard_Real T = myfOnS + (Param - myf) * myRatio;
87 Ok = myLoc->D1(Param, M, V, DM, DV, Poles2d, DPoles2d);
89 Ok = mySec->D1(T, Poles, DPoles, Weigths, DWeigths);
92 for (ii=1; ii<=L; ii++) {
93 PPrim = DPoles(ii).XYZ();
94 gp_XYZ& P = Poles(ii).ChangeCoord();
96 DWeigths(ii) *= myRatio;
100 DPoles(ii).SetXYZ(PPrim);
105 return Standard_True;
108 //=======================================================================
111 //=======================================================================
112 Standard_Boolean GeomFill_SweepFunction::D2(const Standard_Real Param,
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)
125 Standard_Integer ii, L;
127 Standard_Real T = myfOnS + (Param - myf) * myRatio;
128 Standard_Real squareratio = myRatio*myRatio;
131 Ok = myLoc->D2(Param, M, V, DM, DV, D2M, D2V,
132 Poles2d, DPoles2d, D2Poles2d);
134 Ok = mySec->D2(T, Poles, DPoles, D2Poles,
135 Weigths, DWeigths, D2Weigths);
138 for (ii=1; ii<=L; ii++) {
139 gp_XYZ PSecn = D2Poles(ii).XYZ();
140 gp_XYZ PPrim = DPoles(ii).XYZ();
142 DWeigths(ii) *= myRatio;
143 PSecn *= squareratio;
144 D2Weigths(ii) *= squareratio;
145 gp_XYZ& P = Poles(ii).ChangeCoord();
148 PSecn += 2*(DM*PPrim);
151 D2Poles(ii).SetXYZ(PSecn);
156 DPoles(ii).SetXYZ(PPrim);
161 return Standard_True;
164 //=======================================================================
165 //function : Nb2dCurves
167 //=======================================================================
168 Standard_Integer GeomFill_SweepFunction::Nb2dCurves() const
170 return myLoc->Nb2dCurves();
173 //=======================================================================
174 //function : SectionShape
176 //=======================================================================
177 void GeomFill_SweepFunction::SectionShape(Standard_Integer& NbPoles,
178 Standard_Integer& NbKnots,
179 Standard_Integer& Degree) const
181 mySec->SectionShape(NbPoles, NbKnots, Degree);
184 //=======================================================================
187 //=======================================================================
188 void GeomFill_SweepFunction::Knots(TColStd_Array1OfReal& TKnots) const
190 mySec->Knots(TKnots);
193 //=======================================================================
196 //=======================================================================
197 void GeomFill_SweepFunction::Mults(TColStd_Array1OfInteger& TMults) const
199 mySec->Mults(TMults);
202 //=======================================================================
203 //function : IsRational
205 //=======================================================================
206 Standard_Boolean GeomFill_SweepFunction::IsRational() const
208 return mySec->IsRational();
211 //=======================================================================
212 //function : NbIntervals
214 //=======================================================================
215 Standard_Integer GeomFill_SweepFunction::NbIntervals(const GeomAbs_Shape S) const
217 Standard_Integer Nb_Sec, Nb_Loc;
218 Nb_Sec = mySec->NbIntervals(S);
219 Nb_Loc = myLoc->NbIntervals(S);
224 else if (Nb_Loc==1) {
228 TColStd_Array1OfReal IntS(1, Nb_Sec+1);
229 TColStd_Array1OfReal IntL(1, Nb_Loc+1);
230 TColStd_SequenceOfReal Inter;
233 mySec->Intervals(IntS, S);
234 for (ii=1; ii<=Nb_Sec+1; ii++) {
235 T = (IntS(ii) - myfOnS) / myRatio + myf;
238 myLoc->Intervals(IntL, S);
240 GeomLib::FuseIntervals( IntS, IntL, Inter, Precision::PConfusion()*0.99);
241 return Inter.Length()-1;
244 //=======================================================================
245 //function : Intervals
247 //=======================================================================
248 void GeomFill_SweepFunction::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const
250 Standard_Integer Nb_Sec, Nb_Loc, ii;
251 Nb_Sec = mySec->NbIntervals(S);
252 Nb_Loc = myLoc->NbIntervals(S);
255 myLoc->Intervals(T, S);
258 else if (Nb_Loc==1) {
260 mySec->Intervals(T, S);
261 for (ii=1; ii<=Nb_Sec+1; ii++) {
262 t = (T(ii) - myfOnS) / myRatio + myf;
268 TColStd_Array1OfReal IntS(1, Nb_Sec+1);
269 TColStd_Array1OfReal IntL(1, Nb_Loc+1);
270 TColStd_SequenceOfReal Inter;
273 mySec->Intervals(IntS, S);
274 for (ii=1; ii<=Nb_Sec+1; ii++) {
275 t = (IntS(ii) - myfOnS) / myRatio + myf;
278 myLoc->Intervals(IntL, S);
280 GeomLib::FuseIntervals(IntS, IntL, Inter, Precision::PConfusion()*0.99);
281 for (ii=1; ii<=Inter.Length(); ii++)
285 //=======================================================================
286 //function : SetInterval
288 //=======================================================================
289 void GeomFill_SweepFunction::SetInterval(const Standard_Real First,
290 const Standard_Real Last)
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);
299 //=======================================================================
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
308 mySec->GetTolerance( BoundTol, SurfTol, AngleTol, Tol3d);
312 //=======================================================================
313 //function : Resolution
315 //=======================================================================
316 void GeomFill_SweepFunction::Resolution(const Standard_Integer Index,
317 const Standard_Real Tol,
319 Standard_Real& TolV)const
321 myLoc->Resolution(Index, Tol, TolU, TolV);
324 //=======================================================================
327 //=======================================================================
328 void GeomFill_SweepFunction::SetTolerance(const Standard_Real Tol3d,
329 const Standard_Real Tol2d)
331 mySec->SetTolerance(Tol3d, Tol2d);
332 myLoc->SetTolerance(Tol3d, Tol2d);
335 //=======================================================================
338 //=======================================================================
339 gp_Pnt GeomFill_SweepFunction::BarycentreOfSurf() const
345 Bary = mySec->BarycentreOfSurf();
346 myLoc->GetAverageLaw(M, Translate);
347 Bary.ChangeCoord() *= M;
348 Bary.ChangeCoord() += Translate.XYZ();
353 //=======================================================================
356 //=======================================================================
357 Standard_Real GeomFill_SweepFunction::MaximalSection() const
359 Standard_Real L = mySec->MaximalSection();
360 L *= myLoc->GetMaximalNorm();
364 //=======================================================================
367 //=======================================================================
368 void GeomFill_SweepFunction::GetMinimalWeight(TColStd_Array1OfReal& Weigths) const
370 mySec->GetMinimalWeight(Weigths);