1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <Interface_Check.hxx>
16 #include <Interface_EntityIterator.hxx>
17 #include <RWStepShape_RWFacetedBrepAndBrepWithVoids.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepShape_BrepWithVoids.hxx>
21 #include <StepShape_ClosedShell.hxx>
22 #include <StepShape_FacetedBrep.hxx>
23 #include <StepShape_FacetedBrepAndBrepWithVoids.hxx>
24 #include <StepShape_HArray1OfOrientedClosedShell.hxx>
25 #include <StepShape_OrientedClosedShell.hxx>
27 RWStepShape_RWFacetedBrepAndBrepWithVoids::RWStepShape_RWFacetedBrepAndBrepWithVoids () {}
29 void RWStepShape_RWFacetedBrepAndBrepWithVoids::ReadStep
30 (const Handle(StepData_StepReaderData)& data,
31 const Standard_Integer num0,
32 Handle(Interface_Check)& ach,
33 const Handle(StepShape_FacetedBrepAndBrepWithVoids)& ent) const
36 Standard_Integer num = num0;
39 // --- Instance of plex componant BrepWithVoids ---
41 if (!data->CheckNbParams(num,1,ach,"brep_with_voids")) return;
43 // --- field : voids ---
45 Handle(StepShape_HArray1OfOrientedClosedShell) aVoids;
46 Handle(StepShape_OrientedClosedShell) anent;
47 Standard_Integer nsub1;
48 if (data->ReadSubList (num,1,"voids",ach,nsub1)) {
49 Standard_Integer nb1 = data->NbParams(nsub1);
50 aVoids = new StepShape_HArray1OfOrientedClosedShell (1, nb1);
51 for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) {
52 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
53 if (data->ReadEntity (nsub1, i1,"oriented_closed_shell", ach,
54 STANDARD_TYPE(StepShape_OrientedClosedShell), anent))
55 aVoids->SetValue(i1, anent);
59 num = data->NextForComplex(num);
61 // --- Instance of plex componant FacetedBrep ---
63 if (!data->CheckNbParams(num,0,ach,"faceted_brep")) return;
65 num = data->NextForComplex(num);
67 // --- Instance of plex componant GeometricRepresentationItem ---
69 if (!data->CheckNbParams(num,0,ach,"geometric_representation_item")) return;
71 num = data->NextForComplex(num);
73 // --- Instance of common supertype ManifoldSolidBrep ---
75 if (!data->CheckNbParams(num,1,ach,"manifold_solid_brep")) return;
76 // --- field : outer ---
79 Handle(StepShape_ClosedShell) aOuter;
80 //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
81 data->ReadEntity(num, 1,"outer", ach, STANDARD_TYPE(StepShape_ClosedShell), aOuter);
83 num = data->NextForComplex(num);
85 // --- Instance of plex componant RepresentationItem ---
87 if (!data->CheckNbParams(num,1,ach,"representation_item")) return;
90 // --- field : name ---
92 Handle(TCollection_HAsciiString) aName;
93 //szv#4:S4163:12Mar99 `Standard_Boolean stat10 =` not needed
94 data->ReadString (num,1,"name",ach,aName);
96 num = data->NextForComplex(num);
98 // --- Instance of plex componant SolidModel ---
100 if (!data->CheckNbParams(num,0,ach,"solid_model")) return;
102 //--- Initialisation of the red entity ---
104 ent->Init(aName, aOuter,aVoids);
108 void RWStepShape_RWFacetedBrepAndBrepWithVoids::WriteStep
109 (StepData_StepWriter& SW,
110 const Handle(StepShape_FacetedBrepAndBrepWithVoids)& ent) const
113 // --- Instance of plex componant BrepWithVoids ---
115 SW.StartEntity("BREP_WITH_VOIDS");
116 // --- field : voids ---
119 for (Standard_Integer i1 = 1; i1 <= ent->NbVoids(); i1 ++) {
120 SW.Send(ent->VoidsValue(i1));
124 // --- Instance of plex componant FacetedBrep ---
126 SW.StartEntity("FACETED_BREP");
128 // --- Instance of plex componant GeometricRepresentationItem ---
130 SW.StartEntity("GEOMETRIC_REPRESENTATION_ITEM");
132 // --- Instance of common supertype ManifoldSolidBrep ---
134 SW.StartEntity("MANIFOLD_SOLID_BREP");
135 // --- field : outer ---
137 SW.Send(ent->Outer());
139 // --- Instance of plex componant RepresentationItem ---
141 SW.StartEntity("REPRESENTATION_ITEM");
142 // --- field : name ---
144 SW.Send(ent->Name());
146 // --- Instance of plex componant SolidModel ---
148 SW.StartEntity("SOLID_MODEL");
152 void RWStepShape_RWFacetedBrepAndBrepWithVoids::Share(const Handle(StepShape_FacetedBrepAndBrepWithVoids)& ent, Interface_EntityIterator& iter) const
155 iter.GetOneItem(ent->Outer());
157 Standard_Integer nbElem2 = ent->NbVoids();
158 for (Standard_Integer is2=1; is2<=nbElem2; is2 ++) {
159 iter.GetOneItem(ent->VoidsValue(is2));