0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / RWStepGeom / RWStepGeom_RWSurfaceCurve.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_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>
26
27 // --- Enum : PreferredSurfaceCurveRepresentation ---
28 static TCollection_AsciiString pscrPcurveS2(".PCURVE_S2.");
29 static TCollection_AsciiString pscrPcurveS1(".PCURVE_S1.");
30 static TCollection_AsciiString pscrCurve3d(".CURVE_3D.");
31
32 RWStepGeom_RWSurfaceCurve::RWStepGeom_RWSurfaceCurve () {}
33
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
39 {
40
41
42         // --- Number of Parameter Control ---
43
44         if (!data->CheckNbParams(num,4,ach,"surface_curve")) return;
45
46         // --- inherited field : name ---
47
48         Handle(TCollection_HAsciiString) aName;
49         //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
50         data->ReadString (num,1,"name",ach,aName);
51
52         // --- own field : curve3d ---
53
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);
57
58         // --- own field : associatedGeometry ---
59
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);
70           }
71         }
72
73         // --- own field : masterRepresentation ---
74
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");
82         }
83         else ach->AddFail("Parameter #4 (master_representation) is not an enumeration");
84
85         //--- Initialisation of the read entity ---
86
87
88         ent->Init(aName, aCurve3d, aAssociatedGeometry, aMasterRepresentation);
89 }
90
91
92 void RWStepGeom_RWSurfaceCurve::WriteStep
93         (StepData_StepWriter& SW,
94          const Handle(StepGeom_SurfaceCurve)& ent) const
95 {
96
97         // --- inherited field name ---
98
99         SW.Send(ent->Name());
100
101         // --- own field : curve3d ---
102
103         SW.Send(ent->Curve3d());
104
105         // --- own field : associatedGeometry ---
106
107         SW.OpenSub();
108         for (Standard_Integer i3 = 1;  i3 <= ent->NbAssociatedGeometry();  i3 ++) {
109           if (!ent->AssociatedGeometryValue(i3).Value().IsNull()) {
110             SW.Send(ent->AssociatedGeometryValue(i3).Value());
111           }
112         }
113         SW.CloseSub();
114
115         // --- own field : masterRepresentation ---
116
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;
121         }
122 }
123
124
125 void RWStepGeom_RWSurfaceCurve::Share(const Handle(StepGeom_SurfaceCurve)& ent, Interface_EntityIterator& iter) const
126 {
127
128         iter.GetOneItem(ent->Curve3d());
129
130
131         Standard_Integer nbElem2 = ent->NbAssociatedGeometry();
132         for (Standard_Integer is2=1; is2<=nbElem2; is2 ++) {
133           iter.GetOneItem(ent->AssociatedGeometryValue(is2).Value());
134         }
135
136 }
137