summaryrefslogtreecommitdiff
path: root/src/RWStepBasic/RWStepBasic_RWUncertaintyMeasureWithUnit.cxx
blob: 5a7dfeb0d17cd185ab40c7c0f0935bddca8dd359 (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
//gka 05.03.99 S4134 upgrade from CD to DIS
#include <RWStepBasic_RWUncertaintyMeasureWithUnit.ixx>
#include <StepBasic_NamedUnit.hxx>
#include <StepBasic_MeasureValueMember.hxx>

#include <TCollection_AsciiString.hxx>
#include <string.h>

#include <Interface_EntityIterator.hxx>
#include <Interface_FloatWriter.hxx>
#include <Interface_MSG.hxx>

#include <StepBasic_UncertaintyMeasureWithUnit.hxx>

//=======================================================================
//function : RWStepBasic_RWUncertaintyMeasureWithUnit
//purpose  : 
//=======================================================================

RWStepBasic_RWUncertaintyMeasureWithUnit::RWStepBasic_RWUncertaintyMeasureWithUnit () {}

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

void RWStepBasic_RWUncertaintyMeasureWithUnit::ReadStep (const Handle(StepData_StepReaderData)& data,
							 const Standard_Integer num,
							 Handle(Interface_Check)& ach,
							 const Handle(StepBasic_UncertaintyMeasureWithUnit)& ent) const
{
  if (data->IsComplex (num)) {

    ach->AddWarning ("Complex Type not allowed, only suitable values are read");

//   CATIA ecrit des trucs complexes, comme suit :
//  LENGTH_MEASURE_WITH_UNIT ()
//  MEASURE_WITH_UNIT (LENGTH_MEASURE(val),#..)
//  UNCERTAINTY_MEASURE_WITH_UNIT ('str1','str2')
//   -> c est illicite, LENGTH_MEASURE est un invite importun
//  On relit en ignorant ce terme
//    REMARQUE : le ReadWriteModule a deja fait le filtrage des types

//    LENGTH_MEASURE_WITH_UNIT : on passe
    Standard_Integer num1 = num;

//  MEASURE_WITH_UNIT
    num1 = data->NextForComplex (num1);

    if (!data->CheckNbParams(num1,2,ach,"measure_with_unit")) return;

    // --- inherited field : valueComponent ---
    Handle(StepBasic_MeasureValueMember) mvc = new StepBasic_MeasureValueMember;
    data->ReadMember (num1,1, "value_component", ach, mvc);

    // --- inherited field : unitComponent ---
    StepBasic_Unit aUnitComponent;
    data->ReadEntity(num1, 2,"unit_component", ach, aUnitComponent);

//  UNCERTAINTY_MEASURE_WITH_UNIT (ce qu il en reste !)
    num1 = data->NextForComplex (num1);
  
    if (!data->CheckNbParams(num1,2,ach,"uncertainty_measure_with_unit")) return;
  
    // --- own field : name ---
    Handle(TCollection_HAsciiString) aName;
    data->ReadString (num1,1,"name",ach,aName);
  
    // --- own field : description ---
    Handle(TCollection_HAsciiString) aDescription;
    if (data->IsParamDefined (num1,2)) { //gka 05.03.99 S4134 upgrade from CD to DIS
      data->ReadString (num1,2,"description",ach,aDescription);
    }
//  Ca yest, on peut faire l init

    ent->Init(mvc, aUnitComponent, aName, aDescription);
    return;
  }
  
  // --- Number of Parameter Control ---
  
  if (!data->CheckNbParams(num,4,ach,"uncertainty_measure_with_unit")) return;
  
  // --- inherited field : valueComponent ---
  //Standard_Real aValueComponent;
  //Standard_Boolean stat1;
  //stat1 = data->ReadReal (num,1,"value_component",ach,aValueComponent);
  // --- Update 12-02-96 by FMA  =>  31-MAR-1997 by CKY
  Handle(StepBasic_MeasureValueMember) mvc = new StepBasic_MeasureValueMember;
  data->ReadMember (num,1, "value_component", ach, mvc);

  // --- inherited field : unitComponent ---
  StepBasic_Unit aUnitComponent;
  data->ReadEntity(num, 2,"unit_component", ach, aUnitComponent);
  
  // --- own field : name ---
  Handle(TCollection_HAsciiString) aName;
  data->ReadString (num,3,"name",ach,aName);
  
  // --- own field : description ---
  Handle(TCollection_HAsciiString) aDescription;
  data->ReadString (num,4,"description",ach,aDescription);
  
  //--- Initialisation of the read entity ---
  ent->Init(mvc, aUnitComponent, aName, aDescription);
}


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

void RWStepBasic_RWUncertaintyMeasureWithUnit::WriteStep (StepData_StepWriter& SW,
							  const Handle(StepBasic_UncertaintyMeasureWithUnit)& ent) const
{
  
  // --- inherited field valueComponent ---
  
  // Update 12-02-96 by FMA
  // The Value shall be Typed - LENGTH_MEASURE, PLANE_ANGLE_MEASURE,
  //                            SOLID_ANGLE_MEASURE
  // The actual state is LENGTH_MEASURE ONLY
  // UPDATE to be done later but mandatory

//  char lm[100],lmv[50];
//  Interface_FloatWriter::Convert
//    (Interface_MSG::Intervalled(ent->ValueComponent()*0.98,5,Standard_True),
//     lmv,Standard_True, 10.,0.1,"%E","%E");
//  sprintf (lm,"LENGTH_MEASURE(%s)",lmv);
//  SW.SendString(lm);

//  SW.AddString("LENGTH_MEASURE");
//  SW.OpenSub();

//   UPDATE 31-MARS-1997 by CKY : ca devrait etre bon desormais
  SW.Send(ent->ValueComponentMember());
//  SW.CloseSub();
  
  // --- inherited field unitComponent ---
  SW.Send(ent->UnitComponent().Value());
  
  // --- own field : name ---
  SW.Send(ent->Name());
  
  // --- own field : description ---
  SW.Send(ent->Description());
}

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

void RWStepBasic_RWUncertaintyMeasureWithUnit::Share (const Handle(StepBasic_UncertaintyMeasureWithUnit)& ent, 
						      Interface_EntityIterator& iter) const
{
  
  iter.GetOneItem(ent->UnitComponent().Value());
}