b311480e |
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 |
5 | // |
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. |
10 | // |
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. |
13 | // |
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. |
20 | |
7fd59977 |
21 | |
22 | #include <FairCurve_EnergyOfMVC.ixx> |
23 | |
24 | #include <math_IntegerVector.hxx> |
25 | #include <math_GaussSetIntegration.hxx> |
26 | #include <TColgp_HArray1OfPnt2d.hxx> |
27 | |
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, |
258ff83b |
44 | FreeSliding, Angle1, Angle2, |
45 | BSplOrder-1, Curvature1, Curvature2), |
7fd59977 |
46 | MyLengthSliding(LengthSliding), |
258ff83b |
47 | OriginalSliding(LengthSliding), |
7fd59977 |
48 | MyBattenLaw(Law), |
49 | MyPhysicalRatio(PhysicalRatio), |
50 | MyTension(BSplOrder, FlatKnots, Poles, 1, LengthSliding, Law, FreeSliding, Standard_True), |
51 | MySagging(BSplOrder, FlatKnots, Poles, 1, Law, FreeSliding), |
258ff83b |
52 | MyJerk( BSplOrder, FlatKnots, Poles, 1, Law, FreeSliding) |
7fd59977 |
53 | { |
54 | Standard_DomainError_Raise_if(PhysicalRatio < 0 || PhysicalRatio > 1, |
258ff83b |
55 | "FairCurve_EnergyOfMVC: PhysicalRatio error" ); |
7fd59977 |
56 | } |
57 | |
58 | |
59 | //===================================================================================== |
60 | void FairCurve_EnergyOfMVC::ComputePoles(const math_Vector& X) |
61 | //===================================================================================== |
62 | { |
63 | FairCurve_Energy::ComputePoles(X); |
64 | if (MyWithAuxValue) { MyLengthSliding = X(X.Upper()); } |
65 | } |
66 | |
67 | |
68 | //===================================================================================== |
69 | Standard_Boolean FairCurve_EnergyOfMVC::Variable(math_Vector& X) const |
70 | //===================================================================================== |
71 | { |
72 | Standard_Boolean Ok; |
73 | Ok = FairCurve_Energy::Variable(X); |
74 | if (MyWithAuxValue) { X(X.Upper()) = MyLengthSliding; } |
75 | return Ok; |
76 | } |
77 | |
78 | |
79 | //===================================================================================== |
80 | Standard_Boolean FairCurve_EnergyOfMVC::Compute(const Standard_Integer DerivativeOrder, |
81 | math_Vector& Result) |
82 | //===================================================================================== |
83 | { |
84 | math_Vector Debut(1, 1, 0.), Fin(1, 1, 1.); |
85 | math_IntegerVector MyOrder(1, 1, 24); |
86 | Standard_Boolean Ok=Standard_False; |
87 | |
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; |
93 | } |
94 | if ( MyLengthSliding < OriginalSliding/100 ) { |
95 | MyLengthSliding = OriginalSliding/100; |
96 | } |
97 | |
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); |
104 | |
105 | // Integrations |
106 | |
107 | // on decoupe afin d'avoir au moins 2 points d'integration par poles |
108 | // 24 points de Gauss => 12 poles maximum. |
109 | |
110 | Standard_Integer NbInterv = (MyPoles->Length()-1) / 12 + 1, ii; |
111 | Standard_Real Delta = 1./ NbInterv; |
112 | Result.Init(0); |
113 | |
114 | if (MyPhysicalRatio <= 1.e-12) { |
115 | |
116 | // Cas purement non physique -------------------------- |
117 | |
118 | for (ii=1; ii<=NbInterv; ii++) { |
119 | Debut(1) = (ii-1)*Delta; |
120 | Fin(1) = ii*Delta; |
121 | |
122 | math_GaussSetIntegration SumTension(MyTension, Debut, Fin, MyOrder); |
123 | Ok = SumTension.IsDone(); |
124 | if (!Ok) return Ok; |
125 | |
126 | math_GaussSetIntegration SumJerk(MyJerk, Debut, Fin, MyOrder); |
127 | Ok = SumJerk.IsDone(); |
128 | if (!Ok) return Ok; |
129 | |
130 | Result += SumJerk.Value() + SumTension.Value(); // Cas purement non physique |
131 | } |
132 | } |
133 | else { |
134 | // Cas mixte -------------------------- |
135 | for (ii=1; ii<=NbInterv; ii++) { |
136 | Debut(1) = (ii-1)*Delta; |
137 | Fin(1) = ii*Delta; |
138 | |
139 | math_GaussSetIntegration SumTension(MyTension, Debut, Fin, MyOrder); |
140 | Ok = SumTension.IsDone(); |
141 | if (!Ok) return Ok; |
142 | |
143 | math_GaussSetIntegration SumSagging(MySagging, Debut, Fin, MyOrder); |
144 | Ok = SumSagging.IsDone(); |
145 | if (!Ok) return Ok; |
146 | |
147 | math_GaussSetIntegration SumJerk(MyJerk, Debut, Fin, MyOrder); |
148 | Ok = SumJerk.IsDone(); |
149 | if (!Ok) return Ok; |
150 | |
151 | Result += SumJerk.Value() * (1-MyPhysicalRatio) |
152 | + SumSagging.Value() * MyPhysicalRatio |
153 | + SumTension.Value(); |
154 | } |
155 | } |
156 | |
157 | return Ok; |
158 | } |