973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | //gka 05.03.99 S4134 upgrade from CD to DIS |
7fd59977 |
15 | |
42cf5bc1 |
16 | #include <Interface_Check.hxx> |
7fd59977 |
17 | #include <Interface_EntityIterator.hxx> |
18 | #include <Interface_FloatWriter.hxx> |
19 | #include <Interface_MSG.hxx> |
42cf5bc1 |
20 | #include <RWStepBasic_RWUncertaintyMeasureWithUnit.hxx> |
21 | #include <StepBasic_MeasureValueMember.hxx> |
22 | #include <StepBasic_NamedUnit.hxx> |
7fd59977 |
23 | #include <StepBasic_UncertaintyMeasureWithUnit.hxx> |
42cf5bc1 |
24 | #include <StepData_StepReaderData.hxx> |
25 | #include <StepData_StepWriter.hxx> |
26 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
27 | |
42cf5bc1 |
28 | #include <string.h> |
7fd59977 |
29 | //======================================================================= |
30 | //function : RWStepBasic_RWUncertaintyMeasureWithUnit |
31 | //purpose : |
32 | //======================================================================= |
7fd59977 |
33 | RWStepBasic_RWUncertaintyMeasureWithUnit::RWStepBasic_RWUncertaintyMeasureWithUnit () {} |
34 | |
35 | //======================================================================= |
36 | //function : ReadStep |
37 | //purpose : |
38 | //======================================================================= |
39 | |
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 |
44 | { |
45 | if (data->IsComplex (num)) { |
46 | |
47 | ach->AddWarning ("Complex Type not allowed, only suitable values are read"); |
48 | |
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 |
56 | |
57 | // LENGTH_MEASURE_WITH_UNIT : on passe |
58 | Standard_Integer num1 = num; |
59 | |
60 | // MEASURE_WITH_UNIT |
61 | num1 = data->NextForComplex (num1); |
62 | |
63 | if (!data->CheckNbParams(num1,2,ach,"measure_with_unit")) return; |
64 | |
65 | // --- inherited field : valueComponent --- |
66 | Handle(StepBasic_MeasureValueMember) mvc = new StepBasic_MeasureValueMember; |
67 | data->ReadMember (num1,1, "value_component", ach, mvc); |
68 | |
69 | // --- inherited field : unitComponent --- |
70 | StepBasic_Unit aUnitComponent; |
71 | data->ReadEntity(num1, 2,"unit_component", ach, aUnitComponent); |
72 | |
73 | // UNCERTAINTY_MEASURE_WITH_UNIT (ce qu il en reste !) |
74 | num1 = data->NextForComplex (num1); |
75 | |
76 | if (!data->CheckNbParams(num1,2,ach,"uncertainty_measure_with_unit")) return; |
77 | |
78 | // --- own field : name --- |
79 | Handle(TCollection_HAsciiString) aName; |
80 | data->ReadString (num1,1,"name",ach,aName); |
81 | |
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); |
86 | } |
87 | // Ca yest, on peut faire l init |
88 | |
89 | ent->Init(mvc, aUnitComponent, aName, aDescription); |
90 | return; |
91 | } |
92 | |
93 | // --- Number of Parameter Control --- |
94 | |
95 | if (!data->CheckNbParams(num,4,ach,"uncertainty_measure_with_unit")) return; |
96 | |
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); |
104 | |
105 | // --- inherited field : unitComponent --- |
106 | StepBasic_Unit aUnitComponent; |
107 | data->ReadEntity(num, 2,"unit_component", ach, aUnitComponent); |
108 | |
109 | // --- own field : name --- |
110 | Handle(TCollection_HAsciiString) aName; |
111 | data->ReadString (num,3,"name",ach,aName); |
112 | |
113 | // --- own field : description --- |
114 | Handle(TCollection_HAsciiString) aDescription; |
115 | data->ReadString (num,4,"description",ach,aDescription); |
116 | |
117 | //--- Initialisation of the read entity --- |
118 | ent->Init(mvc, aUnitComponent, aName, aDescription); |
119 | } |
120 | |
121 | |
122 | //======================================================================= |
123 | //function : WriteStep |
124 | //purpose : |
125 | //======================================================================= |
126 | |
127 | void RWStepBasic_RWUncertaintyMeasureWithUnit::WriteStep (StepData_StepWriter& SW, |
128 | const Handle(StepBasic_UncertaintyMeasureWithUnit)& ent) const |
129 | { |
130 | |
131 | // --- inherited field valueComponent --- |
132 | |
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 |
138 | |
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); |
145 | |
146 | // SW.AddString("LENGTH_MEASURE"); |
147 | // SW.OpenSub(); |
148 | |
149 | // UPDATE 31-MARS-1997 by CKY : ca devrait etre bon desormais |
150 | SW.Send(ent->ValueComponentMember()); |
151 | // SW.CloseSub(); |
152 | |
153 | // --- inherited field unitComponent --- |
154 | SW.Send(ent->UnitComponent().Value()); |
155 | |
156 | // --- own field : name --- |
157 | SW.Send(ent->Name()); |
158 | |
159 | // --- own field : description --- |
160 | SW.Send(ent->Description()); |
161 | } |
162 | |
163 | //======================================================================= |
164 | //function : Share |
165 | //purpose : |
166 | //======================================================================= |
167 | |
168 | void RWStepBasic_RWUncertaintyMeasureWithUnit::Share (const Handle(StepBasic_UncertaintyMeasureWithUnit)& ent, |
169 | Interface_EntityIterator& iter) const |
170 | { |
171 | |
172 | iter.GetOneItem(ent->UnitComponent().Value()); |
173 | } |
174 | |