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