0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / RWStepVisual / RWStepVisual_RWSurfaceStyleUsage.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 <RWStepVisual_RWSurfaceStyleUsage.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepVisual_SurfaceSide.hxx>
21 #include <StepVisual_SurfaceSideStyle.hxx>
22 #include <StepVisual_SurfaceStyleUsage.hxx>
23 #include <TCollection_AsciiString.hxx>
24
25 // --- Enum : SurfaceSide ---
26 static TCollection_AsciiString ssNegative(".NEGATIVE.");
27 static TCollection_AsciiString ssPositive(".POSITIVE.");
28 static TCollection_AsciiString ssBoth(".BOTH.");
29
30 RWStepVisual_RWSurfaceStyleUsage::RWStepVisual_RWSurfaceStyleUsage () {}
31
32 void RWStepVisual_RWSurfaceStyleUsage::ReadStep
33         (const Handle(StepData_StepReaderData)& data,
34          const Standard_Integer num,
35          Handle(Interface_Check)& ach,
36          const Handle(StepVisual_SurfaceStyleUsage)& ent) const
37 {
38
39
40         // --- Number of Parameter Control ---
41
42         if (!data->CheckNbParams(num,2,ach,"surface_style_usage")) return;
43
44         // --- own field : side ---
45
46         StepVisual_SurfaceSide aSide = StepVisual_ssNegative;
47         if (data->ParamType(num,1) == Interface_ParamEnum) {
48           Standard_CString text = data->ParamCValue(num,1);
49           if      (ssNegative.IsEqual(text)) aSide = StepVisual_ssNegative;
50           else if (ssPositive.IsEqual(text)) aSide = StepVisual_ssPositive;
51           else if (ssBoth.IsEqual(text)) aSide = StepVisual_ssBoth;
52           else ach->AddFail("Enumeration surface_side has not an allowed value");
53         }
54         else ach->AddFail("Parameter #1 (side) is not an enumeration");
55
56         // --- own field : style ---
57
58         Handle(StepVisual_SurfaceSideStyle) aStyle;
59         //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
60         data->ReadEntity(num, 2,"style", ach, STANDARD_TYPE(StepVisual_SurfaceSideStyle), aStyle);
61
62         //--- Initialisation of the read entity ---
63
64
65         ent->Init(aSide, aStyle);
66 }
67
68
69 void RWStepVisual_RWSurfaceStyleUsage::WriteStep
70         (StepData_StepWriter& SW,
71          const Handle(StepVisual_SurfaceStyleUsage)& ent) const
72 {
73
74         // --- own field : side ---
75
76         switch(ent->Side()) {
77           case StepVisual_ssNegative : SW.SendEnum (ssNegative); break;
78           case StepVisual_ssPositive : SW.SendEnum (ssPositive); break;
79           case StepVisual_ssBoth : SW.SendEnum (ssBoth); break;
80         }
81
82         // --- own field : style ---
83
84         SW.Send(ent->Style());
85 }
86
87
88 void RWStepVisual_RWSurfaceStyleUsage::Share(const Handle(StepVisual_SurfaceStyleUsage)& ent, Interface_EntityIterator& iter) const
89 {
90
91         iter.GetOneItem(ent->Style());
92 }
93