b311480e |
1 | // Created on: 1999-10-12 |
2 | // Created by: data exchange team |
3 | // Copyright (c) 1999-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <RWStepBasic_RWSiUnitAndVolumeUnit.ixx> |
18 | #include <StepBasic_SiUnit.hxx> |
19 | #include <RWStepBasic_RWSiUnit.hxx> |
ec357c5c |
20 | #include <StepBasic_DimensionalExponents.hxx> |
7fd59977 |
21 | |
22 | RWStepBasic_RWSiUnitAndVolumeUnit::RWStepBasic_RWSiUnitAndVolumeUnit() |
23 | { |
24 | } |
25 | |
26 | void RWStepBasic_RWSiUnitAndVolumeUnit::ReadStep(const Handle(StepData_StepReaderData)& data, |
27 | const Standard_Integer num0, |
28 | Handle(Interface_Check)& ach, |
29 | const Handle(StepBasic_SiUnitAndVolumeUnit)& ent) const |
30 | { |
31 | Standard_Integer num = 0; |
32 | data->NamedForComplex("NAMED_UNIT NMDUNT",num0,num,ach); |
33 | if (!data->CheckNbParams(num,1,ach,"named_unit")) return; |
34 | Handle(StepBasic_DimensionalExponents) aDimensions; |
35 | data->ReadEntity(num, 1,"dimensions", ach, STANDARD_TYPE(StepBasic_DimensionalExponents), aDimensions); |
36 | |
37 | data->NamedForComplex("SI_UNIT SUNT",num0,num,ach); |
38 | if (!data->CheckNbParams(num,2,ach,"si_unit")) return; |
39 | |
40 | RWStepBasic_RWSiUnit reader; |
1d47d8d0 |
41 | StepBasic_SiPrefix aPrefix = StepBasic_spExa; |
7fd59977 |
42 | Standard_Boolean hasAprefix = Standard_False; |
43 | if (data->IsParamDefined(num,1)) { |
44 | if (data->ParamType(num,1) == Interface_ParamEnum) { |
45 | Standard_CString text = data->ParamCValue(num,1); |
46 | hasAprefix = reader.DecodePrefix(aPrefix,text); |
4e76d93b |
47 | if(!hasAprefix){ |
48 | ach->AddFail("Enumeration si_prefix has not an allowed value"); |
49 | return; |
50 | } |
51 | } |
52 | else{ |
53 | ach->AddFail("Parameter #2 (prefix) is not an enumeration"); |
54 | return; |
7fd59977 |
55 | } |
7fd59977 |
56 | } |
57 | |
58 | StepBasic_SiUnitName aName; |
59 | if (data->ParamType(num,2) == Interface_ParamEnum) { |
60 | Standard_CString text = data->ParamCValue(num,2); |
4e76d93b |
61 | if(!reader.DecodeName(aName,text)){ |
7fd59977 |
62 | ach->AddFail("Enumeration si_unit_name has not an allowed value"); |
4e76d93b |
63 | return; |
64 | } |
65 | } |
66 | else{ |
67 | ach->AddFail("Parameter #3 (name) is not an enumeration"); |
68 | return; |
7fd59977 |
69 | } |
7fd59977 |
70 | |
71 | data->NamedForComplex("VOLUME_UNIT",num0,num,ach); |
72 | if (!data->CheckNbParams(num,0,ach,"volume_unit")) return; |
73 | |
74 | ent->Init(hasAprefix,aPrefix,aName); |
75 | ent->SetDimensions(aDimensions); |
76 | } |
77 | |
78 | void RWStepBasic_RWSiUnitAndVolumeUnit::WriteStep(StepData_StepWriter& SW, |
79 | const Handle(StepBasic_SiUnitAndVolumeUnit)& ent) const |
80 | { |
81 | SW.StartEntity("NAMED_UNIT"); |
82 | SW.Send(ent->Dimensions()); |
83 | SW.StartEntity("SI_UNIT"); |
84 | |
85 | RWStepBasic_RWSiUnit writer; |
86 | Standard_Boolean hasAprefix = ent->HasPrefix(); |
87 | if (hasAprefix) |
88 | SW.SendEnum(writer.EncodePrefix(ent->Prefix())); |
89 | else |
90 | SW.SendUndef(); |
91 | |
92 | SW.SendEnum(writer.EncodeName(ent->Name())); |
93 | SW.StartEntity("VOLUME_UNIT"); |
94 | } |
95 | |
96 | |