0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / RWStepAP242 / RWStepAP242_RWGeometricItemSpecificUsage.cxx
1 // Created on: 2015-07-07
2 // Created by: Irina KRYLOVA
3 // Copyright (c) 2015 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <RWStepAP242_RWGeometricItemSpecificUsage.hxx>
17 #include <Interface_EntityIterator.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepAP242_GeometricItemSpecificUsage.hxx>
21 #include <StepRepr_HArray1OfRepresentationItem.hxx>
22 #include <StepRepr_Representation.hxx>
23 #include <StepRepr_RepresentationItem.hxx>
24
25
26 RWStepAP242_RWGeometricItemSpecificUsage::RWStepAP242_RWGeometricItemSpecificUsage () {}
27
28 void RWStepAP242_RWGeometricItemSpecificUsage::ReadStep
29   (const Handle(StepData_StepReaderData)& data,
30    const Standard_Integer num,
31    Handle(Interface_Check)& ach,
32    const Handle(StepAP242_GeometricItemSpecificUsage)& ent) const
33 {
34
35
36   // --- Number of Parameter Control ---
37
38   if (!data->CheckNbParams(num,5,ach,"geometric_item_specific_usage")) return;
39
40   // Inherited fields of ItemIdentifiedRepresentationUsage
41
42   Handle(TCollection_HAsciiString) aName;
43   data->ReadString (num,1,"item_identified_representation_usage.name",ach,aName);
44
45   Handle(TCollection_HAsciiString) aDescription;
46   if (data->IsParamDefined (num,2)) {
47     data->ReadString (num,2,"item_identified_representation_usage.description",ach,aDescription);
48   }
49
50   StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition;
51   data->ReadEntity(num,3,"item_identified_representation_usage.definition",ach,aDefinition);
52
53   Handle(StepRepr_Representation) aRepresentation;
54   data->ReadEntity (num,4,"item_identified_representation_usage.used_representation",ach,STANDARD_TYPE(StepRepr_Representation), aRepresentation);
55
56   Handle(StepRepr_HArray1OfRepresentationItem) anItems;
57   Handle(StepRepr_RepresentationItem) anEnt;
58   Standard_Integer nbSub;
59   Interface_ParamType aType = data->ParamType(num, 5);
60   if (aType == Interface_ParamIdent) {
61     data->ReadEntity(num, 5,"item_identified_representation_usage.identified_item", ach, STANDARD_TYPE(StepRepr_RepresentationItem), anEnt);
62     anItems = new StepRepr_HArray1OfRepresentationItem (1, 1);
63     anItems->SetValue(1, anEnt);
64   }
65   else if (data->ReadSubList (num,5,"item_identified_representation_usage.identified_item",ach,nbSub)) {
66     Standard_Integer nbElements = data->NbParams(nbSub);
67     anItems = new StepRepr_HArray1OfRepresentationItem (1, nbElements);
68     for (Standard_Integer i = 1; i <= nbElements; i++) {
69       if (data->ReadEntity(nbSub, i,"representation_item", ach,
70          STANDARD_TYPE(StepRepr_RepresentationItem), anEnt))
71         anItems->SetValue(i, anEnt);
72     }
73   }
74
75   //--- Initialisation of the read entity ---
76
77   ent->Init(aName, aDescription, aDefinition, aRepresentation, anItems);
78 }
79
80 void RWStepAP242_RWGeometricItemSpecificUsage::WriteStep
81   (StepData_StepWriter& SW,
82    const Handle(StepAP242_GeometricItemSpecificUsage)& ent) const
83 {
84   // Inherited fields of ItemIdentifiedRepresentationUsage
85
86   SW.Send(ent->Name());
87
88   SW.Send(ent->Description());
89
90   SW.Send(ent->Definition().Value());
91
92   SW.Send(ent->UsedRepresentation());
93
94   if (ent->NbIdentifiedItem() == 1)
95     SW.Send(ent->IdentifiedItemValue(1));
96   else {
97     SW.OpenSub();
98     for (Standard_Integer i = 1;  i <= ent->NbIdentifiedItem();  i++) {
99       SW.Send(ent->IdentifiedItemValue(i));
100     }
101     SW.CloseSub();
102   }
103 }
104
105 void RWStepAP242_RWGeometricItemSpecificUsage::Share(
106   const Handle(StepAP242_GeometricItemSpecificUsage)& ent, 
107   Interface_EntityIterator& iter) const
108 {
109   // Inherited fields of ItemIdentifiedRepresentationUsage
110
111   iter.AddItem(ent->Definition().Value());
112   Standard_Integer i, nb = ent->NbIdentifiedItem();
113   for (i = 1; i <= nb; i++)  
114     iter.AddItem (ent->IdentifiedItemValue(i));
115 }
116