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_RWBSplineCurve.hxx> |
18 | #include <StepData_Logical.hxx> |
19 | #include <StepData_StepReaderData.hxx> |
20 | #include <StepData_StepWriter.hxx> |
7fd59977 |
21 | #include <StepGeom_BSplineCurve.hxx> |
42cf5bc1 |
22 | #include <StepGeom_BSplineCurveForm.hxx> |
23 | #include <StepGeom_CartesianPoint.hxx> |
24 | #include <StepGeom_HArray1OfCartesianPoint.hxx> |
7fd59977 |
25 | #include <TCollection_AsciiString.hxx> |
26 | |
b311480e |
27 | // --- Enum : BSplineCurveForm --- |
7fd59977 |
28 | static TCollection_AsciiString bscfEllipticArc(".ELLIPTIC_ARC."); |
29 | static TCollection_AsciiString bscfPolylineForm(".POLYLINE_FORM."); |
30 | static TCollection_AsciiString bscfParabolicArc(".PARABOLIC_ARC."); |
31 | static TCollection_AsciiString bscfCircularArc(".CIRCULAR_ARC."); |
32 | static TCollection_AsciiString bscfUnspecified(".UNSPECIFIED."); |
33 | static TCollection_AsciiString bscfHyperbolicArc(".HYPERBOLIC_ARC."); |
34 | |
35 | RWStepGeom_RWBSplineCurve::RWStepGeom_RWBSplineCurve () {} |
36 | |
37 | void RWStepGeom_RWBSplineCurve::ReadStep |
38 | (const Handle(StepData_StepReaderData)& data, |
39 | const Standard_Integer num, |
40 | Handle(Interface_Check)& ach, |
41 | const Handle(StepGeom_BSplineCurve)& ent) const |
42 | { |
43 | |
44 | |
45 | // --- Number of Parameter Control --- |
46 | |
47 | if (!data->CheckNbParams(num,6,ach,"b_spline_curve")) return; |
48 | |
49 | // --- inherited field : name --- |
50 | |
51 | Handle(TCollection_HAsciiString) aName; |
52 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
53 | data->ReadString (num,1,"name",ach,aName); |
54 | |
55 | // --- own field : degree --- |
56 | |
57 | Standard_Integer aDegree; |
58 | //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed |
59 | data->ReadInteger (num,2,"degree",ach,aDegree); |
60 | |
61 | // --- own field : controlPointsList --- |
62 | |
63 | Handle(StepGeom_HArray1OfCartesianPoint) aControlPointsList; |
64 | Handle(StepGeom_CartesianPoint) anent3; |
65 | Standard_Integer nsub3; |
66 | if (data->ReadSubList (num,3,"control_points_list",ach,nsub3)) { |
67 | Standard_Integer nb3 = data->NbParams(nsub3); |
68 | aControlPointsList = new StepGeom_HArray1OfCartesianPoint (1, nb3); |
69 | for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) { |
70 | //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed |
71 | if (data->ReadEntity (nsub3, i3,"cartesian_point", ach, |
72 | STANDARD_TYPE(StepGeom_CartesianPoint), anent3)) |
73 | aControlPointsList->SetValue(i3, anent3); |
74 | } |
75 | } |
76 | |
77 | // --- own field : curveForm --- |
78 | |
79 | StepGeom_BSplineCurveForm aCurveForm = StepGeom_bscfPolylineForm; |
80 | if (data->ParamType(num,4) == Interface_ParamEnum) { |
81 | Standard_CString text = data->ParamCValue(num,4); |
82 | if (bscfEllipticArc.IsEqual(text)) aCurveForm = StepGeom_bscfEllipticArc; |
83 | else if (bscfPolylineForm.IsEqual(text)) aCurveForm = StepGeom_bscfPolylineForm; |
84 | else if (bscfParabolicArc.IsEqual(text)) aCurveForm = StepGeom_bscfParabolicArc; |
85 | else if (bscfCircularArc.IsEqual(text)) aCurveForm = StepGeom_bscfCircularArc; |
86 | else if (bscfUnspecified.IsEqual(text)) aCurveForm = StepGeom_bscfUnspecified; |
87 | else if (bscfHyperbolicArc.IsEqual(text)) aCurveForm = StepGeom_bscfHyperbolicArc; |
88 | else ach->AddFail("Enumeration b_spline_curve_form has not an allowed value"); |
89 | } |
90 | else ach->AddFail("Parameter #4 (curve_form) is not an enumeration"); |
91 | |
92 | // --- own field : closedCurve --- |
93 | |
94 | StepData_Logical aClosedCurve; |
95 | //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed |
96 | data->ReadLogical (num,5,"closed_curve",ach,aClosedCurve); |
97 | |
98 | // --- own field : selfIntersect --- |
99 | |
100 | StepData_Logical aSelfIntersect; |
101 | //szv#4:S4163:12Mar99 `Standard_Boolean stat6 =` not needed |
102 | data->ReadLogical (num,6,"self_intersect",ach,aSelfIntersect); |
103 | |
104 | //--- Initialisation of the read entity --- |
105 | |
106 | |
107 | ent->Init(aName, aDegree, aControlPointsList, aCurveForm, aClosedCurve, aSelfIntersect); |
108 | } |
109 | |
110 | |
111 | void RWStepGeom_RWBSplineCurve::WriteStep |
112 | (StepData_StepWriter& SW, |
113 | const Handle(StepGeom_BSplineCurve)& ent) const |
114 | { |
115 | |
116 | // --- inherited field name --- |
117 | |
118 | SW.Send(ent->Name()); |
119 | |
120 | // --- own field : degree --- |
121 | |
122 | SW.Send(ent->Degree()); |
123 | |
124 | // --- own field : controlPointsList --- |
125 | |
126 | SW.OpenSub(); |
127 | for (Standard_Integer i3 = 1; i3 <= ent->NbControlPointsList(); i3 ++) { |
128 | SW.Send(ent->ControlPointsListValue(i3)); |
129 | } |
130 | SW.CloseSub(); |
131 | |
132 | // --- own field : curveForm --- |
133 | |
134 | switch(ent->CurveForm()) { |
135 | case StepGeom_bscfEllipticArc : SW.SendEnum (bscfEllipticArc); break; |
136 | case StepGeom_bscfPolylineForm : SW.SendEnum (bscfPolylineForm); break; |
137 | case StepGeom_bscfParabolicArc : SW.SendEnum (bscfParabolicArc); break; |
138 | case StepGeom_bscfCircularArc : SW.SendEnum (bscfCircularArc); break; |
139 | case StepGeom_bscfUnspecified : SW.SendEnum (bscfUnspecified); break; |
140 | case StepGeom_bscfHyperbolicArc : SW.SendEnum (bscfHyperbolicArc); break; |
141 | } |
142 | |
143 | // --- own field : closedCurve --- |
144 | |
145 | SW.SendLogical(ent->ClosedCurve()); |
146 | |
147 | // --- own field : selfIntersect --- |
148 | |
149 | SW.SendLogical(ent->SelfIntersect()); |
150 | } |
151 | |
152 | |
153 | void RWStepGeom_RWBSplineCurve::Share(const Handle(StepGeom_BSplineCurve)& ent, Interface_EntityIterator& iter) const |
154 | { |
155 | |
156 | Standard_Integer nbElem1 = ent->NbControlPointsList(); |
157 | for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) { |
158 | iter.GetOneItem(ent->ControlPointsListValue(is1)); |
159 | } |
160 | |
161 | } |
162 | |