28a73c1f |
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_RWGeoTolAndGeoTolWthDatRef.hxx> |
20 | #include <StepBasic_MeasureWithUnit.hxx> |
21 | #include <StepData_StepReaderData.hxx> |
22 | #include <StepData_StepWriter.hxx> |
28a73c1f |
23 | #include <StepDimTol_GeometricToleranceWithDatumReference.hxx> |
24 | #include <StepDimTol_GeoTolAndGeoTolWthDatRef.hxx> |
25 | #include <StepDimTol_HArray1OfDatumSystemOrReference.hxx> |
26 | |
27 | //======================================================================= |
28 | //function : RWStepDimTol_RWGeoTolAndGeoTolWthDatRef |
29 | //purpose : |
30 | //======================================================================= |
31 | RWStepDimTol_RWGeoTolAndGeoTolWthDatRef::RWStepDimTol_RWGeoTolAndGeoTolWthDatRef() |
32 | { |
33 | } |
34 | |
35 | |
36 | //======================================================================= |
37 | //function : ReadStep |
38 | //purpose : |
39 | //======================================================================= |
40 | |
41 | void RWStepDimTol_RWGeoTolAndGeoTolWthDatRef::ReadStep |
42 | (const Handle(StepData_StepReaderData)& data, |
43 | const Standard_Integer num0, Handle(Interface_Check)& ach, |
44 | const Handle(StepDimTol_GeoTolAndGeoTolWthDatRef)& ent) const |
45 | { |
46 | Standard_Integer num = 0;//num0; |
a7197ef3 |
47 | data->NamedForComplex("GEOMETRIC_TOLERANCE","GMTTLR",num0,num,ach); |
28a73c1f |
48 | if (!data->CheckNbParams(num,4,ach,"geometric_tolerance")) return; |
49 | // Own fields of GeometricTolerance |
50 | Handle(TCollection_HAsciiString) aName; |
51 | data->ReadString (num, 1, "name", ach, aName); |
52 | Handle(TCollection_HAsciiString) aDescription; |
53 | data->ReadString (num, 2, "description", ach, aDescription); |
54 | Handle(StepBasic_MeasureWithUnit) aMagnitude; |
55 | data->ReadEntity (num, 3, "magnitude", ach, STANDARD_TYPE(StepBasic_MeasureWithUnit), aMagnitude); |
56 | StepDimTol_GeometricToleranceTarget aTolerancedShapeAspect; |
57 | data->ReadEntity (num, 4, "toleranced_shape_aspect", ach, aTolerancedShapeAspect); |
58 | |
a7197ef3 |
59 | data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE","GTWDR",num0,num,ach); |
28a73c1f |
60 | // Own fields of GeometricToleranceWithDatumReference |
61 | Handle(StepDimTol_HArray1OfDatumSystemOrReference) aDatumSystem; |
62 | Standard_Integer sub5 = 0; |
63 | if ( data->ReadSubList (num, 1, "datum_system", ach, sub5) ) { |
64 | Standard_Integer nb0 = data->NbParams(sub5); |
65 | aDatumSystem = new StepDimTol_HArray1OfDatumSystemOrReference (1, nb0); |
66 | Standard_Integer num2 = sub5; |
67 | for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) { |
68 | StepDimTol_DatumSystemOrReference anIt0; |
69 | data->ReadEntity (num2, i0, "datum_system_or_reference", ach, anIt0); |
70 | aDatumSystem->SetValue(i0, anIt0); |
71 | } |
72 | } |
73 | // Initialize entity |
74 | Handle(StepDimTol_GeometricToleranceWithDatumReference) aGTWDR = |
75 | new StepDimTol_GeometricToleranceWithDatumReference; |
76 | aGTWDR->SetDatumSystem(aDatumSystem); |
77 | |
78 | //Choose type of geometric tolerance |
79 | TColStd_SequenceOfAsciiString aTypes; |
80 | data->ComplexType(num0, aTypes); |
81 | Standard_CString aFirst = aTypes.First().ToCString(); |
82 | Standard_CString aLast = aTypes.Last().ToCString(); |
83 | StepDimTol_GeometricToleranceType aType = StepDimTol_GTTPositionTolerance; |
84 | if (strcmp(aFirst, "ANGULARITY_TOLERANCE") == 0) aType = StepDimTol_GTTAngularityTolerance; |
85 | else if (strcmp(aFirst, "CIRCULAR_RUNOUT_TOLERANCE") == 0) aType = StepDimTol_GTTCircularRunoutTolerance; |
86 | else if (strcmp(aFirst, "COAXIALITY_TOLERANCE") == 0) aType = StepDimTol_GTTCoaxialityTolerance; |
87 | else if (strcmp(aFirst, "CONCENTRICITY_TOLERANCE") == 0) aType = StepDimTol_GTTConcentricityTolerance; |
88 | else if (strcmp(aFirst, "CYLINDRICITY_TOLERANCE") == 0) aType = StepDimTol_GTTCylindricityTolerance; |
89 | else if (strcmp(aFirst, "FLATNESS_TOLERANCE") == 0) aType = StepDimTol_GTTFlatnessTolerance; |
90 | else if (strcmp(aLast, "LINE_PROFILE_TOLERANCE") == 0) aType = StepDimTol_GTTLineProfileTolerance; |
91 | else if (strcmp(aLast, "PARALLELISM_TOLERANCE") == 0) aType = StepDimTol_GTTParallelismTolerance; |
92 | else if (strcmp(aLast, "PERPENDICULARITY_TOLERANCE") == 0) aType = StepDimTol_GTTPerpendicularityTolerance; |
93 | else if (strcmp(aLast, "POSITION_TOLERANCE") == 0) aType = StepDimTol_GTTPositionTolerance; |
94 | else if (strcmp(aLast, "ROUNDNESS_TOLERANCE") == 0) aType = StepDimTol_GTTRoundnessTolerance; |
95 | else if (strcmp(aLast, "STRAIGHTNESS_TOLERANCE") == 0) aType = StepDimTol_GTTStraightnessTolerance; |
96 | else if (strcmp(aLast, "SURFACE_PROFILE_TOLERANCE") == 0) aType = StepDimTol_GTTSurfaceProfileTolerance; |
97 | else if (strcmp(aLast, "SYMMETRY_TOLERANCE") == 0) aType = StepDimTol_GTTSymmetryTolerance; |
98 | else if (strcmp(aLast, "TOTAL_RUNOUT_TOLERANCE") == 0) aType = StepDimTol_GTTTotalRunoutTolerance; |
99 | else ach->AddFail("The type of geometric tolerance is not supported"); |
100 | |
101 | // Initialize entity |
102 | ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, aGTWDR, aType); |
103 | } |
104 | |
105 | |
106 | //======================================================================= |
107 | //function : WriteStep |
108 | //purpose : |
109 | //======================================================================= |
110 | |
111 | void RWStepDimTol_RWGeoTolAndGeoTolWthDatRef::WriteStep |
112 | (StepData_StepWriter& SW, |
113 | const Handle(StepDimTol_GeoTolAndGeoTolWthDatRef)& ent) const |
114 | { |
115 | StepDimTol_GeometricToleranceType aType = ent->GetToleranceType(); |
116 | if (aType == StepDimTol_GTTAngularityTolerance) |
117 | SW.StartEntity("ANGULARITY_TOLERANCE"); |
118 | else if (aType == StepDimTol_GTTCircularRunoutTolerance) |
119 | SW.StartEntity("CIRCULAR_RUNOUT_TOLERANCE"); |
120 | else if (aType == StepDimTol_GTTCoaxialityTolerance) |
121 | SW.StartEntity("COAXIALITY_TOLERANCE"); |
122 | else if (aType == StepDimTol_GTTConcentricityTolerance) |
123 | SW.StartEntity("CONCENTRICITY_TOLERANCE"); |
124 | else if (aType == StepDimTol_GTTCylindricityTolerance) |
125 | SW.StartEntity("CYLINDRICITY_TOLERANCE"); |
126 | else if (aType == StepDimTol_GTTFlatnessTolerance) |
127 | SW.StartEntity("FLATNESS_TOLERANCE"); |
128 | |
129 | SW.StartEntity("GEOMETRIC_TOLERANCE"); |
130 | SW.Send(ent->Name()); |
131 | SW.Send(ent->Description()); |
132 | SW.Send(ent->Magnitude()); |
133 | SW.Send(ent->TolerancedShapeAspect().Value()); |
134 | SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE"); |
135 | SW.OpenSub(); |
136 | for(Standard_Integer i4=1; i4<=ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Length(); i4++) { |
137 | StepDimTol_DatumSystemOrReference Var0 = |
138 | ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Value(i4); |
139 | SW.Send(Var0.Value()); |
140 | } |
141 | SW.CloseSub(); |
142 | |
143 | if (aType == StepDimTol_GTTLineProfileTolerance) |
144 | SW.StartEntity("LINE_PROFILE_TOLERANCE"); |
145 | else if (aType == StepDimTol_GTTParallelismTolerance) |
146 | SW.StartEntity("PARALLELISM_TOLERANCE"); |
147 | else if (aType == StepDimTol_GTTPerpendicularityTolerance) |
148 | SW.StartEntity("PERPENDICULARITY_TOLERANCE"); |
149 | else if (aType == StepDimTol_GTTPositionTolerance) |
150 | SW.StartEntity("POSITION_TOLERANCE"); |
151 | else if (aType == StepDimTol_GTTRoundnessTolerance) |
152 | SW.StartEntity("ROUNDNESS_TOLERANCE"); |
153 | else if (aType == StepDimTol_GTTStraightnessTolerance) |
154 | SW.StartEntity("STRAIGHTNESS_TOLERANCE"); |
155 | else if (aType == StepDimTol_GTTSurfaceProfileTolerance) |
156 | SW.StartEntity("SURFACE_PROFILE_TOLERANCE"); |
157 | else if (aType == StepDimTol_GTTSymmetryTolerance) |
158 | SW.StartEntity("SYMMETRY_TOLERANCE"); |
159 | else if (aType == StepDimTol_GTTTotalRunoutTolerance) |
160 | SW.StartEntity("TOTAL_RUNOUT_TOLERANCE"); |
161 | } |
162 | |
163 | |
164 | //======================================================================= |
165 | //function : Share |
166 | //purpose : |
167 | //======================================================================= |
168 | |
169 | void RWStepDimTol_RWGeoTolAndGeoTolWthDatRef::Share |
170 | (const Handle(StepDimTol_GeoTolAndGeoTolWthDatRef)& ent, |
171 | Interface_EntityIterator& iter) const |
172 | { |
173 | // Own fields of GeometricTolerance |
174 | iter.AddItem (ent->Magnitude()); |
175 | iter.AddItem (ent->TolerancedShapeAspect().Value()); |
176 | // Own fields of GeometricToleranceWithDatumReference |
177 | for (Standard_Integer i3=1; i3<=ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Length(); i3++ ) { |
178 | StepDimTol_DatumSystemOrReference Var0 = ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Value(i3); |
179 | iter.AddItem (Var0.Value()); |
180 | } |
181 | } |