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 <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>
26 RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext::RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext () {}
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
35 Standard_Integer num = num0;
38 // --- Instance of plex componant GeometricRepresentationContext ---
40 if (!data->CheckNbParams(num,1,ach,"geometric_representation_context")) return;
42 // --- field : coordinateSpaceDimension ---
44 Standard_Integer aCoordinateSpaceDimension;
45 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
46 data->ReadInteger (num,1,"coordinate_space_dimension",ach,aCoordinateSpaceDimension);
48 num = data->NextForComplex(num);
50 // --- Instance of plex componant GlobalUnitAssignedContext ---
52 if (!data->CheckNbParams(num,1,ach,"global_unit_assigned_context")) return;
54 // --- field : units ---
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);
69 num = data->NextForComplex(num);
71 // --- Instance of common supertype RepresentationContext ---
73 if (!data->CheckNbParams(num,2,ach,"representation_context")) return;
74 // --- field : contextIdentifier ---
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 ---
83 Handle(TCollection_HAsciiString) aContextType;
84 //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed
85 data->ReadString (num,2,"context_type",ach,aContextType);
87 //--- Initialisation of the red entity ---
89 ent->Init(aContextIdentifier,aContextType,aCoordinateSpaceDimension,aUnits);
93 void RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext::WriteStep
94 (StepData_StepWriter& SW,
95 const Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)& ent) const
98 // --- Instance of plex componant GeometricRepresentationContext ---
100 SW.StartEntity("GEOMETRIC_REPRESENTATION_CONTEXT");
101 // --- field : coordinateSpaceDimension ---
103 SW.Send(ent->CoordinateSpaceDimension());
105 // --- Instance of plex componant GlobalUnitAssignedContext ---
107 SW.StartEntity("GLOBAL_UNIT_ASSIGNED_CONTEXT");
108 // --- field : units ---
111 for (Standard_Integer i2 = 1; i2 <= ent->NbUnits(); i2 ++) {
112 SW.Send(ent->UnitsValue(i2));
116 // --- Instance of common supertype RepresentationContext ---
118 SW.StartEntity("REPRESENTATION_CONTEXT");
119 // --- field : contextIdentifier ---
121 SW.Send(ent->ContextIdentifier());
122 // --- field : contextType ---
124 SW.Send(ent->ContextType());
128 void RWStepGeom_RWGeometricRepresentationContextAndGlobalUnitAssignedContext::Share(const Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)& ent, Interface_EntityIterator& iter) const
131 Standard_Integer nbElem1 = ent->NbUnits();
132 for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) {
133 iter.GetOneItem(ent->UnitsValue(is1));