summaryrefslogtreecommitdiff
path: root/src/IGESGeom/IGESGeom_ToolTransformationMatrix.cxx
blob: a1d0d21240a381748163be8fe83b8987a9f65833 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
//--------------------------------------------------------------------
//
//  File Name : IGESGeom_TransformationMatrix.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESGeom_ToolTransformationMatrix.ixx>
#include <IGESData_ParamCursor.hxx>
#include <TColStd_HArray2OfReal.hxx>
#include <gp_GTrsf.hxx>
#include <Interface_Macros.hxx>


// MGE 03/08/98
#include <Message_Msg.hxx>


//=======================================================================
//function : IGESGeom_ToolTransformationMatrix
//purpose  : 
//=======================================================================

IGESGeom_ToolTransformationMatrix::IGESGeom_ToolTransformationMatrix ()
{
}


//=======================================================================
//function : ReadOwnParams
//purpose  : 
//=======================================================================

void IGESGeom_ToolTransformationMatrix::ReadOwnParams
  (const Handle(IGESGeom_TransformationMatrix)& ent,
   const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const
{
  // MGE 03/08/98

  //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
  Standard_Real    temp;
  Handle(TColStd_HArray2OfReal) aMatrix = new TColStd_HArray2OfReal(1,3,1,4);

  for (Standard_Integer I = 1; I <= 3; I++) {
    for (Standard_Integer J = 1; J <= 4; J++) {
      //st = PR.ReadReal(PR.Current(), Msg215, temp); //szv#4:S4163:12Mar99 moved in if
      //st = PR.ReadReal(PR.Current(), "Matrix Elements", temp);
      if (PR.ReadReal(PR.Current(), temp))
	aMatrix->SetValue(I, J, temp);
      else{
	Message_Msg Msg215("XSTEP_215");
	PR.SendFail(Msg215);
      }
    }
  }

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init(aMatrix);
}


//=======================================================================
//function : WriteOwnParams
//purpose  : 
//=======================================================================

void IGESGeom_ToolTransformationMatrix::WriteOwnParams
  (const Handle(IGESGeom_TransformationMatrix)& ent, IGESData_IGESWriter& IW) const
{
  for (Standard_Integer I = 1; I <= 3; I++) {
    for (Standard_Integer J = 1; J <= 4; J++) {
      IW.Send(ent->Data(I, J));
    }
  }
}


//=======================================================================
//function : OwnShared
//purpose  : 
//=======================================================================

void  IGESGeom_ToolTransformationMatrix::OwnShared
  (const Handle(IGESGeom_TransformationMatrix)& /*ent*/, Interface_EntityIterator& /*iter*/) const
{
}


//=======================================================================
//function : OwnCopy
//purpose  : 
//=======================================================================

void IGESGeom_ToolTransformationMatrix::OwnCopy
  (const Handle(IGESGeom_TransformationMatrix)& another,
   const Handle(IGESGeom_TransformationMatrix)& ent, Interface_CopyTool& /*TC*/) const
{
  Handle(TColStd_HArray2OfReal) data = new TColStd_HArray2OfReal(1, 3, 1, 4);
  for (Standard_Integer I = 1; I <= 3;I++) {
    for (Standard_Integer J = 1; J <= 4; J++) {
      data->SetValue(I, J, another->Data(I, J));
    }
  }

  ent->Init(data);
  ent->SetFormNumber(another->FormNumber());
}


//=======================================================================
//function : OwnCorrect
//purpose  : 
//=======================================================================

Standard_Boolean IGESGeom_ToolTransformationMatrix::OwnCorrect
  (const Handle(IGESGeom_TransformationMatrix)& ent) const
{
  if (ent->FormNumber() > 1) return Standard_False;
  Standard_Integer cfn = (ent->Value().IsNegative() ? 1 : 0);
  if (cfn == ent->FormNumber()) return Standard_False;
  ent->SetFormNumber(cfn);
  return Standard_True;
}


//=======================================================================
//function : DirChecker
//purpose  : 
//=======================================================================

IGESData_DirChecker IGESGeom_ToolTransformationMatrix::DirChecker
  (const Handle(IGESGeom_TransformationMatrix)& /*ent*/)   const
{
  IGESData_DirChecker DC(124);
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefAny);
//  DC.LineWeight(IGESData_DefAny);
  DC.Color(IGESData_DefAny);
  DC.BlankStatusIgnored();
  DC.SubordinateStatusIgnored();
  DC.UseFlagIgnored();
  DC.HierarchyStatusIgnored();

  return DC;
}


//=======================================================================
//function : OwnCheck
//purpose  : 
//=======================================================================

void IGESGeom_ToolTransformationMatrix::OwnCheck
  (const Handle(IGESGeom_TransformationMatrix)& ent,
   const Interface_ShareTool& , Handle(Interface_Check)& ach)  const
{
  // MGE 03/08/98
  // Building of messages
  //========================================
  //Message_Msg Msg71("XSTEP_71");
  //========================================

  Standard_Integer form = ent->FormNumber();
  if ((form != 0) && (form != 1) && ((form < 10) || (form > 12))) {
    Message_Msg Msg71("XSTEP_71");
    ach->SendFail(Msg71);
  }
// Theses messages are transfered in the translation procedure
/*
  if (form > 1) return;    // ce qui suit : matrice orthogonale
  if (form == 0 && ent->Value().IsNegative())
    ach.AddFail("For Form 0, Determinant is not Positive");
  else if (form == 1 && !ent->Value().IsNegative())
    ach.AddFail("For Form 1, Determinant is not Negative");

  Standard_Real p12 = ent->Data(1,1)*ent->Data(2,1) +
    ent->Data(1,2)*ent->Data(2,2) + ent->Data(1,3)*ent->Data(2,3);
  Standard_Real p13 = ent->Data(1,1)*ent->Data(3,1) +
    ent->Data(1,2)*ent->Data(3,2) + ent->Data(1,3)*ent->Data(3,3);
  Standard_Real p23 = ent->Data(2,1)*ent->Data(3,1) +
    ent->Data(2,2)*ent->Data(3,2) + ent->Data(2,3)*ent->Data(3,3);
  Standard_Real ep = 1.e-05;  // ?? Tolorance des tests ?
  if (p12 < -ep || p12 > ep || p13 < -ep || p13 > ep || p23 < -ep || p23 > ep)
    ach.AddFail("Matrix is not orthogonal");
*/
}


//=======================================================================
//function : OwnDump
//purpose  : 
//=======================================================================

void IGESGeom_ToolTransformationMatrix::OwnDump
  (const Handle(IGESGeom_TransformationMatrix)& ent, const IGESData_IGESDumper& /*dumper*/,
  const Handle(Message_Messenger)& S, const Standard_Integer /*level*/)  const
{
  S << "IGESGeom_TransformationMatrix" << endl;

  S << "| R11, R12, R13, T1 |       "
    << ent->Data(1, 1) << ", " << ent->Data(1, 2) << ", "
    << ent->Data(1, 3) << ", " << ent->Data(1, 4) << endl;

  S << "| R21, R22, R23, T2 |       "
    << ent->Data(2, 1) << ", " << ent->Data(2, 2) << ", "
    << ent->Data(2, 3) << ", " << ent->Data(2, 4) << endl;

  S << "| R31, R32, R33, T3 |       "
    << ent->Data(3, 1) << ", " << ent->Data(3, 2) << ", "
    << ent->Data(3, 3) << ", " << ent->Data(3, 4) << endl;

  switch (ent->FormNumber()) {
    case  0 : S << "-- Direct Orthogonal Matrix"      << endl;  break;
    case  1 : S << "-- Reverse Orthogonal Matrix"     << endl;  break;
    case 10 : S << "-- Cartesien Coordinate System"   << endl;  break;
    case 11 : S << "-- Cylindrical Coordinate System" << endl;  break;
    case 12 : S << "-- Spherical Coordinate System"   << endl;  break;
    default : S << "--  (Incorrect Form Number)"      << endl;  break;
  }
}