28a73c1f |
1 | // Created on: 2015-07-16 |
2 | // Created by: Irina KRYLOVA |
3 | // Copyright (c) 2015 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #include <RWStepDimTol_RWDatumReferenceModifierWithValue.hxx> |
17 | |
18 | #include <Interface_Check.hxx> |
19 | #include <Interface_EntityIterator.hxx> |
20 | #include <StepData_StepReaderData.hxx> |
21 | #include <StepData_StepWriter.hxx> |
22 | #include <StepBasic_LengthMeasureWithUnit.hxx> |
23 | #include <StepDimTol_DatumReferenceModifierType.hxx> |
24 | #include <StepDimTol_DatumReferenceModifierWithValue.hxx> |
25 | |
26 | //======================================================================= |
27 | //function : RWStepDimTol_RWGeometricTolerance |
28 | //purpose : |
29 | //======================================================================= |
30 | |
31 | RWStepDimTol_RWDatumReferenceModifierWithValue::RWStepDimTol_RWDatumReferenceModifierWithValue () |
32 | { |
33 | } |
34 | |
35 | //======================================================================= |
36 | //function : ReadStep |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | void RWStepDimTol_RWDatumReferenceModifierWithValue:: |
41 | ReadStep (const Handle(StepData_StepReaderData)& data, |
42 | const Standard_Integer num, |
43 | Handle(Interface_Check)& ach, |
44 | const Handle(StepDimTol_DatumReferenceModifierWithValue) &ent) const |
45 | { |
46 | // Check number of parameters |
47 | if ( ! data->CheckNbParams(num, 2, ach, "datum_reference_modifier_with_value") ) return; |
48 | |
49 | // own fields of DatumReferenceModifierWithValue |
50 | |
51 | StepDimTol_DatumReferenceModifierType aModifierType = StepDimTol_CircularOrCylindrical; |
52 | if (data->ParamType (num, 1) == Interface_ParamEnum) { |
53 | Standard_CString text = data->ParamCValue(num, 1); |
54 | if (strcmp(text, ".CIRCULAR_OR_CYLINDRICAL.")==0) aModifierType = StepDimTol_CircularOrCylindrical; |
55 | else if (strcmp(text, ".DISTANCE.")==0) aModifierType = StepDimTol_Distance; |
56 | else if (strcmp(text, ".PROJECTED.")==0) aModifierType = StepDimTol_Projected; |
57 | else if (strcmp(text, ".SPHERICAL.")==0) aModifierType = StepDimTol_Spherical; |
58 | else ach->AddFail("Parameter #1 (modifier_type) has not allowed value"); |
59 | } |
60 | else ach->AddFail("Parameter #1 (modifier_type) is not an enumeration"); |
61 | |
62 | Handle(StepBasic_LengthMeasureWithUnit) aModifierValue; |
63 | data->ReadEntity (num, 2, "modifier_value", ach, STANDARD_TYPE(StepBasic_LengthMeasureWithUnit), aModifierValue); |
64 | |
65 | // Initialize entity |
66 | ent->Init(aModifierType, |
67 | aModifierValue); |
68 | } |
69 | |
70 | //======================================================================= |
71 | //function : WriteStep |
72 | //purpose : |
73 | //======================================================================= |
74 | |
75 | void RWStepDimTol_RWDatumReferenceModifierWithValue:: |
76 | WriteStep (StepData_StepWriter& SW, |
77 | const Handle(StepDimTol_DatumReferenceModifierWithValue) &ent) const |
78 | { |
79 | // own fields of DatumReferenceModifierWithValue |
80 | |
81 | switch (ent->ModifierType()) { |
82 | case StepDimTol_CircularOrCylindrical: SW.SendEnum (".CIRCULAR_OR_CYLINDRICAL."); break; |
83 | case StepDimTol_Distance: SW.SendEnum (".DISTANCE."); break; |
84 | case StepDimTol_Projected: SW.SendEnum (".PROJECTED."); break; |
85 | case StepDimTol_Spherical: SW.SendEnum (".SPHERICAL."); break; |
86 | } |
87 | |
88 | SW.Send (ent->ModifierValue()); |
89 | } |