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_RWQuasiUniformCurveAndRationalBSplineCurve.hxx> |
18 | #include <StepData_Logical.hxx> |
19 | #include <StepData_StepReaderData.hxx> |
20 | #include <StepData_StepWriter.hxx> |
21 | #include <StepGeom_BSplineCurveForm.hxx> |
22 | #include <StepGeom_CartesianPoint.hxx> |
23 | #include <StepGeom_HArray1OfCartesianPoint.hxx> |
24 | #include <StepGeom_QuasiUniformCurve.hxx> |
7fd59977 |
25 | #include <StepGeom_QuasiUniformCurveAndRationalBSplineCurve.hxx> |
42cf5bc1 |
26 | #include <StepGeom_RationalBSplineCurve.hxx> |
27 | #include <TColStd_HArray1OfReal.hxx> |
7fd59977 |
28 | |
b311480e |
29 | // --- Enum : BSplineCurveForm --- |
7fd59977 |
30 | static TCollection_AsciiString bscfEllipticArc(".ELLIPTIC_ARC."); |
31 | static TCollection_AsciiString bscfPolylineForm(".POLYLINE_FORM."); |
32 | static TCollection_AsciiString bscfParabolicArc(".PARABOLIC_ARC."); |
33 | static TCollection_AsciiString bscfCircularArc(".CIRCULAR_ARC."); |
34 | static TCollection_AsciiString bscfUnspecified(".UNSPECIFIED."); |
35 | static TCollection_AsciiString bscfHyperbolicArc(".HYPERBOLIC_ARC."); |
36 | |
37 | RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve::RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve () {} |
38 | |
39 | void RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve::ReadStep |
40 | (const Handle(StepData_StepReaderData)& data, |
41 | const Standard_Integer num0, |
42 | Handle(Interface_Check)& ach, |
43 | const Handle(StepGeom_QuasiUniformCurveAndRationalBSplineCurve)& ent) const |
44 | { |
45 | |
46 | Standard_Integer num = num0; |
47 | |
48 | |
49 | // --- Instance of plex componant BoundedCurve --- |
50 | |
51 | if (!data->CheckNbParams(num,0,ach,"bounded_curve")) return; |
52 | |
53 | num = data->NextForComplex(num); |
54 | |
55 | // --- Instance of common supertype BSplineCurve --- |
56 | |
57 | if (!data->CheckNbParams(num,5,ach,"b_spline_curve")) return; |
58 | // --- field : degree --- |
59 | |
60 | |
61 | Standard_Integer aDegree; |
62 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
63 | data->ReadInteger (num,1,"degree",ach,aDegree); |
64 | // --- field : controlPointsList --- |
65 | |
66 | |
67 | Handle(StepGeom_HArray1OfCartesianPoint) aControlPointsList; |
68 | Handle(StepGeom_CartesianPoint) anent2; |
69 | Standard_Integer nsub2; |
70 | if (data->ReadSubList (num,2,"control_points_list",ach,nsub2)) { |
71 | Standard_Integer nb2 = data->NbParams(nsub2); |
72 | aControlPointsList = new StepGeom_HArray1OfCartesianPoint (1, nb2); |
73 | for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) { |
74 | //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed |
75 | if (data->ReadEntity (nsub2, i2,"cartesian_point", ach, |
76 | STANDARD_TYPE(StepGeom_CartesianPoint), anent2)) |
77 | aControlPointsList->SetValue(i2, anent2); |
78 | } |
79 | } |
80 | |
81 | // --- field : curveForm --- |
82 | |
83 | |
84 | StepGeom_BSplineCurveForm aCurveForm = StepGeom_bscfPolylineForm; |
85 | if (data->ParamType(num,3) == Interface_ParamEnum) { |
86 | Standard_CString text = data->ParamCValue(num,3); |
87 | if (bscfEllipticArc.IsEqual(text)) aCurveForm = StepGeom_bscfEllipticArc; |
88 | else if (bscfPolylineForm.IsEqual(text)) aCurveForm = StepGeom_bscfPolylineForm; |
89 | else if (bscfParabolicArc.IsEqual(text)) aCurveForm = StepGeom_bscfParabolicArc; |
90 | else if (bscfCircularArc.IsEqual(text)) aCurveForm = StepGeom_bscfCircularArc; |
91 | else if (bscfUnspecified.IsEqual(text)) aCurveForm = StepGeom_bscfUnspecified; |
92 | else if (bscfHyperbolicArc.IsEqual(text)) aCurveForm = StepGeom_bscfHyperbolicArc; |
93 | else ach->AddFail("Enumeration b_spline_curve_form has not an allowed value"); |
94 | } |
95 | else ach->AddFail("Parameter #3 (curve_form) is not an enumeration"); |
96 | // --- field : closedCurve --- |
97 | |
98 | |
99 | StepData_Logical aClosedCurve; |
100 | //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed |
101 | data->ReadLogical (num,4,"closed_curve",ach,aClosedCurve); |
102 | // --- field : selfIntersect --- |
103 | |
104 | |
105 | StepData_Logical aSelfIntersect; |
106 | //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed |
107 | data->ReadLogical (num,5,"self_intersect",ach,aSelfIntersect); |
108 | |
109 | num = data->NextForComplex(num); |
110 | |
111 | // --- Instance of plex componant Curve --- |
112 | |
113 | if (!data->CheckNbParams(num,0,ach,"curve")) return; |
114 | |
115 | num = data->NextForComplex(num); |
116 | |
117 | // --- Instance of plex componant GeometricRepresentationItem --- |
118 | |
119 | if (!data->CheckNbParams(num,0,ach,"geometric_representation_item")) return; |
120 | |
121 | num = data->NextForComplex(num); |
122 | |
123 | // --- Instance of plex componant QuasiUniformCurve --- |
124 | |
125 | if (!data->CheckNbParams(num,0,ach,"quasi_uniform_curve")) return; |
126 | |
127 | num = data->NextForComplex(num); |
128 | |
129 | // --- Instance of plex componant RationalBSplineCurve --- |
130 | |
131 | if (!data->CheckNbParams(num,1,ach,"rational_b_spline_curve")) return; |
132 | |
133 | // --- field : weightsData --- |
134 | |
135 | Handle(TColStd_HArray1OfReal) aWeightsData; |
136 | Standard_Real aWeightsDataItem; |
137 | Standard_Integer nsub6; |
138 | if (data->ReadSubList (num,1,"weights_data",ach,nsub6)) { |
139 | Standard_Integer nb6 = data->NbParams(nsub6); |
140 | aWeightsData = new TColStd_HArray1OfReal (1, nb6); |
141 | for (Standard_Integer i6 = 1; i6 <= nb6; i6 ++) { |
142 | //szv#4:S4163:12Mar99 `Standard_Boolean stat6 =` not needed |
143 | if (data->ReadReal (nsub6,i6,"weights_data",ach,aWeightsDataItem)) |
144 | aWeightsData->SetValue(i6,aWeightsDataItem); |
145 | } |
146 | } |
147 | |
148 | num = data->NextForComplex(num); |
149 | |
150 | // --- Instance of plex componant RepresentationItem --- |
151 | |
152 | if (!data->CheckNbParams(num,1,ach,"representation_item")) return; |
153 | |
154 | // --- field : name --- |
155 | |
156 | Handle(TCollection_HAsciiString) aName; |
157 | //szv#4:S4163:12Mar99 `Standard_Boolean stat7 =` not needed |
158 | data->ReadString (num,1,"name",ach,aName); |
159 | |
160 | //--- Initialisation of the red entity --- |
161 | |
162 | ent->Init(aName,aDegree,aControlPointsList,aCurveForm,aClosedCurve,aSelfIntersect,aWeightsData); |
163 | } |
164 | |
165 | |
166 | void RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve::WriteStep |
167 | (StepData_StepWriter& SW, |
168 | const Handle(StepGeom_QuasiUniformCurveAndRationalBSplineCurve)& ent) const |
169 | { |
170 | |
171 | // --- Instance of plex componant BoundedCurve --- |
172 | |
173 | SW.StartEntity("BOUNDED_CURVE"); |
174 | |
175 | // --- Instance of common supertype BSplineCurve --- |
176 | |
177 | SW.StartEntity("B_SPLINE_CURVE"); |
178 | // --- field : degree --- |
179 | |
180 | SW.Send(ent->Degree()); |
181 | // --- field : controlPointsList --- |
182 | |
183 | SW.OpenSub(); |
184 | for (Standard_Integer i2 = 1; i2 <= ent->NbControlPointsList(); i2 ++) { |
185 | SW.Send(ent->ControlPointsListValue(i2)); |
186 | } |
187 | SW.CloseSub(); |
188 | // --- field : curveForm --- |
189 | |
190 | switch(ent->CurveForm()) { |
191 | case StepGeom_bscfEllipticArc : SW.SendEnum (bscfEllipticArc); break; |
192 | case StepGeom_bscfPolylineForm : SW.SendEnum (bscfPolylineForm); break; |
193 | case StepGeom_bscfParabolicArc : SW.SendEnum (bscfParabolicArc); break; |
194 | case StepGeom_bscfCircularArc : SW.SendEnum (bscfCircularArc); break; |
195 | case StepGeom_bscfUnspecified : SW.SendEnum (bscfUnspecified); break; |
196 | case StepGeom_bscfHyperbolicArc : SW.SendEnum (bscfHyperbolicArc); break; |
197 | } |
198 | // --- field : closedCurve --- |
199 | |
200 | SW.SendLogical(ent->ClosedCurve()); |
201 | // --- field : selfIntersect --- |
202 | |
203 | SW.SendLogical(ent->SelfIntersect()); |
204 | |
205 | // --- Instance of plex componant Curve --- |
206 | |
207 | SW.StartEntity("CURVE"); |
208 | |
209 | // --- Instance of plex componant GeometricRepresentationItem --- |
210 | |
211 | SW.StartEntity("GEOMETRIC_REPRESENTATION_ITEM"); |
212 | |
213 | // --- Instance of plex componant QuasiUniformCurve --- |
214 | |
215 | SW.StartEntity("QUASI_UNIFORM_CURVE"); |
216 | |
217 | // --- Instance of plex componant RationalBSplineCurve --- |
218 | |
219 | SW.StartEntity("RATIONAL_B_SPLINE_CURVE"); |
220 | // --- field : weightsData --- |
221 | |
222 | SW.OpenSub(); |
223 | for (Standard_Integer i6 = 1; i6 <= ent->NbWeightsData(); i6 ++) { |
224 | SW.Send(ent->WeightsDataValue(i6)); |
225 | } |
226 | SW.CloseSub(); |
227 | |
228 | // --- Instance of plex componant RepresentationItem --- |
229 | |
230 | SW.StartEntity("REPRESENTATION_ITEM"); |
231 | // --- field : name --- |
232 | |
233 | SW.Send(ent->Name()); |
234 | } |
235 | |
236 | |
237 | void RWStepGeom_RWQuasiUniformCurveAndRationalBSplineCurve::Share(const Handle(StepGeom_QuasiUniformCurveAndRationalBSplineCurve)& ent, Interface_EntityIterator& iter) const |
238 | { |
239 | |
240 | Standard_Integer nbElem1 = ent->NbControlPointsList(); |
241 | for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) { |
242 | iter.GetOneItem(ent->ControlPointsListValue(is1)); |
243 | } |
244 | |
245 | } |
246 | |