1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
20 #include <IGESAppli_HArray1OfNode.hxx>
21 #include <IGESAppli_NodalDisplAndRot.hxx>
22 #include <IGESAppli_Node.hxx>
23 #include <IGESAppli_ToolNodalDisplAndRot.hxx>
24 #include <IGESBasic_HArray1OfHArray1OfXYZ.hxx>
25 #include <IGESData_DirChecker.hxx>
26 #include <IGESData_Dump.hxx>
27 #include <IGESData_IGESDumper.hxx>
28 #include <IGESData_IGESReaderData.hxx>
29 #include <IGESData_IGESWriter.hxx>
30 #include <IGESData_ParamCursor.hxx>
31 #include <IGESData_ParamReader.hxx>
32 #include <IGESDimen_GeneralNote.hxx>
33 #include <IGESDimen_HArray1OfGeneralNote.hxx>
34 #include <Interface_Check.hxx>
35 #include <Interface_CopyTool.hxx>
36 #include <Interface_EntityIterator.hxx>
37 #include <Interface_Macros.hxx>
38 #include <Interface_ShareTool.hxx>
39 #include <Message_Messenger.hxx>
40 #include <Standard_DomainError.hxx>
41 #include <TColgp_HArray1OfXYZ.hxx>
42 #include <TColStd_HArray1OfInteger.hxx>
44 IGESAppli_ToolNodalDisplAndRot::IGESAppli_ToolNodalDisplAndRot () { }
47 void IGESAppli_ToolNodalDisplAndRot::ReadOwnParams
48 (const Handle(IGESAppli_NodalDisplAndRot)& ent,
49 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
51 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
52 Standard_Integer nbcases = 0;
53 Standard_Integer nbnodes = 0;
54 Handle(IGESDimen_HArray1OfGeneralNote) tempNotes ;
55 Handle(TColStd_HArray1OfInteger) tempNodeIdentifiers ;
56 Handle(IGESAppli_HArray1OfNode) tempNodes;
57 Handle(IGESBasic_HArray1OfHArray1OfXYZ) tempTransParam ;
58 Handle(IGESBasic_HArray1OfHArray1OfXYZ) tempRotParam ;
60 Standard_Boolean tempFlag = PR.ReadInteger(PR.Current(),"No. of analysis cases",nbcases);
62 tempNotes = new IGESDimen_HArray1OfGeneralNote(1,nbcases);
63 for (Standard_Integer i=1; i <= nbcases; i++) {
64 Handle(IGESDimen_GeneralNote) anentity;
65 //szv#4:S4163:12Mar99 moved in if
66 if (PR.ReadEntity(IR,PR.Current(),"General Note", STANDARD_TYPE(IGESDimen_GeneralNote), anentity))
67 tempNotes->SetValue(i,anentity);
70 //szv#4:S4163:12Mar99 moved in if
71 if (PR.ReadInteger(PR.Current(),"No. of nodes",nbnodes)) {
72 tempNodeIdentifiers = new TColStd_HArray1OfInteger(1,nbnodes);
73 tempNodes = new IGESAppli_HArray1OfNode(1,nbnodes);
74 tempTransParam = new IGESBasic_HArray1OfHArray1OfXYZ(1, nbnodes);
75 tempRotParam = new IGESBasic_HArray1OfHArray1OfXYZ(1, nbnodes);
76 for (Standard_Integer j=1; j <=nbnodes; j++) {
77 Handle(IGESAppli_Node) aNode = new IGESAppli_Node();
78 Standard_Integer nodeno;
79 if (PR.ReadInteger( PR.Current(), "Node number", nodeno))
80 tempNodeIdentifiers->SetValue(j,nodeno);
81 if (PR.ReadEntity(IR,PR.Current(),"Node Directory Entry", STANDARD_TYPE(IGESAppli_Node), aNode))
82 tempNodes->SetValue(j,aNode);
84 Handle(TColgp_HArray1OfXYZ) tempArray1;
85 Handle(TColgp_HArray1OfXYZ) tempArray;
87 // tempFlag indicates if nbcases has been properly read
88 tempArray1 = new TColgp_HArray1OfXYZ(1,nbcases);
89 tempArray = new TColgp_HArray1OfXYZ(1,nbcases);
90 for (Standard_Integer k = 1; k <= nbcases; k++) {
92 if (PR.ReadXYZ(PR.CurrentList(1,3),"Translation XYZ",atrans))
93 tempArray->SetValue(k,atrans);
94 if (PR.ReadXYZ(PR.CurrentList(1,3),"Rotational XYZ",arot))
95 tempArray1->SetValue(k,arot);
98 tempTransParam->SetValue(j,tempArray);
99 tempRotParam->SetValue(j,tempArray1);
103 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
104 ent->Init(tempNotes,tempNodeIdentifiers,tempNodes,tempRotParam,tempTransParam);
107 void IGESAppli_ToolNodalDisplAndRot::WriteOwnParams
108 (const Handle(IGESAppli_NodalDisplAndRot)& ent, IGESData_IGESWriter& IW) const
110 Standard_Integer nbcases = ent->NbCases();
111 Standard_Integer nbnodes = ent->NbNodes();
114 for (Standard_Integer i = 1; i <= nbcases; i ++)
115 IW.Send(ent->Note(i));
117 for (Standard_Integer j = 1; j <= nbnodes; j ++)
119 IW.Send(ent->NodeIdentifier(j));
120 IW.Send(ent->Node(j));
121 for (Standard_Integer k = 1; k <= nbcases; k ++)
123 IW.Send(ent->TranslationParameter(j,k).X());
124 IW.Send(ent->TranslationParameter(j,k).Y());
125 IW.Send(ent->TranslationParameter(j,k).Z());
126 IW.Send(ent->RotationalParameter(j,k).X());
127 IW.Send(ent->RotationalParameter(j,k).Y());
128 IW.Send(ent->RotationalParameter(j,k).Z());
133 void IGESAppli_ToolNodalDisplAndRot::OwnShared
134 (const Handle(IGESAppli_NodalDisplAndRot)& ent, Interface_EntityIterator& iter) const
136 Standard_Integer nbcases = ent->NbCases();
137 Standard_Integer nbnodes = ent->NbNodes();
139 for (Standard_Integer i = 1; i <= nbcases; i ++)
140 iter.GetOneItem(ent->Note(i));
141 for (Standard_Integer j = 1; j <= nbnodes; j ++)
142 iter.GetOneItem(ent->Node(j));
145 void IGESAppli_ToolNodalDisplAndRot::OwnCopy
146 (const Handle(IGESAppli_NodalDisplAndRot)& another,
147 const Handle(IGESAppli_NodalDisplAndRot)& ent, Interface_CopyTool& TC) const
149 Standard_Integer nbcases = another->NbCases();
150 Standard_Integer nbnodes = another->NbNodes();
151 Handle(IGESDimen_HArray1OfGeneralNote) aNotes =
152 new IGESDimen_HArray1OfGeneralNote(1,nbcases);
153 Handle(TColStd_HArray1OfInteger) aNodeIdentifiers =
154 new TColStd_HArray1OfInteger(1,nbnodes);
155 Handle(IGESAppli_HArray1OfNode) aNodes =
156 new IGESAppli_HArray1OfNode(1,nbnodes);
157 Handle(IGESBasic_HArray1OfHArray1OfXYZ) aTransParam =
158 new IGESBasic_HArray1OfHArray1OfXYZ(1, nbnodes);
159 Handle(IGESBasic_HArray1OfHArray1OfXYZ) aRotParam =
160 new IGESBasic_HArray1OfHArray1OfXYZ(1, nbnodes);
162 for (Standard_Integer i=1 ;i <=nbnodes; i++)
164 aNodeIdentifiers->SetValue(i,(another->NodeIdentifier(i)));
165 DeclareAndCast(IGESAppli_Node,anitem,TC.Transferred(another->Node(i)));
166 aNodes->SetValue(i,anitem);
168 for (Standard_Integer j=1 ;j <=nbcases; j++)
171 (IGESDimen_GeneralNote,anitem,TC.Transferred(another->Note(j)));
172 aNotes->SetValue(j,anitem);
174 for (Standard_Integer n=1 ;n <=nbnodes; n++)
176 Handle(TColgp_HArray1OfXYZ) tempArray1 = new
177 TColgp_HArray1OfXYZ(1,nbcases);
178 Handle(TColgp_HArray1OfXYZ) tempArray2 = new
179 TColgp_HArray1OfXYZ(1,nbcases);
180 for (Standard_Integer k=1;k<= nbcases;k++)
182 tempArray1->SetValue(k,another->TranslationParameter(n,k));
183 tempArray2->SetValue(k,another->RotationalParameter(n,k));
185 aTransParam->SetValue(n,tempArray1);
186 aRotParam->SetValue(n,tempArray2);
189 ent->Init(aNotes,aNodeIdentifiers,aNodes,aRotParam,aTransParam);
192 IGESData_DirChecker IGESAppli_ToolNodalDisplAndRot::DirChecker
193 (const Handle(IGESAppli_NodalDisplAndRot)& /* ent */ ) const
195 IGESData_DirChecker DC(138,0); //Form no = 0 & Type = 138
196 DC.Structure(IGESData_DefVoid);
197 DC.GraphicsIgnored();
198 DC.HierarchyStatusIgnored();
202 void IGESAppli_ToolNodalDisplAndRot::OwnCheck
203 (const Handle(IGESAppli_NodalDisplAndRot)& /* ent */,
204 const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
208 void IGESAppli_ToolNodalDisplAndRot::OwnDump
209 (const Handle(IGESAppli_NodalDisplAndRot)& ent, const IGESData_IGESDumper& dumper,
210 const Handle(Message_Messenger)& S, const Standard_Integer level) const
212 S << "IGESAppli_NodalDisplAndRot" << Message_EndLine;
214 Standard_Integer nbcases = ent->NbCases();
215 Standard_Integer nbnodes = ent->NbNodes();
217 S << "No. of analysis cases : " << nbcases << Message_EndLine;
218 S << "General Notes : ";
219 IGESData_DumpEntities(S,dumper ,level,1, nbcases,ent->Note);
220 S << Message_EndLine;
222 // gp_GTrsf loca; // true location n.u.
227 IGESData_DumpEntities(S,dumper,-level,1, nbnodes,ent->Node);
228 S << "NodeIdentifiers : ";
229 IGESData_DumpVals(S,-level,1, nbnodes,ent->NodeIdentifier);
230 S << "Translation Parameters : ";
231 // ?? Possibly JAGGED ??
232 // IGESData_DumpListXYZL(S,-level,1,nbcases,ent->TranslationParameter,loca);
233 S << "Rotational Parameters : ";
234 // IGESData_DumpListXYZL(S,-level,1,nbcases,ent->RotationalParameter,loca);
235 S << " TO BE DONE" << Message_EndLine;
239 for (Standard_Integer i = 1; i <= nbcases; i ++)
241 S << "[" << i << "]: ";
242 dumper.Dump (ent->Note(i),S, 1);
243 S << Message_EndLine;
245 S << "Nodes : " << Message_EndLine;
246 S << "Node Identifiers : " << Message_EndLine;
247 S << "Translation Parameters : " << Message_EndLine;
248 S << "Rotational Parameters : Count = " << nbcases;
249 // IGESData_DumpListXYZL(S,-level,1,nbcases,ent->RotationalParameter,loca);
250 S << Message_EndLine;
251 for (Standard_Integer j = 1; j <= nbnodes; j ++)
253 S << "[" << j << "]: - NodeIdentifier : "
254 << ent->NodeIdentifier(j) << " - Node :"<<Message_EndLine; ;
256 dumper.Dump (ent->Node(j),S, 1);
257 S << " - Parameters : " << Message_EndLine;
258 for (Standard_Integer k = 1; k <= nbcases; k ++)
260 S << " [" << k << "]: " << Message_EndLine;
261 S << "Translational Parameter : X="
262 << ent->TranslationParameter(j,k).X() << ", Y="
263 << ent->TranslationParameter(j,k).Y() << ", Z="
264 << ent->TranslationParameter(j,k).Z() << Message_EndLine;
265 S << "Rotational Parameter : X="
266 << ent->RotationalParameter(j,k).X() << ", Y="
267 << ent->RotationalParameter(j,k).Y() << ", Z="
268 << ent->RotationalParameter(j,k).Z();
269 if (k == nbcases) S << "] ";
270 S << Message_EndLine;
277 S << Message_EndLine;