1 // Created on: 2015-07-07
2 // Created by: Irina KRYLOVA
3 // Copyright (c) 2015 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <RWStepAP242_RWItemIdentifiedRepresentationUsage.hxx>
17 #include <Interface_EntityIterator.hxx>
18 #include <StepRepr_HArray1OfRepresentationItem.hxx>
19 #include <StepData_StepReaderData.hxx>
20 #include <StepData_StepWriter.hxx>
21 #include <StepAP242_ItemIdentifiedRepresentationUsage.hxx>
22 #include <StepAP242_ItemIdentifiedRepresentationUsageDefinition.hxx>
23 #include <StepRepr_Representation.hxx>
24 #include <StepRepr_RepresentationItem.hxx>
27 RWStepAP242_RWItemIdentifiedRepresentationUsage::RWStepAP242_RWItemIdentifiedRepresentationUsage () {}
29 void RWStepAP242_RWItemIdentifiedRepresentationUsage::ReadStep
30 (const Handle(StepData_StepReaderData)& data,
31 const Standard_Integer num,
32 Handle(Interface_Check)& ach,
33 const Handle(StepAP242_ItemIdentifiedRepresentationUsage)& ent) const
35 // --- Number of Parameter Control ---
37 if (!data->CheckNbParams(num,5,ach,"item_identified_representation_usage")) return;
39 // --- own field : name ---
41 Handle(TCollection_HAsciiString) aName;
42 data->ReadString (num,1,"name",ach,aName);
44 // --- own field : description ---
46 Handle(TCollection_HAsciiString) aDescription;
47 if (data->IsParamDefined (num,2)) {
48 data->ReadString (num,2,"description",ach,aDescription);
50 // --- own field : definition ---
52 StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition;
53 data->ReadEntity(num,3,"definition",ach,aDefinition);
55 // --- own field : used_representation ---
57 Handle(StepRepr_Representation) aRepresentation;
58 data->ReadEntity (num,4,"used_representation",ach,STANDARD_TYPE(StepRepr_Representation), aRepresentation);
60 // --- own field : identified_item
62 Handle(StepRepr_HArray1OfRepresentationItem) anItems;
63 Handle(StepRepr_RepresentationItem) anEnt;
64 Standard_Integer nbSub;
65 Interface_ParamType aType = data->ParamType(num, 5);
66 if (aType == Interface_ParamIdent) {
67 data->ReadEntity(num, 5,"item_identified_representation_usage.identified_item", ach, STANDARD_TYPE(StepRepr_RepresentationItem), anEnt);
68 anItems = new StepRepr_HArray1OfRepresentationItem (1, 1);
69 anItems->SetValue(1, anEnt);
71 else if (data->ReadSubList (num,5,"item_identified_representation_usage.identified_item",ach,nbSub)) {
72 Standard_Integer nbElements = data->NbParams(nbSub);
73 anItems = new StepRepr_HArray1OfRepresentationItem (1, nbElements);
74 for (Standard_Integer i = 1; i <= nbElements; i++) {
75 if (data->ReadEntity(nbSub, i,"representation_item", ach,
76 STANDARD_TYPE(StepRepr_RepresentationItem), anEnt))
77 anItems->SetValue(i, anEnt);
81 //--- Initialisation of the read entity ---
84 ent->Init(aName, aDescription, aDefinition, aRepresentation, anItems);
88 void RWStepAP242_RWItemIdentifiedRepresentationUsage::WriteStep
89 (StepData_StepWriter& SW,
90 const Handle(StepAP242_ItemIdentifiedRepresentationUsage)& ent) const
93 // --- own field : name ---
97 // --- own field : description ---
99 SW.Send(ent->Description());
101 // --- own field : definition ---
103 SW.Send(ent->Definition().Value());
105 // --- own field : used_representation ---
107 SW.Send(ent->UsedRepresentation());
109 // --- own field : identified_item ---
111 if (ent->NbIdentifiedItem() == 1)
112 SW.Send(ent->IdentifiedItemValue(1));
115 for (Standard_Integer i = 1; i <= ent->NbIdentifiedItem(); i++) {
116 SW.Send(ent->IdentifiedItemValue(i));
123 void RWStepAP242_RWItemIdentifiedRepresentationUsage::Share(
124 const Handle(StepAP242_ItemIdentifiedRepresentationUsage)& ent,
125 Interface_EntityIterator& iter) const
127 iter.AddItem(ent->Definition().Value());
128 Standard_Integer i, nb = ent->NbIdentifiedItem();
129 for (i = 1; i <= nb; i++)
130 iter.AddItem (ent->IdentifiedItemValue(i));