summaryrefslogtreecommitdiff
path: root/src/IGESAppli/IGESAppli_ToolNodalResults.cxx
blob: 568941166f4567ea9736ac347c5007812e35a6b5 (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
223
224
225
226
227
228
229
//--------------------------------------------------------------------
//
//  File Name : IGESAppli_NodalResults.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESAppli_ToolNodalResults.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESDimen_GeneralNote.hxx>
#include <IGESAppli_Node.hxx>
#include <IGESAppli_HArray1OfNode.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray2OfReal.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>


IGESAppli_ToolNodalResults::IGESAppli_ToolNodalResults ()    {  }


void  IGESAppli_ToolNodalResults::ReadOwnParams
  (const Handle(IGESAppli_NodalResults)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{
  Standard_Integer tempSubCaseNum = 0;
  Standard_Real tempTime;
  Standard_Integer nbval = 0;
  Standard_Integer nbnodes = 0;
  //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
  Handle(IGESDimen_GeneralNote) tempNote;
  Handle(TColStd_HArray2OfReal) tempData ;
  Handle(IGESAppli_HArray1OfNode) tempNodes ;
  Handle(TColStd_HArray1OfInteger) tempNodeIdentifiers ;

  //szv#4:S4163:12Mar99 `st=` not needed
  PR.ReadEntity(IR,PR.Current(),"General Note describing the analysis case",
		STANDARD_TYPE(IGESDimen_GeneralNote), tempNote);
  PR.ReadInteger (PR.Current(),"Subcase number",tempSubCaseNum);
  PR.ReadReal(PR.Current(),"Analysis time used",tempTime);
  Standard_Boolean tempFlag = PR.ReadInteger(PR.Current(),"No. of values",nbval);
  //szv#4:S4163:12Mar99 moved in if
  if (PR.ReadInteger(PR.Current(),"No. of nodes",nbnodes)) {
    tempData  = new TColStd_HArray2OfReal(1,nbnodes,1,nbval);
    tempNodes = new IGESAppli_HArray1OfNode(1,nbnodes);
    tempNodeIdentifiers = new TColStd_HArray1OfInteger(1,nbnodes);
    for (Standard_Integer i = 1; i <= nbnodes; i ++) {
      Standard_Integer aitem;
      //Check  whether nbval properly read or not.
      Handle(IGESAppli_Node) aNode ;

      if (PR.ReadInteger(PR.Current(),"Node no. identifier",aitem))
	tempNodeIdentifiers->SetValue(i,aitem);
      if (PR.ReadEntity(IR,PR.Current(),"FEM Node", STANDARD_TYPE(IGESAppli_Node), aNode))
	tempNodes->SetValue(i,aNode);
      if (tempFlag)
	//Check  whether nbval properly read or not.
	for (Standard_Integer j = 1; j <= nbval; j ++) {
	  Standard_Real aval;
	  if (PR.ReadReal(PR.Current(),"Value",aval))
	    tempData->SetValue(i,j,aval);
	}
    }
  }
  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init(tempNote,tempSubCaseNum,tempTime,tempNodeIdentifiers,tempNodes,tempData);
}

void  IGESAppli_ToolNodalResults::WriteOwnParams
  (const Handle(IGESAppli_NodalResults)& ent, IGESData_IGESWriter& IW) const
{
  Standard_Integer nbnodes = ent->NbNodes();
  Standard_Integer nbdata  = ent->NbData ();
  IW.Send(ent->Note());
  IW.Send(ent->SubCaseNumber());
  IW.Send(ent->Time());
  IW.Send(nbdata);
  IW.Send(nbnodes);
  for (Standard_Integer i = 1; i <= nbnodes; i++)
    {
      IW.Send(ent->NodeIdentifier(i));
      IW.Send(ent->Node(i));
      for (Standard_Integer j = 1; j <= nbdata; j++)
	IW.Send(ent->Data(i,j));
    }
}

void  IGESAppli_ToolNodalResults::OwnShared
  (const Handle(IGESAppli_NodalResults)& ent, Interface_EntityIterator& iter) const
{
  Standard_Integer nbnodes = ent->NbNodes();
  iter.GetOneItem(ent->Note());
  for (Standard_Integer i = 1; i <= nbnodes; i++)
    iter.GetOneItem(ent->Node(i));
}

void  IGESAppli_ToolNodalResults::OwnCopy
  (const Handle(IGESAppli_NodalResults)& another,
   const Handle(IGESAppli_NodalResults)& ent, Interface_CopyTool& TC) const
{
  DeclareAndCast(IGESDimen_GeneralNote,aNote,TC.Transferred(another->Note()));
  Standard_Integer aSubCaseNum = another->SubCaseNumber();
  Standard_Real aTime = another->Time();
  Standard_Integer nbnodes = another->NbNodes();
  Standard_Integer nbval = another->NbData();
  Handle(TColStd_HArray1OfInteger) aNodeIdentifiers =
    new TColStd_HArray1OfInteger(1,nbnodes);
  Handle(IGESAppli_HArray1OfNode) aNodes =
    new IGESAppli_HArray1OfNode(1,nbnodes);
  Handle(TColStd_HArray2OfReal) aData =
    new TColStd_HArray2OfReal(1,nbnodes,1,nbval);

  for (Standard_Integer i=1; i <= nbnodes; i++)
    {
      Standard_Integer aItem = another->NodeIdentifier(i);
      aNodeIdentifiers->SetValue(i,aItem);
      DeclareAndCast(IGESAppli_Node,anentity,TC.Transferred(another->Node(i)));
      aNodes->SetValue(i,anentity);
      for (Standard_Integer j=1; j <= nbval; j++)
	aData->SetValue(i,j, another->Data(i,j));
    }

  ent->Init(aNote,aSubCaseNum,aTime,aNodeIdentifiers,aNodes,aData);
  ent->SetFormNumber(another->FormNumber());
}

IGESData_DirChecker  IGESAppli_ToolNodalResults::DirChecker
  (const Handle(IGESAppli_NodalResults)& /* ent */ ) const
{
  IGESData_DirChecker DC(146,0,34);  // Type = 146 Form No. = 0 to 34
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefVoid);
  DC.LineWeight(IGESData_DefVoid);
  DC.Color(IGESData_DefAny);
  DC.BlankStatusIgnored();
  DC.UseFlagRequired(03);
  DC.HierarchyStatusIgnored();
  return DC;
}

void  IGESAppli_ToolNodalResults::OwnCheck
  (const Handle(IGESAppli_NodalResults)& ent,
   const Interface_ShareTool& , Handle(Interface_Check)& ach) const
{
  Standard_Integer FormNum = ent->FormNumber();
  Standard_Integer nv = ent->NbData();
  Standard_Boolean OK = Standard_True;
  switch (FormNum) {
    case  0 : if (nv <  0) OK = Standard_False;  break;
    case  1 : if (nv != 1) OK = Standard_False;  break;
    case  2 : if (nv != 1) OK = Standard_False;  break;
    case  3 : if (nv != 3) OK = Standard_False;  break;
    case  4 : if (nv != 6) OK = Standard_False;  break;
    case  5 : if (nv != 3) OK = Standard_False;  break;
    case  6 : if (nv != 3) OK = Standard_False;  break;
    case  7 : if (nv != 3) OK = Standard_False;  break;
    case  8 : if (nv != 3) OK = Standard_False;  break;
    case  9 : if (nv != 3) OK = Standard_False;  break;
    case 10 : if (nv != 1) OK = Standard_False;  break;
    case 11 : if (nv != 1) OK = Standard_False;  break;
    case 12 : if (nv != 3) OK = Standard_False;  break;
    case 13 : if (nv != 1) OK = Standard_False;  break;
    case 14 : if (nv != 1) OK = Standard_False;  break;
    case 15 : if (nv != 3) OK = Standard_False;  break;
    case 16 : if (nv != 1) OK = Standard_False;  break;
    case 17 : if (nv != 3) OK = Standard_False;  break;
    case 18 : if (nv != 3) OK = Standard_False;  break;
    case 19 : if (nv != 3) OK = Standard_False;  break;
    case 20 : if (nv != 3) OK = Standard_False;  break;
    case 21 : if (nv != 3) OK = Standard_False;  break;
    case 22 : if (nv != 3) OK = Standard_False;  break;
    case 23 : if (nv != 6) OK = Standard_False;  break;
    case 24 : if (nv != 6) OK = Standard_False;  break;
    case 25 : if (nv != 6) OK = Standard_False;  break;
    case 26 : if (nv != 6) OK = Standard_False;  break;
    case 27 : if (nv != 6) OK = Standard_False;  break;
    case 28 : if (nv != 6) OK = Standard_False;  break;
    case 29 : if (nv != 9) OK = Standard_False;  break;
    case 30 : if (nv != 9) OK = Standard_False;  break;
    case 31 : if (nv != 9) OK = Standard_False;  break;
    case 32 : if (nv != 9) OK = Standard_False;  break;
    case 33 : if (nv != 9) OK = Standard_False;  break;
    case 34 : if (nv != 9) OK = Standard_False;  break;
    default : ach->AddFail("Incorrect Form Number");    break;
  }
  if (!OK) ach->AddFail
    ("Incorrect count of real values in array V for FEM node");
}

void  IGESAppli_ToolNodalResults::OwnDump
  (const Handle(IGESAppli_NodalResults)& ent, const IGESData_IGESDumper& dumper,
   const Handle(Message_Messenger)& S, const Standard_Integer level) const
{
//  Standard_Integer nbnodes = ent->NbNodes();
//  Standard_Integer nbdata  = ent->NbData ();
  S << "IGESAppli_NodalResults" << endl;

  S << "General Note : ";
  dumper.Dump(ent->Note(),S, (level <= 4) ? 0 : 1);
  S << endl;
  S << "Analysis subcase number : " << ent->SubCaseNumber() << "  ";
  S << "Time used : " << ent->Time() << endl;
  S << "No. of nodes : " << ent->NbNodes() << "  ";
  S << "No. of values for a node : " << ent->NbData() << endl;
  S << "Node Identifiers : " << endl;
  S << "Nodes : " << endl;
  S << "Data : ";  if (level < 6) S << " [ask level > 5]";
//  IGESData_DumpRectVals(S ,-level,1, ent->NbData(),ent->Data);
  S << endl;
  if (level > 4)
    {
      for (Standard_Integer i=1; i <= ent->NbNodes(); i++)
	{
          S << "[" << i << "]: ";
          S << "NodeIdentifier : " << ent->NodeIdentifier(i) << "  ";
          S << "Node : ";
          dumper.Dump (ent->Node(i),S, 1);
          S << endl;
	  if (level < 6) continue;
          S << "Data : [ ";
          for (Standard_Integer j = 1; j <= ent->NbData(); j ++)
              S << "  " << ent->Data(i,j);
	  S << " ]" << endl;
	}
    }
}