fe0d928d |
1 | // Created on: 2016-08-25 |
2 | // Created by: Irina KRYLOVA |
3 | // Copyright (c) 2016 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 <RWStepRepr_RWCharacterizedRepresentation.hxx> |
20 | #include <StepData_StepReaderData.hxx> |
21 | #include <StepData_StepWriter.hxx> |
22 | #include <StepRepr_HArray1OfRepresentationItem.hxx> |
23 | #include <StepRepr_CharacterizedRepresentation.hxx> |
24 | #include <StepRepr_RepresentationContext.hxx> |
25 | #include <StepRepr_RepresentationItem.hxx> |
26 | |
27 | //======================================================================= |
28 | //function : RWStepRepr_RWCharacterizedRepresentation |
29 | //purpose : |
30 | //======================================================================= |
31 | RWStepRepr_RWCharacterizedRepresentation::RWStepRepr_RWCharacterizedRepresentation () {} |
32 | |
33 | //======================================================================= |
34 | //function : ReadStep |
35 | //purpose : |
36 | //======================================================================= |
37 | void RWStepRepr_RWCharacterizedRepresentation::ReadStep |
38 | (const Handle(StepData_StepReaderData)& data, |
39 | const Standard_Integer num, |
40 | Handle(Interface_Check)& ach, |
41 | const Handle(StepRepr_CharacterizedRepresentation)& ent) const |
42 | { |
43 | // Number of Parameter Control |
44 | if (!data->CheckNbParams(num, 4, ach, "characterized_representation")) return; |
45 | |
46 | // name |
47 | Handle(TCollection_HAsciiString) aName; |
48 | data->ReadString (num, 1, "name", ach, aName); |
49 | |
50 | // description |
51 | Handle(TCollection_HAsciiString) aDescription; |
52 | data->ReadString (num, 2, "description", ach, aDescription); |
53 | |
54 | // items |
55 | Handle(StepRepr_HArray1OfRepresentationItem) anItems; |
56 | Handle(StepRepr_RepresentationItem) anItem; |
57 | Standard_Integer nsub; |
58 | if (data->ReadSubList (num, 3, "items", ach, nsub)) { |
59 | Standard_Integer nb = data->NbParams(nsub); |
60 | anItems = new StepRepr_HArray1OfRepresentationItem (1, nb); |
61 | for (Standard_Integer i = 1; i <= nb; i ++) { |
62 | if (data->ReadEntity (nsub, i,"representation_item", ach, |
63 | STANDARD_TYPE(StepRepr_RepresentationItem), anItem)) |
64 | anItems->SetValue(i, anItem); |
65 | } |
66 | } |
67 | |
68 | // context_of_items |
69 | Handle(StepRepr_RepresentationContext) aContextOfItems; |
70 | data->ReadEntity(num, 4, "context_of_items", ach, STANDARD_TYPE(StepRepr_RepresentationContext), aContextOfItems); |
71 | |
72 | // Initialization of the read entity |
73 | ent->Init(aName, aDescription, anItems, aContextOfItems); |
74 | } |
75 | |
76 | //======================================================================= |
77 | //function : WriteStep |
78 | //purpose : |
79 | //======================================================================= |
80 | void RWStepRepr_RWCharacterizedRepresentation::WriteStep |
81 | (StepData_StepWriter& SW, |
82 | const Handle(StepRepr_CharacterizedRepresentation)& ent) const |
83 | { |
84 | // name |
85 | SW.Send(ent->Name()); |
86 | |
87 | // description |
88 | if (!ent->Description().IsNull()) |
89 | SW.Send(ent->Description()); |
90 | else |
91 | SW.SendUndef(); |
92 | |
93 | // items |
94 | SW.OpenSub(); |
95 | for (Standard_Integer i = 1; i <= ent->NbItems(); i ++) { |
96 | SW.Send(ent->ItemsValue(i)); |
97 | } |
98 | SW.CloseSub(); |
99 | |
100 | // context_of_items |
101 | SW.Send(ent->ContextOfItems()); |
102 | } |
103 | |
104 | //======================================================================= |
105 | //function : Share |
106 | //purpose : |
107 | //======================================================================= |
108 | void RWStepRepr_RWCharacterizedRepresentation::Share |
109 | (const Handle(StepRepr_CharacterizedRepresentation)& ent, |
110 | Interface_EntityIterator& iter) const |
111 | { |
112 | Standard_Integer nbElem = ent->NbItems(); |
113 | for (Standard_Integer i=1; i <= nbElem; i++) { |
114 | iter.GetOneItem(ent->ItemsValue(i)); |
115 | } |
116 | iter.GetOneItem(ent->ContextOfItems()); |
117 | } |
118 | |