0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / RWStepShape / RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation.cxx
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
15 #include <Interface_Check.hxx>
16 #include <Interface_EntityIterator.hxx>
17 #include <RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepRepr_HArray1OfRepresentationItem.hxx>
21 #include <StepRepr_RepresentationContext.hxx>
22 #include <StepRepr_RepresentationItem.hxx>
23 #include <StepShape_DefinitionalRepresentationAndShapeRepresentation.hxx>
24
25 RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation::RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation () {}
26
27 void RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation::ReadStep
28         (const Handle(StepData_StepReaderData)& data,
29          const Standard_Integer num0,
30          Handle(Interface_Check)& ach,
31          const Handle(StepShape_DefinitionalRepresentationAndShapeRepresentation)& ent) const
32 {
33
34         Standard_Integer num = num0;
35
36         // skip definitional_representation
37         
38         num = data->NextForComplex(num);
39
40
41         // --- Instance of plex componant definitional_representation ---
42
43         if (!data->CheckNbParams(num,3,ach,"representation")) return;
44
45         // --- inherited field : name ---
46
47         Handle(TCollection_HAsciiString) aName;
48         data->ReadString (num,1,"name",ach,aName);
49
50         // --- inherited field : items ---
51
52         Handle(StepRepr_HArray1OfRepresentationItem) aItems;
53         Handle(StepRepr_RepresentationItem) anent2;
54         Standard_Integer nsub2;
55         if (data->ReadSubList (num,2,"items",ach,nsub2)) {
56           Standard_Integer nb2 = data->NbParams(nsub2);
57           aItems = new StepRepr_HArray1OfRepresentationItem (1, nb2);
58           for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) {
59             if (data->ReadEntity (nsub2, i2,"representation_item", ach, STANDARD_TYPE(StepRepr_RepresentationItem), anent2))
60               aItems->SetValue(i2, anent2);
61           }
62         }
63
64         // --- inherited field : contextOfItems ---
65
66         Handle(StepRepr_RepresentationContext) aContextOfItems;
67         data->ReadEntity(num, 3,"context_of_items", ach, STANDARD_TYPE(StepRepr_RepresentationContext), aContextOfItems);
68
69         // skip shape_representation
70         num = data->NextForComplex(num);
71
72         //--- Initialisation of the read entity ---
73         ent->Init(aName, aItems, aContextOfItems);
74
75 }
76
77
78 void RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation::WriteStep
79         (StepData_StepWriter& SW,
80          const Handle(StepShape_DefinitionalRepresentationAndShapeRepresentation)& ent) const
81 {
82
83         // --- Instance of plex componant ConversionBasedUnit ---
84
85         SW.StartEntity("DEFINITIONAL_REPRESENTATION");
86
87         SW.StartEntity("REPRESENTATION");
88
89         // --- inherited field name ---
90
91         SW.Send(ent->Name());
92
93         // --- inherited field items ---
94
95         SW.OpenSub();
96         for (Standard_Integer i2 = 1;  i2 <= ent->NbItems();  i2 ++) {
97           SW.Send(ent->ItemsValue(i2));
98         }
99         SW.CloseSub();
100
101         // --- inherited field contextOfItems ---
102
103         SW.Send(ent->ContextOfItems());
104
105         // --- Instance of plex componant LengthUnit ---
106
107         SW.StartEntity("SHAPE_REPRESENTATION");
108
109 }
110
111
112 void RWStepShape_RWDefinitionalRepresentationAndShapeRepresentation::Share(const Handle(StepShape_DefinitionalRepresentationAndShapeRepresentation)& ent, 
113                                                                            Interface_EntityIterator& iter) const
114 {
115
116         Standard_Integer nbElem1 = ent->NbItems();
117         for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) {
118           iter.GetOneItem(ent->ItemsValue(is1));
119         }
120
121
122
123         iter.GetOneItem(ent->ContextOfItems());
124 }
125