0033018: Coding - get rid of unused headers [Plugin to ShapeAnalysis]
[occt.git] / src / RWStepShape / RWStepShape_RWToleranceValue.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_EntityIterator.hxx>
16 #include <RWStepShape_RWToleranceValue.hxx>
17 #include <StepBasic_MeasureWithUnit.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepShape_ToleranceValue.hxx>
21 #include <StepRepr_MeasureRepresentationItem.hxx>
22 #include <StepRepr_ReprItemAndMeasureWithUnit.hxx>
23
24 RWStepShape_RWToleranceValue::RWStepShape_RWToleranceValue () {}
25
26 void RWStepShape_RWToleranceValue::ReadStep
27         (const Handle(StepData_StepReaderData)& data,
28          const Standard_Integer num,
29          Handle(Interface_Check)& ach,
30          const Handle(StepShape_ToleranceValue)& ent) const
31 {
32         // --- Number of Parameter Control ---
33
34         if (!data->CheckNbParams(num,2,ach,"tolerance_value")) return;
35
36         // --- own field : lower_bound ---
37
38         Handle(Standard_Transient) LB;
39         if(!data->ReadEntity (num,1,"lower_bound",ach,
40                           STANDARD_TYPE(StepBasic_MeasureWithUnit),LB))
41   {
42     Handle(StepRepr_MeasureRepresentationItem) aMSR;
43     Handle(StepRepr_ReprItemAndMeasureWithUnit) aRIMU;
44      
45     if(data->ReadEntity (num,1,"lower_bound",ach,
46                           STANDARD_TYPE(StepRepr_MeasureRepresentationItem),aMSR) || 
47       data->ReadEntity (num,1,"lower_bound",ach,STANDARD_TYPE(StepRepr_ReprItemAndMeasureWithUnit), aRIMU))
48     {
49       if(!aMSR.IsNull())
50         LB = aMSR;
51        else if(!aRIMU.IsNull())
52         LB = aRIMU;
53     }
54   }
55
56         // --- own field : upper_bound ---
57
58         Handle(Standard_Transient) UB;
59         if(!data->ReadEntity (num,2,"upper_bound",ach,
60                           STANDARD_TYPE(StepBasic_MeasureWithUnit),UB))
61   {
62      Handle(StepRepr_MeasureRepresentationItem) aMSR1;
63      Handle(StepRepr_ReprItemAndMeasureWithUnit) aRIMU1;
64     if(data->ReadEntity (num,2,"upper_bound",ach,STANDARD_TYPE(StepRepr_MeasureRepresentationItem),aMSR1) || 
65       data->ReadEntity (num,2,"upper_bound",ach,STANDARD_TYPE(StepRepr_ReprItemAndMeasureWithUnit), aRIMU1))
66     {
67       if(!aMSR1.IsNull())
68         UB = aMSR1;
69       else if(!aRIMU1.IsNull())
70         UB = aRIMU1;
71     }
72   }
73
74         //--- Initialisation of the read entity ---
75   if( !LB.IsNull() && !UB.IsNull())
76     ach->ClearFails();
77         ent->Init(LB,UB);
78 }
79
80
81 void RWStepShape_RWToleranceValue::WriteStep
82         (StepData_StepWriter& SW,
83          const Handle(StepShape_ToleranceValue)& ent) const
84 {
85   SW.Send (ent->LowerBound());
86   SW.Send (ent->UpperBound());
87 }
88
89
90 void RWStepShape_RWToleranceValue::Share(const Handle(StepShape_ToleranceValue)& ent, Interface_EntityIterator& iter) const
91 {
92   iter.AddItem (ent->LowerBound());
93   iter.AddItem (ent->UpperBound());
94 }
95