0028250: Data Exchange - Wrong number of geometric tolerance modifiers.
[occt.git] / src / RWStepDimTol / RWStepDimTol_RWParallelismTolerance.cxx
1 // Created on: 2003-06-04
2 // Created by: Galina KULIKOVA
3 // Copyright (c) 2003-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 <RWStepDimTol_RWParallelismTolerance.hxx>
21 #include <StepBasic_MeasureWithUnit.hxx>
22 #include <StepData_StepReaderData.hxx>
23 #include <StepData_StepWriter.hxx>
24 #include <StepDimTol_DatumReference.hxx>
25 #include <StepDimTol_GeometricToleranceTarget.hxx>
26 #include <StepDimTol_HArray1OfDatumSystemOrReference.hxx>
27 #include <StepDimTol_ParallelismTolerance.hxx>
28
29 //=======================================================================
30 //function : RWStepDimTol_RWParallelismTolerance
31 //purpose  : 
32 //=======================================================================
33 RWStepDimTol_RWParallelismTolerance::RWStepDimTol_RWParallelismTolerance ()
34 {
35 }
36
37 //=======================================================================
38 //function : ReadStep
39 //purpose  : 
40 //=======================================================================
41
42 void RWStepDimTol_RWParallelismTolerance::ReadStep (const Handle(StepData_StepReaderData)& data,
43                                                     const Standard_Integer num,
44                                                     Handle(Interface_Check)& ach,
45                                                     const Handle(StepDimTol_ParallelismTolerance) &ent) const
46 {
47   // Check number of parameters
48   if ( ! data->CheckNbParams(num,5,ach,"parallelism_tolerance") ) return;
49
50   // Inherited fields of GeometricTolerance
51
52   Handle(TCollection_HAsciiString) aGeometricTolerance_Name;
53   data->ReadString (num, 1, "geometric_tolerance.name", ach, aGeometricTolerance_Name);
54
55   Handle(TCollection_HAsciiString) aGeometricTolerance_Description;
56   data->ReadString (num, 2, "geometric_tolerance.description", ach, aGeometricTolerance_Description);
57
58   Handle(StepBasic_MeasureWithUnit) aGeometricTolerance_Magnitude;
59   data->ReadEntity (num, 3, "geometric_tolerance.magnitude", ach, STANDARD_TYPE(StepBasic_MeasureWithUnit), aGeometricTolerance_Magnitude);
60
61   StepDimTol_GeometricToleranceTarget aGeometricTolerance_TolerancedShapeAspect;
62   data->ReadEntity (num, 4, "geometric_tolerance.toleranced_shape_aspect", ach, aGeometricTolerance_TolerancedShapeAspect);
63
64   // Inherited fields of GeometricToleranceWithDatumReference
65
66   Handle(StepDimTol_HArray1OfDatumSystemOrReference) aGeometricToleranceWithDatumReference_DatumSystem;
67   Standard_Integer sub5 = 0;
68   if ( data->ReadSubList (num, 5, "geometric_tolerance_with_datum_reference.datum_system", ach, sub5) ) {
69     Standard_Integer nb0 = data->NbParams(sub5);
70     aGeometricToleranceWithDatumReference_DatumSystem = new StepDimTol_HArray1OfDatumSystemOrReference (1, nb0);
71     Standard_Integer num2 = sub5;
72     for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
73       StepDimTol_DatumSystemOrReference anIt0;
74       data->ReadEntity (num2, i0, "datum_system_or_reference", ach, anIt0);
75       aGeometricToleranceWithDatumReference_DatumSystem->SetValue(i0, anIt0);
76     }
77   }
78
79   // Initialize entity
80   ent->Init(aGeometricTolerance_Name,
81             aGeometricTolerance_Description,
82             aGeometricTolerance_Magnitude,
83             aGeometricTolerance_TolerancedShapeAspect,
84             aGeometricToleranceWithDatumReference_DatumSystem);
85 }
86
87 //=======================================================================
88 //function : WriteStep
89 //purpose  : 
90 //=======================================================================
91
92 void RWStepDimTol_RWParallelismTolerance::WriteStep (StepData_StepWriter& SW,
93                                                      const Handle(StepDimTol_ParallelismTolerance) &ent) const
94 {
95
96   // Inherited fields of GeometricTolerance
97
98   SW.Send (ent->StepDimTol_GeometricTolerance::Name());
99
100   SW.Send (ent->StepDimTol_GeometricTolerance::Description());
101
102   SW.Send (ent->StepDimTol_GeometricTolerance::Magnitude());
103
104   SW.Send (ent->StepDimTol_GeometricTolerance::TolerancedShapeAspect().Value());
105
106   // Inherited fields of GeometricToleranceWithDatumReference
107
108   SW.OpenSub();
109   for (Standard_Integer i4=1; i4 <= ent->StepDimTol_GeometricToleranceWithDatumReference::DatumSystemAP242()->Length(); i4++ ) {
110     StepDimTol_DatumSystemOrReference Var0 = ent->StepDimTol_GeometricToleranceWithDatumReference::DatumSystemAP242()->Value(i4);
111     SW.Send (Var0.Value());
112   }
113   SW.CloseSub();
114 }
115
116 //=======================================================================
117 //function : Share
118 //purpose  : 
119 //=======================================================================
120
121 void RWStepDimTol_RWParallelismTolerance::Share (const Handle(StepDimTol_ParallelismTolerance) &ent,
122                                                  Interface_EntityIterator& iter) const
123 {
124
125   // Inherited fields of GeometricTolerance
126
127   iter.AddItem (ent->StepDimTol_GeometricTolerance::Magnitude());
128
129   iter.AddItem (ent->StepDimTol_GeometricTolerance::TolerancedShapeAspect().Value());
130
131   // Inherited fields of GeometricToleranceWithDatumReference
132
133   for (Standard_Integer i3=1; i3 <= ent->StepDimTol_GeometricToleranceWithDatumReference::DatumSystemAP242()->Length(); i3++ ) {
134     StepDimTol_DatumSystemOrReference Var0 = ent->StepDimTol_GeometricToleranceWithDatumReference::DatumSystemAP242()->Value(i3);
135     iter.AddItem (Var0.Value());
136   }
137 }