Integration of OCCT 6.5.0 from SVN
[occt.git] / src / IGESAppli / IGESAppli_ToolNodalResults.cxx
1 //--------------------------------------------------------------------
2 //
3 //  File Name : IGESAppli_NodalResults.cxx
4 //  Date      :
5 //  Author    : CKY / Contract Toubro-Larsen
6 //  Copyright : MATRA-DATAVISION 1993
7 //
8 //--------------------------------------------------------------------
9
10 #include <IGESAppli_ToolNodalResults.ixx>
11 #include <IGESData_ParamCursor.hxx>
12 #include <IGESDimen_GeneralNote.hxx>
13 #include <IGESAppli_Node.hxx>
14 #include <IGESAppli_HArray1OfNode.hxx>
15 #include <TColStd_HArray1OfInteger.hxx>
16 #include <TColStd_HArray1OfReal.hxx>
17 #include <TColStd_HArray2OfReal.hxx>
18 #include <IGESData_Dump.hxx>
19 #include <Interface_Macros.hxx>
20
21
22 IGESAppli_ToolNodalResults::IGESAppli_ToolNodalResults ()    {  }
23
24
25 void  IGESAppli_ToolNodalResults::ReadOwnParams
26   (const Handle(IGESAppli_NodalResults)& ent,
27    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
28 {
29   Standard_Integer tempSubCaseNum = 0;
30   Standard_Real tempTime;
31   Standard_Integer nbval = 0;
32   Standard_Integer nbnodes = 0;
33   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
34   Handle(IGESDimen_GeneralNote) tempNote;
35   Handle(TColStd_HArray2OfReal) tempData ;
36   Handle(IGESAppli_HArray1OfNode) tempNodes ;
37   Handle(TColStd_HArray1OfInteger) tempNodeIdentifiers ;
38
39   //szv#4:S4163:12Mar99 `st=` not needed
40   PR.ReadEntity(IR,PR.Current(),"General Note describing the analysis case",
41                 STANDARD_TYPE(IGESDimen_GeneralNote), tempNote);
42   PR.ReadInteger (PR.Current(),"Subcase number",tempSubCaseNum);
43   PR.ReadReal(PR.Current(),"Analysis time used",tempTime);
44   Standard_Boolean tempFlag = PR.ReadInteger(PR.Current(),"No. of values",nbval);
45   //szv#4:S4163:12Mar99 moved in if
46   if (PR.ReadInteger(PR.Current(),"No. of nodes",nbnodes)) {
47     tempData  = new TColStd_HArray2OfReal(1,nbnodes,1,nbval);
48     tempNodes = new IGESAppli_HArray1OfNode(1,nbnodes);
49     tempNodeIdentifiers = new TColStd_HArray1OfInteger(1,nbnodes);
50     for (Standard_Integer i = 1; i <= nbnodes; i ++) {
51       Standard_Integer aitem;
52       //Check  whether nbval properly read or not.
53       Handle(IGESAppli_Node) aNode ;
54
55       if (PR.ReadInteger(PR.Current(),"Node no. identifier",aitem))
56         tempNodeIdentifiers->SetValue(i,aitem);
57       if (PR.ReadEntity(IR,PR.Current(),"FEM Node", STANDARD_TYPE(IGESAppli_Node), aNode))
58         tempNodes->SetValue(i,aNode);
59       if (tempFlag)
60         //Check  whether nbval properly read or not.
61         for (Standard_Integer j = 1; j <= nbval; j ++) {
62           Standard_Real aval;
63           if (PR.ReadReal(PR.Current(),"Value",aval))
64             tempData->SetValue(i,j,aval);
65         }
66     }
67   }
68   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
69   ent->Init(tempNote,tempSubCaseNum,tempTime,tempNodeIdentifiers,tempNodes,tempData);
70 }
71
72 void  IGESAppli_ToolNodalResults::WriteOwnParams
73   (const Handle(IGESAppli_NodalResults)& ent, IGESData_IGESWriter& IW) const
74 {
75   Standard_Integer nbnodes = ent->NbNodes();
76   Standard_Integer nbdata  = ent->NbData ();
77   IW.Send(ent->Note());
78   IW.Send(ent->SubCaseNumber());
79   IW.Send(ent->Time());
80   IW.Send(nbdata);
81   IW.Send(nbnodes);
82   for (Standard_Integer i = 1; i <= nbnodes; i++)
83     {
84       IW.Send(ent->NodeIdentifier(i));
85       IW.Send(ent->Node(i));
86       for (Standard_Integer j = 1; j <= nbdata; j++)
87         IW.Send(ent->Data(i,j));
88     }
89 }
90
91 void  IGESAppli_ToolNodalResults::OwnShared
92   (const Handle(IGESAppli_NodalResults)& ent, Interface_EntityIterator& iter) const
93 {
94   Standard_Integer nbnodes = ent->NbNodes();
95   iter.GetOneItem(ent->Note());
96   for (Standard_Integer i = 1; i <= nbnodes; i++)
97     iter.GetOneItem(ent->Node(i));
98 }
99
100 void  IGESAppli_ToolNodalResults::OwnCopy
101   (const Handle(IGESAppli_NodalResults)& another,
102    const Handle(IGESAppli_NodalResults)& ent, Interface_CopyTool& TC) const
103 {
104   DeclareAndCast(IGESDimen_GeneralNote,aNote,TC.Transferred(another->Note()));
105   Standard_Integer aSubCaseNum = another->SubCaseNumber();
106   Standard_Real aTime = another->Time();
107   Standard_Integer nbnodes = another->NbNodes();
108   Standard_Integer nbval = another->NbData();
109   Handle(TColStd_HArray1OfInteger) aNodeIdentifiers =
110     new TColStd_HArray1OfInteger(1,nbnodes);
111   Handle(IGESAppli_HArray1OfNode) aNodes =
112     new IGESAppli_HArray1OfNode(1,nbnodes);
113   Handle(TColStd_HArray2OfReal) aData =
114     new TColStd_HArray2OfReal(1,nbnodes,1,nbval);
115
116   for (Standard_Integer i=1; i <= nbnodes; i++)
117     {
118       Standard_Integer aItem = another->NodeIdentifier(i);
119       aNodeIdentifiers->SetValue(i,aItem);
120       DeclareAndCast(IGESAppli_Node,anentity,TC.Transferred(another->Node(i)));
121       aNodes->SetValue(i,anentity);
122       for (Standard_Integer j=1; j <= nbval; j++)
123         aData->SetValue(i,j, another->Data(i,j));
124     }
125
126   ent->Init(aNote,aSubCaseNum,aTime,aNodeIdentifiers,aNodes,aData);
127   ent->SetFormNumber(another->FormNumber());
128 }
129
130 IGESData_DirChecker  IGESAppli_ToolNodalResults::DirChecker
131   (const Handle(IGESAppli_NodalResults)& /* ent */ ) const
132 {
133   IGESData_DirChecker DC(146,0,34);  // Type = 146 Form No. = 0 to 34
134   DC.Structure(IGESData_DefVoid);
135   DC.LineFont(IGESData_DefVoid);
136   DC.LineWeight(IGESData_DefVoid);
137   DC.Color(IGESData_DefAny);
138   DC.BlankStatusIgnored();
139   DC.UseFlagRequired(03);
140   DC.HierarchyStatusIgnored();
141   return DC;
142 }
143
144 void  IGESAppli_ToolNodalResults::OwnCheck
145   (const Handle(IGESAppli_NodalResults)& ent,
146    const Interface_ShareTool& , Handle(Interface_Check)& ach) const
147 {
148   Standard_Integer FormNum = ent->FormNumber();
149   Standard_Integer nv = ent->NbData();
150   Standard_Boolean OK = Standard_True;
151   switch (FormNum) {
152     case  0 : if (nv <  0) OK = Standard_False;  break;
153     case  1 : if (nv != 1) OK = Standard_False;  break;
154     case  2 : if (nv != 1) OK = Standard_False;  break;
155     case  3 : if (nv != 3) OK = Standard_False;  break;
156     case  4 : if (nv != 6) OK = Standard_False;  break;
157     case  5 : if (nv != 3) OK = Standard_False;  break;
158     case  6 : if (nv != 3) OK = Standard_False;  break;
159     case  7 : if (nv != 3) OK = Standard_False;  break;
160     case  8 : if (nv != 3) OK = Standard_False;  break;
161     case  9 : if (nv != 3) OK = Standard_False;  break;
162     case 10 : if (nv != 1) OK = Standard_False;  break;
163     case 11 : if (nv != 1) OK = Standard_False;  break;
164     case 12 : if (nv != 3) OK = Standard_False;  break;
165     case 13 : if (nv != 1) OK = Standard_False;  break;
166     case 14 : if (nv != 1) OK = Standard_False;  break;
167     case 15 : if (nv != 3) OK = Standard_False;  break;
168     case 16 : if (nv != 1) OK = Standard_False;  break;
169     case 17 : if (nv != 3) OK = Standard_False;  break;
170     case 18 : if (nv != 3) OK = Standard_False;  break;
171     case 19 : if (nv != 3) OK = Standard_False;  break;
172     case 20 : if (nv != 3) OK = Standard_False;  break;
173     case 21 : if (nv != 3) OK = Standard_False;  break;
174     case 22 : if (nv != 3) OK = Standard_False;  break;
175     case 23 : if (nv != 6) OK = Standard_False;  break;
176     case 24 : if (nv != 6) OK = Standard_False;  break;
177     case 25 : if (nv != 6) OK = Standard_False;  break;
178     case 26 : if (nv != 6) OK = Standard_False;  break;
179     case 27 : if (nv != 6) OK = Standard_False;  break;
180     case 28 : if (nv != 6) OK = Standard_False;  break;
181     case 29 : if (nv != 9) OK = Standard_False;  break;
182     case 30 : if (nv != 9) OK = Standard_False;  break;
183     case 31 : if (nv != 9) OK = Standard_False;  break;
184     case 32 : if (nv != 9) OK = Standard_False;  break;
185     case 33 : if (nv != 9) OK = Standard_False;  break;
186     case 34 : if (nv != 9) OK = Standard_False;  break;
187     default : ach->AddFail("Incorrect Form Number");    break;
188   }
189   if (!OK) ach->AddFail
190     ("Incorrect count of real values in array V for FEM node");
191 }
192
193 void  IGESAppli_ToolNodalResults::OwnDump
194   (const Handle(IGESAppli_NodalResults)& ent, const IGESData_IGESDumper& dumper,
195    const Handle(Message_Messenger)& S, const Standard_Integer level) const
196 {
197 //  Standard_Integer nbnodes = ent->NbNodes();
198 //  Standard_Integer nbdata  = ent->NbData ();
199   S << "IGESAppli_NodalResults" << endl;
200
201   S << "General Note : ";
202   dumper.Dump(ent->Note(),S, (level <= 4) ? 0 : 1);
203   S << endl;
204   S << "Analysis subcase number : " << ent->SubCaseNumber() << "  ";
205   S << "Time used : " << ent->Time() << endl;
206   S << "No. of nodes : " << ent->NbNodes() << "  ";
207   S << "No. of values for a node : " << ent->NbData() << endl;
208   S << "Node Identifiers : " << endl;
209   S << "Nodes : " << endl;
210   S << "Data : ";  if (level < 6) S << " [ask level > 5]";
211 //  IGESData_DumpRectVals(S ,-level,1, ent->NbData(),ent->Data);
212   S << endl;
213   if (level > 4)
214     {
215       for (Standard_Integer i=1; i <= ent->NbNodes(); i++)
216         {
217           S << "[" << i << "]: ";
218           S << "NodeIdentifier : " << ent->NodeIdentifier(i) << "  ";
219           S << "Node : ";
220           dumper.Dump (ent->Node(i),S, 1);
221           S << endl;
222           if (level < 6) continue;
223           S << "Data : [ ";
224           for (Standard_Integer j = 1; j <= ent->NbData(); j ++)
225               S << "  " << ent->Data(i,j);
226           S << " ]" << endl;
227         }
228     }
229 }