summaryrefslogtreecommitdiff
path: root/src/IGESGeom/IGESGeom_TransformationMatrix.cxx
blob: 102a5ed5208a8695c3717fc0fb996ffcdf66171a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//--------------------------------------------------------------------
//
//  File Name : IGESGeom_TransformationMatrix.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESGeom_TransformationMatrix.ixx>
#include <Standard_OutOfRange.hxx>


    IGESGeom_TransformationMatrix::IGESGeom_TransformationMatrix ()    {  }


    void IGESGeom_TransformationMatrix::Init
  (const Handle(TColStd_HArray2OfReal)& aMatrix)
{
  if(aMatrix.IsNull()) {
    theData = new TColStd_HArray2OfReal(1,3,1,4);
    theData->Init(0.0);
    Standard_Integer i =1;
    for( ;i <=3; i++)
      theData->SetValue(i,i,1.0);
    
  }
  if ((aMatrix->RowLength() != 4) || (aMatrix->ColLength() != 3))
    Standard_DimensionMismatch::Raise
  ("IGESGeom_TransformationMatrix : Init");

  
  
  theData = aMatrix;
  if(theData.IsNull()) {
    return;
  }
  InitTypeAndForm(124,FormNumber());
}

    void  IGESGeom_TransformationMatrix::SetFormNumber (const Standard_Integer fm)
{
  if(theData.IsNull()) 
    cout<<"Inavalid Transformation Data"<<endl;
  if ((fm < 0 || fm > 1) && (fm < 10 || fm > 12)) Standard_OutOfRange::Raise
    ("IGESGeom_TransformationMatrix : SetFormNumber");
  InitTypeAndForm(124,fm);
}


    Standard_Real  IGESGeom_TransformationMatrix::Data
  (const Standard_Integer I, const Standard_Integer J) const
{
  return theData->Value(I,J);
}

    gp_GTrsf IGESGeom_TransformationMatrix::Value () const
{
  gp_GTrsf Matrix;
  if(!theData.IsNull()) {
    for (Standard_Integer I = 1; I <= 3; I++) {
      for (Standard_Integer J = 1; J <= 4; J++) {
        Matrix.SetValue(I, J, theData->Value(I, J));
      }
    }
  }
  
  return Matrix;
}