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> |
24 | #include <StepShape_HArray1OfValueQualifier.hxx> |
25 | #include <StepShape_QualifiedRepresentationItem.hxx> |
26 | #include <StepShape_ValueQualifier.hxx> |
27 | |
28 | //======================================================================= |
29 | //function : RWSteprepr_RWReprItemAndLengthMeasureWithUnitAndQRI |
30 | //purpose : |
31 | //======================================================================= |
32 | RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI::RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI() {} |
33 | |
34 | |
35 | //======================================================================= |
36 | //function : ReadStep |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | void RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI::ReadStep |
41 | (const Handle(StepData_StepReaderData)& data, |
42 | const Standard_Integer num0, |
43 | Handle(Interface_Check)& ach, |
44 | const Handle(StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI)& 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 | |
73 | Handle(StepShape_QualifiedRepresentationItem) aQRI = new StepShape_QualifiedRepresentationItem(); |
74 | aQRI->SetQualifiers(quals); |
75 | |
a7197ef3 |
76 | data->NamedForComplex("REPRESENTATION_ITEM","RPRITM",num0,num,ach); |
28a73c1f |
77 | if (!data->CheckNbParams(num,1,ach,"representation_item")) return; |
78 | // --- own field : name --- |
79 | Handle(TCollection_HAsciiString) aName; |
80 | data->ReadString (num,1,"name",ach,aName); |
81 | Handle(StepRepr_RepresentationItem) aReprItem = new StepRepr_RepresentationItem; |
82 | aReprItem->Init(aName); |
83 | |
84 | //--- Initialisation of the read entity --- |
85 | ent->Init(aMeasureWithUnit,aReprItem, aQRI); |
86 | } |
87 | |
88 | |
89 | //======================================================================= |
90 | //function : WriteStep |
91 | //purpose : |
92 | //======================================================================= |
93 | |
94 | void RWStepRepr_RWReprItemAndLengthMeasureWithUnitAndQRI::WriteStep |
95 | (StepData_StepWriter& SW, |
96 | const Handle(StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI)& ent) const |
97 | { |
98 | SW.StartEntity("LENGTH_MEASURE_WITH_UNIT"); |
99 | SW.StartEntity("MEASURE_REPRESENTATION_ITEM"); |
100 | SW.StartEntity("MEASURE_WITH_UNIT"); |
101 | SW.Send(ent->GetMeasureWithUnit()->ValueComponentMember()); |
102 | SW.Send(ent->GetMeasureWithUnit()->UnitComponent().Value()); |
103 | SW.StartEntity ("QUALIFIED_REPRESENTATION_ITEM"); |
104 | Handle(StepShape_QualifiedRepresentationItem) aQRI = ent->GetQualifiedRepresentationItem(); |
105 | Standard_Integer i, nbq = aQRI->NbQualifiers(); |
106 | SW.OpenSub(); |
107 | for (i = 1; i <= nbq; i ++) |
108 | SW.Send (aQRI->QualifiersValue(i).Value()); |
109 | SW.CloseSub(); |
110 | SW.StartEntity("REPRESENTATION_ITEM"); |
111 | SW.Send(ent->Name()); |
112 | } |