de17141f6fe153b769f9a153568bdd901c730e14
[occt.git] / src / RWStepShape / RWStepShape_RWAngularLocation.cxx
1 // Created on: 2000-04-18
2 // Created by: Andrey BETENEV
3 // Copyright (c) 2000-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20 // Generator:   ExpToCas (EXPRESS -> CASCADE/XSTEP Translator) V1.0
21
22 #include <RWStepShape_RWAngularLocation.ixx>
23
24 //=======================================================================
25 //function : RWStepShape_RWAngularLocation
26 //purpose  : 
27 //=======================================================================
28
29 RWStepShape_RWAngularLocation::RWStepShape_RWAngularLocation ()
30 {
31 }
32
33 //=======================================================================
34 //function : ReadStep
35 //purpose  : 
36 //=======================================================================
37
38 void RWStepShape_RWAngularLocation::ReadStep (const Handle(StepData_StepReaderData)& data,
39                                               const Standard_Integer num,
40                                               Handle(Interface_Check)& ach,
41                                               const Handle(StepShape_AngularLocation) &ent) const
42 {
43   // Check number of parameters
44   if ( ! data->CheckNbParams(num,5,ach,"angular_location") ) return;
45
46   // Inherited fields of ShapeAspectRelationship
47
48   Handle(TCollection_HAsciiString) aShapeAspectRelationship_Name;
49   data->ReadString (num, 1, "shape_aspect_relationship.name", ach, aShapeAspectRelationship_Name);
50
51   Handle(TCollection_HAsciiString) aShapeAspectRelationship_Description;
52   Standard_Boolean hasShapeAspectRelationship_Description = Standard_True;
53   if ( data->IsParamDefined (num,2) ) {
54     data->ReadString (num, 2, "shape_aspect_relationship.description", ach, aShapeAspectRelationship_Description);
55   }
56   else {
57     hasShapeAspectRelationship_Description = Standard_False;
58   }
59
60   Handle(StepRepr_ShapeAspect) aShapeAspectRelationship_RelatingShapeAspect;
61   data->ReadEntity (num, 3, "shape_aspect_relationship.relating_shape_aspect", ach, STANDARD_TYPE(StepRepr_ShapeAspect), aShapeAspectRelationship_RelatingShapeAspect);
62
63   Handle(StepRepr_ShapeAspect) aShapeAspectRelationship_RelatedShapeAspect;
64   data->ReadEntity (num, 4, "shape_aspect_relationship.related_shape_aspect", ach, STANDARD_TYPE(StepRepr_ShapeAspect), aShapeAspectRelationship_RelatedShapeAspect);
65
66   // Own fields of AngularLocation
67
68 // PTV 16.09.2000
69 // defaul value set as StepShape_Small, cause there wasn`t default value, but may be situation when
70 // value will not be initialized and returnd in ent->Init.
71   StepShape_AngleRelator aAngleSelection = StepShape_Small;
72   if (data->ParamType (num, 5) == Interface_ParamEnum) {
73     Standard_CString text = data->ParamCValue(num, 5);
74     if      (strcmp(text, ".EQUAL.")) aAngleSelection = StepShape_Equal;
75     else if (strcmp(text, ".LARGE.")) aAngleSelection = StepShape_Large;
76     else if (strcmp(text, ".SMALL.")) aAngleSelection = StepShape_Small;
77     else ach->AddFail("Parameter #5 (angle_selection) has not allowed value");
78   }
79   else ach->AddFail("Parameter #5 (angle_selection) is not enumeration");
80
81   // Initialize entity
82   ent->Init(aShapeAspectRelationship_Name,
83             hasShapeAspectRelationship_Description,
84             aShapeAspectRelationship_Description,
85             aShapeAspectRelationship_RelatingShapeAspect,
86             aShapeAspectRelationship_RelatedShapeAspect,
87             aAngleSelection);
88 }
89
90 //=======================================================================
91 //function : WriteStep
92 //purpose  : 
93 //=======================================================================
94
95 void RWStepShape_RWAngularLocation::WriteStep (StepData_StepWriter& SW,
96                                                const Handle(StepShape_AngularLocation) &ent) const
97 {
98
99   // Inherited fields of ShapeAspectRelationship
100
101   SW.Send (ent->StepRepr_ShapeAspectRelationship::Name());
102
103   if ( ent->StepRepr_ShapeAspectRelationship::HasDescription() ) {
104     SW.Send (ent->StepRepr_ShapeAspectRelationship::Description());
105   }
106   else SW.SendUndef();
107
108   SW.Send (ent->StepRepr_ShapeAspectRelationship::RelatingShapeAspect());
109
110   SW.Send (ent->StepRepr_ShapeAspectRelationship::RelatedShapeAspect());
111
112   // Own fields of AngularLocation
113
114   switch (ent->AngleSelection()) {
115     case StepShape_Equal: SW.SendEnum (".EQUAL."); break;
116     case StepShape_Large: SW.SendEnum (".LARGE."); break;
117     case StepShape_Small: SW.SendEnum (".SMALL."); break;
118   }
119 }
120
121 //=======================================================================
122 //function : Share
123 //purpose  : 
124 //=======================================================================
125
126 void RWStepShape_RWAngularLocation::Share (const Handle(StepShape_AngularLocation) &ent,
127                                            Interface_EntityIterator& iter) const
128 {
129
130   // Inherited fields of ShapeAspectRelationship
131
132   iter.AddItem (ent->StepRepr_ShapeAspectRelationship::RelatingShapeAspect());
133
134   iter.AddItem (ent->StepRepr_ShapeAspectRelationship::RelatedShapeAspect());
135
136   // Own fields of AngularLocation
137 }