0030686: Visualization, SelectMgr_ViewerSelector - sorting issues of transformation...
[occt.git] / src / RWStepElement / RWStepElement_RWSurface3dElementDescriptor.cxx
CommitLineData
b311480e 1// Created on: 2002-12-12
2// Created by: data exchange team
973c2be1 3// Copyright (c) 2002-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
7fd59977 16// Generator: ExpToCas (EXPRESS -> CASCADE/XSTEP Translator) V1.2
7fd59977 17
42cf5bc1 18#include <Interface_Check.hxx>
19#include <Interface_EntityIterator.hxx>
20#include <RWStepElement_RWSurface3dElementDescriptor.hxx>
21#include <StepData_StepReaderData.hxx>
22#include <StepData_StepWriter.hxx>
7fd59977 23#include <StepElement_HArray1OfHSequenceOfSurfaceElementPurposeMember.hxx>
24#include <StepElement_HSequenceOfSurfaceElementPurposeMember.hxx>
42cf5bc1 25#include <StepElement_Surface3dElementDescriptor.hxx>
7fd59977 26#include <StepElement_SurfaceElementPurposeMember.hxx>
27
28//=======================================================================
29//function : RWStepElement_RWSurface3dElementDescriptor
30//purpose :
31//=======================================================================
7fd59977 32RWStepElement_RWSurface3dElementDescriptor::RWStepElement_RWSurface3dElementDescriptor ()
33{
34}
35
36//=======================================================================
37//function : ReadStep
38//purpose :
39//=======================================================================
40
41void RWStepElement_RWSurface3dElementDescriptor::ReadStep (const Handle(StepData_StepReaderData)& data,
42 const Standard_Integer num,
43 Handle(Interface_Check)& ach,
44 const Handle(StepElement_Surface3dElementDescriptor) &ent) const
45{
46 // Check number of parameters
47 if ( ! data->CheckNbParams(num,4,ach,"surface3d_element_descriptor") ) return;
48
49 // Inherited fields of ElementDescriptor
50
1d47d8d0 51 StepElement_ElementOrder aElementDescriptor_TopologyOrder = StepElement_Linear;
7fd59977 52 if (data->ParamType (num, 1) == Interface_ParamEnum) {
53 Standard_CString text = data->ParamCValue(num, 1);
54 if (!strcmp(text, ".LINEAR.")) aElementDescriptor_TopologyOrder = StepElement_Linear;
55 else if (!strcmp(text, ".QUADRATIC.")) aElementDescriptor_TopologyOrder = StepElement_Quadratic;
56 else if (!strcmp(text, ".CUBIC.")) 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 Surface3dElementDescriptor
65
66 Handle(StepElement_HArray1OfHSequenceOfSurfaceElementPurposeMember) 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_HArray1OfHSequenceOfSurfaceElementPurposeMember (1, nb0);
72 for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
73 Handle(StepElement_HSequenceOfSurfaceElementPurposeMember) HSSEPM =
74 new StepElement_HSequenceOfSurfaceElementPurposeMember;
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_SurfaceElementPurposeMember) aMember = new StepElement_SurfaceElementPurposeMember;
81 data->ReadMember (num4, j0, "surface_element_purpose", ach, aMember);
82 HSSEPM->Append(aMember);
83 }
84 }
85 aPurpose->SetValue(i0, HSSEPM);
86 }
87 }
88
1d47d8d0 89 StepElement_Element2dShape aShape = StepElement_Quadrilateral;
7fd59977 90 if (data->ParamType (num, 4) == Interface_ParamEnum) {
91 Standard_CString text = data->ParamCValue(num, 4);
92 if (!strcmp(text, ".QUADRILATERAL.")) aShape = StepElement_Quadrilateral;
93 else if (!strcmp(text, ".TRIANGLE.")) aShape = StepElement_Triangle;
94 else ach->AddFail("Parameter #4 (shape) has not allowed value");
95 }
96 else ach->AddFail("Parameter #4 (shape) is not enumeration");
97
98 // Initialize entity
99 ent->Init(aElementDescriptor_TopologyOrder,
100 aElementDescriptor_Description,
101 aPurpose,
102 aShape);
103}
104
105//=======================================================================
106//function : WriteStep
107//purpose :
108//=======================================================================
109
110void RWStepElement_RWSurface3dElementDescriptor::WriteStep (StepData_StepWriter& SW,
111 const Handle(StepElement_Surface3dElementDescriptor) &ent) const
112{
113
114 // Inherited fields of ElementDescriptor
115
116 switch (ent->StepElement_ElementDescriptor::TopologyOrder()) {
117 case StepElement_Linear: SW.SendEnum (".LINEAR."); break;
118 case StepElement_Quadratic: SW.SendEnum (".QUADRATIC."); break;
119 case StepElement_Cubic: SW.SendEnum (".CUBIC."); break;
120 }
121
122 SW.Send (ent->StepElement_ElementDescriptor::Description());
123
124 // Own fields of Surface3dElementDescriptor
125
126 SW.OpenSub();
127 for (Standard_Integer i2=1; i2 <= ent->Purpose()->Length(); i2++ ) {
128 SW.NewLine(Standard_False);
129 SW.OpenSub();
130 Handle(StepElement_HSequenceOfSurfaceElementPurposeMember) HSSEPM = ent->Purpose()->Value(i2);
131 for (Standard_Integer j2=1; j2 <= HSSEPM->Length(); j2++ ) {
132 Handle(StepElement_SurfaceElementPurposeMember) Var0 = HSSEPM->Value(j2);
133 SW.Send (Var0);
134 }
135 SW.CloseSub();
136 }
137 SW.CloseSub();
138
139 switch (ent->Shape()) {
140 case StepElement_Quadrilateral: SW.SendEnum (".QUADRILATERAL."); break;
141 case StepElement_Triangle: SW.SendEnum (".TRIANGLE."); break;
142 }
143}
144
145//=======================================================================
146//function : Share
147//purpose :
148//=======================================================================
149
35e08fe8 150void RWStepElement_RWSurface3dElementDescriptor::Share (const Handle(StepElement_Surface3dElementDescriptor)&,
151 Interface_EntityIterator&) const
7fd59977 152{
153
154 // Inherited fields of ElementDescriptor
155
156 // Own fields of Surface3dElementDescriptor
157/* CKY 17JUN04 : content is made of STRINGS or ENUMS , no entity !
158 for (Standard_Integer i1=1; i1 <= ent->Purpose()->Length(); i1++ ) {
159 Handle(StepElement_HSequenceOfSurfaceElementPurposeMember) HSSEPM = ent->Purpose()->Value(i1);
160 for (Standard_Integer i2=1; i2 <= HSSEPM->Length(); i2++ ) {
161 Handle(StepElement_SurfaceElementPurposeMember) Var1 = HSSEPM->Value(i2);
162 iter.AddItem (Var1);
163 }
164 }
165*/
166}