0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / RWStepDimTol / RWStepDimTol_RWDatumSystem.cxx
CommitLineData
28a73c1f 1// Created on: 2015-07-16
2// Created by: Irina KRYLOVA
3// Copyright (c) 2015 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#include <RWStepDimTol_RWDatumSystem.hxx>
17
18#include <Interface_EntityIterator.hxx>
19#include <StepData_StepReaderData.hxx>
20#include <StepData_StepWriter.hxx>
21#include <StepDimTol_DatumReferenceCompartment.hxx>
22#include <StepDimTol_DatumSystem.hxx>
23#include <StepRepr_ProductDefinitionShape.hxx>
24
25//=======================================================================
26//function : RWStepDimTol_RWDatumSystem
27//purpose :
28//=======================================================================
29
30RWStepDimTol_RWDatumSystem::RWStepDimTol_RWDatumSystem ()
31{
32}
33
34//=======================================================================
35//function : ReadStep
36//purpose :
37//=======================================================================
38
39void RWStepDimTol_RWDatumSystem::ReadStep (const Handle(StepData_StepReaderData)& data,
40 const Standard_Integer num,
41 Handle(Interface_Check)& ach,
42 const Handle(StepDimTol_DatumSystem) &ent) const
43{
44 // Check number of parameters
45 if ( ! data->CheckNbParams(num,5,ach,"datum_system") ) return;
46
47 // Inherited fields of ShapeAspect
48
49 Handle(TCollection_HAsciiString) aShapeAspect_Name;
50 data->ReadString (num, 1, "shape_aspect.name", ach, aShapeAspect_Name);
51
52 Handle(TCollection_HAsciiString) aShapeAspect_Description;
53 if ( data->IsParamDefined (num,2) ) {
54 data->ReadString (num, 2, "shape_aspect.description", ach, aShapeAspect_Description);
55 }
56
57 Handle(StepRepr_ProductDefinitionShape) aShapeAspect_OfShape;
58 data->ReadEntity (num, 3, "shape_aspect.of_shape", ach, STANDARD_TYPE(StepRepr_ProductDefinitionShape), aShapeAspect_OfShape);
59
60 StepData_Logical aShapeAspect_ProductDefinitional;
61 data->ReadLogical (num, 4, "shape_aspect.product_definitional", ach, aShapeAspect_ProductDefinitional);
62
63 // Own fields of DatumSystem
64
65 Handle(StepDimTol_HArray1OfDatumReferenceCompartment) aConstituents;
66 Handle(StepDimTol_DatumReferenceCompartment) anEnt;
67 Standard_Integer nbSub;
68 if (data->ReadSubList (num,5,"base",ach,nbSub)) {
69 Standard_Integer nbElements = data->NbParams(nbSub);
70 aConstituents = new StepDimTol_HArray1OfDatumReferenceCompartment (1, nbElements);
71 for (Standard_Integer i = 1; i <= nbElements; i++) {
72 if (data->ReadEntity(nbSub, i,"datum_reference_compartment", ach, STANDARD_TYPE(StepDimTol_DatumReferenceCompartment), anEnt))
73 aConstituents->SetValue(i, anEnt);
74 }
75 }
76
77 // Initialize entity
78 ent->Init(aShapeAspect_Name,
79 aShapeAspect_Description,
80 aShapeAspect_OfShape,
81 aShapeAspect_ProductDefinitional,
82 aConstituents);
83}
84
85//=======================================================================
86//function : WriteStep
87//purpose :
88//=======================================================================
89
90void RWStepDimTol_RWDatumSystem::WriteStep (StepData_StepWriter& SW,
91 const Handle(StepDimTol_DatumSystem) &ent) const
92{
93
94 // Inherited fields of ShapeAspect
95
96 SW.Send (ent->Name());
97
98 SW.Send (ent->Description());
99
100 SW.Send (ent->OfShape());
101
102 SW.SendLogical (ent->ProductDefinitional());
103
104 // Own fields of DatumSystem
105 Standard_Integer i, nb = ent->NbConstituents();
106 SW.OpenSub();
107 for (i = 1; i <= nb; i++)
108 SW.Send (ent->ConstituentsValue(i));
109 SW.CloseSub();
110}
111
112//=======================================================================
113//function : Share
114//purpose :
115//=======================================================================
116
117void RWStepDimTol_RWDatumSystem::Share (const Handle(StepDimTol_DatumSystem) &ent,
118 Interface_EntityIterator& iter) const
119{
120
121 // Inherited fields of ShapeAspect
122
123 iter.AddItem (ent->OfShape());
124
125 // Own fields of DatumSystem
126 Standard_Integer i, nb = ent->NbConstituents();
127 for (i = 1; i <= nb; i++)
128 iter.AddItem (ent->ConstituentsValue(i));
129}