b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
7fd59977 |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
7fd59977 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //-------------------------------------------------------------------- |
7fd59977 |
17 | //-------------------------------------------------------------------- |
18 | |
42cf5bc1 |
19 | #include <gp_GTrsf.hxx> |
20 | #include <IGESGeom_TransformationMatrix.hxx> |
21 | #include <Standard_DimensionMismatch.hxx> |
7fd59977 |
22 | #include <Standard_OutOfRange.hxx> |
42cf5bc1 |
23 | #include <Standard_Type.hxx> |
7fd59977 |
24 | |
92efcf78 |
25 | IMPLEMENT_STANDARD_RTTIEXT(IGESGeom_TransformationMatrix,IGESData_TransfEntity) |
26 | |
b311480e |
27 | IGESGeom_TransformationMatrix::IGESGeom_TransformationMatrix () { } |
7fd59977 |
28 | |
29 | |
30 | void IGESGeom_TransformationMatrix::Init |
31 | (const Handle(TColStd_HArray2OfReal)& aMatrix) |
32 | { |
33 | if(aMatrix.IsNull()) { |
34 | theData = new TColStd_HArray2OfReal(1,3,1,4); |
35 | theData->Init(0.0); |
36 | Standard_Integer i =1; |
37 | for( ;i <=3; i++) |
38 | theData->SetValue(i,i,1.0); |
39 | |
40 | } |
41 | if ((aMatrix->RowLength() != 4) || (aMatrix->ColLength() != 3)) |
9775fa61 |
42 | throw Standard_DimensionMismatch("IGESGeom_TransformationMatrix : Init"); |
7fd59977 |
43 | |
44 | |
45 | |
46 | theData = aMatrix; |
47 | if(theData.IsNull()) { |
48 | return; |
49 | } |
50 | InitTypeAndForm(124,FormNumber()); |
51 | } |
52 | |
53 | void IGESGeom_TransformationMatrix::SetFormNumber (const Standard_Integer fm) |
54 | { |
55 | if(theData.IsNull()) |
56 | cout<<"Inavalid Transformation Data"<<endl; |
9775fa61 |
57 | if ((fm < 0 || fm > 1) && (fm < 10 || fm > 12)) throw Standard_OutOfRange("IGESGeom_TransformationMatrix : SetFormNumber"); |
7fd59977 |
58 | InitTypeAndForm(124,fm); |
59 | } |
60 | |
61 | |
62 | Standard_Real IGESGeom_TransformationMatrix::Data |
63 | (const Standard_Integer I, const Standard_Integer J) const |
64 | { |
65 | return theData->Value(I,J); |
66 | } |
67 | |
68 | gp_GTrsf IGESGeom_TransformationMatrix::Value () const |
69 | { |
70 | gp_GTrsf Matrix; |
71 | if(!theData.IsNull()) { |
72 | for (Standard_Integer I = 1; I <= 3; I++) { |
73 | for (Standard_Integer J = 1; J <= 4; J++) { |
74 | Matrix.SetValue(I, J, theData->Value(I, J)); |
75 | } |
76 | } |
77 | } |
78 | |
79 | return Matrix; |
80 | } |