0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / RWStepElement / RWStepElement_RWElementMaterial.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 <RWStepElement_RWElementMaterial.hxx>
21 #include <StepData_StepReaderData.hxx>
22 #include <StepData_StepWriter.hxx>
23 #include <StepElement_ElementMaterial.hxx>
24 #include <StepRepr_HArray1OfMaterialPropertyRepresentation.hxx>
25 #include <StepRepr_MaterialPropertyRepresentation.hxx>
26
27 //=======================================================================
28 //function : RWStepElement_RWElementMaterial
29 //purpose  : 
30 //=======================================================================
31 RWStepElement_RWElementMaterial::RWStepElement_RWElementMaterial ()
32 {
33 }
34
35 //=======================================================================
36 //function : ReadStep
37 //purpose  : 
38 //=======================================================================
39
40 void RWStepElement_RWElementMaterial::ReadStep (const Handle(StepData_StepReaderData)& data,
41                                                 const Standard_Integer num,
42                                                 Handle(Interface_Check)& ach,
43                                                 const Handle(StepElement_ElementMaterial) &ent) const
44 {
45   // Check number of parameters
46   if ( ! data->CheckNbParams(num,3,ach,"element_material") ) return;
47
48   // Own fields of ElementMaterial
49
50   Handle(TCollection_HAsciiString) aMaterialId;
51   data->ReadString (num, 1, "material_id", ach, aMaterialId);
52
53   Handle(TCollection_HAsciiString) aDescription;
54   data->ReadString (num, 2, "description", ach, aDescription);
55
56   Handle(StepRepr_HArray1OfMaterialPropertyRepresentation) aProperties;
57   Standard_Integer sub3 = 0;
58   if ( data->ReadSubList (num, 3, "properties", ach, sub3) ) {
59     Standard_Integer nb0 = data->NbParams(sub3);
60     aProperties = new StepRepr_HArray1OfMaterialPropertyRepresentation (1, nb0);
61     Standard_Integer num2 = sub3;
62     for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
63       Handle(StepRepr_MaterialPropertyRepresentation) anIt0;
64       data->ReadEntity (num2, i0, "material_property_representation", ach, STANDARD_TYPE(StepRepr_MaterialPropertyRepresentation), anIt0);
65       aProperties->SetValue(i0, anIt0);
66     }
67   }
68
69   // Initialize entity
70   ent->Init(aMaterialId,
71             aDescription,
72             aProperties);
73 }
74
75 //=======================================================================
76 //function : WriteStep
77 //purpose  : 
78 //=======================================================================
79
80 void RWStepElement_RWElementMaterial::WriteStep (StepData_StepWriter& SW,
81                                                  const Handle(StepElement_ElementMaterial) &ent) const
82 {
83
84   // Own fields of ElementMaterial
85
86   SW.Send (ent->MaterialId());
87
88   SW.Send (ent->Description());
89
90   SW.OpenSub();
91   for (Standard_Integer i2=1; i2 <= ent->Properties()->Length(); i2++ ) {
92     Handle(StepRepr_MaterialPropertyRepresentation) Var0 = ent->Properties()->Value(i2);
93     SW.Send (Var0);
94   }
95   SW.CloseSub();
96 }
97
98 //=======================================================================
99 //function : Share
100 //purpose  : 
101 //=======================================================================
102
103 void RWStepElement_RWElementMaterial::Share (const Handle(StepElement_ElementMaterial) &ent,
104                                              Interface_EntityIterator& iter) const
105 {
106
107   // Own fields of ElementMaterial
108
109   for (Standard_Integer i1=1; i1 <= ent->Properties()->Length(); i1++ ) {
110     Handle(StepRepr_MaterialPropertyRepresentation) Var0 = ent->Properties()->Value(i1);
111     iter.AddItem (Var0);
112   }
113 }