1 // Created on: 2015-08-10
2 // Created by: Irina KRYLOVA
3 // Copyright (c) 2015 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <Interface_Check.hxx>
18 #include <Interface_EntityIterator.hxx>
19 #include <RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.hxx>
20 #include <StepBasic_LengthMeasureWithUnit.hxx>
21 #include <StepBasic_MeasureWithUnit.hxx>
22 #include <StepData_StepReaderData.hxx>
23 #include <StepData_StepWriter.hxx>
24 #include <StepDimTol_GeometricToleranceTarget.hxx>
25 #include <StepDimTol_GeometricToleranceType.hxx>
26 #include <StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx>
27 #include <StepDimTol_GeometricToleranceWithModifiers.hxx>
29 //=======================================================================
30 //function : RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol
32 //=======================================================================
33 RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol()
38 //=======================================================================
41 //=======================================================================
43 void RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::ReadStep
44 (const Handle(StepData_StepReaderData)& data,
45 const Standard_Integer num0, Handle(Interface_Check)& ach,
46 const Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)& ent) const
48 Standard_Integer num = 0;//num0;
49 data->NamedForComplex("GEOMETRIC_TOLERANCE","GMTTLR",num0,num,ach);
50 if (!data->CheckNbParams(num,4,ach,"geometric_tolerance")) return;
51 // Own fields of GeometricTolerance
52 Handle(TCollection_HAsciiString) aName;
53 data->ReadString (num, 1, "name", ach, aName);
54 Handle(TCollection_HAsciiString) aDescription;
55 data->ReadString (num, 2, "description", ach, aDescription);
56 Handle(StepBasic_MeasureWithUnit) aMagnitude;
57 data->ReadEntity (num, 3, "magnitude", ach, STANDARD_TYPE(StepBasic_MeasureWithUnit), aMagnitude);
58 StepDimTol_GeometricToleranceTarget aTolerancedShapeAspect;
59 data->ReadEntity (num, 4, "toleranced_shape_aspect", ach, aTolerancedShapeAspect);
61 data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_MAXIMUM_TOLERANCE",num0,num,ach);
62 Handle(StepBasic_LengthMeasureWithUnit) aMaxTol;
63 data->ReadEntity (num, 1, "maximum_upper_tolerance", ach, STANDARD_TYPE(StepBasic_LengthMeasureWithUnit), aMaxTol);
65 data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_MODIFIERS",num0,num,ach);
66 // Own fields of ModifiedGeometricTolerance
67 Handle(StepDimTol_HArray1OfGeometricToleranceModifier) aModifiers;
68 Standard_Integer sub = 0;
69 if ( data->ReadSubList (num, 1, "modifiers", ach, sub) ) {
70 Standard_Integer nb0 = data->NbParams(sub);
71 aModifiers = new StepDimTol_HArray1OfGeometricToleranceModifier (1, nb0);
72 Standard_Integer num2 = sub;
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");
94 else ach->AddFail("Parameter #5 (modifier) is not set of enumerations");
95 aModifiers->SetValue(i0, anIt0);
98 Handle(StepDimTol_GeometricToleranceWithModifiers) aGTWM = new StepDimTol_GeometricToleranceWithModifiers;
99 aGTWM->SetModifiers(aModifiers);
101 //Choose type of geometric tolerance
102 TColStd_SequenceOfAsciiString aTypes;
103 data->ComplexType(num0, aTypes);
104 Standard_CString aFirst = aTypes.First().ToCString();
105 Standard_CString aLast = aTypes.Last().ToCString();
106 StepDimTol_GeometricToleranceType aType = StepDimTol_GTTPositionTolerance;
107 if (strcmp(aFirst, "ANGULARITY_TOLERANCE") == 0) aType = StepDimTol_GTTAngularityTolerance;
108 else if (strcmp(aFirst, "CIRCULAR_RUNOUT_TOLERANCE") == 0) aType = StepDimTol_GTTCircularRunoutTolerance;
109 else if (strcmp(aFirst, "COAXIALITY_TOLERANCE") == 0) aType = StepDimTol_GTTCoaxialityTolerance;
110 else if (strcmp(aFirst, "CONCENTRICITY_TOLERANCE") == 0) aType = StepDimTol_GTTConcentricityTolerance;
111 else if (strcmp(aFirst, "CYLINDRICITY_TOLERANCE") == 0) aType = StepDimTol_GTTCylindricityTolerance;
112 else if (strcmp(aFirst, "FLATNESS_TOLERANCE") == 0) aType = StepDimTol_GTTFlatnessTolerance;
113 else if (strcmp(aLast, "LINE_PROFILE_TOLERANCE") == 0) aType = StepDimTol_GTTLineProfileTolerance;
114 else if (strcmp(aLast, "PARALLELISM_TOLERANCE") == 0) aType = StepDimTol_GTTParallelismTolerance;
115 else if (strcmp(aLast, "PERPENDICULARITY_TOLERANCE") == 0) aType = StepDimTol_GTTPerpendicularityTolerance;
116 else if (strcmp(aLast, "POSITION_TOLERANCE") == 0) aType = StepDimTol_GTTPositionTolerance;
117 else if (strcmp(aLast, "ROUNDNESS_TOLERANCE") == 0) aType = StepDimTol_GTTRoundnessTolerance;
118 else if (strcmp(aLast, "STRAIGHTNESS_TOLERANCE") == 0) aType = StepDimTol_GTTStraightnessTolerance;
119 else if (strcmp(aLast, "SURFACE_PROFILE_TOLERANCE") == 0) aType = StepDimTol_GTTSurfaceProfileTolerance;
120 else if (strcmp(aLast, "SYMMETRY_TOLERANCE") == 0) aType = StepDimTol_GTTSymmetryTolerance;
121 else if (strcmp(aLast, "TOTAL_RUNOUT_TOLERANCE") == 0) aType = StepDimTol_GTTTotalRunoutTolerance;
122 else ach->AddFail("The type of geometric tolerance is not supported");
125 ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, aGTWM, aMaxTol, aType);
130 //=======================================================================
131 //function : WriteStep
133 //=======================================================================
135 void RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::WriteStep
136 (StepData_StepWriter& SW,
137 const Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)& ent) const
139 StepDimTol_GeometricToleranceType aType = ent->GetToleranceType();
140 if (aType == StepDimTol_GTTAngularityTolerance)
141 SW.StartEntity("ANGULARITY_TOLERANCE");
142 else if (aType == StepDimTol_GTTCircularRunoutTolerance)
143 SW.StartEntity("CIRCULAR_RUNOUT_TOLERANCE");
144 else if (aType == StepDimTol_GTTCoaxialityTolerance)
145 SW.StartEntity("COAXIALITY_TOLERANCE");
146 else if (aType == StepDimTol_GTTConcentricityTolerance)
147 SW.StartEntity("CONCENTRICITY_TOLERANCE");
148 else if (aType == StepDimTol_GTTCylindricityTolerance)
149 SW.StartEntity("CYLINDRICITY_TOLERANCE");
150 else if (aType == StepDimTol_GTTFlatnessTolerance)
151 SW.StartEntity("FLATNESS_TOLERANCE");
153 SW.StartEntity("GEOMETRIC_TOLERANCE");
154 SW.Send(ent->Name());
155 SW.Send(ent->Description());
156 SW.Send(ent->Magnitude());
157 SW.Send(ent->TolerancedShapeAspect().Value());
158 SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_MAXIMUM_TOLERANCE");
159 SW.Send(ent->GetMaxTolerance());
160 SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_MODIFIERS");
162 Handle(StepDimTol_GeometricToleranceWithModifiers) aGTWM = ent->GetGeometricToleranceWithModifiers();
163 for (Standard_Integer i = 1; i <= aGTWM->NbModifiers(); i++) {
164 switch (aGTWM->ModifierValue(i)) {
165 case StepDimTol_GTMAnyCrossSection: SW.SendEnum (".ANY_CROSS_SECTION."); break;
166 case StepDimTol_GTMCommonZone: SW.SendEnum (".COMMON_ZONE."); break;
167 case StepDimTol_GTMEachRadialElement: SW.SendEnum (".EACH_RADIAL_ELEMENT."); break;
168 case StepDimTol_GTMFreeState: SW.SendEnum (".FREE_STATE."); break;
169 case StepDimTol_GTMLeastMaterialRequirement: SW.SendEnum (".LEAST_MATERIAL_REQUIREMENT."); break;
170 case StepDimTol_GTMLineElement: SW.SendEnum (".LINE_ELEMENT."); break;
171 case StepDimTol_GTMMajorDiameter: SW.SendEnum (".MAJOR_DIAMETER."); break;
172 case StepDimTol_GTMMaximumMaterialRequirement: SW.SendEnum (".MAXIMUM_MATERIAL_REQUIREMENT."); break;
173 case StepDimTol_GTMMinorDiameter: SW.SendEnum (".MINOR_DIAMETER."); break;
174 case StepDimTol_GTMNotConvex: SW.SendEnum (".NOT_CONVEX."); break;
175 case StepDimTol_GTMPitchDiameter: SW.SendEnum (".PITCH_DIAMETER."); break;
176 case StepDimTol_GTMReciprocityRequirement: SW.SendEnum (".RECIPROCITY_REQUIREMENT."); break;
177 case StepDimTol_GTMSeparateRequirement: SW.SendEnum (".SEPARATE_REQUIREMENT."); break;
178 case StepDimTol_GTMStatisticalTolerance: SW.SendEnum (".STATISTICAL_TOLERANCE."); break;
179 case StepDimTol_GTMTangentPlane: SW.SendEnum (".TANGENT_PLANE."); break;
183 if (aType == StepDimTol_GTTLineProfileTolerance)
184 SW.StartEntity("LINE_PROFILE_TOLERANCE");
185 else if (aType == StepDimTol_GTTParallelismTolerance)
186 SW.StartEntity("PARALLELISM_TOLERANCE");
187 else if (aType == StepDimTol_GTTPerpendicularityTolerance)
188 SW.StartEntity("PERPENDICULARITY_TOLERANCE");
189 else if (aType == StepDimTol_GTTPositionTolerance)
190 SW.StartEntity("POSITION_TOLERANCE");
191 else if (aType == StepDimTol_GTTRoundnessTolerance)
192 SW.StartEntity("ROUNDNESS_TOLERANCE");
193 else if (aType == StepDimTol_GTTStraightnessTolerance)
194 SW.StartEntity("STRAIGHTNESS_TOLERANCE");
195 else if (aType == StepDimTol_GTTSurfaceProfileTolerance)
196 SW.StartEntity("SURFACE_PROFILE_TOLERANCE");
197 else if (aType == StepDimTol_GTTSymmetryTolerance)
198 SW.StartEntity("SYMMETRY_TOLERANCE");
199 else if (aType == StepDimTol_GTTTotalRunoutTolerance)
200 SW.StartEntity("TOTAL_RUNOUT_TOLERANCE");
204 //=======================================================================
207 //=======================================================================
209 void RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::Share
210 (const Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)& ent,
211 Interface_EntityIterator& iter) const
213 // Own fields of GeometricTolerance
214 iter.AddItem (ent->Magnitude());
215 iter.AddItem (ent->TolerancedShapeAspect().Value());