0024059: Eliminate compiler warning C4701 in MSVC++ with warning level 4
[occt.git] / src / RWStepDimTol / RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.cxx
1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
2 //
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
7 //
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10 //
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
17
18 #include <RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.ixx>
19
20 #include <StepDimTol_HArray1OfDatumReference.hxx>
21 #include <StepDimTol_DatumReference.hxx>
22 #include <StepDimTol_GeometricToleranceWithDatumReference.hxx>
23 #include <StepDimTol_ModifiedGeometricTolerance.hxx>
24 #include <StepDimTol_LimitCondition.hxx>
25
26
27 //=======================================================================
28 //function : RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol
29 //purpose  : 
30 //=======================================================================
31
32 RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol()
33 {
34 }
35
36
37 //=======================================================================
38 //function : ReadStep
39 //purpose  : 
40 //=======================================================================
41
42 void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::ReadStep
43   (const Handle(StepData_StepReaderData)& data,
44    const Standard_Integer num0, Handle(Interface_Check)& ach,
45    const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)& ent) const
46 {
47   Standard_Integer num = 0;//num0;
48   data->NamedForComplex("GEOMETRIC_TOLERANCE",num0,num,ach);
49   if (!data->CheckNbParams(num,4,ach,"geometric_tolerance")) return;
50   // Own fields of GeometricTolerance
51   Handle(TCollection_HAsciiString) aName;
52   data->ReadString (num, 1, "name", ach, aName);
53   Handle(TCollection_HAsciiString) aDescription;
54   data->ReadString (num, 2, "description", ach, aDescription);
55   Handle(StepBasic_MeasureWithUnit) aMagnitude;
56   data->ReadEntity (num, 3, "magnitude", ach, STANDARD_TYPE(StepBasic_MeasureWithUnit), aMagnitude);
57   Handle(StepRepr_ShapeAspect) aTolerancedShapeAspect;
58   data->ReadEntity (num, 4, "toleranced_shape_aspect", ach, STANDARD_TYPE(StepRepr_ShapeAspect), aTolerancedShapeAspect);
59
60   data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE",num0,num,ach);
61   // Own fields of GeometricToleranceWithDatumReference
62   Handle(StepDimTol_HArray1OfDatumReference) aDatumSystem;
63   Standard_Integer sub5 = 0;
64   if ( data->ReadSubList (num, 1, "datum_system", ach, sub5) ) {
65     Standard_Integer nb0 = data->NbParams(sub5);
66     aDatumSystem = new StepDimTol_HArray1OfDatumReference (1, nb0);
67     Standard_Integer num2 = sub5;
68     for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
69       Handle(StepDimTol_DatumReference) anIt0;
70       data->ReadEntity (num2, i0, "datum_reference", ach, STANDARD_TYPE(StepDimTol_DatumReference), anIt0);
71       aDatumSystem->SetValue(i0, anIt0);
72     }
73   }
74   // Initialize entity
75   Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
76     new StepDimTol_GeometricToleranceWithDatumReference;
77   GTWDR->SetDatumSystem(aDatumSystem);
78
79   data->NamedForComplex("MODIFIED_GEOMETRIC_TOLERANCE",num0,num,ach);
80   // Own fields of ModifiedGeometricTolerance
81   StepDimTol_LimitCondition aModifier = StepDimTol_MaximumMaterialCondition;
82   if (data->ParamType (num, 1) == Interface_ParamEnum) {
83     Standard_CString text = data->ParamCValue(num, 1);
84     if      (strcmp(text, ".MAXIMUM_MATERIAL_CONDITION.")==0) aModifier = StepDimTol_MaximumMaterialCondition;
85     else if (strcmp(text, ".LEAST_MATERIAL_CONDITION.")==0) aModifier = StepDimTol_LeastMaterialCondition;
86     else if (strcmp(text, ".REGARDLESS_OF_FEATURE_SIZE.")==0) aModifier = StepDimTol_RegardlessOfFeatureSize;
87     else ach->AddFail("Parameter in MODIFIED_GEOMETRIC_TOLERANCE has not allowed value");
88   }
89   else ach->AddFail("Parameter in MODIFIED_GEOMETRIC_TOLERANCE is not enumeration");
90   Handle(StepDimTol_ModifiedGeometricTolerance) MGT = new StepDimTol_ModifiedGeometricTolerance;
91   MGT->SetModifier(aModifier);
92
93   // Initialize entity
94   ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, GTWDR, MGT);
95
96 }
97
98
99 //=======================================================================
100 //function : WriteStep
101 //purpose  : 
102 //=======================================================================
103
104 void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::WriteStep
105   (StepData_StepWriter& SW,
106    const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)& ent) const
107 {
108   SW.StartEntity("GEOMETRIC_TOLERANCE");
109   SW.Send(ent->Name());
110   SW.Send(ent->Description());
111   SW.Send(ent->Magnitude());
112   SW.Send(ent->TolerancedShapeAspect());
113   SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE");
114   SW.OpenSub();
115   for(Standard_Integer i4=1; i4<=ent->GetGeometricToleranceWithDatumReference()->DatumSystem()->Length(); i4++) {
116     Handle(StepDimTol_DatumReference) Var0 =
117       ent->GetGeometricToleranceWithDatumReference()->DatumSystem()->Value(i4);
118     SW.Send(Var0);
119   }
120   SW.CloseSub();
121   SW.StartEntity("MODIFIED_GEOMETRIC_TOLERANCE");
122   switch (ent->GetModifiedGeometricTolerance()->Modifier()) {
123     case StepDimTol_MaximumMaterialCondition: SW.SendEnum(".MAXIMUM_MATERIAL_CONDITION."); break;
124     case StepDimTol_LeastMaterialCondition: SW.SendEnum(".LEAST_MATERIAL_CONDITION."); break;
125     case StepDimTol_RegardlessOfFeatureSize: SW.SendEnum(".REGARDLESS_OF_FEATURE_SIZE."); break;
126   }
127   SW.StartEntity("POSITION_TOLERANCE");
128 }
129
130
131 //=======================================================================
132 //function : Share
133 //purpose  : 
134 //=======================================================================
135
136 void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::Share
137   (const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)& ent,
138    Interface_EntityIterator& iter) const
139 {
140   // Own fields of GeometricTolerance
141   iter.AddItem (ent->Magnitude());
142   iter.AddItem (ent->TolerancedShapeAspect());
143   // Own fields of GeometricToleranceWithDatumReference
144   for (Standard_Integer i3=1; i3<=ent->GetGeometricToleranceWithDatumReference()->DatumSystem()->Length(); i3++ ) {
145     Handle(StepDimTol_DatumReference) Var0 = ent->GetGeometricToleranceWithDatumReference()->DatumSystem()->Value(i3);
146     iter.AddItem (Var0);
147   }
148 }