973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | |
42cf5bc1 |
15 | #include <Interface_Check.hxx> |
16 | #include <Interface_EntityIterator.hxx> |
17 | #include <RWStepShape_RWToleranceValue.hxx> |
18 | #include <StepBasic_MeasureWithUnit.hxx> |
19 | #include <StepData_StepReaderData.hxx> |
20 | #include <StepData_StepWriter.hxx> |
21 | #include <StepShape_ToleranceValue.hxx> |
33defc71 |
22 | #include <StepRepr_MeasureRepresentationItem.hxx> |
23 | #include <StepRepr_ReprItemAndMeasureWithUnit.hxx> |
7fd59977 |
24 | |
25 | RWStepShape_RWToleranceValue::RWStepShape_RWToleranceValue () {} |
26 | |
27 | void RWStepShape_RWToleranceValue::ReadStep |
28 | (const Handle(StepData_StepReaderData)& data, |
29 | const Standard_Integer num, |
30 | Handle(Interface_Check)& ach, |
31 | const Handle(StepShape_ToleranceValue)& ent) const |
32 | { |
33 | // --- Number of Parameter Control --- |
34 | |
35 | if (!data->CheckNbParams(num,2,ach,"tolerance_value")) return; |
36 | |
37 | // --- own field : lower_bound --- |
38 | |
33defc71 |
39 | Handle(Standard_Transient) LB; |
40 | if(!data->ReadEntity (num,1,"lower_bound",ach, |
41 | STANDARD_TYPE(StepBasic_MeasureWithUnit),LB)) |
42 | { |
43 | Handle(StepRepr_MeasureRepresentationItem) aMSR; |
44 | Handle(StepRepr_ReprItemAndMeasureWithUnit) aRIMU; |
45 | |
46 | if(data->ReadEntity (num,1,"lower_bound",ach, |
47 | STANDARD_TYPE(StepRepr_MeasureRepresentationItem),aMSR) || |
48 | data->ReadEntity (num,1,"lower_bound",ach,STANDARD_TYPE(StepRepr_ReprItemAndMeasureWithUnit), aRIMU)) |
49 | { |
50 | if(!aMSR.IsNull()) |
51 | LB = aMSR; |
52 | else if(!aRIMU.IsNull()) |
53 | LB = aRIMU; |
54 | } |
55 | } |
7fd59977 |
56 | |
57 | // --- own field : upper_bound --- |
58 | |
33defc71 |
59 | Handle(Standard_Transient) UB; |
60 | if(!data->ReadEntity (num,2,"upper_bound",ach, |
61 | STANDARD_TYPE(StepBasic_MeasureWithUnit),UB)) |
62 | { |
63 | Handle(StepRepr_MeasureRepresentationItem) aMSR1; |
64 | Handle(StepRepr_ReprItemAndMeasureWithUnit) aRIMU1; |
65 | if(data->ReadEntity (num,2,"upper_bound",ach,STANDARD_TYPE(StepRepr_MeasureRepresentationItem),aMSR1) || |
66 | data->ReadEntity (num,2,"upper_bound",ach,STANDARD_TYPE(StepRepr_ReprItemAndMeasureWithUnit), aRIMU1)) |
67 | { |
68 | if(!aMSR1.IsNull()) |
69 | UB = aMSR1; |
70 | else if(!aRIMU1.IsNull()) |
71 | UB = aRIMU1; |
72 | } |
73 | } |
7fd59977 |
74 | |
75 | //--- Initialisation of the read entity --- |
33defc71 |
76 | if( !LB.IsNull() && !UB.IsNull()) |
77 | ach->ClearFails(); |
7fd59977 |
78 | ent->Init(LB,UB); |
79 | } |
80 | |
81 | |
82 | void RWStepShape_RWToleranceValue::WriteStep |
83 | (StepData_StepWriter& SW, |
84 | const Handle(StepShape_ToleranceValue)& ent) const |
85 | { |
86 | SW.Send (ent->LowerBound()); |
87 | SW.Send (ent->UpperBound()); |
88 | } |
89 | |
90 | |
91 | void RWStepShape_RWToleranceValue::Share(const Handle(StepShape_ToleranceValue)& ent, Interface_EntityIterator& iter) const |
92 | { |
93 | iter.AddItem (ent->LowerBound()); |
94 | iter.AddItem (ent->UpperBound()); |
95 | } |
96 | |