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_XYZ.hxx> |
20 | #include <IGESAppli_HArray1OfNode.hxx> |
21 | #include <IGESAppli_NodalDisplAndRot.hxx> |
7fd59977 |
22 | #include <IGESAppli_Node.hxx> |
42cf5bc1 |
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> |
7fd59977 |
32 | #include <IGESDimen_GeneralNote.hxx> |
33 | #include <IGESDimen_HArray1OfGeneralNote.hxx> |
42cf5bc1 |
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> |
7fd59977 |
41 | #include <TColgp_HArray1OfXYZ.hxx> |
7fd59977 |
42 | #include <TColStd_HArray1OfInteger.hxx> |
7fd59977 |
43 | |
44 | IGESAppli_ToolNodalDisplAndRot::IGESAppli_ToolNodalDisplAndRot () { } |
45 | |
46 | |
47 | void IGESAppli_ToolNodalDisplAndRot::ReadOwnParams |
48 | (const Handle(IGESAppli_NodalDisplAndRot)& ent, |
49 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
50 | { |
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 ; |
59 | |
60 | Standard_Boolean tempFlag = PR.ReadInteger(PR.Current(),"No. of analysis cases",nbcases); |
61 | if (tempFlag) { |
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); |
68 | } |
69 | } |
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); |
83 | |
84 | Handle(TColgp_HArray1OfXYZ) tempArray1; |
85 | Handle(TColgp_HArray1OfXYZ) tempArray; |
86 | if (tempFlag) { |
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++) { |
91 | gp_XYZ atrans,arot; |
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); |
96 | } |
97 | } |
98 | tempTransParam->SetValue(j,tempArray); |
99 | tempRotParam->SetValue(j,tempArray1); |
100 | } |
101 | } |
102 | |
103 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
104 | ent->Init(tempNotes,tempNodeIdentifiers,tempNodes,tempRotParam,tempTransParam); |
105 | } |
106 | |
107 | void IGESAppli_ToolNodalDisplAndRot::WriteOwnParams |
108 | (const Handle(IGESAppli_NodalDisplAndRot)& ent, IGESData_IGESWriter& IW) const |
109 | { |
110 | Standard_Integer nbcases = ent->NbCases(); |
111 | Standard_Integer nbnodes = ent->NbNodes(); |
112 | |
113 | IW.Send(nbcases); |
114 | for (Standard_Integer i = 1; i <= nbcases; i ++) |
115 | IW.Send(ent->Note(i)); |
116 | IW.Send(nbnodes); |
117 | for (Standard_Integer j = 1; j <= nbnodes; j ++) |
118 | { |
119 | IW.Send(ent->NodeIdentifier(j)); |
120 | IW.Send(ent->Node(j)); |
121 | for (Standard_Integer k = 1; k <= nbcases; k ++) |
122 | { |
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()); |
129 | } |
130 | } |
131 | } |
132 | |
133 | void IGESAppli_ToolNodalDisplAndRot::OwnShared |
134 | (const Handle(IGESAppli_NodalDisplAndRot)& ent, Interface_EntityIterator& iter) const |
135 | { |
136 | Standard_Integer nbcases = ent->NbCases(); |
137 | Standard_Integer nbnodes = ent->NbNodes(); |
138 | |
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)); |
143 | } |
144 | |
145 | void IGESAppli_ToolNodalDisplAndRot::OwnCopy |
146 | (const Handle(IGESAppli_NodalDisplAndRot)& another, |
147 | const Handle(IGESAppli_NodalDisplAndRot)& ent, Interface_CopyTool& TC) const |
148 | { |
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); |
161 | |
162 | for (Standard_Integer i=1 ;i <=nbnodes; i++) |
163 | { |
164 | aNodeIdentifiers->SetValue(i,(another->NodeIdentifier(i))); |
165 | DeclareAndCast(IGESAppli_Node,anitem,TC.Transferred(another->Node(i))); |
166 | aNodes->SetValue(i,anitem); |
167 | } |
168 | for (Standard_Integer j=1 ;j <=nbcases; j++) |
169 | { |
170 | DeclareAndCast |
171 | (IGESDimen_GeneralNote,anitem,TC.Transferred(another->Note(j))); |
172 | aNotes->SetValue(j,anitem); |
173 | } |
174 | for (Standard_Integer n=1 ;n <=nbnodes; n++) |
175 | { |
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++) |
181 | { |
182 | tempArray1->SetValue(k,another->TranslationParameter(n,k)); |
183 | tempArray2->SetValue(k,another->RotationalParameter(n,k)); |
184 | } |
185 | aTransParam->SetValue(n,tempArray1); |
186 | aRotParam->SetValue(n,tempArray2); |
187 | } |
188 | |
189 | ent->Init(aNotes,aNodeIdentifiers,aNodes,aRotParam,aTransParam); |
190 | } |
191 | |
192 | IGESData_DirChecker IGESAppli_ToolNodalDisplAndRot::DirChecker |
193 | (const Handle(IGESAppli_NodalDisplAndRot)& /* ent */ ) const |
194 | { |
195 | IGESData_DirChecker DC(138,0); //Form no = 0 & Type = 138 |
196 | DC.Structure(IGESData_DefVoid); |
197 | DC.GraphicsIgnored(); |
198 | DC.HierarchyStatusIgnored(); |
199 | return DC; |
200 | } |
201 | |
202 | void IGESAppli_ToolNodalDisplAndRot::OwnCheck |
203 | (const Handle(IGESAppli_NodalDisplAndRot)& /* ent */, |
204 | const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const |
205 | { |
206 | } |
207 | |
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 |
211 | { |
212 | S << "IGESAppli_NodalDisplAndRot" << endl; |
213 | |
214 | Standard_Integer nbcases = ent->NbCases(); |
215 | Standard_Integer nbnodes = ent->NbNodes(); |
216 | |
217 | S << "No. of analysis cases : " << nbcases << endl; |
218 | S << "General Notes : "; |
219 | IGESData_DumpEntities(S,dumper ,level,1, nbcases,ent->Note); |
220 | S << endl; |
221 | |
222 | // gp_GTrsf loca; // true location n.u. |
223 | switch (level) |
224 | { |
225 | case 4: |
226 | S << "Nodes : "; |
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" << endl; |
236 | break; |
237 | case 5: |
238 | case 6: { |
239 | for (Standard_Integer i = 1; i <= nbcases; i ++) |
240 | { |
241 | S << "[" << i << "]: "; |
242 | dumper.Dump (ent->Note(i),S, 1); |
243 | S << endl; |
244 | } |
245 | S << "Nodes : " << endl; |
246 | S << "Node Identifiers : " << endl; |
247 | S << "Translation Parameters : " << endl; |
248 | S << "Rotational Parameters : Count = " << nbcases; |
249 | // IGESData_DumpListXYZL(S,-level,1,nbcases,ent->RotationalParameter,loca); |
250 | S << endl; |
251 | for (Standard_Integer j = 1; j <= nbnodes; j ++) |
252 | { |
253 | S << "[" << j << "]: - NodeIdentifier : " |
254 | << ent->NodeIdentifier(j) << " - Node :"<<endl; ; |
255 | S << "Node : "; |
256 | dumper.Dump (ent->Node(j),S, 1); |
257 | S << " - Parameters : " << endl; |
258 | for (Standard_Integer k = 1; k <= nbcases; k ++) |
259 | { |
260 | S << " [" << k << "]: " << endl; |
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() << endl; |
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 << endl; |
271 | } |
272 | } |
273 | } |
274 | break; |
275 | default: break; |
276 | } |
277 | S << endl; |
278 | } |