1 // Created on: 1996-02-01
2 // Created by: Philippe MANGIN
3 // Copyright (c) 1996-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
22 #include <FairCurve_EnergyOfBatten.ixx>
24 #include <math_IntegerVector.hxx>
25 #include <math_GaussSetIntegration.hxx>
26 #include <TColgp_HArray1OfPnt2d.hxx>
28 //=======================================================================
29 FairCurve_EnergyOfBatten::FairCurve_EnergyOfBatten(const Standard_Integer BSplOrder,
30 const Handle(TColStd_HArray1OfReal)& FlatKnots,
31 const Handle(TColgp_HArray1OfPnt2d)& Poles,
32 const Standard_Integer ContrOrder1,
33 const Standard_Integer ContrOrder2,
34 const FairCurve_BattenLaw& Law,
35 const Standard_Real LengthSliding,
36 const Standard_Boolean FreeSliding,
37 const Standard_Real Angle1,
38 const Standard_Real Angle2)
39 //=======================================================================
40 : FairCurve_Energy( Poles, ContrOrder1, ContrOrder2,
41 FreeSliding, Angle1, Angle2),
42 MyLengthSliding(LengthSliding),
43 OriginalSliding(LengthSliding),
45 MyTension(BSplOrder, FlatKnots, Poles, 1, LengthSliding, Law, FreeSliding),
46 MySagging(BSplOrder, FlatKnots, Poles, 1, Law, FreeSliding)
50 //=======================================================================
51 Standard_Boolean FairCurve_EnergyOfBatten::Variable(math_Vector& X) const
52 //=======================================================================
55 Ok = FairCurve_Energy::Variable(X);
56 if (MyWithAuxValue) { X(X.Upper()) = MyLengthSliding; }
60 //=======================================================================
61 void FairCurve_EnergyOfBatten::ComputePoles(const math_Vector& X)
62 //=======================================================================
64 FairCurve_Energy::ComputePoles(X);
65 if (MyWithAuxValue) { MyLengthSliding = X(X.Upper()); }
68 //=======================================================================
69 Standard_Boolean FairCurve_EnergyOfBatten::Compute(const Standard_Integer DerivativeOrder,
71 //=======================================================================
73 math_Vector Debut(1, 1, 0.), Fin(1, 1, 1.);
74 math_IntegerVector MyOrder(1, 1, 24);
75 Standard_Boolean Ok=Standard_False;
77 // Blindage contre les longueur de glissement trop exotique
78 MyStatus = FairCurve_OK;
79 if ( MyLengthSliding > 10*OriginalSliding ) {
80 MyStatus = FairCurve_InfiniteSliding;
81 return Standard_False;
84 if ( MyLengthSliding < OriginalSliding/100 ) {
85 MyLengthSliding = OriginalSliding/100;
88 // Mise a jour des objets sous-fonction
89 MyTension.SetDerivativeOrder(DerivativeOrder);
90 MyTension.SetLengthSliding(MyLengthSliding);
91 MySagging.SetDerivativeOrder(DerivativeOrder);
92 MyBattenLaw.SetSliding(MyLengthSliding);
96 // on decoupe afin d'avoir au moins 2 points d'integration par poles
97 // 24 points de Gauss => 12 poles maximum.
99 Standard_Integer NbInterv = (MyPoles->Length()-1) / 12 + 1, ii;
100 Standard_Real Delta = 1./ NbInterv;
103 for (ii=1; ii<=NbInterv; ii++) {
104 Debut(1) = (ii-1)*Delta;
107 math_GaussSetIntegration SumTension(MyTension, Debut, Fin, MyOrder);
108 Ok = SumTension.IsDone();
111 math_GaussSetIntegration SumSagging(MySagging, Debut, Fin, MyOrder);
112 Ok = SumSagging.IsDone();
114 if (Ok) { Result += SumSagging.Value() + SumTension.Value(); }