1 // Created on: 2015-07-07
2 // Created by: Irina KRYLOVA
3 // Copyright (c) 2015 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit.hxx>
18 #include <Interface_Check.hxx>
19 #include <Interface_EntityIterator.hxx>
20 #include <StepBasic_LengthMeasureWithUnit.hxx>
21 #include <StepBasic_MeasureWithUnit.hxx>
22 #include <StepData_StepReaderData.hxx>
23 #include <StepData_StepWriter.hxx>
24 #include <StepDimTol_AreaUnitType.hxx>
25 #include <StepDimTol_GeometricToleranceTarget.hxx>
26 #include <StepDimTol_GeometricToleranceWithDefinedAreaUnit.hxx>
28 //=======================================================================
29 //function : RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit
31 //=======================================================================
33 RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit::RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit ()
37 //=======================================================================
40 //=======================================================================
42 void RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit::
43 ReadStep (const Handle(StepData_StepReaderData)& data,
44 const Standard_Integer num,
45 Handle(Interface_Check)& ach,
46 const Handle(StepDimTol_GeometricToleranceWithDefinedAreaUnit) &ent) const
48 // Check number of parameters
49 if ( ! data->CheckNbParams(num, 7, ach, "geometric_tolerance_with_defined_area_unit") ) return;
51 // inherited fields from GeometricTolerance
53 Handle(TCollection_HAsciiString) aName;
54 data->ReadString (num, 1, "geometric_tolerance.name", ach, aName);
56 Handle(TCollection_HAsciiString) aDescription;
57 data->ReadString (num, 2, "geometric_tolerance.description", ach, aDescription);
59 Handle(StepBasic_MeasureWithUnit) aMagnitude;
60 data->ReadEntity (num, 3, "geometric_tolerance.magnitude", ach, STANDARD_TYPE(StepBasic_MeasureWithUnit), aMagnitude);
62 StepDimTol_GeometricToleranceTarget aTolerancedShapeAspect;
63 data->ReadEntity (num, 4, "geometric_tolerance.toleranced_shape_aspect", ach, aTolerancedShapeAspect);
65 // inherited fields from GeometricToleranceWithDefinedUnit
67 Handle(StepBasic_LengthMeasureWithUnit) anUnitSize;
68 data->ReadEntity (num, 5, "geometric_tolerance_with_defined_unit.unit_size", ach, STANDARD_TYPE(StepBasic_LengthMeasureWithUnit), anUnitSize);
70 // own fields of GeometricToleranceWithDefinedAreaUnit
71 StepDimTol_AreaUnitType aType = StepDimTol_Circular;
72 if (data->ParamType (num, 6) == Interface_ParamEnum) {
73 Standard_CString text = data->ParamCValue(num, 6);
74 if (strcmp(text, ".CIRCULAR.")==0) aType = StepDimTol_Circular;
75 else if (strcmp(text, ".RECTANGULAR.")==0) aType = StepDimTol_Rectangular;
76 else if (strcmp(text, ".SQUARE.")==0) aType = StepDimTol_Square;
77 else ach->AddFail("Parameter #6 (area_type) has not allowed value");
79 else ach->AddFail("Parameter #6 (area_type) is not enumerations");
81 Handle(StepBasic_LengthMeasureWithUnit) aSecondUnitSize;
82 Standard_Boolean hasSecondUnitSize = data->IsParamDefined(num, 7);
83 if (hasSecondUnitSize)
84 data->ReadEntity(num, 7, "second_unit_size", ach, STANDARD_TYPE(StepBasic_LengthMeasureWithUnit), aSecondUnitSize);
90 aTolerancedShapeAspect,
97 //=======================================================================
98 //function : WriteStep
100 //=======================================================================
102 void RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit::
103 WriteStep (StepData_StepWriter& SW,
104 const Handle(StepDimTol_GeometricToleranceWithDefinedAreaUnit) &ent) const
107 // inherited fields from GeometricTolerance
109 SW.Send (ent->Name());
111 SW.Send (ent->Description());
113 SW.Send (ent->Magnitude());
115 SW.Send (ent->TolerancedShapeAspect().Value());
117 // inherited fields from GeometricToleranceWithDefinedUnit
119 SW.Send (ent->UnitSize());
121 // own fields of GeometricToleranceWithDefinedAreaUnit
123 switch (ent->AreaType()) {
124 case StepDimTol_Circular: SW.SendEnum (".CIRCULAR."); break;
125 case StepDimTol_Rectangular: SW.SendEnum (".RECTANGULAR."); break;
126 case StepDimTol_Square: SW.SendEnum (".SQUARE."); break;
129 if (ent->HasSecondUnitSize())
130 SW.Send (ent->SecondUnitSize());
135 //=======================================================================
138 //=======================================================================
140 void RWStepDimTol_RWGeometricToleranceWithDefinedAreaUnit::
141 Share (const Handle(StepDimTol_GeometricToleranceWithDefinedAreaUnit) &ent,
142 Interface_EntityIterator& iter) const
145 // inherited fields from GeometricTolerance
147 iter.AddItem (ent->Magnitude());
149 iter.AddItem (ent->TolerancedShapeAspect().Value());