b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
3 | // The content of this file is subject to the Open CASCADE Technology Public |
4 | // License Version 6.5 (the "License"). You may not use the content of this file |
5 | // except in compliance with the License. Please obtain a copy of the License |
6 | // at http://www.opencascade.org and read it completely before using this file. |
7 | // |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
10 | // |
11 | // The Original Code and all software distributed under the License is |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
13 | // Initial Developer hereby disclaims all such warranties, including without |
14 | // limitation, any warranties of merchantability, fitness for a particular |
15 | // purpose or non-infringement. Please see the License for the specific terms |
16 | // and conditions governing the rights and limitations under the License. |
17 | |
7fd59977 |
18 | |
19 | #include <RWStepRepr_RWGlobalUnitAssignedContext.ixx> |
20 | #include <StepBasic_HArray1OfNamedUnit.hxx> |
21 | #include <StepBasic_NamedUnit.hxx> |
22 | |
23 | |
24 | #include <Interface_EntityIterator.hxx> |
25 | |
26 | |
27 | #include <StepRepr_GlobalUnitAssignedContext.hxx> |
28 | |
29 | |
30 | RWStepRepr_RWGlobalUnitAssignedContext::RWStepRepr_RWGlobalUnitAssignedContext () {} |
31 | |
32 | void RWStepRepr_RWGlobalUnitAssignedContext::ReadStep |
33 | (const Handle(StepData_StepReaderData)& data, |
34 | const Standard_Integer num, |
35 | Handle(Interface_Check)& ach, |
36 | const Handle(StepRepr_GlobalUnitAssignedContext)& ent) const |
37 | { |
38 | |
39 | |
40 | // --- Number of Parameter Control --- |
41 | |
42 | if (!data->CheckNbParams(num,3,ach,"global_unit_assigned_context")) return; |
43 | |
44 | // --- inherited field : contextIdentifier --- |
45 | |
46 | Handle(TCollection_HAsciiString) aContextIdentifier; |
47 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
48 | data->ReadString (num,1,"context_identifier",ach,aContextIdentifier); |
49 | |
50 | // --- inherited field : contextType --- |
51 | |
52 | Handle(TCollection_HAsciiString) aContextType; |
53 | //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed |
54 | data->ReadString (num,2,"context_type",ach,aContextType); |
55 | |
56 | // --- own field : units --- |
57 | |
58 | Handle(StepBasic_HArray1OfNamedUnit) aUnits; |
59 | Handle(StepBasic_NamedUnit) anent3; |
60 | Standard_Integer nsub3; |
61 | if (data->ReadSubList (num,3,"units",ach,nsub3)) { |
62 | Standard_Integer nb3 = data->NbParams(nsub3); |
63 | aUnits = new StepBasic_HArray1OfNamedUnit (1, nb3); |
64 | for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) { |
65 | //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed |
66 | if (data->ReadEntity (nsub3, i3,"unit", ach, STANDARD_TYPE(StepBasic_NamedUnit), anent3)) |
67 | aUnits->SetValue(i3, anent3); |
68 | } |
69 | } |
70 | |
71 | //--- Initialisation of the read entity --- |
72 | |
73 | |
74 | ent->Init(aContextIdentifier, aContextType, aUnits); |
75 | } |
76 | |
77 | |
78 | void RWStepRepr_RWGlobalUnitAssignedContext::WriteStep |
79 | (StepData_StepWriter& SW, |
80 | const Handle(StepRepr_GlobalUnitAssignedContext)& ent) const |
81 | { |
82 | |
83 | // --- inherited field contextIdentifier --- |
84 | |
85 | SW.Send(ent->ContextIdentifier()); |
86 | |
87 | // --- inherited field contextType --- |
88 | |
89 | SW.Send(ent->ContextType()); |
90 | |
91 | // --- own field : units --- |
92 | |
93 | SW.OpenSub(); |
94 | for (Standard_Integer i3 = 1; i3 <= ent->NbUnits(); i3 ++) { |
95 | SW.Send(ent->UnitsValue(i3)); |
96 | } |
97 | SW.CloseSub(); |
98 | } |
99 | |
100 | |
101 | void RWStepRepr_RWGlobalUnitAssignedContext::Share(const Handle(StepRepr_GlobalUnitAssignedContext)& ent, Interface_EntityIterator& iter) const |
102 | { |
103 | |
104 | Standard_Integer nbElem1 = ent->NbUnits(); |
105 | for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) { |
106 | iter.GetOneItem(ent->UnitsValue(is1)); |
107 | } |
108 | |
109 | } |
110 | |