1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <RWStepBasic_RWSiUnit.hxx>
16 #include <RWStepBasic_RWSiUnitAndPlaneAngleUnit.hxx>
17 #include <StepBasic_DimensionalExponents.hxx>
18 #include <StepBasic_SiPrefix.hxx>
19 #include <StepBasic_SiUnitAndPlaneAngleUnit.hxx>
20 #include <StepBasic_SiUnitName.hxx>
21 #include <StepData_StepReaderData.hxx>
22 #include <StepData_StepWriter.hxx>
24 RWStepBasic_RWSiUnitAndPlaneAngleUnit::RWStepBasic_RWSiUnitAndPlaneAngleUnit ()
28 void RWStepBasic_RWSiUnitAndPlaneAngleUnit::ReadStep(const Handle(StepData_StepReaderData)& data,
29 const Standard_Integer num0,
30 Handle(Interface_Check)& ach,
31 const Handle(StepBasic_SiUnitAndPlaneAngleUnit)& ent) const
33 Standard_Integer num = num0;
35 // --- Instance of common supertype NamedUnit ---
36 if (!data->CheckNbParams(num,1,ach,"named_unit")) return;
38 // --- field : dimensions ---
39 // --- this field is redefined ---
40 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
41 data->CheckDerived(num,1,"dimensions",ach,Standard_False);
42 num = data->NextForComplex(num);
44 // --- Instance of plex component PlaneAngleUnit ---
45 if (!data->CheckNbParams(num,0,ach,"plane_angle_unit")) return;
46 num = data->NextForComplex(num);
48 // --- Instance of plex component SiUnit ---
49 if (!data->CheckNbParams(num,2,ach,"si_unit")) return;
51 // --- field : prefix ---
52 RWStepBasic_RWSiUnit reader;
53 StepBasic_SiPrefix aPrefix = StepBasic_spExa;
54 Standard_Boolean hasAprefix = Standard_False;
55 if (data->IsParamDefined(num,1)) {
56 if (data->ParamType(num,1) == Interface_ParamEnum) {
57 Standard_CString text = data->ParamCValue(num,1);
58 hasAprefix = reader.DecodePrefix(aPrefix,text);
60 ach->AddFail("Enumeration si_prefix has not an allowed value");
65 ach->AddFail("Parameter #2 (prefix) is not an enumeration");
70 // --- field : name ---
71 StepBasic_SiUnitName aName;
72 if (data->ParamType(num,2) == Interface_ParamEnum) {
73 Standard_CString text = data->ParamCValue(num,2);
74 if(!reader.DecodeName(aName,text)){
75 ach->AddFail("Enumeration si_unit_name has not an allowed value");
80 ach->AddFail("Parameter #2 (name) is not an enumeration");
84 //--- Initialisation of the red entity ---
85 ent->Init(hasAprefix,aPrefix,aName);
89 void RWStepBasic_RWSiUnitAndPlaneAngleUnit::WriteStep(StepData_StepWriter& SW,
90 const Handle(StepBasic_SiUnitAndPlaneAngleUnit)& ent) const
92 // --- Instance of common supertype NamedUnit ---
93 SW.StartEntity("NAMED_UNIT");
95 // --- field : dimensions ---
96 // --- redefined field ---
99 // --- Instance of plex component PlaneAngleUnit ---
100 SW.StartEntity("PLANE_ANGLE_UNIT");
102 // --- Instance of plex component SiUnit ---
103 SW.StartEntity("SI_UNIT");
105 // --- field : prefix ---
106 RWStepBasic_RWSiUnit writer;
107 Standard_Boolean hasAprefix = ent->HasPrefix();
109 SW.SendEnum(writer.EncodePrefix(ent->Prefix()));
113 // --- field : name ---
114 SW.SendEnum(writer.EncodeName(ent->Name()));