0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / RWStepRepr / RWStepRepr_RWCompoundRepresentationItem.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 <RWStepRepr_RWCompoundRepresentationItem.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepRepr_CompoundRepresentationItem.hxx>
21 #include <StepRepr_HArray1OfRepresentationItem.hxx>
22 #include <StepRepr_RepresentationItem.hxx>
23 #include <TCollection_HAsciiString.hxx>
24
25 RWStepRepr_RWCompoundRepresentationItem::RWStepRepr_RWCompoundRepresentationItem  ()    {  }
26
27 void  RWStepRepr_RWCompoundRepresentationItem::ReadStep
28   (const Handle(StepData_StepReaderData)& data,
29    const Standard_Integer num,
30    Handle(Interface_Check)& ach,
31    const Handle(StepRepr_CompoundRepresentationItem)& ent) const
32 {
33   // --- Number of Parameter Control ---
34   if (!data->CheckNbParams(num,2,ach,"compound_representation_item")) return;
35
36   // --- inherited field : name ---
37
38   Handle(TCollection_HAsciiString) aName;
39   //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
40   data->ReadString (num,1,"name",ach,aName);
41
42   // --- own field : item_element
43
44   Handle(StepRepr_HArray1OfRepresentationItem) aItems;
45   Handle(StepRepr_RepresentationItem) anent2;
46   Standard_Integer nsub2;
47   if (data->ReadSubList (num,2,"item_element",ach,nsub2)) {
48     Standard_Integer nb2 = data->NbParams(nsub2);
49     aItems = new StepRepr_HArray1OfRepresentationItem (1, nb2);
50     for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) {
51       if (data->ReadEntity(nsub2, i2,"representation_item", ach,
52                            STANDARD_TYPE(StepRepr_RepresentationItem), anent2))
53         aItems->SetValue(i2, anent2);
54     }
55   }
56
57   ent->Init (aName,aItems);
58 }
59
60 void  RWStepRepr_RWCompoundRepresentationItem::WriteStep
61   (StepData_StepWriter& SW,
62    const Handle(StepRepr_CompoundRepresentationItem)& ent) const
63 {
64   // --- inherited field : name ---
65
66   SW.Send(ent->Name());
67
68   // --- own field : items ---
69
70   SW.OpenSub();
71   for (Standard_Integer i2 = 1;  i2 <= ent->NbItemElement();  i2 ++) {
72     SW.Send(ent->ItemElementValue(i2));
73   }
74   SW.CloseSub();
75 }
76
77 void  RWStepRepr_RWCompoundRepresentationItem::Share
78   (const Handle(StepRepr_CompoundRepresentationItem)& ent,
79    Interface_EntityIterator& iter) const
80 {
81   Standard_Integer i, nb = ent->NbItemElement();
82   for (i = 1; i <= nb; i ++)  iter.AddItem (ent->ItemElementValue(i));
83 }