1 // Created on: 1996-04-01
2 // Created by: Philippe MANGIN
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #include <FairCurve_EnergyOfMVC.ixx>
24 #include <math_IntegerVector.hxx>
25 #include <math_GaussSetIntegration.hxx>
26 #include <TColgp_HArray1OfPnt2d.hxx>
28 //=====================================================================================
29 FairCurve_EnergyOfMVC::FairCurve_EnergyOfMVC(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 PhysicalRatio,
36 const Standard_Real LengthSliding,
37 const Standard_Boolean FreeSliding,
38 const Standard_Real Angle1,
39 const Standard_Real Angle2,
40 const Standard_Real Curvature1,
41 const Standard_Real Curvature2 )
42 //=====================================================================================
43 : FairCurve_Energy( Poles, ContrOrder1, ContrOrder2,
44 FreeSliding, Angle1, Angle2,
45 BSplOrder-1, Curvature1, Curvature2),
46 MyLengthSliding(LengthSliding),
47 OriginalSliding(LengthSliding),
49 MyPhysicalRatio(PhysicalRatio),
50 MyTension(BSplOrder, FlatKnots, Poles, 1, LengthSliding, Law, FreeSliding, Standard_True),
51 MySagging(BSplOrder, FlatKnots, Poles, 1, Law, FreeSliding),
52 MyJerk( BSplOrder, FlatKnots, Poles, 1, Law, FreeSliding)
54 Standard_DomainError_Raise_if(PhysicalRatio < 0 || PhysicalRatio > 1,
55 "FairCurve_EnergyOfMVC: PhysicalRatio error" );
59 //=====================================================================================
60 void FairCurve_EnergyOfMVC::ComputePoles(const math_Vector& X)
61 //=====================================================================================
63 FairCurve_Energy::ComputePoles(X);
64 if (MyWithAuxValue) { MyLengthSliding = X(X.Upper()); }
68 //=====================================================================================
69 Standard_Boolean FairCurve_EnergyOfMVC::Variable(math_Vector& X) const
70 //=====================================================================================
73 Ok = FairCurve_Energy::Variable(X);
74 if (MyWithAuxValue) { X(X.Upper()) = MyLengthSliding; }
79 //=====================================================================================
80 Standard_Boolean FairCurve_EnergyOfMVC::Compute(const Standard_Integer DerivativeOrder,
82 //=====================================================================================
84 math_Vector Debut(1, 1, 0.), Fin(1, 1, 1.);
85 math_IntegerVector MyOrder(1, 1, 24);
86 Standard_Boolean Ok=Standard_False;
88 // Blindage contre les longueur de glissement trop exotique
89 MyStatus = FairCurve_OK;
90 if ( MyLengthSliding > 10*OriginalSliding ) {
91 MyStatus = FairCurve_InfiniteSliding;
92 return Standard_False;
94 if ( MyLengthSliding < OriginalSliding/100 ) {
95 MyLengthSliding = OriginalSliding/100;
98 // Mise a jour des objets sous-fonction
99 MyTension.SetDerivativeOrder(DerivativeOrder);
100 MyTension.SetLengthSliding(MyLengthSliding);
101 MySagging.SetDerivativeOrder(DerivativeOrder);
102 MyJerk.SetDerivativeOrder(DerivativeOrder);
103 MyBattenLaw.SetSliding(MyLengthSliding);
107 // on decoupe afin d'avoir au moins 2 points d'integration par poles
108 // 24 points de Gauss => 12 poles maximum.
110 Standard_Integer NbInterv = (MyPoles->Length()-1) / 12 + 1, ii;
111 Standard_Real Delta = 1./ NbInterv;
114 if (MyPhysicalRatio <= 1.e-12) {
116 // Cas purement non physique --------------------------
118 for (ii=1; ii<=NbInterv; ii++) {
119 Debut(1) = (ii-1)*Delta;
122 math_GaussSetIntegration SumTension(MyTension, Debut, Fin, MyOrder);
123 Ok = SumTension.IsDone();
126 math_GaussSetIntegration SumJerk(MyJerk, Debut, Fin, MyOrder);
127 Ok = SumJerk.IsDone();
130 Result += SumJerk.Value() + SumTension.Value(); // Cas purement non physique
134 // Cas mixte --------------------------
135 for (ii=1; ii<=NbInterv; ii++) {
136 Debut(1) = (ii-1)*Delta;
139 math_GaussSetIntegration SumTension(MyTension, Debut, Fin, MyOrder);
140 Ok = SumTension.IsDone();
143 math_GaussSetIntegration SumSagging(MySagging, Debut, Fin, MyOrder);
144 Ok = SumSagging.IsDone();
147 math_GaussSetIntegration SumJerk(MyJerk, Debut, Fin, MyOrder);
148 Ok = SumJerk.IsDone();
151 Result += SumJerk.Value() * (1-MyPhysicalRatio)
152 + SumSagging.Value() * MyPhysicalRatio
153 + SumTension.Value();