1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <Interface_Check.hxx>
16 #include <Interface_EntityIterator.hxx>
17 #include <RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface.hxx>
18 #include <StepData_Logical.hxx>
19 #include <StepData_StepReaderData.hxx>
20 #include <StepData_StepWriter.hxx>
21 #include <StepGeom_BSplineSurfaceForm.hxx>
22 #include <StepGeom_CartesianPoint.hxx>
23 #include <StepGeom_HArray2OfCartesianPoint.hxx>
24 #include <StepGeom_QuasiUniformSurface.hxx>
25 #include <StepGeom_QuasiUniformSurfaceAndRationalBSplineSurface.hxx>
26 #include <StepGeom_RationalBSplineSurface.hxx>
27 #include <TColStd_HArray2OfReal.hxx>
29 // --- Enum : BSplineSurfaceForm ---
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.");
42 RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface () {}
44 void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::ReadStep
45 (const Handle(StepData_StepReaderData)& data,
46 const Standard_Integer num0,
47 Handle(Interface_Check)& ach,
48 const Handle(StepGeom_QuasiUniformSurfaceAndRationalBSplineSurface)& ent) const
51 Standard_Integer num = num0;
54 // --- Instance of plex componant BoundedSurface ---
56 if (!data->CheckNbParams(num,0,ach,"bounded_surface")) return;
58 num = data->NextForComplex(num);
60 // --- Instance of common supertype BSplineSurface ---
62 if (!data->CheckNbParams(num,7,ach,"b_spline_surface")) return;
63 // --- field : uDegree ---
66 Standard_Integer aUDegree;
67 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
68 data->ReadInteger (num,1,"u_degree",ach,aUDegree);
69 // --- field : vDegree ---
72 Standard_Integer aVDegree;
73 //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
74 data->ReadInteger (num,2,"v_degree",ach,aVDegree);
75 // --- field : controlPointsList ---
78 Handle(StepGeom_HArray2OfCartesianPoint) aControlPointsList;
79 Handle(StepGeom_CartesianPoint) anent3;
80 Standard_Integer nsub3;
81 if (data->ReadSubList (num,3,"control_points_list",ach,nsub3)) {
82 Standard_Integer nbi3 = data->NbParams(nsub3);
83 Standard_Integer nbj3 = data->NbParams(data->ParamNumber(nsub3,1));
84 aControlPointsList = new StepGeom_HArray2OfCartesianPoint (1, nbi3, 1, nbj3);
85 for (Standard_Integer i3 = 1; i3 <= nbi3; i3 ++) {
86 Standard_Integer nsi3;
87 if (data->ReadSubList (nsub3,i3,"sub-part(control_points_list)",ach,nsi3)) {
88 for (Standard_Integer j3 =1; j3 <= nbj3; j3 ++) {
89 //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
90 if (data->ReadEntity (nsi3, j3,"cartesian_point", ach,
91 STANDARD_TYPE(StepGeom_CartesianPoint), anent3))
92 aControlPointsList->SetValue(i3, j3, anent3);
98 // --- field : surfaceForm ---
101 StepGeom_BSplineSurfaceForm aSurfaceForm = StepGeom_bssfPlaneSurf;
102 if (data->ParamType(num,4) == Interface_ParamEnum) {
103 Standard_CString text = data->ParamCValue(num,4);
104 if (bssfSurfOfLinearExtrusion.IsEqual(text)) aSurfaceForm = StepGeom_bssfSurfOfLinearExtrusion;
105 else if (bssfPlaneSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfPlaneSurf;
106 else if (bssfGeneralisedCone.IsEqual(text)) aSurfaceForm = StepGeom_bssfGeneralisedCone;
107 else if (bssfToroidalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfToroidalSurf;
108 else if (bssfConicalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfConicalSurf;
109 else if (bssfSphericalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfSphericalSurf;
110 else if (bssfUnspecified.IsEqual(text)) aSurfaceForm = StepGeom_bssfUnspecified;
111 else if (bssfRuledSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfRuledSurf;
112 else if (bssfSurfOfRevolution.IsEqual(text)) aSurfaceForm = StepGeom_bssfSurfOfRevolution;
113 else if (bssfCylindricalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfCylindricalSurf;
114 else if (bssfQuadricSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfQuadricSurf;
115 else ach->AddFail("Enumeration b_spline_surface_form has not an allowed value");
117 else ach->AddFail("Parameter #4 (surface_form) is not an enumeration");
118 // --- field : uClosed ---
121 StepData_Logical aUClosed;
122 //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed
123 data->ReadLogical (num,5,"u_closed",ach,aUClosed);
124 // --- field : vClosed ---
127 StepData_Logical aVClosed;
128 //szv#4:S4163:12Mar99 `Standard_Boolean stat6 =` not needed
129 data->ReadLogical (num,6,"v_closed",ach,aVClosed);
130 // --- field : selfIntersect ---
133 StepData_Logical aSelfIntersect;
134 //szv#4:S4163:12Mar99 `Standard_Boolean stat7 =` not needed
135 data->ReadLogical (num,7,"self_intersect",ach,aSelfIntersect);
137 num = data->NextForComplex(num);
139 // --- Instance of plex componant GeometricRepresentationItem ---
141 if (!data->CheckNbParams(num,0,ach,"geometric_representation_item")) return;
143 num = data->NextForComplex(num);
145 // --- Instance of plex componant QuasiUniformSurface ---
147 if (!data->CheckNbParams(num,0,ach,"quasi_uniform_surface")) return;
149 num = data->NextForComplex(num);
151 // --- Instance of plex componant RationalBSplineSurface ---
153 if (!data->CheckNbParams(num,1,ach,"rational_b_spline_surface")) return;
155 // --- field : weightsData ---
157 Handle(TColStd_HArray2OfReal) aWeightsData;
158 Standard_Real aWeightsDataItem;
159 Standard_Integer nsub8;
160 if (data->ReadSubList (num,1,"weights_data",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);
176 num = data->NextForComplex(num);
178 // --- Instance of plex componant RepresentationItem ---
180 if (!data->CheckNbParams(num,1,ach,"representation_item")) return;
182 // --- field : name ---
184 Handle(TCollection_HAsciiString) aName;
185 //szv#4:S4163:12Mar99 `Standard_Boolean stat9 =` not needed
186 data->ReadString (num,1,"name",ach,aName);
188 num = data->NextForComplex(num);
190 // --- Instance of plex componant Surface ---
192 if (!data->CheckNbParams(num,0,ach,"surface")) return;
194 //--- Initialisation of the red entity ---
196 ent->Init(aName,aUDegree,aVDegree,aControlPointsList,aSurfaceForm,aUClosed,aVClosed,aSelfIntersect,aWeightsData);
200 void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::WriteStep
201 (StepData_StepWriter& SW,
202 const Handle(StepGeom_QuasiUniformSurfaceAndRationalBSplineSurface)& ent) const
205 // --- Instance of plex componant BoundedSurface ---
207 SW.StartEntity("BOUNDED_SURFACE");
209 // --- Instance of common supertype BSplineSurface ---
211 SW.StartEntity("B_SPLINE_SURFACE");
212 // --- field : uDegree ---
214 SW.Send(ent->UDegree());
215 // --- field : vDegree ---
217 SW.Send(ent->VDegree());
218 // --- field : controlPointsList ---
221 for (Standard_Integer i3 = 1; i3 <= ent->NbControlPointsListI(); i3 ++) {
222 SW.NewLine(Standard_False);
224 for (Standard_Integer j3 = 1; j3 <= ent->NbControlPointsListJ(); j3 ++) {
225 SW.Send(ent->ControlPointsListValue(i3,j3));
226 SW.JoinLast(Standard_False);
231 // --- field : surfaceForm ---
233 switch(ent->SurfaceForm()) {
234 case StepGeom_bssfSurfOfLinearExtrusion : SW.SendEnum (bssfSurfOfLinearExtrusion); break;
235 case StepGeom_bssfPlaneSurf : SW.SendEnum (bssfPlaneSurf); break;
236 case StepGeom_bssfGeneralisedCone : SW.SendEnum (bssfGeneralisedCone); break;
237 case StepGeom_bssfToroidalSurf : SW.SendEnum (bssfToroidalSurf); break;
238 case StepGeom_bssfConicalSurf : SW.SendEnum (bssfConicalSurf); break;
239 case StepGeom_bssfSphericalSurf : SW.SendEnum (bssfSphericalSurf); break;
240 case StepGeom_bssfUnspecified : SW.SendEnum (bssfUnspecified); break;
241 case StepGeom_bssfRuledSurf : SW.SendEnum (bssfRuledSurf); break;
242 case StepGeom_bssfSurfOfRevolution : SW.SendEnum (bssfSurfOfRevolution); break;
243 case StepGeom_bssfCylindricalSurf : SW.SendEnum (bssfCylindricalSurf); break;
244 case StepGeom_bssfQuadricSurf : SW.SendEnum (bssfQuadricSurf); break;
246 // --- field : uClosed ---
248 SW.SendLogical(ent->UClosed());
249 // --- field : vClosed ---
251 SW.SendLogical(ent->VClosed());
252 // --- field : selfIntersect ---
254 SW.SendLogical(ent->SelfIntersect());
256 // --- Instance of plex componant GeometricRepresentationItem ---
258 SW.StartEntity("GEOMETRIC_REPRESENTATION_ITEM");
260 // --- Instance of plex componant QuasiUniformSurface ---
262 SW.StartEntity("QUASI_UNIFORM_SURFACE");
264 // --- Instance of plex componant RationalBSplineSurface ---
266 SW.StartEntity("RATIONAL_B_SPLINE_SURFACE");
267 // --- field : weightsData ---
270 for (Standard_Integer i8 = 1; i8 <= ent->NbWeightsDataI(); i8 ++) {
271 SW.NewLine(Standard_False);
273 for (Standard_Integer j8 = 1; j8 <= ent->NbWeightsDataJ(); j8 ++) {
274 SW.Send(ent->WeightsDataValue(i8,j8));
275 SW.JoinLast(Standard_False);
281 // --- Instance of plex componant RepresentationItem ---
283 SW.StartEntity("REPRESENTATION_ITEM");
284 // --- field : name ---
286 SW.Send(ent->Name());
288 // --- Instance of plex componant Surface ---
290 SW.StartEntity("SURFACE");
294 void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::Share(const Handle(StepGeom_QuasiUniformSurfaceAndRationalBSplineSurface)& ent, Interface_EntityIterator& iter) const
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));