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_RWOverRidingStyledItem.hxx> |
18 | #include <StepData_StepReaderData.hxx> |
19 | #include <StepData_StepWriter.hxx> |
20 | #include <StepRepr_RepresentationItem.hxx> |
21 | #include <StepVisual_HArray1OfPresentationStyleAssignment.hxx> |
7fd59977 |
22 | #include <StepVisual_OverRidingStyledItem.hxx> |
42cf5bc1 |
23 | #include <StepVisual_PresentationStyleAssignment.hxx> |
24 | #include <StepVisual_StyledItem.hxx> |
7fd59977 |
25 | |
26 | RWStepVisual_RWOverRidingStyledItem::RWStepVisual_RWOverRidingStyledItem () {} |
27 | |
28 | void RWStepVisual_RWOverRidingStyledItem::ReadStep |
29 | (const Handle(StepData_StepReaderData)& data, |
30 | const Standard_Integer num, |
31 | Handle(Interface_Check)& ach, |
32 | const Handle(StepVisual_OverRidingStyledItem)& ent) const |
33 | { |
34 | |
35 | |
36 | // --- Number of Parameter Control --- |
37 | |
38 | if (!data->CheckNbParams(num,4,ach,"over_riding_styled_item")) return; |
39 | |
40 | // --- inherited field : name --- |
41 | |
42 | Handle(TCollection_HAsciiString) aName; |
43 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
44 | data->ReadString (num,1,"name",ach,aName); |
45 | |
46 | // --- inherited field : styles --- |
47 | |
48 | Handle(StepVisual_HArray1OfPresentationStyleAssignment) aStyles; |
49 | Handle(StepVisual_PresentationStyleAssignment) anent2; |
50 | Standard_Integer nsub2; |
51 | if (data->ReadSubList (num,2,"styles",ach,nsub2)) { |
52 | Standard_Integer nb2 = data->NbParams(nsub2); |
53 | aStyles = new StepVisual_HArray1OfPresentationStyleAssignment (1, nb2); |
54 | for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) { |
55 | //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed |
56 | if (data->ReadEntity (nsub2, i2,"presentation_style_assignment", ach, |
57 | STANDARD_TYPE(StepVisual_PresentationStyleAssignment), anent2)) |
58 | aStyles->SetValue(i2, anent2); |
59 | } |
60 | } |
61 | |
62 | // --- inherited field : item --- |
63 | |
d658f275 |
64 | Handle(MMgt_TShared) aItem; |
65 | data->ReadEntity(num, 3,"item", ach, STANDARD_TYPE(MMgt_TShared), aItem); |
7fd59977 |
66 | |
67 | // --- own field : overRiddenStyle --- |
68 | |
69 | Handle(StepVisual_StyledItem) aOverRiddenStyle; |
70 | //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed |
71 | data->ReadEntity(num, 4,"over_ridden_style", ach, STANDARD_TYPE(StepVisual_StyledItem), aOverRiddenStyle); |
72 | |
73 | //--- Initialisation of the read entity --- |
74 | |
75 | |
76 | ent->Init(aName, aStyles, aItem, aOverRiddenStyle); |
77 | } |
78 | |
79 | |
80 | void RWStepVisual_RWOverRidingStyledItem::WriteStep |
81 | (StepData_StepWriter& SW, |
82 | const Handle(StepVisual_OverRidingStyledItem)& ent) const |
83 | { |
84 | |
85 | // --- inherited field name --- |
86 | |
87 | SW.Send(ent->Name()); |
88 | |
89 | // --- inherited field styles --- |
90 | |
91 | SW.OpenSub(); |
92 | for (Standard_Integer i2 = 1; i2 <= ent->NbStyles(); i2 ++) { |
93 | SW.Send(ent->StylesValue(i2)); |
94 | } |
95 | SW.CloseSub(); |
96 | |
97 | // --- inherited field item --- |
98 | |
99 | SW.Send(ent->Item()); |
100 | |
101 | // --- own field : overRiddenStyle --- |
102 | |
103 | SW.Send(ent->OverRiddenStyle()); |
104 | } |
105 | |
106 | |
107 | void RWStepVisual_RWOverRidingStyledItem::Share(const Handle(StepVisual_OverRidingStyledItem)& ent, Interface_EntityIterator& iter) const |
108 | { |
109 | |
110 | Standard_Integer nbElem1 = ent->NbStyles(); |
111 | for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) { |
112 | iter.GetOneItem(ent->StylesValue(is1)); |
113 | } |
114 | |
115 | |
116 | |
117 | iter.GetOneItem(ent->Item()); |
118 | |
119 | |
120 | iter.GetOneItem(ent->OverRiddenStyle()); |
121 | } |
122 | |