0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / RWStepGeom / RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext.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 <RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext.hxx>
18 #include <StepBasic_HArray1OfNamedUnit.hxx>
19 #include <StepBasic_NamedUnit.hxx>
20 #include <StepData_StepReaderData.hxx>
21 #include <StepData_StepWriter.hxx>
22 #include <StepGeom_GeometricRepresentationContext.hxx>
23 #include <StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext.hxx>
24 #include <StepRepr_GlobalUnitAssignedContext.hxx>
25
26 RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext::RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext () {}
27
28 void RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext::ReadStep
29         (const Handle(StepData_StepReaderData)& data,
30          const Standard_Integer num0,
31          Handle(Interface_Check)& ach,
32          const Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)& ent) const
33 {
34
35         Standard_Integer num = num0;
36
37
38         // --- Instance of plex componant GeometricRepresentationContext ---
39
40         if (!data->CheckNbParams(num,1,ach,"geometric_representation_context")) return;
41
42         // --- field : coordinateSpaceDimension ---
43
44         Standard_Integer aCoordinateSpaceDimension;
45         //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
46         data->ReadInteger (num,1,"coordinate_space_dimension",ach,aCoordinateSpaceDimension);
47
48         num = data->NextForComplex(num);
49
50         // --- Instance of plex componant GlobalUnitAssignedContext ---
51
52         if (!data->CheckNbParams(num,1,ach,"global_unit_assigned_context")) return;
53
54         // --- field : units ---
55
56         Handle(StepBasic_HArray1OfNamedUnit) aUnits;
57         Handle(StepBasic_NamedUnit) anent2;
58         Standard_Integer nsub2;
59         if (data->ReadSubList (num,1,"units",ach,nsub2)) {
60           Standard_Integer nb2 = data->NbParams(nsub2);
61           aUnits = new StepBasic_HArray1OfNamedUnit (1, nb2);
62           for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) {
63             //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
64             if (data->ReadEntity (nsub2, i2,"unit", ach, STANDARD_TYPE(StepBasic_NamedUnit), anent2))
65               aUnits->SetValue(i2, anent2);
66           }
67         }
68
69         num = data->NextForComplex(num);
70
71         // --- Instance of common supertype RepresentationContext ---
72
73         if (!data->CheckNbParams(num,2,ach,"representation_context")) return;
74         // --- field : contextIdentifier ---
75
76
77         Handle(TCollection_HAsciiString) aContextIdentifier;
78         //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
79         data->ReadString (num,1,"context_identifier",ach,aContextIdentifier);
80         // --- field : contextType ---
81
82
83         Handle(TCollection_HAsciiString) aContextType;
84         //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed
85         data->ReadString (num,2,"context_type",ach,aContextType);
86
87         //--- Initialisation of the red entity ---
88
89         ent->Init(aContextIdentifier,aContextType,aCoordinateSpaceDimension,aUnits);
90 }
91
92
93 void RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext::WriteStep
94         (StepData_StepWriter& SW,
95          const Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)& ent) const
96 {
97
98         // --- Instance of plex componant GeometricRepresentationContext ---
99
100         SW.StartEntity("GEOMETRIC_REPRESENTATION_CONTEXT");
101         // --- field : coordinateSpaceDimension ---
102
103         SW.Send(ent->CoordinateSpaceDimension());
104
105         // --- Instance of plex componant GlobalUnitAssignedContext ---
106
107         SW.StartEntity("GLOBAL_UNIT_ASSIGNED_CONTEXT");
108         // --- field : units ---
109
110         SW.OpenSub();
111         for (Standard_Integer i2 = 1;  i2 <= ent->NbUnits();  i2 ++) {
112           SW.Send(ent->UnitsValue(i2));
113         }
114         SW.CloseSub();
115
116         // --- Instance of common supertype RepresentationContext ---
117
118         SW.StartEntity("REPRESENTATION_CONTEXT");
119         // --- field : contextIdentifier ---
120
121         SW.Send(ent->ContextIdentifier());
122         // --- field : contextType ---
123
124         SW.Send(ent->ContextType());
125 }
126
127
128 void RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext::Share(const Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)& ent, Interface_EntityIterator& iter) const
129 {
130
131         Standard_Integer nbElem1 = ent->NbUnits();
132         for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) {
133           iter.GetOneItem(ent->UnitsValue(is1));
134         }
135
136 }
137