7fd59977 |
1 | // sln 04.10.2001. BUC61003. Correction of looking for items of complex entity |
2 | #include <RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve.ixx> |
3 | #include <StepGeom_BSplineCurveWithKnots.hxx> |
4 | #include <StepGeom_RationalBSplineCurve.hxx> |
5 | #include <StepGeom_HArray1OfCartesianPoint.hxx> |
6 | #include <StepGeom_CartesianPoint.hxx> |
7 | #include <StepGeom_BSplineCurveForm.hxx> |
8 | #include <StepData_Logical.hxx> |
9 | #include <TColStd_HArray1OfInteger.hxx> |
10 | #include <TColStd_HArray1OfReal.hxx> |
11 | #include <StepGeom_KnotType.hxx> |
12 | |
13 | #include <RWStepGeom_RWBSplineCurveWithKnots.hxx> |
14 | #include <RWStepGeom_RWRationalBSplineCurve.hxx> |
15 | |
16 | |
17 | #include <Interface_EntityIterator.hxx> |
18 | |
19 | |
20 | #include <StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve.hxx> |
21 | |
22 | |
23 | |
24 | // --- Enum : BSplineCurveForm --- |
25 | static TCollection_AsciiString bscfEllipticArc(".ELLIPTIC_ARC."); |
26 | static TCollection_AsciiString bscfPolylineForm(".POLYLINE_FORM."); |
27 | static TCollection_AsciiString bscfParabolicArc(".PARABOLIC_ARC."); |
28 | static TCollection_AsciiString bscfCircularArc(".CIRCULAR_ARC."); |
29 | static TCollection_AsciiString bscfUnspecified(".UNSPECIFIED."); |
30 | static TCollection_AsciiString bscfHyperbolicArc(".HYPERBOLIC_ARC."); |
31 | |
32 | // --- Enum : KnotType --- |
33 | static TCollection_AsciiString ktUniformKnots(".UNIFORM_KNOTS."); |
34 | static TCollection_AsciiString ktQuasiUniformKnots(".QUASI_UNIFORM_KNOTS."); |
35 | static TCollection_AsciiString ktPiecewiseBezierKnots(".PIECEWISE_BEZIER_KNOTS."); |
36 | static TCollection_AsciiString ktUnspecified(".UNSPECIFIED."); |
37 | |
38 | RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve () {} |
39 | |
40 | void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::ReadStep |
41 | (const Handle(StepData_StepReaderData)& data, |
42 | const Standard_Integer num0, |
43 | Handle(Interface_Check)& ach, |
44 | const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)& ent) const |
45 | { |
46 | |
47 | // sln 04.10.2001. BUC61003. Correction of looking for items of complex entity |
48 | Standard_Integer num = 0; // num0 |
49 | data->NamedForComplex("BOUNDED_CURVE BNDCRV",num0,num,ach); |
50 | |
51 | // --- Instance of plex componant BoundedCurve --- |
52 | |
53 | if (!data->CheckNbParams(num,0,ach,"bounded_curve")) return; |
54 | |
55 | // num = data->NextForComplex(num); |
56 | // sln 04.10.2001. BUC61003. Correction of looking for items of complex entity |
57 | // num = 0; gka TRJ9 |
58 | data->NamedForComplex("B_SPLINE_CURVE BSPCR",num0,num,ach); |
59 | |
60 | // --- Instance of common supertype BSplineCurve --- |
61 | |
62 | if (!data->CheckNbParams(num,5,ach,"b_spline_curve")) return; |
63 | // --- field : degree --- |
64 | |
65 | |
66 | Standard_Integer aDegree; |
67 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
68 | data->ReadInteger (num,1,"degree",ach,aDegree); |
69 | // --- field : controlPointsList --- |
70 | |
71 | |
72 | Handle(StepGeom_HArray1OfCartesianPoint) aControlPointsList; |
73 | Handle(StepGeom_CartesianPoint) anent2; |
74 | Standard_Integer nsub2; |
75 | if (data->ReadSubList (num,2,"control_points_list",ach,nsub2)) { |
76 | Standard_Integer nb2 = data->NbParams(nsub2); |
77 | aControlPointsList = new StepGeom_HArray1OfCartesianPoint (1, nb2); |
78 | for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) { |
79 | //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed |
80 | if (data->ReadEntity (nsub2, i2,"cartesian_point", ach, |
81 | STANDARD_TYPE(StepGeom_CartesianPoint), anent2)) |
82 | aControlPointsList->SetValue(i2, anent2); |
83 | } |
84 | } |
85 | |
86 | // --- field : curveForm --- |
87 | |
88 | |
89 | StepGeom_BSplineCurveForm aCurveForm = StepGeom_bscfPolylineForm; |
90 | if (data->ParamType(num,3) == Interface_ParamEnum) { |
91 | Standard_CString text = data->ParamCValue(num,3); |
92 | if (bscfEllipticArc.IsEqual(text)) aCurveForm = StepGeom_bscfEllipticArc; |
93 | else if (bscfPolylineForm.IsEqual(text)) aCurveForm = StepGeom_bscfPolylineForm; |
94 | else if (bscfParabolicArc.IsEqual(text)) aCurveForm = StepGeom_bscfParabolicArc; |
95 | else if (bscfCircularArc.IsEqual(text)) aCurveForm = StepGeom_bscfCircularArc; |
96 | else if (bscfUnspecified.IsEqual(text)) aCurveForm = StepGeom_bscfUnspecified; |
97 | else if (bscfHyperbolicArc.IsEqual(text)) aCurveForm = StepGeom_bscfHyperbolicArc; |
98 | else ach->AddFail("Enumeration b_spline_curve_form has not an allowed value"); |
99 | } |
100 | else ach->AddFail("Parameter #3 (curve_form) is not an enumeration"); |
101 | // --- field : closedCurve --- |
102 | |
103 | |
104 | StepData_Logical aClosedCurve; |
105 | //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed |
106 | data->ReadLogical (num,4,"closed_curve",ach,aClosedCurve); |
107 | // --- field : selfIntersect --- |
108 | |
109 | |
110 | StepData_Logical aSelfIntersect; |
111 | //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed |
112 | data->ReadLogical (num,5,"self_intersect",ach,aSelfIntersect); |
113 | |
114 | // num = data->NextForComplex(num); |
115 | // sln 04.10.2001. BUC61003. Correction of looking for items of complex entity |
116 | // num = 0; //gka TRJ9 |
117 | data->NamedForComplex("B_SPLINE_CURVE_WITH_KNOTS BSCWK",num0,num,ach); |
118 | |
119 | // --- Instance of plex componant BSplineCurveWithKnots --- |
120 | |
121 | if (!data->CheckNbParams(num,3,ach,"b_spline_curve_with_knots")) return; |
122 | |
123 | // --- field : knotMultiplicities --- |
124 | |
125 | Handle(TColStd_HArray1OfInteger) aKnotMultiplicities; |
126 | Standard_Integer aKnotMultiplicitiesItem; |
127 | Standard_Integer nsub6; |
128 | if (data->ReadSubList (num,1,"knot_multiplicities",ach,nsub6)) { |
129 | Standard_Integer nb6 = data->NbParams(nsub6); |
130 | aKnotMultiplicities = new TColStd_HArray1OfInteger (1, nb6); |
131 | for (Standard_Integer i6 = 1; i6 <= nb6; i6 ++) { |
132 | //szv#4:S4163:12Mar99 `Standard_Boolean stat6 =` not needed |
133 | if (data->ReadInteger (nsub6,i6,"knot_multiplicities",ach,aKnotMultiplicitiesItem)) |
134 | aKnotMultiplicities->SetValue(i6,aKnotMultiplicitiesItem); |
135 | } |
136 | } |
137 | |
138 | // --- field : knots --- |
139 | |
140 | Handle(TColStd_HArray1OfReal) aKnots; |
141 | Standard_Real aKnotsItem; |
142 | Standard_Integer nsub7; |
143 | if (data->ReadSubList (num,2,"knots",ach,nsub7)) { |
144 | Standard_Integer nb7 = data->NbParams(nsub7); |
145 | aKnots = new TColStd_HArray1OfReal (1, nb7); |
146 | for (Standard_Integer i7 = 1; i7 <= nb7; i7 ++) { |
147 | //szv#4:S4163:12Mar99 `Standard_Boolean stat7 =` not needed |
148 | if (data->ReadReal (nsub7,i7,"knots",ach,aKnotsItem)) |
149 | aKnots->SetValue(i7,aKnotsItem); |
150 | } |
151 | } |
152 | |
153 | // --- field : knotSpec --- |
154 | |
155 | StepGeom_KnotType aKnotSpec = StepGeom_ktUniformKnots; |
156 | if (data->ParamType(num,3) == Interface_ParamEnum) { |
157 | Standard_CString text = data->ParamCValue(num,3); |
158 | if (ktUniformKnots.IsEqual(text)) aKnotSpec = StepGeom_ktUniformKnots; |
159 | else if (ktQuasiUniformKnots.IsEqual(text)) aKnotSpec = StepGeom_ktQuasiUniformKnots; |
160 | else if (ktPiecewiseBezierKnots.IsEqual(text)) aKnotSpec = StepGeom_ktPiecewiseBezierKnots; |
161 | else if (ktUnspecified.IsEqual(text)) aKnotSpec = StepGeom_ktUnspecified; |
162 | else ach->AddFail("Enumeration knot_type has not an allowed value"); |
163 | } |
164 | else ach->AddFail("Parameter #3 (knot_spec) is not an enumeration"); |
165 | |
166 | // num = data->NextForComplex(num); |
167 | // sln 04.10.2001. BUC61003. Correction of looking for items of complex entity |
168 | // num = 0; gka TRJ9 |
169 | data->NamedForComplex("CURVE",num0,num,ach); |
170 | |
171 | // --- Instance of plex componant Curve --- |
172 | |
173 | if (!data->CheckNbParams(num,0,ach,"curve")) return; |
174 | |
175 | // num = data->NextForComplex(num); |
176 | // sln 04.10.2001. BUC61003. Correction of looking for items of complex entity |
177 | //num = 0; |
178 | data->NamedForComplex("GEOMETRIC_REPRESENTATION_ITEM GMRPIT",num0,num,ach); |
179 | |
180 | // --- Instance of plex componant GeometricRepresentationItem --- |
181 | |
182 | if (!data->CheckNbParams(num,0,ach,"geometric_representation_item")) return; |
183 | |
184 | // num = data->NextForComplex(num); |
185 | // sln 04.10.2001. BUC61003. Correction of looking for items of complex entity |
186 | //num = 0; |
187 | data->NamedForComplex("RATIONAL_B_SPLINE_CURVE RBSC",num0,num,ach); |
188 | |
189 | // --- Instance of plex componant RationalBSplineCurve --- |
190 | |
191 | if (!data->CheckNbParams(num,1,ach,"rational_b_spline_curve")) return; |
192 | |
193 | // --- field : weightsData --- |
194 | |
195 | Handle(TColStd_HArray1OfReal) aWeightsData; |
196 | Standard_Real aWeightsDataItem; |
197 | Standard_Integer nsub9; |
198 | if (data->ReadSubList (num,1,"weights_data",ach,nsub9)) { |
199 | Standard_Integer nb9 = data->NbParams(nsub9); |
200 | aWeightsData = new TColStd_HArray1OfReal (1, nb9); |
201 | for (Standard_Integer i9 = 1; i9 <= nb9; i9 ++) { |
202 | //szv#4:S4163:12Mar99 `Standard_Boolean stat9 =` not needed |
203 | if (data->ReadReal (nsub9,i9,"weights_data",ach,aWeightsDataItem)) |
204 | aWeightsData->SetValue(i9,aWeightsDataItem); |
205 | } |
206 | } |
207 | |
208 | // num = data->NextForComplex(num); |
209 | // sln 04.10.2001. BUC61003. Correction of looking for items of complex entity |
210 | //num = 0; |
211 | data->NamedForComplex("REPRESENTATION_ITEM RPRITM",num0,num,ach); |
212 | |
213 | // --- Instance of plex componant RepresentationItem --- |
214 | |
215 | if (!data->CheckNbParams(num,1,ach,"representation_item")) return; |
216 | |
217 | // --- field : name --- |
218 | |
219 | Handle(TCollection_HAsciiString) aName; |
220 | //szv#4:S4163:12Mar99 `Standard_Boolean stat10 =` not needed |
221 | data->ReadString (num,1,"name",ach,aName); |
222 | |
223 | //--- Initialisation of the red entity --- |
224 | |
225 | ent->Init(aName,aDegree,aControlPointsList,aCurveForm,aClosedCurve,aSelfIntersect,aKnotMultiplicities,aKnots,aKnotSpec,aWeightsData); |
226 | } |
227 | |
228 | |
229 | void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::WriteStep |
230 | (StepData_StepWriter& SW, |
231 | const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)& ent) const |
232 | { |
233 | |
234 | // --- Instance of plex componant BoundedCurve --- |
235 | |
236 | SW.StartEntity("BOUNDED_CURVE"); |
237 | |
238 | // --- Instance of common supertype BSplineCurve --- |
239 | |
240 | SW.StartEntity("B_SPLINE_CURVE"); |
241 | // --- field : degree --- |
242 | |
243 | SW.Send(ent->Degree()); |
244 | // --- field : controlPointsList --- |
245 | |
246 | SW.OpenSub(); |
247 | for (Standard_Integer i2 = 1; i2 <= ent->NbControlPointsList(); i2 ++) { |
248 | SW.Send(ent->ControlPointsListValue(i2)); |
249 | } |
250 | SW.CloseSub(); |
251 | // --- field : curveForm --- |
252 | |
253 | switch(ent->CurveForm()) { |
254 | case StepGeom_bscfEllipticArc : SW.SendEnum (bscfEllipticArc); break; |
255 | case StepGeom_bscfPolylineForm : SW.SendEnum (bscfPolylineForm); break; |
256 | case StepGeom_bscfParabolicArc : SW.SendEnum (bscfParabolicArc); break; |
257 | case StepGeom_bscfCircularArc : SW.SendEnum (bscfCircularArc); break; |
258 | case StepGeom_bscfUnspecified : SW.SendEnum (bscfUnspecified); break; |
259 | case StepGeom_bscfHyperbolicArc : SW.SendEnum (bscfHyperbolicArc); break; |
260 | } |
261 | // --- field : closedCurve --- |
262 | |
263 | SW.SendLogical(ent->ClosedCurve()); |
264 | // --- field : selfIntersect --- |
265 | |
266 | SW.SendLogical(ent->SelfIntersect()); |
267 | |
268 | // --- Instance of plex componant BSplineCurveWithKnots --- |
269 | |
270 | SW.StartEntity("B_SPLINE_CURVE_WITH_KNOTS"); |
271 | // --- field : knotMultiplicities --- |
272 | |
273 | SW.OpenSub(); |
274 | for (Standard_Integer i6 = 1; i6 <= ent->NbKnotMultiplicities(); i6 ++) { |
275 | SW.Send(ent->KnotMultiplicitiesValue(i6)); |
276 | } |
277 | SW.CloseSub(); |
278 | // --- field : knots --- |
279 | |
280 | SW.OpenSub(); |
281 | for (Standard_Integer i7 = 1; i7 <= ent->NbKnots(); i7 ++) { |
282 | SW.Send(ent->KnotsValue(i7)); |
283 | } |
284 | SW.CloseSub(); |
285 | // --- field : knotSpec --- |
286 | |
287 | switch(ent->KnotSpec()) { |
288 | case StepGeom_ktUniformKnots : SW.SendEnum (ktUniformKnots); break; |
289 | case StepGeom_ktQuasiUniformKnots : SW.SendEnum (ktQuasiUniformKnots); break; |
290 | case StepGeom_ktPiecewiseBezierKnots : SW.SendEnum (ktPiecewiseBezierKnots); break; |
291 | case StepGeom_ktUnspecified : SW.SendEnum (ktUnspecified); break; |
292 | } |
293 | |
294 | // --- Instance of plex componant Curve --- |
295 | |
296 | SW.StartEntity("CURVE"); |
297 | |
298 | // --- Instance of plex componant GeometricRepresentationItem --- |
299 | |
300 | SW.StartEntity("GEOMETRIC_REPRESENTATION_ITEM"); |
301 | |
302 | // --- Instance of plex componant RationalBSplineCurve --- |
303 | |
304 | SW.StartEntity("RATIONAL_B_SPLINE_CURVE"); |
305 | // --- field : weightsData --- |
306 | |
307 | SW.OpenSub(); |
308 | for (Standard_Integer i9 = 1; i9 <= ent->NbWeightsData(); i9 ++) { |
309 | SW.Send(ent->WeightsDataValue(i9)); |
310 | } |
311 | SW.CloseSub(); |
312 | |
313 | // --- Instance of plex componant RepresentationItem --- |
314 | |
315 | SW.StartEntity("REPRESENTATION_ITEM"); |
316 | // --- field : name --- |
317 | |
318 | SW.Send(ent->Name()); |
319 | } |
320 | |
321 | |
322 | void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::Share(const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)& ent, Interface_EntityIterator& iter) const |
323 | { |
324 | |
325 | Standard_Integer nbElem1 = ent->NbControlPointsList(); |
326 | for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) { |
327 | iter.GetOneItem(ent->ControlPointsListValue(is1)); |
328 | } |
329 | |
330 | } |
331 | |
332 | |
333 | |
334 | void RWStepGeom_RWBSplineCurveWithKnotsAndRationalBSplineCurve::Check |
335 | (const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)& ent, |
336 | const Interface_ShareTool& aShto, |
337 | Handle(Interface_Check)& ach) const |
338 | { |
339 | Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) aRationalBSC = |
340 | Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)::DownCast(ent); |
341 | Handle(StepGeom_BSplineCurveWithKnots) aBSCWK = |
342 | aRationalBSC->BSplineCurveWithKnots(); |
343 | RWStepGeom_RWBSplineCurveWithKnots t1; |
344 | t1.Check(aBSCWK,aShto,ach); |
345 | Handle(StepGeom_RationalBSplineCurve) aRBSC = |
346 | aRationalBSC->RationalBSplineCurve(); |
347 | RWStepGeom_RWRationalBSplineCurve t2; |
348 | t2.Check(aRBSC,aShto,ach); |
349 | } |