0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / RWStepVisual / RWStepVisual_RWAnnotationOccurrence.cxx
1 // Created on: 2015-10-29
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
17 #include <Interface_Check.hxx>
18 #include <Interface_EntityIterator.hxx>
19 #include <RWStepVisual_RWAnnotationOccurrence.hxx>
20 #include <StepData_StepReaderData.hxx>
21 #include <StepData_StepWriter.hxx>
22 #include <StepRepr_RepresentationItem.hxx>
23 #include <StepVisual_HArray1OfPresentationStyleAssignment.hxx>
24 #include <StepVisual_PresentationStyleAssignment.hxx>
25 #include <StepVisual_AnnotationOccurrence.hxx>
26
27 //=======================================================================
28 //function : RWStepVisual_RWAnnotationOccurrence
29 //purpose  : 
30 //=======================================================================
31 RWStepVisual_RWAnnotationOccurrence::RWStepVisual_RWAnnotationOccurrence () {}
32
33 //=======================================================================
34 //function : ReadStep
35 //purpose  : 
36 //=======================================================================
37 void RWStepVisual_RWAnnotationOccurrence::ReadStep
38   (const Handle(StepData_StepReaderData)& data,
39    const Standard_Integer num,
40    Handle(Interface_Check)& ach,
41    const Handle(StepVisual_AnnotationOccurrence)& ent) const
42 {
43   // Number of Parameter Control
44   if (!data->CheckNbParams(num, 3, ach, "annotation_occurrence")) return;
45
46   // Inherited field : name
47   Handle(TCollection_HAsciiString) aName;
48   data->ReadString (num, 1, "name", ach, aName);
49   
50   // Inherited field : styles
51   Handle(StepVisual_HArray1OfPresentationStyleAssignment) aStyles;
52   Handle(StepVisual_PresentationStyleAssignment) anent2;
53   Standard_Integer nsub2;
54   if (data->ReadSubList (num,2,"styles",ach,nsub2)) {
55     Standard_Integer nb2 = data->NbParams(nsub2);
56     aStyles = new StepVisual_HArray1OfPresentationStyleAssignment (1, nb2);
57     for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) {
58       if (data->ReadEntity (nsub2, i2,"presentation_style_assignment", ach,
59           STANDARD_TYPE(StepVisual_PresentationStyleAssignment), anent2))
60         aStyles->SetValue(i2, anent2);
61     }
62   }
63
64   // Inherited field : item
65   Handle(Standard_Transient) aItem;
66   data->ReadEntity(num, 3,"item", ach, STANDARD_TYPE(Standard_Transient), aItem);
67
68   // Initialisation of the read entity
69   ent->Init(aName, aStyles, aItem);
70 }
71
72 //=======================================================================
73 //function : WriteStep
74 //purpose  : 
75 //=======================================================================
76 void RWStepVisual_RWAnnotationOccurrence::WriteStep
77   (StepData_StepWriter& SW,
78    const Handle(StepVisual_AnnotationOccurrence)& ent) const
79 {
80   // Inherited field : name
81   SW.Send(ent->Name());
82
83   // Inherited field : styles
84
85   SW.OpenSub();
86   for (Standard_Integer i2 = 1;  i2 <= ent->NbStyles();  i2 ++) {
87     SW.Send(ent->StylesValue(i2));
88   }
89   SW.CloseSub();
90
91   // Inherited field : item
92
93   SW.Send(ent->Item());
94 }
95
96 //=======================================================================
97 //function : Share
98 //purpose  : 
99 //=======================================================================
100 void RWStepVisual_RWAnnotationOccurrence::Share(const Handle(StepVisual_AnnotationOccurrence)& ent, Interface_EntityIterator& iter) const
101 {
102   Standard_Integer nbElem1 = ent->NbStyles();
103   for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) {
104     iter.GetOneItem(ent->StylesValue(is1));
105   }
106   iter.GetOneItem(ent->Item());
107 }