Test for 0022778: Bug in BRepMesh
[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
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
23#include <FEmTool_ElementsOfRefMatrix.ixx>
24#include <PLib_Base.hxx>
25#include <TColStd_Array1OfReal.hxx>
26
27
28FEmTool_ElementsOfRefMatrix::FEmTool_ElementsOfRefMatrix(const Handle(PLib_Base)& TheBase,
29 const Standard_Integer DerOrder):
30 myBase(TheBase)
31{
32 if(DerOrder < 0 || DerOrder > 3)
33 Standard_ConstructionError::Raise("FEmTool_ElementsOfRefMatrix");
34
35 myDerOrder = DerOrder;
36 myNbEquations = (myBase->WorkDegree()+2)*(myBase->WorkDegree()+1)/2;
37
38}
39
40Standard_Integer FEmTool_ElementsOfRefMatrix::NbVariables() const
41{
42 return 1;
43}
44
45Standard_Integer FEmTool_ElementsOfRefMatrix::NbEquations() const
46{
47 return myNbEquations;
48}
49
50Standard_Boolean FEmTool_ElementsOfRefMatrix::Value(const math_Vector& X, math_Vector& F)
51{
52 if(F.Length() < myNbEquations) Standard_OutOfRange::Raise("FEmTool_ElementsOfRefMatrix::Value");
53
54 Standard_Real u = X(X.Lower());
55 TColStd_Array1OfReal Basis(0,myBase->WorkDegree()), Aux(0,myBase->WorkDegree());
56
57 switch (myDerOrder) {
58 case 0 :
59 myBase->D0(u, Basis);
60 break;
61 case 1 :
62 myBase->D1(u, Aux, Basis);
63 break;
64 case 2 :
65 myBase->D2(u, Aux, Aux, Basis);
66 break;
67 case 3 :
68 myBase->D3(u, Aux, Aux, Aux, Basis);
69 break;
70 }
71
72 Standard_Integer i, j, ii = 0;
73 for(i = 0; i<=myBase->WorkDegree(); i++)
74 for(j = i; j<=myBase->WorkDegree(); j++) {
75 F(F.Lower()+ii) = Basis(i)*Basis(j); ii++;
76 }
77
78 return Standard_True;
79}
80