0030380: Exception while reading Step-file
[occt.git] / src / RWStepFEA / RWStepFEA_RWVolume3dElementRepresentation.cxx
1 // Created on: 2002-12-12
2 // Created by: data exchange team
3 // Copyright (c) 2002-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 // Generator:   ExpToCas (EXPRESS -> CASCADE/XSTEP Translator) V1.2
17
18 #include <Interface_Check.hxx>
19 #include <Interface_EntityIterator.hxx>
20 #include <RWStepFEA_RWVolume3dElementRepresentation.hxx>
21 #include <StepData_StepReaderData.hxx>
22 #include <StepData_StepWriter.hxx>
23 #include <StepElement_ElementMaterial.hxx>
24 #include <StepElement_Volume3dElementDescriptor.hxx>
25 #include <StepFEA_FeaModel3d.hxx>
26 #include <StepFEA_HArray1OfNodeRepresentation.hxx>
27 #include <StepFEA_NodeRepresentation.hxx>
28 #include <StepFEA_Volume3dElementRepresentation.hxx>
29 #include <StepRepr_HArray1OfRepresentationItem.hxx>
30 #include <StepRepr_RepresentationContext.hxx>
31 #include <StepRepr_RepresentationItem.hxx>
32
33 //=======================================================================
34 //function : RWStepFEA_RWVolume3dElementRepresentation
35 //purpose  : 
36 //=======================================================================
37 RWStepFEA_RWVolume3dElementRepresentation::RWStepFEA_RWVolume3dElementRepresentation ()
38 {
39 }
40
41 //=======================================================================
42 //function : ReadStep
43 //purpose  : 
44 //=======================================================================
45
46 void RWStepFEA_RWVolume3dElementRepresentation::ReadStep (const Handle(StepData_StepReaderData)& data,
47                                                           const Standard_Integer num,
48                                                           Handle(Interface_Check)& ach,
49                                                           const Handle(StepFEA_Volume3dElementRepresentation) &ent) const
50 {
51   // Check number of parameters
52   if ( ! data->CheckNbParams(num,7,ach,"volume3d_element_representation") ) return;
53
54   // Inherited fields of Representation
55
56   Handle(TCollection_HAsciiString) aRepresentation_Name;
57   data->ReadString (num, 1, "representation.name", ach, aRepresentation_Name);
58
59   Handle(StepRepr_HArray1OfRepresentationItem) aRepresentation_Items;
60   Standard_Integer sub2 = 0;
61   if ( data->ReadSubList (num, 2, "representation.items", ach, sub2) ) {
62     Standard_Integer nb0 = data->NbParams(sub2);
63     aRepresentation_Items = new StepRepr_HArray1OfRepresentationItem (1, nb0);
64     Standard_Integer num2 = sub2;
65     for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
66       Handle(StepRepr_RepresentationItem) anIt0;
67       data->ReadEntity (num2, i0, "representation_item", ach, STANDARD_TYPE(StepRepr_RepresentationItem), anIt0);
68       aRepresentation_Items->SetValue(i0, anIt0);
69     }
70   }
71
72   Handle(StepRepr_RepresentationContext) aRepresentation_ContextOfItems;
73   data->ReadEntity (num, 3, "representation.context_of_items", ach, STANDARD_TYPE(StepRepr_RepresentationContext), aRepresentation_ContextOfItems);
74
75   // Inherited fields of ElementRepresentation
76
77   Handle(StepFEA_HArray1OfNodeRepresentation) aElementRepresentation_NodeList;
78   Standard_Integer sub4 = 0;
79   if ( data->ReadSubList (num, 4, "element_representation.node_list", ach, sub4) ) {
80     Standard_Integer nb0 = data->NbParams(sub4);
81     aElementRepresentation_NodeList = new StepFEA_HArray1OfNodeRepresentation (1, nb0);
82     Standard_Integer num2 = sub4;
83     for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
84       Handle(StepFEA_NodeRepresentation) anIt0;
85       data->ReadEntity (num2, i0, "node_representation", ach, STANDARD_TYPE(StepFEA_NodeRepresentation), anIt0);
86       aElementRepresentation_NodeList->SetValue(i0, anIt0);
87     }
88   }
89
90   // Own fields of Volume3dElementRepresentation
91
92   Handle(StepFEA_FeaModel3d) aModelRef;
93   data->ReadEntity (num, 5, "model_ref", ach, STANDARD_TYPE(StepFEA_FeaModel3d), aModelRef);
94
95   Handle(StepElement_Volume3dElementDescriptor) aElementDescriptor;
96   data->ReadEntity (num, 6, "element_descriptor", ach, STANDARD_TYPE(StepElement_Volume3dElementDescriptor), aElementDescriptor);
97
98   Handle(StepElement_ElementMaterial) aMaterial;
99   data->ReadEntity (num, 7, "material", ach, STANDARD_TYPE(StepElement_ElementMaterial), aMaterial);
100
101   // Initialize entity
102   ent->Init(aRepresentation_Name,
103             aRepresentation_Items,
104             aRepresentation_ContextOfItems,
105             aElementRepresentation_NodeList,
106             aModelRef,
107             aElementDescriptor,
108             aMaterial);
109 }
110
111 //=======================================================================
112 //function : WriteStep
113 //purpose  : 
114 //=======================================================================
115
116 void RWStepFEA_RWVolume3dElementRepresentation::WriteStep (StepData_StepWriter& SW,
117                                                            const Handle(StepFEA_Volume3dElementRepresentation) &ent) const
118 {
119
120   // Inherited fields of Representation
121
122   SW.Send (ent->StepRepr_Representation::Name());
123
124   SW.OpenSub();
125   for (Standard_Integer i1=1; i1 <= ent->StepRepr_Representation::NbItems(); i1++ ) {
126     Handle(StepRepr_RepresentationItem) Var0 = ent->StepRepr_Representation::Items()->Value(i1);
127     SW.Send (Var0);
128   }
129   SW.CloseSub();
130
131   SW.Send (ent->StepRepr_Representation::ContextOfItems());
132
133   // Inherited fields of ElementRepresentation
134
135   SW.OpenSub();
136   for (Standard_Integer i3=1; i3 <= ent->StepFEA_ElementRepresentation::NodeList()->Length(); i3++ ) {
137     Handle(StepFEA_NodeRepresentation) Var0 = ent->StepFEA_ElementRepresentation::NodeList()->Value(i3);
138     SW.Send (Var0);
139   }
140   SW.CloseSub();
141
142   // Own fields of Volume3dElementRepresentation
143
144   SW.Send (ent->ModelRef());
145
146   SW.Send (ent->ElementDescriptor());
147
148   SW.Send (ent->Material());
149 }
150
151 //=======================================================================
152 //function : Share
153 //purpose  : 
154 //=======================================================================
155
156 void RWStepFEA_RWVolume3dElementRepresentation::Share (const Handle(StepFEA_Volume3dElementRepresentation) &ent,
157                                                        Interface_EntityIterator& iter) const
158 {
159
160   // Inherited fields of Representation
161
162   for (Standard_Integer i1=1; i1 <= ent->StepRepr_Representation::NbItems(); i1++ ) {
163     Handle(StepRepr_RepresentationItem) Var0 = ent->StepRepr_Representation::Items()->Value(i1);
164     iter.AddItem (Var0);
165   }
166
167   iter.AddItem (ent->StepRepr_Representation::ContextOfItems());
168
169   // Inherited fields of ElementRepresentation
170
171   for (Standard_Integer i3=1; i3 <= ent->StepFEA_ElementRepresentation::NodeList()->Length(); i3++ ) {
172     Handle(StepFEA_NodeRepresentation) Var0 = ent->StepFEA_ElementRepresentation::NodeList()->Value(i3);
173     iter.AddItem (Var0);
174   }
175
176   // Own fields of Volume3dElementRepresentation
177
178   iter.AddItem (ent->ModelRef());
179
180   iter.AddItem (ent->ElementDescriptor());
181
182   iter.AddItem (ent->Material());
183 }