summaryrefslogtreecommitdiff
path: root/src/RWStepGeom/RWStepGeom_RWTrimmedCurve.cxx
blob: 2dc6d47a331e7529585d9cd6c8b967347130b83f (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176

#include <RWStepGeom_RWTrimmedCurve.ixx>
#include <StepGeom_Curve.hxx>
#include <StepGeom_HArray1OfTrimmingSelect.hxx>
#include <StepGeom_TrimmingSelect.hxx>
#include <StepGeom_TrimmingPreference.hxx>

#include <StepGeom_CartesianPoint.hxx>

#include <Interface_EntityIterator.hxx>


#include <StepGeom_TrimmedCurve.hxx>

#include <TCollection_AsciiString.hxx>


	// --- Enum : TrimmingPreference ---
static TCollection_AsciiString tpParameter(".PARAMETER.");
static TCollection_AsciiString tpUnspecified(".UNSPECIFIED.");
static TCollection_AsciiString tpCartesian(".CARTESIAN.");

RWStepGeom_RWTrimmedCurve::RWStepGeom_RWTrimmedCurve () {}

void RWStepGeom_RWTrimmedCurve::ReadStep
(const Handle(StepData_StepReaderData)& data,
 const Standard_Integer num,
 Handle(Interface_Check)& ach,
 const Handle(StepGeom_TrimmedCurve)& ent) const
{
  
  
  // --- Number of Parameter Control ---
  
  if (!data->CheckNbParams(num,6,ach,"trimmed_curve")) return;
  
  // --- inherited field : name ---
  
  Handle(TCollection_HAsciiString) aName;
  //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
  data->ReadString (num,1,"name",ach,aName);
  
  // --- own field : basisCurve ---
  
  Handle(StepGeom_Curve) aBasisCurve;
  //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
  data->ReadEntity(num, 2,"basis_curve", ach, STANDARD_TYPE(StepGeom_Curve), aBasisCurve);
  
  // --- own field : trim1 ---
  
  Handle(StepGeom_CartesianPoint) aCartesianPoint;
  //Standard_Real aParameterValue; //szv#4:S4163:12Mar99 unused
  
  Handle(StepGeom_HArray1OfTrimmingSelect) aTrim1;
  Standard_Integer nsub3;
  if (data->ReadSubList (num,3,"trim_1",ach,nsub3)) {
    Standard_Integer nb3 = data->NbParams(nsub3);
    aTrim1 = new StepGeom_HArray1OfTrimmingSelect (1, nb3);
    for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
      StepGeom_TrimmingSelect aTrim1Item;
      //szv#4:S4163:12Mar99 `Standard_Boolean stat3a =` not needed
      if (data->ReadEntity (nsub3,i3,"trim_1",ach,aTrim1Item))
	aTrim1->SetValue(i3,aTrim1Item);
    }
  }
  
  // --- own field : trim2 ---
  
  Handle(StepGeom_HArray1OfTrimmingSelect) aTrim2;
  Standard_Integer nsub4;
  if (data->ReadSubList (num,4,"trim_2",ach,nsub4)) {
    Standard_Integer nb4 = data->NbParams(nsub4);
    aTrim2 = new StepGeom_HArray1OfTrimmingSelect (1, nb4);
    for (Standard_Integer i4 = 1; i4 <= nb4; i4 ++) {
      
      StepGeom_TrimmingSelect aTrim2Item;
      //szv#4:S4163:12Mar99 `Standard_Boolean stat4a =` not needed
      if (data->ReadEntity (nsub4,i4,"trim_2",ach,aTrim2Item))
	aTrim2->SetValue(i4,aTrim2Item);
    }
  }
  
  // --- own field : senseAgreement ---
  
  Standard_Boolean aSenseAgreement;
  //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed
  data->ReadBoolean (num,5,"sense_agreement",ach,aSenseAgreement);
  
  // --- own field : masterRepresentation ---
  
  StepGeom_TrimmingPreference aMasterRepresentation = StepGeom_tpCartesian;
  if (data->ParamType(num,6) == Interface_ParamEnum) {
    Standard_CString text = data->ParamCValue(num,6);
    if      (tpParameter.IsEqual(text)) aMasterRepresentation = StepGeom_tpParameter;
    else if (tpUnspecified.IsEqual(text)) aMasterRepresentation = StepGeom_tpUnspecified;
    else if (tpCartesian.IsEqual(text)) aMasterRepresentation = StepGeom_tpCartesian;
    else ach->AddFail("Enumeration trimming_preference has not an allowed value");
  }
  else ach->AddFail("Parameter #6 (master_representation) is not an enumeration");
  
  //--- Initialisation of the read entity ---
  
  
  ent->Init(aName, aBasisCurve, aTrim1, aTrim2, aSenseAgreement, aMasterRepresentation);
}


void RWStepGeom_RWTrimmedCurve::WriteStep
(StepData_StepWriter& SW,
 const Handle(StepGeom_TrimmedCurve)& ent) const
{
  
  // --- inherited field name ---
  
  SW.Send(ent->Name());
  
  // --- own field : basisCurve ---
  
  SW.Send(ent->BasisCurve());
  
  // --- own field : trim1 ---
  
  SW.OpenSub();
  for (Standard_Integer i2 = 1;  i2 <= ent->NbTrim1();  i2 ++) {
    SW.Send(ent->Trim1Value(i2).Value());
  }
  SW.CloseSub();
  
  // --- own field : trim2 ---
  
  SW.OpenSub();
  for (Standard_Integer i3 = 1;  i3 <= ent->NbTrim2();  i3 ++) {
    SW.Send(ent->Trim2Value(i3).Value());
  }
  SW.CloseSub();
  
  // --- own field : senseAgreement ---
  
  SW.SendBoolean(ent->SenseAgreement());
  
  // --- own field : masterRepresentation ---
  
  switch(ent->MasterRepresentation()) {
  case StepGeom_tpParameter : 
    SW.SendEnum (tpParameter); 
    break;
  case StepGeom_tpUnspecified : 
    SW.SendEnum (tpUnspecified); 
    break;
  case StepGeom_tpCartesian : 
    SW.SendEnum (tpCartesian); 
    break;
  }
}


void RWStepGeom_RWTrimmedCurve::Share(const Handle(StepGeom_TrimmedCurve)& ent, Interface_EntityIterator& iter) const
{

  iter.GetOneItem(ent->BasisCurve());
  
  Standard_Integer nbElem2 = ent->NbTrim1();
  for (Standard_Integer is2=1; is2<=nbElem2; is2 ++) {
    if (ent->Trim1Value(is2).CaseNumber() > 0) {
      iter.GetOneItem(ent->Trim1Value(is2).Value());
    }
  }
  
  Standard_Integer nbElem3 = ent->NbTrim2();
  for (Standard_Integer is3=1; is3<=nbElem3; is3 ++) {
    if (ent->Trim2Value(is3).CaseNumber() > 0) {
      iter.GetOneItem(ent->Trim2Value(is3).Value());
    }
  }
}