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