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 <Interface_Check.hxx>
16 #include <RWStepBasic_RWSiUnit.hxx>
17 #include <RWStepBasic_RWSiUnitAndTimeUnit.hxx>
18 #include <StepBasic_DimensionalExponents.hxx>
19 #include <StepBasic_SiPrefix.hxx>
20 #include <StepBasic_SiUnit.hxx>
21 #include <StepBasic_SiUnitAndTimeUnit.hxx>
22 #include <StepBasic_SiUnitName.hxx>
23 #include <StepBasic_TimeUnit.hxx>
24 #include <StepData_StepReaderData.hxx>
25 #include <StepData_StepWriter.hxx>
27 //=======================================================================
28 //function : RWStepBasic_RWSiUnitAndTimeUnit
30 //=======================================================================
31 RWStepBasic_RWSiUnitAndTimeUnit::RWStepBasic_RWSiUnitAndTimeUnit ()
36 //=======================================================================
39 //=======================================================================
41 void RWStepBasic_RWSiUnitAndTimeUnit::ReadStep (const Handle(StepData_StepReaderData)& data,
42 const Standard_Integer num0,
43 Handle(Interface_Check)& ach,
44 const Handle(StepBasic_SiUnitAndTimeUnit)& ent) const
46 Standard_Integer num = num0;
48 // --- Instance of common supertype NamedUnit ---
49 if (!data->CheckNbParams(num,1,ach,"named_unit")) return;
51 // --- field : dimensions ---
52 // --- this field is redefined ---
53 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =`
54 data->CheckDerived(num,1,"dimensions",ach,Standard_False);
56 // --- Instance of plex component SiUnit ---
57 num = data->NextForComplex(num);
58 if (!data->CheckNbParams(num,2,ach,"si_unit")) return;
60 // --- field : prefix ---
61 RWStepBasic_RWSiUnit reader;
62 StepBasic_SiPrefix aPrefix = StepBasic_spExa;
63 Standard_Boolean hasAprefix = Standard_False;
64 if (data->IsParamDefined(num,1)) {
65 if (data->ParamType(num,1) == Interface_ParamEnum) {
66 Standard_CString text = data->ParamCValue(num,1);
67 hasAprefix = reader.DecodePrefix(aPrefix,text);
69 ach->AddFail("Enumeration si_prefix has not an allowed value");
74 ach->AddFail("Parameter #1 (prefix) is not an enumeration");
79 // --- field : name ---
80 StepBasic_SiUnitName aName;
81 if (data->ParamType(num,2) == Interface_ParamEnum) {
82 Standard_CString text = data->ParamCValue(num,2);
83 if(!reader.DecodeName(aName,text)){
84 ach->AddFail("Enumeration si_unit_name has not an allowed value");
89 ach->AddFail("Parameter #2 (name) is not an enumeration");
93 // --- Instance of plex component TimeUnit ---
94 num = data->NextForComplex(num);
95 if (!data->CheckNbParams(num,0,ach,"time_unit")) return;
97 //--- Initialisation of the red entity ---
98 ent->Init(hasAprefix,aPrefix,aName);
102 //=======================================================================
103 //function : WriteStep
105 //=======================================================================
107 void RWStepBasic_RWSiUnitAndTimeUnit::WriteStep (StepData_StepWriter& SW,
108 const Handle(StepBasic_SiUnitAndTimeUnit)& ent) const
111 // --- Instance of plex component TimeUnit ---
112 //SW.StartEntity("TIME_UNIT");
114 // --- Instance of common supertype NamedUnit ---
115 SW.StartEntity("NAMED_UNIT");
117 // --- field : dimensions ---
118 // --- redefined field ---
121 // --- Instance of plex component SiUnit ---
122 SW.StartEntity("SI_UNIT");
124 // --- field : prefix ---
125 RWStepBasic_RWSiUnit writer;
126 Standard_Boolean hasAprefix = ent->HasPrefix();
128 SW.SendEnum(writer.EncodePrefix(ent->Prefix()));
132 // --- field : name ---
133 SW.SendEnum(writer.EncodeName(ent->Name()));
135 // --- Instance of plex component TimeUnit ---
136 SW.StartEntity("TIME_UNIT");