0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / RWStepElement / RWStepElement_RWCurve3dElementDescriptor.cxx
1 // Created on: 2002-12-12
2 // Created by: data exchange team
3 // Copyright (c) 2002-2014 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 // Generator:   ExpToCas (EXPRESS -> CASCADE/XSTEP Translator) V1.2
17
18 #include <Interface_Check.hxx>
19 #include <Interface_EntityIterator.hxx>
20 #include <RWStepElement_RWCurve3dElementDescriptor.hxx>
21 #include <StepData_StepReaderData.hxx>
22 #include <StepData_StepWriter.hxx>
23 #include <StepElement_Curve3dElementDescriptor.hxx>
24 #include <StepElement_CurveElementPurposeMember.hxx>
25 #include <StepElement_HArray1OfHSequenceOfCurveElementPurposeMember.hxx>
26 #include <StepElement_HSequenceOfCurveElementPurposeMember.hxx>
27
28 //=======================================================================
29 //function : RWStepElement_RWCurve3dElementDescriptor
30 //purpose  : 
31 //=======================================================================
32 RWStepElement_RWCurve3dElementDescriptor::RWStepElement_RWCurve3dElementDescriptor ()
33 {
34 }
35
36 //=======================================================================
37 //function : ReadStep
38 //purpose  : 
39 //=======================================================================
40
41 void RWStepElement_RWCurve3dElementDescriptor::ReadStep (const Handle(StepData_StepReaderData)& data,
42                                                          const Standard_Integer num,
43                                                          Handle(Interface_Check)& ach,
44                                                          const Handle(StepElement_Curve3dElementDescriptor) &ent) const
45 {
46   // Check number of parameters
47   if ( ! data->CheckNbParams(num,3,ach,"curve3d_element_descriptor") ) return;
48
49   // Inherited fields of ElementDescriptor
50
51   StepElement_ElementOrder aElementDescriptor_TopologyOrder = StepElement_Linear;
52   if (data->ParamType (num, 1) == Interface_ParamEnum) {
53     Standard_CString text = data->ParamCValue(num, 1);
54     if      (strcmp(text, ".LINEAR.")==0) aElementDescriptor_TopologyOrder = StepElement_Linear;
55     else if (strcmp(text, ".QUADRATIC.")==0) aElementDescriptor_TopologyOrder = StepElement_Quadratic;
56     else if (strcmp(text, ".CUBIC.")==0) aElementDescriptor_TopologyOrder = StepElement_Cubic;
57     else ach->AddFail("Parameter #1 (element_descriptor.topology_order) has not allowed value");
58   }
59   else ach->AddFail("Parameter #1 (element_descriptor.topology_order) is not enumeration");
60
61   Handle(TCollection_HAsciiString) aElementDescriptor_Description;
62   data->ReadString (num, 2, "element_descriptor.description", ach, aElementDescriptor_Description);
63
64   // Own fields of Curve3dElementDescriptor
65
66   Handle(StepElement_HArray1OfHSequenceOfCurveElementPurposeMember) aPurpose;
67   Standard_Integer sub3 = 0;
68   if ( data->ReadSubList (num, 3, "purpose", ach, sub3) ) {
69     Standard_Integer nb0 = data->NbParams(sub3);
70     //Standard_Integer nbj0 = data->NbParams(data->ParamNumber(sub3,1));
71     aPurpose = new StepElement_HArray1OfHSequenceOfCurveElementPurposeMember (1, nb0);
72     for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
73       Handle(StepElement_HSequenceOfCurveElementPurposeMember) HSCEPM =
74         new StepElement_HSequenceOfCurveElementPurposeMember;
75       Standard_Integer subj3 = 0;
76       if ( data->ReadSubList (sub3, i0, "sub-part(purpose)", ach, subj3) ) {
77         Standard_Integer num4 = subj3;
78         Standard_Integer nbj0 = data->NbParams(data->ParamNumber(sub3,i0));
79         for ( Standard_Integer j0=1; j0 <= nbj0; j0++ ) {
80           Handle(StepElement_CurveElementPurposeMember) aMember = new StepElement_CurveElementPurposeMember;
81           data->ReadMember(num4, j0, "curve_element_purpose", ach, aMember);
82           //data->ReadEntity (num4, j0, "curve_element_purpose", ach, anIt0);
83           HSCEPM->Append(aMember);
84         }
85       }
86       aPurpose->SetValue(i0, HSCEPM);
87     }
88   }
89
90   // Initialize entity
91   ent->Init(aElementDescriptor_TopologyOrder,
92             aElementDescriptor_Description,
93             aPurpose);
94 }
95
96 //=======================================================================
97 //function : WriteStep
98 //purpose  : 
99 //=======================================================================
100
101 void RWStepElement_RWCurve3dElementDescriptor::WriteStep (StepData_StepWriter& SW,
102                                                           const Handle(StepElement_Curve3dElementDescriptor) &ent) const
103 {
104
105   // Inherited fields of ElementDescriptor
106
107   switch (ent->StepElement_ElementDescriptor::TopologyOrder()) {
108     case StepElement_Linear: SW.SendEnum (".LINEAR."); break;
109     case StepElement_Quadratic: SW.SendEnum (".QUADRATIC."); break;
110     case StepElement_Cubic: SW.SendEnum (".CUBIC."); break;
111   }
112
113   SW.Send (ent->StepElement_ElementDescriptor::Description());
114
115   // Own fields of Curve3dElementDescriptor
116
117   SW.OpenSub();
118   for (Standard_Integer i2=1; i2 <= ent->Purpose()->Length(); i2++ ) {
119     SW.NewLine(Standard_False);
120     SW.OpenSub();
121     Handle(StepElement_HSequenceOfCurveElementPurposeMember) HSCEPM = ent->Purpose()->Value(i2);
122     for (Standard_Integer j2=1; j2 <= HSCEPM->Length(); j2++ ) {
123       Handle(StepElement_CurveElementPurposeMember) Var0 = HSCEPM->Value(j2);
124       SW.Send (Var0);
125     }
126     SW.CloseSub();
127   }
128   SW.CloseSub();
129 }
130
131 //=======================================================================
132 //function : Share
133 //purpose  : 
134 //=======================================================================
135
136 void RWStepElement_RWCurve3dElementDescriptor::Share (const Handle(StepElement_Curve3dElementDescriptor)&,
137                                                       Interface_EntityIterator&) const
138 {
139
140   // Inherited fields of ElementDescriptor
141
142   // Own fields of Curve3dElementDescriptor
143 /* CKY  17JUN04. Content is made of strings and enums. No entity !
144   for (Standard_Integer i1=1; i1 <= ent->Purpose()->Length(); i1++ ) {
145     Handle(StepElement_HSequenceOfCurveElementPurposeMember) HSCEPM = ent->Purpose()->Value(i1);
146     for (Standard_Integer i2=1; i2 <= HSCEPM->Length(); i2++ ) {
147       Handle(StepElement_CurveElementPurposeMember) Var1 = HSCEPM->Value(i2);
148       iter.AddItem (Var1);
149     }
150   }
151 */
152 }