0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / RWStepGeom / RWStepGeom_RWRectangularCompositeSurface.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 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
973c2be1 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.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
7fd59977 13
7fd59977 14
42cf5bc1 15#include <Interface_Check.hxx>
7fd59977 16#include <Interface_EntityIterator.hxx>
42cf5bc1 17#include <RWStepGeom_RWRectangularCompositeSurface.hxx>
18#include <StepData_StepReaderData.hxx>
19#include <StepData_StepWriter.hxx>
20#include <StepGeom_HArray2OfSurfacePatch.hxx>
7fd59977 21#include <StepGeom_RectangularCompositeSurface.hxx>
42cf5bc1 22#include <StepGeom_SurfacePatch.hxx>
7fd59977 23
24RWStepGeom_RWRectangularCompositeSurface::RWStepGeom_RWRectangularCompositeSurface () {}
25
26void RWStepGeom_RWRectangularCompositeSurface::ReadStep
27 (const Handle(StepData_StepReaderData)& data,
28 const Standard_Integer num,
29 Handle(Interface_Check)& ach,
30 const Handle(StepGeom_RectangularCompositeSurface)& ent) const
31{
32
33
34 // --- Number of Parameter Control ---
35
36 if (!data->CheckNbParams(num,2,ach,"rectangular_composite_surface")) return;
37
38 // --- inherited field : name ---
39
40 Handle(TCollection_HAsciiString) aName;
41 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
42 data->ReadString (num,1,"name",ach,aName);
43
44 // --- own field : segments ---
45
46 Handle(StepGeom_HArray2OfSurfacePatch) aSegments;
47 Handle(StepGeom_SurfacePatch) anent2;
48 Standard_Integer nsub2;
49 if (data->ReadSubList (num,2,"segments",ach,nsub2)) {
50 Standard_Integer nbi2 = data->NbParams(nsub2);
51 Standard_Integer nbj2 = data->NbParams(data->ParamNumber(nsub2,1));
52 aSegments = new StepGeom_HArray2OfSurfacePatch (1, nbi2, 1, nbj2);
53 for (Standard_Integer i2 = 1; i2 <= nbi2; i2 ++) {
54 Standard_Integer nsi2;
55 if (data->ReadSubList (nsub2,i2,"sub-part(segments)",ach,nsi2)) {
56 for (Standard_Integer j2 =1; j2 <= nbj2; j2 ++) {
57 //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
58 if (data->ReadEntity (nsi2, j2,"surface_patch", ach,
59 STANDARD_TYPE(StepGeom_SurfacePatch), anent2))
60 aSegments->SetValue(i2, j2, anent2);
61 }
62 }
63 }
64 }
65
66 //--- Initialisation of the read entity ---
67
68
69 ent->Init(aName, aSegments);
70}
71
72
73void RWStepGeom_RWRectangularCompositeSurface::WriteStep
74 (StepData_StepWriter& SW,
75 const Handle(StepGeom_RectangularCompositeSurface)& ent) const
76{
77
78 // --- inherited field name ---
79
80 SW.Send(ent->Name());
81
82 // --- own field : segments ---
83
84 SW.OpenSub();
85 for (Standard_Integer i2 = 1; i2 <= ent->NbSegmentsI(); i2 ++) {
86 SW.NewLine(Standard_False);
87 SW.OpenSub();
88 for (Standard_Integer j2 = 1; j2 <= ent->NbSegmentsJ(); j2 ++) {
89 SW.Send(ent->SegmentsValue(i2,j2));
90 SW.JoinLast(Standard_False);
91 }
92 SW.CloseSub();
93 }
94 SW.CloseSub();
95}
96
97
98void RWStepGeom_RWRectangularCompositeSurface::Share(const Handle(StepGeom_RectangularCompositeSurface)& ent, Interface_EntityIterator& iter) const
99{
100
101 Standard_Integer nbiElem1 = ent->NbSegmentsI();
102 Standard_Integer nbjElem1 = ent->NbSegmentsJ();
103 for (Standard_Integer is1=1; is1<=nbiElem1; is1 ++) {
104 for (Standard_Integer js1=1; js1<=nbjElem1; js1 ++) {
105 iter.GetOneItem(ent->SegmentsValue(is1,js1));
106 }
107 }
108
109}
110