0033018: Coding - get rid of unused headers [Plugin to ShapeAnalysis]
[occt.git] / src / RWStepGeom / RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Interface_Check.hxx>
16 #include <Interface_EntityIterator.hxx>
17 #include <RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
21
22 RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx () {}
23
24 void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::ReadStep
25 (const Handle(StepData_StepReaderData)& data,
26  const Standard_Integer num0,
27  Handle(Interface_Check)& ach,
28  const Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)& ent) const
29 {
30   
31   Standard_Integer num = num0;
32   
33   // -----------------------------------------------------------------
34   // --- Instance of plex component GeometricRepresentationContext ---
35   // -----------------------------------------------------------------
36   
37   if (!data->CheckNbParams(num,1,ach,"geometric_representation_context")) return;
38   
39   // --- field : coordinateSpaceDimension ---
40   
41   Standard_Integer aCoordinateSpaceDimension;
42   //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
43   data->ReadInteger (num,1,"coordinate_space_dimension",ach,aCoordinateSpaceDimension);
44
45   num = data->NextForComplex(num);
46   
47   // -------------------------------------------------------------------
48   // --- Instance of plex component GlobalUncertaintyAssignedContext ---
49   // -------------------------------------------------------------------
50   
51   if (!data->CheckNbParams(num,1,ach,"global_uncertainty_assigned_context")) return;
52   
53   // --- field : uncertainty ---
54   
55   Handle(StepBasic_HArray1OfUncertaintyMeasureWithUnit) aUncertainty;
56   Handle(StepBasic_UncertaintyMeasureWithUnit) anent3;
57   Standard_Integer nsub3;
58   if (data->ReadSubList (num,1,"uncertainty",ach,nsub3)) {
59     Standard_Integer nb3 = data->NbParams(nsub3);
60     aUncertainty = new StepBasic_HArray1OfUncertaintyMeasureWithUnit (1, nb3);
61     for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
62       //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
63       if (data->ReadEntity (nsub3, i3,"uncertainty_measure_with_unit", ach,
64                             STANDARD_TYPE(StepBasic_UncertaintyMeasureWithUnit), anent3))
65         aUncertainty->SetValue(i3, anent3);
66     }
67   }
68   
69   num = data->NextForComplex(num);
70   
71   // ------------------------------------------------------------
72   // --- Instance of plex component GlobalUnitAssignedContext ---
73   // ------------------------------------------------------------
74   
75   if (!data->CheckNbParams(num,1,ach,"global_unit_assigned_context")) return;
76   
77   // --- field : units ---
78   
79   Handle(StepBasic_HArray1OfNamedUnit) aUnits;
80   Handle(StepBasic_NamedUnit) anent2;
81   Standard_Integer nsub2;
82   if (data->ReadSubList (num,1,"units",ach,nsub2)) {
83     Standard_Integer nb2 = data->NbParams(nsub2);
84     aUnits = new StepBasic_HArray1OfNamedUnit (1, nb2);
85     for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) {
86       //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
87       if (data->ReadEntity (nsub2, i2,"unit", ach, STANDARD_TYPE(StepBasic_NamedUnit), anent2))
88         aUnits->SetValue(i2, anent2);
89     }
90   }
91   
92   num = data->NextForComplex(num);
93   
94   // ----------------------------------------------------------
95   // --- Instance of common supertype RepresentationContext ---
96   // ----------------------------------------------------------
97   
98   if (!data->CheckNbParams(num,2,ach,"representation_context")) return;
99   
100   // --- field : contextIdentifier ---
101   
102   Handle(TCollection_HAsciiString) aContextIdentifier;
103   //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
104   data->ReadString (num,1,"context_identifier",ach,aContextIdentifier);
105
106   // --- field : contextType ---  
107   
108   Handle(TCollection_HAsciiString) aContextType;
109   //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed
110   data->ReadString (num,2,"context_type",ach,aContextType);
111   
112   //--- Initialisation of the red entity ---
113   
114   ent->Init(aContextIdentifier,aContextType,aCoordinateSpaceDimension,aUnits, aUncertainty);
115 }
116
117
118 void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::WriteStep
119         (StepData_StepWriter& SW,
120          const Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)& ent) const
121 {
122
123   // -----------------------------------------------------------------
124   // --- Instance of plex component GeometricRepresentationContext ---
125   // -----------------------------------------------------------------
126   
127   SW.StartEntity("GEOMETRIC_REPRESENTATION_CONTEXT");
128
129   // --- field : coordinateSpaceDimension ---
130   
131   SW.Send(ent->CoordinateSpaceDimension());
132   
133   // -------------------------------------------------------------------
134   // --- Instance of plex component GlobalUncertaintyAssignedContext ---
135   // -------------------------------------------------------------------
136   
137   SW.StartEntity("GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT");
138   
139   // --- field : uncertainty ---
140   
141   SW.OpenSub();
142   for (Standard_Integer i3 = 1;  i3 <= ent->NbUncertainty();  i3 ++) {
143     SW.Send(ent->UncertaintyValue(i3));
144   }
145   SW.CloseSub();
146   
147   // ------------------------------------------------------------
148   // --- Instance of plex component GlobalUnitAssignedContext ---
149   // ------------------------------------------------------------
150   
151   SW.StartEntity("GLOBAL_UNIT_ASSIGNED_CONTEXT");
152   
153   // --- field : units ---
154   
155   SW.OpenSub();
156   for (Standard_Integer i2 = 1;  i2 <= ent->NbUnits();  i2 ++) {
157     SW.Send(ent->UnitsValue(i2));
158   }
159   SW.CloseSub();
160   
161   // ----------------------------------------------------------
162   // --- Instance of common supertype RepresentationContext ---
163   // ----------------------------------------------------------
164   
165   SW.StartEntity("REPRESENTATION_CONTEXT");
166
167   // --- field : contextIdentifier ---
168   
169   SW.Send(ent->ContextIdentifier());
170   
171   // --- field : contextType ---
172   
173   SW.Send(ent->ContextType());
174 }
175
176
177 void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::Share(const Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)& ent, Interface_EntityIterator& iter) const
178 {
179   
180   Standard_Integer nbElem1 = ent->NbUnits();
181   for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) {
182     iter.GetOneItem(ent->UnitsValue(is1));
183   }
184
185   Standard_Integer nbElem2 = ent->NbUncertainty();
186   for (Standard_Integer is2=1; is2<=nbElem2; is2 ++) {
187     iter.GetOneItem(ent->UncertaintyValue(is2));
188   }
189
190 }
191