0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / FEmTool / FEmTool_ElementsOfRefMatrix.cxx
CommitLineData
b311480e 1// Created on: 1998-11-10
2// Created by: Igor FEOKTISTOV
3// Copyright (c) 1998-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
42cf5bc1 17
18#include <FEmTool_ElementsOfRefMatrix.hxx>
7fd59977 19#include <PLib_Base.hxx>
42cf5bc1 20#include <Standard_ConstructionError.hxx>
7fd59977 21#include <TColStd_Array1OfReal.hxx>
22
7fd59977 23FEmTool_ElementsOfRefMatrix::FEmTool_ElementsOfRefMatrix(const Handle(PLib_Base)& TheBase,
24 const Standard_Integer DerOrder):
25 myBase(TheBase)
26{
27 if(DerOrder < 0 || DerOrder > 3)
28 Standard_ConstructionError::Raise("FEmTool_ElementsOfRefMatrix");
29
30 myDerOrder = DerOrder;
31 myNbEquations = (myBase->WorkDegree()+2)*(myBase->WorkDegree()+1)/2;
32
33}
34
35Standard_Integer FEmTool_ElementsOfRefMatrix::NbVariables() const
36{
37 return 1;
38}
39
40Standard_Integer FEmTool_ElementsOfRefMatrix::NbEquations() const
41{
42 return myNbEquations;
43}
44
45Standard_Boolean FEmTool_ElementsOfRefMatrix::Value(const math_Vector& X, math_Vector& F)
46{
47 if(F.Length() < myNbEquations) Standard_OutOfRange::Raise("FEmTool_ElementsOfRefMatrix::Value");
48
49 Standard_Real u = X(X.Lower());
50 TColStd_Array1OfReal Basis(0,myBase->WorkDegree()), Aux(0,myBase->WorkDegree());
51
52 switch (myDerOrder) {
53 case 0 :
54 myBase->D0(u, Basis);
55 break;
56 case 1 :
57 myBase->D1(u, Aux, Basis);
58 break;
59 case 2 :
60 myBase->D2(u, Aux, Aux, Basis);
61 break;
62 case 3 :
63 myBase->D3(u, Aux, Aux, Aux, Basis);
64 break;
65 }
66
67 Standard_Integer i, j, ii = 0;
68 for(i = 0; i<=myBase->WorkDegree(); i++)
69 for(j = i; j<=myBase->WorkDegree(); j++) {
70 F(F.Lower()+ii) = Basis(i)*Basis(j); ii++;
71 }
72
73 return Standard_True;
74}
75