0026715: Problems in reading STEP short names in complex entities
[occt.git] / src / RWStepRepr / RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI.cxx
CommitLineData
28a73c1f 1// Created on: 2015-07-22
2// Created by: Irina KRYLOVA
3// Copyright (c) 2015 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#include <Interface_Check.hxx>
17#include <RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI.hxx>
18#include <StepBasic_MeasureValueMember.hxx>
19#include <StepBasic_MeasureWithUnit.hxx>
20#include <StepBasic_Unit.hxx>
21#include <StepData_StepReaderData.hxx>
22#include <StepData_StepWriter.hxx>
23#include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI.hxx>
24#include <StepShape_HArray1OfValueQualifier.hxx>
25#include <StepShape_QualifiedRepresentationItem.hxx>
26#include <StepShape_ValueQualifier.hxx>
27
28//=======================================================================
29//function : RWSteprepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI
30//purpose :
31//=======================================================================
32RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI::RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI() {}
33
34
35//=======================================================================
36//function : ReadStep
37//purpose :
38//=======================================================================
39
40void RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI::ReadStep
41 (const Handle(StepData_StepReaderData)& data,
42 const Standard_Integer num0,
43 Handle(Interface_Check)& ach,
44 const Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI)& ent) const
45{
46 Standard_Integer num = 0;//num0;
a7197ef3 47 data->NamedForComplex("MEASURE_WITH_UNIT","MSWTUN",num0,num,ach);
28a73c1f 48 if (!data->CheckNbParams(num,2,ach,"measure_with_unit")) return;
49 // --- own field : valueComponent ---
50 Handle(StepBasic_MeasureValueMember) mvc = new StepBasic_MeasureValueMember;
51 data->ReadMember (num,1, "value_component", ach, mvc);
52 // --- own field : unitComponent ---
53 StepBasic_Unit aUnitComponent;
54 data->ReadEntity(num, 2,"unit_component", ach, aUnitComponent);
55 Handle(StepBasic_MeasureWithUnit) aMeasureWithUnit = new StepBasic_MeasureWithUnit;
56 aMeasureWithUnit->Init(mvc, aUnitComponent);
57
a7197ef3 58 data->NamedForComplex("QUALIFIED_REPRESENTATION_ITEM","QLRPIT",num0,num,ach);
28a73c1f 59 if (!data->CheckNbParams(num,1,ach,"qualified_representation_item")) return;
60 // --- own field : qualifiers ---
61 Handle(StepShape_HArray1OfValueQualifier) quals;
62 Standard_Integer nsub;
63 if (data->ReadSubList (num, 1, "qualifiers", ach, nsub)) {
64 Standard_Integer nb = data->NbParams(nsub);
65 quals = new StepShape_HArray1OfValueQualifier (1, nb);
66 for (Standard_Integer i = 1; i <= nb; i++) {
67 StepShape_ValueQualifier aVQ;
68 if (data->ReadEntity (nsub, i, "qualifier" ,ach, aVQ))
69 quals->SetValue (i, aVQ);
70 }
71 }
72 Handle(StepShape_QualifiedRepresentationItem) aQRI = new StepShape_QualifiedRepresentationItem();
73 aQRI->SetQualifiers(quals);
74
a7197ef3 75 data->NamedForComplex("REPRESENTATION_ITEM","RPRITM",num0,num,ach);
28a73c1f 76 if (!data->CheckNbParams(num,1,ach,"representation_item")) return;
77 // --- own field : name ---
78 Handle(TCollection_HAsciiString) aName;
79 data->ReadString (num,1,"name",ach,aName);
80 Handle(StepRepr_RepresentationItem) aReprItem = new StepRepr_RepresentationItem;
81 aReprItem->Init(aName);
82
83 //--- Initialisation of the read entity ---
84 ent->Init(aMeasureWithUnit,aReprItem, aQRI);
85}
86
87
88//=======================================================================
89//function : WriteStep
90//purpose :
91//=======================================================================
92
93void RWStepRepr_RWReprItemAndPlaneAngleMeasureWithUnitAndQRI::WriteStep
94 (StepData_StepWriter& SW,
95 const Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI)& ent) const
96{
97 SW.StartEntity("MEASURE_REPRESENTATION_ITEM");
98 SW.StartEntity("MEASURE_WITH_UNIT");
99 SW.Send(ent->GetMeasureWithUnit()->ValueComponentMember());
100 SW.Send(ent->GetMeasureWithUnit()->UnitComponent().Value());
101 SW.StartEntity("PLANE_ANGLE_MEASURE_WITH_UNIT");
102 SW.StartEntity ("QUALIFIED_REPRESENTATION_ITEM");
103 Handle(StepShape_QualifiedRepresentationItem) aQRI = ent->GetQualifiedRepresentationItem();
104 Standard_Integer i, nbq = aQRI->NbQualifiers();
105 SW.OpenSub();
106 for (i = 1; i <= nbq; i ++)
107 SW.Send (aQRI->QualifiersValue(i).Value());
108 SW.CloseSub();
109 SW.StartEntity("REPRESENTATION_ITEM");
110 SW.Send(ent->Name());
111}