0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / RWStepRepr / RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI.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_RWReprItemAndLengthMeasureWithUnitAndQRI.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_ReprItemAndLengthMeasureWithUnitAndQRI.hxx>
28a73c1f 24#include <StepShape_QualifiedRepresentationItem.hxx>
25#include <StepShape_ValueQualifier.hxx>
26
27//=======================================================================
28//function : RWSteprepr_RWReprItemAndLengthMeasureWithUnitAndQRI
29//purpose :
30//=======================================================================
31RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI::RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI() {}
32
33
34//=======================================================================
35//function : ReadStep
36//purpose :
37//=======================================================================
38
39void RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI::ReadStep
40 (const Handle(StepData_StepReaderData)& data,
41 const Standard_Integer num0,
42 Handle(Interface_Check)& ach,
43 const Handle(StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI)& ent) const
44{
45 Standard_Integer num = 0;//num0;
a7197ef3 46 data->NamedForComplex("MEASURE_WITH_UNIT","MSWTUN",num0,num,ach);
28a73c1f 47 if (!data->CheckNbParams(num,2,ach,"measure_with_unit")) return;
48 // --- own field : valueComponent ---
49 Handle(StepBasic_MeasureValueMember) mvc = new StepBasic_MeasureValueMember;
50 data->ReadMember (num,1, "value_component", ach, mvc);
51 // --- own field : unitComponent ---
52 StepBasic_Unit aUnitComponent;
53 data->ReadEntity(num, 2,"unit_component", ach, aUnitComponent);
54 Handle(StepBasic_MeasureWithUnit) aMeasureWithUnit = new StepBasic_MeasureWithUnit;
55 aMeasureWithUnit->Init(mvc, aUnitComponent);
56
a7197ef3 57 data->NamedForComplex("QUALIFIED_REPRESENTATION_ITEM","QLRPIT",num0,num,ach);
28a73c1f 58 if (!data->CheckNbParams(num,1,ach,"qualified_representation_item")) return;
59 // --- own field : qualifiers ---
60 Handle(StepShape_HArray1OfValueQualifier) quals;
61 Standard_Integer nsub;
62 if (data->ReadSubList (num, 1, "qualifiers", ach, nsub)) {
63 Standard_Integer nb = data->NbParams(nsub);
64 quals = new StepShape_HArray1OfValueQualifier (1, nb);
65 for (Standard_Integer i = 1; i <= nb; i++) {
66 StepShape_ValueQualifier aVQ;
67 if (data->ReadEntity (nsub, i, "qualifier" ,ach, aVQ))
68 quals->SetValue (i, aVQ);
69 }
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_RWReprItemAndLengthMeasureWithUnitAndQRI::WriteStep
94 (StepData_StepWriter& SW,
95 const Handle(StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI)& ent) const
96{
97 SW.StartEntity("LENGTH_MEASURE_WITH_UNIT");
98 SW.StartEntity("MEASURE_REPRESENTATION_ITEM");
99 SW.StartEntity("MEASURE_WITH_UNIT");
100 SW.Send(ent->GetMeasureWithUnit()->ValueComponentMember());
101 SW.Send(ent->GetMeasureWithUnit()->UnitComponent().Value());
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}