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 | |
7fd59977 |
14 | |
42cf5bc1 |
15 | #include <Interface_Check.hxx> |
7fd59977 |
16 | #include <Interface_EntityIterator.hxx> |
42cf5bc1 |
17 | #include <RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface.hxx> |
18 | #include <StepData_Logical.hxx> |
19 | #include <StepData_StepReaderData.hxx> |
20 | #include <StepData_StepWriter.hxx> |
21 | #include <StepGeom_BezierSurface.hxx> |
7fd59977 |
22 | #include <StepGeom_BezierSurfaceAndRationalBSplineSurface.hxx> |
42cf5bc1 |
23 | #include <StepGeom_BSplineSurfaceForm.hxx> |
24 | #include <StepGeom_CartesianPoint.hxx> |
25 | #include <StepGeom_HArray2OfCartesianPoint.hxx> |
26 | #include <StepGeom_RationalBSplineSurface.hxx> |
27 | #include <TColStd_HArray2OfReal.hxx> |
7fd59977 |
28 | |
b311480e |
29 | // --- Enum : BSplineSurfaceForm --- |
7fd59977 |
30 | static TCollection_AsciiString bssfSurfOfLinearExtrusion(".SURF_OF_LINEAR_EXTRUSION."); |
31 | static TCollection_AsciiString bssfPlaneSurf(".PLANE_SURF."); |
32 | static TCollection_AsciiString bssfGeneralisedCone(".GENERALISED_CONE."); |
33 | static TCollection_AsciiString bssfToroidalSurf(".TOROIDAL_SURF."); |
34 | static TCollection_AsciiString bssfConicalSurf(".CONICAL_SURF."); |
35 | static TCollection_AsciiString bssfSphericalSurf(".SPHERICAL_SURF."); |
36 | static TCollection_AsciiString bssfUnspecified(".UNSPECIFIED."); |
37 | static TCollection_AsciiString bssfRuledSurf(".RULED_SURF."); |
38 | static TCollection_AsciiString bssfSurfOfRevolution(".SURF_OF_REVOLUTION."); |
39 | static TCollection_AsciiString bssfCylindricalSurf(".CYLINDRICAL_SURF."); |
40 | static TCollection_AsciiString bssfQuadricSurf(".QUADRIC_SURF."); |
41 | |
42 | RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface::RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface () {} |
43 | |
44 | void RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface::ReadStep |
45 | (const Handle(StepData_StepReaderData)& data, |
46 | const Standard_Integer num0, |
47 | Handle(Interface_Check)& ach, |
48 | const Handle(StepGeom_BezierSurfaceAndRationalBSplineSurface)& ent) const |
49 | { |
50 | |
51 | Standard_Integer num = num0; |
52 | |
53 | |
54 | // --- Instance of plex componant BezierSurface --- |
55 | |
56 | if (!data->CheckNbParams(num,0,ach,"bezier_surface")) return; |
57 | |
58 | num = data->NextForComplex(num); |
59 | |
60 | // --- Instance of plex componant BoundedSurface --- |
61 | |
62 | if (!data->CheckNbParams(num,0,ach,"bounded_surface")) return; |
63 | |
64 | num = data->NextForComplex(num); |
65 | |
66 | // --- Instance of common supertype BSplineSurface --- |
67 | |
68 | if (!data->CheckNbParams(num,7,ach,"b_spline_surface")) return; |
69 | // --- field : uDegree --- |
70 | |
71 | |
72 | Standard_Integer aUDegree; |
73 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
74 | data->ReadInteger (num,1,"u_degree",ach,aUDegree); |
75 | // --- field : vDegree --- |
76 | |
77 | |
78 | Standard_Integer aVDegree; |
79 | //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed |
80 | data->ReadInteger (num,2,"v_degree",ach,aVDegree); |
81 | // --- field : controlPointsList --- |
82 | |
83 | |
84 | Handle(StepGeom_HArray2OfCartesianPoint) aControlPointsList; |
85 | Handle(StepGeom_CartesianPoint) anent3; |
86 | Standard_Integer nsub3; |
87 | if (data->ReadSubList (num,3,"control_points_list",ach,nsub3)) { |
88 | Standard_Integer nbi3 = data->NbParams(nsub3); |
89 | Standard_Integer nbj3 = data->NbParams(data->ParamNumber(nsub3,1)); |
90 | aControlPointsList = new StepGeom_HArray2OfCartesianPoint (1, nbi3, 1, nbj3); |
91 | for (Standard_Integer i3 = 1; i3 <= nbi3; i3 ++) { |
92 | Standard_Integer nsi3; |
93 | if (data->ReadSubList (nsub3,i3,"sub-part(control_points_list)",ach,nsi3)) { |
94 | for (Standard_Integer j3 =1; j3 <= nbj3; j3 ++) { |
95 | //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed |
96 | if (data->ReadEntity (nsi3, j3,"cartesian_point", ach, |
97 | STANDARD_TYPE(StepGeom_CartesianPoint), anent3)) |
98 | aControlPointsList->SetValue(i3, j3, anent3); |
99 | } |
100 | } |
101 | } |
102 | } |
103 | |
104 | // --- field : surfaceForm --- |
105 | |
106 | |
107 | StepGeom_BSplineSurfaceForm aSurfaceForm = StepGeom_bssfPlaneSurf; |
108 | if (data->ParamType(num,4) == Interface_ParamEnum) { |
109 | Standard_CString text = data->ParamCValue(num,4); |
110 | if (bssfSurfOfLinearExtrusion.IsEqual(text)) aSurfaceForm = StepGeom_bssfSurfOfLinearExtrusion; |
111 | else if (bssfPlaneSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfPlaneSurf; |
112 | else if (bssfGeneralisedCone.IsEqual(text)) aSurfaceForm = StepGeom_bssfGeneralisedCone; |
113 | else if (bssfToroidalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfToroidalSurf; |
114 | else if (bssfConicalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfConicalSurf; |
115 | else if (bssfSphericalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfSphericalSurf; |
116 | else if (bssfUnspecified.IsEqual(text)) aSurfaceForm = StepGeom_bssfUnspecified; |
117 | else if (bssfRuledSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfRuledSurf; |
118 | else if (bssfSurfOfRevolution.IsEqual(text)) aSurfaceForm = StepGeom_bssfSurfOfRevolution; |
119 | else if (bssfCylindricalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfCylindricalSurf; |
120 | else if (bssfQuadricSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfQuadricSurf; |
121 | else ach->AddFail("Enumeration b_spline_surface_form has not an allowed value"); |
122 | } |
123 | else ach->AddFail("Parameter #4 (surface_form) is not an enumeration"); |
124 | // --- field : uClosed --- |
125 | |
126 | |
127 | StepData_Logical aUClosed; |
128 | //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed |
129 | data->ReadLogical (num,5,"u_closed",ach,aUClosed); |
130 | // --- field : vClosed --- |
131 | |
132 | |
133 | StepData_Logical aVClosed; |
134 | //szv#4:S4163:12Mar99 `Standard_Boolean stat6 =` not needed |
135 | data->ReadLogical (num,6,"v_closed",ach,aVClosed); |
136 | // --- field : selfIntersect --- |
137 | |
138 | |
139 | StepData_Logical aSelfIntersect; |
140 | //szv#4:S4163:12Mar99 `Standard_Boolean stat7 =` not needed |
141 | data->ReadLogical (num,7,"self_intersect",ach,aSelfIntersect); |
142 | |
143 | num = data->NextForComplex(num); |
144 | |
145 | // --- Instance of plex componant GeometricRepresentationItem --- |
146 | |
147 | if (!data->CheckNbParams(num,0,ach,"geometric_representation_item")) return; |
148 | |
149 | num = data->NextForComplex(num); |
150 | |
151 | // --- Instance of plex componant RationalBSplineSurface --- |
152 | |
153 | if (!data->CheckNbParams(num,1,ach,"rational_b_spline_surface")) return; |
154 | |
155 | // --- field : weightsData --- |
156 | |
157 | Handle(TColStd_HArray2OfReal) aWeightsData; |
158 | Standard_Real aWeightsDataItem; |
159 | Standard_Integer nsub8; |
160 | if (data->ReadSubList (num,1,"items",ach,nsub8)) { |
161 | Standard_Integer nbi8 = data->NbParams(nsub8); |
162 | Standard_Integer nbj8 = data->NbParams(data->ParamNumber(nsub8,1)); |
163 | aWeightsData = new TColStd_HArray2OfReal (1,nbi8,1,nbj8); |
164 | for (Standard_Integer i8 = 1; i8 <= nbi8; i8 ++) { |
165 | Standard_Integer nsi8; |
166 | if (data->ReadSubList(nsub8,i8,"sub-part(weights_data)",ach,nsi8)){ |
167 | for (Standard_Integer j8 =1; j8 <= nbj8; j8 ++) { |
168 | //szv#4:S4163:12Mar99 `Standard_Boolean stat8 =` not needed |
169 | if (data->ReadReal (nsi8,j8,"weights_data",ach,aWeightsDataItem)) |
170 | aWeightsData->SetValue(i8,j8,aWeightsDataItem); |
171 | } |
172 | } |
173 | } |
174 | } |
175 | |
176 | num = data->NextForComplex(num); |
177 | |
178 | // --- Instance of plex componant RepresentationItem --- |
179 | |
180 | if (!data->CheckNbParams(num,1,ach,"representation_item")) return; |
181 | |
182 | // --- field : name --- |
183 | |
184 | Handle(TCollection_HAsciiString) aName; |
185 | //szv#4:S4163:12Mar99 `Standard_Boolean stat9 =` not needed |
186 | data->ReadString (num,1,"name",ach,aName); |
187 | |
188 | num = data->NextForComplex(num); |
189 | |
190 | // --- Instance of plex componant Surface --- |
191 | |
192 | if (!data->CheckNbParams(num,0,ach,"surface")) return; |
193 | |
194 | //--- Initialisation of the red entity --- |
195 | |
196 | ent->Init(aName,aUDegree,aVDegree,aControlPointsList,aSurfaceForm,aUClosed,aVClosed,aSelfIntersect,aWeightsData); |
197 | } |
198 | |
199 | |
200 | void RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface::WriteStep |
201 | (StepData_StepWriter& SW, |
202 | const Handle(StepGeom_BezierSurfaceAndRationalBSplineSurface)& ent) const |
203 | { |
204 | |
205 | // --- Instance of plex componant BezierSurface --- |
206 | |
207 | SW.StartEntity("BEZIER_SURFACE"); |
208 | |
209 | // --- Instance of plex componant BoundedSurface --- |
210 | |
211 | SW.StartEntity("BOUNDED_SURFACE"); |
212 | |
213 | // --- Instance of common supertype BSplineSurface --- |
214 | |
215 | SW.StartEntity("B_SPLINE_SURFACE"); |
216 | // --- field : uDegree --- |
217 | |
218 | SW.Send(ent->UDegree()); |
219 | // --- field : vDegree --- |
220 | |
221 | SW.Send(ent->VDegree()); |
222 | // --- field : controlPointsList --- |
223 | |
224 | SW.OpenSub(); |
225 | for (Standard_Integer i3 = 1; i3 <= ent->NbControlPointsListI(); i3 ++) { |
226 | SW.NewLine(Standard_False); |
227 | SW.OpenSub(); |
228 | for (Standard_Integer j3 = 1; j3 <= ent->NbControlPointsListJ(); j3 ++) { |
229 | SW.Send(ent->ControlPointsListValue(i3,j3)); |
230 | SW.JoinLast(Standard_False); |
231 | } |
232 | SW.CloseSub(); |
233 | } |
234 | SW.CloseSub(); |
235 | // --- field : surfaceForm --- |
236 | |
237 | switch(ent->SurfaceForm()) { |
238 | case StepGeom_bssfSurfOfLinearExtrusion : SW.SendEnum (bssfSurfOfLinearExtrusion); break; |
239 | case StepGeom_bssfPlaneSurf : SW.SendEnum (bssfPlaneSurf); break; |
240 | case StepGeom_bssfGeneralisedCone : SW.SendEnum (bssfGeneralisedCone); break; |
241 | case StepGeom_bssfToroidalSurf : SW.SendEnum (bssfToroidalSurf); break; |
242 | case StepGeom_bssfConicalSurf : SW.SendEnum (bssfConicalSurf); break; |
243 | case StepGeom_bssfSphericalSurf : SW.SendEnum (bssfSphericalSurf); break; |
244 | case StepGeom_bssfUnspecified : SW.SendEnum (bssfUnspecified); break; |
245 | case StepGeom_bssfRuledSurf : SW.SendEnum (bssfRuledSurf); break; |
246 | case StepGeom_bssfSurfOfRevolution : SW.SendEnum (bssfSurfOfRevolution); break; |
247 | case StepGeom_bssfCylindricalSurf : SW.SendEnum (bssfCylindricalSurf); break; |
248 | case StepGeom_bssfQuadricSurf : SW.SendEnum (bssfQuadricSurf); break; |
249 | } |
250 | // --- field : uClosed --- |
251 | |
252 | SW.SendLogical(ent->UClosed()); |
253 | // --- field : vClosed --- |
254 | |
255 | SW.SendLogical(ent->VClosed()); |
256 | // --- field : selfIntersect --- |
257 | |
258 | SW.SendLogical(ent->SelfIntersect()); |
259 | |
260 | // --- Instance of plex componant GeometricRepresentationItem --- |
261 | |
262 | SW.StartEntity("GEOMETRIC_REPRESENTATION_ITEM"); |
263 | |
264 | // --- Instance of plex componant RationalBSplineSurface --- |
265 | |
266 | SW.StartEntity("RATIONAL_B_SPLINE_SURFACE"); |
267 | // --- field : weightsData --- |
268 | |
269 | SW.OpenSub(); |
270 | for (Standard_Integer i8 = 1; i8 <= ent->NbWeightsDataI(); i8 ++) { |
271 | SW.NewLine(Standard_False); |
272 | SW.OpenSub(); |
273 | for (Standard_Integer j8 = 1; j8 <= ent->NbWeightsDataJ(); j8 ++) { |
274 | SW.Send(ent->WeightsDataValue(i8,j8)); |
275 | SW.JoinLast(Standard_False); |
276 | } |
277 | SW.CloseSub(); |
278 | } |
279 | SW.CloseSub(); |
280 | |
281 | // --- Instance of plex componant RepresentationItem --- |
282 | |
283 | SW.StartEntity("REPRESENTATION_ITEM"); |
284 | // --- field : name --- |
285 | |
286 | SW.Send(ent->Name()); |
287 | |
288 | // --- Instance of plex componant Surface --- |
289 | |
290 | SW.StartEntity("SURFACE"); |
291 | } |
292 | |
293 | |
294 | void RWStepGeom_RWBezierSurfaceAndRationalBSplineSurface::Share(const Handle(StepGeom_BezierSurfaceAndRationalBSplineSurface)& ent, Interface_EntityIterator& iter) const |
295 | { |
296 | |
297 | Standard_Integer nbiElem1 = ent->NbControlPointsListI(); |
298 | Standard_Integer nbjElem1 = ent->NbControlPointsListJ(); |
299 | for (Standard_Integer is1=1; is1<=nbiElem1; is1 ++) { |
300 | for (Standard_Integer js1=1; js1<=nbjElem1; js1 ++) { |
301 | iter.GetOneItem(ent->ControlPointsListValue(is1,js1)); |
302 | } |
303 | } |
304 | |
305 | } |
306 | |