1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <Interface_Check.hxx>
15 #include <Interface_EntityIterator.hxx>
16 #include "RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.pxx"
17 #include <StepBasic_MeasureWithUnit.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepDimTol_GeometricToleranceWithDatumReference.hxx>
21 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx>
22 #include <StepDimTol_HArray1OfDatumSystemOrReference.hxx>
23 #include <StepDimTol_ModifiedGeometricTolerance.hxx>
25 //=================================================================================================
27 RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::
28 RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol()
32 //=================================================================================================
34 void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::ReadStep(
35 const Handle(StepData_StepReaderData)& data,
36 const Standard_Integer num0,
37 Handle(Interface_Check)& ach,
38 const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)& ent) const
40 Standard_Integer num = 0; // num0;
41 data->NamedForComplex("GEOMETRIC_TOLERANCE", "GMTTLR", num0, num, ach);
42 if (!data->CheckNbParams(num, 4, ach, "geometric_tolerance"))
44 // Own fields of GeometricTolerance
45 Handle(TCollection_HAsciiString) aName;
46 data->ReadString(num, 1, "name", ach, aName);
47 Handle(TCollection_HAsciiString) aDescription;
48 data->ReadString(num, 2, "description", ach, aDescription);
49 Handle(StepBasic_MeasureWithUnit) aMagnitude;
50 data->ReadEntity(num, 3, "magnitude", ach, STANDARD_TYPE(StepBasic_MeasureWithUnit), aMagnitude);
51 StepDimTol_GeometricToleranceTarget aTolerancedShapeAspect;
52 data->ReadEntity(num, 4, "toleranced_shape_aspect", ach, aTolerancedShapeAspect);
54 data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE", "GTWDR", num0, num, ach);
55 // Own fields of GeometricToleranceWithDatumReference
56 Handle(StepDimTol_HArray1OfDatumSystemOrReference) aDatumSystem;
57 Standard_Integer sub5 = 0;
58 if (data->ReadSubList(num, 1, "datum_system", ach, sub5))
60 Standard_Integer nb0 = data->NbParams(sub5);
61 aDatumSystem = new StepDimTol_HArray1OfDatumSystemOrReference(1, nb0);
62 Standard_Integer num2 = sub5;
63 for (Standard_Integer i0 = 1; i0 <= nb0; i0++)
65 StepDimTol_DatumSystemOrReference anIt0;
66 data->ReadEntity(num2, i0, "datum_system_or_reference", ach, anIt0);
67 aDatumSystem->SetValue(i0, anIt0);
71 Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
72 new StepDimTol_GeometricToleranceWithDatumReference;
73 GTWDR->SetDatumSystem(aDatumSystem);
75 data->NamedForComplex("MODIFIED_GEOMETRIC_TOLERANCE", "MDGMTL", num0, num, ach);
76 // Own fields of ModifiedGeometricTolerance
77 StepDimTol_LimitCondition aModifier = StepDimTol_MaximumMaterialCondition;
78 if (data->ParamType(num, 1) == Interface_ParamEnum)
80 Standard_CString text = data->ParamCValue(num, 1);
81 if (strcmp(text, ".MAXIMUM_MATERIAL_CONDITION.") == 0)
82 aModifier = StepDimTol_MaximumMaterialCondition;
83 else if (strcmp(text, ".LEAST_MATERIAL_CONDITION.") == 0)
84 aModifier = StepDimTol_LeastMaterialCondition;
85 else if (strcmp(text, ".REGARDLESS_OF_FEATURE_SIZE.") == 0)
86 aModifier = StepDimTol_RegardlessOfFeatureSize;
88 ach->AddFail("Parameter in MODIFIED_GEOMETRIC_TOLERANCE has not allowed value");
91 ach->AddFail("Parameter in MODIFIED_GEOMETRIC_TOLERANCE is not enumeration");
92 Handle(StepDimTol_ModifiedGeometricTolerance) MGT = new StepDimTol_ModifiedGeometricTolerance;
93 MGT->SetModifier(aModifier);
96 ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, GTWDR, MGT);
99 //=================================================================================================
101 void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::WriteStep(
102 StepData_StepWriter& SW,
103 const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)& ent) const
105 SW.StartEntity("GEOMETRIC_TOLERANCE");
106 SW.Send(ent->Name());
107 SW.Send(ent->Description());
108 SW.Send(ent->Magnitude());
109 SW.Send(ent->TolerancedShapeAspect().Value());
110 SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE");
112 for (Standard_Integer i4 = 1;
113 i4 <= ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Length();
116 StepDimTol_DatumSystemOrReference Var0 =
117 ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Value(i4);
118 SW.Send(Var0.Value());
121 SW.StartEntity("MODIFIED_GEOMETRIC_TOLERANCE");
122 switch (ent->GetModifiedGeometricTolerance()->Modifier())
124 case StepDimTol_MaximumMaterialCondition:
125 SW.SendEnum(".MAXIMUM_MATERIAL_CONDITION.");
127 case StepDimTol_LeastMaterialCondition:
128 SW.SendEnum(".LEAST_MATERIAL_CONDITION.");
130 case StepDimTol_RegardlessOfFeatureSize:
131 SW.SendEnum(".REGARDLESS_OF_FEATURE_SIZE.");
134 SW.StartEntity("POSITION_TOLERANCE");
137 //=================================================================================================
139 void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::Share(
140 const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)& ent,
141 Interface_EntityIterator& iter) const
143 // Own fields of GeometricTolerance
144 iter.AddItem(ent->Magnitude());
145 iter.AddItem(ent->TolerancedShapeAspect().Value());
146 // Own fields of GeometricToleranceWithDatumReference
147 for (Standard_Integer i3 = 1;
148 i3 <= ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Length();
151 StepDimTol_DatumSystemOrReference Var0 =
152 ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Value(i3);
153 iter.AddItem(Var0.Value());