28a73c1f |
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_RWToleranceZone.hxx> |
17 | |
18 | #include <Interface_EntityIterator.hxx> |
19 | #include <StepData_StepReaderData.hxx> |
20 | #include <StepData_StepWriter.hxx> |
21 | #include <StepDimTol_HArray1OfToleranceZoneTarget.hxx> |
22 | #include <StepDimTol_ToleranceZone.hxx> |
23 | #include <StepDimTol_ToleranceZoneForm.hxx> |
24 | #include <StepDimTol_ToleranceZoneTarget.hxx> |
25 | #include <StepRepr_ProductDefinitionShape.hxx> |
26 | |
27 | //======================================================================= |
28 | //function : RWStepDimTol_RWToleranceZone |
29 | //purpose : |
30 | //======================================================================= |
31 | |
32 | RWStepDimTol_RWToleranceZone::RWStepDimTol_RWToleranceZone () |
33 | { |
34 | } |
35 | |
36 | //======================================================================= |
37 | //function : ReadStep |
38 | //purpose : |
39 | //======================================================================= |
40 | |
41 | void RWStepDimTol_RWToleranceZone::ReadStep (const Handle(StepData_StepReaderData)& data, |
42 | const Standard_Integer num, |
43 | Handle(Interface_Check)& ach, |
44 | const Handle(StepDimTol_ToleranceZone) &ent) const |
45 | { |
46 | // Check number of parameters |
47 | if ( ! data->CheckNbParams(num,6,ach,"tolerance_zone") ) return; |
48 | |
49 | // Inherited fields of ShapeAspect |
50 | |
51 | Handle(TCollection_HAsciiString) aShapeAspect_Name; |
52 | data->ReadString (num, 1, "shape_aspect.name", ach, aShapeAspect_Name); |
53 | |
54 | Handle(TCollection_HAsciiString) aShapeAspect_Description; |
55 | if ( data->IsParamDefined (num,2) ) { |
56 | data->ReadString (num, 2, "shape_aspect.description", ach, aShapeAspect_Description); |
57 | } |
58 | |
59 | Handle(StepRepr_ProductDefinitionShape) aShapeAspect_OfShape; |
60 | data->ReadEntity (num, 3, "shape_aspect.of_shape", ach, STANDARD_TYPE(StepRepr_ProductDefinitionShape), aShapeAspect_OfShape); |
61 | |
62 | StepData_Logical aShapeAspect_ProductDefinitional; |
63 | data->ReadLogical (num, 4, "shape_aspect.product_definitional", ach, aShapeAspect_ProductDefinitional); |
64 | |
65 | // Own fields of ToleranceZone |
66 | |
67 | Handle(StepDimTol_HArray1OfToleranceZoneTarget) anItems; |
68 | StepDimTol_ToleranceZoneTarget anEnt; |
69 | Standard_Integer nbSub; |
70 | if (data->ReadSubList (num,5,"defining_tolerance",ach,nbSub)) { |
71 | Standard_Integer nbElements = data->NbParams(nbSub); |
72 | anItems = new StepDimTol_HArray1OfToleranceZoneTarget (1, nbElements); |
73 | for (Standard_Integer i = 1; i <= nbElements; i++) { |
74 | if (data->ReadEntity(nbSub, i,"tolerance_zone_target", ach, anEnt)) |
75 | anItems->SetValue(i, anEnt); |
76 | } |
77 | } |
78 | |
79 | Handle (StepDimTol_ToleranceZoneForm) aForm; |
80 | data->ReadEntity (num, 6, "form", ach, STANDARD_TYPE(StepDimTol_ToleranceZoneForm), aForm); |
81 | |
82 | // Initialize entity |
83 | ent->Init(aShapeAspect_Name, |
84 | aShapeAspect_Description, |
85 | aShapeAspect_OfShape, |
86 | aShapeAspect_ProductDefinitional, |
87 | anItems, |
88 | aForm); |
89 | } |
90 | |
91 | //======================================================================= |
92 | //function : WriteStep |
93 | //purpose : |
94 | //======================================================================= |
95 | |
96 | void RWStepDimTol_RWToleranceZone::WriteStep (StepData_StepWriter& SW, |
97 | const Handle(StepDimTol_ToleranceZone) &ent) const |
98 | { |
99 | |
100 | // Inherited fields of ShapeAspect |
101 | |
102 | SW.Send (ent->Name()); |
103 | |
104 | SW.Send (ent->Description()); |
105 | |
106 | SW.Send (ent->OfShape()); |
107 | |
108 | SW.SendLogical (ent->ProductDefinitional()); |
109 | |
110 | // Own fields of ToleranceZone |
111 | |
112 | SW.OpenSub(); |
113 | for (Standard_Integer i = 1; i <= ent->NbDefiningTolerances(); i++) { |
114 | SW.Send(ent->DefiningToleranceValue(i).Value()); |
115 | } |
116 | SW.CloseSub(); |
117 | |
118 | SW.Send (ent->Form()); |
119 | } |
120 | |
121 | //======================================================================= |
122 | //function : Share |
123 | //purpose : |
124 | //======================================================================= |
125 | |
126 | void RWStepDimTol_RWToleranceZone::Share (const Handle(StepDimTol_ToleranceZone) &ent, |
127 | Interface_EntityIterator& iter) const |
128 | { |
129 | |
130 | // Inherited fields of ShapeAspect |
131 | |
132 | iter.AddItem (ent->OfShape()); |
133 | |
134 | // Own fields of ToleranceZone |
135 | Standard_Integer i, nb = ent->NbDefiningTolerances(); |
136 | for (i = 1; i <= nb; i++) |
137 | iter.AddItem (ent->DefiningToleranceValue(i).Value()); |
138 | } |