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