summaryrefslogtreecommitdiff
path: root/src/RWStepElement/RWStepElement_RWSurface3dElementDescriptor.cxx
blob: 83046345fbfcfd2978302e77c1d86e008c7226f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// File:	RWStepElement_RWSurface3dElementDescriptor.cxx
// Created:	Thu Dec 12 17:29:04 2002 
// Author:	data exchange team
// Generator:	ExpToCas (EXPRESS -> CASCADE/XSTEP Translator) V1.2
// Copyright:	Open CASCADE 2002

#include <RWStepElement_RWSurface3dElementDescriptor.ixx>
#include <StepElement_HArray1OfHSequenceOfSurfaceElementPurposeMember.hxx>
#include <StepElement_HSequenceOfSurfaceElementPurposeMember.hxx>
#include <StepElement_SurfaceElementPurposeMember.hxx>

//=======================================================================
//function : RWStepElement_RWSurface3dElementDescriptor
//purpose  : 
//=======================================================================

RWStepElement_RWSurface3dElementDescriptor::RWStepElement_RWSurface3dElementDescriptor ()
{
}

//=======================================================================
//function : ReadStep
//purpose  : 
//=======================================================================

void RWStepElement_RWSurface3dElementDescriptor::ReadStep (const Handle(StepData_StepReaderData)& data,
                                                           const Standard_Integer num,
                                                           Handle(Interface_Check)& ach,
                                                           const Handle(StepElement_Surface3dElementDescriptor) &ent) const
{
  // Check number of parameters
  if ( ! data->CheckNbParams(num,4,ach,"surface3d_element_descriptor") ) return;

  // Inherited fields of ElementDescriptor

  StepElement_ElementOrder aElementDescriptor_TopologyOrder = StepElement_Linear;
  if (data->ParamType (num, 1) == Interface_ParamEnum) {
    Standard_CString text = data->ParamCValue(num, 1);
    if      (!strcmp(text, ".LINEAR.")) aElementDescriptor_TopologyOrder = StepElement_Linear;
    else if (!strcmp(text, ".QUADRATIC.")) aElementDescriptor_TopologyOrder = StepElement_Quadratic;
    else if (!strcmp(text, ".CUBIC.")) aElementDescriptor_TopologyOrder = StepElement_Cubic;
    else ach->AddFail("Parameter #1 (element_descriptor.topology_order) has not allowed value");
  }
  else ach->AddFail("Parameter #1 (element_descriptor.topology_order) is not enumeration");

  Handle(TCollection_HAsciiString) aElementDescriptor_Description;
  data->ReadString (num, 2, "element_descriptor.description", ach, aElementDescriptor_Description);

  // Own fields of Surface3dElementDescriptor

  Handle(StepElement_HArray1OfHSequenceOfSurfaceElementPurposeMember) aPurpose;
  Standard_Integer sub3 = 0;
  if ( data->ReadSubList (num, 3, "purpose", ach, sub3) ) {
    Standard_Integer nb0 = data->NbParams(sub3);
    //Standard_Integer nbj0 = data->NbParams(data->ParamNumber(sub3,1));
    aPurpose = new StepElement_HArray1OfHSequenceOfSurfaceElementPurposeMember (1, nb0);
    for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
      Handle(StepElement_HSequenceOfSurfaceElementPurposeMember) HSSEPM =
        new StepElement_HSequenceOfSurfaceElementPurposeMember;
      Standard_Integer subj3 = 0;
      if ( data->ReadSubList (sub3, i0, "sub-part(purpose)", ach, subj3) ) {
        Standard_Integer num4 = subj3;
        Standard_Integer nbj0 = data->NbParams(data->ParamNumber(sub3,i0));
        for ( Standard_Integer j0=1; j0 <= nbj0; j0++ ) {
          Handle(StepElement_SurfaceElementPurposeMember) aMember = new StepElement_SurfaceElementPurposeMember;
          data->ReadMember (num4, j0, "surface_element_purpose", ach, aMember);
          HSSEPM->Append(aMember);
        }
      }
      aPurpose->SetValue(i0, HSSEPM);
    }
  }

  StepElement_Element2dShape aShape = StepElement_Quadrilateral;
  if (data->ParamType (num, 4) == Interface_ParamEnum) {
    Standard_CString text = data->ParamCValue(num, 4);
    if      (!strcmp(text, ".QUADRILATERAL.")) aShape = StepElement_Quadrilateral;
    else if (!strcmp(text, ".TRIANGLE.")) aShape = StepElement_Triangle;
    else ach->AddFail("Parameter #4 (shape) has not allowed value");
  }
  else ach->AddFail("Parameter #4 (shape) is not enumeration");

  // Initialize entity
  ent->Init(aElementDescriptor_TopologyOrder,
            aElementDescriptor_Description,
            aPurpose,
            aShape);
}

//=======================================================================
//function : WriteStep
//purpose  : 
//=======================================================================

void RWStepElement_RWSurface3dElementDescriptor::WriteStep (StepData_StepWriter& SW,
                                                            const Handle(StepElement_Surface3dElementDescriptor) &ent) const
{

  // Inherited fields of ElementDescriptor

  switch (ent->StepElement_ElementDescriptor::TopologyOrder()) {
    case StepElement_Linear: SW.SendEnum (".LINEAR."); break;
    case StepElement_Quadratic: SW.SendEnum (".QUADRATIC."); break;
    case StepElement_Cubic: SW.SendEnum (".CUBIC."); break;
  }

  SW.Send (ent->StepElement_ElementDescriptor::Description());

  // Own fields of Surface3dElementDescriptor

  SW.OpenSub();
  for (Standard_Integer i2=1; i2 <= ent->Purpose()->Length(); i2++ ) {
    SW.NewLine(Standard_False);
    SW.OpenSub();
    Handle(StepElement_HSequenceOfSurfaceElementPurposeMember) HSSEPM = ent->Purpose()->Value(i2);
    for (Standard_Integer j2=1; j2 <= HSSEPM->Length(); j2++ ) {
      Handle(StepElement_SurfaceElementPurposeMember) Var0 = HSSEPM->Value(j2);
      SW.Send (Var0);
    }
    SW.CloseSub();
  }
  SW.CloseSub();

  switch (ent->Shape()) {
    case StepElement_Quadrilateral: SW.SendEnum (".QUADRILATERAL."); break;
    case StepElement_Triangle: SW.SendEnum (".TRIANGLE."); break;
  }
}

//=======================================================================
//function : Share
//purpose  : 
//=======================================================================

void RWStepElement_RWSurface3dElementDescriptor::Share (const Handle(StepElement_Surface3dElementDescriptor) &ent,
                                                        Interface_EntityIterator& iter) const
{

  // Inherited fields of ElementDescriptor

  // Own fields of Surface3dElementDescriptor
/*  CKY  17JUN04 : content is made of STRINGS or ENUMS , no entity !
  for (Standard_Integer i1=1; i1 <= ent->Purpose()->Length(); i1++ ) {
    Handle(StepElement_HSequenceOfSurfaceElementPurposeMember) HSSEPM = ent->Purpose()->Value(i1);
    for (Standard_Integer i2=1; i2 <= HSSEPM->Length(); i2++ ) {
      Handle(StepElement_SurfaceElementPurposeMember) Var1 = HSSEPM->Value(i2);
      iter.AddItem (Var1);
    }
  }
*/
}