]> OCCT Git - occt.git/blob
0d297cd95dee5d50070feea3de16a43f1ccda0ed
[occt.git] /
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #include <Interface_EntityIterator.hxx>
15 #include "RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource.pxx"
16 #include <StepBasic_Product.hxx>
17 #include <StepBasic_ProductDefinitionFormationWithSpecifiedSource.hxx>
18 #include <StepBasic_Source.hxx>
19 #include <StepData_StepReaderData.hxx>
20 #include <StepData_StepWriter.hxx>
21 #include <TCollection_AsciiString.hxx>
22
23 // --- Enum : Source ---
24 static TCollection_AsciiString sBought(".BOUGHT.");
25 static TCollection_AsciiString sNotKnown(".NOT_KNOWN.");
26 static TCollection_AsciiString sMade(".MADE.");
27
28 RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::
29   RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource()
30 {
31 }
32
33 void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::ReadStep(
34   const Handle(StepData_StepReaderData)&                                 data,
35   const Standard_Integer                                                 num,
36   Handle(Interface_Check)&                                               ach,
37   const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent) const
38 {
39
40   // --- Number of Parameter Control ---
41
42   if (!data->CheckNbParams(num, 4, ach, "product_definition_formation_with_specified_source"))
43     return;
44
45   // --- inherited field : id ---
46
47   Handle(TCollection_HAsciiString) aId;
48   // szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
49   data->ReadString(num, 1, "id", ach, aId);
50
51   // --- inherited field : description ---
52
53   Handle(TCollection_HAsciiString) aDescription;
54   // szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
55   data->ReadString(num, 2, "description", ach, aDescription);
56
57   // --- inherited field : ofProduct ---
58
59   Handle(StepBasic_Product) aOfProduct;
60   // szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
61   data->ReadEntity(num, 3, "of_product", ach, STANDARD_TYPE(StepBasic_Product), aOfProduct);
62
63   // --- own field : makeOrBuy ---
64
65   StepBasic_Source aMakeOrBuy = StepBasic_sNotKnown;
66   if (data->ParamType(num, 4) == Interface_ParamEnum)
67   {
68     Standard_CString text = data->ParamCValue(num, 4);
69     if (sBought.IsEqual(text))
70       aMakeOrBuy = StepBasic_sBought;
71     else if (sNotKnown.IsEqual(text))
72       aMakeOrBuy = StepBasic_sNotKnown;
73     else if (sMade.IsEqual(text))
74       aMakeOrBuy = StepBasic_sMade;
75     else
76       ach->AddFail("Enumeration source has not an allowed value");
77   }
78   else
79     ach->AddFail("Parameter #4 (make_or_buy) is not an enumeration");
80
81   //--- Initialisation of the read entity ---
82
83   ent->Init(aId, aDescription, aOfProduct, aMakeOrBuy);
84 }
85
86 void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::WriteStep(
87   StepData_StepWriter&                                                   SW,
88   const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent) const
89 {
90
91   // --- inherited field id ---
92
93   SW.Send(ent->Id());
94
95   // --- inherited field description ---
96
97   SW.Send(ent->Description());
98
99   // --- inherited field ofProduct ---
100
101   SW.Send(ent->OfProduct());
102
103   // --- own field : makeOrBuy ---
104
105   switch (ent->MakeOrBuy())
106   {
107     case StepBasic_sBought:
108       SW.SendEnum(sBought);
109       break;
110     case StepBasic_sNotKnown:
111       SW.SendEnum(sNotKnown);
112       break;
113     case StepBasic_sMade:
114       SW.SendEnum(sMade);
115       break;
116   }
117 }
118
119 void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::Share(
120   const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent,
121   Interface_EntityIterator&                                              iter) const
122 {
123
124   iter.GetOneItem(ent->OfProduct());
125 }