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 | |
42cf5bc1 |
14 | |
15 | #include <Interface_Check.hxx> |
16 | #include <Interface_EntityIterator.hxx> |
17 | #include <RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx> |
7fd59977 |
18 | #include <StepBasic_HArray1OfNamedUnit.hxx> |
7fd59977 |
19 | #include <StepBasic_HArray1OfUncertaintyMeasureWithUnit.hxx> |
42cf5bc1 |
20 | #include <StepBasic_NamedUnit.hxx> |
7fd59977 |
21 | #include <StepBasic_UncertaintyMeasureWithUnit.hxx> |
42cf5bc1 |
22 | #include <StepData_StepReaderData.hxx> |
23 | #include <StepData_StepWriter.hxx> |
24 | #include <StepGeom_GeometricRepresentationContext.hxx> |
7fd59977 |
25 | #include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx> |
42cf5bc1 |
26 | #include <StepRepr_GlobalUnitAssignedContext.hxx> |
7fd59977 |
27 | |
28 | RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx () {} |
29 | |
30 | void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::ReadStep |
31 | (const Handle(StepData_StepReaderData)& data, |
32 | const Standard_Integer num0, |
33 | Handle(Interface_Check)& ach, |
34 | const Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)& ent) const |
35 | { |
36 | |
37 | Standard_Integer num = num0; |
38 | |
39 | // ----------------------------------------------------------------- |
40 | // --- Instance of plex componant GeometricRepresentationContext --- |
41 | // ----------------------------------------------------------------- |
42 | |
43 | if (!data->CheckNbParams(num,1,ach,"geometric_representation_context")) return; |
44 | |
45 | // --- field : coordinateSpaceDimension --- |
46 | |
47 | Standard_Integer aCoordinateSpaceDimension; |
48 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
49 | data->ReadInteger (num,1,"coordinate_space_dimension",ach,aCoordinateSpaceDimension); |
50 | |
51 | num = data->NextForComplex(num); |
52 | |
53 | // ------------------------------------------------------------------- |
54 | // --- Instance of plex componant GlobalUncertaintyAssignedContext --- |
55 | // ------------------------------------------------------------------- |
56 | |
57 | if (!data->CheckNbParams(num,1,ach,"global_uncertainty_assigned_context")) return; |
58 | |
59 | // --- field : uncertainty --- |
60 | |
61 | Handle(StepBasic_HArray1OfUncertaintyMeasureWithUnit) aUncertainty; |
62 | Handle(StepBasic_UncertaintyMeasureWithUnit) anent3; |
63 | Standard_Integer nsub3; |
64 | if (data->ReadSubList (num,1,"uncertainty",ach,nsub3)) { |
65 | Standard_Integer nb3 = data->NbParams(nsub3); |
66 | aUncertainty = new StepBasic_HArray1OfUncertaintyMeasureWithUnit (1, nb3); |
67 | for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) { |
68 | //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed |
69 | if (data->ReadEntity (nsub3, i3,"uncertainty_measure_with_unit", ach, |
70 | STANDARD_TYPE(StepBasic_UncertaintyMeasureWithUnit), anent3)) |
71 | aUncertainty->SetValue(i3, anent3); |
72 | } |
73 | } |
74 | |
75 | num = data->NextForComplex(num); |
76 | |
77 | // ------------------------------------------------------------ |
78 | // --- Instance of plex componant GlobalUnitAssignedContext --- |
79 | // ------------------------------------------------------------ |
80 | |
81 | if (!data->CheckNbParams(num,1,ach,"global_unit_assigned_context")) return; |
82 | |
83 | // --- field : units --- |
84 | |
85 | Handle(StepBasic_HArray1OfNamedUnit) aUnits; |
86 | Handle(StepBasic_NamedUnit) anent2; |
87 | Standard_Integer nsub2; |
88 | if (data->ReadSubList (num,1,"units",ach,nsub2)) { |
89 | Standard_Integer nb2 = data->NbParams(nsub2); |
90 | aUnits = new StepBasic_HArray1OfNamedUnit (1, nb2); |
91 | for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) { |
92 | //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed |
93 | if (data->ReadEntity (nsub2, i2,"unit", ach, STANDARD_TYPE(StepBasic_NamedUnit), anent2)) |
94 | aUnits->SetValue(i2, anent2); |
95 | } |
96 | } |
97 | |
98 | num = data->NextForComplex(num); |
99 | |
100 | // ---------------------------------------------------------- |
101 | // --- Instance of common supertype RepresentationContext --- |
102 | // ---------------------------------------------------------- |
103 | |
104 | if (!data->CheckNbParams(num,2,ach,"representation_context")) return; |
105 | |
106 | // --- field : contextIdentifier --- |
107 | |
108 | Handle(TCollection_HAsciiString) aContextIdentifier; |
109 | //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed |
110 | data->ReadString (num,1,"context_identifier",ach,aContextIdentifier); |
111 | |
112 | // --- field : contextType --- |
113 | |
114 | Handle(TCollection_HAsciiString) aContextType; |
115 | //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed |
116 | data->ReadString (num,2,"context_type",ach,aContextType); |
117 | |
118 | //--- Initialisation of the red entity --- |
119 | |
120 | ent->Init(aContextIdentifier,aContextType,aCoordinateSpaceDimension,aUnits, aUncertainty); |
121 | } |
122 | |
123 | |
124 | void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::WriteStep |
125 | (StepData_StepWriter& SW, |
126 | const Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)& ent) const |
127 | { |
128 | |
129 | // ----------------------------------------------------------------- |
130 | // --- Instance of plex componant GeometricRepresentationContext --- |
131 | // ----------------------------------------------------------------- |
132 | |
133 | SW.StartEntity("GEOMETRIC_REPRESENTATION_CONTEXT"); |
134 | |
135 | // --- field : coordinateSpaceDimension --- |
136 | |
137 | SW.Send(ent->CoordinateSpaceDimension()); |
138 | |
139 | // ------------------------------------------------------------------- |
140 | // --- Instance of plex componant GlobalUncertaintyAssignedContext --- |
141 | // ------------------------------------------------------------------- |
142 | |
143 | SW.StartEntity("GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT"); |
144 | |
145 | // --- field : uncertainty --- |
146 | |
147 | SW.OpenSub(); |
148 | for (Standard_Integer i3 = 1; i3 <= ent->NbUncertainty(); i3 ++) { |
149 | SW.Send(ent->UncertaintyValue(i3)); |
150 | } |
151 | SW.CloseSub(); |
152 | |
153 | // ------------------------------------------------------------ |
154 | // --- Instance of plex componant GlobalUnitAssignedContext --- |
155 | // ------------------------------------------------------------ |
156 | |
157 | SW.StartEntity("GLOBAL_UNIT_ASSIGNED_CONTEXT"); |
158 | |
159 | // --- field : units --- |
160 | |
161 | SW.OpenSub(); |
162 | for (Standard_Integer i2 = 1; i2 <= ent->NbUnits(); i2 ++) { |
163 | SW.Send(ent->UnitsValue(i2)); |
164 | } |
165 | SW.CloseSub(); |
166 | |
167 | // ---------------------------------------------------------- |
168 | // --- Instance of common supertype RepresentationContext --- |
169 | // ---------------------------------------------------------- |
170 | |
171 | SW.StartEntity("REPRESENTATION_CONTEXT"); |
172 | |
173 | // --- field : contextIdentifier --- |
174 | |
175 | SW.Send(ent->ContextIdentifier()); |
176 | |
177 | // --- field : contextType --- |
178 | |
179 | SW.Send(ent->ContextType()); |
180 | } |
181 | |
182 | |
183 | void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::Share(const Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)& ent, Interface_EntityIterator& iter) const |
184 | { |
185 | |
186 | Standard_Integer nbElem1 = ent->NbUnits(); |
187 | for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) { |
188 | iter.GetOneItem(ent->UnitsValue(is1)); |
189 | } |
190 | |
191 | Standard_Integer nbElem2 = ent->NbUncertainty(); |
192 | for (Standard_Integer is2=1; is2<=nbElem2; is2 ++) { |
193 | iter.GetOneItem(ent->UncertaintyValue(is2)); |
194 | } |
195 | |
196 | } |
197 | |