1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 // pdn 24.12.98 t3d_opt.stp: treatment of unsorted uncertanties
20 #include <RWStepBasic_RWSiUnitAndLengthUnit.ixx>
21 #include <StepBasic_SiUnit.hxx>
22 #include <StepBasic_LengthUnit.hxx>
23 #include <StepBasic_DimensionalExponents.hxx>
24 #include <StepBasic_SiPrefix.hxx>
25 #include <StepBasic_SiUnitName.hxx>
26 #include <RWStepBasic_RWSiUnit.hxx>
29 RWStepBasic_RWSiUnitAndLengthUnit::RWStepBasic_RWSiUnitAndLengthUnit ()
33 void RWStepBasic_RWSiUnitAndLengthUnit::ReadStep(const Handle(StepData_StepReaderData)& data,
34 const Standard_Integer num0,
35 Handle(Interface_Check)& ach,
36 const Handle(StepBasic_SiUnitAndLengthUnit)& ent) const
38 Standard_Integer num = 0; // num0;
39 Standard_Boolean sorted = data->NamedForComplex("LENGTH_UNIT LNGUNT",num0,num,ach);
41 // --- Instance of plex componant LengthUnit ---
42 if (!data->CheckNbParams(num,0,ach,"length_unit")) return;
44 if (!sorted) num = 0; //pdn unsorted case
45 sorted &=data->NamedForComplex("NAMED_UNIT NMDUNT",num0,num,ach);
47 // --- Instance of common supertype NamedUnit ---
48 if (!data->CheckNbParams(num,1,ach,"named_unit")) return;
50 // --- field : dimensions ---
51 // --- this field is redefined ---
52 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
53 data->CheckDerived(num,1,"dimensions",ach,Standard_False);
55 if (!sorted) num = 0; //pdn unsorted case
56 data->NamedForComplex("SI_UNIT SUNT",num0,num,ach);
58 // --- Instance of plex componant SiUnit ---
59 if (!data->CheckNbParams(num,2,ach,"si_unit")) return;
61 // --- field : prefix ---
62 RWStepBasic_RWSiUnit reader;
63 StepBasic_SiPrefix aPrefix;
64 Standard_Boolean hasAprefix = Standard_False;
65 if (data->IsParamDefined(num,1)) {
66 if (data->ParamType(num,1) == Interface_ParamEnum) {
67 Standard_CString text = data->ParamCValue(num,1);
68 hasAprefix = reader.DecodePrefix(aPrefix,text);
70 ach->AddFail("Enumeration si_prefix has not an allowed value");
75 ach->AddFail("Parameter #2 (prefix) is not an enumeration");
80 // --- field : name ---
81 StepBasic_SiUnitName aName;
82 if (data->ParamType(num,2) == Interface_ParamEnum) {
83 Standard_CString text = data->ParamCValue(num,2);
84 if(!reader.DecodeName(aName,text)){
85 ach->AddFail("Enumeration si_unit_name has not an allowed value");
90 ach->AddFail("Parameter #2 (name) is not an enumeration");
94 //--- Initialisation of the red entity ---
95 ent->Init(hasAprefix,aPrefix,aName);
99 void RWStepBasic_RWSiUnitAndLengthUnit::WriteStep(StepData_StepWriter& SW,
100 const Handle(StepBasic_SiUnitAndLengthUnit)& ent) const
103 // --- Instance of plex componant LengthUnit ---
104 SW.StartEntity("LENGTH_UNIT");
106 // --- Instance of common supertype NamedUnit ---
107 SW.StartEntity("NAMED_UNIT");
109 // --- field : dimensions ---
110 // --- redefined field ---
113 // --- Instance of plex componant SiUnit ---
114 SW.StartEntity("SI_UNIT");
116 // --- field : prefix ---
117 RWStepBasic_RWSiUnit writer;
118 Standard_Boolean hasAprefix = ent->HasPrefix();
120 SW.SendEnum(writer.EncodePrefix(ent->Prefix()));
124 // --- field : name ---
125 SW.SendEnum(writer.EncodeName(ent->Name()));