0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / RWStepRepr / RWStepRepr_RWMeasureRepresentationItem.cxx
1 // Created on: 1999-09-08
2 // Created by: Andrey BETENEV
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Interface_Check.hxx>
19 #include <Interface_EntityIterator.hxx>
20 #include <Interface_FloatWriter.hxx>
21 #include <Interface_MSG.hxx>
22 #include <RWStepRepr_RWMeasureRepresentationItem.hxx>
23 #include <StepBasic_MeasureValueMember.hxx>
24 #include <StepBasic_MeasureWithUnit.hxx>
25 #include <StepBasic_NamedUnit.hxx>
26 #include <StepData_StepReaderData.hxx>
27 #include <StepData_StepWriter.hxx>
28 #include <StepRepr_MeasureRepresentationItem.hxx>
29 #include <TCollection_AsciiString.hxx>
30
31 #include <string.h>
32 //=======================================================================
33 //function : RWStepRepr_RWMeasureRepresentationItem
34 //purpose  : 
35 //=======================================================================
36 RWStepRepr_RWMeasureRepresentationItem::RWStepRepr_RWMeasureRepresentationItem () {}
37
38 //=======================================================================
39 //function : ReadStep
40 //purpose  : 
41 //=======================================================================
42
43 void RWStepRepr_RWMeasureRepresentationItem::ReadStep (const Handle(StepData_StepReaderData)& data,
44                                                        const Standard_Integer num,
45                                                        Handle(Interface_Check)& ach,
46                                                        const Handle(StepRepr_MeasureRepresentationItem)& ent) const
47 {
48   // --- Number of Parameter Control ---
49
50   if (!data->CheckNbParams(num,3,ach,"measure_representation_item")) return;
51
52   // --- inherited from representation_item : name ---
53   Handle(TCollection_HAsciiString) aName;
54   data->ReadString (num,1,"name",ach,aName);
55
56   // --- inherited from measure_with_unit : value_component ---
57   Handle(StepBasic_MeasureValueMember) mvc = new StepBasic_MeasureValueMember;
58   data->ReadMember (num,2, "value_component", ach, mvc);
59
60   // --- inherited from measure_with_unit : unit_component ---
61   StepBasic_Unit aUnitComponent;
62   data->ReadEntity(num, 3,"unit_component", ach, aUnitComponent);
63
64   //--- Initialisation of the read entity ---
65
66   ent->Init(aName, mvc, aUnitComponent);
67 }
68
69 //=======================================================================
70 //function : WriteStep
71 //purpose  : 
72 //=======================================================================
73
74 void RWStepRepr_RWMeasureRepresentationItem::WriteStep (StepData_StepWriter& SW,
75                                                         const Handle(StepRepr_MeasureRepresentationItem)& ent) const
76 {
77   // --- inherited from representation_item : name ---
78   SW.Send(ent->Name());
79
80   // --- inherited from measure_with_unit : value_component ---
81   SW.Send(ent->Measure()->ValueComponentMember());
82   
83   // --- inherited from measure_with_unit : unit_component ---
84   SW.Send(ent->Measure()->UnitComponent().Value());
85 }
86
87 //=======================================================================
88 //function : Share
89 //purpose  : 
90 //=======================================================================
91
92 void RWStepRepr_RWMeasureRepresentationItem::Share(const Handle(StepRepr_MeasureRepresentationItem)& ent, 
93                                                    Interface_EntityIterator& iter) const
94 {
95   
96   iter.GetOneItem(ent->Measure()->UnitComponent().Value());
97 }
98