973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
7fd59977 |
13 | |
7fd59977 |
14 | |
42cf5bc1 |
15 | #include <Interface_Check.hxx> |
7fd59977 |
16 | #include <Interface_EntityIterator.hxx> |
42cf5bc1 |
17 | #include <RWStepVisual_RWContextDependentOverRidingStyledItem.hxx> |
18 | #include <StepData_StepReaderData.hxx> |
19 | #include <StepData_StepWriter.hxx> |
20 | #include <StepRepr_RepresentationItem.hxx> |
7fd59977 |
21 | #include <StepVisual_ContextDependentOverRidingStyledItem.hxx> |
42cf5bc1 |
22 | #include <StepVisual_HArray1OfPresentationStyleAssignment.hxx> |
23 | #include <StepVisual_HArray1OfStyleContextSelect.hxx> |
24 | #include <StepVisual_PresentationStyleAssignment.hxx> |
25 | #include <StepVisual_StyleContextSelect.hxx> |
26 | #include <StepVisual_StyledItem.hxx> |
7fd59977 |
27 | |
28 | RWStepVisual_RWContextDependentOverRidingStyledItem::RWStepVisual_RWContextDependentOverRidingStyledItem () {} |
29 | |
30 | void RWStepVisual_RWContextDependentOverRidingStyledItem::ReadStep |
31 | (const Handle(StepData_StepReaderData)& data, |
32 | const Standard_Integer num, |
33 | Handle(Interface_Check)& ach, |
34 | const Handle(StepVisual_ContextDependentOverRidingStyledItem)& ent) const |
35 | { |
36 | |
37 | |
38 | // --- Number of Parameter Control --- |
39 | |
40 | if (!data->CheckNbParams(num,5,ach,"context_dependent_over_riding_styled_item")) return; |
41 | |
42 | // --- inherited field : name --- |
43 | |
44 | Handle(TCollection_HAsciiString) aName; |
45 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
46 | data->ReadString (num,1,"name",ach,aName); |
47 | |
48 | // --- inherited field : styles --- |
49 | |
50 | Handle(StepVisual_HArray1OfPresentationStyleAssignment) aStyles; |
51 | Handle(StepVisual_PresentationStyleAssignment) anent2; |
52 | Standard_Integer nsub2; |
53 | if (data->ReadSubList (num,2,"styles",ach,nsub2)) { |
54 | Standard_Integer nb2 = data->NbParams(nsub2); |
55 | aStyles = new StepVisual_HArray1OfPresentationStyleAssignment (1, nb2); |
56 | for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) { |
57 | //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed |
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 | |
25e59720 |
66 | Handle(Standard_Transient) aItem; |
67 | data->ReadEntity(num, 3,"item", ach, STANDARD_TYPE(Standard_Transient), aItem); |
7fd59977 |
68 | |
69 | // --- inherited field : overRiddenStyle --- |
70 | |
71 | Handle(StepVisual_StyledItem) aOverRiddenStyle; |
72 | //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed |
73 | data->ReadEntity(num, 4,"over_ridden_style", ach, STANDARD_TYPE(StepVisual_StyledItem), aOverRiddenStyle); |
74 | |
75 | // --- own field : styleContext --- |
76 | |
77 | Handle(StepVisual_HArray1OfStyleContextSelect) aStyleContext; |
78 | StepVisual_StyleContextSelect aStyleContextItem; |
79 | Standard_Integer nsub5; |
80 | if (data->ReadSubList (num,5,"style_context",ach,nsub5)) { |
81 | Standard_Integer nb5 = data->NbParams(nsub5); |
82 | aStyleContext = new StepVisual_HArray1OfStyleContextSelect (1, nb5); |
83 | for (Standard_Integer i5 = 1; i5 <= nb5; i5 ++) { |
84 | //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed |
85 | if (data->ReadEntity (nsub5,i5,"style_context",ach,aStyleContextItem)) |
86 | aStyleContext->SetValue(i5,aStyleContextItem); |
87 | } |
88 | } |
89 | |
90 | //--- Initialisation of the read entity --- |
91 | |
92 | |
93 | ent->Init(aName, aStyles, aItem, aOverRiddenStyle, aStyleContext); |
94 | } |
95 | |
96 | |
97 | void RWStepVisual_RWContextDependentOverRidingStyledItem::WriteStep |
98 | (StepData_StepWriter& SW, |
99 | const Handle(StepVisual_ContextDependentOverRidingStyledItem)& ent) const |
100 | { |
101 | |
102 | // --- inherited field name --- |
103 | |
104 | SW.Send(ent->Name()); |
105 | |
106 | // --- inherited field styles --- |
107 | |
108 | SW.OpenSub(); |
109 | for (Standard_Integer i2 = 1; i2 <= ent->NbStyles(); i2 ++) { |
110 | SW.Send(ent->StylesValue(i2)); |
111 | } |
112 | SW.CloseSub(); |
113 | |
114 | // --- inherited field item --- |
115 | |
116 | SW.Send(ent->Item()); |
117 | |
118 | // --- inherited field overRiddenStyle --- |
119 | |
120 | SW.Send(ent->OverRiddenStyle()); |
121 | |
122 | // --- own field : styleContext --- |
123 | |
124 | SW.OpenSub(); |
125 | for (Standard_Integer i5 = 1; i5 <= ent->NbStyleContext(); i5 ++) { |
126 | SW.Send(ent->StyleContextValue(i5).Value()); |
127 | } |
128 | SW.CloseSub(); |
129 | } |
130 | |
131 | |
132 | void RWStepVisual_RWContextDependentOverRidingStyledItem::Share(const Handle(StepVisual_ContextDependentOverRidingStyledItem)& ent, Interface_EntityIterator& iter) const |
133 | { |
134 | |
135 | Standard_Integer nbElem1 = ent->NbStyles(); |
136 | for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) { |
137 | iter.GetOneItem(ent->StylesValue(is1)); |
138 | } |
139 | |
140 | |
141 | |
142 | iter.GetOneItem(ent->Item()); |
143 | |
144 | |
145 | iter.GetOneItem(ent->OverRiddenStyle()); |
146 | |
147 | |
148 | Standard_Integer nbElem4 = ent->NbStyleContext(); |
149 | for (Standard_Integer is4=1; is4<=nbElem4; is4 ++) { |
150 | iter.GetOneItem(ent->StyleContextValue(is4).Value()); |
151 | } |
152 | |
153 | } |
154 | |