0033018: Coding - get rid of unused headers [Plugin to ShapeAnalysis]
[occt.git] / src / RWStepDimTol / RWStepDimTol_RWProjectedZoneDefinition.cxx
1 // Created on: 2015-07-13
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_RWProjectedZoneDefinition.hxx>
17
18 #include <Interface_EntityIterator.hxx>
19 #include <StepData_StepReaderData.hxx>
20 #include <StepData_StepWriter.hxx>
21 #include <StepDimTol_ProjectedZoneDefinition.hxx>
22 #include <StepDimTol_ToleranceZone.hxx>
23 #include <StepRepr_ShapeAspect.hxx>
24
25 //=======================================================================
26 //function : RWStepDimTol_RWProjectedZoneDefinition
27 //purpose  : 
28 //=======================================================================
29
30 RWStepDimTol_RWProjectedZoneDefinition::RWStepDimTol_RWProjectedZoneDefinition ()
31 {
32 }
33
34 //=======================================================================
35 //function : ReadStep
36 //purpose  : 
37 //=======================================================================
38
39 void RWStepDimTol_RWProjectedZoneDefinition::ReadStep (const Handle(StepData_StepReaderData)& data,
40                                                        const Standard_Integer num,
41                                                        Handle(Interface_Check)& ach,
42                                                        const Handle(StepDimTol_ProjectedZoneDefinition) &ent) const
43 {
44   // Check number of parameters
45   if ( ! data->CheckNbParams(num,4,ach,"projected_zone_definition") ) return;
46
47   // Inherited fields from ToleranceZoneDefinition
48
49   Handle(StepDimTol_ToleranceZone) aToleranceZone;
50   data->ReadEntity (num, 1, "tolerance_zone_definition.zone", ach, STANDARD_TYPE(StepDimTol_ToleranceZone), aToleranceZone);
51   
52   Handle(StepRepr_HArray1OfShapeAspect) anItems;
53   Handle(StepRepr_ShapeAspect) anEnt;
54   Standard_Integer nbSub;
55   if (data->ReadSubList (num,2,"tolerance_zone_definition.boundaries",ach,nbSub)) {
56     Standard_Integer nbElements = data->NbParams(nbSub);
57     anItems = new StepRepr_HArray1OfShapeAspect (1, nbElements);
58     for (Standard_Integer i = 1; i <= nbElements; i++) {
59       if (data->ReadEntity(nbSub, i,"shape_aspect", ach, STANDARD_TYPE(StepRepr_ShapeAspect), anEnt))
60         anItems->SetValue(i, anEnt);
61     }
62   }
63   
64   Handle(StepRepr_ShapeAspect) aProjectionEnd;
65   data->ReadEntity(num, 3, "projection_end", ach, STANDARD_TYPE(StepRepr_ShapeAspect), aProjectionEnd);
66   
67   Handle(StepBasic_LengthMeasureWithUnit) aProjectionLength;
68   data->ReadEntity(num, 4, "projection_length", ach, STANDARD_TYPE(StepBasic_LengthMeasureWithUnit), aProjectionLength);
69
70   // Initialize entity
71   ent->Init(aToleranceZone,
72             anItems,
73             aProjectionEnd,
74             aProjectionLength);
75 }
76
77 //=======================================================================
78 //function : WriteStep
79 //purpose  : 
80 //=======================================================================
81
82 void RWStepDimTol_RWProjectedZoneDefinition::WriteStep (StepData_StepWriter& SW,
83                                                         const Handle(StepDimTol_ProjectedZoneDefinition) &ent) const
84 {
85   // Inherited fields of ToleranceZoneDefinition
86   
87   SW.Send (ent->Zone());
88   
89   SW.OpenSub();
90   for (Standard_Integer i = 1;  i <= ent->NbBoundaries();  i++) {
91     SW.Send(ent->BoundariesValue(i));
92   }
93   SW.CloseSub();
94   
95   // Own fields of ProjectedZoneDefinition
96   
97   SW.Send (ent->ProjectionEnd());
98   
99   SW.Send (ent->ProjectionLength());
100 }
101
102 //=======================================================================
103 //function : Share
104 //purpose  : 
105 //=======================================================================
106
107 void RWStepDimTol_RWProjectedZoneDefinition::Share (const Handle(StepDimTol_ProjectedZoneDefinition) &ent,
108                                                     Interface_EntityIterator& iter) const
109 {
110
111   // Inherited fields from ToleranceZoneDefinition
112
113   iter.AddItem (ent->Zone());
114   
115   Standard_Integer i, nb = ent->NbBoundaries();
116   for (i = 1; i <= nb; i++)  
117     iter.AddItem (ent->BoundariesValue(i));
118     
119   //Own field of ProjectionZoneDefinition
120   iter.AddItem (ent->ProjectionEnd());
121 }