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