1 // Created on: 2015-07-13
2 // Created by: Irina KRYLOVA
3 // Copyright (c) 2015 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <RWStepDimTol_RWToleranceZone.hxx>
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>
27 //=======================================================================
28 //function : RWStepDimTol_RWToleranceZone
30 //=======================================================================
32 RWStepDimTol_RWToleranceZone::RWStepDimTol_RWToleranceZone ()
36 //=======================================================================
39 //=======================================================================
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
46 // Check number of parameters
47 if ( ! data->CheckNbParams(num,6,ach,"tolerance_zone") ) return;
49 // Inherited fields of ShapeAspect
51 Handle(TCollection_HAsciiString) aShapeAspect_Name;
52 data->ReadString (num, 1, "shape_aspect.name", ach, aShapeAspect_Name);
54 Handle(TCollection_HAsciiString) aShapeAspect_Description;
55 if ( data->IsParamDefined (num,2) ) {
56 data->ReadString (num, 2, "shape_aspect.description", ach, aShapeAspect_Description);
59 Handle(StepRepr_ProductDefinitionShape) aShapeAspect_OfShape;
60 data->ReadEntity (num, 3, "shape_aspect.of_shape", ach, STANDARD_TYPE(StepRepr_ProductDefinitionShape), aShapeAspect_OfShape);
62 StepData_Logical aShapeAspect_ProductDefinitional;
63 data->ReadLogical (num, 4, "shape_aspect.product_definitional", ach, aShapeAspect_ProductDefinitional);
65 // Own fields of ToleranceZone
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);
79 Handle (StepDimTol_ToleranceZoneForm) aForm;
80 data->ReadEntity (num, 6, "form", ach, STANDARD_TYPE(StepDimTol_ToleranceZoneForm), aForm);
83 ent->Init(aShapeAspect_Name,
84 aShapeAspect_Description,
86 aShapeAspect_ProductDefinitional,
91 //=======================================================================
92 //function : WriteStep
94 //=======================================================================
96 void RWStepDimTol_RWToleranceZone::WriteStep (StepData_StepWriter& SW,
97 const Handle(StepDimTol_ToleranceZone) &ent) const
100 // Inherited fields of ShapeAspect
102 SW.Send (ent->Name());
104 SW.Send (ent->Description());
106 SW.Send (ent->OfShape());
108 SW.SendLogical (ent->ProductDefinitional());
110 // Own fields of ToleranceZone
113 for (Standard_Integer i = 1; i <= ent->NbDefiningTolerances(); i++) {
114 SW.Send(ent->DefiningToleranceValue(i).Value());
118 SW.Send (ent->Form());
121 //=======================================================================
124 //=======================================================================
126 void RWStepDimTol_RWToleranceZone::Share (const Handle(StepDimTol_ToleranceZone) &ent,
127 Interface_EntityIterator& iter) const
130 // Inherited fields of ShapeAspect
132 iter.AddItem (ent->OfShape());
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());