0033018: Coding - get rid of unused headers [Plugin to ShapeAnalysis]
[occt.git] / src / RWStepGeom / RWStepGeom_RWBezierSurface.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Interface_Check.hxx>
16 #include <Interface_EntityIterator.hxx>
17 #include <RWStepGeom_RWBezierSurface.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepGeom_BezierSurface.hxx>
21 #include <StepGeom_BSplineSurfaceForm.hxx>
22 #include <StepGeom_CartesianPoint.hxx>
23 #include <StepGeom_HArray2OfCartesianPoint.hxx>
24
25 // --- Enum : BSplineSurfaceForm ---
26 static TCollection_AsciiString bssfSurfOfLinearExtrusion(".SURF_OF_LINEAR_EXTRUSION.");
27 static TCollection_AsciiString bssfPlaneSurf(".PLANE_SURF.");
28 static TCollection_AsciiString bssfGeneralisedCone(".GENERALISED_CONE.");
29 static TCollection_AsciiString bssfToroidalSurf(".TOROIDAL_SURF.");
30 static TCollection_AsciiString bssfConicalSurf(".CONICAL_SURF.");
31 static TCollection_AsciiString bssfSphericalSurf(".SPHERICAL_SURF.");
32 static TCollection_AsciiString bssfUnspecified(".UNSPECIFIED.");
33 static TCollection_AsciiString bssfRuledSurf(".RULED_SURF.");
34 static TCollection_AsciiString bssfSurfOfRevolution(".SURF_OF_REVOLUTION.");
35 static TCollection_AsciiString bssfCylindricalSurf(".CYLINDRICAL_SURF.");
36 static TCollection_AsciiString bssfQuadricSurf(".QUADRIC_SURF.");
37
38 RWStepGeom_RWBezierSurface::RWStepGeom_RWBezierSurface () {}
39
40 void RWStepGeom_RWBezierSurface::ReadStep
41         (const Handle(StepData_StepReaderData)& data,
42          const Standard_Integer num,
43          Handle(Interface_Check)& ach,
44          const Handle(StepGeom_BezierSurface)& ent) const
45 {
46
47
48         // --- Number of Parameter Control ---
49
50         if (!data->CheckNbParams(num,8,ach,"bezier_surface")) return;
51
52         // --- inherited field : name ---
53
54         Handle(TCollection_HAsciiString) aName;
55         //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
56         data->ReadString (num,1,"name",ach,aName);
57
58         // --- inherited field : uDegree ---
59
60         Standard_Integer aUDegree;
61         //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
62         data->ReadInteger (num,2,"u_degree",ach,aUDegree);
63
64         // --- inherited field : vDegree ---
65
66         Standard_Integer aVDegree;
67         //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
68         data->ReadInteger (num,3,"v_degree",ach,aVDegree);
69
70         // --- inherited field : controlPointsList ---
71
72         Handle(StepGeom_HArray2OfCartesianPoint) aControlPointsList;
73         Handle(StepGeom_CartesianPoint) anent4;
74         Standard_Integer nsub4;
75         if (data->ReadSubList (num,4,"control_points_list",ach,nsub4)) {
76           Standard_Integer nbi4 = data->NbParams(nsub4);
77           Standard_Integer nbj4 = data->NbParams(data->ParamNumber(nsub4,1));
78           aControlPointsList = new StepGeom_HArray2OfCartesianPoint (1, nbi4, 1, nbj4);
79           for (Standard_Integer i4 = 1; i4 <= nbi4; i4 ++) {
80             Standard_Integer nsi4;
81             if (data->ReadSubList (nsub4,i4,"sub-part(control_points_list)",ach,nsi4)) {
82               for (Standard_Integer j4 =1; j4 <= nbj4; j4 ++) {
83                 //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed
84                 if (data->ReadEntity (nsi4, j4,"cartesian_point", ach,
85                                       STANDARD_TYPE(StepGeom_CartesianPoint), anent4))
86                   aControlPointsList->SetValue(i4, j4, anent4);
87               }
88             }
89           }
90         }
91
92         // --- inherited field : surfaceForm ---
93
94         StepGeom_BSplineSurfaceForm aSurfaceForm = StepGeom_bssfPlaneSurf;
95         if (data->ParamType(num,5) == Interface_ParamEnum) {
96           Standard_CString text = data->ParamCValue(num,5);
97           if      (bssfSurfOfLinearExtrusion.IsEqual(text)) aSurfaceForm = StepGeom_bssfSurfOfLinearExtrusion;
98           else if (bssfPlaneSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfPlaneSurf;
99           else if (bssfGeneralisedCone.IsEqual(text)) aSurfaceForm = StepGeom_bssfGeneralisedCone;
100           else if (bssfToroidalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfToroidalSurf;
101           else if (bssfConicalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfConicalSurf;
102           else if (bssfSphericalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfSphericalSurf;
103           else if (bssfUnspecified.IsEqual(text)) aSurfaceForm = StepGeom_bssfUnspecified;
104           else if (bssfRuledSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfRuledSurf;
105           else if (bssfSurfOfRevolution.IsEqual(text)) aSurfaceForm = StepGeom_bssfSurfOfRevolution;
106           else if (bssfCylindricalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfCylindricalSurf;
107           else if (bssfQuadricSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfQuadricSurf;
108           else ach->AddFail("Enumeration b_spline_surface_form has not an allowed value");
109         }
110         else ach->AddFail("Parameter #5 (surface_form) is not an enumeration");
111
112         // --- inherited field : uClosed ---
113
114         StepData_Logical aUClosed;
115         //szv#4:S4163:12Mar99 `Standard_Boolean stat6 =` not needed
116         data->ReadLogical (num,6,"u_closed",ach,aUClosed);
117
118         // --- inherited field : vClosed ---
119
120         StepData_Logical aVClosed;
121         //szv#4:S4163:12Mar99 `Standard_Boolean stat7 =` not needed
122         data->ReadLogical (num,7,"v_closed",ach,aVClosed);
123
124         // --- inherited field : selfIntersect ---
125
126         StepData_Logical aSelfIntersect;
127         //szv#4:S4163:12Mar99 `Standard_Boolean stat8 =` not needed
128         data->ReadLogical (num,8,"self_intersect",ach,aSelfIntersect);
129
130         //--- Initialisation of the read entity ---
131
132
133         ent->Init(aName, aUDegree, aVDegree, aControlPointsList, aSurfaceForm, aUClosed, aVClosed, aSelfIntersect);
134 }
135
136
137 void RWStepGeom_RWBezierSurface::WriteStep
138         (StepData_StepWriter& SW,
139          const Handle(StepGeom_BezierSurface)& ent) const
140 {
141
142         // --- inherited field name ---
143
144         SW.Send(ent->Name());
145
146         // --- inherited field uDegree ---
147
148         SW.Send(ent->UDegree());
149
150         // --- inherited field vDegree ---
151
152         SW.Send(ent->VDegree());
153
154         // --- inherited field controlPointsList ---
155
156         SW.OpenSub();
157         for (Standard_Integer i4 = 1;  i4 <= ent->NbControlPointsListI(); i4 ++) {
158           SW.NewLine(Standard_False);
159           SW.OpenSub();
160           for (Standard_Integer j4 = 1;  j4 <= ent->NbControlPointsListJ(); j4 ++) {
161             SW.Send(ent->ControlPointsListValue(i4,j4));
162             SW.JoinLast(Standard_False);
163           }
164           SW.CloseSub();
165         }
166         SW.CloseSub();
167
168         // --- inherited field surfaceForm ---
169
170         switch(ent->SurfaceForm()) {
171           case StepGeom_bssfSurfOfLinearExtrusion : SW.SendEnum (bssfSurfOfLinearExtrusion); break;
172           case StepGeom_bssfPlaneSurf : SW.SendEnum (bssfPlaneSurf); break;
173           case StepGeom_bssfGeneralisedCone : SW.SendEnum (bssfGeneralisedCone); break;
174           case StepGeom_bssfToroidalSurf : SW.SendEnum (bssfToroidalSurf); break;
175           case StepGeom_bssfConicalSurf : SW.SendEnum (bssfConicalSurf); break;
176           case StepGeom_bssfSphericalSurf : SW.SendEnum (bssfSphericalSurf); break;
177           case StepGeom_bssfUnspecified : SW.SendEnum (bssfUnspecified); break;
178           case StepGeom_bssfRuledSurf : SW.SendEnum (bssfRuledSurf); break;
179           case StepGeom_bssfSurfOfRevolution : SW.SendEnum (bssfSurfOfRevolution); break;
180           case StepGeom_bssfCylindricalSurf : SW.SendEnum (bssfCylindricalSurf); break;
181           case StepGeom_bssfQuadricSurf : SW.SendEnum (bssfQuadricSurf); break;
182         }
183
184         // --- inherited field uClosed ---
185
186         SW.SendLogical(ent->UClosed());
187
188         // --- inherited field vClosed ---
189
190         SW.SendLogical(ent->VClosed());
191
192         // --- inherited field selfIntersect ---
193
194         SW.SendLogical(ent->SelfIntersect());
195 }
196
197
198 void RWStepGeom_RWBezierSurface::Share(const Handle(StepGeom_BezierSurface)& ent, Interface_EntityIterator& iter) const
199 {
200
201         Standard_Integer nbiElem1 = ent->NbControlPointsListI();
202         Standard_Integer nbjElem1 = ent->NbControlPointsListJ();
203         for (Standard_Integer is1=1; is1<=nbiElem1; is1 ++) {
204           for (Standard_Integer js1=1; js1<=nbjElem1; js1 ++) {
205             iter.GetOneItem(ent->ControlPointsListValue(is1,js1));
206           }
207         }
208
209 }
210