0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / FairCurve / FairCurve_EnergyOfBatten.cxx
CommitLineData
b311480e 1// Created on: 1996-02-01
2// Created by: Philippe MANGIN
3// Copyright (c) 1996-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
0797d9d3 17#ifndef OCCT_DEBUG
7fd59977 18#define No_Standard_RangeError
19#define No_Standard_OutOfRange
20#endif
21
7fd59977 22
42cf5bc1 23#include <FairCurve_EnergyOfBatten.hxx>
7fd59977 24#include <math_GaussSetIntegration.hxx>
42cf5bc1 25#include <math_IntegerVector.hxx>
7fd59977 26#include <TColgp_HArray1OfPnt2d.hxx>
27
28//=======================================================================
29FairCurve_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,
258ff83b 41 FreeSliding, Angle1, Angle2),
7fd59977 42 MyLengthSliding(LengthSliding),
258ff83b 43 OriginalSliding(LengthSliding),
7fd59977 44 MyBattenLaw(Law),
45 MyTension(BSplOrder, FlatKnots, Poles, 1, LengthSliding, Law, FreeSliding),
d533dafb 46 MySagging(BSplOrder, FlatKnots, Poles, 1, Law, FreeSliding),
47 MyStatus(FairCurve_OK)
7fd59977 48{
49}
50
51//=======================================================================
52Standard_Boolean FairCurve_EnergyOfBatten::Variable(math_Vector& X) const
53//=======================================================================
54{
55 Standard_Boolean Ok;
56 Ok = FairCurve_Energy::Variable(X);
57 if (MyWithAuxValue) { X(X.Upper()) = MyLengthSliding; }
58 return Ok;
59}
60
61//=======================================================================
62void FairCurve_EnergyOfBatten::ComputePoles(const math_Vector& X)
63//=======================================================================
64{
65 FairCurve_Energy::ComputePoles(X);
66 if (MyWithAuxValue) { MyLengthSliding = X(X.Upper()); }
67}
68
69//=======================================================================
70Standard_Boolean FairCurve_EnergyOfBatten::Compute(const Standard_Integer DerivativeOrder,
71 math_Vector& Result)
72//=======================================================================
73{
74 math_Vector Debut(1, 1, 0.), Fin(1, 1, 1.);
75 math_IntegerVector MyOrder(1, 1, 24);
76 Standard_Boolean Ok=Standard_False;
77
78// Blindage contre les longueur de glissement trop exotique
79 MyStatus = FairCurve_OK;
80 if ( MyLengthSliding > 10*OriginalSliding ) {
81 MyStatus = FairCurve_InfiniteSliding;
82 return Standard_False;
83}
84
85 if ( MyLengthSliding < OriginalSliding/100 ) {
86 MyLengthSliding = OriginalSliding/100;
87 }
88
89// Mise a jour des objets sous-fonction
90 MyTension.SetDerivativeOrder(DerivativeOrder);
91 MyTension.SetLengthSliding(MyLengthSliding);
92 MySagging.SetDerivativeOrder(DerivativeOrder);
93 MyBattenLaw.SetSliding(MyLengthSliding);
94
95// Integrations
96
97 // on decoupe afin d'avoir au moins 2 points d'integration par poles
98 // 24 points de Gauss => 12 poles maximum.
99
100 Standard_Integer NbInterv = (MyPoles->Length()-1) / 12 + 1, ii;
101 Standard_Real Delta = 1./ NbInterv;
102 Result.Init(0);
103
104 for (ii=1; ii<=NbInterv; ii++) {
105 Debut(1) = (ii-1)*Delta;
106 Fin(1) = ii*Delta;
107
108 math_GaussSetIntegration SumTension(MyTension, Debut, Fin, MyOrder);
109 Ok = SumTension.IsDone();
110 if (!Ok) return Ok;
111
112 math_GaussSetIntegration SumSagging(MySagging, Debut, Fin, MyOrder);
113 Ok = SumSagging.IsDone();
114
115 if (Ok) { Result += SumSagging.Value() + SumTension.Value(); }
116 }
117
118 return Ok;
119}
120