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_OutOfRange.hxx>
31 #include <Standard_Type.hxx>
32 #include <TColStd_SequenceOfReal.hxx>
34 IMPLEMENT_STANDARD_RTTIEXT(GeomFill_SweepFunction,Approx_SweepFunction)
36 //=======================================================================
37 //function : GeomFill_SweepFunction
39 //=======================================================================
40 GeomFill_SweepFunction::
41 GeomFill_SweepFunction(const Handle(GeomFill_SectionLaw)& Section,
42 const Handle(GeomFill_LocationLaw)& Location,
43 const Standard_Real FirstParameter,
44 const Standard_Real FirstParameterOnS,
45 const Standard_Real RatioParameterOnS)
50 myfOnS = FirstParameterOnS;
51 myRatio = RatioParameterOnS;
54 //=======================================================================
57 //=======================================================================
58 Standard_Boolean GeomFill_SweepFunction::D0(const Standard_Real Param,
61 TColgp_Array1OfPnt& Poles,
62 TColgp_Array1OfPnt2d& Poles2d,
63 TColStd_Array1OfReal& Weigths)
65 Standard_Integer ii, L;
67 Standard_Real T = myfOnS + (Param - myf) * myRatio;
70 Ok = myLoc->D0(Param, M, V, Poles2d);
72 Ok = mySec->D0(T, Poles, Weigths);
75 for (ii=1; ii<=L; ii++) {
76 gp_XYZ& aux = Poles(ii).ChangeCoord();
83 //=======================================================================
86 //=======================================================================
87 Standard_Boolean GeomFill_SweepFunction::D1(const Standard_Real Param,
90 TColgp_Array1OfPnt& Poles,
91 TColgp_Array1OfVec& DPoles,
92 TColgp_Array1OfPnt2d& Poles2d,
93 TColgp_Array1OfVec2d& DPoles2d,
94 TColStd_Array1OfReal& Weigths,
95 TColStd_Array1OfReal& DWeigths)
97 Standard_Integer ii, L;
99 Standard_Real T = myfOnS + (Param - myf) * myRatio;
103 Ok = myLoc->D1(Param, M, V, DM, DV, Poles2d, DPoles2d);
105 Ok = mySec->D1(T, Poles, DPoles, Weigths, DWeigths);
108 for (ii=1; ii<=L; ii++) {
109 PPrim = DPoles(ii).XYZ();
110 gp_XYZ& P = Poles(ii).ChangeCoord();
112 DWeigths(ii) *= myRatio;
116 DPoles(ii).SetXYZ(PPrim);
121 return Standard_True;
124 //=======================================================================
127 //=======================================================================
128 Standard_Boolean GeomFill_SweepFunction::D2(const Standard_Real Param,
130 const Standard_Real ,
131 TColgp_Array1OfPnt& Poles,
132 TColgp_Array1OfVec& DPoles,
133 TColgp_Array1OfVec& D2Poles,
134 TColgp_Array1OfPnt2d& Poles2d,
135 TColgp_Array1OfVec2d& DPoles2d,
136 TColgp_Array1OfVec2d& D2Poles2d,
137 TColStd_Array1OfReal& Weigths,
138 TColStd_Array1OfReal& DWeigths,
139 TColStd_Array1OfReal& D2Weigths)
141 Standard_Integer ii, L;
143 Standard_Real T = myfOnS + (Param - myf) * myRatio;
144 Standard_Real squareratio = myRatio*myRatio;
147 Ok = myLoc->D2(Param, M, V, DM, DV, D2M, D2V,
148 Poles2d, DPoles2d, D2Poles2d);
150 Ok = mySec->D2(T, Poles, DPoles, D2Poles,
151 Weigths, DWeigths, D2Weigths);
154 for (ii=1; ii<=L; ii++) {
155 gp_XYZ PSecn = D2Poles(ii).XYZ();
156 gp_XYZ PPrim = DPoles(ii).XYZ();
158 DWeigths(ii) *= myRatio;
159 PSecn *= squareratio;
160 D2Weigths(ii) *= squareratio;
161 gp_XYZ& P = Poles(ii).ChangeCoord();
164 PSecn += 2*(DM*PPrim);
167 D2Poles(ii).SetXYZ(PSecn);
172 DPoles(ii).SetXYZ(PPrim);
177 return Standard_True;
180 //=======================================================================
181 //function : Nb2dCurves
183 //=======================================================================
184 Standard_Integer GeomFill_SweepFunction::Nb2dCurves() const
186 return myLoc->Nb2dCurves();
189 //=======================================================================
190 //function : SectionShape
192 //=======================================================================
193 void GeomFill_SweepFunction::SectionShape(Standard_Integer& NbPoles,
194 Standard_Integer& NbKnots,
195 Standard_Integer& Degree) const
197 mySec->SectionShape(NbPoles, NbKnots, Degree);
200 //=======================================================================
203 //=======================================================================
204 void GeomFill_SweepFunction::Knots(TColStd_Array1OfReal& TKnots) const
206 mySec->Knots(TKnots);
209 //=======================================================================
212 //=======================================================================
213 void GeomFill_SweepFunction::Mults(TColStd_Array1OfInteger& TMults) const
215 mySec->Mults(TMults);
218 //=======================================================================
219 //function : IsRational
221 //=======================================================================
222 Standard_Boolean GeomFill_SweepFunction::IsRational() const
224 return mySec->IsRational();
227 //=======================================================================
228 //function : NbIntervals
230 //=======================================================================
231 Standard_Integer GeomFill_SweepFunction::NbIntervals(const GeomAbs_Shape S) const
233 Standard_Integer Nb_Sec, Nb_Loc;
234 Nb_Sec = mySec->NbIntervals(S);
235 Nb_Loc = myLoc->NbIntervals(S);
240 else if (Nb_Loc==1) {
244 TColStd_Array1OfReal IntS(1, Nb_Sec+1);
245 TColStd_Array1OfReal IntL(1, Nb_Loc+1);
246 TColStd_SequenceOfReal Inter;
249 mySec->Intervals(IntS, S);
250 for (ii=1; ii<=Nb_Sec+1; ii++) {
251 T = (IntS(ii) - myfOnS) / myRatio + myf;
254 myLoc->Intervals(IntL, S);
256 GeomLib::FuseIntervals( IntS, IntL, Inter, Precision::PConfusion()*0.99);
257 return Inter.Length()-1;
260 //=======================================================================
261 //function : Intervals
263 //=======================================================================
264 void GeomFill_SweepFunction::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const
266 Standard_Integer Nb_Sec, Nb_Loc, ii;
267 Nb_Sec = mySec->NbIntervals(S);
268 Nb_Loc = myLoc->NbIntervals(S);
271 myLoc->Intervals(T, S);
274 else if (Nb_Loc==1) {
276 mySec->Intervals(T, S);
277 for (ii=1; ii<=Nb_Sec+1; ii++) {
278 t = (T(ii) - myfOnS) / myRatio + myf;
284 TColStd_Array1OfReal IntS(1, Nb_Sec+1);
285 TColStd_Array1OfReal IntL(1, Nb_Loc+1);
286 TColStd_SequenceOfReal Inter;
289 mySec->Intervals(IntS, S);
290 for (ii=1; ii<=Nb_Sec+1; ii++) {
291 t = (IntS(ii) - myfOnS) / myRatio + myf;
294 myLoc->Intervals(IntL, S);
296 GeomLib::FuseIntervals(IntS, IntL, Inter, Precision::PConfusion()*0.99);
297 for (ii=1; ii<=Inter.Length(); ii++)
301 //=======================================================================
302 //function : SetInterval
304 //=======================================================================
305 void GeomFill_SweepFunction::SetInterval(const Standard_Real First,
306 const Standard_Real Last)
308 Standard_Real uf, ul;
309 myLoc->SetInterval(First, Last);
310 uf = myf + (First - myf) * myRatio;
311 ul = myf + (Last - myf) * myRatio;
312 mySec->SetInterval(uf, ul);
315 //=======================================================================
318 //=======================================================================
319 void GeomFill_SweepFunction::GetTolerance(const Standard_Real BoundTol,
320 const Standard_Real SurfTol,
321 const Standard_Real AngleTol,
322 TColStd_Array1OfReal& Tol3d) const
324 mySec->GetTolerance( BoundTol, SurfTol, AngleTol, Tol3d);
328 //=======================================================================
329 //function : Resolution
331 //=======================================================================
332 void GeomFill_SweepFunction::Resolution(const Standard_Integer Index,
333 const Standard_Real Tol,
335 Standard_Real& TolV)const
337 myLoc->Resolution(Index, Tol, TolU, TolV);
340 //=======================================================================
343 //=======================================================================
344 void GeomFill_SweepFunction::SetTolerance(const Standard_Real Tol3d,
345 const Standard_Real Tol2d)
347 mySec->SetTolerance(Tol3d, Tol2d);
348 myLoc->SetTolerance(Tol3d, Tol2d);
351 //=======================================================================
354 //=======================================================================
355 gp_Pnt GeomFill_SweepFunction::BarycentreOfSurf() const
361 Bary = mySec->BarycentreOfSurf();
362 myLoc->GetAverageLaw(aM, Translate);
363 Bary.ChangeCoord() *= aM;
364 Bary.ChangeCoord() += Translate.XYZ();
369 //=======================================================================
372 //=======================================================================
373 Standard_Real GeomFill_SweepFunction::MaximalSection() const
375 Standard_Real L = mySec->MaximalSection();
376 L *= myLoc->GetMaximalNorm();
380 //=======================================================================
383 //=======================================================================
384 void GeomFill_SweepFunction::GetMinimalWeight(TColStd_Array1OfReal& Weigths) const
386 mySec->GetMinimalWeight(Weigths);