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.
14 // pdn 24.12.98 t3d_opt.stp: treatment of unsorted uncertanties
16 #include <RWStepBasic_RWSiUnitAndLengthUnit.ixx>
17 #include <StepBasic_SiUnit.hxx>
18 #include <StepBasic_LengthUnit.hxx>
19 #include <StepBasic_DimensionalExponents.hxx>
20 #include <StepBasic_SiPrefix.hxx>
21 #include <StepBasic_SiUnitName.hxx>
22 #include <RWStepBasic_RWSiUnit.hxx>
25 RWStepBasic_RWSiUnitAndLengthUnit::RWStepBasic_RWSiUnitAndLengthUnit ()
29 void RWStepBasic_RWSiUnitAndLengthUnit::ReadStep(const Handle(StepData_StepReaderData)& data,
30 const Standard_Integer num0,
31 Handle(Interface_Check)& ach,
32 const Handle(StepBasic_SiUnitAndLengthUnit)& ent) const
34 Standard_Integer num = 0; // num0;
35 Standard_Boolean sorted = data->NamedForComplex("LENGTH_UNIT LNGUNT",num0,num,ach);
37 // --- Instance of plex componant LengthUnit ---
38 if (!data->CheckNbParams(num,0,ach,"length_unit")) return;
40 if (!sorted) num = 0; //pdn unsorted case
41 sorted &=data->NamedForComplex("NAMED_UNIT NMDUNT",num0,num,ach);
43 // --- Instance of common supertype NamedUnit ---
44 if (!data->CheckNbParams(num,1,ach,"named_unit")) return;
46 // --- field : dimensions ---
47 // --- this field is redefined ---
48 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
49 data->CheckDerived(num,1,"dimensions",ach,Standard_False);
51 if (!sorted) num = 0; //pdn unsorted case
52 data->NamedForComplex("SI_UNIT SUNT",num0,num,ach);
54 // --- Instance of plex componant SiUnit ---
55 if (!data->CheckNbParams(num,2,ach,"si_unit")) return;
57 // --- field : prefix ---
58 RWStepBasic_RWSiUnit reader;
59 StepBasic_SiPrefix aPrefix = StepBasic_spExa;
60 Standard_Boolean hasAprefix = Standard_False;
61 if (data->IsParamDefined(num,1)) {
62 if (data->ParamType(num,1) == Interface_ParamEnum) {
63 Standard_CString text = data->ParamCValue(num,1);
64 hasAprefix = reader.DecodePrefix(aPrefix,text);
66 ach->AddFail("Enumeration si_prefix has not an allowed value");
71 ach->AddFail("Parameter #2 (prefix) is not an enumeration");
76 // --- field : name ---
77 StepBasic_SiUnitName aName;
78 if (data->ParamType(num,2) == Interface_ParamEnum) {
79 Standard_CString text = data->ParamCValue(num,2);
80 if(!reader.DecodeName(aName,text)){
81 ach->AddFail("Enumeration si_unit_name has not an allowed value");
86 ach->AddFail("Parameter #2 (name) is not an enumeration");
90 //--- Initialisation of the red entity ---
91 ent->Init(hasAprefix,aPrefix,aName);
95 void RWStepBasic_RWSiUnitAndLengthUnit::WriteStep(StepData_StepWriter& SW,
96 const Handle(StepBasic_SiUnitAndLengthUnit)& ent) const
99 // --- Instance of plex componant LengthUnit ---
100 SW.StartEntity("LENGTH_UNIT");
102 // --- Instance of common supertype NamedUnit ---
103 SW.StartEntity("NAMED_UNIT");
105 // --- field : dimensions ---
106 // --- redefined field ---
109 // --- Instance of plex componant SiUnit ---
110 SW.StartEntity("SI_UNIT");
112 // --- field : prefix ---
113 RWStepBasic_RWSiUnit writer;
114 Standard_Boolean hasAprefix = ent->HasPrefix();
116 SW.SendEnum(writer.EncodePrefix(ent->Prefix()));
120 // --- field : name ---
121 SW.SendEnum(writer.EncodeName(ent->Name()));