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_RWGeometricItemSpecificUsage.hxx>
17 #include <Interface_EntityIterator.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepAP242_GeometricItemSpecificUsage.hxx>
21 #include <StepRepr_HArray1OfRepresentationItem.hxx>
22 #include <StepRepr_Representation.hxx>
23 #include <StepRepr_RepresentationItem.hxx>
26 RWStepAP242_RWGeometricItemSpecificUsage::RWStepAP242_RWGeometricItemSpecificUsage () {}
28 void RWStepAP242_RWGeometricItemSpecificUsage::ReadStep
29 (const Handle(StepData_StepReaderData)& data,
30 const Standard_Integer num,
31 Handle(Interface_Check)& ach,
32 const Handle(StepAP242_GeometricItemSpecificUsage)& ent) const
36 // --- Number of Parameter Control ---
38 if (!data->CheckNbParams(num,5,ach,"geometric_item_specific_usage")) return;
40 // Inherited fields of ItemIdentifiedRepresentationUsage
42 Handle(TCollection_HAsciiString) aName;
43 data->ReadString (num,1,"item_identified_representation_usage.name",ach,aName);
45 Handle(TCollection_HAsciiString) aDescription;
46 if (data->IsParamDefined (num,2)) {
47 data->ReadString (num,2,"item_identified_representation_usage.description",ach,aDescription);
50 StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition;
51 data->ReadEntity(num,3,"item_identified_representation_usage.definition",ach,aDefinition);
53 Handle(StepRepr_Representation) aRepresentation;
54 data->ReadEntity (num,4,"item_identified_representation_usage.used_representation",ach,STANDARD_TYPE(StepRepr_Representation), aRepresentation);
56 Handle(StepRepr_HArray1OfRepresentationItem) anItems;
57 Handle(StepRepr_RepresentationItem) anEnt;
58 Standard_Integer nbSub;
59 Interface_ParamType aType = data->ParamType(num, 5);
60 if (aType == Interface_ParamIdent) {
61 data->ReadEntity(num, 5,"item_identified_representation_usage.identified_item", ach, STANDARD_TYPE(StepRepr_RepresentationItem), anEnt);
62 anItems = new StepRepr_HArray1OfRepresentationItem (1, 1);
63 anItems->SetValue(1, anEnt);
65 else if (data->ReadSubList (num,5,"item_identified_representation_usage.identified_item",ach,nbSub)) {
66 Standard_Integer nbElements = data->NbParams(nbSub);
67 anItems = new StepRepr_HArray1OfRepresentationItem (1, nbElements);
68 for (Standard_Integer i = 1; i <= nbElements; i++) {
69 if (data->ReadEntity(nbSub, i,"representation_item", ach,
70 STANDARD_TYPE(StepRepr_RepresentationItem), anEnt))
71 anItems->SetValue(i, anEnt);
75 //--- Initialisation of the read entity ---
77 ent->Init(aName, aDescription, aDefinition, aRepresentation, anItems);
80 void RWStepAP242_RWGeometricItemSpecificUsage::WriteStep
81 (StepData_StepWriter& SW,
82 const Handle(StepAP242_GeometricItemSpecificUsage)& ent) const
84 // Inherited fields of ItemIdentifiedRepresentationUsage
88 SW.Send(ent->Description());
90 SW.Send(ent->Definition().Value());
92 SW.Send(ent->UsedRepresentation());
94 if (ent->NbIdentifiedItem() == 1)
95 SW.Send(ent->IdentifiedItemValue(1));
98 for (Standard_Integer i = 1; i <= ent->NbIdentifiedItem(); i++) {
99 SW.Send(ent->IdentifiedItemValue(i));
105 void RWStepAP242_RWGeometricItemSpecificUsage::Share(
106 const Handle(StepAP242_GeometricItemSpecificUsage)& ent,
107 Interface_EntityIterator& iter) const
109 // Inherited fields of ItemIdentifiedRepresentationUsage
111 iter.AddItem(ent->Definition().Value());
112 Standard_Integer i, nb = ent->NbIdentifiedItem();
113 for (i = 1; i <= nb; i++)
114 iter.AddItem (ent->IdentifiedItemValue(i));