1 // Created on: 1999-10-11
2 // Created by: data exchange team
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Interface_Check.hxx>
19 #include <RWStepBasic_RWSiUnit.hxx>
20 #include <RWStepBasic_RWSiUnitAndAreaUnit.hxx>
21 #include <StepBasic_DimensionalExponents.hxx>
22 #include <StepBasic_SiUnit.hxx>
23 #include <StepBasic_SiUnitAndAreaUnit.hxx>
24 #include <StepData_StepReaderData.hxx>
25 #include <StepData_StepWriter.hxx>
27 RWStepBasic_RWSiUnitAndAreaUnit::RWStepBasic_RWSiUnitAndAreaUnit ()
31 void RWStepBasic_RWSiUnitAndAreaUnit::ReadStep(const Handle(StepData_StepReaderData)& data,
32 const Standard_Integer num0,
33 Handle(Interface_Check)& ach,
34 const Handle(StepBasic_SiUnitAndAreaUnit)& ent) const
36 Standard_Integer num = 0;
37 data->NamedForComplex("AREA_UNIT","ARUNT",num0,num,ach);
38 if (!data->CheckNbParams(num,0,ach,"area_unit")) return;
40 data->NamedForComplex("NAMED_UNIT", "NMDUNT",num0,num,ach);
41 if (!data->CheckNbParams(num,1,ach,"named_unit")) return;
42 Handle(StepBasic_DimensionalExponents) aDimensions;
43 data->ReadEntity(num, 1,"dimensions", ach, STANDARD_TYPE(StepBasic_DimensionalExponents), aDimensions);
45 data->NamedForComplex("SI_UNIT", "SUNT",num0,num,ach);
46 if (!data->CheckNbParams(num,2,ach,"si_unit")) return;
48 RWStepBasic_RWSiUnit reader;
49 StepBasic_SiPrefix aPrefix = StepBasic_spExa;
50 Standard_Boolean hasAprefix = Standard_False;
51 if (data->IsParamDefined(num,1)) {
52 if (data->ParamType(num,1) == Interface_ParamEnum) {
53 Standard_CString text = data->ParamCValue(num,1);
54 hasAprefix = reader.DecodePrefix(aPrefix,text);
56 ach->AddFail("Enumeration si_prefix has not an allowed value");
61 ach->AddFail("Parameter #2 (prefix) is not an enumeration");
66 StepBasic_SiUnitName aName;
67 if (data->ParamType(num,2) == Interface_ParamEnum) {
68 Standard_CString text = data->ParamCValue(num,2);
69 if(!reader.DecodeName(aName,text)){
70 ach->AddFail("Enumeration si_unit_name has not an allowed value");
75 ach->AddFail("Parameter #3 (name) is not an enumeration");
79 ent->Init(hasAprefix,aPrefix,aName);
80 ent->SetDimensions(aDimensions);
83 void RWStepBasic_RWSiUnitAndAreaUnit::WriteStep(StepData_StepWriter& SW,
84 const Handle(StepBasic_SiUnitAndAreaUnit)& ent) const
86 SW.StartEntity("AREA_UNIT");
87 SW.StartEntity("NAMED_UNIT");
88 SW.Send(ent->Dimensions());
89 SW.StartEntity("SI_UNIT");
91 RWStepBasic_RWSiUnit writer;
92 Standard_Boolean hasAprefix = ent->HasPrefix();
94 SW.SendEnum(writer.EncodePrefix(ent->Prefix()));
98 SW.SendEnum(writer.EncodeName(ent->Name()));