Integration of OCCT 6.5.0 from SVN
[occt.git] / src / RWStepBasic / RWStepBasic_RWSiUnitAndPlaneAngleUnit.cxx
1 #include <RWStepBasic_RWSiUnitAndPlaneAngleUnit.ixx>
2 #include <StepBasic_SiUnit.hxx>
3 #include <StepBasic_PlaneAngleUnit.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_RWSiUnitAndPlaneAngleUnit::RWStepBasic_RWSiUnitAndPlaneAngleUnit ()
11 {
12 }
13
14 void RWStepBasic_RWSiUnitAndPlaneAngleUnit::ReadStep(const Handle(StepData_StepReaderData)& data,
15                                                      const Standard_Integer num0,
16                                                      Handle(Interface_Check)& ach,
17                                                      const Handle(StepBasic_SiUnitAndPlaneAngleUnit)& 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   num = data->NextForComplex(num);
29
30   // --- Instance of plex componant PlaneAngleUnit ---
31   if (!data->CheckNbParams(num,0,ach,"plane_angle_unit")) return;
32   num = data->NextForComplex(num);
33
34   // --- Instance of plex componant SiUnit ---
35   if (!data->CheckNbParams(num,2,ach,"si_unit")) return;
36
37   // --- field : prefix ---
38   RWStepBasic_RWSiUnit reader;
39   StepBasic_SiPrefix aPrefix;
40   Standard_Boolean hasAprefix = Standard_False;
41   if (data->IsParamDefined(num,1)) {
42     if (data->ParamType(num,1) == Interface_ParamEnum) {
43       Standard_CString text = data->ParamCValue(num,1);
44       hasAprefix = reader.DecodePrefix(aPrefix,text);
45       if(!hasAprefix)
46         ach->AddFail("Enumeration si_prefix has not an allowed value");
47     }
48     else ach->AddFail("Parameter #2 (prefix) is not an enumeration");
49   }
50         
51   // --- field : name ---
52   StepBasic_SiUnitName aName;
53   if (data->ParamType(num,2) == Interface_ParamEnum) {
54     Standard_CString text = data->ParamCValue(num,2);
55     if(!reader.DecodeName(aName,text))
56       ach->AddFail("Enumeration si_unit_name has not an allowed value");
57   }
58   else ach->AddFail("Parameter #2 (name) is not an enumeration");
59   
60   //--- Initialisation of the red entity ---
61   ent->Init(hasAprefix,aPrefix,aName);
62 }
63
64
65 void RWStepBasic_RWSiUnitAndPlaneAngleUnit::WriteStep(StepData_StepWriter& SW,
66                                                       const Handle(StepBasic_SiUnitAndPlaneAngleUnit)& 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 PlaneAngleUnit ---
76   SW.StartEntity("PLANE_ANGLE_UNIT");
77
78   // --- Instance of plex componant SiUnit ---
79   SW.StartEntity("SI_UNIT");
80         
81   // --- field : prefix ---
82   RWStepBasic_RWSiUnit writer;
83   Standard_Boolean hasAprefix = ent->HasPrefix();
84   if (hasAprefix) 
85     SW.SendEnum(writer.EncodePrefix(ent->Prefix()));
86   else
87     SW.SendUndef();
88   
89   // --- field : name ---
90   SW.SendEnum(writer.EncodeName(ent->Name()));
91 }