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 | |
42cf5bc1 |
14 | |
15 | #include <Interface_Check.hxx> |
16 | #include <RWStepBasic_RWSiUnit.hxx> |
17 | #include <RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit.hxx> |
7fd59977 |
18 | #include <StepBasic_DimensionalExponents.hxx> |
19 | #include <StepBasic_SiPrefix.hxx> |
42cf5bc1 |
20 | #include <StepBasic_SiUnit.hxx> |
21 | #include <StepBasic_SiUnitAndThermodynamicTemperatureUnit.hxx> |
7fd59977 |
22 | #include <StepBasic_SiUnitName.hxx> |
42cf5bc1 |
23 | #include <StepBasic_ThermodynamicTemperatureUnit.hxx> |
24 | #include <StepData_StepReaderData.hxx> |
25 | #include <StepData_StepWriter.hxx> |
7fd59977 |
26 | |
27 | //======================================================================= |
28 | //function : RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit |
29 | //purpose : |
30 | //======================================================================= |
7fd59977 |
31 | RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit::RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit () |
32 | { |
33 | } |
34 | |
35 | |
36 | //======================================================================= |
37 | //function : ReadStep |
38 | //purpose : |
39 | //======================================================================= |
40 | |
41 | void RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit::ReadStep |
42 | (const Handle(StepData_StepReaderData)& data, |
43 | const Standard_Integer num0, |
44 | Handle(Interface_Check)& ach, |
45 | const Handle(StepBasic_SiUnitAndThermodynamicTemperatureUnit)& ent) const |
46 | { |
47 | Standard_Integer num = num0; |
48 | |
49 | // --- Instance of common supertype NamedUnit --- |
50 | if (!data->CheckNbParams(num,1,ach,"named_unit")) return; |
51 | |
52 | // --- field : dimensions --- |
53 | // --- This field is redefined --- |
54 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
55 | data->CheckDerived(num,1,"dimensions",ach,Standard_False); |
56 | |
57 | // --- Instance of plex componant SiUnit --- |
58 | num = data->NextForComplex(num); |
59 | if (!data->CheckNbParams(num,2,ach,"si_unit")) return; |
60 | |
61 | // --- field : prefix --- |
62 | RWStepBasic_RWSiUnit reader; |
a8195d65 |
63 | StepBasic_SiPrefix aPrefix = StepBasic_spExa; |
7fd59977 |
64 | Standard_Boolean hasAprefix = Standard_False; |
65 | if (data->IsParamDefined(num,1)) { |
66 | if (data->ParamType(num,1) == Interface_ParamEnum) { |
67 | Standard_CString text = data->ParamCValue(num,1); |
68 | hasAprefix = reader.DecodePrefix(aPrefix,text); |
4e76d93b |
69 | if(!hasAprefix){ |
70 | ach->AddFail("Enumeration si_prefix has not an allowed value"); |
71 | return; |
72 | } |
73 | } |
74 | else{ |
75 | ach->AddFail("Parameter #1 (prefix) is not an enumeration"); |
76 | return; |
7fd59977 |
77 | } |
7fd59977 |
78 | } |
79 | |
80 | // --- field : name --- |
81 | StepBasic_SiUnitName aName; |
82 | if (data->ParamType(num,2) == Interface_ParamEnum) { |
83 | Standard_CString text = data->ParamCValue(num,2); |
4e76d93b |
84 | if(!reader.DecodeName(aName,text)){ |
7fd59977 |
85 | ach->AddFail("Enumeration si_unit_name has not an allowed value"); |
4e76d93b |
86 | return; |
87 | } |
88 | } |
89 | else{ |
90 | ach->AddFail("Parameter #2 (name) is not an enumeration"); |
91 | return; |
7fd59977 |
92 | } |
7fd59977 |
93 | |
94 | // --- Instance of plex componant SolidAngleUnit --- |
95 | num = data->NextForComplex(num); |
96 | if (!data->CheckNbParams(num,0,ach,"thermodynamic_temperature_unit")) return; |
97 | |
98 | //--- Initialisation of the red entity --- |
99 | ent->Init(hasAprefix,aPrefix,aName); |
100 | } |
101 | |
102 | |
103 | //======================================================================= |
104 | //function : WriteStep |
105 | //purpose : |
106 | //======================================================================= |
107 | |
108 | void RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit::WriteStep |
109 | (StepData_StepWriter& SW, |
110 | const Handle(StepBasic_SiUnitAndThermodynamicTemperatureUnit)& ent) const |
111 | { |
112 | // --- Instance of common supertype NamedUnit --- |
113 | SW.StartEntity("NAMED_UNIT"); |
114 | |
115 | // --- field : dimensions --- |
116 | // --- redefined field --- |
117 | SW.SendDerived(); |
118 | |
119 | // --- Instance of plex componant SiUnit --- |
120 | SW.StartEntity("SI_UNIT"); |
121 | |
122 | // --- field : prefix --- |
123 | RWStepBasic_RWSiUnit writer; |
124 | Standard_Boolean hasAprefix = ent->HasPrefix(); |
125 | if (hasAprefix) |
126 | SW.SendEnum(writer.EncodePrefix(ent->Prefix())); |
127 | else |
128 | SW.SendUndef(); |
129 | |
130 | // --- field : name --- |
131 | SW.SendEnum(writer.EncodeName(ent->Name())); |
132 | |
133 | // --- Instance of plex componant SolidAngleUnit --- |
134 | SW.StartEntity("THERMODYNAMIC_TEMPERATURE_UNIT"); |
135 | } |
136 | |