6595eee7 |
1 | // Created on: 2015-11-13 |
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 | |
17 | #include <Interface_Check.hxx> |
18 | #include <Interface_EntityIterator.hxx> |
19 | #include <RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx> |
20 | #include <StepBasic_LengthMeasureWithUnit.hxx> |
21 | #include <StepBasic_MeasureWithUnit.hxx> |
22 | #include <StepData_StepReaderData.hxx> |
23 | #include <StepData_StepWriter.hxx> |
24 | #include <StepDimTol_DatumReference.hxx> |
25 | #include <StepDimTol_GeometricToleranceTarget.hxx> |
26 | #include <StepDimTol_GeometricToleranceType.hxx> |
27 | #include <StepDimTol_GeometricToleranceWithDatumReference.hxx> |
28 | #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx> |
29 | #include <StepDimTol_HArray1OfDatumSystemOrReference.hxx> |
30 | #include <StepDimTol_GeometricToleranceWithModifiers.hxx> |
31 | |
32 | //======================================================================= |
33 | //function : RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol |
34 | //purpose : |
35 | //======================================================================= |
36 | RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol() |
37 | { |
38 | } |
39 | |
40 | |
41 | //======================================================================= |
42 | //function : ReadStep |
43 | //purpose : |
44 | //======================================================================= |
45 | |
46 | void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::ReadStep |
47 | (const Handle(StepData_StepReaderData)& data, |
48 | const Standard_Integer num0, Handle(Interface_Check)& ach, |
49 | const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)& ent) const |
50 | { |
51 | Standard_Integer num = 0;//num0; |
52 | data->NamedForComplex("GEOMETRIC_TOLERANCE","GMTTLR",num0,num,ach); |
53 | if (!data->CheckNbParams(num,4,ach,"geometric_tolerance")) return; |
54 | // Own fields of GeometricTolerance |
55 | Handle(TCollection_HAsciiString) aName; |
56 | data->ReadString (num, 1, "name", ach, aName); |
57 | Handle(TCollection_HAsciiString) aDescription; |
58 | data->ReadString (num, 2, "description", ach, aDescription); |
59 | Handle(StepBasic_MeasureWithUnit) aMagnitude; |
60 | data->ReadEntity (num, 3, "magnitude", ach, STANDARD_TYPE(StepBasic_MeasureWithUnit), aMagnitude); |
61 | StepDimTol_GeometricToleranceTarget aTolerancedShapeAspect; |
62 | data->ReadEntity (num, 4, "toleranced_shape_aspect", ach, aTolerancedShapeAspect); |
63 | |
64 | data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE","GTWDR",num0,num,ach); |
65 | // Own fields of GeometricToleranceWithDatumReference |
66 | Handle(StepDimTol_HArray1OfDatumSystemOrReference) aDatumSystem; |
67 | Standard_Integer sub5 = 0; |
68 | if ( data->ReadSubList (num, 1, "datum_system", ach, sub5) ) { |
69 | Standard_Integer nb0 = data->NbParams(sub5); |
70 | aDatumSystem = new StepDimTol_HArray1OfDatumSystemOrReference (1, nb0); |
71 | Standard_Integer num2 = sub5; |
72 | for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) { |
73 | StepDimTol_DatumSystemOrReference anIt0; |
74 | data->ReadEntity (num2, i0, "datum_system_or_reference", ach, anIt0); |
75 | aDatumSystem->SetValue(i0, anIt0); |
76 | } |
77 | } |
78 | // Initialize entity |
79 | Handle(StepDimTol_GeometricToleranceWithDatumReference) aGTWDR = |
80 | new StepDimTol_GeometricToleranceWithDatumReference; |
81 | aGTWDR->SetDatumSystem(aDatumSystem); |
82 | |
83 | data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_MAXIMUM_TOLERANCE",num0,num,ach); |
84 | Handle(StepBasic_LengthMeasureWithUnit) aMaxTol; |
85 | data->ReadEntity (num, 1, "maximum_upper_tolerance", ach, STANDARD_TYPE(StepBasic_LengthMeasureWithUnit), aMaxTol); |
86 | |
87 | data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_MODIFIERS",num0,num,ach); |
88 | // Own fields of ModifiedGeometricTolerance |
89 | Handle(StepDimTol_HArray1OfGeometricToleranceModifier) aModifiers; |
90 | Standard_Integer sub = 0; |
91 | if ( data->ReadSubList (num, 1, "modifiers", ach, sub) ) { |
92 | Standard_Integer nb0 = data->NbParams(sub5); |
93 | aModifiers = new StepDimTol_HArray1OfGeometricToleranceModifier (1, nb0); |
94 | Standard_Integer num2 = sub; |
95 | for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) { |
96 | StepDimTol_GeometricToleranceModifier anIt0 = StepDimTol_GTMMaximumMaterialRequirement; |
97 | if (data->ParamType (num2, i0) == Interface_ParamEnum) { |
98 | Standard_CString text = data->ParamCValue(num2, i0); |
99 | if (strcmp(text, ".ANY_CROSS_SECTION.")==0) anIt0 = StepDimTol_GTMAnyCrossSection; |
100 | else if (strcmp(text, ".COMMON_ZONE.")==0) anIt0 = StepDimTol_GTMCommonZone; |
101 | else if (strcmp(text, ".EACH_RADIAL_ELEMENT.")==0) anIt0 = StepDimTol_GTMEachRadialElement; |
102 | else if (strcmp(text, ".FREE_STATE.")==0) anIt0 = StepDimTol_GTMFreeState; |
103 | else if (strcmp(text, ".LEAST_MATERIAL_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMLeastMaterialRequirement; |
104 | else if (strcmp(text, ".LINE_ELEMENT.")==0) anIt0 = StepDimTol_GTMLineElement; |
105 | else if (strcmp(text, ".MAJOR_DIAMETER.")==0) anIt0 = StepDimTol_GTMMajorDiameter; |
106 | else if (strcmp(text, ".MAXIMUM_MATERIAL_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMMaximumMaterialRequirement; |
107 | else if (strcmp(text, ".MINOR_DIAMETER.")==0) anIt0 = StepDimTol_GTMMinorDiameter; |
108 | else if (strcmp(text, ".NOT_CONVEX.")==0) anIt0 = StepDimTol_GTMNotConvex; |
109 | else if (strcmp(text, ".PITCH_DIAMETER.")==0) anIt0 = StepDimTol_GTMPitchDiameter; |
110 | else if (strcmp(text, ".RECIPROCITY_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMReciprocityRequirement; |
111 | else if (strcmp(text, ".SEPARATE_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMSeparateRequirement; |
112 | else if (strcmp(text, ".STATISTICAL_TOLERANCE.")==0) anIt0 = StepDimTol_GTMStatisticalTolerance; |
113 | else if (strcmp(text, ".TANGENT_PLANE.")==0) anIt0 = StepDimTol_GTMTangentPlane; |
114 | else ach->AddFail("Parameter #5 (modifiers) has not allowed value"); |
115 | } |
116 | else ach->AddFail("Parameter #5 (modifier) is not set of enumerations"); |
117 | aModifiers->SetValue(i0, anIt0); |
118 | } |
119 | } |
120 | Handle(StepDimTol_GeometricToleranceWithModifiers) aGTWM = new StepDimTol_GeometricToleranceWithModifiers; |
121 | aGTWM->SetModifiers(aModifiers); |
122 | |
123 | //Choose type of geometric tolerance |
124 | TColStd_SequenceOfAsciiString aTypes; |
125 | data->ComplexType(num0, aTypes); |
126 | Standard_CString aFirst = aTypes.First().ToCString(); |
127 | Standard_CString aLast = aTypes.Last().ToCString(); |
128 | StepDimTol_GeometricToleranceType aType = StepDimTol_GTTPositionTolerance; |
129 | if (strcmp(aFirst, "ANGULARITY_TOLERANCE") == 0) aType = StepDimTol_GTTAngularityTolerance; |
130 | else if (strcmp(aFirst, "CIRCULAR_RUNOUT_TOLERANCE") == 0) aType = StepDimTol_GTTCircularRunoutTolerance; |
131 | else if (strcmp(aFirst, "COAXIALITY_TOLERANCE") == 0) aType = StepDimTol_GTTCoaxialityTolerance; |
132 | else if (strcmp(aFirst, "CONCENTRICITY_TOLERANCE") == 0) aType = StepDimTol_GTTConcentricityTolerance; |
133 | else if (strcmp(aFirst, "CYLINDRICITY_TOLERANCE") == 0) aType = StepDimTol_GTTCylindricityTolerance; |
134 | else if (strcmp(aFirst, "FLATNESS_TOLERANCE") == 0) aType = StepDimTol_GTTFlatnessTolerance; |
135 | else if (strcmp(aLast, "LINE_PROFILE_TOLERANCE") == 0) aType = StepDimTol_GTTLineProfileTolerance; |
136 | else if (strcmp(aLast, "PARALLELISM_TOLERANCE") == 0) aType = StepDimTol_GTTParallelismTolerance; |
137 | else if (strcmp(aLast, "PERPENDICULARITY_TOLERANCE") == 0) aType = StepDimTol_GTTPerpendicularityTolerance; |
138 | else if (strcmp(aLast, "POSITION_TOLERANCE") == 0) aType = StepDimTol_GTTPositionTolerance; |
139 | else if (strcmp(aLast, "ROUNDNESS_TOLERANCE") == 0) aType = StepDimTol_GTTRoundnessTolerance; |
140 | else if (strcmp(aLast, "STRAIGHTNESS_TOLERANCE") == 0) aType = StepDimTol_GTTStraightnessTolerance; |
141 | else if (strcmp(aLast, "SURFACE_PROFILE_TOLERANCE") == 0) aType = StepDimTol_GTTSurfaceProfileTolerance; |
142 | else if (strcmp(aLast, "SYMMETRY_TOLERANCE") == 0) aType = StepDimTol_GTTSymmetryTolerance; |
143 | else if (strcmp(aLast, "TOTAL_RUNOUT_TOLERANCE") == 0) aType = StepDimTol_GTTTotalRunoutTolerance; |
144 | else ach->AddFail("The type of geometric tolerance is not supported"); |
145 | |
146 | // Initialize entity |
147 | ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, aGTWDR, aGTWM, aMaxTol, aType); |
148 | |
149 | } |
150 | |
151 | |
152 | //======================================================================= |
153 | //function : WriteStep |
154 | //purpose : |
155 | //======================================================================= |
156 | |
157 | void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::WriteStep |
158 | (StepData_StepWriter& SW, |
159 | const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)& ent) const |
160 | { |
161 | StepDimTol_GeometricToleranceType aType = ent->GetToleranceType(); |
162 | if (aType == StepDimTol_GTTAngularityTolerance) |
163 | SW.StartEntity("ANGULARITY_TOLERANCE"); |
164 | else if (aType == StepDimTol_GTTCircularRunoutTolerance) |
165 | SW.StartEntity("CIRCULAR_RUNOUT_TOLERANCE"); |
166 | else if (aType == StepDimTol_GTTCoaxialityTolerance) |
167 | SW.StartEntity("COAXIALITY_TOLERANCE"); |
168 | else if (aType == StepDimTol_GTTConcentricityTolerance) |
169 | SW.StartEntity("CONCENTRICITY_TOLERANCE"); |
170 | else if (aType == StepDimTol_GTTCylindricityTolerance) |
171 | SW.StartEntity("CYLINDRICITY_TOLERANCE"); |
172 | else if (aType == StepDimTol_GTTFlatnessTolerance) |
173 | SW.StartEntity("FLATNESS_TOLERANCE"); |
174 | |
175 | SW.StartEntity("GEOMETRIC_TOLERANCE"); |
176 | SW.Send(ent->Name()); |
177 | SW.Send(ent->Description()); |
178 | SW.Send(ent->Magnitude()); |
179 | SW.Send(ent->TolerancedShapeAspect().Value()); |
180 | SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_MAXIMUM_TOLERANCE"); |
181 | SW.Send(ent->GetMaxTolerance()); |
182 | SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE"); |
183 | SW.OpenSub(); |
184 | for(Standard_Integer i4=1; i4<=ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Length(); i4++) { |
185 | StepDimTol_DatumSystemOrReference Var0 = |
186 | ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Value(i4); |
187 | SW.Send(Var0.Value()); |
188 | } |
189 | SW.CloseSub(); |
190 | |
191 | SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_MODIFIERS"); |
192 | SW.OpenSub(); |
193 | Handle(StepDimTol_GeometricToleranceWithModifiers) aGTWM = ent->GetGeometricToleranceWithModifiers(); |
194 | for (Standard_Integer i = 1; i <= aGTWM->NbModifiers(); i++) { |
195 | switch (aGTWM->ModifierValue(i)) { |
196 | case StepDimTol_GTMAnyCrossSection: SW.SendEnum (".ANY_CROSS_SECTION."); break; |
197 | case StepDimTol_GTMCommonZone: SW.SendEnum (".COMMON_ZONE."); break; |
198 | case StepDimTol_GTMEachRadialElement: SW.SendEnum (".EACH_RADIAL_ELEMENT."); break; |
199 | case StepDimTol_GTMFreeState: SW.SendEnum (".FREE_STATE."); break; |
200 | case StepDimTol_GTMLeastMaterialRequirement: SW.SendEnum (".LEAST_MATERIAL_REQUIREMENT."); break; |
201 | case StepDimTol_GTMLineElement: SW.SendEnum (".LINE_ELEMENT."); break; |
202 | case StepDimTol_GTMMajorDiameter: SW.SendEnum (".MAJOR_DIAMETER."); break; |
203 | case StepDimTol_GTMMaximumMaterialRequirement: SW.SendEnum (".MAXIMUM_MATERIAL_REQUIREMENT."); break; |
204 | case StepDimTol_GTMMinorDiameter: SW.SendEnum (".MINOR_DIAMETER."); break; |
205 | case StepDimTol_GTMNotConvex: SW.SendEnum (".NOT_CONVEX."); break; |
206 | case StepDimTol_GTMPitchDiameter: SW.SendEnum (".PITCH_DIAMETER."); break; |
207 | case StepDimTol_GTMReciprocityRequirement: SW.SendEnum (".RECIPROCITY_REQUIREMENT."); break; |
208 | case StepDimTol_GTMSeparateRequirement: SW.SendEnum (".SEPARATE_REQUIREMENT."); break; |
209 | case StepDimTol_GTMStatisticalTolerance: SW.SendEnum (".STATISTICAL_TOLERANCE."); break; |
210 | case StepDimTol_GTMTangentPlane: SW.SendEnum (".TANGENT_PLANE."); break; |
211 | } |
212 | } |
213 | SW.CloseSub(); |
214 | |
215 | if (aType == StepDimTol_GTTLineProfileTolerance) |
216 | SW.StartEntity("LINE_PROFILE_TOLERANCE"); |
217 | else if (aType == StepDimTol_GTTParallelismTolerance) |
218 | SW.StartEntity("PARALLELISM_TOLERANCE"); |
219 | else if (aType == StepDimTol_GTTPerpendicularityTolerance) |
220 | SW.StartEntity("PERPENDICULARITY_TOLERANCE"); |
221 | else if (aType == StepDimTol_GTTPositionTolerance) |
222 | SW.StartEntity("POSITION_TOLERANCE"); |
223 | else if (aType == StepDimTol_GTTRoundnessTolerance) |
224 | SW.StartEntity("ROUNDNESS_TOLERANCE"); |
225 | else if (aType == StepDimTol_GTTStraightnessTolerance) |
226 | SW.StartEntity("STRAIGHTNESS_TOLERANCE"); |
227 | else if (aType == StepDimTol_GTTSurfaceProfileTolerance) |
228 | SW.StartEntity("SURFACE_PROFILE_TOLERANCE"); |
229 | else if (aType == StepDimTol_GTTSymmetryTolerance) |
230 | SW.StartEntity("SYMMETRY_TOLERANCE"); |
231 | else if (aType == StepDimTol_GTTTotalRunoutTolerance) |
232 | SW.StartEntity("TOTAL_RUNOUT_TOLERANCE"); |
233 | } |
234 | |
235 | |
236 | //======================================================================= |
237 | //function : Share |
238 | //purpose : |
239 | //======================================================================= |
240 | |
241 | void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::Share |
242 | (const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)& ent, |
243 | Interface_EntityIterator& iter) const |
244 | { |
245 | // Own fields of GeometricTolerance |
246 | iter.AddItem (ent->Magnitude()); |
247 | iter.AddItem (ent->TolerancedShapeAspect().Value()); |
248 | // Own fields of GeometricToleranceWithDatumReference |
249 | for (Standard_Integer i3=1; i3<=ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Length(); i3++ ) { |
250 | StepDimTol_DatumSystemOrReference Var0 = ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Value(i3); |
251 | iter.AddItem (Var0.Value()); |
252 | } |
253 | } |