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 <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
22 RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx () {}
24 void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::ReadStep
25 (const Handle(StepData_StepReaderData)& data,
26 const Standard_Integer num0,
27 Handle(Interface_Check)& ach,
28 const Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)& ent) const
31 Standard_Integer num = num0;
33 // -----------------------------------------------------------------
34 // --- Instance of plex component GeometricRepresentationContext ---
35 // -----------------------------------------------------------------
37 if (!data->CheckNbParams(num,1,ach,"geometric_representation_context")) return;
39 // --- field : coordinateSpaceDimension ---
41 Standard_Integer aCoordinateSpaceDimension;
42 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
43 data->ReadInteger (num,1,"coordinate_space_dimension",ach,aCoordinateSpaceDimension);
45 num = data->NextForComplex(num);
47 // -------------------------------------------------------------------
48 // --- Instance of plex component GlobalUncertaintyAssignedContext ---
49 // -------------------------------------------------------------------
51 if (!data->CheckNbParams(num,1,ach,"global_uncertainty_assigned_context")) return;
53 // --- field : uncertainty ---
55 Handle(StepBasic_HArray1OfUncertaintyMeasureWithUnit) aUncertainty;
56 Handle(StepBasic_UncertaintyMeasureWithUnit) anent3;
57 Standard_Integer nsub3;
58 if (data->ReadSubList (num,1,"uncertainty",ach,nsub3)) {
59 Standard_Integer nb3 = data->NbParams(nsub3);
60 aUncertainty = new StepBasic_HArray1OfUncertaintyMeasureWithUnit (1, nb3);
61 for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
62 //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
63 if (data->ReadEntity (nsub3, i3,"uncertainty_measure_with_unit", ach,
64 STANDARD_TYPE(StepBasic_UncertaintyMeasureWithUnit), anent3))
65 aUncertainty->SetValue(i3, anent3);
69 num = data->NextForComplex(num);
71 // ------------------------------------------------------------
72 // --- Instance of plex component GlobalUnitAssignedContext ---
73 // ------------------------------------------------------------
75 if (!data->CheckNbParams(num,1,ach,"global_unit_assigned_context")) return;
77 // --- field : units ---
79 Handle(StepBasic_HArray1OfNamedUnit) aUnits;
80 Handle(StepBasic_NamedUnit) anent2;
81 Standard_Integer nsub2;
82 if (data->ReadSubList (num,1,"units",ach,nsub2)) {
83 Standard_Integer nb2 = data->NbParams(nsub2);
84 aUnits = new StepBasic_HArray1OfNamedUnit (1, nb2);
85 for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) {
86 //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
87 if (data->ReadEntity (nsub2, i2,"unit", ach, STANDARD_TYPE(StepBasic_NamedUnit), anent2))
88 aUnits->SetValue(i2, anent2);
92 num = data->NextForComplex(num);
94 // ----------------------------------------------------------
95 // --- Instance of common supertype RepresentationContext ---
96 // ----------------------------------------------------------
98 if (!data->CheckNbParams(num,2,ach,"representation_context")) return;
100 // --- field : contextIdentifier ---
102 Handle(TCollection_HAsciiString) aContextIdentifier;
103 //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
104 data->ReadString (num,1,"context_identifier",ach,aContextIdentifier);
106 // --- field : contextType ---
108 Handle(TCollection_HAsciiString) aContextType;
109 //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed
110 data->ReadString (num,2,"context_type",ach,aContextType);
112 //--- Initialisation of the red entity ---
114 ent->Init(aContextIdentifier,aContextType,aCoordinateSpaceDimension,aUnits, aUncertainty);
118 void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::WriteStep
119 (StepData_StepWriter& SW,
120 const Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)& ent) const
123 // -----------------------------------------------------------------
124 // --- Instance of plex component GeometricRepresentationContext ---
125 // -----------------------------------------------------------------
127 SW.StartEntity("GEOMETRIC_REPRESENTATION_CONTEXT");
129 // --- field : coordinateSpaceDimension ---
131 SW.Send(ent->CoordinateSpaceDimension());
133 // -------------------------------------------------------------------
134 // --- Instance of plex component GlobalUncertaintyAssignedContext ---
135 // -------------------------------------------------------------------
137 SW.StartEntity("GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT");
139 // --- field : uncertainty ---
142 for (Standard_Integer i3 = 1; i3 <= ent->NbUncertainty(); i3 ++) {
143 SW.Send(ent->UncertaintyValue(i3));
147 // ------------------------------------------------------------
148 // --- Instance of plex component GlobalUnitAssignedContext ---
149 // ------------------------------------------------------------
151 SW.StartEntity("GLOBAL_UNIT_ASSIGNED_CONTEXT");
153 // --- field : units ---
156 for (Standard_Integer i2 = 1; i2 <= ent->NbUnits(); i2 ++) {
157 SW.Send(ent->UnitsValue(i2));
161 // ----------------------------------------------------------
162 // --- Instance of common supertype RepresentationContext ---
163 // ----------------------------------------------------------
165 SW.StartEntity("REPRESENTATION_CONTEXT");
167 // --- field : contextIdentifier ---
169 SW.Send(ent->ContextIdentifier());
171 // --- field : contextType ---
173 SW.Send(ent->ContextType());
177 void RWStepGeom_RWGeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx::Share(const Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)& ent, Interface_EntityIterator& iter) const
180 Standard_Integer nbElem1 = ent->NbUnits();
181 for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) {
182 iter.GetOneItem(ent->UnitsValue(is1));
185 Standard_Integer nbElem2 = ent->NbUncertainty();
186 for (Standard_Integer is2=1; is2<=nbElem2; is2 ++) {
187 iter.GetOneItem(ent->UncertaintyValue(is2));