973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | |
42cf5bc1 |
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> |
7fd59977 |
21 | #include <StepDimTol_DatumReference.hxx> |
28a73c1f |
22 | #include <StepDimTol_GeometricToleranceTarget.hxx> |
7fd59977 |
23 | #include <StepDimTol_GeometricToleranceWithDatumReference.hxx> |
42cf5bc1 |
24 | #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx> |
28a73c1f |
25 | #include <StepDimTol_HArray1OfDatumSystemOrReference.hxx> |
7fd59977 |
26 | #include <StepDimTol_LimitCondition.hxx> |
42cf5bc1 |
27 | #include <StepDimTol_ModifiedGeometricTolerance.hxx> |
7fd59977 |
28 | |
7fd59977 |
29 | //======================================================================= |
30 | //function : RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol |
31 | //purpose : |
32 | //======================================================================= |
7fd59977 |
33 | RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol() |
34 | { |
35 | } |
36 | |
37 | |
38 | //======================================================================= |
39 | //function : ReadStep |
40 | //purpose : |
41 | //======================================================================= |
42 | |
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 |
47 | { |
48 | Standard_Integer num = 0;//num0; |
a7197ef3 |
49 | data->NamedForComplex("GEOMETRIC_TOLERANCE","GMTTLR",num0,num,ach); |
7fd59977 |
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); |
28a73c1f |
58 | StepDimTol_GeometricToleranceTarget aTolerancedShapeAspect; |
59 | data->ReadEntity (num, 4, "toleranced_shape_aspect", ach, aTolerancedShapeAspect); |
7fd59977 |
60 | |
a7197ef3 |
61 | data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE","GTWDR",num0,num,ach); |
7fd59977 |
62 | // Own fields of GeometricToleranceWithDatumReference |
28a73c1f |
63 | Handle(StepDimTol_HArray1OfDatumSystemOrReference) aDatumSystem; |
7fd59977 |
64 | Standard_Integer sub5 = 0; |
65 | if ( data->ReadSubList (num, 1, "datum_system", ach, sub5) ) { |
66 | Standard_Integer nb0 = data->NbParams(sub5); |
28a73c1f |
67 | aDatumSystem = new StepDimTol_HArray1OfDatumSystemOrReference (1, nb0); |
7fd59977 |
68 | Standard_Integer num2 = sub5; |
69 | for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) { |
28a73c1f |
70 | StepDimTol_DatumSystemOrReference anIt0; |
71 | data->ReadEntity (num2, i0, "datum_system_or_reference", ach, anIt0); |
7fd59977 |
72 | aDatumSystem->SetValue(i0, anIt0); |
73 | } |
74 | } |
75 | // Initialize entity |
76 | Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR = |
77 | new StepDimTol_GeometricToleranceWithDatumReference; |
78 | GTWDR->SetDatumSystem(aDatumSystem); |
79 | |
a7197ef3 |
80 | data->NamedForComplex("MODIFIED_GEOMETRIC_TOLERANCE","MDGMTL",num0,num,ach); |
7fd59977 |
81 | // Own fields of ModifiedGeometricTolerance |
1d47d8d0 |
82 | StepDimTol_LimitCondition aModifier = StepDimTol_MaximumMaterialCondition; |
7fd59977 |
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"); |
89 | } |
90 | else ach->AddFail("Parameter in MODIFIED_GEOMETRIC_TOLERANCE is not enumeration"); |
91 | Handle(StepDimTol_ModifiedGeometricTolerance) MGT = new StepDimTol_ModifiedGeometricTolerance; |
92 | MGT->SetModifier(aModifier); |
93 | |
94 | // Initialize entity |
95 | ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, GTWDR, MGT); |
96 | |
97 | } |
98 | |
99 | |
100 | //======================================================================= |
101 | //function : WriteStep |
102 | //purpose : |
103 | //======================================================================= |
104 | |
105 | void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::WriteStep |
106 | (StepData_StepWriter& SW, |
107 | const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)& ent) const |
108 | { |
109 | SW.StartEntity("GEOMETRIC_TOLERANCE"); |
110 | SW.Send(ent->Name()); |
111 | SW.Send(ent->Description()); |
112 | SW.Send(ent->Magnitude()); |
28a73c1f |
113 | SW.Send(ent->TolerancedShapeAspect().Value()); |
7fd59977 |
114 | SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE"); |
115 | SW.OpenSub(); |
28a73c1f |
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()); |
7fd59977 |
120 | } |
121 | SW.CloseSub(); |
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; |
127 | } |
128 | SW.StartEntity("POSITION_TOLERANCE"); |
129 | } |
130 | |
131 | |
132 | //======================================================================= |
133 | //function : Share |
134 | //purpose : |
135 | //======================================================================= |
136 | |
137 | void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol::Share |
138 | (const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)& ent, |
139 | Interface_EntityIterator& iter) const |
140 | { |
141 | // Own fields of GeometricTolerance |
142 | iter.AddItem (ent->Magnitude()); |
28a73c1f |
143 | iter.AddItem (ent->TolerancedShapeAspect().Value()); |
7fd59977 |
144 | // Own fields of GeometricToleranceWithDatumReference |
28a73c1f |
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()); |
7fd59977 |
148 | } |
149 | } |