0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / RWStepVisual / RWStepVisual_RWCameraModelD3MultiClippingUnion.cxx
1 // Created on: 2016-11-14
2 // Created by: Irina KRYLOVA
3 // Copyright (c) 2016 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16
17 #include <Interface_Check.hxx>
18 #include <Interface_EntityIterator.hxx>
19 #include <RWStepVisual_RWCameraModelD3MultiClippingUnion.hxx>
20 #include <StepData_StepReaderData.hxx>
21 #include <StepData_StepWriter.hxx>
22 #include <StepVisual_CameraModelD3MultiClippingUnion.hxx>
23 #include <StepVisual_HArray1OfCameraModelD3MultiClippingUnionSelect.hxx>
24
25 //=======================================================================
26 //function : RWStepVisual_RWCameraModelD3MultiClippingUnion
27 //purpose  : 
28 //=======================================================================
29 RWStepVisual_RWCameraModelD3MultiClippingUnion::RWStepVisual_RWCameraModelD3MultiClippingUnion() {}
30
31 //=======================================================================
32 //function : ReadStep
33 //purpose  : 
34 //=======================================================================
35 void RWStepVisual_RWCameraModelD3MultiClippingUnion::ReadStep
36   (const Handle(StepData_StepReaderData)& data,
37    const Standard_Integer num,
38    Handle(Interface_Check)& ach,
39    const Handle(StepVisual_CameraModelD3MultiClippingUnion)& ent) const
40 {
41   // Number of Parameter Control
42   if (!data->CheckNbParams(num, 2, ach, "camera_model_d3_multi_clipping_union"))
43     return;
44
45   // Inherited field : name
46   Handle(TCollection_HAsciiString) aName;
47   data->ReadString (num, 1, "name", ach, aName);
48
49   // Own field : shape_clipping
50   Handle(StepVisual_HArray1OfCameraModelD3MultiClippingUnionSelect) aShapeClipping;
51   StepVisual_CameraModelD3MultiClippingUnionSelect anEnt;
52   Standard_Integer nbSub;
53   if (data->ReadSubList(num, 2, "shape_clipping", ach, nbSub)) {
54     Standard_Integer nbElements = data->NbParams(nbSub);
55     aShapeClipping = new StepVisual_HArray1OfCameraModelD3MultiClippingUnionSelect(1, nbElements);
56     for (Standard_Integer i = 1; i <= nbElements; i++) {
57       if (data->ReadEntity(nbSub, i, "shape_clipping", ach, anEnt))
58         aShapeClipping->SetValue(i, anEnt);
59     }
60   }
61
62   // Initialization of the read entity
63   ent->Init(aName, aShapeClipping);
64 }
65
66 //=======================================================================
67 //function : WriteStep
68 //purpose  : 
69 //=======================================================================
70 void RWStepVisual_RWCameraModelD3MultiClippingUnion::WriteStep
71   (StepData_StepWriter& SW,
72    const Handle(StepVisual_CameraModelD3MultiClippingUnion)& ent) const
73 {
74   // Inherited field name
75   SW.Send(ent->Name());
76
77   // Own field: shape_clipping
78   SW.OpenSub();
79   for (Standard_Integer i = 1; i <= ent->ShapeClipping()->Length(); i++) {
80     SW.Send(ent->ShapeClipping()->Value(i).Value());
81   }
82   SW.CloseSub();
83 }
84
85 //=======================================================================
86 //function : Share
87 //purpose  : 
88 //=======================================================================
89 void RWStepVisual_RWCameraModelD3MultiClippingUnion::Share
90   (const Handle(StepVisual_CameraModelD3MultiClippingUnion)& ent,
91    Interface_EntityIterator& iter) const
92 {
93   // Own field: shape_clipping
94   Standard_Integer i, nb = ent->ShapeClipping()->Length();
95   for (i = 1; i <= nb; i++)
96     iter.AddItem(ent->ShapeClipping()->Value(i).Value());
97 }
98