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.
15 #include <Interface_Check.hxx>
16 #include <Interface_EntityIterator.hxx>
17 #include <RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx>
18 #include <StepBasic_MeasureWithUnit.hxx>
19 #include <StepData_StepReaderData.hxx>
20 #include <StepData_StepWriter.hxx>
21 #include <StepDimTol_DatumReference.hxx>
22 #include <StepDimTol_GeometricToleranceTarget.hxx>
23 #include <StepDimTol_GeometricToleranceWithDatumReference.hxx>
24 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx>
25 #include <StepDimTol_HArray1OfDatumSystemOrReference.hxx>
26 #include <StepDimTol_LimitCondition.hxx>
27 #include <StepDimTol_ModifiedGeometricTolerance.hxx>
29 //=======================================================================
30 //function : RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol
32 //=======================================================================
33 RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol()
38 //=======================================================================
41 //=======================================================================
43 void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::ReadStep
44 (const Handle(StepData_StepReaderData)& data,
45 const Standard_Integer num0, Handle(Interface_Check)& ach,
46 const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)& 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_DATUM_REFERENCE","GTWDR",num0,num,ach);
62 // Own fields of GeometricToleranceWithDatumReference
63 Handle(StepDimTol_HArray1OfDatumSystemOrReference) aDatumSystem;
64 Standard_Integer sub5 = 0;
65 if ( data->ReadSubList (num, 1, "datum_system", ach, sub5) ) {
66 Standard_Integer nb0 = data->NbParams(sub5);
67 aDatumSystem = new StepDimTol_HArray1OfDatumSystemOrReference (1, nb0);
68 Standard_Integer num2 = sub5;
69 for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
70 StepDimTol_DatumSystemOrReference anIt0;
71 data->ReadEntity (num2, i0, "datum_system_or_reference", ach, anIt0);
72 aDatumSystem->SetValue(i0, anIt0);
76 Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
77 new StepDimTol_GeometricToleranceWithDatumReference;
78 GTWDR->SetDatumSystem(aDatumSystem);
80 data->NamedForComplex("MODIFIED_GEOMETRIC_TOLERANCE","MDGMTL",num0,num,ach);
81 // Own fields of ModifiedGeometricTolerance
82 StepDimTol_LimitCondition aModifier = StepDimTol_MaximumMaterialCondition;
83 if (data->ParamType (num, 1) == Interface_ParamEnum) {
84 Standard_CString text = data->ParamCValue(num, 1);
85 if (strcmp(text, ".MAXIMUM_MATERIAL_CONDITION.")==0) aModifier = StepDimTol_MaximumMaterialCondition;
86 else if (strcmp(text, ".LEAST_MATERIAL_CONDITION.")==0) aModifier = StepDimTol_LeastMaterialCondition;
87 else if (strcmp(text, ".REGARDLESS_OF_FEATURE_SIZE.")==0) aModifier = StepDimTol_RegardlessOfFeatureSize;
88 else ach->AddFail("Parameter in MODIFIED_GEOMETRIC_TOLERANCE has not allowed value");
90 else ach->AddFail("Parameter in MODIFIED_GEOMETRIC_TOLERANCE is not enumeration");
91 Handle(StepDimTol_ModifiedGeometricTolerance) MGT = new StepDimTol_ModifiedGeometricTolerance;
92 MGT->SetModifier(aModifier);
95 ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, GTWDR, MGT);
100 //=======================================================================
101 //function : WriteStep
103 //=======================================================================
105 void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::WriteStep
106 (StepData_StepWriter& SW,
107 const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)& ent) const
109 SW.StartEntity("GEOMETRIC_TOLERANCE");
110 SW.Send(ent->Name());
111 SW.Send(ent->Description());
112 SW.Send(ent->Magnitude());
113 SW.Send(ent->TolerancedShapeAspect().Value());
114 SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE");
116 for(Standard_Integer i4=1; i4<=ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Length(); i4++) {
117 StepDimTol_DatumSystemOrReference Var0 =
118 ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Value(i4);
119 SW.Send(Var0.Value());
122 SW.StartEntity("MODIFIED_GEOMETRIC_TOLERANCE");
123 switch (ent->GetModifiedGeometricTolerance()->Modifier()) {
124 case StepDimTol_MaximumMaterialCondition: SW.SendEnum(".MAXIMUM_MATERIAL_CONDITION."); break;
125 case StepDimTol_LeastMaterialCondition: SW.SendEnum(".LEAST_MATERIAL_CONDITION."); break;
126 case StepDimTol_RegardlessOfFeatureSize: SW.SendEnum(".REGARDLESS_OF_FEATURE_SIZE."); break;
128 SW.StartEntity("POSITION_TOLERANCE");
132 //=======================================================================
135 //=======================================================================
137 void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::Share
138 (const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)& ent,
139 Interface_EntityIterator& iter) const
141 // Own fields of GeometricTolerance
142 iter.AddItem (ent->Magnitude());
143 iter.AddItem (ent->TolerancedShapeAspect().Value());
144 // Own fields of GeometricToleranceWithDatumReference
145 for (Standard_Integer i3=1; i3<=ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Length(); i3++ ) {
146 StepDimTol_DatumSystemOrReference Var0 = ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Value(i3);
147 iter.AddItem (Var0.Value());