1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License 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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 //gka 05.03.99 S4134 upgrade from CD to DIS
16 #include <Interface_Check.hxx>
17 #include <Interface_EntityIterator.hxx>
18 #include <Interface_FloatWriter.hxx>
19 #include <Interface_MSG.hxx>
20 #include <RWStepBasic_RWUncertaintyMeasureWithUnit.hxx>
21 #include <StepBasic_MeasureValueMember.hxx>
22 #include <StepBasic_NamedUnit.hxx>
23 #include <StepBasic_UncertaintyMeasureWithUnit.hxx>
24 #include <StepData_StepReaderData.hxx>
25 #include <StepData_StepWriter.hxx>
26 #include <TCollection_AsciiString.hxx>
29 //=======================================================================
30 //function : RWStepBasic_RWUncertaintyMeasureWithUnit
32 //=======================================================================
33 RWStepBasic_RWUncertaintyMeasureWithUnit::RWStepBasic_RWUncertaintyMeasureWithUnit () {}
35 //=======================================================================
38 //=======================================================================
40 void RWStepBasic_RWUncertaintyMeasureWithUnit::ReadStep (const Handle(StepData_StepReaderData)& data,
41 const Standard_Integer num,
42 Handle(Interface_Check)& ach,
43 const Handle(StepBasic_UncertaintyMeasureWithUnit)& ent) const
45 if (data->IsComplex (num)) {
47 ach->AddWarning ("Complex Type not allowed, only suitable values are read");
49 // CATIA ecrit des trucs complexes, comme suit :
50 // LENGTH_MEASURE_WITH_UNIT ()
51 // MEASURE_WITH_UNIT (LENGTH_MEASURE(val),#..)
52 // UNCERTAINTY_MEASURE_WITH_UNIT ('str1','str2')
53 // -> c est illicite, LENGTH_MEASURE est un invite importun
54 // On relit en ignorant ce terme
55 // REMARQUE : le ReadWriteModule a deja fait le filtrage des types
57 // LENGTH_MEASURE_WITH_UNIT : on passe
58 Standard_Integer num1 = num;
61 num1 = data->NextForComplex (num1);
63 if (!data->CheckNbParams(num1,2,ach,"measure_with_unit")) return;
65 // --- inherited field : valueComponent ---
66 Handle(StepBasic_MeasureValueMember) mvc = new StepBasic_MeasureValueMember;
67 data->ReadMember (num1,1, "value_component", ach, mvc);
69 // --- inherited field : unitComponent ---
70 StepBasic_Unit aUnitComponent;
71 data->ReadEntity(num1, 2,"unit_component", ach, aUnitComponent);
73 // UNCERTAINTY_MEASURE_WITH_UNIT (ce qu il en reste !)
74 num1 = data->NextForComplex (num1);
76 if (!data->CheckNbParams(num1,2,ach,"uncertainty_measure_with_unit")) return;
78 // --- own field : name ---
79 Handle(TCollection_HAsciiString) aName;
80 data->ReadString (num1,1,"name",ach,aName);
82 // --- own field : description ---
83 Handle(TCollection_HAsciiString) aDescription;
84 if (data->IsParamDefined (num1,2)) { //gka 05.03.99 S4134 upgrade from CD to DIS
85 data->ReadString (num1,2,"description",ach,aDescription);
87 // Ca yest, on peut faire l init
89 ent->Init(mvc, aUnitComponent, aName, aDescription);
93 // --- Number of Parameter Control ---
95 if (!data->CheckNbParams(num,4,ach,"uncertainty_measure_with_unit")) return;
97 // --- inherited field : valueComponent ---
98 //Standard_Real aValueComponent;
99 //Standard_Boolean stat1;
100 //stat1 = data->ReadReal (num,1,"value_component",ach,aValueComponent);
101 // --- Update 12-02-96 by FMA => 31-MAR-1997 by CKY
102 Handle(StepBasic_MeasureValueMember) mvc = new StepBasic_MeasureValueMember;
103 data->ReadMember (num,1, "value_component", ach, mvc);
105 // --- inherited field : unitComponent ---
106 StepBasic_Unit aUnitComponent;
107 data->ReadEntity(num, 2,"unit_component", ach, aUnitComponent);
109 // --- own field : name ---
110 Handle(TCollection_HAsciiString) aName;
111 data->ReadString (num,3,"name",ach,aName);
113 // --- own field : description ---
114 Handle(TCollection_HAsciiString) aDescription;
115 data->ReadString (num,4,"description",ach,aDescription);
117 //--- Initialisation of the read entity ---
118 ent->Init(mvc, aUnitComponent, aName, aDescription);
122 //=======================================================================
123 //function : WriteStep
125 //=======================================================================
127 void RWStepBasic_RWUncertaintyMeasureWithUnit::WriteStep (StepData_StepWriter& SW,
128 const Handle(StepBasic_UncertaintyMeasureWithUnit)& ent) const
131 // --- inherited field valueComponent ---
133 // Update 12-02-96 by FMA
134 // The Value shall be Typed - LENGTH_MEASURE, PLANE_ANGLE_MEASURE,
135 // SOLID_ANGLE_MEASURE
136 // The actual state is LENGTH_MEASURE ONLY
137 // UPDATE to be done later but mandatory
139 // char lm[100],lmv[50];
140 // Interface_FloatWriter::Convert
141 // (Interface_MSG::Intervalled(ent->ValueComponent()*0.98,5,Standard_True),
142 // lmv,Standard_True, 10.,0.1,"%E","%E");
143 // sprintf (lm,"LENGTH_MEASURE(%s)",lmv);
144 // SW.SendString(lm);
146 // SW.AddString("LENGTH_MEASURE");
149 // UPDATE 31-MARS-1997 by CKY : ca devrait etre bon desormais
150 SW.Send(ent->ValueComponentMember());
153 // --- inherited field unitComponent ---
154 SW.Send(ent->UnitComponent().Value());
156 // --- own field : name ---
157 SW.Send(ent->Name());
159 // --- own field : description ---
160 SW.Send(ent->Description());
163 //=======================================================================
166 //=======================================================================
168 void RWStepBasic_RWUncertaintyMeasureWithUnit::Share (const Handle(StepBasic_UncertaintyMeasureWithUnit)& ent,
169 Interface_EntityIterator& iter) const
172 iter.GetOneItem(ent->UnitComponent().Value());