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