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
23 #include <FairCurve_BattenLaw.hxx>
24 #include <FairCurve_EnergyOfBatten.hxx>
25 #include <math_GaussSetIntegration.hxx>
26 #include <math_IntegerVector.hxx>
27 #include <TColgp_HArray1OfPnt2d.hxx>
29 //=======================================================================
30 FairCurve_EnergyOfBatten::FairCurve_EnergyOfBatten(const Standard_Integer BSplOrder,
31 const Handle(TColStd_HArray1OfReal)& FlatKnots,
32 const Handle(TColgp_HArray1OfPnt2d)& Poles,
33 const Standard_Integer ContrOrder1,
34 const Standard_Integer ContrOrder2,
35 const FairCurve_BattenLaw& Law,
36 const Standard_Real LengthSliding,
37 const Standard_Boolean FreeSliding,
38 const Standard_Real Angle1,
39 const Standard_Real Angle2)
40 //=======================================================================
41 : FairCurve_Energy( Poles, ContrOrder1, ContrOrder2,
42 FreeSliding, Angle1, Angle2),
43 MyLengthSliding(LengthSliding),
44 OriginalSliding(LengthSliding),
46 MyTension(BSplOrder, FlatKnots, Poles, 1, LengthSliding, Law, FreeSliding),
47 MySagging(BSplOrder, FlatKnots, Poles, 1, Law, FreeSliding),
48 MyStatus(FairCurve_OK)
52 //=======================================================================
53 Standard_Boolean FairCurve_EnergyOfBatten::Variable(math_Vector& X) const
54 //=======================================================================
57 Ok = FairCurve_Energy::Variable(X);
58 if (MyWithAuxValue) { X(X.Upper()) = MyLengthSliding; }
62 //=======================================================================
63 void FairCurve_EnergyOfBatten::ComputePoles(const math_Vector& X)
64 //=======================================================================
66 FairCurve_Energy::ComputePoles(X);
67 if (MyWithAuxValue) { MyLengthSliding = X(X.Upper()); }
70 //=======================================================================
71 Standard_Boolean FairCurve_EnergyOfBatten::Compute(const Standard_Integer DerivativeOrder,
73 //=======================================================================
75 math_Vector Debut(1, 1, 0.), Fin(1, 1, 1.);
76 math_IntegerVector MyOrder(1, 1, 24);
77 Standard_Boolean Ok=Standard_False;
79 // Blindage contre les longueur de glissement trop exotique
80 MyStatus = FairCurve_OK;
81 if ( MyLengthSliding > 10*OriginalSliding ) {
82 MyStatus = FairCurve_InfiniteSliding;
83 return Standard_False;
86 if ( MyLengthSliding < OriginalSliding/100 ) {
87 MyLengthSliding = OriginalSliding/100;
90 // Mise a jour des objets sous-fonction
91 MyTension.SetDerivativeOrder(DerivativeOrder);
92 MyTension.SetLengthSliding(MyLengthSliding);
93 MySagging.SetDerivativeOrder(DerivativeOrder);
94 MyBattenLaw.SetSliding(MyLengthSliding);
98 // on decoupe afin d'avoir au moins 2 points d'integration par poles
99 // 24 points de Gauss => 12 poles maximum.
101 Standard_Integer NbInterv = (MyPoles->Length()-1) / 12 + 1, ii;
102 Standard_Real Delta = 1./ NbInterv;
105 for (ii=1; ii<=NbInterv; ii++) {
106 Debut(1) = (ii-1)*Delta;
109 math_GaussSetIntegration SumTension(MyTension, Debut, Fin, MyOrder);
110 Ok = SumTension.IsDone();
113 math_GaussSetIntegration SumSagging(MySagging, Debut, Fin, MyOrder);
114 Ok = SumSagging.IsDone();
116 if (Ok) { Result += SumSagging.Value() + SumTension.Value(); }