0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / RWStepDimTol / RWStepDimTol_RWGeometricToleranceWithModifiers.cxx
CommitLineData
28a73c1f 1// Created on: 2015-07-07
2// Created by: Irina KRYLOVA
3// Copyright (c) 2015 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#include <RWStepDimTol_RWGeometricToleranceWithModifiers.hxx>
17
18#include <Interface_Check.hxx>
19#include <Interface_EntityIterator.hxx>
20#include <StepBasic_MeasureWithUnit.hxx>
21#include <StepData_StepReaderData.hxx>
22#include <StepData_StepWriter.hxx>
23#include <StepDimTol_GeometricToleranceModifier.hxx>
24#include <StepDimTol_GeometricToleranceTarget.hxx>
25#include <StepDimTol_GeometricToleranceWithModifiers.hxx>
26#include <StepDimTol_HArray1OfGeometricToleranceModifier.hxx>
27
28//=======================================================================
29//function : RWStepDimTol_RWGeometricTolerance
30//purpose :
31//=======================================================================
32
33RWStepDimTol_RWGeometricToleranceWithModifiers::RWStepDimTol_RWGeometricToleranceWithModifiers ()
34{
35}
36
37//=======================================================================
38//function : ReadStep
39//purpose :
40//=======================================================================
41
42void RWStepDimTol_RWGeometricToleranceWithModifiers::
43 ReadStep (const Handle(StepData_StepReaderData)& data,
44 const Standard_Integer num,
45 Handle(Interface_Check)& ach,
46 const Handle(StepDimTol_GeometricToleranceWithModifiers) &ent) const
47{
48 // Check number of parameters
49 if ( ! data->CheckNbParams(num, 5, ach, "geometric_tolerance_with_modifiers") ) return;
50
51 // inherited fields from GeometricTolerance
52
53 Handle(TCollection_HAsciiString) aName;
54 data->ReadString (num, 1, "geometric_tolerance.name", ach, aName);
55
56 Handle(TCollection_HAsciiString) aDescription;
57 data->ReadString (num, 2, "geometric_tolerance.description", ach, aDescription);
58
59 Handle(StepBasic_MeasureWithUnit) aMagnitude;
60 data->ReadEntity (num, 3, "geometric_tolerance.magnitude", ach, STANDARD_TYPE(StepBasic_MeasureWithUnit), aMagnitude);
61
62 StepDimTol_GeometricToleranceTarget aTolerancedShapeAspect;
63 data->ReadEntity (num, 4, "geometric_tolerance.toleranced_shape_aspect", ach, aTolerancedShapeAspect);
64
65 // own fields of GeometricToleranceWithModifiers
66 Handle(StepDimTol_HArray1OfGeometricToleranceModifier) aModifiers;
67 Standard_Integer sub5 = 0;
68 if ( data->ReadSubList (num, 5, "modifiers", ach, sub5) ) {
69 Standard_Integer nb0 = data->NbParams(sub5);
70 aModifiers = new StepDimTol_HArray1OfGeometricToleranceModifier (1, nb0);
71 Standard_Integer num2 = sub5;
72 for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
73 StepDimTol_GeometricToleranceModifier anIt0 = StepDimTol_GTMMaximumMaterialRequirement;
74 if (data->ParamType (num2, i0) == Interface_ParamEnum) {
75 Standard_CString text = data->ParamCValue(num2, i0);
76 if (strcmp(text, ".ANY_CROSS_SECTION.")==0) anIt0 = StepDimTol_GTMAnyCrossSection;
77 else if (strcmp(text, ".COMMON_ZONE.")==0) anIt0 = StepDimTol_GTMCommonZone;
78 else if (strcmp(text, ".EACH_RADIAL_ELEMENT.")==0) anIt0 = StepDimTol_GTMEachRadialElement;
79 else if (strcmp(text, ".FREE_STATE.")==0) anIt0 = StepDimTol_GTMFreeState;
80 else if (strcmp(text, ".LEAST_MATERIAL_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMLeastMaterialRequirement;
81 else if (strcmp(text, ".LINE_ELEMENT.")==0) anIt0 = StepDimTol_GTMLineElement;
82 else if (strcmp(text, ".MAJOR_DIAMETER.")==0) anIt0 = StepDimTol_GTMMajorDiameter;
83 else if (strcmp(text, ".MAXIMUM_MATERIAL_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMMaximumMaterialRequirement;
84 else if (strcmp(text, ".MINOR_DIAMETER.")==0) anIt0 = StepDimTol_GTMMinorDiameter;
85 else if (strcmp(text, ".NOT_CONVEX.")==0) anIt0 = StepDimTol_GTMNotConvex;
86 else if (strcmp(text, ".PITCH_DIAMETER.")==0) anIt0 = StepDimTol_GTMPitchDiameter;
87 else if (strcmp(text, ".RECIPROCITY_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMReciprocityRequirement;
88 else if (strcmp(text, ".SEPARATE_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMSeparateRequirement;
89 else if (strcmp(text, ".STATISTICAL_TOLERANCE.")==0) anIt0 = StepDimTol_GTMStatisticalTolerance;
90 else if (strcmp(text, ".TANGENT_PLANE.")==0) anIt0 = StepDimTol_GTMTangentPlane;
91 else ach->AddFail("Parameter #5 (modifiers) has not allowed value");
92 }
93 else ach->AddFail("Parameter #5 (modifier) is not set of enumerations");
94 aModifiers->SetValue(i0, anIt0);
95 }
96 }
97
98 // Initialize entity
99 ent->Init(aName,
100 aDescription,
101 aMagnitude,
102 aTolerancedShapeAspect,
103 aModifiers);
104}
105
106//=======================================================================
107//function : WriteStep
108//purpose :
109//=======================================================================
110
111void RWStepDimTol_RWGeometricToleranceWithModifiers::
112 WriteStep (StepData_StepWriter& SW,
113 const Handle(StepDimTol_GeometricToleranceWithModifiers) &ent) const
114{
115
116 // inherited fields from GeometricTolerance
117
118 SW.Send (ent->Name());
119
120 SW.Send (ent->Description());
121
122 SW.Send (ent->Magnitude());
123
124 SW.Send (ent->TolerancedShapeAspect().Value());
125
126 // own fields of GeometricToleranceWithModifiers
127
128 SW.OpenSub();
129 for (Standard_Integer i = 1; i <= ent->NbModifiers(); i++) {
130 switch (ent->ModifierValue(i)) {
131 case StepDimTol_GTMAnyCrossSection: SW.SendEnum (".ANY_CROSS_SECTION."); break;
132 case StepDimTol_GTMCommonZone: SW.SendEnum (".COMMON_ZONE."); break;
133 case StepDimTol_GTMEachRadialElement: SW.SendEnum (".EACH_RADIAL_ELEMENT."); break;
134 case StepDimTol_GTMFreeState: SW.SendEnum (".FREE_STATE."); break;
135 case StepDimTol_GTMLeastMaterialRequirement: SW.SendEnum (".LEAST_MATERIAL_REQUIREMENT."); break;
136 case StepDimTol_GTMLineElement: SW.SendEnum (".LINE_ELEMENT."); break;
137 case StepDimTol_GTMMajorDiameter: SW.SendEnum (".MAJOR_DIAMETER."); break;
138 case StepDimTol_GTMMaximumMaterialRequirement: SW.SendEnum (".MAXIMUM_MATERIAL_REQUIREMENT."); break;
139 case StepDimTol_GTMMinorDiameter: SW.SendEnum (".MINOR_DIAMETER."); break;
140 case StepDimTol_GTMNotConvex: SW.SendEnum (".NOT_CONVEX."); break;
141 case StepDimTol_GTMPitchDiameter: SW.SendEnum (".PITCH_DIAMETER."); break;
142 case StepDimTol_GTMReciprocityRequirement: SW.SendEnum (".RECIPROCITY_REQUIREMENT."); break;
143 case StepDimTol_GTMSeparateRequirement: SW.SendEnum (".SEPARATE_REQUIREMENT."); break;
144 case StepDimTol_GTMStatisticalTolerance: SW.SendEnum (".STATISTICAL_TOLERANCE."); break;
145 case StepDimTol_GTMTangentPlane: SW.SendEnum (".TANGENT_PLANE."); break;
146 }
147 }
148 SW.CloseSub();
149}
150
151//=======================================================================
152//function : Share
153//purpose :
154//=======================================================================
155
156void RWStepDimTol_RWGeometricToleranceWithModifiers::
157 Share (const Handle(StepDimTol_GeometricToleranceWithModifiers) &ent,
158 Interface_EntityIterator& iter) const
159{
160
161 // inherited fields from GeometricTolerance
162
163 iter.AddItem (ent->Magnitude());
164
165 iter.AddItem (ent->TolerancedShapeAspect().Value());
166}