28a73c1f |
1 | // Created on: 2015-07-07 |
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_RWGeometricToleranceWithMaximumTolerance.hxx> |
17 | |
18 | #include <Interface_Check.hxx> |
19 | #include <Interface_EntityIterator.hxx> |
20 | #include <StepBasic_LengthMeasureWithUnit.hxx> |
21 | #include <StepData_StepReaderData.hxx> |
22 | #include <StepData_StepWriter.hxx> |
23 | #include <StepDimTol_GeometricToleranceModifier.hxx> |
24 | #include <StepDimTol_GeometricToleranceTarget.hxx> |
25 | #include <StepDimTol_GeometricToleranceWithMaximumTolerance.hxx> |
26 | #include <StepDimTol_HArray1OfGeometricToleranceModifier.hxx> |
92efcf78 |
27 | #include <StepBasic_MeasureWithUnit.hxx> |
28a73c1f |
28 | |
29 | //======================================================================= |
30 | //function : RWStepDimTol_RWGeometricTolerance |
31 | //purpose : |
32 | //======================================================================= |
33 | |
34 | RWStepDimTol_RWGeometricToleranceWithMaximumTolerance::RWStepDimTol_RWGeometricToleranceWithMaximumTolerance () |
35 | { |
36 | } |
37 | |
38 | //======================================================================= |
39 | //function : ReadStep |
40 | //purpose : |
41 | //======================================================================= |
42 | |
43 | void RWStepDimTol_RWGeometricToleranceWithMaximumTolerance:: |
44 | ReadStep (const Handle(StepData_StepReaderData)& data, |
45 | const Standard_Integer num, |
46 | Handle(Interface_Check)& ach, |
47 | const Handle(StepDimTol_GeometricToleranceWithMaximumTolerance) &ent) const |
48 | { |
49 | // Check number of parameters |
50 | if ( ! data->CheckNbParams(num, 6, ach, "geometric_tolerance_with_modifiers") ) return; |
51 | |
52 | // inherited fields from GeometricTolerance |
53 | |
54 | Handle(TCollection_HAsciiString) aName; |
55 | data->ReadString (num, 1, "geometric_tolerance.name", ach, aName); |
56 | |
57 | Handle(TCollection_HAsciiString) aDescription; |
58 | data->ReadString (num, 2, "geometric_tolerance.description", ach, aDescription); |
59 | |
60 | Handle(StepBasic_MeasureWithUnit) aMagnitude; |
61 | data->ReadEntity (num, 3, "geometric_tolerance.magnitude", ach, STANDARD_TYPE(StepBasic_MeasureWithUnit), aMagnitude); |
62 | |
63 | StepDimTol_GeometricToleranceTarget aTolerancedShapeAspect; |
64 | data->ReadEntity (num, 4, "geometric_tolerance.toleranced_shape_aspect", ach, aTolerancedShapeAspect); |
65 | |
66 | // inherited fields from GeometricToleranceWithModifiers |
67 | Handle(StepDimTol_HArray1OfGeometricToleranceModifier) aModifiers; |
68 | Standard_Integer sub5 = 0; |
69 | if ( data->ReadSubList (num, 5, "geometric_tolerance_with_modifiers.modifiers", ach, sub5) ) { |
70 | Standard_Integer nb0 = data->NbParams(sub5); |
71 | aModifiers = new StepDimTol_HArray1OfGeometricToleranceModifier (1, nb0); |
72 | Standard_Integer num2 = sub5; |
73 | for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) { |
74 | StepDimTol_GeometricToleranceModifier anIt0 = StepDimTol_GTMMaximumMaterialRequirement; |
75 | if (data->ParamType (num2, i0) == Interface_ParamEnum) { |
76 | Standard_CString text = data->ParamCValue(num2, i0); |
77 | if (strcmp(text, ".ANY_CROSS_SECTION.")==0) anIt0 = StepDimTol_GTMAnyCrossSection; |
78 | else if (strcmp(text, ".COMMON_ZONE.")==0) anIt0 = StepDimTol_GTMCommonZone; |
79 | else if (strcmp(text, ".EACH_RADIAL_ELEMENT.")==0) anIt0 = StepDimTol_GTMEachRadialElement; |
80 | else if (strcmp(text, ".FREE_STATE.")==0) anIt0 = StepDimTol_GTMFreeState; |
81 | else if (strcmp(text, ".LEAST_MATERIAL_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMLeastMaterialRequirement; |
82 | else if (strcmp(text, ".LINE_ELEMENT.")==0) anIt0 = StepDimTol_GTMLineElement; |
83 | else if (strcmp(text, ".MAJOR_DIAMETER.")==0) anIt0 = StepDimTol_GTMMajorDiameter; |
84 | else if (strcmp(text, ".MAXIMUM_MATERIAL_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMMaximumMaterialRequirement; |
85 | else if (strcmp(text, ".MINOR_DIAMETER.")==0) anIt0 = StepDimTol_GTMMinorDiameter; |
86 | else if (strcmp(text, ".NOT_CONVEX.")==0) anIt0 = StepDimTol_GTMNotConvex; |
87 | else if (strcmp(text, ".PITCH_DIAMETER.")==0) anIt0 = StepDimTol_GTMPitchDiameter; |
88 | else if (strcmp(text, ".RECIPROCITY_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMReciprocityRequirement; |
89 | else if (strcmp(text, ".SEPARATE_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMSeparateRequirement; |
90 | else if (strcmp(text, ".STATISTICAL_TOLERANCE.")==0) anIt0 = StepDimTol_GTMStatisticalTolerance; |
91 | else if (strcmp(text, ".TANGENT_PLANE.")==0) anIt0 = StepDimTol_GTMTangentPlane; |
92 | else ach->AddFail("Parameter #5 (modifiers) has not allowed value"); |
93 | } |
94 | else ach->AddFail("Parameter #5 (modifier) is not set of enumerations"); |
95 | aModifiers->SetValue(i0, anIt0); |
96 | } |
97 | } |
98 | |
99 | // own fields of GeometricToleranceWithMaximumTolerance |
100 | |
101 | Handle(StepBasic_LengthMeasureWithUnit) aMaximumUpperTolerance; |
102 | data->ReadEntity (num, 6, "maximum_upper_tolerance", ach, STANDARD_TYPE(StepBasic_LengthMeasureWithUnit), aMaximumUpperTolerance); |
103 | |
104 | // Initialize entity |
105 | ent->Init(aName, |
106 | aDescription, |
107 | aMagnitude, |
108 | aTolerancedShapeAspect, |
109 | aModifiers, |
110 | aMaximumUpperTolerance); |
111 | } |
112 | |
113 | //======================================================================= |
114 | //function : WriteStep |
115 | //purpose : |
116 | //======================================================================= |
117 | |
118 | void RWStepDimTol_RWGeometricToleranceWithMaximumTolerance:: |
119 | WriteStep (StepData_StepWriter& SW, |
120 | const Handle(StepDimTol_GeometricToleranceWithMaximumTolerance) &ent) const |
121 | { |
122 | |
123 | // inherited fields from GeometricTolerance |
124 | |
125 | SW.Send (ent->Name()); |
126 | |
127 | SW.Send (ent->Description()); |
128 | |
129 | SW.Send (ent->Magnitude()); |
130 | |
131 | SW.Send (ent->TolerancedShapeAspect().Value()); |
132 | |
133 | // inherited fields from GeometricToleranceWithModifiers |
134 | |
135 | SW.OpenSub(); |
136 | for (Standard_Integer i = 1; i <= ent->NbModifiers(); i++) { |
137 | switch (ent->ModifierValue(i)) { |
138 | case StepDimTol_GTMAnyCrossSection: SW.SendEnum (".ANY_CROSS_SECTION."); break; |
139 | case StepDimTol_GTMCommonZone: SW.SendEnum (".COMMON_ZONE."); break; |
140 | case StepDimTol_GTMEachRadialElement: SW.SendEnum (".EACH_RADIAL_ELEMENT."); break; |
141 | case StepDimTol_GTMFreeState: SW.SendEnum (".FREE_STATE."); break; |
142 | case StepDimTol_GTMLeastMaterialRequirement: SW.SendEnum (".LEAST_MATERIAL_REQUIREMENT."); break; |
143 | case StepDimTol_GTMLineElement: SW.SendEnum (".LINE_ELEMENT."); break; |
144 | case StepDimTol_GTMMajorDiameter: SW.SendEnum (".MAJOR_DIAMETER."); break; |
145 | case StepDimTol_GTMMaximumMaterialRequirement: SW.SendEnum (".MAXIMUM_MATERIAL_REQUIREMENT."); break; |
146 | case StepDimTol_GTMMinorDiameter: SW.SendEnum (".MINOR_DIAMETER."); break; |
147 | case StepDimTol_GTMNotConvex: SW.SendEnum (".NOT_CONVEX."); break; |
148 | case StepDimTol_GTMPitchDiameter: SW.SendEnum (".PITCH_DIAMETER."); break; |
149 | case StepDimTol_GTMReciprocityRequirement: SW.SendEnum (".RECIPROCITY_REQUIREMENT."); break; |
150 | case StepDimTol_GTMSeparateRequirement: SW.SendEnum (".SEPARATE_REQUIREMENT."); break; |
151 | case StepDimTol_GTMStatisticalTolerance: SW.SendEnum (".STATISTICAL_TOLERANCE."); break; |
152 | case StepDimTol_GTMTangentPlane: SW.SendEnum (".TANGENT_PLANE."); break; |
153 | } |
154 | } |
155 | SW.CloseSub(); |
156 | |
157 | // own fields of GeometricToleranceWithMaximumTolerance |
158 | |
159 | SW.Send (ent->MaximumUpperTolerance()); |
160 | } |
161 | |
162 | //======================================================================= |
163 | //function : Share |
164 | //purpose : |
165 | //======================================================================= |
166 | |
167 | void RWStepDimTol_RWGeometricToleranceWithMaximumTolerance:: |
168 | Share (const Handle(StepDimTol_GeometricToleranceWithMaximumTolerance) &ent, |
169 | Interface_EntityIterator& iter) const |
170 | { |
171 | |
172 | // inherited fields from GeometricTolerance |
173 | |
174 | iter.AddItem (ent->Magnitude()); |
175 | |
176 | iter.AddItem (ent->TolerancedShapeAspect().Value()); |
177 | } |