0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / RWStepRepr / RWStepRepr_RWConstructiveGeometryRepresentation.cxx
CommitLineData
b7b2f85a 1// Created on: 2016-04-26
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 <RWStepRepr_RWConstructiveGeometryRepresentation.hxx>
20#include <StepData_StepReaderData.hxx>
21#include <StepData_StepWriter.hxx>
22#include <StepRepr_HArray1OfRepresentationItem.hxx>
23#include <StepRepr_RepresentationContext.hxx>
24#include <StepRepr_RepresentationItem.hxx>
25#include <StepRepr_ConstructiveGeometryRepresentation.hxx>
26
27//=======================================================================
28//function : RWStepRepr_RWConstructiveGeometryRepresentation
29//purpose :
30//=======================================================================
31RWStepRepr_RWConstructiveGeometryRepresentation::RWStepRepr_RWConstructiveGeometryRepresentation () {}
32
33//=======================================================================
34//function : ReadStep
35//purpose :
36//=======================================================================
37void RWStepRepr_RWConstructiveGeometryRepresentation::ReadStep
38 (const Handle(StepData_StepReaderData)& data,
39 const Standard_Integer num,
40 Handle(Interface_Check)& ach,
41 const Handle(StepRepr_ConstructiveGeometryRepresentation)& ent) const
42{
43 // Number of Parameter Control
44 if (!data->CheckNbParams(num, 3, ach, "constructive_geometry_representation")) return;
45
46 // Inherited field : name
47 Handle(TCollection_HAsciiString) aName;
48 data->ReadString (num, 1, "name" ,ach, aName);
49
50 // Inherited field : items
51 Handle(StepRepr_HArray1OfRepresentationItem) aItems;
52 Handle(StepRepr_RepresentationItem) anEnt;
53 Standard_Integer nsub;
54 if (data->ReadSubList (num, 2, "items", ach, nsub)) {
55 Standard_Integer nb = data->NbParams(nsub);
56 aItems = new StepRepr_HArray1OfRepresentationItem (1, nb);
57 for (Standard_Integer i = 1; i <= nb; i ++) {
58 if (data->ReadEntity (nsub, i, "representation_item", ach,
59 STANDARD_TYPE(StepRepr_RepresentationItem), anEnt))
60 aItems->SetValue(i, anEnt);
61 }
62 }
63
64 // Inherited field : context_of_items
65 Handle(StepRepr_RepresentationContext) aContextOfItems;
66 data->ReadEntity(num, 3,"context_of_items", ach, STANDARD_TYPE(StepRepr_RepresentationContext), aContextOfItems);
67
68 // Initialisation of the read entity
69 ent->Init(aName, aItems, aContextOfItems);
70}
71
72//=======================================================================
73//function : WriteStep
74//purpose :
75//=======================================================================
76void RWStepRepr_RWConstructiveGeometryRepresentation::WriteStep
77 (StepData_StepWriter& SW,
78 const Handle(StepRepr_ConstructiveGeometryRepresentation)& ent) const
79{
80 // Inherited field : name
81 SW.Send(ent->Name());
82
83 // Inherited field : items
84 SW.OpenSub();
85 for (Standard_Integer i = 1; i <= ent->NbItems(); i++) {
86 SW.Send(ent->ItemsValue(i));
87 }
88 SW.CloseSub();
89
90 // Inherited field : context_of_items
91 SW.Send(ent->ContextOfItems());
92}
93
94//=======================================================================
95//function : Share
96//purpose :
97//=======================================================================
98void RWStepRepr_RWConstructiveGeometryRepresentation::Share(const Handle(StepRepr_ConstructiveGeometryRepresentation)& ent, Interface_EntityIterator& iter) const
99{
100 Standard_Integer nbElem = ent->NbItems();
101 for (Standard_Integer i = 1; i <= nbElem; i++) {
102 iter.GetOneItem(ent->ItemsValue(i));
103 }
104 iter.GetOneItem(ent->ContextOfItems());
105}
106