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_RWSurfaceCurve.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepGeom_Curve.hxx>
21 #include <StepGeom_HArray1OfPcurveOrSurface.hxx>
22 #include <StepGeom_PcurveOrSurface.hxx>
23 #include <StepGeom_PreferredSurfaceCurveRepresentation.hxx>
24 #include <StepGeom_SurfaceCurve.hxx>
25 #include <TCollection_AsciiString.hxx>
27 // --- Enum : PreferredSurfaceCurveRepresentation ---
28 static TCollection_AsciiString pscrPcurveS2(".PCURVE_S2.");
29 static TCollection_AsciiString pscrPcurveS1(".PCURVE_S1.");
30 static TCollection_AsciiString pscrCurve3d(".CURVE_3D.");
32 RWStepGeom_RWSurfaceCurve::RWStepGeom_RWSurfaceCurve () {}
34 void RWStepGeom_RWSurfaceCurve::ReadStep
35 (const Handle(StepData_StepReaderData)& data,
36 const Standard_Integer num,
37 Handle(Interface_Check)& ach,
38 const Handle(StepGeom_SurfaceCurve)& ent) const
42 // --- Number of Parameter Control ---
44 if (!data->CheckNbParams(num,4,ach,"surface_curve")) return;
46 // --- inherited field : name ---
48 Handle(TCollection_HAsciiString) aName;
49 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
50 data->ReadString (num,1,"name",ach,aName);
52 // --- own field : curve3d ---
54 Handle(StepGeom_Curve) aCurve3d;
55 //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
56 data->ReadEntity(num, 2,"curve_3d", ach, STANDARD_TYPE(StepGeom_Curve), aCurve3d);
58 // --- own field : associatedGeometry ---
60 Handle(StepGeom_HArray1OfPcurveOrSurface) aAssociatedGeometry;
61 StepGeom_PcurveOrSurface aAssociatedGeometryItem;
62 Standard_Integer nsub3;
63 if (data->ReadSubList (num,3,"associated_geometry",ach,nsub3)) {
64 Standard_Integer nb3 = data->NbParams(nsub3);
65 aAssociatedGeometry = new StepGeom_HArray1OfPcurveOrSurface (1, nb3);
66 for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
67 //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
68 if (data->ReadEntity (nsub3,i3,"associated_geometry",ach,aAssociatedGeometryItem))
69 aAssociatedGeometry->SetValue(i3,aAssociatedGeometryItem);
73 // --- own field : masterRepresentation ---
75 StepGeom_PreferredSurfaceCurveRepresentation aMasterRepresentation = StepGeom_pscrCurve3d;
76 if (data->ParamType(num,4) == Interface_ParamEnum) {
77 Standard_CString text = data->ParamCValue(num,4);
78 if (pscrPcurveS2.IsEqual(text)) aMasterRepresentation = StepGeom_pscrPcurveS2;
79 else if (pscrPcurveS1.IsEqual(text)) aMasterRepresentation = StepGeom_pscrPcurveS1;
80 else if (pscrCurve3d.IsEqual(text)) aMasterRepresentation = StepGeom_pscrCurve3d;
81 else ach->AddFail("Enumeration preferred_surface_curve_representation has not an allowed value");
83 else ach->AddFail("Parameter #4 (master_representation) is not an enumeration");
85 //--- Initialisation of the read entity ---
88 ent->Init(aName, aCurve3d, aAssociatedGeometry, aMasterRepresentation);
92 void RWStepGeom_RWSurfaceCurve::WriteStep
93 (StepData_StepWriter& SW,
94 const Handle(StepGeom_SurfaceCurve)& ent) const
97 // --- inherited field name ---
101 // --- own field : curve3d ---
103 SW.Send(ent->Curve3d());
105 // --- own field : associatedGeometry ---
108 for (Standard_Integer i3 = 1; i3 <= ent->NbAssociatedGeometry(); i3 ++) {
109 if (!ent->AssociatedGeometryValue(i3).Value().IsNull()) {
110 SW.Send(ent->AssociatedGeometryValue(i3).Value());
115 // --- own field : masterRepresentation ---
117 switch(ent->MasterRepresentation()) {
118 case StepGeom_pscrPcurveS2 : SW.SendEnum (pscrPcurveS2); break;
119 case StepGeom_pscrPcurveS1 : SW.SendEnum (pscrPcurveS1); break;
120 case StepGeom_pscrCurve3d : SW.SendEnum (pscrCurve3d); break;
125 void RWStepGeom_RWSurfaceCurve::Share(const Handle(StepGeom_SurfaceCurve)& ent, Interface_EntityIterator& iter) const
128 iter.GetOneItem(ent->Curve3d());
131 Standard_Integer nbElem2 = ent->NbAssociatedGeometry();
132 for (Standard_Integer is2=1; is2<=nbElem2; is2 ++) {
133 iter.GetOneItem(ent->AssociatedGeometryValue(is2).Value());