0024428: Implementation of LGPL license
[occt.git] / src / RWStepRepr / RWStepRepr_RWReprItemAndLengthMeasureWithUnit.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
6 // under the terms of the GNU Lesser General Public 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 #include <RWStepRepr_RWReprItemAndLengthMeasureWithUnit.ixx>
15
16 #include <StepBasic_MeasureValueMember.hxx>
17 #include <StepBasic_Unit.hxx>
18 #include <StepBasic_MeasureWithUnit.hxx>
19
20
21 //=======================================================================
22 //function : RWSteprepr_RWReprItemAndLengthMeasureWithUnit
23 //purpose  : 
24 //=======================================================================
25
26 RWStepRepr_RWReprItemAndLengthMeasureWithUnit::RWStepRepr_RWReprItemAndLengthMeasureWithUnit() {}
27
28
29 //=======================================================================
30 //function : ReadStep
31 //purpose  : 
32 //=======================================================================
33
34 void RWStepRepr_RWReprItemAndLengthMeasureWithUnit::ReadStep
35         (const Handle(StepData_StepReaderData)& data,
36          const Standard_Integer num0,
37          Handle(Interface_Check)& ach,
38          const Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)& ent) const
39 {
40   Standard_Integer num = 0;//num0;
41   data->NamedForComplex("MEASURE_WITH_UNIT",num0,num,ach);
42   if (!data->CheckNbParams(num,2,ach,"measure_with_unit")) return;
43   // --- own field : valueComponent ---
44   Handle(StepBasic_MeasureValueMember) mvc = new StepBasic_MeasureValueMember;
45   data->ReadMember (num,1, "value_component", ach, mvc);
46   // --- own field : unitComponent ---
47   StepBasic_Unit aUnitComponent;
48   data->ReadEntity(num, 2,"unit_component", ach, aUnitComponent);
49   Handle(StepBasic_MeasureWithUnit) aMeasureWithUnit = new StepBasic_MeasureWithUnit;
50   aMeasureWithUnit->Init(mvc, aUnitComponent);
51
52   data->NamedForComplex("REPRESENTATION_ITEM",num0,num,ach);
53   if (!data->CheckNbParams(num,1,ach,"representation_item")) return;
54   // --- own field : name ---
55   Handle(TCollection_HAsciiString) aName;
56   data->ReadString (num,1,"name",ach,aName);
57   Handle(StepRepr_RepresentationItem) aReprItem = new StepRepr_RepresentationItem;
58   aReprItem->Init(aName);
59
60   //--- Initialisation of the read entity ---
61   ent->Init(aMeasureWithUnit,aReprItem);
62 }
63
64
65 //=======================================================================
66 //function : WriteStep
67 //purpose  : 
68 //=======================================================================
69
70 void RWStepRepr_RWReprItemAndLengthMeasureWithUnit::WriteStep
71         (StepData_StepWriter& SW,
72          const Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)& ent) const
73 {
74   SW.StartEntity("LENGTH_MEASURE_WITH_UNIT");
75   SW.StartEntity("MEASURE_REPRESENTATION_ITEM");
76   SW.StartEntity("MEASURE_WITH_UNIT");
77   SW.Send(ent->GetMeasureWithUnit()->ValueComponentMember());
78   SW.Send(ent->GetMeasureWithUnit()->UnitComponent().Value());
79   SW.StartEntity("REPRESENTATION_ITEM");
80   SW.Send(ent->Name());
81 }