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