0033018: Coding - get rid of unused headers [Plugin to ShapeAnalysis]
[occt.git] / src / RWStepGeom / RWStepGeom_RWIntersectionCurve.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Interface_Check.hxx>
16 #include <Interface_EntityIterator.hxx>
17 #include <RWStepGeom_RWIntersectionCurve.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepGeom_IntersectionCurve.hxx>
21 #include <StepGeom_PcurveOrSurface.hxx>
22 #include <StepGeom_PreferredSurfaceCurveRepresentation.hxx>
23
24 // --- Enum : PreferredSurfaceCurveRepresentation ---
25 static TCollection_AsciiString pscrPcurveS2(".PCURVE_S2.");
26 static TCollection_AsciiString pscrPcurveS1(".PCURVE_S1.");
27 static TCollection_AsciiString pscrCurve3d(".CURVE_3D.");
28
29 RWStepGeom_RWIntersectionCurve::RWStepGeom_RWIntersectionCurve () {}
30
31 void RWStepGeom_RWIntersectionCurve::ReadStep
32         (const Handle(StepData_StepReaderData)& data,
33          const Standard_Integer num,
34          Handle(Interface_Check)& ach,
35          const Handle(StepGeom_IntersectionCurve)& ent) const
36 {
37
38
39         // --- Number of Parameter Control ---
40
41         if (!data->CheckNbParams(num,4,ach,"intersection_curve")) return;
42
43         // --- inherited field : name ---
44
45         Handle(TCollection_HAsciiString) aName;
46         //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
47         data->ReadString (num,1,"name",ach,aName);
48
49         // --- inherited field : curve3d ---
50
51         Handle(StepGeom_Curve) aCurve3d;
52         //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
53         data->ReadEntity(num, 2,"curve_3d", ach, STANDARD_TYPE(StepGeom_Curve), aCurve3d);
54
55         // --- inherited field : associatedGeometry ---
56
57         Handle(StepGeom_HArray1OfPcurveOrSurface) aAssociatedGeometry;
58         StepGeom_PcurveOrSurface aAssociatedGeometryItem;
59         Standard_Integer nsub3;
60         if (data->ReadSubList (num,3,"associated_geometry",ach,nsub3)) {
61           Standard_Integer nb3 = data->NbParams(nsub3);
62           aAssociatedGeometry = new StepGeom_HArray1OfPcurveOrSurface (1, nb3);
63           for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
64             //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
65             if (data->ReadEntity (nsub3,i3,"associated_geometry",ach,aAssociatedGeometryItem))
66               aAssociatedGeometry->SetValue(i3,aAssociatedGeometryItem);
67           }
68         }
69
70         // --- inherited field : masterRepresentation ---
71
72         StepGeom_PreferredSurfaceCurveRepresentation aMasterRepresentation = StepGeom_pscrCurve3d;
73         if (data->ParamType(num,4) == Interface_ParamEnum) {
74           Standard_CString text = data->ParamCValue(num,4);
75           if      (pscrPcurveS2.IsEqual(text)) aMasterRepresentation = StepGeom_pscrPcurveS2;
76           else if (pscrPcurveS1.IsEqual(text)) aMasterRepresentation = StepGeom_pscrPcurveS1;
77           else if (pscrCurve3d.IsEqual(text)) aMasterRepresentation = StepGeom_pscrCurve3d;
78           else ach->AddFail("Enumeration preferred_surface_curve_representation has not an allowed value");
79         }
80         else ach->AddFail("Parameter #4 (master_representation) is not an enumeration");
81
82         //--- Initialisation of the read entity ---
83
84
85         ent->Init(aName, aCurve3d, aAssociatedGeometry, aMasterRepresentation);
86 }
87
88
89 void RWStepGeom_RWIntersectionCurve::WriteStep
90         (StepData_StepWriter& SW,
91          const Handle(StepGeom_IntersectionCurve)& ent) const
92 {
93
94         // --- inherited field name ---
95
96         SW.Send(ent->Name());
97
98         // --- inherited field curve3d ---
99
100         SW.Send(ent->Curve3d());
101
102         // --- inherited field associatedGeometry ---
103
104         SW.OpenSub();
105         for (Standard_Integer i3 = 1;  i3 <= ent->NbAssociatedGeometry();  i3 ++) {
106           SW.Send(ent->AssociatedGeometryValue(i3).Value());
107         }
108         SW.CloseSub();
109
110         // --- inherited field masterRepresentation ---
111
112         switch(ent->MasterRepresentation()) {
113           case StepGeom_pscrPcurveS2 : SW.SendEnum (pscrPcurveS2); break;
114           case StepGeom_pscrPcurveS1 : SW.SendEnum (pscrPcurveS1); break;
115           case StepGeom_pscrCurve3d : SW.SendEnum (pscrCurve3d); break;
116         }
117 }
118
119
120 void RWStepGeom_RWIntersectionCurve::Share(const Handle(StepGeom_IntersectionCurve)& ent, Interface_EntityIterator& iter) const
121 {
122
123         iter.GetOneItem(ent->Curve3d());
124
125
126         Standard_Integer nbElem2 = ent->NbAssociatedGeometry();
127         for (Standard_Integer is2=1; is2<=nbElem2; is2 ++) {
128           iter.GetOneItem(ent->AssociatedGeometryValue(is2).Value());
129         }
130
131 }
132