28a73c1f |
1 | // Created on: 2015-08-11 |
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_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.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_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.hxx> |
29 | #include <StepDimTol_HArray1OfDatumSystemOrReference.hxx> |
30 | #include <StepDimTol_UnequallyDisposedGeometricTolerance.hxx> |
31 | |
32 | //======================================================================= |
33 | //function : RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol |
34 | //purpose : |
35 | //======================================================================= |
36 | RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol::RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol() |
37 | { |
38 | } |
39 | |
40 | |
41 | //======================================================================= |
42 | //function : ReadStep |
43 | //purpose : |
44 | //======================================================================= |
45 | |
46 | void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol::ReadStep |
47 | (const Handle(StepData_StepReaderData)& data, |
48 | const Standard_Integer num0, Handle(Interface_Check)& ach, |
49 | const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol)& ent) const |
50 | { |
51 | Standard_Integer num = 0;//num0; |
a7197ef3 |
52 | data->NamedForComplex("GEOMETRIC_TOLERANCE","GMTTLR",num0,num,ach); |
28a73c1f |
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 | |
a7197ef3 |
64 | data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE","GTWDR",num0,num,ach); |
28a73c1f |
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("UNEQUALLY_DISPOSED_GEOMETRIC_TOLERANCE", num0, num, ach); |
84 | Handle (StepBasic_LengthMeasureWithUnit) aDisplacement; |
85 | data->ReadEntity(num, 1, "displacement", ach, STANDARD_TYPE(StepBasic_LengthMeasureWithUnit), aDisplacement); |
86 | //Initialize entity |
87 | Handle(StepDimTol_UnequallyDisposedGeometricTolerance) anUDGT = new |
88 | StepDimTol_UnequallyDisposedGeometricTolerance; |
89 | anUDGT->SetDisplacement(aDisplacement); |
90 | |
91 | //Choose type of geometric tolerance |
92 | TColStd_SequenceOfAsciiString aTypes; |
93 | data->ComplexType(num0, aTypes); |
94 | Standard_CString aFirst = aTypes.First().ToCString(); |
95 | Standard_CString aLast = aTypes.Value(3).ToCString(); |
96 | StepDimTol_GeometricToleranceType aType = StepDimTol_GTTPositionTolerance; |
97 | if (strcmp(aFirst, "ANGULARITY_TOLERANCE") == 0) aType = StepDimTol_GTTAngularityTolerance; |
98 | else if (strcmp(aFirst, "CIRCULAR_RUNOUT_TOLERANCE") == 0) aType = StepDimTol_GTTCircularRunoutTolerance; |
99 | else if (strcmp(aFirst, "COAXIALITY_TOLERANCE") == 0) aType = StepDimTol_GTTCoaxialityTolerance; |
100 | else if (strcmp(aFirst, "CONCENTRICITY_TOLERANCE") == 0) aType = StepDimTol_GTTConcentricityTolerance; |
101 | else if (strcmp(aFirst, "CYLINDRICITY_TOLERANCE") == 0) aType = StepDimTol_GTTCylindricityTolerance; |
102 | else if (strcmp(aFirst, "FLATNESS_TOLERANCE") == 0) aType = StepDimTol_GTTFlatnessTolerance; |
103 | else if (strcmp(aLast, "LINE_PROFILE_TOLERANCE") == 0) aType = StepDimTol_GTTLineProfileTolerance; |
104 | else if (strcmp(aLast, "PARALLELISM_TOLERANCE") == 0) aType = StepDimTol_GTTParallelismTolerance; |
105 | else if (strcmp(aLast, "PERPENDICULARITY_TOLERANCE") == 0) aType = StepDimTol_GTTPerpendicularityTolerance; |
106 | else if (strcmp(aLast, "POSITION_TOLERANCE") == 0) aType = StepDimTol_GTTPositionTolerance; |
107 | else if (strcmp(aLast, "ROUNDNESS_TOLERANCE") == 0) aType = StepDimTol_GTTRoundnessTolerance; |
108 | else if (strcmp(aLast, "STRAIGHTNESS_TOLERANCE") == 0) aType = StepDimTol_GTTStraightnessTolerance; |
109 | else if (strcmp(aLast, "SURFACE_PROFILE_TOLERANCE") == 0) aType = StepDimTol_GTTSurfaceProfileTolerance; |
110 | else if (strcmp(aLast, "SYMMETRY_TOLERANCE") == 0) aType = StepDimTol_GTTSymmetryTolerance; |
111 | else if (strcmp(aLast, "TOTAL_RUNOUT_TOLERANCE") == 0) aType = StepDimTol_GTTTotalRunoutTolerance; |
112 | else ach->AddFail("The type of geometric tolerance is not supported"); |
113 | |
114 | // Initialize entity |
115 | ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, aGTWDR, aType, anUDGT); |
116 | } |
117 | |
118 | |
119 | //======================================================================= |
120 | //function : WriteStep |
121 | //purpose : |
122 | //======================================================================= |
123 | |
124 | void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol::WriteStep |
125 | (StepData_StepWriter& SW, |
126 | const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol)& ent) const |
127 | { |
128 | StepDimTol_GeometricToleranceType aType = ent->GetToleranceType(); |
129 | if (aType == StepDimTol_GTTAngularityTolerance) |
130 | SW.StartEntity("ANGULARITY_TOLERANCE"); |
131 | else if (aType == StepDimTol_GTTCircularRunoutTolerance) |
132 | SW.StartEntity("CIRCULAR_RUNOUT_TOLERANCE"); |
133 | else if (aType == StepDimTol_GTTCoaxialityTolerance) |
134 | SW.StartEntity("COAXIALITY_TOLERANCE"); |
135 | else if (aType == StepDimTol_GTTConcentricityTolerance) |
136 | SW.StartEntity("CONCENTRICITY_TOLERANCE"); |
137 | else if (aType == StepDimTol_GTTCylindricityTolerance) |
138 | SW.StartEntity("CYLINDRICITY_TOLERANCE"); |
139 | else if (aType == StepDimTol_GTTFlatnessTolerance) |
140 | SW.StartEntity("FLATNESS_TOLERANCE"); |
141 | |
142 | SW.StartEntity("GEOMETRIC_TOLERANCE"); |
143 | SW.Send(ent->Name()); |
144 | SW.Send(ent->Description()); |
145 | SW.Send(ent->Magnitude()); |
146 | SW.Send(ent->TolerancedShapeAspect().Value()); |
147 | SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE"); |
148 | SW.OpenSub(); |
149 | for(Standard_Integer i4=1; i4<=ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Length(); i4++) { |
150 | StepDimTol_DatumSystemOrReference Var0 = |
151 | ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Value(i4); |
152 | SW.Send(Var0.Value()); |
153 | } |
154 | SW.CloseSub(); |
155 | |
156 | if (aType == StepDimTol_GTTLineProfileTolerance) |
157 | SW.StartEntity("LINE_PROFILE_TOLERANCE"); |
158 | else if (aType == StepDimTol_GTTParallelismTolerance) |
159 | SW.StartEntity("PARALLELISM_TOLERANCE"); |
160 | else if (aType == StepDimTol_GTTPerpendicularityTolerance) |
161 | SW.StartEntity("PERPENDICULARITY_TOLERANCE"); |
162 | else if (aType == StepDimTol_GTTPositionTolerance) |
163 | SW.StartEntity("POSITION_TOLERANCE"); |
164 | else if (aType == StepDimTol_GTTRoundnessTolerance) |
165 | SW.StartEntity("ROUNDNESS_TOLERANCE"); |
166 | else if (aType == StepDimTol_GTTStraightnessTolerance) |
167 | SW.StartEntity("STRAIGHTNESS_TOLERANCE"); |
168 | else if (aType == StepDimTol_GTTSurfaceProfileTolerance) |
169 | SW.StartEntity("SURFACE_PROFILE_TOLERANCE"); |
170 | else if (aType == StepDimTol_GTTSymmetryTolerance) |
171 | SW.StartEntity("SYMMETRY_TOLERANCE"); |
172 | else if (aType == StepDimTol_GTTTotalRunoutTolerance) |
173 | SW.StartEntity("TOTAL_RUNOUT_TOLERANCE"); |
174 | |
175 | SW.StartEntity("UNEQUALLY_DISPOSED_GEOMETRIC_TOLRANCE"); |
176 | SW.Send(ent->GetUnequallyDisposedGeometricTolerance()->Displacement()); |
177 | } |
178 | |
179 | |
180 | //======================================================================= |
181 | //function : Share |
182 | //purpose : |
183 | //======================================================================= |
184 | |
185 | void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol::Share |
186 | (const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol)& ent, |
187 | Interface_EntityIterator& iter) const |
188 | { |
189 | // Own fields of GeometricTolerance |
190 | iter.AddItem (ent->Magnitude()); |
191 | iter.AddItem (ent->TolerancedShapeAspect().Value()); |
192 | // Own fields of GeometricToleranceWithDatumReference |
193 | for (Standard_Integer i3=1; i3<=ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Length(); i3++ ) { |
194 | StepDimTol_DatumSystemOrReference Var0 = ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Value(i3); |
195 | iter.AddItem (Var0.Value()); |
196 | } |
197 | } |