1 //--------------------------------------------------------------------
3 // File Name : IGESGeom_TransformationMatrix.cxx
5 // Author : CKY / Contract Toubro-Larsen
6 // Copyright : MATRA-DATAVISION 1993
8 //--------------------------------------------------------------------
10 #include <IGESGeom_ToolTransformationMatrix.ixx>
11 #include <IGESData_ParamCursor.hxx>
12 #include <TColStd_HArray2OfReal.hxx>
13 #include <gp_GTrsf.hxx>
14 #include <Interface_Macros.hxx>
18 #include <Message_Msg.hxx>
21 //=======================================================================
22 //function : IGESGeom_ToolTransformationMatrix
24 //=======================================================================
26 IGESGeom_ToolTransformationMatrix::IGESGeom_ToolTransformationMatrix ()
31 //=======================================================================
32 //function : ReadOwnParams
34 //=======================================================================
36 void IGESGeom_ToolTransformationMatrix::ReadOwnParams
37 (const Handle(IGESGeom_TransformationMatrix)& ent,
38 const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const
42 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
44 Handle(TColStd_HArray2OfReal) aMatrix = new TColStd_HArray2OfReal(1,3,1,4);
46 for (Standard_Integer I = 1; I <= 3; I++) {
47 for (Standard_Integer J = 1; J <= 4; J++) {
48 //st = PR.ReadReal(PR.Current(), Msg215, temp); //szv#4:S4163:12Mar99 moved in if
49 //st = PR.ReadReal(PR.Current(), "Matrix Elements", temp);
50 if (PR.ReadReal(PR.Current(), temp))
51 aMatrix->SetValue(I, J, temp);
53 Message_Msg Msg215("XSTEP_215");
59 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
64 //=======================================================================
65 //function : WriteOwnParams
67 //=======================================================================
69 void IGESGeom_ToolTransformationMatrix::WriteOwnParams
70 (const Handle(IGESGeom_TransformationMatrix)& ent, IGESData_IGESWriter& IW) const
72 for (Standard_Integer I = 1; I <= 3; I++) {
73 for (Standard_Integer J = 1; J <= 4; J++) {
74 IW.Send(ent->Data(I, J));
80 //=======================================================================
81 //function : OwnShared
83 //=======================================================================
85 void IGESGeom_ToolTransformationMatrix::OwnShared
86 (const Handle(IGESGeom_TransformationMatrix)& /*ent*/, Interface_EntityIterator& /*iter*/) const
91 //=======================================================================
94 //=======================================================================
96 void IGESGeom_ToolTransformationMatrix::OwnCopy
97 (const Handle(IGESGeom_TransformationMatrix)& another,
98 const Handle(IGESGeom_TransformationMatrix)& ent, Interface_CopyTool& /*TC*/) const
100 Handle(TColStd_HArray2OfReal) data = new TColStd_HArray2OfReal(1, 3, 1, 4);
101 for (Standard_Integer I = 1; I <= 3;I++) {
102 for (Standard_Integer J = 1; J <= 4; J++) {
103 data->SetValue(I, J, another->Data(I, J));
108 ent->SetFormNumber(another->FormNumber());
112 //=======================================================================
113 //function : OwnCorrect
115 //=======================================================================
117 Standard_Boolean IGESGeom_ToolTransformationMatrix::OwnCorrect
118 (const Handle(IGESGeom_TransformationMatrix)& ent) const
120 if (ent->FormNumber() > 1) return Standard_False;
121 Standard_Integer cfn = (ent->Value().IsNegative() ? 1 : 0);
122 if (cfn == ent->FormNumber()) return Standard_False;
123 ent->SetFormNumber(cfn);
124 return Standard_True;
128 //=======================================================================
129 //function : DirChecker
131 //=======================================================================
133 IGESData_DirChecker IGESGeom_ToolTransformationMatrix::DirChecker
134 (const Handle(IGESGeom_TransformationMatrix)& /*ent*/) const
136 IGESData_DirChecker DC(124);
137 DC.Structure(IGESData_DefVoid);
138 DC.LineFont(IGESData_DefAny);
139 // DC.LineWeight(IGESData_DefAny);
140 DC.Color(IGESData_DefAny);
141 DC.BlankStatusIgnored();
142 DC.SubordinateStatusIgnored();
144 DC.HierarchyStatusIgnored();
150 //=======================================================================
151 //function : OwnCheck
153 //=======================================================================
155 void IGESGeom_ToolTransformationMatrix::OwnCheck
156 (const Handle(IGESGeom_TransformationMatrix)& ent,
157 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
160 // Building of messages
161 //========================================
162 //Message_Msg Msg71("XSTEP_71");
163 //========================================
165 Standard_Integer form = ent->FormNumber();
166 if ((form != 0) && (form != 1) && ((form < 10) || (form > 12))) {
167 Message_Msg Msg71("XSTEP_71");
168 ach->SendFail(Msg71);
170 // Theses messages are transfered in the translation procedure
172 if (form > 1) return; // ce qui suit : matrice orthogonale
173 if (form == 0 && ent->Value().IsNegative())
174 ach.AddFail("For Form 0, Determinant is not Positive");
175 else if (form == 1 && !ent->Value().IsNegative())
176 ach.AddFail("For Form 1, Determinant is not Negative");
178 Standard_Real p12 = ent->Data(1,1)*ent->Data(2,1) +
179 ent->Data(1,2)*ent->Data(2,2) + ent->Data(1,3)*ent->Data(2,3);
180 Standard_Real p13 = ent->Data(1,1)*ent->Data(3,1) +
181 ent->Data(1,2)*ent->Data(3,2) + ent->Data(1,3)*ent->Data(3,3);
182 Standard_Real p23 = ent->Data(2,1)*ent->Data(3,1) +
183 ent->Data(2,2)*ent->Data(3,2) + ent->Data(2,3)*ent->Data(3,3);
184 Standard_Real ep = 1.e-05; // ?? Tolorance des tests ?
185 if (p12 < -ep || p12 > ep || p13 < -ep || p13 > ep || p23 < -ep || p23 > ep)
186 ach.AddFail("Matrix is not orthogonal");
191 //=======================================================================
194 //=======================================================================
196 void IGESGeom_ToolTransformationMatrix::OwnDump
197 (const Handle(IGESGeom_TransformationMatrix)& ent, const IGESData_IGESDumper& /*dumper*/,
198 const Handle(Message_Messenger)& S, const Standard_Integer /*level*/) const
200 S << "IGESGeom_TransformationMatrix" << endl;
202 S << "| R11, R12, R13, T1 | "
203 << ent->Data(1, 1) << ", " << ent->Data(1, 2) << ", "
204 << ent->Data(1, 3) << ", " << ent->Data(1, 4) << endl;
206 S << "| R21, R22, R23, T2 | "
207 << ent->Data(2, 1) << ", " << ent->Data(2, 2) << ", "
208 << ent->Data(2, 3) << ", " << ent->Data(2, 4) << endl;
210 S << "| R31, R32, R33, T3 | "
211 << ent->Data(3, 1) << ", " << ent->Data(3, 2) << ", "
212 << ent->Data(3, 3) << ", " << ent->Data(3, 4) << endl;
214 switch (ent->FormNumber()) {
215 case 0 : S << "-- Direct Orthogonal Matrix" << endl; break;
216 case 1 : S << "-- Reverse Orthogonal Matrix" << endl; break;
217 case 10 : S << "-- Cartesien Coordinate System" << endl; break;
218 case 11 : S << "-- Cylindrical Coordinate System" << endl; break;
219 case 12 : S << "-- Spherical Coordinate System" << endl; break;
220 default : S << "-- (Incorrect Form Number)" << endl; break;