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_RWBezierCurve.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepGeom_BezierCurve.hxx>
21 #include <StepGeom_BSplineCurveForm.hxx>
22 #include <StepGeom_CartesianPoint.hxx>
23 #include <StepGeom_HArray1OfCartesianPoint.hxx>
25 // --- Enum : BSplineCurveForm ---
26 static TCollection_AsciiString bscfEllipticArc(".ELLIPTIC_ARC.");
27 static TCollection_AsciiString bscfPolylineForm(".POLYLINE_FORM.");
28 static TCollection_AsciiString bscfParabolicArc(".PARABOLIC_ARC.");
29 static TCollection_AsciiString bscfCircularArc(".CIRCULAR_ARC.");
30 static TCollection_AsciiString bscfUnspecified(".UNSPECIFIED.");
31 static TCollection_AsciiString bscfHyperbolicArc(".HYPERBOLIC_ARC.");
33 RWStepGeom_RWBezierCurve::RWStepGeom_RWBezierCurve () {}
35 void RWStepGeom_RWBezierCurve::ReadStep
36 (const Handle(StepData_StepReaderData)& data,
37 const Standard_Integer num,
38 Handle(Interface_Check)& ach,
39 const Handle(StepGeom_BezierCurve)& ent) const
43 // --- Number of Parameter Control ---
45 if (!data->CheckNbParams(num,6,ach,"bezier_curve")) return;
47 // --- inherited field : name ---
49 Handle(TCollection_HAsciiString) aName;
50 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
51 data->ReadString (num,1,"name",ach,aName);
53 // --- inherited field : degree ---
55 Standard_Integer aDegree;
56 //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
57 data->ReadInteger (num,2,"degree",ach,aDegree);
59 // --- inherited field : controlPointsList ---
61 Handle(StepGeom_HArray1OfCartesianPoint) aControlPointsList;
62 Handle(StepGeom_CartesianPoint) anent3;
63 Standard_Integer nsub3;
64 if (data->ReadSubList (num,3,"control_points_list",ach,nsub3)) {
65 Standard_Integer nb3 = data->NbParams(nsub3);
66 aControlPointsList = new StepGeom_HArray1OfCartesianPoint (1, nb3);
67 for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
68 //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
69 if (data->ReadEntity (nsub3, i3,"cartesian_point", ach,
70 STANDARD_TYPE(StepGeom_CartesianPoint), anent3))
71 aControlPointsList->SetValue(i3, anent3);
75 // --- inherited field : curveForm ---
77 StepGeom_BSplineCurveForm aCurveForm = StepGeom_bscfPolylineForm;
78 if (data->ParamType(num,4) == Interface_ParamEnum) {
79 Standard_CString text = data->ParamCValue(num,4);
80 if (bscfEllipticArc.IsEqual(text)) aCurveForm = StepGeom_bscfEllipticArc;
81 else if (bscfPolylineForm.IsEqual(text)) aCurveForm = StepGeom_bscfPolylineForm;
82 else if (bscfParabolicArc.IsEqual(text)) aCurveForm = StepGeom_bscfParabolicArc;
83 else if (bscfCircularArc.IsEqual(text)) aCurveForm = StepGeom_bscfCircularArc;
84 else if (bscfUnspecified.IsEqual(text)) aCurveForm = StepGeom_bscfUnspecified;
85 else if (bscfHyperbolicArc.IsEqual(text)) aCurveForm = StepGeom_bscfHyperbolicArc;
86 else ach->AddFail("Enumeration b_spline_curve_form has not an allowed value");
88 else ach->AddFail("Parameter #4 (curve_form) is not an enumeration");
90 // --- inherited field : closedCurve ---
92 StepData_Logical aClosedCurve;
93 //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed
94 data->ReadLogical (num,5,"closed_curve",ach,aClosedCurve);
96 // --- inherited field : selfIntersect ---
98 StepData_Logical aSelfIntersect;
99 //szv#4:S4163:12Mar99 `Standard_Boolean stat6 =` not needed
100 data->ReadLogical (num,6,"self_intersect",ach,aSelfIntersect);
102 //--- Initialisation of the read entity ---
105 ent->Init(aName, aDegree, aControlPointsList, aCurveForm, aClosedCurve, aSelfIntersect);
109 void RWStepGeom_RWBezierCurve::WriteStep
110 (StepData_StepWriter& SW,
111 const Handle(StepGeom_BezierCurve)& ent) const
114 // --- inherited field name ---
116 SW.Send(ent->Name());
118 // --- inherited field degree ---
120 SW.Send(ent->Degree());
122 // --- inherited field controlPointsList ---
125 for (Standard_Integer i3 = 1; i3 <= ent->NbControlPointsList(); i3 ++) {
126 SW.Send(ent->ControlPointsListValue(i3));
130 // --- inherited field curveForm ---
132 switch(ent->CurveForm()) {
133 case StepGeom_bscfEllipticArc : SW.SendEnum (bscfEllipticArc); break;
134 case StepGeom_bscfPolylineForm : SW.SendEnum (bscfPolylineForm); break;
135 case StepGeom_bscfParabolicArc : SW.SendEnum (bscfParabolicArc); break;
136 case StepGeom_bscfCircularArc : SW.SendEnum (bscfCircularArc); break;
137 case StepGeom_bscfUnspecified : SW.SendEnum (bscfUnspecified); break;
138 case StepGeom_bscfHyperbolicArc : SW.SendEnum (bscfHyperbolicArc); break;
141 // --- inherited field closedCurve ---
143 SW.SendLogical(ent->ClosedCurve());
145 // --- inherited field selfIntersect ---
147 SW.SendLogical(ent->SelfIntersect());
151 void RWStepGeom_RWBezierCurve::Share(const Handle(StepGeom_BezierCurve)& ent, Interface_EntityIterator& iter) const
154 Standard_Integer nbElem1 = ent->NbControlPointsList();
155 for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) {
156 iter.GetOneItem(ent->ControlPointsListValue(is1));