5df609e7 |
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_RWAnnotationPlane.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_AnnotationPlane.hxx> |
26 | |
27 | //======================================================================= |
28 | //function : RWStepVisual_RWAnnotationPlane |
29 | //purpose : |
30 | //======================================================================= |
31 | RWStepVisual_RWAnnotationPlane::RWStepVisual_RWAnnotationPlane () {} |
32 | |
33 | //======================================================================= |
34 | //function : ReadStep |
35 | //purpose : |
36 | //======================================================================= |
37 | void RWStepVisual_RWAnnotationPlane::ReadStep |
38 | (const Handle(StepData_StepReaderData)& data, |
39 | const Standard_Integer num, |
40 | Handle(Interface_Check)& ach, |
41 | const Handle(StepVisual_AnnotationPlane)& ent) const |
42 | { |
43 | // Number of Parameter Control |
44 | if (!data->CheckNbParams(num, 4, ach, "annotation_plane")) 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 |
d658f275 |
65 | Handle(MMgt_TShared) aItem; |
66 | data->ReadEntity(num, 3,"item", ach, STANDARD_TYPE(MMgt_TShared), aItem); |
5df609e7 |
67 | |
68 | // Own field: elements |
69 | Handle(StepVisual_HArray1OfAnnotationPlaneElement) anElements; |
70 | StepVisual_AnnotationPlaneElement anEnt; |
71 | Standard_Integer nbSub; |
72 | if (data->ReadSubList (num, 4, "elements", ach, nbSub)) { |
73 | Standard_Integer nbElements = data->NbParams(nbSub); |
74 | anElements = new StepVisual_HArray1OfAnnotationPlaneElement (1, nbElements); |
75 | for (Standard_Integer i = 1; i <= nbElements; i++) { |
76 | if (data->ReadEntity(nbSub, i,"content", ach, anEnt)) |
77 | anElements->SetValue(i, anEnt); |
78 | } |
79 | } |
80 | |
81 | // Initialisation of the read entity |
82 | ent->Init(aName, aStyles, aItem, anElements); |
83 | } |
84 | |
85 | //======================================================================= |
86 | //function : WriteStep |
87 | //purpose : |
88 | //======================================================================= |
89 | void RWStepVisual_RWAnnotationPlane::WriteStep |
90 | (StepData_StepWriter& SW, |
91 | const Handle(StepVisual_AnnotationPlane)& ent) const |
92 | { |
93 | // Inherited field : name |
94 | |
95 | SW.Send(ent->Name()); |
96 | |
97 | // Inherited field : styles |
98 | |
99 | SW.OpenSub(); |
100 | for (Standard_Integer i2 = 1; i2 <= ent->NbStyles(); i2 ++) { |
101 | SW.Send(ent->StylesValue(i2)); |
102 | } |
103 | SW.CloseSub(); |
104 | |
105 | // Inherited field : item |
106 | SW.Send(ent->Item()); |
107 | |
108 | // Own field: elements |
109 | SW.OpenSub(); |
110 | for (Standard_Integer i = 1; i <= ent->NbElements(); i++) { |
111 | SW.Send(ent->ElementsValue(i).Value()); |
112 | } |
113 | SW.CloseSub(); |
114 | } |
115 | |
116 | //======================================================================= |
117 | //function : Share |
118 | //purpose : |
119 | //======================================================================= |
120 | void RWStepVisual_RWAnnotationPlane::Share(const Handle(StepVisual_AnnotationPlane)& ent, Interface_EntityIterator& iter) const |
121 | { |
122 | Standard_Integer nbElem1 = ent->NbStyles(); |
123 | for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) { |
124 | iter.GetOneItem(ent->StylesValue(is1)); |
125 | } |
126 | iter.GetOneItem(ent->Item()); |
127 | |
128 | // Own field: contents |
129 | Standard_Integer i, nb = ent->NbElements(); |
130 | for (i = 1; i <= nb; i++) |
131 | iter.AddItem (ent->ElementsValue(i).Value()); |
132 | } |
133 | |