1 // Created on: 1997-11-21
2 // Created by: Philippe MANGIN
3 // Copyright (c) 1997-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.
18 #define No_Standard_RangeError
19 #define No_Standard_OutOfRange
20 #define No_Standard_DimensionError
24 #include <GeomFill_LocationLaw.hxx>
25 #include <GeomFill_SectionLaw.hxx>
26 #include <GeomFill_SweepFunction.hxx>
27 #include <GeomLib.hxx>
29 #include <Precision.hxx>
30 #include <Standard_Type.hxx>
31 #include <TColStd_SequenceOfReal.hxx>
33 IMPLEMENT_STANDARD_RTTIEXT(GeomFill_SweepFunction,Approx_SweepFunction)
35 //=======================================================================
36 //function : GeomFill_SweepFunction
38 //=======================================================================
39 GeomFill_SweepFunction::
40 GeomFill_SweepFunction(const Handle(GeomFill_SectionLaw)& Section,
41 const Handle(GeomFill_LocationLaw)& Location,
42 const Standard_Real FirstParameter,
43 const Standard_Real FirstParameterOnS,
44 const Standard_Real RatioParameterOnS)
49 myfOnS = FirstParameterOnS;
50 myRatio = RatioParameterOnS;
53 //=======================================================================
56 //=======================================================================
57 Standard_Boolean GeomFill_SweepFunction::D0(const Standard_Real Param,
60 TColgp_Array1OfPnt& Poles,
61 TColgp_Array1OfPnt2d& Poles2d,
62 TColStd_Array1OfReal& Weigths)
64 Standard_Integer ii, L;
66 Standard_Real T = myfOnS + (Param - myf) * myRatio;
69 Ok = myLoc->D0(Param, M, V, Poles2d);
71 Ok = mySec->D0(T, Poles, Weigths);
74 for (ii=1; ii<=L; ii++) {
75 gp_XYZ& aux = Poles(ii).ChangeCoord();
82 //=======================================================================
85 //=======================================================================
86 Standard_Boolean GeomFill_SweepFunction::D1(const Standard_Real Param,
89 TColgp_Array1OfPnt& Poles,
90 TColgp_Array1OfVec& DPoles,
91 TColgp_Array1OfPnt2d& Poles2d,
92 TColgp_Array1OfVec2d& DPoles2d,
93 TColStd_Array1OfReal& Weigths,
94 TColStd_Array1OfReal& DWeigths)
96 Standard_Integer ii, L;
98 Standard_Real T = myfOnS + (Param - myf) * myRatio;
102 Ok = myLoc->D1(Param, M, V, DM, DV, Poles2d, DPoles2d);
104 Ok = mySec->D1(T, Poles, DPoles, Weigths, DWeigths);
107 for (ii=1; ii<=L; ii++) {
108 PPrim = DPoles(ii).XYZ();
109 gp_XYZ& P = Poles(ii).ChangeCoord();
111 DWeigths(ii) *= myRatio;
115 DPoles(ii).SetXYZ(PPrim);
120 return Standard_True;
123 //=======================================================================
126 //=======================================================================
127 Standard_Boolean GeomFill_SweepFunction::D2(const Standard_Real Param,
129 const Standard_Real ,
130 TColgp_Array1OfPnt& Poles,
131 TColgp_Array1OfVec& DPoles,
132 TColgp_Array1OfVec& D2Poles,
133 TColgp_Array1OfPnt2d& Poles2d,
134 TColgp_Array1OfVec2d& DPoles2d,
135 TColgp_Array1OfVec2d& D2Poles2d,
136 TColStd_Array1OfReal& Weigths,
137 TColStd_Array1OfReal& DWeigths,
138 TColStd_Array1OfReal& D2Weigths)
140 Standard_Integer ii, L;
142 Standard_Real T = myfOnS + (Param - myf) * myRatio;
143 Standard_Real squareratio = myRatio*myRatio;
146 Ok = myLoc->D2(Param, M, V, DM, DV, D2M, D2V,
147 Poles2d, DPoles2d, D2Poles2d);
149 Ok = mySec->D2(T, Poles, DPoles, D2Poles,
150 Weigths, DWeigths, D2Weigths);
153 for (ii=1; ii<=L; ii++) {
154 gp_XYZ PSecn = D2Poles(ii).XYZ();
155 gp_XYZ PPrim = DPoles(ii).XYZ();
157 DWeigths(ii) *= myRatio;
158 PSecn *= squareratio;
159 D2Weigths(ii) *= squareratio;
160 gp_XYZ& P = Poles(ii).ChangeCoord();
163 PSecn += 2*(DM*PPrim);
166 D2Poles(ii).SetXYZ(PSecn);
171 DPoles(ii).SetXYZ(PPrim);
176 return Standard_True;
179 //=======================================================================
180 //function : Nb2dCurves
182 //=======================================================================
183 Standard_Integer GeomFill_SweepFunction::Nb2dCurves() const
185 return myLoc->Nb2dCurves();
188 //=======================================================================
189 //function : SectionShape
191 //=======================================================================
192 void GeomFill_SweepFunction::SectionShape(Standard_Integer& NbPoles,
193 Standard_Integer& NbKnots,
194 Standard_Integer& Degree) const
196 mySec->SectionShape(NbPoles, NbKnots, Degree);
199 //=======================================================================
202 //=======================================================================
203 void GeomFill_SweepFunction::Knots(TColStd_Array1OfReal& TKnots) const
205 mySec->Knots(TKnots);
208 //=======================================================================
211 //=======================================================================
212 void GeomFill_SweepFunction::Mults(TColStd_Array1OfInteger& TMults) const
214 mySec->Mults(TMults);
217 //=======================================================================
218 //function : IsRational
220 //=======================================================================
221 Standard_Boolean GeomFill_SweepFunction::IsRational() const
223 return mySec->IsRational();
226 //=======================================================================
227 //function : NbIntervals
229 //=======================================================================
230 Standard_Integer GeomFill_SweepFunction::NbIntervals(const GeomAbs_Shape S) const
232 Standard_Integer Nb_Sec, Nb_Loc;
233 Nb_Sec = mySec->NbIntervals(S);
234 Nb_Loc = myLoc->NbIntervals(S);
239 else if (Nb_Loc==1) {
243 TColStd_Array1OfReal IntS(1, Nb_Sec+1);
244 TColStd_Array1OfReal IntL(1, Nb_Loc+1);
245 TColStd_SequenceOfReal Inter;
248 mySec->Intervals(IntS, S);
249 for (ii=1; ii<=Nb_Sec+1; ii++) {
250 T = (IntS(ii) - myfOnS) / myRatio + myf;
253 myLoc->Intervals(IntL, S);
255 GeomLib::FuseIntervals( IntS, IntL, Inter, Precision::PConfusion()*0.99);
256 return Inter.Length()-1;
259 //=======================================================================
260 //function : Intervals
262 //=======================================================================
263 void GeomFill_SweepFunction::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const
265 Standard_Integer Nb_Sec, Nb_Loc, ii;
266 Nb_Sec = mySec->NbIntervals(S);
267 Nb_Loc = myLoc->NbIntervals(S);
270 myLoc->Intervals(T, S);
273 else if (Nb_Loc==1) {
275 mySec->Intervals(T, S);
276 for (ii=1; ii<=Nb_Sec+1; ii++) {
277 t = (T(ii) - myfOnS) / myRatio + myf;
283 TColStd_Array1OfReal IntS(1, Nb_Sec+1);
284 TColStd_Array1OfReal IntL(1, Nb_Loc+1);
285 TColStd_SequenceOfReal Inter;
288 mySec->Intervals(IntS, S);
289 for (ii=1; ii<=Nb_Sec+1; ii++) {
290 t = (IntS(ii) - myfOnS) / myRatio + myf;
293 myLoc->Intervals(IntL, S);
295 GeomLib::FuseIntervals(IntS, IntL, Inter, Precision::PConfusion()*0.99);
296 for (ii=1; ii<=Inter.Length(); ii++)
300 //=======================================================================
301 //function : SetInterval
303 //=======================================================================
304 void GeomFill_SweepFunction::SetInterval(const Standard_Real First,
305 const Standard_Real Last)
307 Standard_Real uf, ul;
308 myLoc->SetInterval(First, Last);
309 uf = myf + (First - myf) * myRatio;
310 ul = myf + (Last - myf) * myRatio;
311 mySec->SetInterval(uf, ul);
314 //=======================================================================
317 //=======================================================================
318 void GeomFill_SweepFunction::GetTolerance(const Standard_Real BoundTol,
319 const Standard_Real SurfTol,
320 const Standard_Real AngleTol,
321 TColStd_Array1OfReal& Tol3d) const
323 mySec->GetTolerance( BoundTol, SurfTol, AngleTol, Tol3d);
327 //=======================================================================
328 //function : Resolution
330 //=======================================================================
331 void GeomFill_SweepFunction::Resolution(const Standard_Integer Index,
332 const Standard_Real Tol,
334 Standard_Real& TolV)const
336 myLoc->Resolution(Index, Tol, TolU, TolV);
339 //=======================================================================
342 //=======================================================================
343 void GeomFill_SweepFunction::SetTolerance(const Standard_Real Tol3d,
344 const Standard_Real Tol2d)
346 mySec->SetTolerance(Tol3d, Tol2d);
347 myLoc->SetTolerance(Tol3d, Tol2d);
350 //=======================================================================
353 //=======================================================================
354 gp_Pnt GeomFill_SweepFunction::BarycentreOfSurf() const
360 Bary = mySec->BarycentreOfSurf();
361 myLoc->GetAverageLaw(aM, Translate);
362 Bary.ChangeCoord() *= aM;
363 Bary.ChangeCoord() += Translate.XYZ();
368 //=======================================================================
371 //=======================================================================
372 Standard_Real GeomFill_SweepFunction::MaximalSection() const
374 Standard_Real L = mySec->MaximalSection();
375 L *= myLoc->GetMaximalNorm();
379 //=======================================================================
382 //=======================================================================
383 void GeomFill_SweepFunction::GetMinimalWeight(TColStd_Array1OfReal& Weigths) const
385 mySec->GetMinimalWeight(Weigths);