b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
3 | // The content of this file is subject to the Open CASCADE Technology Public |
4 | // License Version 6.5 (the "License"). You may not use the content of this file |
5 | // except in compliance with the License. Please obtain a copy of the License |
6 | // at http://www.opencascade.org and read it completely before using this file. |
7 | // |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
10 | // |
11 | // The Original Code and all software distributed under the License is |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
13 | // Initial Developer hereby disclaims all such warranties, including without |
14 | // limitation, any warranties of merchantability, fitness for a particular |
15 | // purpose or non-infringement. Please see the License for the specific terms |
16 | // and conditions governing the rights and limitations under the License. |
17 | |
7fd59977 |
18 | #include <RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit.ixx> |
19 | #include <StepBasic_SiUnit.hxx> |
20 | #include <StepBasic_ThermodynamicTemperatureUnit.hxx> |
21 | #include <StepBasic_DimensionalExponents.hxx> |
22 | #include <StepBasic_SiPrefix.hxx> |
23 | #include <StepBasic_SiUnitName.hxx> |
24 | #include <RWStepBasic_RWSiUnit.hxx> |
25 | |
26 | |
27 | //======================================================================= |
28 | //function : RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit |
29 | //purpose : |
30 | //======================================================================= |
31 | |
32 | RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit::RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit () |
33 | { |
34 | } |
35 | |
36 | |
37 | //======================================================================= |
38 | //function : ReadStep |
39 | //purpose : |
40 | //======================================================================= |
41 | |
42 | void RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit::ReadStep |
43 | (const Handle(StepData_StepReaderData)& data, |
44 | const Standard_Integer num0, |
45 | Handle(Interface_Check)& ach, |
46 | const Handle(StepBasic_SiUnitAndThermodynamicTemperatureUnit)& ent) const |
47 | { |
48 | Standard_Integer num = num0; |
49 | |
50 | // --- Instance of common supertype NamedUnit --- |
51 | if (!data->CheckNbParams(num,1,ach,"named_unit")) return; |
52 | |
53 | // --- field : dimensions --- |
54 | // --- This field is redefined --- |
55 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
56 | data->CheckDerived(num,1,"dimensions",ach,Standard_False); |
57 | |
58 | // --- Instance of plex componant SiUnit --- |
59 | num = data->NextForComplex(num); |
60 | if (!data->CheckNbParams(num,2,ach,"si_unit")) return; |
61 | |
62 | // --- field : prefix --- |
63 | RWStepBasic_RWSiUnit reader; |
a8195d65 |
64 | StepBasic_SiPrefix aPrefix = StepBasic_spExa; |
7fd59977 |
65 | Standard_Boolean hasAprefix = Standard_False; |
66 | if (data->IsParamDefined(num,1)) { |
67 | if (data->ParamType(num,1) == Interface_ParamEnum) { |
68 | Standard_CString text = data->ParamCValue(num,1); |
69 | hasAprefix = reader.DecodePrefix(aPrefix,text); |
4e76d93b |
70 | if(!hasAprefix){ |
71 | ach->AddFail("Enumeration si_prefix has not an allowed value"); |
72 | return; |
73 | } |
74 | } |
75 | else{ |
76 | ach->AddFail("Parameter #1 (prefix) is not an enumeration"); |
77 | return; |
7fd59977 |
78 | } |
7fd59977 |
79 | } |
80 | |
81 | // --- field : name --- |
82 | StepBasic_SiUnitName aName; |
83 | if (data->ParamType(num,2) == Interface_ParamEnum) { |
84 | Standard_CString text = data->ParamCValue(num,2); |
4e76d93b |
85 | if(!reader.DecodeName(aName,text)){ |
7fd59977 |
86 | ach->AddFail("Enumeration si_unit_name has not an allowed value"); |
4e76d93b |
87 | return; |
88 | } |
89 | } |
90 | else{ |
91 | ach->AddFail("Parameter #2 (name) is not an enumeration"); |
92 | return; |
7fd59977 |
93 | } |
7fd59977 |
94 | |
95 | // --- Instance of plex componant SolidAngleUnit --- |
96 | num = data->NextForComplex(num); |
97 | if (!data->CheckNbParams(num,0,ach,"thermodynamic_temperature_unit")) return; |
98 | |
99 | //--- Initialisation of the red entity --- |
100 | ent->Init(hasAprefix,aPrefix,aName); |
101 | } |
102 | |
103 | |
104 | //======================================================================= |
105 | //function : WriteStep |
106 | //purpose : |
107 | //======================================================================= |
108 | |
109 | void RWStepBasic_RWSiUnitAndThermodynamicTemperatureUnit::WriteStep |
110 | (StepData_StepWriter& SW, |
111 | const Handle(StepBasic_SiUnitAndThermodynamicTemperatureUnit)& ent) const |
112 | { |
113 | // --- Instance of common supertype NamedUnit --- |
114 | SW.StartEntity("NAMED_UNIT"); |
115 | |
116 | // --- field : dimensions --- |
117 | // --- redefined field --- |
118 | SW.SendDerived(); |
119 | |
120 | // --- Instance of plex componant SiUnit --- |
121 | SW.StartEntity("SI_UNIT"); |
122 | |
123 | // --- field : prefix --- |
124 | RWStepBasic_RWSiUnit writer; |
125 | Standard_Boolean hasAprefix = ent->HasPrefix(); |
126 | if (hasAprefix) |
127 | SW.SendEnum(writer.EncodePrefix(ent->Prefix())); |
128 | else |
129 | SW.SendUndef(); |
130 | |
131 | // --- field : name --- |
132 | SW.SendEnum(writer.EncodeName(ent->Name())); |
133 | |
134 | // --- Instance of plex componant SolidAngleUnit --- |
135 | SW.StartEntity("THERMODYNAMIC_TEMPERATURE_UNIT"); |
136 | } |
137 | |