1 // Created on: 1999-10-12
2 // Created by: data exchange team
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <RWStepBasic_RWSiUnitAndVolumeUnit.ixx>
24 #include <StepBasic_SiUnit.hxx>
25 #include <RWStepBasic_RWSiUnit.hxx>
27 RWStepBasic_RWSiUnitAndVolumeUnit::RWStepBasic_RWSiUnitAndVolumeUnit()
31 void RWStepBasic_RWSiUnitAndVolumeUnit::ReadStep(const Handle(StepData_StepReaderData)& data,
32 const Standard_Integer num0,
33 Handle(Interface_Check)& ach,
34 const Handle(StepBasic_SiUnitAndVolumeUnit)& ent) const
36 Standard_Integer num = 0;
37 data->NamedForComplex("NAMED_UNIT NMDUNT",num0,num,ach);
38 if (!data->CheckNbParams(num,1,ach,"named_unit")) return;
39 Handle(StepBasic_DimensionalExponents) aDimensions;
40 data->ReadEntity(num, 1,"dimensions", ach, STANDARD_TYPE(StepBasic_DimensionalExponents), aDimensions);
42 data->NamedForComplex("SI_UNIT SUNT",num0,num,ach);
43 if (!data->CheckNbParams(num,2,ach,"si_unit")) return;
45 RWStepBasic_RWSiUnit reader;
46 StepBasic_SiPrefix aPrefix = StepBasic_spExa;
47 Standard_Boolean hasAprefix = Standard_False;
48 if (data->IsParamDefined(num,1)) {
49 if (data->ParamType(num,1) == Interface_ParamEnum) {
50 Standard_CString text = data->ParamCValue(num,1);
51 hasAprefix = reader.DecodePrefix(aPrefix,text);
53 ach->AddFail("Enumeration si_prefix has not an allowed value");
58 ach->AddFail("Parameter #2 (prefix) is not an enumeration");
63 StepBasic_SiUnitName aName;
64 if (data->ParamType(num,2) == Interface_ParamEnum) {
65 Standard_CString text = data->ParamCValue(num,2);
66 if(!reader.DecodeName(aName,text)){
67 ach->AddFail("Enumeration si_unit_name has not an allowed value");
72 ach->AddFail("Parameter #3 (name) is not an enumeration");
76 data->NamedForComplex("VOLUME_UNIT",num0,num,ach);
77 if (!data->CheckNbParams(num,0,ach,"volume_unit")) return;
79 ent->Init(hasAprefix,aPrefix,aName);
80 ent->SetDimensions(aDimensions);
83 void RWStepBasic_RWSiUnitAndVolumeUnit::WriteStep(StepData_StepWriter& SW,
84 const Handle(StepBasic_SiUnitAndVolumeUnit)& ent) const
86 SW.StartEntity("NAMED_UNIT");
87 SW.Send(ent->Dimensions());
88 SW.StartEntity("SI_UNIT");
90 RWStepBasic_RWSiUnit writer;
91 Standard_Boolean hasAprefix = ent->HasPrefix();
93 SW.SendEnum(writer.EncodePrefix(ent->Prefix()));
97 SW.SendEnum(writer.EncodeName(ent->Name()));
98 SW.StartEntity("VOLUME_UNIT");