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