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_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
18 #include <StepBasic_HArray1OfNamedUnit.hxx>
19 #include <StepBasic_HArray1OfUncertaintyMeasureWithUnit.hxx>
20 #include <StepBasic_NamedUnit.hxx>
21 #include <StepBasic_UncertaintyMeasureWithUnit.hxx>
22 #include <StepData_StepReaderData.hxx>
23 #include <StepData_StepWriter.hxx>
24 #include <StepGeom_GeometricRepresentationContext.hxx>
25 #include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
26 #include <StepRepr_GlobalUnitAssignedContext.hxx>
28 RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx () {}
30 void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::ReadStep
31 (const Handle(StepData_StepReaderData)& data,
32 const Standard_Integer num0,
33 Handle(Interface_Check)& ach,
34 const Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)& ent) const
37 Standard_Integer num = num0;
39 // -----------------------------------------------------------------
40 // --- Instance of plex componant GeometricRepresentationContext ---
41 // -----------------------------------------------------------------
43 if (!data->CheckNbParams(num,1,ach,"geometric_representation_context")) return;
45 // --- field : coordinateSpaceDimension ---
47 Standard_Integer aCoordinateSpaceDimension;
48 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
49 data->ReadInteger (num,1,"coordinate_space_dimension",ach,aCoordinateSpaceDimension);
51 num = data->NextForComplex(num);
53 // -------------------------------------------------------------------
54 // --- Instance of plex componant GlobalUncertaintyAssignedContext ---
55 // -------------------------------------------------------------------
57 if (!data->CheckNbParams(num,1,ach,"global_uncertainty_assigned_context")) return;
59 // --- field : uncertainty ---
61 Handle(StepBasic_HArray1OfUncertaintyMeasureWithUnit) aUncertainty;
62 Handle(StepBasic_UncertaintyMeasureWithUnit) anent3;
63 Standard_Integer nsub3;
64 if (data->ReadSubList (num,1,"uncertainty",ach,nsub3)) {
65 Standard_Integer nb3 = data->NbParams(nsub3);
66 aUncertainty = new StepBasic_HArray1OfUncertaintyMeasureWithUnit (1, nb3);
67 for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
68 //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
69 if (data->ReadEntity (nsub3, i3,"uncertainty_measure_with_unit", ach,
70 STANDARD_TYPE(StepBasic_UncertaintyMeasureWithUnit), anent3))
71 aUncertainty->SetValue(i3, anent3);
75 num = data->NextForComplex(num);
77 // ------------------------------------------------------------
78 // --- Instance of plex componant GlobalUnitAssignedContext ---
79 // ------------------------------------------------------------
81 if (!data->CheckNbParams(num,1,ach,"global_unit_assigned_context")) return;
83 // --- field : units ---
85 Handle(StepBasic_HArray1OfNamedUnit) aUnits;
86 Handle(StepBasic_NamedUnit) anent2;
87 Standard_Integer nsub2;
88 if (data->ReadSubList (num,1,"units",ach,nsub2)) {
89 Standard_Integer nb2 = data->NbParams(nsub2);
90 aUnits = new StepBasic_HArray1OfNamedUnit (1, nb2);
91 for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) {
92 //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
93 if (data->ReadEntity (nsub2, i2,"unit", ach, STANDARD_TYPE(StepBasic_NamedUnit), anent2))
94 aUnits->SetValue(i2, anent2);
98 num = data->NextForComplex(num);
100 // ----------------------------------------------------------
101 // --- Instance of common supertype RepresentationContext ---
102 // ----------------------------------------------------------
104 if (!data->CheckNbParams(num,2,ach,"representation_context")) return;
106 // --- field : contextIdentifier ---
108 Handle(TCollection_HAsciiString) aContextIdentifier;
109 //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
110 data->ReadString (num,1,"context_identifier",ach,aContextIdentifier);
112 // --- field : contextType ---
114 Handle(TCollection_HAsciiString) aContextType;
115 //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed
116 data->ReadString (num,2,"context_type",ach,aContextType);
118 //--- Initialisation of the red entity ---
120 ent->Init(aContextIdentifier,aContextType,aCoordinateSpaceDimension,aUnits, aUncertainty);
124 void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::WriteStep
125 (StepData_StepWriter& SW,
126 const Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)& ent) const
129 // -----------------------------------------------------------------
130 // --- Instance of plex componant GeometricRepresentationContext ---
131 // -----------------------------------------------------------------
133 SW.StartEntity("GEOMETRIC_REPRESENTATION_CONTEXT");
135 // --- field : coordinateSpaceDimension ---
137 SW.Send(ent->CoordinateSpaceDimension());
139 // -------------------------------------------------------------------
140 // --- Instance of plex componant GlobalUncertaintyAssignedContext ---
141 // -------------------------------------------------------------------
143 SW.StartEntity("GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT");
145 // --- field : uncertainty ---
148 for (Standard_Integer i3 = 1; i3 <= ent->NbUncertainty(); i3 ++) {
149 SW.Send(ent->UncertaintyValue(i3));
153 // ------------------------------------------------------------
154 // --- Instance of plex componant GlobalUnitAssignedContext ---
155 // ------------------------------------------------------------
157 SW.StartEntity("GLOBAL_UNIT_ASSIGNED_CONTEXT");
159 // --- field : units ---
162 for (Standard_Integer i2 = 1; i2 <= ent->NbUnits(); i2 ++) {
163 SW.Send(ent->UnitsValue(i2));
167 // ----------------------------------------------------------
168 // --- Instance of common supertype RepresentationContext ---
169 // ----------------------------------------------------------
171 SW.StartEntity("REPRESENTATION_CONTEXT");
173 // --- field : contextIdentifier ---
175 SW.Send(ent->ContextIdentifier());
177 // --- field : contextType ---
179 SW.Send(ent->ContextType());
183 void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::Share(const Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)& ent, Interface_EntityIterator& iter) const
186 Standard_Integer nbElem1 = ent->NbUnits();
187 for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) {
188 iter.GetOneItem(ent->UnitsValue(is1));
191 Standard_Integer nbElem2 = ent->NbUncertainty();
192 for (Standard_Integer is2=1; is2<=nbElem2; is2 ++) {
193 iter.GetOneItem(ent->UncertaintyValue(is2));